@innovatorved/code-lab 0.1.10 → 0.1.11
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/dist/code-lab.css +28 -0
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +163 -18
- package/dist/code-lab.js +162 -17
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +29 -4
- package/dist/runtime.js +29 -4
- package/dist/shell.esm.js +119 -9
- package/dist/shell.js +119 -9
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/package.json +1 -1
- package/src/code-lab.css +28 -0
- package/src/runtime.ts +28 -3
- package/src/shell.ts +118 -8
- package/src/workbench.ts +14 -4
package/dist/code-lab.css
CHANGED
|
@@ -4347,6 +4347,27 @@ code-lab,
|
|
|
4347
4347
|
max-width: 110px;
|
|
4348
4348
|
}
|
|
4349
4349
|
|
|
4350
|
+
/* The split pane is narrower than the drawer, so the single-row chrome would
|
|
4351
|
+
clip its right-hand controls. Wrap instead, and give the URL its own row. */
|
|
4352
|
+
.codelab-preview-split .codelab-preview-chrome {
|
|
4353
|
+
flex-wrap: wrap;
|
|
4354
|
+
row-gap: 4px;
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4357
|
+
.codelab-preview-split .codelab-preview-url-input {
|
|
4358
|
+
order: 10;
|
|
4359
|
+
flex: 1 1 100%;
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
/* Icon-only pop-out keeps the split chrome to two rows. */
|
|
4363
|
+
.codelab-preview-split [data-cl-action="preview-popout"] {
|
|
4364
|
+
padding: 0 6px;
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
.codelab-preview-split [data-cl-action="preview-popout"] > span {
|
|
4368
|
+
display: none;
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4350
4371
|
.codelab-preview-csp--blocked {
|
|
4351
4372
|
color: var(--cl-red);
|
|
4352
4373
|
border-color: var(--cl-red);
|
|
@@ -5107,6 +5128,13 @@ code-lab,
|
|
|
5107
5128
|
These must come after the base `.codelab-workspace.has-preview-split` rule
|
|
5108
5129
|
above: equal specificity, later wins. */
|
|
5109
5130
|
@media (max-width: 900px) {
|
|
5131
|
+
/* Device emulation and the allowlist badge are not useful in a narrow pane.
|
|
5132
|
+
The violation chip stays visible so blocked requests are still surfaced. */
|
|
5133
|
+
.codelab-preview-split .codelab-preview-modes,
|
|
5134
|
+
.codelab-preview-split #cl-preview-csp-badge {
|
|
5135
|
+
display: none;
|
|
5136
|
+
}
|
|
5137
|
+
|
|
5110
5138
|
/* Keep the split, but give the editor a floor and cap the preview share. */
|
|
5111
5139
|
.codelab-workspace.has-preview-split {
|
|
5112
5140
|
grid-template-columns: 155px 4px minmax(180px, 1fr) 5px minmax(200px, min(42%, var(--cl-preview-split-width, 44%)));
|
package/dist/code-lab.d.ts
CHANGED
package/dist/code-lab.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ============================================================
|
|
3
|
-
* @innovatorved/code-lab v0.1.
|
|
3
|
+
* @innovatorved/code-lab v0.1.11 — Standalone Browser Code IDE & Virtual Runtime
|
|
4
4
|
* ============================================================
|
|
5
5
|
* Features:
|
|
6
6
|
* - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
|
|
@@ -5932,6 +5932,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
5932
5932
|
if (/@jsx\b/.test(source)) return true;
|
|
5933
5933
|
if (source.indexOf('<>') !== -1) return true;
|
|
5934
5934
|
if (/<\/[A-Za-z]/.test(source)) return true;
|
|
5935
|
+
if (/<[A-Za-z_$][A-Za-z0-9_$:.\-]*\b[^>\n]*\/>/.test(source)) return true;
|
|
5935
5936
|
return false;
|
|
5936
5937
|
}
|
|
5937
5938
|
|
|
@@ -6009,6 +6010,23 @@ function __initVirtualRuntime(rootScope) {
|
|
|
6009
6010
|
return i;
|
|
6010
6011
|
}
|
|
6011
6012
|
|
|
6013
|
+
function isJsxCommentOnly(str) {
|
|
6014
|
+
if (!str) return true;
|
|
6015
|
+
let k = 0;
|
|
6016
|
+
while (k < str.length) {
|
|
6017
|
+
k = jsxSkipWs(str, k);
|
|
6018
|
+
if (k >= str.length) break;
|
|
6019
|
+
if (str[k] === '/' && (str[k + 1] === '/' || str[k + 1] === '*')) {
|
|
6020
|
+
const next = jsxSkipJsLiteral(str, k);
|
|
6021
|
+
if (next === -1) return false;
|
|
6022
|
+
k = next;
|
|
6023
|
+
} else {
|
|
6024
|
+
return false;
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
6027
|
+
return true;
|
|
6028
|
+
}
|
|
6029
|
+
|
|
6012
6030
|
function normalizeJsxText(raw) {
|
|
6013
6031
|
if (!raw) return '';
|
|
6014
6032
|
let t = raw.replace(/\r/g, '');
|
|
@@ -6152,8 +6170,12 @@ function __initVirtualRuntime(rootScope) {
|
|
|
6152
6170
|
}
|
|
6153
6171
|
if (c === '{') {
|
|
6154
6172
|
const br = jsxReadBraced(source, j, o);
|
|
6155
|
-
|
|
6156
|
-
|
|
6173
|
+
if (!isJsxCommentOnly(br.inner)) {
|
|
6174
|
+
const inner = jsxTransform(br.inner, o);
|
|
6175
|
+
if (inner && inner.trim()) {
|
|
6176
|
+
children.push(inner.indexOf('//') !== -1 && !inner.endsWith('\n') ? inner + '\n' : inner);
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6157
6179
|
j = br.next;
|
|
6158
6180
|
continue;
|
|
6159
6181
|
}
|
|
@@ -6218,7 +6240,8 @@ function __initVirtualRuntime(rootScope) {
|
|
|
6218
6240
|
// JSX/TSX must be rewritten before masking so JSX text is kept verbatim.
|
|
6219
6241
|
if (hasJsx) {
|
|
6220
6242
|
const { pragma, frag } = readJsxPragma(source);
|
|
6221
|
-
const
|
|
6243
|
+
const hasReactBinding = /\bimport\s+(?!type\b)(?:\*\s+as\s+React\b|React\b)|(?:\bconst|\blet|\bvar|\bfunction|\bclass)\s+React\b|\bReact\s*=/.test(source);
|
|
6244
|
+
const needsReact = pragma === 'React.createElement' && (keepEsm ? !hasReactBinding : !/\bReact\b/.test(source));
|
|
6222
6245
|
const transformed = jsxTransform(source, { pragma, frag });
|
|
6223
6246
|
if (transformed !== source) {
|
|
6224
6247
|
source = transformed;
|
|
@@ -6226,6 +6249,8 @@ function __initVirtualRuntime(rootScope) {
|
|
|
6226
6249
|
if (needsReact) {
|
|
6227
6250
|
source = (keepEsm ? 'import React from "react";\n' : 'const React = require("react");\n') + source;
|
|
6228
6251
|
}
|
|
6252
|
+
} else if (!isTS && !hasESM) {
|
|
6253
|
+
return source;
|
|
6229
6254
|
}
|
|
6230
6255
|
}
|
|
6231
6256
|
|
|
@@ -13176,6 +13201,12 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13176
13201
|
if (!pkgName) continue;
|
|
13177
13202
|
const subpath = spec.slice(pkgName.length).replace(/^\/+/, '');
|
|
13178
13203
|
const version = resolveBareVersion(vfs, rootDir, pkgName);
|
|
13204
|
+
if (subpath && /\.css$/i.test(subpath)) {
|
|
13205
|
+
const cssHref = `${CDN_ESM_BASE}/${pkgName}@${version}/${subpath.replace(/^\/+/, '')}`;
|
|
13206
|
+
const loader = `if(typeof document!=='undefined'){const l=document.createElement('link');l.rel='stylesheet';l.href=${JSON.stringify(cssHref)};document.head.appendChild(l);}export default ${JSON.stringify(cssHref)};`;
|
|
13207
|
+
imports[spec] = `data:text/javascript;charset=utf-8,${encodeURIComponent(loader)}`;
|
|
13208
|
+
continue;
|
|
13209
|
+
}
|
|
13179
13210
|
imports[spec] = cdnEsmUrl(pkgName, version, subpath || undefined);
|
|
13180
13211
|
}
|
|
13181
13212
|
return imports;
|
|
@@ -13196,6 +13227,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13196
13227
|
let match;
|
|
13197
13228
|
while ((match = re.exec(text)) !== null) {
|
|
13198
13229
|
const url = match[0];
|
|
13230
|
+
if (url.includes('${')) continue;
|
|
13199
13231
|
const pkgName = decodeURIComponent(match[1]);
|
|
13200
13232
|
const rest = match[2];
|
|
13201
13233
|
const pinnedVersion = rest.split(/[\/?]/)[0];
|
|
@@ -13240,6 +13272,33 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13240
13272
|
return files;
|
|
13241
13273
|
}
|
|
13242
13274
|
|
|
13275
|
+
function collectPreviewAssetFiles(vfs, rootDir, maxFiles = 200) {
|
|
13276
|
+
const files = [];
|
|
13277
|
+
const walk = (dir, depth) => {
|
|
13278
|
+
if (depth > 8 || files.length >= maxFiles) return;
|
|
13279
|
+
let entries = [];
|
|
13280
|
+
try { entries = vfs.readdirSync(dir); } catch (_) { return; }
|
|
13281
|
+
for (const name of entries) {
|
|
13282
|
+
if (name === 'node_modules' || name.startsWith('.')) continue;
|
|
13283
|
+
const full = PosixPath.join(dir, name);
|
|
13284
|
+
let st;
|
|
13285
|
+
try { st = vfs.statSync(full); } catch (_) { continue; }
|
|
13286
|
+
const dirFlag = st && (typeof st.isDirectory === 'function' ? st.isDirectory() : st.isDirectory);
|
|
13287
|
+
if (dirFlag) {
|
|
13288
|
+
walk(full, depth + 1);
|
|
13289
|
+
} else if (/\.(?:css|json|svg)$/i.test(name) && files.length < maxFiles) {
|
|
13290
|
+
try {
|
|
13291
|
+
const content = vfs.readFileSync(full, 'utf8');
|
|
13292
|
+
const rel = full.startsWith(rootDir + '/') ? full.slice(rootDir.length + 1) : name;
|
|
13293
|
+
files.push({ full, rel, content });
|
|
13294
|
+
} catch (_) {}
|
|
13295
|
+
}
|
|
13296
|
+
}
|
|
13297
|
+
};
|
|
13298
|
+
walk(rootDir, 0);
|
|
13299
|
+
return files;
|
|
13300
|
+
}
|
|
13301
|
+
|
|
13243
13302
|
function collectPreviewScripts(vfs, rootDir, maxFiles = 200) {
|
|
13244
13303
|
return collectPreviewScriptFiles(vfs, rootDir, maxFiles).map((f) => f.content);
|
|
13245
13304
|
}
|
|
@@ -13322,11 +13381,31 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13322
13381
|
return out;
|
|
13323
13382
|
};
|
|
13324
13383
|
|
|
13384
|
+
const inlineLocalCssImports = (cssText, cssDir) => {
|
|
13385
|
+
if (!cssText) return '';
|
|
13386
|
+
return cssText.replace(/@import\s+(?:url\(\s*['"]?([^'")]+)['"]?\s*\)|['"]([^'"]+)['"])\s*;?/gi, (full, u1, u2) => {
|
|
13387
|
+
const spec = (u1 || u2 || '').trim();
|
|
13388
|
+
if (!spec || /^(?:https?:|data:|\/\/)/i.test(spec)) return full;
|
|
13389
|
+
if (spec === 'tailwindcss') return '';
|
|
13390
|
+
const subTarget = resolveLocalTarget(cssDir, spec);
|
|
13391
|
+
if (subTarget && /\.css$/i.test(subTarget)) {
|
|
13392
|
+
const subCss = readText(subTarget);
|
|
13393
|
+
if (subCss !== null) return subCss;
|
|
13394
|
+
}
|
|
13395
|
+
return '';
|
|
13396
|
+
});
|
|
13397
|
+
};
|
|
13398
|
+
|
|
13325
13399
|
const buildHtmlPreviewResponse = (htmlBody, htmlTargetPath) => {
|
|
13326
13400
|
const scriptFiles = collectPreviewScriptFiles(ctx.vfs, rootDir);
|
|
13401
|
+
const assetFiles = collectPreviewAssetFiles(ctx.vfs, rootDir);
|
|
13327
13402
|
const specifiers = new Set();
|
|
13403
|
+
const compiledScripts = [];
|
|
13328
13404
|
for (const f of scriptFiles) {
|
|
13329
13405
|
for (const s of extractBareSpecifiers(f.content)) specifiers.add(s);
|
|
13406
|
+
const compiled = transpileAndRewriteLocalImports(f.content, f.full);
|
|
13407
|
+
for (const s of extractBareSpecifiers(compiled)) specifiers.add(s);
|
|
13408
|
+
compiledScripts.push({ file: f, compiled });
|
|
13330
13409
|
}
|
|
13331
13410
|
// Also scan inline module scripts in HTML for bare specifiers
|
|
13332
13411
|
const inlineScriptRe = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
@@ -13340,14 +13419,53 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13340
13419
|
const importMap = buildPreviewImportMap(ctx.vfs, rootDir, specifiers);
|
|
13341
13420
|
for (const f of scriptFiles) aliasPinnedCdnUrls(ctx.vfs, rootDir, f.content, importMap);
|
|
13342
13421
|
aliasPinnedCdnUrls(ctx.vfs, rootDir, htmlBody, importMap);
|
|
13343
|
-
for (const
|
|
13344
|
-
const
|
|
13345
|
-
const key = toLocalImportKey(f.full);
|
|
13422
|
+
for (const { file, compiled } of compiledScripts) {
|
|
13423
|
+
const key = toLocalImportKey(file.full);
|
|
13346
13424
|
importMap[key] = `data:text/javascript;charset=utf-8,${encodeURIComponent(compiled)}`;
|
|
13347
13425
|
}
|
|
13348
13426
|
|
|
13427
|
+
let needsTailwindBrowser = false;
|
|
13428
|
+
for (const af of assetFiles) {
|
|
13429
|
+
const key = toLocalImportKey(af.full);
|
|
13430
|
+
if (/\.css$/i.test(af.full)) {
|
|
13431
|
+
if (/@import\s+['"]tailwindcss['"]/i.test(af.content)) {
|
|
13432
|
+
needsTailwindBrowser = true;
|
|
13433
|
+
}
|
|
13434
|
+
const resolvedCss = inlineLocalCssImports(af.content, PosixPath.dirname(af.full));
|
|
13435
|
+
const cssModuleJs = `const __css=${JSON.stringify(resolvedCss)};if(typeof document!=='undefined'){const __s=document.createElement('style');__s.setAttribute('data-codelab-css',${JSON.stringify(af.rel)});__s.textContent=__css;document.head.appendChild(__s);}export default __css;`;
|
|
13436
|
+
importMap[key] = `data:text/javascript;charset=utf-8,${encodeURIComponent(cssModuleJs)}`;
|
|
13437
|
+
} else if (/\.json$/i.test(af.full)) {
|
|
13438
|
+
const jsonModuleJs = `export default ${af.content.trim() || 'null'};`;
|
|
13439
|
+
importMap[key] = `data:text/javascript;charset=utf-8,${encodeURIComponent(jsonModuleJs)}`;
|
|
13440
|
+
} else if (/\.svg$/i.test(af.full)) {
|
|
13441
|
+
const svgDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(af.content)}`;
|
|
13442
|
+
const svgModuleJs = `export default ${JSON.stringify(svgDataUrl)};`;
|
|
13443
|
+
importMap[key] = `data:text/javascript;charset=utf-8,${encodeURIComponent(svgModuleJs)}`;
|
|
13444
|
+
}
|
|
13445
|
+
}
|
|
13446
|
+
|
|
13349
13447
|
const htmlDir = PosixPath.dirname(htmlTargetPath);
|
|
13350
|
-
let transformedHtml = htmlBody;
|
|
13448
|
+
let transformedHtml = htmlBody.replace(/%PUBLIC_URL%\//g, '/').replace(/%PUBLIC_URL%/g, '');
|
|
13449
|
+
|
|
13450
|
+
// Auto-inject entry script for Create React App / bundler templates where index.html omits <script src="...">
|
|
13451
|
+
const hasLocalScriptTag = /<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/i.test(transformedHtml);
|
|
13452
|
+
if (!hasLocalScriptTag) {
|
|
13453
|
+
const defaultEntries = [
|
|
13454
|
+
'/src/main.tsx', '/src/main.jsx', '/src/main.ts', '/src/main.js',
|
|
13455
|
+
'/src/index.tsx', '/src/index.jsx', '/src/index.ts', '/src/index.js'
|
|
13456
|
+
];
|
|
13457
|
+
for (const cand of defaultEntries) {
|
|
13458
|
+
if (isFile(PosixPath.join(rootDir, cand.slice(1)))) {
|
|
13459
|
+
const entryTag = `<script type="module" src="${cand}"></script>`;
|
|
13460
|
+
if (/<\/body>/i.test(transformedHtml)) {
|
|
13461
|
+
transformedHtml = transformedHtml.replace(/<\/body>/i, ` ${entryTag}\n</body>`);
|
|
13462
|
+
} else {
|
|
13463
|
+
transformedHtml += `\n${entryTag}`;
|
|
13464
|
+
}
|
|
13465
|
+
break;
|
|
13466
|
+
}
|
|
13467
|
+
}
|
|
13468
|
+
}
|
|
13351
13469
|
|
|
13352
13470
|
// Inline local <link rel="stylesheet" href="..."> so styles work in opaque-origin / srcdoc frames
|
|
13353
13471
|
transformedHtml = transformedHtml.replace(/<link\b([^>]*?)>/gi, (fullTag, attrs) => {
|
|
@@ -13358,7 +13476,11 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13358
13476
|
if (!cssTarget || !/\.css$/i.test(cssTarget)) return fullTag;
|
|
13359
13477
|
const cssContent = readText(cssTarget);
|
|
13360
13478
|
if (cssContent === null) return fullTag;
|
|
13361
|
-
|
|
13479
|
+
if (/@import\s+['"]tailwindcss['"]/i.test(cssContent)) {
|
|
13480
|
+
needsTailwindBrowser = true;
|
|
13481
|
+
}
|
|
13482
|
+
const resolvedCss = inlineLocalCssImports(cssContent, PosixPath.dirname(cssTarget));
|
|
13483
|
+
return `<style data-codelab-href="${hrefMatch[1].replace(/"/g, '"')}">\n${resolvedCss}\n</style>`;
|
|
13362
13484
|
});
|
|
13363
13485
|
|
|
13364
13486
|
// Inline local <script ... src="..."></script> so entry modules & scripts execute reliably in opaque-origin / srcdoc frames
|
|
@@ -13370,11 +13492,20 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13370
13492
|
const rawScript = readText(scriptTarget);
|
|
13371
13493
|
if (rawScript === null) return fullTag;
|
|
13372
13494
|
const compiled = transpileAndRewriteLocalImports(rawScript, scriptTarget);
|
|
13373
|
-
const isMod = /\btype\s*=\s*["']module["']/i.test(attrs) || /\.(?:tsx|ts|jsx|mjs)$/i.test(scriptTarget);
|
|
13495
|
+
const isMod = /\btype\s*=\s*["']module["']/i.test(attrs) || /\.(?:tsx|ts|jsx|mjs)$/i.test(scriptTarget) || /^\s*(?:import|export)\b/m.test(rawScript);
|
|
13374
13496
|
const typeAttr = isMod ? ' type="module"' : '';
|
|
13375
13497
|
return `<script${typeAttr} data-codelab-src="${srcMatch[1].replace(/"/g, '"')}">\n${compiled}\n</script>`;
|
|
13376
13498
|
});
|
|
13377
13499
|
|
|
13500
|
+
if (needsTailwindBrowser && !transformedHtml.includes('@tailwindcss/browser')) {
|
|
13501
|
+
const twTag = '<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>';
|
|
13502
|
+
if (/<head[^>]*>/i.test(transformedHtml)) {
|
|
13503
|
+
transformedHtml = transformedHtml.replace(/<head[^>]*>/i, (m) => `${m}\n ${twTag}`);
|
|
13504
|
+
} else {
|
|
13505
|
+
transformedHtml = twTag + '\n' + transformedHtml;
|
|
13506
|
+
}
|
|
13507
|
+
}
|
|
13508
|
+
|
|
13378
13509
|
return injectPreviewExtras(transformedHtml, importMap);
|
|
13379
13510
|
};
|
|
13380
13511
|
|
|
@@ -13386,7 +13517,9 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13386
13517
|
const hasExt = /\.[A-Za-z0-9]+$/.test(rel);
|
|
13387
13518
|
|
|
13388
13519
|
if (!rel || pathname.endsWith('/') || isDir(target)) {
|
|
13389
|
-
|
|
13520
|
+
const rootIdx = PosixPath.join(target, 'index.html');
|
|
13521
|
+
const pubIdx = PosixPath.join(target, 'public', 'index.html');
|
|
13522
|
+
target = (!exists(rootIdx) && exists(pubIdx)) ? pubIdx : rootIdx;
|
|
13390
13523
|
}
|
|
13391
13524
|
if (!exists(target) && !hasExt) {
|
|
13392
13525
|
// Resolve extensionless module specifiers (e.g. `./components/Counter`)
|
|
@@ -13400,7 +13533,9 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
13400
13533
|
for (const c of cands) { if (exists(c)) { target = c; break; } }
|
|
13401
13534
|
}
|
|
13402
13535
|
if (!exists(target) && !hasExt) {
|
|
13403
|
-
|
|
13536
|
+
const rootIdx = PosixPath.join(rootDir, 'index.html');
|
|
13537
|
+
const pubIdx = PosixPath.join(rootDir, 'public', 'index.html');
|
|
13538
|
+
target = (!exists(rootIdx) && exists(pubIdx)) ? pubIdx : rootIdx; // SPA fallback
|
|
13404
13539
|
}
|
|
13405
13540
|
if (!exists(target)) {
|
|
13406
13541
|
return new Response(
|
|
@@ -18778,7 +18913,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
18778
18913
|
|
|
18779
18914
|
// The bundler rewrites this literal from package.json at build time. Keeping
|
|
18780
18915
|
// the fallback in sync lets tests require src/workbench.js directly.
|
|
18781
|
-
const CODELAB_VERSION = '0.1.
|
|
18916
|
+
const CODELAB_VERSION = '0.1.11';
|
|
18782
18917
|
|
|
18783
18918
|
// Ambient TypeScript declarations for Node.js built-ins inside Monaco
|
|
18784
18919
|
const NODE_AMBIENT_DTS = `
|
|
@@ -20709,7 +20844,12 @@ declare module 'bun:sqlite' {
|
|
|
20709
20844
|
const found = names.find(f => pattern.test(f));
|
|
20710
20845
|
if (found) return found;
|
|
20711
20846
|
if (kind === 'demo') {
|
|
20712
|
-
|
|
20847
|
+
const isConfigOrTest = f => /(^|\/)(test|.*\.(?:test|spec|config|d))\.(js|ts|mjs|cjs)$/i.test(f) || /(^|\/)\.[^/]+$/i.test(f);
|
|
20848
|
+
const hasHtmlEntry = Boolean(this.files['index.html'] || this.files['public/index.html']);
|
|
20849
|
+
if (hasHtmlEntry) {
|
|
20850
|
+
return names.find(f => /(^|\/)(server|app|demo)\.(js|ts)$/i.test(f) && !/^src\//i.test(f)) || null;
|
|
20851
|
+
}
|
|
20852
|
+
return names.find(f => /\.(js|ts)$/i.test(f) && !isConfigOrTest(f)) || null;
|
|
20713
20853
|
}
|
|
20714
20854
|
return null;
|
|
20715
20855
|
}
|
|
@@ -23442,8 +23582,10 @@ declare module 'bun:sqlite' {
|
|
|
23442
23582
|
return null;
|
|
23443
23583
|
}
|
|
23444
23584
|
|
|
23445
|
-
const
|
|
23446
|
-
|
|
23585
|
+
const hasSrcScripts = Boolean(this.files && Object.keys(this.files).some((f) => /^src\/.+\.(?:[cm]?jsx?|tsx?)$/i.test(f)));
|
|
23586
|
+
const rootDir = this.files['index.html'] ? '/workspace'
|
|
23587
|
+
: (this.files['public/index.html'] && !hasSrcScripts) ? '/workspace/public'
|
|
23588
|
+
: this.files['site/index.html'] ? '/workspace/site'
|
|
23447
23589
|
: '/workspace';
|
|
23448
23590
|
|
|
23449
23591
|
if (!this.shell || typeof this.shell.execute !== 'function') return null;
|
|
@@ -25931,6 +26073,9 @@ declare module 'bun:sqlite' {
|
|
|
25931
26073
|
if (this.isRunning) return;
|
|
25932
26074
|
const entry = this._findEntryFile('demo');
|
|
25933
26075
|
if (!entry) {
|
|
26076
|
+
if ((this.files['index.html'] || this.files['public/index.html']) && typeof this.previewApp === 'function') {
|
|
26077
|
+
return this.previewApp();
|
|
26078
|
+
}
|
|
25934
26079
|
this.terminalLogs.push({ type: 'stderr', text: 'No demo.js / demo.ts file found in this workspace.' });
|
|
25935
26080
|
this.drawerTab = 'terminal';
|
|
25936
26081
|
this._renderDrawerBody();
|
|
@@ -26806,7 +26951,7 @@ declare module 'bun:sqlite' {
|
|
|
26806
26951
|
Enter any public GitHub repository URL or <code>owner/repo</code> slug. Files will be cloned directly into the in-memory Virtual Filesystem (VFS) with zero authentication required.
|
|
26807
26952
|
</p>
|
|
26808
26953
|
<div style="display:flex;gap:8px;">
|
|
26809
|
-
<input id="cl-clone-repo-input" type="text" placeholder="e.g.
|
|
26954
|
+
<input id="cl-clone-repo-input" type="text" placeholder="e.g. mdn/todo-react or https://github.com/owner/repo" style="flex:1;height:34px;padding:0 10px;background:var(--cl-bg);border:1px solid var(--cl-border-strong);border-radius:var(--cl-radius-sm);color:var(--cl-fg);font-family:var(--cl-font-mono);font-size:12px;outline:none;" />
|
|
26810
26955
|
<button type="button" class="codelab-btn codelab-btn--primary" data-cl-action="confirm-clone-repo">Clone Repo</button>
|
|
26811
26956
|
</div>
|
|
26812
26957
|
</div>
|
|
@@ -27281,7 +27426,7 @@ const PTYTerminalEngine = CodeLabTerminal ? CodeLabTerminal.PTYTerminalEngine :
|
|
|
27281
27426
|
const mount = CodeLab ? CodeLab.mount : null;
|
|
27282
27427
|
const create = CodeLab ? CodeLab.create : null;
|
|
27283
27428
|
const unmount = CodeLab ? CodeLab.unmount : null;
|
|
27284
|
-
const version = CodeLab ? CodeLab.version : '0.1.
|
|
27429
|
+
const version = CodeLab ? CodeLab.version : '0.1.11';
|
|
27285
27430
|
const renderMarkdown = CodeLab ? CodeLab.renderMarkdown : null;
|
|
27286
27431
|
const renderSimpleMarkdown = CodeLab ? CodeLab.renderSimpleMarkdown : null;
|
|
27287
27432
|
const cloneRepo = CodeLab ? CodeLab.cloneRepo : null;
|