@innovatorved/code-lab 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +114 -0
- package/LICENSE +21 -0
- package/README.md +156 -0
- package/dist/code-lab.css +4100 -0
- package/dist/code-lab.d.ts +348 -0
- package/dist/code-lab.esm.js +21954 -0
- package/dist/code-lab.js +21933 -0
- package/dist/extensions/guided-lab.d.ts +13 -0
- package/dist/extensions/guided-lab.esm.js +4218 -0
- package/dist/extensions/guided-lab.js +4236 -0
- package/dist/index.d.ts +11 -0
- package/dist/preview-sw.js +149 -0
- package/dist/runtime.d.ts +48 -0
- package/dist/runtime.esm.js +7510 -0
- package/dist/runtime.js +7491 -0
- package/dist/sample.html +304 -0
- package/dist/schemas.d.ts +514 -0
- package/dist/shell.d.ts +66 -0
- package/dist/shell.esm.js +6405 -0
- package/dist/shell.js +6384 -0
- package/dist/terminal.d.ts +102 -0
- package/dist/terminal.esm.js +1083 -0
- package/dist/terminal.js +1072 -0
- package/dist/workbench.d.ts +1 -0
- package/package.json +98 -0
- package/src/code-lab.css +4100 -0
- package/src/extensions/guided-lab.ts +54 -0
- package/src/index.ts +28 -0
- package/src/preview-sw.js +149 -0
- package/src/runtime.js +7465 -0
- package/src/runtime.ts +7512 -0
- package/src/sample.html +304 -0
- package/src/schemas.ts +177 -0
- package/src/shell.js +6358 -0
- package/src/shell.ts +6456 -0
- package/src/terminal.js +1046 -0
- package/src/terminal.ts +1097 -0
- package/src/workbench.js +6987 -0
- package/src/workbench.ts +6988 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @innovatorved/code-lab - Pure-JS/TS PTY Terminal Emulator Component
|
|
3
|
+
*
|
|
4
|
+
* High-fidelity, self-contained terminal emulator engine providing:
|
|
5
|
+
* - Inline prompt with cwd awareness (codelab:${cwd}$ )
|
|
6
|
+
* - Interactive REPL sub-mode (> ) with .exit and Ctrl+D/Ctrl+C
|
|
7
|
+
* - Character-by-character editing with cursor navigation:
|
|
8
|
+
* ArrowLeft, ArrowRight, Home, End, Ctrl+A, Ctrl+E, Ctrl+U, Ctrl+K, Backspace, Delete
|
|
9
|
+
* - Tab auto-completion for built-in commands and VFS filesystem paths
|
|
10
|
+
* - History navigation (ArrowUp, ArrowDown)
|
|
11
|
+
* - ANSI 16/256 SGR escape sequence translation to styled Geist HTML spans
|
|
12
|
+
* - Headless DOM safety (defensive guards for Node.js test environments)
|
|
13
|
+
*
|
|
14
|
+
* (C) 2026 InnovatorVed / CodeLab. MIT License.
|
|
15
|
+
*/
|
|
16
|
+
export interface TerminalLogItem {
|
|
17
|
+
text: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CompletionResult {
|
|
21
|
+
matches: string[];
|
|
22
|
+
token: string;
|
|
23
|
+
tokenStart: number;
|
|
24
|
+
}
|
|
25
|
+
export interface TerminalOptions {
|
|
26
|
+
container?: any;
|
|
27
|
+
logs?: TerminalLogItem[];
|
|
28
|
+
cwd?: string;
|
|
29
|
+
replMode?: boolean;
|
|
30
|
+
prompt?: string | null;
|
|
31
|
+
history?: string[];
|
|
32
|
+
onCommand?: ((command: string) => void) | null;
|
|
33
|
+
getCompletions?: ((buffer: string, cursor: number) => CompletionResult | null) | null;
|
|
34
|
+
onKey?: ((event: any) => boolean | void) | null;
|
|
35
|
+
onInterrupt?: (() => void) | null;
|
|
36
|
+
}
|
|
37
|
+
export declare const ANSI_CODE_MAP: Record<number, string>;
|
|
38
|
+
export declare const ANSI_256_PALETTE: string[];
|
|
39
|
+
export declare function ansi256ToColor(n: number | string): string | null;
|
|
40
|
+
export declare function escapeHtml(str: any): string;
|
|
41
|
+
export declare function resolveAnsiControlCodes(raw: any): string;
|
|
42
|
+
export declare function ansiToHtml(str: any): string;
|
|
43
|
+
export declare const parseAnsiToHtml: typeof ansiToHtml;
|
|
44
|
+
export declare class PTYTerminalEngine {
|
|
45
|
+
container: any;
|
|
46
|
+
options: TerminalOptions;
|
|
47
|
+
logs: TerminalLogItem[];
|
|
48
|
+
cwd: string;
|
|
49
|
+
replMode: boolean;
|
|
50
|
+
promptOverride: string | null;
|
|
51
|
+
history: string[];
|
|
52
|
+
historyIdx: number;
|
|
53
|
+
savedBuffer: string;
|
|
54
|
+
buffer: string;
|
|
55
|
+
cursor: number;
|
|
56
|
+
searchMode: boolean;
|
|
57
|
+
searchQuery: string;
|
|
58
|
+
searchMatchIdx: number;
|
|
59
|
+
_readLineQueue: Array<(line: string) => void>;
|
|
60
|
+
onCommand: ((command: string) => void) | null;
|
|
61
|
+
getCompletions: ((buffer: string, cursor: number) => CompletionResult | null) | null;
|
|
62
|
+
onKey: ((event: any) => boolean | void) | null;
|
|
63
|
+
onInterrupt: (() => void) | null;
|
|
64
|
+
_activeLineCommitted: boolean;
|
|
65
|
+
_cursorCol: number;
|
|
66
|
+
_pendingEscape: string;
|
|
67
|
+
_targetLineIdx: number;
|
|
68
|
+
_needsRewrite: boolean;
|
|
69
|
+
_activeLineEl: any;
|
|
70
|
+
_mounted: boolean;
|
|
71
|
+
_listeners: Array<any>;
|
|
72
|
+
constructor(container?: any, options?: TerminalOptions);
|
|
73
|
+
getPrompt(): string;
|
|
74
|
+
setPrompt(p: string | null): void;
|
|
75
|
+
setCwd(cwd: string): void;
|
|
76
|
+
setReplMode(enabled: boolean): void;
|
|
77
|
+
writeStreamChunk(data: any, type?: string): void;
|
|
78
|
+
write(data: any, type?: string): void;
|
|
79
|
+
writeln(data: any, type?: string): void;
|
|
80
|
+
_getActiveLine(type: string): TerminalLogItem;
|
|
81
|
+
_appendDomLine(line: TerminalLogItem): void;
|
|
82
|
+
_updateActiveDomLine(): void;
|
|
83
|
+
_getActiveLineSync(): TerminalLogItem | null;
|
|
84
|
+
_scrollToBottom(): void;
|
|
85
|
+
clear(): void;
|
|
86
|
+
getHistory(): string[];
|
|
87
|
+
readLine(promptText?: string): Promise<string>;
|
|
88
|
+
focus(): void;
|
|
89
|
+
mount(container: any): void;
|
|
90
|
+
_cleanupListeners(): void;
|
|
91
|
+
destroy(): void;
|
|
92
|
+
_addListener(target: any, type: string, handler: any): void;
|
|
93
|
+
_bindEvents(): void;
|
|
94
|
+
_findReverseSearchMatch(query: string, startIdx?: number): number;
|
|
95
|
+
handleKeyDown(e: any): void;
|
|
96
|
+
autoComplete(): void;
|
|
97
|
+
submitLine(): void;
|
|
98
|
+
updateActiveLine(): void;
|
|
99
|
+
render(): void;
|
|
100
|
+
}
|
|
101
|
+
export declare function createTerminal(container?: any, options?: TerminalOptions): PTYTerminalEngine;
|
|
102
|
+
export declare const createPTYTerminalEngine: typeof createTerminal;
|