tempo-sdk 0.0.20 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.d.ts +19 -2
- package/dist/canvas/index.js +224 -50
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4250 -1547
- package/dist/canvas/interact-projection.js.map +1 -1
- package/dist/chunk-ZT2REPH4.js +19 -0
- package/dist/chunk-ZT2REPH4.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +610 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/canvas/index.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ declare function CanvasImportBoundary({ canvasPath, load, }: {
|
|
|
27
27
|
load: () => Promise<CanvasModule>;
|
|
28
28
|
}): react_jsx_runtime.JSX.Element;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Live document title of every component-host page. AI agents connected over
|
|
32
|
+
* CDP identify Tempo-internal frames by the leading "INTERNAL" marker and
|
|
33
|
+
* leave them alone. Only the runtime title changes: the static
|
|
34
|
+
* `<title>tempo-host</title>` in the harness HTML must stay untouched because
|
|
35
|
+
* tempo-devserver's HTTP host detector matches on that exact body text.
|
|
36
|
+
*/
|
|
37
|
+
declare const CANVAS_HOST_DOCUMENT_TITLE = "INTERNAL tempo-host \u2014 Tempo component host, do not interact";
|
|
30
38
|
type CanvasHostModule = {
|
|
31
39
|
canvasPath: string;
|
|
32
40
|
load: () => Promise<CanvasModule>;
|
|
@@ -46,6 +54,10 @@ type CanvasHostCaptureResult = {
|
|
|
46
54
|
src: string;
|
|
47
55
|
width: number;
|
|
48
56
|
height: number;
|
|
57
|
+
/** The capture is fully transparent — the storyboard rendered nothing
|
|
58
|
+
* visible. Reported by hosts that scan the decoded bitmap; absent means
|
|
59
|
+
* the host did not answer, never that content was found. */
|
|
60
|
+
contentEmpty?: boolean;
|
|
49
61
|
};
|
|
50
62
|
timing?: Record<string, number>;
|
|
51
63
|
};
|
|
@@ -116,7 +128,12 @@ declare const buildRenderContentSelector: (renderId: string) => string;
|
|
|
116
128
|
declare const buildRenderContentFiberSelector: (renderId: string) => string;
|
|
117
129
|
declare function stripRenderContentWrapperAttributes<T>(capture: T, renderId: string): T;
|
|
118
130
|
declare function stripRenderContentWrapperFromCombinedCapture<T>(capture: T, renderId: string): T;
|
|
119
|
-
declare function captureStoryboardImage(renderId: string, options?: Parameters<CanvasHostRuntime["captureSelector"]>[1]
|
|
131
|
+
declare function captureStoryboardImage(renderId: string, options?: Parameters<CanvasHostRuntime["captureSelector"]>[1] & {
|
|
132
|
+
/** Capture a single descendant of the storyboard's render root instead of
|
|
133
|
+
* the root — composed as `<renderRoot> <childSelector>`, so it can only
|
|
134
|
+
* ever match inside this storyboard's slot. */
|
|
135
|
+
childSelector?: string;
|
|
136
|
+
}): Promise<CanvasHostCaptureResult | null>;
|
|
120
137
|
declare function captureStoryboardHtml(renderId: string, options?: {
|
|
121
138
|
timeout?: number;
|
|
122
139
|
}): Promise<unknown | null>;
|
|
@@ -254,4 +271,4 @@ declare function StoryboardSlot({ children, id, kind, layout, name, route, filep
|
|
|
254
271
|
src?: string;
|
|
255
272
|
}): react_jsx_runtime.JSX.Element | null;
|
|
256
273
|
|
|
257
|
-
export { Canvas, CanvasContext, CanvasHost, type CanvasHostCaptureResult, CanvasHostContractError, type CanvasHostModule, type CanvasHostRecoveryEvent, type CanvasHostRecoveryFeed, type CanvasHostRuntime, type CanvasHostWatch, CanvasImportBoundary, HtmlStoryboard, LegacyStoryboardV1, RouteStoryboard, Storyboard, type StoryboardLayout, StoryboardSlot, TEMPO_INTERACT_FRAME_NAME, buildRenderContentFiberSelector, buildRenderContentSelector, buildRenderSelector, canvasHostCapability, captureStoryboardCombined, captureStoryboardHtml, captureStoryboardImage, getCanvasHostRecoveryFeed, getCanvasHostRuntime, getCanvasStoryboardRenderId, getOptionalCanvasHostRuntime, isTempoInteractFrameName, stripRenderContentWrapperAttributes, stripRenderContentWrapperFromCombinedCapture, useActiveState, watchStoryboardCombined };
|
|
274
|
+
export { CANVAS_HOST_DOCUMENT_TITLE, Canvas, CanvasContext, CanvasHost, type CanvasHostCaptureResult, CanvasHostContractError, type CanvasHostModule, type CanvasHostRecoveryEvent, type CanvasHostRecoveryFeed, type CanvasHostRuntime, type CanvasHostWatch, CanvasImportBoundary, HtmlStoryboard, LegacyStoryboardV1, RouteStoryboard, Storyboard, type StoryboardLayout, StoryboardSlot, TEMPO_INTERACT_FRAME_NAME, buildRenderContentFiberSelector, buildRenderContentSelector, buildRenderSelector, canvasHostCapability, captureStoryboardCombined, captureStoryboardHtml, captureStoryboardImage, getCanvasHostRecoveryFeed, getCanvasHostRuntime, getCanvasStoryboardRenderId, getOptionalCanvasHostRuntime, isTempoInteractFrameName, stripRenderContentWrapperAttributes, stripRenderContentWrapperFromCombinedCapture, useActiveState, watchStoryboardCombined };
|
package/dist/canvas/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PROJECTION_PENDING_ATTRIBUTE
|
|
3
|
+
} from "../chunk-ZT2REPH4.js";
|
|
1
4
|
import {
|
|
2
5
|
TEMPO_INTERACT_FRAME_NAME,
|
|
3
6
|
isTempoInteractFrameName
|
|
@@ -89,7 +92,7 @@ function CanvasContext({
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
// canvas/canvas-host.tsx
|
|
92
|
-
import { useMemo as useMemo4 } from "react";
|
|
95
|
+
import { useEffect as useEffect3, useMemo as useMemo4 } from "react";
|
|
93
96
|
|
|
94
97
|
// canvas/canvas-import-boundary.tsx
|
|
95
98
|
import {
|
|
@@ -104,6 +107,19 @@ import {
|
|
|
104
107
|
useState
|
|
105
108
|
} from "react";
|
|
106
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
|
+
|
|
107
123
|
// canvas/host-recovery-feed.ts
|
|
108
124
|
var FEED_KEY = "__tempoCanvasHostRecoveryFeed";
|
|
109
125
|
function createFeed() {
|
|
@@ -185,7 +201,7 @@ function useStoryboardPlacement(storyboardId) {
|
|
|
185
201
|
}
|
|
186
202
|
|
|
187
203
|
// canvas/canvas-import-boundary.tsx
|
|
188
|
-
import { jsx as
|
|
204
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
189
205
|
var CanvasImportErrorBoundary = class extends Component {
|
|
190
206
|
constructor() {
|
|
191
207
|
super(...arguments);
|
|
@@ -234,7 +250,7 @@ function CanvasImportBoundary({
|
|
|
234
250
|
const LazyCanvas = useMemo2(() => {
|
|
235
251
|
void lazyIdentity;
|
|
236
252
|
return lazy(
|
|
237
|
-
() => loadRef.current().catch((error) => {
|
|
253
|
+
() => Promise.resolve().then(() => loadRef.current()).catch((error) => {
|
|
238
254
|
getCanvasHostRecoveryFeed().publish({
|
|
239
255
|
type: "module-load-failure",
|
|
240
256
|
path: canvasPath,
|
|
@@ -272,9 +288,9 @@ function CanvasImportBoundary({
|
|
|
272
288
|
() => registerCanvasProblemScope(canvasPath),
|
|
273
289
|
[canvasPath, registerCanvasProblemScope]
|
|
274
290
|
);
|
|
275
|
-
return /* @__PURE__ */
|
|
276
|
-
/* @__PURE__ */
|
|
277
|
-
/* @__PURE__ */
|
|
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 })
|
|
278
294
|
] }) }) }, retryRevision);
|
|
279
295
|
}
|
|
280
296
|
|
|
@@ -639,11 +655,14 @@ async function captureStoryboardImage(renderId, options) {
|
|
|
639
655
|
...options?.portalSelectors ?? [],
|
|
640
656
|
...getStoryboardPortalSelectors(renderId)
|
|
641
657
|
];
|
|
658
|
+
const renderSelector = buildRenderSelector(renderId);
|
|
659
|
+
const { childSelector, ...captureOptions } = options ?? {};
|
|
660
|
+
const captureSelector = childSelector ? `${renderSelector} ${childSelector}` : renderSelector;
|
|
642
661
|
await nextAnimationFrame();
|
|
643
662
|
await nextAnimationFrame();
|
|
644
663
|
return await getCanvasHostRuntime().captureSelector(
|
|
645
|
-
|
|
646
|
-
portalSelectors.length > 0 ? { ...
|
|
664
|
+
captureSelector,
|
|
665
|
+
portalSelectors.length > 0 ? { ...captureOptions, portalSelectors: [...new Set(portalSelectors)] } : captureOptions
|
|
647
666
|
);
|
|
648
667
|
}
|
|
649
668
|
async function captureStoryboardHtml(renderId, options) {
|
|
@@ -919,8 +938,9 @@ function evictCachedRenders(entries, maxCached) {
|
|
|
919
938
|
}
|
|
920
939
|
return next;
|
|
921
940
|
}
|
|
922
|
-
function buildRenderStatePayload(entries, maxCached) {
|
|
941
|
+
function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
|
|
923
942
|
return {
|
|
943
|
+
canvasPaths: [...canvasPaths],
|
|
924
944
|
renders: [...entries.values()].map(
|
|
925
945
|
({
|
|
926
946
|
activeCount: _activeCount,
|
|
@@ -1882,7 +1902,7 @@ function setRuntimeWatchPaused(watch, paused, resumeOptions) {
|
|
|
1882
1902
|
}
|
|
1883
1903
|
}
|
|
1884
1904
|
}
|
|
1885
|
-
function useCanvasHostPostMessage() {
|
|
1905
|
+
function useCanvasHostPostMessage(registeredCanvasPaths = []) {
|
|
1886
1906
|
const [renderEntriesById, setRenderEntriesById] = useState2(
|
|
1887
1907
|
() => /* @__PURE__ */ new Map()
|
|
1888
1908
|
);
|
|
@@ -1894,6 +1914,8 @@ function useCanvasHostPostMessage() {
|
|
|
1894
1914
|
);
|
|
1895
1915
|
const renderEntriesRef = useRef2(renderEntriesById);
|
|
1896
1916
|
const watchRequestsRef = useRef2(watchRequestsById);
|
|
1917
|
+
const registeredCanvasPathsRef = useRef2([]);
|
|
1918
|
+
registeredCanvasPathsRef.current = registeredCanvasPaths;
|
|
1897
1919
|
const maxCachedRef = useRef2(DEFAULT_MAX_CACHED_RENDERS);
|
|
1898
1920
|
const legacyHealthRef = useRef2(createLegacyHostHealth());
|
|
1899
1921
|
const renderedRenderIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
@@ -2027,7 +2049,11 @@ function useCanvasHostPostMessage() {
|
|
|
2027
2049
|
[stopRuntimeWatch]
|
|
2028
2050
|
);
|
|
2029
2051
|
const buildState = useCallback3(
|
|
2030
|
-
() => buildRenderStatePayload(
|
|
2052
|
+
() => buildRenderStatePayload(
|
|
2053
|
+
renderEntriesRef.current,
|
|
2054
|
+
maxCachedRef.current,
|
|
2055
|
+
registeredCanvasPathsRef.current
|
|
2056
|
+
),
|
|
2031
2057
|
[]
|
|
2032
2058
|
);
|
|
2033
2059
|
const markStoryboardRendered = useCallback3((storyboardId) => {
|
|
@@ -2329,6 +2355,7 @@ function useCanvasHostPostMessage() {
|
|
|
2329
2355
|
void withRenderLease(
|
|
2330
2356
|
request,
|
|
2331
2357
|
() => captureStoryboardImage(request.renderId, {
|
|
2358
|
+
childSelector: typeof payload.childSelector === "string" ? payload.childSelector : void 0,
|
|
2332
2359
|
overlaySelector: typeof payload.overlaySelector === "string" ? payload.overlaySelector : void 0,
|
|
2333
2360
|
format: payload.format === "jpeg" || payload.format === "png" ? payload.format : void 0,
|
|
2334
2361
|
quality: readOptionalNumber(payload, "quality"),
|
|
@@ -2565,7 +2592,28 @@ function buildWatchBindingKey(commandType, payload) {
|
|
|
2565
2592
|
}
|
|
2566
2593
|
|
|
2567
2594
|
// canvas/canvas-host.tsx
|
|
2568
|
-
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
|
+
}
|
|
2569
2617
|
var CanvasHostContractError = class extends Error {
|
|
2570
2618
|
constructor() {
|
|
2571
2619
|
super(...arguments);
|
|
@@ -2624,6 +2672,14 @@ function CanvasHost({
|
|
|
2624
2672
|
"CanvasHost cannot receive both children and canvasModules."
|
|
2625
2673
|
);
|
|
2626
2674
|
}
|
|
2675
|
+
const registeredCanvasPaths = useMemo4(
|
|
2676
|
+
() => [
|
|
2677
|
+
...new Set(
|
|
2678
|
+
canvasModules?.map(({ canvasPath }) => canvasPath.trim()) ?? []
|
|
2679
|
+
)
|
|
2680
|
+
].filter(Boolean),
|
|
2681
|
+
[canvasModules]
|
|
2682
|
+
);
|
|
2627
2683
|
const {
|
|
2628
2684
|
renderStatusById: renderStatusById2,
|
|
2629
2685
|
renderSizeById,
|
|
@@ -2634,7 +2690,11 @@ function CanvasHost({
|
|
|
2634
2690
|
reportCanvasImportError,
|
|
2635
2691
|
clearCanvasImportError,
|
|
2636
2692
|
registerCanvasProblemScope
|
|
2637
|
-
} = useCanvasHostPostMessage();
|
|
2693
|
+
} = useCanvasHostPostMessage(registeredCanvasPaths);
|
|
2694
|
+
useEffect3(() => {
|
|
2695
|
+
if (typeof document === "undefined") return;
|
|
2696
|
+
return protectCanvasHostDocumentTitle(document);
|
|
2697
|
+
}, []);
|
|
2638
2698
|
const directUrlSearch = typeof window === "undefined" ? "" : window.location.search;
|
|
2639
2699
|
const directUrlRender = useMemo4(() => {
|
|
2640
2700
|
void directUrlSearch;
|
|
@@ -2689,7 +2749,7 @@ function CanvasHost({
|
|
|
2689
2749
|
);
|
|
2690
2750
|
return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
|
|
2691
2751
|
children,
|
|
2692
|
-
canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */
|
|
2752
|
+
canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx4(
|
|
2693
2753
|
CanvasImportBoundary,
|
|
2694
2754
|
{
|
|
2695
2755
|
canvasPath,
|
|
@@ -2714,23 +2774,93 @@ import {
|
|
|
2714
2774
|
isValidElement as isValidElement2,
|
|
2715
2775
|
Suspense as Suspense2,
|
|
2716
2776
|
useCallback as useCallback5,
|
|
2717
|
-
useEffect as
|
|
2777
|
+
useEffect as useEffect5,
|
|
2718
2778
|
useLayoutEffect as useLayoutEffect3,
|
|
2719
2779
|
useMemo as useMemo5,
|
|
2720
2780
|
useRef as useRef4,
|
|
2721
2781
|
useState as useState3
|
|
2722
2782
|
} from "react";
|
|
2723
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
|
+
|
|
2724
2843
|
// canvas/render-error-recovery.ts
|
|
2725
|
-
import { useCallback as useCallback4, useEffect as
|
|
2844
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
2726
2845
|
var renderErrorRetryBaseDelayMs = 1e3;
|
|
2727
2846
|
var renderErrorRetryMaxDelayMs = 8e3;
|
|
2728
|
-
var
|
|
2729
|
-
function
|
|
2730
|
-
|
|
2847
|
+
var BEAT_BUS_KEY = "__tempoRenderErrorRecoveryBeatBus";
|
|
2848
|
+
function createBeatBus() {
|
|
2849
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2850
|
+
return {
|
|
2851
|
+
emit() {
|
|
2852
|
+
for (const listener of [...listeners]) listener();
|
|
2853
|
+
},
|
|
2854
|
+
subscribe(listener) {
|
|
2855
|
+
listeners.add(listener);
|
|
2856
|
+
return () => listeners.delete(listener);
|
|
2857
|
+
}
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
function getRenderErrorRecoveryBeatBus() {
|
|
2861
|
+
const globals = globalThis;
|
|
2862
|
+
return globals[BEAT_BUS_KEY] ?? (globals[BEAT_BUS_KEY] = createBeatBus());
|
|
2731
2863
|
}
|
|
2732
|
-
var hot = import.meta.hot;
|
|
2733
|
-
hot?.on?.("vite:afterUpdate", emitRenderErrorRecoveryBeat);
|
|
2734
2864
|
function useRenderErrorRecovery(retryNow) {
|
|
2735
2865
|
const retryNowRef = useRef3(retryNow);
|
|
2736
2866
|
retryNowRef.current = retryNow;
|
|
@@ -2757,16 +2887,16 @@ function useRenderErrorRecovery(retryNow) {
|
|
|
2757
2887
|
nextDelayRef.current = renderErrorRetryBaseDelayMs;
|
|
2758
2888
|
clearTimer();
|
|
2759
2889
|
}, [clearTimer]);
|
|
2760
|
-
|
|
2890
|
+
useEffect4(() => {
|
|
2761
2891
|
const onBeat = () => {
|
|
2762
2892
|
nextDelayRef.current = renderErrorRetryBaseDelayMs;
|
|
2763
2893
|
if (!erroredRef.current) return;
|
|
2764
2894
|
clearTimer();
|
|
2765
2895
|
retryNowRef.current();
|
|
2766
2896
|
};
|
|
2767
|
-
|
|
2897
|
+
const unsubscribe = getRenderErrorRecoveryBeatBus().subscribe(onBeat);
|
|
2768
2898
|
return () => {
|
|
2769
|
-
|
|
2899
|
+
unsubscribe();
|
|
2770
2900
|
clearTimer();
|
|
2771
2901
|
};
|
|
2772
2902
|
}, [clearTimer]);
|
|
@@ -2774,7 +2904,7 @@ function useRenderErrorRecovery(retryNow) {
|
|
|
2774
2904
|
}
|
|
2775
2905
|
|
|
2776
2906
|
// canvas/storyboard.tsx
|
|
2777
|
-
import { Fragment, jsx as
|
|
2907
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2778
2908
|
function Storyboard({
|
|
2779
2909
|
id,
|
|
2780
2910
|
name,
|
|
@@ -2783,27 +2913,27 @@ function Storyboard({
|
|
|
2783
2913
|
props
|
|
2784
2914
|
}) {
|
|
2785
2915
|
const Component3 = component;
|
|
2786
|
-
return /* @__PURE__ */
|
|
2916
|
+
return /* @__PURE__ */ jsx5(StoryboardSlot, { id, name, layout, kind: "component", children: /* @__PURE__ */ jsx5(Component3, { ...props ?? {} }) });
|
|
2787
2917
|
}
|
|
2788
2918
|
function LegacyStoryboardV1({
|
|
2789
2919
|
id,
|
|
2790
2920
|
storyboard
|
|
2791
2921
|
}) {
|
|
2792
|
-
return /* @__PURE__ */
|
|
2922
|
+
return /* @__PURE__ */ jsx5(
|
|
2793
2923
|
StoryboardSlot,
|
|
2794
2924
|
{
|
|
2795
2925
|
id,
|
|
2796
2926
|
name: storyboard.name,
|
|
2797
2927
|
layout: storyboard.layout,
|
|
2798
2928
|
kind: "component",
|
|
2799
|
-
children: /* @__PURE__ */
|
|
2929
|
+
children: /* @__PURE__ */ jsx5(LegacyStoryboardV1Render, { render: storyboard.render })
|
|
2800
2930
|
}
|
|
2801
2931
|
);
|
|
2802
2932
|
}
|
|
2803
2933
|
function LegacyStoryboardV1Render({
|
|
2804
2934
|
render
|
|
2805
2935
|
}) {
|
|
2806
|
-
return /* @__PURE__ */
|
|
2936
|
+
return /* @__PURE__ */ jsx5(Fragment, { children: render() });
|
|
2807
2937
|
}
|
|
2808
2938
|
function RouteStoryboard({
|
|
2809
2939
|
id,
|
|
@@ -2811,7 +2941,7 @@ function RouteStoryboard({
|
|
|
2811
2941
|
route,
|
|
2812
2942
|
layout
|
|
2813
2943
|
}) {
|
|
2814
|
-
return /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ jsx5(
|
|
2815
2945
|
StoryboardSlot,
|
|
2816
2946
|
{
|
|
2817
2947
|
id,
|
|
@@ -2829,7 +2959,7 @@ function HtmlStoryboard({
|
|
|
2829
2959
|
src,
|
|
2830
2960
|
layout
|
|
2831
2961
|
}) {
|
|
2832
|
-
return /* @__PURE__ */
|
|
2962
|
+
return /* @__PURE__ */ jsx5(
|
|
2833
2963
|
StoryboardSlot,
|
|
2834
2964
|
{
|
|
2835
2965
|
id,
|
|
@@ -2865,6 +2995,10 @@ function StoryboardSlot({
|
|
|
2865
2995
|
const intrinsicSize = renderSize?.intrinsicSize ?? (kind === "component" && layout.intrinsicSizing === "root-element");
|
|
2866
2996
|
const resetKey = `${renderId}:${renderRevision}`;
|
|
2867
2997
|
const contentRef = useRef4(null);
|
|
2998
|
+
const [admittedRenderId, setAdmittedRenderId] = useState3(
|
|
2999
|
+
typeof document === "undefined" ? renderId : null
|
|
3000
|
+
);
|
|
3001
|
+
const admitted = admittedRenderId === renderId;
|
|
2868
3002
|
const errorBoundaryRef = useRef4(null);
|
|
2869
3003
|
const lastReportedCommitRef = useRef4(null);
|
|
2870
3004
|
const previousChildrenRef = useRef4(children);
|
|
@@ -2883,16 +3017,35 @@ function StoryboardSlot({
|
|
|
2883
3017
|
},
|
|
2884
3018
|
[noteRenderError, reportError]
|
|
2885
3019
|
);
|
|
3020
|
+
const pendingRenderedReportRef = useRef4(
|
|
3021
|
+
null
|
|
3022
|
+
);
|
|
2886
3023
|
const handleRendered = useCallback5(
|
|
2887
3024
|
(reportedCommitKey) => {
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
3025
|
+
if (pendingRenderedReportRef.current !== null) {
|
|
3026
|
+
clearTimeout(pendingRenderedReportRef.current);
|
|
3027
|
+
}
|
|
3028
|
+
pendingRenderedReportRef.current = setTimeout(() => {
|
|
3029
|
+
pendingRenderedReportRef.current = null;
|
|
3030
|
+
if (errorBoundaryRef.current?.hasError()) return;
|
|
3031
|
+
noteRecovered();
|
|
3032
|
+
if (lastReportedCommitRef.current === reportedCommitKey) return;
|
|
3033
|
+
lastReportedCommitRef.current = reportedCommitKey;
|
|
3034
|
+
clearError();
|
|
3035
|
+
markRendered();
|
|
3036
|
+
}, 0);
|
|
2893
3037
|
},
|
|
2894
3038
|
[clearError, markRendered, noteRecovered]
|
|
2895
3039
|
);
|
|
3040
|
+
useEffect5(
|
|
3041
|
+
() => () => {
|
|
3042
|
+
if (pendingRenderedReportRef.current !== null) {
|
|
3043
|
+
clearTimeout(pendingRenderedReportRef.current);
|
|
3044
|
+
pendingRenderedReportRef.current = null;
|
|
3045
|
+
}
|
|
3046
|
+
},
|
|
3047
|
+
[]
|
|
3048
|
+
);
|
|
2896
3049
|
const renderChildren = useMemo5(() => {
|
|
2897
3050
|
if (isValidElement2(children)) return cloneElement2(children);
|
|
2898
3051
|
return Children2.map(
|
|
@@ -2900,22 +3053,25 @@ function StoryboardSlot({
|
|
|
2900
3053
|
(child) => isValidElement2(child) ? cloneElement2(child) : child
|
|
2901
3054
|
);
|
|
2902
3055
|
}, [children]);
|
|
2903
|
-
|
|
2904
|
-
|
|
3056
|
+
useEffect5(() => markUnmounted, [markUnmounted]);
|
|
3057
|
+
useEffect5(() => {
|
|
3058
|
+
setAdmittedRenderId(renderId);
|
|
3059
|
+
}, [renderId]);
|
|
3060
|
+
useEffect5(() => {
|
|
2905
3061
|
const childrenChanged = previousChildrenRef.current !== children;
|
|
2906
3062
|
previousChildrenRef.current = children;
|
|
2907
3063
|
if (childrenChanged) retryRenderNow();
|
|
2908
3064
|
}, [children, retryRenderNow]);
|
|
2909
|
-
|
|
3065
|
+
useEffect5(() => {
|
|
2910
3066
|
if (!contentRef.current || status === "unmounted") return;
|
|
2911
3067
|
return trackStoryboardPortals(renderId, contentRef.current, status);
|
|
2912
3068
|
}, [renderId, status]);
|
|
2913
|
-
|
|
3069
|
+
useEffect5(() => {
|
|
2914
3070
|
if (status === "unmounted") return;
|
|
2915
3071
|
syncStoryboardPortals(renderId, status);
|
|
2916
3072
|
}, [renderId, status]);
|
|
2917
3073
|
if (status === "unmounted") return null;
|
|
2918
|
-
return /* @__PURE__ */
|
|
3074
|
+
return /* @__PURE__ */ jsx5(
|
|
2919
3075
|
"div",
|
|
2920
3076
|
{
|
|
2921
3077
|
"data-render-id": renderId,
|
|
@@ -2940,23 +3096,24 @@ function StoryboardSlot({
|
|
|
2940
3096
|
visibility: status === "active" ? "visible" : "hidden",
|
|
2941
3097
|
pointerEvents: status === "active" ? "auto" : "none"
|
|
2942
3098
|
},
|
|
2943
|
-
children: /* @__PURE__ */
|
|
3099
|
+
children: /* @__PURE__ */ jsx5(
|
|
2944
3100
|
"div",
|
|
2945
3101
|
{
|
|
2946
3102
|
"data-render-content": renderId,
|
|
3103
|
+
"data-render-admitted": admitted ? "true" : void 0,
|
|
2947
3104
|
"data-tempo-render-mode": kind === "html" ? "static-dom" : void 0,
|
|
2948
3105
|
"data-tempo-hide-fiber": "true",
|
|
2949
3106
|
ref: contentRef,
|
|
2950
3107
|
style: { width: "100%", height: "100%" },
|
|
2951
|
-
children: /* @__PURE__ */
|
|
3108
|
+
children: /* @__PURE__ */ jsx5(
|
|
2952
3109
|
StoryboardErrorBoundary,
|
|
2953
3110
|
{
|
|
2954
3111
|
ref: errorBoundaryRef,
|
|
2955
3112
|
onError: handleRenderError,
|
|
2956
3113
|
resetKey,
|
|
2957
|
-
children: /* @__PURE__ */ jsxs3(Suspense2, { fallback:
|
|
2958
|
-
renderChildren,
|
|
2959
|
-
/* @__PURE__ */
|
|
3114
|
+
children: admitted ? /* @__PURE__ */ jsxs3(Suspense2, { fallback: /* @__PURE__ */ jsx5(CanvasPendingMarker, {}), children: [
|
|
3115
|
+
/* @__PURE__ */ jsx5(StoryboardAdmission, { children: renderChildren }),
|
|
3116
|
+
/* @__PURE__ */ jsx5(
|
|
2960
3117
|
StoryboardCommitSignal,
|
|
2961
3118
|
{
|
|
2962
3119
|
commitKey,
|
|
@@ -2964,7 +3121,7 @@ function StoryboardSlot({
|
|
|
2964
3121
|
},
|
|
2965
3122
|
commitKey
|
|
2966
3123
|
)
|
|
2967
|
-
] })
|
|
3124
|
+
] }) : null
|
|
2968
3125
|
}
|
|
2969
3126
|
)
|
|
2970
3127
|
}
|
|
@@ -2972,6 +3129,10 @@ function StoryboardSlot({
|
|
|
2972
3129
|
}
|
|
2973
3130
|
);
|
|
2974
3131
|
}
|
|
3132
|
+
function StoryboardAdmission({ children }) {
|
|
3133
|
+
beginAdmissionWindow();
|
|
3134
|
+
return children;
|
|
3135
|
+
}
|
|
2975
3136
|
function StoryboardCommitSignal({
|
|
2976
3137
|
commitKey,
|
|
2977
3138
|
onCommit
|
|
@@ -2981,6 +3142,17 @@ function StoryboardCommitSignal({
|
|
|
2981
3142
|
useLayoutEffect3(() => onCommitRef.current(commitKey), [commitKey]);
|
|
2982
3143
|
return null;
|
|
2983
3144
|
}
|
|
3145
|
+
var maxReportedComponentStackFrames = 40;
|
|
3146
|
+
function boundComponentStack(componentStack) {
|
|
3147
|
+
if (!componentStack) return void 0;
|
|
3148
|
+
const frames = componentStack.split("\n");
|
|
3149
|
+
if (frames.length <= maxReportedComponentStackFrames) return componentStack;
|
|
3150
|
+
const dropped = frames.length - maxReportedComponentStackFrames;
|
|
3151
|
+
return [
|
|
3152
|
+
...frames.slice(0, maxReportedComponentStackFrames),
|
|
3153
|
+
` ... ${dropped} more frames`
|
|
3154
|
+
].join("\n");
|
|
3155
|
+
}
|
|
2984
3156
|
var StoryboardErrorBoundary = class extends Component2 {
|
|
2985
3157
|
constructor() {
|
|
2986
3158
|
super(...arguments);
|
|
@@ -3004,11 +3176,12 @@ var StoryboardErrorBoundary = class extends Component2 {
|
|
|
3004
3176
|
return null;
|
|
3005
3177
|
}
|
|
3006
3178
|
componentDidCatch(error, info) {
|
|
3007
|
-
|
|
3179
|
+
const componentStack = boundComponentStack(info.componentStack);
|
|
3180
|
+
this.setState({ componentStack });
|
|
3008
3181
|
this.props.onError({
|
|
3009
3182
|
message: error.message,
|
|
3010
3183
|
stack: error.stack,
|
|
3011
|
-
componentStack
|
|
3184
|
+
componentStack
|
|
3012
3185
|
});
|
|
3013
3186
|
}
|
|
3014
3187
|
hasError() {
|
|
@@ -3023,7 +3196,7 @@ var StoryboardErrorBoundary = class extends Component2 {
|
|
|
3023
3196
|
}
|
|
3024
3197
|
render() {
|
|
3025
3198
|
if (this.state.error) {
|
|
3026
|
-
return /* @__PURE__ */
|
|
3199
|
+
return /* @__PURE__ */ jsx5(
|
|
3027
3200
|
"div",
|
|
3028
3201
|
{
|
|
3029
3202
|
"data-render-error": "true",
|
|
@@ -3036,6 +3209,7 @@ var StoryboardErrorBoundary = class extends Component2 {
|
|
|
3036
3209
|
}
|
|
3037
3210
|
};
|
|
3038
3211
|
export {
|
|
3212
|
+
CANVAS_HOST_DOCUMENT_TITLE,
|
|
3039
3213
|
Canvas,
|
|
3040
3214
|
CanvasContext,
|
|
3041
3215
|
CanvasHost,
|