mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +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,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;
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user