mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: augment
This commit is contained in:
1 parent
f70864a0db
commit
1cc15f64b0
9 files changed
+63
-75
No files matched your search
@@ -74,6 +74,7 @@
|
||||
"adm-zip": "^0.5.16",
|
||||
"crc": "^4.3.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"fast-xml-parser": "^5.3.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lz4js": "^0.2.0",
|
||||
"pickleparser": "^0.2.1",
|
||||
@@ -1438,7 +1439,7 @@
|
||||
|
||||
"fast-uri": ["[email protected]", "", {}, "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA=="],
|
||||
|
||||
"fast-xml-parser": ["fast-xml-parser@5.2.5", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ=="],
|
||||
"fast-xml-parser": ["fast-xml-parser@5.3.2", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-n8v8b6p4Z1sMgqRmqLJm3awW4NX7NkaKPfb3uJIBTSH7Pdvufi3PQ3/lJLQrvxcMYl7JI2jnDO90siPEpD8JBA=="],
|
||||
|
||||
"fastq": ["[email protected]", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
|
||||
|
||||
@@ -2614,6 +2615,8 @@
|
||||
|
||||
"@blitzkit/scripts/@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.0" } }, "sha512-+lAGCYjXjip2qY375xX/scJeVRmZ5cY0wyHYyCYxNcdEXrQ4AOe3gACgd4iQ8ksOslJtW4VNxBJ8llUwc3a6AA=="],
|
||||
|
||||
"@blitzkit/scripts/fast-xml-parser": ["[email protected]", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ=="],
|
||||
|
||||
"@blitzkit/website/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-4nVGliEpxmhCL8DslSAUdxlB6+SMrhB0a1v5ijlh1xB1nEPuy1mxaHxysVucLHuWryAxLWg6a5ei+U4TLn/rFg=="],
|
||||
|
||||
"@discordjs/rest/@discordjs/collection": ["@discordjs/[email protected]", "", {}, "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="],
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"adm-zip": "^0.5.16",
|
||||
"crc": "^4.3.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"fast-xml-parser": "^5.3.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lz4js": "^0.2.0",
|
||||
"pickleparser": "^0.2.1",
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { XMLParser } from "fast-xml-parser";
|
||||
import SteamUser, { EConnectionProtocol } from "steam-user";
|
||||
import { parse } from "yaml";
|
||||
|
||||
interface SteamManifestFile {
|
||||
chunks: {
|
||||
@@ -31,6 +33,8 @@ interface SteamManifest {
|
||||
|
||||
export class SteamVFS {
|
||||
private steam = new SteamUser({ protocol: EConnectionProtocol.TCP });
|
||||
private textDecoder = new TextDecoder();
|
||||
private xmlParser = new XMLParser();
|
||||
|
||||
private manifest: Map<string, SteamManifestFile> = new Map();
|
||||
|
||||
@@ -75,13 +79,26 @@ export class SteamVFS {
|
||||
return this;
|
||||
}
|
||||
|
||||
async file(path: string) {
|
||||
if (!this.manifest.has(path)) {
|
||||
throw new Error(`File not found: ${path}`);
|
||||
}
|
||||
has(path: string) {
|
||||
const dvplPath = `${path}.dvpl`;
|
||||
|
||||
return (
|
||||
(this.manifest.has(dvplPath) && dvplPath) ||
|
||||
(this.manifest.has(path) && path)
|
||||
);
|
||||
}
|
||||
|
||||
assert(requested: string) {
|
||||
const path = this.has(requested);
|
||||
|
||||
if (!path) throw new Error(`File not found: ${path}`);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
async file(requested: string) {
|
||||
const path = this.assert(requested);
|
||||
const fileManifest = this.manifest.get(path)!;
|
||||
|
||||
const downloaded: { type: "complete"; file: Buffer } =
|
||||
// @ts-expect-error
|
||||
await this.steam.downloadFile(this.app, this.depot, fileManifest);
|
||||
@@ -89,6 +106,21 @@ export class SteamVFS {
|
||||
return new Uint8Array(downloaded.file);
|
||||
}
|
||||
|
||||
async text(path: string) {
|
||||
const file = await this.file(path);
|
||||
return this.textDecoder.decode(file);
|
||||
}
|
||||
|
||||
async yaml<Type>(path: string) {
|
||||
const file = await this.text(path);
|
||||
return parse(file) as Type;
|
||||
}
|
||||
|
||||
async xml<Type>(path: string) {
|
||||
const file = await this.text(path);
|
||||
return this.xmlParser.parse(file) as Type;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.steam.logOff();
|
||||
}
|
||||
|
||||
@@ -1,32 +1,11 @@
|
||||
import { readdir } from "fs/promises";
|
||||
import { argv } from "process";
|
||||
import { assertSecret, SteamVFS } from "@blitzkit/core";
|
||||
|
||||
const WINDOWS_APPS = "C:/Program Files/WindowsApps";
|
||||
const wotbPackageRegex = /7458BE2C\..+_\d+(\.\d+)+_x64__.+/;
|
||||
const APP = 444200;
|
||||
const DEPOT = 444202;
|
||||
|
||||
const isManual = argv.includes("--manual");
|
||||
|
||||
let data: string;
|
||||
let compressed: boolean;
|
||||
|
||||
if (isManual) {
|
||||
data = "../../temp/game/Data";
|
||||
compressed = true;
|
||||
} else {
|
||||
const directories = await readdir(WINDOWS_APPS).then((files) =>
|
||||
files.filter((file) => wotbPackageRegex.test(file))
|
||||
);
|
||||
|
||||
if (directories.length !== 1) {
|
||||
throw new Error(
|
||||
`Expected 1 directory for WoTB Windows App, got ${directories.length}.`
|
||||
);
|
||||
}
|
||||
|
||||
const [windowsApp] = directories;
|
||||
data = `${WINDOWS_APPS}/${windowsApp}/Data`;
|
||||
compressed = false;
|
||||
}
|
||||
|
||||
export const DATA = data;
|
||||
export const DATA_COMPRESSED = compressed;
|
||||
export const vfs = new SteamVFS(
|
||||
assertSecret(import.meta.env.STEAM_USERNAME),
|
||||
assertSecret(import.meta.env.STEAM_PASSWORD),
|
||||
APP,
|
||||
DEPOT
|
||||
);
|
||||
@@ -1,16 +1,8 @@
|
||||
import { config } from "dotenv";
|
||||
import { argv } from "process";
|
||||
|
||||
config();
|
||||
|
||||
const allTargets = argv.includes("--all-targets");
|
||||
const targets = argv
|
||||
.find((argument) => argument.startsWith("--target"))
|
||||
?.split("=")[1]
|
||||
.split(",");
|
||||
|
||||
import { boosterIcons } from "./boosterIcons";
|
||||
import { camouflageIcons } from "./camouflageIcons";
|
||||
import { vfs } from "./constants";
|
||||
import { consumableProvisionIcons } from "./consumableProvisionIcons";
|
||||
import { currencies } from "./currencies";
|
||||
import { definitions } from "./definitions";
|
||||
@@ -27,6 +19,14 @@ import { tankArmors } from "./tankArmors";
|
||||
import { tankIcons } from "./tankIcons";
|
||||
import { tankModels } from "./tankModels";
|
||||
|
||||
config();
|
||||
|
||||
const allTargets = argv.includes("--all-targets");
|
||||
const targets = argv
|
||||
.find((argument) => argument.startsWith("--target"))
|
||||
?.split("=")[1]
|
||||
.split(",");
|
||||
|
||||
if (!targets && !allTargets) throw new Error("No target(s) specified");
|
||||
|
||||
const methods = [
|
||||
@@ -59,3 +59,6 @@ for (const method of methods) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vfs.dispose();
|
||||
process.exit(0);
|
||||
@@ -1,6 +0,0 @@
|
||||
import { readDVPLFile } from './readDVPLFile';
|
||||
|
||||
export async function readStringDVPL(file: string) {
|
||||
const buffer = await readDVPLFile(file);
|
||||
return buffer.toString();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { XMLParser } from 'fast-xml-parser';
|
||||
import { readStringDVPL } from './readStringDVPL';
|
||||
|
||||
export async function readXMLDVPL<Type>(file: string) {
|
||||
const parser = new XMLParser();
|
||||
const xml = await readStringDVPL(file);
|
||||
|
||||
return parser.parse(xml) as Type;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { readFile } from 'fs/promises';
|
||||
import { parse } from 'yaml';
|
||||
|
||||
export async function readYAML<Type>(file: string) {
|
||||
const yaml = (await readFile(file)).toString();
|
||||
return parse(yaml) as Type;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { parse } from 'yaml';
|
||||
import { readStringDVPL } from './readStringDVPL';
|
||||
|
||||
export async function readYAMLDVPL<Type>(file: string) {
|
||||
const yaml = await readStringDVPL(file);
|
||||
|
||||
return parse(yaml) as Type;
|
||||
}
|
||||
Reference in new issue
Block a user