a bit of front-end work, changing users almost done on login, "drunk-code" no more (id hope), continuous processes and keybinds still not done.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "svelte-portfolio",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.69",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -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: {
|
||||
|
||||
@@ -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<Result>;
|
||||
method: (this: Bash, args: CommandArgs) => Result;
|
||||
keybinds?: Map<KeyBind, () => any>;
|
||||
flags: string[];
|
||||
help: string;
|
||||
@@ -28,7 +29,7 @@ export const COMMANDS = {
|
||||
cd,
|
||||
ls,
|
||||
clear,
|
||||
aSync
|
||||
testProcess
|
||||
} as const satisfies Record<string, ICommand>;
|
||||
|
||||
/* //export const commands {
|
||||
|
||||
@@ -38,7 +38,7 @@ const months: readonly string[] = [
|
||||
'Dec'
|
||||
];
|
||||
|
||||
export const cmd_ls = async function (this: Bash, args: CommandArgs): Promise<Result> {
|
||||
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);
|
||||
|
||||
|
||||
@@ -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<Result> {
|
||||
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<KeyBind, () => 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',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<PageCallbacks> = {};
|
||||
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<KeyStroke, () => any> = new Map([
|
||||
const keybinds: Map<KeyBind, () => 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,55 @@
|
||||
<script lang="ts">
|
||||
import { enhance } from "$app/forms";
|
||||
import { ArrowRight, CircleAlert, Lock } from "@lucide/svelte";
|
||||
import { PASSWD } from "$lib/stores/bash/etc/userData";
|
||||
import { ArrowRight, ChevronLeft, ChevronRight, CircleAlert, Lock } from "@lucide/svelte";
|
||||
import type { effect } from "zod/v3";
|
||||
|
||||
let formElem: HTMLElement;
|
||||
let {init, form}: { init: (formData: FormData) => void, form: any} = $props();
|
||||
|
||||
const basePath: string = '/src/lib/assets/login/';
|
||||
|
||||
let userIndex: number = $state(3);
|
||||
|
||||
$inspect(userIndex);
|
||||
|
||||
let username: string = $state('gornodox');
|
||||
let userImage: string = $derived(`${basePath}${username}.png`);
|
||||
|
||||
function changeUser(direction: 0 | 1) {
|
||||
if(direction === 0) {
|
||||
userIndex--;
|
||||
document.getElementById('username')?.classList.add('switchR');
|
||||
}
|
||||
else {
|
||||
userIndex++;
|
||||
document.getElementById('username')?.classList.add('switchL');
|
||||
}
|
||||
if(userIndex >= PASSWD.length) userIndex = 0;
|
||||
if(userIndex < 0) userIndex = PASSWD.length - 1;
|
||||
|
||||
|
||||
|
||||
const user = PASSWD[userIndex];
|
||||
username = user.username;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="wrapper" class=" 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>
|
||||
<img class="rounded-full mb-4 border-primary-dark border-2" src={userImage} alt="" width="80" height="80" />
|
||||
<div id="name" class=" relative flex flex-row items-center text-text-muted-dark justify-center gap-4 w-1/2">
|
||||
<button onclick={() => changeUser(0)}
|
||||
class=" active:-translate-x-0.5 hover:text-primary-hover-dark"><ChevronLeft size={16} strokeWidth={2} /></button>
|
||||
<strong id="username" class=" mx-auto" onanimationend={(event) => {event.currentTarget.innerText = username; event.currentTarget.classList.remove('switchR', 'switchL');}}>gornodox</strong>
|
||||
<button onclick={() => changeUser(1)}
|
||||
class=" active:translate-x-0.5 hover:text-primary-hover-dark"><ChevronRight size={16} strokeWidth={2} /></button>
|
||||
</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">
|
||||
<input name="username" value={username} class=" hidden ">
|
||||
<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">
|
||||
@@ -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;
|
||||
|
||||
@@ -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<string>('');
|
||||
|
||||
|
||||
@@ -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':
|
||||
|
||||
}
|
||||
} */
|
||||
</script>
|
||||
|
||||
<div class=" relative">
|
||||
<input
|
||||
autofocus
|
||||
bind:value={inputValue}
|
||||
onkeydown={(e) => e.key === 'Enter' && (inputValue = '')}
|
||||
oninput={handleInput}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
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>
|
||||
|
||||
|
||||
|
||||
<Login />
|
||||
Reference in New Issue
Block a user