@innovatorved/code-lab 0.5.0 → 0.6.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 +3 -3
- package/CHANGELOG.md +15 -0
- package/README.md +3 -3
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +32 -7273
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +4669 -74678
- package/dist/code-lab.js +4655 -74665
- package/dist/code-lab.umd.js +4655 -74665
- package/dist/extensions/cpp.d.ts +2 -2
- package/dist/extensions/cpp.esm.js +1788 -14707
- package/dist/extensions/cpp.js +1788 -14707
- package/dist/extensions/guided-lab.esm.js +2938 -16127
- package/dist/extensions/guided-lab.js +2938 -16127
- package/dist/extensions/python.d.ts +2 -2
- package/dist/extensions/python.esm.js +1769 -14701
- package/dist/extensions/python.js +1769 -14701
- package/dist/index.d.ts +1 -1
- package/dist/preview-sw.js +4 -188
- package/dist/runtime.esm.js +109 -10284
- package/dist/runtime.js +107 -10284
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.esm.js +2938 -16127
- package/dist/schemas.js +2941 -16130
- package/dist/scm.d.ts +221 -20
- package/dist/shell.esm.js +811 -10002
- package/dist/shell.js +811 -10002
- package/dist/storage.d.ts +9 -0
- package/dist/terminal.esm.js +20 -1347
- package/dist/terminal.js +20 -1347
- package/dist/workbench/command-palette.d.ts +16 -1
- package/dist/workbench/diff-editor.d.ts +27 -1
- package/dist/workbench/icons.d.ts +6 -2
- package/dist/workbench/index.d.ts +32 -0
- package/dist/workbench/intellisense.d.ts +194 -0
- package/dist/workbench/xterm-adapter.d.ts +122 -0
- package/package.json +7 -1
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/settings-dialog.ts +36 -24
- package/packages/ui/src/themes.ts +89 -23
- package/src/code-lab.css +1345 -481
- package/src/extensions/cpp.ts +304 -38
- package/src/extensions/python.ts +342 -43
- package/src/index.ts +1 -1
- package/src/runtime.ts +272 -43
- package/src/schemas.ts +2 -2
- package/src/scm.ts +1467 -92
- package/src/shell.ts +1075 -93
- package/src/storage.ts +66 -3
- package/src/terminal.ts +148 -12
- package/src/workbench/command-palette.ts +289 -48
- package/src/workbench/diff-editor.ts +240 -78
- package/src/workbench/icons.ts +250 -53
- package/src/workbench/index.ts +7 -1
- package/src/workbench/intellisense.ts +1859 -0
- package/src/workbench/xterm-adapter.ts +1566 -0
- package/src/workbench.ts +1605 -236
package/dist/index.d.ts
CHANGED
package/dist/preview-sw.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ============================================================
|
|
3
|
-
* @innovatorved/code-lab v0.
|
|
3
|
+
* @innovatorved/code-lab v0.6.0 — Standalone Browser Code IDE & Virtual Runtime
|
|
4
4
|
* ============================================================
|
|
5
5
|
* Features:
|
|
6
6
|
* - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
|
|
7
7
|
* - First-Class Node.js and Bun Runtimes (Bun.serve, bun:test, bun:sqlite, Bun.*)
|
|
8
|
-
* - Full POSIX Shell AST &
|
|
8
|
+
* - Full POSIX Shell AST & 73 UNIX Coreutils (pipes, redirects, globs, env vars, git & git clone)
|
|
9
9
|
* - Interactive PTY Terminal Emulator with inline prompt, Tab completion & ANSI colors
|
|
10
10
|
* - Persistent HTTP/TCP Servers, CLI curl & Live Port/HTTP Preview
|
|
11
11
|
* - Modular VS Code Workbench: File Tree, Tabs, Command Palette, Diff Viewer
|
|
@@ -15,180 +15,7 @@
|
|
|
15
15
|
* ============================================================
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
var CodeLabCsp = (() => {
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
21
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
22
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
|
|
37
|
-
// src/csp.ts
|
|
38
|
-
var csp_exports = {};
|
|
39
|
-
__export(csp_exports, {
|
|
40
|
-
PREVIEW_SHIM_MARKER: () => PREVIEW_SHIM_MARKER,
|
|
41
|
-
buildPreviewPolicy: () => buildPreviewPolicy,
|
|
42
|
-
buildPreviewShims: () => buildPreviewShims,
|
|
43
|
-
default: () => csp_default,
|
|
44
|
-
describePreviewNetwork: () => describePreviewNetwork,
|
|
45
|
-
normalizeOrigin: () => normalizeOrigin,
|
|
46
|
-
normalizePreviewCspConfig: () => normalizePreviewCspConfig
|
|
47
|
-
});
|
|
48
|
-
var IMPORT_MAP_CDNS = ["https://cdn.jsdelivr.net", "https://esm.sh"];
|
|
49
|
-
var FONT_CDNS = ["https://cdn.jsdelivr.net", "https://fonts.gstatic.com"];
|
|
50
|
-
var PRESETS = {
|
|
51
|
-
strict: {},
|
|
52
|
-
balanced: {
|
|
53
|
-
scriptSrc: IMPORT_MAP_CDNS.slice(),
|
|
54
|
-
styleSrc: ["https://cdn.jsdelivr.net", "https://fonts.googleapis.com"],
|
|
55
|
-
fontSrc: FONT_CDNS.slice(),
|
|
56
|
-
connectSrc: IMPORT_MAP_CDNS.slice(),
|
|
57
|
-
imgSrc: ["https://cdn.jsdelivr.net"]
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var SOURCE_KEYS = [
|
|
61
|
-
"scriptSrc",
|
|
62
|
-
"styleSrc",
|
|
63
|
-
"imgSrc",
|
|
64
|
-
"fontSrc",
|
|
65
|
-
"connectSrc",
|
|
66
|
-
"mediaSrc",
|
|
67
|
-
"workerSrc",
|
|
68
|
-
"frameSrc"
|
|
69
|
-
];
|
|
70
|
-
var MAX_SOURCES = 64;
|
|
71
|
-
var MAX_SOURCE_LENGTH = 512;
|
|
72
|
-
var PREVIEW_SHIM_MARKER = "data-codelab-preview-shims";
|
|
73
|
-
function normalizeOrigin(raw) {
|
|
74
|
-
if (raw === null || raw === void 0 || raw === "") return null;
|
|
75
|
-
try {
|
|
76
|
-
const parsed = new URL(String(raw));
|
|
77
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
|
|
78
|
-
return parsed.origin;
|
|
79
|
-
} catch (_) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function normalizeMode(raw) {
|
|
84
|
-
if (raw === "strict" || raw === "custom") return raw;
|
|
85
|
-
return "balanced";
|
|
86
|
-
}
|
|
87
|
-
var ALLOWED_KEYWORDS = [
|
|
88
|
-
"'self'",
|
|
89
|
-
"'none'",
|
|
90
|
-
"'unsafe-inline'",
|
|
91
|
-
"'unsafe-eval'",
|
|
92
|
-
"'wasm-unsafe-eval'",
|
|
93
|
-
"'strict-dynamic'",
|
|
94
|
-
"'unsafe-hashes'"
|
|
95
|
-
];
|
|
96
|
-
var SOURCE_PATTERN = /^(?:https?:\/\/[A-Za-z0-9._~%-]+(?::\d{1,5})?(?:\/[^\s;,'"]*)?|data:|blob:|filesystem:)$/;
|
|
97
|
-
function isSafeSource(source) {
|
|
98
|
-
return ALLOWED_KEYWORDS.indexOf(source) !== -1 || SOURCE_PATTERN.test(source);
|
|
99
|
-
}
|
|
100
|
-
function cleanSources(raw) {
|
|
101
|
-
if (!Array.isArray(raw)) return [];
|
|
102
|
-
const out = [];
|
|
103
|
-
for (const value of raw.slice(0, MAX_SOURCES)) {
|
|
104
|
-
if (typeof value !== "string") continue;
|
|
105
|
-
const source = value.trim();
|
|
106
|
-
if (!source || source.length > MAX_SOURCE_LENGTH) continue;
|
|
107
|
-
if (!isSafeSource(source)) continue;
|
|
108
|
-
if (out.indexOf(source) === -1) out.push(source);
|
|
109
|
-
}
|
|
110
|
-
return out;
|
|
111
|
-
}
|
|
112
|
-
function unique(...lists) {
|
|
113
|
-
const out = [];
|
|
114
|
-
for (const list of lists) {
|
|
115
|
-
if (!list) continue;
|
|
116
|
-
for (const value of list) {
|
|
117
|
-
if (value && out.indexOf(value) === -1) out.push(value);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return out;
|
|
121
|
-
}
|
|
122
|
-
function normalizePreviewCspConfig(raw) {
|
|
123
|
-
if (typeof raw === "string") return { mode: normalizeMode(raw), allow: {} };
|
|
124
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
125
|
-
return { mode: "balanced", allow: {} };
|
|
126
|
-
}
|
|
127
|
-
const input = raw;
|
|
128
|
-
const nested = input.allow;
|
|
129
|
-
const sources = nested && typeof nested === "object" && !Array.isArray(nested) ? nested : input;
|
|
130
|
-
const allow = {};
|
|
131
|
-
for (const key of SOURCE_KEYS) {
|
|
132
|
-
const list = cleanSources(sources[key]);
|
|
133
|
-
if (list.length) allow[key] = list;
|
|
134
|
-
}
|
|
135
|
-
return { mode: normalizeMode(input.mode), allow };
|
|
136
|
-
}
|
|
137
|
-
function sourcesFor(mode, allow, key) {
|
|
138
|
-
const preset = mode === "custom" ? {} : PRESETS[mode];
|
|
139
|
-
return unique(preset[key], cleanSources(allow[key]));
|
|
140
|
-
}
|
|
141
|
-
function buildPreviewPolicy(options = {}) {
|
|
142
|
-
const mode = normalizeMode(options.mode);
|
|
143
|
-
const allow = options;
|
|
144
|
-
const host = normalizeOrigin(options.hostOrigin);
|
|
145
|
-
const self = host || "'self'";
|
|
146
|
-
const directive = (name, parts) => `${name} ${unique(parts).join(" ")}`;
|
|
147
|
-
const script = () => [self, "data:", "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
|
|
148
|
-
const style = () => [self, "'unsafe-inline'"].concat(sourcesFor(mode, allow, "styleSrc"));
|
|
149
|
-
const withData = (key) => [self, "data:", "blob:"].concat(sourcesFor(mode, allow, key));
|
|
150
|
-
return [
|
|
151
|
-
directive("default-src", [self, "data:", "blob:"]),
|
|
152
|
-
directive("base-uri", [self]),
|
|
153
|
-
"object-src 'none'",
|
|
154
|
-
directive("script-src", script()),
|
|
155
|
-
directive("style-src", style()),
|
|
156
|
-
directive("img-src", withData("imgSrc")),
|
|
157
|
-
directive("font-src", [self, "data:"].concat(sourcesFor(mode, allow, "fontSrc"))),
|
|
158
|
-
directive("connect-src", withData("connectSrc")),
|
|
159
|
-
directive("media-src", withData("mediaSrc")),
|
|
160
|
-
directive("worker-src", [self, "blob:"].concat(sourcesFor(mode, allow, "workerSrc"))),
|
|
161
|
-
directive("frame-src", withData("frameSrc")),
|
|
162
|
-
directive("form-action", [self]),
|
|
163
|
-
directive("frame-ancestors", (() => {
|
|
164
|
-
const rawFa = typeof options.frameAncestors === "string" ? options.frameAncestors.trim() : "";
|
|
165
|
-
if (!rawFa) return ["'self'"];
|
|
166
|
-
const tokens = cleanSources(rawFa.split(/\s+/));
|
|
167
|
-
return tokens.length > 0 ? tokens : ["'self'"];
|
|
168
|
-
})())
|
|
169
|
-
].join("; ");
|
|
170
|
-
}
|
|
171
|
-
function describePreviewNetwork(config) {
|
|
172
|
-
const normalized = normalizePreviewCspConfig(config);
|
|
173
|
-
if (normalized.mode === "strict") return [];
|
|
174
|
-
const preset = normalized.mode === "custom" ? {} : PRESETS[normalized.mode];
|
|
175
|
-
const hosts = [];
|
|
176
|
-
for (const key of ["scriptSrc", "connectSrc", "imgSrc", "styleSrc", "fontSrc"]) {
|
|
177
|
-
for (const source of unique(preset[key], normalized.allow[key])) {
|
|
178
|
-
if (!/^https?:\/\//i.test(source)) continue;
|
|
179
|
-
let host;
|
|
180
|
-
try {
|
|
181
|
-
host = new URL(source).host;
|
|
182
|
-
} catch (_) {
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (hosts.indexOf(host) === -1) hosts.push(host);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return hosts;
|
|
189
|
-
}
|
|
190
|
-
function buildPreviewShims() {
|
|
191
|
-
return `<script ${PREVIEW_SHIM_MARKER}>
|
|
18
|
+
var CodeLabCsp=(()=>{var u=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of C(t))!P.call(e,o)&&o!==r&&u(e,o,{get:()=>t[o],enumerable:!(n=O(t,o))||n.enumerable});return e};var I=e=>A(u({},"__esModule",{value:!0}),e);var L={};E(L,{PREVIEW_SHIM_MARKER:()=>f,buildPreviewPolicy:()=>S,buildPreviewShims:()=>k,default:()=>U,describePreviewNetwork:()=>x,normalizeOrigin:()=>v,normalizePreviewCspConfig:()=>m});var y=["https://cdn.jsdelivr.net","https://esm.sh"],j=["https://cdn.jsdelivr.net","https://fonts.gstatic.com"],b={strict:{},balanced:{scriptSrc:y.slice(),styleSrc:["https://cdn.jsdelivr.net","https://fonts.googleapis.com"],fontSrc:j.slice(),connectSrc:y.slice(),imgSrc:["https://cdn.jsdelivr.net"]}},R=["scriptSrc","styleSrc","imgSrc","fontSrc","connectSrc","mediaSrc","workerSrc","frameSrc"],_=64,N=512,f="data-codelab-preview-shims";function v(e){if(e==null||e==="")return null;try{let t=new URL(String(e));return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.origin}catch{return null}}function p(e){return e==="strict"||e==="custom"?e:"balanced"}var T=["'self'","'none'","'unsafe-inline'","'unsafe-eval'","'wasm-unsafe-eval'","'strict-dynamic'","'unsafe-hashes'"],H=/^(?:https?:\/\/[A-Za-z0-9._~%-]+(?::\d{1,5})?(?:\/[^\s;,'"]*)?|data:|blob:|filesystem:)$/;function M(e){return T.indexOf(e)!==-1||H.test(e)}function g(e){if(!Array.isArray(e))return[];let t=[];for(let r of e.slice(0,_)){if(typeof r!="string")continue;let n=r.trim();!n||n.length>N||M(n)&&t.indexOf(n)===-1&&t.push(n)}return t}function h(...e){let t=[];for(let r of e)if(r)for(let n of r)n&&t.indexOf(n)===-1&&t.push(n);return t}function m(e){if(typeof e=="string")return{mode:p(e),allow:{}};if(!e||typeof e!="object"||Array.isArray(e))return{mode:"balanced",allow:{}};let t=e,r=t.allow,n=r&&typeof r=="object"&&!Array.isArray(r)?r:t,o={};for(let i of R){let a=g(n[i]);a.length&&(o[i]=a)}return{mode:p(t.mode),allow:o}}function c(e,t,r){let n=e==="custom"?{}:b[e];return h(n[r],g(t[r]))}function S(e={}){let t=p(e.mode),r=e,o=v(e.hostOrigin)||"'self'",i=(s,d)=>`${s} ${h(d).join(" ")}`,a=()=>[o,"data:","blob:","'unsafe-inline'","'unsafe-eval'"].concat(c(t,r,"scriptSrc")),w=()=>[o,"'unsafe-inline'"].concat(c(t,r,"styleSrc")),l=s=>[o,"data:","blob:"].concat(c(t,r,s));return[i("default-src",[o,"data:","blob:"]),i("base-uri",[o]),"object-src 'none'",i("script-src",a()),i("style-src",w()),i("img-src",l("imgSrc")),i("font-src",[o,"data:"].concat(c(t,r,"fontSrc"))),i("connect-src",l("connectSrc")),i("media-src",l("mediaSrc")),i("worker-src",[o,"blob:"].concat(c(t,r,"workerSrc"))),i("frame-src",l("frameSrc")),i("form-action",[o]),i("frame-ancestors",(()=>{let s=typeof e.frameAncestors=="string"?e.frameAncestors.trim():"";if(!s)return["'self'"];let d=g(s.split(/\s+/));return d.length>0?d:["'self'"]})())].join("; ")}function x(e){let t=m(e);if(t.mode==="strict")return[];let r=t.mode==="custom"?{}:b[t.mode],n=[];for(let o of["scriptSrc","connectSrc","imgSrc","styleSrc","fontSrc"])for(let i of h(r[o],t.allow[o])){if(!/^https?:\/\//i.test(i))continue;let a;try{a=new URL(i).host}catch{continue}n.indexOf(a)===-1&&n.push(a)}return n}function k(){return`<script ${f}>
|
|
192
19
|
(function () {
|
|
193
20
|
'use strict';
|
|
194
21
|
function memoryStorage() {
|
|
@@ -502,18 +329,7 @@ var CodeLabCsp = (() => {
|
|
|
502
329
|
});
|
|
503
330
|
} catch (e) { void e; }
|
|
504
331
|
})();
|
|
505
|
-
<\/script
|
|
506
|
-
}
|
|
507
|
-
var csp_default = {
|
|
508
|
-
buildPreviewPolicy,
|
|
509
|
-
buildPreviewShims,
|
|
510
|
-
describePreviewNetwork,
|
|
511
|
-
normalizePreviewCspConfig,
|
|
512
|
-
normalizeOrigin,
|
|
513
|
-
PREVIEW_SHIM_MARKER
|
|
514
|
-
};
|
|
515
|
-
return __toCommonJS(csp_exports);
|
|
516
|
-
})();
|
|
332
|
+
<\/script>`}var U={buildPreviewPolicy:S,buildPreviewShims:k,describePreviewNetwork:x,normalizePreviewCspConfig:m,normalizeOrigin:v,PREVIEW_SHIM_MARKER:f};return I(L);})();
|
|
517
333
|
|
|
518
334
|
/**
|
|
519
335
|
* @innovatorved/code-lab — Web Preview Virtual Loopback Service Worker (Milestone 3)
|