mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: use buffers
This commit is contained in:
1 parent
c8bb1f190a
commit
c98c19dc36
26 files changed
+134
-269
No files matched your search
@@ -27,22 +27,19 @@ export async function boosterIcons() {
|
||||
.split('\n')[4]
|
||||
.split(' ')
|
||||
.map(Number);
|
||||
const content = (
|
||||
await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/boosters/${name}.webp`,
|
||||
content,
|
||||
encoding: 'base64',
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -7,11 +7,10 @@ export async function camouflageIcons() {
|
||||
console.log('Building camouflage icons...');
|
||||
const content = await readDVPLFile(
|
||||
`${DATA}/Gfx/UI/Hangar/IconCamouflage.packed.webp.dvpl`,
|
||||
).then((content) => content.toString('base64'));
|
||||
);
|
||||
const changes: FileChange[] = [
|
||||
{
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: 'icons/camo.webp',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -74,13 +74,10 @@ export async function consumableProvisionIcons() {
|
||||
const image = sharp(
|
||||
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
||||
);
|
||||
const content = (
|
||||
await image.trim({ threshold: 100 }).toBuffer()
|
||||
).toString('base64');
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/consumables/${consumable.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
} else {
|
||||
@@ -93,21 +90,18 @@ export async function consumableProvisionIcons() {
|
||||
.split('\n')[4]
|
||||
.split(' ')
|
||||
.map(Number);
|
||||
const content = (
|
||||
await consumablesTexture
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await consumablesTexture
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/consumables/${consumable.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
}
|
||||
@@ -147,13 +141,10 @@ export async function consumableProvisionIcons() {
|
||||
const image = sharp(
|
||||
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
||||
);
|
||||
const content = (
|
||||
await image.trim({ threshold: 100 }).toBuffer()
|
||||
).toString('base64');
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/provisions/${provision.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
} else {
|
||||
@@ -166,21 +157,18 @@ export async function consumableProvisionIcons() {
|
||||
.split('\n')[4]
|
||||
.split(' ')
|
||||
.map(Number);
|
||||
const content = (
|
||||
await provisionsTexture
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await provisionsTexture
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/provisions/${provision.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,17 +29,14 @@ export async function currencies() {
|
||||
|
||||
await Promise.all(
|
||||
ICONS.map(async ([file, name]) => {
|
||||
const content = (
|
||||
await sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/Lobby/currency/${file}.dvpl`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/Lobby/currency/${file}.dvpl`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `icons/currencies/${name}.webp`,
|
||||
});
|
||||
}),
|
||||
@@ -58,18 +55,15 @@ export async function currencies() {
|
||||
const imageRaw = await fetch(item.image_url).then((response) =>
|
||||
response.arrayBuffer(),
|
||||
);
|
||||
const content = (
|
||||
await sharp(imageRaw)
|
||||
.trim({
|
||||
threshold: 100,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await sharp(imageRaw)
|
||||
.trim({
|
||||
threshold: 100,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `icons/currencies/${key}.webp`,
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ConsumableTankCategoryFilterCategory,
|
||||
Crew,
|
||||
CrewType,
|
||||
encodePB64,
|
||||
encodePBBuffer,
|
||||
EquipmentDefinitions,
|
||||
EquipmentSlot,
|
||||
GameDefinitions,
|
||||
@@ -1650,48 +1650,39 @@ export async function definitions() {
|
||||
|
||||
await commitAssets('definitions', [
|
||||
{
|
||||
content: encodePB64(GameDefinitions, gameDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(GameDefinitions, gameDefinitions),
|
||||
path: 'definitions/game.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(TankDefinitions, tankDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(TankDefinitions, tankDefinitions),
|
||||
path: 'definitions/tanks.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(ModelDefinitions, modelDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(ModelDefinitions, modelDefinitions),
|
||||
path: 'definitions/models.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(EquipmentDefinitions, equipmentDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(EquipmentDefinitions, equipmentDefinitions),
|
||||
path: 'definitions/equipment.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(ConsumableDefinitions, consumableDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(ConsumableDefinitions, consumableDefinitions),
|
||||
path: 'definitions/consumables.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(ProvisionDefinitions, provisionDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(ProvisionDefinitions, provisionDefinitions),
|
||||
path: 'definitions/provisions.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(SkillDefinitions, skillDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(SkillDefinitions, skillDefinitions),
|
||||
path: 'definitions/skills.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(MapDefinitions, mapDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(MapDefinitions, mapDefinitions),
|
||||
path: 'definitions/maps.pb',
|
||||
},
|
||||
{
|
||||
content: encodePB64(CamouflageDefinitions, camouflageDefinitions),
|
||||
encoding: 'base64',
|
||||
content: encodePBBuffer(CamouflageDefinitions, camouflageDefinitions),
|
||||
path: 'definitions/camouflages.pb',
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -59,31 +59,27 @@ export async function equipmentIcons() {
|
||||
const image = sharp(
|
||||
await readDVPLFile(`${DATA}/${configPathWebp}.packed.webp.dvpl`),
|
||||
);
|
||||
const content = (await image.trim().toBuffer()).toString('base64');
|
||||
const content = await image.trim().toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/equipment/${optionalDevice.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
} else {
|
||||
const config = await readStringDVPL(`${DATA}/${configPath}.dvpl`);
|
||||
const sizes = config.split('\n')[4].split(' ').map(Number);
|
||||
const content = (
|
||||
await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/equipment/${optionalDevice.id}.webp`,
|
||||
encoding: 'base64',
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { readdir } from 'fs/promises';
|
||||
import sharp from 'sharp';
|
||||
import { readBase64DVPL } from '../core/blitz/readBase64DVPL';
|
||||
import { readDVPLFile } from '../core/blitz/readDVPLFile';
|
||||
import { commitAssets } from '../core/github/commitAssets';
|
||||
import { FileChange } from '../core/github/commitMultipleFiles';
|
||||
@@ -11,9 +10,7 @@ export async function flags() {
|
||||
|
||||
const changes = [
|
||||
...(await Promise.all(
|
||||
(
|
||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
||||
)
|
||||
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||
.filter(
|
||||
(flag) =>
|
||||
flag.startsWith('flag_profile-stat_') &&
|
||||
@@ -23,63 +20,52 @@ export async function flags() {
|
||||
const image = sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
|
||||
);
|
||||
const content = (
|
||||
await image.trim({ threshold: 100 }).toBuffer()
|
||||
).toString('base64');
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
|
||||
|
||||
return {
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `flags/circle/${name}.webp`,
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
)),
|
||||
...(await Promise.all(
|
||||
(
|
||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
||||
)
|
||||
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||
.filter(
|
||||
(flag) =>
|
||||
flag.startsWith('flag_tutor-tank_') &&
|
||||
!flag.endsWith('@2x.packed.webp.dvpl'),
|
||||
)
|
||||
.map(async (flag) => {
|
||||
const content = await readBase64DVPL(
|
||||
`${DATA}/Gfx/Lobby/flags/${flag}`,
|
||||
);
|
||||
const content = await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`);
|
||||
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
|
||||
|
||||
return {
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `flags/scratched/${name}.webp`,
|
||||
content,
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
)),
|
||||
...(await Promise.all(
|
||||
(
|
||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
||||
)
|
||||
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||
.filter(
|
||||
(flag) =>
|
||||
flag.startsWith('flag_filter_') &&
|
||||
flag.endsWith('@2x.packed.webp.dvpl'),
|
||||
)
|
||||
.map(async (flag) => {
|
||||
const content = (
|
||||
await sharp(await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`))
|
||||
.trim({
|
||||
threshold: 100,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
|
||||
)
|
||||
.trim({
|
||||
threshold: 100,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
})
|
||||
.toBuffer();
|
||||
const name = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
|
||||
|
||||
return {
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `flags/fade_small/${name}.webp`,
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
|
||||
@@ -37,16 +37,15 @@ export async function gameModeBanners() {
|
||||
path = `/Gfx/UI/Hangar/GameTypes/battle-type_${name.toLowerCase()}`;
|
||||
}
|
||||
|
||||
const content = (
|
||||
await sharp(await readDVPLFile(`${DATA}${path}.packed.webp.dvpl`))
|
||||
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await sharp(
|
||||
await readDVPLFile(`${DATA}${path}.packed.webp.dvpl`),
|
||||
)
|
||||
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||
.toBuffer();
|
||||
|
||||
changes.push({
|
||||
path: `icons/game_mode_banners/${id}.webp`,
|
||||
content,
|
||||
encoding: 'base64',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,18 +17,15 @@ export async function moduleIcons() {
|
||||
.map(async (file) => {
|
||||
const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1];
|
||||
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
||||
const content = (
|
||||
await sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/UI/ModulesTechTree/${file}`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer()
|
||||
).toString('base64');
|
||||
const content = await sharp(
|
||||
await readDVPLFile(`${DATA}/Gfx/UI/ModulesTechTree/${file}`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer();
|
||||
|
||||
return {
|
||||
content,
|
||||
path: `icons/modules/${name}.webp`,
|
||||
encoding: 'base64',
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -16,9 +16,7 @@ export async function shellIcons() {
|
||||
);
|
||||
|
||||
const changes = await Promise.all(
|
||||
(
|
||||
await readdir(`${DATA}/Gfx/Shared/tank-supply/ammunition/big`)
|
||||
)
|
||||
(await readdir(`${DATA}/Gfx/Shared/tank-supply/ammunition/big`))
|
||||
.filter((file) => file.endsWith('_l.txt.dvpl'))
|
||||
.map(async (file) => {
|
||||
const name = file.match(/(.+)_l\.txt\.dvpl/)![1];
|
||||
@@ -32,18 +30,15 @@ export async function shellIcons() {
|
||||
.map(Number);
|
||||
|
||||
return {
|
||||
content: (
|
||||
await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer()
|
||||
).toString('base64'),
|
||||
encoding: 'base64',
|
||||
content: await image
|
||||
.clone()
|
||||
.extract({
|
||||
left: sizes[0],
|
||||
top: sizes[1],
|
||||
width: sizes[2],
|
||||
height: sizes[3],
|
||||
})
|
||||
.toBuffer(),
|
||||
path: `icons/shells/${name}.webp`,
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
|
||||
@@ -37,11 +37,10 @@ export async function skillIcons() {
|
||||
const name = icon.name.split('/').at(-1)!.replace(/_\d$/, '');
|
||||
const path = `${DATA}${icon.name.replace('~res:', '')}.packed.webp.dvpl`;
|
||||
const image = sharp(await readDVPLFile(path)).trim();
|
||||
const content = (await image.toBuffer()).toString('base64');
|
||||
const content = await image.toBuffer();
|
||||
|
||||
return {
|
||||
content,
|
||||
encoding: 'base64',
|
||||
path: `icons/skills/${name}.webp`,
|
||||
} satisfies FileChange;
|
||||
}),
|
||||
|
||||
@@ -32,10 +32,7 @@ export async function tankArmors() {
|
||||
|
||||
changes.push({
|
||||
path: `3d/tanks/armor/${id}.glb`,
|
||||
encoding: 'base64',
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
||||
'base64',
|
||||
),
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)),
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -80,15 +80,13 @@ export async function tankIcons() {
|
||||
|
||||
if (big) {
|
||||
changes.push({
|
||||
content: big.toString('base64'),
|
||||
encoding: 'base64',
|
||||
content: big,
|
||||
path: `icons/tanks/big/${id}.webp`,
|
||||
});
|
||||
}
|
||||
if (small) {
|
||||
changes.push({
|
||||
content: small.toString('base64'),
|
||||
encoding: 'base64',
|
||||
content: small,
|
||||
path: `icons/tanks/small/${id}.webp`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,10 +42,7 @@ export async function tankModels() {
|
||||
|
||||
changes.push({
|
||||
path: `3d/tanks/models/${id}.glb`,
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
||||
'base64',
|
||||
),
|
||||
encoding: 'base64',
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)),
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user