tempo-sdk 0.0.60 → 0.0.66

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 (108) hide show
  1. package/astro/client.d.ts +4 -0
  2. package/dist/assets/editor.js +1 -1
  3. package/dist/assets/index.d.ts +10 -63
  4. package/dist/assets/index.js +12 -32
  5. package/dist/assets/index.js.map +1 -1
  6. package/dist/assets/parser.js +1 -1
  7. package/dist/astro/asset-preview-client.d.ts +4 -0
  8. package/dist/astro/asset-preview-client.js +93 -0
  9. package/dist/astro/asset-preview-client.js.map +1 -0
  10. package/dist/astro/controls.d.ts +7 -0
  11. package/dist/astro/controls.js +7 -0
  12. package/dist/astro/controls.js.map +1 -0
  13. package/dist/astro/document-client.d.ts +10 -0
  14. package/dist/astro/document-client.js +78 -0
  15. package/dist/astro/document-client.js.map +1 -0
  16. package/dist/astro/runtime.d.ts +15 -0
  17. package/dist/astro/runtime.js +86 -0
  18. package/dist/astro/runtime.js.map +1 -0
  19. package/dist/astro.d.ts +21 -0
  20. package/dist/astro.js +749 -0
  21. package/dist/astro.js.map +1 -0
  22. package/dist/canvas/astro-contract.d.ts +21 -0
  23. package/dist/canvas/astro-contract.js +9 -0
  24. package/dist/canvas/astro-contract.js.map +1 -0
  25. package/dist/canvas/astro.d.ts +18 -0
  26. package/dist/canvas/astro.js +42 -0
  27. package/dist/canvas/astro.js.map +1 -0
  28. package/dist/canvas/editor.d.ts +1 -1
  29. package/dist/canvas/editor.js +3 -2
  30. package/dist/canvas/editor.js.map +1 -1
  31. package/dist/canvas/index.d.ts +1 -1
  32. package/dist/canvas/index.js +40 -16
  33. package/dist/canvas/index.js.map +1 -1
  34. package/dist/canvas/interact-projection.js +4 -4
  35. package/dist/canvas/parser.d.ts +3 -1
  36. package/dist/canvas/parser.js +1 -1
  37. package/dist/canvas/svelte.d.ts +1 -1
  38. package/dist/canvas/svelte.js +3 -3
  39. package/dist/{chunk-5BHIHP25.js → chunk-2JRAG36X.js} +37 -11
  40. package/dist/chunk-2JRAG36X.js.map +1 -0
  41. package/dist/{chunk-N2TYN3RB.js → chunk-6AAE4LYV.js} +123 -123
  42. package/dist/chunk-6AAE4LYV.js.map +1 -0
  43. package/dist/{chunk-7DT5DDSH.js → chunk-6IR5JY6W.js} +106 -7
  44. package/dist/chunk-6IR5JY6W.js.map +1 -0
  45. package/dist/{chunk-FQSZRVSL.js → chunk-6W6UKDSY.js} +45 -4
  46. package/dist/chunk-6W6UKDSY.js.map +1 -0
  47. package/dist/chunk-77DZCV5Z.js +38 -0
  48. package/dist/chunk-77DZCV5Z.js.map +1 -0
  49. package/dist/chunk-DELFOKU3.js +2495 -0
  50. package/dist/chunk-DELFOKU3.js.map +1 -0
  51. package/dist/{chunk-MXKZZOLM.js → chunk-EYKOOLPL.js} +368 -32
  52. package/dist/chunk-EYKOOLPL.js.map +1 -0
  53. package/dist/chunk-F23JGM4U.js +107 -0
  54. package/dist/chunk-F23JGM4U.js.map +1 -0
  55. package/dist/chunk-FE6TYCLF.js +1514 -0
  56. package/dist/chunk-FE6TYCLF.js.map +1 -0
  57. package/dist/chunk-H6OZIX2U.js +133 -0
  58. package/dist/chunk-H6OZIX2U.js.map +1 -0
  59. package/dist/chunk-JVVHU3A7.js +1077 -0
  60. package/dist/chunk-JVVHU3A7.js.map +1 -0
  61. package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
  62. package/dist/chunk-KOSJXE4G.js.map +1 -0
  63. package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
  64. package/dist/chunk-NSKYOKG5.js.map +1 -0
  65. package/dist/chunk-OX2YKYSL.js +13 -0
  66. package/dist/chunk-OX2YKYSL.js.map +1 -0
  67. package/dist/{chunk-VMTQDG4U.js → chunk-PXDTH36X.js} +12 -10
  68. package/dist/chunk-PXDTH36X.js.map +1 -0
  69. package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
  70. package/dist/chunk-PYAJHLXO.js.map +1 -0
  71. package/dist/{chunk-OTVBSF7U.js → chunk-Q2A46HHW.js} +17 -12
  72. package/dist/chunk-Q2A46HHW.js.map +1 -0
  73. package/dist/controls-reader-SNMI2UY7.js +191 -0
  74. package/dist/controls-reader-SNMI2UY7.js.map +1 -0
  75. package/dist/controls-uCaQ3CNX.d.ts +61 -0
  76. package/dist/expo/plugin.cjs +16 -11
  77. package/dist/expo/plugin.cjs.map +1 -1
  78. package/dist/expo/plugin.js +1 -1
  79. package/dist/expo-babel-plugin.cjs +16 -11
  80. package/dist/expo-babel-plugin.cjs.map +1 -1
  81. package/dist/expo-babel-plugin.js +1 -1
  82. package/dist/index.d.ts +4 -0
  83. package/dist/index.js +10 -2465
  84. package/dist/index.js.map +1 -1
  85. package/dist/nextjs/plugin.cjs +44 -3
  86. package/dist/nextjs/plugin.cjs.map +1 -1
  87. package/dist/nextjs/plugin.js +1 -1
  88. package/dist/nextjs-loader.cjs +60 -14
  89. package/dist/nextjs-loader.cjs.map +1 -1
  90. package/dist/nextjs.cjs +44 -3
  91. package/dist/nextjs.cjs.map +1 -1
  92. package/dist/nextjs.d.cts +4 -4
  93. package/dist/nextjs.d.ts +4 -4
  94. package/dist/nextjs.js +1 -1
  95. package/dist/{storyboard-DjOF61B_.d.ts → storyboard-4YdTYq_e.d.ts} +1 -1
  96. package/dist/svelte.js +7 -1075
  97. package/dist/svelte.js.map +1 -1
  98. package/package.json +44 -3
  99. package/dist/chunk-2IQD2KPS.js.map +0 -1
  100. package/dist/chunk-5BHIHP25.js.map +0 -1
  101. package/dist/chunk-7DT5DDSH.js.map +0 -1
  102. package/dist/chunk-FQSZRVSL.js.map +0 -1
  103. package/dist/chunk-MXKZZOLM.js.map +0 -1
  104. package/dist/chunk-N2TYN3RB.js.map +0 -1
  105. package/dist/chunk-OTVBSF7U.js.map +0 -1
  106. package/dist/chunk-TL4MGN7E.js.map +0 -1
  107. package/dist/chunk-VMTQDG4U.js.map +0 -1
  108. package/dist/chunk-XLEKCOB7.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../modules/iframe-projection/html/selectors.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/capture.ts","../../../modules/iframe-projection/html/runtime-mutations.ts"],"sourcesContent":["/**\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 * 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/** Every source kind uses character offsets in the same annotation contract. */\nconst SOURCE_ANNOTATED_SELECTOR = \"[data-tempo-filepath]\";\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 const filepath = element.getAttribute(\"data-tempo-filepath\");\n if (filepath == null || filepath.length === 0) return;\n\n const modifiedTsRaw = element.getAttribute(\"data-tempo-modifiedts\");\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(\"data-tempo-source-version\");\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(\"data-tempo-position\");\n if (position != null && position.length > 0) {\n anchorSet.add(`${filepath} ${position}`);\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 * 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","/** Browser-only mutation hooks shared by ordinary and isolated producers.\n * Notifications carry no values or authority: receivers read the actual DOM.\n * Private events avoid firing application input/change handlers. No polling.\n * The fixed source also installs in an isolated guest's page realm before JS.\n */\nexport const FORM_RUNTIME_MUTATION = \"tempo:form-runtime-mutation\";\nexport const CSS_RUNTIME_MUTATION = \"tempo:css-runtime-mutation\";\n\nexport const RUNTIME_MUTATION_SOURCE = String.raw`(scope => {\n const doc = scope.document;\n const undo = [];\n let active = true;\n const emit = (target, kind, detail) => {\n if (active) target.dispatchEvent(detail\n ? new scope.CustomEvent(kind, { bubbles: true, detail })\n : new scope.Event(kind, { bubbles: true }));\n };\n const form = target => {\n if (target instanceof scope.HTMLOptionElement) target = target.closest('select');\n if (target && target.isConnected) emit(target, 'tempo:form-runtime-mutation');\n };\n const css = target => {\n const sheet = target instanceof scope.CSSStyleSheet ? target : target.parentStyleSheet;\n if (target === doc || sheet && (sheet.ownerNode?.isConnected || doc.adoptedStyleSheets.includes(sheet)))\n emit(doc, 'tempo:css-runtime-mutation', { ownerNode: sheet?.ownerNode ?? null });\n };\n const setter = (proto, key, changed) => {\n if (!proto) return;\n const original = Object.getOwnPropertyDescriptor(proto, key);\n if (!original?.set || !original.configurable) return;\n const set = function(value) {\n const before = original.get?.call(this);\n original.set.call(this, value);\n if (key === 'adoptedStyleSheets' || before !== original.get?.call(this)) changed(this);\n };\n Object.defineProperty(proto, key, { ...original, set });\n undo.push(() => {\n if (Object.getOwnPropertyDescriptor(proto, key)?.set === set)\n Object.defineProperty(proto, key, original);\n });\n };\n const method = (proto, key, changed) => {\n if (!proto) return;\n const original = Object.getOwnPropertyDescriptor(proto, key);\n if (typeof original?.value !== 'function' || !original.configurable) return;\n const value = function(...args) {\n const result = original.value.apply(this, args);\n if (result instanceof scope.Promise) result.then(() => changed(this), () => {});\n else changed(this);\n return result;\n };\n Object.defineProperty(proto, key, { ...original, value });\n undo.push(() => {\n if (Object.getOwnPropertyDescriptor(proto, key)?.value === value)\n Object.defineProperty(proto, key, original);\n });\n };\n for (const [type, keys] of [\n ['HTMLInputElement', ['value', 'checked', 'valueAsNumber', 'valueAsDate']],\n ['HTMLTextAreaElement', ['value']],\n ['HTMLSelectElement', ['value', 'selectedIndex']],\n ['HTMLOptionElement', ['selected']],\n ]) for (const key of keys) setter(scope[type]?.prototype, key, form);\n for (const type of ['HTMLInputElement', 'HTMLTextAreaElement'])\n method(scope[type]?.prototype, 'setRangeText', form);\n for (const key of ['stepUp', 'stepDown']) method(scope.HTMLInputElement?.prototype, key, form);\n // CSSOM edits do not create MutationRecords, including declaration setters.\n for (const key of ['insertRule', 'deleteRule', 'addRule', 'removeRule', 'replace', 'replaceSync'])\n method(scope.CSSStyleSheet?.prototype, key, css);\n for (const key of ['insertRule', 'deleteRule']) method(scope.CSSGroupingRule?.prototype, key, css);\n const declarations = scope.CSSStyleDeclaration?.prototype;\n setter(declarations, 'cssText', target => { if (target.parentRule) css(target.parentRule); });\n for (const key of ['setProperty', 'removeProperty'])\n method(declarations, key, target => { if (target.parentRule) css(target.parentRule); });\n setter(scope.Document?.prototype, 'adoptedStyleSheets', css);\n setter(scope.StyleSheet?.prototype, 'disabled', css);\n method(scope.HTMLFormElement?.prototype, 'reset', target => {\n for (const element of target.elements) form(element);\n });\n const dispose = () => {\n if (!active) return;\n active = false;\n for (const restore of undo.reverse()) restore();\n };\n return dispose;\n})`;\n\ntype RuntimeMutationInstaller = (scope: Window) => () => void;\nlet install: RuntimeMutationInstaller | undefined;\nconst owners = new WeakMap<Document, { count: number; stop(): void }>();\n\n/** Multiple root/head watchers share one set of hooks in their browser realm. */\nexport function observeRuntimeMutations(doc: Document): () => void {\n if (!doc.defaultView) return () => {};\n let owner = owners.get(doc);\n if (!owner) {\n install ??= new Function(\n `return ${RUNTIME_MUTATION_SOURCE}`,\n )() as RuntimeMutationInstaller;\n owner = { count: 0, stop: install(doc.defaultView) };\n owners.set(doc, owner);\n }\n owner.count++;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n if (--owner.count === 0) {\n owner.stop();\n owners.delete(doc);\n }\n };\n}\n"],"mappings":";AAwBO,SAAS,iBAAiB,SAAkB,MAAwB;AAEzE,MAAI,CAAC,MAAM;AACT,QAAI,YAAY,SAAS,gBAAiB,QAAO;AACjD,QAAI,YAAY,SAAS,KAAM,QAAO;AACtC,QAAI,YAAY,SAAS,KAAM,QAAO;AAAA,EACxC;AAGA,MAAI,QAAQ,YAAY,KAAM,QAAO;AAErC,QAAM,QAAkB,CAAC;AACzB,MAAI,UAA0B;AAC9B,QAAM,SAAS,QAAQ,SAAS;AAEhC,SAAO,WAAW,YAAY,QAAQ;AACpC,UAAM,SAAyB,QAAQ;AACvC,QAAI,CAAC,OAAQ;AAEb,UAAM,UAAU,QAAQ,QAAQ,YAAY;AAG5C,QAAI,QAAQ;AACZ,QAAI,UAAU,QAAQ;AACtB,WAAO,SAAS;AACd,UAAI,QAAQ,YAAY,QAAQ,QAAS;AACzC,gBAAU,QAAQ;AAAA,IACpB;AAEA,QAAI,mBAAmB;AACvB,eAAW,SAAS,OAAO,UAAU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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgF9C,IAAI;AACJ,IAAM,SAAS,oBAAI,QAAmD;AAG/D,SAAS,wBAAwB,KAA2B;AACjE,MAAI,CAAC,IAAI,YAAa,QAAO,MAAM;AAAA,EAAC;AACpC,MAAI,QAAQ,OAAO,IAAI,GAAG;AAC1B,MAAI,CAAC,OAAO;AACV,0BAAY,IAAI;AAAA,MACd,UAAU,uBAAuB;AAAA,IACnC,EAAE;AACF,YAAQ,EAAE,OAAO,GAAG,MAAM,QAAQ,IAAI,WAAW,EAAE;AACnD,WAAO,IAAI,KAAK,KAAK;AAAA,EACvB;AACA,QAAM;AACN,MAAI,WAAW;AACf,SAAO,MAAM;AACX,QAAI,SAAU;AACd,eAAW;AACX,QAAI,EAAE,MAAM,UAAU,GAAG;AACvB,YAAM,KAAK;AACX,aAAO,OAAO,GAAG;AAAA,IACnB;AAAA,EACF;AACF;","names":["document"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas-component-reference.ts","../canvas/parser.ts","../expo-babel-plugin.ts","../annotation-strategy.ts","../../../modules/annotation/expression-facts.ts","../../../modules/annotation/source-version.ts","../sdk-package-files.ts"],"sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { dirname, isAbsolute, normalize, posix, resolve } from \"node:path\";\nimport { parseCanvasFile } from \"./canvas/parser\";\n\nexport const COMPONENT_REFERENCE_ATTRIBUTE = \"data-tempo-component-reference\";\nfunction moduleIdentity(\n file: string,\n specifier: string,\n resolved?: ReadonlyMap<string, string>,\n): string {\n const bundled = resolved?.get(specifier);\n // Match Vite's module-graph timestamp normalization. Other query parameters\n // and fragments can select different modules and remain part of identity.\n const target =\n bundled === undefined\n ? specifier\n : bundled.replace(/\\bt=\\d{13}&?\\b/, \"\").replace(/[?&]$/, \"\");\n if (target.startsWith(\"\\0\")) return target;\n const suffixAt = target.search(/[?#]/);\n let path = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(\n /\\\\/g,\n \"/\",\n );\n const suffix = suffixAt < 0 ? \"\" : target.slice(suffixAt);\n if (bundled === undefined && path.startsWith(\".\"))\n path = resolve(dirname(file), path);\n // Bare or virtual module IDs are opaque; path.normalize can change their\n // meaning. Only filesystem paths receive filesystem canonicalization.\n if (!isAbsolute(path) && !/^[A-Za-z]:\\//.test(path)) return target;\n if (bundled !== undefined) {\n try {\n path = realpathSync.native(path);\n } catch {\n /* The resolver may return a virtual absolute path. */\n }\n }\n return normalize(path).replace(/\\\\/g, \"/\") + suffix;\n}\n/** Static references carry provenance. Inline/dynamic expressions remain owned\n * by their storyboard; body and props never participate in source identity. */\nexport function canvasComponentAnnotations(\n file: string,\n source: string,\n resolved?: ReadonlyMap<string, string>,\n): ReadonlyMap<number, Readonly<Record<string, string>>> {\n const result = new Map<number, Readonly<Record<string, string>>>();\n if (!source.includes(\"tempo-sdk/canvas\")) return result;\n const parsed = parseCanvasFile(file, source);\n for (const board of parsed.storyboards) {\n const ref = board.component;\n if (\n board.kind !== \"component\" ||\n !ref?.localName ||\n board.openingElementSpan === undefined\n )\n continue;\n const member = ref.expression.match(\n /^\\s*([$\\w]+)(?:\\s*\\.\\s*([$\\w]+))?\\s*$/,\n );\n if (!member) continue;\n let name: string;\n if (ref.import) {\n if (ref.import.kind === \"namespace\") {\n if (!member[2]) continue;\n name = member[2];\n } else {\n if (member[2]) continue;\n name = ref.import.importedName;\n }\n } else {\n if (member[2]) continue;\n name = ref.localName;\n }\n // Match the canvas-config reader's V1 rule using the authored specifier,\n // before bundler resolution changes aliases into filesystem paths.\n const specifier = ref.import?.source.replace(/\\\\/g, \"/\").replace(/[?#].*/, \"\");\n const canvasDir = posix.dirname(file.replace(/\\\\/g, \"/\"));\n const external = specifier !== undefined &&\n (!specifier.startsWith(\".\") ||\n !posix.join(canvasDir, specifier).startsWith(`${canvasDir}/`));\n result.set(board.openingElementSpan.start, {\n [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([\n ref.import ? \"import\" : \"local\",\n moduleIdentity(file, ref.import?.source ?? file, resolved),\n name,\n ]),\n ...(external ? { \"data-tempo-external-component\": \"true\" } : {}),\n });\n }\n return result;\n}\n","import { parseSync, type JSXElement } 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};\n\nexport type ParsedCanvasLayoutSpans = {\n x?: CanvasSourceSpan;\n y?: CanvasSourceSpan;\n width?: CanvasSourceSpan;\n height?: CanvasSourceSpan;\n zIndex?: 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};\n\nconst DEFAULT_VIEWPORT_LAYOUT: ParsedCanvasLayout = {\n ...DEFAULT_LAYOUT,\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\n if (\n component === \"Storyboard\" ||\n component === \"SvelteStoryboard\" ||\n component === \"HtmlStoryboard\"\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.trim() ? filepath.value : undefined;\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?.value.trim() && !src?.value.trim()) {\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 isViewport =\n componentName === \"RouteStoryboard\" || componentName === \"HtmlStoryboard\";\n const attribute = getAttribute(openingElement, \"layout\");\n const expression = unwrapAttributeExpression(attribute?.value);\n\n if (!expression) {\n return {\n value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : 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 const isViewport =\n componentName === \"RouteStoryboard\" || componentName === \"HtmlStoryboard\";\n\n if (expression.type !== \"ObjectExpression\") {\n return {\n value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : 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 const width = getObjectProperty(expression, \"width\");\n const height = getObjectProperty(expression, \"height\");\n const legacySizing = getObjectProperty(expression, \"intrinsicSizing\");\n const legacyResponsiveFlag = legacySizing?.value?.value === \"root-element\";\n const hasBothSizes = Boolean(width && height);\n const readSize = isViewport || (hasBothSizes && !legacyResponsiveFlag);\n const incompleteSize = !isViewport && Boolean(width) !== Boolean(height);\n if (incompleteSize) {\n errors.push({\n message: \"layout.width and layout.height must be set together\",\n span: toSpan(expression),\n kind: \"degraded\",\n });\n }\n const size = readSize\n ? {\n width: width ? readNumberLiteral(width.value) : null,\n height: height ? readNumberLiteral(height.value) : null,\n }\n : null;\n const keys = readSize\n ? ([\"x\", \"y\", \"width\", \"height\"] as const)\n : ([\"x\", \"y\"] as const);\n for (const key of keys) {\n const property =\n key === \"width\"\n ? width\n : key === \"height\"\n ? height\n : getObjectProperty(expression, key);\n const value =\n key === \"width\" || key === \"height\"\n ? size?.[key]\n : property\n ? readNumberLiteral(property.value)\n : null;\n const keepValue =\n key === \"x\" ||\n key === \"y\" ||\n isViewport ||\n Boolean(size?.width && size.height);\n if (!value) {\n errors.push({\n message: `<${componentName}> layout.${key} must be a number literal`,\n span: toSpan(property ?? expression),\n kind: \"degraded\",\n });\n continue;\n }\n if (!keepValue) continue;\n layout[key] = value.value;\n spans[key] = value.span;\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 invalidLegacyFlag =\n legacySizing &&\n (legacySizing.value?.type !== \"Literal\" || !legacyResponsiveFlag);\n if (invalidLegacyFlag) {\n errors.push({\n message: `<${componentName}> layout.intrinsicSizing must be \"root-element\" when set`,\n span: toSpan(legacySizing),\n kind: \"degraded\",\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\n/** Resolve only direct component returns, so nested callbacks cannot supply a false root. */\nexport function parseComponentRoot(\n filePath: string,\n source: string,\n exportName: string,\n): { name: string; root: JSXElement } | null {\n const result = parseSync(filePath, source);\n if (result.errors.length > 0) {\n throw new Error(result.errors.map((error) => error.message).join(\"; \"));\n }\n const declarations = new Map<string, any>();\n let component: any;\n let localName = exportName;\n let exported = false;\n for (const statement of result.program.body as any[]) {\n const declaration = statement.declaration ?? statement;\n if (declaration.type === \"FunctionDeclaration\" && declaration.id) {\n declarations.set(declaration.id.name, declaration);\n }\n if (declaration.type === \"VariableDeclaration\") {\n for (const entry of declaration.declarations) {\n if (entry.id.type === \"Identifier\") {\n declarations.set(entry.id.name, unwrapTsExpression(entry.init));\n }\n }\n }\n if (\n statement.type === \"ExportDefaultDeclaration\" &&\n exportName === \"default\"\n ) {\n exported = true;\n if (declaration.type === \"Identifier\") localName = declaration.name;\n else component = declaration;\n }\n if (statement.type !== \"ExportNamedDeclaration\") continue;\n for (const specifier of statement.specifiers ?? []) {\n if (\n !statement.source &&\n (specifier.exported.name ?? specifier.exported.value) === exportName\n ) {\n exported = true;\n localName = specifier.local.name;\n }\n }\n if (declaration.id?.name === exportName) {\n exported = true;\n component = declaration;\n }\n if (\n declaration.type === \"VariableDeclaration\" &&\n declaration.declarations.some(\n (entry: any) => entry.id.name === exportName,\n )\n ) {\n exported = true;\n }\n }\n if (!exported) return null;\n component = unwrapTsExpression(component ?? declarations.get(localName));\n const isFunction =\n component?.type === \"FunctionDeclaration\" ||\n component?.type === \"FunctionExpression\" ||\n component?.type === \"ArrowFunctionExpression\";\n if (!isFunction) return null;\n const name = component.id?.name ?? localName;\n let root = unwrapTsExpression(component.body);\n if (root?.type === \"BlockStatement\") {\n const returns = root.body.filter(\n (statement: any) => statement.type === \"ReturnStatement\",\n );\n const hasControlFlow = root.body.some(\n (statement: any) =>\n ![\n \"ReturnStatement\",\n \"VariableDeclaration\",\n \"ExpressionStatement\",\n \"FunctionDeclaration\",\n \"EmptyStatement\",\n ].includes(statement.type),\n );\n if (returns.length !== 1 || hasControlFlow) return null;\n root = unwrapTsExpression(returns[0].argument);\n }\n return root?.type === \"JSXElement\" ? { name, root } : null;\n}\n","import { canvasComponentAnnotations } from \"./canvas-component-reference\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type { NodePath, types as BabelTypes } from \"@babel/core\";\nimport { createFilter, type FilterPattern } from \"@rollup/pluginutils\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n cleanModuleId,\n computeTempoAnnotatedProps,\n DEFAULT_EXCLUDE,\n getFileAnnotationContext,\n isIntrinsicElement,\n resolveCanonicalRoot,\n type ComputeAnnotatedProps,\n} from \"./annotation-strategy.ts\";\nimport { createSdkFileMatcher } from \"./sdk-package-files.ts\";\n\nconst EXPO_DEFAULT_INCLUDE: FilterPattern = [\"**/*.tsx\", \"**/*.jsx\", \"**/*.js\"];\n\nconst FRAGMENT_TAG_NAMES = new Set([\"Fragment\", \"React.Fragment\"]);\n\n// The React Native builtin host components we annotate. Membership decides\n// whether a component is annotated at all; `supports-children` is then keyed\n// off REACT_NATIVE_NO_CHILDREN_COMPONENTS below.\nconst REACT_NATIVE_HOST_COMPONENTS = new Set([\n \"ActivityIndicator\",\n \"Button\",\n \"FlatList\",\n \"Image\",\n \"ImageBackground\",\n \"KeyboardAvoidingView\",\n \"Modal\",\n \"Pressable\",\n \"RefreshControl\",\n \"SafeAreaView\",\n \"ScrollView\",\n \"SectionList\",\n \"Switch\",\n \"Text\",\n \"TextInput\",\n \"TouchableHighlight\",\n \"TouchableNativeFeedback\",\n \"TouchableOpacity\",\n \"TouchableWithoutFeedback\",\n \"View\",\n \"VirtualizedList\",\n]);\n\nconst REACT_NATIVE_NO_CHILDREN_COMPONENTS = new Set([\n \"ActivityIndicator\",\n \"Image\",\n \"RefreshControl\",\n \"Switch\",\n]);\n\nconst REACT_NATIVE_SUPPORT_OVERRIDES = new Map(\n [...REACT_NATIVE_HOST_COMPONENTS].map((tagName) => [\n tagName,\n { supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName) },\n ]),\n);\n\nexport interface TempoExpoBabelPluginOptions {\n /**\n * Defaults to `!!process.env.TEMPO`, matching `tempoVitePlugin`.\n * Expo users can pass `{ enabled: true }` in babel.config.js for direct tests.\n */\n enabled?: boolean;\n root?: string;\n include?: FilterPattern;\n exclude?: FilterPattern;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n}\n\ntype BabelApi = {\n assertVersion(version: number): void;\n types: typeof BabelTypes;\n template: {\n expression(source: string): () => BabelTypes.Expression;\n statement(source: string): () => BabelTypes.Statement;\n };\n};\n\ntype BabelPluginState = {\n cwd?: string;\n filename?: string;\n file: {\n code: string;\n opts: {\n cwd?: string;\n filename?: string;\n root?: string;\n };\n };\n opts: TempoExpoBabelPluginOptions;\n};\n\nfunction hasParserPlugin(\n plugins: NonNullable<import(\"@babel/core\").ParserOptions[\"plugins\"]>,\n name: string,\n): boolean {\n return plugins.some((plugin) =>\n Array.isArray(plugin) ? plugin[0] === name : plugin === name,\n );\n}\n\nfunction getBabelTagName(\n name: BabelTypes.JSXElement[\"openingElement\"][\"name\"],\n): string {\n switch (name.type) {\n case \"JSXIdentifier\":\n return name.name;\n case \"JSXNamespacedName\":\n return `${name.namespace.name}:${name.name.name}`;\n case \"JSXMemberExpression\":\n return `${getBabelTagName(name.object)}.${name.property.name}`;\n }\n}\n\nfunction hasAttribute(\n node: BabelTypes.JSXOpeningElement,\n attrName: string,\n): boolean {\n return node.attributes.some(\n (attr) => attr.type === \"JSXAttribute\" && attr.name.name === attrName,\n );\n}\n\nfunction propValueToExpression(\n api: BabelApi,\n value: Exclude<PropValue, undefined>,\n): BabelTypes.Expression {\n if (typeof value === \"function\") {\n return api.template.expression(value.toString())();\n }\n return api.types.valueToNode(value) as BabelTypes.Expression;\n}\n\n// \"data-tempo-filepath\" -> \"tempoFilepath\". react-native-web hyphenates dataSet\n// keys back to \"data-tempo-filepath\" on the rendered DOM node, so this round-trips.\nfunction dataAttrToDataSetKey(attrName: string): string {\n return attrName\n .replace(/^data-/, \"\")\n .replace(/-([a-z])/g, (_, char: string) => char.toUpperCase());\n}\n\nfunction findDataSetAttribute(\n openingElement: BabelTypes.JSXOpeningElement,\n): BabelTypes.JSXAttribute | undefined {\n return openingElement.attributes.find(\n (attr): attr is BabelTypes.JSXAttribute =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"dataSet\",\n );\n}\n\nfunction addAnnotations(\n api: BabelApi,\n tagName: string,\n openingElement: BabelTypes.JSXOpeningElement,\n props: Record<string, PropValue>,\n) {\n const t = api.types;\n\n // Intrinsic web elements (lowercase: div/span/...) are real DOM nodes that\n // forward arbitrary `data-*` attributes, so annotate them directly. React\n // Native host components (View, Text, ...) and any other component are NOT\n // DOM nodes: react-native-web only forwards an allow-list of props plus\n // `dataSet` to the rendered element and drops raw `data-*`. For those we emit\n // the annotations through `dataSet` (camelCase keys), which RNW maps back to\n // `data-*` on the host element.\n if (isIntrinsicElement(tagName)) {\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || hasAttribute(openingElement, key)) continue;\n openingElement.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(propValueToExpression(api, value)),\n ),\n );\n }\n return;\n }\n\n const dataSetProps: BabelTypes.ObjectProperty[] = [];\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined) continue;\n dataSetProps.push(\n t.objectProperty(\n t.identifier(dataAttrToDataSetKey(key)),\n propValueToExpression(api, value),\n ),\n );\n }\n if (dataSetProps.length === 0) return;\n\n const existing = findDataSetAttribute(openingElement);\n if (!existing) {\n openingElement.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(\"dataSet\"),\n t.jsxExpressionContainer(t.objectExpression(dataSetProps)),\n ),\n );\n return;\n }\n\n // Merge into a user-provided `dataSet={...}` without clobbering their keys:\n // { ...existingDataSet, ...tempoKeys }.\n if (\n existing.value?.type === \"JSXExpressionContainer\" &&\n existing.value.expression.type !== \"JSXEmptyExpression\"\n ) {\n existing.value.expression = t.objectExpression([\n t.spreadElement(existing.value.expression),\n ...dataSetProps,\n ]);\n }\n}\n\nconst ROOT_META_NAME = \"tempo-project-root\";\n\n// Rewrite the sidecar entry to stamp the absolute sidecar root into a\n// `<meta name=\"tempo-project-root\">` at runtime. The canvas reads this meta off\n// the live DOM (`read-source.ts`) to resolve `data-tempo-filepath` annotations —\n// which are relative to this root — back to absolute on-disk paths.\n//\n// Why stamp at runtime instead of writing the path into the committed\n// `public/index.html`: that file is committed to the user's repo, so it must not\n// hold a machine-specific absolute path. `root` here is resolved from the\n// sidecar's `__dirname` when Metro bundles, so it lives only in the built bundle\n// — never in committed source — yet still points at wherever the sidecar lives on\n// the machine running the dev server.\n//\n// Guarded on `typeof document` so it's inert under native/SSR bundles, and\n// idempotent (reuses an existing meta) so the static `public/index.html` marker —\n// kept present-but-empty for dev-server readiness detection — is upgraded in\n// place rather than duplicated.\nfunction injectProjectRootMeta(\n api: BabelApi,\n programPath: NodePath<BabelTypes.Program>,\n root: string,\n) {\n const setter = api.template.statement(`\n if (typeof document !== \"undefined\") {\n var __tempoRootMeta = document.querySelector('meta[name=\"${ROOT_META_NAME}\"]');\n if (!__tempoRootMeta) {\n __tempoRootMeta = document.createElement(\"meta\");\n __tempoRootMeta.setAttribute(\"name\", \"${ROOT_META_NAME}\");\n document.head.appendChild(__tempoRootMeta);\n }\n __tempoRootMeta.setAttribute(\"content\", ${JSON.stringify(root)});\n }\n `)();\n programPath.pushContainer(\"body\", setter);\n}\n\nfunction resolveBabelRoot(\n state: BabelPluginState,\n options: TempoExpoBabelPluginOptions,\n filename: string,\n): string {\n return resolveCanonicalRoot(\n resolve(\n options.root ??\n findNearestPackageRoot(filename) ??\n state.cwd ??\n state.file.opts.cwd ??\n state.file.opts.root ??\n process.cwd(),\n ),\n );\n}\n\nfunction findNearestPackageRoot(filename: string): string | null {\n let current = dirname(filename);\n while (true) {\n if (existsSync(resolve(current, \"package.json\"))) return current;\n const parent = dirname(current);\n if (parent === current) return null;\n current = parent;\n }\n}\n\nfunction resolveFilename(state: BabelPluginState): string | null {\n const filename = state.filename ?? state.file.opts.filename;\n if (!filename) return null;\n return resolve(cleanModuleId(filename));\n}\n\nexport default function tempoExpoBabelPlugin(\n api: BabelApi,\n rawOptions: TempoExpoBabelPluginOptions = {},\n) {\n api.assertVersion(7);\n\n const enabled = rawOptions.enabled ?? !!process.env.TEMPO;\n const include =\n rawOptions.include === undefined\n ? EXPO_DEFAULT_INCLUDE\n : rawOptions.include;\n const exclude =\n rawOptions.exclude === undefined ? DEFAULT_EXCLUDE : rawOptions.exclude;\n const userFilter = createFilter(include, exclude);\n const isSdkFile = createSdkFileMatcher();\n const filter = (id: string) => userFilter(id) && !isSdkFile(id);\n\n return {\n name: \"tempo-expo-annotate\",\n\n manipulateOptions(\n opts: { filename?: string },\n parserOpts: NonNullable<\n import(\"@babel/core\").TransformOptions[\"parserOpts\"]\n >,\n ) {\n parserOpts.plugins ??= [];\n if (!hasParserPlugin(parserOpts.plugins, \"jsx\")) {\n parserOpts.plugins.push(\"jsx\");\n }\n const filename = opts.filename ?? \"\";\n if (\n /\\.(ts|tsx)$/.test(filename) &&\n !hasParserPlugin(parserOpts.plugins, \"typescript\")\n ) {\n parserOpts.plugins.push(\"typescript\");\n }\n },\n\n visitor: {\n Program: {\n enter(path: NodePath<BabelTypes.Program>, state: BabelPluginState) {\n if (!enabled) return;\n const options = { ...rawOptions, ...state.opts };\n const filename = resolveFilename(state);\n if (!filename || !filter(filename)) return;\n\n const source = state.file.code;\n const root = resolveBabelRoot(state, options, filename);\n let context: ReturnType<typeof getFileAnnotationContext>;\n try {\n context = getFileAnnotationContext({\n source,\n filename,\n root,\n canonicalizeFilename: true,\n });\n } catch {\n return;\n }\n\n // The sidecar entry runs once at startup; stamp the project-root meta\n // there so the canvas can resolve annotations off the live DOM. Keyed\n // on the entry's root-relative path (`index.js`), matching the entry\n // scaffolded by tempo-project's `EXPO_INDEX_JS`.\n if (context.filepath === \"index.js\") {\n injectProjectRootMeta(api, path, root);\n }\n\n const componentReferences = canvasComponentAnnotations(\n filename,\n source,\n );\n path.traverse({\n JSXElement(elementPath) {\n const element = elementPath.node;\n const tagName = getBabelTagName(element.openingElement.name);\n if (FRAGMENT_TAG_NAMES.has(tagName)) return;\n\n const info = {\n element,\n tagName,\n parentType: elementPath.parent.type,\n } as unknown as ElementInfo;\n const props = computeTempoAnnotatedProps({\n info,\n filepath: context.filepath,\n modifiedtsMs: context.modifiedtsMs,\n sourceVersion: context.sourceVersion,\n computeAnnotatedProps: options.computeAnnotatedProps,\n elementSupportOverrides: REACT_NATIVE_SUPPORT_OVERRIDES,\n });\n\n addAnnotations(api, tagName, element.openingElement, props);\n const annotations = componentReferences.get(\n element.openingElement.start ?? -1,\n );\n // SDK declaration props, not a React Native host dataSet.\n for (const [name, value] of Object.entries(annotations ?? {})) {\n element.openingElement.attributes.push(\n api.types.jsxAttribute(\n api.types.jsxIdentifier(name),\n api.types.jsxExpressionContainer(\n api.types.stringLiteral(value),\n ),\n ),\n );\n }\n },\n });\n },\n },\n },\n };\n}\n\nexport { tempoExpoBabelPlugin };\n","import { realpathSync, statSync } from \"node:fs\";\nimport { relative } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n EXPRESSION_FACTS_ATTRIBUTE,\n expressionFacts,\n} from \"../../modules/annotation/expression-facts.ts\";\nimport { sourceVersionHash } from \"../../modules/annotation/source-version.ts\";\n\nexport const DEFAULT_EXCLUDE = [\"**/node_modules/**\"] as const;\n\n/**\n * Static per-component declaration of whether a custom component accepts\n * `children`. Supplied by callers that know this from a fixed table (e.g. the\n * Expo plugin's React Native host-component overrides). The Vite/Next.js\n * plugins supply no overrides — custom components are left without a\n * `supports-children` flag and consumers treat their support as unknown.\n */\nexport interface ElementTypeSupport {\n supportsChildren: boolean;\n}\n\n/** HTML void elements that cannot have children (self-closing only). */\nexport const HTML_VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n) => Record<string, PropValue>;\n\nexport function cleanModuleId(id: string): string {\n return id.replace(/[?#].*$/, \"\");\n}\n\nexport function resolveCanonicalRoot(root: string): string {\n try {\n return realpathSync.native(root);\n } catch {\n return root;\n }\n}\n\nexport function isIntrinsicElement(tagName: string): boolean {\n return tagName.length > 0 && tagName[0] === tagName[0]!.toLowerCase();\n}\n\nexport function hasJsxAttribute(info: ElementInfo, attrName: string): boolean {\n for (const attr of info.element.openingElement.attributes) {\n const name = (attr as { name?: { name?: unknown } }).name;\n if (name?.name === attrName) return true;\n }\n return false;\n}\n\nexport function defaultComputeAnnotatedProps(\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): Record<string, PropValue> {\n return {\n \"data-tempo-filepath\": filepath,\n \"data-tempo-position\": info.element.openingElement.start,\n \"data-tempo-modifiedts\": modifiedtsMs,\n // Content-hash identity of the file this element was annotated from. The\n // canvas reconcile loop equality-compares it against the write pipeline's\n // computed version to decide whether a capture reflects a given edit.\n \"data-tempo-source-version\": sourceVersion,\n };\n}\n\n/**\n * Appends the module version record: one guarded statement that runs when the\n * browser evaluates the module and pushes `{file, modifiedTs, sourceVersion}`\n * onto `globalThis.__TEMPO_MODULE_VERSIONS__`, keyed by the same `filepath`\n * the element stamps carry. The projection producer joins these records to\n * React's refresh so the canvas learns that a write reached the host even\n * when the write left no element of the file on a board (V2-498).\n *\n * It is appended to every filtered module, JSX or not: a write that removes a\n * file's last element is exactly the case that needs it. It goes at the end\n * so it never displaces a leading directive such as \"use client\", and adds no\n * line above existing code so positions and source maps are unchanged. The\n * `window` guard keeps server-side evaluation (Next server components, SSR)\n * from recording anything.\n */\nexport function appendModuleVersionRecord(\n source: string,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): string {\n const record = JSON.stringify({\n file: filepath,\n modifiedTs: modifiedtsMs,\n sourceVersion,\n });\n return `${source}\\n;typeof window !== \"undefined\" && (globalThis.__TEMPO_MODULE_VERSIONS__ || (globalThis.__TEMPO_MODULE_VERSIONS__ = [])).push(${record});\\n`;\n}\n\nexport function computeTempoAnnotatedProps(params: {\n info: ElementInfo;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n elementSupportOverrides?: ReadonlyMap<string, ElementTypeSupport>;\n}): Record<string, PropValue> {\n const {\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n computeAnnotatedProps,\n elementSupportOverrides,\n } = params;\n\n const userProps = {\n ...(computeAnnotatedProps\n ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion)\n : defaultComputeAnnotatedProps(\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n )),\n // Only a caller that knows the parent can say whether the slot is a JSX\n // child; without it every element would read as a dynamic slot.\n ...(info.parentType !== undefined &&\n !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE)\n ? {\n [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(\n info.element,\n info.parentType,\n ),\n }\n : {}),\n };\n\n if (isIntrinsicElement(info.tagName)) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : !HTML_VOID_ELEMENTS.has(info.tagName),\n };\n }\n\n const override = elementSupportOverrides?.get(info.tagName);\n if (override) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : override.supportsChildren,\n };\n }\n\n // Custom component with no static override: emit no `data-tempo-supports-*`\n // flags. Determining them required a per-file TypeScript program, which was\n // removed for being the dominant cost of devserver startup. Consumers treat\n // the absent flags as \"unknown\" and fall back to their own defaults.\n return userProps;\n}\n\nexport function getFileAnnotationContext(params: {\n source: string;\n filename: string;\n root: string;\n canonicalizeFilename?: boolean;\n}): {\n cleanFilename: string;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n} {\n const rawCleanFilename = cleanModuleId(params.filename);\n let cleanFilename = rawCleanFilename;\n if (params.canonicalizeFilename) {\n try {\n cleanFilename = realpathSync.native(rawCleanFilename);\n } catch {\n cleanFilename = rawCleanFilename;\n }\n }\n return {\n cleanFilename,\n filepath: relative(params.root, cleanFilename),\n modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),\n // Hashed once per file per transform (the context is built once, reused\n // for every element) so the per-element funnel just forwards the token.\n sourceVersion: sourceVersionHash(params.source),\n };\n}\n","/**\n * Expression facts: which parts of one JSX element's source are runtime\n * expressions, stamped as `data-tempo-expr` so the canvas can know before an\n * edit that the edit's operand is not literal source.\n *\n * The value is a space-separated token list. Each token is a fact, never a\n * decision:\n * - `#slot`: the element's own slot is not a JSX child. Its syntactic parent\n * is a `.map` callback, a conditional, a `return`, a prop value or a `{}`\n * container. The `#` keeps it apart from attribute names.\n * - `<name>`: the attribute is written at the callsite and its value is an\n * expression, or a later spread may override it.\n * - `style` alone: the style value is not an object literal, or a later\n * spread may override it. Every style key is then an expression.\n * - `style.<key>`: that key of a style object literal is an expression, a\n * shorthand, or a later spread or computed key may override it.\n *\n * A fact is written only when the file proves it, and exactly where the\n * checked writer refuses (`main/literal-writes.ts` planAttribute and\n * planInlineStyles, `astParentKind` for the slot; pinned cell by cell in\n * `literal-writes.expression-facts.test.ts`). Both read JSX in order:\n * - a spread (or a computed key in a style object) overrides only what comes\n * before it, so an attribute or key before one is a fact and one after it\n * is not;\n * - of repeated occurrences the last renders, so only the last is judged\n * and the writer edits that one.\n * What the file leaves open, such as an attribute absent at a callsite with\n * a spread, gets no token.\n *\n * Works on oxc (ESTree) and Babel JSX trees alike.\n */\n\nexport const EXPRESSION_FACTS_ATTRIBUTE = \"data-tempo-expr\";\nexport const DYNAMIC_SLOT_FACT = \"#slot\";\n\ntype Node = { type: string; [key: string]: unknown };\n\n/**\n * The stamp for one element, or undefined when there is nothing to write.\n * An element with a spread attribute always gets a stamp, empty when it has\n * no fact: annotations land after every spread, so its own value replaces\n * one a caller's props would otherwise carry onto it.\n */\nexport function expressionFacts(\n element: unknown,\n parentType: string | null,\n): string | undefined {\n const opening = (element as { openingElement: { attributes: Node[] } })\n .openingElement;\n const attributes = opening.attributes;\n const facts: string[] = [];\n if (parentType !== \"JSXElement\" && parentType !== \"JSXFragment\")\n facts.push(DYNAMIC_SLOT_FACT);\n\n // The writer reads an attribute's last occurrence, so only that one counts.\n const last = new Map<string, number>();\n attributes.forEach((attribute, index) => {\n const name = attributeName(attribute);\n if (name !== null) last.set(name, index);\n });\n let lastSpread = -1;\n attributes.forEach((attribute, index) => {\n if (attribute.type === \"JSXSpreadAttribute\") lastSpread = index;\n });\n for (const [name, index] of last) {\n if (unstamped(name)) continue;\n const overridden = index < lastSpread;\n const value = attributes[index]!.value as Node | null;\n // A bare attribute is `true`, not an expression.\n if (value === null) continue;\n if (name === \"style\" && !overridden) {\n facts.push(...styleFacts(value));\n continue;\n }\n if (overridden || !isLiteralValue(value)) facts.push(name);\n }\n\n if (facts.length > 0) return facts.join(\" \");\n return lastSpread >= 0 ? \"\" : undefined;\n}\n\n/** The facts one stamp holds, the inverse of `expressionFacts`. No stamp\n * holds none. */\nexport function stampedFacts(stamp: string | undefined): ReadonlySet<string> {\n return new Set((stamp ?? \"\").split(\" \").filter(Boolean));\n}\n\nfunction attributeName(attribute: Node): string | null {\n if (attribute.type !== \"JSXAttribute\") return null;\n const name = attribute.name as Node;\n if (name.type === \"JSXIdentifier\") return name.name as string;\n if (name.type === \"JSXNamespacedName\") {\n const namespace = (name.namespace as Node).name as string;\n return `${namespace}:${(name.name as Node).name as string}`;\n }\n return null;\n}\n\n/** Props the stamp leaves out: Tempo's own annotations, and `key`, which\n * the canvas reads from the layer. A handler, `ref` or `children` is\n * stamped although no canvas edit writes it: it renders no DOM attribute,\n * so this is where the canvas learns that an element is not plain rich\n * text (review2 r2 R3-A: un-bold of `<b onClick={f}>` deleted the handler). */\nfunction unstamped(name: string): boolean {\n return name === \"key\" || name.startsWith(\"data-tempo-\");\n}\n\nfunction styleFacts(value: Node): string[] {\n const expression =\n value.type === \"JSXExpressionContainer\"\n ? unwrap(value.expression as Node)\n : value;\n if (expression.type !== \"ObjectExpression\") return [\"style\"];\n const properties = expression.properties as Node[];\n const last = new Map<string, number>();\n properties.forEach((property, index) => {\n const key = styleKey(property);\n if (key !== null) last.set(key, index);\n });\n const facts: string[] = [];\n for (const [key, index] of last) {\n const property = properties[index]!;\n const overridden = properties\n .slice(index + 1)\n .some((later) => later.type === \"SpreadElement\" || later.computed);\n const literal =\n property.type !== \"ObjectMethod\" &&\n !property.shorthand &&\n isLiteral(property.value as Node);\n if (overridden || !literal) facts.push(`style.${key}`);\n }\n return facts;\n}\n\n/** A property's key as the writer names it; computed keys have no name. */\nfunction styleKey(property: Node): string | null {\n const isProperty =\n property.type === \"Property\" ||\n property.type === \"ObjectProperty\" ||\n property.type === \"ObjectMethod\";\n if (!isProperty || property.computed) return null;\n const key = property.key as Node;\n if (key.type === \"Identifier\") return key.name as string;\n const isString =\n (key.type === \"Literal\" || key.type === \"StringLiteral\") &&\n typeof key.value === \"string\";\n return isString ? (key.value as string) : null;\n}\n\n/** An attribute value the writer can rewrite in place: a JSX string, or a\n * container holding one literal. */\nfunction isLiteralValue(value: Node): boolean {\n if (value.type === \"Literal\" || value.type === \"StringLiteral\") return true;\n if (value.type !== \"JSXExpressionContainer\") return false;\n return isLiteral(value.expression as Node);\n}\n\n/** The writer's literal: a string, a finite number, a boolean, or a signed\n * number, inside any parentheses. */\nfunction isLiteral(node: Node): boolean {\n const current = unwrap(node);\n if (current.type === \"UnaryExpression\") {\n const signed = current.operator === \"-\" || current.operator === \"+\";\n return signed && isNumber(current.argument as Node);\n }\n if (isNumber(current)) return true;\n if (current.type === \"StringLiteral\" || current.type === \"BooleanLiteral\")\n return true;\n const value = current.value;\n return (\n current.type === \"Literal\" &&\n (typeof value === \"string\" || typeof value === \"boolean\")\n );\n}\n\nfunction isNumber(node: Node): boolean {\n const numeric = node.type === \"Literal\" || node.type === \"NumericLiteral\";\n return (\n numeric && typeof node.value === \"number\" && Number.isFinite(node.value)\n );\n}\n\nfunction unwrap(node: Node): Node {\n let current = node;\n while (current.type === \"ParenthesizedExpression\")\n current = current.expression as Node;\n return current;\n}\n","/**\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","import { readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\n/** This package's published name, as declared in its package.json. */\nexport const SDK_PACKAGE_NAME = \"tempo-sdk\";\n\nconst SDK_NODE_MODULES_SEGMENT = `/node_modules/${SDK_PACKAGE_NAME}/`;\n\n/**\n * A predicate for \"this file belongs to tempo-sdk itself\". The SDK's own\n * components (storyboard shells, error boundaries, admission gates) are\n * canvas plumbing, never authored UI, so no annotation entry point may stamp\n * source locations on them — the canvas treats every stamped element as user\n * code.\n *\n * A project can reach SDK files under many spellings: a published copy in\n * node_modules, a pnpm store path, a workspace link, a symlink, or a source\n * alias into a checkout. Ownership is therefore decided by where the file\n * really lives — the nearest package.json above its real path declares this\n * package — and not by the id's spelling or the caller's include/exclude\n * patterns. A package nested inside the SDK checkout (the demo apps) has its\n * own package.json and stays annotatable.\n */\nexport function createSdkFileMatcher(): (file: string) => boolean {\n // Directory → whether its nearest enclosing package.json is this package.\n const ownerIsSdkByDirectory = new Map<string, boolean>();\n\n const nearestPackageIsSdk = (startDirectory: string): boolean => {\n const visited: string[] = [];\n let directory = startDirectory;\n let isSdk = false;\n while (true) {\n const cached = ownerIsSdkByDirectory.get(directory);\n if (cached !== undefined) {\n isSdk = cached;\n break;\n }\n visited.push(directory);\n const manifest = readPackageManifest(directory);\n if (manifest !== undefined) {\n isSdk = manifest?.name === SDK_PACKAGE_NAME;\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const entry of visited) ownerIsSdkByDirectory.set(entry, isSdk);\n return isSdk;\n };\n\n return (file) => {\n if (file.replace(/\\\\/g, \"/\").includes(SDK_NODE_MODULES_SEGMENT)) {\n return true;\n }\n let realFile = file;\n try {\n realFile = realpathSync.native(file);\n } catch {\n // Virtual or not-yet-written ids keep their authored spelling.\n }\n return nearestPackageIsSdk(dirname(realFile));\n };\n}\n\n/** The package.json in `directory`: `undefined` when there is none, `null`\n * when one exists but cannot be read as a manifest (still a package\n * boundary, just not this package). */\nfunction readPackageManifest(\n directory: string,\n): { name?: unknown } | null | undefined {\n let text: string;\n try {\n text = readFileSync(join(directory, \"package.json\"), \"utf8\");\n } catch {\n return undefined;\n }\n try {\n const manifest: unknown = JSON.parse(text);\n return manifest && typeof manifest === \"object\" ? manifest : null;\n } catch {\n return null;\n }\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS,YAAY,WAAW,OAAO,eAAe;;;ACD/D,SAAS,iBAAkC;AA0M3C,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAiB,oBAAI,IAAkB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