@innovatorved/code-lab 0.7.1 → 0.7.2
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 +2 -2
- package/CHANGELOG.md +10 -0
- package/README.md +5 -5
- package/dist/code-lab-sql.esm.js +2 -2
- package/dist/code-lab-sql.umd.js +3 -3
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +47 -38
- package/dist/code-lab.esm.js +918 -884
- package/dist/code-lab.js +917 -881
- package/dist/extensions/cpp.esm.js +33 -33
- package/dist/extensions/cpp.js +33 -33
- package/dist/extensions/python.esm.js +79 -49
- package/dist/extensions/python.js +79 -49
- package/dist/index.d.ts +1 -1
- package/dist/logger.d.ts +4 -20
- package/dist/modular-kernel.d.ts +0 -1
- package/dist/packages/core/src/errors.d.ts +5 -1
- package/dist/packages/fs/src/backends.d.ts +0 -27
- package/dist/packages/fs/src/index.d.ts +1 -1
- package/dist/packages/ui/src/html.d.ts +1 -0
- package/dist/packages/ui/src/index.d.ts +1 -0
- package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -2
- package/dist/packages/ui/src/observability.d.ts +1 -1
- package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.esm.js +2 -2
- package/dist/runtime.js +2 -2
- package/dist/schemas.d.ts +1 -1
- package/dist/shell.esm.js +277 -285
- package/dist/shell.js +277 -285
- package/dist/terminal.esm.js +2 -2
- package/dist/terminal.js +2 -2
- package/dist/workbench/editor.d.ts +0 -4
- package/dist/workbench/index.d.ts +0 -2
- package/dist/workbench/intellisense.d.ts +0 -1
- package/dist/workbench/xterm-adapter.d.ts +0 -1
- package/package.json +2 -4
- package/src/code-lab.css +0 -8086
- package/src/csp.ts +0 -590
- package/src/diagnostics.ts +0 -287
- package/src/extensions/cpp.ts +0 -2371
- package/src/extensions/guided-lab.ts +0 -68
- package/src/extensions/javascript.ts +0 -54
- package/src/extensions/python.ts +0 -1743
- package/src/extensions/typescript.ts +0 -85
- package/src/extensions/umbrella.ts +0 -5
- package/src/html.ts +0 -88
- package/src/index.ts +0 -129
- package/src/logger.ts +0 -139
- package/src/modular-kernel.ts +0 -7
- package/src/preview-sw.js +0 -296
- package/src/runtime/test-harness.ts +0 -57
- package/src/runtime.ts +0 -10565
- package/src/sample.html +0 -304
- package/src/schemas.ts +0 -366
- package/src/scm.ts +0 -2453
- package/src/search.ts +0 -433
- package/src/shell.ts +0 -10990
- package/src/storage.ts +0 -773
- package/src/terminal.ts +0 -1402
- package/src/workbench/command-palette.ts +0 -101
- package/src/workbench/diff-editor.ts +0 -472
- package/src/workbench/editor.ts +0 -49
- package/src/workbench/icons.ts +0 -255
- package/src/workbench/index.ts +0 -29
- package/src/workbench/intellisense.ts +0 -1884
- package/src/workbench/share.ts +0 -128
- package/src/workbench/xterm-adapter.ts +0 -1571
- package/src/workbench.ts +0 -21825
- package/src/zip.ts +0 -348
package/src/workbench/share.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Zero-Backend URL Snapshot Compressor & Decompressor
|
|
3
|
-
*
|
|
4
|
-
* Serializes workspace state { lang, activeFile, files, stdin }, compresses it
|
|
5
|
-
* with browser-native `CompressionStream('deflate-raw')`, and encodes as Base64url
|
|
6
|
-
* in the URL hash `#codelab=<base64url>`.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export interface WorkspaceSharePayload {
|
|
10
|
-
lang?: string;
|
|
11
|
-
activeFile?: string | null;
|
|
12
|
-
files: Record<string, string>;
|
|
13
|
-
stdin?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function bufferToBase64Url(uint8: Uint8Array): string {
|
|
17
|
-
let binary = '';
|
|
18
|
-
for (let i = 0; i < uint8.length; i++) {
|
|
19
|
-
binary += String.fromCharCode(uint8[i]);
|
|
20
|
-
}
|
|
21
|
-
const base64 = typeof btoa !== 'undefined' ? btoa(binary) : Buffer.from(uint8).toString('base64');
|
|
22
|
-
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function base64UrlToBuffer(base64url: string): Uint8Array {
|
|
26
|
-
let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
|
|
27
|
-
while (base64.length % 4) {
|
|
28
|
-
base64 += '=';
|
|
29
|
-
}
|
|
30
|
-
if (typeof atob !== 'undefined') {
|
|
31
|
-
const binary = atob(base64);
|
|
32
|
-
const bytes = new Uint8Array(binary.length);
|
|
33
|
-
for (let i = 0; i < binary.length; i++) {
|
|
34
|
-
bytes[i] = binary.charCodeAt(i);
|
|
35
|
-
}
|
|
36
|
-
return bytes;
|
|
37
|
-
}
|
|
38
|
-
return new Uint8Array(Buffer.from(base64, 'base64'));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Compresses workspace payload into a compact Base64url string.
|
|
43
|
-
*/
|
|
44
|
-
export async function compressWorkspaceSnapshot(payload: WorkspaceSharePayload): Promise<string> {
|
|
45
|
-
const jsonStr = JSON.stringify(payload);
|
|
46
|
-
const encoder = new TextEncoder();
|
|
47
|
-
const rawBytes = encoder.encode(jsonStr);
|
|
48
|
-
|
|
49
|
-
if (typeof CompressionStream !== 'undefined') {
|
|
50
|
-
const cs = new CompressionStream('deflate-raw');
|
|
51
|
-
const writer = cs.writable.getWriter();
|
|
52
|
-
writer.write(rawBytes);
|
|
53
|
-
writer.close();
|
|
54
|
-
|
|
55
|
-
const response = new Response(cs.readable);
|
|
56
|
-
const compressedBuffer = await response.arrayBuffer();
|
|
57
|
-
return bufferToBase64Url(new Uint8Array(compressedBuffer));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Fallback: uncompressed Base64url if CompressionStream unsupported
|
|
61
|
-
return bufferToBase64Url(rawBytes);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const MAX_DECOMPRESSED_SNAPSHOT_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Decompresses a Base64url string into workspace snapshot payload.
|
|
68
|
-
*/
|
|
69
|
-
export async function decompressWorkspaceSnapshot(encoded: string): Promise<WorkspaceSharePayload | null> {
|
|
70
|
-
if (!encoded || typeof encoded !== 'string') return null;
|
|
71
|
-
try {
|
|
72
|
-
const bytes = base64UrlToBuffer(encoded);
|
|
73
|
-
if (bytes.byteLength > MAX_DECOMPRESSED_SNAPSHOT_BYTES) {
|
|
74
|
-
throw new Error('Snapshot payload exceeds maximum allowed size');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (typeof DecompressionStream !== 'undefined') {
|
|
78
|
-
try {
|
|
79
|
-
const ds = new DecompressionStream('deflate-raw');
|
|
80
|
-
const writer = ds.writable.getWriter();
|
|
81
|
-
const writeInput = new Uint8Array(bytes.byteLength);
|
|
82
|
-
writeInput.set(bytes);
|
|
83
|
-
writer.write(writeInput).catch(() => {});
|
|
84
|
-
writer.close().catch(() => {});
|
|
85
|
-
|
|
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
|
-
}
|
|
108
|
-
const text = new TextDecoder().decode(decompressed);
|
|
109
|
-
return JSON.parse(text) as WorkspaceSharePayload;
|
|
110
|
-
} catch (err) {
|
|
111
|
-
if (err instanceof Error && err.message.includes('safety limit')) {
|
|
112
|
-
throw err;
|
|
113
|
-
}
|
|
114
|
-
// Fallback for uncompressed raw JSON payload
|
|
115
|
-
const rawText = new TextDecoder().decode(bytes);
|
|
116
|
-
return JSON.parse(rawText) as WorkspaceSharePayload;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const rawText = new TextDecoder().decode(bytes);
|
|
121
|
-
return JSON.parse(rawText) as WorkspaceSharePayload;
|
|
122
|
-
} catch (err) {
|
|
123
|
-
if (typeof console !== 'undefined' && console.warn) {
|
|
124
|
-
console.warn('[CodeLab Share Snapshot Restore Error]:', err);
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
}
|