mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +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
@@ -1,5 +0,0 @@
|
|||||||
import { MessageFns } from '../protos';
|
|
||||||
|
|
||||||
export function encodePB64<Type>(message: MessageFns<Type>, data: Type) {
|
|
||||||
return Buffer.from(message.encode(data).finish()).toString('base64');
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { MessageFns } from '../protos';
|
||||||
|
|
||||||
|
export function encodePBBuffer<Type>(message: MessageFns<Type>, data: Type) {
|
||||||
|
return Buffer.from(message.encode(data).finish());
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export * from './encodePB64';
|
export * from './encodePBBuffer';
|
||||||
export * from './fetchPB';
|
export * from './fetchPB';
|
||||||
export * from './pbMap';
|
export * from './pbMap';
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Samples,
|
Samples,
|
||||||
averageDefinitionsAllStatsKeys,
|
averageDefinitionsAllStatsKeys,
|
||||||
emptySamples,
|
emptySamples,
|
||||||
encodePB64,
|
encodePBBuffer,
|
||||||
getAccountInfo,
|
getAccountInfo,
|
||||||
getTankStats,
|
getTankStats,
|
||||||
idToRegion,
|
idToRegion,
|
||||||
@@ -235,13 +235,11 @@ async function postWork() {
|
|||||||
commitAssets('averages', [
|
commitAssets('averages', [
|
||||||
{
|
{
|
||||||
path: `averages/${latest}.pb`,
|
path: `averages/${latest}.pb`,
|
||||||
content: encodePB64(AverageDefinitions, averageDefinitions),
|
content: encodePBBuffer(AverageDefinitions, averageDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'averages/manifest.json',
|
path: 'averages/manifest.json',
|
||||||
content: JSON.stringify(manifest),
|
content: Buffer.from(JSON.stringify(manifest), 'utf-8'),
|
||||||
encoding: 'utf-8',
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -27,22 +27,19 @@ export async function boosterIcons() {
|
|||||||
.split('\n')[4]
|
.split('\n')[4]
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(Number);
|
.map(Number);
|
||||||
const content = (
|
const content = await image
|
||||||
await image
|
.clone()
|
||||||
.clone()
|
.extract({
|
||||||
.extract({
|
left: sizes[0],
|
||||||
left: sizes[0],
|
top: sizes[1],
|
||||||
top: sizes[1],
|
width: sizes[2],
|
||||||
width: sizes[2],
|
height: sizes[3],
|
||||||
height: sizes[3],
|
})
|
||||||
})
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/boosters/${name}.webp`,
|
path: `icons/boosters/${name}.webp`,
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ export async function camouflageIcons() {
|
|||||||
console.log('Building camouflage icons...');
|
console.log('Building camouflage icons...');
|
||||||
const content = await readDVPLFile(
|
const content = await readDVPLFile(
|
||||||
`${DATA}/Gfx/UI/Hangar/IconCamouflage.packed.webp.dvpl`,
|
`${DATA}/Gfx/UI/Hangar/IconCamouflage.packed.webp.dvpl`,
|
||||||
).then((content) => content.toString('base64'));
|
);
|
||||||
const changes: FileChange[] = [
|
const changes: FileChange[] = [
|
||||||
{
|
{
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: 'icons/camo.webp',
|
path: 'icons/camo.webp',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -74,13 +74,10 @@ export async function consumableProvisionIcons() {
|
|||||||
const image = sharp(
|
const image = sharp(
|
||||||
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
||||||
);
|
);
|
||||||
const content = (
|
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||||
await image.trim({ threshold: 100 }).toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/consumables/${consumable.id}.webp`,
|
path: `icons/consumables/${consumable.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -93,21 +90,18 @@ export async function consumableProvisionIcons() {
|
|||||||
.split('\n')[4]
|
.split('\n')[4]
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(Number);
|
.map(Number);
|
||||||
const content = (
|
const content = await consumablesTexture
|
||||||
await consumablesTexture
|
.clone()
|
||||||
.clone()
|
.extract({
|
||||||
.extract({
|
left: sizes[0],
|
||||||
left: sizes[0],
|
top: sizes[1],
|
||||||
top: sizes[1],
|
width: sizes[2],
|
||||||
width: sizes[2],
|
height: sizes[3],
|
||||||
height: sizes[3],
|
})
|
||||||
})
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/consumables/${consumable.id}.webp`,
|
path: `icons/consumables/${consumable.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -147,13 +141,10 @@ export async function consumableProvisionIcons() {
|
|||||||
const image = sharp(
|
const image = sharp(
|
||||||
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
|
||||||
);
|
);
|
||||||
const content = (
|
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||||
await image.trim({ threshold: 100 }).toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/provisions/${provision.id}.webp`,
|
path: `icons/provisions/${provision.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -166,21 +157,18 @@ export async function consumableProvisionIcons() {
|
|||||||
.split('\n')[4]
|
.split('\n')[4]
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(Number);
|
.map(Number);
|
||||||
const content = (
|
const content = await provisionsTexture
|
||||||
await provisionsTexture
|
.clone()
|
||||||
.clone()
|
.extract({
|
||||||
.extract({
|
left: sizes[0],
|
||||||
left: sizes[0],
|
top: sizes[1],
|
||||||
top: sizes[1],
|
width: sizes[2],
|
||||||
width: sizes[2],
|
height: sizes[3],
|
||||||
height: sizes[3],
|
})
|
||||||
})
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/provisions/${provision.id}.webp`,
|
path: `icons/provisions/${provision.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,17 +29,14 @@ export async function currencies() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
ICONS.map(async ([file, name]) => {
|
ICONS.map(async ([file, name]) => {
|
||||||
const content = (
|
const content = await sharp(
|
||||||
await sharp(
|
await readDVPLFile(`${DATA}/Gfx/Lobby/currency/${file}.dvpl`),
|
||||||
await readDVPLFile(`${DATA}/Gfx/Lobby/currency/${file}.dvpl`),
|
)
|
||||||
)
|
.trim()
|
||||||
.trim()
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/currencies/${name}.webp`,
|
path: `icons/currencies/${name}.webp`,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
@@ -58,18 +55,15 @@ export async function currencies() {
|
|||||||
const imageRaw = await fetch(item.image_url).then((response) =>
|
const imageRaw = await fetch(item.image_url).then((response) =>
|
||||||
response.arrayBuffer(),
|
response.arrayBuffer(),
|
||||||
);
|
);
|
||||||
const content = (
|
const content = await sharp(imageRaw)
|
||||||
await sharp(imageRaw)
|
.trim({
|
||||||
.trim({
|
threshold: 100,
|
||||||
threshold: 100,
|
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
})
|
||||||
})
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/currencies/${key}.webp`,
|
path: `icons/currencies/${key}.webp`,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ConsumableTankCategoryFilterCategory,
|
ConsumableTankCategoryFilterCategory,
|
||||||
Crew,
|
Crew,
|
||||||
CrewType,
|
CrewType,
|
||||||
encodePB64,
|
encodePBBuffer,
|
||||||
EquipmentDefinitions,
|
EquipmentDefinitions,
|
||||||
EquipmentSlot,
|
EquipmentSlot,
|
||||||
GameDefinitions,
|
GameDefinitions,
|
||||||
@@ -1650,48 +1650,39 @@ export async function definitions() {
|
|||||||
|
|
||||||
await commitAssets('definitions', [
|
await commitAssets('definitions', [
|
||||||
{
|
{
|
||||||
content: encodePB64(GameDefinitions, gameDefinitions),
|
content: encodePBBuffer(GameDefinitions, gameDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/game.pb',
|
path: 'definitions/game.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(TankDefinitions, tankDefinitions),
|
content: encodePBBuffer(TankDefinitions, tankDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/tanks.pb',
|
path: 'definitions/tanks.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(ModelDefinitions, modelDefinitions),
|
content: encodePBBuffer(ModelDefinitions, modelDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/models.pb',
|
path: 'definitions/models.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(EquipmentDefinitions, equipmentDefinitions),
|
content: encodePBBuffer(EquipmentDefinitions, equipmentDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/equipment.pb',
|
path: 'definitions/equipment.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(ConsumableDefinitions, consumableDefinitions),
|
content: encodePBBuffer(ConsumableDefinitions, consumableDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/consumables.pb',
|
path: 'definitions/consumables.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(ProvisionDefinitions, provisionDefinitions),
|
content: encodePBBuffer(ProvisionDefinitions, provisionDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/provisions.pb',
|
path: 'definitions/provisions.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(SkillDefinitions, skillDefinitions),
|
content: encodePBBuffer(SkillDefinitions, skillDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/skills.pb',
|
path: 'definitions/skills.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(MapDefinitions, mapDefinitions),
|
content: encodePBBuffer(MapDefinitions, mapDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/maps.pb',
|
path: 'definitions/maps.pb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: encodePB64(CamouflageDefinitions, camouflageDefinitions),
|
content: encodePBBuffer(CamouflageDefinitions, camouflageDefinitions),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/camouflages.pb',
|
path: 'definitions/camouflages.pb',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -59,31 +59,27 @@ export async function equipmentIcons() {
|
|||||||
const image = sharp(
|
const image = sharp(
|
||||||
await readDVPLFile(`${DATA}/${configPathWebp}.packed.webp.dvpl`),
|
await readDVPLFile(`${DATA}/${configPathWebp}.packed.webp.dvpl`),
|
||||||
);
|
);
|
||||||
const content = (await image.trim().toBuffer()).toString('base64');
|
const content = await image.trim().toBuffer();
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/equipment/${optionalDevice.id}.webp`,
|
path: `icons/equipment/${optionalDevice.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const config = await readStringDVPL(`${DATA}/${configPath}.dvpl`);
|
const config = await readStringDVPL(`${DATA}/${configPath}.dvpl`);
|
||||||
const sizes = config.split('\n')[4].split(' ').map(Number);
|
const sizes = config.split('\n')[4].split(' ').map(Number);
|
||||||
const content = (
|
const content = await image
|
||||||
await image
|
.clone()
|
||||||
.clone()
|
.extract({
|
||||||
.extract({
|
left: sizes[0],
|
||||||
left: sizes[0],
|
top: sizes[1],
|
||||||
top: sizes[1],
|
width: sizes[2],
|
||||||
width: sizes[2],
|
height: sizes[3],
|
||||||
height: sizes[3],
|
})
|
||||||
})
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/equipment/${optionalDevice.id}.webp`,
|
path: `icons/equipment/${optionalDevice.id}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { readBase64DVPL } from '../core/blitz/readBase64DVPL';
|
|
||||||
import { readDVPLFile } from '../core/blitz/readDVPLFile';
|
import { readDVPLFile } from '../core/blitz/readDVPLFile';
|
||||||
import { commitAssets } from '../core/github/commitAssets';
|
import { commitAssets } from '../core/github/commitAssets';
|
||||||
import { FileChange } from '../core/github/commitMultipleFiles';
|
import { FileChange } from '../core/github/commitMultipleFiles';
|
||||||
@@ -11,9 +10,7 @@ export async function flags() {
|
|||||||
|
|
||||||
const changes = [
|
const changes = [
|
||||||
...(await Promise.all(
|
...(await Promise.all(
|
||||||
(
|
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
|
||||||
)
|
|
||||||
.filter(
|
.filter(
|
||||||
(flag) =>
|
(flag) =>
|
||||||
flag.startsWith('flag_profile-stat_') &&
|
flag.startsWith('flag_profile-stat_') &&
|
||||||
@@ -23,63 +20,52 @@ export async function flags() {
|
|||||||
const image = sharp(
|
const image = sharp(
|
||||||
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
|
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
|
||||||
);
|
);
|
||||||
const content = (
|
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||||
await image.trim({ threshold: 100 }).toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
|
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: `flags/circle/${name}.webp`,
|
path: `flags/circle/${name}.webp`,
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
...(await Promise.all(
|
...(await Promise.all(
|
||||||
(
|
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
|
||||||
)
|
|
||||||
.filter(
|
.filter(
|
||||||
(flag) =>
|
(flag) =>
|
||||||
flag.startsWith('flag_tutor-tank_') &&
|
flag.startsWith('flag_tutor-tank_') &&
|
||||||
!flag.endsWith('@2x.packed.webp.dvpl'),
|
!flag.endsWith('@2x.packed.webp.dvpl'),
|
||||||
)
|
)
|
||||||
.map(async (flag) => {
|
.map(async (flag) => {
|
||||||
const content = await readBase64DVPL(
|
const content = await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`);
|
||||||
`${DATA}/Gfx/Lobby/flags/${flag}`,
|
|
||||||
);
|
|
||||||
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
|
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
|
||||||
encoding: 'base64',
|
|
||||||
path: `flags/scratched/${name}.webp`,
|
path: `flags/scratched/${name}.webp`,
|
||||||
|
content,
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
...(await Promise.all(
|
...(await Promise.all(
|
||||||
(
|
(await readdir(`${DATA}/Gfx/Lobby/flags`))
|
||||||
await readdir(`${DATA}/Gfx/Lobby/flags`)
|
|
||||||
)
|
|
||||||
.filter(
|
.filter(
|
||||||
(flag) =>
|
(flag) =>
|
||||||
flag.startsWith('flag_filter_') &&
|
flag.startsWith('flag_filter_') &&
|
||||||
flag.endsWith('@2x.packed.webp.dvpl'),
|
flag.endsWith('@2x.packed.webp.dvpl'),
|
||||||
)
|
)
|
||||||
.map(async (flag) => {
|
.map(async (flag) => {
|
||||||
const content = (
|
const content = await sharp(
|
||||||
await sharp(await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`))
|
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
|
||||||
.trim({
|
)
|
||||||
threshold: 100,
|
.trim({
|
||||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
threshold: 100,
|
||||||
})
|
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||||
.toBuffer()
|
})
|
||||||
).toString('base64');
|
.toBuffer();
|
||||||
const name = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
|
const name = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: `flags/fade_small/${name}.webp`,
|
path: `flags/fade_small/${name}.webp`,
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -37,16 +37,15 @@ export async function gameModeBanners() {
|
|||||||
path = `/Gfx/UI/Hangar/GameTypes/battle-type_${name.toLowerCase()}`;
|
path = `/Gfx/UI/Hangar/GameTypes/battle-type_${name.toLowerCase()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = (
|
const content = await sharp(
|
||||||
await sharp(await readDVPLFile(`${DATA}${path}.packed.webp.dvpl`))
|
await readDVPLFile(`${DATA}${path}.packed.webp.dvpl`),
|
||||||
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
)
|
||||||
.toBuffer()
|
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||||
).toString('base64');
|
.toBuffer();
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `icons/game_mode_banners/${id}.webp`,
|
path: `icons/game_mode_banners/${id}.webp`,
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,15 @@ export async function moduleIcons() {
|
|||||||
.map(async (file) => {
|
.map(async (file) => {
|
||||||
const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1];
|
const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1];
|
||||||
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
||||||
const content = (
|
const content = await sharp(
|
||||||
await sharp(
|
await readDVPLFile(`${DATA}/Gfx/UI/ModulesTechTree/${file}`),
|
||||||
await readDVPLFile(`${DATA}/Gfx/UI/ModulesTechTree/${file}`),
|
)
|
||||||
)
|
.trim()
|
||||||
.trim()
|
.toBuffer();
|
||||||
.toBuffer()
|
|
||||||
).toString('base64');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
path: `icons/modules/${name}.webp`,
|
path: `icons/modules/${name}.webp`,
|
||||||
encoding: 'base64',
|
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ export async function shellIcons() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const changes = await Promise.all(
|
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'))
|
.filter((file) => file.endsWith('_l.txt.dvpl'))
|
||||||
.map(async (file) => {
|
.map(async (file) => {
|
||||||
const name = file.match(/(.+)_l\.txt\.dvpl/)![1];
|
const name = file.match(/(.+)_l\.txt\.dvpl/)![1];
|
||||||
@@ -32,18 +30,15 @@ export async function shellIcons() {
|
|||||||
.map(Number);
|
.map(Number);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: (
|
content: await image
|
||||||
await image
|
.clone()
|
||||||
.clone()
|
.extract({
|
||||||
.extract({
|
left: sizes[0],
|
||||||
left: sizes[0],
|
top: sizes[1],
|
||||||
top: sizes[1],
|
width: sizes[2],
|
||||||
width: sizes[2],
|
height: sizes[3],
|
||||||
height: sizes[3],
|
})
|
||||||
})
|
.toBuffer(),
|
||||||
.toBuffer()
|
|
||||||
).toString('base64'),
|
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/shells/${name}.webp`,
|
path: `icons/shells/${name}.webp`,
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ export async function skillIcons() {
|
|||||||
const name = icon.name.split('/').at(-1)!.replace(/_\d$/, '');
|
const name = icon.name.split('/').at(-1)!.replace(/_\d$/, '');
|
||||||
const path = `${DATA}${icon.name.replace('~res:', '')}.packed.webp.dvpl`;
|
const path = `${DATA}${icon.name.replace('~res:', '')}.packed.webp.dvpl`;
|
||||||
const image = sharp(await readDVPLFile(path)).trim();
|
const image = sharp(await readDVPLFile(path)).trim();
|
||||||
const content = (await image.toBuffer()).toString('base64');
|
const content = await image.toBuffer();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/skills/${name}.webp`,
|
path: `icons/skills/${name}.webp`,
|
||||||
} satisfies FileChange;
|
} satisfies FileChange;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ export async function tankArmors() {
|
|||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `3d/tanks/armor/${id}.glb`,
|
path: `3d/tanks/armor/${id}.glb`,
|
||||||
encoding: 'base64',
|
content: Buffer.from(await nodeIO.writeBinary(model)),
|
||||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
|
||||||
'base64',
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -80,15 +80,13 @@ export async function tankIcons() {
|
|||||||
|
|
||||||
if (big) {
|
if (big) {
|
||||||
changes.push({
|
changes.push({
|
||||||
content: big.toString('base64'),
|
content: big,
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/tanks/big/${id}.webp`,
|
path: `icons/tanks/big/${id}.webp`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (small) {
|
if (small) {
|
||||||
changes.push({
|
changes.push({
|
||||||
content: small.toString('base64'),
|
content: small,
|
||||||
encoding: 'base64',
|
|
||||||
path: `icons/tanks/small/${id}.webp`,
|
path: `icons/tanks/small/${id}.webp`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,7 @@ export async function tankModels() {
|
|||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `3d/tanks/models/${id}.glb`,
|
path: `3d/tanks/models/${id}.glb`,
|
||||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
content: Buffer.from(await nodeIO.writeBinary(model)),
|
||||||
'base64',
|
|
||||||
),
|
|
||||||
encoding: 'base64',
|
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import { assertSecret } from '@blitzkit/core';
|
|
||||||
import { GithubChangeBlob, createBlob } from './createBlob';
|
|
||||||
import { octokit } from './octokit';
|
|
||||||
|
|
||||||
export class AssetCommit {
|
|
||||||
constructor(public message: string) {}
|
|
||||||
private blobs: GithubChangeBlob[] = [];
|
|
||||||
|
|
||||||
async add(path: string, content: string, encoding: 'utf-8' | 'base64') {
|
|
||||||
console.log(`Blob: adding ${path}...`);
|
|
||||||
|
|
||||||
const blob = await createBlob(
|
|
||||||
'tresabhi',
|
|
||||||
assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
{
|
|
||||||
content,
|
|
||||||
encoding,
|
|
||||||
path,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
this.blobs.push(blob!);
|
|
||||||
}
|
|
||||||
|
|
||||||
async push() {
|
|
||||||
if (this.blobs.length === 0) return;
|
|
||||||
|
|
||||||
const latestCommitSha = (
|
|
||||||
await octokit.git.getRef({
|
|
||||||
owner: 'tresabhi',
|
|
||||||
repo: assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
ref: `heads/${assertSecret(process.env.PUBLIC_ASSET_BRANCH)}`,
|
|
||||||
})
|
|
||||||
).data.object.sha;
|
|
||||||
const treeSha = (
|
|
||||||
await octokit.git.getCommit({
|
|
||||||
owner: 'tresabhi',
|
|
||||||
repo: assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
commit_sha: latestCommitSha,
|
|
||||||
})
|
|
||||||
).data.tree.sha;
|
|
||||||
const blobs: GithubChangeBlob[] = [];
|
|
||||||
|
|
||||||
const { data: treeData } = await octokit.git.createTree({
|
|
||||||
owner: 'tresabhi',
|
|
||||||
repo: assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
base_tree: treeSha,
|
|
||||||
tree: blobs,
|
|
||||||
});
|
|
||||||
const { data: newCommitData } = await octokit.git.createCommit({
|
|
||||||
owner: 'tresabhi',
|
|
||||||
repo: assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
message: this.message,
|
|
||||||
tree: treeData.sha,
|
|
||||||
parents: [latestCommitSha],
|
|
||||||
});
|
|
||||||
await octokit.git.updateRef({
|
|
||||||
owner: 'tresabhi',
|
|
||||||
repo: assertSecret(process.env.PUBLIC_ASSET_REPO),
|
|
||||||
ref: `heads/${assertSecret(process.env.PUBLIC_ASSET_BRANCH)}`,
|
|
||||||
sha: newCommitData.sha,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ export async function commitAssets(message: string, changes: FileChange[]) {
|
|||||||
if (changes.length === 0) return;
|
if (changes.length === 0) return;
|
||||||
|
|
||||||
await commitMultipleFiles(
|
await commitMultipleFiles(
|
||||||
'tresabhi',
|
|
||||||
assertSecret(process.env.PUBLIC_ASSET_REPO),
|
assertSecret(process.env.PUBLIC_ASSET_REPO),
|
||||||
assertSecret(process.env.PUBLIC_ASSET_BRANCH),
|
assertSecret(process.env.PUBLIC_ASSET_BRANCH),
|
||||||
`${message} - ${new Date().toDateString()}`,
|
`${message} - ${new Date().toDateString()}`,
|
||||||
|
|||||||
@@ -4,17 +4,16 @@ import { octokit } from './octokit';
|
|||||||
|
|
||||||
export interface FileChange {
|
export interface FileChange {
|
||||||
path: string;
|
path: string;
|
||||||
content: string;
|
content: Buffer;
|
||||||
encoding: 'utf-8' | 'base64';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function commitMultipleFiles(
|
export async function commitMultipleFiles(
|
||||||
owner: string,
|
repoRaw: string,
|
||||||
repo: string,
|
|
||||||
branch: string,
|
branch: string,
|
||||||
message: string,
|
message: string,
|
||||||
changes: FileChange[],
|
changes: FileChange[],
|
||||||
) {
|
) {
|
||||||
|
const [owner, repo] = repoRaw.split('/');
|
||||||
const latestCommitSha = (
|
const latestCommitSha = (
|
||||||
await octokit.git.getRef({
|
await octokit.git.getRef({
|
||||||
owner,
|
owner,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ export const createBlob = throttle(
|
|||||||
await octokit.git.createBlob({
|
await octokit.git.createBlob({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
content: change.content,
|
content: change.content.toString('base64'),
|
||||||
encoding: change.encoding,
|
encoding: 'base64',
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ export const createBlob = throttle(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Failed blob ${change.path}; retrying in ${TIME_PER_BLOB}ms...`,
|
`Failed blob ${change.path}; retrying in ${TIME_PER_BLOB}ms...`,
|
||||||
// error,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, TIME_PER_BLOB));
|
await new Promise((resolve) => setTimeout(resolve, TIME_PER_BLOB));
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import { chunk, times, uniq } from 'lodash-es';
|
import { chunk, times, uniq } from 'lodash-es';
|
||||||
import { compress, decompress } from 'lz4js';
|
import { compress, decompress } from 'lz4js';
|
||||||
import { commitAssets } from './core/github/commitAssets';
|
import { commitAssets } from './core/github/commitAssets';
|
||||||
|
import { FileChange } from './core/github/commitMultipleFiles';
|
||||||
|
|
||||||
const CHUNK_SIZE = 2 ** 21;
|
const CHUNK_SIZE = 2 ** 21;
|
||||||
const RUN_TIME = 1000 * 60 * 60 * 5.5;
|
const RUN_TIME = 1000 * 60 * 60 * 5.5;
|
||||||
@@ -139,24 +140,25 @@ function post() {
|
|||||||
`Chunk ${index} with ${chunk.length} ids (compressed: ${compressed.length}; uncompressed: ${buffer.length})`,
|
`Chunk ${index} with ${chunk.length} ids (compressed: ${compressed.length}; uncompressed: ${buffer.length})`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const content = Buffer.from(compressed).toString('base64');
|
const content = Buffer.from(compressed);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
encoding: 'base64' as const,
|
|
||||||
path: `ids/${index}.dids.lz4`,
|
path: `ids/${index}.dids.lz4`,
|
||||||
};
|
} satisfies FileChange;
|
||||||
});
|
});
|
||||||
|
|
||||||
commitAssets('discovered ids', [
|
commitAssets('discovered ids', [
|
||||||
...files,
|
...files,
|
||||||
{
|
{
|
||||||
content: JSON.stringify({
|
content: Buffer.from(
|
||||||
chunks: idsChunked.length,
|
JSON.stringify({
|
||||||
count: ids.length,
|
chunks: idsChunked.length,
|
||||||
time: Date.now(),
|
count: ids.length,
|
||||||
} satisfies DiscoveredIdsDefinitions),
|
time: Date.now(),
|
||||||
encoding: 'utf-8',
|
} satisfies DiscoveredIdsDefinitions),
|
||||||
|
'utf-8',
|
||||||
|
),
|
||||||
path: 'ids/manifest.json',
|
path: 'ids/manifest.json',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
asset,
|
asset,
|
||||||
encodePB64,
|
encodePBBuffer,
|
||||||
Reviews,
|
Reviews,
|
||||||
toUniqueId,
|
toUniqueId,
|
||||||
Video,
|
Video,
|
||||||
@@ -126,8 +126,7 @@ for (const tank of tanksSanitized) {
|
|||||||
|
|
||||||
await commitAssets('reviews', [
|
await commitAssets('reviews', [
|
||||||
{
|
{
|
||||||
content: encodePB64(Reviews, reviews),
|
content: encodePBBuffer(Reviews, reviews),
|
||||||
encoding: 'base64',
|
|
||||||
path: 'definitions/reviews.pb',
|
path: 'definitions/reviews.pb',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { idToRegion } from '@blitzkit/core';
|
import { assertSecret, idToRegion } from '@blitzkit/core';
|
||||||
import { Button, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
import { Button, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { App } from '../stores/app';
|
import { App } from '../stores/app';
|
||||||
@@ -81,9 +81,9 @@ function Content() {
|
|||||||
fetch(
|
fetch(
|
||||||
`https://api.worldoftanks.${idToRegion(
|
`https://api.worldoftanks.${idToRegion(
|
||||||
wargaming.id,
|
wargaming.id,
|
||||||
)}/wot/auth/prolongate/?application_id=${
|
)}/wot/auth/prolongate/?application_id=${assertSecret(
|
||||||
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID
|
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID,
|
||||||
}&access_token=${wargaming.token}`,
|
)}&access_token=${wargaming.token}`,
|
||||||
)
|
)
|
||||||
.then((response) => response.json() as Promise<Extension>)
|
.then((response) => response.json() as Promise<Extension>)
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { fetchGameDefinitions } from '@blitzkit/core';
|
import { assertSecret, fetchGameDefinitions } from '@blitzkit/core';
|
||||||
import { Code, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
import { Code, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
||||||
import packageJson from '../../../../package.json';
|
import packageJson from '../../../../package.json';
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ const gameDefinitions = await fetchGameDefinitions();
|
|||||||
{gameDefinitions.version}
|
{gameDefinitions.version}
|
||||||
</Code>
|
</Code>
|
||||||
<Code size="2" color="gray">
|
<Code size="2" color="gray">
|
||||||
{import.meta.env.PUBLIC_ASSET_BRANCH}
|
{assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH)}
|
||||||
</Code>
|
</Code>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -150,7 +150,7 @@ const gameDefinitions = await fetchGameDefinitions();
|
|||||||
</Code>
|
</Code>
|
||||||
<Text size="2" color="gray"> CDN </Text>
|
<Text size="2" color="gray"> CDN </Text>
|
||||||
<Code size="2" color="gray">
|
<Code size="2" color="gray">
|
||||||
{import.meta.env.PUBLIC_ASSET_BRANCH}
|
{assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH)}
|
||||||
</Code>
|
</Code>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
Reference in new issue
Block a user