@vizhub/runtime 0.6.0 → 0.7.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.
@@ -1,14 +1,14 @@
1
1
  import { magicSandbox as j } from "magic-sandbox";
2
- import { isVizId as z, getFileText as k, generateVizId as U, vizFilesToFileCollection as J } from "@vizhub/viz-utils";
3
- import { transform as V } from "sucrase";
4
- const jt = () => (Math.random() + "").slice(2);
2
+ import { isVizId as U, getFileText as k, generateVizId as V, fileCollectionToVizFiles as J, vizFilesToFileCollection as D } from "@vizhub/viz-utils";
3
+ import { transform as B } from "sucrase";
4
+ const $t = () => (Math.random() + "").slice(2);
5
5
  function I() {
6
6
  return {
7
7
  name: "sucrase",
8
8
  transform(e, t) {
9
9
  if (!t.match(/\.(?:js|[jt]sx)$/))
10
10
  return null;
11
- const n = V(e, {
11
+ const n = B(e, {
12
12
  transforms: ["jsx", "typescript"],
13
13
  filePath: t,
14
14
  // For source maps
@@ -28,41 +28,41 @@ const T = {
28
28
  dependencies: {},
29
29
  vizhub: {},
30
30
  license: "MIT"
31
- }, D = !1, x = (e) => {
31
+ }, A = !1, E = (e) => {
32
32
  const t = e["package.json"];
33
33
  try {
34
34
  const n = t ? JSON.parse(t) : T;
35
- return D && console.log(
35
+ return A && console.log(
36
36
  "[packageJSON] pkg:",
37
37
  JSON.stringify(n, null, 2)
38
38
  ), n;
39
39
  } catch {
40
40
  return T;
41
41
  }
42
- }, N = (e) => x(e).dependencies || {}, C = (e) => (x(e).vizhub || {}).libraries || {}, R = ({ name: e, version: t }, n, r = "jsdelivr") => {
42
+ }, N = (e) => E(e).dependencies || {}, C = (e) => (E(e).vizhub || {}).libraries || {}, R = ({ name: e, version: t }, n, r = "jsdelivr") => {
43
43
  const s = n[e] && n[e].path || "";
44
44
  return r === "jsdelivr" ? `https://cdn.jsdelivr.net/npm/${e}@${t}${s}` : `https://unpkg.com/${e}@${t}${s}`;
45
- }, B = (e) => {
45
+ }, q = (e) => {
46
46
  var n;
47
47
  const t = (n = e == null ? void 0 : e.vizhub) == null ? void 0 : n.libraries;
48
48
  return t ? Object.entries(t).reduce(
49
49
  (r, [s, o]) => (o.global && (r[s] = o.global), r),
50
50
  {}
51
51
  ) : {};
52
- }, A = {
52
+ }, Y = {
53
53
  d3: "d3",
54
54
  react: "React",
55
55
  "react-dom": "ReactDOM"
56
56
  }, W = (e) => {
57
- const t = B(e);
57
+ const t = q(e);
58
58
  return {
59
- ...A,
59
+ ...Y,
60
60
  ...t
61
61
  };
62
- }, v = (e) => {
62
+ }, g = (e) => {
63
63
  const [t, ...n] = e.split("/"), r = n.join("/");
64
64
  return { vizId: t, fileName: r };
65
- }, q = `var EOL = {},
65
+ }, _ = `var EOL = {},
66
66
  EOF = {},
67
67
  QUOTE = 34,
68
68
  NEWLINE = 10,
@@ -182,32 +182,32 @@ var tsv = dsv(' ');
182
182
 
183
183
  var tsvParse = tsv.parse;
184
184
 
185
- export { csvParse, tsvParse };`, Y = (e) => (
185
+ export { csvParse, tsvParse };`, G = (e) => (
186
186
  // str.replace(/`/g, '\\`');
187
187
  e.replace(/\\/g, "\\\\").replace(/`/g, "\\`")
188
- ), _ = () => ({
188
+ ), H = () => ({
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 } = v(t), r = n.endsWith(".csv"), s = n.endsWith(".tsv");
193
+ const { fileName: n } = g(t), r = n.endsWith(".csv"), s = n.endsWith(".tsv");
194
194
  if (r || s)
195
195
  return {
196
196
  code: `
197
- ${q}
198
- const data = ${r ? "csvParse" : "tsvParse"}(\`${Y(e)}\`);
197
+ ${_}
198
+ const data = ${r ? "csvParse" : "tsvParse"}(\`${G(e)}\`);
199
199
  export default data;
200
200
  `,
201
201
  map: { mappings: "" }
202
202
  };
203
203
  }
204
- }), G = (e) => {
204
+ }), Q = (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
- }, H = ({
210
+ }, Z = ({
211
211
  vizId: e,
212
212
  slugCache: t
213
213
  }) => ({
@@ -219,15 +219,15 @@ export { csvParse, tsvParse };`, Y = (e) => (
219
219
  const {
220
220
  vizId: i,
221
221
  fileName: c
222
- } = v(r), a = c.split("/").slice(0, -1).join("/"), l = a ? `${a}/${o}` : o;
222
+ } = g(r), a = c.split("/").slice(0, -1).join("/"), l = a ? `${a}/${o}` : o;
223
223
  return `${i}/${l}`;
224
224
  }
225
225
  return e + "/" + o;
226
226
  }
227
- const s = G(n);
227
+ const s = Q(n);
228
228
  if (s) {
229
229
  let o;
230
- if (z(s.idOrSlug))
230
+ if (U(s.idOrSlug))
231
231
  o = s.idOrSlug;
232
232
  else {
233
233
  if (!t)
@@ -241,32 +241,40 @@ export { csvParse, tsvParse };`, Y = (e) => (
241
241
  return o + "/index.js";
242
242
  }
243
243
  }
244
- }), Q = ({
244
+ }), K = ({
245
245
  vizCache: e,
246
- trackCSSImport: t
246
+ trackCSSImport: t,
247
+ vizId: n,
248
+ files: r
247
249
  }) => ({
248
250
  name: "vizLoad",
249
251
  // `id` here is of the form
250
252
  // `{vizId}/{fileName}`
251
- load: async (n) => {
252
- const { vizId: r, fileName: s } = v(n);
253
- if (s.endsWith(".css"))
254
- return t(n), "";
255
- const o = await e.get(r), i = k(o, s);
256
- if (i === null)
253
+ load: async (s) => {
254
+ const o = g(s), i = o.vizId, c = o.fileName;
255
+ if (c.endsWith(".css"))
256
+ return t(s), "";
257
+ let a = null;
258
+ if (i === n && r)
259
+ a = r[c] || null;
260
+ else {
261
+ const l = await e.get(i);
262
+ a = k(l, c);
263
+ }
264
+ if (a === null)
257
265
  throw new Error(
258
- `Imported file "${s}" not found.`
266
+ `Imported file "${c}" not found.`
259
267
  );
260
- return i;
268
+ return a;
261
269
  }
262
270
  }), M = /* @__PURE__ */ new Map();
263
271
  let S;
264
- const w = "https://cdn.jsdelivr.net/npm/svelte@4.2.9", St = `${w}/compiler.cjs`, Z = ({
272
+ const v = "https://cdn.jsdelivr.net/npm/svelte@4.2.9", Ot = `${v}/compiler.cjs`, X = ({
265
273
  getSvelteCompiler: e
266
274
  }) => ({
267
275
  name: "transformSvelte",
268
276
  load: async (t) => {
269
- if (!t.startsWith(w))
277
+ if (!t.startsWith(v))
270
278
  return;
271
279
  const n = M.get(t);
272
280
  if (n) return n;
@@ -278,19 +286,19 @@ const w = "https://cdn.jsdelivr.net/npm/svelte@4.2.9", St = `${w}/compiler.cjs`,
278
286
  // From https://github.com/sveltejs/sites/blob/master/packages/repl/src/lib/workers/bundler/index.js#L255C2-L271C5
279
287
  resolveId: async (t, n) => {
280
288
  if (t === "svelte")
281
- return `${w}/src/runtime/index.js`;
289
+ return `${v}/src/runtime/index.js`;
282
290
  if (t.startsWith("svelte/")) {
283
291
  const r = t.slice(7);
284
- return `${w}/src/runtime/${r}/index.js`;
292
+ return `${v}/src/runtime/${r}/index.js`;
285
293
  }
286
294
  if (/^https?:/.test(t)) return t;
287
- if (t.startsWith(".") && n && n.startsWith(w)) {
295
+ if (t.startsWith(".") && n && n.startsWith(v)) {
288
296
  const r = new URL(t, n).href;
289
297
  return new URL(t, n).href, r;
290
298
  }
291
299
  },
292
300
  transform: async (t, n) => {
293
- const { fileName: r } = v(n);
301
+ const { fileName: r } = g(n);
294
302
  if (r.endsWith(".svelte")) {
295
303
  if (!S) {
296
304
  if (!e)
@@ -303,7 +311,7 @@ const w = "https://cdn.jsdelivr.net/npm/svelte@4.2.9", St = `${w}/compiler.cjs`,
303
311
  }).js;
304
312
  }
305
313
  }
306
- }), K = async ({
314
+ }), tt = async ({
307
315
  files: e,
308
316
  rollup: t,
309
317
  enableSourcemap: n = !0,
@@ -320,40 +328,47 @@ const w = "https://cdn.jsdelivr.net/npm/svelte@4.2.9", St = `${w}/compiler.cjs`,
320
328
  const d = {
321
329
  input: "./index.js",
322
330
  plugins: [
323
- ...s ? [H({ vizId: s, slugCache: o })] : [],
324
- _(),
331
+ ...s ? [Z({ vizId: s, slugCache: o })] : [],
332
+ H(),
325
333
  I(),
326
- Z({ getSvelteCompiler: i }),
327
- ...r ? [Q({ vizCache: r, trackCSSImport: a })] : []
334
+ X({ getSvelteCompiler: i }),
335
+ ...r ? [
336
+ K({
337
+ vizCache: r,
338
+ trackCSSImport: a,
339
+ vizId: s,
340
+ files: e
341
+ })
342
+ ] : []
328
343
  ],
329
- onwarn(u, h) {
330
- u.code !== "UNRESOLVED_IMPORT" && h(u);
344
+ onwarn(u, f) {
345
+ u.code !== "UNRESOLVED_IMPORT" && f(u);
331
346
  }
332
347
  }, p = {
333
348
  format: "umd",
334
349
  name: "Viz",
335
350
  sourcemap: !!n,
336
351
  compact: !0
337
- }, f = x(e);
338
- if (f) {
339
- const u = W(f);
352
+ }, h = E(e);
353
+ if (h) {
354
+ const u = W(h);
340
355
  u && (d.external = Object.keys(u), p.globals = u);
341
356
  }
342
- const g = await t(d), { output: m } = await g.generate(p);
357
+ const x = await t(d), { output: m } = await x.generate(p);
343
358
  return {
344
359
  src: m[0].code,
345
360
  cssFiles: Array.from(c)
346
361
  };
347
362
  };
348
- function X() {
363
+ function et() {
349
364
  return Math.random().toString().slice(2, 7);
350
365
  }
351
- const tt = ({
366
+ const nt = ({
352
367
  cdn: e,
353
368
  src: t,
354
369
  styles: n
355
370
  }) => {
356
- const s = `viz-container-${X()}`;
371
+ const s = `viz-container-${et()}`;
357
372
  return `<!DOCTYPE html>
358
373
  <html>
359
374
  <head>
@@ -433,7 +448,7 @@ const tt = ({
433
448
  <\/script>
434
449
  </body>
435
450
  </html>`;
436
- }, et = async ({
451
+ }, rt = async ({
437
452
  files: e,
438
453
  rollup: t,
439
454
  enableSourcemap: n = !0,
@@ -442,7 +457,7 @@ const tt = ({
442
457
  slugCache: o,
443
458
  getSvelteCompiler: i
444
459
  }) => {
445
- const { src: c, cssFiles: a } = await K({
460
+ const { src: c, cssFiles: a } = await tt({
446
461
  files: e,
447
462
  rollup: t,
448
463
  enableSourcemap: n,
@@ -454,21 +469,28 @@ const tt = ({
454
469
  let l = [];
455
470
  if (a.length > 0)
456
471
  for (let m = 0; m < a.length; m++) {
457
- const u = a[m], { vizId: h, fileName: y } = v(u), b = await r.get(h), E = k(b, y);
458
- E && l.push(E);
472
+ const u = a[m], f = g(u), y = f.vizId, b = f.fileName;
473
+ let w = null;
474
+ if (y === s && e)
475
+ w = e[b] || null;
476
+ else {
477
+ const L = await r.get(y);
478
+ w = k(L, b);
479
+ }
480
+ w && l.push(w);
459
481
  }
460
482
  const d = l.join(`
461
483
  `), p = `
462
484
  <style id="injected-style">${d}</style>`;
463
- let f = "";
464
- const g = Object.entries(
485
+ let h = "";
486
+ const x = Object.entries(
465
487
  N(e)
466
488
  );
467
- if (g.length > 0) {
489
+ if (x.length > 0) {
468
490
  const m = C(e);
469
- f = g.map(([u, h], y) => {
491
+ h = x.map(([u, f], y) => {
470
492
  const b = R(
471
- { name: u, version: h },
493
+ { name: u, version: f },
472
494
  m
473
495
  );
474
496
  return `${y > 0 ? " " : `
@@ -476,11 +498,11 @@ const tt = ({
476
498
  }).join("");
477
499
  }
478
500
  return {
479
- html: tt({ cdn: f, src: c, styles: p }),
501
+ html: nt({ cdn: h, src: c, styles: p }),
480
502
  css: d,
481
503
  js: c
482
504
  };
483
- }, nt = ({
505
+ }, st = ({
484
506
  initialContents: e,
485
507
  handleCacheMiss: t
486
508
  }) => {
@@ -506,7 +528,7 @@ const tt = ({
506
528
  }, invalidate: (i) => {
507
529
  n.delete(i);
508
530
  } };
509
- }, $t = ({
531
+ }, It = ({
510
532
  initialMappings: e = {},
511
533
  handleCacheMiss: t
512
534
  }) => {
@@ -530,53 +552,40 @@ const tt = ({
530
552
  }, invalidate: (i) => {
531
553
  n.delete(i);
532
554
  } };
533
- }, rt = (e, t = "Sample Content for Exporting") => {
534
- const n = U(), r = {};
535
- return Object.entries(e).forEach(
536
- ([s, o]) => {
537
- const i = Math.floor(
538
- Math.random() * 1e7
539
- ).toString();
540
- r[i] = {
541
- name: s,
542
- text: o
543
- };
544
- }
545
- ), {
546
- id: n,
547
- files: r,
548
- title: t
549
- };
550
- }, st = (e) => {
555
+ }, ot = (e, t = "Sample Content for Exporting", n = V()) => ({
556
+ id: n,
557
+ files: J(e),
558
+ title: t
559
+ }), it = (e) => {
551
560
  if (Object.keys(e).length === 0)
552
561
  return null;
553
562
  const t = "index.html" in e, n = "index.js" in e, r = "index.jsx" in e;
554
563
  return t ? e["index.html"].includes('type="module"') ? "v4" : n || r ? "v2" : "v1" : !t && n ? "v3" : null;
555
- }, $ = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), ot = (e) => {
564
+ }, $ = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), ct = (e) => {
556
565
  const t = e.trim();
557
566
  return $(t, "html") && $(t, "head") && $(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
558
- }, it = (e, t) => e.replace(
567
+ }, at = (e, t) => e.replace(
559
568
  new RegExp(
560
569
  `<script[^>]*src=["'][^"']*${t.source}[^"']*["'][^>]*>\\s*<\/script>`,
561
570
  "gi"
562
571
  ),
563
572
  ""
564
- ), P = (e, t, n) => e.replace(
573
+ ), F = (e, t, n) => e.replace(
565
574
  new RegExp(t, "i"),
566
575
  `${n}${t}`
567
- ), ct = (e, t) => {
568
- let n = ot(e);
576
+ ), lt = (e, t) => {
577
+ let n = ct(e);
569
578
  const r = Object.entries(N(t));
570
579
  if (r.length) {
571
580
  const o = C(t);
572
581
  r.forEach(([c]) => {
573
- n = it(n, new RegExp(`${c}@`));
582
+ n = at(n, new RegExp(`${c}@`));
574
583
  });
575
584
  const i = r.map(
576
585
  ([c, a]) => R({ name: c, version: a }, o)
577
586
  ).map((c) => `<script src="${c}"><\/script>`).join(`
578
587
  `);
579
- n = P(
588
+ n = F(
580
589
  n,
581
590
  "</head>",
582
591
  i + `
@@ -590,25 +599,25 @@ const tt = ({
590
599
  if (l === -1) return !1;
591
600
  const d = n.search(/<body\b[^>]*>/i), p = n.search(/<\/body>/i);
592
601
  return d !== -1 && p !== -1 && l > d && l < p;
593
- })() || (n = n.replace(i, ""), n = P(n, "</body>", o));
602
+ })() || (n = n.replace(i, ""), n = F(n, "</body>", o));
594
603
  }
595
604
  return /^\s*<!DOCTYPE/i.test(n) ? n : `<!DOCTYPE html>${n}`;
596
- }, at = (e) => {
605
+ }, ut = (e) => {
597
606
  const t = e["index.html"];
598
- return !t && !e["index.js"] && !e["bundle.js"] ? "" : ct(t || "<!DOCTYPE html><html><head></head><body></body></html>", e);
599
- }, F = (e) => {
607
+ return !t && !e["index.js"] && !e["bundle.js"] ? "" : lt(t || "<!DOCTYPE html><html><head></head><body></body></html>", e);
608
+ }, P = (e) => {
600
609
  let t = e.replace(/^\.\//, "");
601
610
  return t = t.replace(/\/+/g, "/"), t = t.replace(/\/$/, ""), t;
602
- }, lt = (e, t) => {
611
+ }, dt = (e, t) => {
603
612
  const n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = t.split("/"), s = n ? n.split("/") : [];
604
613
  for (const o of r)
605
614
  o === ".." ? s.pop() : o !== "." && o !== "" && s.push(o);
606
615
  return s.join("/");
607
- }, L = (e) => ({
616
+ }, z = (e) => ({
608
617
  name: "virtual-file-system",
609
618
  resolveId(t, n) {
610
619
  if (t.startsWith("./") || t.startsWith("../")) {
611
- const s = F(n ? lt(n, t) : t);
620
+ const s = P(n ? dt(n, t) : t);
612
621
  if (e[s])
613
622
  return s;
614
623
  const o = [".js", ".jsx", ".ts", ".tsx"];
@@ -631,7 +640,7 @@ const tt = ({
631
640
  load(t) {
632
641
  return e[t] ? e[t] : null;
633
642
  }
634
- }), ut = async ({
643
+ }), pt = async ({
635
644
  files: e,
636
645
  rollup: t,
637
646
  enableSourcemap: n = !0
@@ -640,33 +649,33 @@ const tt = ({
640
649
  throw new Error("Missing index.js");
641
650
  const s = {
642
651
  input: "./index.js",
643
- plugins: [L(e), I()],
652
+ plugins: [z(e), I()],
644
653
  onwarn(l, d) {
645
654
  l.code !== "UNRESOLVED_IMPORT" && d(l);
646
655
  }
647
656
  }, o = {
648
657
  format: "iife",
649
658
  sourcemap: n
650
- }, i = x(e);
659
+ }, i = E(e);
651
660
  if (i) {
652
661
  const l = W(i);
653
662
  l && (s.external = Object.keys(l), o.globals = l);
654
663
  }
655
664
  const c = await t(s), { output: a } = await c.generate(o);
656
665
  return a[0].code;
657
- }, dt = async ({
666
+ }, mt = async ({
658
667
  files: e,
659
668
  rollup: t,
660
669
  enableSourcemap: n
661
670
  }) => ({
662
671
  ...e,
663
- "bundle.js": await ut({
672
+ "bundle.js": await pt({
664
673
  files: e,
665
674
  rollup: t,
666
675
  enableSourcemap: n
667
676
  }),
668
- "index.html": at(e)
669
- }), pt = (e) => {
677
+ "index.html": ut(e)
678
+ }), ft = (e) => {
670
679
  const t = [], n = /<script\b([^>]*)>[\s\S]*?<\/script>/gi;
671
680
  let r;
672
681
  for (; (r = n.exec(e)) !== null; ) {
@@ -679,7 +688,7 @@ const tt = ({
679
688
  o && t.push(o[1]);
680
689
  }
681
690
  return t;
682
- }, mt = async ({
691
+ }, ht = async ({
683
692
  entryPoint: e,
684
693
  files: t,
685
694
  rollup: n,
@@ -687,7 +696,7 @@ const tt = ({
687
696
  }) => {
688
697
  const s = {
689
698
  input: `./${e}`,
690
- plugins: [L(t), I()],
699
+ plugins: [z(t), I()],
691
700
  external: (c) => t[c] ? !1 : !c.startsWith("./"),
692
701
  onwarn(c, a) {
693
702
  a(c);
@@ -697,13 +706,13 @@ const tt = ({
697
706
  sourcemap: r
698
707
  });
699
708
  return i[0].code;
700
- }, O = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), ft = (e) => {
709
+ }, O = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), wt = (e) => {
701
710
  const t = e.trim();
702
711
  return O(t, "html") && O(t, "head") && O(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
703
- }, ht = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), wt = (e, t, n) => e.replace(
712
+ }, vt = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), gt = (e, t, n) => e.replace(
704
713
  new RegExp(t, "i"),
705
714
  `${n}${t}`
706
- ), vt = (e) => {
715
+ ), xt = (e) => {
707
716
  const t = N(e);
708
717
  if (Object.keys(t).length === 0) return null;
709
718
  const n = C(e), r = {};
@@ -713,12 +722,12 @@ const tt = ({
713
722
  n
714
723
  );
715
724
  return JSON.stringify({ imports: r }, null, 2);
716
- }, gt = (e, t) => {
725
+ }, yt = (e, t) => {
717
726
  if (!e["index.html"]) return "";
718
- let n = ft(e["index.html"]);
727
+ let n = wt(e["index.html"]);
719
728
  t.forEach((s, o) => {
720
729
  const i = new RegExp(
721
- `<script\\b[^>]*\\bsrc=["']${ht(o)}["'][^>]*>[^<]*<\/script>`,
730
+ `<script\\b[^>]*\\bsrc=["']${vt(o)}["'][^>]*>[^<]*<\/script>`,
722
731
  "gi"
723
732
  );
724
733
  n = n.replace(
@@ -728,7 +737,7 @@ ${s}
728
737
  <\/script>`
729
738
  );
730
739
  });
731
- const r = vt(e);
740
+ const r = xt(e);
732
741
  if (r && !/<script\b[^>]*type=["']importmap["'][^>]*>/i.test(
733
742
  n
734
743
  )) {
@@ -736,24 +745,24 @@ ${s}
736
745
  ${r}
737
746
  <\/script>
738
747
  `;
739
- n = wt(
748
+ n = gt(
740
749
  n,
741
750
  "</head>",
742
751
  o
743
752
  );
744
753
  }
745
754
  return /^\s*<!DOCTYPE/i.test(n) ? n : `<!DOCTYPE html>${n}`;
746
- }, xt = async ({
755
+ }, bt = async ({
747
756
  files: e,
748
757
  rollup: t,
749
758
  enableSourcemap: n = !0
750
759
  }) => {
751
- const r = e["index.html"] || "", s = pt(r);
760
+ const r = e["index.html"] || "", s = ft(r);
752
761
  if (s.length === 0)
753
762
  return e;
754
763
  const o = /* @__PURE__ */ new Map();
755
764
  for (const c of s) {
756
- const a = await mt({
765
+ const a = await ht({
757
766
  entryPoint: c,
758
767
  files: e,
759
768
  rollup: t,
@@ -761,12 +770,12 @@ ${r}
761
770
  });
762
771
  o.set(c, a);
763
772
  }
764
- const i = gt(e, o);
773
+ const i = yt(e, o);
765
774
  return {
766
775
  ...e,
767
776
  "index.html": i
768
777
  };
769
- }, Ot = async ({
778
+ }, Nt = async ({
770
779
  files: e,
771
780
  rollup: t,
772
781
  enableSourcemap: n = !0,
@@ -782,11 +791,11 @@ ${r}
782
791
  throw new Error(
783
792
  "vizId is required when using vizCache"
784
793
  );
785
- if (!e && r && s && (e = J(
794
+ if (!e && r && s && (e = D(
786
795
  (a = await r.get(s)) == null ? void 0 : a.files
787
796
  )), !e)
788
797
  throw new Error("Upable to extract viz files");
789
- const c = st(e);
798
+ const c = it(e);
790
799
  if (c === "v1")
791
800
  return {
792
801
  html: j(e)
@@ -796,7 +805,7 @@ ${r}
796
805
  throw new Error("Rollup is required for v2 runtime");
797
806
  return {
798
807
  html: j(
799
- await dt({ files: e, rollup: t, enableSourcemap: n })
808
+ await mt({ files: e, rollup: t, enableSourcemap: n })
800
809
  )
801
810
  };
802
811
  }
@@ -804,8 +813,8 @@ ${r}
804
813
  if (!t)
805
814
  throw new Error("Rollup is required for v3 runtime");
806
815
  if (!r && !s) {
807
- const l = rt(e);
808
- s = l.id, r = nt({
816
+ const l = ot(e);
817
+ s = l.id, r = st({
809
818
  initialContents: [l],
810
819
  handleCacheMiss: async () => {
811
820
  throw new Error(
@@ -819,8 +828,10 @@ ${r}
819
828
  "vizCache is required for v3 runtime"
820
829
  );
821
830
  if (!s)
822
- throw new Error("vizId is required for v3 runtime");
823
- return await et({
831
+ throw new Error(
832
+ "vizId is required for v3 runtime if vizCache is provided"
833
+ );
834
+ return await rt({
824
835
  files: e,
825
836
  rollup: t,
826
837
  vizCache: r,
@@ -834,7 +845,7 @@ ${r}
834
845
  throw new Error("Rollup is required for v4 runtime");
835
846
  return {
836
847
  html: j(
837
- await xt({ files: e, rollup: t, enableSourcemap: n })
848
+ await bt({ files: e, rollup: t, enableSourcemap: n })
838
849
  )
839
850
  };
840
851
  }
@@ -843,13 +854,13 @@ ${r}
843
854
  );
844
855
  };
845
856
  export {
846
- nt as a,
847
- Ot as b,
848
- K as c,
849
- $t as d,
850
- rt as e,
851
- jt as g,
852
- St as s,
853
- et as v
857
+ st as a,
858
+ Nt as b,
859
+ tt as c,
860
+ It as d,
861
+ ot as e,
862
+ $t as g,
863
+ Ot as s,
864
+ rt as v
854
865
  };
855
- //# sourceMappingURL=build-DU4cyBtp.js.map
866
+ //# sourceMappingURL=build-NWFvyYnC.js.map