tempo-sdk 0.0.57 → 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 +4 -2
  32. package/dist/canvas/index.js +138 -34
  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-U3SLJNRS.js → chunk-6IR5JY6W.js} +106 -7
  44. package/dist/chunk-6IR5JY6W.js.map +1 -0
  45. package/dist/{chunk-QXL6GL2P.js → chunk-6W6UKDSY.js} +46 -5
  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-U64AHDHZ.js → chunk-EYKOOLPL.js} +380 -34
  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-RHHVVWAC.js → chunk-PXDTH36X.js} +14 -12
  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-EMYYTS6D.js → chunk-Q2A46HHW.js} +19 -14
  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 +18 -13
  77. package/dist/expo/plugin.cjs.map +1 -1
  78. package/dist/expo/plugin.js +1 -1
  79. package/dist/expo-babel-plugin.cjs +18 -13
  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 -2294
  84. package/dist/index.js.map +1 -1
  85. package/dist/nextjs/plugin.cjs +45 -4
  86. package/dist/nextjs/plugin.cjs.map +1 -1
  87. package/dist/nextjs/plugin.js +1 -1
  88. package/dist/nextjs-loader.cjs +63 -17
  89. package/dist/nextjs-loader.cjs.map +1 -1
  90. package/dist/nextjs.cjs +45 -4
  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-BtQuVGpl.d.ts → storyboard-4YdTYq_e.d.ts} +3 -1
  96. package/dist/svelte.js +7 -1075
  97. package/dist/svelte.js.map +1 -1
  98. package/package.json +45 -4
  99. package/dist/chunk-2IQD2KPS.js.map +0 -1
  100. package/dist/chunk-5BHIHP25.js.map +0 -1
  101. package/dist/chunk-EMYYTS6D.js.map +0 -1
  102. package/dist/chunk-N2TYN3RB.js.map +0 -1
  103. package/dist/chunk-QXL6GL2P.js.map +0 -1
  104. package/dist/chunk-RHHVVWAC.js.map +0 -1
  105. package/dist/chunk-TL4MGN7E.js.map +0 -1
  106. package/dist/chunk-U3SLJNRS.js.map +0 -1
  107. package/dist/chunk-U64AHDHZ.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,UAA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AAA;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":["../nextjs.ts","../host-identity.ts","../package.json","../release-channel.ts"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { TEMPO_SDK_CHANNEL } from \"./release-channel\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER = \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\";\n\nexport interface TempoHostIdentity {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n sdkChannel: string;\n pluginActive: boolean;\n framework: TempoHostFramework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity(\n framework: TempoHostFramework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n sdkChannel: TEMPO_SDK_CHANNEL,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.57\",\n \"publishConfig\": {\n \"tag\": \"sdk-v2-latest\"\n },\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"peerDependencies\": {\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import sdkPackage from \"./package.json\" with { type: \"json\" };\n\n/** Shared by the app, generated projects and the SDK host identity. */\nexport const TEMPO_SDK_CHANNEL = sdkPackage.publishConfig.tag;\n\nexport function sdkChannelGeneration(channel: unknown): number | null {\n if (typeof channel !== \"string\") return null;\n const match = /^sdk-v([1-9]\\d*)-latest$/.exec(channel);\n return match ? Number(match[1]) : null;\n}\n\nif (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {\n throw new Error(\"tempo-sdk publishConfig.tag must be sdk-v<N>-latest\");\n}\n\n/** Preserve local development links; registry installs follow the app channel. */\nexport function managedTempoSdkSpec(spec: string): string {\n const generation = sdkChannelGeneration(spec);\n if (\n generation !== null &&\n generation > sdkChannelGeneration(TEMPO_SDK_CHANNEL)!\n ) {\n throw new Error(\n `This project requires tempo-sdk@${spec}. Update Tempo before opening it; this app supports ${TEMPO_SDK_CHANNEL}.`,\n );\n }\n if (/^(workspace:|file:|link:|portal:|git|https?:|ssh:|github:)/.test(spec))\n return spec;\n return TEMPO_SDK_CHANNEL;\n}\n"],"mappings":";AAiBA,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AA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;AACzC;AAGO,SAAS,yBAA+B;AAC7C,2BAAyB;AAC3B;AAkBO,SAAS,kBACd,gBAAoC,CAAC,GACa;AAClD,SAAO,CAAC,mBAAoD;AAC1D,UAAM,cAA8B,kBAAkB,CAAC;AAEvD,QAAI,CAAC,QAAQ,IAAI,MAAO,QAAO;AAI/B,UAAM,aAAa,UAAU,kBAAkB;AAC/C,UAAM,UAAU,UAAU,kBAAkB;AAC5C,UAAM,gBAAgB,UAAU,oBAAoB,OAAO;AAC3D,UAAM,kBAAkB,UAAU,qBAAqB,OAAO;AAE9D,UAAM,UAAU,mBAAmB,YAAY,aAAa;AAE5D,UAAM,gBAAgB,kBAClB,YAAY,cAAc,QAC1B,YAAY;AAChB,UAAM,cAAc,oBAAoB,eAAe,OAAO;AAE9D,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA,YAAY,WAAW;AAAA,IACzB;AAEA,UAAM,OAAuB;AAAA,MAC3B,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAMA,UAAM,kBAAkB,QAAQ,IAAI;AACpC,QAAI,iBAAiB;AACnB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,CAAC,eAAe;AAClB,UAAI,iBAAiB;AACnB,aAAK,eAAe;AAAA,UAClB,GAAG,YAAY;AAAA,UACf,OAAO;AAAA,QACT;AAAA,MACF,OAAO;AACL,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAEA,IAAO,iBAAQ;AAYR,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["resolve","resolve"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas/parser.ts"],"sourcesContent":["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;\n storyboard.filepathSpan = filepath?.valueSpan;\n storyboard.filepathAttributeSpan = filepath?.attributeSpan;\n storyboard.src = src?.value;\n storyboard.srcSpan = src?.valueSpan;\n storyboard.srcAttributeSpan = src?.attributeSpan;\n if (!filepath && !src) {\n errors.push({\n message:\n '<HtmlStoryboard> must include a literal \"filepath\" or \"src\" prop',\n span: toSpan(openingElement),\n kind: \"degraded\",\n });\n }\n }\n\n globalErrors.push(...errors);\n return storyboard;\n}\n\nfunction readDirectCanvasStoryboardElements(\n canvasElement: any,\n imports: ParsedImports,\n): StoryboardElement[] {\n const elements: StoryboardElement[] = [];\n\n for (const child of canvasElement.children ?? []) {\n if (child?.type !== \"JSXElement\") continue;\n const component = resolveSdkComponent(child.openingElement?.name, imports);\n if (isStoryboardSdkComponent(component)) {\n elements.push({ element: child, component });\n }\n }\n\n return elements;\n}\n\nfunction reportDuplicateStoryboardIds(\n storyboards: ParsedCanvasStoryboard[],\n errors: CanvasParseError[],\n) {\n const byId = new Map<string, ParsedCanvasStoryboard[]>();\n\n for (const storyboard of storyboards) {\n if (!storyboard.storyboardKey) continue;\n const matching = byId.get(storyboard.storyboardKey);\n if (matching) {\n matching.push(storyboard);\n } else {\n byId.set(storyboard.storyboardKey, [storyboard]);\n }\n }\n\n for (const [storyboardKey, matching] of byId) {\n if (matching.length < 2) continue;\n errors.push({\n message: `Duplicate storyboard id \"${storyboardKey}\" (${matching.length} declarations) — storyboard ids must be unique`,\n span: matching[1]?.jsxElementSpan,\n kind: \"structural\",\n });\n }\n}\n\nfunction validateCanvasChildren(\n canvasElement: any,\n imports: ParsedImports,\n): CanvasParseError[] {\n const errors: CanvasParseError[] = [];\n\n for (const child of canvasElement.children ?? []) {\n if (!child) continue;\n if (child.type === \"JSXText\") {\n if (typeof child.value === \"string\" && child.value.trim() === \"\") {\n continue;\n }\n }\n if (child.type === \"JSXExpressionContainer\") {\n if (child.expression?.type === \"JSXEmptyExpression\") {\n continue;\n }\n errors.push({\n message:\n \"<Canvas> children must be static storyboard declarations, not expressions\",\n span: toSpan(child),\n kind: \"structural\",\n });\n continue;\n }\n if (child.type === \"JSXElement\") {\n const component = resolveSdkComponent(\n child.openingElement?.name,\n imports,\n );\n if (\n component === \"Storyboard\" ||\n component === \"SvelteStoryboard\" ||\n component === \"LegacyStoryboardV1\" ||\n component === \"RouteStoryboard\" ||\n component === \"HtmlStoryboard\"\n ) {\n continue;\n }\n }\n errors.push({\n message:\n \"<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations\",\n span: toSpan(child),\n kind: \"structural\",\n });\n }\n\n return errors;\n}\n\n/**\n * Reads the opt-in `vrt` prop on a `<Storyboard>` (TEM-1775). Only statically\n * analyzable literal shapes are tracked — the mark is a build-time manifest,\n * so a dynamic expression is a degraded parse error, never a guess:\n * `vrt` / `vrt={true}` → tracked with defaults ({})\n * `vrt={false}` → untracked (absent)\n * `vrt={{ threshold, skip, ignore }}` → tracked with overrides\n */\nfunction readVrt(\n openingElement: any,\n errors: CanvasParseError[],\n): {\n /** Null when the attribute exists but reads as untracked (`vrt={false}`,\n * dynamic / malformed forms). The span stays so editors can target the\n * declaration without inserting a duplicate. */\n value: ParsedStoryboardVrt | null;\n attributeSpan?: CanvasSourceSpan;\n} | null {\n const attribute = getAttribute(openingElement, \"vrt\");\n if (!attribute) return null;\n const attributeSpan = toSpan(attribute);\n\n // Bare `vrt` (no value) — tracked with defaults.\n if (attribute.value == null) {\n return { value: {}, attributeSpan };\n }\n\n const expression = unwrapTsExpression(\n unwrapAttributeExpression(attribute.value),\n );\n if (expression?.type === \"Literal\" && expression.value === true) {\n return { value: {}, attributeSpan };\n }\n if (expression?.type === \"Literal\" && expression.value === false) {\n return { value: null, attributeSpan };\n }\n if (expression?.type !== \"ObjectExpression\") {\n errors.push({\n message:\n \"<Storyboard> vrt must be a boolean literal or an object literal ({ threshold?, skip?, ignore? })\",\n span: toSpan(expression) ?? attributeSpan,\n kind: \"degraded\",\n });\n return { value: null, attributeSpan };\n }\n\n const value: ParsedStoryboardVrt = {};\n for (const property of expression.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) {\n errors.push({\n message: \"<Storyboard> vrt must contain only literal properties\",\n span: toSpan(property ?? expression),\n kind: \"degraded\",\n });\n continue;\n }\n const key = readPropertyKeyName(property.key);\n if (key === \"threshold\") {\n // Capped at 0.5: beyond that pixelmatch is effectively blind and the\n // \"tracked\" mark would be a lie — black→white passes at threshold 1.\n const threshold = readNumberLiteral(property.value);\n if (threshold && threshold.value >= 0 && threshold.value <= 0.5) {\n value.threshold = threshold.value;\n } else {\n errors.push({\n message:\n \"<Storyboard> vrt.threshold must be a number literal between 0 and 0.5\",\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n continue;\n }\n if (key === \"skip\") {\n if (\n property.value?.type === \"Literal\" &&\n typeof property.value.value === \"boolean\"\n ) {\n if (property.value.value) value.skip = true;\n } else {\n errors.push({\n message: \"<Storyboard> vrt.skip must be a boolean literal\",\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n continue;\n }\n if (key === \"ignore\") {\n const regions = readVrtIgnoreRegions(property.value, errors);\n if (regions) value.ignore = regions;\n continue;\n }\n errors.push({\n message: `<Storyboard> vrt has unknown property \"${key ?? \"?\"}\" — expected threshold, skip, or ignore`,\n span: toSpan(property),\n kind: \"degraded\",\n });\n }\n\n return { value, attributeSpan };\n}\n\nfunction readVrtIgnoreRegions(\n node: any,\n errors: CanvasParseError[],\n): ParsedStoryboardVrtIgnoreRegion[] | null {\n if (node?.type !== \"ArrayExpression\") {\n errors.push({\n message:\n \"<Storyboard> vrt.ignore must be an array of { x, y, w, h } literals\",\n span: toSpan(node),\n kind: \"degraded\",\n });\n return null;\n }\n const regions: ParsedStoryboardVrtIgnoreRegion[] = [];\n for (const element of node.elements ?? []) {\n const region: Partial<ParsedStoryboardVrtIgnoreRegion> = {};\n for (const key of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const property = getObjectProperty(element, key);\n const number = property ? readNumberLiteral(property.value) : null;\n if (number) region[key] = number.value;\n }\n if (\n region.x === undefined ||\n region.y === undefined ||\n region.w === undefined ||\n region.h === undefined\n ) {\n errors.push({\n message:\n \"<Storyboard> vrt.ignore regions must be { x, y, w, h } number literals\",\n span: toSpan(element) ?? toSpan(node),\n kind: \"degraded\",\n });\n return null;\n }\n regions.push(region as ParsedStoryboardVrtIgnoreRegion);\n }\n return regions;\n}\n\nfunction readComponentReference(\n openingElement: any,\n imports: ParsedImports,\n source: string,\n): ParsedCanvasComponentReference | null {\n const attribute = getAttribute(openingElement, \"component\");\n const expression = unwrapAttributeExpression(attribute?.value);\n const span = toSpan(expression);\n if (!expression || !span) return null;\n\n const localName =\n expression.type === \"Identifier\"\n ? expression.name\n : expression.type === \"MemberExpression\" &&\n expression.object?.type === \"Identifier\"\n ? expression.object.name\n : undefined;\n\n return {\n expression: source.slice(span.start, span.end),\n span,\n attributeSpan: toSpan(attribute),\n localName,\n import: localName ? imports.byLocalName.get(localName) : undefined,\n };\n}\n\nfunction readRenderComponentReference(\n renderValue: any,\n imports: ParsedImports,\n source: string,\n): ParsedCanvasComponentReference | null {\n if (renderValue?.type !== \"ArrowFunctionExpression\") return null;\n const body = unwrapTsExpression(renderValue.body);\n if (body?.type !== \"JSXElement\") return null;\n const name = body.openingElement?.name;\n if (name?.type !== \"JSXIdentifier\") return null;\n\n const span = toSpan(name);\n if (!span || typeof name.name !== \"string\") return null;\n\n return {\n expression: source.slice(span.start, span.end),\n span,\n localName: name.name,\n import: imports.byLocalName.get(name.name),\n };\n}\n\nfunction readExpressionReference(\n openingElement: any,\n name: string,\n source: string,\n): ParsedCanvasExpressionReference | undefined {\n const attribute = getAttribute(openingElement, name);\n const expression = unwrapAttributeExpression(attribute?.value);\n const span = toSpan(expression);\n if (!expression || !span) return undefined;\n return {\n expression: source.slice(span.start, span.end),\n span,\n attributeSpan: toSpan(attribute),\n };\n}\n\nfunction isIdentifierExpression(expression: string): boolean {\n return /^[A-Za-z_$][\\w$]*$/.test(expression);\n}\n\nfunction readLayout(\n openingElement: any,\n componentName: string,\n): {\n value: ParsedCanvasLayout;\n attributeSpan?: CanvasSourceSpan;\n spans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n} {\n const 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"],"mappings":";AAAA,SAAS,iBAAkC;AA0M3C,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAiB,oBAAI,IAAkB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,2BAA2B,oBAAI,IAAI;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAqC;AAAA,EACzC,GAAG;AAAA,EACH,GAAG;AACL;AAEA,IAAM,0BAA8C;AAAA,EAClD,GAAG;AAAA,EACH,OAAO;AAAA,EACP,QAAQ;AACV;AAIO,IAAM,8BACX;AAEK,SAAS,gBACd,UACA,QACkB;AAClB,QAAM,SAA6B,CAAC;AACpC,MAAI;AAEJ,MAAI;AACF,UAAM,SAAS,UAAU,UAAU,MAAM;AACzC,cAAU,OAAO;AACjB,eAAW,SAAS,OAAO,UAAU,CAAC,GAAG;AACvC,aAAO,KAAK;AAAA,QACV,SAAS,MAAM,WAAW;AAAA,QAC1B,MAAM,OAAO,KAAK,KAAK,OAAO,OAAO,SAAS,CAAC,CAAC;AAAA,QAChD,MAAM;AAAA,MACR,CAAC;AAAA,IACH;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL;AAAA,MACA,UAAU,iBAAiB,QAAQ;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