@innovatorved/code-lab 0.4.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.
Files changed (82) hide show
  1. package/ARCHITECTURE.md +4 -4
  2. package/CHANGELOG.md +36 -0
  3. package/README.md +6 -30
  4. package/dist/code-lab-sql.esm.js +1 -1
  5. package/dist/code-lab-sql.umd.js +2 -2
  6. package/dist/code-lab.css +32 -5818
  7. package/dist/code-lab.d.ts +1 -1
  8. package/dist/code-lab.esm.js +4655 -64400
  9. package/dist/code-lab.js +4540 -64286
  10. package/dist/code-lab.umd.js +4540 -64286
  11. package/dist/diagnostics.d.ts +3 -0
  12. package/dist/extensions/cpp.d.ts +2 -2
  13. package/dist/extensions/cpp.esm.js +1804 -14725
  14. package/dist/extensions/cpp.js +1804 -14725
  15. package/dist/extensions/guided-lab.esm.js +2938 -16127
  16. package/dist/extensions/guided-lab.js +2938 -16127
  17. package/dist/extensions/python.d.ts +2 -2
  18. package/dist/extensions/python.esm.js +1765 -14698
  19. package/dist/extensions/python.js +1765 -14698
  20. package/dist/index.d.ts +1 -1
  21. package/dist/packages/settings/src/configuration-service.d.ts +7 -0
  22. package/dist/packages/settings/src/index.d.ts +1 -1
  23. package/dist/packages/ui/src/index.d.ts +2 -2
  24. package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
  25. package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
  26. package/dist/packages/ui/src/themes.d.ts +5 -0
  27. package/dist/preview-sw.js +4 -188
  28. package/dist/runtime.esm.js +109 -10284
  29. package/dist/runtime.js +107 -10284
  30. package/dist/schemas.d.ts +2 -2
  31. package/dist/schemas.esm.js +2938 -16127
  32. package/dist/schemas.js +2941 -16130
  33. package/dist/scm.d.ts +296 -14
  34. package/dist/shell.esm.js +811 -9178
  35. package/dist/shell.js +811 -9178
  36. package/dist/storage.d.ts +56 -0
  37. package/dist/terminal.esm.js +20 -1347
  38. package/dist/terminal.js +20 -1347
  39. package/dist/workbench/command-palette.d.ts +16 -1
  40. package/dist/workbench/diff-editor.d.ts +27 -1
  41. package/dist/workbench/icons.d.ts +6 -2
  42. package/dist/workbench/index.d.ts +33 -1
  43. package/dist/workbench/intellisense.d.ts +194 -0
  44. package/dist/workbench/styles.d.ts +1 -1
  45. package/dist/workbench/xterm-adapter.d.ts +122 -0
  46. package/package.json +8 -2
  47. package/packages/commands/package.json +1 -1
  48. package/packages/core/package.json +1 -1
  49. package/packages/editor/package.json +1 -1
  50. package/packages/fs/package.json +1 -1
  51. package/packages/preview/package.json +1 -1
  52. package/packages/runtime/package.json +1 -1
  53. package/packages/settings/package.json +1 -1
  54. package/packages/settings/src/builtin-schemas.ts +17 -6
  55. package/packages/settings/src/configuration-service.ts +72 -6
  56. package/packages/settings/src/index.ts +1 -0
  57. package/packages/sql/package.json +1 -1
  58. package/packages/terminal/package.json +1 -1
  59. package/packages/ui/package.json +1 -1
  60. package/packages/ui/src/index.ts +4 -0
  61. package/packages/ui/src/plugin-registry.ts +17 -2
  62. package/packages/ui/src/settings-dialog.ts +393 -99
  63. package/packages/ui/src/themes.ts +183 -24
  64. package/src/code-lab.css +2763 -444
  65. package/src/diagnostics.ts +139 -7
  66. package/src/extensions/cpp.ts +337 -71
  67. package/src/extensions/python.ts +375 -75
  68. package/src/index.ts +1 -1
  69. package/src/runtime.ts +272 -43
  70. package/src/schemas.ts +2 -2
  71. package/src/scm.ts +2172 -74
  72. package/src/shell.ts +1999 -193
  73. package/src/storage.ts +401 -5
  74. package/src/terminal.ts +148 -12
  75. package/src/workbench/command-palette.ts +289 -48
  76. package/src/workbench/diff-editor.ts +240 -78
  77. package/src/workbench/icons.ts +250 -46
  78. package/src/workbench/index.ts +7 -1
  79. package/src/workbench/intellisense.ts +1859 -0
  80. package/src/workbench/styles.ts +25 -19
  81. package/src/workbench/xterm-adapter.ts +1566 -0
  82. package/src/workbench.ts +13446 -3881
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.4.0
2
+ * @innovatorved/code-lab v0.6.0
3
3
  * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, WASI C++20 Toolchain, Python 3.12 WebAssembly, and Git Engine.
