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