terminal initializes successfully, scuffed intro visuals, termianl still visible with the login form, user temporarily locked to gornodox only. all algorithms work for now, needs to check for bugs and merge to master befpre build. SIDE NOTE - *Make domain builds only from the* master *branch.*

This commit is contained in:
2026-03-05 19:50:05 +01:00
parent 9ac27f5fbd
commit 43589410e3
18 changed files with 288 additions and 119 deletions
+1 -1
View File
@@ -433,7 +433,7 @@
},
"13": {
"Inode": 13,
"Name": "kamil",
"Name": "gornodox",
"Type": 16384,
"Size": 4096,
"Children": [
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+3 -6
View File
@@ -8,9 +8,8 @@ import { GROUP, type Group } from './etc/groupData';
export type BashInitArgs = {
io?: Terminal;
instanceId: number;
fs: Map<number, TreeNode>;
user: {username: string, password: string};
fs?: VirtualFS;
};
export type Result = {
@@ -20,7 +19,6 @@ export type Result = {
};
export class Bash {
private readonly _instanceId: number;
private vfs: VirtualFS;
private _passwd: User[];
private _userInstances: Stack<User>;
@@ -30,7 +28,6 @@ export class Bash {
private readonly _commands: Record<string, ICommand>;
constructor(args: BashInitArgs) {
this._instanceId = args.instanceId
this._commands = COMMANDS;
this._passwd = PASSWD;
this._group = GROUP;
@@ -46,7 +43,7 @@ export class Bash {
this.user = this._userInstances.peek()!
this.vfs = this._terminal.fileSystem;
this.vfs = new VirtualFS({ fs: args.fs, user: this.user});
}
private _initNewUserSession(user: User): User {
@@ -63,7 +60,7 @@ export class Bash {
output: output,
cmd: cmd
};
console.log(data);
console.log(this.vfs.formatPath(this.vfs.getPathByInode(inode)), "TEST TEST !@#");
this._terminal.PrintOutput(data);
}
+3 -2
View File
@@ -1,5 +1,6 @@
import { ExitCode, type Bash } from "../bash";
import type { CommandArgs, ICommand, Result } from "../static";
import { type Bash, type Result } from "../bash";
import type { CommandArgs, ICommand } from "../commandRegistry";
import { ExitCode } from "../metadata";
export const cmd_clear = function(this: Bash, args: CommandArgs): Result {
let result: Result = { exitCode: ExitCode.ERROR, path: this.getCwd() };
+2 -2
View File
@@ -35,11 +35,11 @@ export const PASSWD: User[] = [
history: []
},
{
username: 'kamil',
username: 'gornodox',
passwd: '000',
uid: 1002,
gid: 1000,
home: '/home/kamil',
home: '/home/gornodox',
history: []
}
];
+12 -8
View File
@@ -1,4 +1,5 @@
import type { Bash } from "./bash";
import type { User } from "./etc/userData";
import type { Permission, TimeStamps } from "./metadata";
export enum Type {
@@ -14,8 +15,8 @@ export type NodePerms = {
};
export type FsInitArgs = {
fs: any;
bash: Bash;
fs: Map<number, TreeNode>;
user: User;
};
export type TreeNode = {
@@ -38,7 +39,7 @@ export type TreeNode = {
export class VirtualFS {
private FsTable: Map<number, TreeNode>;
private rootINode: number;
private _Bash: Bash;
private user: User;
home: number;
cwd: number;
@@ -46,11 +47,12 @@ export class VirtualFS {
constructor(args: FsInitArgs) {
this.FsTable = args.fs;
this.user = args.user;
this.rootINode = 1;
this._Bash = args.bash;
this.home = this._pathStringToINode(args.bash.getUser().home);
this.cwd = args.bash.getUser().cwd ? args.bash.getUser().cwd! : this.home;
this.pwd = args.bash.getUser().pwd ? args.bash.getUser().pwd! : this.cwd;
this.home = this._pathStringToINode(args.user.home);
this.cwd = args.user.cwd ? args.user.cwd! : this.home;
this.pwd = args.user.pwd ? args.user.pwd! : this.cwd;
console.log(this.home);
console.log(this.cwd);
@@ -59,10 +61,12 @@ export class VirtualFS {
private _iNodeToPathString(inode: number): string {
const currentNode = this.FsTable.get(inode);
if (!currentNode)
throw new Error('could not find the node in the fs table - inodetopathstring');
if (!currentNode.parent) {
if (!currentNode.parent ||
currentNode.inode === this.rootINode) {
return '/';
}
+6 -7
View File
@@ -1,6 +1,6 @@
import type { User } from '../bash/etc/userData';
import type { TreeNode } from '../bash/fs';
import { type ILocale } from './localeRegistry';
//import { type ILocale } from './localeRegistry';
import { Terminal, type PageCallbacks, type TermInitArgs } from './terminal';
let initializing = $state(true);
@@ -117,17 +117,16 @@ export async function initTerminal(
const sig = await fetchFsSignature('/src/lib/assets/fs/signature');
const fsJson = await fetchFsJson(sig);
const fs: Map<number, TreeNode> = jsonToNodeTable(fsJson);
const locale: ILocale = {
/* const locale: ILocale = {
id: localeId,
keys: fetchLocale(localeId)
};
}; */
const args: TermInitArgs = {
fs,
locale,
//locale,
bash: {
user,
instanceId: 0
fs,
user
}
};
+10 -5
View File
@@ -1,13 +1,18 @@
export interface ILocale {
/* export interface ILocale {
id: string;
keys?: {};
SetKeys: () => void;
}
const en: ILocale = {
const en_US: ILocale = {
id: 'en_US',
keys: {}
keys: {},
SetKeys(): () {
}
}
export const LOCALES = {
en
} as const satisfies Record<string, ILocale>;
en_US
} as const satisfies Record<string, ILocale>; */
+12 -25
View File
@@ -3,14 +3,13 @@ import type { CommandArgs } from '../bash/commandRegistry';
import type { User } from '../bash/etc/userData';
import { VirtualFS, type TreeNode } from '../bash/fs';
import type { ExitCode } from '../bash/metadata';
import type { ILocale } from './localeRegistry';
//import type { ILocale } from './localeRegistry';
export type TerminalMode = {};
export type TermInitArgs = {
fs: Map<number, TreeNode>;
bash: BashInitArgs;
locale: ILocale
//locale: ILocale
};
export type ParsedInput = {
@@ -32,27 +31,15 @@ export type PageCallbacks = {
};
export class Terminal {
private _bashInstanceId: number;
private _bashInstances: Bash[];
private _bash: Bash;
private _callbacks: Partial<PageCallbacks> = {};
public fileSystem: VirtualFS;
public locale: ILocale;
//public locale: ILocale;
constructor(args: TermInitArgs) {
args.bash.io = this;
this._bashInstanceId = 0;
this._bashInstances = [];
this._bash = new Bash(args.bash);
this._initializeBashInstance(args.bash);
this.fileSystem = new VirtualFS({ fs: args.fs, bash: this._bashInstances[this._bashInstanceId] });
this.locale = args.locale;
}
private _initializeBashInstance(init: BashInitArgs) {
const instance: Bash = new Bash(init);
this._bashInstances.push(instance);
//this.locale = args.locale;
}
@@ -114,10 +101,10 @@ export class Terminal {
}
executeCommand(input: string): void {
this._bashInstances[this._bashInstanceId].updateHistory(input);
this._bash.updateHistory(input);
const parsed: ParsedInput = this._parseInput(input);
console.log(parsed, 'executeCommand output');
this._bashInstances[this._bashInstanceId].executeCommand(parsed.command, parsed.args);
this._bash.executeCommand(parsed.command, parsed.args);
}
registerCallbacks(callbacks: PageCallbacks): void {
@@ -129,7 +116,7 @@ export class Terminal {
}
getUser(): User {
return this._bashInstances[this._bashInstanceId].getUser();
return this._bash.getUser();
}
getTerminalWidth(): number {
@@ -147,9 +134,9 @@ export class Terminal {
}
getCwd(): string {
const fs: VirtualFS = this._bashInstances[this._bashInstanceId].getFs();
console.log(fs.getPathByInode(this._bashInstances[this._bashInstanceId].getCwd()));
return fs.formatPath(fs.getPathByInode(this._bashInstances[this._bashInstanceId].getCwd()));
const fs: VirtualFS = this._bash.getFs();
console.log(fs.getPathByInode(this._bash.getCwd()));
return fs.formatPath(fs.getPathByInode(this._bash.getCwd()));
}
PrintOutput(data: PrintData) {