4
4
  */
5
5
  export * from './schemas';
@@ -2,6 +2,7 @@ import { type Event, type IDisposable } from '@code-lab/core';
2
2
  import { type SettingDescriptor } from './builtin-schemas';
3
3
  import { type JsonSchema } from './schema';
4
4
  export type ConfigurationTarget = 'default' | 'user' | 'workspace' | 'override';
5
+ export type ConfigurationResetScope = 'user' | 'workspace' | 'all';
5
6
  export interface SettingDiagnostic {
6
7
  readonly file: string;
7
8
  readonly key?: string;
@@ -46,8 +47,11 @@ export interface IConfigurationService extends IDisposable {
46
47
  get<T = unknown>(key: string, fallback?: T): T;
47
48
  inspect<T = unknown>(key: string): SettingInspection<T>;
48
49
  getDiagnostics(): readonly SettingDiagnostic[];
50
+ getWorkspaceSettings(): Record<string, unknown>;
49
51
  setUserSetting(key: string, value: unknown): boolean;
50
52
  resetSetting(key: string): void;
53
+ resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void>;
54
+ resetAllSettings(scope?: ConfigurationResetScope): Promise<void>;
51
55
  setWorkspaceSetting(key: string, value: unknown): boolean;
52
56
  loadWorkspaceSettingsJson(rawJsonc: string, filePath?: string): readonly SettingDiagnostic[];
53
57
  setOverrides(overrides: Readonly<Record<string, unknown>>): void;
@@ -79,6 +83,9 @@ export declare class ConfigurationService implements IConfigurationService {
79
83
  setUserSetting(key: string, value: unknown): boolean;
80
84
  setWorkspaceSetting(key: string, value: unknown): boolean;
81
85
  resetSetting(key: string): void;
86
+ getWorkspaceSettings(): Record<string, unknown>;
87
+ resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void>;
88
+ resetAllSettings(scope?: ConfigurationResetScope): Promise<void>;
82
89
  loadWorkspaceSettingsJson(rawJsonc: string, filePath?: string): readonly SettingDiagnostic[];
83
90
  setOverrides(overrides: Readonly<Record<string, unknown>>): void;
84
91
  toWorkspaceJsonString(): string;
@@ -1,4 +1,4 @@
1
1
  export { type JsoncParseError, type JsoncParseResult, stripJsonCommentsAndTrailingCommas, parseJsonc } from './jsonc';
2
2
  export { type JsonSchemaType, type JsonSchema, type SchemaValidationIssue, validateJsonSchema } from './schema';
3
3
  export { type SettingCategory, type SettingDescriptor, BUILTIN_SETTINGS, buildSettingsJsonSchema, KEYBINDINGS_JSON_SCHEMA, TASKS_JSON_SCHEMA, EXTENSIONS_JSON_SCHEMA } from './builtin-schemas';
4
- export { type ConfigurationTarget, type SettingDiagnostic, type ConfigurationChangeEvent, type SettingInspection, type WorkspaceTaskDefinition, type WorkspaceExtensionsConfig, type IConfigurationService, IConfigurationServiceId, ConfigurationService, parseTasksConfig, parseExtensionsConfig } from './configuration-service';
4
+ export { type ConfigurationTarget, type ConfigurationResetScope, type SettingDiagnostic, type ConfigurationChangeEvent, type SettingInspection, type WorkspaceTaskDefinition, type WorkspaceExtensionsConfig, type IConfigurationService, IConfigurationServiceId, ConfigurationService, parseTasksConfig, parseExtensionsConfig } from './configuration-service';
@@ -1,4 +1,4 @@
1
- export { type ThemeKind, type ThemeDefinition, type IThemeService, DARK_THEME, LIGHT_THEME, HIGH_CONTRAST_THEME, IThemeServiceId, parseCustomTheme, ThemeService } from './themes';
1
+ export { type ThemeKind, type ThemeDefinition, type IThemeService, DARK_THEME, LIGHT_THEME, HIGH_CONTRAST_THEME, IThemeServiceId, pickContrastingFg, parseCustomTheme, ThemeService } from './themes';
2
2
  export { type PanelContribution, type LanguageContribution, type PluginContributions, type PluginActivationContext, type CodeLabPluginManifest, type RegisteredPluginInfo, type IPluginRegistry, IPluginRegistryId, PluginRegistry } from './plugin-registry';
3
- export { type SettingsDialogOptions, SettingsDialogController } from './settings-dialog';
3
+ export { type SettingsScope, type SettingsInlineMountOptions, type SettingsOpenOptions, type SettingsDialogOptions, SettingsDialogController } from './settings-dialog';
4
4
  export { type ObservabilitySnapshotInput, scoreFuzzyFileMatch, rankWorkspaceFiles, renderObservabilityPanelHtml, WorkbenchErrorBoundary } from './observability';
@@ -34,6 +34,7 @@ export interface PluginActivationContext {
34
34
  readonly keybindings: IKeybindingService;
35
35
  readonly themes: IThemeService;
36
36
  readonly logger: ILogger;
37
+ readonly registerPanel?: (panel: PanelContribution) => IDisposable;
37
38
  }
38
39
  export interface CodeLabPluginManifest {
39
40
  readonly id: string;
@@ -1,23 +1,51 @@
1
1
  import { type IDisposable } from '@code-lab/core';
2
2
  import type { IConfigurationService } from '@code-lab/settings';
3
+ export type SettingsScope = 'user' | 'workspace';
4
+ export interface SettingsInlineMountOptions {
5
+ readonly scope?: SettingsScope;
6
+ readonly onOpenJson?: () => void;
7
+ readonly onOpenSettingsJson?: () => void;
8
+ readonly onWorkspaceSettingsMutated?: (nextWorkspaceSettings: Record<string, unknown>) => void;
9
+ }
10
+ export type SettingsOpenOptions = SettingsInlineMountOptions;
3
11
  export interface SettingsDialogOptions {
4
12
  readonly configuration: IConfigurationService;
13
+ readonly scope?: SettingsScope;
5
14
  readonly onOpenSettingsJson?: () => void;
15
+ readonly onOpenJson?: () => void;
6
16
  readonly onExportSettings?: (json: string) => void;
7
17
  readonly onImportSettings?: () => void;
18
+ readonly onWorkspaceSettingsMutated?: (nextWorkspaceSettings: Record<string, unknown>) => void;
8
19
  }
9
20
  export declare class SettingsDialogController implements IDisposable {
10
- private readonly disposables;
21
+ private readonly dialogDisposables;
22
+ private readonly inlineDisposables;
11
23
  private readonly config;
12
24
  private readonly options;
25
+ private hostRoot;
13
26
  private dialogEl;
27
+ private inlineRootEl;
28
+ private runtimeCallbacks;
29
+ private inlineCallbacks;
30
+ private activeScope;
14
31
  private activeCategory;
15
32
  private searchQuery;
16
33
  constructor(hostRoot: HTMLElement, options: SettingsDialogOptions);
17
- private mount;
34
+ constructor(options: SettingsDialogOptions);
35
+ private buildSurfaceInnerHtml;
36
+ private getWorkspaceSnapshot;
37
+ private notifyWorkspaceMutated;
38
+ private invokeOpenJsonCallback;
39
+ private bindSurfaceEvents;
40
+ private mountDialog;
18
41
  get isOpen(): boolean;
19
- open(): void;
42
+ get isInlineMounted(): boolean;
43
+ open(options?: SettingsOpenOptions): void;
20
44
  close(): void;
45
+ mountInline(container: HTMLElement, options?: SettingsInlineMountOptions): void;
46
+ unmountInline(): void;
47
+ private renderAllActiveSurfaces;
48
+ private renderScopes;
21
49
  private renderCategories;
22
50
  private renderControl;
23
51
  private renderItems;
@@ -10,6 +10,11 @@ export interface ThemeDefinition {
10
10
  export declare const DARK_THEME: ThemeDefinition;
11
11
  export declare const LIGHT_THEME: ThemeDefinition;
12
12
  export declare const HIGH_CONTRAST_THEME: ThemeDefinition;
13
+ /**
14
+ * Picks `'#ffffff'` or `'#000000'` to maximize WCAG 2.1 contrast (>= 4.58:1)
15
+ * against a solid hex/rgb background color, returning `fallback` for dynamic CSS expressions.
16
+ */
17
+ export declare function pickContrastingFg(color: string, fallback?: string): string;
13
18
  export declare function parseCustomTheme(rawJsonc: string): ThemeDefinition;
14
19
  export interface IThemeService extends IDisposable {
15
20
  readonly activeTheme: ThemeDefinition;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.4.0 — Standalone Browser Code IDE & Virtual Runtime
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 & 71 UNIX Coreutils (pipes, redirects, globs, env vars, git & git clone)
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)