tempo-sdk 0.0.52 → 0.0.60
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/assets/index.js +4 -2
- package/dist/assets/index.js.map +1 -1
- package/dist/canvas/editor.d.ts +11 -16
- package/dist/canvas/editor.js +79 -49
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +13 -7
- package/dist/canvas/index.js +227 -64
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -3
- package/dist/canvas/parser.d.ts +10 -5
- package/dist/canvas/parser.js +3 -1
- package/dist/canvas/svelte.d.ts +8 -5
- package/dist/canvas/svelte.js +20 -5
- package/dist/canvas/svelte.js.map +1 -1
- package/dist/chunk-2IQD2KPS.js +219 -0
- package/dist/chunk-2IQD2KPS.js.map +1 -0
- package/dist/chunk-5BHIHP25.js +410 -0
- package/dist/chunk-5BHIHP25.js.map +1 -0
- package/dist/{chunk-PULSTDX2.js → chunk-7DT5DDSH.js} +284 -46
- package/dist/chunk-7DT5DDSH.js.map +1 -0
- package/dist/{chunk-7Y7XNHUM.js → chunk-FQSZRVSL.js} +18 -3
- package/dist/chunk-FQSZRVSL.js.map +1 -0
- package/dist/{chunk-ZZYNOX24.js → chunk-MXKZZOLM.js} +1717 -2460
- package/dist/chunk-MXKZZOLM.js.map +1 -0
- package/dist/{chunk-DX6XAXCK.js → chunk-N2TYN3RB.js} +189 -420
- package/dist/chunk-N2TYN3RB.js.map +1 -0
- package/dist/chunk-OTVBSF7U.js +1585 -0
- package/dist/chunk-OTVBSF7U.js.map +1 -0
- package/dist/chunk-TL4MGN7E.js +2570 -0
- package/dist/chunk-TL4MGN7E.js.map +1 -0
- package/dist/{chunk-QP2NTODB.js → chunk-VMTQDG4U.js} +117 -27
- package/dist/chunk-VMTQDG4U.js.map +1 -0
- package/dist/expo/plugin.cjs +1256 -16
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.d.cts +0 -1
- package/dist/expo/plugin.d.ts +0 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +1258 -16
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +8 -5
- package/dist/expo-babel-plugin.d.ts +8 -5
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +647 -166
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.cjs +151 -0
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.d.cts +1 -1
- package/dist/nextjs/plugin.d.ts +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +1432 -35
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +17 -2
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +14 -3
- package/dist/nextjs.d.ts +14 -3
- package/dist/nextjs.js +1 -1
- package/dist/{page-xi1aI5a7.d.ts → page-DwLnOM5d.d.ts} +12 -6
- package/dist/{storyboard-DbtzTPvI.d.ts → storyboard-DjOF61B_.d.ts} +35 -15
- package/dist/svelte.d.ts +3 -2
- package/dist/svelte.js +103 -29
- package/dist/svelte.js.map +1 -1
- package/dist/v1-client-compat-qxaXEDm_.d.ts +23 -0
- package/package.json +5 -2
- package/dist/chunk-57KAYXHF.js +0 -19
- package/dist/chunk-57KAYXHF.js.map +0 -1
- package/dist/chunk-7Y7XNHUM.js.map +0 -1
- package/dist/chunk-CB5NJJJT.js +0 -345
- package/dist/chunk-CB5NJJJT.js.map +0 -1
- package/dist/chunk-DX6XAXCK.js.map +0 -1
- package/dist/chunk-F3KJDCMU.js +0 -19
- package/dist/chunk-F3KJDCMU.js.map +0 -1
- package/dist/chunk-PULSTDX2.js.map +0 -1
- package/dist/chunk-QP2NTODB.js.map +0 -1
- package/dist/chunk-ZZYNOX24.js.map +0 -1
package/dist/canvas/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
VITE_ERROR_FEED_KEY
|
|
3
3
|
} from "../chunk-K3EYTZLL.js";
|
|
4
4
|
import {
|
|
5
|
+
AdmissionBudgetError,
|
|
5
6
|
Canvas,
|
|
6
7
|
CanvasContext,
|
|
7
8
|
CanvasHostContext,
|
|
@@ -12,25 +13,34 @@ import {
|
|
|
12
13
|
Storyboard,
|
|
13
14
|
StoryboardSlot,
|
|
14
15
|
getCanvasStoryboardRenderId,
|
|
16
|
+
getStoryboardKey,
|
|
15
17
|
getStoryboardPortalSelectors,
|
|
18
|
+
isV1CanvasClient,
|
|
16
19
|
normalizeId,
|
|
17
20
|
useActiveState,
|
|
18
21
|
useRenderErrorRecovery,
|
|
19
|
-
useRequiredCanvasHost
|
|
20
|
-
|
|
22
|
+
useRequiredCanvasHost,
|
|
23
|
+
v1DirectUrlSize,
|
|
24
|
+
v1RenderRequestSize
|
|
25
|
+
} from "../chunk-7DT5DDSH.js";
|
|
21
26
|
import {
|
|
22
27
|
installTempoInteractProjectionSource
|
|
23
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-MXKZZOLM.js";
|
|
24
29
|
import {
|
|
25
30
|
TEMPO_INTERACT_FRAME_NAME,
|
|
26
31
|
isTempoInteractFrameName
|
|
27
32
|
} from "../chunk-65B52AR7.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
33
|
+
import "../chunk-TL4MGN7E.js";
|
|
34
|
+
import "../chunk-5BHIHP25.js";
|
|
35
|
+
import "../chunk-N2TYN3RB.js";
|
|
30
36
|
|
|
31
37
|
// canvas/canvas-host.tsx
|
|
32
38
|
import {
|
|
33
39
|
useEffect as useEffect3,
|
|
40
|
+
useCallback as useCallback3,
|
|
41
|
+
useLayoutEffect as useLayoutEffect3,
|
|
42
|
+
useRef as useRef3,
|
|
43
|
+
useState as useState3,
|
|
34
44
|
useMemo as useMemo3,
|
|
35
45
|
useSyncExternalStore
|
|
36
46
|
} from "react";
|
|
@@ -111,11 +121,16 @@ function CanvasImportBoundary({
|
|
|
111
121
|
const failedRef = useRef(false);
|
|
112
122
|
const importRejectedRef = useRef(false);
|
|
113
123
|
const loadRef = useRef(load);
|
|
124
|
+
const currentExportRef = useRef(null);
|
|
125
|
+
const [replacement, setReplacement] = useState(null);
|
|
126
|
+
const loadGenerationRef = useRef(0);
|
|
114
127
|
const previousLoadRef = useRef(load);
|
|
115
128
|
loadRef.current = load;
|
|
116
129
|
const [retryRevision, setRetryRevision] = useState(0);
|
|
117
130
|
const retryRenderNow = useCallback(() => {
|
|
118
131
|
if (!failedRef.current || importRejectedRef.current) return false;
|
|
132
|
+
currentExportRef.current = null;
|
|
133
|
+
setReplacement(null);
|
|
119
134
|
setRetryRevision((revision) => revision + 1);
|
|
120
135
|
return true;
|
|
121
136
|
}, []);
|
|
@@ -127,6 +142,19 @@ function CanvasImportBoundary({
|
|
|
127
142
|
() => Promise.resolve().then(() => {
|
|
128
143
|
importRejectedRef.current = false;
|
|
129
144
|
return loadRef.current();
|
|
145
|
+
}).then((module) => {
|
|
146
|
+
const current = module;
|
|
147
|
+
if (currentExportRef.current === null) {
|
|
148
|
+
currentExportRef.current = module.default;
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
default: function LoadedCanvas({
|
|
152
|
+
replacement: replacement2
|
|
153
|
+
}) {
|
|
154
|
+
const Component2 = replacement2 ?? current.default;
|
|
155
|
+
return /* @__PURE__ */ jsx(Component2, {});
|
|
156
|
+
}
|
|
157
|
+
};
|
|
130
158
|
}).catch((error) => {
|
|
131
159
|
importRejectedRef.current = true;
|
|
132
160
|
getCanvasHostRecoveryFeed().publish({
|
|
@@ -155,10 +183,38 @@ function CanvasImportBoundary({
|
|
|
155
183
|
useEffect(() => {
|
|
156
184
|
const loadChanged = previousLoadRef.current !== load;
|
|
157
185
|
previousLoadRef.current = load;
|
|
158
|
-
|
|
186
|
+
const generation = ++loadGenerationRef.current;
|
|
187
|
+
if (!loadChanged) return;
|
|
188
|
+
if (failedRef.current) {
|
|
189
|
+
currentExportRef.current = null;
|
|
190
|
+
setReplacement(null);
|
|
159
191
|
setRetryRevision((revision) => revision + 1);
|
|
192
|
+
return;
|
|
160
193
|
}
|
|
161
|
-
|
|
194
|
+
Promise.resolve().then(load).then(
|
|
195
|
+
(module) => {
|
|
196
|
+
if (generation !== loadGenerationRef.current) return;
|
|
197
|
+
const getFamily = globalThis[/* @__PURE__ */ Symbol.for("tempo.react-refresh.family")];
|
|
198
|
+
if (typeof getFamily === "function") {
|
|
199
|
+
const family = getFamily(currentExportRef.current);
|
|
200
|
+
if (family && family === getFamily(module.default)) return;
|
|
201
|
+
}
|
|
202
|
+
currentExportRef.current = module.default;
|
|
203
|
+
setReplacement(() => module.default);
|
|
204
|
+
},
|
|
205
|
+
(error) => {
|
|
206
|
+
if (generation !== loadGenerationRef.current) return;
|
|
207
|
+
getCanvasHostRecoveryFeed().publish({
|
|
208
|
+
type: "module-load-failure",
|
|
209
|
+
path: canvasPath,
|
|
210
|
+
message: error instanceof Error ? error.message : String(error)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
return () => {
|
|
215
|
+
++loadGenerationRef.current;
|
|
216
|
+
};
|
|
217
|
+
}, [load, canvasPath]);
|
|
162
218
|
useEffect(
|
|
163
219
|
() => () => {
|
|
164
220
|
clearCanvasImportError(canvasPath);
|
|
@@ -170,7 +226,7 @@ function CanvasImportBoundary({
|
|
|
170
226
|
[canvasPath, registerCanvasProblemScope]
|
|
171
227
|
);
|
|
172
228
|
return /* @__PURE__ */ jsx(CanvasImportErrorBoundary, { reportError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(CanvasPendingMarker, {}), children: /* @__PURE__ */ jsxs(CanvasContext, { path: canvasPath, children: [
|
|
173
|
-
/* @__PURE__ */ jsx(LazyCanvas, {}),
|
|
229
|
+
/* @__PURE__ */ jsx(LazyCanvas, { replacement }),
|
|
174
230
|
/* @__PURE__ */ jsx(CanvasCommitSignal, { onCommit: markCommitted })
|
|
175
231
|
] }) }) }, retryRevision);
|
|
176
232
|
}
|
|
@@ -483,7 +539,7 @@ function readRenderRequest(commandType, payload) {
|
|
|
483
539
|
importName: importName ?? target.storyboardId ?? target.renderId,
|
|
484
540
|
...props ? { props } : {},
|
|
485
541
|
...readOptionalSize(payload),
|
|
486
|
-
|
|
542
|
+
...isV1CanvasClient() ? v1RenderRequestSize(payload) : {}
|
|
487
543
|
};
|
|
488
544
|
}
|
|
489
545
|
function readWatchId(commandType, payload) {
|
|
@@ -497,7 +553,7 @@ function readWatchId(commandType, payload) {
|
|
|
497
553
|
// canvas/canvas-host-render-state.ts
|
|
498
554
|
var propsMatch = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
|
|
499
555
|
function renderRequestMatchesEntry(entry, request) {
|
|
500
|
-
return entry?.importPath === request.importPath && entry.importName === request.importName && entry.width === request.width && entry.height === request.height && entry.intrinsicSize === request.intrinsicSize && propsMatch(entry.props, request.props);
|
|
556
|
+
return entry?.importPath === request.importPath && entry.importName === request.importName && entry.width === request.width && entry.height === request.height && (!isV1CanvasClient() || entry.intrinsicSize === request.intrinsicSize) && propsMatch(entry.props, request.props);
|
|
501
557
|
}
|
|
502
558
|
function renderRequestTargetsEntry(entry, request) {
|
|
503
559
|
return entry?.importPath === request.importPath && entry.importName === request.importName && propsMatch(entry.props, request.props);
|
|
@@ -516,7 +572,7 @@ function acquireRender(entries, request) {
|
|
|
516
572
|
}
|
|
517
573
|
function releaseRender(entries, renderId, maxCached, now = Date.now()) {
|
|
518
574
|
const current = entries.get(renderId);
|
|
519
|
-
if (!current) return
|
|
575
|
+
if (!current) return entries;
|
|
520
576
|
const next = new Map(entries);
|
|
521
577
|
const activeCount = Math.max(0, current.activeCount - 1);
|
|
522
578
|
if (activeCount > 0) {
|
|
@@ -532,11 +588,11 @@ function releaseRender(entries, renderId, maxCached, now = Date.now()) {
|
|
|
532
588
|
return evictCachedRenders(next, maxCached);
|
|
533
589
|
}
|
|
534
590
|
function evictCachedRenders(entries, maxCached) {
|
|
591
|
+
const cached = [...entries.values()].filter((entry) => entry.status === "cached").sort((a, b) => (a.lastInactiveAt ?? 0) - (b.lastInactiveAt ?? 0));
|
|
592
|
+
const evicted = cached.slice(0, Math.max(0, cached.length - maxCached));
|
|
593
|
+
if (evicted.length === 0) return entries;
|
|
535
594
|
const next = new Map(entries);
|
|
536
|
-
|
|
537
|
-
for (const entry of cached.slice(0, Math.max(0, cached.length - maxCached))) {
|
|
538
|
-
next.delete(entry.renderId);
|
|
539
|
-
}
|
|
595
|
+
for (const entry of evicted) next.delete(entry.renderId);
|
|
540
596
|
return next;
|
|
541
597
|
}
|
|
542
598
|
function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
|
|
@@ -553,21 +609,33 @@ function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
|
|
|
553
609
|
maxCached
|
|
554
610
|
};
|
|
555
611
|
}
|
|
556
|
-
function
|
|
557
|
-
|
|
612
|
+
function sameMap(previous, next, same) {
|
|
613
|
+
if (!previous || previous.size !== next.size) return false;
|
|
614
|
+
for (const [id, value] of next) {
|
|
615
|
+
const before = previous.get(id);
|
|
616
|
+
if (before === void 0 || !same(before, value)) return false;
|
|
617
|
+
}
|
|
618
|
+
return true;
|
|
558
619
|
}
|
|
559
|
-
function
|
|
560
|
-
|
|
620
|
+
function buildRenderStatusMap(entries, previous) {
|
|
621
|
+
const next = new Map([...entries].map(([id, entry]) => [id, entry.status]));
|
|
622
|
+
return previous && sameMap(previous, next, (a, b) => a === b) ? previous : next;
|
|
623
|
+
}
|
|
624
|
+
function buildRenderSizeMap(entries, previous) {
|
|
625
|
+
const v1Client = isV1CanvasClient();
|
|
626
|
+
const next = new Map(
|
|
561
627
|
[...entries].map(([id, entry]) => [
|
|
562
628
|
id,
|
|
563
629
|
{
|
|
564
630
|
width: entry.width,
|
|
565
631
|
height: entry.height,
|
|
566
|
-
|
|
567
|
-
|
|
632
|
+
revision: entry.revision,
|
|
633
|
+
...v1Client ? { intrinsicSize: entry.intrinsicSize } : {}
|
|
568
634
|
}
|
|
569
635
|
])
|
|
570
636
|
);
|
|
637
|
+
const sameSize = (a, b) => a.width === b.width && a.height === b.height && a.revision === b.revision && (!v1Client || a.intrinsicSize === b.intrinsicSize);
|
|
638
|
+
return previous && sameMap(previous, next, sameSize) ? previous : next;
|
|
571
639
|
}
|
|
572
640
|
|
|
573
641
|
// canvas/source-identity.ts
|
|
@@ -1093,8 +1161,11 @@ var FAILED_RELOAD_PROBE_DELAYS_MS = [50, 400, 1600];
|
|
|
1093
1161
|
async function moduleTransformSucceeds(path) {
|
|
1094
1162
|
const [pathname, query = ""] = path.split("?");
|
|
1095
1163
|
const url = `${pathname}?${query ? `${query}&` : ""}t=${Date.now()}`;
|
|
1096
|
-
const response = await fetch(url, {
|
|
1097
|
-
|
|
1164
|
+
const response = await fetch(url, {
|
|
1165
|
+
cache: "no-store",
|
|
1166
|
+
headers: { Accept: "application/javascript" }
|
|
1167
|
+
});
|
|
1168
|
+
return response.ok && /javascript/i.test(response.headers.get("content-type") ?? "");
|
|
1098
1169
|
}
|
|
1099
1170
|
async function compileErrorFileStillBroken(file) {
|
|
1100
1171
|
const cleaned = file.replace(/:\d+(?::\d+)?$/, "");
|
|
@@ -1120,13 +1191,24 @@ function isProjectedViteProblemSourceKind(sourceKind) {
|
|
|
1120
1191
|
function createProblem(sourceKind, error, details = {}) {
|
|
1121
1192
|
return {
|
|
1122
1193
|
sourceKind,
|
|
1123
|
-
|
|
1124
|
-
stack: error instanceof Error ? error.stack : void 0,
|
|
1194
|
+
...describeError(error),
|
|
1125
1195
|
frameUrl: typeof window === "undefined" ? void 0 : window.location.href,
|
|
1126
1196
|
timestamp: Date.now(),
|
|
1127
1197
|
...details
|
|
1128
1198
|
};
|
|
1129
1199
|
}
|
|
1200
|
+
function describeError(error) {
|
|
1201
|
+
if (!(error instanceof Error)) return { message: String(error) };
|
|
1202
|
+
const cause = error.cause;
|
|
1203
|
+
if (cause === void 0 || cause === null) {
|
|
1204
|
+
return { message: error.message, stack: error.stack };
|
|
1205
|
+
}
|
|
1206
|
+
const inner = describeError(cause);
|
|
1207
|
+
return {
|
|
1208
|
+
message: `${error.message} Cause: ${inner.message}`,
|
|
1209
|
+
stack: inner.stack ?? error.stack
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1130
1212
|
function findRenderIdsForProblem(problem, registered = [], includeDom = true) {
|
|
1131
1213
|
const observed = [
|
|
1132
1214
|
...registered
|
|
@@ -1207,9 +1289,13 @@ function uniqueRenderIds(matches) {
|
|
|
1207
1289
|
function normalizeCanvasPath(value) {
|
|
1208
1290
|
return value.trim();
|
|
1209
1291
|
}
|
|
1292
|
+
function isRecoveredAdmissionBudgetError(error) {
|
|
1293
|
+
return error instanceof Error && error.cause instanceof AdmissionBudgetError;
|
|
1294
|
+
}
|
|
1210
1295
|
function installHostProblemCapture(tracker) {
|
|
1211
1296
|
const onError = (event) => {
|
|
1212
1297
|
if (event.target instanceof Element) return;
|
|
1298
|
+
if (isRecoveredAdmissionBudgetError(event.error)) return;
|
|
1213
1299
|
tracker.reportProblemNearRender(
|
|
1214
1300
|
"page-error",
|
|
1215
1301
|
event.error ?? event.message,
|
|
@@ -1508,10 +1594,8 @@ function setRuntimeWatchPaused(watch, paused, resumeOptions) {
|
|
|
1508
1594
|
}
|
|
1509
1595
|
}
|
|
1510
1596
|
}
|
|
1511
|
-
function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId = null) {
|
|
1512
|
-
const [renderEntriesById, setRenderEntriesById] = useState2(
|
|
1513
|
-
() => /* @__PURE__ */ new Map()
|
|
1514
|
-
);
|
|
1597
|
+
function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId = null, registerCanvas) {
|
|
1598
|
+
const [renderEntriesById, setRenderEntriesById] = useState2(() => /* @__PURE__ */ new Map());
|
|
1515
1599
|
const [watchRequestsById, setWatchRequestsById] = useState2(
|
|
1516
1600
|
() => /* @__PURE__ */ new Map()
|
|
1517
1601
|
);
|
|
@@ -1519,11 +1603,15 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
|
|
|
1519
1603
|
() => /* @__PURE__ */ new Map()
|
|
1520
1604
|
);
|
|
1521
1605
|
const renderEntriesRef = useRef2(renderEntriesById);
|
|
1606
|
+
const renderStatusRef = useRef2();
|
|
1607
|
+
const renderSizeRef = useRef2();
|
|
1522
1608
|
const watchRequestsRef = useRef2(watchRequestsById);
|
|
1523
1609
|
const registeredCanvasPathsRef = useRef2([]);
|
|
1524
1610
|
registeredCanvasPathsRef.current = registeredCanvasPaths;
|
|
1525
1611
|
const urlPinnedRenderIdRef = useRef2(null);
|
|
1526
1612
|
urlPinnedRenderIdRef.current = urlPinnedRenderId;
|
|
1613
|
+
const registerCanvasRef = useRef2(registerCanvas);
|
|
1614
|
+
registerCanvasRef.current = registerCanvas;
|
|
1527
1615
|
const maxCachedRef = useRef2(DEFAULT_MAX_CACHED_RENDERS);
|
|
1528
1616
|
const legacyHealthRef = useRef2(createLegacyHostHealth());
|
|
1529
1617
|
const renderedRenderIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
@@ -1569,6 +1657,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
|
|
|
1569
1657
|
(update) => {
|
|
1570
1658
|
setRenderEntriesById((entries) => {
|
|
1571
1659
|
const next = update(entries);
|
|
1660
|
+
if (next === entries) return entries;
|
|
1572
1661
|
renderEntriesRef.current = next;
|
|
1573
1662
|
problemTrackerRef.current.syncRenderSourcePaths([...next.values()]);
|
|
1574
1663
|
for (const renderId of [...renderedRenderIdsRef.current]) {
|
|
@@ -1658,11 +1747,14 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
|
|
|
1658
1747
|
[stopRuntimeWatch]
|
|
1659
1748
|
);
|
|
1660
1749
|
const buildState = useCallback2(
|
|
1661
|
-
() =>
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1750
|
+
() => ({
|
|
1751
|
+
...registerCanvasRef.current ? { incrementalCanvasRegistration: true } : {},
|
|
1752
|
+
...buildRenderStatePayload(
|
|
1753
|
+
renderEntriesRef.current,
|
|
1754
|
+
maxCachedRef.current,
|
|
1755
|
+
registeredCanvasPathsRef.current
|
|
1756
|
+
)
|
|
1757
|
+
}),
|
|
1666
1758
|
[]
|
|
1667
1759
|
);
|
|
1668
1760
|
const markStoryboardRendered = useCallback2((storyboardId) => {
|
|
@@ -2053,6 +2145,12 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
|
|
|
2053
2145
|
ack();
|
|
2054
2146
|
return;
|
|
2055
2147
|
}
|
|
2148
|
+
if (command.type === "render-pool:register-canvas") {
|
|
2149
|
+
if (!registerCanvasRef.current || typeof payload.canvasPath !== "string" || !payload.canvasPath.trim() || typeof payload.moduleUrl !== "string")
|
|
2150
|
+
throw new Error("Invalid canvas registration command");
|
|
2151
|
+
void registerCanvasRef.current(payload.canvasPath, payload.moduleUrl).then(ack).catch(postAsyncError);
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2056
2154
|
if (command.type === "render-pool:list") {
|
|
2057
2155
|
post({
|
|
2058
2156
|
type: "render-pool:state",
|
|
@@ -2176,11 +2274,17 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
|
|
|
2176
2274
|
]);
|
|
2177
2275
|
return {
|
|
2178
2276
|
renderStatusById: useMemo2(
|
|
2179
|
-
() => buildRenderStatusMap(
|
|
2277
|
+
() => renderStatusRef.current = buildRenderStatusMap(
|
|
2278
|
+
renderEntriesById,
|
|
2279
|
+
renderStatusRef.current
|
|
2280
|
+
),
|
|
2180
2281
|
[renderEntriesById]
|
|
2181
2282
|
),
|
|
2182
2283
|
renderSizeById: useMemo2(
|
|
2183
|
-
() => buildRenderSizeMap(
|
|
2284
|
+
() => renderSizeRef.current = buildRenderSizeMap(
|
|
2285
|
+
renderEntriesById,
|
|
2286
|
+
renderSizeRef.current
|
|
2287
|
+
),
|
|
2184
2288
|
[renderEntriesById]
|
|
2185
2289
|
),
|
|
2186
2290
|
markStoryboardRendered,
|
|
@@ -2247,25 +2351,15 @@ function readDirectUrlDimension(value) {
|
|
|
2247
2351
|
}
|
|
2248
2352
|
return unit && unit !== "px" ? `${numberValue}${unit}` : numberValue;
|
|
2249
2353
|
}
|
|
2250
|
-
function readDirectUrlFlag(value) {
|
|
2251
|
-
if (value === null) return false;
|
|
2252
|
-
const normalized = value.trim().toLowerCase();
|
|
2253
|
-
return normalized !== "0" && normalized !== "false";
|
|
2254
|
-
}
|
|
2255
2354
|
function readDirectUrlSize(params) {
|
|
2355
|
+
if (isV1CanvasClient())
|
|
2356
|
+
return v1DirectUrlSize(params, readDirectUrlDimension);
|
|
2256
2357
|
const width = params.get("width")?.trim();
|
|
2257
2358
|
const height = params.get("height")?.trim();
|
|
2258
|
-
|
|
2259
|
-
if (!width && !height) {
|
|
2260
|
-
return intrinsicSize ? { intrinsicSize: true, revision: 1 } : void 0;
|
|
2261
|
-
}
|
|
2262
|
-
if (!width || !height) {
|
|
2263
|
-
throw new Error("Direct URL width and height must be provided together");
|
|
2264
|
-
}
|
|
2359
|
+
if (!width || !height) return { revision: 1 };
|
|
2265
2360
|
return {
|
|
2266
2361
|
width: readDirectUrlDimension(width),
|
|
2267
2362
|
height: readDirectUrlDimension(height),
|
|
2268
|
-
...intrinsicSize ? { intrinsicSize: true } : {},
|
|
2269
2363
|
revision: 1
|
|
2270
2364
|
};
|
|
2271
2365
|
}
|
|
@@ -2291,6 +2385,7 @@ function readDirectUrlSearch() {
|
|
|
2291
2385
|
function CanvasHost({
|
|
2292
2386
|
children,
|
|
2293
2387
|
canvasModules,
|
|
2388
|
+
incremental = false,
|
|
2294
2389
|
activeStoryboardIds,
|
|
2295
2390
|
isStoryboardActive
|
|
2296
2391
|
}) {
|
|
@@ -2299,19 +2394,77 @@ function CanvasHost({
|
|
|
2299
2394
|
"CanvasHost cannot receive both children and canvasModules."
|
|
2300
2395
|
);
|
|
2301
2396
|
}
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2397
|
+
const [admitted, setAdmitted] = useState3([]);
|
|
2398
|
+
const pendingAdmissions = useRef3(
|
|
2399
|
+
/* @__PURE__ */ new Map()
|
|
2400
|
+
);
|
|
2401
|
+
const admittedRef = useRef3(admitted);
|
|
2402
|
+
const modules = useMemo3(() => {
|
|
2403
|
+
const all = new Map(
|
|
2404
|
+
canvasModules?.map((module) => [module.canvasPath, module])
|
|
2405
|
+
);
|
|
2406
|
+
for (const module of admitted)
|
|
2407
|
+
if (!all.has(module.canvasPath)) all.set(module.canvasPath, module);
|
|
2408
|
+
return [...all.values()];
|
|
2409
|
+
}, [canvasModules, admitted]);
|
|
2410
|
+
const registerCanvas = useCallback3((canvasPath, rawUrl) => {
|
|
2411
|
+
const url = new URL(rawUrl, window.location.href);
|
|
2412
|
+
if (url.origin !== window.location.origin || !url.pathname.startsWith("/@fs/")) {
|
|
2413
|
+
return Promise.reject(
|
|
2414
|
+
new Error("Canvas registration requires a same-origin Vite module URL")
|
|
2415
|
+
);
|
|
2416
|
+
}
|
|
2417
|
+
if (admittedRef.current.some((module) => module.canvasPath === canvasPath))
|
|
2418
|
+
return Promise.resolve();
|
|
2419
|
+
return new Promise((resolve, reject) => {
|
|
2420
|
+
const pending = pendingAdmissions.current.get(canvasPath) ?? [];
|
|
2421
|
+
pending.push({ resolve, reject });
|
|
2422
|
+
pendingAdmissions.current.set(canvasPath, pending);
|
|
2423
|
+
setAdmitted(
|
|
2424
|
+
(current) => current.some((module) => module.canvasPath === canvasPath) ? current : [
|
|
2425
|
+
...current,
|
|
2426
|
+
{ canvasPath, load: () => import(
|
|
2427
|
+
/* @vite-ignore */
|
|
2428
|
+
url.href
|
|
2429
|
+
) }
|
|
2430
|
+
]
|
|
2431
|
+
);
|
|
2432
|
+
});
|
|
2433
|
+
}, []);
|
|
2434
|
+
useLayoutEffect3(() => {
|
|
2435
|
+
admittedRef.current = admitted;
|
|
2436
|
+
for (const module of admitted) {
|
|
2437
|
+
const pending = pendingAdmissions.current.get(module.canvasPath);
|
|
2438
|
+
pendingAdmissions.current.delete(module.canvasPath);
|
|
2439
|
+
pending?.forEach(({ resolve }) => resolve());
|
|
2440
|
+
}
|
|
2441
|
+
}, [admitted]);
|
|
2442
|
+
useEffect3(
|
|
2443
|
+
() => () => {
|
|
2444
|
+
for (const pending of pendingAdmissions.current.values())
|
|
2445
|
+
pending.forEach(
|
|
2446
|
+
({ reject }) => reject(new Error("Canvas host disposed during registration"))
|
|
2447
|
+
);
|
|
2448
|
+
pendingAdmissions.current.clear();
|
|
2449
|
+
},
|
|
2450
|
+
[]
|
|
2309
2451
|
);
|
|
2310
2452
|
const directUrlSearch = useSyncExternalStore(
|
|
2311
2453
|
subscribeDirectUrlSearch,
|
|
2312
2454
|
readDirectUrlSearch,
|
|
2313
2455
|
() => ""
|
|
2314
2456
|
);
|
|
2457
|
+
const demandRegistration = incremental && new URLSearchParams(directUrlSearch).get("canvasRegistration") === "incremental";
|
|
2458
|
+
const registeredCanvasPaths = useMemo3(
|
|
2459
|
+
() => [
|
|
2460
|
+
...new Set(
|
|
2461
|
+
(demandRegistration ? admitted : modules).map(
|
|
2462
|
+
({ canvasPath }) => canvasPath.trim()
|
|
2463
|
+
)
|
|
2464
|
+
)
|
|
2465
|
+
].filter(Boolean),
|
|
2466
|
+
[modules, admitted, demandRegistration]
|
|
2467
|
+
);
|
|
2315
2468
|
const directUrlRender = useMemo3(() => {
|
|
2316
2469
|
return readDirectUrlRender();
|
|
2317
2470
|
}, [directUrlSearch]);
|
|
@@ -2327,7 +2480,8 @@ function CanvasHost({
|
|
|
2327
2480
|
registerCanvasProblemScope
|
|
2328
2481
|
} = useCanvasHostPostMessage(
|
|
2329
2482
|
registeredCanvasPaths,
|
|
2330
|
-
directUrlRender?.renderId ?? null
|
|
2483
|
+
directUrlRender?.renderId ?? null,
|
|
2484
|
+
incremental ? registerCanvas : void 0
|
|
2331
2485
|
);
|
|
2332
2486
|
useEffect3(() => {
|
|
2333
2487
|
if (typeof document === "undefined") return;
|
|
@@ -2342,10 +2496,14 @@ function CanvasHost({
|
|
|
2342
2496
|
[directUrlSearch]
|
|
2343
2497
|
);
|
|
2344
2498
|
const mountedCanvasModules = useMemo3(
|
|
2345
|
-
() => directUrlIdle ? [] : directUrlRender ?
|
|
2499
|
+
() => directUrlIdle ? [] : directUrlRender ? modules.filter(
|
|
2346
2500
|
({ canvasPath }) => canvasPath.trim() === directUrlRender.canvasPath
|
|
2347
|
-
) :
|
|
2348
|
-
|
|
2501
|
+
) : demandRegistration ? modules.filter(
|
|
2502
|
+
(module) => admitted.some(
|
|
2503
|
+
(entry) => entry.canvasPath === module.canvasPath
|
|
2504
|
+
)
|
|
2505
|
+
) : modules,
|
|
2506
|
+
[modules, admitted, demandRegistration, directUrlIdle, directUrlRender]
|
|
2349
2507
|
);
|
|
2350
2508
|
const runtime = useMemo3(
|
|
2351
2509
|
() => ({
|
|
@@ -2395,16 +2553,20 @@ function CanvasHost({
|
|
|
2395
2553
|
renderStatusById
|
|
2396
2554
|
]
|
|
2397
2555
|
);
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
mountedCanvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
|
|
2556
|
+
const canvasBoundaries = useMemo3(
|
|
2557
|
+
() => mountedCanvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
|
|
2401
2558
|
CanvasImportBoundary,
|
|
2402
2559
|
{
|
|
2403
2560
|
canvasPath,
|
|
2404
2561
|
load
|
|
2405
2562
|
},
|
|
2406
2563
|
canvasPath
|
|
2407
|
-
))
|
|
2564
|
+
)),
|
|
2565
|
+
[mountedCanvasModules]
|
|
2566
|
+
);
|
|
2567
|
+
return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
|
|
2568
|
+
children,
|
|
2569
|
+
canvasBoundaries
|
|
2408
2570
|
] });
|
|
2409
2571
|
}
|
|
2410
2572
|
|
|
@@ -2437,6 +2599,7 @@ export {
|
|
|
2437
2599
|
getCanvasHostRuntime,
|
|
2438
2600
|
getCanvasStoryboardRenderId,
|
|
2439
2601
|
getOptionalCanvasHostRuntime,
|
|
2602
|
+
getStoryboardKey,
|
|
2440
2603
|
isTempoInteractFrameName,
|
|
2441
2604
|
stripRenderContentWrapperAttributes,
|
|
2442
2605
|
stripRenderContentWrapperFromCombinedCapture,
|