tempo-sdk 0.0.28 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,125 +1,41 @@
1
1
  import {
2
- PROJECTION_PENDING_ATTRIBUTE
3
- } from "../chunk-ZT2REPH4.js";
2
+ Canvas,
3
+ CanvasContext,
4
+ CanvasHostContext,
5
+ CanvasPendingMarker,
6
+ HtmlStoryboard,
7
+ LegacyStoryboardV1,
8
+ RouteStoryboard,
9
+ Storyboard,
10
+ StoryboardSlot,
11
+ getCanvasStoryboardRenderId,
12
+ getStoryboardPortalSelectors,
13
+ normalizeId,
14
+ useActiveState,
15
+ useRequiredCanvasHost
16
+ } from "../chunk-DXKG4IGS.js";
4
17
  import {
5
18
  TEMPO_INTERACT_FRAME_NAME,
6
19
  isTempoInteractFrameName
7
20
  } from "../chunk-QXB32HG4.js";
8
-
9
- // canvas/canvas.tsx
10
- import {
11
- Children,
12
- cloneElement,
13
- createContext,
14
- isValidElement,
15
- useContext,
16
- useMemo
17
- } from "react";
18
-
19
- // canvas/ids.ts
20
- function normalizeId(value, label) {
21
- const normalized = value?.trim();
22
- if (!normalized) {
23
- throw new Error(`${label} is required.`);
24
- }
25
- return normalized;
26
- }
27
-
28
- // canvas/canvas.tsx
29
- import { jsx } from "react/jsx-runtime";
30
- var CanvasIdentityContext = createContext(null);
31
- function getCanvasStoryboardRenderId(canvasPath, storyboardId) {
32
- return `canvas:${encodeURIComponent(
33
- normalizeId(canvasPath, "Canvas path")
34
- )}#storyboard:${encodeURIComponent(
35
- normalizeId(storyboardId, "Storyboard id")
36
- )}`;
37
- }
38
- function useCanvasIdentity() {
39
- return useContext(CanvasIdentityContext);
40
- }
41
- function useCanvasStoryboardRenderId(storyboardId) {
42
- const canvas = useCanvasIdentity();
43
- const normalizedId = normalizeId(storyboardId, "Storyboard id");
44
- return canvas ? getCanvasStoryboardRenderId(canvas.path, normalizedId) : normalizedId;
45
- }
46
- function Canvas({
47
- children,
48
- name,
49
- path,
50
- backgroundColor,
51
- defaultViewport,
52
- ...sourceAnnotations
53
- }) {
54
- const contextIdentity = useCanvasIdentity();
55
- const canvasName = normalizeId(name, "Canvas name");
56
- const canvasPath = path === void 0 ? contextIdentity?.path : normalizeId(path, "Canvas path");
57
- if (!canvasPath) {
58
- throw new Error(
59
- '<Canvas> must be rendered inside <CanvasContext path="..."> or receive a path prop.'
60
- );
61
- }
62
- const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);
63
- const keyedChildren = useMemo(
64
- () => Children.map(children, (child) => {
65
- if (!isValidElement(child)) return child;
66
- if (child.key != null) return child;
67
- const id = child.props.id;
68
- if (typeof id !== "string" || id.length === 0) return child;
69
- return cloneElement(child, { key: `storyboard:${id}` });
70
- }),
71
- [children]
72
- );
73
- return /* @__PURE__ */ jsx(CanvasIdentityContext.Provider, { value: identity, children: /* @__PURE__ */ jsx(
74
- "div",
75
- {
76
- ...sourceAnnotations,
77
- "data-tempo-canvas": canvasName,
78
- "data-tempo-canvas-path": canvasPath,
79
- "data-tempo-canvas-background": backgroundColor,
80
- "data-tempo-canvas-viewport": defaultViewport ? JSON.stringify(defaultViewport) : void 0,
81
- children: keyedChildren
82
- }
83
- ) });
84
- }
85
- function CanvasContext({
86
- children,
87
- path
88
- }) {
89
- const canvasPath = normalizeId(path, "Canvas path");
90
- const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);
91
- return /* @__PURE__ */ jsx(CanvasIdentityContext.Provider, { value: identity, children });
92
- }
21
+ import "../chunk-ZT2REPH4.js";
93
22
 
94
23
  // canvas/canvas-host.tsx
95
- import { useEffect as useEffect3, useMemo as useMemo4 } from "react";
24
+ import { useEffect as useEffect3, useMemo as useMemo3 } from "react";
96
25
 
97
26
  // canvas/canvas-import-boundary.tsx
98
27
  import {
99
28
  Component,
100
29
  lazy,
101
30
  Suspense,
102
- useCallback as useCallback2,
31
+ useCallback,
103
32
  useEffect,
104
33
  useLayoutEffect,
105
- useMemo as useMemo2,
34
+ useMemo,
106
35
  useRef,
107
36
  useState
108
37
  } from "react";
109
38
 
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
39
  // canvas/host-recovery-feed.ts
124
40
  var FEED_KEY = "__tempoCanvasHostRecoveryFeed";
