@innovatorved/code-lab 0.1.6 → 0.1.8

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.
Files changed (51) hide show
  1. package/ARCHITECTURE.md +34 -16
  2. package/README.md +17 -7
  3. package/dist/code-lab.css +26 -0
  4. package/dist/code-lab.d.ts +271 -1
  5. package/dist/code-lab.esm.js +2909 -166
  6. package/dist/code-lab.js +2869 -164
  7. package/dist/csp.d.ts +86 -0
  8. package/dist/diagnostics.d.ts +43 -0
  9. package/dist/extensions/guided-lab.esm.js +66 -0
  10. package/dist/extensions/guided-lab.js +66 -0
  11. package/dist/html.d.ts +24 -0
  12. package/dist/index.d.ts +9 -1
  13. package/dist/logger.d.ts +60 -0
  14. package/dist/preview-sw.js +425 -11
  15. package/dist/runtime.d.ts +6 -27
  16. package/dist/runtime.esm.js +171 -31
  17. package/dist/runtime.js +171 -31
  18. package/dist/schemas.d.ts +366 -25
  19. package/dist/schemas.esm.js +73 -0
  20. package/dist/schemas.js +73 -0
  21. package/dist/scm.d.ts +77 -0
  22. package/dist/search.d.ts +75 -0
  23. package/dist/shell.d.ts +18 -47
  24. package/dist/shell.esm.js +236 -37
  25. package/dist/shell.js +236 -37
  26. package/dist/storage.d.ts +57 -0
  27. package/dist/terminal.d.ts +11 -87
  28. package/dist/terminal.esm.js +124 -7
  29. package/dist/terminal.js +124 -7
  30. package/dist/zip.d.ts +42 -0
  31. package/package.json +11 -3
  32. package/src/code-lab.css +26 -0
  33. package/src/csp.ts +396 -0
  34. package/src/diagnostics.ts +116 -0
  35. package/src/html.ts +88 -0
  36. package/src/index.ts +39 -1
  37. package/src/logger.ts +139 -0
  38. package/src/preview-sw.js +97 -11
  39. package/src/runtime.ts +132 -105
  40. package/src/schemas.ts +94 -1
  41. package/src/scm.ts +268 -0
  42. package/src/search.ts +389 -0
  43. package/src/shell.ts +410 -369
  44. package/src/storage.ts +377 -0
  45. package/src/terminal.ts +898 -918
  46. package/src/workbench.ts +926 -89
  47. package/src/zip.ts +326 -0
  48. package/src/runtime.js +0 -8229
  49. package/src/shell.js +0 -7257
  50. package/src/terminal.js +0 -1046
  51. package/src/workbench.js +0 -7353
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v2.0.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.8 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -15,7 +15,109 @@
15
15
  * ============================================================
16
16
  */
17
17
  const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {};
