move server funcs to init

This commit is contained in:
tresabhi committed 2026-08-30 14:36:51 -05:00
1 parent 5f737d940d
commit 5c89bcea99
5 files changed
+24 -11

No files matched your search

+13 -4
View File
@@ -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<typeof this>;
protected normalizePath?: typeof normalize;
async init() {
const path = await import("node:path/posix");
this.normalizePath = path.normalize;
await this._init();
}
protected abstract _init(): Promise<typeof this>;
abstract dispose(): void;
@@ -17,7 +26,7 @@ export abstract class AbstractVFS {
abstract raw(path: string): Promise<Uint8Array<ArrayBuffer>>;
async resolve(path: string) {
const normalized = normalize(path);
const normalized = this.normalizePath!(path);
if (await this.has(normalized)) return normalized;
const dvplPath = `${normalized}.dvpl`;
+8 -3
View File
@@ -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 [];
}
+1 -1
View File
@@ -5,7 +5,7 @@ export class MixedVFS extends AbstractVFS {
super();
}
async init() {
async _init() {
for (const vfs of this.vfses) {
await vfs.init();
}
+1 -2
View File
@@ -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",
+1 -1
View File
@@ -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);