mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
move server funcs to init 2
This commit is contained in:
1 parent
5c89bcea99
commit
8c08a00d64
4 files changed
+17
-10
No files matched your search
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user