move server funcs to init 2

This commit is contained in:
tresabhi committed 2026-08-30 14:46:14 -05:00
1 parent 5c89bcea99
commit 8c08a00d64
4 files changed
+17 -10

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
import { AbstractVFS, BlitzKitAPI } from "@blitzkit/core";
export async function createDynamicAPI(vfs: AbstractVFS) {
export async function createDynamicAPI(vfs: () => Promise<AbstractVFS>) {
let _api: BlitzKitAPI;
if (import.meta.env.SSR) {
@@ -8,7 +8,7 @@ export async function createDynamicAPI(vfs: AbstractVFS) {
"@blitzkit/core/src/blitzkit/api/server/index"
);
_api = await new ServerBlitzKitAPI(vfs).init();
_api = await new ServerBlitzKitAPI(await vfs()).init();
} else {
const { ClientBlitzKitAPI } = await import(
"@blitzkit/core/src/blitzkit/api/client"
+9 -4
View File
@@ -1,4 +1,4 @@
import SteamUser, { EConnectionProtocol } from "steam-user";
import type SteamUser from "steam-user";
import { AbstractVFS } from "./abstract";
interface SteamManifestFile {
@@ -31,7 +31,7 @@ interface SteamManifest {
}
export class SteamVFS extends AbstractVFS {
private steam = new SteamUser({ protocol: EConnectionProtocol.TCP });
private steam?: SteamUser;
private manifest: Map<string, SteamManifestFile> = new Map();
constructor(
@@ -44,12 +44,17 @@ export class SteamVFS extends AbstractVFS {
}
async _init() {
const steamUser = await import("steam-user");
this.steam = new steamUser.default({
protocol: steamUser.EConnectionProtocol.TCP,
});
this.steam.logOn({
accountName: this.username,
password: this.password,
});
await new Promise((resolve) => this.steam.once("loggedOn", resolve));
await new Promise((resolve) => this.steam!.once("loggedOn", resolve));
const productInfo = await this.steam.getProductInfo([this.app], []);
const manifest: SteamManifest = await new Promise((resolve) => {
@@ -105,6 +110,6 @@ export class SteamVFS extends AbstractVFS {
}
dispose() {
this.steam.logOff();
this.steam!.logOff();
}
}
+3 -2
View File
@@ -1,4 +1,3 @@
import { normalize } from "path/posix";
import { HTTPRangeReader, unzip, ZipEntry } from "unzipit";
import { AbstractVFS } from "./abstract";
@@ -17,7 +16,9 @@ export class ZipVFS extends AbstractVFS {
const { entries } = await unzip(reader);
for (const entry of Object.values(entries)) {
const normalized = normalize(entry.name.slice(this.root.length));
const normalized = this.normalizePath!(
entry.name.slice(this.root.length),
);
this.entries.set(normalized, entry);
}
+3 -2
View File
@@ -1,4 +1,5 @@
import { createDynamicAPI } from "@blitzkit/core";
import { vfs } from "./vfs";
export const api = await createDynamicAPI(vfs);
export const api = await createDynamicAPI(() =>
import("./vfs").then(({ vfs }) => vfs),
);