tempo-sdk 0.0.40 → 0.0.44
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/canvas/index.js +52 -17
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +1 -1
- package/dist/canvas/svelte.js +1 -1
- package/dist/{chunk-DXKG4IGS.js → chunk-KQHC77IF.js} +17 -3
- package/dist/chunk-KQHC77IF.js.map +1 -0
- package/dist/{chunk-IGFW4HE7.js → chunk-MUW75SOS.js} +3 -3
- package/dist/{chunk-IGFW4HE7.js.map → chunk-MUW75SOS.js.map} +1 -1
- package/dist/{chunk-ED5VHXXD.js → chunk-U52RN7MP.js} +18 -11
- package/dist/chunk-U52RN7MP.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs.cjs +2 -2
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/svelte.js +6 -1
- package/dist/svelte.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-DXKG4IGS.js.map +0 -1
- package/dist/chunk-ED5VHXXD.js.map +0 -1
package/dist/canvas/index.js
CHANGED
|
@@ -12,11 +12,12 @@ import {
|
|
|
12
12
|
getStoryboardPortalSelectors,
|
|
13
13
|
normalizeId,
|
|
14
14
|
useActiveState,
|
|
15
|
+
useRenderErrorRecovery,
|
|
15
16
|
useRequiredCanvasHost
|
|
16
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-KQHC77IF.js";
|
|
17
18
|
import {
|
|
18
19
|
installTempoInteractProjectionSource
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-U52RN7MP.js";
|
|
20
21
|
import {
|
|
21
22
|
TEMPO_INTERACT_FRAME_NAME,
|
|
22
23
|
isTempoInteractFrameName
|
|
@@ -104,15 +105,26 @@ function CanvasImportBoundary({
|
|
|
104
105
|
reportCanvasImportError
|
|
105
106
|
} = useRequiredCanvasHost();
|
|
106
107
|
const failedRef = useRef(false);
|
|
108
|
+
const importRejectedRef = useRef(false);
|
|
107
109
|
const loadRef = useRef(load);
|
|
108
110
|
const previousLoadRef = useRef(load);
|
|
109
111
|
loadRef.current = load;
|
|
110
112
|
const [retryRevision, setRetryRevision] = useState(0);
|
|
113
|
+
const retryRenderNow = useCallback(() => {
|
|
114
|
+
if (!failedRef.current || importRejectedRef.current) return false;
|
|
115
|
+
setRetryRevision((revision) => revision + 1);
|
|
116
|
+
return true;
|
|
117
|
+
}, []);
|
|
118
|
+
const { noteRenderError, noteRecovered } = useRenderErrorRecovery(retryRenderNow);
|
|
111
119
|
const lazyIdentity = `${canvasPath}:${retryRevision}`;
|
|
112
120
|
const LazyCanvas = useMemo(() => {
|
|
113
121
|
void lazyIdentity;
|
|
114
122
|
return lazy(
|
|
115
|
-
() => Promise.resolve().then(() =>
|
|
123
|
+
() => Promise.resolve().then(() => {
|
|
124
|
+
importRejectedRef.current = false;
|
|
125
|
+
return loadRef.current();
|
|
126
|
+
}).catch((error) => {
|
|
127
|
+
importRejectedRef.current = true;
|
|
116
128
|
getCanvasHostRecoveryFeed().publish({
|
|
117
129
|
type: "module-load-failure",
|
|
118
130
|
path: canvasPath,
|
|
@@ -125,14 +137,17 @@ function CanvasImportBoundary({
|
|
|
125
137
|
const reportError = useCallback(
|
|
126
138
|
(error) => {
|
|
127
139
|
failedRef.current = true;
|
|
140
|
+
if (importRejectedRef.current) noteRecovered();
|
|
141
|
+
else noteRenderError();
|
|
128
142
|
reportCanvasImportError(canvasPath, error);
|
|
129
143
|
},
|
|
130
|
-
[canvasPath, reportCanvasImportError]
|
|
144
|
+
[canvasPath, noteRecovered, noteRenderError, reportCanvasImportError]
|
|
131
145
|
);
|
|
132
146
|
const markCommitted = useCallback(() => {
|
|
133
147
|
failedRef.current = false;
|
|
148
|
+
noteRecovered();
|
|
134
149
|
clearCanvasImportError(canvasPath);
|
|
135
|
-
}, [canvasPath, clearCanvasImportError]);
|
|
150
|
+
}, [canvasPath, clearCanvasImportError, noteRecovered]);
|
|
136
151
|
useEffect(() => {
|
|
137
152
|
const loadChanged = previousLoadRef.current !== load;
|
|
138
153
|
previousLoadRef.current = load;
|
|
@@ -1484,7 +1499,7 @@ function setRuntimeWatchPaused(watch, paused, resumeOptions) {
|
|
|
1484
1499
|
}
|
|
1485
1500
|
}
|
|
1486
1501
|
}
|
|
1487
|
-
function useCanvasHostPostMessage(registeredCanvasPaths = []) {
|
|
1502
|
+
function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId = null) {
|
|
1488
1503
|
const [renderEntriesById, setRenderEntriesById] = useState2(
|
|
1489
1504
|
() => /* @__PURE__ */ new Map()
|
|
1490
1505
|
);
|
|
@@ -1498,6 +1513,8 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
|
|
|
1498
1513
|
const watchRequestsRef = useRef2(watchRequestsById);
|
|
1499
1514
|
const registeredCanvasPathsRef = useRef2([]);
|
|
1500
1515
|
registeredCanvasPathsRef.current = registeredCanvasPaths;
|
|
1516
|
+
const urlPinnedRenderIdRef = useRef2(null);
|
|
1517
|
+
urlPinnedRenderIdRef.current = urlPinnedRenderId;
|
|
1501
1518
|
const maxCachedRef = useRef2(DEFAULT_MAX_CACHED_RENDERS);
|
|
1502
1519
|
const legacyHealthRef = useRef2(createLegacyHostHealth());
|
|
1503
1520
|
const renderedRenderIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
@@ -1559,7 +1576,8 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
|
|
|
1559
1576
|
const waitForRender = useCallback2(
|
|
1560
1577
|
(request) => {
|
|
1561
1578
|
const current = renderEntriesRef.current.get(request.renderId);
|
|
1562
|
-
const
|
|
1579
|
+
const rendered = renderedRenderIdsRef.current.has(request.renderId);
|
|
1580
|
+
const alreadyRendered = rendered && (urlPinnedRenderIdRef.current === request.renderId || current?.status === "active" && renderRequestMatchesEntry(current, request));
|
|
1563
1581
|
setEntries((entries) => acquireRender(entries, request));
|
|
1564
1582
|
if (alreadyRendered) {
|
|
1565
1583
|
return Promise.resolve();
|
|
@@ -2220,16 +2238,25 @@ function readDirectUrlDimension(value) {
|
|
|
2220
2238
|
}
|
|
2221
2239
|
return unit && unit !== "px" ? `${numberValue}${unit}` : numberValue;
|
|
2222
2240
|
}
|
|
2241
|
+
function readDirectUrlFlag(value) {
|
|
2242
|
+
if (value === null) return false;
|
|
2243
|
+
const normalized = value.trim().toLowerCase();
|
|
2244
|
+
return normalized !== "0" && normalized !== "false";
|
|
2245
|
+
}
|
|
2223
2246
|
function readDirectUrlSize(params) {
|
|
2224
2247
|
const width = params.get("width")?.trim();
|
|
2225
2248
|
const height = params.get("height")?.trim();
|
|
2226
|
-
|
|
2249
|
+
const intrinsicSize = readDirectUrlFlag(params.get("intrinsicSize"));
|
|
2250
|
+
if (!width && !height) {
|
|
2251
|
+
return intrinsicSize ? { intrinsicSize: true, revision: 1 } : void 0;
|
|
2252
|
+
}
|
|
2227
2253
|
if (!width || !height) {
|
|
2228
2254
|
throw new Error("Direct URL width and height must be provided together");
|
|
2229
2255
|
}
|
|
2230
2256
|
return {
|
|
2231
2257
|
width: readDirectUrlDimension(width),
|
|
2232
2258
|
height: readDirectUrlDimension(height),
|
|
2259
|
+
...intrinsicSize ? { intrinsicSize: true } : {},
|
|
2233
2260
|
revision: 1
|
|
2234
2261
|
};
|
|
2235
2262
|
}
|
|
@@ -2271,6 +2298,14 @@ function CanvasHost({
|
|
|
2271
2298
|
].filter(Boolean),
|
|
2272
2299
|
[canvasModules]
|
|
2273
2300
|
);
|
|
2301
|
+
const directUrlSearch = useSyncExternalStore(
|
|
2302
|
+
subscribeDirectUrlSearch,
|
|
2303
|
+
readDirectUrlSearch,
|
|
2304
|
+
() => ""
|
|
2305
|
+
);
|
|
2306
|
+
const directUrlRender = useMemo3(() => {
|
|
2307
|
+
return readDirectUrlRender();
|
|
2308
|
+
}, [directUrlSearch]);
|
|
2274
2309
|
const {
|
|
2275
2310
|
renderStatusById,
|
|
2276
2311
|
renderSizeById,
|
|
@@ -2281,19 +2316,14 @@ function CanvasHost({
|
|
|
2281
2316
|
reportCanvasImportError,
|
|
2282
2317
|
clearCanvasImportError,
|
|
2283
2318
|
registerCanvasProblemScope
|
|
2284
|
-
} = useCanvasHostPostMessage(
|
|
2319
|
+
} = useCanvasHostPostMessage(
|
|
2320
|
+
registeredCanvasPaths,
|
|
2321
|
+
directUrlRender?.renderId ?? null
|
|
2322
|
+
);
|
|
2285
2323
|
useEffect3(() => {
|
|
2286
2324
|
if (typeof document === "undefined") return;
|
|
2287
2325
|
return protectCanvasHostDocumentTitle(document);
|
|
2288
2326
|
}, []);
|
|
2289
|
-
const directUrlSearch = useSyncExternalStore(
|
|
2290
|
-
subscribeDirectUrlSearch,
|
|
2291
|
-
readDirectUrlSearch,
|
|
2292
|
-
() => ""
|
|
2293
|
-
);
|
|
2294
|
-
const directUrlRender = useMemo3(() => {
|
|
2295
|
-
return readDirectUrlRender();
|
|
2296
|
-
}, [directUrlSearch]);
|
|
2297
2327
|
const propActiveIds = useMemo3(
|
|
2298
2328
|
() => new Set(activeStoryboardIds ?? []),
|
|
2299
2329
|
[activeStoryboardIds]
|
|
@@ -2328,6 +2358,11 @@ function CanvasHost({
|
|
|
2328
2358
|
const normalizedId = normalizeId(storyboardId, "Storyboard id");
|
|
2329
2359
|
return directUrlRender?.renderId === normalizedId ? { left: 0, top: 0 } : void 0;
|
|
2330
2360
|
},
|
|
2361
|
+
prepareStoryboardCapture(storyboardId) {
|
|
2362
|
+
if (directUrlRender?.renderId !== storyboardId) return;
|
|
2363
|
+
const captureGlobal = globalThis;
|
|
2364
|
+
captureGlobal.__tempoResetCaptureDeterminism?.();
|
|
2365
|
+
},
|
|
2331
2366
|
markStoryboardRendered,
|
|
2332
2367
|
markStoryboardUnmounted,
|
|
2333
2368
|
reportStoryboardError,
|