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:
Generated
+55
-36
@@ -1195,9 +1195,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sveltejs/kit": {
|
||||
"version": "2.50.2",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.50.2.tgz",
|
||||
"integrity": "sha512-875hTUkEbz+MyJIxWbQjfMaekqdmEKUUfR7JyKcpfMRZqcGyrO9Gd+iS1D/Dx8LpE5FEtutWGOtlAh4ReSAiOA==",
|
||||
"version": "2.53.2",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.53.2.tgz",
|
||||
"integrity": "sha512-M+MqAvFve12T1HWws/2npP/s3hFtyjw3GB/OXW/8a1jZBk48qnvPJrtgE+VOMc3RnjUMxc4mv/vQ73nvj2uNMg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
@@ -1207,12 +1207,11 @@
|
||||
"@types/cookie": "^0.6.0",
|
||||
"acorn": "^8.14.1",
|
||||
"cookie": "^0.6.0",
|
||||
"devalue": "^5.6.2",
|
||||
"devalue": "^5.6.3",
|
||||
"esm-env": "^1.2.2",
|
||||
"kleur": "^4.1.5",
|
||||
"magic-string": "^0.30.5",
|
||||
"mrmime": "^2.0.0",
|
||||
"sade": "^1.8.1",
|
||||
"set-cookie-parser": "^3.0.0",
|
||||
"sirv": "^3.0.0"
|
||||
},
|
||||
@@ -1224,10 +1223,10 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opentelemetry/api": "^1.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0",
|
||||
"svelte": "^4.0.0 || ^5.0.0-next.0",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0"
|
||||
"vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@opentelemetry/api": {
|
||||
@@ -1641,6 +1640,12 @@
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.46.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.46.2.tgz",
|
||||
@@ -1832,24 +1837,37 @@
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.3.tgz",
|
||||
"integrity": "sha512-fy6KJm2RawA5RcHkLa1z/ScpBeA762UF9KmZQxwIbDtRJrgLzM10depAiEQ+CXYcoiqW1/m96OAAoke2nE9EeA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||
"version": "9.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.8.tgz",
|
||||
"integrity": "sha512-reYkDYtj/b19TeqbNZCV4q9t+Yxylf/rYBsLb42SXJatTv4/ylq5lEiAmhA/IToxO7NI2UzNMghHoHuaqDkAjw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
"brace-expansion": "^5.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
@@ -2076,9 +2094,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
|
||||
"integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2405,10 +2423,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/devalue": {
|
||||
"version": "5.6.2",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.2.tgz",
|
||||
"integrity": "sha512-nPRkjWzzDQlsejL1WVifk5rvcFi/y1onBRxjaFMjZeR9mFpqu2gmAZ9xUB9/IEanEP/vBtGeGganC/GO1fmufg==",
|
||||
"dev": true,
|
||||
"version": "5.6.3",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.3.tgz",
|
||||
"integrity": "sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dom-accessibility-api": {
|
||||
@@ -2673,9 +2690,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/esrap": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.1.2.tgz",
|
||||
"integrity": "sha512-DgvlIQeowRNyvLPWW4PT7Gu13WznY288Du086E751mwwbsgr29ytBiYeLzAGIo0qk3Ujob0SDk8TiSaM5WQzNg==",
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.3.tgz",
|
||||
"integrity": "sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.15"
|
||||
@@ -3484,9 +3501,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
||||
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -4282,9 +4299,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/svelte": {
|
||||
"version": "5.43.2",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.43.2.tgz",
|
||||
"integrity": "sha512-ro1umEzX8rT5JpCmlf0PPv7ncD8MdVob9e18bhwqTKNoLjS8kDvhVpaoYVPc+qMwDAOfcwJtyY7ZFSDbOaNPgA==",
|
||||
"version": "5.53.5",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.5.tgz",
|
||||
"integrity": "sha512-YkqERnF05g8KLdDZwZrF8/i1eSbj6Eoat8Jjr2IfruZz9StLuBqo8sfCSzjosNKd+ZrQ8DkKZDjpO5y3ht1Pow==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
@@ -4292,12 +4309,14 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||
"@sveltejs/acorn-typescript": "^1.0.5",
|
||||
"@types/estree": "^1.0.5",
|
||||
"@types/trusted-types": "^2.0.7",
|
||||
"acorn": "^8.12.1",
|
||||
"aria-query": "^5.3.1",
|
||||
"aria-query": "5.3.1",
|
||||
"axobject-query": "^4.1.0",
|
||||
"clsx": "^2.1.1",
|
||||
"devalue": "^5.6.3",
|
||||
"esm-env": "^1.2.1",
|
||||
"esrap": "^2.1.0",
|
||||
"esrap": "^2.2.2",
|
||||
"is-reference": "^3.0.3",
|
||||
"locate-character": "^3.0.0",
|
||||
"magic-string": "^0.30.11",
|
||||
@@ -4362,9 +4381,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/svelte/node_modules/aria-query": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
|
||||
"integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==",
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
|
||||
"integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
||||
@@ -433,7 +433,7 @@
|
||||
},
|
||||
"13": {
|
||||
"Inode": 13,
|
||||
"Name": "kamil",
|
||||
"Name": "gornodox",
|
||||
"Type": 16384,
|
||||
"Size": 4096,
|
||||
"Children": [
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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() };
|
||||
|
||||
@@ -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: []
|
||||
}
|
||||
];
|
||||
@@ -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 '/';
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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>; */
|
||||
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<script lang="ts">
|
||||
import { enhance } from "$app/forms";
|
||||
import { ArrowRight, CircleAlert, Lock } from "@lucide/svelte";
|
||||
|
||||
let formElem: HTMLElement;
|
||||
let {init, form}: { init: (formData: FormData) => void, form: any} = $props();
|
||||
</script>
|
||||
|
||||
<div id="wrapper" class=" opacity-0 flex flex-col items-center" class:outro={form?.success}>
|
||||
<img class="rounded-full mb-4 border-primary-dark border-2" src="/src/lib/assets/login-avatar.png" alt="" width="80" height="80" />
|
||||
<div id="name" class="flex flex-row items-center text-text-muted-dark justify-center gap-4">
|
||||
<strong>gornodox</strong>
|
||||
</div>
|
||||
<form bind:this={formElem} onanimationend={() => {formElem.classList.remove('invalid')}} use:enhance={({ formData }) =>
|
||||
{
|
||||
init(formData);
|
||||
}
|
||||
} method="POST" action="?/login" class:invalid={form?.error} name="login-form" autocomplete="off" class="mt-6 flex flex-row gap-1">
|
||||
<div class=" bg-bg-lighter-dark flex flex-row ml-4 items-center rounded outline-none border border-transparent text-sm p-1.5 w-2xs text-text-dark focus-within:bg-bg-light-dark focus-within:border-primary-dark {form?.error ? 'focus-within:border-warning-dark text-warning-dark' : ''}">
|
||||
<Lock size={16} strokeWidth={2} />
|
||||
<input autofocus name="password" type="password" autocomplete="off" placeholder="Password..." class=" placeholder-text-dark {form?.error ? 'placeholder-warning-dark' : ''} grow ml-2 appearance-none outline-none">
|
||||
</div>
|
||||
<button type="submit" class=" bg-bg-lighter-dark rounded p-1.5 hover:text-primary-hover-dark active:text-primary-dark active:bg-bg-light-dark">
|
||||
<ArrowRight size={20} strokeWidth={2} />
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.invalid {
|
||||
animation: var(--animate-error-shake);
|
||||
}
|
||||
|
||||
#error {
|
||||
animation: fadeIn 0.2s forwards cubic-bezier(.4,.7,0,.99);
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
animation: fadeIn 0.5s forwards cubic-bezier(.4,.7,0,.99) 1s;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.outro {
|
||||
transition: opacity 0.5s cubic-bezier(.4,.7,0,.99) 1s;
|
||||
opacity: 0;
|
||||
form {
|
||||
transition: opacity 0.2s cubic-bezier(.4,.7,0,.99);
|
||||
opacity: 0;
|
||||
}
|
||||
img {
|
||||
transform: translateY(30px) scale(1.2);
|
||||
transition: transform 0.5s ease-out;
|
||||
}
|
||||
#name {
|
||||
transform: translateY(30px);
|
||||
transition: transform 0.5s ease-out;
|
||||
}
|
||||
#error {
|
||||
transition: opacity 0.2s cubic-bezier(.4,.7,0,.99);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<div
|
||||
id="options"
|
||||
class="absolute top-0 left-0 isolate mx-4 rounded-b-xl bg-bg-dark light:bg-bg-light"
|
||||
class=" z-100 absolute top-0 left-0 isolate mx-4 rounded-b-xl bg-bg-dark light:bg-bg-light"
|
||||
>
|
||||
<section class="hide grid" id="settings-menu">
|
||||
<div class="flex flex-col items-center justify-center gap-4 overflow-hidden">
|
||||
|
||||
+28
-21
@@ -10,6 +10,17 @@
|
||||
|
||||
const printOutput = (e: HTMLElement, d: PrintData): void => print(e, d);
|
||||
|
||||
export async function init(password: string) {
|
||||
try {
|
||||
terminal = await initTerminal({ username: 'gornodox', password}, callbackInit, 'en_US');
|
||||
updateTerminal();
|
||||
} catch (error) {
|
||||
console.error('onMount trycatch failed', error);
|
||||
}
|
||||
|
||||
runTerminal();
|
||||
}
|
||||
|
||||
function updateTerminal() {
|
||||
username = terminal!.getUser().username;
|
||||
cwd = terminal!.getCwd();
|
||||
@@ -66,6 +77,10 @@
|
||||
elem.scrollTop = elem.scrollHeight;
|
||||
}
|
||||
|
||||
function runTerminal() {
|
||||
document.getElementById('terminal-window')?.classList.remove('hidden');
|
||||
}
|
||||
|
||||
//Callback initializer
|
||||
const callbackInit = {
|
||||
print: (data: any) => {
|
||||
@@ -78,35 +93,17 @@
|
||||
getFontSize: getFontSize
|
||||
};
|
||||
|
||||
//Test user with basic data so the bash can run
|
||||
let testUser: User = {
|
||||
username: 'kamil',
|
||||
passwd: '123',
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
home: '/home/kamil',
|
||||
history: []
|
||||
};
|
||||
|
||||
//Empty terminal variable where the terminal class instance will be stored
|
||||
let terminal: Terminal;
|
||||
let username: string = $state(testUser.username);
|
||||
let cwd: string = $state(testUser.home);
|
||||
let username: string = $state('');
|
||||
let cwd: string = $state('');
|
||||
|
||||
let inputValue = $state<string>('');
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
terminal = await initTerminal({ username: 'root', password: '123'}, callbackInit, 'en_US');
|
||||
updateTerminal();
|
||||
} catch (error) {
|
||||
console.error('onMount trycatch failed', error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<label for="input" onkeydowncapture={(event) => inputHandler(event)} class="w-11/12">
|
||||
<div id="terminal" class="terminal-window shadow-() h-full w-full rounded-md shadow-bg">
|
||||
<div id="terminal" class=" transition-discrete terminal-window shadow-() h-full w-full rounded-md shadow-bg">
|
||||
<div
|
||||
class="terminal-bar flex h-9 w-full flex-row items-center rounded-t-md bg-bg-dark text-center font-terminal text-sm font-bold text-primary-dark light:bg-bg-dark-light light:text-primary-light"
|
||||
>
|
||||
@@ -136,6 +133,16 @@
|
||||
* {
|
||||
transition: var(--transition-standard);
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
display: none;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.dots-wrapper {
|
||||
& > button {
|
||||
border: none;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { onMount, type Snippet } from 'svelte';
|
||||
import { theme } from '$lib/stores/theme';
|
||||
import Loading from '../modules/Loading.svelte';
|
||||
|
||||
let { children }: { children: Snippet } = $props();
|
||||
|
||||
@@ -42,6 +43,7 @@
|
||||
class:dark={$theme === 'dark'}
|
||||
class:light={$theme === 'light'}
|
||||
>
|
||||
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PASSWD } from "$lib/stores/bash/etc/userData";
|
||||
import type { Actions } from "./$types";
|
||||
|
||||
export const actions = {
|
||||
login: async ({request}) => {
|
||||
const user = PASSWD.find((object) => object.username == "gornodox");
|
||||
let data = await request.formData();
|
||||
let out = data.get("password")?.toString();
|
||||
let error = false;
|
||||
let success = true
|
||||
|
||||
if(out != user?.passwd || out == undefined) {
|
||||
error = true;
|
||||
success = false;
|
||||
}
|
||||
|
||||
return { error, success, data: out };
|
||||
}
|
||||
} satisfies Actions
|
||||
+38
-4
@@ -1,14 +1,48 @@
|
||||
<script lang="ts">
|
||||
import TerminalModule from '../modules/Terminal.svelte';
|
||||
import Settings from '../modules/Settings.svelte';
|
||||
import Loading from '../modules/Loading.svelte';
|
||||
import { isInitializing } from '$lib/stores/terminal/init.svelte';
|
||||
import Login from '../modules/Login.svelte';
|
||||
import { mount } from 'svelte';
|
||||
import Terminal from '../modules/Terminal.svelte';
|
||||
import { CircleAlert } from '@lucide/svelte';
|
||||
|
||||
let { form } = $props();
|
||||
//export let isWelcomeSequence = false;
|
||||
let terminalComponent: Terminal;
|
||||
|
||||
function welcomeSequence() {
|
||||
//isWelcomeSequence = true;
|
||||
|
||||
//TODO: do magic :)
|
||||
}
|
||||
|
||||
function initializer(formData: FormData) {
|
||||
if(form?.error) return;
|
||||
const password = formData.get("password")?.toString();
|
||||
if(!password) throw new Error("password is null or undefined");
|
||||
terminalComponent.init(password)
|
||||
}
|
||||
</script>
|
||||
|
||||
<Settings></Settings>
|
||||
<div class="h-dvh w-full p-24 flex justify-center">
|
||||
<TerminalModule />
|
||||
<div id="main" class="h-dvh w-full p-24 relative flex justify-center items-center">
|
||||
<div id="wrapper1" class=" absolute z-5 flex flex-col items-center {form?.success ? 'outro' : ''}">
|
||||
<Login init={initializer} form={form}/>
|
||||
</div>
|
||||
<div id="wrapper2" class=" size-4/5 absolute z-4 {form?.success ? 'intro' : ''}">
|
||||
<Terminal bind:this={terminalComponent} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.outro {
|
||||
animation: fadeOut 0.5s forwards cubic-bezier(.4,.7,0,.99) 1s;
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
to {
|
||||
opacity: 0;
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import Login from "../../modules/Login.svelte";
|
||||
|
||||
</script>
|
||||
<div class=" flex flex-col items-center">
|
||||
<div class=" absolute left-1/2 z-11">
|
||||
<Login init={() => {}}/>
|
||||
</div>
|
||||
<div class=" absolute top-1/2 left-1/2 size-96 z-10 bg-red-600"></div>
|
||||
</div>
|
||||
@@ -1,6 +1,7 @@
|
||||
@theme {
|
||||
--animate-loading: loading 1s ease-in-out infinite;
|
||||
--animate-cursor-blink: blink 1s step-end infinite;
|
||||
--animate-error-shake: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
|
||||
|
||||
@keyframes blink {
|
||||
0% {
|
||||
@@ -23,4 +24,19 @@
|
||||
transform: scaleY(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shake {
|
||||
10%, 90% {
|
||||
transform: translate3d(-1px, 0, 0);
|
||||
}
|
||||
20%, 80% {
|
||||
transform: translate3d(2px, 0, 0);
|
||||
}
|
||||
30%, 50%, 70% {
|
||||
transform: translate3d(-4px, 0, 0);
|
||||
}
|
||||
40%, 60% {
|
||||
transform: translate3d(4px, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user