WIP: new abstraction layer, file system now a singleton, shell should be too

This commit is contained in:
2026-05-13 17:56:19 +02:00
parent 106abd851a
commit 619de5e1f8
24 changed files with 628 additions and 302 deletions
+22 -20
View File
@@ -1,11 +1,9 @@
<script lang="ts">
import { Terminal, type PrintData } from '$lib/stores/terminal/terminal';
import { onMount } from 'svelte';
import Input from './terminal/Input.svelte';
import { initTerminal, isInitializing } from '$lib/stores/terminal/init.svelte';
import { clear, print } from '$lib/stores/terminal/stdio/io';
import type { User } from '$lib/stores/bash/etc/userData';
import { ExitCode } from '$lib/stores/bash/metadata';
import { initTerminal } from '$lib/stores/terminal/init.svelte';
import { clear, print } from '$lib/stores/terminal/stdio/io';
import { Terminal, type PrintData } from '$lib/stores/terminal/terminal';
import Input from './terminal/Input.svelte';
const clearTerminal = (): void => clear();
@@ -13,7 +11,7 @@
export async function init(username: string, password: string) {
try {
terminal = await initTerminal({username, password}, callbackInit, 'en_US');
terminal = await initTerminal({ username, password }, callbackInit, 'en_US');
updateTerminal();
} catch (error) {
console.error('terminal init failed', error);
@@ -30,23 +28,25 @@
function getWidth() {
const e = document.getElementById('cout');
if(!e){
if (!e) {
throw new Error('cant get width of the teminal element. Its null');
}
//gets an int from padding property value (which is a string) by cutting last 2 letters "px" and parsing to int
const padding: number = parseInt(window.getComputedStyle(e, null).getPropertyValue('padding').slice(0, -2));
return e.clientWidth - (padding * 2);
const padding: number = parseInt(
window.getComputedStyle(e, null).getPropertyValue('padding').slice(0, -2)
);
return e.clientWidth - padding * 2;
}
function getFontSize() {
const e = document.getElementById('cout');
if(!e) {
if (!e) {
throw new Error('cant get font size of the terminal element. its null');
}
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d')!;
ctx.font = `${window.getComputedStyle(e, null).getPropertyValue('font-size')} 'JetBrains Mono', monospace;`;
const ctx = canvas.getContext('2d')!;
ctx.font = `${window.getComputedStyle(e, null).getPropertyValue('font-size')} 'JetBrains Mono', monospace;`;
return ctx.measureText('M').width;
}
@@ -55,7 +55,7 @@
terminalKeyInhibitor.processKeystroke(event);
const processKeyInhibitor = terminal.getProcessKeyInhibitor();
if(processKeyInhibitor != ExitCode.ERROR) {
if (processKeyInhibitor != ExitCode.ERROR) {
processKeyInhibitor.processKeystroke(event);
}
@@ -81,7 +81,7 @@
}
const elem = document.getElementById('cout');
if(!elem){
if (!elem) {
throw new Error('cant scroll to bottom, element is null');
}
@@ -111,11 +111,13 @@
//let isProcessActive = $state(false);
let inputValue = $state<string>('');
</script>
<label for="input" onkeydowncapture={(event) => inputHandler(event)} class="w-11/12">
<div id="terminal" class=" transition-discrete terminal-window shadow-() h-full w-full rounded-md shadow-bg">
<div
id="terminal"
class=" terminal-window shadow-() h-full w-full rounded-md shadow-bg transition-discrete"
>
<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"
>
@@ -124,7 +126,7 @@
<button class="size-2.5 cursor-pointer rounded-full p-0" title=""></button>
<button class="size-2.5 cursor-pointer rounded-full p-0" title=""></button>
</div>
<div class=" flex mr-2 grow">
<div class=" mr-2 flex grow">
<h5>{username}</h5>
<!-- prettier-ignore -->
<h5 class=" mr-2">@terminal: </h5>
@@ -153,8 +155,8 @@
to {
opacity: 1;
display: block;
}
}
}
}
.dots-wrapper {
& > button {
border: none;