unsable code rework, doesnt run

This commit is contained in:
2026-02-23 17:15:28 +01:00
parent 1faab39849
commit 9ac27f5fbd
19 changed files with 287 additions and 189 deletions
+23 -4
View File
@@ -1,6 +1,7 @@
import type { User } from '../bash/bash';
import type { User } from '../bash/etc/userData';
import type { TreeNode } from '../bash/fs';
import { Terminal, type TermInitArgs } from './terminal';
import { type ILocale } from './localeRegistry';
import { Terminal, type PageCallbacks, type TermInitArgs } from './terminal';
let initializing = $state(true);
@@ -99,16 +100,34 @@ async function fetchFileSystem(path: string): Promise<any> {
return data;
}
export async function initTerminal(user: User, callbackInit: any): Promise<Terminal> {
async function fetchLocale(id: string): Promise<any> {
const response = await fetch(`/src/lib/assets/locales/terminal/${id}.json`);
if(!response.ok) throw new Error('Failed to fetch the chosen locale');
const data = await response.json();
return data;
}
export async function initTerminal(
user: {username: string, password: string},
callbackInit: PageCallbacks,
localeId: string
): Promise<Terminal> {
try {
const sig = await fetchFsSignature('/src/lib/assets/fs/signature');
const fsJson = await fetchFsJson(sig);
const fs: Map<number, TreeNode> = jsonToNodeTable(fsJson);
const locale: ILocale = {
id: localeId,
keys: fetchLocale(localeId)
};
const args: TermInitArgs = {
fs,
locale,
bash: {
user,
fs
instanceId: 0
}
};