tempo-sdk 0.0.35 → 0.0.38

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.
@@ -223,7 +223,7 @@ declare const TEMPO_INTERACT_FRAME_NAME = "tempo-interact-preview";
223
223
  declare function isTempoInteractFrameName(value: string): boolean;
224
224
  declare global {
225
225
  interface Window {
226
- __tempoInteractProjectionOwner?: "vite" | "electron";
226
+ __tempoInteractProjectionOwner?: "vite" | "electron" | "canvas-host";
227
227
  }
228
228
  }
229
229
 
@@ -14,14 +14,21 @@ import {
14
14
  useActiveState,
15
15
  useRequiredCanvasHost
16
16
  } from "../chunk-DXKG4IGS.js";
17
+ import {
18
+ installTempoInteractProjectionSource
19
+ } from "../chunk-FAO5QIJG.js";
17
20
  import {
18
21
  TEMPO_INTERACT_FRAME_NAME,
19
22
  isTempoInteractFrameName
20
- } from "../chunk-QXB32HG4.js";
23
+ } from "../chunk-65B52AR7.js";
21
24
  import "../chunk-ZT2REPH4.js";
22
25
 
23
26
  // canvas/canvas-host.tsx
24
- import { useEffect as useEffect3, useMemo as useMemo3 } from "react";
27
+ import {
28
+ useEffect as useEffect3,
29
+ useMemo as useMemo3,
30
+ useSyncExternalStore
31
+ } from "react";
25
32
 
26
33
  // canvas/canvas-import-boundary.tsx
27
34
  import {
@@ -149,6 +156,22 @@ function CanvasImportBoundary({
149
156
  ] }) }) }, retryRevision);
150
157
  }
151
158
 
159
+ // canvas/interact-projection-fallback.ts
160
+ function installTempoInteractProjectionFallback(owner = "electron") {
161
+ if (typeof window === "undefined" || window.parent === window || !isTempoInteractFrameName(window.name)) {
162
+ return null;
163
+ }
164
+ if (window.__tempoInteractProjectionOwner) return null;
165
+ window.__tempoInteractProjectionOwner = owner;
166
+ const stopSource = installTempoInteractProjectionSource();
167
+ return () => {
168
+ stopSource();
169
+ if (window.__tempoInteractProjectionOwner === owner) {
170
+ delete window.__tempoInteractProjectionOwner;
171
+ }
172
+ };
173
+ }
174
+
152
175
  // canvas/use-canvas-host-postmessage.ts
153
176
  import {
154
177
  useCallback as useCallback2,
@@ -2152,6 +2175,7 @@ function buildWatchBindingKey(commandType, payload) {
2152
2175
 
2153
2176
  // canvas/canvas-host.tsx
2154
2177
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2178
+ installTempoInteractProjectionFallback("canvas-host");
2155
2179
  var CANVAS_HOST_DOCUMENT_TITLE = "INTERNAL tempo-host \u2014 Tempo component host, do not interact";
2156
2180
  function protectCanvasHostDocumentTitle(doc) {
2157
2181
  const restoreTitle = () => {
@@ -2216,10 +2240,18 @@ function readDirectUrlRender() {
2216
2240
  const storyboardId = params.get("storyboardId")?.trim() ?? params.get("exportName")?.trim() ?? params.get("importName")?.trim() ?? "";
2217
2241
  if (!canvasPath || !storyboardId) return null;
2218
2242
  return {
2243
+ canvasPath,
2219
2244
  renderId: getCanvasStoryboardRenderId(canvasPath, storyboardId),
2220
2245
  size: readDirectUrlSize(params)
2221
2246
  };
2222
2247
  }
2248
+ function subscribeDirectUrlSearch(onChange) {
2249
+ window.addEventListener("popstate", onChange);
2250
+ return () => window.removeEventListener("popstate", onChange);
2251
+ }
2252
+ function readDirectUrlSearch() {
2253
+ return window.location.search;
2254
+ }
2223
2255
  function CanvasHost({
2224
2256
  children,
2225
2257
  canvasModules,
@@ -2254,15 +2286,28 @@ function CanvasHost({
2254
2286
  if (typeof document === "undefined") return;
2255
2287
  return protectCanvasHostDocumentTitle(document);
2256
2288
  }, []);
2257
- const directUrlSearch = typeof window === "undefined" ? "" : window.location.search;
2289
+ const directUrlSearch = useSyncExternalStore(
2290
+ subscribeDirectUrlSearch,
2291
+ readDirectUrlSearch,
2292
+ () => ""
2293
+ );
2258
2294
  const directUrlRender = useMemo3(() => {
2259
- void directUrlSearch;
2260
2295
  return readDirectUrlRender();
2261
2296
  }, [directUrlSearch]);
2262
2297
  const propActiveIds = useMemo3(
2263
2298
  () => new Set(activeStoryboardIds ?? []),
2264
2299
  [activeStoryboardIds]
2265
2300
  );
2301
+ const directUrlIdle = useMemo3(
2302
+ () => new URLSearchParams(directUrlSearch).has("tempoCaptureIdle"),
2303
+ [directUrlSearch]
2304
+ );
2305
+ const mountedCanvasModules = useMemo3(
2306
+ () => directUrlIdle ? [] : directUrlRender ? canvasModules?.filter(
2307
+ ({ canvasPath }) => canvasPath.trim() === directUrlRender.canvasPath
2308
+ ) : canvasModules,
2309
+ [canvasModules, directUrlIdle, directUrlRender]
2310
+ );
2266
2311
  const runtime = useMemo3(
2267
2312
  () => ({
2268
2313
  getStoryboardStatus(storyboardId) {
@@ -2308,7 +2353,7 @@ function CanvasHost({
2308
2353
  );
2309
2354
  return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
2310
2355
  children,
2311
- canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
2356
+ mountedCanvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
2312
2357
  CanvasImportBoundary,
2313
2358
  {
2314
2359
  canvasPath,