tempo-sdk 0.0.42 → 0.0.45

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.
@@ -1,3 +1,6 @@
1
+ import {
2
+ VITE_ERROR_FEED_KEY
3
+ } from "../chunk-K3EYTZLL.js";
1
4
  import {
2
5
  Canvas,
3
6
  CanvasContext,
@@ -12,16 +15,17 @@ import {
12
15
  getStoryboardPortalSelectors,
13
16
  normalizeId,
14
17
  useActiveState,
18
+ useRenderErrorRecovery,
15
19
  useRequiredCanvasHost
16
- } from "../chunk-L7OESAOE.js";
20
+ } from "../chunk-7O6DPEMF.js";
17
21
  import {
18
22
  installTempoInteractProjectionSource
19
- } from "../chunk-U52RN7MP.js";
23
+ } from "../chunk-FIIU52RN.js";
20
24
  import {
21
25
  TEMPO_INTERACT_FRAME_NAME,
22
26
  isTempoInteractFrameName
23
27
  } from "../chunk-65B52AR7.js";
24
- import "../chunk-ZT2REPH4.js";
28
+ import "../chunk-57KAYXHF.js";
25
29
 
26
30
  // canvas/canvas-host.tsx
27
31
  import {
@@ -104,15 +108,26 @@ function CanvasImportBoundary({
104
108
  reportCanvasImportError
105
109
  } = useRequiredCanvasHost();
106
110
  const failedRef = useRef(false);
111
+ const importRejectedRef = useRef(false);
107
112
  const loadRef = useRef(load);
108
113
  const previousLoadRef = useRef(load);
109
114
  loadRef.current = load;
110
115
  const [retryRevision, setRetryRevision] = useState(0);
116
+ const retryRenderNow = useCallback(() => {
117
+ if (!failedRef.current || importRejectedRef.current) return false;
118
+ setRetryRevision((revision) => revision + 1);
119
+ return true;
120
+ }, []);
121
+ const { noteRenderError, noteRecovered } = useRenderErrorRecovery(retryRenderNow);
111
122
  const lazyIdentity = `${canvasPath}:${retryRevision}`;
112
123
  const LazyCanvas = useMemo(() => {
113
124
  void lazyIdentity;
114
125
  return lazy(
115
- () => Promise.resolve().then(() => loadRef.current()).catch((error) => {
126
+ () => Promise.resolve().then(() => {
127
+ importRejectedRef.current = false;
128
+ return loadRef.current();
129
+ }).catch((error) => {
130
+ importRejectedRef.current = true;
116
131
  getCanvasHostRecoveryFeed().publish({
117
132
  type: "module-load-failure",
118
133
  path: canvasPath,
@@ -125,14 +140,17 @@ function CanvasImportBoundary({
125
140
  const reportError = useCallback(
126
141
  (error) => {
127
142
  failedRef.current = true;
143
+ if (importRejectedRef.current) noteRecovered();
144
+ else noteRenderError();
128
145
  reportCanvasImportError(canvasPath, error);
129
146
  },
130
- [canvasPath, reportCanvasImportError]
147
+ [canvasPath, noteRecovered, noteRenderError, reportCanvasImportError]
131
148
  );
132
149
  const markCommitted = useCallback(() => {
133
150
  failedRef.current = false;
151
+ noteRecovered();
134
152
  clearCanvasImportError(canvasPath);
135
- }, [canvasPath, clearCanvasImportError]);
153
+ }, [canvasPath, clearCanvasImportError, noteRecovered]);
136
154
  useEffect(() => {
137
155
  const loadChanged = previousLoadRef.current !== load;
138
156
  previousLoadRef.current = load;
@@ -1010,6 +1028,19 @@ function installCanvasHostRuntimeProblemTracking(tracker) {
1010
1028
  };
1011
1029
  }
1012
1030
  function installViteErrorStream(tracker) {
1031
+ const receive = (problem) => {
1032
+ if (problem === null) {
1033
+ tracker.clearHostProblem(["vite-hmr-error"]);
1034
+ return;
1035
+ }
1036
+ if (typeof problem?.message !== "string") return;
1037
+ tracker.reportHostProblem("vite-hmr-error", problem.message, {
1038
+ stack: problem.stack,
1039
+ filename: problem.file ?? problem.loc?.file
1040
+ });
1041
+ };
1042
+ const feed = globalThis[VITE_ERROR_FEED_KEY];
1043
+ if (feed) return feed.subscribe(receive);
1013
1044
  if (typeof EventSource === "undefined") return () => {
1014
1045
  };
1015
1046
  const source = new EventSource("/__tempo/errors");
@@ -1020,15 +1051,7 @@ function installViteErrorStream(tracker) {
1020
1051
  } catch {
1021
1052
  return;
1022
1053
  }
1023
- if (problem === null) {
1024
- tracker.clearHostProblem(["vite-hmr-error"]);
1025
- return;
1026
- }
1027
- if (typeof problem?.message !== "string") return;
1028
- tracker.reportHostProblem("vite-hmr-error", problem.message, {
1029
- stack: problem.stack,
1030
- filename: problem.file ?? problem.loc?.file
1031
- });
1054
+ receive(problem);
1032
1055
  };
1033
1056
  return () => {
1034
1057
  source.close();
@@ -2343,6 +2366,11 @@ function CanvasHost({
2343
2366
  const normalizedId = normalizeId(storyboardId, "Storyboard id");
2344
2367
  return directUrlRender?.renderId === normalizedId ? { left: 0, top: 0 } : void 0;
2345
2368
  },
2369
+ prepareStoryboardCapture(storyboardId) {
2370
+ if (directUrlRender?.renderId !== storyboardId) return;
2371
+ const captureGlobal = globalThis;
2372
+ captureGlobal.__tempoResetCaptureDeterminism?.();
2373
+ },
2346
2374
  markStoryboardRendered,
2347
2375
  markStoryboardUnmounted,
2348
2376
  reportStoryboardError,