@vizhub/runtime 4.1.0 → 4.2.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/dist/build/build.d.ts.map +1 -1
- package/dist/build-BXOhZlRS.cjs +256 -0
- package/dist/build-BXOhZlRS.cjs.map +1 -0
- package/dist/build-DnPT2Qew.js +1075 -0
- package/dist/build-DnPT2Qew.js.map +1 -0
- package/dist/common/runtimeErrorHandling.d.ts +9 -0
- package/dist/common/runtimeErrorHandling.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -92
- package/dist/index.js.map +1 -1
- package/dist/orchestration/createRuntime.d.ts +2 -1
- package/dist/orchestration/createRuntime.d.ts.map +1 -1
- package/dist/orchestration/types.d.ts +3 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/test/extractEntryPoints.test.d.ts +2 -0
- package/dist/test/extractEntryPoints.test.d.ts.map +1 -0
- package/dist/test/extractEntryPointsEdgeCases.test.d.ts +2 -0
- package/dist/test/extractEntryPointsEdgeCases.test.d.ts.map +1 -0
- package/dist/test/fixtures/v3/svelte.d.ts.map +1 -1
- package/dist/test/fixtures/v4/index.d.ts +1 -0
- package/dist/test/fixtures/v4/index.d.ts.map +1 -1
- package/dist/test/fixtures/v4/jsInlineScriptModule.d.ts +5 -0
- package/dist/test/fixtures/v4/jsInlineScriptModule.d.ts.map +1 -0
- package/dist/test/runtimeErrorHandling.test.d.ts +2 -0
- package/dist/test/runtimeErrorHandling.test.d.ts.map +1 -0
- package/dist/test/runtimeErrorHandlingAllVersions.test.d.ts +2 -0
- package/dist/test/runtimeErrorHandlingAllVersions.test.d.ts.map +1 -0
- package/dist/test/runtimeErrorHandlingIntegration.test.d.ts +2 -0
- package/dist/test/runtimeErrorHandlingIntegration.test.d.ts.map +1 -0
- package/dist/test/updateHTML.test.d.ts +2 -0
- package/dist/test/updateHTML.test.d.ts.map +1 -0
- package/dist/test/v4Build.test.d.ts +2 -0
- package/dist/test/v4Build.test.d.ts.map +1 -0
- package/dist/test/v4BuildIntegration.test.d.ts +2 -0
- package/dist/test/v4BuildIntegration.test.d.ts.map +1 -0
- package/dist/v2/getComputedIndexHtml.d.ts.map +1 -1
- package/dist/v3/htmlTemplate.d.ts.map +1 -1
- package/dist/v3/svelte5-integration.test.d.ts +2 -0
- package/dist/v3/svelte5-integration.test.d.ts.map +1 -0
- package/dist/v3/transformSvelte.d.ts +9 -2
- package/dist/v3/transformSvelte.d.ts.map +1 -1
- package/dist/v3/transformSvelte.test.d.ts +2 -0
- package/dist/v3/transformSvelte.test.d.ts.map +1 -0
- package/dist/v4/extractEntryPoints.d.ts +7 -1
- package/dist/v4/extractEntryPoints.d.ts.map +1 -1
- package/dist/v4/index.d.ts.map +1 -1
- package/dist/v4/updateHTML.d.ts +4 -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 +22 -14
- package/dist/build-D8ObHgQc.js +0 -984
- package/dist/build-D8ObHgQc.js.map +0 -1
- package/dist/build-t6B4kQWS.cjs +0 -214
- package/dist/build-t6B4kQWS.cjs.map +0 -1
@@ -0,0 +1,1075 @@
|
|
1
|
+
import { magicSandbox as I } from "magic-sandbox";
|
2
|
+
import { isVizId as q, getFileText as D, generateVizId as H, fileCollectionToVizFiles as G, vizFilesToFileCollection as Y } from "@vizhub/viz-utils";
|
3
|
+
import { transform as Q } from "sucrase";
|
4
|
+
const ze = () => (Math.random() + "").slice(2);
|
5
|
+
function k(e = {}) {
|
6
|
+
return {
|
7
|
+
name: "sucrase",
|
8
|
+
transform(t, n) {
|
9
|
+
if (!n.match(/\.(?:js|[jt]sx)$/))
|
10
|
+
return null;
|
11
|
+
const r = Q(t, {
|
12
|
+
transforms: ["jsx", "typescript"],
|
13
|
+
// For source maps
|
14
|
+
filePath: n,
|
15
|
+
sourceMapOptions: {
|
16
|
+
compiledFilename: "bundle.js"
|
17
|
+
},
|
18
|
+
production: !0,
|
19
|
+
...e
|
20
|
+
});
|
21
|
+
return {
|
22
|
+
code: r.code,
|
23
|
+
map: r.sourceMap
|
24
|
+
};
|
25
|
+
}
|
26
|
+
};
|
27
|
+
}
|
28
|
+
const P = {
|
29
|
+
dependencies: {},
|
30
|
+
vizhub: {},
|
31
|
+
license: "MIT"
|
32
|
+
}, X = !1, j = (e) => {
|
33
|
+
const t = e["package.json"];
|
34
|
+
try {
|
35
|
+
const n = t ? JSON.parse(t) : P;
|
36
|
+
return X && console.log(
|
37
|
+
"[packageJSON] pkg:",
|
38
|
+
JSON.stringify(n, null, 2)
|
39
|
+
), n;
|
40
|
+
} catch {
|
41
|
+
return P;
|
42
|
+
}
|
43
|
+
}, M = (e) => j(e).dependencies || {}, F = (e) => (j(e).vizhub || {}).libraries || {}, L = ({ name: e, version: t }, n, r = "jsdelivr") => {
|
44
|
+
const o = n[e] && n[e].path || "";
|
45
|
+
return r === "jsdelivr" ? `https://cdn.jsdelivr.net/npm/${e}@${t}${o}` : `https://unpkg.com/${e}@${t}${o}`;
|
46
|
+
}, Z = (e) => {
|
47
|
+
const t = e?.vizhub?.libraries;
|
48
|
+
return t ? Object.entries(t).reduce(
|
49
|
+
(n, [r, o]) => (o.global && (n[r] = o.global), n),
|
50
|
+
{}
|
51
|
+
) : {};
|
52
|
+
}, K = {
|
53
|
+
d3: "d3",
|
54
|
+
react: "React",
|
55
|
+
"react-dom": "ReactDOM"
|
56
|
+
}, A = (e) => {
|
57
|
+
const t = Z(e);
|
58
|
+
return {
|
59
|
+
...K,
|
60
|
+
...t
|
61
|
+
};
|
62
|
+
}, b = (e) => {
|
63
|
+
const [t, ...n] = e.split("/"), r = n.join("/");
|
64
|
+
return { vizId: t, fileName: r };
|
65
|
+
}, ee = `var EOL = {},
|
66
|
+
EOF = {},
|
67
|
+
QUOTE = 34,
|
68
|
+
NEWLINE = 10,
|
69
|
+
RETURN = 13;
|
70
|
+
|
71
|
+
function objectConverter(columns) {
|
72
|
+
return new Function(
|
73
|
+
'd',
|
74
|
+
'return {' +
|
75
|
+
columns
|
76
|
+
.map(function (name, i) {
|
77
|
+
return (
|
78
|
+
JSON.stringify(name) + ': d[' + i + '] || ""'
|
79
|
+
);
|
80
|
+
})
|
81
|
+
.join(',') +
|
82
|
+
'}',
|
83
|
+
);
|
84
|
+
}
|
85
|
+
|
86
|
+
function customConverter(columns, f) {
|
87
|
+
var object = objectConverter(columns);
|
88
|
+
return function (row, i) {
|
89
|
+
return f(object(row), i, columns);
|
90
|
+
};
|
91
|
+
}
|
92
|
+
|
93
|
+
function dsv(delimiter) {
|
94
|
+
var DELIMITER = delimiter.charCodeAt(0);
|
95
|
+
|
96
|
+
function parse(text, f) {
|
97
|
+
var convert,
|
98
|
+
columns,
|
99
|
+
rows = parseRows(text, function (row, i) {
|
100
|
+
if (convert) return convert(row, i - 1);
|
101
|
+
(columns = row),
|
102
|
+
(convert = f
|
103
|
+
? customConverter(row, f)
|
104
|
+
: objectConverter(row));
|
105
|
+
});
|
106
|
+
rows.columns = columns || [];
|
107
|
+
return rows;
|
108
|
+
}
|
109
|
+
|
110
|
+
function parseRows(text, f) {
|
111
|
+
var rows = [], // output rows
|
112
|
+
N = text.length,
|
113
|
+
I = 0, // current character index
|
114
|
+
n = 0, // current line number
|
115
|
+
t, // current token
|
116
|
+
eof = N <= 0, // current token followed by EOF?
|
117
|
+
eol = false; // current token followed by EOL?
|
118
|
+
|
119
|
+
// Strip the trailing newline.
|
120
|
+
if (text.charCodeAt(N - 1) === NEWLINE) --N;
|
121
|
+
if (text.charCodeAt(N - 1) === RETURN) --N;
|
122
|
+
|
123
|
+
function token() {
|
124
|
+
if (eof) return EOF;
|
125
|
+
if (eol) return (eol = false), EOL;
|
126
|
+
|
127
|
+
// Unescape quotes.
|
128
|
+
var i,
|
129
|
+
j = I,
|
130
|
+
c;
|
131
|
+
if (text.charCodeAt(j) === QUOTE) {
|
132
|
+
while (
|
133
|
+
(I++ < N && text.charCodeAt(I) !== QUOTE) ||
|
134
|
+
text.charCodeAt(++I) === QUOTE
|
135
|
+
);
|
136
|
+
if ((i = I) >= N) eof = true;
|
137
|
+
else if ((c = text.charCodeAt(I++)) === NEWLINE)
|
138
|
+
eol = true;
|
139
|
+
else if (c === RETURN) {
|
140
|
+
eol = true;
|
141
|
+
if (text.charCodeAt(I) === NEWLINE) ++I;
|
142
|
+
}
|
143
|
+
return text.slice(j + 1, i - 1).replace(/""/g, '"');
|
144
|
+
}
|
145
|
+
|
146
|
+
// Find next delimiter or newline.
|
147
|
+
while (I < N) {
|
148
|
+
if ((c = text.charCodeAt((i = I++))) === NEWLINE)
|
149
|
+
eol = true;
|
150
|
+
else if (c === RETURN) {
|
151
|
+
eol = true;
|
152
|
+
if (text.charCodeAt(I) === NEWLINE) ++I;
|
153
|
+
} else if (c !== DELIMITER) continue;
|
154
|
+
return text.slice(j, i);
|
155
|
+
}
|
156
|
+
|
157
|
+
// Return last token before EOF.
|
158
|
+
return (eof = true), text.slice(j, N);
|
159
|
+
}
|
160
|
+
|
161
|
+
while ((t = token()) !== EOF) {
|
162
|
+
var row = [];
|
163
|
+
while (t !== EOL && t !== EOF)
|
164
|
+
row.push(t), (t = token());
|
165
|
+
if (f && (row = f(row, n++)) == null) continue;
|
166
|
+
rows.push(row);
|
167
|
+
}
|
168
|
+
|
169
|
+
return rows;
|
170
|
+
}
|
171
|
+
|
172
|
+
return {
|
173
|
+
parse: parse,
|
174
|
+
};
|
175
|
+
}
|
176
|
+
|
177
|
+
var csv = dsv(',');
|
178
|
+
|
179
|
+
var csvParse = csv.parse;
|
180
|
+
|
181
|
+
var tsv = dsv(' ');
|
182
|
+
|
183
|
+
var tsvParse = tsv.parse;
|
184
|
+
|
185
|
+
export { csvParse, tsvParse };`, te = (e) => (
|
186
|
+
// str.replace(/`/g, '\\`');
|
187
|
+
e.replace(/\\/g, "\\\\").replace(/`/g, "\\`")
|
188
|
+
), ne = () => ({
|
189
|
+
name: "transformDSV",
|
190
|
+
// `id` here is of the form
|
191
|
+
// `{vizId}/{fileName}`
|
192
|
+
transform: async (e, t) => {
|
193
|
+
const { fileName: n } = b(t), r = n.endsWith(".csv"), o = n.endsWith(".tsv");
|
194
|
+
if (r || o)
|
195
|
+
return {
|
196
|
+
code: `
|
197
|
+
${ee}
|
198
|
+
const data = ${r ? "csvParse" : "tsvParse"}(\`${te(e)}\`);
|
199
|
+
export default data;
|
200
|
+
`,
|
201
|
+
map: { mappings: "" }
|
202
|
+
};
|
203
|
+
}
|
204
|
+
}), re = (e) => {
|
205
|
+
const t = /^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)$/, n = e.match(t);
|
206
|
+
return n ? {
|
207
|
+
userName: n[1],
|
208
|
+
idOrSlug: n[2]
|
209
|
+
} : null;
|
210
|
+
}, se = ({
|
211
|
+
vizId: e,
|
212
|
+
slugCache: t
|
213
|
+
}) => ({
|
214
|
+
name: "vizResolve",
|
215
|
+
resolveId: async (n, r) => {
|
216
|
+
if (n.startsWith("./") && !r?.startsWith("https://")) {
|
217
|
+
let s = n.substring(2);
|
218
|
+
if (!s.endsWith(".js") && !s.endsWith(".css") && !s.endsWith(".csv") && !s.endsWith(".svelte") && (s += ".js"), r) {
|
219
|
+
const {
|
220
|
+
vizId: c,
|
221
|
+
fileName: i
|
222
|
+
} = b(r), a = i.split("/").slice(0, -1).join("/"), d = a ? `${a}/${s}` : s;
|
223
|
+
return `${c}/${d}`;
|
224
|
+
}
|
225
|
+
return e + "/" + s;
|
226
|
+
}
|
227
|
+
const o = re(n);
|
228
|
+
if (o) {
|
229
|
+
let s;
|
230
|
+
if (q(o.idOrSlug))
|
231
|
+
s = o.idOrSlug;
|
232
|
+
else {
|
233
|
+
if (!t)
|
234
|
+
throw new Error(
|
235
|
+
"slugCache is required to import by slug in v3 runtime"
|
236
|
+
);
|
237
|
+
s = await t.get(
|
238
|
+
`${o.userName}/${o.idOrSlug}`
|
239
|
+
);
|
240
|
+
}
|
241
|
+
return s + "/index.js";
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}), oe = ({
|
245
|
+
vizCache: e,
|
246
|
+
trackCSSImport: t,
|
247
|
+
vizId: n,
|
248
|
+
files: r
|
249
|
+
}) => ({
|
250
|
+
name: "vizLoad",
|
251
|
+
// `id` here is of the form
|
252
|
+
// `{vizId}/{fileName}`
|
253
|
+
load: async (o) => {
|
254
|
+
const s = b(o), c = s.vizId, i = s.fileName;
|
255
|
+
if (i.endsWith(".css"))
|
256
|
+
return t(o), "";
|
257
|
+
let a = null;
|
258
|
+
if (c === n && r)
|
259
|
+
a = r[i] || null;
|
260
|
+
else {
|
261
|
+
const d = await e.get(c);
|
262
|
+
a = D(d, i);
|
263
|
+
}
|
264
|
+
if (a === null)
|
265
|
+
throw new Error(
|
266
|
+
`Imported file "${i}" not found.`
|
267
|
+
);
|
268
|
+
return a;
|
269
|
+
}
|
270
|
+
}), z = /* @__PURE__ */ new Map();
|
271
|
+
let C;
|
272
|
+
const E = "https://cdn.jsdelivr.net/npm/svelte@5", Ue = `${E}/compiler.cjs`, ie = ({
|
273
|
+
getSvelteCompiler: e
|
274
|
+
}) => ({
|
275
|
+
name: "transformSvelte",
|
276
|
+
load: async (t) => {
|
277
|
+
if (!t.startsWith(E))
|
278
|
+
return;
|
279
|
+
const n = z.get(t);
|
280
|
+
if (n) return n;
|
281
|
+
const r = await fetch(t).then(
|
282
|
+
(o) => o.text()
|
283
|
+
);
|
284
|
+
return z.set(t, r), r;
|
285
|
+
},
|
286
|
+
// From https://github.com/sveltejs/sites/blob/master/packages/repl/src/lib/workers/bundler/index.js#L255C2-L271C5
|
287
|
+
resolveId: async (t, n) => {
|
288
|
+
if (t === "svelte")
|
289
|
+
return `${E}/src/runtime/index.js`;
|
290
|
+
if (t.startsWith("svelte/")) {
|
291
|
+
const r = t.slice(7);
|
292
|
+
return `${E}/src/runtime/${r}/index.js`;
|
293
|
+
}
|
294
|
+
if (/^https?:/.test(t)) return t;
|
295
|
+
if (t.startsWith(".") && n && n.startsWith(E)) {
|
296
|
+
const r = new URL(t, n).href;
|
297
|
+
return new URL(t, n).href, r;
|
298
|
+
}
|
299
|
+
},
|
300
|
+
transform: async (t, n) => {
|
301
|
+
const { fileName: r } = b(n);
|
302
|
+
if (r.endsWith(".svelte")) {
|
303
|
+
if (!C) {
|
304
|
+
if (!e)
|
305
|
+
throw new Error("Svelte compiler not available");
|
306
|
+
C = await e();
|
307
|
+
}
|
308
|
+
const s = C(t, {
|
309
|
+
filename: r,
|
310
|
+
generate: "client",
|
311
|
+
// Svelte 5 uses 'client' instead of 'dom'
|
312
|
+
css: "external",
|
313
|
+
// Extract CSS instead of auto-injecting
|
314
|
+
dev: !1
|
315
|
+
// Production mode
|
316
|
+
});
|
317
|
+
let c = s.js.code;
|
318
|
+
return s.css && s.css.code && (c = `
|
319
|
+
// Auto-inject CSS for Svelte component
|
320
|
+
(function() {
|
321
|
+
if (typeof document !== 'undefined') {
|
322
|
+
const style = document.createElement('style');
|
323
|
+
style.textContent = ${JSON.stringify(s.css.code)};
|
324
|
+
document.head.appendChild(style);
|
325
|
+
}
|
326
|
+
})();
|
327
|
+
` + c), c;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}), ce = async ({
|
331
|
+
files: e,
|
332
|
+
rollup: t,
|
333
|
+
enableSourcemap: n = !0,
|
334
|
+
vizCache: r,
|
335
|
+
vizId: o,
|
336
|
+
slugCache: s,
|
337
|
+
getSvelteCompiler: c
|
338
|
+
}) => {
|
339
|
+
const i = /* @__PURE__ */ new Set(), a = (u) => {
|
340
|
+
i.add(u);
|
341
|
+
};
|
342
|
+
if (!e["index.js"])
|
343
|
+
throw new Error("Missing index.js");
|
344
|
+
const l = {
|
345
|
+
input: "./index.js",
|
346
|
+
plugins: [
|
347
|
+
...o ? [se({ vizId: o, slugCache: s })] : [],
|
348
|
+
ne(),
|
349
|
+
k(),
|
350
|
+
ie({ getSvelteCompiler: c }),
|
351
|
+
...r ? [
|
352
|
+
oe({
|
353
|
+
vizCache: r,
|
354
|
+
trackCSSImport: a,
|
355
|
+
vizId: o,
|
356
|
+
files: e
|
357
|
+
})
|
358
|
+
] : []
|
359
|
+
],
|
360
|
+
onwarn(u, g) {
|
361
|
+
u.code !== "UNRESOLVED_IMPORT" && g(u);
|
362
|
+
}
|
363
|
+
}, p = {
|
364
|
+
format: "umd",
|
365
|
+
name: "Viz",
|
366
|
+
sourcemap: !!n,
|
367
|
+
compact: !0
|
368
|
+
}, m = j(e);
|
369
|
+
if (m) {
|
370
|
+
const u = A(m);
|
371
|
+
u && (l.external = Object.keys(u), p.globals = u);
|
372
|
+
}
|
373
|
+
const y = await t(l), { output: h } = await y.generate(p);
|
374
|
+
return {
|
375
|
+
src: h[0].code,
|
376
|
+
cssFiles: Array.from(i)
|
377
|
+
};
|
378
|
+
}, ae = (e) => {
|
379
|
+
if (e instanceof Error) {
|
380
|
+
const t = e.stack || "", n = e.message || "Unknown error";
|
381
|
+
return `${e.name || "Error"}: ${n}
|
382
|
+
${t}`;
|
383
|
+
} else if ("error" in e && e.error instanceof Error) {
|
384
|
+
const t = e.error, n = t.stack || "", r = t.message || "Unknown error", o = "filename" in e ? e.filename : "", s = "lineno" in e ? e.lineno : "", c = "colno" in e ? e.colno : "";
|
385
|
+
let i = "";
|
386
|
+
return o && s && (i = ` at ${o}:${s}`, c && (i += `:${c}`)), `${t.name || "Error"}: ${r}${i}
|
387
|
+
${n}`;
|
388
|
+
} else if ("reason" in e) {
|
389
|
+
const t = e.reason;
|
390
|
+
if (t instanceof Error) {
|
391
|
+
const n = t.stack || "", r = t.message || "Unknown error";
|
392
|
+
return `Unhandled Promise Rejection - ${t.name || "Error"}: ${r}
|
393
|
+
${n}`;
|
394
|
+
} else
|
395
|
+
return `Unhandled Promise Rejection: ${String(t)}`;
|
396
|
+
} else
|
397
|
+
return `Unknown runtime error: ${String(e)}`;
|
398
|
+
}, S = () => `
|
399
|
+
// Global error handling for runtime errors
|
400
|
+
(() => {
|
401
|
+
const formatRuntimeError = ${ae.toString()};
|
402
|
+
|
403
|
+
// Handle uncaught JavaScript errors
|
404
|
+
window.addEventListener('error', (event) => {
|
405
|
+
const formattedErrorMessage = formatRuntimeError(event);
|
406
|
+
parent.postMessage({
|
407
|
+
type: 'runtimeError',
|
408
|
+
formattedErrorMessage
|
409
|
+
}, "*");
|
410
|
+
});
|
411
|
+
|
412
|
+
// Handle unhandled promise rejections
|
413
|
+
window.addEventListener('unhandledrejection', (event) => {
|
414
|
+
const formattedErrorMessage = formatRuntimeError(event);
|
415
|
+
parent.postMessage({
|
416
|
+
type: 'runtimeError',
|
417
|
+
formattedErrorMessage
|
418
|
+
}, "*");
|
419
|
+
});
|
420
|
+
})();
|
421
|
+
`;
|
422
|
+
function de() {
|
423
|
+
return Math.random().toString().slice(2, 7);
|
424
|
+
}
|
425
|
+
const le = ({
|
426
|
+
cdn: e,
|
427
|
+
src: t,
|
428
|
+
styles: n
|
429
|
+
}) => {
|
430
|
+
const o = `viz-container-${de()}`;
|
431
|
+
return `<!DOCTYPE html>
|
432
|
+
<html>
|
433
|
+
<head>
|
434
|
+
<meta charset="utf-8">${e}${n}
|
435
|
+
<style>
|
436
|
+
body {
|
437
|
+
margin: 0;
|
438
|
+
overflow: hidden;
|
439
|
+
}
|
440
|
+
#${o} {
|
441
|
+
height: 100vh;
|
442
|
+
}
|
443
|
+
</style>
|
444
|
+
</head>
|
445
|
+
<body>
|
446
|
+
<div id="${o}"></div>
|
447
|
+
<script>${S()}<\/script>
|
448
|
+
<script id="injected-script">${t}<\/script>
|
449
|
+
<script>
|
450
|
+
(() => {
|
451
|
+
let cleanup;
|
452
|
+
const render = () => {
|
453
|
+
const container = document.getElementById('${o}');
|
454
|
+
typeof cleanup === 'function' && cleanup();
|
455
|
+
cleanup = Viz.main(container, { state: window.state, setState, writeFile });
|
456
|
+
};
|
457
|
+
const setState = (next) => {
|
458
|
+
window.state = next(window.state);
|
459
|
+
render();
|
460
|
+
};
|
461
|
+
const writeFile = (fileName, content) => {
|
462
|
+
parent.postMessage({ type: 'writeFile', fileName, content }, "*");
|
463
|
+
};
|
464
|
+
const run = () => {
|
465
|
+
try {
|
466
|
+
setState((state) => state || {});
|
467
|
+
} catch (error) {
|
468
|
+
console.error(error);
|
469
|
+
parent.postMessage({ type: 'runError', error }, "*");
|
470
|
+
}
|
471
|
+
}
|
472
|
+
run();
|
473
|
+
const runJS = (src) => {
|
474
|
+
document.getElementById('injected-script')?.remove();
|
475
|
+
const script = document.createElement('script');
|
476
|
+
script.textContent = src;
|
477
|
+
script.id = 'injected-script';
|
478
|
+
document.body.appendChild(script);
|
479
|
+
run();
|
480
|
+
};
|
481
|
+
const runCSS = (css) => {
|
482
|
+
let style = document.getElementById('injected-style');
|
483
|
+
if (!style) {
|
484
|
+
style = document.createElement('style');
|
485
|
+
style.type = 'text/css';
|
486
|
+
style.id = 'injected-style';
|
487
|
+
document.head.appendChild(style);
|
488
|
+
}
|
489
|
+
style.textContent = css;
|
490
|
+
};
|
491
|
+
onmessage = (message) => {
|
492
|
+
switch (message.data.type) {
|
493
|
+
case 'runJS':
|
494
|
+
runJS(message.data.js);
|
495
|
+
parent.postMessage({ type: 'runDone' }, "*");
|
496
|
+
break;
|
497
|
+
case 'runCSS':
|
498
|
+
runCSS(message.data.css);
|
499
|
+
break;
|
500
|
+
case 'ping':
|
501
|
+
parent.postMessage({ type: 'pong' }, "*");
|
502
|
+
break;
|
503
|
+
default:
|
504
|
+
break;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
})();
|
508
|
+
<\/script>
|
509
|
+
</body>
|
510
|
+
</html>`;
|
511
|
+
}, ue = async ({
|
512
|
+
files: e,
|
513
|
+
rollup: t,
|
514
|
+
enableSourcemap: n = !0,
|
515
|
+
vizCache: r,
|
516
|
+
vizId: o,
|
517
|
+
slugCache: s,
|
518
|
+
getSvelteCompiler: c
|
519
|
+
}) => {
|
520
|
+
const { src: i, cssFiles: a } = await ce({
|
521
|
+
files: e,
|
522
|
+
rollup: t,
|
523
|
+
enableSourcemap: n,
|
524
|
+
vizCache: r,
|
525
|
+
vizId: o,
|
526
|
+
slugCache: s,
|
527
|
+
getSvelteCompiler: c
|
528
|
+
});
|
529
|
+
let d = [];
|
530
|
+
if (a.length > 0)
|
531
|
+
for (let h = 0; h < a.length; h++) {
|
532
|
+
const u = a[h], g = b(u), x = g.vizId, $ = g.fileName;
|
533
|
+
let v = null;
|
534
|
+
if (x === o && e)
|
535
|
+
v = e[$] || null;
|
536
|
+
else {
|
537
|
+
const _ = await r.get(x);
|
538
|
+
v = D(_, $);
|
539
|
+
}
|
540
|
+
v && d.push(v);
|
541
|
+
}
|
542
|
+
const l = d.join(`
|
543
|
+
`), p = `
|
544
|
+
<style id="injected-style">${l}</style>`;
|
545
|
+
let m = "";
|
546
|
+
const y = Object.entries(
|
547
|
+
M(e)
|
548
|
+
);
|
549
|
+
if (y.length > 0) {
|
550
|
+
const h = F(e);
|
551
|
+
m = y.map(([u, g], x) => {
|
552
|
+
const $ = L(
|
553
|
+
{ name: u, version: g },
|
554
|
+
h
|
555
|
+
);
|
556
|
+
return `${x > 0 ? " " : `
|
557
|
+
`}<script src="${$}"><\/script>`;
|
558
|
+
}).join("");
|
559
|
+
}
|
560
|
+
return {
|
561
|
+
html: le({ cdn: m, src: i, styles: p }),
|
562
|
+
css: l,
|
563
|
+
js: i,
|
564
|
+
runtimeVersion: "v3"
|
565
|
+
};
|
566
|
+
}, pe = ({
|
567
|
+
initialContents: e,
|
568
|
+
handleCacheMiss: t
|
569
|
+
}) => {
|
570
|
+
const n = new Map(
|
571
|
+
e.map((c) => [c.id, c])
|
572
|
+
);
|
573
|
+
return { get: async (c) => {
|
574
|
+
const i = n.get(c);
|
575
|
+
if (i !== void 0)
|
576
|
+
return i;
|
577
|
+
if (!t)
|
578
|
+
throw new Error(
|
579
|
+
`Unresolved import from vizId ${c}, cache miss handler not provided.`
|
580
|
+
);
|
581
|
+
const a = await t(c);
|
582
|
+
if (a)
|
583
|
+
return n.set(c, a), a;
|
584
|
+
throw new Error(
|
585
|
+
`Unresolved import from vizId ${c}`
|
586
|
+
);
|
587
|
+
}, set: (c) => {
|
588
|
+
n.set(c.id, c);
|
589
|
+
}, invalidate: (c) => {
|
590
|
+
n.delete(c);
|
591
|
+
} };
|
592
|
+
}, Ve = ({
|
593
|
+
initialMappings: e = {},
|
594
|
+
handleCacheMiss: t
|
595
|
+
}) => ({ get: async (s) => {
|
596
|
+
const c = e[s];
|
597
|
+
if (c !== void 0)
|
598
|
+
return c;
|
599
|
+
if (!t)
|
600
|
+
throw new Error(
|
601
|
+
`Unresolved slug ${s}, cache miss handler not provided.`
|
602
|
+
);
|
603
|
+
const i = await t(s);
|
604
|
+
if (i)
|
605
|
+
return e[s] = i, i;
|
606
|
+
throw new Error(`Unresolved slug ${s}`);
|
607
|
+
}, set: (s, c) => {
|
608
|
+
e[s] = c;
|
609
|
+
}, invalidate: (s) => {
|
610
|
+
delete e[s];
|
611
|
+
} }), me = (e, t = "Sample Content for Exporting", n = H()) => ({
|
612
|
+
id: n,
|
613
|
+
files: G(e),
|
614
|
+
title: t
|
615
|
+
}), fe = (e) => {
|
616
|
+
if (Object.keys(e).length === 0)
|
617
|
+
return null;
|
618
|
+
const t = "index.html" in e, n = "index.js" in e, r = "index.jsx" in e;
|
619
|
+
return t ? e["index.html"].includes('type="module"') ? "v4" : n || r ? "v2" : "v1" : !t && n ? "v3" : null;
|
620
|
+
}, R = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), he = (e) => {
|
621
|
+
const t = e.trim();
|
622
|
+
return R(t, "html") && R(t, "head") && R(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
|
623
|
+
}, ge = (e, t) => e.replace(
|
624
|
+
new RegExp(
|
625
|
+
`<script[^>]*src=["'][^"']*${t.source}[^"']*["'][^>]*>\\s*<\/script>`,
|
626
|
+
"gi"
|
627
|
+
),
|
628
|
+
""
|
629
|
+
), O = (e, t, n) => e.replace(
|
630
|
+
new RegExp(t, "i"),
|
631
|
+
`${n}${t}`
|
632
|
+
), ve = (e, t) => {
|
633
|
+
let n = he(e);
|
634
|
+
const r = Object.entries(M(t));
|
635
|
+
if (r.length) {
|
636
|
+
const c = F(t);
|
637
|
+
r.forEach(([a]) => {
|
638
|
+
n = ge(n, new RegExp(`${a}@`));
|
639
|
+
});
|
640
|
+
const i = r.map(
|
641
|
+
([a, d]) => L({ name: a, version: d }, c)
|
642
|
+
).map((a) => `<script src="${a}"><\/script>`).join(`
|
643
|
+
`);
|
644
|
+
n = O(
|
645
|
+
n,
|
646
|
+
"</head>",
|
647
|
+
i + `
|
648
|
+
`
|
649
|
+
);
|
650
|
+
}
|
651
|
+
if (t["bundle.js"] !== void 0 || t["index.js"] !== void 0) {
|
652
|
+
const c = '<script src="bundle.js"><\/script>', i = /<script\b[^>]*\bsrc=["']bundle\.js["'][^>]*>\s*<\/script>/gi, a = [...n.matchAll(i)];
|
653
|
+
a.length === 1 && (() => {
|
654
|
+
const l = a[0].index ?? -1;
|
655
|
+
if (l === -1) return !1;
|
656
|
+
const p = n.search(/<body\b[^>]*>/i), m = n.search(/<\/body>/i);
|
657
|
+
return p !== -1 && m !== -1 && l > p && l < m;
|
658
|
+
})() || (n = n.replace(i, ""), n = O(n, "</body>", c));
|
659
|
+
}
|
660
|
+
const s = `<script>${S()}<\/script>
|
661
|
+
`;
|
662
|
+
return n = O(n, "</head>", s), /^\s*<!DOCTYPE/i.test(n) ? n : `<!DOCTYPE html>${n}`;
|
663
|
+
}, we = (e) => {
|
664
|
+
const t = e["index.html"];
|
665
|
+
return !t && !e["index.js"] && !e["bundle.js"] ? "" : ve(t || "<!DOCTYPE html><html><head></head><body></body></html>", e);
|
666
|
+
};
|
667
|
+
function Ee(e) {
|
668
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
669
|
+
}
|
670
|
+
var N, U;
|
671
|
+
function be() {
|
672
|
+
return U || (U = 1, N = {
|
673
|
+
d3: "d3",
|
674
|
+
"d3-array": "d3",
|
675
|
+
"d3-axis": "d3",
|
676
|
+
"d3-brush": "d3",
|
677
|
+
"d3-chord": "d3",
|
678
|
+
"d3-collection": "d3",
|
679
|
+
"d3-color": "d3",
|
680
|
+
"d3-contour": "d3",
|
681
|
+
"d3-dispatch": "d3",
|
682
|
+
"d3-drag": "d3",
|
683
|
+
"d3-dsv": "d3",
|
684
|
+
"d3-ease": "d3",
|
685
|
+
"d3-fetch": "d3",
|
686
|
+
"d3-force": "d3",
|
687
|
+
"d3-format": "d3",
|
688
|
+
"d3-geo": "d3",
|
689
|
+
"d3-hierarchy": "d3",
|
690
|
+
"d3-interpolate": "d3",
|
691
|
+
"d3-path": "d3",
|
692
|
+
"d3-polygon": "d3",
|
693
|
+
"d3-quadtree": "d3",
|
694
|
+
"d3-random": "d3",
|
695
|
+
"d3-scale": "d3",
|
696
|
+
"d3-scale-chromatic": "d3",
|
697
|
+
"d3-selection": "d3",
|
698
|
+
"d3-shape": "d3",
|
699
|
+
"d3-tile": "d3",
|
700
|
+
"d3-time": "d3",
|
701
|
+
"d3-time-format": "d3",
|
702
|
+
"d3-timer": "d3",
|
703
|
+
"d3-transition": "d3",
|
704
|
+
"d3-voronoi": "d3",
|
705
|
+
"d3-zoom": "d3",
|
706
|
+
react: "React",
|
707
|
+
"react-dom": "ReactDOM",
|
708
|
+
"react-dropdown-browser": "ReactDropdown",
|
709
|
+
"react-dropdown": "ReactDropdown",
|
710
|
+
three: "THREE",
|
711
|
+
vega: "vega",
|
712
|
+
"vega-embed": "vegaEmbed",
|
713
|
+
"vega-lite": "vegaLite",
|
714
|
+
"vega-lite-api": "vl",
|
715
|
+
"vega-tooltip": "vegaTooltip",
|
716
|
+
"vega-themes": "vegaThemes",
|
717
|
+
"vizhub-vega-lite-config": "vizhubVegaLiteConfig",
|
718
|
+
semiotic: "Semiotic",
|
719
|
+
"viz.js": "Viz"
|
720
|
+
}), N;
|
721
|
+
}
|
722
|
+
var ye = be();
|
723
|
+
const xe = /* @__PURE__ */ Ee(ye), f = "\0virtual:", V = (e) => {
|
724
|
+
let t = e.replace(/^\.\//, "");
|
725
|
+
return t = t.replace(/\/+/g, "/"), t = t.replace(/\/$/, ""), t;
|
726
|
+
}, $e = (e, t) => {
|
727
|
+
const n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = t.split("/"), o = n ? n.split("/") : [];
|
728
|
+
for (const s of r)
|
729
|
+
s === ".." ? o.pop() : s !== "." && s !== "" && o.push(s);
|
730
|
+
return o.join("/");
|
731
|
+
}, B = (e) => ({
|
732
|
+
name: "virtual-file-system",
|
733
|
+
resolveId(t, n) {
|
734
|
+
const r = n?.startsWith(
|
735
|
+
f
|
736
|
+
) ? n.slice(f.length) : n;
|
737
|
+
if (t.startsWith("./") || t.startsWith("../")) {
|
738
|
+
const s = V(r ? $e(r, t) : t);
|
739
|
+
if (e[s])
|
740
|
+
return f + s;
|
741
|
+
const c = [".js", ".jsx", ".ts", ".tsx"];
|
742
|
+
for (const i of c) {
|
743
|
+
const a = s + i;
|
744
|
+
if (e[a])
|
745
|
+
return f + a;
|
746
|
+
}
|
747
|
+
}
|
748
|
+
if (e[t])
|
749
|
+
return f + t;
|
750
|
+
const o = [".js", ".jsx", ".ts", ".tsx"];
|
751
|
+
for (const s of o) {
|
752
|
+
const c = t + s;
|
753
|
+
if (e[c])
|
754
|
+
return f + c;
|
755
|
+
}
|
756
|
+
return null;
|
757
|
+
},
|
758
|
+
load(t) {
|
759
|
+
if (t.startsWith(f)) {
|
760
|
+
const n = t.slice(f.length);
|
761
|
+
if (e[n])
|
762
|
+
return e[n];
|
763
|
+
}
|
764
|
+
return null;
|
765
|
+
}
|
766
|
+
}), je = async ({
|
767
|
+
files: e,
|
768
|
+
rollup: t,
|
769
|
+
enableSourcemap: n = !0
|
770
|
+
}) => {
|
771
|
+
let r = "index.js";
|
772
|
+
if (!e[r] && (r = "index.jsx", !e[r]))
|
773
|
+
throw new Error(
|
774
|
+
"Missing entry point, can't find index.js or index.jsx"
|
775
|
+
);
|
776
|
+
const s = {
|
777
|
+
input: "./" + r,
|
778
|
+
plugins: [B(e), k()],
|
779
|
+
onwarn(l, p) {
|
780
|
+
l.code !== "UNRESOLVED_IMPORT" && p(l);
|
781
|
+
}
|
782
|
+
}, c = {
|
783
|
+
format: "iife",
|
784
|
+
sourcemap: n
|
785
|
+
}, i = j(e);
|
786
|
+
if (i) {
|
787
|
+
const l = {
|
788
|
+
// Pre-configured globals for v2 only
|
789
|
+
...xe,
|
790
|
+
// Libraries from package.json
|
791
|
+
...A(i)
|
792
|
+
};
|
793
|
+
l && (s.external = Object.keys(l), c.globals = l);
|
794
|
+
}
|
795
|
+
const a = await t(s), { output: d } = await a.generate(c);
|
796
|
+
return d[0].code;
|
797
|
+
}, Se = async ({
|
798
|
+
files: e,
|
799
|
+
rollup: t,
|
800
|
+
enableSourcemap: n
|
801
|
+
}) => ({
|
802
|
+
...e,
|
803
|
+
"bundle.js": await je({
|
804
|
+
files: e,
|
805
|
+
rollup: t,
|
806
|
+
enableSourcemap: n
|
807
|
+
}),
|
808
|
+
"index.html": we(e)
|
809
|
+
}), Ie = (e) => {
|
810
|
+
const t = [], n = [], r = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
|
811
|
+
let o, s = 0;
|
812
|
+
for (; (o = r.exec(e)) !== null; ) {
|
813
|
+
const c = o[1], i = o[2];
|
814
|
+
if (!/\btype\s*=\s*["']module["']/i.test(c))
|
815
|
+
continue;
|
816
|
+
const a = c.match(
|
817
|
+
/\bsrc\s*=\s*["']([^"']+)["']/i
|
818
|
+
);
|
819
|
+
if (a)
|
820
|
+
t.push(a[1]);
|
821
|
+
else if (i.trim()) {
|
822
|
+
const d = `__inline_script_${s++}.js`;
|
823
|
+
n.push({
|
824
|
+
id: d,
|
825
|
+
content: i.trim()
|
826
|
+
}), t.push(d);
|
827
|
+
}
|
828
|
+
}
|
829
|
+
return { entryPoints: t, inlineScripts: n };
|
830
|
+
}, Ce = () => ({
|
831
|
+
name: "catch-all-prevent-fs",
|
832
|
+
resolveId(e, t) {
|
833
|
+
return { id: e, external: !0 };
|
834
|
+
}
|
835
|
+
}), Re = async ({
|
836
|
+
entryPoint: e,
|
837
|
+
files: t,
|
838
|
+
rollup: n,
|
839
|
+
enableSourcemap: r = !0
|
840
|
+
}) => {
|
841
|
+
const s = {
|
842
|
+
input: e.startsWith("./") ? e : `./${e}`,
|
843
|
+
plugins: [
|
844
|
+
B(t),
|
845
|
+
k({
|
846
|
+
// Enable JSX runtime
|
847
|
+
// so we don't need to import React
|
848
|
+
// in every file that uses JSX
|
849
|
+
jsxRuntime: "automatic"
|
850
|
+
}),
|
851
|
+
Ce()
|
852
|
+
],
|
853
|
+
// external: (source: string) => {
|
854
|
+
// DEBUG && console.log("external", source);
|
855
|
+
// // Handle strings resolved by `virtualFileSystem`.
|
856
|
+
// const isVirtualFile = source.startsWith("./");
|
857
|
+
// // Handle external dependencies, e.g. from import maps.
|
858
|
+
// const isLibrary = !source.startsWith("./");
|
859
|
+
// const isExternal = !isVirtualFile || isLibrary;
|
860
|
+
// DEBUG && console.log("isExternal", isExternal);
|
861
|
+
// return isExternal;
|
862
|
+
// },
|
863
|
+
onwarn(a, d) {
|
864
|
+
}
|
865
|
+
}, c = await n(s), { output: i } = await c.generate({
|
866
|
+
format: "es",
|
867
|
+
sourcemap: r
|
868
|
+
});
|
869
|
+
return i[0].code;
|
870
|
+
}, T = (e, t) => new RegExp(`<${t}\\b`, "i").test(e) && new RegExp(`</${t}>`, "i").test(e), Oe = (e) => {
|
871
|
+
const t = e.trim();
|
872
|
+
return T(t, "html") && T(t, "head") && T(t, "body") ? t : `<html><head></head><body>${t}</body></html>`;
|
873
|
+
}, W = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), J = (e, t, n) => e.replace(
|
874
|
+
new RegExp(t, "i"),
|
875
|
+
`${n}${t}`
|
876
|
+
), Ne = (e) => {
|
877
|
+
const t = M(e);
|
878
|
+
if (Object.keys(t).length === 0) return null;
|
879
|
+
const n = F(e), r = {};
|
880
|
+
for (const [o, s] of Object.entries(t))
|
881
|
+
r[o] = L(
|
882
|
+
{ name: o, version: s },
|
883
|
+
n
|
884
|
+
);
|
885
|
+
return JSON.stringify({ imports: r }, null, 2);
|
886
|
+
}, Te = (e, t, n = []) => {
|
887
|
+
if (!e["index.html"]) return "";
|
888
|
+
let r = Oe(e["index.html"]);
|
889
|
+
t.forEach((c, i) => {
|
890
|
+
if (n.some((d) => d.id === i)) {
|
891
|
+
const d = n.find((m) => m.id === i)?.content || "", l = W(d), p = new RegExp(
|
892
|
+
`<script\\b[^>]*\\btype=["']module["'][^>]*>\\s*${l}\\s*<\/script>`,
|
893
|
+
"gi"
|
894
|
+
);
|
895
|
+
r = r.replace(
|
896
|
+
p,
|
897
|
+
`<script type="module">
|
898
|
+
${c}
|
899
|
+
<\/script>`
|
900
|
+
);
|
901
|
+
} else {
|
902
|
+
const d = new RegExp(
|
903
|
+
`<script\\b[^>]*\\bsrc=["']${W(i)}["'][^>]*>[^<]*<\/script>`,
|
904
|
+
"gi"
|
905
|
+
);
|
906
|
+
r = r.replace(
|
907
|
+
d,
|
908
|
+
`<script type="module">
|
909
|
+
${c}
|
910
|
+
<\/script>`
|
911
|
+
);
|
912
|
+
}
|
913
|
+
});
|
914
|
+
const o = Ne(e);
|
915
|
+
if (o && !/<script\b[^>]*type=["']importmap["'][^>]*>/i.test(
|
916
|
+
r
|
917
|
+
)) {
|
918
|
+
const i = `<script type="importmap">
|
919
|
+
${o}
|
920
|
+
<\/script>
|
921
|
+
`;
|
922
|
+
r = J(
|
923
|
+
r,
|
924
|
+
"</head>",
|
925
|
+
i
|
926
|
+
);
|
927
|
+
}
|
928
|
+
const s = `<script>${S()}<\/script>
|
929
|
+
`;
|
930
|
+
return r = J(r, "</head>", s), /^\s*<!DOCTYPE/i.test(r) ? r : `<!DOCTYPE html>${r}`;
|
931
|
+
}, ke = async ({
|
932
|
+
files: e,
|
933
|
+
rollup: t,
|
934
|
+
enableSourcemap: n = !0
|
935
|
+
}) => {
|
936
|
+
const r = e["index.html"] || "", { entryPoints: o, inlineScripts: s } = Ie(r);
|
937
|
+
if (o.length === 0)
|
938
|
+
return e;
|
939
|
+
const c = { ...e };
|
940
|
+
for (const d of s)
|
941
|
+
c[d.id] = d.content;
|
942
|
+
const i = /* @__PURE__ */ new Map();
|
943
|
+
for (const d of o) {
|
944
|
+
const l = await Re({
|
945
|
+
entryPoint: d,
|
946
|
+
files: c,
|
947
|
+
rollup: t,
|
948
|
+
enableSourcemap: n
|
949
|
+
});
|
950
|
+
i.set(d, l);
|
951
|
+
}
|
952
|
+
const a = Te(c, i, s);
|
953
|
+
return {
|
954
|
+
...e,
|
955
|
+
"index.html": a
|
956
|
+
};
|
957
|
+
}, w = !1, Me = (e) => {
|
958
|
+
const t = `<script>${S()}<\/script>`;
|
959
|
+
return e.includes("</head>") ? e.replace("</head>", `${t}
|
960
|
+
</head>`) : e.includes("</body>") ? e.replace("</body>", `${t}
|
961
|
+
</body>`) : e + t;
|
962
|
+
}, We = async ({
|
963
|
+
files: e,
|
964
|
+
rollup: t,
|
965
|
+
enableSourcemap: n = !0,
|
966
|
+
vizCache: r,
|
967
|
+
vizId: o,
|
968
|
+
slugCache: s,
|
969
|
+
getSvelteCompiler: c
|
970
|
+
}) => {
|
971
|
+
try {
|
972
|
+
if (w && console.log(
|
973
|
+
"[build] files:",
|
974
|
+
e ? JSON.stringify(e).substring(0, 100) : void 0
|
975
|
+
), w && console.log("[build] vizCache:", r), w && console.log("[build] vizId:", o), !e && !r)
|
976
|
+
throw new Error(
|
977
|
+
"Either files or vizCache is required"
|
978
|
+
);
|
979
|
+
if (!e && r && !o)
|
980
|
+
throw new Error(
|
981
|
+
"vizId is required when using vizCache"
|
982
|
+
);
|
983
|
+
if (!e && r && o && (e = Y(
|
984
|
+
(await r.get(o))?.files
|
985
|
+
)), !e)
|
986
|
+
throw new Error("Upable to extract viz files");
|
987
|
+
const i = fe(e);
|
988
|
+
if (w && console.log("[build] version:", i), i === "v1")
|
989
|
+
return {
|
990
|
+
html: Me(I(e)),
|
991
|
+
runtimeVersion: i
|
992
|
+
};
|
993
|
+
if (i === "v2") {
|
994
|
+
if (!t)
|
995
|
+
throw new Error(
|
996
|
+
"Rollup is required for v2 runtime"
|
997
|
+
);
|
998
|
+
return {
|
999
|
+
html: I(
|
1000
|
+
await Se({ files: e, rollup: t, enableSourcemap: n })
|
1001
|
+
),
|
1002
|
+
runtimeVersion: i
|
1003
|
+
};
|
1004
|
+
}
|
1005
|
+
if (i === "v3") {
|
1006
|
+
if (!t)
|
1007
|
+
throw new Error(
|
1008
|
+
"Rollup is required for v3 runtime"
|
1009
|
+
);
|
1010
|
+
if (!r && !o) {
|
1011
|
+
const a = me(e);
|
1012
|
+
o = a.id, r = pe({
|
1013
|
+
initialContents: [a],
|
1014
|
+
handleCacheMiss: async () => {
|
1015
|
+
throw new Error(
|
1016
|
+
"Cache miss handler not implemented"
|
1017
|
+
);
|
1018
|
+
}
|
1019
|
+
});
|
1020
|
+
}
|
1021
|
+
if (!r)
|
1022
|
+
throw new Error(
|
1023
|
+
"vizCache is required for v3 runtime"
|
1024
|
+
);
|
1025
|
+
if (!o)
|
1026
|
+
throw new Error(
|
1027
|
+
"vizId is required for v3 runtime if vizCache is provided"
|
1028
|
+
);
|
1029
|
+
return await ue({
|
1030
|
+
files: e,
|
1031
|
+
rollup: t,
|
1032
|
+
vizCache: r,
|
1033
|
+
vizId: o,
|
1034
|
+
slugCache: s,
|
1035
|
+
getSvelteCompiler: c
|
1036
|
+
});
|
1037
|
+
}
|
1038
|
+
if (i === "v4") {
|
1039
|
+
if (!t)
|
1040
|
+
throw new Error(
|
1041
|
+
"Rollup is required for v4 runtime"
|
1042
|
+
);
|
1043
|
+
return w && console.log("[build] v4Build", {
|
1044
|
+
files: e,
|
1045
|
+
rollup: t,
|
1046
|
+
enableSourcemap: n
|
1047
|
+
}), {
|
1048
|
+
html: I(
|
1049
|
+
await ke({ files: e, rollup: t, enableSourcemap: n })
|
1050
|
+
),
|
1051
|
+
runtimeVersion: i
|
1052
|
+
};
|
1053
|
+
}
|
1054
|
+
throw new Error(
|
1055
|
+
`Unsupported runtime version: ${i}`
|
1056
|
+
);
|
1057
|
+
} catch (i) {
|
1058
|
+
throw i instanceof Error && i.message.indexOf(f) && (i.message = i.message.replace(
|
1059
|
+
f,
|
1060
|
+
""
|
1061
|
+
)), i;
|
1062
|
+
}
|
1063
|
+
};
|
1064
|
+
export {
|
1065
|
+
pe as a,
|
1066
|
+
We as b,
|
1067
|
+
ce as c,
|
1068
|
+
fe as d,
|
1069
|
+
Ve as e,
|
1070
|
+
me as f,
|
1071
|
+
ze as g,
|
1072
|
+
Ue as s,
|
1073
|
+
ue as v
|
1074
|
+
};
|
1075
|
+
//# sourceMappingURL=build-DnPT2Qew.js.map
|