diff --git a/package.json b/package.json index 0894270..b3229b3 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "svelte-portfolio", "private": true, - "version": "0.0.1", + "version": "0.0.69", "type": "module", "scripts": { "dev": "vite dev", diff --git a/src/lib/assets/login/default.png b/src/lib/assets/login/default.png new file mode 100644 index 0000000..637e5b2 Binary files /dev/null and b/src/lib/assets/login/default.png differ diff --git a/src/lib/assets/login-avatar.png b/src/lib/assets/login/gornodox.png similarity index 100% rename from src/lib/assets/login-avatar.png rename to src/lib/assets/login/gornodox.png diff --git a/src/lib/stores/bash/bash.ts b/src/lib/stores/bash/bash.ts index 2c6743c..aa586fd 100755 --- a/src/lib/stores/bash/bash.ts +++ b/src/lib/stores/bash/bash.ts @@ -73,6 +73,8 @@ export class Bash { command, args ); + + //this._terminal.isProcessActive = true; } private _appendNewResult(inode: number, output: any, cmd: string) { @@ -168,15 +170,6 @@ export class Bash { return out; } - processKill(): ExitCode { - if(this._process) { - return this._process.sigKill(() => {console.log("process Kill successfull")}); - } - else { - return ExitCode.SUCCESS; //Temp need to make custom enum value - } - } - throwError(result: Result): void { switch (result.exitCode) { default: { diff --git a/src/lib/stores/bash/commandRegistry.ts b/src/lib/stores/bash/commandRegistry.ts index 8097c27..87dc8f8 100644 --- a/src/lib/stores/bash/commandRegistry.ts +++ b/src/lib/stores/bash/commandRegistry.ts @@ -1,12 +1,13 @@ +import { isBuildCommand } from "typescript"; import type { KeyBind } from "../terminal/keybindRegistry"; import type { Bash, Result } from "./bash"; import { cd } from "./commands/cd"; import { clear } from "./commands/clear"; import { ls } from "./commands/ls"; -import { aSync } from "./commands/testAsync"; +import { testProcess } from "./commands/testAsync"; export type ICommand = { - method: (this: Bash, args: CommandArgs) => Promise; + method: (this: Bash, args: CommandArgs) => Result; keybinds?: Map any>; flags: string[]; help: string; @@ -28,7 +29,7 @@ export const COMMANDS = { cd, ls, clear, - aSync + testProcess } as const satisfies Record; /* //export const commands { diff --git a/src/lib/stores/bash/commands/ls.ts b/src/lib/stores/bash/commands/ls.ts index bef13ea..fedc211 100755 --- a/src/lib/stores/bash/commands/ls.ts +++ b/src/lib/stores/bash/commands/ls.ts @@ -38,7 +38,7 @@ const months: readonly string[] = [ 'Dec' ]; -export const cmd_ls = async function (this: Bash, args: CommandArgs): Promise { +export const cmd_ls = function (this: Bash, args: CommandArgs): Result { const Fs = this.getFs(); const resultData: CommandResultData = { cmd: 'ls', data: null, args: args }; const result: Result = { exitCode: ExitCode.ERROR, path: this.getCwd(), resultData: resultData }; @@ -80,16 +80,16 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement { const f_a: boolean = flagInfo.has('a') || flagInfo.has('all'); const f_A: boolean = flagInfo.has('A') || flagInfo.has('almost-all'); - const f_G: boolean = flagInfo.has('G') || flagInfo.has('no-group'); + //const f_G: boolean = flagInfo.has('G') || flagInfo.has('no-group'); const f_h: boolean = flagInfo.has('h') || flagInfo.has('human-readable'); const f_r: boolean = flagInfo.has('r') || flagInfo.has('reverse'); const f_R: boolean = flagInfo.has('R') || flagInfo.has('recursive'); - const f_Q: boolean = flagInfo.has('Q') || flagInfo.has('quote-name'); - const f_n: boolean = flagInfo.has('n') || flagInfo.has('numeric-uid-gid'); - const f_N: boolean = flagInfo.has('N') || flagInfo.has('literal'); - const f_L: boolean = flagInfo.has('L') || flagInfo.has('dereference'); + //const f_Q: boolean = flagInfo.has('Q') || flagInfo.has('quote-name'); + //const f_n: boolean = flagInfo.has('n') || flagInfo.has('numeric-uid-gid'); + //const f_N: boolean = flagInfo.has('N') || flagInfo.has('literal'); + //const f_L: boolean = flagInfo.has('L') || flagInfo.has('dereference'); const f_i: boolean = flagInfo.has('i') || flagInfo.has('inode'); - const f_help: boolean = flagInfo.has('help'); + //const f_help: boolean = flagInfo.has('help'); const f_si: boolean = flagInfo.has('si'); const f_X: boolean = flagInfo.has('X'); const f_S: boolean = flagInfo.has('S'); @@ -278,8 +278,8 @@ function isValidNodeTimestamp(value: string): value is SortNodeBy.ATIME | SortNo function parsePerms(perms: NodePerms): string { const parts: string[] = []; //for each key (key representing key name and p representing the key contents) of entries in perms as types keyof NodePerms and Permission - for (const [key, p] of Object.entries(perms) as [keyof NodePerms, Permission][]) { - const perms: string = `${p.r ? 'r' : '-'}${p.w ? 'w' : '-'}${p.x ? 'x' : '-'}`; + for (const [, permission] of Object.entries(perms) as [keyof NodePerms, Permission][]) { + const perms: string = `${permission.r ? 'r' : '-'}${permission.w ? 'w' : '-'}${permission.x ? 'x' : '-'}`; parts.push(perms); } return parts.join(''); @@ -371,25 +371,6 @@ function formatName(node: TreeNode, flag: any, shouldShift: boolean) { return flag.has('p') && node.type === Type.Directory ? `${name}/` : name; } -/* function formatOutputShort(node: TreeNode, flag: any) { - let output: string = node.name; - const char: string = flag.has('Q') ? '"' : "'"; - - if (/\s/.test(node.name)) { - if(flag.has('i')) { - - } - else { - output = `${char}${node.name}${char}`; - } - - if(flag.has('i')) { - output = `${node.inode} ${output}` - } - - return flag.has('p') && node.type === Type.Directory ? ` ${output}/ ` : output; -} */ - const checkFlags = (pFlags: string[]) => { const flagSet = new Set(pFlags); diff --git a/src/lib/stores/bash/commands/testAsync.ts b/src/lib/stores/bash/commands/testAsync.ts index ea2d06a..3d131f1 100644 --- a/src/lib/stores/bash/commands/testAsync.ts +++ b/src/lib/stores/bash/commands/testAsync.ts @@ -1,12 +1,16 @@ import type { KeyBind } from "$lib/stores/terminal/keybindRegistry"; +import { mount } from "svelte"; import { type Bash, type Result } from "../bash"; -import type { CommandArgs, ICommand } from "../commandRegistry"; +import type { CommandArgs, CommandResultData, ICommand } from "../commandRegistry"; import { ExitCode } from "../metadata"; +import Login from "../../../../modules/Login.svelte"; +import Loading from "../../../../modules/Loading.svelte"; -export const cmd_async = async function(this: Bash, args: CommandArgs): Promise { +export const cmd_process = function(this: Bash, args: CommandArgs): Result { let result: Result = { exitCode: ExitCode.ERROR, path: this.getCwd() }; - + const resultData: CommandResultData = { cmd: 'ls', data: null, args: args }; + result.resultData = resultData; result.exitCode = ExitCode.SUCCESS; return result; } @@ -28,8 +32,8 @@ const keybinds: Map any> = new Map([ [test_keybind,test] ]); -export const aSync: ICommand = { - method: cmd_async, +export const testProcess: ICommand = { + method: cmd_process, keybinds: keybinds, flags: [] as string[], help: 'PATH TO HELP.md', diff --git a/src/lib/stores/bash/process.ts b/src/lib/stores/bash/process.ts index 7d17baa..eb9b360 100644 --- a/src/lib/stores/bash/process.ts +++ b/src/lib/stores/bash/process.ts @@ -67,7 +67,7 @@ export class Process { } private async _Run(command: ICommand, bashInstance: Bash, args: CommandArgs) { - this._result = await command.method.call( + this._result = command.method.call( bashInstance, args); } diff --git a/src/lib/stores/terminal/terminal.ts b/src/lib/stores/terminal/terminal.ts index a702cb3..c966b90 100755 --- a/src/lib/stores/terminal/terminal.ts +++ b/src/lib/stores/terminal/terminal.ts @@ -1,3 +1,4 @@ +import type { BooleanLiteral } from 'typescript'; import { Bash, Signal, type BashInitArgs, type Result } from '../bash/bash'; import type { CommandArgs } from '../bash/commandRegistry'; import type { User } from '../bash/etc/userData'; @@ -5,7 +6,7 @@ import { VirtualFS, type TreeNode } from '../bash/fs'; import { KeybindInhibitor } from '../bash/keybindInhibitor'; import { ExitCode } from '../bash/metadata'; import type { Process } from '../bash/process'; -import { TERMINAL_KEYBINDS, type KeyStroke } from './keybindRegistry'; +import { TERMINAL_KEYBINDS, type KeyBind } from './keybindRegistry'; //import type { ILocale } from './localeRegistry'; export type TerminalMode = {}; @@ -37,13 +38,15 @@ export class Terminal { private _bash: Bash; private _callbacks: Partial = {}; private _keybindInhibitor: KeybindInhibitor; + + //public isProcessActive: boolean = false; //public locale: ILocale; constructor(args: TermInitArgs) { args.bash.io = this; this._bash = new Bash(args.bash); - const keybinds: Map any> = new Map([ + const keybinds: Map any> = new Map([ [TERMINAL_KEYBINDS.sigint,this._processKill] ]); @@ -62,6 +65,8 @@ export class Terminal { console.log("process kill successful"); }); + //this.isProcessActive = false; + return result; } diff --git a/src/modules/Login.svelte b/src/modules/Login.svelte index a281777..9283659 100644 --- a/src/modules/Login.svelte +++ b/src/modules/Login.svelte @@ -1,21 +1,55 @@
- -
- gornodox + +
+ + {event.currentTarget.innerText = username; event.currentTarget.classList.remove('switchR', 'switchL');}}>gornodox +
{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"> +
@@ -35,6 +69,45 @@ animation: fadeIn 0.2s forwards cubic-bezier(.4,.7,0,.99); } +.switchL { + animation: fadeSlideLeft 1s forwards cubic-bezier(.4,.7,0,.99); +} + +.switchR { + animation: fadeSlideRight 1s forwards cubic-bezier(.4,.7,0,.99); +} + + +@keyframes fadeSlideLeft { + 25% { + transform: translateX(-1rem); + opacity: 0; + } + 50% { + transform: translateX(1rem); + opacity: 0; + } + 75% { + transform: none; + opacity: 1; + } +} + +@keyframes fadeSlideRight { + 25% { + transform: translateX(1rem); + opacity: 0; + } + 50% { + transform: translateX(-1rem); + opacity: 0; + } + 100% { + transform: none; + opacity: 1; + } +} + @keyframes fadeIn { to { opacity: 1; diff --git a/src/modules/Terminal.svelte b/src/modules/Terminal.svelte index c909808..a0e34c5 100755 --- a/src/modules/Terminal.svelte +++ b/src/modules/Terminal.svelte @@ -16,13 +16,14 @@ terminal = await initTerminal({ username: 'gornodox', password}, callbackInit, 'en_US'); updateTerminal(); } catch (error) { - console.error('onMount trycatch failed', error); + console.error('terminal init failed', error); } runTerminal(); } function updateTerminal() { + //isProcessActive = terminal.isProcessActive; username = terminal!.getUser().username; cwd = terminal!.getCwd(); } @@ -107,6 +108,7 @@ let terminal: Terminal; let username: string = $state(''); let cwd: string = $state(''); + //let isProcessActive = $state(false); let inputValue = $state(''); diff --git a/src/modules/terminal/Input.svelte b/src/modules/terminal/Input.svelte index 2b09ac6..8ecf716 100755 --- a/src/modules/terminal/Input.svelte +++ b/src/modules/terminal/Input.svelte @@ -8,10 +8,26 @@ function handleInput(event: Event) { inputValue = (event.target as HTMLInputElement).value; } + + /* function moveCursor() { + + } + + function keyDown(event: KeyboardEvent) { + switch(event.key) { + case 'Enter': + inputValue = '' + case 'ArrowRight': + document.getElementById('cursor')?.style.transform = 'translateX(8px)' + case 'ArrowLeft': + + } + } */
e.key === 'Enter' && (inputValue = '')} oninput={handleInput} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0979627..a963020 100755 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,7 +9,7 @@ let { form, data } = $props(); - const MAINTENANCE = $state(Boolean(data.settings[0].setting)); + const MAINTENANCE = $derived(Boolean(data.settings[0].setting)); //export let isWelcomeSequence = false; diff --git a/src/routes/test/+page.svelte b/src/routes/test/+page.svelte index 5c8ba5b..5b28374 100755 --- a/src/routes/test/+page.svelte +++ b/src/routes/test/+page.svelte @@ -1,10 +1,9 @@ - -
-
- {}}/> -
-
-
\ No newline at end of file + + + + \ No newline at end of file