WIP: new abstraction layer, file system now a singleton, shell should be too
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { TermOS } from '$lib/termos/termos';
|
||||
import type { TreeNode } from '../bash/fs';
|
||||
//import { type ILocale } from './localeRegistry';
|
||||
import { Terminal, type PageCallbacks, type TermInitArgs } from './terminal';
|
||||
@@ -9,7 +8,7 @@ export function isInitializing(): boolean {
|
||||
return initializing;
|
||||
}
|
||||
|
||||
function jsonToNodeTable(data: any): Map<number, TreeNode> {
|
||||
function jsonToNodeTable(data: JSON): Map<number, TreeNode> {
|
||||
const FsTable: Map<number, TreeNode> = new Map<number, TreeNode>();
|
||||
const entryList = Object.entries(data);
|
||||
|
||||
@@ -24,7 +23,7 @@ function jsonToNodeTable(data: any): Map<number, TreeNode> {
|
||||
func: object.Func,
|
||||
children: object.Children,
|
||||
content: object.Content,
|
||||
link: object.Link,
|
||||
link: object.Target,
|
||||
permission: {
|
||||
user: {
|
||||
r: object.Permission[0]?.Read,
|
||||
@@ -57,7 +56,7 @@ function jsonToNodeTable(data: any): Map<number, TreeNode> {
|
||||
return FsTable;
|
||||
}
|
||||
|
||||
async function fetchFsJson(sig: string): Promise<any> {
|
||||
async function fetchFsJson(sig: string): Promise<JSON> {
|
||||
const signature: string | null = localStorage.getItem('signature');
|
||||
|
||||
if (signature !== sig || signature === null || localStorage.getItem('fs') === null) {
|
||||
@@ -108,16 +107,14 @@ async function fetchLocale(id: string): Promise<any> {
|
||||
return data;
|
||||
}
|
||||
|
||||
TermOS.Shell.Bash;
|
||||
|
||||
export async function initTerminal(
|
||||
user: { username: string; password: string },
|
||||
callbackInit: PageCallbacks,
|
||||
localeId: string
|
||||
): Promise<Terminal> {
|
||||
): Promise<Shell> {
|
||||
try {
|
||||
const sig = await fetchFsSignature('/src/lib/assets/fs/signature');
|
||||
const fsJson = await fetchFsJson(sig);
|
||||
const fsJson: JSON = await fetchFsJson(sig);
|
||||
const fs: Map<number, TreeNode> = jsonToNodeTable(fsJson);
|
||||
/* const locale: ILocale = {
|
||||
id: localeId,
|
||||
|
||||
Reference in New Issue
Block a user