mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: augment
This commit is contained in:
1 parent
f70864a0db
commit
1cc15f64b0
9 files changed
+63
-75
No files matched your search
@@ -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