unsable code rework, doesnt run
This commit is contained in:
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user