@innovatorved/code-lab 0.1.13 → 0.3.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 +12 -7
- package/CHANGELOG.md +134 -0
- package/README.md +59 -9
- package/dist/code-lab.css +198 -0
- package/dist/code-lab.d.ts +37 -7
- package/dist/code-lab.esm.js +20444 -1278
- package/dist/code-lab.js +20439 -1276
- package/dist/extensions/cpp.d.ts +145 -0
- package/dist/extensions/cpp.esm.js +5932 -0
- package/dist/extensions/cpp.js +5951 -0
- package/dist/extensions/guided-lab.esm.js +86 -6
- package/dist/extensions/guided-lab.js +87 -6
- package/dist/extensions/javascript.d.ts +24 -0
- package/dist/extensions/javascript.esm.js +36 -0
- package/dist/extensions/javascript.js +59 -0
- package/dist/extensions/python.d.ts +92 -0
- package/dist/extensions/python.esm.js +5476 -0
- package/dist/extensions/python.js +5495 -0
- package/dist/extensions/typescript.d.ts +36 -0
- package/dist/extensions/typescript.esm.js +55 -0
- package/dist/extensions/typescript.js +78 -0
- package/dist/index.d.ts +9 -3
- package/dist/preview-sw.js +1 -1
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/module-loader.d.ts +11 -0
- package/dist/runtime/test-harness.d.ts +24 -0
- package/dist/runtime/vfs.d.ts +31 -0
- package/dist/runtime/wasi-host.d.ts +33 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.esm.js +920 -15
- package/dist/runtime.js +914 -15
- package/dist/schemas.d.ts +237 -25
- package/dist/schemas.esm.js +85 -6
- package/dist/schemas.js +85 -6
- package/dist/shell/coreutils/compilers-cli.d.ts +24 -0
- package/dist/shell/index.d.ts +4 -0
- package/dist/shell/lexer-parser.d.ts +26 -0
- package/dist/shell.esm.js +289 -4
- package/dist/shell.js +289 -4
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/dist/workbench/command-palette.d.ts +10 -0
- package/dist/workbench/diff-editor.d.ts +26 -0
- package/dist/workbench/drawer.d.ts +18 -0
- package/dist/workbench/editor.d.ts +11 -0
- package/dist/workbench/file-tree.d.ts +11 -0
- package/dist/workbench/guided-pane.d.ts +11 -0
- package/dist/workbench/icons.d.ts +5 -0
- package/dist/workbench/index.d.ts +39 -0
- package/dist/workbench/share.d.ts +21 -0
- package/dist/workbench/styles.d.ts +4 -0
- package/dist/workbench/toolbar.d.ts +17 -0
- package/dist/workbench.d.ts +6 -1
- package/package.json +33 -3
- package/src/code-lab.css +198 -0
- package/src/extensions/cpp.ts +1786 -0
- package/src/extensions/guided-lab.ts +10 -0
- package/src/extensions/javascript.ts +54 -0
- package/src/extensions/python.ts +1293 -0
- package/src/extensions/typescript.ts +85 -0
- package/src/index.ts +66 -3
- package/src/runtime/index.ts +5 -0
- package/src/runtime/test-harness.ts +57 -0
- package/src/runtime.ts +915 -14
- package/src/schemas.ts +94 -7
- package/src/shell/coreutils/compilers-cli.ts +103 -0
- package/src/shell/index.ts +5 -0
- package/src/shell.ts +288 -3
- package/src/workbench/command-palette.ts +140 -0
- package/src/workbench/diff-editor.ts +216 -0
- package/src/workbench/drawer.ts +148 -0
- package/src/workbench/editor.ts +49 -0
- package/src/workbench/file-tree.ts +51 -0
- package/src/workbench/guided-pane.ts +33 -0
- package/src/workbench/icons.ts +48 -0
- package/src/workbench/index.ts +38 -0
- package/src/workbench/share.ts +99 -0
- package/src/workbench/styles.ts +200 -0
- package/src/workbench/toolbar.ts +171 -0
- package/src/workbench.ts +1016 -78
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { CppExtensionOptions } from '../schemas';
|
|
2
|
+
import type { DiagnosticItem } from '../diagnostics';
|
|
3
|
+
/**
|
|
4
|
+
* Built-in competitive programming & DSA headers seeded into `/usr/include`
|
|
5
|
+
* inside the VirtualFS alongside the WASI sysroot.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BUILTIN_CPP_HEADERS: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Extracts a POSIX UStar `.tar` archive into a `VirtualFS` instance.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractTarToVfs(tarBytes: Uint8Array, vfs: any, baseDir?: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a POSIX UStar `.tar` archive from a map of file paths to contents.
|
|
14
|
+
* Useful for packaging custom sysroot headers/libraries or testing TAR extraction.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTarArchive(files: Record<string, string | Uint8Array>): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Seeds built-in C++ headers (`<bits/stdc++.h>`, `<codelab/dsa.hpp>`, `<codelab/test.hpp>`)
|
|
19
|
+
* and any user-provided extra headers into a VirtualFS instance.
|
|
20
|
+
*/
|
|
21
|
+
export declare function seedCppHeadersIntoVfs(vfs: any, extraHeaders?: Record<string, string>): void;
|
|
22
|
+
export interface CppCompileRequest {
|
|
23
|
+
entry?: string;
|
|
24
|
+
sourceFiles?: string[];
|
|
25
|
+
outputPath?: string;
|
|
26
|
+
std?: 'c++17' | 'c++20' | 'c++23';
|
|
27
|
+
optLevel?: '-O0' | '-O1' | '-O2' | '-O3';
|
|
28
|
+
extraFlags?: string[];
|
|
29
|
+
vfs: any;
|
|
30
|
+
onStdout?: (text: string) => void;
|
|
31
|
+
onStderr?: (text: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface CppCompileResult {
|
|
34
|
+
ok: boolean;
|
|
35
|
+
exitCode: number;
|
|
36
|
+
wasmBinary: Uint8Array | null;
|
|
37
|
+
outputPath: string;
|
|
38
|
+
stdout: string;
|
|
39
|
+
stderr: string;
|
|
40
|
+
}
|
|
41
|
+
export declare const DEFAULT_CPP_CDN_BASE_URL = "https://cdn.jsdelivr.net/npm/@yowasp/clang";
|
|
42
|
+
export type CppCompileOptions = CppCompileRequest;
|
|
43
|
+
export type CppCompilerAdapter = CppToolchainManager;
|
|
44
|
+
export interface ExtendedCppExtensionOptions extends Partial<CppExtensionOptions> {
|
|
45
|
+
/**
|
|
46
|
+
* Pre-loaded `clang.wasm` binary (optional; bypasses network download).
|
|
47
|
+
*/
|
|
48
|
+
clangWasm?: Uint8Array;
|
|
49
|
+
/**
|
|
50
|
+
* Pre-loaded `lld.wasm` binary (optional; bypasses network download).
|
|
51
|
+
*/
|
|
52
|
+
lldWasm?: Uint8Array;
|
|
53
|
+
/**
|
|
54
|
+
* Pre-loaded `sysroot.tar` archive (optional; bypasses network download).
|
|
55
|
+
*/
|
|
56
|
+
sysrootTar?: Uint8Array;
|
|
57
|
+
/**
|
|
58
|
+
* Optional custom compilation hook `(req: CppCompileRequest) => Promise<CppCompileResult>`.
|
|
59
|
+
*/
|
|
60
|
+
compilerHook?: (req: CppCompileRequest) => Promise<CppCompileResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Immediately switch the active workbench language to 'cpp'.
|
|
63
|
+
*/
|
|
64
|
+
activate?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Manages downloading, IndexedDB caching (`codelab_cpp_toolchain_v1`), sysroot extraction,
|
|
68
|
+
* and 2-stage WASI Clang + LLD compilation (`clang.wasm` -> `lld.wasm` -> `.wasm` binary).
|
|
69
|
+
*/
|
|
70
|
+
export declare class CppToolchainManager {
|
|
71
|
+
options: CppExtensionOptions & ExtendedCppExtensionOptions;
|
|
72
|
+
clangWasm: Uint8Array | null;
|
|
73
|
+
lldWasm: Uint8Array | null;
|
|
74
|
+
sysrootTar: Uint8Array | null;
|
|
75
|
+
private _loadingPromise;
|
|
76
|
+
constructor(options?: ExtendedCppExtensionOptions);
|
|
77
|
+
private _emitProgress;
|
|
78
|
+
private _fetchAssetWithProgress;
|
|
79
|
+
ensureLoaded(): Promise<void>;
|
|
80
|
+
prepareVfs(vfs: any): void;
|
|
81
|
+
compile(req: CppCompileRequest): Promise<CppCompileResult>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parses POSIX shell arguments for `g++` / `clang++` / `c++` commands.
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseCppCompilerFlags(args: string[], cwd?: string): {
|
|
87
|
+
sourceFiles: string[];
|
|
88
|
+
outputPath: string;
|
|
89
|
+
std: "c++17" | "c++20" | "c++23";
|
|
90
|
+
optLevel: "-O0" | "-O1" | "-O2" | "-O3";
|
|
91
|
+
extraFlags: string[];
|
|
92
|
+
showVersion: boolean;
|
|
93
|
+
showHelp: boolean;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Registers the C++20 WebAssembly compiler toolchain on the global runtime and workbench.
|
|
97
|
+
*/
|
|
98
|
+
export declare function registerCppCompilerOnRuntime(toolchain: CppToolchainManager): (req: any) => Promise<{
|
|
99
|
+
ok: boolean;
|
|
100
|
+
exitCode: number;
|
|
101
|
+
wasmBinary: Uint8Array<ArrayBufferLike>;
|
|
102
|
+
outputPath: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Full C++20 standard library header set + built-in CodeLab headers.
|
|
106
|
+
*/
|
|
107
|
+
export declare const STANDARD_CPP20_HEADERS: ReadonlySet<string>;
|
|
108
|
+
export interface CppSymbolDoc {
|
|
109
|
+
label: string;
|
|
110
|
+
kind?: string;
|
|
111
|
+
detail: string;
|
|
112
|
+
documentation: string;
|
|
113
|
+
insertText?: string;
|
|
114
|
+
header?: string;
|
|
115
|
+
complexity?: string;
|
|
116
|
+
}
|
|
117
|
+
export declare const CPP_COMPLETIONS_AND_HOVERS: Record<string, CppSymbolDoc>;
|
|
118
|
+
/**
|
|
119
|
+
* Registers Monaco C++20 completion and hover providers.
|
|
120
|
+
*/
|
|
121
|
+
export declare function registerMonacoCppLanguageService(monacoInstance: any): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Real-time C++20 static AST/syntax linter.
|
|
124
|
+
* Debounced on keystroke in `.cpp`, `.cc`, `.cxx`, `.hpp`, `.h` files.
|
|
125
|
+
*/
|
|
126
|
+
export declare function analyzeCppSource(source: string, filename?: string, vfs?: any): DiagnosticItem[];
|
|
127
|
+
/**
|
|
128
|
+
* Parses Clang / LLVM WASI compiler stderr and applies diagnostics to Monaco and DiagnosticsStore.
|
|
129
|
+
*/
|
|
130
|
+
export declare function applyClangStderrDiagnostics(stderrText: string, diagnosticsStore?: any, monacoInstance?: any, activeModel?: any): DiagnosticItem[];
|
|
131
|
+
/**
|
|
132
|
+
* Real C++20 in WebAssembly Extension for CodeLab (`@innovatorved/code-lab/extensions/cpp`).
|
|
133
|
+
*
|
|
134
|
+
* Enables:
|
|
135
|
+
* - Real Clang/LLVM + LLD + WASI C++20 compilation in WebAssembly (~35 MB downloaded on demand & cached in IndexedDB)
|
|
136
|
+
* - `<bits/stdc++.h>`, `<codelab/dsa.hpp>`, and `<codelab/test.hpp>` headers in VirtualFS
|
|
137
|
+
* - `JS | TS | C++` language switcher in the CodeLab workbench
|
|
138
|
+
* - `g++`, `clang++`, `c++`, and `./a.out` binary execution in the POSIX shell
|
|
139
|
+
* - Guided Lab `cppStarterFiles`, `cppSolutionFiles`, and `cppFiles` curriculum support
|
|
140
|
+
* - Monaco IntelliSense, hovers, debounced C++20 static linter, and Clang compiler squiggles
|
|
141
|
+
*/
|
|
142
|
+
export declare function installCppExtension(workbench: any, options?: ExtendedCppExtensionOptions): any;
|
|
143
|
+
export declare function cppExtension(workbenchOrOptions?: any, maybeOptions?: ExtendedCppExtensionOptions): any;
|
|
144
|
+
export declare function createCppExtension(options?: ExtendedCppExtensionOptions): any;
|
|
145
|
+
export default cppExtension;
|