@innovatorved/code-lab 0.3.1 → 0.4.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 +8 -4
- package/CHANGELOG.md +45 -0
- package/README.md +70 -158
- package/dist/apps/web/src/index.d.ts +34 -0
- package/dist/code-lab-sql.css +482 -0
- package/dist/code-lab-sql.d.ts +179 -0
- package/dist/code-lab-sql.esm.js +542 -0
- package/dist/code-lab-sql.umd.js +531 -0
- package/dist/code-lab.css +298 -2
- package/dist/code-lab.d.ts +110 -15
- package/dist/code-lab.esm.js +35284 -18253
- package/dist/code-lab.js +40434 -23431
- package/dist/code-lab.umd.js +65502 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/extensions/cpp.esm.js +19532 -3772
- package/dist/extensions/cpp.js +19529 -3769
- package/dist/extensions/guided-lab.esm.js +19401 -3725
- package/dist/extensions/guided-lab.js +19400 -3724
- package/dist/extensions/python.d.ts +1 -0
- package/dist/extensions/python.esm.js +19666 -3843
- package/dist/extensions/python.js +19668 -3845
- package/dist/extensions/umbrella.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/modular-kernel.d.ts +11 -0
- package/dist/packages/commands/src/index.d.ts +96 -0
- package/dist/packages/core/src/di.d.ts +36 -0
- package/dist/packages/core/src/disposable.d.ts +27 -0
- package/dist/packages/core/src/errors.d.ts +69 -0
- package/dist/packages/core/src/events.d.ts +38 -0
- package/dist/packages/core/src/index.d.ts +6 -0
- package/dist/packages/core/src/path.d.ts +14 -0
- package/dist/packages/core/src/registry.d.ts +23 -0
- package/dist/packages/editor/src/index.d.ts +118 -0
- package/dist/packages/fs/src/backends.d.ts +37 -0
- package/dist/packages/fs/src/index.d.ts +3 -0
- package/dist/packages/fs/src/types.d.ts +40 -0
- package/dist/packages/fs/src/vfs-service.d.ts +33 -0
- package/dist/packages/preview/src/index.d.ts +34 -0
- package/dist/packages/runtime/src/index.d.ts +47 -0
- package/dist/packages/settings/src/builtin-schemas.d.ts +15 -0
- package/dist/packages/settings/src/configuration-service.d.ts +100 -0
- package/dist/packages/settings/src/index.d.ts +4 -0
- package/dist/packages/settings/src/jsonc.d.ts +20 -0
- package/dist/packages/settings/src/schema.d.ts +28 -0
- package/dist/packages/sql/src/completions.d.ts +8 -0
- package/dist/packages/sql/src/diagnostics.d.ts +2 -0
- package/dist/packages/sql/src/formatter.d.ts +2 -0
- package/dist/packages/sql/src/index.d.ts +7 -0
- package/dist/packages/sql/src/sql-editor.d.ts +2 -0
- package/dist/packages/sql/src/styles.d.ts +2 -0
- package/dist/packages/sql/src/tokenizer.d.ts +13 -0
- package/dist/packages/sql/src/types.d.ts +130 -0
- package/dist/packages/terminal/src/index.d.ts +54 -0
- package/dist/packages/ui/src/index.d.ts +4 -0
- package/dist/packages/ui/src/observability.d.ts +22 -0
- package/dist/packages/ui/src/plugin-registry.d.ts +89 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +25 -0
- package/dist/packages/ui/src/themes.d.ts +35 -0
- package/dist/preview-sw.js +82 -24
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.esm.js +503 -73
- package/dist/runtime.js +501 -73
- package/dist/schemas.d.ts +234 -814
- package/dist/schemas.esm.js +19401 -3725
- package/dist/schemas.js +19404 -3728
- package/dist/scm.d.ts +13 -2
- package/dist/search.d.ts +5 -1
- package/dist/shell.d.ts +1 -1
- package/dist/shell.esm.js +435 -54
- package/dist/shell.js +435 -54
- package/dist/terminal.esm.js +242 -54
- package/dist/terminal.js +242 -54
- package/dist/workbench/diff-editor.d.ts +1 -0
- package/dist/workbench/index.d.ts +1 -1
- package/dist/workbench/styles.d.ts +1 -1
- package/dist/zip.d.ts +4 -3
- package/package.json +37 -8
- package/packages/commands/README.md +7 -0
- package/packages/commands/package.json +16 -0
- package/packages/commands/src/index.ts +467 -0
- package/packages/commands/tsconfig.json +22 -0
- package/packages/core/README.md +12 -0
- package/packages/core/package.json +13 -0
- package/packages/core/src/di.ts +147 -0
- package/packages/core/src/disposable.ts +112 -0
- package/packages/core/src/errors.ts +205 -0
- package/packages/core/src/events.ts +157 -0
- package/packages/core/src/index.ts +49 -0
- package/packages/core/src/path.ts +118 -0
- package/packages/core/src/registry.ts +61 -0
- package/packages/core/tsconfig.json +19 -0
- package/packages/editor/README.md +9 -0
- package/packages/editor/package.json +18 -0
- package/packages/editor/src/index.ts +344 -0
- package/packages/editor/tsconfig.json +24 -0
- package/packages/fs/README.md +7 -0
- package/packages/fs/package.json +16 -0
- package/packages/fs/src/backends.ts +301 -0
- package/packages/fs/src/index.ts +18 -0
- package/packages/fs/src/types.ts +44 -0
- package/packages/fs/src/vfs-service.ts +257 -0
- package/packages/fs/tsconfig.json +22 -0
- package/packages/preview/README.md +3 -0
- package/packages/preview/package.json +16 -0
- package/packages/preview/src/index.ts +125 -0
- package/packages/preview/tsconfig.json +22 -0
- package/packages/runtime/README.md +3 -0
- package/packages/runtime/package.json +17 -0
- package/packages/runtime/src/index.ts +134 -0
- package/packages/runtime/tsconfig.json +23 -0
- package/packages/settings/README.md +7 -0
- package/packages/settings/package.json +16 -0
- package/packages/settings/src/builtin-schemas.ts +235 -0
- package/packages/settings/src/configuration-service.ts +543 -0
- package/packages/settings/src/index.ts +37 -0
- package/packages/settings/src/jsonc.ts +189 -0
- package/packages/settings/src/schema.ts +164 -0
- package/packages/settings/tsconfig.json +22 -0
- package/packages/sql/README.md +12 -0
- package/packages/sql/package.json +13 -0
- package/packages/sql/src/completions.ts +359 -0
- package/packages/sql/src/diagnostics.ts +200 -0
- package/packages/sql/src/formatter.ts +271 -0
- package/packages/sql/src/index.ts +54 -0
- package/packages/sql/src/sql-editor.ts +802 -0
- package/packages/sql/src/styles.ts +501 -0
- package/packages/sql/src/tokenizer.ts +457 -0
- package/packages/sql/src/types.ts +148 -0
- package/packages/sql/tsconfig.json +19 -0
- package/packages/terminal/README.md +3 -0
- package/packages/terminal/package.json +16 -0
- package/packages/terminal/src/index.ts +183 -0
- package/packages/terminal/tsconfig.json +22 -0
- package/packages/ui/README.md +8 -0
- package/packages/ui/package.json +18 -0
- package/packages/ui/src/index.ts +36 -0
- package/packages/ui/src/observability.ts +175 -0
- package/packages/ui/src/plugin-registry.ts +274 -0
- package/packages/ui/src/settings-dialog.ts +293 -0
- package/packages/ui/src/themes.ts +174 -0
- package/packages/ui/tsconfig.json +24 -0
- package/src/code-lab.css +298 -2
- package/src/csp.ts +7 -10
- package/src/diagnostics.ts +42 -3
- package/src/extensions/cpp.ts +105 -24
- package/src/extensions/python.ts +260 -116
- package/src/extensions/umbrella.ts +5 -0
- package/src/index.ts +1 -1
- package/src/modular-kernel.ts +11 -0
- package/src/preview-sw.js +73 -12
- package/src/runtime.ts +501 -74
- package/src/schemas.ts +62 -62
- package/src/scm.ts +106 -19
- package/src/search.ts +71 -27
- package/src/shell.ts +433 -53
- package/src/terminal.ts +239 -52
- package/src/workbench/diff-editor.ts +106 -18
- package/src/workbench/drawer.ts +17 -4
- package/src/workbench/guided-pane.ts +12 -2
- package/src/workbench/icons.ts +5 -2
- package/src/workbench/share.ts +37 -8
- package/src/workbench/styles.ts +2 -1
- package/src/workbench/toolbar.ts +15 -4
- package/src/workbench.ts +2877 -284
- package/src/zip.ts +29 -7
- package/dist/runtime/index.d.ts +0 -4
- package/dist/shell/coreutils/compilers-cli.d.ts +0 -24
- package/dist/shell/index.d.ts +0 -4
- package/src/runtime/index.ts +0 -5
- package/src/shell/coreutils/compilers-cli.ts +0 -103
- package/src/shell/index.ts +0 -5
package/src/workbench/icons.ts
CHANGED
|
@@ -43,6 +43,9 @@ export const CL_ICONS: Record<string, string> = {
|
|
|
43
43
|
warning: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',
|
|
44
44
|
clock: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',
|
|
45
45
|
memory: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 19v2"/><path d="M10 19v2"/><path d="M14 19v2"/><path d="M18 19v2"/><path d="M6 3v2"/><path d="M10 3v2"/><path d="M14 3v2"/><path d="M18 3v2"/><rect x="2" y="5" width="20" height="14" rx="2"/></svg>',
|
|
46
|
-
keyboard: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M6 12h.01"/><path d="M10 12h.01"/><path d="M14 12h.01"/><path d="M18 12h.01"/><path d="M7 16h10"/></svg>',
|
|
47
|
-
share: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>'
|
|
46
|
+
keyboard: '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M6 12h.01"/><path d="M10 12h.01"/><path d="M14 12h.01"/><path d="M18 12h.01"/><path d="M7 16h10"/></svg>',
|
|
47
|
+
share: '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>',
|
|
48
|
+
layout: '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',
|
|
49
|
+
maximize: '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',
|
|
50
|
+
settings: '<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>'
|
|
48
51
|
};
|
package/src/workbench/share.ts
CHANGED
|
@@ -61,6 +61,8 @@ export async function compressWorkspaceSnapshot(payload: WorkspaceSharePayload):
|
|
|
61
61
|
return bufferToBase64Url(rawBytes);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
const MAX_DECOMPRESSED_SNAPSHOT_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
65
|
+
|
|
64
66
|
/**
|
|
65
67
|
* Decompresses a Base64url string into workspace snapshot payload.
|
|
66
68
|
*/
|
|
@@ -68,28 +70,55 @@ export async function decompressWorkspaceSnapshot(encoded: string): Promise<Work
|
|
|
68
70
|
if (!encoded || typeof encoded !== 'string') return null;
|
|
69
71
|
try {
|
|
70
72
|
const bytes = base64UrlToBuffer(encoded);
|
|
73
|
+
if (bytes.byteLength > MAX_DECOMPRESSED_SNAPSHOT_BYTES) {
|
|
74
|
+
throw new Error('Snapshot payload exceeds maximum allowed size');
|
|
75
|
+
}
|
|
71
76
|
|
|
72
77
|
if (typeof DecompressionStream !== 'undefined') {
|
|
73
78
|
try {
|
|
74
79
|
const ds = new DecompressionStream('deflate-raw');
|
|
75
80
|
const writer = ds.writable.getWriter();
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
const writeInput = new Uint8Array(bytes.byteLength);
|
|
82
|
+
writeInput.set(bytes);
|
|
83
|
+
writer.write(writeInput).catch(() => {});
|
|
84
|
+
writer.close().catch(() => {});
|
|
78
85
|
|
|
79
|
-
const
|
|
80
|
-
const
|
|
86
|
+
const reader = ds.readable.getReader();
|
|
87
|
+
const chunks: Uint8Array[] = [];
|
|
88
|
+
let totalLength = 0;
|
|
89
|
+
while (true) {
|
|
90
|
+
const step = await reader.read();
|
|
91
|
+
if (step.done) break;
|
|
92
|
+
const chunk = step.value;
|
|
93
|
+
if (chunk) {
|
|
94
|
+
totalLength += chunk.byteLength;
|
|
95
|
+
if (totalLength > MAX_DECOMPRESSED_SNAPSHOT_BYTES) {
|
|
96
|
+
await reader.cancel().catch(() => {});
|
|
97
|
+
throw new Error('Decompressed snapshot exceeds 5 MB safety limit');
|
|
98
|
+
}
|
|
99
|
+
chunks.push(chunk);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const decompressed = new Uint8Array(totalLength);
|
|
103
|
+
let offset = 0;
|
|
104
|
+
for (const chunk of chunks) {
|
|
105
|
+
decompressed.set(chunk, offset);
|
|
106
|
+
offset += chunk.byteLength;
|
|
107
|
+
}
|
|
81
108
|
const text = new TextDecoder().decode(decompressed);
|
|
82
|
-
return JSON.parse(text);
|
|
109
|
+
return JSON.parse(text) as WorkspaceSharePayload;
|
|
83
110
|
} catch (err) {
|
|
111
|
+
if (err instanceof Error && err.message.includes('safety limit')) {
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
84
114
|
// Fallback for uncompressed raw JSON payload
|
|
85
|
-
void err;
|
|
86
115
|
const rawText = new TextDecoder().decode(bytes);
|
|
87
|
-
return JSON.parse(rawText);
|
|
116
|
+
return JSON.parse(rawText) as WorkspaceSharePayload;
|
|
88
117
|
}
|
|
89
118
|
}
|
|
90
119
|
|
|
91
120
|
const rawText = new TextDecoder().decode(bytes);
|
|
92
|
-
return JSON.parse(rawText);
|
|
121
|
+
return JSON.parse(rawText) as WorkspaceSharePayload;
|
|
93
122
|
} catch (err) {
|
|
94
123
|
if (typeof console !== 'undefined' && console.warn) {
|
|
95
124
|
console.warn('[CodeLab Share Snapshot Restore Error]:', err);
|
package/src/workbench/styles.ts
CHANGED
package/src/workbench/toolbar.ts
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { CL_ICONS } from './icons';
|
|
6
6
|
|
|
7
|
+
function escapeHtml(str: unknown): string {
|
|
8
|
+
return String(str ?? '')
|
|
9
|
+
.replace(/&/g, '&')
|
|
10
|
+
.replace(/</g, '<')
|
|
11
|
+
.replace(/>/g, '>')
|
|
12
|
+
.replace(/"/g, '"')
|
|
13
|
+
.replace(/'/g, ''');
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
export interface ToolbarRenderOptions {
|
|
8
17
|
workbench: any;
|
|
9
18
|
title: string;
|
|
@@ -42,7 +51,9 @@ export function renderLanguageSwitcherHtml(workbench: any): string {
|
|
|
42
51
|
export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
43
52
|
const { workbench, title, backLabel, hasGuidedLab, mode, activeFile, hasWebContent, activeServerCount } = opts;
|
|
44
53
|
const isGuided = Boolean(hasGuidedLab && mode === 'guided');
|
|
45
|
-
const brandLabel = title || 'code-lab';
|
|
54
|
+
const brandLabel = escapeHtml(title || 'code-lab');
|
|
55
|
+
const safeBackLabel = escapeHtml(backLabel);
|
|
56
|
+
const safeActiveFile = escapeHtml(activeFile || 'active');
|
|
46
57
|
|
|
47
58
|
const testFileExists = Boolean(
|
|
48
59
|
workbench._findEntryFile && workbench._findEntryFile('test') !== null
|
|
@@ -52,9 +63,9 @@ export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
|
52
63
|
<div class="codelab-topbar codelab-toolbar">
|
|
53
64
|
<div class="codelab-topbar__left">
|
|
54
65
|
${workbench.onClose ? `
|
|
55
|
-
<button type="button" class="codelab-btn codelab-btn--back" data-cl-action="close-lab" title="${
|
|
66
|
+
<button type="button" class="codelab-btn codelab-btn--back" data-cl-action="close-lab" title="${safeBackLabel}">
|
|
56
67
|
${CL_ICONS.arrowLeft}
|
|
57
|
-
<span>${
|
|
68
|
+
<span>${safeBackLabel}</span>
|
|
58
69
|
</button>
|
|
59
70
|
` : ''}
|
|
60
71
|
<span class="codelab-brand ${workbench.onClose ? 'codelab-brand--with-back' : ''}" title="${brandLabel}">
|
|
@@ -118,7 +129,7 @@ export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
|
118
129
|
<span>▶ Run Entry / Demo</span> <kbd style="opacity:0.6">⌘↵</kbd>
|
|
119
130
|
</button>
|
|
120
131
|
<button type="button" class="codelab-split-menu__item" data-cl-action="run-active-file">
|
|
121
|
-
<span>▶ Run Active File (${
|
|
132
|
+
<span>▶ Run Active File (${safeActiveFile})</span> <kbd style="opacity:0.6">⇧⌘↵</kbd>
|
|
122
133
|
</button>
|
|
123
134
|
${testFileExists ? `
|
|
124
135
|
<button type="button" class="codelab-split-menu__item" data-cl-action="run-tests">
|