From 5c89bcea996c4734a8c114c53fc81b356e1b864b Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sun, 30 Aug 2026 14:36:51 -0500 Subject: [PATCH] move server funcs to init --- packages/core/src/blitzkit/vfs/abstract.ts | 17 +++++++++++++---- packages/core/src/blitzkit/vfs/local.ts | 11 ++++++++--- packages/core/src/blitzkit/vfs/mixed.ts | 2 +- packages/core/src/blitzkit/vfs/steam.ts | 3 +-- packages/core/src/blitzkit/vfs/zip.ts | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/core/src/blitzkit/vfs/abstract.ts b/packages/core/src/blitzkit/vfs/abstract.ts index ea69982d3..e342e82a8 100644 --- a/packages/core/src/blitzkit/vfs/abstract.ts +++ b/packages/core/src/blitzkit/vfs/abstract.ts @@ -1,14 +1,23 @@ import { readDVPL } from "@blitzkit/core"; -import { Options, parse as parseCSV } from "csv-parse/sync"; +import { Options, parse as parseCSV } from "csv-parse/browser/esm/sync"; import { XMLParser } from "fast-xml-parser"; -import { normalize } from "path/posix"; +import type { normalize } from "node:path/posix"; import { parse as parseYaml } from "yaml"; export abstract class AbstractVFS { textDecoder = new TextDecoder(); private xmlParser = new XMLParser(); - abstract init(): Promise; + protected normalizePath?: typeof normalize; + + async init() { + const path = await import("node:path/posix"); + this.normalizePath = path.normalize; + + await this._init(); + } + + protected abstract _init(): Promise; abstract dispose(): void; @@ -17,7 +26,7 @@ export abstract class AbstractVFS { abstract raw(path: string): Promise>; async resolve(path: string) { - const normalized = normalize(path); + const normalized = this.normalizePath!(path); if (await this.has(normalized)) return normalized; const dvplPath = `${normalized}.dvpl`; diff --git a/packages/core/src/blitzkit/vfs/local.ts b/packages/core/src/blitzkit/vfs/local.ts index c82510048..fbd293524 100644 --- a/packages/core/src/blitzkit/vfs/local.ts +++ b/packages/core/src/blitzkit/vfs/local.ts @@ -1,12 +1,17 @@ -import { readdir } from "node:fs/promises"; +import type { readdir } from "node:fs/promises"; import { AbstractVFS } from "./abstract"; export class LocalVFS extends AbstractVFS { + protected readdir?: typeof readdir; + constructor(private base: string) { super(); } - async init() { + async _init() { + const path = await import("node:path/posix"); + this.normalizePath = path.normalize; + return this; } @@ -25,7 +30,7 @@ export class LocalVFS extends AbstractVFS { async _dir(path: string) { try { - return await readdir(`${this.base}/${path}`); + return await this.readdir!(`${this.base}/${path}`); } catch (_) { return []; } diff --git a/packages/core/src/blitzkit/vfs/mixed.ts b/packages/core/src/blitzkit/vfs/mixed.ts index d510e4115..ea5a3380b 100644 --- a/packages/core/src/blitzkit/vfs/mixed.ts +++ b/packages/core/src/blitzkit/vfs/mixed.ts @@ -5,7 +5,7 @@ export class MixedVFS extends AbstractVFS { super(); } - async init() { + async _init() { for (const vfs of this.vfses) { await vfs.init(); } diff --git a/packages/core/src/blitzkit/vfs/steam.ts b/packages/core/src/blitzkit/vfs/steam.ts index 9ab2c5047..d364cb571 100644 --- a/packages/core/src/blitzkit/vfs/steam.ts +++ b/packages/core/src/blitzkit/vfs/steam.ts @@ -43,7 +43,7 @@ export class SteamVFS extends AbstractVFS { super(); } - async init() { + async _init() { this.steam.logOn({ accountName: this.username, password: this.password, @@ -57,7 +57,6 @@ export class SteamVFS extends AbstractVFS { this.steam.getManifest( this.app, this.depot, - // @ts-expect-error productInfo.apps[this.app].appinfo.depots[this.depot].manifests.public .gid, "public", diff --git a/packages/core/src/blitzkit/vfs/zip.ts b/packages/core/src/blitzkit/vfs/zip.ts index 53d3e2856..f17915e4c 100644 --- a/packages/core/src/blitzkit/vfs/zip.ts +++ b/packages/core/src/blitzkit/vfs/zip.ts @@ -12,7 +12,7 @@ export class ZipVFS extends AbstractVFS { super(); } - async init() { + async _init() { const reader = new HTTPRangeReader(this.url); const { entries } = await unzip(reader);