tempo-sdk 0.0.19 → 0.0.22
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/README.md +32 -2
- package/dist/canvas/editor.d.ts +9 -8
- package/dist/canvas/editor.js +8 -37
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +115 -18
- package/dist/canvas/index.js +1580 -724
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.d.ts +8 -0
- package/dist/canvas/interact-projection.js +5532 -0
- package/dist/canvas/interact-projection.js.map +1 -0
- package/dist/canvas/parser.js +1 -1
- package/dist/{chunk-P277UVZE.js → chunk-GBKYTBEE.js} +1 -3
- package/dist/{chunk-P277UVZE.js.map → chunk-GBKYTBEE.js.map} +1 -1
- package/dist/chunk-QXB32HG4.js +11 -0
- package/dist/chunk-QXB32HG4.js.map +1 -0
- package/dist/chunk-ZT2REPH4.js +19 -0
- package/dist/chunk-ZT2REPH4.js.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +962 -27
- package/dist/index.js.map +1 -1
- package/dist/{page-xi1aI5a7.d.ts → page-BUbHO0BI.d.ts} +2 -0
- package/package.json +7 -2
package/dist/canvas/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PROJECTION_PENDING_ATTRIBUTE
|
|
3
|
+
} from "../chunk-ZT2REPH4.js";
|
|
4
|
+
import {
|
|
5
|
+
TEMPO_INTERACT_FRAME_NAME,
|
|
6
|
+
isTempoInteractFrameName
|
|
7
|
+
} from "../chunk-QXB32HG4.js";
|
|
8
|
+
|
|
1
9
|
// canvas/canvas.tsx
|
|
2
10
|
import {
|
|
3
11
|
Children,
|
|
@@ -40,7 +48,8 @@ function Canvas({
|
|
|
40
48
|
name,
|
|
41
49
|
path,
|
|
42
50
|
backgroundColor,
|
|
43
|
-
defaultViewport
|
|
51
|
+
defaultViewport,
|
|
52
|
+
...sourceAnnotations
|
|
44
53
|
}) {
|
|
45
54
|
const contextIdentity = useCanvasIdentity();
|
|
46
55
|
const canvasName = normalizeId(name, "Canvas name");
|
|
@@ -64,6 +73,7 @@ function Canvas({
|
|
|
64
73
|
return /* @__PURE__ */ jsx(CanvasIdentityContext.Provider, { value: identity, children: /* @__PURE__ */ jsx(
|
|
65
74
|
"div",
|
|
66
75
|
{
|
|
76
|
+
...sourceAnnotations,
|
|
67
77
|
"data-tempo-canvas": canvasName,
|
|
68
78
|
"data-tempo-canvas-path": canvasPath,
|
|
69
79
|
"data-tempo-canvas-background": backgroundColor,
|
|
@@ -82,10 +92,53 @@ function CanvasContext({
|
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
// canvas/canvas-host.tsx
|
|
95
|
+
import { useEffect as useEffect3, useMemo as useMemo4 } from "react";
|
|
96
|
+
|
|
97
|
+
// canvas/canvas-import-boundary.tsx
|
|
85
98
|
import {
|
|
86
|
-
|
|
99
|
+
Component,
|
|
100
|
+
lazy,
|
|
101
|
+
Suspense,
|
|
102
|
+
useCallback as useCallback2,
|
|
103
|
+
useEffect,
|
|
104
|
+
useLayoutEffect,
|
|
105
|
+
useMemo as useMemo2,
|
|
106
|
+
useRef,
|
|
107
|
+
useState
|
|
87
108
|
} from "react";
|
|
88
109
|
|
|
110
|
+
// canvas/canvas-pending-marker.tsx
|
|
111
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
112
|
+
function CanvasPendingMarker() {
|
|
113
|
+
return /* @__PURE__ */ jsx2(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
...{ [PROJECTION_PENDING_ATTRIBUTE]: "" },
|
|
117
|
+
style: { display: "none" },
|
|
118
|
+
"aria-hidden": "true"
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// canvas/host-recovery-feed.ts
|
|
124
|
+
var FEED_KEY = "__tempoCanvasHostRecoveryFeed";
|
|
125
|
+
function createFeed() {
|
|
126
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
127
|
+
return {
|
|
128
|
+
publish(event) {
|
|
129
|
+
for (const listener of [...listeners]) listener(event);
|
|
130
|
+
},
|
|
131
|
+
subscribe(listener) {
|
|
132
|
+
listeners.add(listener);
|
|
133
|
+
return () => listeners.delete(listener);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function getCanvasHostRecoveryFeed() {
|
|
138
|
+
const globals = globalThis;
|
|
139
|
+
return globals[FEED_KEY] ?? (globals[FEED_KEY] = createFeed());
|
|
140
|
+
}
|
|
141
|
+
|
|
89
142
|
// canvas/runtime-context.ts
|
|
90
143
|
import { createContext as createContext2, useCallback, useContext as useContext2 } from "react";
|
|
91
144
|
var CanvasHostContext = createContext2(null);
|
|
@@ -115,6 +168,13 @@ function useStoryboardRendered(storyboardId) {
|
|
|
115
168
|
host.markStoryboardRendered(renderId);
|
|
116
169
|
}, [host, renderId]);
|
|
117
170
|
}
|
|
171
|
+
function useStoryboardUnmounted(storyboardId) {
|
|
172
|
+
const renderId = useCanvasStoryboardRenderId(storyboardId);
|
|
173
|
+
const { markStoryboardUnmounted } = useRequiredCanvasHost();
|
|
174
|
+
return useCallback(() => {
|
|
175
|
+
markStoryboardUnmounted(renderId);
|
|
176
|
+
}, [markStoryboardUnmounted, renderId]);
|
|
177
|
+
}
|
|
118
178
|
function useStoryboardErrorReporter(storyboardId) {
|
|
119
179
|
const renderId = useCanvasStoryboardRenderId(storyboardId);
|
|
120
180
|
const host = useRequiredCanvasHost();
|
|
@@ -140,8 +200,109 @@ function useStoryboardPlacement(storyboardId) {
|
|
|
140
200
|
return host.getStoryboardPlacement(renderId);
|
|
141
201
|
}
|
|
142
202
|
|
|
203
|
+
// canvas/canvas-import-boundary.tsx
|
|
204
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
205
|
+
var CanvasImportErrorBoundary = class extends Component {
|
|
206
|
+
constructor() {
|
|
207
|
+
super(...arguments);
|
|
208
|
+
this.state = { hasError: false };
|
|
209
|
+
}
|
|
210
|
+
static getDerivedStateFromError() {
|
|
211
|
+
return { hasError: true };
|
|
212
|
+
}
|
|
213
|
+
componentDidCatch(error, info) {
|
|
214
|
+
this.props.reportError({
|
|
215
|
+
message: error instanceof Error ? error.message : String(error),
|
|
216
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
217
|
+
componentStack: info.componentStack ?? void 0
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
render() {
|
|
221
|
+
return this.state.hasError ? null : this.props.children;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
function CanvasCommitSignal({ onCommit }) {
|
|
225
|
+
const onCommitRef = useRef(onCommit);
|
|
226
|
+
const didCommitRef = useRef(false);
|
|
227
|
+
onCommitRef.current = onCommit;
|
|
228
|
+
useLayoutEffect(() => {
|
|
229
|
+
if (didCommitRef.current) return;
|
|
230
|
+
didCommitRef.current = true;
|
|
231
|
+
onCommitRef.current();
|
|
232
|
+
}, []);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
function CanvasImportBoundary({
|
|
236
|
+
canvasPath,
|
|
237
|
+
load
|
|
238
|
+
}) {
|
|
239
|
+
const {
|
|
240
|
+
clearCanvasImportError,
|
|
241
|
+
registerCanvasProblemScope,
|
|
242
|
+
reportCanvasImportError
|
|
243
|
+
} = useRequiredCanvasHost();
|
|
244
|
+
const failedRef = useRef(false);
|
|
245
|
+
const loadRef = useRef(load);
|
|
246
|
+
const previousLoadRef = useRef(load);
|
|
247
|
+
loadRef.current = load;
|
|
248
|
+
const [retryRevision, setRetryRevision] = useState(0);
|
|
249
|
+
const lazyIdentity = `${canvasPath}:${retryRevision}`;
|
|
250
|
+
const LazyCanvas = useMemo2(() => {
|
|
251
|
+
void lazyIdentity;
|
|
252
|
+
return lazy(
|
|
253
|
+
() => Promise.resolve().then(() => loadRef.current()).catch((error) => {
|
|
254
|
+
getCanvasHostRecoveryFeed().publish({
|
|
255
|
+
type: "module-load-failure",
|
|
256
|
+
path: canvasPath,
|
|
257
|
+
message: error instanceof Error ? error.message : String(error)
|
|
258
|
+
});
|
|
259
|
+
throw error;
|
|
260
|
+
})
|
|
261
|
+
);
|
|
262
|
+
}, [lazyIdentity, canvasPath]);
|
|
263
|
+
const reportError = useCallback2(
|
|
264
|
+
(error) => {
|
|
265
|
+
failedRef.current = true;
|
|
266
|
+
reportCanvasImportError(canvasPath, error);
|
|
267
|
+
},
|
|
268
|
+
[canvasPath, reportCanvasImportError]
|
|
269
|
+
);
|
|
270
|
+
const markCommitted = useCallback2(() => {
|
|
271
|
+
failedRef.current = false;
|
|
272
|
+
clearCanvasImportError(canvasPath);
|
|
273
|
+
}, [canvasPath, clearCanvasImportError]);
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
const loadChanged = previousLoadRef.current !== load;
|
|
276
|
+
previousLoadRef.current = load;
|
|
277
|
+
if (loadChanged && failedRef.current) {
|
|
278
|
+
setRetryRevision((revision) => revision + 1);
|
|
279
|
+
}
|
|
280
|
+
}, [load]);
|
|
281
|
+
useEffect(
|
|
282
|
+
() => () => {
|
|
283
|
+
clearCanvasImportError(canvasPath);
|
|
284
|
+
},
|
|
285
|
+
[canvasPath, clearCanvasImportError]
|
|
286
|
+
);
|
|
287
|
+
useEffect(
|
|
288
|
+
() => registerCanvasProblemScope(canvasPath),
|
|
289
|
+
[canvasPath, registerCanvasProblemScope]
|
|
290
|
+
);
|
|
291
|
+
return /* @__PURE__ */ jsx3(CanvasImportErrorBoundary, { reportError, children: /* @__PURE__ */ jsx3(Suspense, { fallback: /* @__PURE__ */ jsx3(CanvasPendingMarker, {}), children: /* @__PURE__ */ jsxs(CanvasContext, { path: canvasPath, children: [
|
|
292
|
+
/* @__PURE__ */ jsx3(LazyCanvas, {}),
|
|
293
|
+
/* @__PURE__ */ jsx3(CanvasCommitSignal, { onCommit: markCommitted })
|
|
294
|
+
] }) }) }, retryRevision);
|
|
295
|
+
}
|
|
296
|
+
|
|
143
297
|
// canvas/use-canvas-host-postmessage.ts
|
|
144
|
-
import {
|
|
298
|
+
import {
|
|
299
|
+
useCallback as useCallback3,
|
|
300
|
+
useEffect as useEffect2,
|
|
301
|
+
useLayoutEffect as useLayoutEffect2,
|
|
302
|
+
useMemo as useMemo3,
|
|
303
|
+
useRef as useRef2,
|
|
304
|
+
useState as useState2
|
|
305
|
+
} from "react";
|
|
145
306
|
|
|
146
307
|
// canvas/canvas-host-runtime.ts
|
|
147
308
|
function getCanvasHostRuntime() {
|
|
@@ -455,7 +616,10 @@ function trackStoryboardPortals(renderId, element, status) {
|
|
|
455
616
|
var escapeRenderId = (renderId) => renderId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
456
617
|
var buildRenderSelector = (renderId) => `[data-render-id="${escapeRenderId(renderId)}"]`;
|
|
457
618
|
var buildRenderContentSelector = (renderId) => `[data-render-content="${escapeRenderId(renderId)}"]`;
|
|
458
|
-
var buildRenderContentFiberSelector = (renderId) =>
|
|
619
|
+
var buildRenderContentFiberSelector = (renderId) => [
|
|
620
|
+
`${buildRenderContentSelector(renderId)} > :not([data-tempo-hide-fiber="true"])`,
|
|
621
|
+
`${buildRenderContentSelector(renderId)}:not(:has(> *))`
|
|
622
|
+
].join(", ");
|
|
459
623
|
function stripRenderContentWrapperAttributes(capture, renderId) {
|
|
460
624
|
if (!capture || typeof capture !== "object") return capture;
|
|
461
625
|
const dom = capture.dom;
|
|
@@ -483,14 +647,22 @@ function stripRenderContentWrapperFromCombinedCapture(capture, renderId) {
|
|
|
483
647
|
html: stripRenderContentWrapperAttributes(html, renderId)
|
|
484
648
|
};
|
|
485
649
|
}
|
|
486
|
-
|
|
650
|
+
var nextAnimationFrame = () => new Promise((resolve) => {
|
|
651
|
+
requestAnimationFrame(() => resolve());
|
|
652
|
+
});
|
|
653
|
+
async function captureStoryboardImage(renderId, options) {
|
|
487
654
|
const portalSelectors = [
|
|
488
655
|
...options?.portalSelectors ?? [],
|
|
489
656
|
...getStoryboardPortalSelectors(renderId)
|
|
490
657
|
];
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
658
|
+
const renderSelector = buildRenderSelector(renderId);
|
|
659
|
+
const { childSelector, ...captureOptions } = options ?? {};
|
|
660
|
+
const captureSelector = childSelector ? `${renderSelector} ${childSelector}` : renderSelector;
|
|
661
|
+
await nextAnimationFrame();
|
|
662
|
+
await nextAnimationFrame();
|
|
663
|
+
return await getCanvasHostRuntime().captureSelector(
|
|
664
|
+
captureSelector,
|
|
665
|
+
portalSelectors.length > 0 ? { ...captureOptions, portalSelectors: [...new Set(portalSelectors)] } : captureOptions
|
|
494
666
|
);
|
|
495
667
|
}
|
|
496
668
|
async function captureStoryboardHtml(renderId, options) {
|
|
@@ -553,6 +725,87 @@ function watchStoryboardCombined(renderId, options) {
|
|
|
553
725
|
});
|
|
554
726
|
}
|
|
555
727
|
|
|
728
|
+
// canvas/canvas-host-legacy-compat.ts
|
|
729
|
+
var sourceAnnotationSelector = "[data-tempo-source-file], [data-tempo-source-loc], [data-tempo-filepath], [data-tempo-html-filepath]";
|
|
730
|
+
function getObservedSourceFiles(slot) {
|
|
731
|
+
if (!slot) return [];
|
|
732
|
+
return [
|
|
733
|
+
...new Set(
|
|
734
|
+
[...slot.querySelectorAll(sourceAnnotationSelector)].flatMap((element) => [
|
|
735
|
+
element.getAttribute("data-tempo-source-file"),
|
|
736
|
+
element.getAttribute("data-tempo-filepath"),
|
|
737
|
+
element.getAttribute("data-tempo-html-filepath"),
|
|
738
|
+
element.getAttribute("data-tempo-source-loc")
|
|
739
|
+
]).filter((file) => Boolean(file))
|
|
740
|
+
)
|
|
741
|
+
];
|
|
742
|
+
}
|
|
743
|
+
function latestTimestamp(values) {
|
|
744
|
+
let latest = null;
|
|
745
|
+
for (const value of values.values()) {
|
|
746
|
+
latest = latest === null ? value : Math.max(latest, value);
|
|
747
|
+
}
|
|
748
|
+
return latest;
|
|
749
|
+
}
|
|
750
|
+
function isReactConnected() {
|
|
751
|
+
const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
752
|
+
return (hook?.renderers?.size ?? 0) > 0;
|
|
753
|
+
}
|
|
754
|
+
function createLegacyHostHealth() {
|
|
755
|
+
const renderCommitTimes = /* @__PURE__ */ new Map();
|
|
756
|
+
const sourceAnnotatedCommitTimes = /* @__PURE__ */ new Map();
|
|
757
|
+
const recordSourceAnnotatedCommit = (renderId, observedAt = Date.now()) => {
|
|
758
|
+
const slot = document.querySelector(buildRenderContentSelector(renderId));
|
|
759
|
+
if (getObservedSourceFiles(slot).length > 0) {
|
|
760
|
+
sourceAnnotatedCommitTimes.set(renderId, observedAt);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
return {
|
|
764
|
+
recordRenderCommit(renderId) {
|
|
765
|
+
const committedAt = Date.now();
|
|
766
|
+
renderCommitTimes.set(renderId, committedAt);
|
|
767
|
+
recordSourceAnnotatedCommit(renderId, committedAt);
|
|
768
|
+
},
|
|
769
|
+
recordSourceAnnotatedCommit(renderId) {
|
|
770
|
+
recordSourceAnnotatedCommit(renderId);
|
|
771
|
+
},
|
|
772
|
+
forgetRender(renderId) {
|
|
773
|
+
renderCommitTimes.delete(renderId);
|
|
774
|
+
sourceAnnotatedCommitTimes.delete(renderId);
|
|
775
|
+
},
|
|
776
|
+
buildSnapshot(renderId, context) {
|
|
777
|
+
const slot = renderId ? document.querySelector(buildRenderContentSelector(renderId)) : null;
|
|
778
|
+
const observedSourceFiles = getObservedSourceFiles(slot);
|
|
779
|
+
return {
|
|
780
|
+
alive: true,
|
|
781
|
+
reactConnected: isReactConnected() || renderCommitTimes.size > 0 || context.hasRenderEntries,
|
|
782
|
+
documentReadyState: document.readyState,
|
|
783
|
+
hasViteOverlayElement: document.querySelector("vite-error-overlay") !== null,
|
|
784
|
+
lastHostRenderCommitAt: latestTimestamp(renderCommitTimes),
|
|
785
|
+
lastClaimRenderCommitAt: renderCommitTimes.get(renderId) ?? null,
|
|
786
|
+
lastHostSourceAnnotatedCommitAt: latestTimestamp(
|
|
787
|
+
sourceAnnotatedCommitTimes
|
|
788
|
+
),
|
|
789
|
+
lastClaimSourceAnnotatedCommitAt: sourceAnnotatedCommitTimes.get(renderId) ?? null,
|
|
790
|
+
renderSlotExists: slot !== null,
|
|
791
|
+
renderSlotHasSourceAnnotatedContent: observedSourceFiles.length > 0,
|
|
792
|
+
renderSlotObservedSourceFiles: observedSourceFiles,
|
|
793
|
+
claimErrorBoundaryTripped: context.claimErrorBoundaryTripped,
|
|
794
|
+
observedAt: Date.now()
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
function applyLegacyRenderIsolation(renderId) {
|
|
800
|
+
document.querySelector("[data-render-isolation]")?.remove();
|
|
801
|
+
if (!renderId) return;
|
|
802
|
+
const style = document.createElement("style");
|
|
803
|
+
style.setAttribute("data-render-isolation", "");
|
|
804
|
+
const escapedId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(renderId) : renderId;
|
|
805
|
+
style.textContent = '[data-render-id]:not([data-render-id="' + escapedId + '"]) { opacity: 0 !important; pointer-events: none !important; }';
|
|
806
|
+
document.head.appendChild(style);
|
|
807
|
+
}
|
|
808
|
+
|
|
556
809
|
// canvas/canvas-host-protocol.ts
|
|
557
810
|
function isRecord(value) {
|
|
558
811
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -570,15 +823,22 @@ var readTrimmedString = (value) => {
|
|
|
570
823
|
const normalized = value.trim();
|
|
571
824
|
return normalized.length > 0 ? normalized : void 0;
|
|
572
825
|
};
|
|
826
|
+
var readStringArray = (value) => {
|
|
827
|
+
if (!Array.isArray(value)) return void 0;
|
|
828
|
+
const values = value.map(readTrimmedString).filter((entry) => entry !== void 0);
|
|
829
|
+
return values.length > 0 ? [...new Set(values)] : void 0;
|
|
830
|
+
};
|
|
573
831
|
function resolveRenderTarget(payload) {
|
|
574
832
|
const explicitRenderId = readTrimmedString(payload.renderId);
|
|
575
833
|
const canvasPath = readTrimmedString(payload.canvasPath);
|
|
576
834
|
const storyboardId = readTrimmedString(payload.storyboardId);
|
|
835
|
+
const sourcePaths = readStringArray(payload.sourcePaths);
|
|
577
836
|
const renderId = explicitRenderId || (canvasPath && storyboardId ? getCanvasStoryboardRenderId(canvasPath, storyboardId) : storyboardId);
|
|
578
837
|
return renderId ? {
|
|
579
838
|
renderId,
|
|
580
839
|
...canvasPath ? { canvasPath } : {},
|
|
581
|
-
...storyboardId ? { storyboardId } : {}
|
|
840
|
+
...storyboardId ? { storyboardId } : {},
|
|
841
|
+
...sourcePaths ? { sourcePaths } : {}
|
|
582
842
|
} : null;
|
|
583
843
|
}
|
|
584
844
|
function requireRenderTarget(commandType, payload) {
|
|
@@ -638,6 +898,9 @@ var propsMatch = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
|
|
|
638
898
|
function renderRequestMatchesEntry(entry, request) {
|
|
639
899
|
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);
|
|
640
900
|
}
|
|
901
|
+
function renderRequestTargetsEntry(entry, request) {
|
|
902
|
+
return entry?.importPath === request.importPath && entry.importName === request.importName && propsMatch(entry.props, request.props);
|
|
903
|
+
}
|
|
641
904
|
function acquireRender(entries, request) {
|
|
642
905
|
const next = new Map(entries);
|
|
643
906
|
const current = next.get(request.renderId);
|
|
@@ -675,8 +938,9 @@ function evictCachedRenders(entries, maxCached) {
|
|
|
675
938
|
}
|
|
676
939
|
return next;
|
|
677
940
|
}
|
|
678
|
-
function buildRenderStatePayload(entries, maxCached) {
|
|
941
|
+
function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
|
|
679
942
|
return {
|
|
943
|
+
canvasPaths: [...canvasPaths],
|
|
680
944
|
renders: [...entries.values()].map(
|
|
681
945
|
({
|
|
682
946
|
activeCount: _activeCount,
|
|
@@ -705,26 +969,210 @@ function buildRenderSizeMap(entries) {
|
|
|
705
969
|
);
|
|
706
970
|
}
|
|
707
971
|
|
|
972
|
+
// canvas/source-identity.ts
|
|
973
|
+
function normalizeSourceIdentity(value) {
|
|
974
|
+
let normalized = value.trim().replace(/\\/g, "/");
|
|
975
|
+
const suffixIndex = normalized.search(/[?#]/);
|
|
976
|
+
if (suffixIndex !== -1) normalized = normalized.slice(0, suffixIndex);
|
|
977
|
+
try {
|
|
978
|
+
normalized = decodeURIComponent(normalized);
|
|
979
|
+
} catch {
|
|
980
|
+
}
|
|
981
|
+
normalized = normalized.replace(/^file:\/\//, "").replace(/^\/@fs\//, "/");
|
|
982
|
+
return normalized.replace(/^\.\//, "").replace(/\/{2,}/g, "/");
|
|
983
|
+
}
|
|
984
|
+
function distinctSourceIdentities(paths) {
|
|
985
|
+
return [
|
|
986
|
+
...new Set(
|
|
987
|
+
paths.map(normalizeSourceIdentity).filter((path) => path.length)
|
|
988
|
+
)
|
|
989
|
+
];
|
|
990
|
+
}
|
|
991
|
+
function normalizeDiagnosticText(value) {
|
|
992
|
+
const normalized = value.replace(/\\/g, "/");
|
|
993
|
+
try {
|
|
994
|
+
return decodeURIComponent(normalized).replace(/\bhttps?:\/\/[^/\s)]+/g, "").replace(/\/@fs\//g, "/");
|
|
995
|
+
} catch {
|
|
996
|
+
return normalized.replace(/\bhttps?:\/\/[^/\s)]+/g, "").replace(/\/@fs\//g, "/");
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function isPathCharacter(value) {
|
|
1000
|
+
return /[A-Za-z0-9._@+-]/.test(value);
|
|
1001
|
+
}
|
|
1002
|
+
function textMentionsPathSuffix(text, suffix) {
|
|
1003
|
+
let fromIndex = 0;
|
|
1004
|
+
while (fromIndex < text.length) {
|
|
1005
|
+
const index = text.indexOf(suffix, fromIndex);
|
|
1006
|
+
if (index < 0) return false;
|
|
1007
|
+
const before = index === 0 ? "" : text[index - 1];
|
|
1008
|
+
const after = text[index + suffix.length] ?? "";
|
|
1009
|
+
if ((before === "" || before === "/" || !isPathCharacter(before)) && (after === "" || !isPathCharacter(after))) {
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
fromIndex = index + 1;
|
|
1013
|
+
}
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
function textMentionsExactPath(text, path) {
|
|
1017
|
+
let fromIndex = 0;
|
|
1018
|
+
while (fromIndex < text.length) {
|
|
1019
|
+
const index = text.indexOf(path, fromIndex);
|
|
1020
|
+
if (index < 0) return false;
|
|
1021
|
+
const before = index === 0 ? "" : text[index - 1];
|
|
1022
|
+
const after = text[index + path.length] ?? "";
|
|
1023
|
+
if ((before === "" || before !== "/" && !isPathCharacter(before)) && (after === "" || after !== "/" && !isPathCharacter(after))) {
|
|
1024
|
+
return true;
|
|
1025
|
+
}
|
|
1026
|
+
fromIndex = index + 1;
|
|
1027
|
+
}
|
|
1028
|
+
return false;
|
|
1029
|
+
}
|
|
1030
|
+
function projectRootSpellings(projectRoot) {
|
|
1031
|
+
const spellings = [projectRoot];
|
|
1032
|
+
if (/^\/(?:var|tmp)\//.test(projectRoot)) {
|
|
1033
|
+
spellings.push(`/private${projectRoot}`);
|
|
1034
|
+
} else if (/^\/private\/(?:var|tmp)\//.test(projectRoot)) {
|
|
1035
|
+
spellings.push(projectRoot.slice("/private".length));
|
|
1036
|
+
}
|
|
1037
|
+
return spellings;
|
|
1038
|
+
}
|
|
1039
|
+
function rootedDiagnosticAliases(identityValue, projectRootValue) {
|
|
1040
|
+
const identity = normalizeSourceIdentity(identityValue);
|
|
1041
|
+
const projectRoot = normalizeSourceIdentity(projectRootValue).replace(
|
|
1042
|
+
/\/+$/,
|
|
1043
|
+
""
|
|
1044
|
+
);
|
|
1045
|
+
if (!identity || !projectRoot) return [];
|
|
1046
|
+
const roots = projectRootSpellings(projectRoot);
|
|
1047
|
+
const rootPrefix = roots.find((root) => identity.startsWith(`${root}/`));
|
|
1048
|
+
const relative = rootPrefix ? identity.slice(rootPrefix.length + 1) : identity.startsWith("/") ? identity.slice(1) : identity;
|
|
1049
|
+
return [
|
|
1050
|
+
.../* @__PURE__ */ new Set([
|
|
1051
|
+
relative,
|
|
1052
|
+
`/${relative}`,
|
|
1053
|
+
...roots.map((root) => `${root}/${relative}`)
|
|
1054
|
+
])
|
|
1055
|
+
];
|
|
1056
|
+
}
|
|
1057
|
+
function matchingDiagnosticSegments(text, identity) {
|
|
1058
|
+
const segments = identity.split("/").filter(Boolean);
|
|
1059
|
+
for (let count = segments.length; count >= 2; count -= 1) {
|
|
1060
|
+
if (textMentionsPathSuffix(text, segments.slice(-count).join("/"))) {
|
|
1061
|
+
return count;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return 0;
|
|
1065
|
+
}
|
|
1066
|
+
function resolveUniqueDiagnosticSourceMatches(textValue, candidates, options = {}) {
|
|
1067
|
+
const text = normalizeDiagnosticText(textValue);
|
|
1068
|
+
if (!text) return [];
|
|
1069
|
+
const projectRoot = options.projectRoot?.trim();
|
|
1070
|
+
if (projectRoot) {
|
|
1071
|
+
const exactMatches = candidates.filter((candidate) => {
|
|
1072
|
+
const aliases = rootedDiagnosticAliases(candidate, projectRoot);
|
|
1073
|
+
if (aliases.some((alias) => textMentionsExactPath(text, alias))) {
|
|
1074
|
+
return true;
|
|
1075
|
+
}
|
|
1076
|
+
if (!options.allowExtensionlessJsTs || /\.(?:[cm]?[jt]sx?)$/i.test(normalizeSourceIdentity(candidate))) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
return aliases.some(
|
|
1080
|
+
(alias) => [".js", ".jsx", ".ts", ".tsx", ".mjs", ".mts", ".cjs", ".cts"].some(
|
|
1081
|
+
(extension) => textMentionsExactPath(text, `${alias}${extension}`)
|
|
1082
|
+
)
|
|
1083
|
+
);
|
|
1084
|
+
});
|
|
1085
|
+
return distinctSourceIdentities(exactMatches).length === 1 ? exactMatches : [];
|
|
1086
|
+
}
|
|
1087
|
+
const evaluated = candidates.map((candidate) => {
|
|
1088
|
+
const identity = normalizeSourceIdentity(candidate);
|
|
1089
|
+
return {
|
|
1090
|
+
candidate,
|
|
1091
|
+
identity,
|
|
1092
|
+
identitySegments: identity.split("/").filter(Boolean).length,
|
|
1093
|
+
matchSegments: matchingDiagnosticSegments(text, identity)
|
|
1094
|
+
};
|
|
1095
|
+
});
|
|
1096
|
+
const pathMatches = evaluated.filter(
|
|
1097
|
+
({ matchSegments }) => matchSegments > 0
|
|
1098
|
+
);
|
|
1099
|
+
if (pathMatches.length > 0) {
|
|
1100
|
+
const strongest = Math.max(
|
|
1101
|
+
...pathMatches.map(({ matchSegments }) => matchSegments)
|
|
1102
|
+
);
|
|
1103
|
+
const strongestMatches = pathMatches.filter(
|
|
1104
|
+
({ matchSegments }) => matchSegments === strongest
|
|
1105
|
+
);
|
|
1106
|
+
const fullMatches = strongestMatches.filter(
|
|
1107
|
+
({ identitySegments, matchSegments }) => identitySegments === matchSegments
|
|
1108
|
+
);
|
|
1109
|
+
const unambiguousMatches = fullMatches.length > 0 ? fullMatches : strongestMatches;
|
|
1110
|
+
if (distinctSourceIdentities(
|
|
1111
|
+
unambiguousMatches.map(({ identity }) => identity)
|
|
1112
|
+
).length === 1) {
|
|
1113
|
+
return unambiguousMatches.map(({ candidate }) => candidate);
|
|
1114
|
+
}
|
|
1115
|
+
return [];
|
|
1116
|
+
}
|
|
1117
|
+
const basenameMatches = evaluated.filter(({ identity }) => {
|
|
1118
|
+
const basename = identity.split("/").pop() ?? "";
|
|
1119
|
+
return basename.length > 0 && textMentionsPathSuffix(text, basename);
|
|
1120
|
+
});
|
|
1121
|
+
return distinctSourceIdentities(
|
|
1122
|
+
basenameMatches.map(({ identity }) => identity)
|
|
1123
|
+
).length === 1 ? basenameMatches.map(({ candidate }) => candidate) : [];
|
|
1124
|
+
}
|
|
1125
|
+
|
|
708
1126
|
// canvas/runtime-problems.ts
|
|
709
1127
|
var CanvasHostProblemTracker = class {
|
|
710
1128
|
constructor() {
|
|
711
|
-
this.
|
|
1129
|
+
this.hostProblemWasNearRender = false;
|
|
712
1130
|
this.componentProblems = /* @__PURE__ */ new Map();
|
|
713
|
-
this.componentProblemHmrGenerations = /* @__PURE__ */ new Map();
|
|
714
1131
|
this.canvasProblems = /* @__PURE__ */ new Map();
|
|
1132
|
+
this.registeredCanvasPaths = /* @__PURE__ */ new Map();
|
|
1133
|
+
this.registeredRenderSourcePaths = /* @__PURE__ */ new Map();
|
|
715
1134
|
this.watchers = /* @__PURE__ */ new Set();
|
|
716
1135
|
this.hostProblemClearedWatchers = /* @__PURE__ */ new Set();
|
|
717
|
-
this.hmrGeneration = 0;
|
|
718
1136
|
}
|
|
719
1137
|
snapshot() {
|
|
1138
|
+
const componentProblems = new Map(this.componentProblems);
|
|
1139
|
+
const canvasProblems = new Map(this.canvasProblems);
|
|
1140
|
+
const projectViteProblem = (problem) => {
|
|
1141
|
+
const canvasPaths = this.matchingCanvasPaths(problem);
|
|
1142
|
+
if (canvasPaths.length > 0) {
|
|
1143
|
+
for (const canvasPath of canvasPaths) {
|
|
1144
|
+
canvasProblems.set(canvasPath, problem);
|
|
1145
|
+
}
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
const renderIds = this.matchingRenderIds(problem);
|
|
1149
|
+
if (renderIds.length === 0) return false;
|
|
1150
|
+
for (const renderId of renderIds) {
|
|
1151
|
+
componentProblems.set(
|
|
1152
|
+
renderId,
|
|
1153
|
+
this.problemForMatchedRender(problem, renderId)
|
|
1154
|
+
);
|
|
1155
|
+
}
|
|
1156
|
+
return true;
|
|
1157
|
+
};
|
|
720
1158
|
const currentViteOverlay = readCurrentViteOverlay();
|
|
721
|
-
|
|
1159
|
+
let hostProblem = this.hostProblem?.sourceKind === "vite-overlay" ? void 0 : this.hostProblem;
|
|
1160
|
+
if (hostProblem && isViteProblemSourceKind(hostProblem.sourceKind) && projectViteProblem(hostProblem)) {
|
|
1161
|
+
hostProblem = void 0;
|
|
1162
|
+
}
|
|
1163
|
+
if (hostProblem && (this.hostProblemWasNearRender || isNearRenderProblemSourceKind(hostProblem.sourceKind)) && projectViteProblem(hostProblem)) {
|
|
1164
|
+
hostProblem = void 0;
|
|
1165
|
+
}
|
|
1166
|
+
if (currentViteOverlay && !projectViteProblem(currentViteOverlay)) {
|
|
1167
|
+
hostProblem = currentViteOverlay;
|
|
1168
|
+
}
|
|
722
1169
|
return {
|
|
723
1170
|
hostProblem,
|
|
724
|
-
componentProblems: [...
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
1171
|
+
componentProblems: [...componentProblems].map(([renderId, problem]) => ({
|
|
1172
|
+
renderId,
|
|
1173
|
+
problem
|
|
1174
|
+
})),
|
|
1175
|
+
canvasProblems: [...canvasProblems].map(([canvasPath, problem]) => ({
|
|
728
1176
|
canvasPath,
|
|
729
1177
|
problem
|
|
730
1178
|
}))
|
|
@@ -744,18 +1192,22 @@ var CanvasHostProblemTracker = class {
|
|
|
744
1192
|
}
|
|
745
1193
|
reportHostProblem(sourceKind, error, details = {}) {
|
|
746
1194
|
this.hostProblem = createProblem(sourceKind, error, details);
|
|
747
|
-
this.
|
|
1195
|
+
this.hostProblemWasNearRender = false;
|
|
748
1196
|
this.publish();
|
|
749
1197
|
}
|
|
750
1198
|
reportProblemNearRender(sourceKind, error, details = {}) {
|
|
751
1199
|
const problem = createProblem(sourceKind, error, details);
|
|
752
|
-
const
|
|
753
|
-
if (
|
|
754
|
-
|
|
755
|
-
|
|
1200
|
+
const renderIds = this.matchingRenderIds(problem);
|
|
1201
|
+
if (renderIds.length > 0) {
|
|
1202
|
+
for (const renderId of renderIds) {
|
|
1203
|
+
this.componentProblems.set(
|
|
1204
|
+
renderId,
|
|
1205
|
+
this.problemForMatchedRender(problem, renderId)
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
756
1208
|
} else {
|
|
757
1209
|
this.hostProblem = problem;
|
|
758
|
-
this.
|
|
1210
|
+
this.hostProblemWasNearRender = true;
|
|
759
1211
|
}
|
|
760
1212
|
this.publish();
|
|
761
1213
|
}
|
|
@@ -769,17 +1221,53 @@ var CanvasHostProblemTracker = class {
|
|
|
769
1221
|
);
|
|
770
1222
|
this.publish();
|
|
771
1223
|
}
|
|
772
|
-
clearCanvasProblem(canvasPath) {
|
|
773
|
-
|
|
1224
|
+
clearCanvasProblem(canvasPath, sourceKinds) {
|
|
1225
|
+
const problem = this.canvasProblems.get(canvasPath);
|
|
1226
|
+
if (!problem) return;
|
|
1227
|
+
if (sourceKinds && !sourceKinds.includes(problem.sourceKind)) return;
|
|
1228
|
+
this.canvasProblems.delete(canvasPath);
|
|
774
1229
|
this.publish();
|
|
775
1230
|
}
|
|
1231
|
+
registerCanvasPath(canvasPath) {
|
|
1232
|
+
const normalizedPath = normalizeCanvasPath(canvasPath);
|
|
1233
|
+
if (!normalizedPath) return () => {
|
|
1234
|
+
};
|
|
1235
|
+
this.registeredCanvasPaths.set(
|
|
1236
|
+
normalizedPath,
|
|
1237
|
+
(this.registeredCanvasPaths.get(normalizedPath) ?? 0) + 1
|
|
1238
|
+
);
|
|
1239
|
+
this.publishIfViteProjectionChanged();
|
|
1240
|
+
return () => {
|
|
1241
|
+
const count = this.registeredCanvasPaths.get(normalizedPath) ?? 0;
|
|
1242
|
+
if (count <= 1) {
|
|
1243
|
+
this.registeredCanvasPaths.delete(normalizedPath);
|
|
1244
|
+
this.clearCanvasProblem(normalizedPath, ["vite-overlay"]);
|
|
1245
|
+
} else {
|
|
1246
|
+
this.registeredCanvasPaths.set(normalizedPath, count - 1);
|
|
1247
|
+
}
|
|
1248
|
+
this.publishIfViteProjectionChanged();
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
matchingCanvasPaths(problem) {
|
|
1252
|
+
const candidates = [...this.registeredCanvasPaths.keys()];
|
|
1253
|
+
const filenameMatches = resolveUniqueDiagnosticSourceMatches(
|
|
1254
|
+
problem.filename ?? "",
|
|
1255
|
+
candidates,
|
|
1256
|
+
{ projectRoot: readTempoProjectRoot() }
|
|
1257
|
+
);
|
|
1258
|
+
if (filenameMatches.length > 0) return filenameMatches;
|
|
1259
|
+
const text = [problem.message, problem.stack, problem.filename].filter(Boolean).join("\n");
|
|
1260
|
+
return resolveUniqueDiagnosticSourceMatches(text, candidates, {
|
|
1261
|
+
projectRoot: readTempoProjectRoot()
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
776
1264
|
clearHostProblem(sourceKinds) {
|
|
777
1265
|
if (!this.hostProblem) return;
|
|
778
1266
|
if (sourceKinds && !sourceKinds.includes(this.hostProblem.sourceKind))
|
|
779
1267
|
return;
|
|
780
1268
|
const clearedProblem = this.hostProblem;
|
|
781
1269
|
this.hostProblem = void 0;
|
|
782
|
-
this.
|
|
1270
|
+
this.hostProblemWasNearRender = false;
|
|
783
1271
|
this.publish();
|
|
784
1272
|
this.publishHostProblemCleared(clearedProblem);
|
|
785
1273
|
}
|
|
@@ -788,7 +1276,6 @@ var CanvasHostProblemTracker = class {
|
|
|
788
1276
|
renderId,
|
|
789
1277
|
createProblem(sourceKind, error, details)
|
|
790
1278
|
);
|
|
791
|
-
this.componentProblemHmrGenerations.set(renderId, this.hmrGeneration);
|
|
792
1279
|
this.publish();
|
|
793
1280
|
}
|
|
794
1281
|
clearComponentProblem(renderId, sourceKinds) {
|
|
@@ -796,52 +1283,100 @@ var CanvasHostProblemTracker = class {
|
|
|
796
1283
|
if (!problem) return;
|
|
797
1284
|
if (sourceKinds && !sourceKinds.includes(problem.sourceKind)) return;
|
|
798
1285
|
this.componentProblems.delete(renderId);
|
|
799
|
-
this.componentProblemHmrGenerations.delete(renderId);
|
|
800
1286
|
this.publish();
|
|
801
1287
|
}
|
|
802
1288
|
hasComponentProblem(renderId) {
|
|
803
1289
|
return this.componentProblems.has(renderId);
|
|
804
1290
|
}
|
|
1291
|
+
syncRenderSourcePaths(entries) {
|
|
1292
|
+
const next = new Map(
|
|
1293
|
+
entries.flatMap(
|
|
1294
|
+
(entry) => entry.sourcePaths?.length ? [[entry.renderId, entry.sourcePaths]] : []
|
|
1295
|
+
)
|
|
1296
|
+
);
|
|
1297
|
+
const changed = JSON.stringify([...this.registeredRenderSourcePaths]) !== JSON.stringify([...next]);
|
|
1298
|
+
if (!changed) return;
|
|
1299
|
+
this.registeredRenderSourcePaths = next;
|
|
1300
|
+
if (this.hostProblem && (this.hostProblemWasNearRender || isNearRenderProblemSourceKind(this.hostProblem.sourceKind)) && this.matchingRenderIds(this.hostProblem).length > 0) {
|
|
1301
|
+
this.publish();
|
|
1302
|
+
} else {
|
|
1303
|
+
this.publishIfViteProjectionChanged();
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
matchingRenderIds(problem) {
|
|
1307
|
+
return findRenderIdsForProblem(
|
|
1308
|
+
problem,
|
|
1309
|
+
[...this.registeredRenderSourcePaths].flatMap(
|
|
1310
|
+
([renderId, sourcePaths]) => sourcePaths.map((sourceFile) => ({ renderId, sourceFile }))
|
|
1311
|
+
)
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
problemForMatchedRender(problem, renderId) {
|
|
1315
|
+
if (problem.sourceKind !== "unhandled-rejection" || !this.matchingDeclaredRenderIds(problem).includes(renderId)) {
|
|
1316
|
+
return problem;
|
|
1317
|
+
}
|
|
1318
|
+
return { ...problem, sourceKind: "render-error-boundary" };
|
|
1319
|
+
}
|
|
1320
|
+
matchingDeclaredRenderIds(problem) {
|
|
1321
|
+
return findRenderIdsForProblem(
|
|
1322
|
+
problem,
|
|
1323
|
+
[...this.registeredRenderSourcePaths].flatMap(
|
|
1324
|
+
([renderId, sourcePaths]) => sourcePaths.map((sourceFile) => ({ renderId, sourceFile }))
|
|
1325
|
+
),
|
|
1326
|
+
false
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
805
1329
|
clearRecoveredComponentProblemsAfterRender(renderId) {
|
|
806
1330
|
let changed = false;
|
|
807
1331
|
const problem = this.componentProblems.get(renderId);
|
|
808
|
-
if (problem && problem.sourceKind !== "render-error-boundary"
|
|
1332
|
+
if (problem && problem.sourceKind !== "render-error-boundary") {
|
|
809
1333
|
this.componentProblems.delete(renderId);
|
|
810
|
-
this.componentProblemHmrGenerations.delete(renderId);
|
|
811
1334
|
changed = true;
|
|
812
1335
|
}
|
|
813
1336
|
if (this.clearRecoveredHostProblemAfterRender(renderId)) changed = true;
|
|
814
|
-
if (changed)
|
|
1337
|
+
if (changed) {
|
|
1338
|
+
this.publish();
|
|
1339
|
+
} else {
|
|
1340
|
+
this.publishIfViteProjectionChanged();
|
|
1341
|
+
}
|
|
815
1342
|
}
|
|
816
|
-
|
|
817
|
-
this.
|
|
1343
|
+
reconcileViteOverlayProjection() {
|
|
1344
|
+
this.publishIfViteProjectionChanged();
|
|
818
1345
|
}
|
|
819
1346
|
dispose() {
|
|
820
1347
|
this.watchers.clear();
|
|
821
1348
|
this.hostProblemClearedWatchers.clear();
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
const renderIdFilter = options.renderId ?? void 0;
|
|
825
|
-
const currentRenderFailures = [];
|
|
826
|
-
for (const [renderId, failure] of this.componentProblems) {
|
|
827
|
-
if (renderIdFilter != null && renderId !== renderIdFilter) continue;
|
|
828
|
-
currentRenderFailures.push({ renderId, failure });
|
|
829
|
-
}
|
|
830
|
-
const currentHostFailure = readCurrentViteOverlay() ?? this.hostProblem;
|
|
831
|
-
return {
|
|
832
|
-
...currentHostFailure ? { currentHostFailure } : {},
|
|
833
|
-
currentRenderFailures,
|
|
834
|
-
currentCanvasFailures: [...this.canvasProblems].map(
|
|
835
|
-
([canvasPath, failure]) => ({ canvasPath, failure })
|
|
836
|
-
),
|
|
837
|
-
observedAt: Date.now()
|
|
838
|
-
};
|
|
1349
|
+
this.registeredCanvasPaths.clear();
|
|
1350
|
+
this.registeredRenderSourcePaths.clear();
|
|
839
1351
|
}
|
|
840
1352
|
publish() {
|
|
1353
|
+
this.publishedViteProjectionSignature = this.viteProjectionSignature();
|
|
841
1354
|
for (const watcher of this.watchers) {
|
|
842
1355
|
watcher();
|
|
843
1356
|
}
|
|
844
1357
|
}
|
|
1358
|
+
publishIfViteProjectionChanged() {
|
|
1359
|
+
const signature = this.viteProjectionSignature();
|
|
1360
|
+
if (this.publishedViteProjectionSignature === void 0) {
|
|
1361
|
+
this.publishedViteProjectionSignature = signature;
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
if (signature === this.publishedViteProjectionSignature) return;
|
|
1365
|
+
this.publish();
|
|
1366
|
+
}
|
|
1367
|
+
viteProjectionSignature() {
|
|
1368
|
+
const snapshot = this.snapshot();
|
|
1369
|
+
const identify = (problem) => [problem.sourceKind, problem.filename, problem.message].join("\0");
|
|
1370
|
+
return JSON.stringify({
|
|
1371
|
+
host: snapshot.hostProblem && isProjectedViteProblemSourceKind(snapshot.hostProblem.sourceKind) ? identify(snapshot.hostProblem) : null,
|
|
1372
|
+
components: snapshot.componentProblems.flatMap(
|
|
1373
|
+
({ renderId, problem }) => isProjectedViteProblemSourceKind(problem.sourceKind) ? [[renderId, identify(problem)]] : []
|
|
1374
|
+
),
|
|
1375
|
+
canvases: snapshot.canvasProblems.flatMap(
|
|
1376
|
+
({ canvasPath, problem }) => isProjectedViteProblemSourceKind(problem.sourceKind) ? [[canvasPath, identify(problem)]] : []
|
|
1377
|
+
)
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
845
1380
|
publishHostProblemCleared(problem) {
|
|
846
1381
|
for (const watcher of this.hostProblemClearedWatchers) {
|
|
847
1382
|
watcher(problem);
|
|
@@ -853,13 +1388,12 @@ var CanvasHostProblemTracker = class {
|
|
|
853
1388
|
)) {
|
|
854
1389
|
return false;
|
|
855
1390
|
}
|
|
856
|
-
|
|
857
|
-
if (
|
|
1391
|
+
const matchingRenderIds = this.matchingRenderIds(this.hostProblem);
|
|
1392
|
+
if (matchingRenderIds.length > 0 && !matchingRenderIds.includes(renderId))
|
|
858
1393
|
return false;
|
|
859
|
-
}
|
|
860
1394
|
const clearedProblem = this.hostProblem;
|
|
861
1395
|
this.hostProblem = void 0;
|
|
862
|
-
this.
|
|
1396
|
+
this.hostProblemWasNearRender = false;
|
|
863
1397
|
this.publishHostProblemCleared(clearedProblem);
|
|
864
1398
|
return true;
|
|
865
1399
|
}
|
|
@@ -870,39 +1404,113 @@ function createCanvasHostProblemTracker() {
|
|
|
870
1404
|
function installCanvasHostRuntimeProblemTracking(tracker) {
|
|
871
1405
|
if (typeof window === "undefined") return () => {
|
|
872
1406
|
};
|
|
1407
|
+
const startupProblems = takeFrameStartupProblems();
|
|
873
1408
|
const cleanupHostCapture = installHostProblemCapture(tracker);
|
|
874
|
-
const cleanupCanvasImportCapture = installCanvasImportProblemCapture(tracker);
|
|
875
1409
|
const cleanupViteCapture = installViteProblemCapture(tracker);
|
|
876
|
-
const
|
|
1410
|
+
const cleanupViteErrorStream = installViteErrorStream(tracker);
|
|
1411
|
+
for (const problem of startupProblems) {
|
|
1412
|
+
tracker.reportProblemNearRender(
|
|
1413
|
+
problem.kind === "error" ? "page-error" : "unhandled-rejection",
|
|
1414
|
+
problem.message,
|
|
1415
|
+
{
|
|
1416
|
+
timestamp: problem.timestamp,
|
|
1417
|
+
stack: problem.stack,
|
|
1418
|
+
filename: problem.filename,
|
|
1419
|
+
line: problem.line,
|
|
1420
|
+
column: problem.column
|
|
1421
|
+
}
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
877
1424
|
return () => {
|
|
878
1425
|
cleanupHostCapture();
|
|
879
|
-
cleanupCanvasImportCapture();
|
|
880
1426
|
cleanupViteCapture();
|
|
881
|
-
|
|
882
|
-
tracker.dispose();
|
|
1427
|
+
cleanupViteErrorStream();
|
|
883
1428
|
};
|
|
884
1429
|
}
|
|
885
|
-
function
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1430
|
+
function installViteErrorStream(tracker) {
|
|
1431
|
+
if (typeof EventSource === "undefined") return () => {
|
|
1432
|
+
};
|
|
1433
|
+
const source = new EventSource("/__tempo/errors");
|
|
1434
|
+
source.onmessage = (event) => {
|
|
1435
|
+
let problem;
|
|
1436
|
+
try {
|
|
1437
|
+
problem = JSON.parse(event.data);
|
|
1438
|
+
} catch {
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (problem === null) {
|
|
1442
|
+
tracker.clearHostProblem(["vite-hmr-error"]);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
if (typeof problem?.message !== "string") return;
|
|
1446
|
+
tracker.reportHostProblem("vite-hmr-error", problem.message, {
|
|
1447
|
+
stack: problem.stack,
|
|
1448
|
+
filename: problem.file ?? problem.loc?.file
|
|
895
1449
|
});
|
|
896
1450
|
};
|
|
897
|
-
window.addEventListener("tempo:canvas-import-error", onCanvasImportError);
|
|
898
1451
|
return () => {
|
|
899
|
-
|
|
900
|
-
"tempo:canvas-import-error",
|
|
901
|
-
onCanvasImportError
|
|
902
|
-
);
|
|
1452
|
+
source.close();
|
|
903
1453
|
};
|
|
904
1454
|
}
|
|
1455
|
+
function takeFrameStartupProblems() {
|
|
1456
|
+
const take = window.framePool?.takeStartupErrors;
|
|
1457
|
+
if (typeof take !== "function") return [];
|
|
1458
|
+
let value;
|
|
1459
|
+
try {
|
|
1460
|
+
value = take();
|
|
1461
|
+
} catch {
|
|
1462
|
+
return [];
|
|
1463
|
+
}
|
|
1464
|
+
if (!Array.isArray(value)) return [];
|
|
1465
|
+
return value.flatMap((candidate) => {
|
|
1466
|
+
if (!candidate || typeof candidate !== "object" || candidate.kind !== "error" && candidate.kind !== "unhandledrejection" || typeof candidate.message !== "string" || typeof candidate.timestamp !== "number") {
|
|
1467
|
+
return [];
|
|
1468
|
+
}
|
|
1469
|
+
const record = candidate;
|
|
1470
|
+
return [
|
|
1471
|
+
{
|
|
1472
|
+
kind: record.kind,
|
|
1473
|
+
timestamp: record.timestamp,
|
|
1474
|
+
message: record.message,
|
|
1475
|
+
...typeof record.stack === "string" && { stack: record.stack },
|
|
1476
|
+
...typeof record.filename === "string" && {
|
|
1477
|
+
filename: record.filename
|
|
1478
|
+
},
|
|
1479
|
+
...typeof record.line === "number" && { line: record.line },
|
|
1480
|
+
...typeof record.column === "number" && { column: record.column }
|
|
1481
|
+
}
|
|
1482
|
+
];
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
905
1485
|
var renderRecoveredHostProblemSourceKinds = ["page-error", "unhandled-rejection", "console-vite-error", "vite-hmr-error"];
|
|
1486
|
+
var FAILED_RELOAD_PROBE_DELAYS_MS = [50, 400, 1600];
|
|
1487
|
+
async function moduleTransformSucceeds(path) {
|
|
1488
|
+
const [pathname, query = ""] = path.split("?");
|
|
1489
|
+
const url = `${pathname}?${query ? `${query}&` : ""}t=${Date.now()}`;
|
|
1490
|
+
const response = await fetch(url, { cache: "no-store" });
|
|
1491
|
+
return response.ok;
|
|
1492
|
+
}
|
|
1493
|
+
async function compileErrorFileStillBroken(file) {
|
|
1494
|
+
const cleaned = file.replace(/:\d+(?::\d+)?$/, "");
|
|
1495
|
+
const candidates = cleaned.startsWith("/@") ? [cleaned] : [`/@fs${cleaned}`, cleaned];
|
|
1496
|
+
for (const candidate of candidates) {
|
|
1497
|
+
try {
|
|
1498
|
+
if (await moduleTransformSucceeds(candidate)) return false;
|
|
1499
|
+
} catch {
|
|
1500
|
+
return true;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
function isViteProblemSourceKind(sourceKind) {
|
|
1506
|
+
return sourceKind === "vite-hmr-error" || sourceKind === "console-vite-error";
|
|
1507
|
+
}
|
|
1508
|
+
function isNearRenderProblemSourceKind(sourceKind) {
|
|
1509
|
+
return sourceKind === "page-error" || sourceKind === "unhandled-rejection" || sourceKind === "console-vite-error";
|
|
1510
|
+
}
|
|
1511
|
+
function isProjectedViteProblemSourceKind(sourceKind) {
|
|
1512
|
+
return sourceKind === "vite-overlay" || isViteProblemSourceKind(sourceKind);
|
|
1513
|
+
}
|
|
906
1514
|
function createProblem(sourceKind, error, details = {}) {
|
|
907
1515
|
return {
|
|
908
1516
|
sourceKind,
|
|
@@ -913,31 +1521,47 @@ function createProblem(sourceKind, error, details = {}) {
|
|
|
913
1521
|
...details
|
|
914
1522
|
};
|
|
915
1523
|
}
|
|
916
|
-
function
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (!renderId) continue;
|
|
928
|
-
const sourceFiles = getObservedSourceFiles(slot);
|
|
929
|
-
if (sourceFiles.some(
|
|
930
|
-
(sourceFile) => problemTextMentionsSource(haystack, sourceFile)
|
|
931
|
-
)) {
|
|
932
|
-
return renderId;
|
|
1524
|
+
function findRenderIdsForProblem(problem, registered = [], includeDom = true) {
|
|
1525
|
+
const observed = [
|
|
1526
|
+
...registered
|
|
1527
|
+
];
|
|
1528
|
+
if (includeDom && typeof document !== "undefined") {
|
|
1529
|
+
for (const slot of document.querySelectorAll("[data-render-id]")) {
|
|
1530
|
+
const renderId = slot.getAttribute("data-render-id");
|
|
1531
|
+
if (!renderId) continue;
|
|
1532
|
+
for (const sourceFile of getObservedSourceFiles2(slot)) {
|
|
1533
|
+
observed.push({ renderId, sourceFile });
|
|
1534
|
+
}
|
|
933
1535
|
}
|
|
934
1536
|
}
|
|
935
|
-
|
|
1537
|
+
if (observed.length === 0) return [];
|
|
1538
|
+
const exactFilenameMatches = new Set(
|
|
1539
|
+
resolveUniqueDiagnosticSourceMatches(
|
|
1540
|
+
problem.filename ?? "",
|
|
1541
|
+
observed.map(({ sourceFile }) => sourceFile),
|
|
1542
|
+
{
|
|
1543
|
+
projectRoot: readTempoProjectRoot(),
|
|
1544
|
+
allowExtensionlessJsTs: true
|
|
1545
|
+
}
|
|
1546
|
+
)
|
|
1547
|
+
);
|
|
1548
|
+
if (exactFilenameMatches.size > 0) {
|
|
1549
|
+
return uniqueRenderIds(
|
|
1550
|
+
observed.filter(({ sourceFile }) => exactFilenameMatches.has(sourceFile))
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
const filenameMatches = matchObservedRenderIds(
|
|
1554
|
+
problem.filename ?? "",
|
|
1555
|
+
observed
|
|
1556
|
+
);
|
|
1557
|
+
if (filenameMatches.length > 0) return filenameMatches;
|
|
1558
|
+
const haystack = [problem.message, problem.stack, problem.componentStack].filter(Boolean).join("\n");
|
|
1559
|
+
return matchObservedRenderIds(haystack, observed);
|
|
936
1560
|
}
|
|
937
|
-
var
|
|
938
|
-
function
|
|
1561
|
+
var sourceAnnotationSelector2 = "[data-tempo-source-file], [data-tempo-source-loc], [data-tempo-filepath], [data-tempo-html-filepath]";
|
|
1562
|
+
function getObservedSourceFiles2(slot) {
|
|
939
1563
|
const sourceFiles = /* @__PURE__ */ new Set();
|
|
940
|
-
for (const element of slot.querySelectorAll(
|
|
1564
|
+
for (const element of slot.querySelectorAll(sourceAnnotationSelector2)) {
|
|
941
1565
|
for (const attribute of [
|
|
942
1566
|
"data-tempo-source-file",
|
|
943
1567
|
"data-tempo-filepath",
|
|
@@ -952,10 +1576,30 @@ function getObservedSourceFiles(slot) {
|
|
|
952
1576
|
}
|
|
953
1577
|
return [...sourceFiles];
|
|
954
1578
|
}
|
|
955
|
-
function
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
|
|
1579
|
+
function matchObservedRenderIds(text, observed) {
|
|
1580
|
+
const matches = new Set(
|
|
1581
|
+
resolveUniqueDiagnosticSourceMatches(
|
|
1582
|
+
text,
|
|
1583
|
+
observed.map(({ sourceFile }) => sourceFile),
|
|
1584
|
+
{
|
|
1585
|
+
projectRoot: readTempoProjectRoot(),
|
|
1586
|
+
allowExtensionlessJsTs: true
|
|
1587
|
+
}
|
|
1588
|
+
)
|
|
1589
|
+
);
|
|
1590
|
+
return uniqueRenderIds(
|
|
1591
|
+
observed.filter(({ sourceFile }) => matches.has(sourceFile))
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
function readTempoProjectRoot() {
|
|
1595
|
+
if (typeof document === "undefined") return null;
|
|
1596
|
+
return document.querySelector('meta[name="tempo-source-identity-root"]')?.content.trim() || document.querySelector('meta[name="tempo-project-root"]')?.content.trim() || null;
|
|
1597
|
+
}
|
|
1598
|
+
function uniqueRenderIds(matches) {
|
|
1599
|
+
return [...new Set(matches.map(({ renderId }) => renderId))];
|
|
1600
|
+
}
|
|
1601
|
+
function normalizeCanvasPath(value) {
|
|
1602
|
+
return value.trim();
|
|
959
1603
|
}
|
|
960
1604
|
function installHostProblemCapture(tracker) {
|
|
961
1605
|
const onError = (event) => {
|
|
@@ -987,7 +1631,7 @@ function installHostProblemCapture(tracker) {
|
|
|
987
1631
|
return;
|
|
988
1632
|
}
|
|
989
1633
|
const url = target.getAttribute("src") || target.getAttribute("href") || "";
|
|
990
|
-
const message =
|
|
1634
|
+
const message = `Failed to load ${target.tagName.toLowerCase()}${url ? `: ${url}` : ""}`;
|
|
991
1635
|
const renderId = target.closest("[data-render-id]")?.getAttribute("data-render-id");
|
|
992
1636
|
if (renderId) {
|
|
993
1637
|
tracker.reportComponentProblem(renderId, "resource-load", message);
|
|
@@ -1002,7 +1646,7 @@ function installHostProblemCapture(tracker) {
|
|
|
1002
1646
|
const families = faces.map((face) => face.family).filter(Boolean).join(", ");
|
|
1003
1647
|
tracker.reportHostProblem(
|
|
1004
1648
|
"resource-load",
|
|
1005
|
-
|
|
1649
|
+
`Failed to load font${families ? `: ${families}` : ""}`
|
|
1006
1650
|
);
|
|
1007
1651
|
};
|
|
1008
1652
|
const fontFaceSet = typeof document.fonts?.addEventListener === "function" ? document.fonts : void 0;
|
|
@@ -1021,15 +1665,7 @@ function installHostProblemCapture(tracker) {
|
|
|
1021
1665
|
}
|
|
1022
1666
|
function installViteProblemCapture(tracker) {
|
|
1023
1667
|
const reconcileViteOverlay = () => {
|
|
1024
|
-
|
|
1025
|
-
if (problem) {
|
|
1026
|
-
tracker.reportHostProblem("vite-overlay", problem.message, {
|
|
1027
|
-
stack: problem.stack,
|
|
1028
|
-
filename: problem.filename
|
|
1029
|
-
});
|
|
1030
|
-
} else {
|
|
1031
|
-
tracker.clearHostProblem(["vite-overlay"]);
|
|
1032
|
-
}
|
|
1668
|
+
tracker.reconcileViteOverlayProjection();
|
|
1033
1669
|
};
|
|
1034
1670
|
const observer = new MutationObserver(reconcileViteOverlay);
|
|
1035
1671
|
if (document.body) {
|
|
@@ -1037,26 +1673,16 @@ function installViteProblemCapture(tracker) {
|
|
|
1037
1673
|
reconcileViteOverlay();
|
|
1038
1674
|
void Promise.resolve().then(reconcileViteOverlay);
|
|
1039
1675
|
}
|
|
1040
|
-
const
|
|
1041
|
-
const
|
|
1676
|
+
const evalFailedModules = /* @__PURE__ */ new Map();
|
|
1677
|
+
const latestEvaluationFailure = () => {
|
|
1042
1678
|
let latest;
|
|
1043
|
-
for (const problem of
|
|
1679
|
+
for (const problem of evalFailedModules.values()) {
|
|
1044
1680
|
if (!latest || problem.timestamp >= latest.timestamp) latest = problem;
|
|
1045
1681
|
}
|
|
1046
1682
|
return latest;
|
|
1047
1683
|
};
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
for (const key of [...viteHmrFailedModules.keys()]) {
|
|
1051
|
-
if (key !== pathlessViteErrorKey && modulePathsMatch(key, path)) {
|
|
1052
|
-
viteHmrFailedModules.delete(key);
|
|
1053
|
-
removed = true;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
return removed;
|
|
1057
|
-
};
|
|
1058
|
-
const reconcileViteHmrHostProblem = () => {
|
|
1059
|
-
const latest = latestViteHmrFailure();
|
|
1684
|
+
const reconcileEvaluationHostProblem = () => {
|
|
1685
|
+
const latest = latestEvaluationFailure();
|
|
1060
1686
|
if (latest) {
|
|
1061
1687
|
tracker.reportHostProblem("vite-hmr-error", latest.message, latest);
|
|
1062
1688
|
} else {
|
|
@@ -1064,107 +1690,12 @@ function installViteProblemCapture(tracker) {
|
|
|
1064
1690
|
}
|
|
1065
1691
|
};
|
|
1066
1692
|
const failedReloadPattern = /^Failed to reload (.+?)\. This could be due to/;
|
|
1067
|
-
|
|
1068
|
-
let viteHmrCycleActive = false;
|
|
1069
|
-
let cycleFailedPaths = /* @__PURE__ */ new Map();
|
|
1070
|
-
let lastCycleViteErrorDetail;
|
|
1071
|
-
let hmrCycleSeq = 0;
|
|
1072
|
-
const cleanUpdateCycleByPath = /* @__PURE__ */ new Map();
|
|
1073
|
-
const onViteBeforeUpdate = () => {
|
|
1074
|
-
viteHmrCycleActive = true;
|
|
1075
|
-
hmrCycleSeq += 1;
|
|
1076
|
-
cycleFailedPaths = /* @__PURE__ */ new Map();
|
|
1077
|
-
lastCycleViteErrorDetail = void 0;
|
|
1078
|
-
tracker.noteHmrUpdateStarted();
|
|
1079
|
-
};
|
|
1080
|
-
const onViteAfterUpdate = (payload) => {
|
|
1081
|
-
const updatedPaths = readUpdatePaths(payload);
|
|
1082
|
-
let shouldReconcile = false;
|
|
1083
|
-
const failedThisCycle = [...cycleFailedPaths.keys()];
|
|
1084
|
-
for (const updatedPath of updatedPaths) {
|
|
1085
|
-
if (failedThisCycle.some((failed) => modulePathsMatch(failed, updatedPath))) {
|
|
1086
|
-
continue;
|
|
1087
|
-
}
|
|
1088
|
-
cleanUpdateCycleByPath.set(normalizeModulePath(updatedPath), hmrCycleSeq);
|
|
1089
|
-
for (const key of [...viteHmrFailedModules.keys()]) {
|
|
1090
|
-
if (key === pathlessViteErrorKey) continue;
|
|
1091
|
-
if (modulePathsMatch(key, updatedPath)) {
|
|
1092
|
-
viteHmrFailedModules.delete(key);
|
|
1093
|
-
shouldReconcile = true;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
if (updatedPaths.length > 0 && !cycleFailedPaths.has(pathlessViteErrorKey)) {
|
|
1098
|
-
if (viteHmrFailedModules.delete(pathlessViteErrorKey)) {
|
|
1099
|
-
shouldReconcile = true;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
for (const [path, problem] of cycleFailedPaths) {
|
|
1103
|
-
viteHmrFailedModules.set(path, problem);
|
|
1104
|
-
shouldReconcile = true;
|
|
1105
|
-
void verifyModuleStillExists(path).then((exists) => {
|
|
1106
|
-
if (exists) return;
|
|
1107
|
-
if (deleteViteHmrFailureForPath(path)) {
|
|
1108
|
-
reconcileViteHmrHostProblem();
|
|
1109
|
-
}
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
viteHmrCycleActive = false;
|
|
1113
|
-
cycleFailedPaths = /* @__PURE__ */ new Map();
|
|
1114
|
-
if (shouldReconcile) reconcileViteHmrHostProblem();
|
|
1115
|
-
};
|
|
1116
|
-
const onViteError = (payload) => {
|
|
1117
|
-
const error = readViteError(payload);
|
|
1118
|
-
if (!error) return;
|
|
1119
|
-
lastCycleViteErrorDetail = error;
|
|
1120
|
-
const path = error.filename ?? pathlessViteErrorKey;
|
|
1121
|
-
const problem = createProblem("vite-hmr-error", error.message, {
|
|
1122
|
-
stack: error.stack,
|
|
1123
|
-
filename: error.filename
|
|
1124
|
-
});
|
|
1125
|
-
if (viteHmrCycleActive) {
|
|
1126
|
-
cycleFailedPaths.set(path, problem);
|
|
1127
|
-
} else {
|
|
1128
|
-
viteHmrFailedModules.set(path, problem);
|
|
1129
|
-
}
|
|
1130
|
-
reconcileViteHmrHostProblem();
|
|
1131
|
-
};
|
|
1132
|
-
let hotEventsCancelled = false;
|
|
1133
|
-
let subscribedHot;
|
|
1134
|
-
const subscribeHotEvents = (hot2) => {
|
|
1135
|
-
subscribedHot = hot2;
|
|
1136
|
-
hot2.on?.("vite:beforeUpdate", onViteBeforeUpdate);
|
|
1137
|
-
hot2.on?.("vite:afterUpdate", onViteAfterUpdate);
|
|
1138
|
-
hot2.on?.("vite:error", onViteError);
|
|
1139
|
-
};
|
|
1140
|
-
const hot = readViteHot();
|
|
1141
|
-
if (hot?.on) {
|
|
1142
|
-
subscribeHotEvents(hot);
|
|
1143
|
-
} else {
|
|
1144
|
-
void import(
|
|
1145
|
-
/* @vite-ignore */
|
|
1146
|
-
/* webpackIgnore: true */
|
|
1147
|
-
/* turbopackIgnore: true */
|
|
1148
|
-
"/@vite/client"
|
|
1149
|
-
).then((client) => {
|
|
1150
|
-
const createHotContext = client.createHotContext;
|
|
1151
|
-
const context = createHotContext?.("/__tempo-canvas-host__");
|
|
1152
|
-
if (!context || hotEventsCancelled) return;
|
|
1153
|
-
subscribeHotEvents(context);
|
|
1154
|
-
}).catch(() => {
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1693
|
+
let lastViteConsoleErrorDetail = null;
|
|
1157
1694
|
const stopClearedWatch = tracker.watchHostProblemCleared((problem) => {
|
|
1158
1695
|
if (problem.sourceKind !== "vite-hmr-error") return;
|
|
1159
|
-
const
|
|
1160
|
-
let removed = false;
|
|
1161
|
-
if (filename == null) {
|
|
1162
|
-
removed = viteHmrFailedModules.delete(pathlessViteErrorKey);
|
|
1163
|
-
} else {
|
|
1164
|
-
removed = deleteViteHmrFailureForPath(filename);
|
|
1165
|
-
}
|
|
1696
|
+
const removed = problem.filename ? evalFailedModules.delete(problem.filename) : false;
|
|
1166
1697
|
if (!removed) return;
|
|
1167
|
-
|
|
1698
|
+
queueMicrotask(reconcileEvaluationHostProblem);
|
|
1168
1699
|
});
|
|
1169
1700
|
const originalConsoleError = console.error;
|
|
1170
1701
|
const patchedConsoleError = (...args) => {
|
|
@@ -1173,79 +1704,76 @@ function installViteProblemCapture(tracker) {
|
|
|
1173
1704
|
if (!error) return;
|
|
1174
1705
|
const failedReload = failedReloadPattern.exec(error.message);
|
|
1175
1706
|
if (failedReload) {
|
|
1176
|
-
const path = failedReload[1];
|
|
1177
|
-
const detail =
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
filename: detail?.filename ?? path
|
|
1184
|
-
}
|
|
1185
|
-
);
|
|
1186
|
-
if (detail) {
|
|
1187
|
-
cycleFailedPaths.set(path, problem);
|
|
1188
|
-
viteHmrFailedModules.set(path, problem);
|
|
1189
|
-
reconcileViteHmrHostProblem();
|
|
1190
|
-
} else {
|
|
1191
|
-
const observedCycleSeq = hmrCycleSeq;
|
|
1192
|
-
void verifyModuleStillExists(path).then((exists) => {
|
|
1193
|
-
const cleanSeq = cleanUpdateCycleByPath.get(
|
|
1194
|
-
normalizeModulePath(path)
|
|
1195
|
-
);
|
|
1196
|
-
if (cleanSeq !== void 0 && cleanSeq > observedCycleSeq) return;
|
|
1197
|
-
if (exists) viteHmrFailedModules.set(path, problem);
|
|
1198
|
-
else viteHmrFailedModules.delete(path);
|
|
1199
|
-
reconcileViteHmrHostProblem();
|
|
1707
|
+
const path = failedReload[1] ?? error.message;
|
|
1708
|
+
const detail = lastViteConsoleErrorDetail;
|
|
1709
|
+
lastViteConsoleErrorDetail = null;
|
|
1710
|
+
if (detail && !/failed to fetch/i.test(detail.message)) {
|
|
1711
|
+
const problem = createProblem("vite-hmr-error", detail.message, {
|
|
1712
|
+
stack: detail.stack,
|
|
1713
|
+
filename: path
|
|
1200
1714
|
});
|
|
1715
|
+
evalFailedModules.set(path, problem);
|
|
1716
|
+
reconcileEvaluationHostProblem();
|
|
1717
|
+
getCanvasHostRecoveryFeed().publish({
|
|
1718
|
+
type: "module-load-failure",
|
|
1719
|
+
path,
|
|
1720
|
+
message: detail.message
|
|
1721
|
+
});
|
|
1722
|
+
return;
|
|
1201
1723
|
}
|
|
1724
|
+
void (async () => {
|
|
1725
|
+
for (const delayMs of FAILED_RELOAD_PROBE_DELAYS_MS) {
|
|
1726
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
1727
|
+
try {
|
|
1728
|
+
if (!await moduleTransformSucceeds(path)) continue;
|
|
1729
|
+
const snapshot = tracker.snapshot();
|
|
1730
|
+
const compileErrorFiles = /* @__PURE__ */ new Set();
|
|
1731
|
+
for (const problem of [
|
|
1732
|
+
snapshot.hostProblem,
|
|
1733
|
+
...snapshot.componentProblems.map((entry) => entry.problem),
|
|
1734
|
+
...snapshot.canvasProblems.map((entry) => entry.problem)
|
|
1735
|
+
]) {
|
|
1736
|
+
if (!problem) continue;
|
|
1737
|
+
if (!isProjectedViteProblemSourceKind(problem.sourceKind)) {
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
if (problem.filename) compileErrorFiles.add(problem.filename);
|
|
1741
|
+
}
|
|
1742
|
+
for (const file of compileErrorFiles) {
|
|
1743
|
+
if (await compileErrorFileStillBroken(file)) return;
|
|
1744
|
+
}
|
|
1745
|
+
getCanvasHostRecoveryFeed().publish({
|
|
1746
|
+
type: "module-update-dropped",
|
|
1747
|
+
path,
|
|
1748
|
+
message: error.message
|
|
1749
|
+
});
|
|
1750
|
+
return;
|
|
1751
|
+
} catch {
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
})();
|
|
1202
1756
|
return;
|
|
1203
1757
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
return;
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1758
|
+
lastViteConsoleErrorDetail = error;
|
|
1759
|
+
queueMicrotask(() => {
|
|
1760
|
+
if (lastViteConsoleErrorDetail !== error) return;
|
|
1761
|
+
lastViteConsoleErrorDetail = null;
|
|
1762
|
+
tracker.reportProblemNearRender("console-vite-error", error.message, {
|
|
1763
|
+
stack: error.stack,
|
|
1764
|
+
filename: error.filename
|
|
1765
|
+
});
|
|
1211
1766
|
});
|
|
1212
1767
|
};
|
|
1213
1768
|
console.error = patchedConsoleError;
|
|
1214
1769
|
return () => {
|
|
1215
1770
|
observer.disconnect();
|
|
1216
1771
|
stopClearedWatch();
|
|
1217
|
-
hotEventsCancelled = true;
|
|
1218
|
-
subscribedHot?.off?.("vite:beforeUpdate", onViteBeforeUpdate);
|
|
1219
|
-
subscribedHot?.off?.("vite:afterUpdate", onViteAfterUpdate);
|
|
1220
|
-
subscribedHot?.off?.("vite:error", onViteError);
|
|
1221
1772
|
if (console.error === patchedConsoleError) {
|
|
1222
1773
|
console.error = originalConsoleError;
|
|
1223
1774
|
}
|
|
1224
1775
|
};
|
|
1225
1776
|
}
|
|
1226
|
-
function installCurrentProblemInspector(tracker) {
|
|
1227
|
-
const maybeWindow = window;
|
|
1228
|
-
const previous = maybeWindow.__tempoErrorTrackingInspectCurrentProblems;
|
|
1229
|
-
const inspect = (options = {}) => mergeCurrentProblemSnapshots(
|
|
1230
|
-
tracker.inspectCurrentProblems(options),
|
|
1231
|
-
previous?.(options) ?? null
|
|
1232
|
-
);
|
|
1233
|
-
maybeWindow.__tempoErrorTrackingInspectCurrentProblems = inspect;
|
|
1234
|
-
return () => {
|
|
1235
|
-
if (maybeWindow.__tempoErrorTrackingInspectCurrentProblems === inspect) {
|
|
1236
|
-
maybeWindow.__tempoErrorTrackingInspectCurrentProblems = previous;
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
function readViteHot() {
|
|
1241
|
-
const explicitHot = window.__tempoCanvasHostViteHot;
|
|
1242
|
-
if (explicitHot) return explicitHot;
|
|
1243
|
-
try {
|
|
1244
|
-
return eval("import.meta && import.meta.hot");
|
|
1245
|
-
} catch {
|
|
1246
|
-
return void 0;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
1777
|
function readCurrentViteOverlay() {
|
|
1250
1778
|
if (typeof document === "undefined") return void 0;
|
|
1251
1779
|
const overlay = document.querySelector("vite-error-overlay");
|
|
@@ -1300,77 +1828,9 @@ function readViteConsoleError(first, second) {
|
|
|
1300
1828
|
filename: detail?.filename
|
|
1301
1829
|
} : void 0;
|
|
1302
1830
|
}
|
|
1303
|
-
function readUpdatePaths(payload) {
|
|
1304
|
-
const updates = typeof payload === "object" && payload !== null && Array.isArray(payload.updates) ? payload.updates : [];
|
|
1305
|
-
const paths = /* @__PURE__ */ new Set();
|
|
1306
|
-
const collectPath = (value) => {
|
|
1307
|
-
if (typeof value === "string") paths.add(value);
|
|
1308
|
-
};
|
|
1309
|
-
for (const update of updates) {
|
|
1310
|
-
collectPath(update.path);
|
|
1311
|
-
collectPath(update.acceptedPath);
|
|
1312
|
-
collectPath(update.id);
|
|
1313
|
-
}
|
|
1314
|
-
return [...paths];
|
|
1315
|
-
}
|
|
1316
|
-
function normalizeModulePath(value) {
|
|
1317
|
-
const cutIndex = value.search(/[?#]/);
|
|
1318
|
-
return cutIndex === -1 ? value : value.slice(0, cutIndex);
|
|
1319
|
-
}
|
|
1320
|
-
function modulePathsMatch(a, b) {
|
|
1321
|
-
const left = normalizeModulePath(a);
|
|
1322
|
-
const right = normalizeModulePath(b);
|
|
1323
|
-
if (!left || !right) return false;
|
|
1324
|
-
if (left === right) return true;
|
|
1325
|
-
const [longer, shorter] = left.length >= right.length ? [left, right] : [right, left];
|
|
1326
|
-
return shorter.startsWith("/") && longer.endsWith(shorter);
|
|
1327
|
-
}
|
|
1328
|
-
async function verifyModuleStillExists(path) {
|
|
1329
|
-
if (typeof fetch !== "function") return true;
|
|
1330
|
-
try {
|
|
1331
|
-
const response = await fetch(path, { cache: "no-store" });
|
|
1332
|
-
if ("ok" in response && response.ok === false) return false;
|
|
1333
|
-
const contentType = response.headers.get("content-type") || "";
|
|
1334
|
-
return !contentType.includes("text/html");
|
|
1335
|
-
} catch {
|
|
1336
|
-
return true;
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
function mergeCurrentProblemSnapshots(primary, fallback) {
|
|
1340
|
-
if (!fallback) return primary;
|
|
1341
|
-
const currentRenderFailures = [...primary.currentRenderFailures];
|
|
1342
|
-
const seen = new Set(
|
|
1343
|
-
currentRenderFailures.map(
|
|
1344
|
-
(entry) => `${entry.renderId ?? ""}:${entry.failure.sourceKind}:${entry.failure.message}`
|
|
1345
|
-
)
|
|
1346
|
-
);
|
|
1347
|
-
for (const entry of fallback.currentRenderFailures) {
|
|
1348
|
-
const key = `${entry.renderId ?? ""}:${entry.failure.sourceKind}:${entry.failure.message}`;
|
|
1349
|
-
if (seen.has(key)) continue;
|
|
1350
|
-
seen.add(key);
|
|
1351
|
-
currentRenderFailures.push(entry);
|
|
1352
|
-
}
|
|
1353
|
-
const currentCanvasFailures = [...primary.currentCanvasFailures ?? []];
|
|
1354
|
-
const seenCanvas = new Set(
|
|
1355
|
-
currentCanvasFailures.map(
|
|
1356
|
-
(entry) => `${entry.canvasPath}:${entry.failure.sourceKind}:${entry.failure.message}`
|
|
1357
|
-
)
|
|
1358
|
-
);
|
|
1359
|
-
for (const entry of fallback.currentCanvasFailures ?? []) {
|
|
1360
|
-
const key = `${entry.canvasPath}:${entry.failure.sourceKind}:${entry.failure.message}`;
|
|
1361
|
-
if (seenCanvas.has(key)) continue;
|
|
1362
|
-
seenCanvas.add(key);
|
|
1363
|
-
currentCanvasFailures.push(entry);
|
|
1364
|
-
}
|
|
1365
|
-
return {
|
|
1366
|
-
currentHostFailure: primary.currentHostFailure ?? fallback.currentHostFailure,
|
|
1367
|
-
currentRenderFailures,
|
|
1368
|
-
currentCanvasFailures,
|
|
1369
|
-
observedAt: Math.max(primary.observedAt, fallback.observedAt)
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
1831
|
|
|
1373
1832
|
// canvas/use-canvas-host-postmessage.ts
|
|
1833
|
+
var DEFAULT_MAX_CACHED_RENDERS = 20;
|
|
1374
1834
|
function postToMessageSource(source, response, targetOrigin) {
|
|
1375
1835
|
const origin = safePostMessageTargetOrigin(targetOrigin);
|
|
1376
1836
|
if (source && "postMessage" in source && source !== window) {
|
|
@@ -1386,39 +1846,103 @@ function safePostMessageTargetOrigin(targetOrigin) {
|
|
|
1386
1846
|
const currentOrigin = window.location.origin;
|
|
1387
1847
|
return currentOrigin && currentOrigin !== "null" ? currentOrigin : "*";
|
|
1388
1848
|
}
|
|
1389
|
-
function
|
|
1390
|
-
|
|
1849
|
+
function acknowledgeWatchEstablishment(request) {
|
|
1850
|
+
if (request.establishment.status !== "pending") return;
|
|
1851
|
+
request.establishment.status = "established";
|
|
1852
|
+
postToMessageSource(
|
|
1853
|
+
request.source,
|
|
1854
|
+
{
|
|
1855
|
+
type: "render-pool:ack",
|
|
1856
|
+
requestId: request.requestId,
|
|
1857
|
+
command: request.commandType
|
|
1858
|
+
},
|
|
1859
|
+
request.targetOrigin
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
function rejectWatchEstablishment(request, error) {
|
|
1863
|
+
if (request.establishment.status !== "pending") return;
|
|
1864
|
+
request.establishment.status = "failed";
|
|
1865
|
+
postWatchError(request, error);
|
|
1866
|
+
}
|
|
1867
|
+
function postWatchError(request, error) {
|
|
1868
|
+
postToMessageSource(
|
|
1869
|
+
request.source,
|
|
1870
|
+
{
|
|
1871
|
+
type: "render-pool:error",
|
|
1872
|
+
requestId: request.requestId,
|
|
1873
|
+
watchId: request.watchId,
|
|
1874
|
+
command: request.commandType,
|
|
1875
|
+
error: error.message
|
|
1876
|
+
},
|
|
1877
|
+
request.targetOrigin
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
function readWatchResumeOptions(payload) {
|
|
1881
|
+
const flush = payload.flush;
|
|
1882
|
+
const triggers = Array.isArray(payload.triggers) ? payload.triggers.filter(
|
|
1883
|
+
(trigger) => trigger === "viewport-capture"
|
|
1884
|
+
) : [];
|
|
1885
|
+
const validFlush = flush === "always" || flush === "if-dirty" || flush === "never" ? flush : void 0;
|
|
1886
|
+
return validFlush === void 0 && triggers.length === 0 ? void 0 : { flush: validFlush, triggers };
|
|
1887
|
+
}
|
|
1888
|
+
function setRuntimeWatchPaused(watch, paused, resumeOptions) {
|
|
1889
|
+
if (watch.setPaused) {
|
|
1890
|
+
if (resumeOptions === void 0) {
|
|
1891
|
+
watch.setPaused(paused);
|
|
1892
|
+
} else {
|
|
1893
|
+
watch.setPaused(paused, resumeOptions);
|
|
1894
|
+
}
|
|
1895
|
+
} else if (paused) {
|
|
1896
|
+
watch.pause?.();
|
|
1897
|
+
} else {
|
|
1898
|
+
if (resumeOptions === void 0) {
|
|
1899
|
+
watch.resume?.();
|
|
1900
|
+
} else {
|
|
1901
|
+
watch.resume?.(resumeOptions);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
function useCanvasHostPostMessage(registeredCanvasPaths = []) {
|
|
1906
|
+
const [renderEntriesById, setRenderEntriesById] = useState2(
|
|
1391
1907
|
() => /* @__PURE__ */ new Map()
|
|
1392
1908
|
);
|
|
1393
|
-
const [watchRequestsById, setWatchRequestsById] =
|
|
1909
|
+
const [watchRequestsById, setWatchRequestsById] = useState2(
|
|
1394
1910
|
() => /* @__PURE__ */ new Map()
|
|
1395
1911
|
);
|
|
1396
|
-
const [renderCommitVersionById, setRenderCommitVersionById] =
|
|
1912
|
+
const [renderCommitVersionById, setRenderCommitVersionById] = useState2(
|
|
1397
1913
|
() => /* @__PURE__ */ new Map()
|
|
1398
1914
|
);
|
|
1399
|
-
const renderEntriesRef =
|
|
1400
|
-
const watchRequestsRef =
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1404
|
-
const
|
|
1405
|
-
const
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
const sourceAnnotatedCommitTimesRef = useRef(/* @__PURE__ */ new Map());
|
|
1409
|
-
const buildProblemSnapshot = useCallback2(
|
|
1410
|
-
() => problemTrackerRef.current.snapshot(),
|
|
1411
|
-
[]
|
|
1915
|
+
const renderEntriesRef = useRef2(renderEntriesById);
|
|
1916
|
+
const watchRequestsRef = useRef2(watchRequestsById);
|
|
1917
|
+
const registeredCanvasPathsRef = useRef2([]);
|
|
1918
|
+
registeredCanvasPathsRef.current = registeredCanvasPaths;
|
|
1919
|
+
const maxCachedRef = useRef2(DEFAULT_MAX_CACHED_RENDERS);
|
|
1920
|
+
const legacyHealthRef = useRef2(createLegacyHostHealth());
|
|
1921
|
+
const renderedRenderIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
1922
|
+
const pendingRenderWaitersRef = useRef2(
|
|
1923
|
+
/* @__PURE__ */ new Map()
|
|
1412
1924
|
);
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1925
|
+
const watchesRef = useRef2(/* @__PURE__ */ new Map());
|
|
1926
|
+
const startingWatchesRef = useRef2(
|
|
1927
|
+
/* @__PURE__ */ new Map()
|
|
1928
|
+
);
|
|
1929
|
+
const problemWatchersRef = useRef2(/* @__PURE__ */ new Map());
|
|
1930
|
+
const problemTrackerRef = useRef2(createCanvasHostProblemTracker());
|
|
1931
|
+
const updateWatchRequests = useCallback3(
|
|
1932
|
+
(update) => {
|
|
1933
|
+
const current = watchRequestsRef.current;
|
|
1934
|
+
const next = update(current);
|
|
1935
|
+
if (next === current) return;
|
|
1936
|
+
watchRequestsRef.current = next;
|
|
1937
|
+
setWatchRequestsById(next);
|
|
1418
1938
|
},
|
|
1419
1939
|
[]
|
|
1420
1940
|
);
|
|
1421
|
-
const
|
|
1941
|
+
const buildProblemSnapshot = useCallback3(
|
|
1942
|
+
() => problemTrackerRef.current.snapshot(),
|
|
1943
|
+
[]
|
|
1944
|
+
);
|
|
1945
|
+
const publishProblemSnapshot = useCallback3(() => {
|
|
1422
1946
|
const payload = buildProblemSnapshot();
|
|
1423
1947
|
for (const watcher of problemWatchersRef.current.values()) {
|
|
1424
1948
|
postToMessageSource(
|
|
@@ -1433,16 +1957,16 @@ function useCanvasHostPostMessage() {
|
|
|
1433
1957
|
);
|
|
1434
1958
|
}
|
|
1435
1959
|
}, [buildProblemSnapshot]);
|
|
1436
|
-
const setEntries =
|
|
1960
|
+
const setEntries = useCallback3(
|
|
1437
1961
|
(update) => {
|
|
1438
1962
|
setRenderEntriesById((entries) => {
|
|
1439
1963
|
const next = update(entries);
|
|
1440
1964
|
renderEntriesRef.current = next;
|
|
1965
|
+
problemTrackerRef.current.syncRenderSourcePaths([...next.values()]);
|
|
1441
1966
|
for (const renderId of [...renderedRenderIdsRef.current]) {
|
|
1442
1967
|
if (!next.has(renderId)) {
|
|
1443
1968
|
renderedRenderIdsRef.current.delete(renderId);
|
|
1444
|
-
|
|
1445
|
-
sourceAnnotatedCommitTimesRef.current.delete(renderId);
|
|
1969
|
+
legacyHealthRef.current.forgetRender(renderId);
|
|
1446
1970
|
}
|
|
1447
1971
|
}
|
|
1448
1972
|
return next;
|
|
@@ -1450,7 +1974,7 @@ function useCanvasHostPostMessage() {
|
|
|
1450
1974
|
},
|
|
1451
1975
|
[]
|
|
1452
1976
|
);
|
|
1453
|
-
const waitForRender =
|
|
1977
|
+
const waitForRender = useCallback3(
|
|
1454
1978
|
(request) => {
|
|
1455
1979
|
const current = renderEntriesRef.current.get(request.renderId);
|
|
1456
1980
|
const alreadyRendered = current?.status === "active" && renderedRenderIdsRef.current.has(request.renderId) && renderRequestMatchesEntry(current, request);
|
|
@@ -1459,14 +1983,14 @@ function useCanvasHostPostMessage() {
|
|
|
1459
1983
|
return Promise.resolve();
|
|
1460
1984
|
}
|
|
1461
1985
|
return new Promise((resolve, reject) => {
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1464
|
-
|
|
1986
|
+
const pendingWaiters = pendingRenderWaitersRef.current.get(request.renderId) ?? [];
|
|
1987
|
+
pendingWaiters.push({ resolve, reject });
|
|
1988
|
+
pendingRenderWaitersRef.current.set(request.renderId, pendingWaiters);
|
|
1465
1989
|
});
|
|
1466
1990
|
},
|
|
1467
1991
|
[setEntries]
|
|
1468
1992
|
);
|
|
1469
|
-
const releaseRenderLease =
|
|
1993
|
+
const releaseRenderLease = useCallback3(
|
|
1470
1994
|
(renderId) => {
|
|
1471
1995
|
setEntries(
|
|
1472
1996
|
(entries) => releaseRender(entries, renderId, maxCachedRef.current)
|
|
@@ -1474,79 +1998,111 @@ function useCanvasHostPostMessage() {
|
|
|
1474
1998
|
},
|
|
1475
1999
|
[setEntries]
|
|
1476
2000
|
);
|
|
1477
|
-
const stopRuntimeWatch =
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
2001
|
+
const stopRuntimeWatch = useCallback3(
|
|
2002
|
+
async (watchId, establishment) => {
|
|
2003
|
+
const existingWatch = watchesRef.current.get(watchId);
|
|
2004
|
+
if (!existingWatch || establishment && existingWatch.establishment !== establishment) {
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
watchesRef.current.delete(watchId);
|
|
2008
|
+
await existingWatch.watch.stop();
|
|
2009
|
+
},
|
|
2010
|
+
[]
|
|
2011
|
+
);
|
|
2012
|
+
const removeWatchRequest = useCallback3(
|
|
2013
|
+
async (watchId, reason) => {
|
|
1485
2014
|
const existingRequest = watchRequestsRef.current.get(watchId);
|
|
2015
|
+
if (existingRequest) {
|
|
2016
|
+
rejectWatchEstablishment(
|
|
2017
|
+
existingRequest,
|
|
2018
|
+
reason ?? new Error(
|
|
2019
|
+
`Canvas host watch ${watchId} was cancelled before establishment`
|
|
2020
|
+
)
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
1486
2023
|
try {
|
|
1487
|
-
await stopRuntimeWatch(watchId);
|
|
2024
|
+
await stopRuntimeWatch(watchId, existingRequest?.establishment);
|
|
1488
2025
|
} finally {
|
|
1489
|
-
if (
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
2026
|
+
if (existingRequest) {
|
|
2027
|
+
updateWatchRequests((requests) => {
|
|
2028
|
+
if (requests.get(watchId)?.establishment !== existingRequest.establishment) {
|
|
2029
|
+
return requests;
|
|
2030
|
+
}
|
|
2031
|
+
const next = new Map(requests);
|
|
2032
|
+
next.delete(watchId);
|
|
2033
|
+
return next;
|
|
2034
|
+
});
|
|
2035
|
+
releaseRenderLease(existingRequest.request.renderId);
|
|
2036
|
+
}
|
|
1497
2037
|
}
|
|
1498
2038
|
},
|
|
1499
|
-
[releaseRenderLease, stopRuntimeWatch]
|
|
2039
|
+
[releaseRenderLease, stopRuntimeWatch, updateWatchRequests]
|
|
2040
|
+
);
|
|
2041
|
+
const suspendEstablishedWatch = useCallback3(
|
|
2042
|
+
(request) => {
|
|
2043
|
+
if (request.establishment.status !== "established") return;
|
|
2044
|
+
void stopRuntimeWatch(request.watchId, request.establishment).catch(
|
|
2045
|
+
() => {
|
|
2046
|
+
}
|
|
2047
|
+
);
|
|
2048
|
+
},
|
|
2049
|
+
[stopRuntimeWatch]
|
|
1500
2050
|
);
|
|
1501
|
-
const buildState =
|
|
1502
|
-
() => buildRenderStatePayload(
|
|
2051
|
+
const buildState = useCallback3(
|
|
2052
|
+
() => buildRenderStatePayload(
|
|
2053
|
+
renderEntriesRef.current,
|
|
2054
|
+
maxCachedRef.current,
|
|
2055
|
+
registeredCanvasPathsRef.current
|
|
2056
|
+
),
|
|
1503
2057
|
[]
|
|
1504
2058
|
);
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
claimErrorBoundaryTripped: problemTrackerRef.current.hasComponentProblem(renderId),
|
|
1523
|
-
observedAt: Date.now()
|
|
1524
|
-
};
|
|
2059
|
+
const markStoryboardRendered = useCallback3((storyboardId) => {
|
|
2060
|
+
renderedRenderIdsRef.current.add(storyboardId);
|
|
2061
|
+
legacyHealthRef.current.recordRenderCommit(storyboardId);
|
|
2062
|
+
setRenderCommitVersionById((versions) => {
|
|
2063
|
+
const next = new Map(versions);
|
|
2064
|
+
next.set(storyboardId, (next.get(storyboardId) ?? 0) + 1);
|
|
2065
|
+
return next;
|
|
2066
|
+
});
|
|
2067
|
+
problemTrackerRef.current.clearRecoveredComponentProblemsAfterRender(
|
|
2068
|
+
storyboardId
|
|
2069
|
+
);
|
|
2070
|
+
const pendingWaiters = pendingRenderWaitersRef.current.get(storyboardId);
|
|
2071
|
+
if (!pendingWaiters) return;
|
|
2072
|
+
pendingRenderWaitersRef.current.delete(storyboardId);
|
|
2073
|
+
for (const waiter of pendingWaiters) {
|
|
2074
|
+
waiter.resolve();
|
|
2075
|
+
}
|
|
1525
2076
|
}, []);
|
|
1526
|
-
const
|
|
2077
|
+
const markStoryboardUnmounted = useCallback3(
|
|
1527
2078
|
(storyboardId) => {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
2079
|
+
queueMicrotask(() => {
|
|
2080
|
+
const remounted = [
|
|
2081
|
+
...document.querySelectorAll("[data-render-id]")
|
|
2082
|
+
].some(
|
|
2083
|
+
(element) => element.getAttribute("data-render-id") === storyboardId
|
|
2084
|
+
);
|
|
2085
|
+
if (remounted) return;
|
|
2086
|
+
renderedRenderIdsRef.current.delete(storyboardId);
|
|
2087
|
+
for (const request of watchRequestsRef.current.values()) {
|
|
2088
|
+
if (request.request.renderId === storyboardId) {
|
|
2089
|
+
suspendEstablishedWatch(request);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
const pendingWaiters = pendingRenderWaitersRef.current.get(storyboardId);
|
|
2093
|
+
if (!pendingWaiters) return;
|
|
2094
|
+
pendingRenderWaitersRef.current.delete(storyboardId);
|
|
2095
|
+
const error = new Error(
|
|
2096
|
+
`Storyboard ${JSON.stringify(storyboardId)} unmounted before its requested render committed`
|
|
2097
|
+
);
|
|
2098
|
+
for (const waiter of pendingWaiters) {
|
|
2099
|
+
waiter.reject(error);
|
|
2100
|
+
}
|
|
1536
2101
|
});
|
|
1537
|
-
problemTrackerRef.current.clearRecoveredComponentProblemsAfterRender(
|
|
1538
|
-
storyboardId
|
|
1539
|
-
);
|
|
1540
|
-
const pendingAcks = pendingRenderAcksRef.current.get(storyboardId);
|
|
1541
|
-
if (!pendingAcks) return;
|
|
1542
|
-
pendingRenderAcksRef.current.delete(storyboardId);
|
|
1543
|
-
for (const ack of pendingAcks) {
|
|
1544
|
-
ack.resolve();
|
|
1545
|
-
}
|
|
1546
2102
|
},
|
|
1547
|
-
[
|
|
2103
|
+
[suspendEstablishedWatch]
|
|
1548
2104
|
);
|
|
1549
|
-
const reportStoryboardError =
|
|
2105
|
+
const reportStoryboardError = useCallback3(
|
|
1550
2106
|
(storyboardId, error) => {
|
|
1551
2107
|
renderedRenderIdsRef.current.delete(storyboardId);
|
|
1552
2108
|
problemTrackerRef.current.reportComponentProblem(
|
|
@@ -1558,28 +2114,79 @@ function useCanvasHostPostMessage() {
|
|
|
1558
2114
|
componentStack: error.componentStack
|
|
1559
2115
|
}
|
|
1560
2116
|
);
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
for (const
|
|
1566
|
-
|
|
2117
|
+
const renderError = new Error(error.message);
|
|
2118
|
+
const pendingWaiters = pendingRenderWaitersRef.current.get(storyboardId);
|
|
2119
|
+
if (pendingWaiters) {
|
|
2120
|
+
pendingRenderWaitersRef.current.delete(storyboardId);
|
|
2121
|
+
for (const waiter of pendingWaiters) {
|
|
2122
|
+
waiter.reject(renderError);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
for (const request of watchRequestsRef.current.values()) {
|
|
2126
|
+
if (request.request.renderId !== storyboardId || request.establishment.status === "failed") {
|
|
2127
|
+
continue;
|
|
2128
|
+
}
|
|
2129
|
+
if (request.establishment.status === "pending") {
|
|
2130
|
+
rejectWatchEstablishment(request, renderError);
|
|
2131
|
+
void removeWatchRequest(request.watchId, renderError);
|
|
2132
|
+
} else {
|
|
2133
|
+
postWatchError(request, renderError);
|
|
2134
|
+
suspendEstablishedWatch(request);
|
|
1567
2135
|
}
|
|
1568
2136
|
}
|
|
1569
2137
|
},
|
|
2138
|
+
[removeWatchRequest, suspendEstablishedWatch]
|
|
2139
|
+
);
|
|
2140
|
+
const clearStoryboardError = useCallback3((storyboardId) => {
|
|
2141
|
+
problemTrackerRef.current.clearComponentProblem(storyboardId, [
|
|
2142
|
+
"render-error-boundary"
|
|
2143
|
+
]);
|
|
2144
|
+
}, []);
|
|
2145
|
+
const reportCanvasImportError = useCallback3(
|
|
2146
|
+
(canvasPath, error) => {
|
|
2147
|
+
const normalizedPath = canvasPath.trim();
|
|
2148
|
+
if (!normalizedPath) return;
|
|
2149
|
+
problemTrackerRef.current.reportCanvasProblem(
|
|
2150
|
+
normalizedPath,
|
|
2151
|
+
"runtime-bootstrap",
|
|
2152
|
+
error.message,
|
|
2153
|
+
{
|
|
2154
|
+
stack: error.stack,
|
|
2155
|
+
componentStack: error.componentStack,
|
|
2156
|
+
filename: normalizedPath
|
|
2157
|
+
}
|
|
2158
|
+
);
|
|
2159
|
+
},
|
|
1570
2160
|
[]
|
|
1571
2161
|
);
|
|
1572
|
-
const
|
|
1573
|
-
(
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
2162
|
+
const clearCanvasImportError = useCallback3((canvasPath) => {
|
|
2163
|
+
const normalizedPath = canvasPath.trim();
|
|
2164
|
+
if (!normalizedPath) return;
|
|
2165
|
+
problemTrackerRef.current.clearCanvasProblem(normalizedPath, [
|
|
2166
|
+
"runtime-bootstrap"
|
|
2167
|
+
]);
|
|
2168
|
+
}, []);
|
|
2169
|
+
const registerCanvasProblemScope = useCallback3(
|
|
2170
|
+
(canvasPath) => problemTrackerRef.current.registerCanvasPath(canvasPath),
|
|
2171
|
+
[]
|
|
2172
|
+
);
|
|
2173
|
+
useEffect2(
|
|
2174
|
+
() => () => {
|
|
2175
|
+
problemTrackerRef.current.dispose();
|
|
1577
2176
|
},
|
|
1578
2177
|
[]
|
|
1579
2178
|
);
|
|
1580
|
-
|
|
2179
|
+
useLayoutEffect2(() => {
|
|
2180
|
+
if (typeof window === "undefined") return;
|
|
2181
|
+
const stopRuntimeProblemTracking = installCanvasHostRuntimeProblemTracking(
|
|
2182
|
+
problemTrackerRef.current
|
|
2183
|
+
);
|
|
2184
|
+
return () => {
|
|
2185
|
+
stopRuntimeProblemTracking();
|
|
2186
|
+
};
|
|
2187
|
+
}, []);
|
|
2188
|
+
useEffect2(() => {
|
|
1581
2189
|
if (typeof window === "undefined") return;
|
|
1582
|
-
let cancelled = false;
|
|
1583
2190
|
const activeWatchIds = new Set(watchRequestsById.keys());
|
|
1584
2191
|
for (const watchId of watchesRef.current.keys()) {
|
|
1585
2192
|
if (!activeWatchIds.has(watchId)) {
|
|
@@ -1587,18 +2194,40 @@ function useCanvasHostPostMessage() {
|
|
|
1587
2194
|
}
|
|
1588
2195
|
}
|
|
1589
2196
|
for (const request of watchRequestsById.values()) {
|
|
2197
|
+
if (request.establishment.status === "failed") continue;
|
|
1590
2198
|
const renderEntry = renderEntriesById.get(request.request.renderId);
|
|
1591
|
-
const renderReady = renderEntry?.status === "active" && renderedRenderIdsRef.current.has(request.request.renderId) &&
|
|
2199
|
+
const renderReady = renderEntry?.status === "active" && renderedRenderIdsRef.current.has(request.request.renderId) && renderRequestTargetsEntry(renderEntry, request.request);
|
|
1592
2200
|
if (!renderReady) continue;
|
|
1593
2201
|
const existing = watchesRef.current.get(request.watchId);
|
|
1594
|
-
if (existing?.bindingKey === request.bindingKey)
|
|
2202
|
+
if (existing?.bindingKey === request.bindingKey && existing.establishment === request.establishment) {
|
|
2203
|
+
const currentRequest = watchRequestsRef.current.get(request.watchId);
|
|
2204
|
+
if (currentRequest?.establishment !== request.establishment) continue;
|
|
2205
|
+
if (currentRequest.paused) setRuntimeWatchPaused(existing.watch, true);
|
|
2206
|
+
acknowledgeWatchEstablishment(currentRequest);
|
|
2207
|
+
continue;
|
|
2208
|
+
}
|
|
2209
|
+
if (!existing && request.paused) continue;
|
|
2210
|
+
const starting = startingWatchesRef.current.get(request.watchId);
|
|
2211
|
+
if (starting?.bindingKey === request.bindingKey && starting.establishment === request.establishment) {
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
const startToken = {
|
|
2215
|
+
bindingKey: request.bindingKey,
|
|
2216
|
+
establishment: request.establishment
|
|
2217
|
+
};
|
|
2218
|
+
startingWatchesRef.current.set(request.watchId, startToken);
|
|
1595
2219
|
void (async () => {
|
|
1596
2220
|
if (existing) {
|
|
1597
|
-
await stopRuntimeWatch(request.watchId);
|
|
2221
|
+
await stopRuntimeWatch(request.watchId, existing.establishment);
|
|
1598
2222
|
}
|
|
1599
|
-
if (cancelled) return;
|
|
1600
2223
|
const onUpdate = (capture) => {
|
|
1601
|
-
|
|
2224
|
+
const currentRequest2 = watchRequestsRef.current.get(request.watchId);
|
|
2225
|
+
if (currentRequest2?.establishment !== request.establishment || currentRequest2.establishment.status === "failed") {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
legacyHealthRef.current.recordSourceAnnotatedCommit(
|
|
2229
|
+
request.request.renderId
|
|
2230
|
+
);
|
|
1602
2231
|
postToMessageSource(
|
|
1603
2232
|
request.source,
|
|
1604
2233
|
{
|
|
@@ -1612,17 +2241,14 @@ function useCanvasHostPostMessage() {
|
|
|
1612
2241
|
);
|
|
1613
2242
|
};
|
|
1614
2243
|
const onError = (error) => {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
},
|
|
1624
|
-
request.targetOrigin
|
|
1625
|
-
);
|
|
2244
|
+
const currentRequest2 = watchRequestsRef.current.get(request.watchId);
|
|
2245
|
+
if (currentRequest2?.establishment !== request.establishment) return;
|
|
2246
|
+
if (currentRequest2.establishment.status === "pending") {
|
|
2247
|
+
rejectWatchEstablishment(currentRequest2, error);
|
|
2248
|
+
void removeWatchRequest(request.watchId, error);
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
postWatchError(request, error);
|
|
1626
2252
|
};
|
|
1627
2253
|
const common = {
|
|
1628
2254
|
onUpdate,
|
|
@@ -1637,44 +2263,47 @@ function useCanvasHostPostMessage() {
|
|
|
1637
2263
|
fiberTags: Array.isArray(request.payload.fiberTags) ? request.payload.fiberTags : void 0,
|
|
1638
2264
|
knownSourceVersion: typeof request.payload.knownSourceVersion === "object" && request.payload.knownSourceVersion !== null ? request.payload.knownSourceVersion : void 0
|
|
1639
2265
|
});
|
|
1640
|
-
|
|
2266
|
+
const currentRequest = watchRequestsRef.current.get(request.watchId);
|
|
2267
|
+
if (currentRequest?.establishment !== request.establishment || currentRequest.establishment.status === "failed") {
|
|
1641
2268
|
await watch.stop();
|
|
1642
2269
|
return;
|
|
1643
2270
|
}
|
|
1644
2271
|
watchesRef.current.set(request.watchId, {
|
|
1645
2272
|
renderId: request.request.renderId,
|
|
1646
2273
|
bindingKey: request.bindingKey,
|
|
2274
|
+
establishment: request.establishment,
|
|
1647
2275
|
watch
|
|
1648
2276
|
});
|
|
1649
|
-
if (
|
|
1650
|
-
|
|
1651
|
-
else watch.pause?.();
|
|
2277
|
+
if (currentRequest.paused) {
|
|
2278
|
+
setRuntimeWatchPaused(watch, true);
|
|
1652
2279
|
}
|
|
2280
|
+
acknowledgeWatchEstablishment(currentRequest);
|
|
1653
2281
|
})().catch((caught) => {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
);
|
|
2282
|
+
const currentRequest = watchRequestsRef.current.get(request.watchId);
|
|
2283
|
+
if (currentRequest?.establishment !== request.establishment) {
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
const error = caught instanceof Error ? caught : new Error(String(caught));
|
|
2287
|
+
if (currentRequest.establishment.status === "pending") {
|
|
2288
|
+
rejectWatchEstablishment(currentRequest, error);
|
|
2289
|
+
} else {
|
|
2290
|
+
postWatchError(currentRequest, error);
|
|
2291
|
+
}
|
|
2292
|
+
void removeWatchRequest(request.watchId, error);
|
|
2293
|
+
}).finally(() => {
|
|
2294
|
+
if (startingWatchesRef.current.get(request.watchId) === startToken) {
|
|
2295
|
+
startingWatchesRef.current.delete(request.watchId);
|
|
2296
|
+
}
|
|
1665
2297
|
});
|
|
1666
2298
|
}
|
|
1667
|
-
return () => {
|
|
1668
|
-
cancelled = true;
|
|
1669
|
-
};
|
|
1670
2299
|
}, [
|
|
1671
|
-
recordSourceAnnotatedCommit,
|
|
1672
2300
|
renderCommitVersionById,
|
|
1673
2301
|
renderEntriesById,
|
|
2302
|
+
removeWatchRequest,
|
|
1674
2303
|
stopRuntimeWatch,
|
|
1675
2304
|
watchRequestsById
|
|
1676
2305
|
]);
|
|
1677
|
-
|
|
2306
|
+
useEffect2(() => {
|
|
1678
2307
|
if (typeof window === "undefined") return;
|
|
1679
2308
|
const waitForRenderLease = async (request) => {
|
|
1680
2309
|
try {
|
|
@@ -1711,23 +2340,22 @@ function useCanvasHostPostMessage() {
|
|
|
1711
2340
|
const postAsyncError = (caught) => {
|
|
1712
2341
|
error(caught instanceof Error ? caught.message : String(caught));
|
|
1713
2342
|
};
|
|
1714
|
-
const postCaptureResult = (capture) =>
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
2343
|
+
const postCaptureResult = (renderId) => (capture) => {
|
|
2344
|
+
legacyHealthRef.current.recordSourceAnnotatedCommit(renderId);
|
|
2345
|
+
post({
|
|
2346
|
+
type: "render-pool:capture-result",
|
|
2347
|
+
requestId: command.requestId,
|
|
2348
|
+
command: command.type,
|
|
2349
|
+
payload: { capture }
|
|
2350
|
+
});
|
|
2351
|
+
};
|
|
1720
2352
|
try {
|
|
1721
|
-
if (command.type === "render-pool:render") {
|
|
1722
|
-
const request = readRenderRequest(command.type, payload);
|
|
1723
|
-
void waitForRenderLease(request).then(ack).catch(postAsyncError);
|
|
1724
|
-
return;
|
|
1725
|
-
}
|
|
1726
2353
|
if (command.type === "render-pool:capture-image") {
|
|
1727
2354
|
const request = readRenderRequest(command.type, payload);
|
|
1728
2355
|
void withRenderLease(
|
|
1729
2356
|
request,
|
|
1730
2357
|
() => captureStoryboardImage(request.renderId, {
|
|
2358
|
+
childSelector: typeof payload.childSelector === "string" ? payload.childSelector : void 0,
|
|
1731
2359
|
overlaySelector: typeof payload.overlaySelector === "string" ? payload.overlaySelector : void 0,
|
|
1732
2360
|
format: payload.format === "jpeg" || payload.format === "png" ? payload.format : void 0,
|
|
1733
2361
|
quality: readOptionalNumber(payload, "quality"),
|
|
@@ -1738,10 +2366,7 @@ function useCanvasHostPostMessage() {
|
|
|
1738
2366
|
(selector) => typeof selector === "string"
|
|
1739
2367
|
) : void 0
|
|
1740
2368
|
})
|
|
1741
|
-
).then((
|
|
1742
|
-
recordSourceAnnotatedCommit(request.renderId);
|
|
1743
|
-
postCaptureResult(capture);
|
|
1744
|
-
}).catch(postAsyncError);
|
|
2369
|
+
).then(postCaptureResult(request.renderId)).catch(postAsyncError);
|
|
1745
2370
|
return;
|
|
1746
2371
|
}
|
|
1747
2372
|
if (command.type === "render-pool:capture-html") {
|
|
@@ -1751,23 +2376,7 @@ function useCanvasHostPostMessage() {
|
|
|
1751
2376
|
() => captureStoryboardHtml(request.renderId, {
|
|
1752
2377
|
timeout: readOptionalNumber(payload, "timeout")
|
|
1753
2378
|
})
|
|
1754
|
-
).then((
|
|
1755
|
-
recordSourceAnnotatedCommit(request.renderId);
|
|
1756
|
-
postCaptureResult(capture);
|
|
1757
|
-
}).catch(postAsyncError);
|
|
1758
|
-
return;
|
|
1759
|
-
}
|
|
1760
|
-
if (command.type === "render-pool:capture-static-html") {
|
|
1761
|
-
const request = readRenderRequest(command.type, payload);
|
|
1762
|
-
void withRenderLease(
|
|
1763
|
-
request,
|
|
1764
|
-
() => captureStoryboardStaticHtml(request.renderId, {
|
|
1765
|
-
timeout: readOptionalNumber(payload, "timeout")
|
|
1766
|
-
})
|
|
1767
|
-
).then((capture) => {
|
|
1768
|
-
recordSourceAnnotatedCommit(request.renderId);
|
|
1769
|
-
postCaptureResult(capture);
|
|
1770
|
-
}).catch(postAsyncError);
|
|
2379
|
+
).then(postCaptureResult(request.renderId)).catch(postAsyncError);
|
|
1771
2380
|
return;
|
|
1772
2381
|
}
|
|
1773
2382
|
if (command.type === "render-pool:capture-combined") {
|
|
@@ -1779,34 +2388,33 @@ function useCanvasHostPostMessage() {
|
|
|
1779
2388
|
fiberTags: Array.isArray(payload.fiberTags) ? payload.fiberTags : void 0,
|
|
1780
2389
|
timeout: readOptionalNumber(payload, "timeout")
|
|
1781
2390
|
})
|
|
1782
|
-
).then((
|
|
1783
|
-
recordSourceAnnotatedCommit(request.renderId);
|
|
1784
|
-
postCaptureResult(capture);
|
|
1785
|
-
}).catch(postAsyncError);
|
|
2391
|
+
).then(postCaptureResult(request.renderId)).catch(postAsyncError);
|
|
1786
2392
|
return;
|
|
1787
2393
|
}
|
|
1788
|
-
if (command.type === "render-pool:watch-
|
|
2394
|
+
if (command.type === "render-pool:watch-combined" || command.type === "render-pool:watch-html") {
|
|
1789
2395
|
const request = readRenderRequest(command.type, payload);
|
|
1790
2396
|
const watchId = readWatchId(command.type, payload);
|
|
1791
2397
|
void removeWatchRequest(watchId).then(() => {
|
|
1792
2398
|
setEntries((entries) => acquireRender(entries, request));
|
|
1793
|
-
|
|
2399
|
+
const establishment = { status: "pending" };
|
|
2400
|
+
const watchRequest = {
|
|
2401
|
+
commandType: command.type,
|
|
2402
|
+
requestId: command.requestId,
|
|
2403
|
+
watchId,
|
|
2404
|
+
source,
|
|
2405
|
+
targetOrigin,
|
|
2406
|
+
request,
|
|
2407
|
+
payload,
|
|
2408
|
+
paused: payload.paused === true,
|
|
2409
|
+
bindingKey: buildWatchBindingKey(command.type, payload),
|
|
2410
|
+
establishment
|
|
2411
|
+
};
|
|
2412
|
+
updateWatchRequests((requests) => {
|
|
1794
2413
|
const next = new Map(requests);
|
|
1795
|
-
next.set(watchId,
|
|
1796
|
-
commandType: command.type,
|
|
1797
|
-
requestId: command.requestId,
|
|
1798
|
-
watchId,
|
|
1799
|
-
source,
|
|
1800
|
-
targetOrigin,
|
|
1801
|
-
request,
|
|
1802
|
-
payload,
|
|
1803
|
-
paused: false,
|
|
1804
|
-
bindingKey: buildWatchBindingKey(command.type, payload)
|
|
1805
|
-
});
|
|
1806
|
-
watchRequestsRef.current = next;
|
|
2414
|
+
next.set(watchId, watchRequest);
|
|
1807
2415
|
return next;
|
|
1808
2416
|
});
|
|
1809
|
-
|
|
2417
|
+
acknowledgeWatchEstablishment(watchRequest);
|
|
1810
2418
|
}).catch(postAsyncError);
|
|
1811
2419
|
return;
|
|
1812
2420
|
}
|
|
@@ -1819,28 +2427,23 @@ function useCanvasHostPostMessage() {
|
|
|
1819
2427
|
const watchId = readWatchId(command.type, payload);
|
|
1820
2428
|
const paused = payload.paused === true;
|
|
1821
2429
|
const watch = watchesRef.current.get(watchId)?.watch;
|
|
1822
|
-
watch
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
2430
|
+
if (watch) {
|
|
2431
|
+
setRuntimeWatchPaused(
|
|
2432
|
+
watch,
|
|
2433
|
+
paused,
|
|
2434
|
+
paused ? void 0 : readWatchResumeOptions(payload)
|
|
2435
|
+
);
|
|
1826
2436
|
}
|
|
1827
|
-
|
|
2437
|
+
updateWatchRequests((requests) => {
|
|
1828
2438
|
const current = requests.get(watchId);
|
|
1829
2439
|
if (!current || current.paused === paused) return requests;
|
|
1830
2440
|
const next = new Map(requests);
|
|
1831
2441
|
next.set(watchId, { ...current, paused });
|
|
1832
|
-
watchRequestsRef.current = next;
|
|
1833
2442
|
return next;
|
|
1834
2443
|
});
|
|
1835
2444
|
ack();
|
|
1836
2445
|
return;
|
|
1837
2446
|
}
|
|
1838
|
-
if (command.type === "render-pool:unrender") {
|
|
1839
|
-
const target = requireRenderTarget(command.type, payload);
|
|
1840
|
-
releaseRenderLease(target.renderId);
|
|
1841
|
-
ack();
|
|
1842
|
-
return;
|
|
1843
|
-
}
|
|
1844
2447
|
if (command.type === "render-pool:list") {
|
|
1845
2448
|
post({
|
|
1846
2449
|
type: "render-pool:state",
|
|
@@ -1849,43 +2452,6 @@ function useCanvasHostPostMessage() {
|
|
|
1849
2452
|
});
|
|
1850
2453
|
return;
|
|
1851
2454
|
}
|
|
1852
|
-
if (command.type === "render-pool:set-cache-limit") {
|
|
1853
|
-
const maxCached = typeof payload.maxCached === "number" && Number.isInteger(payload.maxCached) ? Math.max(0, payload.maxCached) : maxCachedRef.current;
|
|
1854
|
-
maxCachedRef.current = maxCached;
|
|
1855
|
-
setEntries((entries) => evictCachedRenders(entries, maxCached));
|
|
1856
|
-
ack();
|
|
1857
|
-
return;
|
|
1858
|
-
}
|
|
1859
|
-
if (command.type === "render-pool:isolate") {
|
|
1860
|
-
const target = resolveRenderTarget(payload);
|
|
1861
|
-
document.querySelector("[data-render-isolation]")?.remove();
|
|
1862
|
-
if (target?.renderId) {
|
|
1863
|
-
const style = document.createElement("style");
|
|
1864
|
-
style.setAttribute("data-render-isolation", "");
|
|
1865
|
-
const escapedId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(target.renderId) : target.renderId;
|
|
1866
|
-
style.textContent = '[data-render-id]:not([data-render-id="' + escapedId + '"]) { opacity: 0 !important; pointer-events: none !important; }';
|
|
1867
|
-
document.head.appendChild(style);
|
|
1868
|
-
}
|
|
1869
|
-
ack();
|
|
1870
|
-
return;
|
|
1871
|
-
}
|
|
1872
|
-
if (command.type === "render-pool:query-health") {
|
|
1873
|
-
const target = resolveRenderTarget(payload);
|
|
1874
|
-
post({
|
|
1875
|
-
type: "render-pool:health-snapshot",
|
|
1876
|
-
requestId: command.requestId,
|
|
1877
|
-
snapshot: buildHealthSnapshot(target?.renderId ?? "")
|
|
1878
|
-
});
|
|
1879
|
-
return;
|
|
1880
|
-
}
|
|
1881
|
-
if (command.type === "render-pool:query-problems") {
|
|
1882
|
-
post({
|
|
1883
|
-
type: "render-pool:problem-snapshot",
|
|
1884
|
-
requestId: command.requestId,
|
|
1885
|
-
payload: buildProblemSnapshot()
|
|
1886
|
-
});
|
|
1887
|
-
return;
|
|
1888
|
-
}
|
|
1889
2455
|
if (command.type === "render-pool:watch-problems") {
|
|
1890
2456
|
const watchId = typeof payload.watchId === "string" && payload.watchId.trim() ? payload.watchId : String(command.requestId ?? "default");
|
|
1891
2457
|
problemWatchersRef.current.set(watchId, {
|
|
@@ -1907,6 +2473,65 @@ function useCanvasHostPostMessage() {
|
|
|
1907
2473
|
const watchId = typeof payload.watchId === "string" && payload.watchId.trim() ? payload.watchId : String(command.requestId ?? "default");
|
|
1908
2474
|
problemWatchersRef.current.delete(watchId);
|
|
1909
2475
|
ack();
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
if (command.type === "render-pool:query-problems") {
|
|
2479
|
+
post({
|
|
2480
|
+
type: "render-pool:problem-snapshot",
|
|
2481
|
+
requestId: command.requestId,
|
|
2482
|
+
payload: buildProblemSnapshot()
|
|
2483
|
+
});
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
if (command.type === "render-pool:render") {
|
|
2487
|
+
const request = readRenderRequest(command.type, payload);
|
|
2488
|
+
void waitForRenderLease(request).then(ack).catch(postAsyncError);
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
if (command.type === "render-pool:unrender") {
|
|
2492
|
+
const target = requireRenderTarget(command.type, payload);
|
|
2493
|
+
releaseRenderLease(target.renderId);
|
|
2494
|
+
ack();
|
|
2495
|
+
return;
|
|
2496
|
+
}
|
|
2497
|
+
if (command.type === "render-pool:capture-static-html") {
|
|
2498
|
+
const request = readRenderRequest(command.type, payload);
|
|
2499
|
+
void withRenderLease(
|
|
2500
|
+
request,
|
|
2501
|
+
() => captureStoryboardStaticHtml(request.renderId, {
|
|
2502
|
+
timeout: readOptionalNumber(payload, "timeout")
|
|
2503
|
+
})
|
|
2504
|
+
).then(postCaptureResult(request.renderId)).catch(postAsyncError);
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
if (command.type === "render-pool:set-cache-limit") {
|
|
2508
|
+
if (typeof payload.maxCached === "number" && Number.isInteger(payload.maxCached)) {
|
|
2509
|
+
maxCachedRef.current = Math.max(0, payload.maxCached);
|
|
2510
|
+
}
|
|
2511
|
+
setEntries(
|
|
2512
|
+
(entries) => evictCachedRenders(entries, maxCachedRef.current)
|
|
2513
|
+
);
|
|
2514
|
+
ack();
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
if (command.type === "render-pool:isolate") {
|
|
2518
|
+
applyLegacyRenderIsolation(
|
|
2519
|
+
resolveRenderTarget(payload)?.renderId ?? null
|
|
2520
|
+
);
|
|
2521
|
+
ack();
|
|
2522
|
+
return;
|
|
2523
|
+
}
|
|
2524
|
+
if (command.type === "render-pool:query-health") {
|
|
2525
|
+
const renderId = resolveRenderTarget(payload)?.renderId ?? "";
|
|
2526
|
+
post({
|
|
2527
|
+
type: "render-pool:health-snapshot",
|
|
2528
|
+
requestId: command.requestId,
|
|
2529
|
+
snapshot: legacyHealthRef.current.buildSnapshot(renderId, {
|
|
2530
|
+
hasRenderEntries: renderEntriesRef.current.size > 0,
|
|
2531
|
+
claimErrorBoundaryTripped: problemTrackerRef.current.hasComponentProblem(renderId)
|
|
2532
|
+
})
|
|
2533
|
+
});
|
|
2534
|
+
return;
|
|
1910
2535
|
}
|
|
1911
2536
|
} catch (caught) {
|
|
1912
2537
|
postAsyncError(caught);
|
|
@@ -1919,14 +2544,10 @@ function useCanvasHostPostMessage() {
|
|
|
1919
2544
|
const stopProblemPublisher = problemTrackerRef.current.watch(
|
|
1920
2545
|
publishProblemSnapshot
|
|
1921
2546
|
);
|
|
1922
|
-
const stopRuntimeProblemTracking = installCanvasHostRuntimeProblemTracking(
|
|
1923
|
-
problemTrackerRef.current
|
|
1924
|
-
);
|
|
1925
2547
|
window.postMessage({ type: "render-pool:ready" }, "*");
|
|
1926
2548
|
return () => {
|
|
1927
2549
|
window.removeEventListener("message", onMessage);
|
|
1928
2550
|
window.removeEventListener("__render-pool:command", onBridgeCommand);
|
|
1929
|
-
stopRuntimeProblemTracking();
|
|
1930
2551
|
stopProblemPublisher();
|
|
1931
2552
|
for (const { watch } of watchesRef.current.values()) {
|
|
1932
2553
|
void watch.stop();
|
|
@@ -1935,41 +2556,33 @@ function useCanvasHostPostMessage() {
|
|
|
1935
2556
|
problemWatchersRef.current.clear();
|
|
1936
2557
|
};
|
|
1937
2558
|
}, [
|
|
1938
|
-
buildHealthSnapshot,
|
|
1939
2559
|
buildProblemSnapshot,
|
|
1940
2560
|
buildState,
|
|
1941
2561
|
publishProblemSnapshot,
|
|
1942
|
-
recordSourceAnnotatedCommit,
|
|
1943
2562
|
releaseRenderLease,
|
|
1944
2563
|
removeWatchRequest,
|
|
1945
2564
|
setEntries,
|
|
2565
|
+
updateWatchRequests,
|
|
1946
2566
|
waitForRender
|
|
1947
2567
|
]);
|
|
1948
2568
|
return {
|
|
1949
|
-
renderStatusById:
|
|
2569
|
+
renderStatusById: useMemo3(
|
|
1950
2570
|
() => buildRenderStatusMap(renderEntriesById),
|
|
1951
2571
|
[renderEntriesById]
|
|
1952
2572
|
),
|
|
1953
|
-
renderSizeById:
|
|
2573
|
+
renderSizeById: useMemo3(
|
|
1954
2574
|
() => buildRenderSizeMap(renderEntriesById),
|
|
1955
2575
|
[renderEntriesById]
|
|
1956
2576
|
),
|
|
1957
2577
|
markStoryboardRendered,
|
|
2578
|
+
markStoryboardUnmounted,
|
|
1958
2579
|
reportStoryboardError,
|
|
1959
|
-
clearStoryboardError
|
|
2580
|
+
clearStoryboardError,
|
|
2581
|
+
reportCanvasImportError,
|
|
2582
|
+
clearCanvasImportError,
|
|
2583
|
+
registerCanvasProblemScope
|
|
1960
2584
|
};
|
|
1961
2585
|
}
|
|
1962
|
-
function latestTimestamp(values) {
|
|
1963
|
-
let latest = null;
|
|
1964
|
-
for (const value of values.values()) {
|
|
1965
|
-
latest = latest === null ? value : Math.max(latest, value);
|
|
1966
|
-
}
|
|
1967
|
-
return latest;
|
|
1968
|
-
}
|
|
1969
|
-
function isReactConnected() {
|
|
1970
|
-
const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
1971
|
-
return (hook?.renderers?.size ?? 0) > 0;
|
|
1972
|
-
}
|
|
1973
2586
|
function buildWatchBindingKey(commandType, payload) {
|
|
1974
2587
|
try {
|
|
1975
2588
|
return JSON.stringify({ commandType, payload });
|
|
@@ -1977,27 +2590,36 @@ function buildWatchBindingKey(commandType, payload) {
|
|
|
1977
2590
|
return `${commandType}:${Date.now()}`;
|
|
1978
2591
|
}
|
|
1979
2592
|
}
|
|
1980
|
-
var sourceAnnotationSelector2 = "[data-tempo-source-file], [data-tempo-source-loc], [data-tempo-filepath], [data-tempo-html-filepath]";
|
|
1981
|
-
function renderSlotHasSourceAnnotations(renderId) {
|
|
1982
|
-
const slot = typeof document === "undefined" ? null : document.querySelector(buildRenderContentSelector(renderId));
|
|
1983
|
-
return getObservedSourceFiles2(slot).length > 0;
|
|
1984
|
-
}
|
|
1985
|
-
function getObservedSourceFiles2(slot) {
|
|
1986
|
-
if (!slot) return [];
|
|
1987
|
-
return [
|
|
1988
|
-
...new Set(
|
|
1989
|
-
[...slot.querySelectorAll(sourceAnnotationSelector2)].flatMap((element) => [
|
|
1990
|
-
element.getAttribute("data-tempo-source-file"),
|
|
1991
|
-
element.getAttribute("data-tempo-filepath"),
|
|
1992
|
-
element.getAttribute("data-tempo-html-filepath"),
|
|
1993
|
-
element.getAttribute("data-tempo-source-loc")
|
|
1994
|
-
]).filter((file) => Boolean(file))
|
|
1995
|
-
)
|
|
1996
|
-
];
|
|
1997
|
-
}
|
|
1998
2593
|
|
|
1999
2594
|
// canvas/canvas-host.tsx
|
|
2000
|
-
import { jsx as
|
|
2595
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2596
|
+
var CANVAS_HOST_DOCUMENT_TITLE = "INTERNAL tempo-host \u2014 Tempo component host, do not interact";
|
|
2597
|
+
function protectCanvasHostDocumentTitle(doc) {
|
|
2598
|
+
const restoreTitle = () => {
|
|
2599
|
+
if (doc.title !== CANVAS_HOST_DOCUMENT_TITLE) {
|
|
2600
|
+
doc.title = CANVAS_HOST_DOCUMENT_TITLE;
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
restoreTitle();
|
|
2604
|
+
const Observer = doc.defaultView?.MutationObserver;
|
|
2605
|
+
const observer = Observer ? new Observer(restoreTitle) : null;
|
|
2606
|
+
observer?.observe(doc.head ?? doc.documentElement, {
|
|
2607
|
+
childList: true,
|
|
2608
|
+
subtree: true,
|
|
2609
|
+
characterData: true
|
|
2610
|
+
});
|
|
2611
|
+
const interval = doc.defaultView?.setInterval(restoreTitle, 250);
|
|
2612
|
+
return () => {
|
|
2613
|
+
observer?.disconnect();
|
|
2614
|
+
if (interval !== void 0) doc.defaultView?.clearInterval(interval);
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
var CanvasHostContractError = class extends Error {
|
|
2618
|
+
constructor() {
|
|
2619
|
+
super(...arguments);
|
|
2620
|
+
this.name = "CanvasHostContractError";
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2001
2623
|
function readDirectUrlDimension(value) {
|
|
2002
2624
|
const match = value.trim().match(/^([0-9]*\.?[0-9]+)(px|vw|vh)?$/);
|
|
2003
2625
|
if (!match) {
|
|
@@ -2041,23 +2663,48 @@ function readDirectUrlRender() {
|
|
|
2041
2663
|
}
|
|
2042
2664
|
function CanvasHost({
|
|
2043
2665
|
children,
|
|
2666
|
+
canvasModules,
|
|
2044
2667
|
activeStoryboardIds,
|
|
2045
2668
|
isStoryboardActive
|
|
2046
2669
|
}) {
|
|
2670
|
+
if (children !== void 0 && canvasModules !== void 0) {
|
|
2671
|
+
throw new CanvasHostContractError(
|
|
2672
|
+
"CanvasHost cannot receive both children and canvasModules."
|
|
2673
|
+
);
|
|
2674
|
+
}
|
|
2675
|
+
const registeredCanvasPaths = useMemo4(
|
|
2676
|
+
() => [
|
|
2677
|
+
...new Set(
|
|
2678
|
+
canvasModules?.map(({ canvasPath }) => canvasPath.trim()) ?? []
|
|
2679
|
+
)
|
|
2680
|
+
].filter(Boolean),
|
|
2681
|
+
[canvasModules]
|
|
2682
|
+
);
|
|
2047
2683
|
const {
|
|
2048
2684
|
renderStatusById: renderStatusById2,
|
|
2049
2685
|
renderSizeById,
|
|
2050
2686
|
markStoryboardRendered,
|
|
2687
|
+
markStoryboardUnmounted,
|
|
2051
2688
|
reportStoryboardError,
|
|
2052
|
-
clearStoryboardError
|
|
2053
|
-
|
|
2689
|
+
clearStoryboardError,
|
|
2690
|
+
reportCanvasImportError,
|
|
2691
|
+
clearCanvasImportError,
|
|
2692
|
+
registerCanvasProblemScope
|
|
2693
|
+
} = useCanvasHostPostMessage(registeredCanvasPaths);
|
|
2694
|
+
useEffect3(() => {
|
|
2695
|
+
if (typeof document === "undefined") return;
|
|
2696
|
+
return protectCanvasHostDocumentTitle(document);
|
|
2697
|
+
}, []);
|
|
2054
2698
|
const directUrlSearch = typeof window === "undefined" ? "" : window.location.search;
|
|
2055
|
-
const directUrlRender =
|
|
2056
|
-
|
|
2699
|
+
const directUrlRender = useMemo4(() => {
|
|
2700
|
+
void directUrlSearch;
|
|
2701
|
+
return readDirectUrlRender();
|
|
2702
|
+
}, [directUrlSearch]);
|
|
2703
|
+
const propActiveIds = useMemo4(
|
|
2057
2704
|
() => new Set(activeStoryboardIds ?? []),
|
|
2058
2705
|
[activeStoryboardIds]
|
|
2059
2706
|
);
|
|
2060
|
-
const runtime =
|
|
2707
|
+
const runtime = useMemo4(
|
|
2061
2708
|
() => ({
|
|
2062
2709
|
getStoryboardStatus(storyboardId) {
|
|
2063
2710
|
const normalizedId = normalizeId(storyboardId, "Storyboard id");
|
|
@@ -2078,31 +2725,175 @@ function CanvasHost({
|
|
|
2078
2725
|
return directUrlRender?.renderId === normalizedId ? { left: 0, top: 0 } : void 0;
|
|
2079
2726
|
},
|
|
2080
2727
|
markStoryboardRendered,
|
|
2728
|
+
markStoryboardUnmounted,
|
|
2081
2729
|
reportStoryboardError,
|
|
2082
|
-
clearStoryboardError
|
|
2730
|
+
clearStoryboardError,
|
|
2731
|
+
reportCanvasImportError,
|
|
2732
|
+
clearCanvasImportError,
|
|
2733
|
+
registerCanvasProblemScope
|
|
2083
2734
|
}),
|
|
2084
2735
|
[
|
|
2085
2736
|
clearStoryboardError,
|
|
2737
|
+
clearCanvasImportError,
|
|
2086
2738
|
directUrlRender,
|
|
2087
2739
|
isStoryboardActive,
|
|
2088
2740
|
markStoryboardRendered,
|
|
2741
|
+
markStoryboardUnmounted,
|
|
2089
2742
|
propActiveIds,
|
|
2743
|
+
registerCanvasProblemScope,
|
|
2744
|
+
reportCanvasImportError,
|
|
2090
2745
|
reportStoryboardError,
|
|
2091
2746
|
renderSizeById,
|
|
2092
2747
|
renderStatusById2
|
|
2093
2748
|
]
|
|
2094
2749
|
);
|
|
2095
|
-
return /* @__PURE__ */
|
|
2750
|
+
return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
|
|
2751
|
+
children,
|
|
2752
|
+
canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx4(
|
|
2753
|
+
CanvasImportBoundary,
|
|
2754
|
+
{
|
|
2755
|
+
canvasPath,
|
|
2756
|
+
load
|
|
2757
|
+
},
|
|
2758
|
+
canvasPath
|
|
2759
|
+
))
|
|
2760
|
+
] });
|
|
2096
2761
|
}
|
|
2097
2762
|
|
|
2763
|
+
// canvas/host-capability.ts
|
|
2764
|
+
var canvasHostCapability = {
|
|
2765
|
+
protocolVersion: 1,
|
|
2766
|
+
supportsModules: true
|
|
2767
|
+
};
|
|
2768
|
+
|
|
2098
2769
|
// canvas/storyboard.tsx
|
|
2099
2770
|
import {
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2771
|
+
Children as Children2,
|
|
2772
|
+
Component as Component2,
|
|
2773
|
+
cloneElement as cloneElement2,
|
|
2774
|
+
isValidElement as isValidElement2,
|
|
2775
|
+
Suspense as Suspense2,
|
|
2776
|
+
useCallback as useCallback5,
|
|
2777
|
+
useEffect as useEffect5,
|
|
2778
|
+
useLayoutEffect as useLayoutEffect3,
|
|
2779
|
+
useMemo as useMemo5,
|
|
2780
|
+
useRef as useRef4,
|
|
2781
|
+
useState as useState3
|
|
2104
2782
|
} from "react";
|
|
2105
|
-
|
|
2783
|
+
|
|
2784
|
+
// canvas/admission-budget.ts
|
|
2785
|
+
import * as React from "react";
|
|
2786
|
+
var admissionRenderStepBudget = 1e5;
|
|
2787
|
+
var AdmissionBudgetError = class extends Error {
|
|
2788
|
+
constructor() {
|
|
2789
|
+
super(
|
|
2790
|
+
"This storyboard renders itself recursively: it kept creating components without ever finishing a render. Check for a component that returns itself, or two components that render each other."
|
|
2791
|
+
);
|
|
2792
|
+
this.name = "AdmissionBudgetError";
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
function findDispatcherSlot() {
|
|
2796
|
+
const react = React;
|
|
2797
|
+
const modern = react.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
2798
|
+
if (modern && "H" in modern) return { holder: modern, key: "H" };
|
|
2799
|
+
const legacy = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher;
|
|
2800
|
+
if (legacy && "current" in legacy) return { holder: legacy, key: "current" };
|
|
2801
|
+
return null;
|
|
2802
|
+
}
|
|
2803
|
+
var stepsRemaining = admissionRenderStepBudget;
|
|
2804
|
+
var rearmScheduled = false;
|
|
2805
|
+
var counterState = "uninstalled";
|
|
2806
|
+
function scheduleRearm() {
|
|
2807
|
+
if (rearmScheduled) return;
|
|
2808
|
+
rearmScheduled = true;
|
|
2809
|
+
queueMicrotask(() => {
|
|
2810
|
+
rearmScheduled = false;
|
|
2811
|
+
stepsRemaining = admissionRenderStepBudget;
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
2814
|
+
function installCounter() {
|
|
2815
|
+
if (counterState !== "uninstalled") return counterState === "installed";
|
|
2816
|
+
const slot = findDispatcherSlot();
|
|
2817
|
+
if (!slot) {
|
|
2818
|
+
counterState = "unavailable";
|
|
2819
|
+
return false;
|
|
2820
|
+
}
|
|
2821
|
+
const { holder, key } = slot;
|
|
2822
|
+
let dispatcher = holder[key];
|
|
2823
|
+
Object.defineProperty(holder, key, {
|
|
2824
|
+
configurable: true,
|
|
2825
|
+
get: () => dispatcher,
|
|
2826
|
+
set: (value) => {
|
|
2827
|
+
dispatcher = value;
|
|
2828
|
+
scheduleRearm();
|
|
2829
|
+
stepsRemaining -= 1;
|
|
2830
|
+
if (stepsRemaining > 0) return;
|
|
2831
|
+
stepsRemaining = admissionRenderStepBudget;
|
|
2832
|
+
throw new AdmissionBudgetError();
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2835
|
+
counterState = "installed";
|
|
2836
|
+
return true;
|
|
2837
|
+
}
|
|
2838
|
+
function beginAdmissionWindow() {
|
|
2839
|
+
if (!installCounter()) return;
|
|
2840
|
+
stepsRemaining = admissionRenderStepBudget;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
// canvas/render-error-recovery.ts
|
|
2844
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
2845
|
+
var renderErrorRetryBaseDelayMs = 1e3;
|
|
2846
|
+
var renderErrorRetryMaxDelayMs = 8e3;
|
|
2847
|
+
var beatListeners = /* @__PURE__ */ new Set();
|
|
2848
|
+
function emitRenderErrorRecoveryBeat() {
|
|
2849
|
+
for (const listener of [...beatListeners]) listener();
|
|
2850
|
+
}
|
|
2851
|
+
var hot = import.meta.hot;
|
|
2852
|
+
hot?.on?.("vite:afterUpdate", emitRenderErrorRecoveryBeat);
|
|
2853
|
+
function useRenderErrorRecovery(retryNow) {
|
|
2854
|
+
const retryNowRef = useRef3(retryNow);
|
|
2855
|
+
retryNowRef.current = retryNow;
|
|
2856
|
+
const timerRef = useRef3(null);
|
|
2857
|
+
const nextDelayRef = useRef3(renderErrorRetryBaseDelayMs);
|
|
2858
|
+
const erroredRef = useRef3(false);
|
|
2859
|
+
const clearTimer = useCallback4(() => {
|
|
2860
|
+
if (timerRef.current === null) return;
|
|
2861
|
+
clearTimeout(timerRef.current);
|
|
2862
|
+
timerRef.current = null;
|
|
2863
|
+
}, []);
|
|
2864
|
+
const noteRenderError = useCallback4(() => {
|
|
2865
|
+
erroredRef.current = true;
|
|
2866
|
+
if (timerRef.current !== null) return;
|
|
2867
|
+
const delay = nextDelayRef.current;
|
|
2868
|
+
nextDelayRef.current = Math.min(delay * 2, renderErrorRetryMaxDelayMs);
|
|
2869
|
+
timerRef.current = setTimeout(() => {
|
|
2870
|
+
timerRef.current = null;
|
|
2871
|
+
retryNowRef.current();
|
|
2872
|
+
}, delay);
|
|
2873
|
+
}, []);
|
|
2874
|
+
const noteRecovered = useCallback4(() => {
|
|
2875
|
+
erroredRef.current = false;
|
|
2876
|
+
nextDelayRef.current = renderErrorRetryBaseDelayMs;
|
|
2877
|
+
clearTimer();
|
|
2878
|
+
}, [clearTimer]);
|
|
2879
|
+
useEffect4(() => {
|
|
2880
|
+
const onBeat = () => {
|
|
2881
|
+
nextDelayRef.current = renderErrorRetryBaseDelayMs;
|
|
2882
|
+
if (!erroredRef.current) return;
|
|
2883
|
+
clearTimer();
|
|
2884
|
+
retryNowRef.current();
|
|
2885
|
+
};
|
|
2886
|
+
beatListeners.add(onBeat);
|
|
2887
|
+
return () => {
|
|
2888
|
+
beatListeners.delete(onBeat);
|
|
2889
|
+
clearTimer();
|
|
2890
|
+
};
|
|
2891
|
+
}, [clearTimer]);
|
|
2892
|
+
return { noteRenderError, noteRecovered };
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
// canvas/storyboard.tsx
|
|
2896
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2106
2897
|
function Storyboard({
|
|
2107
2898
|
id,
|
|
2108
2899
|
name,
|
|
@@ -2110,28 +2901,28 @@ function Storyboard({
|
|
|
2110
2901
|
layout,
|
|
2111
2902
|
props
|
|
2112
2903
|
}) {
|
|
2113
|
-
const
|
|
2114
|
-
return /* @__PURE__ */
|
|
2904
|
+
const Component3 = component;
|
|
2905
|
+
return /* @__PURE__ */ jsx5(StoryboardSlot, { id, name, layout, kind: "component", children: /* @__PURE__ */ jsx5(Component3, { ...props ?? {} }) });
|
|
2115
2906
|
}
|
|
2116
2907
|
function LegacyStoryboardV1({
|
|
2117
2908
|
id,
|
|
2118
2909
|
storyboard
|
|
2119
2910
|
}) {
|
|
2120
|
-
return /* @__PURE__ */
|
|
2911
|
+
return /* @__PURE__ */ jsx5(
|
|
2121
2912
|
StoryboardSlot,
|
|
2122
2913
|
{
|
|
2123
2914
|
id,
|
|
2124
2915
|
name: storyboard.name,
|
|
2125
2916
|
layout: storyboard.layout,
|
|
2126
2917
|
kind: "component",
|
|
2127
|
-
children: /* @__PURE__ */
|
|
2918
|
+
children: /* @__PURE__ */ jsx5(LegacyStoryboardV1Render, { render: storyboard.render })
|
|
2128
2919
|
}
|
|
2129
2920
|
);
|
|
2130
2921
|
}
|
|
2131
2922
|
function LegacyStoryboardV1Render({
|
|
2132
2923
|
render
|
|
2133
2924
|
}) {
|
|
2134
|
-
return /* @__PURE__ */
|
|
2925
|
+
return /* @__PURE__ */ jsx5(Fragment, { children: render() });
|
|
2135
2926
|
}
|
|
2136
2927
|
function RouteStoryboard({
|
|
2137
2928
|
id,
|
|
@@ -2139,7 +2930,7 @@ function RouteStoryboard({
|
|
|
2139
2930
|
route,
|
|
2140
2931
|
layout
|
|
2141
2932
|
}) {
|
|
2142
|
-
return /* @__PURE__ */
|
|
2933
|
+
return /* @__PURE__ */ jsx5(
|
|
2143
2934
|
StoryboardSlot,
|
|
2144
2935
|
{
|
|
2145
2936
|
id,
|
|
@@ -2157,7 +2948,7 @@ function HtmlStoryboard({
|
|
|
2157
2948
|
src,
|
|
2158
2949
|
layout
|
|
2159
2950
|
}) {
|
|
2160
|
-
return /* @__PURE__ */
|
|
2951
|
+
return /* @__PURE__ */ jsx5(
|
|
2161
2952
|
StoryboardSlot,
|
|
2162
2953
|
{
|
|
2163
2954
|
id,
|
|
@@ -2185,22 +2976,91 @@ function StoryboardSlot({
|
|
|
2185
2976
|
const renderSize = useStoryboardSize(id);
|
|
2186
2977
|
const placement = useStoryboardPlacement(id);
|
|
2187
2978
|
const markRendered = useStoryboardRendered(id);
|
|
2979
|
+
const markUnmounted = useStoryboardUnmounted(id);
|
|
2188
2980
|
const { reportError, clearError } = useStoryboardErrorReporter(id);
|
|
2189
2981
|
const renderWidth = renderSize?.width;
|
|
2190
2982
|
const renderHeight = renderSize?.height;
|
|
2983
|
+
const renderRevision = renderSize?.revision ?? 0;
|
|
2191
2984
|
const intrinsicSize = renderSize?.intrinsicSize ?? (kind === "component" && layout.intrinsicSizing === "root-element");
|
|
2192
|
-
const resetKey = `${renderId}:${
|
|
2193
|
-
const contentRef =
|
|
2194
|
-
|
|
2985
|
+
const resetKey = `${renderId}:${renderRevision}`;
|
|
2986
|
+
const contentRef = useRef4(null);
|
|
2987
|
+
const [admittedRenderId, setAdmittedRenderId] = useState3(
|
|
2988
|
+
typeof document === "undefined" ? renderId : null
|
|
2989
|
+
);
|
|
2990
|
+
const admitted = admittedRenderId === renderId;
|
|
2991
|
+
const errorBoundaryRef = useRef4(null);
|
|
2992
|
+
const lastReportedCommitRef = useRef4(null);
|
|
2993
|
+
const previousChildrenRef = useRef4(children);
|
|
2994
|
+
const [recoveryRevision, setRecoveryRevision] = useState3(0);
|
|
2995
|
+
const commitKey = `${resetKey}:${recoveryRevision}`;
|
|
2996
|
+
const retryRenderNow = useCallback5(() => {
|
|
2997
|
+
if (!errorBoundaryRef.current?.retry()) return false;
|
|
2998
|
+
setRecoveryRevision((revision) => revision + 1);
|
|
2999
|
+
return true;
|
|
3000
|
+
}, []);
|
|
3001
|
+
const { noteRenderError, noteRecovered } = useRenderErrorRecovery(retryRenderNow);
|
|
3002
|
+
const handleRenderError = useCallback5(
|
|
3003
|
+
(error) => {
|
|
3004
|
+
noteRenderError();
|
|
3005
|
+
reportError(error);
|
|
3006
|
+
},
|
|
3007
|
+
[noteRenderError, reportError]
|
|
3008
|
+
);
|
|
3009
|
+
const pendingRenderedReportRef = useRef4(
|
|
3010
|
+
null
|
|
3011
|
+
);
|
|
3012
|
+
const handleRendered = useCallback5(
|
|
3013
|
+
(reportedCommitKey) => {
|
|
3014
|
+
if (pendingRenderedReportRef.current !== null) {
|
|
3015
|
+
clearTimeout(pendingRenderedReportRef.current);
|
|
3016
|
+
}
|
|
3017
|
+
pendingRenderedReportRef.current = setTimeout(() => {
|
|
3018
|
+
pendingRenderedReportRef.current = null;
|
|
3019
|
+
if (errorBoundaryRef.current?.hasError()) return;
|
|
3020
|
+
noteRecovered();
|
|
3021
|
+
if (lastReportedCommitRef.current === reportedCommitKey) return;
|
|
3022
|
+
lastReportedCommitRef.current = reportedCommitKey;
|
|
3023
|
+
clearError();
|
|
3024
|
+
markRendered();
|
|
3025
|
+
}, 0);
|
|
3026
|
+
},
|
|
3027
|
+
[clearError, markRendered, noteRecovered]
|
|
3028
|
+
);
|
|
3029
|
+
useEffect5(
|
|
3030
|
+
() => () => {
|
|
3031
|
+
if (pendingRenderedReportRef.current !== null) {
|
|
3032
|
+
clearTimeout(pendingRenderedReportRef.current);
|
|
3033
|
+
pendingRenderedReportRef.current = null;
|
|
3034
|
+
}
|
|
3035
|
+
},
|
|
3036
|
+
[]
|
|
3037
|
+
);
|
|
3038
|
+
const renderChildren = useMemo5(() => {
|
|
3039
|
+
if (isValidElement2(children)) return cloneElement2(children);
|
|
3040
|
+
return Children2.map(
|
|
3041
|
+
children,
|
|
3042
|
+
(child) => isValidElement2(child) ? cloneElement2(child) : child
|
|
3043
|
+
);
|
|
3044
|
+
}, [children]);
|
|
3045
|
+
useEffect5(() => markUnmounted, [markUnmounted]);
|
|
3046
|
+
useEffect5(() => {
|
|
3047
|
+
setAdmittedRenderId(renderId);
|
|
3048
|
+
}, [renderId]);
|
|
3049
|
+
useEffect5(() => {
|
|
3050
|
+
const childrenChanged = previousChildrenRef.current !== children;
|
|
3051
|
+
previousChildrenRef.current = children;
|
|
3052
|
+
if (childrenChanged) retryRenderNow();
|
|
3053
|
+
}, [children, retryRenderNow]);
|
|
3054
|
+
useEffect5(() => {
|
|
2195
3055
|
if (!contentRef.current || status === "unmounted") return;
|
|
2196
3056
|
return trackStoryboardPortals(renderId, contentRef.current, status);
|
|
2197
3057
|
}, [renderId, status]);
|
|
2198
|
-
|
|
3058
|
+
useEffect5(() => {
|
|
2199
3059
|
if (status === "unmounted") return;
|
|
2200
3060
|
syncStoryboardPortals(renderId, status);
|
|
2201
3061
|
}, [renderId, status]);
|
|
2202
3062
|
if (status === "unmounted") return null;
|
|
2203
|
-
return /* @__PURE__ */
|
|
3063
|
+
return /* @__PURE__ */ jsx5(
|
|
2204
3064
|
"div",
|
|
2205
3065
|
{
|
|
2206
3066
|
"data-render-id": renderId,
|
|
@@ -2225,29 +3085,32 @@ function StoryboardSlot({
|
|
|
2225
3085
|
visibility: status === "active" ? "visible" : "hidden",
|
|
2226
3086
|
pointerEvents: status === "active" ? "auto" : "none"
|
|
2227
3087
|
},
|
|
2228
|
-
children: /* @__PURE__ */
|
|
3088
|
+
children: /* @__PURE__ */ jsx5(
|
|
2229
3089
|
"div",
|
|
2230
3090
|
{
|
|
2231
3091
|
"data-render-content": renderId,
|
|
3092
|
+
"data-render-admitted": admitted ? "true" : void 0,
|
|
3093
|
+
"data-tempo-render-mode": kind === "html" ? "static-dom" : void 0,
|
|
3094
|
+
"data-tempo-hide-fiber": "true",
|
|
2232
3095
|
ref: contentRef,
|
|
2233
3096
|
style: { width: "100%", height: "100%" },
|
|
2234
|
-
children: /* @__PURE__ */
|
|
3097
|
+
children: /* @__PURE__ */ jsx5(
|
|
2235
3098
|
StoryboardErrorBoundary,
|
|
2236
3099
|
{
|
|
2237
|
-
|
|
2238
|
-
|
|
3100
|
+
ref: errorBoundaryRef,
|
|
3101
|
+
onError: handleRenderError,
|
|
2239
3102
|
resetKey,
|
|
2240
|
-
children: /* @__PURE__ */
|
|
2241
|
-
children,
|
|
2242
|
-
/* @__PURE__ */
|
|
2243
|
-
|
|
3103
|
+
children: admitted ? /* @__PURE__ */ jsxs3(Suspense2, { fallback: /* @__PURE__ */ jsx5(CanvasPendingMarker, {}), children: [
|
|
3104
|
+
/* @__PURE__ */ jsx5(StoryboardAdmission, { children: renderChildren }),
|
|
3105
|
+
/* @__PURE__ */ jsx5(
|
|
3106
|
+
StoryboardCommitSignal,
|
|
2244
3107
|
{
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
3108
|
+
commitKey,
|
|
3109
|
+
onCommit: handleRendered
|
|
3110
|
+
},
|
|
3111
|
+
commitKey
|
|
2249
3112
|
)
|
|
2250
|
-
] })
|
|
3113
|
+
] }) : null
|
|
2251
3114
|
}
|
|
2252
3115
|
)
|
|
2253
3116
|
}
|
|
@@ -2255,11 +3118,33 @@ function StoryboardSlot({
|
|
|
2255
3118
|
}
|
|
2256
3119
|
);
|
|
2257
3120
|
}
|
|
2258
|
-
|
|
2259
|
-
|
|
3121
|
+
function StoryboardAdmission({ children }) {
|
|
3122
|
+
beginAdmissionWindow();
|
|
3123
|
+
return children;
|
|
3124
|
+
}
|
|
3125
|
+
function StoryboardCommitSignal({
|
|
3126
|
+
commitKey,
|
|
3127
|
+
onCommit
|
|
3128
|
+
}) {
|
|
3129
|
+
const onCommitRef = useRef4(onCommit);
|
|
3130
|
+
onCommitRef.current = onCommit;
|
|
3131
|
+
useLayoutEffect3(() => onCommitRef.current(commitKey), [commitKey]);
|
|
3132
|
+
return null;
|
|
3133
|
+
}
|
|
3134
|
+
var maxReportedComponentStackFrames = 40;
|
|
3135
|
+
function boundComponentStack(componentStack) {
|
|
3136
|
+
if (!componentStack) return void 0;
|
|
3137
|
+
const frames = componentStack.split("\n");
|
|
3138
|
+
if (frames.length <= maxReportedComponentStackFrames) return componentStack;
|
|
3139
|
+
const dropped = frames.length - maxReportedComponentStackFrames;
|
|
3140
|
+
return [
|
|
3141
|
+
...frames.slice(0, maxReportedComponentStackFrames),
|
|
3142
|
+
` ... ${dropped} more frames`
|
|
3143
|
+
].join("\n");
|
|
3144
|
+
}
|
|
3145
|
+
var StoryboardErrorBoundary = class extends Component2 {
|
|
2260
3146
|
constructor() {
|
|
2261
3147
|
super(...arguments);
|
|
2262
|
-
this.retryTimer = null;
|
|
2263
3148
|
this.state = {
|
|
2264
3149
|
error: null,
|
|
2265
3150
|
componentStack: void 0,
|
|
@@ -2271,49 +3156,36 @@ var StoryboardErrorBoundary = class extends Component {
|
|
|
2271
3156
|
}
|
|
2272
3157
|
static getDerivedStateFromProps(props, state) {
|
|
2273
3158
|
if (props.resetKey !== state.resetKey) {
|
|
2274
|
-
return {
|
|
3159
|
+
return {
|
|
3160
|
+
error: null,
|
|
3161
|
+
componentStack: void 0,
|
|
3162
|
+
resetKey: props.resetKey
|
|
3163
|
+
};
|
|
2275
3164
|
}
|
|
2276
3165
|
return null;
|
|
2277
3166
|
}
|
|
2278
3167
|
componentDidCatch(error, info) {
|
|
2279
|
-
|
|
3168
|
+
const componentStack = boundComponentStack(info.componentStack);
|
|
3169
|
+
this.setState({ componentStack });
|
|
2280
3170
|
this.props.onError({
|
|
2281
3171
|
message: error.message,
|
|
2282
3172
|
stack: error.stack,
|
|
2283
|
-
componentStack
|
|
3173
|
+
componentStack
|
|
2284
3174
|
});
|
|
2285
|
-
this.scheduleRetry();
|
|
2286
|
-
}
|
|
2287
|
-
componentDidUpdate(_prevProps, prevState) {
|
|
2288
|
-
if (this.state.error) {
|
|
2289
|
-
if (!this.retryTimer) this.scheduleRetry();
|
|
2290
|
-
return;
|
|
2291
|
-
}
|
|
2292
|
-
this.clearRetryTimer();
|
|
2293
|
-
if (prevState.error && !this.state.error) {
|
|
2294
|
-
this.props.onRecover();
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
componentWillUnmount() {
|
|
2298
|
-
this.clearRetryTimer();
|
|
2299
3175
|
}
|
|
2300
|
-
|
|
2301
|
-
this.
|
|
2302
|
-
this.retryTimer = setTimeout(() => {
|
|
2303
|
-
this.retryTimer = null;
|
|
2304
|
-
this.setState(
|
|
2305
|
-
(state) => state.error ? { error: null, componentStack: void 0, resetKey: state.resetKey } : null
|
|
2306
|
-
);
|
|
2307
|
-
}, renderErrorRetryDelayMs);
|
|
3176
|
+
hasError() {
|
|
3177
|
+
return this.state.error !== null;
|
|
2308
3178
|
}
|
|
2309
|
-
|
|
2310
|
-
if (!this.
|
|
2311
|
-
|
|
2312
|
-
|
|
3179
|
+
retry() {
|
|
3180
|
+
if (!this.state.error) return false;
|
|
3181
|
+
this.setState(
|
|
3182
|
+
(state) => state.error ? { error: null, componentStack: void 0, resetKey: state.resetKey } : null
|
|
3183
|
+
);
|
|
3184
|
+
return true;
|
|
2313
3185
|
}
|
|
2314
3186
|
render() {
|
|
2315
3187
|
if (this.state.error) {
|
|
2316
|
-
return /* @__PURE__ */
|
|
3188
|
+
return /* @__PURE__ */ jsx5(
|
|
2317
3189
|
"div",
|
|
2318
3190
|
{
|
|
2319
3191
|
"data-render-error": "true",
|
|
@@ -2325,50 +3197,34 @@ var StoryboardErrorBoundary = class extends Component {
|
|
|
2325
3197
|
return this.props.children;
|
|
2326
3198
|
}
|
|
2327
3199
|
};
|
|
2328
|
-
function StoryboardReadySentinel({
|
|
2329
|
-
active,
|
|
2330
|
-
clearError,
|
|
2331
|
-
markRendered
|
|
2332
|
-
}) {
|
|
2333
|
-
useEffect2(() => {
|
|
2334
|
-
if (!active) return;
|
|
2335
|
-
let paintFrame = 0;
|
|
2336
|
-
const commitFrame = requestAnimationFrame(() => {
|
|
2337
|
-
paintFrame = requestAnimationFrame(() => {
|
|
2338
|
-
clearError();
|
|
2339
|
-
markRendered();
|
|
2340
|
-
});
|
|
2341
|
-
});
|
|
2342
|
-
return () => {
|
|
2343
|
-
cancelAnimationFrame(commitFrame);
|
|
2344
|
-
cancelAnimationFrame(paintFrame);
|
|
2345
|
-
};
|
|
2346
|
-
}, [active, clearError, markRendered]);
|
|
2347
|
-
return null;
|
|
2348
|
-
}
|
|
2349
3200
|
export {
|
|
3201
|
+
CANVAS_HOST_DOCUMENT_TITLE,
|
|
2350
3202
|
Canvas,
|
|
2351
3203
|
CanvasContext,
|
|
2352
3204
|
CanvasHost,
|
|
3205
|
+
CanvasHostContractError,
|
|
3206
|
+
CanvasImportBoundary,
|
|
2353
3207
|
HtmlStoryboard,
|
|
2354
3208
|
LegacyStoryboardV1,
|
|
2355
3209
|
RouteStoryboard,
|
|
2356
3210
|
Storyboard,
|
|
2357
3211
|
StoryboardSlot,
|
|
3212
|
+
TEMPO_INTERACT_FRAME_NAME,
|
|
2358
3213
|
buildRenderContentFiberSelector,
|
|
2359
3214
|
buildRenderContentSelector,
|
|
2360
3215
|
buildRenderSelector,
|
|
3216
|
+
canvasHostCapability,
|
|
2361
3217
|
captureStoryboardCombined,
|
|
2362
3218
|
captureStoryboardHtml,
|
|
2363
3219
|
captureStoryboardImage,
|
|
2364
|
-
|
|
3220
|
+
getCanvasHostRecoveryFeed,
|
|
2365
3221
|
getCanvasHostRuntime,
|
|
2366
3222
|
getCanvasStoryboardRenderId,
|
|
2367
3223
|
getOptionalCanvasHostRuntime,
|
|
3224
|
+
isTempoInteractFrameName,
|
|
2368
3225
|
stripRenderContentWrapperAttributes,
|
|
2369
3226
|
stripRenderContentWrapperFromCombinedCapture,
|
|
2370
3227
|
useActiveState,
|
|
2371
|
-
watchStoryboardCombined
|
|
2372
|
-
watchStoryboardHtml
|
|
3228
|
+
watchStoryboardCombined
|
|
2373
3229
|
};
|
|
2374
3230
|
//# sourceMappingURL=index.js.map
|