@innovatorved/code-lab 0.1.9 → 0.1.10

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 CHANGED
@@ -1,4 +1,4 @@
1
- # `@innovatorved/code-lab` Architecture (v0.1.9)
1
+ # `@innovatorved/code-lab` Architecture (v0.1.10)
2
2
 
3
3
  `@innovatorved/code-lab` is an embeddable, browser-native Node.js v22 + Bun v1.1 IDE, POSIX shell, PTY terminal, and virtual execution sandbox with self-contained browser bundles (zero runtime dependencies in `dist/*`; Zod schemas available under `@innovatorved/code-lab/schemas`).
4
4
 
package/README.md CHANGED
@@ -11,7 +11,7 @@ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorv
11
11
 
12
12
  ## Features
13
13
 
14
- - **Modular Architecture (`v0.1.9`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, and PTY Terminal. Curriculum features (Guided Steps, Mode Switcher, and JS/TS switcher) are encapsulated in an opt-in modular extension (`@innovatorved/code-lab/extensions/guided-lab`).
14
+ - **Modular Architecture (`v0.1.10`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, and PTY Terminal. Curriculum features (Guided Steps, Mode Switcher, and JS/TS switcher) are encapsulated in an opt-in modular extension (`@innovatorved/code-lab/extensions/guided-lab`).
15
15
  - **End-to-End TypeScript & Zod Type Safety**: Written in TypeScript with strict runtime schemas and inferred types (`z.infer<typeof ...>`) for workbench options, guided labs, runtime execution, and git cloning.
16
16
  - **Public GitHub Repository Cloning (`git clone`)**: Clone any public GitHub repository (`git clone https://github.com/owner/repo` or `git clone owner/repo --branch main` in the terminal, or `await lab.cloneRepo('owner/repo')` via the SDK) directly into `/workspace` with zero authentication required (automatic GitHub Trees API + jsDelivr unlimited fallback). Clone progress (`remote: Enumerating objects…`, `Receiving objects: n%…`) streams into the terminal in real time as it downloads.
17
17
  - **Interactive IDE Workbench**: Multi-file Monaco editor, collapsible hierarchical file tree with drag-and-drop, a workspace **folder switcher** (breadcrumb dropdown that scopes the explorer to any subfolder), decoupled editor tabs, Command Palette (`Cmd+Shift+P`), Quick Open (`Cmd+P`), breadcrumbs, and line-by-line solution diff viewer.
package/dist/code-lab.css CHANGED
@@ -4259,19 +4259,20 @@ code-lab,
4259
4259
  display: flex;
4260
4260
  flex-direction: column;
4261
4261
  height: 100%;
4262
- min-height: 260px;
4262
+ min-height: 0;
4263
4263
  gap: 8px;
4264
4264
  }
4265
4265
 
4266
4266
  .codelab-preview-chrome {
4267
4267
  display: flex;
4268
4268
  align-items: center;
4269
- gap: 8px;
4269
+ gap: 6px;
4270
4270
  flex-wrap: nowrap;
4271
4271
  padding: 6px 8px;
4272
4272
  background: var(--cl-bg-panel);
4273
4273
  border: 1px solid var(--cl-border);
4274
4274
  border-radius: var(--cl-radius-md);
4275
+ flex-shrink: 0;
4275
4276
  }
4276
4277
 
4277
4278
  .codelab-preview-nav { display: flex; gap: 2px; flex: 0 0 auto; }
@@ -4294,7 +4295,7 @@ code-lab,
4294
4295
  .codelab-preview-btn:disabled { opacity: 0.35; cursor: default; }
4295
4296
 
4296
4297
  .codelab-preview-port-select {
4297
- flex: 0 0 auto;
4298
+ flex: 0 1 auto;
4298
4299
  height: 28px;
4299
4300
  background: var(--cl-bg-elevated);
4300
4301
  color: var(--cl-fg);
@@ -4302,12 +4303,16 @@ code-lab,
4302
4303
  border-radius: var(--cl-radius-sm);
4303
4304
  font-size: 12px;
4304
4305
  padding: 0 6px;
4305
- max-width: 200px;
4306
+ max-width: 170px;
4307
+ }
4308
+
4309
+ .codelab-preview-split .codelab-preview-port-select {
4310
+ max-width: 118px;
4306
4311
  }
4307
4312
 
4308
4313
  .codelab-preview-url-input {
4309
- flex: 1 1 auto;
4310
- min-width: 0;
4314
+ flex: 1 1 160px;
4315
+ min-width: 120px;
4311
4316
  height: 28px;
4312
4317
  background: var(--cl-bg);
4313
4318
  color: var(--cl-fg);
@@ -4324,8 +4329,8 @@ code-lab,
4324
4329
 
4325
4330
  /* CSP badge: which remote hosts the current preview may reach. */
4326
4331
  .codelab-preview-csp {
4327
- flex: 0 0 auto;
4328
- max-width: 220px;
4332
+ flex: 0 1 auto;
4333
+ max-width: 180px;
4329
4334
  overflow: hidden;
4330
4335
  text-overflow: ellipsis;
4331
4336
  white-space: nowrap;
@@ -4338,6 +4343,10 @@ code-lab,
4338
4343
  background: var(--cl-bg-elevated);
4339
4344
  }
4340
4345
 
4346
+ .codelab-preview-split .codelab-preview-csp {
4347
+ max-width: 110px;
4348
+ }
4349
+
4341
4350
  .codelab-preview-csp--blocked {
4342
4351
  color: var(--cl-red);
4343
4352
  border-color: var(--cl-red);
@@ -4345,7 +4354,7 @@ code-lab,
4345
4354
 
4346
4355
  .codelab-preview-viewport {
4347
4356
  flex: 1 1 auto;
4348
- min-height: 180px;
4357
+ min-height: 120px;
4349
4358
  display: flex;
4350
4359
  justify-content: center;
4351
4360
  background: var(--cl-bg);
@@ -4430,12 +4439,20 @@ code-lab,
4430
4439
  }
4431
4440
 
4432
4441
  /* ── Split-Pane Web Preview, Maximize Mode & Inline Console ─────────────── */
4442
+ .codelab-workspace.has-preview-split {
4443
+ grid-template-columns: var(--cl-explorer-width, 196px) 4px minmax(260px, 1fr) 5px minmax(240px, var(--cl-preview-split-width, 44%));
4444
+ }
4445
+
4446
+ .codelab.files-collapsed .codelab-workspace.has-preview-split {
4447
+ grid-template-columns: 0px 0px minmax(260px, 1fr) 5px minmax(240px, var(--cl-preview-split-width, 44%));
4448
+ }
4449
+
4433
4450
  .codelab-preview-split {
4434
4451
  display: none;
4435
4452
  flex-direction: column;
4436
- width: var(--cl-preview-split-width, 44%);
4437
- min-width: 240px;
4438
- max-width: 65%;
4453
+ width: 100%;
4454
+ /* Width comes from the grid track so the pane can shrink with the viewport. */
4455
+ min-width: 0;
4439
4456
  height: 100%;
4440
4457
  background: var(--cl-bg-panel);
4441
4458
  border-left: 1px solid var(--cl-border);
@@ -4560,7 +4577,7 @@ code-lab,
4560
4577
  /* ── Ports, Mini HTTP Client & Network Inspector Drawer UI ──────────────── */
4561
4578
  .codelab-ports-panel {
4562
4579
  display: grid;
4563
- grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.25fr);
4580
+ grid-template-columns: minmax(360px, 1.25fr) minmax(320px, 1fr);
4564
4581
  gap: 12px;
4565
4582
  padding: 10px 12px;
4566
4583
  height: 100%;
@@ -4678,7 +4695,7 @@ code-lab,
4678
4695
  text-transform: uppercase;
4679
4696
  letter-spacing: 0.03em;
4680
4697
  color: var(--cl-fg-muted);
4681
- padding: 6px 8px;
4698
+ padding: 6px 6px;
4682
4699
  border-bottom: 1px solid var(--cl-border);
4683
4700
  background: var(--cl-bg-elevated);
4684
4701
  white-space: nowrap;
@@ -4686,7 +4703,7 @@ code-lab,
4686
4703
 
4687
4704
  .codelab-ports-table td,
4688
4705
  .codelab-net-table td {
4689
- padding: 6px 8px;
4706
+ padding: 6px 6px;
4690
4707
  border-bottom: 1px solid var(--cl-border);
4691
4708
  color: var(--cl-fg);
4692
4709
  vertical-align: middle;
@@ -5085,3 +5102,30 @@ code-lab,
5085
5102
  white-space: pre-wrap;
5086
5103
  word-break: break-word;
5087
5104
  }
5105
+
5106
+ /* ── Split-Pane Web Preview: responsive behaviour ────────────────────────────
5107
+ These must come after the base `.codelab-workspace.has-preview-split` rule
5108
+ above: equal specificity, later wins. */
5109
+ @media (max-width: 900px) {
5110
+ /* Keep the split, but give the editor a floor and cap the preview share. */
5111
+ .codelab-workspace.has-preview-split {
5112
+ grid-template-columns: 155px 4px minmax(180px, 1fr) 5px minmax(200px, min(42%, var(--cl-preview-split-width, 44%)));
5113
+ }
5114
+ .codelab.files-collapsed .codelab-workspace.has-preview-split {
5115
+ grid-template-columns: 0px 0px minmax(180px, 1fr) 5px minmax(200px, min(42%, var(--cl-preview-split-width, 44%)));
5116
+ }
5117
+ }
5118
+
5119
+ @media (max-width: 680px) {
5120
+ /* A five-column split cannot fit a phone: stack the preview under the editor
5121
+ instead of letting both shrink to nothing. The explorer and its splitter are
5122
+ hidden at this width, so only editor, splitter and preview are placed. */
5123
+ .codelab-workspace.has-preview-split {
5124
+ grid-template-columns: 1fr;
5125
+ grid-template-rows: minmax(140px, 1fr) 5px 45%;
5126
+ }
5127
+ .codelab-preview-split {
5128
+ border-left: 0;
5129
+ border-top: 1px solid var(--cl-border);
5130
+ }
5131
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TypeScript Definitions for @innovatorved/code-lab v0.1.9
2
+ * TypeScript Definitions for @innovatorved/code-lab v0.1.10
3
3
  */
4
4
 
5
5
  export interface CodeLabStep {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -146,7 +146,7 @@ var CodeLabCsp = (() => {
146
146
  const host = normalizeOrigin(options.hostOrigin);
147
147
  const self = host || "'self'";
148
148
  const directive = (name, parts) => `${name} ${unique(parts).join(" ")}`;
149
- const script = () => [self, "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
149
+ const script = () => [self, "data:", "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
150
150
  const style = () => [self, "'unsafe-inline'"].concat(sourcesFor(mode, allow, "styleSrc"));
151
151
  const withData = (key) => [self, "data:", "blob:"].concat(sourcesFor(mode, allow, key));
152
152
  return [
@@ -13181,6 +13181,36 @@ if (typeof module !== 'undefined' && module.exports) {
13181
13181
  return imports;
13182
13182
  }
13183
13183
 
13184
+ // Some templates pin a CDN URL in the source instead of importing a bare
13185
+ // specifier, e.g. `import React from "https://cdn.jsdelivr.net/npm/react@19.3.1/+esm"`.
13186
+ // Those URL specifiers are resolved by the browser directly, so they bypass the
13187
+ // generated import map (and with it the project's declared version and the
13188
+ // multi-CDN fallback). Import maps can remap URL specifiers, so alias each
13189
+ // literal URL found in the project to the resolved bare-specifier URL.
13190
+ // The pinned version is kept when the project has no dependency to resolve.
13191
+ const PINNED_CDN_URL_RE = /https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;
13192
+
13193
+ function aliasPinnedCdnUrls(vfs, rootDir, text, importMap) {
13194
+ if (!text || typeof text !== 'string') return;
13195
+ const re = new RegExp(PINNED_CDN_URL_RE.source, 'g');
13196
+ let match;
13197
+ while ((match = re.exec(text)) !== null) {
13198
+ const url = match[0];
13199
+ const pkgName = decodeURIComponent(match[1]);
13200
+ const rest = match[2];
13201
+ const pinnedVersion = rest.split(/[\/?]/)[0];
13202
+ const tail = rest.slice(pinnedVersion.length);
13203
+ const rawSubpath = tail.startsWith('/') && tail !== '/+esm' ? tail.slice(1).split(/[?#]/)[0] : '';
13204
+ const subpath = rawSubpath.replace(/^\/+|\/+$/g, '');
13205
+ const bare = subpath ? `${pkgName}/${subpath}` : pkgName;
13206
+
13207
+ const declared = resolveBareVersion(vfs, rootDir, pkgName);
13208
+ const version = declared && declared !== 'latest' ? declared : decodeURIComponent(pinnedVersion);
13209
+ const target = importMap[bare] || cdnEsmUrl(pkgName, version, subpath || undefined);
13210
+ if (target && target !== url) importMap[url] = target;
13211
+ }
13212
+ }
13213
+
13184
13214
  function collectPreviewScriptFiles(vfs, rootDir, maxFiles = 200) {
13185
13215
  const files = [];
13186
13216
  const walk = (dir, depth) => {
@@ -13308,6 +13338,8 @@ if (typeof module !== 'undefined' && module.exports) {
13308
13338
  }
13309
13339
 
13310
13340
  const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
13341
+ for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
13342
+ aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
13311
13343
  for (const f of scriptFiles) {
13312
13344
  const compiled = transpileAndRewriteLocalImports(f.content, f.full);
13313
13345
  const key = toLocalImportKey(f.full);
@@ -18746,7 +18778,7 @@ if (typeof module !== 'undefined' && module.exports) {
18746
18778
 
18747
18779
  // The bundler rewrites this literal from package.json at build time. Keeping
18748
18780
  // the fallback in sync lets tests require src/workbench.js directly.
18749
- const CODELAB_VERSION = '0.1.9';
18781
+ const CODELAB_VERSION = '0.1.10';
18750
18782
 
18751
18783
  // Ambient TypeScript declarations for Node.js built-ins inside Monaco
18752
18784
  const NODE_AMBIENT_DTS = `
@@ -20053,6 +20085,11 @@ declare module 'bun:sqlite' {
20053
20085
  this.explorerWidth = (typeof this.savedState?.explorerWidth === 'number' && this.savedState.explorerWidth >= 120)
20054
20086
  ? this.savedState.explorerWidth
20055
20087
  : 196;
20088
+ // 0 = use the default 44% track; otherwise a pixel width chosen by dragging
20089
+ // the preview splitter.
20090
+ this.previewSplitWidth = (typeof this.savedState?.previewSplitWidth === 'number' && this.savedState.previewSplitWidth >= 200)
20091
+ ? this.savedState.previewSplitWidth
20092
+ : 0;
20056
20093
  this.folderSwitcherOpen = false;
20057
20094
  this.creatingItem = null; // { type: 'file' | 'folder', parentFolder: string } | null
20058
20095
  this.renamingItem = null;
@@ -20445,7 +20482,8 @@ declare module 'bun:sqlite' {
20445
20482
  folders: Array.from(this.folders || []),
20446
20483
  collapsedFolders: Array.from(this.collapsedFolders || []),
20447
20484
  explorerFolder: this.explorerFolder || '',
20448
- explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined
20485
+ explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined,
20486
+ previewSplitWidth: this.previewSplitWidth || undefined
20449
20487
  };
20450
20488
  this.savedState = state;
20451
20489
  if (this.options && this.options.persistState === false) {
@@ -20707,7 +20745,9 @@ declare module 'bun:sqlite' {
20707
20745
  const themeAttr = this.themeOption !== 'auto' ? `data-theme="${escapeHtml(this.themeOption)}"` : '';
20708
20746
  const brandLabel = (this.title && this.title !== 'custom-lab' && this.title !== this.labId) ? this.title : 'code-lab';
20709
20747
  const isGuideCollapsed = !this.hasGuidedLab || this.mode === 'sandbox' || !this.steps.length;
20710
- const explorerStyle = `style="--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px"`;
20748
+ const shellVars = [`--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px`];
20749
+ if (this.previewSplitWidth) shellVars.push(`--cl-preview-split-width:${Math.round(this.previewSplitWidth)}px`);
20750
+ const explorerStyle = `style="${shellVars.join(';')}"`;
20711
20751
  this.container.innerHTML = `
20712
20752
  <div class="codelab codelab-workbench ${isGuideCollapsed ? 'guide-collapsed' : ''}" id="codelab-${escapeHtml(this.labId)}" ${themeAttr} ${explorerStyle}>
20713
20753
  <!-- Top Bar -->
@@ -22102,6 +22142,7 @@ declare module 'bun:sqlite' {
22102
22142
  }
22103
22143
 
22104
22144
  if (this.drawerTab === 'preview') {
22145
+ bodyEl.scrollTop = 0;
22105
22146
  this._renderWebPreview(bodyEl);
22106
22147
  return;
22107
22148
  }
@@ -23550,9 +23591,11 @@ declare module 'bun:sqlite' {
23550
23591
  _togglePreviewDock() {
23551
23592
  this.previewState.dockMode = this.previewState.dockMode === 'split' ? 'bottom' : 'split';
23552
23593
  this._previewRenderKey = null;
23594
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
23553
23595
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
23554
23596
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
23555
23597
  if (this.previewState.dockMode === 'split') {
23598
+ if (ws) ws.classList.add('has-preview-split');
23556
23599
  if (splitBar) splitBar.style.display = 'block';
23557
23600
  if (splitHost) {
23558
23601
  splitHost.style.display = 'flex';
@@ -23564,6 +23607,7 @@ declare module 'bun:sqlite' {
23564
23607
  this._renderDrawerBody();
23565
23608
  }
23566
23609
  } else {
23610
+ if (ws) ws.classList.remove('has-preview-split');
23567
23611
  if (splitBar) splitBar.style.display = 'none';
23568
23612
  if (splitHost) {
23569
23613
  splitHost.style.display = 'none';
@@ -23663,9 +23707,11 @@ declare module 'bun:sqlite' {
23663
23707
  this._warnPreviewIsolation();
23664
23708
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
23665
23709
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
23710
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
23666
23711
 
23667
23712
  let targetHost = bodyEl;
23668
23713
  if (this.previewState.dockMode === 'split' && splitHost) {
23714
+ if (ws) ws.classList.add('has-preview-split');
23669
23715
  if (splitBar) splitBar.style.display = 'block';
23670
23716
  splitHost.style.display = 'flex';
23671
23717
  if (bodyEl !== splitHost) {
@@ -23678,6 +23724,7 @@ declare module 'bun:sqlite' {
23678
23724
  }
23679
23725
  targetHost = splitHost;
23680
23726
  } else {
23727
+ if (ws) ws.classList.remove('has-preview-split');
23681
23728
  if (splitBar) splitBar.style.display = 'none';
23682
23729
  if (splitHost && bodyEl !== splitHost) {
23683
23730
  splitHost.style.display = 'none';
@@ -25387,8 +25434,10 @@ declare module 'bun:sqlite' {
25387
25434
  const pSplitter = this.container.querySelector('#cl-splitter-preview');
25388
25435
  if (pSplitter) {
25389
25436
  pSplitter.addEventListener('dblclick', () => {
25390
- shell.style.setProperty('--cl-preview-split-width', '44%');
25437
+ this.previewSplitWidth = 0;
25438
+ shell.style.removeProperty('--cl-preview-split-width');
25391
25439
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
25440
+ this._saveState();
25392
25441
  });
25393
25442
 
25394
25443
  pSplitter.addEventListener('pointerdown', e => {
@@ -25403,6 +25452,7 @@ declare module 'bun:sqlite' {
25403
25452
  const minW = 240;
25404
25453
  const maxW = Math.max(minW, Math.floor(rect.width * 0.65));
25405
25454
  const nextW = Math.min(maxW, Math.max(minW, Math.round(rect.right - ev.clientX)));
25455
+ this.previewSplitWidth = nextW;
25406
25456
  shell.style.setProperty('--cl-preview-split-width', `${nextW}px`);
25407
25457
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
25408
25458
  };
@@ -25413,6 +25463,7 @@ declare module 'bun:sqlite' {
25413
25463
  try { pSplitter.releasePointerCapture(ev.pointerId); } catch (err) { this.logger.debug('releasePointerCapture failed.', err); }
25414
25464
  pSplitter.removeEventListener('pointermove', onMove);
25415
25465
  pSplitter.removeEventListener('pointerup', onUp);
25466
+ this._saveState();
25416
25467
  };
25417
25468
 
25418
25469
  pSplitter.addEventListener('pointermove', onMove);
@@ -27230,7 +27281,7 @@ const PTYTerminalEngine = CodeLabTerminal ? CodeLabTerminal.PTYTerminalEngine :
27230
27281
  const mount = CodeLab ? CodeLab.mount : null;
27231
27282
  const create = CodeLab ? CodeLab.create : null;
27232
27283
  const unmount = CodeLab ? CodeLab.unmount : null;
27233
- const version = CodeLab ? CodeLab.version : '0.1.9';
27284
+ const version = CodeLab ? CodeLab.version : '0.1.10';
27234
27285
  const renderMarkdown = CodeLab ? CodeLab.renderMarkdown : null;
27235
27286
  const renderSimpleMarkdown = CodeLab ? CodeLab.renderSimpleMarkdown : null;
27236
27287
  const cloneRepo = CodeLab ? CodeLab.cloneRepo : null;
package/dist/code-lab.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -147,7 +147,7 @@ var CodeLabCsp = (() => {
147
147
  const host = normalizeOrigin(options.hostOrigin);
148
148
  const self = host || "'self'";
149
149
  const directive = (name, parts) => `${name} ${unique(parts).join(" ")}`;
150
- const script = () => [self, "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
150
+ const script = () => [self, "data:", "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
151
151
  const style = () => [self, "'unsafe-inline'"].concat(sourcesFor(mode, allow, "styleSrc"));
152
152
  const withData = (key) => [self, "data:", "blob:"].concat(sourcesFor(mode, allow, key));
153
153
  return [
@@ -13184,6 +13184,36 @@ if (typeof module !== 'undefined' && module.exports) {
13184
13184
  return imports;
13185
13185
  }
13186
13186
 
13187
+ // Some templates pin a CDN URL in the source instead of importing a bare
13188
+ // specifier, e.g. `import React from "https://cdn.jsdelivr.net/npm/react@19.3.1/+esm"`.
13189
+ // Those URL specifiers are resolved by the browser directly, so they bypass the
13190
+ // generated import map (and with it the project's declared version and the
13191
+ // multi-CDN fallback). Import maps can remap URL specifiers, so alias each
13192
+ // literal URL found in the project to the resolved bare-specifier URL.
13193
+ // The pinned version is kept when the project has no dependency to resolve.
13194
+ const PINNED_CDN_URL_RE = /https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;
13195
+
13196
+ function aliasPinnedCdnUrls(vfs, rootDir, text, importMap) {
13197
+ if (!text || typeof text !== 'string') return;
13198
+ const re = new RegExp(PINNED_CDN_URL_RE.source, 'g');
13199
+ let match;
13200
+ while ((match = re.exec(text)) !== null) {
13201
+ const url = match[0];
13202
+ const pkgName = decodeURIComponent(match[1]);
13203
+ const rest = match[2];
13204
+ const pinnedVersion = rest.split(/[\/?]/)[0];
13205
+ const tail = rest.slice(pinnedVersion.length);
13206
+ const rawSubpath = tail.startsWith('/') && tail !== '/+esm' ? tail.slice(1).split(/[?#]/)[0] : '';
13207
+ const subpath = rawSubpath.replace(/^\/+|\/+$/g, '');
13208
+ const bare = subpath ? `${pkgName}/${subpath}` : pkgName;
13209
+
13210
+ const declared = resolveBareVersion(vfs, rootDir, pkgName);
13211
+ const version = declared && declared !== 'latest' ? declared : decodeURIComponent(pinnedVersion);
13212
+ const target = importMap[bare] || cdnEsmUrl(pkgName, version, subpath || undefined);
13213
+ if (target && target !== url) importMap[url] = target;
13214
+ }
13215
+ }
13216
+
13187
13217
  function collectPreviewScriptFiles(vfs, rootDir, maxFiles = 200) {
13188
13218
  const files = [];
13189
13219
  const walk = (dir, depth) => {
@@ -13311,6 +13341,8 @@ if (typeof module !== 'undefined' && module.exports) {
13311
13341
  }
13312
13342
 
13313
13343
  const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
13344
+ for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
13345
+ aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
13314
13346
  for (const f of scriptFiles) {
13315
13347
  const compiled = transpileAndRewriteLocalImports(f.content, f.full);
13316
13348
  const key = toLocalImportKey(f.full);
@@ -18753,7 +18785,7 @@ if (typeof module !== 'undefined' && module.exports) {
18753
18785
 
18754
18786
  // The bundler rewrites this literal from package.json at build time. Keeping
18755
18787
  // the fallback in sync lets tests require src/workbench.js directly.
18756
- const CODELAB_VERSION = '0.1.9';
18788
+ const CODELAB_VERSION = '0.1.10';
18757
18789
 
18758
18790
  // Ambient TypeScript declarations for Node.js built-ins inside Monaco
18759
18791
  const NODE_AMBIENT_DTS = `
@@ -20060,6 +20092,11 @@ declare module 'bun:sqlite' {
20060
20092
  this.explorerWidth = (typeof this.savedState?.explorerWidth === 'number' && this.savedState.explorerWidth >= 120)
20061
20093
  ? this.savedState.explorerWidth
20062
20094
  : 196;
20095
+ // 0 = use the default 44% track; otherwise a pixel width chosen by dragging
20096
+ // the preview splitter.
20097
+ this.previewSplitWidth = (typeof this.savedState?.previewSplitWidth === 'number' && this.savedState.previewSplitWidth >= 200)
20098
+ ? this.savedState.previewSplitWidth
20099
+ : 0;
20063
20100
  this.folderSwitcherOpen = false;
20064
20101
  this.creatingItem = null; // { type: 'file' | 'folder', parentFolder: string } | null
20065
20102
  this.renamingItem = null;
@@ -20452,7 +20489,8 @@ declare module 'bun:sqlite' {
20452
20489
  folders: Array.from(this.folders || []),
20453
20490
  collapsedFolders: Array.from(this.collapsedFolders || []),
20454
20491
  explorerFolder: this.explorerFolder || '',
20455
- explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined
20492
+ explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined,
20493
+ previewSplitWidth: this.previewSplitWidth || undefined
20456
20494
  };
20457
20495
  this.savedState = state;
20458
20496
  if (this.options && this.options.persistState === false) {
@@ -20714,7 +20752,9 @@ declare module 'bun:sqlite' {
20714
20752
  const themeAttr = this.themeOption !== 'auto' ? `data-theme="${escapeHtml(this.themeOption)}"` : '';
20715
20753
  const brandLabel = (this.title && this.title !== 'custom-lab' && this.title !== this.labId) ? this.title : 'code-lab';
20716
20754
  const isGuideCollapsed = !this.hasGuidedLab || this.mode === 'sandbox' || !this.steps.length;
20717
- const explorerStyle = `style="--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px"`;
20755
+ const shellVars = [`--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px`];
20756
+ if (this.previewSplitWidth) shellVars.push(`--cl-preview-split-width:${Math.round(this.previewSplitWidth)}px`);
20757
+ const explorerStyle = `style="${shellVars.join(';')}"`;
20718
20758
  this.container.innerHTML = `
20719
20759
  <div class="codelab codelab-workbench ${isGuideCollapsed ? 'guide-collapsed' : ''}" id="codelab-${escapeHtml(this.labId)}" ${themeAttr} ${explorerStyle}>
20720
20760
  <!-- Top Bar -->
@@ -22109,6 +22149,7 @@ declare module 'bun:sqlite' {
22109
22149
  }
22110
22150
 
22111
22151
  if (this.drawerTab === 'preview') {
22152
+ bodyEl.scrollTop = 0;
22112
22153
  this._renderWebPreview(bodyEl);
22113
22154
  return;
22114
22155
  }
@@ -23557,9 +23598,11 @@ declare module 'bun:sqlite' {
23557
23598
  _togglePreviewDock() {
23558
23599
  this.previewState.dockMode = this.previewState.dockMode === 'split' ? 'bottom' : 'split';
23559
23600
  this._previewRenderKey = null;
23601
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
23560
23602
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
23561
23603
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
23562
23604
  if (this.previewState.dockMode === 'split') {
23605
+ if (ws) ws.classList.add('has-preview-split');
23563
23606
  if (splitBar) splitBar.style.display = 'block';
23564
23607
  if (splitHost) {
23565
23608
  splitHost.style.display = 'flex';
@@ -23571,6 +23614,7 @@ declare module 'bun:sqlite' {
23571
23614
  this._renderDrawerBody();
23572
23615
  }
23573
23616
  } else {
23617
+ if (ws) ws.classList.remove('has-preview-split');
23574
23618
  if (splitBar) splitBar.style.display = 'none';
23575
23619
  if (splitHost) {
23576
23620
  splitHost.style.display = 'none';
@@ -23670,9 +23714,11 @@ declare module 'bun:sqlite' {
23670
23714
  this._warnPreviewIsolation();
23671
23715
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
23672
23716
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
23717
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
23673
23718
 
23674
23719
  let targetHost = bodyEl;
23675
23720
  if (this.previewState.dockMode === 'split' && splitHost) {
23721
+ if (ws) ws.classList.add('has-preview-split');
23676
23722
  if (splitBar) splitBar.style.display = 'block';
23677
23723
  splitHost.style.display = 'flex';
23678
23724
  if (bodyEl !== splitHost) {
@@ -23685,6 +23731,7 @@ declare module 'bun:sqlite' {
23685
23731
  }
23686
23732
  targetHost = splitHost;
23687
23733
  } else {
23734
+ if (ws) ws.classList.remove('has-preview-split');
23688
23735
  if (splitBar) splitBar.style.display = 'none';
23689
23736
  if (splitHost && bodyEl !== splitHost) {
23690
23737
  splitHost.style.display = 'none';
@@ -25394,8 +25441,10 @@ declare module 'bun:sqlite' {
25394
25441
  const pSplitter = this.container.querySelector('#cl-splitter-preview');
25395
25442
  if (pSplitter) {
25396
25443
  pSplitter.addEventListener('dblclick', () => {
25397
- shell.style.setProperty('--cl-preview-split-width', '44%');
25444
+ this.previewSplitWidth = 0;
25445
+ shell.style.removeProperty('--cl-preview-split-width');
25398
25446
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
25447
+ this._saveState();
25399
25448
  });
25400
25449
 
25401
25450
  pSplitter.addEventListener('pointerdown', e => {
@@ -25410,6 +25459,7 @@ declare module 'bun:sqlite' {
25410
25459
  const minW = 240;
25411
25460
  const maxW = Math.max(minW, Math.floor(rect.width * 0.65));
25412
25461
  const nextW = Math.min(maxW, Math.max(minW, Math.round(rect.right - ev.clientX)));
25462
+ this.previewSplitWidth = nextW;
25413
25463
  shell.style.setProperty('--cl-preview-split-width', `${nextW}px`);
25414
25464
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
25415
25465
  };
@@ -25420,6 +25470,7 @@ declare module 'bun:sqlite' {
25420
25470
  try { pSplitter.releasePointerCapture(ev.pointerId); } catch (err) { this.logger.debug('releasePointerCapture failed.', err); }
25421
25471
  pSplitter.removeEventListener('pointermove', onMove);
25422
25472
  pSplitter.removeEventListener('pointerup', onUp);
25473
+ this._saveState();
25423
25474
  };
25424
25475
 
25425
25476
  pSplitter.addEventListener('pointermove', onMove);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.1.9
2
+ * @innovatorved/code-lab v0.1.10
3
3
  * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, and Git Engine.
4
4
  */
5
5
  export * from './schemas';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -144,7 +144,7 @@ var CodeLabCsp = (() => {
144
144
  const host = normalizeOrigin(options.hostOrigin);
145
145
  const self = host || "'self'";
146
146
  const directive = (name, parts) => `${name} ${unique(parts).join(" ")}`;
147
- const script = () => [self, "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
147
+ const script = () => [self, "data:", "blob:", "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, "scriptSrc"));
148
148
  const style = () => [self, "'unsafe-inline'"].concat(sourcesFor(mode, allow, "styleSrc"));
149
149
  const withData = (key) => [self, "data:", "blob:"].concat(sourcesFor(mode, allow, key));
150
150
  return [
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/schemas.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  /**
3
- * Zod Schemas and Inferred TypeScript Types for code-lab v0.1.9
3
+ * Zod Schemas and Inferred TypeScript Types for code-lab v0.1.10
4
4
  */
5
5
  export declare const GuidedStepSchema: z.ZodObject<{
6
6
  id: z.ZodString;
package/dist/shell.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -3143,6 +3143,36 @@ var CodeLabLogger = (() => {
3143
3143
  return imports;
3144
3144
  }
3145
3145
 
3146
+ // Some templates pin a CDN URL in the source instead of importing a bare
3147
+ // specifier, e.g. `import React from "https://cdn.jsdelivr.net/npm/react@19.3.1/+esm"`.
3148
+ // Those URL specifiers are resolved by the browser directly, so they bypass the
3149
+ // generated import map (and with it the project's declared version and the
3150
+ // multi-CDN fallback). Import maps can remap URL specifiers, so alias each
3151
+ // literal URL found in the project to the resolved bare-specifier URL.
3152
+ // The pinned version is kept when the project has no dependency to resolve.
3153
+ const PINNED_CDN_URL_RE = /https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;
3154
+
3155
+ function aliasPinnedCdnUrls(vfs, rootDir, text, importMap) {
3156
+ if (!text || typeof text !== 'string') return;
3157
+ const re = new RegExp(PINNED_CDN_URL_RE.source, 'g');
3158
+ let match;
3159
+ while ((match = re.exec(text)) !== null) {
3160
+ const url = match[0];
3161
+ const pkgName = decodeURIComponent(match[1]);
3162
+ const rest = match[2];
3163
+ const pinnedVersion = rest.split(/[\/?]/)[0];
3164
+ const tail = rest.slice(pinnedVersion.length);
3165
+ const rawSubpath = tail.startsWith('/') && tail !== '/+esm' ? tail.slice(1).split(/[?#]/)[0] : '';
3166
+ const subpath = rawSubpath.replace(/^\/+|\/+$/g, '');
3167
+ const bare = subpath ? `${pkgName}/${subpath}` : pkgName;
3168
+
3169
+ const declared = resolveBareVersion(vfs, rootDir, pkgName);
3170
+ const version = declared && declared !== 'latest' ? declared : decodeURIComponent(pinnedVersion);
3171
+ const target = importMap[bare] || cdnEsmUrl(pkgName, version, subpath || undefined);
3172
+ if (target && target !== url) importMap[url] = target;
3173
+ }
3174
+ }
3175
+
3146
3176
  function collectPreviewScriptFiles(vfs, rootDir, maxFiles = 200) {
3147
3177
  const files = [];
3148
3178
  const walk = (dir, depth) => {
@@ -3270,6 +3300,8 @@ var CodeLabLogger = (() => {
3270
3300
  }
3271
3301
 
3272
3302
  const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
3303
+ for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
3304
+ aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
3273
3305
  for (const f of scriptFiles) {
3274
3306
  const compiled = transpileAndRewriteLocalImports(f.content, f.full);
3275
3307
  const key = toLocalImportKey(f.full);
package/dist/shell.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -3144,6 +3144,36 @@ var CodeLabLogger = (() => {
3144
3144
  return imports;
3145
3145
  }
3146
3146
 
3147
+ // Some templates pin a CDN URL in the source instead of importing a bare
3148
+ // specifier, e.g. `import React from "https://cdn.jsdelivr.net/npm/react@19.3.1/+esm"`.
3149
+ // Those URL specifiers are resolved by the browser directly, so they bypass the
3150
+ // generated import map (and with it the project's declared version and the
3151
+ // multi-CDN fallback). Import maps can remap URL specifiers, so alias each
3152
+ // literal URL found in the project to the resolved bare-specifier URL.
3153
+ // The pinned version is kept when the project has no dependency to resolve.
3154
+ const PINNED_CDN_URL_RE = /https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;
3155
+
3156
+ function aliasPinnedCdnUrls(vfs, rootDir, text, importMap) {
3157
+ if (!text || typeof text !== 'string') return;
3158
+ const re = new RegExp(PINNED_CDN_URL_RE.source, 'g');
3159
+ let match;
3160
+ while ((match = re.exec(text)) !== null) {
3161
+ const url = match[0];
3162
+ const pkgName = decodeURIComponent(match[1]);
3163
+ const rest = match[2];
3164
+ const pinnedVersion = rest.split(/[\/?]/)[0];
3165
+ const tail = rest.slice(pinnedVersion.length);
3166
+ const rawSubpath = tail.startsWith('/') && tail !== '/+esm' ? tail.slice(1).split(/[?#]/)[0] : '';
3167
+ const subpath = rawSubpath.replace(/^\/+|\/+$/g, '');
3168
+ const bare = subpath ? `${pkgName}/${subpath}` : pkgName;
3169
+
3170
+ const declared = resolveBareVersion(vfs, rootDir, pkgName);
3171
+ const version = declared && declared !== 'latest' ? declared : decodeURIComponent(pinnedVersion);
3172
+ const target = importMap[bare] || cdnEsmUrl(pkgName, version, subpath || undefined);
3173
+ if (target && target !== url) importMap[url] = target;
3174
+ }
3175
+ }
3176
+
3147
3177
  function collectPreviewScriptFiles(vfs, rootDir, maxFiles = 200) {
3148
3178
  const files = [];
3149
3179
  const walk = (dir, depth) => {
@@ -3271,6 +3301,8 @@ var CodeLabLogger = (() => {
3271
3301
  }
3272
3302
 
3273
3303
  const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
3304
+ for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
3305
+ aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
3274
3306
  for (const f of scriptFiles) {
3275
3307
  const compiled = transpileAndRewriteLocalImports(f.content, f.full);
3276
3308
  const key = toLocalImportKey(f.full);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/terminal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.9 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.1.10 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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",
package/src/code-lab.css CHANGED
@@ -4259,19 +4259,20 @@ code-lab,
4259
4259
  display: flex;
4260
4260
  flex-direction: column;
4261
4261
  height: 100%;
4262
- min-height: 260px;
4262
+ min-height: 0;
4263
4263
  gap: 8px;
4264
4264
  }
4265
4265
 
4266
4266
  .codelab-preview-chrome {
4267
4267
  display: flex;
4268
4268
  align-items: center;
4269
- gap: 8px;
4269
+ gap: 6px;
4270
4270
  flex-wrap: nowrap;
4271
4271
  padding: 6px 8px;
4272
4272
  background: var(--cl-bg-panel);
4273
4273
  border: 1px solid var(--cl-border);
4274
4274
  border-radius: var(--cl-radius-md);
4275
+ flex-shrink: 0;
4275
4276
  }
4276
4277
 
4277
4278
  .codelab-preview-nav { display: flex; gap: 2px; flex: 0 0 auto; }
@@ -4294,7 +4295,7 @@ code-lab,
4294
4295
  .codelab-preview-btn:disabled { opacity: 0.35; cursor: default; }
4295
4296
 
4296
4297
  .codelab-preview-port-select {
4297
- flex: 0 0 auto;
4298
+ flex: 0 1 auto;
4298
4299
  height: 28px;
4299
4300
  background: var(--cl-bg-elevated);
4300
4301
  color: var(--cl-fg);
@@ -4302,12 +4303,16 @@ code-lab,
4302
4303
  border-radius: var(--cl-radius-sm);
4303
4304
  font-size: 12px;
4304
4305
  padding: 0 6px;
4305
- max-width: 200px;
4306
+ max-width: 170px;
4307
+ }
4308
+
4309
+ .codelab-preview-split .codelab-preview-port-select {
4310
+ max-width: 118px;
4306
4311
  }
4307
4312
 
4308
4313
  .codelab-preview-url-input {
4309
- flex: 1 1 auto;
4310
- min-width: 0;
4314
+ flex: 1 1 160px;
4315
+ min-width: 120px;
4311
4316
  height: 28px;
4312
4317
  background: var(--cl-bg);
4313
4318
  color: var(--cl-fg);
@@ -4324,8 +4329,8 @@ code-lab,
4324
4329
 
4325
4330
  /* CSP badge: which remote hosts the current preview may reach. */
4326
4331
  .codelab-preview-csp {
4327
- flex: 0 0 auto;
4328
- max-width: 220px;
4332
+ flex: 0 1 auto;
4333
+ max-width: 180px;
4329
4334
  overflow: hidden;
4330
4335
  text-overflow: ellipsis;
4331
4336
  white-space: nowrap;
@@ -4338,6 +4343,10 @@ code-lab,
4338
4343
  background: var(--cl-bg-elevated);
4339
4344
  }
4340
4345
 
4346
+ .codelab-preview-split .codelab-preview-csp {
4347
+ max-width: 110px;
4348
+ }
4349
+
4341
4350
  .codelab-preview-csp--blocked {
4342
4351
  color: var(--cl-red);
4343
4352
  border-color: var(--cl-red);
@@ -4345,7 +4354,7 @@ code-lab,
4345
4354
 
4346
4355
  .codelab-preview-viewport {
4347
4356
  flex: 1 1 auto;
4348
- min-height: 180px;
4357
+ min-height: 120px;
4349
4358
  display: flex;
4350
4359
  justify-content: center;
4351
4360
  background: var(--cl-bg);
@@ -4430,12 +4439,20 @@ code-lab,
4430
4439
  }
4431
4440
 
4432
4441
  /* ── Split-Pane Web Preview, Maximize Mode & Inline Console ─────────────── */
4442
+ .codelab-workspace.has-preview-split {
4443
+ grid-template-columns: var(--cl-explorer-width, 196px) 4px minmax(260px, 1fr) 5px minmax(240px, var(--cl-preview-split-width, 44%));
4444
+ }
4445
+
4446
+ .codelab.files-collapsed .codelab-workspace.has-preview-split {
4447
+ grid-template-columns: 0px 0px minmax(260px, 1fr) 5px minmax(240px, var(--cl-preview-split-width, 44%));
4448
+ }
4449
+
4433
4450
  .codelab-preview-split {
4434
4451
  display: none;
4435
4452
  flex-direction: column;
4436
- width: var(--cl-preview-split-width, 44%);
4437
- min-width: 240px;
4438
- max-width: 65%;
4453
+ width: 100%;
4454
+ /* Width comes from the grid track so the pane can shrink with the viewport. */
4455
+ min-width: 0;
4439
4456
  height: 100%;
4440
4457
  background: var(--cl-bg-panel);
4441
4458
  border-left: 1px solid var(--cl-border);
@@ -4560,7 +4577,7 @@ code-lab,
4560
4577
  /* ── Ports, Mini HTTP Client & Network Inspector Drawer UI ──────────────── */
4561
4578
  .codelab-ports-panel {
4562
4579
  display: grid;
4563
- grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.25fr);
4580
+ grid-template-columns: minmax(360px, 1.25fr) minmax(320px, 1fr);
4564
4581
  gap: 12px;
4565
4582
  padding: 10px 12px;
4566
4583
  height: 100%;
@@ -4678,7 +4695,7 @@ code-lab,
4678
4695
  text-transform: uppercase;
4679
4696
  letter-spacing: 0.03em;
4680
4697
  color: var(--cl-fg-muted);
4681
- padding: 6px 8px;
4698
+ padding: 6px 6px;
4682
4699
  border-bottom: 1px solid var(--cl-border);
4683
4700
  background: var(--cl-bg-elevated);
4684
4701
  white-space: nowrap;
@@ -4686,7 +4703,7 @@ code-lab,
4686
4703
 
4687
4704
  .codelab-ports-table td,
4688
4705
  .codelab-net-table td {
4689
- padding: 6px 8px;
4706
+ padding: 6px 6px;
4690
4707
  border-bottom: 1px solid var(--cl-border);
4691
4708
  color: var(--cl-fg);
4692
4709
  vertical-align: middle;
@@ -5085,3 +5102,30 @@ code-lab,
5085
5102
  white-space: pre-wrap;
5086
5103
  word-break: break-word;
5087
5104
  }
5105
+
5106
+ /* ── Split-Pane Web Preview: responsive behaviour ────────────────────────────
5107
+ These must come after the base `.codelab-workspace.has-preview-split` rule
5108
+ above: equal specificity, later wins. */
5109
+ @media (max-width: 900px) {
5110
+ /* Keep the split, but give the editor a floor and cap the preview share. */
5111
+ .codelab-workspace.has-preview-split {
5112
+ grid-template-columns: 155px 4px minmax(180px, 1fr) 5px minmax(200px, min(42%, var(--cl-preview-split-width, 44%)));
5113
+ }
5114
+ .codelab.files-collapsed .codelab-workspace.has-preview-split {
5115
+ grid-template-columns: 0px 0px minmax(180px, 1fr) 5px minmax(200px, min(42%, var(--cl-preview-split-width, 44%)));
5116
+ }
5117
+ }
5118
+
5119
+ @media (max-width: 680px) {
5120
+ /* A five-column split cannot fit a phone: stack the preview under the editor
5121
+ instead of letting both shrink to nothing. The explorer and its splitter are
5122
+ hidden at this width, so only editor, splitter and preview are placed. */
5123
+ .codelab-workspace.has-preview-split {
5124
+ grid-template-columns: 1fr;
5125
+ grid-template-rows: minmax(140px, 1fr) 5px 45%;
5126
+ }
5127
+ .codelab-preview-split {
5128
+ border-left: 0;
5129
+ border-top: 1px solid var(--cl-border);
5130
+ }
5131
+ }
package/src/csp.ts CHANGED
@@ -195,7 +195,12 @@ export function buildPreviewPolicy(options: PreviewCspOptions = {}): string {
195
195
 
196
196
  const directive = (name: string, parts: string[]): string => `${name} ${unique(parts).join(' ')}`;
197
197
 
198
- const script = (): string[] => [self, 'blob:', "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, 'scriptSrc'));
198
+ // `data:` is required for scripts: the preview import map serves every local
199
+ // module as `data:text/javascript;...` so it works in a sandboxed frame (see
200
+ // buildHtmlPreviewResponse in src/shell.ts). Without it, any project with
201
+ // local ES modules fails to boot. `'unsafe-inline'` already allows inline
202
+ // script, so this does not widen the practical attack surface.
203
+ const script = (): string[] => [self, 'data:', 'blob:', "'unsafe-inline'", "'unsafe-eval'"].concat(sourcesFor(mode, allow, 'scriptSrc'));
199
204
  const style = (): string[] => [self, "'unsafe-inline'"].concat(sourcesFor(mode, allow, 'styleSrc'));
200
205
  const withData = (key: keyof PreviewCspSources): string[] => [self, 'data:', 'blob:'].concat(sourcesFor(mode, allow, key));
201
206
 
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.1.9
2
+ * @innovatorved/code-lab v0.1.10
3
3
  * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, and Git Engine.
4
4
  */
5
5
 
package/src/schemas.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  /**
4
- * Zod Schemas and Inferred TypeScript Types for code-lab v0.1.9
4
+ * Zod Schemas and Inferred TypeScript Types for code-lab v0.1.10
5
5
  */
6
6
 
7
7
  // ── 1. Guided Step ──────────────────────────────────────────────────────────
package/src/shell.ts CHANGED
@@ -3024,6 +3024,36 @@
3024
3024
  return imports;
3025
3025
  }
3026
3026
 
3027
+ // Some templates pin a CDN URL in the source instead of importing a bare
3028
+ // specifier, e.g. `import React from "https://cdn.jsdelivr.net/npm/react@19.3.1/+esm"`.
3029
+ // Those URL specifiers are resolved by the browser directly, so they bypass the
3030
+ // generated import map (and with it the project's declared version and the
3031
+ // multi-CDN fallback). Import maps can remap URL specifiers, so alias each
3032
+ // literal URL found in the project to the resolved bare-specifier URL.
3033
+ // The pinned version is kept when the project has no dependency to resolve.
3034
+ const PINNED_CDN_URL_RE = /https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;
3035
+
3036
+ function aliasPinnedCdnUrls(vfs, rootDir, text, importMap) {
3037
+ if (!text || typeof text !== 'string') return;
3038
+ const re = new RegExp(PINNED_CDN_URL_RE.source, 'g');
3039
+ let match;
3040
+ while ((match = re.exec(text)) !== null) {
3041
+ const url = match[0];
3042
+ const pkgName = decodeURIComponent(match[1]);
3043
+ const rest = match[2];
3044
+ const pinnedVersion = rest.split(/[\/?]/)[0];
3045
+ const tail = rest.slice(pinnedVersion.length);
3046
+ const rawSubpath = tail.startsWith('/') && tail !== '/+esm' ? tail.slice(1).split(/[?#]/)[0] : '';
3047
+ const subpath = rawSubpath.replace(/^\/+|\/+$/g, '');
3048
+ const bare = subpath ? `${pkgName}/${subpath}` : pkgName;
3049
+
3050
+ const declared = resolveBareVersion(vfs, rootDir, pkgName);
3051
+ const version = declared && declared !== 'latest' ? declared : decodeURIComponent(pinnedVersion);
3052
+ const target = importMap[bare] || cdnEsmUrl(pkgName, version, subpath || undefined);
3053
+ if (target && target !== url) importMap[url] = target;
3054
+ }
3055
+ }
3056
+
3027
3057
  function collectPreviewScriptFiles(vfs, rootDir, maxFiles = 200) {
3028
3058
  const files = [];
3029
3059
  const walk = (dir, depth) => {
@@ -3151,6 +3181,8 @@
3151
3181
  }
3152
3182
 
3153
3183
  const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
3184
+ for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
3185
+ aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
3154
3186
  for (const f of scriptFiles) {
3155
3187
  const compiled = transpileAndRewriteLocalImports(f.content, f.full);
3156
3188
  const key = toLocalImportKey(f.full);
package/src/workbench.ts CHANGED
@@ -57,7 +57,7 @@
57
57
 
58
58
  // The bundler rewrites this literal from package.json at build time. Keeping
59
59
  // the fallback in sync lets tests require src/workbench.js directly.
60
- const CODELAB_VERSION = '0.1.9';
60
+ const CODELAB_VERSION = '0.1.10';
61
61
 
62
62
  // Ambient TypeScript declarations for Node.js built-ins inside Monaco
63
63
  const NODE_AMBIENT_DTS = `
@@ -1364,6 +1364,11 @@ declare module 'bun:sqlite' {
1364
1364
  this.explorerWidth = (typeof this.savedState?.explorerWidth === 'number' && this.savedState.explorerWidth >= 120)
1365
1365
  ? this.savedState.explorerWidth
1366
1366
  : 196;
1367
+ // 0 = use the default 44% track; otherwise a pixel width chosen by dragging
1368
+ // the preview splitter.
1369
+ this.previewSplitWidth = (typeof this.savedState?.previewSplitWidth === 'number' && this.savedState.previewSplitWidth >= 200)
1370
+ ? this.savedState.previewSplitWidth
1371
+ : 0;
1367
1372
  this.folderSwitcherOpen = false;
1368
1373
  this.creatingItem = null; // { type: 'file' | 'folder', parentFolder: string } | null
1369
1374
  this.renamingItem = null;
@@ -1756,7 +1761,8 @@ declare module 'bun:sqlite' {
1756
1761
  folders: Array.from(this.folders || []),
1757
1762
  collapsedFolders: Array.from(this.collapsedFolders || []),
1758
1763
  explorerFolder: this.explorerFolder || '',
1759
- explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined
1764
+ explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined,
1765
+ previewSplitWidth: this.previewSplitWidth || undefined
1760
1766
  };
1761
1767
  this.savedState = state;
1762
1768
  if (this.options && this.options.persistState === false) {
@@ -2018,7 +2024,9 @@ declare module 'bun:sqlite' {
2018
2024
  const themeAttr = this.themeOption !== 'auto' ? `data-theme="${escapeHtml(this.themeOption)}"` : '';
2019
2025
  const brandLabel = (this.title && this.title !== 'custom-lab' && this.title !== this.labId) ? this.title : 'code-lab';
2020
2026
  const isGuideCollapsed = !this.hasGuidedLab || this.mode === 'sandbox' || !this.steps.length;
2021
- const explorerStyle = `style="--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px"`;
2027
+ const shellVars = [`--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px`];
2028
+ if (this.previewSplitWidth) shellVars.push(`--cl-preview-split-width:${Math.round(this.previewSplitWidth)}px`);
2029
+ const explorerStyle = `style="${shellVars.join(';')}"`;
2022
2030
  this.container.innerHTML = `
2023
2031
  <div class="codelab codelab-workbench ${isGuideCollapsed ? 'guide-collapsed' : ''}" id="codelab-${escapeHtml(this.labId)}" ${themeAttr} ${explorerStyle}>
2024
2032
  <!-- Top Bar -->
@@ -3413,6 +3421,7 @@ declare module 'bun:sqlite' {
3413
3421
  }
3414
3422
 
3415
3423
  if (this.drawerTab === 'preview') {
3424
+ bodyEl.scrollTop = 0;
3416
3425
  this._renderWebPreview(bodyEl);
3417
3426
  return;
3418
3427
  }
@@ -4861,9 +4870,11 @@ declare module 'bun:sqlite' {
4861
4870
  _togglePreviewDock() {
4862
4871
  this.previewState.dockMode = this.previewState.dockMode === 'split' ? 'bottom' : 'split';
4863
4872
  this._previewRenderKey = null;
4873
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
4864
4874
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
4865
4875
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
4866
4876
  if (this.previewState.dockMode === 'split') {
4877
+ if (ws) ws.classList.add('has-preview-split');
4867
4878
  if (splitBar) splitBar.style.display = 'block';
4868
4879
  if (splitHost) {
4869
4880
  splitHost.style.display = 'flex';
@@ -4875,6 +4886,7 @@ declare module 'bun:sqlite' {
4875
4886
  this._renderDrawerBody();
4876
4887
  }
4877
4888
  } else {
4889
+ if (ws) ws.classList.remove('has-preview-split');
4878
4890
  if (splitBar) splitBar.style.display = 'none';
4879
4891
  if (splitHost) {
4880
4892
  splitHost.style.display = 'none';
@@ -4974,9 +4986,11 @@ declare module 'bun:sqlite' {
4974
4986
  this._warnPreviewIsolation();
4975
4987
  const splitHost = this.container ? this.container.querySelector('#cl-preview-split') : null;
4976
4988
  const splitBar = this.container ? this.container.querySelector('#cl-splitter-preview') : null;
4989
+ const ws = this.container ? this.container.querySelector('.codelab-workspace') : null;
4977
4990
 
4978
4991
  let targetHost = bodyEl;
4979
4992
  if (this.previewState.dockMode === 'split' && splitHost) {
4993
+ if (ws) ws.classList.add('has-preview-split');
4980
4994
  if (splitBar) splitBar.style.display = 'block';
4981
4995
  splitHost.style.display = 'flex';
4982
4996
  if (bodyEl !== splitHost) {
@@ -4989,6 +5003,7 @@ declare module 'bun:sqlite' {
4989
5003
  }
4990
5004
  targetHost = splitHost;
4991
5005
  } else {
5006
+ if (ws) ws.classList.remove('has-preview-split');
4992
5007
  if (splitBar) splitBar.style.display = 'none';
4993
5008
  if (splitHost && bodyEl !== splitHost) {
4994
5009
  splitHost.style.display = 'none';
@@ -6698,8 +6713,10 @@ declare module 'bun:sqlite' {
6698
6713
  const pSplitter = this.container.querySelector('#cl-splitter-preview');
6699
6714
  if (pSplitter) {
6700
6715
  pSplitter.addEventListener('dblclick', () => {
6701
- shell.style.setProperty('--cl-preview-split-width', '44%');
6716
+ this.previewSplitWidth = 0;
6717
+ shell.style.removeProperty('--cl-preview-split-width');
6702
6718
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
6719
+ this._saveState();
6703
6720
  });
6704
6721
 
6705
6722
  pSplitter.addEventListener('pointerdown', e => {
@@ -6714,6 +6731,7 @@ declare module 'bun:sqlite' {
6714
6731
  const minW = 240;
6715
6732
  const maxW = Math.max(minW, Math.floor(rect.width * 0.65));
6716
6733
  const nextW = Math.min(maxW, Math.max(minW, Math.round(rect.right - ev.clientX)));
6734
+ this.previewSplitWidth = nextW;
6717
6735
  shell.style.setProperty('--cl-preview-split-width', `${nextW}px`);
6718
6736
  if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
6719
6737
  };
@@ -6724,6 +6742,7 @@ declare module 'bun:sqlite' {
6724
6742
  try { pSplitter.releasePointerCapture(ev.pointerId); } catch (err) { this.logger.debug('releasePointerCapture failed.', err); }
6725
6743
  pSplitter.removeEventListener('pointermove', onMove);
6726
6744
  pSplitter.removeEventListener('pointerup', onUp);
6745
+ this._saveState();
6727
6746
  };
6728
6747
 
6729
6748
  pSplitter.addEventListener('pointermove', onMove);