tempo-sdk 0.0.40 → 0.0.42

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.
@@ -13,10 +13,10 @@ import {
13
13
  normalizeId,
14
14
  useActiveState,
15
15
  useRequiredCanvasHost
16
- } from "../chunk-DXKG4IGS.js";
16
+ } from "../chunk-L7OESAOE.js";
17
17
  import {
18
18
  installTempoInteractProjectionSource
19
- } from "../chunk-ED5VHXXD.js";
19
+ } from "../chunk-U52RN7MP.js";
20
20
  import {
21
21
  TEMPO_INTERACT_FRAME_NAME,
22
22
  isTempoInteractFrameName
@@ -1484,7 +1484,7 @@ function setRuntimeWatchPaused(watch, paused, resumeOptions) {
1484
1484
  }
1485
1485
  }
1486
1486
  }
1487
- function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1487
+ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId = null) {
1488
1488
  const [renderEntriesById, setRenderEntriesById] = useState2(
1489
1489
  () => /* @__PURE__ */ new Map()
1490
1490
  );
@@ -1498,6 +1498,8 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1498
1498
  const watchRequestsRef = useRef2(watchRequestsById);
1499
1499
  const registeredCanvasPathsRef = useRef2([]);
1500
1500
  registeredCanvasPathsRef.current = registeredCanvasPaths;
1501
+ const urlPinnedRenderIdRef = useRef2(null);
1502
+ urlPinnedRenderIdRef.current = urlPinnedRenderId;
1501
1503
  const maxCachedRef = useRef2(DEFAULT_MAX_CACHED_RENDERS);
1502
1504
  const legacyHealthRef = useRef2(createLegacyHostHealth());
1503
1505
  const renderedRenderIdsRef = useRef2(/* @__PURE__ */ new Set());
@@ -1559,7 +1561,8 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1559
1561
  const waitForRender = useCallback2(
1560
1562
  (request) => {
1561
1563
  const current = renderEntriesRef.current.get(request.renderId);
1562
- const alreadyRendered = current?.status === "active" && renderedRenderIdsRef.current.has(request.renderId) && renderRequestMatchesEntry(current, request);
1564
+ const rendered = renderedRenderIdsRef.current.has(request.renderId);
1565
+ const alreadyRendered = rendered && (urlPinnedRenderIdRef.current === request.renderId || current?.status === "active" && renderRequestMatchesEntry(current, request));
1563
1566
  setEntries((entries) => acquireRender(entries, request));
1564
1567
  if (alreadyRendered) {
1565
1568
  return Promise.resolve();
@@ -2220,16 +2223,25 @@ function readDirectUrlDimension(value) {
2220
2223
  }
2221
2224
  return unit && unit !== "px" ? `${numberValue}${unit}` : numberValue;
2222
2225
  }
2226
+ function readDirectUrlFlag(value) {
2227
+ if (value === null) return false;
2228
+ const normalized = value.trim().toLowerCase();
2229
+ return normalized !== "0" && normalized !== "false";
2230
+ }
2223
2231
  function readDirectUrlSize(params) {
2224
2232
  const width = params.get("width")?.trim();
2225
2233
  const height = params.get("height")?.trim();
2226
- if (!width && !height) return void 0;
2234
+ const intrinsicSize = readDirectUrlFlag(params.get("intrinsicSize"));
2235
+ if (!width && !height) {
2236
+ return intrinsicSize ? { intrinsicSize: true, revision: 1 } : void 0;
2237
+ }
2227
2238
  if (!width || !height) {
2228
2239
  throw new Error("Direct URL width and height must be provided together");
2229
2240
  }
2230
2241
  return {
2231
2242
  width: readDirectUrlDimension(width),
2232
2243
  height: readDirectUrlDimension(height),
2244
+ ...intrinsicSize ? { intrinsicSize: true } : {},
2233
2245
  revision: 1
2234
2246
  };
2235
2247
  }
@@ -2271,6 +2283,14 @@ function CanvasHost({
2271
2283
  ].filter(Boolean),
2272
2284
  [canvasModules]
2273
2285
  );
2286
+ const directUrlSearch = useSyncExternalStore(
2287
+ subscribeDirectUrlSearch,
2288
+ readDirectUrlSearch,
2289
+ () => ""
2290
+ );
2291
+ const directUrlRender = useMemo3(() => {
2292
+ return readDirectUrlRender();
2293
+ }, [directUrlSearch]);
2274
2294
  const {
2275
2295
  renderStatusById,
2276
2296
  renderSizeById,
@@ -2281,19 +2301,14 @@ function CanvasHost({
2281
2301
  reportCanvasImportError,
2282
2302
  clearCanvasImportError,
2283
2303
  registerCanvasProblemScope
2284
- } = useCanvasHostPostMessage(registeredCanvasPaths);
2304
+ } = useCanvasHostPostMessage(
2305
+ registeredCanvasPaths,
2306
+ directUrlRender?.renderId ?? null
2307
+ );
2285
2308
  useEffect3(() => {
2286
2309
  if (typeof document === "undefined") return;
2287
2310
  return protectCanvasHostDocumentTitle(document);
2288
2311
  }, []);
2289
- const directUrlSearch = useSyncExternalStore(
2290
- subscribeDirectUrlSearch,
2291
- readDirectUrlSearch,
2292
- () => ""
2293
- );
2294
- const directUrlRender = useMemo3(() => {
2295
- return readDirectUrlRender();
2296
- }, [directUrlSearch]);
2297
2312
  const propActiveIds = useMemo3(
2298
2313
  () => new Set(activeStoryboardIds ?? []),
2299
2314
  [activeStoryboardIds]