unsable code rework, doesnt run
This commit is contained in:
43
src/lib/stores/terminal/stdio/io.ts
Executable file
43
src/lib/stores/terminal/stdio/io.ts
Executable file
@@ -0,0 +1,43 @@
|
||||
import { mount, unmount } from 'svelte';
|
||||
import Output from '../../../../modules/terminal/Output.svelte';
|
||||
import { isInitializing } from '../init.svelte';
|
||||
import type { PrintData } from '../terminal';
|
||||
|
||||
interface OutputProps {
|
||||
path: string;
|
||||
output: any;
|
||||
cmd: string;
|
||||
}
|
||||
|
||||
const outputInstances = new Set<Output>();
|
||||
|
||||
function appendOutput(container: HTMLElement, props: OutputProps): Output | undefined {
|
||||
if (!container) return;
|
||||
const instance = mount(Output, {
|
||||
target: container,
|
||||
props
|
||||
});
|
||||
|
||||
outputInstances.add(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
export function print(e: HTMLElement, data: PrintData): void {
|
||||
if(data.cmd == 'clear') return;
|
||||
|
||||
if (isInitializing()) {
|
||||
console.error('Terminal is initializing! Skipping Print');
|
||||
return;
|
||||
}
|
||||
appendOutput(e, {
|
||||
path: data.path,
|
||||
output: data.output,
|
||||
cmd: data.cmd
|
||||
});
|
||||
}
|
||||
|
||||
export function clear(): void {
|
||||
for(const instance of outputInstances) {
|
||||
unmount(instance, {});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user