@vizhub/runtime 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/build/build.d.ts.map +1 -1
- package/dist/build-4ni0mWxG.cjs +317 -0
- package/dist/build-4ni0mWxG.cjs.map +1 -0
- package/dist/{build-DnPT2Qew.js → build-B7w6NcTo.js} +510 -299
- package/dist/build-B7w6NcTo.js.map +1 -0
- package/dist/common/imageSupport.d.ts +23 -0
- package/dist/common/imageSupport.d.ts.map +1 -0
- package/dist/common/imageSupport.test.d.ts +2 -0
- package/dist/common/imageSupport.test.d.ts.map +1 -0
- package/dist/common/runtimeErrorHandling.d.ts.map +1 -1
- package/dist/common/virtualFileSystem.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -51
- package/dist/index.js.map +1 -1
- package/dist/orchestration/createRuntime.d.ts.map +1 -1
- package/dist/orchestration/types.d.ts +1 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/worker.d.ts.map +1 -1
- package/dist/test/fixtures/v1/imageSupport.d.ts +18 -0
- package/dist/test/fixtures/v1/imageSupport.d.ts.map +1 -0
- package/dist/test/fixtures/v1/index.d.ts +1 -0
- package/dist/test/fixtures/v1/index.d.ts.map +1 -1
- package/dist/test/fixtures/v2/imageSupport.d.ts +13 -0
- package/dist/test/fixtures/v2/imageSupport.d.ts.map +1 -0
- package/dist/test/fixtures/v2/index.d.ts +1 -0
- package/dist/test/fixtures/v2/index.d.ts.map +1 -1
- package/dist/test/fixtures/v3/basicIndexJSWithViz.d.ts +4 -0
- package/dist/test/fixtures/v3/basicIndexJSWithViz.d.ts.map +1 -0
- package/dist/test/fixtures/v3/index.d.ts +1 -0
- package/dist/test/fixtures/v3/index.d.ts.map +1 -1
- package/dist/test/imageSupport.test.d.ts +2 -0
- package/dist/test/imageSupport.test.d.ts.map +1 -0
- package/dist/test/v3BuildIntegrationViz.test.d.ts +2 -0
- package/dist/test/v3BuildIntegrationViz.test.d.ts.map +1 -0
- package/dist/test/v4HotReload.test.d.ts +2 -0
- package/dist/test/v4HotReload.test.d.ts.map +1 -0
- package/dist/test/v4HotReloadIntegration.test.d.ts +2 -0
- package/dist/test/v4HotReloadIntegration.test.d.ts.map +1 -0
- package/dist/test/vizExportSupport.test.d.ts +2 -0
- package/dist/test/vizExportSupport.test.d.ts.map +1 -0
- package/dist/test/vizPriorityTest.test.d.ts +2 -0
- package/dist/test/vizPriorityTest.test.d.ts.map +1 -0
- package/dist/v2/getComputedIndexHtml.d.ts.map +1 -1
- package/dist/v3/computeBundleJSV3.d.ts.map +1 -1
- package/dist/v3/transformSvelte.d.ts +1 -1
- package/dist/v3/transformSvelte.d.ts.map +1 -1
- package/dist/v3/vizLoad.d.ts.map +1 -1
- package/dist/v3/vizResolve.d.ts.map +1 -1
- package/dist/v4/extractEntryPoints.d.ts.map +1 -1
- package/dist/v4/hotReloadScript.d.ts +6 -0
- package/dist/v4/hotReloadScript.d.ts.map +1 -0
- package/dist/v4/index.d.ts +12 -0
- package/dist/v4/index.d.ts.map +1 -1
- package/dist/v4/updateHTML.d.ts +1 -1
- package/dist/v4/updateHTML.d.ts.map +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +10 -10
- package/dist/build-BXOhZlRS.cjs +0 -256
- package/dist/build-BXOhZlRS.cjs.map +0 -1
- package/dist/build-DnPT2Qew.js.map +0 -1
@@ -1,14 +1,14 @@
|
|
1
|
-
import { magicSandbox as
|
2
|
-
import { isVizId as
|
3
|
-
import { transform as
|
4
|
-
const
|
5
|
-
function
|
1
|
+
import { magicSandbox as C } from "magic-sandbox";
|
2
|
+
import { isVizId as X, getFileText as q, generateVizId as Z, fileCollectionToVizFiles as K, vizFilesToFileCollection as ee } from "@vizhub/viz-utils";
|
3
|
+
import { transform as te } from "sucrase";
|
4
|
+
const qe = () => (Math.random() + "").slice(2);
|
5
|
+
function F(e = {}) {
|
6
6
|
return {
|
7
7
|
name: "sucrase",
|
8
8
|
transform(t, n) {
|
9
9
|
if (!n.match(/\.(?:js|[jt]sx)$/))
|
10
10
|
return null;
|
11
|
-
const r =
|
11
|
+
const r = te(t, {
|
12
12
|
transforms: ["jsx", "typescript"],
|
13
13
|
// For source maps
|
14
14
|
filePath: n,
|
@@ -25,44 +25,44 @@ function k(e = {}) {
|
|
25
25
|
}
|
26
26
|
};
|
27
27
|
}
|
28
|
-
const
|
28
|
+
const J = {
|
29
29
|
dependencies: {},
|
30
30
|
vizhub: {},
|
31
31
|
license: "MIT"
|
32
|
-
},
|
32
|
+
}, ne = !1, $ = (e) => {
|
33
33
|
const t = e["package.json"];
|
34
34
|
try {
|
35
|
-
const n = t ? JSON.parse(t) :
|
36
|
-
return
|
35
|
+
const n = t ? JSON.parse(t) : J;
|
36
|
+
return ne && console.log(
|
37
37
|
"[packageJSON] pkg:",
|
38
38
|
JSON.stringify(n, null, 2)
|
39
39
|
), n;
|
40
40
|
} catch {
|
41
|
-
return
|
41
|
+
return J;
|
42
42
|
}
|
43
|
-
},
|
44
|
-
const
|
45
|
-
return r === "jsdelivr" ? `https://cdn.jsdelivr.net/npm/${e}@${t}${
|
46
|
-
},
|
43
|
+
}, W = (e) => $(e).dependencies || {}, V = (e) => ($(e).vizhub || {}).libraries || {}, U = ({ name: e, version: t }, n, r = "jsdelivr") => {
|
44
|
+
const s = n[e] && n[e].path || "";
|
45
|
+
return r === "jsdelivr" ? `https://cdn.jsdelivr.net/npm/${e}@${t}${s}` : `https://unpkg.com/${e}@${t}${s}`;
|
46
|
+
}, re = (e) => {
|
47
47
|
const t = e?.vizhub?.libraries;
|
48
48
|
return t ? Object.entries(t).reduce(
|
49
|
-
(n, [r,
|
49
|
+
(n, [r, s]) => (s.global && (n[r] = s.global), n),
|
50
50
|
{}
|
51
51
|
) : {};
|
52
|
-
},
|
52
|
+
}, se = {
|
53
53
|
d3: "d3",
|
54
54
|
react: "React",
|
55
55
|
"react-dom": "ReactDOM"
|
56
|
-
},
|
57
|
-
const t =
|
56
|
+
}, G = (e) => {
|
57
|
+
const t = re(e);
|
58
58
|
return {
|
59
|
-
...
|
59
|
+
...se,
|
60
60
|
...t
|
61
61
|
};
|
62
|
-
},
|
62
|
+
}, S = (e) => {
|
63
63
|
const [t, ...n] = e.split("/"), r = n.join("/");
|
64
64
|
return { vizId: t, fileName: r };
|
65
|
-
},
|
65
|
+
}, oe = `var EOL = {},
|
66
66
|
EOF = {},
|
67
67
|
QUOTE = 34,
|
68
68
|
NEWLINE = 10,
|
@@ -182,66 +182,113 @@ var tsv = dsv(' ');
|
|
182
182
|
|
183
183
|
var tsvParse = tsv.parse;
|
184
184
|
|
185
|
-
export { csvParse, tsvParse };`,
|
185
|
+
export { csvParse, tsvParse };`, ie = (e) => (
|
186
186
|
// str.replace(/`/g, '\\`');
|
187
187
|
e.replace(/\\/g, "\\\\").replace(/`/g, "\\`")
|
188
|
-
),
|
188
|
+
), ce = () => ({
|
189
189
|
name: "transformDSV",
|
190
190
|
// `id` here is of the form
|
191
191
|
// `{vizId}/{fileName}`
|
192
192
|
transform: async (e, t) => {
|
193
|
-
const { fileName: n } =
|
194
|
-
if (r ||
|
193
|
+
const { fileName: n } = S(t), r = n.endsWith(".csv"), s = n.endsWith(".tsv");
|
194
|
+
if (r || s)
|
195
195
|
return {
|
196
196
|
code: `
|
197
|
-
${
|
198
|
-
const data = ${r ? "csvParse" : "tsvParse"}(\`${
|
197
|
+
${oe}
|
198
|
+
const data = ${r ? "csvParse" : "tsvParse"}(\`${ie(e)}\`);
|
199
199
|
export default data;
|
200
200
|
`,
|
201
201
|
map: { mappings: "" }
|
202
202
|
};
|
203
203
|
}
|
204
|
-
}),
|
204
|
+
}), ae = (e) => {
|
205
205
|
const t = /^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)$/, n = e.match(t);
|
206
206
|
return n ? {
|
207
207
|
userName: n[1],
|
208
208
|
idOrSlug: n[2]
|
209
209
|
} : null;
|
210
|
-
},
|
210
|
+
}, de = ({
|
211
211
|
vizId: e,
|
212
212
|
slugCache: t
|
213
213
|
}) => ({
|
214
214
|
name: "vizResolve",
|
215
215
|
resolveId: async (n, r) => {
|
216
216
|
if (n.startsWith("./") && !r?.startsWith("https://")) {
|
217
|
-
let
|
218
|
-
if (!
|
217
|
+
let o = n.substring(2);
|
218
|
+
if (!o.endsWith(".js") && !o.endsWith(".css") && !o.endsWith(".csv") && !o.endsWith(".svelte") && !o.endsWith(".png") && !o.endsWith(".jpg") && !o.endsWith(".jpeg") && !o.endsWith(".gif") && !o.endsWith(".svg") && !o.endsWith(".webp") && !o.endsWith(".bmp") && (o += ".js"), r) {
|
219
219
|
const {
|
220
220
|
vizId: c,
|
221
221
|
fileName: i
|
222
|
-
} =
|
222
|
+
} = S(r), a = i.split("/").slice(0, -1).join("/"), d = a ? `${a}/${o}` : o;
|
223
223
|
return `${c}/${d}`;
|
224
224
|
}
|
225
|
-
return e + "/" +
|
225
|
+
return e + "/" + o;
|
226
226
|
}
|
227
|
-
const
|
228
|
-
if (
|
229
|
-
let
|
230
|
-
if (
|
231
|
-
|
227
|
+
const s = ae(n);
|
228
|
+
if (s) {
|
229
|
+
let o;
|
230
|
+
if (X(s.idOrSlug))
|
231
|
+
o = s.idOrSlug;
|
232
232
|
else {
|
233
233
|
if (!t)
|
234
234
|
throw new Error(
|
235
235
|
"slugCache is required to import by slug in v3 runtime"
|
236
236
|
);
|
237
|
-
|
238
|
-
`${
|
237
|
+
o = await t.get(
|
238
|
+
`${s.userName}/${s.idOrSlug}`
|
239
239
|
);
|
240
240
|
}
|
241
|
-
return
|
241
|
+
return o + "/index.js";
|
242
242
|
}
|
243
243
|
}
|
244
|
-
}),
|
244
|
+
}), le = [
|
245
|
+
".jpg",
|
246
|
+
".jpeg",
|
247
|
+
".png",
|
248
|
+
".gif",
|
249
|
+
".svg",
|
250
|
+
".webp",
|
251
|
+
".bmp"
|
252
|
+
], z = (e) => {
|
253
|
+
const t = e.toLowerCase().split(".").pop();
|
254
|
+
return t ? le.includes(`.${t}`) : !1;
|
255
|
+
}, ue = (e) => {
|
256
|
+
switch (e.toLowerCase().split(".").pop()) {
|
257
|
+
case "jpg":
|
258
|
+
case "jpeg":
|
259
|
+
return "image/jpeg";
|
260
|
+
case "png":
|
261
|
+
return "image/png";
|
262
|
+
case "gif":
|
263
|
+
return "image/gif";
|
264
|
+
case "svg":
|
265
|
+
return "image/svg+xml";
|
266
|
+
case "webp":
|
267
|
+
return "image/webp";
|
268
|
+
case "bmp":
|
269
|
+
return "image/bmp";
|
270
|
+
default:
|
271
|
+
return "image/png";
|
272
|
+
}
|
273
|
+
}, pe = (e) => {
|
274
|
+
const t = e.replace(/\s/g, "");
|
275
|
+
return /^[A-Za-z0-9+/]*={0,2}$/.test(t);
|
276
|
+
}, P = (e, t) => {
|
277
|
+
const n = ue(e);
|
278
|
+
return e.toLowerCase().split(".").pop() === "svg" && !pe(t) ? `data:${n};utf8,${encodeURIComponent(t)}` : `data:${n};base64,${t}`;
|
279
|
+
}, me = (e, t) => e.replace(
|
280
|
+
/<img([^>]*)\s+src=["']([^"']+)["']([^>]*)>/gi,
|
281
|
+
(n, r, s, o) => {
|
282
|
+
if (t[s] !== void 0 && z(s)) {
|
283
|
+
const c = P(
|
284
|
+
s,
|
285
|
+
t[s]
|
286
|
+
);
|
287
|
+
return `<img${r} src="${c}"${o}>`;
|
288
|
+
}
|
289
|
+
return n;
|
290
|
+
}
|
291
|
+
), fe = ({
|
245
292
|
vizCache: e,
|
246
293
|
trackCSSImport: t,
|
247
294
|
vizId: n,
|
@@ -250,62 +297,96 @@ export { csvParse, tsvParse };`, te = (e) => (
|
|
250
297
|
name: "vizLoad",
|
251
298
|
// `id` here is of the form
|
252
299
|
// `{vizId}/{fileName}`
|
253
|
-
load: async (
|
254
|
-
const
|
300
|
+
load: async (s) => {
|
301
|
+
const o = S(s), c = o.vizId, i = o.fileName;
|
255
302
|
if (i.endsWith(".css"))
|
256
|
-
return t(
|
303
|
+
return t(s), "";
|
257
304
|
let a = null;
|
258
305
|
if (c === n && r)
|
259
306
|
a = r[i] || null;
|
260
307
|
else {
|
261
308
|
const d = await e.get(c);
|
262
|
-
a =
|
309
|
+
a = q(d, i);
|
263
310
|
}
|
264
311
|
if (a === null)
|
265
312
|
throw new Error(
|
266
313
|
`Imported file "${i}" not found.`
|
267
314
|
);
|
268
|
-
return
|
315
|
+
return z(i) ? `export default "${P(
|
316
|
+
i,
|
317
|
+
a
|
318
|
+
)}";` : a;
|
269
319
|
}
|
270
|
-
}),
|
271
|
-
let
|
272
|
-
const
|
320
|
+
}), D = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
|
321
|
+
let I;
|
322
|
+
const b = "https://cdn.jsdelivr.net/npm/svelte@5.37.1", Ge = `${b}/compiler/index.js`;
|
323
|
+
async function A(e) {
|
324
|
+
const t = R.get(e);
|
325
|
+
if (t)
|
326
|
+
return t;
|
327
|
+
const n = [".js", "/index.js"];
|
328
|
+
for (const s of n) {
|
329
|
+
const o = `${e}${s}`;
|
330
|
+
try {
|
331
|
+
if ((await fetch(o, { method: "HEAD" })).ok)
|
332
|
+
return R.set(e, o), o;
|
333
|
+
} catch {
|
334
|
+
continue;
|
335
|
+
}
|
336
|
+
}
|
337
|
+
const r = `${e}.js`;
|
338
|
+
return R.set(e, r), r;
|
339
|
+
}
|
340
|
+
const he = ({
|
273
341
|
getSvelteCompiler: e
|
274
342
|
}) => ({
|
275
343
|
name: "transformSvelte",
|
276
344
|
load: async (t) => {
|
277
|
-
if (
|
345
|
+
if (t === "virtual:esm-env")
|
346
|
+
return `
|
347
|
+
export const BROWSER = true;
|
348
|
+
export const DEV = true;
|
349
|
+
export const NODE = false;
|
350
|
+
export const PROD = false;
|
351
|
+
`;
|
352
|
+
if (!t.startsWith(b))
|
278
353
|
return;
|
279
|
-
const n =
|
354
|
+
const n = D.get(t);
|
280
355
|
if (n) return n;
|
281
356
|
const r = await fetch(t).then(
|
282
|
-
(
|
357
|
+
(s) => s.text()
|
283
358
|
);
|
284
|
-
return
|
359
|
+
return D.set(t, r), r;
|
285
360
|
},
|
286
361
|
// From https://github.com/sveltejs/sites/blob/master/packages/repl/src/lib/workers/bundler/index.js#L255C2-L271C5
|
287
362
|
resolveId: async (t, n) => {
|
363
|
+
if (t === "esm-env")
|
364
|
+
return "virtual:esm-env";
|
288
365
|
if (t === "svelte")
|
289
|
-
return `${
|
366
|
+
return `${b}/src/index-client.js`;
|
290
367
|
if (t.startsWith("svelte/")) {
|
291
|
-
const r = t.slice(7)
|
292
|
-
return
|
368
|
+
const r = t.slice(7), s = `${b}/src/${r}`;
|
369
|
+
return await A(s);
|
370
|
+
}
|
371
|
+
if (t.startsWith("#client/")) {
|
372
|
+
const r = t.slice(8), s = `${b}/src/internal/client/${r}`;
|
373
|
+
return await A(s);
|
293
374
|
}
|
294
375
|
if (/^https?:/.test(t)) return t;
|
295
|
-
if (t.startsWith(".") && n && n.startsWith(
|
376
|
+
if (t.startsWith(".") && n && n.startsWith(b)) {
|
296
377
|
const r = new URL(t, n).href;
|
297
378
|
return new URL(t, n).href, r;
|
298
379
|
}
|
299
380
|
},
|
300
381
|
transform: async (t, n) => {
|
301
|
-
const { fileName: r } =
|
382
|
+
const { fileName: r } = S(n);
|
302
383
|
if (r.endsWith(".svelte")) {
|
303
|
-
if (!
|
384
|
+
if (!I) {
|
304
385
|
if (!e)
|
305
386
|
throw new Error("Svelte compiler not available");
|
306
|
-
|
387
|
+
I = await e();
|
307
388
|
}
|
308
|
-
const
|
389
|
+
const o = I(t, {
|
309
390
|
filename: r,
|
310
391
|
generate: "client",
|
311
392
|
// Svelte 5 uses 'client' instead of 'dom'
|
@@ -314,76 +395,89 @@ const E = "https://cdn.jsdelivr.net/npm/svelte@5", Ue = `${E}/compiler.cjs`, ie
|
|
314
395
|
dev: !1
|
315
396
|
// Production mode
|
316
397
|
});
|
317
|
-
let c =
|
318
|
-
return
|
398
|
+
let c = o.js.code;
|
399
|
+
return o.css && o.css.code && (c = `
|
319
400
|
// Auto-inject CSS for Svelte component
|
320
401
|
(function() {
|
321
402
|
if (typeof document !== 'undefined') {
|
322
403
|
const style = document.createElement('style');
|
323
|
-
style.textContent = ${JSON.stringify(
|
404
|
+
style.textContent = ${JSON.stringify(o.css.code)};
|
324
405
|
document.head.appendChild(style);
|
325
406
|
}
|
326
407
|
})();
|
327
408
|
` + c), c;
|
328
409
|
}
|
329
410
|
}
|
330
|
-
}),
|
411
|
+
}), ge = async ({
|
331
412
|
files: e,
|
332
413
|
rollup: t,
|
333
414
|
enableSourcemap: n = !0,
|
334
415
|
vizCache: r,
|
335
|
-
vizId:
|
336
|
-
slugCache:
|
416
|
+
vizId: s,
|
417
|
+
slugCache: o,
|
337
418
|
getSvelteCompiler: c
|
338
419
|
}) => {
|
339
|
-
const i = /* @__PURE__ */ new Set(), a = (
|
340
|
-
i.add(
|
420
|
+
const i = /* @__PURE__ */ new Set(), a = (p) => {
|
421
|
+
i.add(p);
|
341
422
|
};
|
342
423
|
if (!e["index.js"])
|
343
424
|
throw new Error("Missing index.js");
|
344
425
|
const l = {
|
426
|
+
name: "replace",
|
427
|
+
transform(p, w) {
|
428
|
+
let y = !1, f = p;
|
429
|
+
return f.includes("process.env.NODE_ENV") && (f = f.replace(
|
430
|
+
/\bprocess\.env\.NODE_ENV\b/g,
|
431
|
+
JSON.stringify("production")
|
432
|
+
), y = !0), y ? { code: f, map: null } : null;
|
433
|
+
}
|
434
|
+
}, u = {
|
345
435
|
input: "./index.js",
|
346
436
|
plugins: [
|
347
|
-
...
|
348
|
-
|
349
|
-
|
350
|
-
|
437
|
+
...s ? [de({ vizId: s, slugCache: o })] : [],
|
438
|
+
ce(),
|
439
|
+
F(),
|
440
|
+
he({ getSvelteCompiler: c }),
|
441
|
+
l,
|
351
442
|
...r ? [
|
352
|
-
|
443
|
+
fe({
|
353
444
|
vizCache: r,
|
354
445
|
trackCSSImport: a,
|
355
|
-
vizId:
|
446
|
+
vizId: s,
|
356
447
|
files: e
|
357
448
|
})
|
358
449
|
] : []
|
359
450
|
],
|
360
|
-
onwarn(
|
361
|
-
|
451
|
+
onwarn(p, w) {
|
452
|
+
p.code !== "UNRESOLVED_IMPORT" && w(p);
|
362
453
|
}
|
363
|
-
},
|
454
|
+
}, m = {
|
364
455
|
format: "umd",
|
365
456
|
name: "Viz",
|
366
457
|
sourcemap: !!n,
|
367
458
|
compact: !0
|
368
|
-
},
|
369
|
-
if (
|
370
|
-
const
|
371
|
-
|
459
|
+
}, g = $(e);
|
460
|
+
if (g) {
|
461
|
+
const p = G(g);
|
462
|
+
p && (u.external = Object.keys(p), m.globals = p);
|
372
463
|
}
|
373
|
-
|
464
|
+
u.external || (u.external = []), m.globals || (m.globals = {}), Array.isArray(u.external) && (u.external = u.external.filter(
|
465
|
+
(p) => typeof p == "string" && !p.startsWith("#client/")
|
466
|
+
));
|
467
|
+
const v = await t(u), { output: E } = await v.generate(m);
|
374
468
|
return {
|
375
|
-
src:
|
469
|
+
src: E[0].code,
|
376
470
|
cssFiles: Array.from(i)
|
377
471
|
};
|
378
|
-
},
|
472
|
+
}, ve = (e) => {
|
379
473
|
if (e instanceof Error) {
|
380
474
|
const t = e.stack || "", n = e.message || "Unknown error";
|
381
475
|
return `${e.name || "Error"}: ${n}
|
382
476
|
${t}`;
|
383
477
|
} else if ("error" in e && e.error instanceof Error) {
|
384
|
-
const t = e.error, n = t.stack || "", r = t.message || "Unknown error",
|
478
|
+
const t = e.error, n = t.stack || "", r = t.message || "Unknown error", s = "filename" in e ? e.filename : "", o = "lineno" in e ? e.lineno : "", c = "colno" in e ? e.colno : "";
|
385
479
|
let i = "";
|
386
|
-
return
|
480
|
+
return s && o && (i = ` at ${s}:${o}`, c && (i += `:${c}`)), `${t.name || "Error"}: ${r}${i}
|
387
481
|
${n}`;
|
388
482
|
} else if ("reason" in e) {
|
389
483
|
const t = e.reason;
|
@@ -395,10 +489,10 @@ ${n}`;
|
|
395
489
|
return `Unhandled Promise Rejection: ${String(t)}`;
|
396
490
|
} else
|
397
491
|
return `Unknown runtime error: ${String(e)}`;
|
398
|
-
},
|
492
|
+
}, j = () => `
|
399
493
|
// Global error handling for runtime errors
|
400
494
|
(() => {
|
401
|
-
const formatRuntimeError = ${
|
495
|
+
const formatRuntimeError = ${ve.toString()};
|
402
496
|
|
403
497
|
// Handle uncaught JavaScript errors
|
404
498
|
window.addEventListener('error', (event) => {
|
@@ -419,15 +513,15 @@ ${n}`;
|
|
419
513
|
});
|
420
514
|
})();
|
421
515
|
`;
|
422
|
-
function
|
516
|
+
function we() {
|
423
517
|
return Math.random().toString().slice(2, 7);
|
424
518
|
}
|
425
|
-
const
|
519
|
+
const ye = ({
|
426
520
|
cdn: e,
|
427
521
|
src: t,
|
428
522
|
styles: n
|
429
523
|
}) => {
|
430
|
-
const
|
524
|
+
const s = `viz-container-${we()}`;
|
431
525
|
return `<!DOCTYPE html>
|
432
526
|
<html>
|
433
527
|
<head>
|
@@ -437,22 +531,22 @@ const le = ({
|
|
437
531
|
margin: 0;
|
438
532
|
overflow: hidden;
|
439
533
|
}
|
440
|
-
#${
|
534
|
+
#${s} {
|
441
535
|
height: 100vh;
|
442
536
|
}
|
443
537
|
</style>
|
444
538
|
</head>
|
445
539
|
<body>
|
446
|
-
<div id="${
|
447
|
-
<script>${
|
540
|
+
<div id="${s}"></div>
|
541
|
+
<script>${j()}<\/script>
|
448
542
|
<script id="injected-script">${t}<\/script>
|
449
543
|
<script>
|
450
544
|
(() => {
|
451
545
|
let cleanup;
|
452
546
|
const render = () => {
|
453
|
-
const container = document.getElementById('${
|
547
|
+
const container = document.getElementById('${s}');
|
454
548
|
typeof cleanup === 'function' && cleanup();
|
455
|
-
cleanup = Viz.main(container, { state: window.state, setState, writeFile });
|
549
|
+
cleanup = (Viz.viz || Viz.main)(container, { state: window.state, setState, writeFile });
|
456
550
|
};
|
457
551
|
const setState = (next) => {
|
458
552
|
window.state = next(window.state);
|
@@ -508,62 +602,62 @@ const le = ({
|
|
508
602
|
<\/script>
|
509
603
|
</body>
|
510
604
|
</html>`;
|
511
|
-
},
|
605
|
+
}, be = async ({
|
512
606
|
files: e,
|
513
607
|
rollup: t,
|
514
608
|
enableSourcemap: n = !0,
|
515
609
|
vizCache: r,
|
516
|
-
vizId:
|
517
|
-
slugCache:
|
610
|
+
vizId: s,
|
611
|
+
slugCache: o,
|
518
612
|
getSvelteCompiler: c
|
519
613
|
}) => {
|
520
|
-
const { src: i, cssFiles: a } = await
|
614
|
+
const { src: i, cssFiles: a } = await ge({
|
521
615
|
files: e,
|
522
616
|
rollup: t,
|
523
617
|
enableSourcemap: n,
|
524
618
|
vizCache: r,
|
525
|
-
vizId:
|
526
|
-
slugCache:
|
619
|
+
vizId: s,
|
620
|
+
slugCache: o,
|
527
621
|
getSvelteCompiler: c
|
528
622
|
});
|
529
623
|
let d = [];
|
530
624
|
if (a.length > 0)
|
531
|
-
for (let
|
532
|
-
const
|
533
|
-
let
|
534
|
-
if (
|
535
|
-
|
625
|
+
for (let v = 0; v < a.length; v++) {
|
626
|
+
const E = a[v], p = S(E), w = p.vizId, y = p.fileName;
|
627
|
+
let f = null;
|
628
|
+
if (w === s && e)
|
629
|
+
f = e[y] || null;
|
536
630
|
else {
|
537
|
-
const
|
538
|
-
|
631
|
+
const Q = await r.get(w);
|
632
|
+
f = q(Q, y);
|
539
633
|
}
|
540
|
-
|
634
|
+
f && d.push(f);
|
541
635
|
}
|
542
636
|
const l = d.join(`
|
543
|
-
`),
|
637
|
+
`), u = `
|
544
638
|
<style id="injected-style">${l}</style>`;
|
545
639
|
let m = "";
|
546
|
-
const
|
547
|
-
|
640
|
+
const g = Object.entries(
|
641
|
+
W(e)
|
548
642
|
);
|
549
|
-
if (
|
550
|
-
const
|
551
|
-
m =
|
552
|
-
const
|
553
|
-
{ name:
|
554
|
-
|
643
|
+
if (g.length > 0) {
|
644
|
+
const v = V(e);
|
645
|
+
m = g.map(([E, p], w) => {
|
646
|
+
const y = U(
|
647
|
+
{ name: E, version: p },
|
648
|
+
v
|
555
649
|
);
|
556
|
-
return `${
|
557
|
-
`}<script src="${
|
650
|
+
return `${w > 0 ? " " : `
|
651
|
+
`}<script src="${y}"><\/script>`;
|
558
652
|
}).join("");
|
559
653
|
}
|
560
654
|
return {
|
561
|
-
html:
|
655
|
+
html: ye({ cdn: m, src: i, styles: u }),
|
562
656
|
css: l,
|
563
657
|
js: i,
|
564
658
|
runtimeVersion: "v3"
|
565
659
|
};
|
566
|
-
},
|
660
|
+
}, Ee = ({
|
567
661
|
initialContents: e,
|
568
662
|
handleCacheMiss: t
|
569
663
|
}) => {
|
@@ -589,59 +683,59 @@ const le = ({
|
|
589
683
|
}, invalidate: (c) => {
|
590
684
|
n.delete(c);
|
591
685
|
} };
|
592
|
-
},
|
686
|
+
}, Ye = ({
|
593
687
|
initialMappings: e = {},
|
594
688
|
handleCacheMiss: t
|
595
|
-
}) => ({ get: async (
|
596
|
-
const c = e[
|
689
|
+
}) => ({ get: async (o) => {
|
690
|
+
const c = e[o];
|
597
691
|
if (c !== void 0)
|
598
692
|
return c;
|
599
693
|
if (!t)
|
600
694
|
throw new Error(
|
601
|
-
`Unresolved slug ${
|
695
|
+
`Unresolved slug ${o}, cache miss handler not provided.`
|
602
696
|
);
|
603
|
-
const i = await t(
|
697
|
+
const i = await t(o);
|
604
698
|
if (i)
|
605
|
-
return e[
|
606
|
-
throw new Error(`Unresolved slug ${
|
607
|
-
}, set: (
|
608
|
-
e[
|
609
|
-
}, invalidate: (
|
610
|
-
delete e[
|
611
|
-
} }),
|
699
|
+
return e[o] = i, i;
|
700
|
+
throw new Error(`Unresolved slug ${o}`);
|
701
|
+
}, set: (o, c) => {
|
702
|
+
e[o] = c;
|
703
|
+
}, invalidate: (o) => {
|
704
|
+
delete e[o];
|
705
|
+
} }), xe = (e, t = "Sample Content for Exporting", n = Z()) => ({
|
612
706
|
id: n,
|
613
|
-
files:
|
707
|
+
files: K(e),
|
614
708
|
title: t
|
615
|
-
}),
|
709
|
+
}), Se = (e) => {
|
616
710
|
if (Object.keys(e).length === 0)
|
617
711
|
return null;
|
618
712
|
const t = "index.html" in e, n = "index.js" in e, r = "index.jsx" in e;
|
619
713
|
return t ? e["index.html"].includes('type="module"') ? "v4" : n || r ? "v2" : "v1" : !t && n ? "v3" : null;
|
620
|
-
},
|
714
|
+
}, O = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), $e = (e) => {
|
621
715
|
const t = e.trim();
|
622
|
-
return
|
623
|
-
},
|
716
|
+
return O(t, "html") && O(t, "head") && O(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
|
717
|
+
}, je = (e, t) => e.replace(
|
624
718
|
new RegExp(
|
625
719
|
`<script[^>]*src=["'][^"']*${t.source}[^"']*["'][^>]*>\\s*<\/script>`,
|
626
720
|
"gi"
|
627
721
|
),
|
628
722
|
""
|
629
|
-
),
|
723
|
+
), N = (e, t, n) => e.replace(
|
630
724
|
new RegExp(t, "i"),
|
631
725
|
`${n}${t}`
|
632
|
-
),
|
633
|
-
let n =
|
634
|
-
const r = Object.entries(
|
726
|
+
), Ce = (e, t) => {
|
727
|
+
let n = $e(e);
|
728
|
+
const r = Object.entries(W(t));
|
635
729
|
if (r.length) {
|
636
|
-
const c =
|
730
|
+
const c = V(t);
|
637
731
|
r.forEach(([a]) => {
|
638
|
-
n =
|
732
|
+
n = je(n, new RegExp(`${a}@`));
|
639
733
|
});
|
640
734
|
const i = r.map(
|
641
|
-
([a, d]) =>
|
735
|
+
([a, d]) => U({ name: a, version: d }, c)
|
642
736
|
).map((a) => `<script src="${a}"><\/script>`).join(`
|
643
737
|
`);
|
644
|
-
n =
|
738
|
+
n = N(
|
645
739
|
n,
|
646
740
|
"</head>",
|
647
741
|
i + `
|
@@ -653,23 +747,27 @@ const le = ({
|
|
653
747
|
a.length === 1 && (() => {
|
654
748
|
const l = a[0].index ?? -1;
|
655
749
|
if (l === -1) return !1;
|
656
|
-
const
|
657
|
-
return
|
658
|
-
})() || (n = n.replace(i, ""), n =
|
750
|
+
const u = n.search(/<body\b[^>]*>/i), m = n.search(/<\/body>/i);
|
751
|
+
return u !== -1 && m !== -1 && l > u && l < m;
|
752
|
+
})() || (n = n.replace(i, ""), n = N(n, "</body>", c));
|
659
753
|
}
|
660
|
-
const
|
754
|
+
const o = `<script>${j()}<\/script>
|
661
755
|
`;
|
662
|
-
return n =
|
663
|
-
|
756
|
+
return n = N(
|
757
|
+
n,
|
758
|
+
"</head>",
|
759
|
+
o
|
760
|
+
), /^\s*<!DOCTYPE/i.test(n) ? n : `<!DOCTYPE html>${n}`;
|
761
|
+
}, Re = (e) => {
|
664
762
|
const t = e["index.html"];
|
665
|
-
return !t && !e["index.js"] && !e["bundle.js"] ? "" :
|
763
|
+
return !t && !e["index.js"] && !e["bundle.js"] ? "" : Ce(t || "<!DOCTYPE html><html><head></head><body></body></html>", e);
|
666
764
|
};
|
667
|
-
function
|
765
|
+
function Ie(e) {
|
668
766
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
669
767
|
}
|
670
|
-
var
|
671
|
-
function
|
672
|
-
return
|
768
|
+
var T, B;
|
769
|
+
function Oe() {
|
770
|
+
return B || (B = 1, T = {
|
673
771
|
d3: "d3",
|
674
772
|
"d3-array": "d3",
|
675
773
|
"d3-axis": "d3",
|
@@ -717,53 +815,56 @@ function be() {
|
|
717
815
|
"vizhub-vega-lite-config": "vizhubVegaLiteConfig",
|
718
816
|
semiotic: "Semiotic",
|
719
817
|
"viz.js": "Viz"
|
720
|
-
}),
|
818
|
+
}), T;
|
721
819
|
}
|
722
|
-
var
|
723
|
-
const
|
820
|
+
var Ne = Oe();
|
821
|
+
const Te = /* @__PURE__ */ Ie(Ne), h = "\0virtual:", H = (e) => {
|
724
822
|
let t = e.replace(/^\.\//, "");
|
725
823
|
return t = t.replace(/\/+/g, "/"), t = t.replace(/\/$/, ""), t;
|
726
|
-
},
|
727
|
-
const n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = t.split("/"),
|
728
|
-
for (const
|
729
|
-
|
730
|
-
return
|
731
|
-
},
|
824
|
+
}, ke = (e, t) => {
|
825
|
+
const n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = t.split("/"), s = n ? n.split("/") : [];
|
826
|
+
for (const o of r)
|
827
|
+
o === ".." ? s.pop() : o !== "." && o !== "" && s.push(o);
|
828
|
+
return s.join("/");
|
829
|
+
}, Y = (e) => ({
|
732
830
|
name: "virtual-file-system",
|
733
831
|
resolveId(t, n) {
|
734
832
|
const r = n?.startsWith(
|
735
|
-
|
736
|
-
) ? n.slice(
|
833
|
+
h
|
834
|
+
) ? n.slice(h.length) : n;
|
737
835
|
if (t.startsWith("./") || t.startsWith("../")) {
|
738
|
-
const
|
739
|
-
if (e[
|
740
|
-
return
|
836
|
+
const o = H(r ? ke(r, t) : t);
|
837
|
+
if (e[o])
|
838
|
+
return h + o;
|
741
839
|
const c = [".js", ".jsx", ".ts", ".tsx"];
|
742
840
|
for (const i of c) {
|
743
|
-
const a =
|
841
|
+
const a = o + i;
|
744
842
|
if (e[a])
|
745
|
-
return
|
843
|
+
return h + a;
|
746
844
|
}
|
747
845
|
}
|
748
846
|
if (e[t])
|
749
|
-
return
|
750
|
-
const
|
751
|
-
for (const
|
752
|
-
const c = t +
|
847
|
+
return h + t;
|
848
|
+
const s = [".js", ".jsx", ".ts", ".tsx"];
|
849
|
+
for (const o of s) {
|
850
|
+
const c = t + o;
|
753
851
|
if (e[c])
|
754
|
-
return
|
852
|
+
return h + c;
|
755
853
|
}
|
756
854
|
return null;
|
757
855
|
},
|
758
856
|
load(t) {
|
759
|
-
if (t.startsWith(
|
760
|
-
const n = t.slice(
|
857
|
+
if (t.startsWith(h)) {
|
858
|
+
const n = t.slice(h.length);
|
761
859
|
if (e[n])
|
762
|
-
return
|
860
|
+
return z(n) ? `export default "${P(
|
861
|
+
n,
|
862
|
+
e[n]
|
863
|
+
)}";` : e[n];
|
763
864
|
}
|
764
865
|
return null;
|
765
866
|
}
|
766
|
-
}),
|
867
|
+
}), Le = async ({
|
767
868
|
files: e,
|
768
869
|
rollup: t,
|
769
870
|
enableSourcemap: n = !0
|
@@ -773,44 +874,44 @@ const xe = /* @__PURE__ */ Ee(ye), f = "\0virtual:", V = (e) => {
|
|
773
874
|
throw new Error(
|
774
875
|
"Missing entry point, can't find index.js or index.jsx"
|
775
876
|
);
|
776
|
-
const
|
877
|
+
const o = {
|
777
878
|
input: "./" + r,
|
778
|
-
plugins: [
|
779
|
-
onwarn(l,
|
780
|
-
l.code !== "UNRESOLVED_IMPORT" &&
|
879
|
+
plugins: [Y(e), F()],
|
880
|
+
onwarn(l, u) {
|
881
|
+
l.code !== "UNRESOLVED_IMPORT" && u(l);
|
781
882
|
}
|
782
883
|
}, c = {
|
783
884
|
format: "iife",
|
784
885
|
sourcemap: n
|
785
|
-
}, i =
|
886
|
+
}, i = $(e);
|
786
887
|
if (i) {
|
787
888
|
const l = {
|
788
889
|
// Pre-configured globals for v2 only
|
789
|
-
...
|
890
|
+
...Te,
|
790
891
|
// Libraries from package.json
|
791
|
-
...
|
892
|
+
...G(i)
|
792
893
|
};
|
793
|
-
l && (
|
894
|
+
l && (o.external = Object.keys(l), c.globals = l);
|
794
895
|
}
|
795
|
-
const a = await t(
|
896
|
+
const a = await t(o), { output: d } = await a.generate(c);
|
796
897
|
return d[0].code;
|
797
|
-
},
|
898
|
+
}, Me = async ({
|
798
899
|
files: e,
|
799
900
|
rollup: t,
|
800
901
|
enableSourcemap: n
|
801
902
|
}) => ({
|
802
903
|
...e,
|
803
|
-
"bundle.js": await
|
904
|
+
"bundle.js": await Le({
|
804
905
|
files: e,
|
805
906
|
rollup: t,
|
806
907
|
enableSourcemap: n
|
807
908
|
}),
|
808
|
-
"index.html":
|
809
|
-
}),
|
909
|
+
"index.html": Re(e)
|
910
|
+
}), Fe = (e) => {
|
810
911
|
const t = [], n = [], r = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
|
811
|
-
let
|
812
|
-
for (; (
|
813
|
-
const c =
|
912
|
+
let s, o = 0;
|
913
|
+
for (; (s = r.exec(e)) !== null; ) {
|
914
|
+
const c = s[1], i = s[2];
|
814
915
|
if (!/\btype\s*=\s*["']module["']/i.test(c))
|
815
916
|
continue;
|
816
917
|
const a = c.match(
|
@@ -819,7 +920,7 @@ const xe = /* @__PURE__ */ Ee(ye), f = "\0virtual:", V = (e) => {
|
|
819
920
|
if (a)
|
820
921
|
t.push(a[1]);
|
821
922
|
else if (i.trim()) {
|
822
|
-
const d = `__inline_script_${
|
923
|
+
const d = `__inline_script_${o++}.js`;
|
823
924
|
n.push({
|
824
925
|
id: d,
|
825
926
|
content: i.trim()
|
@@ -827,28 +928,28 @@ const xe = /* @__PURE__ */ Ee(ye), f = "\0virtual:", V = (e) => {
|
|
827
928
|
}
|
828
929
|
}
|
829
930
|
return { entryPoints: t, inlineScripts: n };
|
830
|
-
},
|
931
|
+
}, We = () => ({
|
831
932
|
name: "catch-all-prevent-fs",
|
832
933
|
resolveId(e, t) {
|
833
934
|
return { id: e, external: !0 };
|
834
935
|
}
|
835
|
-
}),
|
936
|
+
}), Ve = async ({
|
836
937
|
entryPoint: e,
|
837
938
|
files: t,
|
838
939
|
rollup: n,
|
839
940
|
enableSourcemap: r = !0
|
840
941
|
}) => {
|
841
|
-
const
|
942
|
+
const o = {
|
842
943
|
input: e.startsWith("./") ? e : `./${e}`,
|
843
944
|
plugins: [
|
844
|
-
|
845
|
-
|
945
|
+
Y(t),
|
946
|
+
F({
|
846
947
|
// Enable JSX runtime
|
847
948
|
// so we don't need to import React
|
848
949
|
// in every file that uses JSX
|
849
950
|
jsxRuntime: "automatic"
|
850
951
|
}),
|
851
|
-
|
952
|
+
We()
|
852
953
|
],
|
853
954
|
// external: (source: string) => {
|
854
955
|
// DEBUG && console.log("external", source);
|
@@ -862,143 +963,246 @@ const xe = /* @__PURE__ */ Ee(ye), f = "\0virtual:", V = (e) => {
|
|
862
963
|
// },
|
863
964
|
onwarn(a, d) {
|
864
965
|
}
|
865
|
-
}, c = await n(
|
966
|
+
}, c = await n(o), { output: i } = await c.generate({
|
866
967
|
format: "es",
|
867
968
|
sourcemap: r
|
868
969
|
});
|
869
970
|
return i[0].code;
|
870
|
-
},
|
971
|
+
}, k = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), Ue = (e) => {
|
871
972
|
const t = e.trim();
|
872
|
-
return
|
873
|
-
},
|
973
|
+
return k(t, "html") && k(t, "head") && k(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
|
974
|
+
}, _ = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), L = (e, t, n) => e.replace(
|
874
975
|
new RegExp(t, "i"),
|
875
976
|
`${n}${t}`
|
876
|
-
),
|
877
|
-
const t =
|
977
|
+
), ze = (e) => {
|
978
|
+
const t = W(e);
|
878
979
|
if (Object.keys(t).length === 0) return null;
|
879
|
-
const n =
|
880
|
-
for (const [
|
881
|
-
r[
|
882
|
-
{ name:
|
980
|
+
const n = V(e), r = {};
|
981
|
+
for (const [s, o] of Object.entries(t))
|
982
|
+
r[s] = U(
|
983
|
+
{ name: s, version: o },
|
883
984
|
n
|
884
985
|
);
|
885
986
|
return JSON.stringify({ imports: r }, null, 2);
|
886
|
-
},
|
987
|
+
}, Pe = () => `
|
988
|
+
// V4 Hot Reloading Support
|
989
|
+
(() => {
|
990
|
+
const runJS = (js) => {
|
991
|
+
// Remove all existing bundled module scripts
|
992
|
+
const existingScripts = document.querySelectorAll('script[type="module"]');
|
993
|
+
existingScripts.forEach(script => {
|
994
|
+
// Only remove scripts that contain bundled code (not import maps or external scripts)
|
995
|
+
if (script.textContent && script.textContent.trim()) {
|
996
|
+
script.remove();
|
997
|
+
}
|
998
|
+
});
|
999
|
+
|
1000
|
+
// Create new script with updated bundled code
|
1001
|
+
const script = document.createElement('script');
|
1002
|
+
script.type = 'module';
|
1003
|
+
script.textContent = js;
|
1004
|
+
document.body.appendChild(script);
|
1005
|
+
};
|
1006
|
+
|
1007
|
+
const runCSS = (css) => {
|
1008
|
+
let style = document.getElementById('v4-injected-style');
|
1009
|
+
if (!style) {
|
1010
|
+
style = document.createElement('style');
|
1011
|
+
style.type = 'text/css';
|
1012
|
+
style.id = 'v4-injected-style';
|
1013
|
+
document.head.appendChild(style);
|
1014
|
+
}
|
1015
|
+
style.textContent = css;
|
1016
|
+
};
|
1017
|
+
|
1018
|
+
// Listen for hot reload messages
|
1019
|
+
window.addEventListener('message', (message) => {
|
1020
|
+
switch (message.data.type) {
|
1021
|
+
case 'runJS':
|
1022
|
+
try {
|
1023
|
+
runJS(message.data.js);
|
1024
|
+
parent.postMessage({ type: 'runDone' }, "*");
|
1025
|
+
} catch (error) {
|
1026
|
+
console.error('V4 Hot reload error:', error);
|
1027
|
+
parent.postMessage({ type: 'runError', error }, "*");
|
1028
|
+
}
|
1029
|
+
break;
|
1030
|
+
case 'runCSS':
|
1031
|
+
runCSS(message.data.css);
|
1032
|
+
break;
|
1033
|
+
case 'ping':
|
1034
|
+
parent.postMessage({ type: 'pong' }, "*");
|
1035
|
+
break;
|
1036
|
+
default:
|
1037
|
+
break;
|
1038
|
+
}
|
1039
|
+
});
|
1040
|
+
})();
|
1041
|
+
`, Je = (e, t, n = [], r = !1) => {
|
887
1042
|
if (!e["index.html"]) return "";
|
888
|
-
let
|
889
|
-
t.forEach((
|
890
|
-
if (n.some(
|
891
|
-
|
892
|
-
|
1043
|
+
let s = Ue(e["index.html"]);
|
1044
|
+
t.forEach((i, a) => {
|
1045
|
+
if (n.some(
|
1046
|
+
(l) => l.id === a
|
1047
|
+
)) {
|
1048
|
+
const l = n.find((g) => g.id === a)?.content || "", u = _(
|
1049
|
+
l
|
1050
|
+
), m = new RegExp(
|
1051
|
+
`<script\\b[^>]*\\btype=["']module["'][^>]*>\\s*${u}\\s*<\/script>`,
|
893
1052
|
"gi"
|
894
1053
|
);
|
895
|
-
|
896
|
-
|
1054
|
+
s = s.replace(
|
1055
|
+
m,
|
897
1056
|
`<script type="module">
|
898
|
-
${
|
1057
|
+
${i}
|
899
1058
|
<\/script>`
|
900
1059
|
);
|
901
1060
|
} else {
|
902
|
-
const
|
903
|
-
`<script\\b[^>]*\\bsrc=["']${
|
1061
|
+
const l = new RegExp(
|
1062
|
+
`<script\\b[^>]*\\bsrc=["']${_(a)}["'][^>]*>[^<]*<\/script>`,
|
904
1063
|
"gi"
|
905
1064
|
);
|
906
|
-
|
907
|
-
|
1065
|
+
s = s.replace(
|
1066
|
+
l,
|
908
1067
|
`<script type="module">
|
909
|
-
${
|
1068
|
+
${i}
|
910
1069
|
<\/script>`
|
911
1070
|
);
|
912
1071
|
}
|
913
1072
|
});
|
914
|
-
const o =
|
1073
|
+
const o = ze(e);
|
915
1074
|
if (o && !/<script\b[^>]*type=["']importmap["'][^>]*>/i.test(
|
916
|
-
|
1075
|
+
s
|
917
1076
|
)) {
|
918
|
-
const
|
1077
|
+
const a = `<script type="importmap">
|
919
1078
|
${o}
|
920
1079
|
<\/script>
|
921
1080
|
`;
|
922
|
-
|
923
|
-
|
1081
|
+
s = L(
|
1082
|
+
s,
|
924
1083
|
"</head>",
|
925
|
-
|
1084
|
+
a
|
926
1085
|
);
|
927
1086
|
}
|
928
|
-
const
|
1087
|
+
const c = `<script>${j()}<\/script>
|
929
1088
|
`;
|
930
|
-
|
931
|
-
|
1089
|
+
if (s = L(
|
1090
|
+
s,
|
1091
|
+
"</head>",
|
1092
|
+
c
|
1093
|
+
), r) {
|
1094
|
+
const i = `<script>${Pe()}<\/script>
|
1095
|
+
`;
|
1096
|
+
s = L(
|
1097
|
+
s,
|
1098
|
+
"</body>",
|
1099
|
+
i
|
1100
|
+
);
|
1101
|
+
}
|
1102
|
+
return /^\s*<!DOCTYPE/i.test(s) ? s : `<!DOCTYPE html>${s}`;
|
1103
|
+
}, De = async ({
|
932
1104
|
files: e,
|
933
1105
|
rollup: t,
|
934
1106
|
enableSourcemap: n = !0
|
935
1107
|
}) => {
|
936
|
-
const r = e["index.html"] || "", { entryPoints:
|
937
|
-
if (
|
938
|
-
return e;
|
1108
|
+
const r = e["index.html"] || "", { entryPoints: s, inlineScripts: o } = Fe(r);
|
1109
|
+
if (s.length === 0)
|
1110
|
+
return { files: e, bundledJS: "" };
|
939
1111
|
const c = { ...e };
|
940
|
-
for (const
|
941
|
-
c[
|
942
|
-
const i = /* @__PURE__ */ new Map();
|
943
|
-
for (const
|
944
|
-
const
|
945
|
-
entryPoint:
|
1112
|
+
for (const u of o)
|
1113
|
+
c[u.id] = u.content;
|
1114
|
+
const i = /* @__PURE__ */ new Map(), a = [];
|
1115
|
+
for (const u of s) {
|
1116
|
+
const m = await Ve({
|
1117
|
+
entryPoint: u,
|
946
1118
|
files: c,
|
947
1119
|
rollup: t,
|
948
1120
|
enableSourcemap: n
|
949
1121
|
});
|
950
|
-
i.set(
|
1122
|
+
i.set(u, m), a.push(m);
|
951
1123
|
}
|
952
|
-
const
|
1124
|
+
const d = Je(
|
1125
|
+
c,
|
1126
|
+
i,
|
1127
|
+
o,
|
1128
|
+
!0
|
1129
|
+
), l = a.join(`
|
1130
|
+
`);
|
953
1131
|
return {
|
954
|
-
|
955
|
-
|
1132
|
+
files: {
|
1133
|
+
...e,
|
1134
|
+
"index.html": d
|
1135
|
+
},
|
1136
|
+
bundledJS: l
|
956
1137
|
};
|
957
|
-
},
|
958
|
-
const t = `<script>${
|
959
|
-
return e.includes("</head>") ? e.replace(
|
960
|
-
</head
|
961
|
-
|
962
|
-
|
1138
|
+
}, x = !1, Ae = (e) => {
|
1139
|
+
const t = `<script>${j()}<\/script>`;
|
1140
|
+
return e.includes("</head>") ? e.replace(
|
1141
|
+
"</head>",
|
1142
|
+
`${t}
|
1143
|
+
</head>`
|
1144
|
+
) : e.includes("</body>") ? e.replace(
|
1145
|
+
"</body>",
|
1146
|
+
`${t}
|
1147
|
+
</body>`
|
1148
|
+
) : e + t;
|
1149
|
+
}, M = (e) => {
|
1150
|
+
const t = { ...e };
|
1151
|
+
for (const [n, r] of Object.entries(
|
1152
|
+
t
|
1153
|
+
))
|
1154
|
+
n.toLowerCase().endsWith(".html") && (t[n] = me(
|
1155
|
+
r,
|
1156
|
+
e
|
1157
|
+
));
|
1158
|
+
return t;
|
1159
|
+
}, Qe = async ({
|
963
1160
|
files: e,
|
964
1161
|
rollup: t,
|
965
1162
|
enableSourcemap: n = !0,
|
966
1163
|
vizCache: r,
|
967
|
-
vizId:
|
968
|
-
slugCache:
|
1164
|
+
vizId: s,
|
1165
|
+
slugCache: o,
|
969
1166
|
getSvelteCompiler: c
|
970
1167
|
}) => {
|
971
1168
|
try {
|
972
|
-
if (
|
1169
|
+
if (x && console.log(
|
973
1170
|
"[build] files:",
|
974
1171
|
e ? JSON.stringify(e).substring(0, 100) : void 0
|
975
|
-
),
|
1172
|
+
), x && console.log("[build] vizCache:", r), x && console.log("[build] vizId:", s), !e && !r)
|
976
1173
|
throw new Error(
|
977
1174
|
"Either files or vizCache is required"
|
978
1175
|
);
|
979
|
-
if (!e && r && !
|
1176
|
+
if (!e && r && !s)
|
980
1177
|
throw new Error(
|
981
1178
|
"vizId is required when using vizCache"
|
982
1179
|
);
|
983
|
-
if (!e && r &&
|
984
|
-
(await r.get(
|
1180
|
+
if (!e && r && s && (e = ee(
|
1181
|
+
(await r.get(s))?.files
|
985
1182
|
)), !e)
|
986
1183
|
throw new Error("Upable to extract viz files");
|
987
|
-
const i =
|
988
|
-
if (
|
1184
|
+
const i = Se(e);
|
1185
|
+
if (x && console.log("[build] version:", i), i === "v1") {
|
1186
|
+
const a = M(e);
|
989
1187
|
return {
|
990
|
-
html:
|
1188
|
+
html: Ae(
|
1189
|
+
C(a)
|
1190
|
+
),
|
991
1191
|
runtimeVersion: i
|
992
1192
|
};
|
1193
|
+
}
|
993
1194
|
if (i === "v2") {
|
994
1195
|
if (!t)
|
995
1196
|
throw new Error(
|
996
1197
|
"Rollup is required for v2 runtime"
|
997
1198
|
);
|
1199
|
+
const a = await Me({
|
1200
|
+
files: e,
|
1201
|
+
rollup: t,
|
1202
|
+
enableSourcemap: n
|
1203
|
+
}), d = M(a);
|
998
1204
|
return {
|
999
|
-
html:
|
1000
|
-
await Se({ files: e, rollup: t, enableSourcemap: n })
|
1001
|
-
),
|
1205
|
+
html: C(d),
|
1002
1206
|
runtimeVersion: i
|
1003
1207
|
};
|
1004
1208
|
}
|
@@ -1007,9 +1211,9 @@ ${o}
|
|
1007
1211
|
throw new Error(
|
1008
1212
|
"Rollup is required for v3 runtime"
|
1009
1213
|
);
|
1010
|
-
if (!r && !
|
1011
|
-
const a =
|
1012
|
-
|
1214
|
+
if (!r && !s) {
|
1215
|
+
const a = xe(e);
|
1216
|
+
s = a.id, r = Ee({
|
1013
1217
|
initialContents: [a],
|
1014
1218
|
handleCacheMiss: async () => {
|
1015
1219
|
throw new Error(
|
@@ -1022,16 +1226,16 @@ ${o}
|
|
1022
1226
|
throw new Error(
|
1023
1227
|
"vizCache is required for v3 runtime"
|
1024
1228
|
);
|
1025
|
-
if (!
|
1229
|
+
if (!s)
|
1026
1230
|
throw new Error(
|
1027
1231
|
"vizId is required for v3 runtime if vizCache is provided"
|
1028
1232
|
);
|
1029
|
-
return await
|
1233
|
+
return await be({
|
1030
1234
|
files: e,
|
1031
1235
|
rollup: t,
|
1032
1236
|
vizCache: r,
|
1033
|
-
vizId:
|
1034
|
-
slugCache:
|
1237
|
+
vizId: s,
|
1238
|
+
slugCache: o,
|
1035
1239
|
getSvelteCompiler: c
|
1036
1240
|
});
|
1037
1241
|
}
|
@@ -1040,14 +1244,21 @@ ${o}
|
|
1040
1244
|
throw new Error(
|
1041
1245
|
"Rollup is required for v4 runtime"
|
1042
1246
|
);
|
1043
|
-
|
1247
|
+
x && console.log("[build] v4Build", {
|
1044
1248
|
files: e,
|
1045
1249
|
rollup: t,
|
1046
1250
|
enableSourcemap: n
|
1047
|
-
})
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1251
|
+
});
|
1252
|
+
const a = await De({
|
1253
|
+
files: e,
|
1254
|
+
rollup: t,
|
1255
|
+
enableSourcemap: n
|
1256
|
+
}), d = M(
|
1257
|
+
a.files
|
1258
|
+
);
|
1259
|
+
return {
|
1260
|
+
html: C(d),
|
1261
|
+
js: a.bundledJS,
|
1051
1262
|
runtimeVersion: i
|
1052
1263
|
};
|
1053
1264
|
}
|
@@ -1055,21 +1266,21 @@ ${o}
|
|
1055
1266
|
`Unsupported runtime version: ${i}`
|
1056
1267
|
);
|
1057
1268
|
} catch (i) {
|
1058
|
-
throw i instanceof Error && i.message.indexOf(
|
1059
|
-
|
1269
|
+
throw i instanceof Error && i.message.indexOf(h) && (i.message = i.message.replace(
|
1270
|
+
h,
|
1060
1271
|
""
|
1061
1272
|
)), i;
|
1062
1273
|
}
|
1063
1274
|
};
|
1064
1275
|
export {
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1276
|
+
Ee as a,
|
1277
|
+
Qe as b,
|
1278
|
+
ge as c,
|
1279
|
+
Se as d,
|
1280
|
+
Ye as e,
|
1281
|
+
xe as f,
|
1282
|
+
qe as g,
|
1283
|
+
Ge as s,
|
1284
|
+
be as v
|
1074
1285
|
};
|
1075
|
-
//# sourceMappingURL=build-
|
1286
|
+
//# sourceMappingURL=build-B7w6NcTo.js.map
|