125
41
  function createFeed() {
@@ -139,69 +55,8 @@ function getCanvasHostRecoveryFeed() {
139
55
  return globals[FEED_KEY] ?? (globals[FEED_KEY] = createFeed());
140
56
  }
141
57
 
142
- // canvas/runtime-context.ts
143
- import { createContext as createContext2, useCallback, useContext as useContext2 } from "react";
144
- var CanvasHostContext = createContext2(null);
145
- function useRequiredCanvasHost() {
146
- const host = useContext2(CanvasHostContext);
147
- if (!host) {
148
- throw new Error(
149
- "Tempo canvas components must be rendered inside <CanvasHost>."
150
- );
151
- }
152
- return host;
153
- }
154
- function useActiveState(storyboardId) {
155
- const renderId = useCanvasStoryboardRenderId(storyboardId);
156
- const host = useRequiredCanvasHost();
157
- return host.getStoryboardStatus(renderId) !== "unmounted";
158
- }
159
- function useStoryboardStatus(storyboardId) {
160
- const renderId = useCanvasStoryboardRenderId(storyboardId);
161
- const host = useRequiredCanvasHost();
162
- return host.getStoryboardStatus(renderId);
163
- }
164
- function useStoryboardRendered(storyboardId) {
165
- const renderId = useCanvasStoryboardRenderId(storyboardId);
166
- const host = useRequiredCanvasHost();
167
- return useCallback(() => {
168
- host.markStoryboardRendered(renderId);
169
- }, [host, renderId]);
170
- }
171
- function useStoryboardUnmounted(storyboardId) {
172
- const renderId = useCanvasStoryboardRenderId(storyboardId);
173
- const { markStoryboardUnmounted } = useRequiredCanvasHost();
174
- return useCallback(() => {
175
- markStoryboardUnmounted(renderId);
176
- }, [markStoryboardUnmounted, renderId]);
177
- }
178
- function useStoryboardErrorReporter(storyboardId) {
179
- const renderId = useCanvasStoryboardRenderId(storyboardId);
180
- const host = useRequiredCanvasHost();
181
- const reportError = useCallback(
182
- (error) => {
183
- host.reportStoryboardError(renderId, error);
184
- },
185
- [host, renderId]
186
- );
187
- const clearError = useCallback(() => {
188
- host.clearStoryboardError(renderId);
189
- }, [host, renderId]);
190
- return { reportError, clearError };
191
- }
192
- function useStoryboardSize(storyboardId) {
193
- const renderId = useCanvasStoryboardRenderId(storyboardId);
194
- const host = useRequiredCanvasHost();
195
- return host.getStoryboardSize(renderId);
196
- }
197
- function useStoryboardPlacement(storyboardId) {
198
- const renderId = useCanvasStoryboardRenderId(storyboardId);
199
- const host = useRequiredCanvasHost();
200
- return host.getStoryboardPlacement(renderId);
201
- }
202
-
203
58
  // canvas/canvas-import-boundary.tsx
204
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
59
+ import { jsx, jsxs } from "react/jsx-runtime";
205
60
  var CanvasImportErrorBoundary = class extends Component {
206
61
  constructor() {
207
62
  super(...arguments);
@@ -247,7 +102,7 @@ function CanvasImportBoundary({
247
102
  loadRef.current = load;
248
103
  const [retryRevision, setRetryRevision] = useState(0);
249
104
  const lazyIdentity = `${canvasPath}:${retryRevision}`;
250
- const LazyCanvas = useMemo2(() => {
105
+ const LazyCanvas = useMemo(() => {
251
106
  void lazyIdentity;
252
107
  return lazy(
253
108
  () => Promise.resolve().then(() => loadRef.current()).catch((error) => {
@@ -260,14 +115,14 @@ function CanvasImportBoundary({
260
115
  })
261
116
  );
262
117
  }, [lazyIdentity, canvasPath]);
263
- const reportError = useCallback2(
118
+ const reportError = useCallback(
264
119
  (error) => {
265
120
  failedRef.current = true;
266
121
  reportCanvasImportError(canvasPath, error);
267
122
  },
268
123
  [canvasPath, reportCanvasImportError]
269
124
  );
270
- const markCommitted = useCallback2(() => {
125
+ const markCommitted = useCallback(() => {
271
126
  failedRef.current = false;
272
127
  clearCanvasImportError(canvasPath);
273
128
  }, [canvasPath, clearCanvasImportError]);
@@ -288,18 +143,18 @@ function CanvasImportBoundary({
288
143
  () => registerCanvasProblemScope(canvasPath),
289
144
  [canvasPath, registerCanvasProblemScope]
290
145
  );
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 })
146
+ return /* @__PURE__ */ jsx(CanvasImportErrorBoundary, { reportError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(CanvasPendingMarker, {}), children: /* @__PURE__ */ jsxs(CanvasContext, { path: canvasPath, children: [
147
+ /* @__PURE__ */ jsx(LazyCanvas, {}),
148
+ /* @__PURE__ */ jsx(CanvasCommitSignal, { onCommit: markCommitted })
294
149
  ] }) }) }, retryRevision);
295
150
  }
296
151
 
297
152
  // canvas/use-canvas-host-postmessage.ts
298
153
  import {
299
- useCallback as useCallback3,
154
+ useCallback as useCallback2,
300
155
  useEffect as useEffect2,
301
156
  useLayoutEffect as useLayoutEffect2,
302
- useMemo as useMemo3,
157
+ useMemo as useMemo2,
303
158
  useRef as useRef2,
304
159
  useState as useState2
305
160
  } from "react";
@@ -316,302 +171,6 @@ function getOptionalCanvasHostRuntime() {
316
171
  return typeof window === "undefined" ? void 0 : window.__tempoCanvasHostRuntime;
317
172
  }
318
173
 
319
- // canvas/portal-tracking.ts
320
- var PORTAL_MANAGED_PROPERTIES = [
321
- { key: "visibility", cssName: "visibility", hiddenValue: "hidden" },
322
- { key: "pointerEvents", cssName: "pointer-events", hiddenValue: "none" },
323
- {
324
- key: "contentVisibility",
325
- cssName: "content-visibility",
326
- hiddenValue: "hidden"
327
- },
328
- { key: "transition", cssName: "transition", hiddenValue: "none" },
329
- { key: "animation", cssName: "animation", hiddenValue: "none" }
330
- ];
331
- var portalElementsByRenderId = /* @__PURE__ */ new Map();
332
- var portalOwnerRenderIdsByElement = /* @__PURE__ */ new Map();
333
- var portalInlineStyleByElement = /* @__PURE__ */ new Map();
334
- var renderStatusById = /* @__PURE__ */ new Map();
335
- var projectionPortalIdAttribute = "data-projection-portal-id";
336
- var nextSdkPortalId = 1;
337
- function escapeAttributeValue(value) {
338
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
339
- }
340
- function ensureProjectionPortalId(portalRoot) {
341
- const existingId = portalRoot.getAttribute(projectionPortalIdAttribute);
342
- if (existingId) return existingId;
343
- const id = `tempo-sdk-portal-${nextSdkPortalId++}`;
344
- portalRoot.setAttribute(projectionPortalIdAttribute, id);
345
- return id;
346
- }
347
- function buildProjectionPortalSelector(portalRoot) {
348
- return `[${projectionPortalIdAttribute}="${escapeAttributeValue(
349
- ensureProjectionPortalId(portalRoot)
350
- )}"]`;
351
- }
352
- function findFiberKey(element) {
353
- return Object.keys(element).find(
354
- (key) => key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$")
355
- ) ?? null;
356
- }
357
- function findContainerKey(element) {
358
- return Object.keys(element).find((key) => key.startsWith("__reactContainer$")) ?? null;
359
- }
360
- function getFiberFromElement(element) {
361
- const fiberKey = findFiberKey(element);
362
- if (fiberKey) {
363
- return element[fiberKey] ?? null;
364
- }
365
- const containerKey = findContainerKey(element);
366
- if (containerKey) {
367
- return element[containerKey] ?? null;
368
- }
369
- return null;
370
- }
371
- var PortalTracker = class {
372
- constructor() {
373
- this.watchers = /* @__PURE__ */ new Set();
374
- this.ownerWatchersByPortalRoot = /* @__PURE__ */ new Map();
375
- this.observer = null;
376
- this.handleMutations = (mutations) => {
377
- for (const mutation of mutations) {
378
- for (const node of mutation.addedNodes) {
379
- if (node instanceof Element) {
380
- queueMicrotask(() => this.checkElement(node));
381
- }
382
- }
383
- for (const node of mutation.removedNodes) {
384
- if (!(node instanceof Element)) continue;
385
- const owners = this.ownerWatchersByPortalRoot.get(node);
386
- if (!owners) continue;
387
- for (const owner of owners) {
388
- owner.onPortalRemoved(node);
389
- }
390
- this.ownerWatchersByPortalRoot.delete(node);
391
- }
392
- }
393
- };
394
- }
395
- register(watcher) {
396
- this.watchers.add(watcher);
397
- if (this.watchers.size === 1) {
398
- this.startObserving();
399
- }
400
- if (typeof document !== "undefined" && document.body) {
401
- this.checkExistingElements();
402
- queueMicrotask(() => this.checkExistingElements());
403
- }
404
- return () => this.unregister(watcher);
405
- }
406
- checkExistingElements() {
407
- if (typeof document === "undefined" || !document.body) return;
408
- for (const child of Array.from(document.body.children)) {
409
- this.checkElement(child);
410
- }
411
- }
412
- unregister(watcher) {
413
- this.watchers.delete(watcher);
414
- for (const [portalRoot, owners] of this.ownerWatchersByPortalRoot) {
415
- owners.delete(watcher);
416
- if (owners.size === 0) {
417
- this.ownerWatchersByPortalRoot.delete(portalRoot);
418
- }
419
- }
420
- if (this.watchers.size === 0) {
421
- this.stopObserving();
422
- }
423
- }
424
- startObserving() {
425
- if (this.observer || typeof document === "undefined" || !document.body || typeof MutationObserver === "undefined") {
426
- return;
427
- }
428
- this.observer = new MutationObserver(this.handleMutations);
429
- this.observer.observe(document.body, { childList: true });
430
- }
431
- stopObserving() {
432
- this.observer?.disconnect();
433
- this.observer = null;
434
- }
435
- checkElement(element) {
436
- const ancestorDomNodes = this.getDomAncestorsViaFiber(element);
437
- if (ancestorDomNodes.length === 0) return;
438
- let owners = this.ownerWatchersByPortalRoot.get(element);
439
- for (const watcher of this.watchers) {
440
- const belongsToWatcher = ancestorDomNodes.some(
441
- (node) => watcher.element.contains(node) || watcher.element === node
442
- );
443
- if (!belongsToWatcher) continue;
444
- if (!owners) {
445
- owners = /* @__PURE__ */ new Set();
446
- this.ownerWatchersByPortalRoot.set(element, owners);
447
- }
448
- if (owners.has(watcher)) continue;
449
- owners.add(watcher);
450
- watcher.onPortalFound(element);
451
- }
452
- }
453
- getDomAncestorsViaFiber(element) {
454
- const fiber = getFiberFromElement(element);
455
- if (!fiber) return [];
456
- const domNodes = [];
457
- let current = fiber.return;
458
- while (current) {
459
- if (current.stateNode instanceof Element) {
460
- domNodes.push(current.stateNode);
461
- }
462
- current = current.return;
463
- }
464
- return domNodes;
465
- }
466
- };
467
- var portalTracker = null;
468
- function getPortalTracker() {
469
- if (!portalTracker) {
470
- portalTracker = new PortalTracker();
471
- }
472
- return portalTracker;
473
- }
474
- function getStylablePortalElement(portalRoot) {
475
- if (portalRoot instanceof HTMLElement || portalRoot instanceof SVGElement) {
476
- return portalRoot;
477
- }
478
- return null;
479
- }
480
- function ensurePortalInlineStyle(portalRoot) {
481
- const existing = portalInlineStyleByElement.get(portalRoot);
482
- if (existing) return existing;
483
- const stylableElement = getStylablePortalElement(portalRoot);
484
- const baseline = {
485
- visibility: readInlineStyleValue(stylableElement, "visibility"),
486
- pointerEvents: readInlineStyleValue(stylableElement, "pointer-events"),
487
- contentVisibility: readInlineStyleValue(
488
- stylableElement,
489
- "content-visibility"
490
- ),
491
- transition: readInlineStyleValue(stylableElement, "transition"),
492
- animation: readInlineStyleValue(stylableElement, "animation")
493
- };
494
- portalInlineStyleByElement.set(portalRoot, baseline);
495
- return baseline;
496
- }
497
- function readInlineStyleValue(element, propertyName) {
498
- return {
499
- value: element?.style.getPropertyValue(propertyName) ?? "",
500
- priority: element?.style.getPropertyPriority(propertyName) ?? ""
501
- };
502
- }
503
- function restoreInlineStyleValue(style, propertyName, baseline) {
504
- if (baseline.value) {
505
- style.setProperty(propertyName, baseline.value, baseline.priority);
506
- return;
507
- }
508
- style.removeProperty(propertyName);
509
- }
510
- function restorePortalInlineStyle(portalRoot) {
511
- const stylableElement = getStylablePortalElement(portalRoot);
512
- const baseline = portalInlineStyleByElement.get(portalRoot);
513
- if (!stylableElement || !baseline) return;
514
- for (const property of PORTAL_MANAGED_PROPERTIES) {
515
- restoreInlineStyleValue(
516
- stylableElement.style,
517
- property.cssName,
518
- baseline[property.key]
519
- );
520
- }
521
- }
522
- function syncPortalVisibility(portalRoot) {
523
- const owners = portalOwnerRenderIdsByElement.get(portalRoot);
524
- if (!owners || owners.size === 0) {
525
- restorePortalInlineStyle(portalRoot);
526
- portalInlineStyleByElement.delete(portalRoot);
527
- return;
528
- }
529
- const stylableElement = getStylablePortalElement(portalRoot);
530
- if (!stylableElement) return;
531
- const shouldBeVisible = [...owners].some(
532
- (renderId) => renderStatusById.get(renderId) === "active"
533
- );
534
- if (shouldBeVisible) {
535
- restorePortalInlineStyle(portalRoot);
536
- portalInlineStyleByElement.delete(portalRoot);
537
- return;
538
- }
539
- ensurePortalInlineStyle(portalRoot);
540
- for (const property of PORTAL_MANAGED_PROPERTIES) {
541
- stylableElement.style.setProperty(
542
- property.cssName,
543
- property.hiddenValue,
544
- "important"
545
- );
546
- }
547
- }
548
- function trackPortal(renderId, portalRoot) {
549
- ensureProjectionPortalId(portalRoot);
550
- const portals = portalElementsByRenderId.get(renderId) ?? /* @__PURE__ */ new Set();
551
- portals.add(portalRoot);
552
- portalElementsByRenderId.set(renderId, portals);
553
- const owners = portalOwnerRenderIdsByElement.get(portalRoot) ?? /* @__PURE__ */ new Set();
554
- owners.add(renderId);
555
- portalOwnerRenderIdsByElement.set(portalRoot, owners);
556
- syncPortalVisibility(portalRoot);
557
- }
558
- function untrackPortal(renderId, portalRoot) {
559
- const portals = portalElementsByRenderId.get(renderId);
560
- if (!portals) return;
561
- portals.delete(portalRoot);
562
- if (portals.size === 0) {
563
- portalElementsByRenderId.delete(renderId);
564
- }
565
- const owners = portalOwnerRenderIdsByElement.get(portalRoot);
566
- if (owners) {
567
- owners.delete(renderId);
568
- if (owners.size === 0) {
569
- portalOwnerRenderIdsByElement.delete(portalRoot);
570
- }
571
- }
572
- syncPortalVisibility(portalRoot);
573
- }
574
- function releaseStoryboardPortals(renderId) {
575
- const portals = portalElementsByRenderId.get(renderId);
576
- if (!portals) {
577
- renderStatusById.delete(renderId);
578
- return;
579
- }
580
- for (const portalRoot of [...portals]) {
581
- untrackPortal(renderId, portalRoot);
582
- }
583
- renderStatusById.delete(renderId);
584
- }
585
- function getStoryboardPortalSelectors(renderId) {
586
- const portals = portalElementsByRenderId.get(renderId);
587
- if (!portals) return [];
588
- return [...portals].filter((portalRoot) => portalRoot.isConnected).map(buildProjectionPortalSelector);
589
- }
590
- function syncStoryboardPortals(renderId, status) {
591
- renderStatusById.set(renderId, status);
592
- const portals = portalElementsByRenderId.get(renderId);
593
- if (!portals) return;
594
- for (const portalRoot of portals) {
595
- syncPortalVisibility(portalRoot);
596
- }
597
- }
598
- function trackStoryboardPortals(renderId, element, status) {
599
- syncStoryboardPortals(renderId, status);
600
- const unregister = getPortalTracker().register({
601
- element,
602
- onPortalFound(portalRoot) {
603
- trackPortal(renderId, portalRoot);
604
- },
605
- onPortalRemoved(portalRoot) {
606
- untrackPortal(renderId, portalRoot);
607
- }
608
- });
609
- return () => {
610
- unregister();
611
- releaseStoryboardPortals(renderId);
612
- };
613
- }
614
-
615
174
  // canvas/canvas-host-operations.ts
616
175
  var escapeRenderId = (renderId) => renderId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
617
176
  var buildRenderSelector = (renderId) => `[data-render-id="${escapeRenderId(renderId)}"]`;
@@ -1928,7 +1487,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1928
1487
  );
1929
1488
  const problemWatchersRef = useRef2(/* @__PURE__ */ new Map());
1930
1489
  const problemTrackerRef = useRef2(createCanvasHostProblemTracker());
1931
- const updateWatchRequests = useCallback3(
1490
+ const updateWatchRequests = useCallback2(
1932
1491
  (update) => {
1933
1492
  const current = watchRequestsRef.current;
1934
1493
  const next = update(current);
@@ -1938,11 +1497,11 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1938
1497
  },
1939
1498
  []
1940
1499
  );
1941
- const buildProblemSnapshot = useCallback3(
1500
+ const buildProblemSnapshot = useCallback2(
1942
1501
  () => problemTrackerRef.current.snapshot(),
1943
1502
  []
1944
1503
  );
1945
- const publishProblemSnapshot = useCallback3(() => {
1504
+ const publishProblemSnapshot = useCallback2(() => {
1946
1505
  const payload = buildProblemSnapshot();
1947
1506
  for (const watcher of problemWatchersRef.current.values()) {
1948
1507
  postToMessageSource(
@@ -1957,7 +1516,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1957
1516
  );
1958
1517
  }
1959
1518
  }, [buildProblemSnapshot]);
1960
- const setEntries = useCallback3(
1519
+ const setEntries = useCallback2(
1961
1520
  (update) => {
1962
1521
  setRenderEntriesById((entries) => {
1963
1522
  const next = update(entries);
@@ -1974,7 +1533,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1974
1533
  },
1975
1534
  []
1976
1535
  );
1977
- const waitForRender = useCallback3(
1536
+ const waitForRender = useCallback2(
1978
1537
  (request) => {
1979
1538
  const current = renderEntriesRef.current.get(request.renderId);
1980
1539
  const alreadyRendered = current?.status === "active" && renderedRenderIdsRef.current.has(request.renderId) && renderRequestMatchesEntry(current, request);
@@ -1990,7 +1549,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1990
1549
  },
1991
1550
  [setEntries]
1992
1551
  );
1993
- const releaseRenderLease = useCallback3(
1552
+ const releaseRenderLease = useCallback2(
1994
1553
  (renderId) => {
1995
1554
  setEntries(
1996
1555
  (entries) => releaseRender(entries, renderId, maxCachedRef.current)
@@ -1998,7 +1557,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
1998
1557
  },
1999
1558
  [setEntries]
2000
1559
  );
2001
- const stopRuntimeWatch = useCallback3(
1560
+ const stopRuntimeWatch = useCallback2(
2002
1561
  async (watchId, establishment) => {
2003
1562
  const existingWatch = watchesRef.current.get(watchId);
2004
1563
  if (!existingWatch || establishment && existingWatch.establishment !== establishment) {
@@ -2009,7 +1568,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2009
1568
  },
2010
1569
  []
2011
1570
  );
2012
- const removeWatchRequest = useCallback3(
1571
+ const removeWatchRequest = useCallback2(
2013
1572
  async (watchId, reason) => {
2014
1573
  const existingRequest = watchRequestsRef.current.get(watchId);
2015
1574
  if (existingRequest) {
@@ -2038,7 +1597,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2038
1597
  },
2039
1598
  [releaseRenderLease, stopRuntimeWatch, updateWatchRequests]
2040
1599
  );
2041
- const suspendEstablishedWatch = useCallback3(
1600
+ const suspendEstablishedWatch = useCallback2(
2042
1601
  (request) => {
2043
1602
  if (request.establishment.status !== "established") return;
2044
1603
  void stopRuntimeWatch(request.watchId, request.establishment).catch(
@@ -2048,7 +1607,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2048
1607
  },
2049
1608
  [stopRuntimeWatch]
2050
1609
  );
2051
- const buildState = useCallback3(
1610
+ const buildState = useCallback2(
2052
1611
  () => buildRenderStatePayload(
2053
1612
  renderEntriesRef.current,
2054
1613
  maxCachedRef.current,
@@ -2056,7 +1615,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2056
1615
  ),
2057
1616
  []
2058
1617
  );
2059
- const markStoryboardRendered = useCallback3((storyboardId) => {
1618
+ const markStoryboardRendered = useCallback2((storyboardId) => {
2060
1619
  renderedRenderIdsRef.current.add(storyboardId);
2061
1620
  legacyHealthRef.current.recordRenderCommit(storyboardId);
2062
1621
  setRenderCommitVersionById((versions) => {
@@ -2074,7 +1633,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2074
1633
  waiter.resolve();
2075
1634
  }
2076
1635
  }, []);
2077
- const markStoryboardUnmounted = useCallback3(
1636
+ const markStoryboardUnmounted = useCallback2(
2078
1637
  (storyboardId) => {
2079
1638
  queueMicrotask(() => {
2080
1639
  const remounted = [
@@ -2102,7 +1661,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2102
1661
  },
2103
1662
  [suspendEstablishedWatch]
2104
1663
  );
2105
- const reportStoryboardError = useCallback3(
1664
+ const reportStoryboardError = useCallback2(
2106
1665
  (storyboardId, error) => {
2107
1666
  renderedRenderIdsRef.current.delete(storyboardId);
2108
1667
  problemTrackerRef.current.reportComponentProblem(
@@ -2137,12 +1696,12 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2137
1696
  },
2138
1697
  [removeWatchRequest, suspendEstablishedWatch]
2139
1698
  );
2140
- const clearStoryboardError = useCallback3((storyboardId) => {
1699
+ const clearStoryboardError = useCallback2((storyboardId) => {
2141
1700
  problemTrackerRef.current.clearComponentProblem(storyboardId, [
2142
1701
  "render-error-boundary"
2143
1702
  ]);
2144
1703
  }, []);
2145
- const reportCanvasImportError = useCallback3(
1704
+ const reportCanvasImportError = useCallback2(
2146
1705
  (canvasPath, error) => {
2147
1706
  const normalizedPath = canvasPath.trim();
2148
1707
  if (!normalizedPath) return;
@@ -2159,14 +1718,14 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2159
1718
  },
2160
1719
  []
2161
1720
  );
2162
- const clearCanvasImportError = useCallback3((canvasPath) => {
1721
+ const clearCanvasImportError = useCallback2((canvasPath) => {
2163
1722
  const normalizedPath = canvasPath.trim();
2164
1723
  if (!normalizedPath) return;
2165
1724
  problemTrackerRef.current.clearCanvasProblem(normalizedPath, [
2166
1725
  "runtime-bootstrap"
2167
1726
  ]);
2168
1727
  }, []);
2169
- const registerCanvasProblemScope = useCallback3(
1728
+ const registerCanvasProblemScope = useCallback2(
2170
1729
  (canvasPath) => problemTrackerRef.current.registerCanvasPath(canvasPath),
2171
1730
  []
2172
1731
  );
@@ -2566,11 +2125,11 @@ function useCanvasHostPostMessage(registeredCanvasPaths = []) {
2566
2125
  waitForRender
2567
2126
  ]);
2568
2127
  return {
2569
- renderStatusById: useMemo3(
2128
+ renderStatusById: useMemo2(
2570
2129
  () => buildRenderStatusMap(renderEntriesById),
2571
2130
  [renderEntriesById]
2572
2131
  ),
2573
- renderSizeById: useMemo3(
2132
+ renderSizeById: useMemo2(
2574
2133
  () => buildRenderSizeMap(renderEntriesById),
2575
2134
  [renderEntriesById]
2576
2135
  ),
@@ -2592,7 +2151,7 @@ function buildWatchBindingKey(commandType, payload) {
2592
2151
  }
2593
2152
 
2594
2153
  // canvas/canvas-host.tsx
2595
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
2154
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2596
2155
  var CANVAS_HOST_DOCUMENT_TITLE = "INTERNAL tempo-host \u2014 Tempo component host, do not interact";
2597
2156
  function protectCanvasHostDocumentTitle(doc) {
2598
2157
  const restoreTitle = () => {
@@ -2672,7 +2231,7 @@ function CanvasHost({
2672
2231
  "CanvasHost cannot receive both children and canvasModules."
2673
2232
  );
2674
2233
  }
2675
- const registeredCanvasPaths = useMemo4(
2234
+ const registeredCanvasPaths = useMemo3(
2676
2235
  () => [
2677
2236
  ...new Set(
2678
2237
  canvasModules?.map(({ canvasPath }) => canvasPath.trim()) ?? []
@@ -2681,7 +2240,7 @@ function CanvasHost({
2681
2240
  [canvasModules]
2682
2241
  );
2683
2242
  const {
2684
- renderStatusById: renderStatusById2,
2243
+ renderStatusById,
2685
2244
  renderSizeById,
2686
2245
  markStoryboardRendered,
2687
2246
  markStoryboardUnmounted,
@@ -2696,22 +2255,22 @@ function CanvasHost({
2696
2255
  return protectCanvasHostDocumentTitle(document);
2697
2256
  }, []);
2698
2257
  const directUrlSearch = typeof window === "undefined" ? "" : window.location.search;
2699
- const directUrlRender = useMemo4(() => {
2258
+ const directUrlRender = useMemo3(() => {
2700
2259
  void directUrlSearch;
2701
2260
  return readDirectUrlRender();
2702
2261
  }, [directUrlSearch]);
2703
- const propActiveIds = useMemo4(
2262
+ const propActiveIds = useMemo3(
2704
2263
  () => new Set(activeStoryboardIds ?? []),
2705
2264
  [activeStoryboardIds]
2706
2265
  );
2707
- const runtime = useMemo4(
2266
+ const runtime = useMemo3(
2708
2267
  () => ({
2709
2268
  getStoryboardStatus(storyboardId) {
2710
2269
  const normalizedId = normalizeId(storyboardId, "Storyboard id");
2711
2270
  if (propActiveIds.has(normalizedId) || directUrlRender?.renderId === normalizedId || (isStoryboardActive ? isStoryboardActive(normalizedId) : false)) {
2712
2271
  return "active";
2713
2272
  }
2714
- return renderStatusById2.get(normalizedId) ?? "unmounted";
2273
+ return renderStatusById.get(normalizedId) ?? "unmounted";
2715
2274
  },
2716
2275
  getStoryboardSize(storyboardId) {
2717
2276
  const normalizedId = normalizeId(storyboardId, "Storyboard id");
@@ -2744,12 +2303,12 @@ function CanvasHost({
2744
2303
  reportCanvasImportError,
2745
2304
  reportStoryboardError,
2746
2305
  renderSizeById,
2747
- renderStatusById2
2306
+ renderStatusById
2748
2307
  ]
2749
2308
  );
2750
2309
  return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
2751
2310
  children,
2752
- canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx4(
2311
+ canvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
2753
2312
  CanvasImportBoundary,
2754
2313
  {
2755
2314
  canvasPath,
@@ -2765,449 +2324,6 @@ var canvasHostCapability = {
2765
2324
  protocolVersion: 1,
2766
2325
  supportsModules: true
2767
2326
  };
2768
-
2769
- // canvas/storyboard.tsx
2770
- import {
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
2782
- } from "react";
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 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());
2863
- }
2864
- function useRenderErrorRecovery(retryNow) {
2865
- const retryNowRef = useRef3(retryNow);
2866
- retryNowRef.current = retryNow;
2867
- const timerRef = useRef3(null);
2868
- const nextDelayRef = useRef3(renderErrorRetryBaseDelayMs);
2869
- const erroredRef = useRef3(false);
2870
- const clearTimer = useCallback4(() => {
2871
- if (timerRef.current === null) return;
2872
- clearTimeout(timerRef.current);
2873
- timerRef.current = null;
2874
- }, []);
2875
- const noteRenderError = useCallback4(() => {
2876
- erroredRef.current = true;
2877
- if (timerRef.current !== null) return;
2878
- const delay = nextDelayRef.current;
2879
- nextDelayRef.current = Math.min(delay * 2, renderErrorRetryMaxDelayMs);
2880
- timerRef.current = setTimeout(() => {
2881
- timerRef.current = null;
2882
- retryNowRef.current();
2883
- }, delay);
2884
- }, []);
2885
- const noteRecovered = useCallback4(() => {
2886
- erroredRef.current = false;
2887
- nextDelayRef.current = renderErrorRetryBaseDelayMs;
2888
- clearTimer();
2889
- }, [clearTimer]);
2890
- useEffect4(() => {
2891
- const onBeat = () => {
2892
- nextDelayRef.current = renderErrorRetryBaseDelayMs;
2893
- if (!erroredRef.current) return;
2894
- clearTimer();
2895
- retryNowRef.current();
2896
- };
2897
- const unsubscribe = getRenderErrorRecoveryBeatBus().subscribe(onBeat);
2898
- return () => {
2899
- unsubscribe();
2900
- clearTimer();
2901
- };
2902
- }, [clearTimer]);
2903
- return { noteRenderError, noteRecovered };
2904
- }
2905
-
2906
- // canvas/storyboard.tsx
2907
- import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
2908
- function Storyboard({
2909
- id,
2910
- name,
2911
- component,
2912
- layout,
2913
- props
2914
- }) {
2915
- const Component3 = component;
2916
- return /* @__PURE__ */ jsx5(StoryboardSlot, { id, name, layout, kind: "component", children: /* @__PURE__ */ jsx5(Component3, { ...props ?? {} }) });
2917
- }
2918
- function LegacyStoryboardV1({
2919
- id,
2920
- storyboard
2921
- }) {
2922
- return /* @__PURE__ */ jsx5(
2923
- StoryboardSlot,
2924
- {
2925
- id,
2926
- name: storyboard.name,
2927
- layout: storyboard.layout,
2928
- kind: "component",
2929
- children: /* @__PURE__ */ jsx5(LegacyStoryboardV1Render, { render: storyboard.render })
2930
- }
2931
- );
2932
- }
2933
- function LegacyStoryboardV1Render({
2934
- render
2935
- }) {
2936
- return /* @__PURE__ */ jsx5(Fragment, { children: render() });
2937
- }
2938
- function RouteStoryboard({
2939
- id,
2940
- name,
2941
- route,
2942
- layout
2943
- }) {
2944
- return /* @__PURE__ */ jsx5(
2945
- StoryboardSlot,
2946
- {
2947
- id,
2948
- name,
2949
- layout,
2950
- kind: "route",
2951
- route
2952
- }
2953
- );
2954
- }
2955
- function HtmlStoryboard({
2956
- id,
2957
- name,
2958
- filepath,
2959
- src,
2960
- layout
2961
- }) {
2962
- return /* @__PURE__ */ jsx5(
2963
- StoryboardSlot,
2964
- {
2965
- id,
2966
- name,
2967
- layout,
2968
- kind: "html",
2969
- filepath,
2970
- src
2971
- }
2972
- );
2973
- }
2974
- function StoryboardSlot({
2975
- children,
2976
- id,
2977
- kind,
2978
- layout,
2979
- name,
2980
- route,
2981
- filepath,
2982
- src
2983
- }) {
2984
- const renderId = useCanvasStoryboardRenderId(id);
2985
- const canvas = useCanvasIdentity();
2986
- const status = useStoryboardStatus(id);
2987
- const renderSize = useStoryboardSize(id);
2988
- const placement = useStoryboardPlacement(id);
2989
- const markRendered = useStoryboardRendered(id);
2990
- const markUnmounted = useStoryboardUnmounted(id);
2991
- const { reportError, clearError } = useStoryboardErrorReporter(id);
2992
- const renderWidth = renderSize?.width;
2993
- const renderHeight = renderSize?.height;
2994
- const renderRevision = renderSize?.revision ?? 0;
2995
- const intrinsicSize = renderSize?.intrinsicSize ?? (kind === "component" && layout.intrinsicSizing === "root-element");
2996
- const resetKey = `${renderId}:${renderRevision}`;
2997
- const contentRef = useRef4(null);
2998
- const [admittedRenderId, setAdmittedRenderId] = useState3(
2999
- typeof document === "undefined" ? renderId : null
3000
- );
3001
- const admitted = admittedRenderId === renderId;
3002
- const errorBoundaryRef = useRef4(null);
3003
- const lastReportedCommitRef = useRef4(null);
3004
- const previousChildrenRef = useRef4(children);
3005
- const [recoveryRevision, setRecoveryRevision] = useState3(0);
3006
- const commitKey = `${resetKey}:${recoveryRevision}`;
3007
- const retryRenderNow = useCallback5(() => {
3008
- if (!errorBoundaryRef.current?.retry()) return false;
3009
- setRecoveryRevision((revision) => revision + 1);
3010
- return true;
3011
- }, []);
3012
- const { noteRenderError, noteRecovered } = useRenderErrorRecovery(retryRenderNow);
3013
- const handleRenderError = useCallback5(
3014
- (error) => {
3015
- noteRenderError();
3016
- reportError(error);
3017
- },
3018
- [noteRenderError, reportError]
3019
- );
3020
- const pendingRenderedReportRef = useRef4(
3021
- null
3022
- );
3023
- const handleRendered = useCallback5(
3024
- (reportedCommitKey) => {
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);
3037
- },
3038
- [clearError, markRendered, noteRecovered]
3039
- );
3040
- useEffect5(
3041
- () => () => {
3042
- if (pendingRenderedReportRef.current !== null) {
3043
- clearTimeout(pendingRenderedReportRef.current);
3044
- pendingRenderedReportRef.current = null;
3045
- }
3046
- },
3047
- []
3048
- );
3049
- const renderChildren = useMemo5(() => {
3050
- if (isValidElement2(children)) return cloneElement2(children);
3051
- return Children2.map(
3052
- children,
3053
- (child) => isValidElement2(child) ? cloneElement2(child) : child
3054
- );
3055
- }, [children]);
3056
- useEffect5(() => markUnmounted, [markUnmounted]);
3057
- useEffect5(() => {
3058
- setAdmittedRenderId(renderId);
3059
- }, [renderId]);
3060
- useEffect5(() => {
3061
- const childrenChanged = previousChildrenRef.current !== children;
3062
- previousChildrenRef.current = children;
3063
- if (childrenChanged) retryRenderNow();
3064
- }, [children, retryRenderNow]);
3065
- useEffect5(() => {
3066
- if (!contentRef.current || status === "unmounted") return;
3067
- return trackStoryboardPortals(renderId, contentRef.current, status);
3068
- }, [renderId, status]);
3069
- useEffect5(() => {
3070
- if (status === "unmounted") return;
3071
- syncStoryboardPortals(renderId, status);
3072
- }, [renderId, status]);
3073
- if (status === "unmounted") return null;
3074
- return /* @__PURE__ */ jsx5(
3075
- "div",
3076
- {
3077
- "data-render-id": renderId,
3078
- "data-render-status": status,
3079
- "data-tempo-storyboard-render-id": renderId,
3080
- "data-tempo-storyboard-id": id,
3081
- "data-tempo-canvas-path": canvas?.path,
3082
- "data-tempo-storyboard-name": name,
3083
- "data-tempo-storyboard-kind": kind,
3084
- "data-tempo-storyboard-route": route,
3085
- "data-tempo-storyboard-filepath": filepath,
3086
- "data-tempo-storyboard-src": src,
3087
- style: {
3088
- position: "absolute",
3089
- left: placement?.left ?? layout.x,
3090
- top: placement?.top ?? layout.y,
3091
- width: intrinsicSize ? "max-content" : renderWidth ?? layout.width,
3092
- height: intrinsicSize ? "max-content" : renderHeight ?? layout.height,
3093
- minWidth: intrinsicSize ? renderWidth : void 0,
3094
- minHeight: intrinsicSize ? renderHeight : void 0,
3095
- zIndex: layout.zIndex,
3096
- visibility: status === "active" ? "visible" : "hidden",
3097
- pointerEvents: status === "active" ? "auto" : "none"
3098
- },
3099
- children: /* @__PURE__ */ jsx5(
3100
- "div",
3101
- {
3102
- "data-render-content": renderId,
3103
- "data-render-admitted": admitted ? "true" : void 0,
3104
- "data-tempo-render-mode": kind === "html" ? "static-dom" : void 0,
3105
- "data-tempo-hide-fiber": "true",
3106
- ref: contentRef,
3107
- style: { width: "100%", height: "100%" },
3108
- children: /* @__PURE__ */ jsx5(
3109
- StoryboardErrorBoundary,
3110
- {
3111
- ref: errorBoundaryRef,
3112
- onError: handleRenderError,
3113
- resetKey,
3114
- children: admitted ? /* @__PURE__ */ jsxs3(Suspense2, { fallback: /* @__PURE__ */ jsx5(CanvasPendingMarker, {}), children: [
3115
- /* @__PURE__ */ jsx5(StoryboardAdmission, { children: renderChildren }),
3116
- /* @__PURE__ */ jsx5(
3117
- StoryboardCommitSignal,
3118
- {
3119
- commitKey,
3120
- onCommit: handleRendered
3121
- },
3122
- commitKey
3123
- )
3124
- ] }) : null
3125
- }
3126
- )
3127
- }
3128
- )
3129
- }
3130
- );
3131
- }
3132
- function StoryboardAdmission({ children }) {
3133
- beginAdmissionWindow();
3134
- return children;
3135
- }
3136
- function StoryboardCommitSignal({
3137
- commitKey,
3138
- onCommit
3139
- }) {
3140
- const onCommitRef = useRef4(onCommit);
3141
- onCommitRef.current = onCommit;
3142
- useLayoutEffect3(() => onCommitRef.current(commitKey), [commitKey]);
3143
- return null;
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
- }
3156
- var StoryboardErrorBoundary = class extends Component2 {
3157
- constructor() {
3158
- super(...arguments);
3159
- this.state = {
3160
- error: null,
3161
- componentStack: void 0,
3162
- resetKey: this.props.resetKey
3163
- };
3164
- }
3165
- static getDerivedStateFromError(error) {
3166
- return { error };
3167
- }
3168
- static getDerivedStateFromProps(props, state) {
3169
- if (props.resetKey !== state.resetKey) {
3170
- return {
3171
- error: null,
3172
- componentStack: void 0,
3173
- resetKey: props.resetKey
3174
- };
3175
- }
3176
- return null;
3177
- }
3178
- componentDidCatch(error, info) {
3179
- const componentStack = boundComponentStack(info.componentStack);
3180
- this.setState({ componentStack });
3181
- this.props.onError({
3182
- message: error.message,
3183
- stack: error.stack,
3184
- componentStack
3185
- });
3186
- }
3187
- hasError() {
3188
- return this.state.error !== null;
3189
- }
3190
- retry() {
3191
- if (!this.state.error) return false;
3192
- this.setState(
3193
- (state) => state.error ? { error: null, componentStack: void 0, resetKey: state.resetKey } : null
3194
- );
3195
- return true;
3196
- }
3197
- render() {
3198
- if (this.state.error) {
3199
- return /* @__PURE__ */ jsx5(
3200
- "div",
3201
- {
3202
- "data-render-error": "true",
3203
- "data-render-error-message": this.state.error.message,
3204
- style: { width: "100%", height: "100%" }
3205
- }
3206
- );
3207
- }
3208
- return this.props.children;
3209
- }
3210
- };
3211
2327
  export {
3212
2328
  CANVAS_HOST_DOCUMENT_TITLE,
3213
2329
  Canvas,