@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
package/dist/index.js
CHANGED
@@ -1,74 +1,75 @@
|
|
1
|
-
import { g as
|
2
|
-
import { b as G, c as _, e as A, a as F, f as J, d as T, s as Y, v as Q } from "./build-
|
3
|
-
const
|
4
|
-
const i =
|
5
|
-
return new Promise((
|
6
|
-
const
|
7
|
-
|
1
|
+
import { g as q } from "./build-DnPT2Qew.js";
|
2
|
+
import { b as G, c as _, e as A, a as F, f as J, d as T, s as Y, v as Q } from "./build-DnPT2Qew.js";
|
3
|
+
const M = (s) => async (t) => {
|
4
|
+
const i = q();
|
5
|
+
return new Promise((p) => {
|
6
|
+
const u = (r) => {
|
7
|
+
r.data.type === "invalidateVizCacheResponse" && r.data.requestId === i && (s.removeEventListener(
|
8
8
|
"message",
|
9
|
-
|
10
|
-
),
|
9
|
+
u
|
10
|
+
), p());
|
11
11
|
};
|
12
|
-
|
12
|
+
s.addEventListener(
|
13
13
|
"message",
|
14
|
-
|
15
|
-
),
|
14
|
+
u
|
15
|
+
), s.postMessage({
|
16
16
|
type: "invalidateVizCacheRequest",
|
17
17
|
changedVizIds: t,
|
18
18
|
requestId: i
|
19
19
|
});
|
20
20
|
});
|
21
21
|
}, b = ({
|
22
|
-
worker:
|
22
|
+
worker: s,
|
23
23
|
setBuildErrorMessage: t
|
24
24
|
}) => ({
|
25
25
|
files: i,
|
26
|
-
enableSourcemap:
|
27
|
-
vizId:
|
26
|
+
enableSourcemap: p,
|
27
|
+
vizId: u
|
28
28
|
}) => {
|
29
|
-
const
|
29
|
+
const r = q();
|
30
30
|
return new Promise(
|
31
|
-
(
|
32
|
-
const
|
33
|
-
const
|
34
|
-
if (
|
35
|
-
|
31
|
+
(f) => {
|
32
|
+
const n = (v) => {
|
33
|
+
const d = v.data;
|
34
|
+
if (d.type === "buildResponse" && d.requestId === r) {
|
35
|
+
s.removeEventListener(
|
36
36
|
"message",
|
37
|
-
|
37
|
+
n
|
38
38
|
);
|
39
|
-
const
|
40
|
-
|
39
|
+
const m = d.buildResult, g = d.error;
|
40
|
+
t?.(g || null), f(m);
|
41
41
|
}
|
42
42
|
};
|
43
|
-
|
44
|
-
const
|
43
|
+
s.addEventListener("message", n);
|
44
|
+
const c = {
|
45
45
|
type: "buildRequest",
|
46
46
|
files: i,
|
47
|
-
enableSourcemap:
|
48
|
-
requestId:
|
49
|
-
vizId:
|
47
|
+
enableSourcemap: p,
|
48
|
+
requestId: r,
|
49
|
+
vizId: u
|
50
50
|
};
|
51
|
-
|
51
|
+
s.postMessage(c);
|
52
52
|
}
|
53
53
|
);
|
54
|
-
},
|
55
|
-
iframe:
|
54
|
+
}, w = "IDLE", y = "ENQUEUED", D = "PENDING_CLEAN", I = "PENDING_DIRTY", P = ({
|
55
|
+
iframe: s,
|
56
56
|
worker: t,
|
57
57
|
setBuildErrorMessage: i,
|
58
|
-
getLatestContent:
|
59
|
-
resolveSlugKey:
|
60
|
-
writeFile:
|
58
|
+
getLatestContent: p,
|
59
|
+
resolveSlugKey: u,
|
60
|
+
writeFile: r,
|
61
|
+
handleRuntimeError: f
|
61
62
|
}) => {
|
62
|
-
let
|
63
|
-
const
|
63
|
+
let n = w, c = null;
|
64
|
+
const v = b({
|
64
65
|
worker: t,
|
65
66
|
setBuildErrorMessage: i
|
66
|
-
}),
|
67
|
+
}), d = ({
|
67
68
|
data: o
|
68
69
|
}) => {
|
69
|
-
if (o.type === "contentRequest" &&
|
70
|
+
if (o.type === "contentRequest" && p) {
|
70
71
|
const { vizId: e } = o;
|
71
|
-
|
72
|
+
p(e).then((a) => {
|
72
73
|
t.postMessage({
|
73
74
|
type: "contentResponse",
|
74
75
|
vizId: e,
|
@@ -77,126 +78,126 @@ const V = (n) => async (t) => {
|
|
77
78
|
});
|
78
79
|
} else if (o.type === "resolveSlugRequest") {
|
79
80
|
const { slugKey: e, requestId: a } = o;
|
80
|
-
if (
|
81
|
-
|
82
|
-
(
|
83
|
-
const
|
81
|
+
if (u)
|
82
|
+
u(e).then(
|
83
|
+
(l) => {
|
84
|
+
const E = {
|
84
85
|
type: "resolveSlugResponse",
|
85
|
-
vizId:
|
86
|
+
vizId: l,
|
86
87
|
requestId: a
|
87
88
|
};
|
88
|
-
t.postMessage(
|
89
|
+
t.postMessage(E);
|
89
90
|
}
|
90
91
|
);
|
91
92
|
else {
|
92
|
-
const
|
93
|
+
const l = {
|
93
94
|
type: "resolveSlugResponse",
|
94
95
|
vizId: null,
|
95
96
|
requestId: a
|
96
97
|
};
|
97
|
-
t.postMessage(
|
98
|
+
t.postMessage(l);
|
98
99
|
}
|
99
100
|
}
|
100
101
|
};
|
101
|
-
t.addEventListener("message",
|
102
|
-
const
|
102
|
+
t.addEventListener("message", d);
|
103
|
+
const m = (o) => {
|
103
104
|
const e = o.data;
|
104
|
-
(e.type === "runDone" || e.type === "runError") && e.type === "runError" && i && i(e.error.message), e.type === "writeFile" &&
|
105
|
+
(e.type === "runDone" || e.type === "runError") && e.type === "runError" && i && i(e.error.message), e.type === "runtimeError" && f && f(e.formattedErrorMessage), e.type === "writeFile" && r && e.fileName && e.content && r(e.fileName, e.content);
|
105
106
|
};
|
106
|
-
window.addEventListener("message",
|
107
|
-
const
|
108
|
-
t.removeEventListener("message",
|
109
|
-
},
|
107
|
+
window.addEventListener("message", m);
|
108
|
+
const g = () => {
|
109
|
+
t.removeEventListener("message", d), window.removeEventListener("message", m);
|
110
|
+
}, R = async ({
|
110
111
|
files: o,
|
111
112
|
enableHotReloading: e = !1,
|
112
113
|
enableSourcemap: a = !1,
|
113
|
-
vizId:
|
114
|
+
vizId: l
|
114
115
|
}) => {
|
115
|
-
|
116
|
-
const
|
116
|
+
n = D;
|
117
|
+
const E = await v({
|
117
118
|
files: o,
|
118
119
|
enableSourcemap: a,
|
119
|
-
vizId:
|
120
|
+
vizId: l
|
120
121
|
});
|
121
|
-
if (
|
122
|
-
const { html:
|
123
|
-
if (console.clear(), e &&
|
124
|
-
if (
|
125
|
-
const
|
122
|
+
if (E) {
|
123
|
+
const { html: S, runtimeVersion: V, js: N, css: L } = E;
|
124
|
+
if (console.clear(), e && V === "v3") {
|
125
|
+
if (L) {
|
126
|
+
const h = {
|
126
127
|
type: "runCSS",
|
127
|
-
css:
|
128
|
+
css: L
|
128
129
|
};
|
129
|
-
if (!
|
130
|
+
if (!s.contentWindow)
|
130
131
|
throw new Error(
|
131
132
|
"iframe.contentWindow is null - this should never happen"
|
132
133
|
);
|
133
|
-
|
134
|
-
|
134
|
+
s.contentWindow.postMessage(
|
135
|
+
h,
|
135
136
|
window.location.origin
|
136
137
|
);
|
137
138
|
}
|
138
139
|
if (N) {
|
139
|
-
const
|
140
|
+
const h = {
|
140
141
|
type: "runJS",
|
141
142
|
js: N
|
142
143
|
};
|
143
|
-
if (!
|
144
|
+
if (!s.contentWindow)
|
144
145
|
throw new Error(
|
145
146
|
"iframe.contentWindow is null - this should never happen"
|
146
147
|
);
|
147
|
-
|
148
|
-
|
148
|
+
s.contentWindow.postMessage(
|
149
|
+
h,
|
149
150
|
window.location.origin
|
150
151
|
);
|
151
152
|
}
|
152
153
|
} else
|
153
|
-
|
154
|
+
s.srcdoc = S || "";
|
154
155
|
}
|
155
|
-
|
156
|
+
n === I ? (requestAnimationFrame(() => {
|
156
157
|
if (!c)
|
157
158
|
throw new Error(
|
158
159
|
"latestFiles is not defined and state is PENDING_DIRTY - this should never happen"
|
159
160
|
);
|
160
|
-
|
161
|
+
R({
|
161
162
|
files: c,
|
162
163
|
enableHotReloading: e,
|
163
164
|
enableSourcemap: a,
|
164
|
-
vizId:
|
165
|
+
vizId: l
|
165
166
|
});
|
166
|
-
}),
|
167
|
-
},
|
167
|
+
}), n = y) : n = w;
|
168
|
+
}, C = ({
|
168
169
|
files: o,
|
169
170
|
enableHotReloading: e = !1,
|
170
171
|
enableSourcemap: a = !1,
|
171
|
-
vizId:
|
172
|
+
vizId: l = void 0
|
172
173
|
}) => {
|
173
|
-
if (c = null,
|
174
|
-
|
174
|
+
if (c = null, n === w)
|
175
|
+
n = y, R({
|
175
176
|
files: o,
|
176
177
|
enableHotReloading: e,
|
177
178
|
enableSourcemap: a,
|
178
|
-
vizId:
|
179
|
+
vizId: l
|
179
180
|
});
|
180
|
-
else if (
|
181
|
-
c = o,
|
182
|
-
else if (
|
181
|
+
else if (n === D)
|
182
|
+
c = o, n = I;
|
183
|
+
else if (n === I)
|
183
184
|
c = o;
|
184
|
-
else if (
|
185
|
+
else if (n === y)
|
185
186
|
c = o;
|
186
187
|
else
|
187
|
-
throw new Error(`Unexpected state: ${
|
188
|
+
throw new Error(`Unexpected state: ${n}`);
|
188
189
|
};
|
189
190
|
return {
|
190
|
-
invalidateVizCache:
|
191
|
-
run:
|
192
|
-
cleanup:
|
191
|
+
invalidateVizCache: M(t),
|
192
|
+
run: C,
|
193
|
+
cleanup: g
|
193
194
|
};
|
194
195
|
}, U = ({
|
195
|
-
rawMessage:
|
196
|
+
rawMessage: s,
|
196
197
|
vizId: t
|
197
198
|
}) => {
|
198
199
|
const i = new RegExp(t, "g");
|
199
|
-
return
|
200
|
+
return s?.replace(i, ".");
|
200
201
|
};
|
201
202
|
export {
|
202
203
|
G as build,
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/orchestration/setupInvalidateVizCache.ts","../src/orchestration/setupBuild.ts","../src/orchestration/createRuntime.ts","../src/v3/cleanRollupErrorMessage.ts"],"sourcesContent":["import { VizId } from \"@vizhub/viz-types\";\nimport { generateRequestId } from \"./generateRequestId\";\n\nexport const setupInvalidateVizCache =\n (worker: Worker) =>\n async (changedVizIds: Array<VizId>): Promise<void> => {\n const requestId = generateRequestId();\n return new Promise<void>((resolve) => {\n const invalidateListener = (e: MessageEvent) => {\n if (\n e.data.type === \"invalidateVizCacheResponse\" &&\n e.data.requestId === requestId\n ) {\n worker.removeEventListener(\n \"message\",\n invalidateListener,\n );\n resolve();\n }\n };\n worker.addEventListener(\n \"message\",\n invalidateListener,\n );\n\n worker.postMessage({\n type: \"invalidateVizCacheRequest\",\n changedVizIds,\n requestId,\n });\n });\n };\n","import { FileCollection, VizId } from \"@vizhub/viz-types\";\nimport { generateRequestId } from \"./generateRequestId\";\nimport { BuildWorkerMessage } from \"./types\";\nimport { BuildResult } from \"../build/types\";\n\nexport const setupBuild =\n ({\n worker,\n setBuildErrorMessage,\n }: {\n worker: Worker;\n setBuildErrorMessage?: (error: string | null) => void;\n }) =>\n ({\n files,\n enableSourcemap,\n vizId,\n }: {\n files: FileCollection;\n enableSourcemap: boolean;\n vizId?: VizId;\n }): Promise<BuildResult | undefined> => {\n const requestId = generateRequestId();\n return new Promise<BuildResult | undefined>(\n (resolve) => {\n const buildListener = (e: MessageEvent) => {\n const data: BuildWorkerMessage = e.data;\n if (\n data.type === \"buildResponse\" &&\n data.requestId === requestId\n ) {\n worker.removeEventListener(\n \"message\",\n buildListener,\n );\n\n const buildResult: BuildResult | undefined =\n data.buildResult;\n const error: string | undefined = data.error;\n\n if (error) {\n setBuildErrorMessage?.(error);\n } else {\n setBuildErrorMessage?.(null);\n }\n\n resolve(buildResult);\n }\n };\n\n worker.addEventListener(\"message\", buildListener);\n\n const message: BuildWorkerMessage = {\n type: \"buildRequest\",\n files,\n enableSourcemap,\n requestId,\n vizId,\n };\n worker.postMessage(message);\n },\n );\n };\n","import {\n FileCollection,\n VizContent,\n VizId,\n} from \"@vizhub/viz-types\";\n\nimport { setupInvalidateVizCache } from \"./setupInvalidateVizCache\";\nimport { setupBuild } from \"./setupBuild\";\nimport {\n BuildWorkerMessage,\n VizHubRuntime,\n WindowMessage,\n} from \"./types\";\n\n// Flag for debugging.\nconst DEBUG = false;\n\n// State constants:\n\n// Nothing happening.\nconst IDLE = \"IDLE\";\n\n// An update has been enqueued\n// via requestAnimationFrame.\nconst ENQUEUED = \"ENQUEUED\";\n\n// An update (build and run) is pending,\n// and the files have not changed.\nconst PENDING_CLEAN = \"PENDING_CLEAN\";\n\n// An update (build and run) is pending,\n// and the files have changed\n// while this run is taking place.\nconst PENDING_DIRTY = \"PENDING_DIRTY\";\n\n// Valid State Transitions:\n//\n// * IDLE --> ENQUEUED\n// When the system is idle and files are changed.\n//\n// * ENQUEUED --> PENDING_CLEAN\n// When the pending changes run.\n//\n// * PENDING_CLEAN --> IDLE\n// When the pending update finishes running\n// and files were not changed in the mean time.\n//\n// * PENDING_CLEAN --> PENDING_DIRTY\n// When files are changed while an update is pending.\n//\n// * PENDING_DIRTY --> ENQUEUED\n// When the pending update finishes running\n// and files were changed in the mean time.\n//\n// When a build error happens, the state is set to IDLE.\n// This is to prevent a build error from causing\n// the whole system to stop working.\n\n// Creates an instance of the VizHub Runtime Environment.\n// This is the main entry point for the runtime, for use\n// by front end applications.\n// It sets up the iframe and worker, and handles messages\n// between them.\n// For server-side rendering where only a build is required,\n// just use the build function directly.\nexport const createRuntime = ({\n iframe,\n worker,\n setBuildErrorMessage,\n getLatestContent,\n resolveSlugKey,\n writeFile,\n}: {\n iframe: HTMLIFrameElement;\n worker: Worker;\n setBuildErrorMessage?: (error: string | null) => void;\n getLatestContent?: (\n vizId: VizId,\n ) => Promise<VizContent | null>;\n resolveSlugKey?: (\n slugKey: string,\n ) => Promise<VizId | null>;\n writeFile?: (fileName: string, content: string) => void;\n}): VizHubRuntime => {\n // Track the current state of the runtime\n let state:\n | typeof IDLE\n | typeof ENQUEUED\n | typeof PENDING_CLEAN\n | typeof PENDING_DIRTY = IDLE;\n\n // When a run is requested while the state is PENDING_CLEAN\n // or PENDING_DIRTY, we need to wait for the pending build to finish,\n // so until the build finishes, we use `latestFiles` to stash the latest files.\n let latestFiles: FileCollection | null = null;\n\n const build = setupBuild({\n worker,\n setBuildErrorMessage,\n });\n\n // Pending promise resolvers\n let pendingRunPromise: (() => void) | null = null;\n\n // This runs when the build worker sends a message.\n const workerListener: (e: MessageEvent) => void = ({\n data,\n }: {\n data: BuildWorkerMessage;\n }) => {\n if (\n data.type === \"contentRequest\" &&\n getLatestContent\n ) {\n DEBUG &&\n console.log(\n \"[worker] contentRequest\",\n JSON.stringify(data, null, 2),\n );\n const { vizId } = data;\n\n getLatestContent(vizId).then((content) => {\n worker.postMessage({\n type: \"contentResponse\",\n vizId,\n content,\n });\n });\n } else if (data.type === \"resolveSlugRequest\") {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest\",\n JSON.stringify(data, null, 2),\n );\n const { slugKey, requestId } = data;\n\n if (resolveSlugKey) {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: resolving slug key\",\n slugKey,\n );\n resolveSlugKey(slugKey).then(\n (vizId: VizId | null) => {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: resolved slug key\",\n slugKey,\n \"to vizId\",\n vizId,\n );\n const message: BuildWorkerMessage = {\n type: \"resolveSlugResponse\",\n vizId,\n requestId,\n };\n worker.postMessage(message);\n },\n );\n } else {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: no slug resolver, returning null\",\n JSON.stringify(data, null, 2),\n );\n // If we don't have a slug resolver, we just\n // send back the slug key as the vizId.\n const message: BuildWorkerMessage = {\n type: \"resolveSlugResponse\",\n vizId: null,\n requestId,\n };\n worker.postMessage(message);\n }\n }\n };\n\n worker.addEventListener(\"message\", workerListener);\n\n // Handle messages from the iframe\n const windowListener = (event: MessageEvent) => {\n const data = event.data;\n\n if (\n data.type === \"runDone\" ||\n data.type === \"runError\"\n ) {\n if (pendingRunPromise) {\n pendingRunPromise();\n pendingRunPromise = null;\n }\n\n if (data.type === \"runError\") {\n setBuildErrorMessage &&\n setBuildErrorMessage(data.error.message);\n }\n }\n\n if (data.type === \"writeFile\" && writeFile) {\n if (data.fileName && data.content) {\n writeFile(data.fileName, data.content);\n }\n }\n };\n\n // This runs when the IFrame sends a message.\n window.addEventListener(\"message\", windowListener);\n\n const cleanup = () => {\n worker.removeEventListener(\"message\", workerListener);\n window.removeEventListener(\"message\", windowListener);\n };\n\n const update = async ({\n files,\n enableHotReloading = false,\n enableSourcemap = false,\n vizId,\n }: {\n files: FileCollection;\n enableHotReloading?: boolean;\n enableSourcemap?: boolean;\n vizId?: VizId;\n }) => {\n state = PENDING_CLEAN;\n\n DEBUG && console.log(\"[runtime] update: before build\");\n\n // Build the code\n const buildResult = await build({\n files,\n enableSourcemap,\n vizId,\n });\n\n // In this case, the build failed\n // and in the meantime the callback `setBuildErrorMessage`\n // was called.\n if (!buildResult) {\n DEBUG &&\n console.log(\"[runtime] update: build failed\");\n }\n\n DEBUG && console.log(\"[runtime] update: after build\");\n\n if (buildResult) {\n const { html, runtimeVersion, js, css } = buildResult;\n\n DEBUG &&\n console.log(\n \"[runtime] enableHotReloading\",\n enableHotReloading,\n );\n\n DEBUG &&\n console.log(\n \"[runtime] html: \",\n html?.substring(0, 200),\n );\n\n DEBUG &&\n console.log(\n \"[runtime] js: \",\n js?.substring(0, 200),\n );\n\n DEBUG &&\n console.log(\n \"[runtime] css: \",\n css?.substring(0, 200),\n );\n\n // Clear the console before each run.\n !DEBUG && console.clear();\n\n // The `enableHotReloading` only works for v3.\n if (enableHotReloading && runtimeVersion === \"v3\") {\n if (css) {\n const runCSSMessage: WindowMessage = {\n type: \"runCSS\",\n css,\n };\n if (!iframe.contentWindow) {\n throw new Error(\n \"iframe.contentWindow is null - this should never happen\",\n );\n }\n iframe.contentWindow.postMessage(\n runCSSMessage,\n window.location.origin,\n );\n }\n if (js) {\n const runJSMessage: WindowMessage = {\n type: \"runJS\",\n js,\n };\n if (!iframe.contentWindow) {\n throw new Error(\n \"iframe.contentWindow is null - this should never happen\",\n );\n }\n iframe.contentWindow.postMessage(\n runJSMessage,\n window.location.origin,\n );\n }\n } else {\n iframe.srcdoc = html || \"\";\n }\n }\n\n // TypeScript can't comprehend that `state`\n // may change during the await calls above.\n // @ts-ignore\n if (state === PENDING_DIRTY) {\n requestAnimationFrame(() => {\n if (!latestFiles) {\n throw new Error(\n \"latestFiles is not defined and state is PENDING_DIRTY - this should never happen\",\n );\n }\n update({\n files: latestFiles,\n enableHotReloading,\n enableSourcemap,\n vizId,\n });\n });\n state = ENQUEUED;\n } else {\n state = IDLE;\n }\n };\n\n // Handle code changes\n\n const run = ({\n files,\n enableHotReloading = false,\n enableSourcemap = false,\n vizId = undefined,\n }: {\n files: FileCollection;\n enableHotReloading?: boolean;\n enableSourcemap?: boolean;\n vizId?: VizId;\n }) => {\n DEBUG && console.log(\"[runtime] run\");\n latestFiles = null;\n if (state === IDLE) {\n DEBUG && console.log(\"[runtime] run: IDLE\");\n state = ENQUEUED;\n update({\n files,\n enableHotReloading,\n enableSourcemap,\n vizId,\n });\n } else if (state === PENDING_CLEAN) {\n DEBUG && console.log(\"[runtime] run: PENDING_CLEAN\");\n latestFiles = files;\n state = PENDING_DIRTY;\n } else if (state === PENDING_DIRTY) {\n DEBUG && console.log(\"[runtime] run: PENDING_DIRTY\");\n latestFiles = files;\n } else if (state === ENQUEUED) {\n DEBUG && console.log(\"[runtime] run: ENQUEUED\");\n latestFiles = files;\n } else {\n throw new Error(`Unexpected state: ${state}`);\n }\n };\n\n return {\n invalidateVizCache: setupInvalidateVizCache(worker),\n run,\n cleanup,\n };\n};\n","// We want to remove the vizId from the error message\n// to make it more user-friendly.\n// Example error message before and after:\n// Before: \"7f0b69fcb754479699172d1887817027/index.js (14:8): Expected ';', '}' or <eof>\"\n// After: \"./index.js (14:8): Expected ';', '}' or <eof>\"\nexport const cleanRollupErrorMessage = ({\n rawMessage,\n vizId,\n}: {\n rawMessage: string;\n vizId: string;\n}) => {\n const regex = new RegExp(vizId, \"g\");\n return rawMessage?.replace(regex, \".\");\n};\n"],"names":["setupInvalidateVizCache","worker","changedVizIds","requestId","generateRequestId","resolve","invalidateListener","e","setupBuild","setBuildErrorMessage","files","enableSourcemap","vizId","buildListener","data","buildResult","error","message","IDLE","ENQUEUED","PENDING_CLEAN","PENDING_DIRTY","createRuntime","iframe","getLatestContent","resolveSlugKey","writeFile","state","latestFiles","build","workerListener","content","slugKey","windowListener","event","cleanup","update","enableHotReloading","html","runtimeVersion","js","css","runCSSMessage","runJSMessage","run","cleanRollupErrorMessage","rawMessage","regex"],"mappings":";;AAGO,MAAMA,IACX,CAACC,MACD,OAAOC,MAA+C;AACpD,QAAMC,IAAYC,EAAkB;AAC7B,SAAA,IAAI,QAAc,CAACC,MAAY;AAC9B,UAAAC,IAAqB,CAACC,MAAoB;AAC9C,MACEA,EAAE,KAAK,SAAS,gCAChBA,EAAE,KAAK,cAAcJ,MAEdF,EAAA;AAAA,QACL;AAAA,QACAK;AAAA,MACF,GACQD,EAAA;AAAA,IAEZ;AACO,IAAAJ,EAAA;AAAA,MACL;AAAA,MACAK;AAAA,IACF,GAEAL,EAAO,YAAY;AAAA,MACjB,MAAM;AAAA,MACN,eAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,CACD;AAAA,EAAA,CACF;A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IAAQ;AAAA,EAAA,MAMJ;AAGJ,QADcgB,IAAA,MACVD,MAAUT;AAEJ,MAAAS,IAAAR,GACDiB,EAAA;AAAA,QACL,OAAA1B;AAAA,QACA,oBAAA2B;AAAA,QACA,iBAAA1B;AAAA,QACA,OAAAC;AAAA,MAAA,CACD;AAAA,aACQe,MAAUP;AAEL,MAAAQ,IAAAlB,GACNiB,IAAAN;AAAA,aACCM,MAAUN;AAEL,MAAAO,IAAAlB;AAAA,aACLiB,MAAUR;AAEL,MAAAS,IAAAlB;AAAA;AAEd,YAAM,IAAI,MAAM,qBAAqBiB,CAAK,EAAE;AAAA,EAEhD;AAEO,SAAA;AAAA,IACL,oBAAoB3B,EAAwBC,CAAM;AAAA,IAClD,KAAA2C;AAAA,IACA,SAAAT;AAAA,EACF;AACF,GCtXaU,IAA0B,CAAC;AAAA,EACtC,YAAAC;AAAA,EACA,OAAAlC;AACF,MAGM;AACJ,QAAMmC,IAAQ,IAAI,OAAOnC,GAAO,GAAG;AAC5B,SAAAkC,KAAA,gBAAAA,EAAY,QAAQC,GAAO;AACpC;"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/orchestration/setupInvalidateVizCache.ts","../src/orchestration/setupBuild.ts","../src/orchestration/createRuntime.ts","../src/v3/cleanRollupErrorMessage.ts"],"sourcesContent":["import { VizId } from \"@vizhub/viz-types\";\nimport { generateRequestId } from \"./generateRequestId\";\n\nexport const setupInvalidateVizCache =\n (worker: Worker) =>\n async (changedVizIds: Array<VizId>): Promise<void> => {\n const requestId = generateRequestId();\n return new Promise<void>((resolve) => {\n const invalidateListener = (e: MessageEvent) => {\n if (\n e.data.type === \"invalidateVizCacheResponse\" &&\n e.data.requestId === requestId\n ) {\n worker.removeEventListener(\n \"message\",\n invalidateListener,\n );\n resolve();\n }\n };\n worker.addEventListener(\n \"message\",\n invalidateListener,\n );\n\n worker.postMessage({\n type: \"invalidateVizCacheRequest\",\n changedVizIds,\n requestId,\n });\n });\n };\n","import { FileCollection, VizId } from \"@vizhub/viz-types\";\nimport { generateRequestId } from \"./generateRequestId\";\nimport { BuildWorkerMessage } from \"./types\";\nimport { BuildResult } from \"../build/types\";\n\nexport const setupBuild =\n ({\n worker,\n setBuildErrorMessage,\n }: {\n worker: Worker;\n setBuildErrorMessage?: (error: string | null) => void;\n }) =>\n ({\n files,\n enableSourcemap,\n vizId,\n }: {\n files: FileCollection;\n enableSourcemap: boolean;\n vizId?: VizId;\n }): Promise<BuildResult | undefined> => {\n const requestId = generateRequestId();\n return new Promise<BuildResult | undefined>(\n (resolve) => {\n const buildListener = (e: MessageEvent) => {\n const data: BuildWorkerMessage = e.data;\n if (\n data.type === \"buildResponse\" &&\n data.requestId === requestId\n ) {\n worker.removeEventListener(\n \"message\",\n buildListener,\n );\n\n const buildResult: BuildResult | undefined =\n data.buildResult;\n const error: string | undefined = data.error;\n\n if (error) {\n setBuildErrorMessage?.(error);\n } else {\n setBuildErrorMessage?.(null);\n }\n\n resolve(buildResult);\n }\n };\n\n worker.addEventListener(\"message\", buildListener);\n\n const message: BuildWorkerMessage = {\n type: \"buildRequest\",\n files,\n enableSourcemap,\n requestId,\n vizId,\n };\n worker.postMessage(message);\n },\n );\n };\n","import {\n FileCollection,\n VizContent,\n VizId,\n} from \"@vizhub/viz-types\";\n\nimport { setupInvalidateVizCache } from \"./setupInvalidateVizCache\";\nimport { setupBuild } from \"./setupBuild\";\nimport {\n BuildWorkerMessage,\n VizHubRuntime,\n WindowMessage,\n} from \"./types\";\n\n// Flag for debugging.\nconst DEBUG = false;\n\n// State constants:\n\n// Nothing happening.\nconst IDLE = \"IDLE\";\n\n// An update has been enqueued\n// via requestAnimationFrame.\nconst ENQUEUED = \"ENQUEUED\";\n\n// An update (build and run) is pending,\n// and the files have not changed.\nconst PENDING_CLEAN = \"PENDING_CLEAN\";\n\n// An update (build and run) is pending,\n// and the files have changed\n// while this run is taking place.\nconst PENDING_DIRTY = \"PENDING_DIRTY\";\n\n// Valid State Transitions:\n//\n// * IDLE --> ENQUEUED\n// When the system is idle and files are changed.\n//\n// * ENQUEUED --> PENDING_CLEAN\n// When the pending changes run.\n//\n// * PENDING_CLEAN --> IDLE\n// When the pending update finishes running\n// and files were not changed in the mean time.\n//\n// * PENDING_CLEAN --> PENDING_DIRTY\n// When files are changed while an update is pending.\n//\n// * PENDING_DIRTY --> ENQUEUED\n// When the pending update finishes running\n// and files were changed in the mean time.\n//\n// When a build error happens, the state is set to IDLE.\n// This is to prevent a build error from causing\n// the whole system to stop working.\n\n// Creates an instance of the VizHub Runtime Environment.\n// This is the main entry point for the runtime, for use\n// by front end applications.\n// It sets up the iframe and worker, and handles messages\n// between them.\n// For server-side rendering where only a build is required,\n// just use the build function directly.\nexport const createRuntime = ({\n iframe,\n worker,\n setBuildErrorMessage,\n getLatestContent,\n resolveSlugKey,\n writeFile,\n handleRuntimeError,\n}: {\n iframe: HTMLIFrameElement;\n worker: Worker;\n setBuildErrorMessage?: (error: string | null) => void;\n getLatestContent?: (\n vizId: VizId,\n ) => Promise<VizContent | null>;\n resolveSlugKey?: (\n slugKey: string,\n ) => Promise<VizId | null>;\n writeFile?: (fileName: string, content: string) => void;\n handleRuntimeError?: (formattedErrorMessage: string) => void;\n}): VizHubRuntime => {\n // Track the current state of the runtime\n let state:\n | typeof IDLE\n | typeof ENQUEUED\n | typeof PENDING_CLEAN\n | typeof PENDING_DIRTY = IDLE;\n\n // When a run is requested while the state is PENDING_CLEAN\n // or PENDING_DIRTY, we need to wait for the pending build to finish,\n // so until the build finishes, we use `latestFiles` to stash the latest files.\n let latestFiles: FileCollection | null = null;\n\n const build = setupBuild({\n worker,\n setBuildErrorMessage,\n });\n\n // Pending promise resolvers\n let pendingRunPromise: (() => void) | null = null;\n\n // This runs when the build worker sends a message.\n const workerListener: (e: MessageEvent) => void = ({\n data,\n }: {\n data: BuildWorkerMessage;\n }) => {\n if (\n data.type === \"contentRequest\" &&\n getLatestContent\n ) {\n DEBUG &&\n console.log(\n \"[worker] contentRequest\",\n JSON.stringify(data, null, 2),\n );\n const { vizId } = data;\n\n getLatestContent(vizId).then((content) => {\n worker.postMessage({\n type: \"contentResponse\",\n vizId,\n content,\n });\n });\n } else if (data.type === \"resolveSlugRequest\") {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest\",\n JSON.stringify(data, null, 2),\n );\n const { slugKey, requestId } = data;\n\n if (resolveSlugKey) {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: resolving slug key\",\n slugKey,\n );\n resolveSlugKey(slugKey).then(\n (vizId: VizId | null) => {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: resolved slug key\",\n slugKey,\n \"to vizId\",\n vizId,\n );\n const message: BuildWorkerMessage = {\n type: \"resolveSlugResponse\",\n vizId,\n requestId,\n };\n worker.postMessage(message);\n },\n );\n } else {\n DEBUG &&\n console.log(\n \"[worker] resolveSlugRequest: no slug resolver, returning null\",\n JSON.stringify(data, null, 2),\n );\n // If we don't have a slug resolver, we just\n // send back the slug key as the vizId.\n const message: BuildWorkerMessage = {\n type: \"resolveSlugResponse\",\n vizId: null,\n requestId,\n };\n worker.postMessage(message);\n }\n }\n };\n\n worker.addEventListener(\"message\", workerListener);\n\n // Handle messages from the iframe\n const windowListener = (event: MessageEvent) => {\n const data = event.data;\n\n if (\n data.type === \"runDone\" ||\n data.type === \"runError\"\n ) {\n if (pendingRunPromise) {\n pendingRunPromise();\n pendingRunPromise = null;\n }\n\n if (data.type === \"runError\") {\n setBuildErrorMessage &&\n setBuildErrorMessage(data.error.message);\n }\n }\n\n if (data.type === \"runtimeError\" && handleRuntimeError) {\n handleRuntimeError(data.formattedErrorMessage);\n }\n\n if (data.type === \"writeFile\" && writeFile) {\n if (data.fileName && data.content) {\n writeFile(data.fileName, data.content);\n }\n }\n };\n\n // This runs when the IFrame sends a message.\n window.addEventListener(\"message\", windowListener);\n\n const cleanup = () => {\n worker.removeEventListener(\"message\", workerListener);\n window.removeEventListener(\"message\", windowListener);\n };\n\n const update = async ({\n files,\n enableHotReloading = false,\n enableSourcemap = false,\n vizId,\n }: {\n files: FileCollection;\n enableHotReloading?: boolean;\n enableSourcemap?: boolean;\n vizId?: VizId;\n }) => {\n state = PENDING_CLEAN;\n\n DEBUG && console.log(\"[runtime] update: before build\");\n\n // Build the code\n const buildResult = await build({\n files,\n enableSourcemap,\n vizId,\n });\n\n // In this case, the build failed\n // and in the meantime the callback `setBuildErrorMessage`\n // was called.\n if (!buildResult) {\n DEBUG &&\n console.log(\"[runtime] update: build failed\");\n }\n\n DEBUG && console.log(\"[runtime] update: after build\");\n\n if (buildResult) {\n const { html, runtimeVersion, js, css } = buildResult;\n\n DEBUG &&\n console.log(\n \"[runtime] enableHotReloading\",\n enableHotReloading,\n );\n\n DEBUG &&\n console.log(\n \"[runtime] html: \",\n html?.substring(0, 200),\n );\n\n DEBUG &&\n console.log(\n \"[runtime] js: \",\n js?.substring(0, 200),\n );\n\n DEBUG &&\n console.log(\n \"[runtime] css: \",\n css?.substring(0, 200),\n );\n\n // Clear the console before each run.\n !DEBUG && console.clear();\n\n // The `enableHotReloading` only works for v3.\n if (enableHotReloading && runtimeVersion === \"v3\") {\n if (css) {\n const runCSSMessage: WindowMessage = {\n type: \"runCSS\",\n css,\n };\n if (!iframe.contentWindow) {\n throw new Error(\n \"iframe.contentWindow is null - this should never happen\",\n );\n }\n iframe.contentWindow.postMessage(\n runCSSMessage,\n window.location.origin,\n );\n }\n if (js) {\n const runJSMessage: WindowMessage = {\n type: \"runJS\",\n js,\n };\n if (!iframe.contentWindow) {\n throw new Error(\n \"iframe.contentWindow is null - this should never happen\",\n );\n }\n iframe.contentWindow.postMessage(\n runJSMessage,\n window.location.origin,\n );\n }\n } else {\n iframe.srcdoc = html || \"\";\n }\n }\n\n // TypeScript can't comprehend that `state`\n // may change during the await calls above.\n // @ts-ignore\n if (state === PENDING_DIRTY) {\n requestAnimationFrame(() => {\n if (!latestFiles) {\n throw new Error(\n \"latestFiles is not defined and state is PENDING_DIRTY - this should never happen\",\n );\n }\n update({\n files: latestFiles,\n enableHotReloading,\n enableSourcemap,\n vizId,\n });\n });\n state = ENQUEUED;\n } else {\n state = IDLE;\n }\n };\n\n // Handle code changes\n\n const run = ({\n files,\n enableHotReloading = false,\n enableSourcemap = false,\n vizId = undefined,\n }: {\n files: FileCollection;\n enableHotReloading?: boolean;\n enableSourcemap?: boolean;\n vizId?: VizId;\n }) => {\n DEBUG && console.log(\"[runtime] run\");\n latestFiles = null;\n if (state === IDLE) {\n DEBUG && console.log(\"[runtime] run: IDLE\");\n state = ENQUEUED;\n update({\n files,\n enableHotReloading,\n enableSourcemap,\n vizId,\n });\n } else if (state === PENDING_CLEAN) {\n DEBUG && console.log(\"[runtime] run: PENDING_CLEAN\");\n latestFiles = files;\n state = PENDING_DIRTY;\n } else if (state === PENDING_DIRTY) {\n DEBUG && console.log(\"[runtime] run: PENDING_DIRTY\");\n latestFiles = files;\n } else if (state === ENQUEUED) {\n DEBUG && console.log(\"[runtime] run: ENQUEUED\");\n latestFiles = files;\n } else {\n throw new Error(`Unexpected state: ${state}`);\n }\n };\n\n return {\n invalidateVizCache: setupInvalidateVizCache(worker),\n run,\n cleanup,\n };\n};\n","// We want to remove the vizId from the error message\n// to make it more user-friendly.\n// Example error message before and after:\n// Before: \"7f0b69fcb754479699172d1887817027/index.js (14:8): Expected ';', '}' or <eof>\"\n// After: \"./index.js (14:8): Expected ';', '}' or <eof>\"\nexport const cleanRollupErrorMessage = ({\n rawMessage,\n vizId,\n}: {\n rawMessage: string;\n vizId: string;\n}) => {\n const regex = new RegExp(vizId, \"g\");\n return rawMessage?.replace(regex, \".\");\n};\n"],"names":["setupInvalidateVizCache","worker","changedVizIds","requestId","generateRequestId","resolve","invalidateListener","e","setupBuild","setBuildErrorMessage","files","enableSourcemap","vizId","buildListener","data","buildResult","error","message","IDLE","ENQUEUED","PENDING_CLEAN","PENDING_DIRTY","createRuntime","iframe","getLatestContent","resolveSlugKey","writeFile","handleRuntimeError","state","latestFiles","build","workerListener","content","slugKey","windowListener","event","cleanup","update","enableHotReloading","html","runtimeVersion","js","css","runCSSMessage","runJSMessage","run","cleanRollupErrorMessage","rawMessage","regex"],"mappings":";;AAGO,MAAMA,IACX,CAACC,MACD,OAAOC,MAA+C;AACpD,QAAMC,IAAYC,EAAA;AAClB,SAAO,IAAI,QAAc,CAACC,MAAY;AACpC,UAAMC,IAAqB,CAACC,MAAoB;AAC9C,MACEA,EAAE,KAAK,SAAS,gCAChBA,EAAE,KAAK,cAAcJ,MAErBF,EAAO;AAAA,QACL;AAAA,QACAK;AAAA,MAAA,GAEFD,EAAA;AAAA,IAEJ;AACA,IAAAJ,EAAO;AAAA,MACL;AAAA,MACAK;AAAA,IAAA,GAGFL,EAAO,YAAY;AAAA,MACjB,MAAM;AAAA,MACN,eAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,CACD;AAAA,EACH,CAAC;AACH,GC1BWK,IACX,CAAC;AAAA,EACC,QAAAP;AAAA,EACA,sBAAAQ;AACF,MAIA,CAAC;AAAA,EACC,OAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,OAAAC;AACF,MAIwC;AACtC,QAAMT,IAAYC,EAAA;AAClB,SAAO,IAAI;AAAA,IACT,CAACC,MAAY;AACX,YAAMQ,IAAgB,CAACN,MAAoB;AACzC,cAAMO,IAA2BP,EAAE;AACnC,YACEO,EAAK,SAAS,mBACdA,EAAK,cAAcX,GACnB;AACA,UAAAF,EAAO;AAAA,YACL;AAAA,YACAY;AAAA,UAAA;AAGF,gBAAME,IACJD,EAAK,aACDE,IAA4BF,EAAK;AAEvC,UACEL,IADEO,KAGqB,IAFK,GAK9BX,EAAQU,CAAW;AAAA,QACrB;AAAA,MACF;AAEA,MAAAd,EAAO,iBAAiB,WAAWY,CAAa;AAEhD,YAAMI,IAA8B;AAAA,QAClC,MAAM;AAAA,QACN,OAAAP;AAAA,QACA,iBAAAC;AAAA,QACA,WAAAR;AAAA,QACA,OAAAS;AAAA,MAAA;AAEF,MAAAX,EAAO,YAAY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AY,QAAQC,GAAO,GAAG;AACvC;"}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { VizContent, VizId } from "@vizhub/viz-types";
|
2
2
|
import { VizHubRuntime } from "./types";
|
3
|
-
export declare const createRuntime: ({ iframe, worker, setBuildErrorMessage, getLatestContent, resolveSlugKey, writeFile, }: {
|
3
|
+
export declare const createRuntime: ({ iframe, worker, setBuildErrorMessage, getLatestContent, resolveSlugKey, writeFile, handleRuntimeError, }: {
|
4
4
|
iframe: HTMLIFrameElement;
|
5
5
|
worker: Worker;
|
6
6
|
setBuildErrorMessage?: (error: string | null) => void;
|
7
7
|
getLatestContent?: (vizId: VizId) => Promise<VizContent | null>;
|
8
8
|
resolveSlugKey?: (slugKey: string) => Promise<VizId | null>;
|
9
9
|
writeFile?: (fileName: string, content: string) => void;
|
10
|
+
handleRuntimeError?: (formattedErrorMessage: string) => void;
|
10
11
|
}) => VizHubRuntime;
|
11
12
|
//# sourceMappingURL=createRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createRuntime.d.ts","sourceRoot":"","sources":["../../src/orchestration/createRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,KAAK,EACN,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAEL,aAAa,EAEd,MAAM,SAAS,CAAC;AAqDjB,eAAO,MAAM,aAAa,GAAI,
|
1
|
+
{"version":3,"file":"createRuntime.d.ts","sourceRoot":"","sources":["../../src/orchestration/createRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,KAAK,EACN,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAEL,aAAa,EAEd,MAAM,SAAS,CAAC;AAqDjB,eAAO,MAAM,aAAa,GAAI,4GAQ3B;IACD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAA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E,qBAAqB,CAAC;IAC5B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,GAKD;IACE,IAAI,EAAE,2BAA2B,CAAC;IAClC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,GAKD;IACE,IAAI,EAAE,4BAA4B,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAGN,MAAM,MAAM,aAAa,GAIrB;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,GAKD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,GAKD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,GAKD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,GAKD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,GAKD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extractEntryPoints.test.d.ts","sourceRoot":"","sources":["../../src/test/extractEntryPoints.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extractEntryPointsEdgeCases.test.d.ts","sourceRoot":"","sources":["../../src/test/extractEntryPointsEdgeCases.test.ts"],"names":[],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../../../../src/test/fixtures/v3/svelte.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;
|
1
|
+
{"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../../../../src/test/fixtures/v3/svelte.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAkBlB,CAAC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export { jsScriptTagTypeModule } from "./jsScriptTagTypeModule";
|
2
2
|
export { jsScriptTagTypeModules } from "./jsScriptTagTypeModules";
|
3
3
|
export { jsScriptTagTypeModulesRelative } from "./jsScriptTagTypeModulesRelative";
|
4
|
+
export { jsInlineScriptModule } from "./jsInlineScriptModule";
|
4
5
|
export { fetchInterception } from "./fetchInterception";
|
5
6
|
export { esmBuild } from "./esmBuild";
|
6
7
|
export { reactJsx } from "./reactJsx";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/fixtures/v4/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/fixtures/v4/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsInlineScriptModule.d.ts","sourceRoot":"","sources":["../../../../src/test/fixtures/v4/jsInlineScriptModule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;CAuBhC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtimeErrorHandling.test.d.ts","sourceRoot":"","sources":["../../src/test/runtimeErrorHandling.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtimeErrorHandlingAllVersions.test.d.ts","sourceRoot":"","sources":["../../src/test/runtimeErrorHandlingAllVersions.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtimeErrorHandlingIntegration.test.d.ts","sourceRoot":"","sources":["../../src/test/runtimeErrorHandlingIntegration.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"updateHTML.test.d.ts","sourceRoot":"","sources":["../../src/test/updateHTML.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"v4Build.test.d.ts","sourceRoot":"","sources":["../../src/test/v4Build.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"v4BuildIntegration.test.d.ts","sourceRoot":"","sources":["../../src/test/v4BuildIntegration.test.ts"],"names":[],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getComputedIndexHtml.d.ts","sourceRoot":"","sources":["../../src/v2/getComputedIndexHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
1
|
+
{"version":3,"file":"getComputedIndexHtml.d.ts","sourceRoot":"","sources":["../../src/v2/getComputedIndexHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAkJnD,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,KACpB,MA0BF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"htmlTemplate.d.ts","sourceRoot":"","sources":["../../src/v3/htmlTemplate.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"htmlTemplate.d.ts","sourceRoot":"","sources":["../../src/v3/htmlTemplate.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,GAAI,uBAI1B;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,WAuFA,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"svelte5-integration.test.d.ts","sourceRoot":"","sources":["../../src/v3/svelte5-integration.test.ts"],"names":[],"mappings":""}
|
@@ -1,8 +1,15 @@
|
|
1
1
|
import type { InputPluginOption } from "rollup";
|
2
2
|
export type SvelteCompiler = (code: string, options: any) => {
|
3
|
-
js:
|
3
|
+
js: {
|
4
|
+
code: string;
|
5
|
+
map?: object;
|
6
|
+
};
|
7
|
+
css?: {
|
8
|
+
code: string;
|
9
|
+
map?: object;
|
10
|
+
} | null;
|
4
11
|
};
|
5
|
-
export declare const svelteCompilerUrl = "https://cdn.jsdelivr.net/npm/svelte@
|
12
|
+
export declare const svelteCompilerUrl = "https://cdn.jsdelivr.net/npm/svelte@5/compiler.cjs";
|
6
13
|
export declare const transformSvelte: ({ getSvelteCompiler, }: {
|
7
14
|
getSvelteCompiler?: () => Promise<any>;
|
8
15
|
}) => InputPluginOption;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transformSvelte.d.ts","sourceRoot":"","sources":["../../src/v3/transformSvelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAUhD,MAAM,MAAM,cAAc,GAAG,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,GAAG,KACT;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;
|
1
|
+
{"version":3,"file":"transformSvelte.d.ts","sourceRoot":"","sources":["../../src/v3/transformSvelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAUhD,MAAM,MAAM,cAAc,GAAG,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,GAAG,KACT;IAAE,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,CAAC;AAMzF,eAAO,MAAM,iBAAiB,uDAA8B,CAAC;AAO7D,eAAO,MAAM,eAAe,GAAI,wBAE7B;IACD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACxC,KAAG,iBA0GF,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transformSvelte.test.d.ts","sourceRoot":"","sources":["../../src/v3/transformSvelte.test.ts"],"names":[],"mappings":""}
|
@@ -1,5 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* Extract module script entry points from index.html
|
3
3
|
*/
|
4
|
-
export declare const extractModuleEntryPoints: (html: string) =>
|
4
|
+
export declare const extractModuleEntryPoints: (html: string) => {
|
5
|
+
entryPoints: string[];
|
6
|
+
inlineScripts: Array<{
|
7
|
+
id: string;
|
8
|
+
content: string;
|
9
|
+
}>;
|
10
|
+
};
|
5
11
|
//# sourceMappingURL=extractEntryPoints.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"extractEntryPoints.d.ts","sourceRoot":"","sources":["../../src/v4/extractEntryPoints.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,MAAM,KACX,MAAM,
|
1
|
+
{"version":3,"file":"extractEntryPoints.d.ts","sourceRoot":"","sources":["../../src/v4/extractEntryPoints.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,MAAM,KACX;IACD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAiCvD,CAAC"}
|
package/dist/v4/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAMnE;;GAEG;AACH,eAAO,MAAM,OAAO,GAAU,qCAI3B;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,KAAG,OAAO,CAAC,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAMnE;;GAEG;AACH,eAAO,MAAM,OAAO,GAAU,qCAI3B;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,KAAG,OAAO,CAAC,cAAc,CAiCzB,CAAC;AAGF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
package/dist/v4/updateHTML.d.ts
CHANGED
@@ -2,5 +2,8 @@ import { FileCollection } from "@vizhub/viz-types";
|
|
2
2
|
/**
|
3
3
|
* Update HTML to include import map and bundled modules
|
4
4
|
*/
|
5
|
-
export declare const updateHTML: (files: FileCollection, bundled: Map<string, string
|
5
|
+
export declare const updateHTML: (files: FileCollection, bundled: Map<string, string>, inlineScripts?: Array<{
|
6
|
+
id: string;
|
7
|
+
content: string;
|
8
|
+
}>) => string;
|
6
9
|
//# sourceMappingURL=updateHTML.d.ts.map
|