18
+ var CodeLabLogger = (() => {
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/logger.ts
38
+ var logger_exports = {};
39
+ __export(logger_exports, {
40
+ CodeLabError: () => CodeLabError,
41
+ DEFAULT_LOGGER: () => DEFAULT_LOGGER,
42
+ LOG_PREFIX: () => LOG_PREFIX,
43
+ createLogger: () => createLogger,
44
+ default: () => logger_default,
45
+ isCodeLabError: () => isCodeLabError
46
+ });
47
+ var LOG_PREFIX = "[code-lab]";
48
+ var CodeLabError = class extends Error {
49
+ code;
50
+ options;
51
+ cause;
52
+ recoverable;
53
+ details;
54
+ context;
55
+ constructor(code, message, options = {}) {
56
+ super(message);
57
+ this.name = "CodeLabError";
58
+ this.code = code;
59
+ this.options = options;
60
+ this.cause = options.cause;
61
+ this.recoverable = options.recoverable !== false;
62
+ const meta = options.details ?? options.context;
63
+ if (meta !== void 0) {
64
+ this.details = meta;
65
+ this.context = meta;
66
+ }
67
+ Object.setPrototypeOf(this, new.target.prototype);
68
+ }
69
+ };
70
+ function isCodeLabError(value) {
71
+ return Boolean(
72
+ value && typeof value === "object" && (value instanceof CodeLabError || value.name === "CodeLabError" && typeof value.code === "string")
73
+ );
74
+ }
75
+ function createLogger(options = {}) {
76
+ const sink = options.logger ?? null;
77
+ const debugEnabled = options.debug === true;
78
+ const prefix = options.prefix || LOG_PREFIX;
79
+ const write = (level, args) => {
80
+ if (level === "debug" && !debugEnabled) return;
81
+ if (sink && typeof sink[level] === "function") {
82
+ let sinkError = null;
83
+ try {
84
+ sink[level](...args);
85
+ return;
86
+ } catch (err) {
87
+ sinkError = err;
88
+ }
89
+ }
90
+ const consoleObj = typeof console !== "undefined" ? console : null;
91
+ const fn = consoleObj ? consoleObj[level] : null;
92
+ if (typeof fn === "function") {
93
+ fn.call(consoleObj, prefix, ...args);
94
+ }
95
+ };
96
+ return {
97
+ debug: (...args) => write("debug", args),
98
+ info: (...args) => write("info", args),
99
+ warn: (...args) => write("warn", args),
100
+ error: (...args) => write("error", args)
101
+ };
102
+ }
103
+ var DEFAULT_LOGGER = createLogger();
104
+ var _loggerNamespace = {
105
+ LOG_PREFIX,
106
+ CodeLabError,
107
+ isCodeLabError,
108
+ createLogger,
109
+ DEFAULT_LOGGER
110
+ };
111
+ var _globalRoot = typeof globalThis !== "undefined" ? globalThis : null;
112
+ if (_globalRoot && !_globalRoot.CodeLabLogger) {
113
+ _globalRoot.CodeLabLogger = _loggerNamespace;
114
+ }
115
+ var logger_default = _loggerNamespace;
116
+ return __toCommonJS(logger_exports);
117
+ })();
118
+
18
119
  (function () {
120
+ // @ts-nocheck
19
121
  /**
20
122
  * @innovatorved/code-lab - Pure-JS PTY Terminal Emulator Component
21
123
  *
@@ -50,6 +152,16 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
50
152
  })(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this), function () {
51
153
  'use strict';
52
154
 
155
+ const _termRoot = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : {});
156
+ const _terminalLogger = (_termRoot && _termRoot.CodeLabLogger && typeof _termRoot.CodeLabLogger.createLogger === 'function')
157
+ ? _termRoot.CodeLabLogger.createLogger()
158
+ : {
159
+ debug() {},
160
+ info(...args) { if (typeof console !== 'undefined' && console.info) console.info('[code-lab]', ...args); },
161
+ warn(...args) { if (typeof console !== 'undefined' && console.warn) console.warn('[code-lab]', ...args); },
162
+ error(...args) { if (typeof console !== 'undefined' && console.error) console.error('[code-lab]', ...args); }
163
+ };
164
+
53
165
  const ANSI_CODE_MAP = {
54
166
  1: 'cl-ansi-bold',
55
167
  2: 'cl-ansi-dim',
@@ -590,7 +702,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
590
702
  if (!this.container || typeof this.container.querySelector !== 'function') return;
591
703
  const input = this.container.querySelector('#cl-repl-input');
592
704
  if (input && typeof input.focus === 'function') {
593
- try { input.focus(); } catch (_) {}
705
+ try { input.focus(); } catch (err) { _terminalLogger.debug('Terminal input focus skipped.', err); }
594
706
  }
595
707
  }
596
708
 
@@ -614,9 +726,9 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
614
726
  }
615
727
  for (const entry of this._listeners) {
616
728
  if (typeof entry === 'function') {
617
- try { entry(); } catch (_) {}
729
+ try { entry(); } catch (err) { _terminalLogger.debug('Terminal listener cleanup callback failed.', err); }
618
730
  } else if (entry && entry.target && typeof entry.target.removeEventListener === 'function') {
619
- try { entry.target.removeEventListener(entry.type, entry.handler); } catch (_) {}
731
+ try { entry.target.removeEventListener(entry.type, entry.handler); } catch (err) { _terminalLogger.debug('Terminal removeEventListener failed.', err); }
620
732
  }
621
733
  }
622
734
  this._listeners = [];
@@ -685,7 +797,9 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
685
797
  try {
686
798
  const res = this.onKey(e);
687
799
  if (res === false) return;
688
- } catch (_) {}
800
+ } catch (err) {
801
+ _terminalLogger.warn('Terminal onKey callback threw.', err);
802
+ }
689
803
  }
690
804
 
691
805
  const key = e.key;
@@ -838,7 +952,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
838
952
  this.replMode = false;
839
953
  }
840
954
  if (this.onInterrupt) {
841
- try { this.onInterrupt(); } catch (_) {}
955
+ try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
842
956
  }
843
957
  this.render();
844
958
  return;
@@ -1039,7 +1153,9 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
1039
1153
  if (typeof nextInput.setSelectionRange === 'function') {
1040
1154
  nextInput.setSelectionRange(this.cursor, this.cursor);
1041
1155
  }
1042
- } catch (_) {}
1156
+ } catch (err) {
1157
+ _terminalLogger.debug('Terminal focus/selection restore skipped.', err);
1158
+ }
1043
1159
  }
1044
1160
  }
1045
1161
  }
@@ -1063,6 +1179,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
1063
1179
  };
1064
1180
  });
1065
1181
 
1182
+
1066
1183
  })();
1067
1184
 
1068
1185
  const CodeLabTerminal = _root.CodeLabTerminal;
package/dist/terminal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v2.0.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.8 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -16,7 +16,109 @@
16
16
  */
17
17
  (function (root) {
18
18
  'use strict';
19
+ var CodeLabLogger = (() => {
20
+ var __defProp = Object.defineProperty;
21
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
22
+ var __getOwnPropNames = Object.getOwnPropertyNames;
23
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+
38
+ // src/logger.ts
39
+ var logger_exports = {};
40
+ __export(logger_exports, {
41
+ CodeLabError: () => CodeLabError,
42
+ DEFAULT_LOGGER: () => DEFAULT_LOGGER,
43
+ LOG_PREFIX: () => LOG_PREFIX,
44
+ createLogger: () => createLogger,
45
+ default: () => logger_default,
46
+ isCodeLabError: () => isCodeLabError
47
+ });
48
+ var LOG_PREFIX = "[code-lab]";
49
+ var CodeLabError = class extends Error {
50
+ code;
51
+ options;
52
+ cause;
53
+ recoverable;
54
+ details;
55
+ context;
56
+ constructor(code, message, options = {}) {
57
+ super(message);
58
+ this.name = "CodeLabError";
59
+ this.code = code;
60
+ this.options = options;
61
+ this.cause = options.cause;
62
+ this.recoverable = options.recoverable !== false;
63
+ const meta = options.details ?? options.context;
64
+ if (meta !== void 0) {
65
+ this.details = meta;
66
+ this.context = meta;
67
+ }
68
+ Object.setPrototypeOf(this, new.target.prototype);
69
+ }
70
+ };
71
+ function isCodeLabError(value) {
72
+ return Boolean(
73
+ value && typeof value === "object" && (value instanceof CodeLabError || value.name === "CodeLabError" && typeof value.code === "string")
74
+ );
75
+ }
76
+ function createLogger(options = {}) {
77
+ const sink = options.logger ?? null;
78
+ const debugEnabled = options.debug === true;
79
+ const prefix = options.prefix || LOG_PREFIX;
80
+ const write = (level, args) => {
81
+ if (level === "debug" && !debugEnabled) return;
82
+ if (sink && typeof sink[level] === "function") {
83
+ let sinkError = null;
84
+ try {
85
+ sink[level](...args);
86
+ return;
87
+ } catch (err) {
88
+ sinkError = err;
89
+ }
90
+ }
91
+ const consoleObj = typeof console !== "undefined" ? console : null;
92
+ const fn = consoleObj ? consoleObj[level] : null;
93
+ if (typeof fn === "function") {
94
+ fn.call(consoleObj, prefix, ...args);
95
+ }
96
+ };
97
+ return {
98
+ debug: (...args) => write("debug", args),
99
+ info: (...args) => write("info", args),
100
+ warn: (...args) => write("warn", args),
101
+ error: (...args) => write("error", args)
102
+ };
103
+ }
104
+ var DEFAULT_LOGGER = createLogger();
105
+ var _loggerNamespace = {
106
+ LOG_PREFIX,
107
+ CodeLabError,
108
+ isCodeLabError,
109
+ createLogger,
110
+ DEFAULT_LOGGER
111
+ };
112
+ var _globalRoot = typeof globalThis !== "undefined" ? globalThis : null;
113
+ if (_globalRoot && !_globalRoot.CodeLabLogger) {
114
+ _globalRoot.CodeLabLogger = _loggerNamespace;
115
+ }
116
+ var logger_default = _loggerNamespace;
117
+ return __toCommonJS(logger_exports);
118
+ })();
119
+
19
120
  (function () {
121
+ // @ts-nocheck
20
122
  /**
21
123
  * @innovatorved/code-lab - Pure-JS PTY Terminal Emulator Component
22
124
  *
@@ -51,6 +153,16 @@
51
153
  })(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this), function () {
52
154
  'use strict';
53
155
 
156
+ const _termRoot = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : {});
157
+ const _terminalLogger = (_termRoot && _termRoot.CodeLabLogger && typeof _termRoot.CodeLabLogger.createLogger === 'function')
158
+ ? _termRoot.CodeLabLogger.createLogger()
159
+ : {
160
+ debug() {},
161
+ info(...args) { if (typeof console !== 'undefined' && console.info) console.info('[code-lab]', ...args); },
162
+ warn(...args) { if (typeof console !== 'undefined' && console.warn) console.warn('[code-lab]', ...args); },
163
+ error(...args) { if (typeof console !== 'undefined' && console.error) console.error('[code-lab]', ...args); }
164
+ };
165
+
54
166
  const ANSI_CODE_MAP = {
55
167
  1: 'cl-ansi-bold',
56
168
  2: 'cl-ansi-dim',
@@ -591,7 +703,7 @@
591
703
  if (!this.container || typeof this.container.querySelector !== 'function') return;
592
704
  const input = this.container.querySelector('#cl-repl-input');
593
705
  if (input && typeof input.focus === 'function') {
594
- try { input.focus(); } catch (_) {}
706
+ try { input.focus(); } catch (err) { _terminalLogger.debug('Terminal input focus skipped.', err); }
595
707
  }
596
708
  }
597
709
 
@@ -615,9 +727,9 @@
615
727
  }
616
728
  for (const entry of this._listeners) {
617
729
  if (typeof entry === 'function') {
618
- try { entry(); } catch (_) {}
730
+ try { entry(); } catch (err) { _terminalLogger.debug('Terminal listener cleanup callback failed.', err); }
619
731
  } else if (entry && entry.target && typeof entry.target.removeEventListener === 'function') {
620
- try { entry.target.removeEventListener(entry.type, entry.handler); } catch (_) {}
732
+ try { entry.target.removeEventListener(entry.type, entry.handler); } catch (err) { _terminalLogger.debug('Terminal removeEventListener failed.', err); }
621
733
  }
622
734
  }
623
735
  this._listeners = [];
@@ -686,7 +798,9 @@
686
798
  try {
687
799
  const res = this.onKey(e);
688
800
  if (res === false) return;
689
- } catch (_) {}
801
+ } catch (err) {
802
+ _terminalLogger.warn('Terminal onKey callback threw.', err);
803
+ }
690
804
  }
691
805
 
692
806
  const key = e.key;
@@ -839,7 +953,7 @@
839
953
  this.replMode = false;
840
954
  }
841
955
  if (this.onInterrupt) {
842
- try { this.onInterrupt(); } catch (_) {}
956
+ try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
843
957
  }
844
958
  this.render();
845
959
  return;
@@ -1040,7 +1154,9 @@
1040
1154
  if (typeof nextInput.setSelectionRange === 'function') {
1041
1155
  nextInput.setSelectionRange(this.cursor, this.cursor);
1042
1156
  }
1043
- } catch (_) {}
1157
+ } catch (err) {
1158
+ _terminalLogger.debug('Terminal focus/selection restore skipped.', err);
1159
+ }
1044
1160
  }
1045
1161
  }
1046
1162
  }
@@ -1064,6 +1180,7 @@
1064
1180
  };
1065
1181
  });
1066
1182
 
1183
+
1067
1184
  })();
1068
1185
 
1069
1186
  if (typeof module !== 'undefined' && module.exports) {
package/dist/zip.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @innovatorved/code-lab — Zero-Dependency PKZip v2.0 Archive Engine
3
+ * ============================================================================
4
+ * Pure TypeScript implementation of PKZip 2.0 (Store method 0 + UTF-8 flag
5
+ * bit 11 + IEEE 802.3 CRC32) for browser and Node/Bun project export & import.
6
+ *
7
+ * Includes built-in Zip-Slip path traversal sanitization and header integrity
8
+ * verification.
9
+ *
10
+ * Strict leaf module: fully typed, zero explicit any, zero empty catches.
11
+ */
12
+ /**
13
+ * Converts a string or byte buffer into a `Uint8Array`.
14
+ */
15
+ export declare function toUint8Array(input: string | Uint8Array | ArrayBuffer): Uint8Array;
16
+ /**
17
+ * Computes the standard IEEE 802.3 CRC32 checksum of a string or byte array.
18
+ */
19
+ export declare function computeCrc32(data: string | Uint8Array | ArrayBuffer): number;
20
+ /**
21
+ * Sanitizes an archive entry path to prevent Zip-Slip directory traversal attacks.
22
+ * Normalizes backslashes, strips drive prefixes and leading slashes, and collapses
23
+ * or removes `..` and `.` segments so the resulting path is strictly relative.
24
+ */
25
+ export declare function sanitizeZipPath(rawPath: string): string;
26
+ /**
27
+ * Creates a standard PKZip v2.0 archive from a map of file paths to contents.
28
+ */
29
+ export declare function createZip(files: Record<string, string | Uint8Array>): Promise<Uint8Array>;
30
+ /**
31
+ * Extracts a PKZip v2.0 archive into a UTF-8 file dictionary (`Record<string, string>`).
32
+ * Validates magic headers, checks boundaries, and sanitizes paths against Zip-Slip.
33
+ */
34
+ export declare function extractZip(data: Uint8Array | ArrayBuffer): Promise<Record<string, string>>;
35
+ declare const _default: {
36
+ createZip: typeof createZip;
37
+ extractZip: typeof extractZip;
38
+ computeCrc32: typeof computeCrc32;
39
+ sanitizeZipPath: typeof sanitizeZipPath;
40
+ toUint8Array: typeof toUint8Array;
41
+ };
42
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, and Web Worker Node.js/Bun Virtual Runtime.",
5
5
  "main": "./dist/code-lab.js",
6
6
  "module": "./dist/code-lab.esm.js",
@@ -71,15 +71,23 @@
71
71
  "packageManager": "bun@1.4.3",
72
72
  "scripts": {
73
73
  "build": "bun run tools/bundle.js",
74
+ "lint": "node tools/lint.js",
74
75
  "typecheck": "bun x tsc --noEmit",
75
- "test": "bun run tests/test-all-builds.js",
76
- "test:all": "bun run tools/bundle.js && bun run tests/test-all-builds.js && bun run tests/test-runtime-advanced.js && bun run tests/test-option1-shell-bun-http.js && bun run tests/test-frameworks.js && bun run tests/test-esm-exports.js && bun run tests/test-installer-integrity.js && bun run tests/test-coreutils-adversarial.js && bun run tests/test-stress-shell.js && bun run tests/test-workbench-ui.js && bun run tests/test-terminal-streaming.js && bun run tests/test-git-clone-streaming.js && bun run tests/test-m1-adversarial-challenger.js && bun run tests/test-m1-interruption-lifecycle-stress.js && bun run tests/test-gfm-markdown.js && bun run tests/test-m2-adversarial-syntax.js && bun run tests/test-m2-adversarial-interactive.js && bun run tests/test-web-preview.js && bun run tests/test-preview-sw.js",
76
+ "typecheck:strict": "bun x tsc -p tsconfig.strict.json",
77
+ "test": "bun run tools/bundle.js && bun run tests/run-all.js",
78
+ "test:all": "bun run test",
79
+ "test:unit": "bun run tests/run-all.js --filter=test-",
80
+ "test:e2e": "bun run tools/bundle.js && bun run tests/e2e/run-all-e2e.js",
81
+ "test:browser": "bunx playwright test --project=chromium",
82
+ "test:browser:all": "bunx playwright test",
83
+ "test:browser:install": "bunx playwright install --with-deps chromium firefox webkit",
77
84
  "pack:check": "bun pm pack --dry-run"
78
85
  },
79
86
  "dependencies": {
80
87
  "zod": "^3.23.8"
81
88
  },
82
89
  "devDependencies": {
90
+ "@playwright/test": "^1.64.1",
83
91
  "@types/node": "^22.7.5",
84
92
  "esbuild": "^0.24.0",
85
93
  "typescript": "^5.6.3"
package/src/code-lab.css CHANGED
@@ -2300,6 +2300,11 @@ code-lab,
2300
2300
  background: var(--cl-red);
2301
2301
  }
2302
2302
 
2303
+ .codelab-statusbar__save.is-failed {
2304
+ color: var(--cl-amber);
2305
+ font-weight: 500;
2306
+ }
2307
+
2303
2308
  @keyframes clStatusPulse {
2304
2309
  0%, 100% { opacity: 1; transform: scale(1); }
2305
2310
  50% { opacity: 0.45; transform: scale(0.85); }
@@ -4317,6 +4322,27 @@ code-lab,
4317
4322
 
4318
4323
  .codelab-preview-modes { display: flex; gap: 2px; flex: 0 0 auto; }
4319
4324
 
4325
+ /* CSP badge: which remote hosts the current preview may reach. */
4326
+ .codelab-preview-csp {
4327
+ flex: 0 0 auto;
4328
+ max-width: 220px;
4329
+ overflow: hidden;
4330
+ text-overflow: ellipsis;
4331
+ white-space: nowrap;
4332
+ font-size: 11px;
4333
+ line-height: 18px;
4334
+ padding: 0 8px;
4335
+ border-radius: 999px;
4336
+ border: 1px solid var(--cl-border);
4337
+ color: var(--cl-fg-muted);
4338
+ background: var(--cl-bg-elevated);
4339
+ }
4340
+
4341
+ .codelab-preview-csp--blocked {
4342
+ color: var(--cl-red);
4343
+ border-color: var(--cl-red);
4344
+ }
4345
+
4320
4346
  .codelab-preview-viewport {
4321
4347
  flex: 1 1 auto;
4322
4348
  min-height: 180px;