tempo-sdk 0.0.52 → 0.0.57

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.
Files changed (75) hide show
  1. package/dist/assets/index.js +4 -2
  2. package/dist/assets/index.js.map +1 -1
  3. package/dist/canvas/editor.d.ts +11 -16
  4. package/dist/canvas/editor.js +79 -49
  5. package/dist/canvas/editor.js.map +1 -1
  6. package/dist/canvas/index.d.ts +10 -6
  7. package/dist/canvas/index.js +130 -47
  8. package/dist/canvas/index.js.map +1 -1
  9. package/dist/canvas/interact-projection.js +4 -3
  10. package/dist/canvas/parser.d.ts +10 -5
  11. package/dist/canvas/parser.js +3 -1
  12. package/dist/canvas/svelte.d.ts +8 -5
  13. package/dist/canvas/svelte.js +20 -5
  14. package/dist/canvas/svelte.js.map +1 -1
  15. package/dist/chunk-2IQD2KPS.js +219 -0
  16. package/dist/chunk-2IQD2KPS.js.map +1 -0
  17. package/dist/chunk-5BHIHP25.js +410 -0
  18. package/dist/chunk-5BHIHP25.js.map +1 -0
  19. package/dist/chunk-EMYYTS6D.js +1585 -0
  20. package/dist/chunk-EMYYTS6D.js.map +1 -0
  21. package/dist/{chunk-DX6XAXCK.js → chunk-N2TYN3RB.js} +189 -420
  22. package/dist/chunk-N2TYN3RB.js.map +1 -0
  23. package/dist/{chunk-7Y7XNHUM.js → chunk-QXL6GL2P.js} +18 -3
  24. package/dist/chunk-QXL6GL2P.js.map +1 -0
  25. package/dist/{chunk-QP2NTODB.js → chunk-RHHVVWAC.js} +115 -25
  26. package/dist/chunk-RHHVVWAC.js.map +1 -0
  27. package/dist/chunk-TL4MGN7E.js +2570 -0
  28. package/dist/chunk-TL4MGN7E.js.map +1 -0
  29. package/dist/{chunk-PULSTDX2.js → chunk-U3SLJNRS.js} +284 -46
  30. package/dist/chunk-U3SLJNRS.js.map +1 -0
  31. package/dist/{chunk-ZZYNOX24.js → chunk-U64AHDHZ.js} +1708 -2461
  32. package/dist/chunk-U64AHDHZ.js.map +1 -0
  33. package/dist/expo/plugin.cjs +1256 -16
  34. package/dist/expo/plugin.cjs.map +1 -1
  35. package/dist/expo/plugin.d.cts +0 -1
  36. package/dist/expo/plugin.d.ts +0 -1
  37. package/dist/expo/plugin.js +1 -1
  38. package/dist/expo-babel-plugin.cjs +1258 -16
  39. package/dist/expo-babel-plugin.cjs.map +1 -1
  40. package/dist/expo-babel-plugin.d.cts +8 -5
  41. package/dist/expo-babel-plugin.d.ts +8 -5
  42. package/dist/expo-babel-plugin.js +1 -1
  43. package/dist/index.d.ts +5 -1
  44. package/dist/index.js +463 -153
  45. package/dist/index.js.map +1 -1
  46. package/dist/nextjs/plugin.cjs +151 -0
  47. package/dist/nextjs/plugin.cjs.map +1 -1
  48. package/dist/nextjs/plugin.d.cts +1 -1
  49. package/dist/nextjs/plugin.d.ts +1 -1
  50. package/dist/nextjs/plugin.js +1 -1
  51. package/dist/nextjs-loader.cjs +1432 -35
  52. package/dist/nextjs-loader.cjs.map +1 -1
  53. package/dist/nextjs.cjs +17 -2
  54. package/dist/nextjs.cjs.map +1 -1
  55. package/dist/nextjs.d.cts +14 -3
  56. package/dist/nextjs.d.ts +14 -3
  57. package/dist/nextjs.js +1 -1
  58. package/dist/{page-xi1aI5a7.d.ts → page-DwLnOM5d.d.ts} +12 -6
  59. package/dist/{storyboard-DbtzTPvI.d.ts → storyboard-BtQuVGpl.d.ts} +33 -15
  60. package/dist/svelte.d.ts +3 -2
  61. package/dist/svelte.js +103 -29
  62. package/dist/svelte.js.map +1 -1
  63. package/dist/v1-client-compat-qxaXEDm_.d.ts +23 -0
  64. package/package.json +5 -2
  65. package/dist/chunk-57KAYXHF.js +0 -19
  66. package/dist/chunk-57KAYXHF.js.map +0 -1
  67. package/dist/chunk-7Y7XNHUM.js.map +0 -1
  68. package/dist/chunk-CB5NJJJT.js +0 -345
  69. package/dist/chunk-CB5NJJJT.js.map +0 -1
  70. package/dist/chunk-DX6XAXCK.js.map +0 -1
  71. package/dist/chunk-F3KJDCMU.js +0 -19
  72. package/dist/chunk-F3KJDCMU.js.map +0 -1
  73. package/dist/chunk-PULSTDX2.js.map +0 -1
  74. package/dist/chunk-QP2NTODB.js.map +0 -1
  75. package/dist/chunk-ZZYNOX24.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../modules/iframe-projection/html/watch-head.ts","../../../modules/iframe-projection/shared/capture-perf.ts","../../../modules/iframe-projection/html/declared-facts.ts","../../../modules/iframe-projection/html/displayability.ts","../../../modules/iframe-projection/html/selectors.ts","../../../modules/iframe-projection/html/capture.ts"],"sourcesContent":["/**\n * Head Capture Utility\n *\n * Captures relevant <head> content from a document, excluding scripts\n * and resolving relative URLs to absolute.\n *\n * ## Shared Observer Pattern\n *\n * Uses a singleton HeadTracker that maintains one MutationObserver per document,\n * shared across all subscriptions. This avoids creating 50+ observers when there\n * are many watchers on the same page.\n */\n\n/** Elements to include from <head> */\nconst INCLUDE_TAGS = new Set([\"STYLE\", \"META\", \"BASE\", \"LINK\"]);\n\n/** Link rel values to include (stylesheet-related) */\nconst INCLUDE_LINK_RELS = new Set([\"stylesheet\"]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Tracker (Shared Observer)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * A subscription to head changes for a specific document.\n * Each subscription maintains its own hasMutations flag since they flush independently.\n */\nexport interface HeadSubscription {\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Flush and get head content. Returns content if isInitial or if mutations occurred. */\n flush(isInitial: boolean): string | undefined;\n /** Unsubscribe from head changes */\n unsubscribe(): void;\n}\n\nexport interface HeadMutationDetails {\n /** Vite stylesheet module ids whose style/link nodes changed in this batch. */\n stylesheetPaths: string[];\n}\n\n/**\n * Singleton tracker that manages shared MutationObservers for head watching.\n * One observer per document, shared across all subscriptions.\n */\nexport interface HeadTracker {\n /** Subscribe to head changes for a document */\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription;\n /** Clean up all observers */\n destroy(): void;\n /** Cardinality only; reads maintained collection sizes and performs no DOM\n * work. Used by the performance trace attached to an emitted capture. */\n readPerfSnapshot(): { observers: number; subscriptions: number };\n}\n\n/** Module-level singleton */\nlet instance: HeadTrackerImpl | null = null;\n\n/**\n * Get the singleton HeadTracker instance.\n */\nexport function getHeadTracker(): HeadTracker {\n if (!instance) {\n instance = new HeadTrackerImpl();\n }\n return instance;\n}\n\n/**\n * Reset the singleton. For testing only.\n * @internal\n */\nexport function _resetHeadTrackerForTesting(): void {\n instance?.destroy();\n instance = null;\n}\n\n/** Internal subscription implementation */\nclass HeadSubscriptionImpl implements HeadSubscription {\n hasMutations = false;\n private doc: Document;\n private callback: (details: HeadMutationDetails) => void;\n private onUnsubscribe: () => void;\n\n constructor(\n doc: Document,\n callback: (details: HeadMutationDetails) => void,\n onUnsubscribe: () => void,\n ) {\n this.doc = doc;\n this.callback = callback;\n this.onUnsubscribe = onUnsubscribe;\n }\n\n flush(isInitial: boolean): string | undefined {\n if (!isInitial && !this.hasMutations) {\n return undefined;\n }\n this.hasMutations = false;\n return captureHead(this.doc);\n }\n\n unsubscribe(): void {\n this.onUnsubscribe();\n }\n\n /** Called by tracker when relevant mutation detected */\n notifyMutation(details: HeadMutationDetails): void {\n this.hasMutations = true;\n this.callback(details);\n }\n}\n\n/** Per-document observer state */\ninterface DocObserverState {\n observer: MutationObserver;\n subscriptions: Set<HeadSubscriptionImpl>;\n}\n\nclass HeadTrackerImpl implements HeadTracker {\n private docObservers = new Map<Document, DocObserverState>();\n private activeSubscriptions = 0;\n\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription {\n let docState = this.docObservers.get(doc);\n\n // Create observer for this document if first subscription\n if (!docState) {\n docState = this.createDocObserver(doc);\n this.docObservers.set(doc, docState);\n }\n\n const subscription = new HeadSubscriptionImpl(doc, onMutation, () => {\n this.unsubscribe(doc, subscription);\n });\n docState.subscriptions.add(subscription);\n this.activeSubscriptions += 1;\n\n return subscription;\n }\n\n private createDocObserver(doc: Document): DocObserverState {\n const subscriptions = new Set<HeadSubscriptionImpl>();\n\n const notify = (details: HeadMutationDetails): void => {\n for (const sub of subscriptions) {\n sub.notifyMutation(details);\n }\n };\n\n const observeHead = (head: HTMLHeadElement): MutationObserver => {\n const observer = new MutationObserver((mutations) => {\n const details = this.readRelevantMutations(mutations, head);\n if (!details) return;\n notify(details);\n });\n observer.observe(head, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n return observer;\n };\n\n if (doc.head) {\n return { observer: observeHead(doc.head), subscriptions };\n }\n\n // The document has no <head> yet — subscribers can attach before parsing\n // (e.g. a producer created from a frame preload). Watch for the head to\n // appear, then swap in the real observer and report one synthetic\n // mutation so subscribers capture the head they never saw arrive.\n const bootstrap = new MutationObserver(() => {\n const head = doc.head;\n if (!head) return;\n bootstrap.disconnect();\n state.observer = observeHead(head);\n notify({ stylesheetPaths: [] });\n });\n bootstrap.observe(doc, { childList: true, subtree: true });\n const state: DocObserverState = { observer: bootstrap, subscriptions };\n return state;\n }\n\n private unsubscribe(doc: Document, sub: HeadSubscriptionImpl): void {\n const docState = this.docObservers.get(doc);\n if (!docState) return;\n\n if (!docState.subscriptions.delete(sub)) return;\n this.activeSubscriptions = Math.max(0, this.activeSubscriptions - 1);\n\n // Disconnect observer if no more subscriptions for this document\n if (docState.subscriptions.size === 0) {\n docState.observer.disconnect();\n this.docObservers.delete(doc);\n }\n }\n\n /**\n * Check if mutations contain changes to elements we care about.\n * This filtering runs once per mutation batch (not once per subscription).\n */\n private readRelevantMutations(\n mutations: MutationRecord[],\n head: HTMLHeadElement,\n ): HeadMutationDetails | null {\n let relevant = false;\n const stylesheetPaths = new Set<string>();\n const collectStylesheetPath = (node: Node | null): void => {\n const element =\n node instanceof Element ? node : (node?.parentElement ?? null);\n if (!element) return;\n const candidates = [\n element,\n ...element.querySelectorAll(\n \"style[data-vite-dev-id], link[rel~='stylesheet']\",\n ),\n ];\n for (const candidate of candidates) {\n if (candidate instanceof HTMLStyleElement) {\n const id = candidate.getAttribute(\"data-vite-dev-id\")?.trim();\n if (id) stylesheetPaths.add(id);\n } else if (\n candidate instanceof HTMLLinkElement &&\n shouldIncludeLink(candidate)\n ) {\n const href = candidate.getAttribute(\"href\")?.trim() || candidate.href;\n if (href) stylesheetPaths.add(href);\n }\n }\n };\n\n for (const mutation of mutations) {\n const target = mutation.target;\n const element = target instanceof Element ? target : target.parentElement;\n\n if (!element || (!head.contains(element) && target !== head)) continue;\n\n // Check if this is a relevant element (one we would capture)\n const tagName = element.tagName;\n if (INCLUDE_TAGS.has(tagName)) {\n // For LINK, check if it's a stylesheet\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(element)) continue;\n }\n relevant = true;\n collectStylesheetPath(element);\n }\n\n // Also trigger for childList mutations on head itself (added/removed elements)\n if (mutation.type === \"childList\" && target === head) {\n relevant = true;\n }\n if (mutation.type === \"childList\") {\n for (const node of mutation.addedNodes) collectStylesheetPath(node);\n for (const node of mutation.removedNodes) collectStylesheetPath(node);\n }\n }\n return relevant ? { stylesheetPaths: [...stylesheetPaths] } : null;\n }\n\n destroy(): void {\n for (const docState of this.docObservers.values()) {\n docState.observer.disconnect();\n docState.subscriptions.clear();\n }\n this.docObservers.clear();\n this.activeSubscriptions = 0;\n }\n\n readPerfSnapshot(): { observers: number; subscriptions: number } {\n return {\n observers: this.docObservers.size,\n subscriptions: this.activeSubscriptions,\n };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Legacy API (Backward Compatibility)\n// These functions delegate to the shared tracker for backward compatibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * State for a head watcher instance.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport interface HeadWatcher {\n /** The document being watched */\n doc: Document;\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Stop watching */\n stop: () => void;\n}\n\n/**\n * Starts watching a document's <head> for mutations.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport function watchHead(doc: Document, onMutation: () => void): HeadWatcher {\n const subscription = getHeadTracker().subscribe(doc, onMutation);\n\n // Wrap subscription in legacy HeadWatcher interface\n return {\n doc,\n get hasMutations() {\n return subscription.hasMutations;\n },\n set hasMutations(value: boolean) {\n subscription.hasMutations = value;\n },\n stop: () => subscription.unsubscribe(),\n };\n}\n\n/**\n * Checks if watcher has any pending head mutations.\n * @deprecated Access subscription.hasMutations directly\n */\nexport function hasPendingHeadChanges(watcher: HeadWatcher): boolean {\n return watcher.hasMutations;\n}\n\n/**\n * Flushes the head watcher, returning captured head content if there were changes.\n * @deprecated Use subscription.flush() directly\n */\nexport function flushHeadWatcher(\n watcher: HeadWatcher,\n isInitial: boolean,\n): string | undefined {\n if (!isInitial && !watcher.hasMutations) {\n return undefined;\n }\n watcher.hasMutations = false;\n return captureHead(watcher.doc);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Capture\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Captures the <head> content from a document.\n *\n * - Includes: <style>, <link rel=\"stylesheet\">, <meta>, <base>\n * - Excludes: <script>, <title>, <link rel=\"icon/preload/etc\">\n * - Resolves relative URLs to absolute using document.baseURI\n *\n * @param doc - The document to capture head from\n * @returns Serialized head content (innerHTML for destination <head>)\n */\nexport function captureHead(doc: Document): string {\n const head = doc.head;\n if (!head) return \"\";\n\n const baseURI = doc.baseURI;\n const fragments: string[] = [];\n\n for (const child of Array.from(head.children)) {\n const tagName = child.tagName;\n\n // Skip non-included tags\n if (!INCLUDE_TAGS.has(tagName)) continue;\n\n // For <link>, only include stylesheets\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(child)) continue;\n if (isDisabledStylesheet(child)) continue;\n }\n\n // Exclude Content-Security-Policy meta tags (they block srcdoc assets)\n if (tagName === \"META\") {\n const httpEquiv = child.getAttribute(\"http-equiv\")?.toLowerCase();\n const name = child.getAttribute(\"name\")?.toLowerCase();\n if (\n httpEquiv === \"content-security-policy\" ||\n name === \"content-security-policy\"\n ) {\n continue;\n }\n }\n\n // Clone and resolve URLs\n let clone = child.cloneNode(true) as Element;\n materializeStyleElementCssom(child, clone);\n if (tagName === \"LINK\") {\n clone = materializeStylesheetLinkCssom(child, clone);\n }\n resolveUrls(clone, baseURI);\n\n // Strip crossorigin from stylesheet links so they load in no-cors mode\n // in srcdoc projection iframes (which have a null origin that won't\n // match any server's Access-Control-Allow-Origin header)\n if (clone.tagName === \"LINK\") {\n clone.removeAttribute(\"crossorigin\");\n } else if (clone.tagName === \"STYLE\") {\n escapeStyleForHtmlSerialization(clone);\n }\n\n fragments.push(clone.outerHTML);\n }\n\n fragments.push(...captureAdoptedStyleSheets(doc));\n\n return fragments.join(\"\\n\");\n}\n\n/**\n * Same-origin stylesheets are already readable in the source page. Preserve\n * their authored rules as an inline style before the projection crosses into\n * its null-origin document. Opaque cross-origin sheets remain links and may be\n * handled by a consumer-specific, policy-checked fallback later.\n */\nfunction materializeStylesheetLinkCssom(\n source: Element,\n clone: Element,\n): Element {\n const link = source as HTMLLinkElement;\n const cssText = serializeCssRules(link.sheet);\n if (!cssText) {\n return clone;\n }\n\n const style = source.ownerDocument.createElement(\"style\");\n for (const attribute of Array.from(source.attributes)) {\n if (\n [\n \"as\",\n \"crossorigin\",\n \"fetchpriority\",\n \"href\",\n \"integrity\",\n \"referrerpolicy\",\n \"rel\",\n ].includes(attribute.name.toLowerCase())\n ) {\n continue;\n }\n style.setAttribute(attribute.name, attribute.value);\n }\n style.setAttribute(\"data-projection-stylesheet-href\", link.href);\n style.textContent = absolutifyCssReferences(cssText, link.href);\n return style;\n}\n\n/**\n * CSS-in-JS and framework runtimes can insert rules through CSSOM APIs, leaving\n * the DOM <style> text empty. Clone-time materialization preserves those rules\n * without mutating the live host document.\n */\nfunction materializeStyleElementCssom(source: Element, clone: Element): void {\n if (source.tagName !== \"STYLE\" || clone.tagName !== \"STYLE\") {\n return;\n }\n\n const style = source as HTMLStyleElement;\n const text = style.textContent ?? \"\";\n if (text.trim().length > 0) {\n return;\n }\n\n const cssText = serializeCssRules(style.sheet);\n if (cssText) {\n clone.textContent = cssText;\n }\n}\n\nfunction captureAdoptedStyleSheets(doc: Document): string[] {\n const sheets = Array.from(doc.adoptedStyleSheets ?? []);\n if (sheets.length === 0) {\n return [];\n }\n\n const fragments: string[] = [];\n for (const sheet of sheets) {\n const cssText = serializeCssRules(sheet);\n if (!cssText) {\n continue;\n }\n const style = doc.createElement(\"style\");\n style.setAttribute(\"data-projection-adopted-stylesheet\", \"true\");\n style.textContent = cssText;\n escapeStyleForHtmlSerialization(style);\n fragments.push(style.outerHTML);\n }\n return fragments;\n}\n\nfunction escapeStyleForHtmlSerialization(style: Element): void {\n style.textContent = (style.textContent ?? \"\").replace(/<\\//gi, \"<\\\\/\");\n}\n\nfunction serializeCssRules(sheet: CSSStyleSheet | null): string {\n if (!sheet) {\n return \"\";\n }\n\n try {\n return Array.from(sheet.cssRules)\n .map((rule) => rule.cssText)\n .join(\"\\n\");\n } catch {\n // Cross-origin or otherwise unreadable stylesheet.\n return \"\";\n }\n}\n\nfunction absolutifyCssReferences(cssText: string, baseHref: string): string {\n if (!/^https?:/i.test(baseHref)) {\n return cssText;\n }\n\n const resolve = (value: string): string => {\n const trimmed = value.trim();\n if (\n !trimmed ||\n trimmed.startsWith(\"#\") ||\n /^(?:data|blob|javascript):/i.test(trimmed)\n ) {\n return /^javascript:/i.test(trimmed) ? \"\" : trimmed;\n }\n try {\n return new URL(trimmed, baseHref).href;\n } catch {\n return trimmed;\n }\n };\n\n return cssText\n .replace(\n /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/gi,\n (_match, quote: string, value: string) =>\n `url(${quote}${resolve(value)}${quote})`,\n )\n .replace(\n /@import\\s+([\"'])([^\"']+)\\1/gi,\n (_match, quote: string, value: string) =>\n `@import ${quote}${resolve(value)}${quote}`,\n );\n}\n\nfunction shouldIncludeLink(element: Element): boolean {\n const rel = element.getAttribute(\"rel\");\n if (!rel) {\n return false;\n }\n return rel\n .toLowerCase()\n .split(/\\s+/)\n .some((token) => INCLUDE_LINK_RELS.has(token));\n}\n\nfunction isDisabledStylesheet(element: Element): boolean {\n const link = element as HTMLLinkElement;\n return link.disabled || link.sheet?.disabled === true;\n}\n\n/**\n * Resolves relative URLs in an element to absolute URLs.\n */\nfunction resolveUrls(element: Element, baseURI: string): void {\n // Skip URL resolution if baseURI is not a valid HTTP(S) URL\n // (e.g., in test environments where baseURI is \"about:blank\")\n if (!baseURI || !baseURI.startsWith(\"http\")) {\n return;\n }\n\n // Resolve href attribute (for <link>, <base>)\n const href = element.getAttribute(\"href\");\n if (href && !isAbsoluteUrl(href)) {\n try {\n element.setAttribute(\"href\", new URL(href, baseURI).href);\n } catch {\n // Keep original href if URL resolution fails\n }\n }\n\n // Resolve src attribute (for future-proofing)\n const src = element.getAttribute(\"src\");\n if (src && !isAbsoluteUrl(src)) {\n try {\n element.setAttribute(\"src\", new URL(src, baseURI).href);\n } catch {\n // Keep original src if URL resolution fails\n }\n }\n}\n\n/**\n * Checks if a URL is absolute.\n */\nfunction isAbsoluteUrl(url: string): boolean {\n return /^(https?:)?\\/\\//i.test(url) || url.startsWith(\"data:\");\n}\n","/**\n * Capture-flush perf counters.\n *\n * Module-local mutable counters incremented by the hot paths that run inside\n * a combined-watch flush: the displayability walk's getComputedStyle reads,\n * the layout-kind style read during fiber serialization, and the\n * render-identity declaration walks. The flush resets them before capturing\n * and reads them after, shipping the totals on the emitted capture's `perf`\n * field — so the paths themselves never thread perf parameters through their\n * signatures. Increment-only: no DOM reads, no allocation.\n *\n * The same functions also run outside a flush (one-shot capture APIs); those\n * increments are simply discarded by the next flush's reset.\n */\n\ninterface CaptureFlushCounters {\n styleReadCount: number;\n identityNodesVisited: number;\n sourceVersionDomScanNodes: number;\n sourceVersionFiberSerializeNodes: number;\n sourceVersionFiberReductionNodes: number;\n sourceVersionFallbackScanNodes: number;\n}\n\nconst counters: CaptureFlushCounters = {\n styleReadCount: 0,\n identityNodesVisited: 0,\n sourceVersionDomScanNodes: 0,\n sourceVersionFiberSerializeNodes: 0,\n sourceVersionFiberReductionNodes: 0,\n sourceVersionFallbackScanNodes: 0,\n};\n\nconst producerReferencesByDocument = new Map<Document, number>();\nlet activeDocumentProducers = 0;\nlet activeRootObservers = 0;\nlet activeReactCommitSubscriptions = 0;\n\n/** Register one document producer and its one React commit subscription. */\nexport function registerDocumentCaptureProducer(\n document: Document,\n): () => void {\n const references = producerReferencesByDocument.get(document) ?? 0;\n if (references === 0) activeDocumentProducers += 1;\n producerReferencesByDocument.set(document, references + 1);\n activeReactCommitSubscriptions += 1;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n const current = producerReferencesByDocument.get(document) ?? 0;\n if (current <= 1) {\n producerReferencesByDocument.delete(document);\n activeDocumentProducers = Math.max(0, activeDocumentProducers - 1);\n } else {\n producerReferencesByDocument.set(document, current - 1);\n }\n activeReactCommitSubscriptions = Math.max(\n 0,\n activeReactCommitSubscriptions - 1,\n );\n };\n}\n\n/** Register one independently observed projection root. */\nexport function registerCaptureRootObserver(): () => void {\n activeRootObservers += 1;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n activeRootObservers = Math.max(0, activeRootObservers - 1);\n };\n}\n\nexport function readCaptureProducerCardinality(): {\n activeDocumentProducers: number;\n activeRootObservers: number;\n reactCommitSubscriptions: number;\n} {\n return {\n activeDocumentProducers,\n activeRootObservers,\n reactCommitSubscriptions: activeReactCommitSubscriptions,\n };\n}\n\n/** @internal Test isolation for producer ownership counters. */\nexport function _resetCaptureProducerCardinalityForTesting(): void {\n producerReferencesByDocument.clear();\n activeDocumentProducers = 0;\n activeRootObservers = 0;\n activeReactCommitSubscriptions = 0;\n}\n\n/** One getComputedStyle call on the capture path. */\nexport function countCaptureStyleRead(): void {\n counters.styleReadCount += 1;\n}\n\n/** One element/node visited by a render-identity declaration walk. */\nexport function countIdentityNodeVisited(): void {\n counters.identityNodesVisited += 1;\n}\n\nexport function countSourceVersionDomScanNode(): void {\n counters.sourceVersionDomScanNodes += 1;\n}\n\nexport function countSourceVersionFiberSerializeNode(): void {\n counters.sourceVersionFiberSerializeNodes += 1;\n}\n\nexport function countSourceVersionFiberReductionNode(): void {\n counters.sourceVersionFiberReductionNodes += 1;\n}\n\nexport function countSourceVersionFallbackScanNode(): void {\n counters.sourceVersionFallbackScanNodes += 1;\n}\n\nexport function resetCaptureFlushCounters(): void {\n counters.styleReadCount = 0;\n counters.identityNodesVisited = 0;\n counters.sourceVersionDomScanNodes = 0;\n counters.sourceVersionFiberSerializeNodes = 0;\n counters.sourceVersionFiberReductionNodes = 0;\n counters.sourceVersionFallbackScanNodes = 0;\n}\n\nexport function readCaptureFlushCounters(): Readonly<CaptureFlushCounters> {\n return { ...counters };\n}\n","/**\n * Declared Capture Facts (producer-side)\n *\n * Computes the `DeclaredCaptureFacts` a capture producer attaches to its\n * `DomCapture`. Everything here reads the LIVE DOM the producer already\n * holds — never the serialized HTML string — so the facts are ground truth\n * rather than a re-parse of the payload. See specs/canvas-determinism.md §4.\n */\n\nimport type { DeclaredCaptureFacts } from \"./types\";\n\n/**\n * Two annotation namespaces stamp the source-mapped iframe DOM:\n * - JSX: `data-tempo-filepath` + `data-tempo-position` + `data-tempo-modifiedts`\n * - HTML: `data-tempo-html-filepath` + `data-tempo-html-offset` +\n * `data-tempo-html-modifiedts`\n * A single element may carry BOTH (an HTML element nested inside a JSX host\n * that also got source-located), so each namespace is read independently.\n */\nconst SOURCE_ANNOTATED_SELECTOR =\n \"[data-tempo-filepath], [data-tempo-html-filepath]\";\n\ninterface AnnotationNamespace {\n filepathAttr: string;\n positionAttr: string;\n modifiedTsAttr: string;\n sourceVersionAttr: string;\n}\n\nconst NAMESPACES: readonly AnnotationNamespace[] = [\n {\n filepathAttr: \"data-tempo-filepath\",\n positionAttr: \"data-tempo-position\",\n modifiedTsAttr: \"data-tempo-modifiedts\",\n sourceVersionAttr: \"data-tempo-source-version\",\n },\n {\n filepathAttr: \"data-tempo-html-filepath\",\n positionAttr: \"data-tempo-html-offset\",\n modifiedTsAttr: \"data-tempo-html-modifiedts\",\n sourceVersionAttr: \"data-tempo-html-source-version\",\n },\n];\n\n/**\n * Compute the declared facts for a capture.\n *\n * @param targetElement - The element whose subtree is serialized into\n * `dom.html` (the mutation LCA for scoped captures, or the capture root\n * for whole-surface ones).\n * @param captureRoot - The watched root. `complete` is `targetElement ===\n * captureRoot`. The render-error probe searches the WHOLE root (the error\n * overlay is a surface-level fact, not necessarily inside the scoped LCA).\n * @param scopeSelector - The selector the producer already computed for\n * `targetElement` relative to `captureRoot` (\"\" for whole-surface).\n * Surfaced as `scopeSelector` only when the capture is not complete.\n * @param portalElements - Live portal root elements whose content the\n * producer also serializes into `portals`. Their annotations count toward\n * `observedVersions`/`containedAnchors` exactly as the DOM subtree's do.\n */\nexport function computeDeclaredFacts(\n targetElement: Element,\n captureRoot: Element,\n scopeSelector: string,\n portalElements: readonly Element[],\n): DeclaredCaptureFacts {\n const observedVersions: Record<string, number> = {};\n const observedSourceVersions: Record<string, string> = {};\n const anchorSet = new Set<string>();\n\n const visit = (element: Element): void => {\n for (const ns of NAMESPACES) {\n const filepath = element.getAttribute(ns.filepathAttr);\n if (filepath == null || filepath.length === 0) continue;\n\n const modifiedTsRaw = element.getAttribute(ns.modifiedTsAttr);\n if (modifiedTsRaw != null) {\n const modifiedTs = Number(modifiedTsRaw);\n if (!Number.isNaN(modifiedTs)) {\n const existing = observedVersions[filepath];\n if (existing === undefined || modifiedTs > existing) {\n observedVersions[filepath] = modifiedTs;\n // Co-locate the content-version token with the newest render: it\n // rides the same element that just set the file's MAX modifiedts.\n // Clear a stale token from an older render when the newest element\n // carries none (a mid-HMR mixed tree, or an old-SDK element).\n const version = element.getAttribute(ns.sourceVersionAttr);\n if (version != null && version.length > 0) {\n observedSourceVersions[filepath] = version;\n } else {\n delete observedSourceVersions[filepath];\n }\n }\n }\n }\n\n const position = element.getAttribute(ns.positionAttr);\n if (position != null && position.length > 0) {\n anchorSet.add(`${filepath} ${position}`);\n }\n }\n };\n\n // The serialized population: the target subtree (including the target\n // element itself, whose annotations travel in `dom.attributes`) plus every\n // portal root and its descendants.\n const walkRoots: readonly Element[] = [targetElement, ...portalElements];\n for (const root of walkRoots) {\n if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);\n for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {\n visit(annotated);\n }\n }\n\n const complete = targetElement === captureRoot;\n\n return {\n complete,\n scopeSelector: complete ? null : scopeSelector,\n observedVersions,\n observedSourceVersions,\n containedAnchors: Array.from(anchorSet),\n renderError: computeRenderError(captureRoot),\n };\n}\n\n/**\n * Render-error boundary state for a capture root. Non-null iff a\n * `[data-render-error=\"true\"]` element exists anywhere in the live root\n * subtree (or is the root itself); its `data-render-error-message` becomes\n * `message` when present.\n */\nfunction computeRenderError(\n captureRoot: Element,\n): DeclaredCaptureFacts[\"renderError\"] {\n const errorElement = captureRoot.matches('[data-render-error=\"true\"]')\n ? captureRoot\n : captureRoot.querySelector('[data-render-error=\"true\"]');\n if (!errorElement) return null;\n return {\n message: errorElement.getAttribute(\"data-render-error-message\"),\n };\n}\n","import { countCaptureStyleRead } from \"../shared/capture-perf\";\nimport type { CaptureDisplayability } from \"./types\";\n\n/** Elements whose descendants do not contribute projected pixels/content. */\nconst IGNORED_CONTENT_TAGS = new Set([\n \"DATALIST\",\n \"LINK\",\n \"META\",\n \"NOSCRIPT\",\n \"SCRIPT\",\n \"STYLE\",\n \"TEMPLATE\",\n]);\n\nconst VISUAL_ASSET_TAGS = new Set([\n \"AUDIO\",\n \"CANVAS\",\n \"EMBED\",\n \"IFRAME\",\n \"IMG\",\n \"INPUT\",\n \"OBJECT\",\n \"SELECT\",\n \"SVG\",\n \"TEXTAREA\",\n \"VIDEO\",\n]);\n\n/**\n * Measures displayable structure in a live, styled document.\n *\n * The capture root itself is excluded because `DomCapture.dom.html` contains\n * its children. Supplemental roots are included because portal updates carry\n * each portal root's `outerHTML`. A null result means no browsing context was\n * available, so callers must omit the proof rather than infer it from markup.\n */\nexport function measureComputedDisplayability(\n captureRoot: Element,\n supplementalRoots: readonly Element[] = [],\n): CaptureDisplayability | null {\n const doc = captureRoot.ownerDocument;\n const view = doc.defaultView;\n if (\n !view ||\n !captureRoot.isConnected ||\n supplementalRoots.some(\n (root) => root.ownerDocument !== doc || !root.isConnected,\n )\n ) {\n return null;\n }\n\n const result: CaptureDisplayability = {\n version: 1,\n elementCount: 0,\n paintedElementCount: 0,\n nonEmptyTextNodeCount: 0,\n visualAssetCount: 0,\n };\n\n try {\n const rootBlocked = hasBlockingElementInChain(captureRoot, view);\n const rootTextVisible =\n !rootBlocked && elementHasVisibleComputedVisibility(captureRoot, view);\n for (const child of Array.from(captureRoot.childNodes)) {\n visitNode(child, rootBlocked, rootTextVisible, view, result);\n }\n\n for (const supplementalRoot of supplementalRoots) {\n visitNode(\n supplementalRoot,\n hasBlockingElementInChain(supplementalRoot.parentElement, view),\n true,\n view,\n result,\n );\n }\n } catch {\n // A producer declaration is proof. If style inspection is unavailable for\n // any part of the render domain, omit the whole profile conservatively.\n return null;\n }\n\n return result;\n}\n\nfunction visitNode(\n node: Node,\n blockedByAncestor: boolean,\n parentTextVisible: boolean,\n view: Window,\n result: CaptureDisplayability,\n): void {\n if (node.nodeType === 3) {\n if (\n !blockedByAncestor &&\n parentTextVisible &&\n (node.textContent?.trim().length ?? 0) > 0\n ) {\n result.nonEmptyTextNodeCount += 1;\n }\n return;\n }\n if (node.nodeType !== 1) return;\n\n const element = node as Element;\n const blocked = blockedByAncestor || elementBlocksSubtree(element, view);\n if (blocked) return;\n\n const visible = elementHasVisibleComputedVisibility(element, view);\n if (visible) {\n result.elementCount += 1;\n if (elementPaintsOwnPixels(element, view)) {\n result.paintedElementCount = (result.paintedElementCount ?? 0) + 1;\n }\n if (VISUAL_ASSET_TAGS.has(element.tagName)) {\n result.visualAssetCount += 1;\n }\n }\n\n for (const child of Array.from(element.childNodes)) {\n visitNode(child, false, visible, view, result);\n }\n}\n\nfunction elementPaintsOwnPixels(element: Element, view: Window): boolean {\n countCaptureStyleRead();\n const style = view.getComputedStyle(element);\n if (colorCanPaint(style.backgroundColor)) return true;\n if (style.backgroundImage && style.backgroundImage !== \"none\") return true;\n if (style.boxShadow && style.boxShadow !== \"none\") return true;\n if (\n style.outlineStyle !== \"none\" &&\n parseFloat(style.outlineWidth) > 0 &&\n colorCanPaint(style.outlineColor)\n ) {\n return true;\n }\n for (const side of [\"Top\", \"Right\", \"Bottom\", \"Left\"] as const) {\n if (\n style[`border${side}Style`] !== \"none\" &&\n parseFloat(style[`border${side}Width`]) > 0 &&\n colorCanPaint(style[`border${side}Color`])\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction colorCanPaint(value: string): boolean {\n const normalized = value.trim().toLowerCase().replace(/ /g, \"\");\n if (!normalized || normalized === \"transparent\") return false;\n return !(\n /^rgba\\([^)]*,0(?:\\.0+)?\\)$/.test(normalized) ||\n /^rgb\\([^)]*\\/0(?:\\.0+)?\\)$/.test(normalized)\n );\n}\n\nfunction hasBlockingElementInChain(\n start: Element | null,\n view: Window,\n): boolean {\n for (let element = start; element; element = element.parentElement) {\n if (elementBlocksSubtree(element, view)) return true;\n }\n return false;\n}\n\nfunction elementBlocksSubtree(element: Element, view: Window): boolean {\n if (IGNORED_CONTENT_TAGS.has(element.tagName)) return true;\n if (element.hasAttribute(\"hidden\")) return true;\n if (element.tagName === \"DIALOG\" && !element.hasAttribute(\"open\")) {\n return true;\n }\n if (\n element.tagName === \"INPUT\" &&\n element.getAttribute(\"type\")?.trim().toLowerCase() === \"hidden\"\n ) {\n return true;\n }\n\n countCaptureStyleRead();\n const style = view.getComputedStyle(element);\n const opacity = style.opacity.trim();\n return (\n style.display === \"none\" ||\n (opacity.length > 0 && Number(opacity) <= 0) ||\n style.getPropertyValue(\"content-visibility\") === \"hidden\"\n );\n}\n\nfunction elementHasVisibleComputedVisibility(\n element: Element,\n view: Window,\n): boolean {\n countCaptureStyleRead();\n const visibility = view.getComputedStyle(element).visibility;\n return visibility !== \"hidden\" && visibility !== \"collapse\";\n}\n","/**\n * CSS Selector Utilities\n *\n * Pure functions for generating CSS selectors.\n */\n\n/**\n * Generates a unique CSS selector path for an element.\n *\n * Uses nth-of-type notation when needed for uniqueness among siblings.\n *\n * @param element - Element to generate selector for\n * @param root - Optional root element to stop at (selector will be relative to this)\n * @returns CSS selector path (e.g., \"body > div > button:nth-of-type(2)\")\n *\n * @example\n * ```ts\n * generateSelector(document.querySelector('button'));\n * // \"body > div > button\"\n *\n * generateSelector(button, container);\n * // \"div > button\" (relative to container)\n * ```\n */\nexport function generateSelector(element: Element, root?: Element): string {\n // Special cases for well-known elements\n if (!root) {\n if (element === document.documentElement) return \":root\";\n if (element === document.head) return \"head\";\n if (element === document.body) return \"body\";\n }\n\n // If element is the root, return empty string\n if (root && element === root) return \"\";\n\n const parts: string[] = [];\n let current: Element | null = element;\n const stopAt = root ?? document.documentElement;\n\n while (current && current !== stopAt) {\n const parent: Element | null = current.parentElement;\n if (!parent) break;\n\n const tagName = current.tagName.toLowerCase();\n\n // Count same-type siblings to determine if :nth-of-type is needed\n let index = 1;\n let sibling = current.previousElementSibling;\n while (sibling) {\n if (sibling.tagName === current.tagName) index++;\n sibling = sibling.previousElementSibling;\n }\n\n let sameTypeSiblings = 0;\n for (const child of parent.children) {\n if (child.tagName === current.tagName) sameTypeSiblings++;\n }\n\n if (sameTypeSiblings > 1) {\n parts.unshift(`${tagName}:nth-of-type(${index})`);\n } else {\n parts.unshift(tagName);\n }\n\n current = parent;\n }\n\n // Handle edge cases\n if (parts.length === 0) {\n if (element === document.body) return \"body\";\n if (element === document.head) return \"head\";\n return \"\";\n }\n\n const path = parts.join(\" > \");\n\n // Anchor to root with :scope so querySelector matches at the correct depth.\n // Without this, \"div > div > div:nth-of-type(2)\" is ambiguous — it can match\n // any ancestor chain of divs at any depth within the subtree, not just the\n // specific depth from the root. :scope pins the first segment to a direct\n // child of the querySelector target.\n if (root) return `:scope > ${path}`;\n\n return path;\n}\n\n/**\n * Finds the Lowest Common Ancestor (LCA) of a set of nodes.\n *\n * The LCA is the deepest element that is an ancestor of all provided nodes.\n * Useful for determining the minimal subtree that contains all mutations.\n *\n * @param nodes - Set of DOM nodes to find common ancestor for\n * @returns The LCA element, or null if no common ancestor found\n */\nexport function findLowestCommonAncestor(nodes: Set<Node>): Element | null {\n if (nodes.size === 0) return null;\n\n // Build ancestor chains for each node (from root to node)\n const ancestorChains: Element[][] = [];\n\n for (const node of nodes) {\n const chain: Element[] = [];\n let current: Node | null =\n node instanceof Element ? node : node.parentElement;\n\n while (current && current !== document) {\n if (current instanceof Element) {\n chain.unshift(current);\n }\n current = current.parentNode;\n }\n\n if (chain.length > 0) {\n ancestorChains.push(chain);\n }\n }\n\n if (ancestorChains.length === 0) {\n return document.documentElement;\n }\n\n // Find the deepest common ancestor by comparing chains\n let lca: Element = document.documentElement;\n const firstChain = ancestorChains[0]!;\n const minLength = Math.min(...ancestorChains.map((c) => c.length));\n\n for (let i = 0; i < minLength; i++) {\n const candidate = firstChain[i];\n if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {\n lca = candidate;\n } else {\n break;\n }\n }\n\n return lca;\n}\n","/**\n * DOM Capture\n *\n * One-shot capture of DOM content and element states.\n */\n\nimport { computeDeclaredFacts } from \"./declared-facts\";\nimport { measureComputedDisplayability } from \"./displayability\";\nimport { generateSelector } from \"./selectors\";\nimport type { DomCapture, ElementState } from \"./types\";\n\nexport interface CollectElementStatesOptions {\n /** Whether to include document-level scroll via the :root selector. */\n includeDocumentScroll?: boolean;\n}\n\n/**\n * Captures the current state of an element as a DomCapture.\n *\n * @param element - Element to capture\n * @returns DomCapture containing HTML and element states\n *\n * @example\n * ```ts\n * const snapshot = capture(document.body);\n * // { dom: { selector: \"body\", html: \"...\" }, states: [...] }\n * ```\n */\nexport function capture(element: Element): DomCapture {\n return captureWithSupplementalRoots(element, []);\n}\n\n/** Internal complete-capture primitive used when a higher-level producer also\n * serializes supplemental roots such as owned React portals. */\nexport function captureWithSupplementalRoots(\n element: Element,\n supplementalRoots: readonly Element[],\n): DomCapture {\n // Sync form state to attributes before serializing\n syncFormStateToAttributes(element);\n\n // Selector relative to itself = \"\" (this IS the container)\n const selector = generateSelector(element, element);\n // Use innerHTML - we capture the children, not the container itself\n const html = removeScriptTags(element.innerHTML);\n const attributes = captureAttributes(element);\n const documentElementAttributes = element.ownerDocument\n ? captureAttributes(element.ownerDocument.documentElement)\n : undefined;\n const bodyAttributes = element.ownerDocument?.body\n ? captureAttributes(element.ownerDocument.body)\n : undefined;\n const baseUrl = element.ownerDocument?.baseURI;\n const states = collectElementStates(element);\n const displayability = measureComputedDisplayability(\n element,\n supplementalRoots,\n );\n\n return {\n // Whole-surface one-shot: the element is both the capture root and the\n // serialized scope, so `complete` is true and there is no scope selector.\n declared: computeDeclaredFacts(element, element, \"\", supplementalRoots),\n ...(displayability && { displayability }),\n dom: {\n selector,\n html,\n attributes,\n documentElementAttributes,\n bodyAttributes,\n },\n states,\n baseUrl,\n };\n}\n\n/**\n * Syncs form element state (DOM properties) to HTML attributes.\n *\n * Form elements like checkboxes, selects, and inputs have runtime state\n * that isn't reflected in their HTML attributes. This syncs that state\n * to attributes so it survives serialization.\n */\nfunction syncFormStateToAttributes(root: Element): void {\n // Checkboxes and radios\n for (const input of root.querySelectorAll(\n 'input[type=\"checkbox\"], input[type=\"radio\"]',\n )) {\n const el = input as HTMLInputElement;\n if (el.checked) {\n el.setAttribute(\"checked\", \"\");\n } else {\n el.removeAttribute(\"checked\");\n }\n }\n\n // Text inputs\n for (const input of root.querySelectorAll(\n 'input:not([type=\"checkbox\"]):not([type=\"radio\"])',\n )) {\n const el = input as HTMLInputElement;\n if (el.value !== el.getAttribute(\"value\")) {\n el.setAttribute(\"value\", el.value);\n }\n }\n\n // Textareas\n for (const textarea of root.querySelectorAll(\"textarea\")) {\n const el = textarea as HTMLTextAreaElement;\n if (el.value !== el.textContent) {\n el.textContent = el.value;\n }\n if (el.hasAttribute(\"value\")) {\n el.removeAttribute(\"value\");\n }\n }\n\n // Selects\n for (const select of root.querySelectorAll(\"select\")) {\n const el = select as HTMLSelectElement;\n for (const option of el.options) {\n if (option.selected) {\n option.setAttribute(\"selected\", \"\");\n } else {\n option.removeAttribute(\"selected\");\n }\n }\n }\n}\n\n/**\n * Removes all script tags from HTML string.\n */\nexport function removeScriptTags(html: string): string {\n return html.replace(/<script\\b[^>]*>[\\s\\S]*?<\\/script>/gi, \"\");\n}\n\n/**\n * Captures attributes from an element into a serializable map.\n */\nexport function captureAttributes(element: Element): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const attr of Array.from(element.attributes)) {\n attrs[attr.name] = attr.value;\n }\n return attrs;\n}\n\n/**\n * Collects current element states from a root element.\n *\n * Walks form elements and scrollable containers to collect their runtime state.\n */\nexport function collectElementStates(\n root: Element,\n options: CollectElementStatesOptions = {},\n): ElementState[] {\n const { includeDocumentScroll = true } = options;\n const states: ElementState[] = [];\n\n // Collect form states\n for (const input of root.querySelectorAll(\"input\")) {\n const el = input as HTMLInputElement;\n const isCheckable = el.type === \"checkbox\" || el.type === \"radio\";\n const hasNonDefault = isCheckable\n ? el.checked !== el.defaultChecked\n : el.value !== el.defaultValue;\n\n if (hasNonDefault) {\n const selector = generateSelector(el, root);\n if (isCheckable) {\n states.push({ selector, checked: el.checked });\n } else {\n states.push({ selector, value: el.value });\n }\n }\n }\n\n for (const textarea of root.querySelectorAll(\"textarea\")) {\n const el = textarea as HTMLTextAreaElement;\n if (el.value !== el.defaultValue) {\n const selector = generateSelector(el, root);\n states.push({ selector, value: el.value });\n }\n }\n\n for (const select of root.querySelectorAll(\"select\")) {\n const el = select as HTMLSelectElement;\n for (const option of el.options) {\n if (option.selected !== option.defaultSelected) {\n const selector = generateSelector(option, root);\n states.push({ selector, selected: option.selected });\n }\n }\n }\n\n // Collect scroll states - always include root and document-level scroll\n // so that scrolling back to 0 is properly communicated.\n states.push({\n selector: \"\",\n scrollTop: root.scrollTop,\n scrollLeft: root.scrollLeft,\n });\n\n // Check document-level scroll (scrollingElement, usually <html>)\n // This handles the common case where scroll is on documentElement, not body\n if (includeDocumentScroll) {\n const scrollingEl = root.ownerDocument?.scrollingElement;\n if (scrollingEl && scrollingEl !== root) {\n states.push({\n selector: \":root\",\n scrollTop: scrollingEl.scrollTop,\n scrollLeft: scrollingEl.scrollLeft,\n });\n }\n }\n\n for (const el of root.querySelectorAll(\"*\")) {\n if (el.scrollTop > 0 || el.scrollLeft > 0) {\n const selector = generateSelector(el, root);\n states.push({\n selector,\n scrollTop: el.scrollTop,\n scrollLeft: el.scrollLeft,\n });\n }\n }\n\n return states;\n}\n"],"mappings":";AAcA,IAAM,eAAe,oBAAI,IAAI,CAAC,SAAS,QAAQ,QAAQ,MAAM,CAAC;AAG9D,IAAM,oBAAoB,oBAAI,IAAI,CAAC,YAAY,CAAC;AA0ChD,IAAI,WAAmC;AAKhC,SAAS,iBAA8B;AAC5C,MAAI,CAAC,UAAU;AACb,eAAW,IAAI,gBAAgB;AAAA,EACjC;AACA,SAAO;AACT;AAYA,IAAM,uBAAN,MAAuD;AAAA,EAMrD,YACE,KACA,UACA,eACA;AATF,wBAAe;AAUb,SAAK,MAAM;AACX,SAAK,WAAW;AAChB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAM,WAAwC;AAC5C,QAAI,CAAC,aAAa,CAAC,KAAK,cAAc;AACpC,aAAO;AAAA,IACT;AACA,SAAK,eAAe;AACpB,WAAO,YAAY,KAAK,GAAG;AAAA,EAC7B;AAAA,EAEA,cAAoB;AAClB,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA,EAGA,eAAe,SAAoC;AACjD,SAAK,eAAe;AACpB,SAAK,SAAS,OAAO;AAAA,EACvB;AACF;AAQA,IAAM,kBAAN,MAA6C;AAAA,EAA7C;AACE,SAAQ,eAAe,oBAAI,IAAgC;AAC3D,SAAQ,sBAA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AAK;AAAA,QACV,UAAU;AAAA,QACV,WAAW,YAAY;AAAA,QACvB,YAAY,YAAY;AAAA,MAC1B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,aAAW,MAAM,KAAK,iBAAiB,GAAG,GAAG;AAC3C,QAAI,GAAG,YAAY,KAAK,GAAG,aAAa,GAAG;AACzC,YAAM,WAAW,iBAAiB,IAAI,IAAI;AAC1C,aAAO,KAAK;AAAA,QACV;AAAA,QACA,WAAW,GAAG;AAAA,QACd,YAAY,GAAG;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["document"]}
@@ -1,19 +0,0 @@
1
- // ../../modules/annotation/source-version.ts
2
- function sourceVersionHash(content) {
3
- let djb2 = 5381;
4
- let sdbm = 0;
5
- for (let i = 0; i < content.length; i++) {
6
- const c = content.charCodeAt(i);
7
- djb2 = (djb2 << 5) + djb2 ^ c;
8
- sdbm = c + (sdbm << 6) + (sdbm << 16) - sdbm | 0;
9
- }
10
- return toHex8(djb2) + toHex8(sdbm);
11
- }
12
- function toHex8(n) {
13
- return (n >>> 0).toString(16).padStart(8, "0");
14
- }
15
-
16
- export {
17
- sourceVersionHash
18
- };
19
- //# sourceMappingURL=chunk-F3KJDCMU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../modules/annotation/source-version.ts"],"sourcesContent":["/**\n * Canvas source-version identity.\n *\n * `sourceVersionHash` maps the exact text of a source file to a 16-hex-character\n * token identifying that content. It is the version stamp the canvas edit/\n * reconcile loop uses to answer \"has the host caught up to write W?\": the SDK\n * JSX transforms stamp `data-tempo-source-version` with the hash of the source\n * they annotate, and the write pipeline (`applyWrites` → `sourceVersionsByFile`)\n * reports the hash of the exact bytes it wrote. A captured element's stamp is\n * compared for EQUALITY against a write's version — never ordered, never\n * subtracted, never used as a high-water mark. Two identical contents MUST\n * produce the same token; two different contents MUST (for identity purposes)\n * produce different tokens.\n *\n * Because coverage is an equality test across independently-computed hashes,\n * every producer of a version — this function's callers in the vite/next/expo\n * transforms and in `applyWrites` — MUST route through THIS function so the\n * tokens are bit-identical. Changing the algorithm requires changing it for all\n * producers in lockstep, or old stamps and new write-versions stop matching.\n *\n * The token concatenates two independent 32-bit rolling hashes over the string's\n * UTF-16 code units — djb2 and sdbm — each rendered as unsigned 8-char hex. Two\n * independent hash families make an accidental collision between distinct source\n * contents vanishingly unlikely for version-identity use, while the function\n * stays dependency-free and single-pass (fast enough to run once per file per\n * transform on the devserver hot path).\n */\nexport function sourceVersionHash(content: string): string {\n let djb2 = 5381;\n let sdbm = 0;\n for (let i = 0; i < content.length; i++) {\n const c = content.charCodeAt(i);\n // djb2: hash * 33 ^ c. The trailing `^ c` keeps the value inside 32-bit\n // signed range every iteration, so no explicit coercion is needed.\n djb2 = ((djb2 << 5) + djb2) ^ c;\n // sdbm: c + hash*65599. The final term is an arithmetic subtraction, so\n // coerce back to a 32-bit int each step to prevent float drift.\n sdbm = (c + (sdbm << 6) + (sdbm << 16) - sdbm) | 0;\n }\n return toHex8(djb2) + toHex8(sdbm);\n}\n\n/** Render a 32-bit value as unsigned, zero-padded 8-char lowercase hex. */\nfunction toHex8(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n"],"mappings":";AA2BO,SAAS,kBAAkB,SAAyB;AACzD,MAAI,OAAO;AACX,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,WAAW,CAAC;AAG9B,YAAS,QAAQ,KAAK,OAAQ;AAG9B,WAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,OAAQ;AAAA,EACnD;AACA,SAAO,OAAO,IAAI,IAAI,OAAO,IAAI;AACnC;AAGA,SAAS,OAAO,GAAmB;AACjC,UAAQ,MAAM,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC/C;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas/canvas.tsx","../canvas/ids.ts","../canvas/runtime-context.ts","../canvas/storyboard.tsx","../canvas/admission-budget.ts","../canvas/canvas-pending-marker.tsx","../canvas/portal-tracking.ts","../canvas/render-error-recovery.ts"],"sourcesContent":["import {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useContext,\n useMemo,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\n\nimport { normalizeId } from \"./ids\";\n\ntype CanvasIdentity = {\n path: string;\n};\n\nconst CanvasIdentityContext = createContext<CanvasIdentity | null>(null);\n\nexport function getCanvasStoryboardRenderId(\n canvasPath: string,\n storyboardId: string,\n): string {\n return `canvas:${encodeURIComponent(\n normalizeId(canvasPath, \"Canvas path\"),\n )}#storyboard:${encodeURIComponent(\n normalizeId(storyboardId, \"Storyboard id\"),\n )}`;\n}\n\nexport function useCanvasIdentity(): CanvasIdentity | null {\n return useContext(CanvasIdentityContext);\n}\n\nexport function useCanvasStoryboardRenderId(storyboardId: string): string {\n const canvas = useCanvasIdentity();\n const normalizedId = normalizeId(storyboardId, \"Storyboard id\");\n return canvas\n ? getCanvasStoryboardRenderId(canvas.path, normalizedId)\n : normalizedId;\n}\n\nexport function Canvas({\n children,\n name,\n path,\n backgroundColor,\n defaultViewport,\n ...sourceAnnotations\n}: {\n children?: ReactNode;\n name: string;\n path?: string;\n backgroundColor?: string;\n defaultViewport?: { x: number; y: number; zoom: number };\n} & Record<`data-tempo-${string}`, unknown>) {\n const contextIdentity = useCanvasIdentity();\n const canvasName = normalizeId(name, \"Canvas name\");\n const canvasPath =\n path === undefined\n ? contextIdentity?.path\n : normalizeId(path, \"Canvas path\");\n\n if (!canvasPath) {\n throw new Error(\n '<Canvas> must be rendered inside <CanvasContext path=\"...\"> or receive a path prop.',\n );\n }\n\n const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);\n\n // Key each storyboard child by its declared id so React reconciles slots\n // by STORYBOARD IDENTITY rather than child position. Canvas files declare\n // storyboards as static JSX siblings (no keys), and positional\n // reconciliation reuses one storyboard's slot DOM node for another when\n // an edit inserts or removes a sibling above it — but slot DOM identity\n // is load-bearing: capture watchers, portal tracking, and the pool's\n // render-content wrappers all anchor to the slot node, and a reused node\n // silently starts feeding one storyboard's pipeline with another's\n // render.\n const keyedChildren = useMemo(\n () =>\n Children.map(children, (child) => {\n if (!isValidElement(child)) return child;\n if (child.key != null) return child;\n const id = (child.props as { id?: unknown }).id;\n if (typeof id !== \"string\" || id.length === 0) return child;\n return cloneElement(child, { key: `storyboard:${id}` });\n }),\n [children],\n );\n\n return (\n <CanvasIdentityContext.Provider value={identity}>\n <div\n {...(sourceAnnotations as HTMLAttributes<HTMLDivElement>)}\n data-tempo-canvas={canvasName}\n data-tempo-canvas-path={canvasPath}\n data-tempo-canvas-background={backgroundColor}\n data-tempo-canvas-viewport={\n defaultViewport ? JSON.stringify(defaultViewport) : undefined\n }\n >\n {keyedChildren}\n </div>\n </CanvasIdentityContext.Provider>\n );\n}\n\nexport function CanvasContext({\n children,\n path,\n}: {\n children?: ReactNode;\n path: string;\n}) {\n const canvasPath = normalizeId(path, \"Canvas path\");\n const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);\n return (\n <CanvasIdentityContext.Provider value={identity}>\n {children}\n </CanvasIdentityContext.Provider>\n );\n}\n","export function normalizeId(value: string | undefined, label: string): string {\n const normalized = value?.trim();\n if (!normalized) {\n throw new Error(`${label} is required.`);\n }\n return normalized;\n}\n","import { createContext, useCallback, useContext } from \"react\";\n\nimport { useCanvasStoryboardRenderId } from \"./canvas\";\n\nexport type CanvasHostRuntimeError = {\n message: string;\n stack?: string;\n componentStack?: string;\n};\n\nexport type CanvasHostRuntimeSize = {\n width?: number | string;\n height?: number | string;\n intrinsicSize?: boolean;\n revision?: number;\n};\n\nexport type CanvasHostRuntimePlacement = {\n left: number;\n top: number;\n};\n\nexport type CanvasHostRuntime = {\n getStoryboardStatus(storyboardId: string): \"active\" | \"cached\" | \"unmounted\";\n getStoryboardSize(storyboardId: string): CanvasHostRuntimeSize | undefined;\n getStoryboardPlacement(\n storyboardId: string,\n ): CanvasHostRuntimePlacement | undefined;\n /** Reset capture-only inputs after imports, before a fresh user-tree mount.\n * Only the direct URL's selected storyboard may reset the document RNG. */\n prepareStoryboardCapture?(storyboardId: string): void;\n markStoryboardRendered(storyboardId: string): void;\n markStoryboardUnmounted(storyboardId: string): void;\n reportStoryboardError(\n storyboardId: string,\n error: CanvasHostRuntimeError,\n ): void;\n clearStoryboardError(storyboardId: string): void;\n reportCanvasImportError(\n canvasPath: string,\n error: CanvasHostRuntimeError,\n ): void;\n clearCanvasImportError(canvasPath: string): void;\n /**\n * Declares a canvas path as a problem-attribution candidate while its\n * boundary is mounted. Host-level Vite diagnostics that uniquely name a\n * registered canvas's source are scoped to that canvas instead of being\n * shown host-wide on every sibling. Returns the unregister disposer.\n */\n registerCanvasProblemScope(canvasPath: string): () => void;\n};\n\nexport const CanvasHostContext = createContext<CanvasHostRuntime | null>(null);\n\nexport function useRequiredCanvasHost(): CanvasHostRuntime {\n const host = useContext(CanvasHostContext);\n if (!host) {\n throw new Error(\n \"Tempo canvas components must be rendered inside <CanvasHost>.\",\n );\n }\n return host;\n}\n\nexport function useActiveState(storyboardId: string): boolean {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardStatus(renderId) !== \"unmounted\";\n}\n\nexport function useStoryboardStatus(\n storyboardId: string,\n): \"active\" | \"cached\" | \"unmounted\" {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardStatus(renderId);\n}\n\nexport function useStoryboardRendered(storyboardId: string): () => void {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return useCallback(() => {\n host.markStoryboardRendered(renderId);\n }, [host, renderId]);\n}\n\nexport function useStoryboardUnmounted(storyboardId: string): () => void {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const { markStoryboardUnmounted } = useRequiredCanvasHost();\n return useCallback(() => {\n markStoryboardUnmounted(renderId);\n }, [markStoryboardUnmounted, renderId]);\n}\n\nexport function useStoryboardErrorReporter(storyboardId: string): {\n reportError(error: CanvasHostRuntimeError): void;\n clearError(): void;\n} {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n const reportError = useCallback(\n (error: CanvasHostRuntimeError) => {\n host.reportStoryboardError(renderId, error);\n },\n [host, renderId],\n );\n const clearError = useCallback(() => {\n host.clearStoryboardError(renderId);\n }, [host, renderId]);\n return { reportError, clearError };\n}\n\nexport function useStoryboardSize(\n storyboardId: string,\n): CanvasHostRuntimeSize | undefined {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardSize(renderId);\n}\n\nexport function useStoryboardPlacement(\n storyboardId: string,\n): CanvasHostRuntimePlacement | undefined {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardPlacement(renderId);\n}\n","import {\n Children,\n Component,\n type ComponentType,\n cloneElement,\n type ErrorInfo,\n isValidElement,\n type ReactNode,\n Suspense,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { TempoStoryboard } from \"../page\";\nimport { beginAdmissionWindow } from \"./admission-budget\";\nimport { useCanvasIdentity, useCanvasStoryboardRenderId } from \"./canvas\";\nimport { CanvasPendingMarker } from \"./canvas-pending-marker\";\nimport {\n syncStoryboardPortals,\n trackStoryboardPortals,\n} from \"./portal-tracking\";\nimport { useRenderErrorRecovery } from \"./render-error-recovery\";\nimport {\n useRequiredCanvasHost,\n useStoryboardErrorReporter,\n useStoryboardPlacement,\n useStoryboardRendered,\n useStoryboardSize,\n useStoryboardStatus,\n useStoryboardUnmounted,\n} from \"./runtime-context\";\n\nexport interface StoryboardLayout {\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex?: number;\n intrinsicSizing?: \"root-element\";\n}\n\nexport interface StoryboardVrtIgnoreRegion {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/**\n * Opt-in visual-regression tracking config (TEM-1775). The `vrt` prop is a\n * static, build-time mark read by AST enumeration (`parseCanvasFile`) — it\n * has no runtime behavior. Values must be literals to be tracked.\n */\nexport interface StoryboardVrtConfig {\n /** Per-storyboard pixelmatch threshold override (0..0.5). */\n threshold?: number;\n /** Temporarily untracked without losing config. */\n skip?: boolean;\n /** Regions (storyboard-local px) excluded from comparison. */\n ignore?: StoryboardVrtIgnoreRegion[];\n}\n\nexport function Storyboard<Props extends object = object>({\n id,\n name,\n component,\n layout,\n props,\n ...annotations\n}: {\n id: string;\n component: ComponentType<Props>;\n layout: StoryboardLayout;\n name?: string;\n props?: Props;\n [annotation: `data-tempo-${string}`]: unknown;\n /** Opt this storyboard into visual regression testing (static mark). */\n vrt?: boolean | StoryboardVrtConfig;\n}) {\n const Component = component as ComponentType<Props>;\n const sourceAnnotations = Object.fromEntries(\n Object.entries(annotations).filter(([key]) =>\n key.startsWith(\"data-tempo-\"),\n ),\n );\n\n return (\n <StoryboardSlot id={id} name={name} layout={layout} kind=\"component\">\n <Component {...(props ?? ({} as Props))} {...sourceAnnotations} />\n </StoryboardSlot>\n );\n}\n\nexport function LegacyStoryboardV1({\n id,\n storyboard,\n}: {\n id: string;\n storyboard: TempoStoryboard;\n}) {\n return (\n <StoryboardSlot\n id={id}\n name={storyboard.name}\n layout={storyboard.layout}\n kind=\"component\"\n >\n <LegacyStoryboardV1Render render={storyboard.render} />\n </StoryboardSlot>\n );\n}\n\nfunction LegacyStoryboardV1Render({\n render,\n}: {\n render: TempoStoryboard[\"render\"];\n}) {\n return <>{render()}</>;\n}\n\nexport function RouteStoryboard({\n id,\n name,\n route,\n layout,\n}: {\n id: string;\n route: string;\n layout: StoryboardLayout;\n name?: string;\n}) {\n return (\n <StoryboardSlot\n id={id}\n name={name}\n layout={layout}\n kind=\"route\"\n route={route}\n />\n );\n}\n\nexport function HtmlStoryboard({\n id,\n name,\n filepath,\n src,\n layout,\n}: {\n id: string;\n layout: StoryboardLayout;\n filepath?: string;\n src?: string;\n name?: string;\n}) {\n return (\n <StoryboardSlot\n id={id}\n name={name}\n layout={layout}\n kind=\"html\"\n filepath={filepath}\n src={src}\n />\n );\n}\n\nexport function StoryboardSlot({\n children,\n id,\n kind,\n layout,\n name,\n route,\n filepath,\n src,\n}: {\n children?: ReactNode;\n id: string;\n kind: \"component\" | \"route\" | \"html\";\n layout: StoryboardLayout;\n name?: string;\n route?: string;\n filepath?: string;\n src?: string;\n}) {\n const renderId = useCanvasStoryboardRenderId(id);\n const canvas = useCanvasIdentity();\n const status = useStoryboardStatus(id);\n const renderSize = useStoryboardSize(id);\n const placement = useStoryboardPlacement(id);\n const markRendered = useStoryboardRendered(id);\n const markUnmounted = useStoryboardUnmounted(id);\n const { reportError, clearError } = useStoryboardErrorReporter(id);\n const renderWidth = renderSize?.width;\n const renderHeight = renderSize?.height;\n const renderRevision = renderSize?.revision ?? 0;\n const intrinsicSize =\n renderSize?.intrinsicSize ??\n (kind === \"component\" && layout.intrinsicSizing === \"root-element\");\n const resetKey = `${renderId}:${renderRevision}`;\n const contentRef = useRef<HTMLDivElement | null>(null);\n // Phase 1 commits this slot's own elements with no user code under them, so\n // the projection root can register off a DOM node that exists whatever the\n // storyboard's component does; phase 2 admits the user tree one task later,\n // by which point the registration command has been answered. Keying the\n // admission by render id gives every projection identity its own phase 1.\n // Server rendering has no live document to register against and no event\n // loop to keep responsive, so there the whole tree is admitted at once.\n const [admittedRenderId, setAdmittedRenderId] = useState<string | null>(\n typeof document === \"undefined\" ? renderId : null,\n );\n const admitted = admittedRenderId === renderId;\n const errorBoundaryRef = useRef<StoryboardErrorBoundary | null>(null);\n const lastReportedCommitRef = useRef<string | null>(null);\n const previousChildrenRef = useRef(children);\n const [recoveryRevision, setRecoveryRevision] = useState(0);\n const commitKey = `${resetKey}:${recoveryRevision}`;\n // Bumping the recovery revision after a successful boundary reset remounts\n // the commit signal, so a recovery is re-reported (clearError) instead of\n // being swallowed by the commit-key dedupe.\n const retryRenderNow = useCallback(() => {\n if (!errorBoundaryRef.current?.retry()) return false;\n setRecoveryRevision((revision) => revision + 1);\n return true;\n }, []);\n const { noteRenderError, noteRecovered } =\n useRenderErrorRecovery(retryRenderNow);\n const handleRenderError = useCallback(\n (error: { message: string; stack?: string; componentStack?: string }) => {\n noteRenderError();\n reportError(error);\n },\n [noteRenderError, reportError],\n );\n // React finishes the remaining layout effects after capturing a sibling\n // layout-effect error, so the commit signal is provisional. Report success\n // in the next task, after the boundary has had a chance to record the error.\n const pendingRenderedReportRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const handleRendered = useCallback(\n (reportedCommitKey: string) => {\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n }\n pendingRenderedReportRef.current = setTimeout(() => {\n pendingRenderedReportRef.current = null;\n if (errorBoundaryRef.current?.hasError()) return;\n noteRecovered();\n if (lastReportedCommitRef.current === reportedCommitKey) return;\n lastReportedCommitRef.current = reportedCommitKey;\n clearError();\n markRendered();\n }, 0);\n },\n [clearError, markRendered, noteRecovered],\n );\n useEffect(\n () => () => {\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n pendingRenderedReportRef.current = null;\n }\n },\n [],\n );\n useLayoutEffect(() => {\n if (status !== \"unmounted\") return;\n // The slot survives render-cache eviction even though its content does\n // not. A direct URL can remount that content with the SAME commit key;\n // it must report the new commit after the runtime forgot the old render.\n lastReportedCommitRef.current = null;\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n pendingRenderedReportRef.current = null;\n }\n }, [status]);\n const renderChildren = useMemo(() => {\n if (isValidElement(children)) return cloneElement(children);\n return Children.map(children, (child) =>\n isValidElement(child) ? cloneElement(child) : child,\n );\n }, [children]);\n\n useEffect(() => markUnmounted, [markUnmounted]);\n\n // A passive effect, deliberately: React flushes these in a scheduler task of\n // their own, so the microtask checkpoint between phase 1's commit and this\n // admission is where the frame's registration observer gets to run.\n useEffect(() => {\n setAdmittedRenderId(renderId);\n }, [renderId]);\n\n useEffect(() => {\n const childrenChanged = previousChildrenRef.current !== children;\n previousChildrenRef.current = children;\n if (childrenChanged) retryRenderNow();\n }, [children, retryRenderNow]);\n\n useEffect(() => {\n if (!contentRef.current || status === \"unmounted\") return;\n return trackStoryboardPortals(renderId, contentRef.current, status);\n }, [renderId, status]);\n\n useEffect(() => {\n if (status === \"unmounted\") return;\n syncStoryboardPortals(renderId, status);\n }, [renderId, status]);\n\n if (status === \"unmounted\") return null;\n\n return (\n <div\n data-render-id={renderId}\n data-render-status={status}\n data-tempo-storyboard-render-id={renderId}\n data-tempo-storyboard-id={id}\n data-tempo-canvas-path={canvas?.path}\n data-tempo-storyboard-name={name}\n data-tempo-storyboard-kind={kind}\n data-tempo-storyboard-route={route}\n data-tempo-storyboard-filepath={filepath}\n data-tempo-storyboard-src={src}\n style={{\n position: \"absolute\",\n left: placement?.left ?? layout.x,\n top: placement?.top ?? layout.y,\n width: intrinsicSize ? \"max-content\" : (renderWidth ?? layout.width),\n height: intrinsicSize ? \"max-content\" : (renderHeight ?? layout.height),\n minWidth: intrinsicSize ? renderWidth : undefined,\n minHeight: intrinsicSize ? renderHeight : undefined,\n zIndex: layout.zIndex,\n visibility: status === \"active\" ? \"visible\" : \"hidden\",\n pointerEvents: status === \"active\" ? \"auto\" : \"none\",\n }}\n >\n <div\n data-render-content={renderId}\n // Phase 2's marker: the producer registers off the shell but waits for\n // this before opening its watch, so no baseline is ever taken from the\n // placeholder-only phase 1.\n data-render-admitted={admitted ? \"true\" : undefined}\n data-tempo-render-mode={kind === \"html\" ? \"static-dom\" : undefined}\n data-tempo-hide-fiber=\"true\"\n ref={contentRef}\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <StoryboardErrorBoundary\n ref={errorBoundaryRef}\n onError={handleRenderError}\n resetKey={resetKey}\n >\n {admitted ? (\n <Suspense fallback={<CanvasPendingMarker />}>\n <StoryboardAdmission renderId={renderId}>\n {renderChildren}\n </StoryboardAdmission>\n <StoryboardCommitSignal\n key={commitKey}\n commitKey={commitKey}\n onCommit={handleRendered}\n />\n </Suspense>\n ) : (\n // An established watch can rebind to this shell after a remount,\n // before the passive admission effect runs. Mark that loading\n // phase so it holds the preview instead of publishing an empty\n // baseline. Admitted components may still intentionally return null.\n <CanvasPendingMarker />\n )}\n </StoryboardErrorBoundary>\n </div>\n </div>\n );\n}\n\n/** Opens the admission budget for the user tree React is about to render\n * under it. Rendering this component is what arms the counter, so it must sit\n * directly above the user tree and below the error boundary that catches the\n * budget's throw. */\nfunction StoryboardAdmission({\n children,\n renderId,\n}: {\n children?: ReactNode;\n renderId: string;\n}) {\n const host = useRequiredCanvasHost();\n // Imports can consume random values on a cold page but stay cached on a\n // reused page. Reset once, after those imports and before the user tree's\n // render/effects; ordinary updates must keep advancing the same sequence.\n useState(() => host.prepareStoryboardCapture?.(renderId));\n beginAdmissionWindow();\n return children;\n}\n\nfunction StoryboardCommitSignal({\n commitKey,\n onCommit,\n}: {\n commitKey: string;\n onCommit(commitKey: string): void;\n}) {\n const onCommitRef = useRef(onCommit);\n onCommitRef.current = onCommit;\n useLayoutEffect(() => onCommitRef.current(commitKey), [commitKey]);\n return null;\n}\n\ntype StoryboardErrorBoundaryProps = {\n children?: ReactNode;\n onError(error: {\n message: string;\n stack?: string;\n componentStack?: string;\n }): void;\n resetKey: string;\n};\n\ntype StoryboardErrorBoundaryState = {\n error: Error | null;\n componentStack?: string;\n resetKey: string;\n};\n\n/** React emits one component-stack frame per fiber, so a storyboard that\n * recursed until it hit the admission budget produces a megabyte of stack in\n * which every frame after the first few is the same repeated line. The whole\n * string is reported onto the storyboard's problem lane and read back by the\n * Tempo renderer, so it is cut where it stops being evidence. */\nconst maxReportedComponentStackFrames = 40;\n\nfunction boundComponentStack(\n componentStack: string | null | undefined,\n): string | undefined {\n if (!componentStack) return undefined;\n const frames = componentStack.split(\"\\n\");\n if (frames.length <= maxReportedComponentStackFrames) return componentStack;\n const dropped = frames.length - maxReportedComponentStackFrames;\n return [\n ...frames.slice(0, maxReportedComponentStackFrames),\n ` ... ${dropped} more frames`,\n ].join(\"\\n\");\n}\n\nclass StoryboardErrorBoundary extends Component<\n StoryboardErrorBoundaryProps,\n StoryboardErrorBoundaryState\n> {\n state: StoryboardErrorBoundaryState = {\n error: null,\n componentStack: undefined,\n resetKey: this.props.resetKey,\n };\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n static getDerivedStateFromProps(\n props: StoryboardErrorBoundaryProps,\n state: StoryboardErrorBoundaryState,\n ) {\n if (props.resetKey !== state.resetKey) {\n return {\n error: null,\n componentStack: undefined,\n resetKey: props.resetKey,\n };\n }\n return null;\n }\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n const componentStack = boundComponentStack(info.componentStack);\n this.setState({ componentStack });\n this.props.onError({\n message: error.message,\n stack: error.stack,\n componentStack,\n });\n }\n\n hasError(): boolean {\n return this.state.error !== null;\n }\n\n retry(): boolean {\n if (!this.state.error) return false;\n this.setState((state) =>\n state.error\n ? { error: null, componentStack: undefined, resetKey: state.resetKey }\n : null,\n );\n return true;\n }\n\n render() {\n if (this.state.error) {\n return (\n <div\n data-render-error=\"true\"\n data-render-error-message={this.state.error.message}\n style={{ width: \"100%\", height: \"100%\" }}\n />\n );\n }\n return this.props.children;\n }\n}\n","import * as React from \"react\";\n\n/**\n * A bound on how much render work can happen in one uninterrupted burst.\n *\n * A user can write `const Loop = () => <Loop/>` — or split the same cycle\n * across two modules that import each other — into any storyboard file. React\n * then allocates fibers until the renderer dies at V8's 4 GB heap limit. No\n * timer, watchdog, or IPC message can intervene, because the render loop is\n * synchronous and never yields the thread: nothing else in the document runs\n * again, ever. The bound therefore has to be enforced from inside the render\n * itself.\n *\n * React transitions its hooks dispatcher on entry to and exit from every\n * function component (`renderWithHooks` / `finishRenderingHooks` both assign\n * `ReactSharedInternals.H`), so an accessor on that one property counts render\n * work across arbitrary user code with nothing injected into user modules.\n * Past the budget the accessor throws, which is an ordinary render-phase\n * throw: React unwinds to the nearest storyboard error boundary, every sibling\n * in the same pass still renders and commits, and an infinite recursion\n * becomes one storyboard showing a problem instead of a dead canvas.\n *\n * The counter re-arms on the first microtask after any step, which is what\n * makes the bound *per burst* rather than per render pass. A synchronous React\n * pass never reaches a microtask checkpoint, so a runaway drains one budget and\n * throws, while ordinary work is handed a full budget again the moment the\n * thread returns to the event loop. Bounding bursts rather than passes is what\n * catches the common case: a user edits an already-mounted storyboard into a\n * recursive one, and Fast Refresh re-renders that component's own fiber without\n * ever re-rendering the storyboard slot above it.\n */\n\n/**\n * Dispatcher transitions one burst may spend. React transitions twice per\n * function component, so this is roughly 50k component instantiations: orders\n * of magnitude above any real storyboard (a large one costs a few thousand)\n * and orders of magnitude below the fiber count that exhausts the heap.\n */\nexport const admissionRenderStepBudget = 100_000;\n\n/** Thrown from inside the render that exceeded {@link admissionRenderStepBudget}. */\nexport class AdmissionBudgetError extends Error {\n constructor() {\n super(\n \"This storyboard renders itself recursively: it kept creating \" +\n \"components without ever finishing a render. Check for a component \" +\n \"that returns itself, or two components that render each other.\",\n );\n this.name = \"AdmissionBudgetError\";\n }\n}\n\n/**\n * Where React keeps the current hooks dispatcher: `H` on React 19's client\n * internals, `ReactCurrentDispatcher.current` on React 18. Both are assigned\n * on every function component render, which is the only property of them this\n * module depends on.\n */\nfunction findDispatcherSlot(): {\n holder: Record<string, unknown>;\n key: string;\n} | null {\n const react = React as unknown as Record<string, Record<string, unknown>>;\n const modern =\n react.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;\n if (modern && \"H\" in modern) return { holder: modern, key: \"H\" };\n const legacy = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentDispatcher as Record<string, unknown> | undefined;\n if (legacy && \"current\" in legacy) return { holder: legacy, key: \"current\" };\n return null;\n}\n\nlet stepsRemaining = admissionRenderStepBudget;\nlet rearmScheduled = false;\nlet counterState: \"uninstalled\" | \"installed\" | \"unavailable\" = \"uninstalled\";\n\nfunction scheduleRearm(): void {\n if (rearmScheduled) return;\n rearmScheduled = true;\n queueMicrotask(() => {\n rearmScheduled = false;\n stepsRemaining = admissionRenderStepBudget;\n });\n}\n\nfunction installCounter(): boolean {\n if (counterState !== \"uninstalled\") return counterState === \"installed\";\n const slot = findDispatcherSlot();\n if (!slot) {\n // A React whose dispatcher lives somewhere else still renders storyboards\n // correctly; it just runs without this bound. Failing open is deliberate:\n // an internals rename must never stop storyboards from rendering, and the\n // projection stall watchdog remains the outcome-based net underneath.\n counterState = \"unavailable\";\n return false;\n }\n const { holder, key } = slot;\n let dispatcher = holder[key];\n Object.defineProperty(holder, key, {\n configurable: true,\n get: () => dispatcher,\n set: (value: unknown) => {\n dispatcher = value;\n scheduleRearm();\n stepsRemaining -= 1;\n if (stepsRemaining > 0) return;\n // Re-arming as it throws lets React's unwinding assignments through, and\n // hands React's one automatic retry of the failed root a fresh budget so\n // the retry trips the same way and the boundary finally sees the error.\n stepsRemaining = admissionRenderStepBudget;\n throw new AdmissionBudgetError();\n },\n });\n counterState = \"installed\";\n return true;\n}\n\n/**\n * Charges the storyboard about to render its own budget, so one pass covering\n * many storyboards cannot accumulate their work into a single overrun. Called\n * during render, immediately above the user tree.\n */\nexport function beginAdmissionWindow(): void {\n if (!installCounter()) return;\n stepsRemaining = admissionRenderStepBudget;\n}\n","import { PROJECTION_PENDING_ATTRIBUTE } from \"../../../modules/iframe-projection/combined/projection-pending\";\n\n/**\n * The placeholder Tempo-owned admission and Suspense boundaries render\n * while they wait.\n *\n * A not-yet-admitted or suspended subtree reaches the DOM as an empty one,\n * which is indistinguishable from a subtree that intentionally emptied. This\n * marker makes the difference observable to the projection producer, which treats a root\n * whose children are all markers as pending and holds the mirror's last-good\n * content instead of publishing the blank.\n *\n * Only Tempo's own boundaries render it. A user's Suspense inside their\n * storyboard keeps mirroring faithfully: their fallback — even `null` —\n * renders inside the root with no marker beside it, so their loading state\n * stays a real state the mirror shows.\n *\n * It carries no layout of its own: the host document must look the same with a\n * subtree pending as it does with that subtree absent.\n */\nexport function CanvasPendingMarker() {\n return (\n <div\n {...{ [PROJECTION_PENDING_ATTRIBUTE]: \"\" }}\n style={{ display: \"none\" }}\n aria-hidden=\"true\"\n />\n );\n}\n","type FiberLike = {\n return: FiberLike | null;\n stateNode: unknown;\n};\n\ntype PortalWatcher = {\n element: Element;\n onPortalFound(portalRoot: Element): void;\n onPortalRemoved(portalRoot: Element): void;\n};\n\ntype PortalInlineStyleValue = {\n value: string;\n priority: string;\n};\n\ntype PortalInlineStyle = {\n visibility: PortalInlineStyleValue;\n pointerEvents: PortalInlineStyleValue;\n contentVisibility: PortalInlineStyleValue;\n transition: PortalInlineStyleValue;\n animation: PortalInlineStyleValue;\n};\n\ntype PortalManagedProperty = {\n // The PortalInlineStyle field that holds this property's saved baseline.\n key: keyof PortalInlineStyle;\n // The CSS property name as written in inline styles.\n cssName: string;\n // The value forced (with !important) while the portal is hidden.\n hiddenValue: string;\n};\n\n// Single source of truth for the inline-style properties this module overrides\n// to hide cached/inactive portals, so the hide path and the restore path can't\n// drift out of sync.\nconst PORTAL_MANAGED_PROPERTIES: readonly PortalManagedProperty[] = [\n { key: \"visibility\", cssName: \"visibility\", hiddenValue: \"hidden\" },\n { key: \"pointerEvents\", cssName: \"pointer-events\", hiddenValue: \"none\" },\n {\n key: \"contentVisibility\",\n cssName: \"content-visibility\",\n hiddenValue: \"hidden\",\n },\n { key: \"transition\", cssName: \"transition\", hiddenValue: \"none\" },\n { key: \"animation\", cssName: \"animation\", hiddenValue: \"none\" },\n];\n\nconst portalElementsByRenderId = new Map<string, Set<Element>>();\nconst portalOwnerRenderIdsByElement = new Map<Element, Set<string>>();\nconst portalInlineStyleByElement = new Map<Element, PortalInlineStyle>();\nconst renderStatusById = new Map<string, \"active\" | \"cached\">();\nconst projectionPortalIdAttribute = \"data-projection-portal-id\";\nlet nextSdkPortalId = 1;\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n}\n\nfunction ensureProjectionPortalId(portalRoot: Element): string {\n const existingId = portalRoot.getAttribute(projectionPortalIdAttribute);\n if (existingId) return existingId;\n\n const id = `tempo-sdk-portal-${nextSdkPortalId++}`;\n portalRoot.setAttribute(projectionPortalIdAttribute, id);\n return id;\n}\n\nfunction buildProjectionPortalSelector(portalRoot: Element): string {\n return `[${projectionPortalIdAttribute}=\"${escapeAttributeValue(\n ensureProjectionPortalId(portalRoot),\n )}\"]`;\n}\n\nfunction findFiberKey(element: Element): string | null {\n return (\n Object.keys(element).find(\n (key) =>\n key.startsWith(\"__reactFiber$\") ||\n key.startsWith(\"__reactInternalInstance$\"),\n ) ?? null\n );\n}\n\nfunction findContainerKey(element: Element): string | null {\n return Object.keys(element).find((key) => key.startsWith(\"__reactContainer$\")) ?? null;\n}\n\nfunction getFiberFromElement(element: Element): FiberLike | null {\n const fiberKey = findFiberKey(element);\n if (fiberKey) {\n return (\n (element as unknown as Record<string, FiberLike | undefined>)[fiberKey] ??\n null\n );\n }\n\n const containerKey = findContainerKey(element);\n if (containerKey) {\n return (\n (element as unknown as Record<string, FiberLike | undefined>)[\n containerKey\n ] ?? null\n );\n }\n\n return null;\n}\n\nclass PortalTracker {\n private readonly watchers = new Set<PortalWatcher>();\n private readonly ownerWatchersByPortalRoot = new Map<\n Element,\n Set<PortalWatcher>\n >();\n private observer: MutationObserver | null = null;\n\n register(watcher: PortalWatcher): () => void {\n this.watchers.add(watcher);\n\n if (this.watchers.size === 1) {\n this.startObserving();\n }\n\n if (typeof document !== \"undefined\" && document.body) {\n this.checkExistingElements();\n queueMicrotask(() => this.checkExistingElements());\n }\n\n return () => this.unregister(watcher);\n }\n\n private checkExistingElements(): void {\n if (typeof document === \"undefined\" || !document.body) return;\n for (const child of Array.from(document.body.children)) {\n this.checkElement(child);\n }\n }\n\n private unregister(watcher: PortalWatcher): void {\n this.watchers.delete(watcher);\n\n for (const [portalRoot, owners] of this.ownerWatchersByPortalRoot) {\n owners.delete(watcher);\n if (owners.size === 0) {\n this.ownerWatchersByPortalRoot.delete(portalRoot);\n }\n }\n\n if (this.watchers.size === 0) {\n this.stopObserving();\n }\n }\n\n private startObserving(): void {\n if (\n this.observer ||\n typeof document === \"undefined\" ||\n !document.body ||\n typeof MutationObserver === \"undefined\"\n ) {\n return;\n }\n\n this.observer = new MutationObserver(this.handleMutations);\n this.observer.observe(document.body, { childList: true });\n }\n\n private stopObserving(): void {\n this.observer?.disconnect();\n this.observer = null;\n }\n\n private handleMutations = (mutations: MutationRecord[]): void => {\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (node instanceof Element) {\n queueMicrotask(() => this.checkElement(node));\n }\n }\n\n for (const node of mutation.removedNodes) {\n if (!(node instanceof Element)) continue;\n const owners = this.ownerWatchersByPortalRoot.get(node);\n if (!owners) continue;\n for (const owner of owners) {\n owner.onPortalRemoved(node);\n }\n this.ownerWatchersByPortalRoot.delete(node);\n }\n }\n };\n\n private checkElement(element: Element): void {\n const ancestorDomNodes = this.getDomAncestorsViaFiber(element);\n if (ancestorDomNodes.length === 0) return;\n\n let owners = this.ownerWatchersByPortalRoot.get(element);\n for (const watcher of this.watchers) {\n const belongsToWatcher = ancestorDomNodes.some(\n (node) => watcher.element.contains(node) || watcher.element === node,\n );\n if (!belongsToWatcher) continue;\n\n if (!owners) {\n owners = new Set<PortalWatcher>();\n this.ownerWatchersByPortalRoot.set(element, owners);\n }\n if (owners.has(watcher)) continue;\n\n owners.add(watcher);\n watcher.onPortalFound(element);\n }\n }\n\n private getDomAncestorsViaFiber(element: Element): Element[] {\n const fiber = getFiberFromElement(element);\n if (!fiber) return [];\n\n const domNodes: Element[] = [];\n let current: FiberLike | null = fiber.return;\n while (current) {\n if (current.stateNode instanceof Element) {\n domNodes.push(current.stateNode);\n }\n current = current.return;\n }\n return domNodes;\n }\n}\n\nlet portalTracker: PortalTracker | null = null;\n\nfunction getPortalTracker(): PortalTracker {\n if (!portalTracker) {\n portalTracker = new PortalTracker();\n }\n return portalTracker;\n}\n\nfunction getStylablePortalElement(\n portalRoot: Element,\n): HTMLElement | SVGElement | null {\n if (portalRoot instanceof HTMLElement || portalRoot instanceof SVGElement) {\n return portalRoot;\n }\n return null;\n}\n\nfunction ensurePortalInlineStyle(portalRoot: Element): PortalInlineStyle {\n const existing = portalInlineStyleByElement.get(portalRoot);\n if (existing) return existing;\n\n const stylableElement = getStylablePortalElement(portalRoot);\n const baseline = {\n visibility: readInlineStyleValue(stylableElement, \"visibility\"),\n pointerEvents: readInlineStyleValue(stylableElement, \"pointer-events\"),\n contentVisibility: readInlineStyleValue(\n stylableElement,\n \"content-visibility\",\n ),\n transition: readInlineStyleValue(stylableElement, \"transition\"),\n animation: readInlineStyleValue(stylableElement, \"animation\"),\n };\n portalInlineStyleByElement.set(portalRoot, baseline);\n return baseline;\n}\n\nfunction readInlineStyleValue(\n element: HTMLElement | SVGElement | null,\n propertyName: string,\n): PortalInlineStyleValue {\n return {\n value: element?.style.getPropertyValue(propertyName) ?? \"\",\n priority: element?.style.getPropertyPriority(propertyName) ?? \"\",\n };\n}\n\nfunction restoreInlineStyleValue(\n style: CSSStyleDeclaration,\n propertyName: string,\n baseline: PortalInlineStyleValue,\n): void {\n if (baseline.value) {\n style.setProperty(propertyName, baseline.value, baseline.priority);\n return;\n }\n style.removeProperty(propertyName);\n}\n\nfunction restorePortalInlineStyle(portalRoot: Element): void {\n const stylableElement = getStylablePortalElement(portalRoot);\n const baseline = portalInlineStyleByElement.get(portalRoot);\n if (!stylableElement || !baseline) return;\n\n for (const property of PORTAL_MANAGED_PROPERTIES) {\n restoreInlineStyleValue(\n stylableElement.style,\n property.cssName,\n baseline[property.key],\n );\n }\n}\n\nfunction syncPortalVisibility(portalRoot: Element): void {\n const owners = portalOwnerRenderIdsByElement.get(portalRoot);\n if (!owners || owners.size === 0) {\n restorePortalInlineStyle(portalRoot);\n portalInlineStyleByElement.delete(portalRoot);\n return;\n }\n\n const stylableElement = getStylablePortalElement(portalRoot);\n if (!stylableElement) return;\n\n const shouldBeVisible = [...owners].some(\n (renderId) => renderStatusById.get(renderId) === \"active\",\n );\n\n if (shouldBeVisible) {\n restorePortalInlineStyle(portalRoot);\n portalInlineStyleByElement.delete(portalRoot);\n return;\n }\n\n ensurePortalInlineStyle(portalRoot);\n for (const property of PORTAL_MANAGED_PROPERTIES) {\n stylableElement.style.setProperty(\n property.cssName,\n property.hiddenValue,\n \"important\",\n );\n }\n}\n\nfunction trackPortal(renderId: string, portalRoot: Element): void {\n ensureProjectionPortalId(portalRoot);\n\n const portals = portalElementsByRenderId.get(renderId) ?? new Set<Element>();\n portals.add(portalRoot);\n portalElementsByRenderId.set(renderId, portals);\n\n const owners = portalOwnerRenderIdsByElement.get(portalRoot) ?? new Set<string>();\n owners.add(renderId);\n portalOwnerRenderIdsByElement.set(portalRoot, owners);\n syncPortalVisibility(portalRoot);\n}\n\nfunction untrackPortal(renderId: string, portalRoot: Element): void {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return;\n\n portals.delete(portalRoot);\n if (portals.size === 0) {\n portalElementsByRenderId.delete(renderId);\n }\n\n const owners = portalOwnerRenderIdsByElement.get(portalRoot);\n if (owners) {\n owners.delete(renderId);\n if (owners.size === 0) {\n portalOwnerRenderIdsByElement.delete(portalRoot);\n }\n }\n syncPortalVisibility(portalRoot);\n}\n\nexport function releaseStoryboardPortals(renderId: string): void {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) {\n renderStatusById.delete(renderId);\n return;\n }\n\n for (const portalRoot of [...portals]) {\n untrackPortal(renderId, portalRoot);\n }\n renderStatusById.delete(renderId);\n}\n\nexport function getStoryboardPortalSelectors(renderId: string): string[] {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return [];\n return [...portals]\n .filter((portalRoot) => portalRoot.isConnected)\n .map(buildProjectionPortalSelector);\n}\n\nexport function syncStoryboardPortals(\n renderId: string,\n status: \"active\" | \"cached\",\n): void {\n renderStatusById.set(renderId, status);\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return;\n for (const portalRoot of portals) {\n syncPortalVisibility(portalRoot);\n }\n}\n\nexport function trackStoryboardPortals(\n renderId: string,\n element: Element,\n status: \"active\" | \"cached\",\n): () => void {\n syncStoryboardPortals(renderId, status);\n const unregister = getPortalTracker().register({\n element,\n onPortalFound(portalRoot) {\n trackPortal(renderId, portalRoot);\n },\n onPortalRemoved(portalRoot) {\n untrackPortal(renderId, portalRoot);\n },\n });\n\n return () => {\n unregister();\n releaseStoryboardPortals(renderId);\n };\n}\n","import { useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Self-contained recovery for storyboard render errors.\n *\n * A render error unmounts the throwing subtree, so React Fast Refresh alone\n * cannot repair it: refresh only re-renders mounted fibers, and the fixed\n * component has none. The design shell repairs this by advancing the render\n * revision (which resets the boundary), but a host page without the shell —\n * a direct `/tempo-host?canvasPath=...` document — has no revision driver at\n * all. Recovery must therefore be armed from inside the SDK:\n *\n * - a retry timer with exponential backoff, armed while a boundary is\n * errored — the universal mechanism, needing no signal from anyone; and\n * - an immediate retry on an HMR beat, when one is observable — new code\n * just arrived, so waiting out the backoff would be pure latency.\n *\n * The beat arrives over a window-global bus (create-if-absent on both sides,\n * mirroring the host-recovery feed) from the devserver-generated Vite\n * recovery adapter, which owns `import.meta.hot`. This module must stay free\n * of literal `import.meta` itself: the built bundle is force-resolved into\n * Expo's Metro web bundle, which runs as a classic script where that token\n * is a parse error that kills the whole document (TEM-1409). The beat is\n * best-effort by design — hosts without the adapter (Expo, a bare\n * `/tempo-host?canvasPath=...` document) never see one. That asymmetry is\n * why the backoff cap stays low: without a beat, the cap IS the worst-case\n * fix-to-recovery latency.\n */\n\n/** First retry after a fresh error; also the rung the ladder resets to. */\nexport const renderErrorRetryBaseDelayMs = 1_000;\n/**\n * Backoff cap. Doubling stops here (1s → 2s → 4s → 8s) so a persistently\n * broken storyboard costs at most one re-render per 8s — negligible even for\n * expensive trees — while a fix still becomes visible within 8s when no HMR\n * beat is observable.\n */\nexport const renderErrorRetryMaxDelayMs = 8_000;\n\ntype RenderErrorRecoveryBeatBus = {\n emit(): void;\n subscribe(listener: () => void): () => void;\n};\n\nconst BEAT_BUS_KEY = \"__tempoRenderErrorRecoveryBeatBus\";\n\nfunction createBeatBus(): RenderErrorRecoveryBeatBus {\n const listeners = new Set<() => void>();\n return {\n emit() {\n for (const listener of [...listeners]) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n// The beat is a document-lifetime fact, not a per-storyboard one, and its\n// producer (the generated Vite adapter) must not import the SDK — so the bus\n// lives on the window global with create-if-absent semantics on both sides,\n// exactly like the host-recovery feed: whichever party evaluates first\n// creates it, the other reuses it.\nfunction getRenderErrorRecoveryBeatBus(): RenderErrorRecoveryBeatBus {\n const globals = globalThis as typeof globalThis & {\n [BEAT_BUS_KEY]?: RenderErrorRecoveryBeatBus;\n };\n return (globals[BEAT_BUS_KEY] ??= createBeatBus());\n}\n\n/**\n * Announces \"new code may have arrived\" to every errored boundary. Exported\n * so tests can drive beats directly; production beats come from the\n * devserver-generated Vite recovery adapter emitting on the shared bus.\n */\nexport function emitRenderErrorRecoveryBeat(): void {\n getRenderErrorRecoveryBeatBus().emit();\n}\n\n/**\n * Owns the retry schedule for one storyboard's error boundary. The caller\n * reports the boundary's state transitions (`noteRenderError` from every\n * catch, `noteRecovered` from every healthy commit) and supplies `retryNow`,\n * which resets the boundary and returns whether it was actually errored.\n *\n * The normal still-broken loop is: timer fires → retry → children throw →\n * catch calls `noteRenderError` → next rung is armed. A retry that sticks\n * leads to a commit, whose `noteRecovered` clears the pending state and\n * resets the ladder.\n */\nexport function useRenderErrorRecovery(retryNow: () => boolean): {\n noteRenderError(): void;\n noteRecovered(): void;\n} {\n const retryNowRef = useRef(retryNow);\n retryNowRef.current = retryNow;\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const nextDelayRef = useRef(renderErrorRetryBaseDelayMs);\n const erroredRef = useRef(false);\n\n const clearTimer = useCallback(() => {\n if (timerRef.current === null) return;\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }, []);\n\n const noteRenderError = useCallback(() => {\n erroredRef.current = true;\n // A pending timer already covers this error (e.g. a children-change\n // retry failed while the scheduled one was still counting down).\n if (timerRef.current !== null) return;\n const delay = nextDelayRef.current;\n nextDelayRef.current = Math.min(delay * 2, renderErrorRetryMaxDelayMs);\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n retryNowRef.current();\n }, delay);\n }, []);\n\n const noteRecovered = useCallback(() => {\n erroredRef.current = false;\n nextDelayRef.current = renderErrorRetryBaseDelayMs;\n clearTimer();\n }, [clearTimer]);\n\n useEffect(() => {\n const onBeat = () => {\n // Fresh code deserves a fresh ladder: whether the immediate retry\n // below succeeds or re-catches, the next scheduled attempt starts\n // from the base delay again.\n nextDelayRef.current = renderErrorRetryBaseDelayMs;\n if (!erroredRef.current) return;\n clearTimer();\n retryNowRef.current();\n };\n const unsubscribe = getRenderErrorRecoveryBeatBus().subscribe(onBeat);\n return () => {\n unsubscribe();\n clearTimer();\n };\n }, [clearTimer]);\n\n return { noteRenderError, noteRecovered };\n}\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;;;ACTA,SAAS,YAAY,OAA2B,OAAuB;AAC5E,QAAM,aAAa,OAAO,KAAK;AAC/B,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,GAAG,KAAK,eAAe;AAAA,EACzC;AACA,SAAO;AACT;;;ADwFM;AA7EN,IAAM,wBAAwB,cAAqC,IAAI;AAEhE,SAAS,4BACd,YACA,cACQ;AACR,SAAO,UAAU;AAAA,IACf,YAAY,YAAY,aAAa;AAAA,EACvC,CAAC,eAAe;AAAA,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AAA,EAEA,kBAAkB,OAAc,MAAiB;AAC/C,UAAM,iBAAiB,oBAAoB,KAAK,cAAc;AAC9D,SAAK,SAAS,EAAE,eAAe,CAAC;AAChC,SAAK,MAAM,QAAQ;AAAA,MACjB,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,WAAoB;AAClB,WAAO,KAAK,MAAM,UAAU;AAAA,EAC9B;AAAA,EAEA,QAAiB;AACf,QAAI,CAAC,KAAK,MAAM,MAAO,QAAO;AAC9B,SAAK;AAAA,MAAS,CAAC,UACb,MAAM,QACF,EAAE,OAAO,MAAM,gBAAgB,QAAW,UAAU,MAAM,SAAS,IACnE;AAAA,IACN;AACA,WAAO;AAAA,EACT;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,MAAM,OAAO;AACpB,aACE,gBAAAF;AAAA,QAAC;AAAA;AAAA,UACC,qBAAkB;AAAA,UAClB,6BAA2B,KAAK,MAAM,MAAM;AAAA,UAC5C,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO;AAAA;AAAA,MACzC;AAAA,IAEJ;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;","names":["createContext","useContext","createContext","useContext","Children","cloneElement","isValidElement","useCallback","useEffect","useMemo","useRef","jsx","useCallback","useCallback","jsx","Component","useRef","useCallback","useEffect","useMemo","isValidElement","cloneElement","Children"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas/parser.ts"],"sourcesContent":["import { parseSync } from \"oxc-parser\";\n\nexport type CanvasSourceSpan = { start: number; end: number };\n\nexport type CanvasParseError = {\n message: string;\n span?: CanvasSourceSpan;\n /** \"structural\": the file's storyboard identity/structure cannot be\n * trusted — readers must fail closed. \"degraded\": a single storyboard\n * (or the canvas display name) is not statically readable/editable but\n * identity is intact — readers keep working with fallback values. */\n kind: \"structural\" | \"degraded\";\n};\n\nexport type ParsedCanvasImport = {\n localName: string;\n source: string;\n importedName: string;\n kind: \"default\" | \"named\" | \"namespace\";\n importKind?: \"type\" | \"value\";\n span: CanvasSourceSpan;\n declarationSpan: CanvasSourceSpan;\n specifierCount: number;\n namedSpecifierCount: number;\n hasDefaultSpecifier: boolean;\n hasNamespaceSpecifier: boolean;\n};\n\n/** An import statement that names Tempo SDK canvas components but uses the\n * wrong tempo-sdk specifier (e.g. `import { Canvas } from \"tempo-sdk\"`).\n * Neither the main entry nor the other subpaths export the components, so\n * the file both fails at runtime and is invisible to this parser's <Canvas>\n * detection — migrate-on-read uses these records to repair the specifier. */\nexport type MisimportedSdkCanvasImport = {\n /** Import source exactly as written, e.g. \"tempo-sdk\". */\n source: string;\n /** Span of the source string literal INCLUDING its quote characters. */\n sourceSpan: CanvasSourceSpan;\n /** Imported names of every value specifier on the statement. */\n importedNames: string[];\n /** True when every value specifier on the statement is a named import of a\n * value actually exported by \"tempo-sdk/canvas\" — rewriting the source\n * string to \"tempo-sdk/canvas\" provably fixes the statement. */\n rewritable: boolean;\n};\n\nexport type ParsedCanvasLayout = {\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex?: number;\n intrinsicSizing?: \"root-element\";\n};\n\nexport type ParsedCanvasLayoutSpans = {\n x?: CanvasSourceSpan;\n y?: CanvasSourceSpan;\n width?: CanvasSourceSpan;\n height?: CanvasSourceSpan;\n zIndex?: CanvasSourceSpan;\n intrinsicSizing?: CanvasSourceSpan;\n layoutClose?: number;\n};\n\nexport type ParsedCanvasComponentReference = {\n expression: string;\n span: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n localName?: string;\n import?: ParsedCanvasImport;\n};\n\nexport type ParsedStoryboardVrtIgnoreRegion = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/** Opt-in visual-regression tracking parsed from the `vrt` prop on\n * `<Storyboard>` (TEM-1775). Presence of the parsed field means the\n * storyboard is tracked; `skip: true` keeps the config but pauses gating.\n * `vrt` / `vrt={true}` parse to `{}`; `vrt={false}` parses to absent. */\nexport type ParsedStoryboardVrt = {\n /** Per-storyboard pixelmatch threshold override (0..0.5). */\n threshold?: number;\n /** Temporarily untracked without losing config. */\n skip?: boolean;\n /** Regions (storyboard-local px) excluded from comparison. */\n ignore?: ParsedStoryboardVrtIgnoreRegion[];\n};\n\nexport type ParsedCanvasExpressionReference = {\n expression: string;\n span: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n};\n\nexport type ParsedCanvasStoryboard = {\n storyboardKey: string;\n displayName?: string;\n kind: \"component\" | \"route\" | \"html\";\n /** Authored component runtime selected by the storyboard declaration. */\n uiFramework?: \"svelte\";\n layout: ParsedCanvasLayout;\n editable: boolean;\n jsxElementSpan: CanvasSourceSpan;\n openingElementSpan?: CanvasSourceSpan;\n idSpan?: CanvasSourceSpan;\n idAttributeSpan?: CanvasSourceSpan;\n nameSpan?: CanvasSourceSpan;\n nameAttributeSpan?: CanvasSourceSpan;\n layoutAttributeSpan?: CanvasSourceSpan;\n layoutSpans?: ParsedCanvasLayoutSpans;\n component?: ParsedCanvasComponentReference;\n props?: ParsedCanvasExpressionReference;\n vrt?: ParsedStoryboardVrt;\n /** Span of the whole `vrt` attribute. Present whenever the attribute\n * exists in source — including `vrt={false}` and degraded (dynamic /\n * malformed) forms whose `vrt` value stays absent — so an editor can\n * replace or remove the declaration without ever inserting a duplicate. */\n vrtAttributeSpan?: CanvasSourceSpan;\n route?: string;\n routeSpan?: CanvasSourceSpan;\n routeAttributeSpan?: CanvasSourceSpan;\n filepath?: string;\n filepathSpan?: CanvasSourceSpan;\n filepathAttributeSpan?: CanvasSourceSpan;\n src?: string;\n srcSpan?: CanvasSourceSpan;\n srcAttributeSpan?: CanvasSourceSpan;\n legacyV1?: {\n storyboard: ParsedCanvasExpressionReference;\n objectName?: string;\n objectSpan?: CanvasSourceSpan;\n objectClose?: number;\n namePropertySpan?: CanvasSourceSpan;\n layoutPropertySpan?: CanvasSourceSpan;\n };\n errors: CanvasParseError[];\n};\n\nexport type ParsedCanvasFile = {\n filePath: string;\n canvasPath?: string;\n pageName: string;\n backgroundColor?: string;\n canvasElementSpan?: CanvasSourceSpan;\n canvasOpeningElementSpan?: CanvasSourceSpan;\n canvasChildrenInsertionOffset?: number;\n nameSpan?: CanvasSourceSpan;\n nameAttributeSpan?: CanvasSourceSpan;\n pathSpan?: CanvasSourceSpan;\n pathAttributeSpan?: CanvasSourceSpan;\n backgroundColorSpan?: CanvasSourceSpan;\n backgroundColorAttributeSpan?: CanvasSourceSpan;\n imports: ParsedCanvasImport[];\n misimportedSdkCanvasImports: MisimportedSdkCanvasImport[];\n storyboards: ParsedCanvasStoryboard[];\n errors: CanvasParseError[];\n};\n\ntype SdkComponent =\n | \"Canvas\"\n | \"Storyboard\"\n | \"SvelteStoryboard\"\n | \"LegacyStoryboardV1\"\n | \"RouteStoryboard\"\n | \"HtmlStoryboard\";\n\ntype StoryboardSdkComponent = Exclude<SdkComponent, \"Canvas\">;\n\ntype StoryboardElement = {\n element: any;\n component: StoryboardSdkComponent;\n};\n\ntype ParsedImports = {\n all: ParsedCanvasImport[];\n byLocalName: Map<string, ParsedCanvasImport>;\n sdkLocalNames: Map<string, SdkComponent>;\n sdkNamespaces: Set<string>;\n};\n\ntype ParsedLegacyStoryboardObject = {\n bindingName: string;\n displayName?: string;\n component?: ParsedCanvasComponentReference;\n objectSpan?: CanvasSourceSpan;\n objectClose?: number;\n nameSpan?: CanvasSourceSpan;\n namePropertySpan?: CanvasSourceSpan;\n layoutPropertySpan?: CanvasSourceSpan;\n layout: ParsedCanvasLayout;\n layoutSpans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n};\n\ntype ObjectStringBindings = Map<\n string,\n Map<string, { value: string; span: CanvasSourceSpan }>\n>;\n\nconst SDK_IMPORT_SOURCES = new Set([\n \"tempo-sdk/canvas\",\n \"tempo-sdk/canvas/svelte\",\n]);\n\nconst SDK_COMPONENTS = new Set<SdkComponent>([\n \"Canvas\",\n \"Storyboard\",\n \"SvelteStoryboard\",\n \"LegacyStoryboardV1\",\n \"RouteStoryboard\",\n \"HtmlStoryboard\",\n]);\n\n// Must stay in sync with runtime value exports from tempo-sdk/canvas/index.ts.\nconst SDK_CANVAS_VALUE_EXPORTS = new Set([\n \"Canvas\",\n \"CanvasContext\",\n \"getCanvasStoryboardRenderId\",\n \"CanvasHost\",\n \"buildRenderContentFiberSelector\",\n \"buildRenderContentSelector\",\n \"buildRenderSelector\",\n \"captureStoryboardCombined\",\n \"captureStoryboardHtml\",\n \"captureStoryboardImage\",\n \"stripRenderContentWrapperAttributes\",\n \"stripRenderContentWrapperFromCombinedCapture\",\n \"watchStoryboardCombined\",\n \"getCanvasHostRuntime\",\n \"getOptionalCanvasHostRuntime\",\n \"useActiveState\",\n \"HtmlStoryboard\",\n \"LegacyStoryboardV1\",\n \"RouteStoryboard\",\n \"Storyboard\",\n \"StoryboardSlot\",\n]);\n\nconst DEFAULT_LAYOUT: ParsedCanvasLayout = {\n x: 0,\n y: 0,\n width: 600,\n height: 400,\n};\n\n/** Emitted when a file parses cleanly but declares no `<Canvas>` — for\n * readers that need to distinguish \"legacy page format\" from \"broken\". */\nexport const NO_CANVAS_DECLARATION_ERROR =\n \"No <Canvas> declaration found in canvas file\";\n\nexport function parseCanvasFile(\n filePath: string,\n source: string,\n): ParsedCanvasFile {\n const errors: CanvasParseError[] = [];\n let program: any;\n\n try {\n const result = parseSync(filePath, source) as any;\n program = result.program;\n for (const error of result.errors ?? []) {\n errors.push({\n message: error.message ?? \"Unable to parse canvas source\",\n span: toSpan(error) ?? toSpan(error?.labels?.[0]),\n kind: \"structural\",\n });\n }\n } catch (error) {\n return {\n filePath,\n pageName: fallbackPageName(filePath),\n imports: [],\n misimportedSdkCanvasImports: [],\n storyboards: [],\n errors: [\n {\n message:\n error instanceof Error\n ? error.message\n : \"Unable to parse canvas source\",\n kind: \"structural\",\n },\n ],\n };\n }\n\n const imports = readImports(program);\n const misimportedSdkCanvasImports = readMisimportedSdkCanvasImports(program);\n const { legacyObjects, stringBindings: objectStringBindings } =\n readObjectExpressionBindings(program, imports, source);\n let canvasElement: any | null = null;\n const allStoryboardElements: StoryboardElement[] = [];\n\n walk(program, (node) => {\n if (node.type !== \"JSXElement\") return;\n\n const component = resolveSdkComponent(node.openingElement?.name, imports);\n const namespaceMisimport = resolveMisimportedNamespaceSdkComponent(\n node.openingElement?.name,\n imports,\n misimportedSdkCanvasImports,\n );\n if (namespaceMisimport) {\n misimportedSdkCanvasImports.add(namespaceMisimport);\n }\n\n if (component === \"Canvas\") {\n if (!canvasElement) {\n canvasElement = node;\n } else {\n errors.push({\n message: \"Canvas file must declare exactly one <Canvas> element\",\n span: toSpan(node),\n kind: \"structural\",\n });\n }\n return;\n }\n\n if (isStoryboardSdkComponent(component)) {\n allStoryboardElements.push({ element: node, component });\n }\n });\n\n const directStoryboardElements = canvasElement\n ? readDirectCanvasStoryboardElements(canvasElement, imports)\n : [];\n const directStoryboardElementSet = new Set(\n directStoryboardElements.map((item) => item.element),\n );\n\n const storyboards = directStoryboardElements.map((item) =>\n readStoryboard(\n item.element,\n item.component,\n imports,\n legacyObjects,\n source,\n errors,\n ),\n );\n\n // Storyboard identity and layout only map faithfully when declarations are\n // direct Canvas children; anything else has no stable page-stack position.\n for (const item of allStoryboardElements) {\n if (directStoryboardElementSet.has(item.element)) continue;\n errors.push({\n message: `<${item.component}> declarations must be direct children of the <Canvas> element`,\n span: toSpan(item.element),\n kind: \"structural\",\n });\n }\n\n reportDuplicateStoryboardIds(storyboards, errors);\n\n if (!canvasElement) {\n if (misimportedSdkCanvasImports.all.length > 0) {\n for (const entry of misimportedSdkCanvasImports.all) {\n errors.push({\n message: misimportedSdkCanvasImportMessage(entry),\n span: entry.sourceSpan,\n kind: \"structural\",\n });\n }\n } else {\n errors.push({\n message: NO_CANVAS_DECLARATION_ERROR,\n kind: \"structural\",\n });\n }\n } else {\n errors.push(...validateCanvasChildren(canvasElement, imports));\n }\n\n const openingElement = canvasElement?.openingElement;\n const name = readResolvableStringAttribute(\n openingElement,\n \"name\",\n objectStringBindings,\n );\n const path = readStringAttribute(openingElement, \"path\");\n const backgroundColor =\n readResolvableStringAttribute(\n openingElement,\n \"backgroundColor\",\n objectStringBindings,\n ) ??\n readResolvableStringAttribute(\n openingElement,\n \"background\",\n objectStringBindings,\n );\n\n if (openingElement && !name) {\n errors.push({\n message: '<Canvas> must include a literal \"name\" prop',\n span: toSpan(openingElement),\n kind: \"degraded\",\n });\n }\n\n return {\n filePath,\n canvasPath: path?.value,\n pageName: name?.value ?? fallbackPageName(filePath),\n backgroundColor: backgroundColor?.value,\n canvasElementSpan: toSpan(canvasElement),\n canvasOpeningElementSpan: toSpan(openingElement),\n canvasChildrenInsertionOffset:\n typeof canvasElement?.closingElement?.start === \"number\"\n ? canvasElement.closingElement.start\n : undefined,\n nameSpan: name?.valueSpan,\n nameAttributeSpan: name?.attributeSpan,\n pathSpan: path?.valueSpan,\n pathAttributeSpan: path?.attributeSpan,\n backgroundColorSpan: backgroundColor?.valueSpan,\n backgroundColorAttributeSpan: backgroundColor?.attributeSpan,\n imports: imports.all,\n misimportedSdkCanvasImports: misimportedSdkCanvasImports.all,\n storyboards,\n errors,\n };\n}\n\ntype MutableMisimportedSdkCanvasImports = {\n all: MisimportedSdkCanvasImport[];\n byDeclarationKey: Map<string, MisimportedSdkCanvasImport>;\n namespaceCandidatesByLocalName: Map<string, MisimportedSdkCanvasImport>;\n add(entry: MisimportedSdkCanvasImport): void;\n};\n\nexport function misimportedSdkCanvasImportMessage(\n entry: MisimportedSdkCanvasImport,\n): string {\n return `Tempo canvas components must be imported from \"tempo-sdk/canvas\" — found import of ${entry.importedNames.join(\", \")} from \"${entry.source}\"`;\n}\n\nfunction readMisimportedSdkCanvasImports(\n program: any,\n): MutableMisimportedSdkCanvasImports {\n const all: MisimportedSdkCanvasImport[] = [];\n const byDeclarationKey = new Map<string, MisimportedSdkCanvasImport>();\n const namespaceCandidatesByLocalName = new Map<\n string,\n MisimportedSdkCanvasImport\n >();\n const add = (entry: MisimportedSdkCanvasImport) => {\n const key = spanKey(entry.sourceSpan);\n if (byDeclarationKey.has(key)) return;\n byDeclarationKey.set(key, entry);\n all.push(entry);\n };\n\n for (const statement of program?.body ?? []) {\n if (\n statement?.type !== \"ImportDeclaration\" ||\n typeof statement.source?.value !== \"string\" ||\n !isWrongTempoSdkCanvasImportSource(statement.source.value) ||\n statement.importKind === \"type\"\n ) {\n continue;\n }\n\n const source = statement.source.value;\n const sourceSpan = toSpan(statement.source);\n if (!sourceSpan) continue;\n\n const valueSpecifiers = (statement.specifiers ?? []).filter(\n (specifier: any) => specifier?.importKind !== \"type\",\n );\n const importedNames = valueSpecifiers.map(readImportedName);\n const entry: MisimportedSdkCanvasImport = {\n source,\n sourceSpan,\n importedNames,\n rewritable:\n valueSpecifiers.length > 0 &&\n valueSpecifiers.every(\n (specifier: any) =>\n specifier?.type === \"ImportSpecifier\" &&\n SDK_CANVAS_VALUE_EXPORTS.has(readImportedName(specifier)),\n ),\n };\n\n const hasMisimportedNamedSdkComponent = valueSpecifiers.some(\n (specifier: any) =>\n specifier?.type === \"ImportSpecifier\" &&\n SDK_COMPONENTS.has(readImportedName(specifier) as SdkComponent),\n );\n if (hasMisimportedNamedSdkComponent) {\n add(entry);\n }\n\n for (const specifier of valueSpecifiers) {\n if (specifier?.type !== \"ImportNamespaceSpecifier\") continue;\n const localName = specifier.local?.name;\n if (typeof localName === \"string\") {\n namespaceCandidatesByLocalName.set(localName, entry);\n }\n }\n }\n\n return { all, byDeclarationKey, namespaceCandidatesByLocalName, add };\n}\n\nfunction readImports(program: any): ParsedImports {\n const all: ParsedCanvasImport[] = [];\n const byLocalName = new Map<string, ParsedCanvasImport>();\n const sdkLocalNames = new Map<string, SdkComponent>();\n const sdkNamespaces = new Set<string>();\n\n for (const statement of program?.body ?? []) {\n if (\n statement?.type !== \"ImportDeclaration\" ||\n typeof statement.source?.value !== \"string\"\n ) {\n continue;\n }\n\n const source = statement.source.value;\n const isSdkImport = isSdkImportSource(source);\n\n for (const specifier of statement.specifiers ?? []) {\n const localName = specifier.local?.name;\n if (typeof localName !== \"string\") continue;\n\n const importedName = readImportedName(specifier);\n const imported: ParsedCanvasImport = {\n localName,\n source,\n importedName,\n kind: readImportKind(specifier),\n importKind: specifier.importKind === \"type\" ? \"type\" : \"value\",\n span: toSpan(specifier) ?? toSpan(statement) ?? { start: 0, end: 0 },\n declarationSpan: toSpan(statement) ?? { start: 0, end: 0 },\n specifierCount: statement.specifiers?.length ?? 0,\n namedSpecifierCount: (statement.specifiers ?? []).filter(\n (item: any) => item?.type === \"ImportSpecifier\",\n ).length,\n hasDefaultSpecifier: (statement.specifiers ?? []).some(\n (item: any) => item?.type === \"ImportDefaultSpecifier\",\n ),\n hasNamespaceSpecifier: (statement.specifiers ?? []).some(\n (item: any) => item?.type === \"ImportNamespaceSpecifier\",\n ),\n };\n\n all.push(imported);\n byLocalName.set(localName, imported);\n\n if (!isSdkImport) continue;\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n sdkNamespaces.add(localName);\n continue;\n }\n\n if (SDK_COMPONENTS.has(importedName as SdkComponent)) {\n sdkLocalNames.set(localName, importedName as SdkComponent);\n }\n }\n }\n\n return { all, byLocalName, sdkLocalNames, sdkNamespaces };\n}\n\nfunction readObjectExpressionBindings(\n program: any,\n imports: ParsedImports,\n source: string,\n): {\n legacyObjects: Map<string, ParsedLegacyStoryboardObject>;\n stringBindings: ObjectStringBindings;\n} {\n const legacyObjects = new Map<string, ParsedLegacyStoryboardObject>();\n const stringBindings: ObjectStringBindings = new Map();\n\n // Canvas metadata and legacy storyboard objects are module-level authoring\n // contracts; function-local shadowing must not change parsed identities.\n for (const node of readTopLevelVariableDeclarators(program)) {\n if (node.id?.type !== \"Identifier\") {\n continue;\n }\n const objectExpression = unwrapTsExpression(node.init);\n if (objectExpression?.type !== \"ObjectExpression\") continue;\n\n const bindingName = node.id.name;\n legacyObjects.set(\n bindingName,\n readLegacyStoryboardObject(\n bindingName,\n objectExpression,\n imports,\n source,\n ),\n );\n\n const stringProperties = readObjectStringProperties(objectExpression);\n if (stringProperties.size > 0) {\n stringBindings.set(bindingName, stringProperties);\n }\n }\n\n return { legacyObjects, stringBindings };\n}\n\nfunction readTopLevelVariableDeclarators(program: any): any[] {\n const declarators: any[] = [];\n\n for (const statement of program?.body ?? []) {\n const declaration =\n statement?.type === \"VariableDeclaration\"\n ? statement\n : statement?.type === \"ExportNamedDeclaration\" &&\n statement.declaration?.type === \"VariableDeclaration\"\n ? statement.declaration\n : null;\n if (!declaration) continue;\n declarators.push(...(declaration.declarations ?? []));\n }\n\n return declarators;\n}\n\nfunction readLegacyStoryboardObject(\n bindingName: string,\n objectExpression: any,\n imports: ParsedImports,\n source: string,\n): ParsedLegacyStoryboardObject {\n const errors: CanvasParseError[] = [];\n const nameProperty = getObjectProperty(objectExpression, \"name\");\n const name = nameProperty ? readStringLiteralValue(nameProperty.value) : null;\n const layoutProperty = getObjectProperty(objectExpression, \"layout\");\n const layout: {\n value: ParsedCanvasLayout;\n spans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n } = layoutProperty\n ? readLayoutExpression(layoutProperty.value, \"LegacyStoryboardV1\")\n : {\n value: DEFAULT_LAYOUT,\n errors: [\n {\n message:\n '<LegacyStoryboardV1> storyboard object must include a literal \"layout\" object',\n span: toSpan(objectExpression),\n kind: \"degraded\",\n },\n ],\n };\n const renderProperty = getObjectProperty(objectExpression, \"render\");\n const component = readRenderComponentReference(\n renderProperty?.value,\n imports,\n source,\n );\n\n if (nameProperty && !name) {\n errors.push({\n message:\n \"<LegacyStoryboardV1> storyboard.name must be a string literal when set\",\n span: toSpan(nameProperty),\n kind: \"degraded\",\n });\n }\n errors.push(...layout.errors);\n\n return {\n bindingName,\n displayName: name?.value,\n component: component ?? undefined,\n objectSpan: toSpan(objectExpression),\n objectClose: readLayoutClose(objectExpression),\n nameSpan: name?.span,\n namePropertySpan: toSpan(nameProperty),\n layoutPropertySpan: toSpan(layoutProperty),\n layout: layout.value,\n layoutSpans: layout.spans,\n errors,\n };\n}\n\nfunction readObjectStringProperties(\n objectExpression: any,\n): Map<string, { value: string; span: CanvasSourceSpan }> {\n const properties = new Map<\n string,\n { value: string; span: CanvasSourceSpan }\n >();\n for (const property of objectExpression.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) continue;\n const propertyName = readPropertyKeyName(property.key);\n const value = readStringLiteralValue(property.value);\n if (!propertyName || !value) continue;\n properties.set(propertyName, value);\n }\n return properties;\n}\n\nfunction readStoryboard(\n element: any,\n component: Exclude<SdkComponent, \"Canvas\">,\n imports: ParsedImports,\n legacyObjects: Map<string, ParsedLegacyStoryboardObject>,\n source: string,\n globalErrors: CanvasParseError[],\n): ParsedCanvasStoryboard {\n const openingElement = element.openingElement;\n const errors: CanvasParseError[] = [];\n const id = readStringAttribute(openingElement, \"id\");\n const name = readStringAttribute(openingElement, \"name\");\n const legacyReference =\n component === \"LegacyStoryboardV1\"\n ? readExpressionReference(openingElement, \"storyboard\", source)\n : undefined;\n const legacyObject =\n legacyReference?.expression &&\n isIdentifierExpression(legacyReference.expression)\n ? legacyObjects.get(legacyReference.expression)\n : undefined;\n const layout =\n component === \"LegacyStoryboardV1\"\n ? {\n value: legacyObject?.layout ?? DEFAULT_LAYOUT,\n spans: legacyObject?.layoutSpans,\n attributeSpan: undefined,\n errors:\n legacyObject?.errors ??\n (legacyReference\n ? [\n {\n message:\n \"<LegacyStoryboardV1> storyboard prop must reference a same-file object literal\",\n span: legacyReference.span,\n kind: \"degraded\",\n },\n ]\n : [\n {\n message:\n '<LegacyStoryboardV1> must include a \"storyboard\" expression prop',\n span: toSpan(openingElement),\n kind: \"degraded\",\n },\n ]),\n }\n : readLayout(openingElement, component);\n const kind =\n component === \"Storyboard\" ||\n component === \"SvelteStoryboard\" ||\n component === \"LegacyStoryboardV1\"\n ? \"component\"\n : component === \"RouteStoryboard\"\n ? \"route\"\n : \"html\";\n\n if (!id) {\n errors.push({\n message: `<${component}> must include a literal \"id\" prop`,\n span: toSpan(openingElement),\n kind: \"structural\",\n });\n }\n\n if (layout.errors.length > 0) {\n errors.push(...layout.errors);\n }\n\n const storyboard: ParsedCanvasStoryboard = {\n storyboardKey: id?.value ?? \"\",\n displayName: name?.value ?? legacyObject?.displayName,\n kind,\n ...(component === \"SvelteStoryboard\"\n ? { uiFramework: \"svelte\" as const }\n : {}),\n layout: layout.value,\n editable: Boolean(id) && layout.errors.length === 0,\n jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },\n openingElementSpan: toSpan(openingElement),\n idSpan: id?.valueSpan,\n idAttributeSpan: id?.attributeSpan,\n nameSpan: name?.valueSpan ?? legacyObject?.nameSpan,\n nameAttributeSpan: name?.attributeSpan ?? legacyObject?.namePropertySpan,\n layoutAttributeSpan: layout.attributeSpan,\n layoutSpans: layout.spans,\n props: readExpressionReference(openingElement, \"props\", source),\n component: legacyObject?.component,\n legacyV1: legacyReference\n ? {\n storyboard: legacyReference,\n objectName: legacyObject?.bindingName,\n objectSpan: legacyObject?.objectSpan,\n objectClose: legacyObject?.objectClose,\n namePropertySpan: legacyObject?.namePropertySpan,\n layoutPropertySpan: legacyObject?.layoutPropertySpan,\n }\n : undefined,\n errors,\n };\n\n if (component === \"Storyboard\" || component === \"SvelteStoryboard\") {\n const componentReference = readComponentReference(\n openingElement,\n imports,\n source,\n );\n if (componentReference) {\n storyboard.component = componentReference;\n } else {\n errors.push({\n message: `<${component}> must include a \"component\" expression prop`,\n span: toSpan(openingElement),\n kind: \"degraded\",\n });\n }\n\n const vrt = readVrt(openingElement, errors);\n if (vrt) {\n if (vrt.value) {\n storyboard.vrt = vrt.value;\n }\n storyboard.vrtAttributeSpan = vrt.attributeSpan;\n }\n }\n\n if (component === \"RouteStoryboard\") {\n const route = readStringAttribute(openingElement, \"route\");\n if (route) {\n storyboard.route = route.value;\n storyboard.routeSpan = route.valueSpan;\n storyboard.routeAttributeSpan = route.attributeSpan;\n } else {\n errors.push({\n message: '<RouteStoryboard> must include a literal \"route\" prop',\n span: toSpan(openingElement),\n kind: \"degraded\",\n });\n }\n }\n\n if (component === \"HtmlStoryboard\") {\n const filepath = readStringAttribute(openingElement, \"filepath\");\n const src = readStringAttribute(openingElement, \"src\");\n storyboard.filepath = filepath?.value;\n storyboard.filepathSpan = filepath?.valueSpan;\n storyboard.filepathAttributeSpan = filepath?.attributeSpan;\n storyboard.src = src?.value;\n storyboard.srcSpan = src?.valueSpan;\n storyboard.srcAttributeSpan = src?.attributeSpan;\n if (!filepath && !src) {\n errors.push({\n message:\n '<HtmlStoryboard> must include a literal \"filepath\" or \"src\" prop',\n span: toSpan(openingElement),\n kind: \"degraded\",\n });\n }\n }\n\n globalErrors.push(...errors);\n return storyboard;\n}\n\nfunction readDirectCanvasStoryboardElements(\n canvasElement: any,\n imports: ParsedImports,\n): StoryboardElement[] {\n const elements: StoryboardElement[] = [];\n\n for (const child of canvasElement.children ?? []) {\n if (child?.type !== \"JSXElement\") continue;\n const component = resolveSdkComponent(child.openingElement?.name, imports);\n if (isStoryboardSdkComponent(component)) {\n elements.push({ element: child, component });\n }\n }\n\n return elements;\n}\n\nfunction reportDuplicateStoryboardIds(\n storyboards: ParsedCanvasStoryboard[],\n errors: CanvasParseError[],\n) {\n const byId = new Map<string, ParsedCanvasStoryboard[]>();\n\n for (const storyboard of storyboards) {\n if (!storyboard.storyboardKey) continue;\n const matching = byId.get(storyboard.storyboardKey);\n if (matching) {\n matching.push(storyboard);\n } else {\n byId.set(storyboard.storyboardKey, [storyboard]);\n }\n }\n\n for (const [storyboardKey, matching] of byId) {\n if (matching.length < 2) continue;\n errors.push({\n message: `Duplicate storyboard id \"${storyboardKey}\" (${matching.length} declarations) — storyboard ids must be unique`,\n span: matching[1]?.jsxElementSpan,\n kind: \"structural\",\n });\n }\n}\n\nfunction validateCanvasChildren(\n canvasElement: any,\n imports: ParsedImports,\n): CanvasParseError[] {\n const errors: CanvasParseError[] = [];\n\n for (const child of canvasElement.children ?? []) {\n if (!child) continue;\n if (child.type === \"JSXText\") {\n if (typeof child.value === \"string\" && child.value.trim() === \"\") {\n continue;\n }\n }\n if (child.type === \"JSXExpressionContainer\") {\n if (child.expression?.type === \"JSXEmptyExpression\") {\n continue;\n }\n errors.push({\n message:\n \"<Canvas> children must be static storyboard declarations, not expressions\",\n span: toSpan(child),\n kind: \"structural\",\n });\n continue;\n }\n if (child.type === \"JSXElement\") {\n const component = resolveSdkComponent(\n child.openingElement?.name,\n imports,\n );\n if (\n component === \"Storyboard\" ||\n component === \"SvelteStoryboard\" ||\n component === \"LegacyStoryboardV1\" ||\n component === \"RouteStoryboard\" ||\n component === \"HtmlStoryboard\"\n ) {\n continue;\n }\n }\n errors.push({\n message:\n \"<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations\",\n span: toSpan(child),\n kind: \"structural\",\n });\n }\n\n return errors;\n}\n\n/**\n * Reads the opt-in `vrt` prop on a `<Storyboard>` (TEM-1775). Only statically\n * analyzable literal shapes are tracked — the mark is a build-time manifest,\n * so a dynamic expression is a degraded parse error, never a guess:\n * `vrt` / `vrt={true}` → tracked with defaults ({})\n * `vrt={false}` → untracked (absent)\n * `vrt={{ threshold, skip, ignore }}` → tracked with overrides\n */\nfunction readVrt(\n openingElement: any,\n errors: CanvasParseError[],\n): {\n /** Null when the attribute exists but reads as untracked (`vrt={false}`,\n * dynamic / malformed forms). The span stays so editors can target the\n * declaration without inserting a duplicate. */\n value: ParsedStoryboardVrt | null;\n attributeSpan?: CanvasSourceSpan;\n} | null {\n const attribute = getAttribute(openingElement, \"vrt\");\n if (!attribute) return null;\n const attributeSpan = toSpan(attribute);\n\n // Bare `vrt` (no value) — tracked with defaults.\n if (attribute.value == null) {\n return { value: {}, attributeSpan };\n }\n\n const expression = unwrapTsExpression(\n unwrapAttributeExpression(attribute.value),\n );\n if (expression?.type === \"Literal\" && expression.value === true) {\n return { value: {}, attributeSpan };\n }\n if (expression?.type === \"Literal\" && expression.value === false) {\n return { value: null, attributeSpan };\n }\n if (expression?.type !== \"ObjectExpression\") {\n errors.push({\n message:\n '<Storyboard> vrt must be a boolean literal or an object literal ({ threshold?, skip?, ignore? })',\n span: toSpan(expression) ?? attributeSpan,\n kind: \"degraded\",\n });\n return { value: null, attributeSpan };\n }\n\n const value: ParsedStoryboardVrt = {};\n for (const property of expression.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) {\n errors.push({\n message: \"<Storyboard> vrt must contain only literal properties\",\n span: toSpan(property ?? expression),\n kind: \"degraded\",\n });\n continue;\n }\n const key = readPropertyKeyName(property.key);\n if (key === \"threshold\") {\n // Capped at 0.5: beyond that pixelmatch is effectively blind and the\n // \"tracked\" mark would be a lie — black→white passes at threshold 1.\n const threshold = readNumberLiteral(property.value);\n if (threshold && threshold.value >= 0 && threshold.value <= 0.5) {\n value.threshold = threshold.value;\n } else {\n errors.push({\n message:\n \"<Storyboard> vrt.threshold must be a number literal between 0 and 0.5\",\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n continue;\n }\n if (key === \"skip\") {\n if (\n property.value?.type === \"Literal\" &&\n typeof property.value.value === \"boolean\"\n ) {\n if (property.value.value) value.skip = true;\n } else {\n errors.push({\n message: \"<Storyboard> vrt.skip must be a boolean literal\",\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n continue;\n }\n if (key === \"ignore\") {\n const regions = readVrtIgnoreRegions(property.value, errors);\n if (regions) value.ignore = regions;\n continue;\n }\n errors.push({\n message: `<Storyboard> vrt has unknown property \"${key ?? \"?\"}\" — expected threshold, skip, or ignore`,\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n\n return { value, attributeSpan };\n}\n\nfunction readVrtIgnoreRegions(\n node: any,\n errors: CanvasParseError[],\n): ParsedStoryboardVrtIgnoreRegion[] | null {\n if (node?.type !== \"ArrayExpression\") {\n errors.push({\n message:\n \"<Storyboard> vrt.ignore must be an array of { x, y, w, h } literals\",\n span: toSpan(node),\n kind: \"degraded\",\n });\n return null;\n }\n const regions: ParsedStoryboardVrtIgnoreRegion[] = [];\n for (const element of node.elements ?? []) {\n const region: Partial<ParsedStoryboardVrtIgnoreRegion> = {};\n for (const key of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const property = getObjectProperty(element, key);\n const number = property ? readNumberLiteral(property.value) : null;\n if (number) region[key] = number.value;\n }\n if (\n region.x === undefined ||\n region.y === undefined ||\n region.w === undefined ||\n region.h === undefined\n ) {\n errors.push({\n message:\n \"<Storyboard> vrt.ignore regions must be { x, y, w, h } number literals\",\n span: toSpan(element) ?? toSpan(node),\n kind: \"degraded\",\n });\n return null;\n }\n regions.push(region as ParsedStoryboardVrtIgnoreRegion);\n }\n return regions;\n}\n\nfunction readComponentReference(\n openingElement: any,\n imports: ParsedImports,\n source: string,\n): ParsedCanvasComponentReference | null {\n const attribute = getAttribute(openingElement, \"component\");\n const expression = unwrapAttributeExpression(attribute?.value);\n const span = toSpan(expression);\n if (!expression || !span) return null;\n\n const localName =\n expression.type === \"Identifier\"\n ? expression.name\n : expression.type === \"MemberExpression\" &&\n expression.object?.type === \"Identifier\"\n ? expression.object.name\n : undefined;\n\n return {\n expression: source.slice(span.start, span.end),\n span,\n attributeSpan: toSpan(attribute),\n localName,\n import: localName ? imports.byLocalName.get(localName) : undefined,\n };\n}\n\nfunction readRenderComponentReference(\n renderValue: any,\n imports: ParsedImports,\n source: string,\n): ParsedCanvasComponentReference | null {\n if (renderValue?.type !== \"ArrowFunctionExpression\") return null;\n const body = unwrapTsExpression(renderValue.body);\n if (body?.type !== \"JSXElement\") return null;\n const name = body.openingElement?.name;\n if (name?.type !== \"JSXIdentifier\") return null;\n\n const span = toSpan(name);\n if (!span || typeof name.name !== \"string\") return null;\n\n return {\n expression: source.slice(span.start, span.end),\n span,\n localName: name.name,\n import: imports.byLocalName.get(name.name),\n };\n}\n\nfunction readExpressionReference(\n openingElement: any,\n name: string,\n source: string,\n): ParsedCanvasExpressionReference | undefined {\n const attribute = getAttribute(openingElement, name);\n const expression = unwrapAttributeExpression(attribute?.value);\n const span = toSpan(expression);\n if (!expression || !span) return undefined;\n return {\n expression: source.slice(span.start, span.end),\n span,\n attributeSpan: toSpan(attribute),\n };\n}\n\nfunction isIdentifierExpression(expression: string): boolean {\n return /^[A-Za-z_$][\\w$]*$/.test(expression);\n}\n\nfunction readLayout(\n openingElement: any,\n componentName: string,\n): {\n value: ParsedCanvasLayout;\n attributeSpan?: CanvasSourceSpan;\n spans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n} {\n const errors: CanvasParseError[] = [];\n const attribute = getAttribute(openingElement, \"layout\");\n const expression = unwrapAttributeExpression(attribute?.value);\n\n if (!expression) {\n return {\n value: DEFAULT_LAYOUT,\n attributeSpan: toSpan(attribute),\n errors: [\n {\n message: `<${componentName}> must include a literal \"layout\" object prop`,\n span: toSpan(openingElement),\n kind: \"degraded\",\n },\n ],\n };\n }\n\n const layout = readLayoutExpression(expression, componentName);\n return {\n ...layout,\n attributeSpan: toSpan(attribute),\n };\n}\n\nfunction readLayoutExpression(\n expression: any,\n componentName: string,\n): {\n value: ParsedCanvasLayout;\n spans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n} {\n const errors: CanvasParseError[] = [];\n\n if (expression.type !== \"ObjectExpression\") {\n return {\n value: DEFAULT_LAYOUT,\n spans: { layoutClose: readLayoutClose(expression) },\n errors: [\n {\n message: `<${componentName}> layout must be an object literal`,\n span: toSpan(expression),\n kind: \"degraded\",\n },\n ],\n };\n }\n\n const spans: ParsedCanvasLayoutSpans = {\n layoutClose: readLayoutClose(expression),\n };\n const layout: ParsedCanvasLayout = { ...DEFAULT_LAYOUT };\n\n for (const key of [\"x\", \"y\", \"width\", \"height\"] as const) {\n const property = getObjectProperty(expression, key);\n const value = property ? readNumberLiteral(property.value) : null;\n if (value) {\n layout[key] = value.value;\n spans[key] = value.span;\n } else {\n errors.push({\n message: `<${componentName}> layout.${key} must be a number literal`,\n span: toSpan(property ?? expression),\n kind: \"degraded\",\n });\n }\n }\n\n const zIndex = getObjectProperty(expression, \"zIndex\");\n if (zIndex) {\n const value = readNumberLiteral(zIndex.value);\n if (value) {\n layout.zIndex = value.value;\n spans.zIndex = value.span;\n } else {\n errors.push({\n message: `<${componentName}> layout.zIndex must be a number literal`,\n span: toSpan(zIndex),\n kind: \"degraded\",\n });\n }\n }\n\n const intrinsicSizing = getObjectProperty(expression, \"intrinsicSizing\");\n if (intrinsicSizing) {\n if (\n intrinsicSizing.value?.type === \"Literal\" &&\n intrinsicSizing.value.value === \"root-element\"\n ) {\n layout.intrinsicSizing = \"root-element\";\n spans.intrinsicSizing = toSpan(intrinsicSizing.value);\n } else {\n errors.push({\n message: `<${componentName}> layout.intrinsicSizing must be \"root-element\" when set`,\n span: toSpan(intrinsicSizing),\n kind: \"degraded\",\n });\n }\n }\n\n return { value: layout, spans, errors };\n}\n\nfunction readStringLiteralValue(\n node: any,\n): { value: string; span: CanvasSourceSpan } | null {\n return node?.type === \"Literal\" && typeof node.value === \"string\"\n ? { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } }\n : null;\n}\n\nexport function unwrapTsExpression(node: any): any {\n let current = node;\n while (\n current?.type === \"TSSatisfiesExpression\" ||\n current?.type === \"TSAsExpression\" ||\n current?.type === \"TSNonNullExpression\" ||\n current?.type === \"ParenthesizedExpression\"\n ) {\n current = current.expression;\n }\n return current;\n}\n\nfunction readResolvableStringAttribute(\n openingElement: any,\n name: string,\n bindings: ObjectStringBindings,\n): {\n value: string;\n valueSpan: CanvasSourceSpan;\n attributeSpan: CanvasSourceSpan;\n} | null {\n const literal = readStringAttribute(openingElement, name);\n if (literal) return literal;\n\n const attribute = getAttribute(openingElement, name);\n const expression = unwrapAttributeExpression(attribute?.value);\n const expressionSpan = toSpan(expression);\n const attributeSpan = toSpan(attribute);\n if (!expression || !expressionSpan || !attributeSpan) return null;\n\n const resolved = resolveStringMemberExpression(expression, bindings);\n return resolved\n ? {\n value: resolved.value,\n valueSpan: expressionSpan,\n attributeSpan,\n }\n : null;\n}\n\nfunction resolveStringMemberExpression(\n expression: any,\n bindings: ObjectStringBindings,\n): { value: string; span: CanvasSourceSpan } | null {\n if (expression?.type !== \"MemberExpression\") return null;\n if (expression.object?.type !== \"Identifier\") return null;\n const propertyName = readPropertyKeyName(expression.property);\n if (!propertyName) return null;\n return bindings.get(expression.object.name)?.get(propertyName) ?? null;\n}\n\nfunction readStringAttribute(\n openingElement: any,\n name: string,\n): {\n value: string;\n valueSpan: CanvasSourceSpan;\n attributeSpan: CanvasSourceSpan;\n} | null {\n const attribute = getAttribute(openingElement, name);\n if (!attribute) return null;\n\n const value = attribute.value;\n if (value?.type === \"Literal\" && typeof value.value === \"string\") {\n return {\n value: value.value,\n valueSpan: toSpan(value) ?? toSpan(attribute) ?? { start: 0, end: 0 },\n attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 },\n };\n }\n\n const expression = unwrapAttributeExpression(value);\n if (expression?.type === \"Literal\" && typeof expression.value === \"string\") {\n return {\n value: expression.value,\n valueSpan: toSpan(expression) ??\n toSpan(attribute) ?? { start: 0, end: 0 },\n attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 },\n };\n }\n return null;\n}\n\nfunction getAttribute(openingElement: any, name: string): any | null {\n for (const attribute of openingElement?.attributes ?? []) {\n if (\n attribute?.type === \"JSXAttribute\" &&\n attribute.name?.type === \"JSXIdentifier\" &&\n attribute.name.name === name\n ) {\n return attribute;\n }\n }\n return null;\n}\n\nfunction unwrapAttributeExpression(value: any): any | null {\n if (!value) return null;\n if (value.type === \"JSXExpressionContainer\") {\n return value.expression;\n }\n return value;\n}\n\nfunction readPropertyKeyName(key: any): string | null {\n if (key?.type === \"Identifier\") return key.name;\n if (key?.type === \"Literal\" && typeof key.value === \"string\") {\n return key.value;\n }\n return null;\n}\n\nfunction getObjectProperty(objectExpression: any, name: string): any | null {\n if (objectExpression?.type !== \"ObjectExpression\") return null;\n for (const property of objectExpression.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) continue;\n const propertyName = readPropertyKeyName(property.key);\n if (propertyName === name) return property;\n }\n return null;\n}\n\nfunction readNumberLiteral(\n node: any,\n): { value: number; span: CanvasSourceSpan } | null {\n if (\n node?.type === \"Literal\" &&\n typeof node.value === \"number\" &&\n Number.isFinite(node.value)\n ) {\n return { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } };\n }\n\n if (\n node?.type === \"UnaryExpression\" &&\n node.operator === \"-\" &&\n node.argument?.type === \"Literal\" &&\n typeof node.argument.value === \"number\" &&\n Number.isFinite(node.argument.value)\n ) {\n return {\n value: -node.argument.value,\n span: toSpan(node) ?? { start: 0, end: 0 },\n };\n }\n\n return null;\n}\n\nfunction resolveSdkComponent(\n nameNode: any,\n imports: ParsedImports,\n): SdkComponent | null {\n if (nameNode?.type === \"JSXIdentifier\") {\n return imports.sdkLocalNames.get(nameNode.name) ?? null;\n }\n\n if (\n nameNode?.type === \"JSXMemberExpression\" &&\n nameNode.object?.type === \"JSXIdentifier\" &&\n nameNode.property?.type === \"JSXIdentifier\" &&\n imports.sdkNamespaces.has(nameNode.object.name) &&\n SDK_COMPONENTS.has(nameNode.property.name as SdkComponent)\n ) {\n return nameNode.property.name as SdkComponent;\n }\n\n return null;\n}\n\nfunction resolveMisimportedNamespaceSdkComponent(\n nameNode: any,\n imports: ParsedImports,\n misimportedSdkCanvasImports: MutableMisimportedSdkCanvasImports,\n): MisimportedSdkCanvasImport | null {\n if (\n nameNode?.type !== \"JSXMemberExpression\" ||\n nameNode.object?.type !== \"JSXIdentifier\" ||\n nameNode.property?.type !== \"JSXIdentifier\" ||\n !SDK_COMPONENTS.has(nameNode.property.name as SdkComponent)\n ) {\n return null;\n }\n\n const imported = imports.byLocalName.get(nameNode.object.name);\n if (\n imported?.kind !== \"namespace\" ||\n !isWrongTempoSdkCanvasImportSource(imported.source)\n ) {\n return null;\n }\n\n return (\n misimportedSdkCanvasImports.namespaceCandidatesByLocalName.get(\n nameNode.object.name,\n ) ?? null\n );\n}\n\nfunction isStoryboardSdkComponent(\n component: SdkComponent | null,\n): component is StoryboardSdkComponent {\n return (\n component === \"Storyboard\" ||\n component === \"SvelteStoryboard\" ||\n component === \"LegacyStoryboardV1\" ||\n component === \"RouteStoryboard\" ||\n component === \"HtmlStoryboard\"\n );\n}\n\nfunction readImportedName(specifier: any): string {\n if (specifier.type === \"ImportDefaultSpecifier\") return \"default\";\n if (specifier.type === \"ImportNamespaceSpecifier\") return \"*\";\n return specifier.imported?.name ?? specifier.local?.name ?? \"unknown\";\n}\n\nfunction readImportKind(specifier: any): ParsedCanvasImport[\"kind\"] {\n if (specifier.type === \"ImportDefaultSpecifier\") return \"default\";\n if (specifier.type === \"ImportNamespaceSpecifier\") return \"namespace\";\n return \"named\";\n}\n\nfunction isSdkImportSource(source: string): boolean {\n return (\n SDK_IMPORT_SOURCES.has(source) ||\n source.endsWith(\"/tempo-sdk/canvas\") ||\n source.endsWith(\"/tempo-sdk/canvas/svelte\")\n );\n}\n\nfunction isWrongTempoSdkCanvasImportSource(source: string): boolean {\n return (\n (source === \"tempo-sdk\" || source.startsWith(\"tempo-sdk/\")) &&\n !isSdkImportSource(source)\n );\n}\n\nfunction spanKey(span: CanvasSourceSpan): string {\n return `${span.start}:${span.end}`;\n}\n\nfunction readLayoutClose(node: any): number | undefined {\n return typeof node?.end === \"number\" && Number.isFinite(node.end)\n ? node.end - 1\n : undefined;\n}\n\nexport function fallbackPageName(filePath: string): string {\n const normalized = filePath.replace(/\\\\/g, \"/\");\n const segments = normalized.split(\"/\").filter(Boolean);\n const fileName =\n segments.length > 0 ? segments[segments.length - 1] : filePath;\n const parentName =\n segments.length > 1 ? segments[segments.length - 2] : fileName;\n const baseName = /^index\\.canvas\\.[tj]sx?$/.test(fileName)\n ? parentName\n : fileName.replace(/\\.canvas\\.[tj]sx?$/, \"\");\n\n return baseName\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n}\n\nfunction toSpan(node: any): CanvasSourceSpan | undefined {\n return typeof node?.start === \"number\" &&\n Number.isFinite(node.start) &&\n typeof node?.end === \"number\" &&\n Number.isFinite(node.end)\n ? { start: node.start, end: node.end }\n : undefined;\n}\n\nfunction walk(node: any, visitor: (node: any) => void, seen = new Set<any>()) {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n visitor(node);\n\n for (const value of Object.values(node)) {\n if (!value) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n walk(item, visitor, seen);\n }\n } else if (typeof value === \"object\") {\n walk(value, visitor, seen);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AA4M1B,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAiB,oBAAI,IAAkB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,2BAA2B,oBAAI,IAAI;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAqC;AAAA,EACzC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO;AAAA,EACP,QAAQ;AACV;AAIO,IAAM,8BACX;AAEK,SAAS,gBACd,UACA,QACkB;AAClB,QAAM,SAA6B,CAAC;AACpC,MAAI;AAEJ,MAAI;AACF,UAAM,SAAS,UAAU,UAAU,MAAM;AACzC,cAAU,OAAO;AACjB,eAAW,SAAS,OAAO,UAAU,CAAC,GAAG;AACvC,aAAO,KAAK;AAAA,QACV,SAAS,MAAM,WAAW;AAAA,QAC1B,MAAM,OAAO,KAAK,KAAK,OAAO,O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