tempo-sdk 0.0.69 → 0.0.75

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 (109) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +2 -2
  3. package/dist/astro.js +17 -11
  4. package/dist/astro.js.map +1 -1
  5. package/dist/canvas/astro.d.ts +1 -1
  6. package/dist/canvas/astro.js +2 -2
  7. package/dist/canvas/editor.d.ts +15 -5
  8. package/dist/canvas/editor.js +13 -8
  9. package/dist/canvas/editor.js.map +1 -1
  10. package/dist/canvas/flutter-preview.d.ts +18 -0
  11. package/dist/canvas/flutter-preview.js +9 -0
  12. package/dist/canvas/flutter-preview.js.map +1 -0
  13. package/dist/canvas/index.d.ts +33 -2
  14. package/dist/canvas/index.js +1134 -26
  15. package/dist/canvas/index.js.map +1 -1
  16. package/dist/canvas/interact-projection.js +5 -4
  17. package/dist/canvas/parser.d.ts +142 -3
  18. package/dist/canvas/parser.js +14 -1
  19. package/dist/canvas/svelte.d.ts +1 -1
  20. package/dist/canvas/svelte.js +2 -2
  21. package/dist/canvas/vue.d.ts +74 -0
  22. package/dist/canvas/vue.js +264 -0
  23. package/dist/canvas/vue.js.map +1 -0
  24. package/dist/{chunk-6BSLP7P3.js → chunk-2YX4WVFH.js} +49 -7
  25. package/dist/chunk-2YX4WVFH.js.map +1 -0
  26. package/dist/chunk-5HIIF354.js +67 -0
  27. package/dist/chunk-5HIIF354.js.map +1 -0
  28. package/dist/{chunk-FE6TYCLF.js → chunk-5VIBKVFO.js} +2 -2
  29. package/dist/{chunk-FE6TYCLF.js.map → chunk-5VIBKVFO.js.map} +1 -1
  30. package/dist/{chunk-77DZCV5Z.js → chunk-CXIW4IKC.js} +2 -2
  31. package/dist/chunk-CYQE3TLC.js +37 -0
  32. package/dist/chunk-CYQE3TLC.js.map +1 -0
  33. package/dist/{chunk-WTQQOLXM.js → chunk-DNSCVLKV.js} +1571 -1410
  34. package/dist/chunk-DNSCVLKV.js.map +1 -0
  35. package/dist/chunk-EGRHWZRV.js +1 -0
  36. package/dist/chunk-EGRHWZRV.js.map +1 -0
  37. package/dist/{chunk-EYKOOLPL.js → chunk-GKDDNDG3.js} +1039 -134
  38. package/dist/chunk-GKDDNDG3.js.map +1 -0
  39. package/dist/{chunk-KOSJXE4G.js → chunk-H6BQZOAW.js} +4 -3
  40. package/dist/chunk-HOBTDB6G.js +112 -0
  41. package/dist/chunk-HOBTDB6G.js.map +1 -0
  42. package/dist/chunk-HZXQPM4W.js +285 -0
  43. package/dist/chunk-HZXQPM4W.js.map +1 -0
  44. package/dist/chunk-SGN7BDRE.js +16 -0
  45. package/dist/chunk-SGN7BDRE.js.map +1 -0
  46. package/dist/{chunk-F23JGM4U.js → chunk-UBTL6JUF.js} +6 -2
  47. package/dist/{chunk-F23JGM4U.js.map → chunk-UBTL6JUF.js.map} +1 -1
  48. package/dist/{chunk-2JRAG36X.js → chunk-WBMO4ZYO.js} +2 -2
  49. package/dist/chunk-WBMO4ZYO.js.map +1 -0
  50. package/dist/{chunk-K3EYTZLL.js → chunk-WTXOWQ7N.js} +3 -1
  51. package/dist/chunk-WTXOWQ7N.js.map +1 -0
  52. package/dist/{chunk-Q2A46HHW.js → chunk-XFPFWTWX.js} +276 -43
  53. package/dist/chunk-XFPFWTWX.js.map +1 -0
  54. package/dist/chunk-XMFVWJUY.js +342 -0
  55. package/dist/chunk-XMFVWJUY.js.map +1 -0
  56. package/dist/{chunk-PXDTH36X.js → chunk-Y72PIE3I.js} +212 -20
  57. package/dist/chunk-Y72PIE3I.js.map +1 -0
  58. package/dist/{chunk-6IR5JY6W.js → chunk-YECMP34I.js} +41 -9
  59. package/dist/chunk-YECMP34I.js.map +1 -0
  60. package/dist/{chunk-NSKYOKG5.js → chunk-ZXC7SZIT.js} +278 -26
  61. package/dist/chunk-ZXC7SZIT.js.map +1 -0
  62. package/dist/{controls-reader-SNMI2UY7.js → controls-reader-Z7OQWYWQ.js} +4 -3
  63. package/dist/{controls-reader-SNMI2UY7.js.map → controls-reader-Z7OQWYWQ.js.map} +1 -1
  64. package/dist/expo/plugin.cjs +301 -58
  65. package/dist/expo/plugin.cjs.map +1 -1
  66. package/dist/expo/plugin.js +1 -1
  67. package/dist/expo-babel-plugin.cjs +301 -58
  68. package/dist/expo-babel-plugin.cjs.map +1 -1
  69. package/dist/expo-babel-plugin.js +1 -1
  70. package/dist/flutter-preview-path.d.ts +9 -0
  71. package/dist/flutter-preview-path.js +16 -0
  72. package/dist/flutter-preview-path.js.map +1 -0
  73. package/dist/index.d.ts +16 -15
  74. package/dist/index.js +9 -6
  75. package/dist/nextjs/plugin.cjs +46 -5
  76. package/dist/nextjs/plugin.cjs.map +1 -1
  77. package/dist/nextjs/plugin.js +1 -1
  78. package/dist/nextjs-loader.cjs +343 -68
  79. package/dist/nextjs-loader.cjs.map +1 -1
  80. package/dist/nextjs.cjs +48 -6
  81. package/dist/nextjs.cjs.map +1 -1
  82. package/dist/nextjs.d.cts +9 -1
  83. package/dist/nextjs.d.ts +9 -1
  84. package/dist/nextjs.js +1 -1
  85. package/dist/nuxt/runtime/identity.d.ts +24 -0
  86. package/dist/nuxt/runtime/identity.js +18 -0
  87. package/dist/nuxt/runtime/identity.js.map +1 -0
  88. package/dist/nuxt.d.ts +102 -0
  89. package/dist/nuxt.js +5673 -0
  90. package/dist/nuxt.js.map +1 -0
  91. package/dist/{storyboard-4YdTYq_e.d.ts → storyboard-CMJVBSXn.d.ts} +9 -3
  92. package/dist/svelte.d.ts +4 -2
  93. package/dist/svelte.js +21 -88
  94. package/dist/svelte.js.map +1 -1
  95. package/dist/vue.d.ts +66 -0
  96. package/dist/vue.js +1403 -0
  97. package/dist/vue.js.map +1 -0
  98. package/package.json +48 -5
  99. package/dist/chunk-2JRAG36X.js.map +0 -1
  100. package/dist/chunk-6BSLP7P3.js.map +0 -1
  101. package/dist/chunk-6IR5JY6W.js.map +0 -1
  102. package/dist/chunk-EYKOOLPL.js.map +0 -1
  103. package/dist/chunk-K3EYTZLL.js.map +0 -1
  104. package/dist/chunk-NSKYOKG5.js.map +0 -1
  105. package/dist/chunk-PXDTH36X.js.map +0 -1
  106. package/dist/chunk-Q2A46HHW.js.map +0 -1
  107. package/dist/chunk-WTQQOLXM.js.map +0 -1
  108. /package/dist/{chunk-77DZCV5Z.js.map → chunk-CXIW4IKC.js.map} +0 -0
  109. /package/dist/{chunk-KOSJXE4G.js.map → chunk-H6BQZOAW.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../modules/iframe-projection/html/watch-head.ts"],"sourcesContent":["/**\n * Head Capture Utility\n *\n * Captures relevant <head> content from a document, excluding scripts\n * and resolving relative URLs to absolute.\n *\n * ## Shared Observer Pattern\n *\n * Uses a singleton HeadTracker that maintains one MutationObserver per document,\n * shared across all subscriptions. This avoids creating 50+ observers when there\n * are many watchers on the same page.\n */\n\nimport {\n CSS_RUNTIME_MUTATION,\n observeRuntimeMutations,\n} from \"./runtime-mutations\";\n\n/** Elements to include from <head> */\nconst INCLUDE_TAGS = new Set([\"STYLE\", \"META\", \"BASE\", \"LINK\"]);\n\n/** Link rel values to include (stylesheet-related) */\nconst INCLUDE_LINK_RELS = new Set([\"stylesheet\"]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Tracker (Shared Observer)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * A subscription to head changes for a specific document.\n * Each subscription maintains its own hasMutations flag since they flush independently.\n */\nexport interface HeadSubscription {\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Flush and get head content. Returns content if isInitial or if mutations occurred. */\n flush(isInitial: boolean): string | undefined;\n /** Unsubscribe from head changes */\n unsubscribe(): void;\n}\n\nexport interface HeadMutationDetails {\n /** Vite stylesheet module ids whose style/link nodes changed in this batch. */\n stylesheetPaths: string[];\n}\n\n/**\n * Singleton tracker that manages shared MutationObservers for head watching.\n * One observer per document, shared across all subscriptions.\n */\nexport interface HeadTracker {\n /** Publish already queued mutations before synchronous root admission. */\n flushPending?(doc: Document): void;\n /** Subscribe to head changes for a document */\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription;\n /** Clean up all observers */\n destroy(): void;\n /** Cardinality only; reads maintained collection sizes and performs no DOM\n * work. Used by the performance trace attached to an emitted capture. */\n readPerfSnapshot(): { observers: number; subscriptions: number };\n}\n\n/** Module-level singleton */\nlet instance: HeadTrackerImpl | null = null;\n\n/**\n * Get the singleton HeadTracker instance.\n */\nexport function getHeadTracker(): HeadTracker {\n if (!instance) {\n instance = new HeadTrackerImpl();\n }\n return instance;\n}\n\n/**\n * Reset the singleton. For testing only.\n * @internal\n */\nexport function _resetHeadTrackerForTesting(): void {\n instance?.destroy();\n instance = null;\n}\n\n/** Internal subscription implementation */\nclass HeadSubscriptionImpl implements HeadSubscription {\n hasMutations = false;\n private doc: Document;\n private callback: (details: HeadMutationDetails) => void;\n private onUnsubscribe: () => void;\n\n constructor(\n doc: Document,\n callback: (details: HeadMutationDetails) => void,\n onUnsubscribe: () => void,\n ) {\n this.doc = doc;\n this.callback = callback;\n this.onUnsubscribe = onUnsubscribe;\n }\n\n flush(isInitial: boolean): string | undefined {\n if (!isInitial && !this.hasMutations) {\n return undefined;\n }\n this.hasMutations = false;\n return captureHead(this.doc);\n }\n\n unsubscribe(): void {\n this.onUnsubscribe();\n }\n\n /** Called by tracker when relevant mutation detected */\n notifyMutation(details: HeadMutationDetails): void {\n this.hasMutations = true;\n this.callback(details);\n }\n}\n\n/** Per-document observer state */\ninterface DocObserverState {\n observer: MutationObserver;\n flushPending(): void;\n stopRuntime(): void;\n subscriptions: Set<HeadSubscriptionImpl>;\n}\n\nclass HeadTrackerImpl implements HeadTracker {\n private docObservers = new Map<Document, DocObserverState>();\n private activeSubscriptions = 0;\n\n flushPending(doc: Document): void {\n this.docObservers.get(doc)?.flushPending();\n }\n\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription {\n let docState = this.docObservers.get(doc);\n\n // Create observer for this document if first subscription\n if (!docState) {\n docState = this.createDocObserver(doc);\n this.docObservers.set(doc, docState);\n }\n\n const subscription = new HeadSubscriptionImpl(doc, onMutation, () => {\n this.unsubscribe(doc, subscription);\n });\n docState.subscriptions.add(subscription);\n this.activeSubscriptions += 1;\n\n return subscription;\n }\n\n private createDocObserver(doc: Document): DocObserverState {\n const subscriptions = new Set<HeadSubscriptionImpl>();\n\n const notify = (details: HeadMutationDetails): void => {\n for (const sub of subscriptions) {\n sub.notifyMutation(details);\n }\n };\n const stopHooks = observeRuntimeMutations(doc);\n const cssChanged = () => notify({ stylesheetPaths: [] });\n doc.addEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n const stopRuntime = () => {\n doc.removeEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n stopHooks();\n };\n\n const observeHead = (head: HTMLHeadElement) => {\n const changed = (mutations: MutationRecord[]) => {\n const details = this.readRelevantMutations(mutations, head);\n if (!details) return;\n notify(details);\n };\n const observer = new MutationObserver(changed);\n observer.observe(head, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n return { observer, flushPending: () => changed(observer.takeRecords()) };\n };\n\n if (doc.head) {\n return { ...observeHead(doc.head), subscriptions, stopRuntime };\n }\n\n // The document has no <head> yet — subscribers can attach before parsing\n // (e.g. a producer created from a frame preload). Watch for the head to\n // appear, then swap in the real observer and report one synthetic\n // mutation so subscribers capture the head they never saw arrive.\n const attachHead = () => {\n const head = doc.head;\n if (!head) return;\n bootstrap.disconnect();\n Object.assign(state, observeHead(head));\n notify({ stylesheetPaths: [] });\n };\n const bootstrap = new MutationObserver(attachHead);\n bootstrap.observe(doc, { childList: true, subtree: true });\n const state: DocObserverState = {\n observer: bootstrap,\n flushPending: attachHead,\n subscriptions,\n stopRuntime,\n };\n return state;\n }\n\n private unsubscribe(doc: Document, sub: HeadSubscriptionImpl): void {\n const docState = this.docObservers.get(doc);\n if (!docState) return;\n\n if (!docState.subscriptions.delete(sub)) return;\n this.activeSubscriptions = Math.max(0, this.activeSubscriptions - 1);\n\n // Disconnect observer if no more subscriptions for this document\n if (docState.subscriptions.size === 0) {\n docState.observer.disconnect();\n docState.stopRuntime();\n this.docObservers.delete(doc);\n }\n }\n\n /**\n * Check if mutations contain changes to elements we care about.\n * This filtering runs once per mutation batch (not once per subscription).\n */\n private readRelevantMutations(\n mutations: MutationRecord[],\n head: HTMLHeadElement,\n ): HeadMutationDetails | null {\n let relevant = false;\n const stylesheetPaths = new Set<string>();\n const collectStylesheetPath = (node: Node | null): void => {\n const element =\n node instanceof Element ? node : (node?.parentElement ?? null);\n if (!element) return;\n const candidates = [\n element,\n ...element.querySelectorAll(\n \"style[data-vite-dev-id], link[rel~='stylesheet']\",\n ),\n ];\n for (const candidate of candidates) {\n if (candidate instanceof HTMLStyleElement) {\n const id = candidate.getAttribute(\"data-vite-dev-id\")?.trim();\n if (id) stylesheetPaths.add(id);\n } else if (\n candidate instanceof HTMLLinkElement &&\n shouldIncludeLink(candidate)\n ) {\n const href = candidate.getAttribute(\"href\")?.trim() || candidate.href;\n if (href) stylesheetPaths.add(href);\n }\n }\n };\n\n for (const mutation of mutations) {\n const target = mutation.target;\n const element = target instanceof Element ? target : target.parentElement;\n\n if (!element || (!head.contains(element) && target !== head)) continue;\n\n // Check if this is a relevant element (one we would capture)\n const tagName = element.tagName;\n if (INCLUDE_TAGS.has(tagName)) {\n // For LINK, check if it's a stylesheet\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(element)) continue;\n }\n relevant = true;\n collectStylesheetPath(element);\n }\n\n // Also trigger for childList mutations on head itself (added/removed elements)\n if (mutation.type === \"childList\" && target === head) {\n relevant = true;\n }\n if (mutation.type === \"childList\") {\n for (const node of mutation.addedNodes) collectStylesheetPath(node);\n for (const node of mutation.removedNodes) collectStylesheetPath(node);\n }\n }\n return relevant ? { stylesheetPaths: [...stylesheetPaths] } : null;\n }\n\n destroy(): void {\n for (const docState of this.docObservers.values()) {\n docState.observer.disconnect();\n docState.stopRuntime();\n docState.subscriptions.clear();\n }\n this.docObservers.clear();\n this.activeSubscriptions = 0;\n }\n\n readPerfSnapshot(): { observers: number; subscriptions: number } {\n return {\n observers: this.docObservers.size,\n subscriptions: this.activeSubscriptions,\n };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Legacy API (Backward Compatibility)\n// These functions delegate to the shared tracker for backward compatibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * State for a head watcher instance.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport interface HeadWatcher {\n /** The document being watched */\n doc: Document;\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Stop watching */\n stop: () => void;\n}\n\n/**\n * Starts watching a document's <head> for mutations.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport function watchHead(doc: Document, onMutation: () => void): HeadWatcher {\n const subscription = getHeadTracker().subscribe(doc, onMutation);\n\n // Wrap subscription in legacy HeadWatcher interface\n return {\n doc,\n get hasMutations() {\n return subscription.hasMutations;\n },\n set hasMutations(value: boolean) {\n subscription.hasMutations = value;\n },\n stop: () => subscription.unsubscribe(),\n };\n}\n\n/**\n * Checks if watcher has any pending head mutations.\n * @deprecated Access subscription.hasMutations directly\n */\nexport function hasPendingHeadChanges(watcher: HeadWatcher): boolean {\n return watcher.hasMutations;\n}\n\n/**\n * Flushes the head watcher, returning captured head content if there were changes.\n * @deprecated Use subscription.flush() directly\n */\nexport function flushHeadWatcher(\n watcher: HeadWatcher,\n isInitial: boolean,\n): string | undefined {\n if (!isInitial && !watcher.hasMutations) {\n return undefined;\n }\n watcher.hasMutations = false;\n return captureHead(watcher.doc);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Capture\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Captures the <head> content from a document.\n *\n * - Includes: <style>, <link rel=\"stylesheet\">, <meta>, <base>\n * - Excludes: <script>, <title>, <link rel=\"icon/preload/etc\">\n * - Resolves relative URLs to absolute using document.baseURI\n *\n * @param doc - The document to capture head from\n * @returns Serialized head content (innerHTML for destination <head>)\n */\nexport type StyleResource = (css: string) => string | null;\n\nfunction serializeHeadStyle(style: Element, resource?: StyleResource): string {\n const type = style.getAttribute(\"type\")?.trim().toLowerCase();\n const href =\n !type || type === \"text/css\" ? resource?.(style.textContent ?? \"\") : null;\n if (href) {\n const link = style.ownerDocument.createElement(\"link\");\n for (const attribute of Array.from(style.attributes))\n if (\n ![\"type\", \"href\", \"rel\", \"integrity\", \"crossorigin\"].includes(\n attribute.name,\n )\n )\n link.setAttribute(attribute.name, attribute.value);\n link.rel = \"stylesheet\";\n link.href = href;\n return link.outerHTML;\n }\n escapeStyleForHtmlSerialization(style);\n return style.outerHTML;\n}\n\nexport function captureHead(doc: Document, resource?: StyleResource): string {\n const head = doc.head;\n if (!head) return \"\";\n\n const baseURI = doc.baseURI;\n const fragments: string[] = [];\n\n for (const child of Array.from(head.children)) {\n const tagName = child.tagName;\n\n // Skip non-included tags\n if (!INCLUDE_TAGS.has(tagName)) continue;\n\n // For <link>, only include stylesheets\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(child)) continue;\n if (isDisabledStylesheet(child)) continue;\n }\n\n // Exclude Content-Security-Policy meta tags (they block srcdoc assets),\n // and theme-color, which tints only the browser's own UI, never the page.\n // Apps rewrite theme-color freely: a Flutter app's Title writes it on\n // every build of every view, into the one document all views share. Kept\n // in the head, views with different colors flipped the head back and\n // forth with no pixel changed, and every flip was a new head revision.\n if (tagName === \"META\") {\n const httpEquiv = child.getAttribute(\"http-equiv\")?.toLowerCase();\n const name = child.getAttribute(\"name\")?.toLowerCase();\n if (\n httpEquiv === \"content-security-policy\" ||\n name === \"content-security-policy\" ||\n name === \"theme-color\"\n ) {\n continue;\n }\n }\n\n // Clone and resolve URLs\n let clone = child.cloneNode(true) as Element;\n materializeStyleElementCssom(child, clone);\n if (tagName === \"LINK\") {\n clone = materializeStylesheetLinkCssom(child, clone);\n }\n resolveUrls(clone, baseURI);\n\n // Strip crossorigin from stylesheet links so they load in no-cors mode\n // in srcdoc projection iframes (which have a null origin that won't\n // match any server's Access-Control-Allow-Origin header)\n if (clone.tagName === \"LINK\") {\n clone.removeAttribute(\"crossorigin\");\n } else if (clone.tagName === \"STYLE\") {\n // The destination stages this head before installing its incoming base.\n // Authored inline/CSSOM styles must not resolve assets against that old\n // document. Materialized links already carry their stylesheet's own base.\n clone.textContent = absolutifyCssReferences(\n clone.textContent ?? \"\",\n baseURI,\n );\n fragments.push(serializeHeadStyle(clone, resource));\n continue;\n }\n\n fragments.push(clone.outerHTML);\n }\n\n fragments.push(...captureAdoptedStyleSheets(doc, resource));\n\n return fragments.join(\"\\n\");\n}\n\n/**\n * Same-origin stylesheets are already readable in the source page. Preserve\n * their authored rules as an inline style before the projection crosses into\n * its null-origin document. Opaque cross-origin sheets remain links and may be\n * handled by a consumer-specific, policy-checked fallback later.\n */\nfunction materializeStylesheetLinkCssom(\n source: Element,\n clone: Element,\n): Element {\n const link = source as HTMLLinkElement;\n const cssText = serializeCssRules(link.sheet);\n if (cssText === null) {\n return clone;\n }\n\n const style = source.ownerDocument.createElement(\"style\");\n for (const attribute of Array.from(source.attributes)) {\n if (\n [\n \"as\",\n \"crossorigin\",\n \"fetchpriority\",\n \"href\",\n \"integrity\",\n \"referrerpolicy\",\n \"rel\",\n ].includes(attribute.name.toLowerCase())\n ) {\n continue;\n }\n style.setAttribute(attribute.name, attribute.value);\n }\n style.setAttribute(\"data-projection-stylesheet-href\", link.href);\n style.textContent = absolutifyCssReferences(cssText, link.href);\n return style;\n}\n\nconst styleSourceEvidence = new WeakMap<\n HTMLStyleElement,\n {\n text: string;\n inline: string | null;\n url: string | null;\n }\n>();\n\n/** Original identity metadata survives CSSOM comment removal; visual CSS stays CSSOM.\n * Decode unchanged authored metadata once per live style. CSSOM serialization\n * still runs on every capture, and a same-task text edit invalidates immediately. */\nfunction retainStyleSourceEvidence(\n source: HTMLStyleElement,\n clone: Element,\n): void {\n clone.removeAttribute(\"data-projection-css-source-map\");\n clone.removeAttribute(\"data-projection-css-source-map-url\");\n const text = source.textContent ?? \"\";\n if (text.length > 5 * 1024 * 1024) {\n styleSourceEvidence.delete(source);\n return;\n }\n const cached = styleSourceEvidence.get(source);\n if (cached?.text === text) {\n if (cached.inline)\n clone.setAttribute(\"data-projection-css-source-map\", cached.inline);\n if (cached.url)\n clone.setAttribute(\"data-projection-css-source-map-url\", cached.url);\n return;\n }\n captureStyleSourceEvidence(text, clone);\n styleSourceEvidence.set(source, {\n text,\n inline: clone.getAttribute(\"data-projection-css-source-map\"),\n url: clone.getAttribute(\"data-projection-css-source-map-url\"),\n });\n}\n\nfunction captureStyleSourceEvidence(text: string, clone: Element): void {\n const reference = [\n ...text.matchAll(/\\/\\*[#@]\\s*sourceMappingURL\\s*=\\s*(\\S+?)\\s*\\*\\//g),\n ].slice(-1)[0]?.[1];\n if (!reference || reference.length > 1024 * 1024) return;\n const inline =\n /^data:application\\/json(?:;charset=[\\w-]+)?(;base64)?,(.*)$/is.exec(\n reference,\n );\n if (!inline) {\n // A detached inline style has no proven relative map base. Absolute URLs\n // can be admitted later against the existing app/server source origin.\n try {\n const url = new URL(reference);\n if (/^https?:$/.test(url.protocol))\n clone.setAttribute(\"data-projection-css-source-map-url\", url.href);\n } catch {}\n return;\n }\n function compact(raw: unknown, depth: number): object | null {\n if (!raw || typeof raw !== \"object\" || depth > 16) return null;\n const map = raw as Record<string, unknown>;\n if (map.version !== 3) return null;\n const sources =\n Array.isArray(map.sources) &&\n map.sources.length <= 4096 &&\n map.sources.every((source) => typeof source === \"string\")\n ? map.sources\n : undefined;\n const sections =\n Array.isArray(map.sections) && map.sections.length <= 256\n ? map.sections.flatMap((section) => {\n const nested =\n section && typeof section === \"object\"\n ? compact(section.map, depth + 1)\n : null;\n return nested ? [{ map: nested }] : [];\n })\n : undefined;\n return {\n version: 3,\n ...(typeof map.file === \"string\" ? { file: map.file } : {}),\n ...(typeof map.sourceRoot === \"string\"\n ? { sourceRoot: map.sourceRoot }\n : {}),\n ...(sources ? { sources } : {}),\n ...(sections ? { sections } : {}),\n };\n }\n try {\n const json = inline[1]\n ? new TextDecoder().decode(\n Uint8Array.from(atob(inline[2]!), (character) =>\n character.charCodeAt(0),\n ),\n )\n : decodeURIComponent(inline[2]!);\n const metadata = compact(JSON.parse(json), 0);\n if (!metadata) return;\n const serialized = JSON.stringify(metadata);\n if (serialized.length <= 64 * 1024)\n clone.setAttribute(\"data-projection-css-source-map\", serialized);\n } catch {}\n}\n\n/**\n * CSSOM is current visual truth even when authored style text is nonempty.\n * A deleted final rule must serialize empty, not revive the original DOM text.\n */\nfunction materializeStyleElementCssom(source: Element, clone: Element): void {\n if (source.tagName !== \"STYLE\" || clone.tagName !== \"STYLE\") {\n return;\n }\n\n const style = source as HTMLStyleElement;\n retainStyleSourceEvidence(style, clone);\n const cssText = serializeCssRules(style.sheet);\n if (cssText !== null) {\n clone.textContent = cssText;\n }\n}\n\nfunction captureAdoptedStyleSheets(\n doc: Document,\n resource?: StyleResource,\n): string[] {\n const sheets = Array.from(doc.adoptedStyleSheets ?? []);\n if (sheets.length === 0) {\n return [];\n }\n\n const fragments: string[] = [];\n for (const sheet of sheets) {\n const cssText = serializeCssRules(sheet);\n if (!cssText) {\n continue;\n }\n const style = doc.createElement(\"style\");\n style.setAttribute(\"data-projection-adopted-stylesheet\", \"true\");\n style.textContent = absolutifyCssReferences(cssText, doc.baseURI);\n fragments.push(serializeHeadStyle(style, resource));\n }\n return fragments;\n}\n\nfunction escapeStyleForHtmlSerialization(style: Element): void {\n style.textContent = (style.textContent ?? \"\").replace(/<\\//gi, \"<\\\\/\");\n}\n\nfunction serializeCssRules(sheet: CSSStyleSheet | null): string | null {\n if (!sheet) {\n return null;\n }\n\n try {\n return Array.from(sheet.cssRules)\n .map((rule) => rule.cssText)\n .join(\"\\n\");\n } catch {\n // Cross-origin or otherwise unreadable stylesheet.\n return null;\n }\n}\n\nfunction absolutifyCssReferences(cssText: string, baseHref: string): string {\n const resolve = (value: string): string => {\n const trimmed = value.trim();\n if (\n !trimmed ||\n trimmed.startsWith(\"#\") ||\n /^(?:data|blob|javascript):/i.test(trimmed)\n ) {\n return /^javascript:/i.test(trimmed) ? \"\" : trimmed;\n }\n try {\n return new URL(trimmed, baseHref).href;\n } catch {\n return trimmed;\n }\n };\n\n return cssText\n .replace(\n /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/gi,\n (_match, quote: string, value: string) =>\n `url(${quote}${resolve(value)}${quote})`,\n )\n .replace(\n /@import\\s+([\"'])([^\"']+)\\1/gi,\n (_match, quote: string, value: string) =>\n `@import ${quote}${resolve(value)}${quote}`,\n );\n}\n\nfunction shouldIncludeLink(element: Element): boolean {\n const rel = element.getAttribute(\"rel\");\n if (!rel) {\n return false;\n }\n return rel\n .toLowerCase()\n .split(/\\s+/)\n .some((token) => INCLUDE_LINK_RELS.has(token));\n}\n\nfunction isDisabledStylesheet(element: Element): boolean {\n const link = element as HTMLLinkElement;\n return link.disabled || link.sheet?.disabled === true;\n}\n\n/**\n * Resolves relative URLs in an element to absolute URLs.\n */\nfunction resolveUrls(element: Element, baseURI: string): void {\n // URL resolution supports retained custom-scheme documents as well as HTTP.\n // This only serializes the source's URLs; protocol authorization remains at\n // the serving boundary. Opaque bases (about:blank, data:) fall through catch.\n // Resolve href attribute (for <link>, <base>)\n const href = element.getAttribute(\"href\");\n if (href && !isAbsoluteUrl(href)) {\n try {\n element.setAttribute(\"href\", new URL(href, baseURI).href);\n } catch {\n // Keep original href if URL resolution fails\n }\n }\n\n // Resolve src attribute (for future-proofing)\n const src = element.getAttribute(\"src\");\n if (src && !isAbsoluteUrl(src)) {\n try {\n element.setAttribute(\"src\", new URL(src, baseURI).href);\n } catch {\n // Keep original src if URL resolution fails\n }\n }\n}\n\n/**\n * Checks if a URL is absolute.\n */\nfunction isAbsoluteUrl(url: string): boolean {\n return /^(https?:)?\\/\\//i.test(url) ||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Ac,GAAG,GAAG;AAC9B,QAAI;AACF,cAAQ,aAAa,OAAO,IAAI,IAAI,KAAK,OAAO,EAAE,IAAI;AAAA,IACxD,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAKA,SAAS,cAAc,KAAsB;AAC3C,SAAO,mBAAmB,KAAK,GAAG,KAAK,IAAI,WAAW,OAAO;AAC/D;","names":[]}
@@ -1,5 +1,6 @@
1
1
  // vite-error-transport.ts
2
2
  var VITE_ERROR_CLIENT_PATH = "/@tempo/server-errors";
3
+ var VITE_ERROR_CLIENT_ID = "\0tempo:server-errors";
3
4
  var VITE_ERROR_STATE_EVENT = "tempo:server-error-state";
4
5
  var VITE_ERROR_SUBSCRIBE_EVENT = "tempo:subscribe-server-errors";
5
6
  var VITE_ERROR_FEED_KEY = "__tempoViteServerErrors";
@@ -37,9 +38,10 @@ if (import.meta.hot) {
37
38
 
38
39
  export {
39
40
  VITE_ERROR_CLIENT_PATH,
41
+ VITE_ERROR_CLIENT_ID,
40
42
  VITE_ERROR_STATE_EVENT,
41
43
  VITE_ERROR_SUBSCRIBE_EVENT,
42
44
  VITE_ERROR_FEED_KEY,
43
45
  VITE_ERROR_CLIENT_SOURCE
44
46
  };
45
- //# sourceMappingURL=chunk-K3EYTZLL.js.map
47
+ //# sourceMappingURL=chunk-WTXOWQ7N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../vite-error-transport.ts"],"sourcesContent":["export const VITE_ERROR_CLIENT_PATH = \"/@tempo/server-errors\";\n/** The resolved id of the client module above, for the plugins serving it. */\nexport const VITE_ERROR_CLIENT_ID = \"\\0tempo:server-errors\";\nexport const VITE_ERROR_STATE_EVENT = \"tempo:server-error-state\";\nexport const VITE_ERROR_SUBSCRIBE_EVENT = \"tempo:subscribe-server-errors\";\nexport const VITE_ERROR_FEED_KEY = \"__tempoViteServerErrors\";\n\nexport type TempoViteServerError = {\n message: string;\n stack?: string;\n file?: string;\n loc?: { file?: string };\n};\n\nexport type TempoViteErrorFeed = {\n subscribe(listener: (error: TempoViteServerError | null) => void): () => void;\n};\n\n// Served by the Vite plugin before application modules. Keeping import.meta\n// in this virtual module preserves the SDK runtime's Metro compatibility.\n// The replaying feed closes the cold-import/startup gap while sharing Vite's\n// existing socket: one SSE connection per host exhausts Chromium's six HTTP\n// connections per origin and prevents later hosts from importing canvases.\nexport const VITE_ERROR_CLIENT_SOURCE = `\nif (import.meta.hot) {\n const hot = import.meta.hot;\n const feed = globalThis.${VITE_ERROR_FEED_KEY} ??= (() => {\n const listeners = new Set();\n let hasState = false;\n let state;\n return {\n subscribe(listener) {\n listeners.add(listener);\n if (hasState) listener(state);\n return () => listeners.delete(listener);\n },\n publish(next) {\n hasState = true;\n state = next;\n for (const listener of listeners) listener(state);\n },\n };\n })();\n const publish = (state) => feed.publish(state);\n const subscribe = () => hot.send(${JSON.stringify(VITE_ERROR_SUBSCRIBE_EVENT)});\n hot.on(${JSON.stringify(VITE_ERROR_STATE_EVENT)}, publish);\n hot.on(\"vite:ws:connect\", subscribe);\n subscribe();\n hot.dispose(() => {\n hot.off(${JSON.stringify(VITE_ERROR_STATE_EVENT)}, publish);\n hot.off(\"vite:ws:connect\", subscribe);\n });\n}\n`;\n"],"mappings":";AAAO,IAAM,yBAAyB;AAE/B,IAAM,uBAAuB;AAC7B,IAAM,yBAAyB;AAC/B,IAAM,6BAA6B;AACnC,IAAM,sBAAsB;AAkB5B,IAAM,2BAA2B;AAAA;AAAA;AAAA,4BAGZ,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAkBV,KAAK,UAAU,0BAA0B,CAAC;AAAA,WACpE,KAAK,UAAU,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA,cAInC,KAAK,UAAU,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -1,23 +1,150 @@
1
1
  // canvas-component-reference.ts
2
- import { realpathSync } from "fs";
2
+ import { realpathSync as realpathSync2 } from "fs";
3
3
  import { dirname, isAbsolute, normalize, posix, resolve } from "path";
4
4
 
5
+ // canvas/flutter-preview.ts
6
+ function parseFlutterPreview(value) {
7
+ const prefix = `preview ${JSON.stringify(value)}`;
8
+ if (value.includes("\\"))
9
+ return {
10
+ error: `${prefix} uses a backslash; use "/" (paths in canvases are POSIX).`
11
+ };
12
+ const hash = value.lastIndexOf("#");
13
+ if (hash < 0)
14
+ return {
15
+ error: `${prefix} needs "#<function>" after the file, e.g. "../../lib/cards.dart#productCard".`
16
+ };
17
+ const file = value.slice(0, hash);
18
+ const functionName = value.slice(hash + 1);
19
+ if (!file.startsWith("./") && !file.startsWith("../"))
20
+ return {
21
+ error: file.startsWith("lib/") ? `${prefix} is no longer relative to a Flutter app folder; write the path from this canvas file, starting with "./" or "../".` : `${prefix} must be a path relative to this canvas file and start with "./" or "../", like a relative import.`
22
+ };
23
+ if (!file.endsWith(".dart"))
24
+ return { error: `${prefix} must name a .dart file.` };
25
+ if (/[?#]/.test(file) || file.includes("//"))
26
+ return {
27
+ error: `${prefix} must not contain "?", "#", or empty path segments.`
28
+ };
29
+ if (!/^[A-Za-z$][A-Za-z0-9_$]*$/.test(functionName))
30
+ return {
31
+ error: `${prefix}: ${JSON.stringify(functionName)} is not a public Dart function name.`
32
+ };
33
+ return { file, functionName };
34
+ }
35
+ var FLUTTER_PREVIEW_KEY_ATTRIBUTE = "data-tempo-flutter-preview-key";
36
+
37
+ // flutter-preview-path.ts
38
+ import { lstatSync, realpathSync } from "fs";
39
+ import path from "path";
40
+ function canonicalPathAllowMissing(file) {
41
+ const absolute = path.resolve(file);
42
+ try {
43
+ return realpathSync.native(absolute);
44
+ } catch (error) {
45
+ const code = error.code;
46
+ if (code !== "ENOENT" && code !== "ENOTDIR") throw error;
47
+ let isLink = false;
48
+ try {
49
+ isLink = lstatSync(absolute).isSymbolicLink();
50
+ } catch (statError) {
51
+ if (statError.code !== "ENOENT" && statError.code !== "ENOTDIR")
52
+ throw statError;
53
+ }
54
+ if (isLink) throw error;
55
+ const parent = path.dirname(absolute);
56
+ if (parent === absolute) throw error;
57
+ return path.join(
58
+ canonicalPathAllowMissing(parent),
59
+ path.basename(absolute)
60
+ );
61
+ }
62
+ }
63
+ function flutterPreviewKey(hostRoot, file, functionName) {
64
+ return `${path.relative(canonicalPathAllowMissing(hostRoot), canonicalPathAllowMissing(file)).split(path.sep).join("/")}#${functionName}`;
65
+ }
66
+
5
67
  // canvas/parser.ts
6
68
  import { parseSync } from "oxc-parser";
69
+
70
+ // canvas/storyboard-components.ts
71
+ var STORYBOARD_SDK_COMPONENT_ROWS = {
72
+ Storyboard: {
73
+ importSource: "tempo-sdk/canvas",
74
+ kind: "component",
75
+ requiresComponentProp: true,
76
+ allowsVrt: true,
77
+ componentFileExtension: ".tsx"
78
+ },
79
+ SvelteStoryboard: {
80
+ importSource: "tempo-sdk/canvas/svelte",
81
+ kind: "component",
82
+ uiFramework: "svelte",
83
+ requiresComponentProp: true,
84
+ allowsVrt: true,
85
+ componentFileExtension: ".svelte"
86
+ },
87
+ VueStoryboard: {
88
+ importSource: "tempo-sdk/canvas/vue",
89
+ kind: "component",
90
+ uiFramework: "vue",
91
+ requiresComponentProp: true,
92
+ allowsVrt: true,
93
+ componentFileExtension: ".vue"
94
+ },
95
+ AstroStoryboard: {
96
+ importSource: "tempo-sdk/canvas/astro",
97
+ kind: "component",
98
+ uiFramework: "astro",
99
+ requiresComponentProp: true,
100
+ allowsVrt: true,
101
+ componentFileExtension: ".astro",
102
+ componentImportQuery: "?tempo-component"
103
+ },
104
+ FlutterStoryboard: {
105
+ importSource: "tempo-sdk/canvas",
106
+ kind: "component",
107
+ requiresComponentProp: false,
108
+ allowsVrt: true
109
+ },
110
+ RouteStoryboard: {
111
+ importSource: "tempo-sdk/canvas",
112
+ kind: "route",
113
+ requiresComponentProp: false,
114
+ allowsVrt: false
115
+ },
116
+ HtmlStoryboard: {
117
+ importSource: "tempo-sdk/canvas",
118
+ kind: "html",
119
+ requiresComponentProp: false,
120
+ allowsVrt: true
121
+ },
122
+ LegacyStoryboardV1: {
123
+ importSource: "tempo-sdk/canvas",
124
+ kind: "component",
125
+ requiresComponentProp: false,
126
+ allowsVrt: false
127
+ }
128
+ };
129
+ var STORYBOARD_SDK_COMPONENTS = STORYBOARD_SDK_COMPONENT_ROWS;
130
+ var STORYBOARD_SDK_COMPONENT_NAMES = Object.keys(
131
+ STORYBOARD_SDK_COMPONENTS
132
+ );
133
+
134
+ // canvas/parser.ts
7
135
  var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set([
8
136
  "tempo-sdk/canvas",
9
- "tempo-sdk/canvas/svelte",
10
- "tempo-sdk/canvas/astro"
137
+ ...STORYBOARD_SDK_COMPONENT_NAMES.map(
138
+ (component) => STORYBOARD_SDK_COMPONENTS[component].importSource
139
+ )
11
140
  ]);
12
141
  var SDK_COMPONENTS = /* @__PURE__ */ new Set([
13
142
  "Canvas",
14
- "Storyboard",
15
- "SvelteStoryboard",
16
- "AstroStoryboard",
17
- "LegacyStoryboardV1",
18
- "RouteStoryboard",
19
- "HtmlStoryboard"
143
+ ...STORYBOARD_SDK_COMPONENT_NAMES
20
144
  ]);
145
+ var CANVAS_CHILDREN_ERROR = `<Canvas> children must be ${formatAlternatives(
146
+ STORYBOARD_SDK_COMPONENT_NAMES.map((component) => `<${component}>`)
147
+ )} declarations`;
21
148
  var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
22
149
  "Canvas",
23
150
  "CanvasContext",
@@ -35,6 +162,7 @@ var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
35
162
  "getCanvasHostRuntime",
36
163
  "getOptionalCanvasHostRuntime",
37
164
  "useActiveState",
165
+ "FlutterStoryboard",
38
166
  "HtmlStoryboard",
39
167
  "LegacyStoryboardV1",
40
168
  "RouteStoryboard",
@@ -158,7 +286,7 @@ function parseCanvasFile(filePath, source) {
158
286
  "name",
159
287
  objectStringBindings
160
288
  );
161
- const path = readStringAttribute(openingElement, "path");
289
+ const path2 = readStringAttribute(openingElement, "path");
162
290
  const backgroundColor = readResolvableStringAttribute(
163
291
  openingElement,
164
292
  "backgroundColor",
@@ -177,7 +305,7 @@ function parseCanvasFile(filePath, source) {
177
305
  }
178
306
  return {
179
307
  filePath,
180
- canvasPath: path?.value,
308
+ canvasPath: path2?.value,
181
309
  pageName: name?.value ?? fallbackPageName(filePath),
182
310
  backgroundColor: backgroundColor?.value,
183
311
  canvasElementSpan: toSpan(canvasElement),
@@ -185,8 +313,8 @@ function parseCanvasFile(filePath, source) {
185
313
  canvasChildrenInsertionOffset: typeof canvasElement?.closingElement?.start === "number" ? canvasElement.closingElement.start : void 0,
186
314
  nameSpan: name?.valueSpan,
187
315
  nameAttributeSpan: name?.attributeSpan,
188
- pathSpan: path?.valueSpan,
189
- pathAttributeSpan: path?.attributeSpan,
316
+ pathSpan: path2?.valueSpan,
317
+ pathAttributeSpan: path2?.attributeSpan,
190
318
  backgroundColorSpan: backgroundColor?.valueSpan,
191
319
  backgroundColorAttributeSpan: backgroundColor?.attributeSpan,
192
320
  imports: imports.all,
@@ -405,7 +533,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
405
533
  }
406
534
  ])
407
535
  } : readLayout(openingElement, component);
408
- const kind = component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" ? "component" : component === "RouteStoryboard" ? "route" : "html";
536
+ const spec = STORYBOARD_SDK_COMPONENTS[component];
409
537
  if (!id) {
410
538
  errors.push({
411
539
  message: `<${component}> must include a literal "id" prop`,
@@ -419,8 +547,9 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
419
547
  const storyboard = {
420
548
  storyboardKey: id?.value ?? "",
421
549
  displayName: name?.value ?? legacyObject?.displayName,
422
- kind,
423
- ...component === "SvelteStoryboard" ? { uiFramework: "svelte" } : component === "AstroStoryboard" ? { runtimeFramework: "astro" } : {},
550
+ kind: spec.kind,
551
+ ...spec.uiFramework ? { componentFramework: spec.uiFramework } : {},
552
+ ...spec.uiFramework === "svelte" ? { uiFramework: spec.uiFramework } : spec.uiFramework === "astro" ? { runtimeFramework: spec.uiFramework } : {},
424
553
  layout: layout.value,
425
554
  editable: Boolean(id) && layout.errors.length === 0,
426
555
  jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
@@ -443,7 +572,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
443
572
  } : void 0,
444
573
  errors
445
574
  };
446
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard") {
575
+ if (spec.requiresComponentProp) {
447
576
  const componentReference = readComponentReference(
448
577
  openingElement,
449
578
  imports,
@@ -459,7 +588,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
459
588
  });
460
589
  }
461
590
  }
462
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "HtmlStoryboard") {
591
+ if (spec.allowsVrt) {
463
592
  const vrt = readVrt(openingElement, errors);
464
593
  if (vrt) {
465
594
  if (vrt.value) {
@@ -499,6 +628,27 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
499
628
  });
500
629
  }
501
630
  }
631
+ if (component === "FlutterStoryboard") {
632
+ const preview = readStringAttribute(openingElement, "preview");
633
+ if (preview?.value.trim()) {
634
+ storyboard.preview = preview.value;
635
+ storyboard.previewSpan = preview.valueSpan;
636
+ storyboard.previewAttributeSpan = preview.attributeSpan;
637
+ const parsedPreview = parseFlutterPreview(preview.value);
638
+ if ("error" in parsedPreview)
639
+ errors.push({
640
+ message: `flutter_preview_invalid: ${parsedPreview.error}`,
641
+ span: preview.valueSpan,
642
+ kind: "structural"
643
+ });
644
+ } else {
645
+ errors.push({
646
+ message: '<FlutterStoryboard> must include a literal "preview" prop naming a Flutter @Preview function, e.g. preview="../../lib/cards.dart#productCard"',
647
+ span: toSpan(getAttribute(openingElement, "preview") ?? openingElement),
648
+ kind: "structural"
649
+ });
650
+ }
651
+ }
502
652
  globalErrors.push(...errors);
503
653
  return storyboard;
504
654
  }
@@ -558,18 +708,61 @@ function validateCanvasChildren(canvasElement, imports) {
558
708
  child.openingElement?.name,
559
709
  imports
560
710
  );
561
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
711
+ if (isStoryboardSdkComponent(component)) continue;
712
+ const newerComponent = resolveNewerSdkStoryboardComponent(
713
+ child.openingElement?.name,
714
+ imports
715
+ );
716
+ if (newerComponent) {
717
+ errors.push(newerSdkStoryboardError(child, newerComponent));
562
718
  continue;
563
719
  }
564
720
  }
565
721
  errors.push({
566
- message: "<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <AstroStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations",
722
+ message: CANVAS_CHILDREN_ERROR,
567
723
  span: toSpan(child),
568
724
  kind: "structural"
569
725
  });
570
726
  }
571
727
  return errors;
572
728
  }
729
+ var SDK_CANVAS_SUBPATH = /(^|\/)tempo-sdk\/canvas(\/[^/]+)?$/;
730
+ function resolveNewerSdkStoryboardComponent(nameNode, imports) {
731
+ let importedName;
732
+ let source;
733
+ if (nameNode?.type === "JSXIdentifier") {
734
+ const imported = imports.byLocalName.get(nameNode.name);
735
+ if (imported?.kind !== "named") return null;
736
+ importedName = imported.importedName;
737
+ source = imported.source;
738
+ } else if (nameNode?.type === "JSXMemberExpression" && nameNode.object?.type === "JSXIdentifier" && nameNode.property?.type === "JSXIdentifier") {
739
+ const imported = imports.byLocalName.get(nameNode.object.name);
740
+ if (imported?.kind !== "namespace") return null;
741
+ importedName = nameNode.property.name;
742
+ source = imported.source;
743
+ } else {
744
+ return null;
745
+ }
746
+ const fromSdkCanvas = SDK_CANVAS_SUBPATH.test(source);
747
+ const namesStoryboard = importedName.endsWith("Storyboard");
748
+ return fromSdkCanvas && namesStoryboard ? importedName : null;
749
+ }
750
+ function newerSdkStoryboardError(element, component) {
751
+ const openingElement = element.openingElement;
752
+ const storyboardKey = readStringAttribute(openingElement, "id")?.value;
753
+ const vrt = readVrt(openingElement, [])?.value != null;
754
+ const named = storyboardKey ? ` id="${storyboardKey}"` : "";
755
+ return {
756
+ message: `<${component}${named}> is a storyboard from a newer tempo-sdk than this reader supports`,
757
+ span: toSpan(element),
758
+ kind: "structural",
759
+ newerSdkStoryboard: {
760
+ component,
761
+ ...storyboardKey ? { storyboardKey } : {},
762
+ vrt
763
+ }
764
+ };
765
+ }
573
766
  function readVrt(openingElement, errors) {
574
767
  const attribute = getAttribute(openingElement, "vrt");
575
768
  if (!attribute) return null;
@@ -716,7 +909,7 @@ function isIdentifierExpression(expression) {
716
909
  return /^[A-Za-z_$][\w$]*$/.test(expression);
717
910
  }
718
911
  function readLayout(openingElement, componentName) {
719
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
912
+ const isViewport = requiresFixedLayoutSize(componentName);
720
913
  const attribute = getAttribute(openingElement, "layout");
721
914
  const expression = unwrapAttributeExpression(attribute?.value);
722
915
  if (!expression) {
@@ -740,7 +933,7 @@ function readLayout(openingElement, componentName) {
740
933
  }
741
934
  function readLayoutExpression(expression, componentName) {
742
935
  const errors = [];
743
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
936
+ const isViewport = requiresFixedLayoutSize(componentName);
744
937
  if (expression.type !== "ObjectExpression") {
745
938
  return {
746
939
  value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : DEFAULT_LAYOUT,
@@ -935,7 +1128,14 @@ function resolveMisimportedNamespaceSdkComponent(nameNode, imports, misimportedS
935
1128
  ) ?? null;
936
1129
  }
937
1130
  function isStoryboardSdkComponent(component) {
938
- return component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard";
1131
+ return component !== null && component !== "Canvas";
1132
+ }
1133
+ function formatAlternatives(items) {
1134
+ if (items.length <= 1) return items.join("");
1135
+ return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
1136
+ }
1137
+ function requiresFixedLayoutSize(componentName) {
1138
+ return componentName === "RouteStoryboard" || componentName === "HtmlStoryboard" || componentName === "FlutterStoryboard";
939
1139
  }
940
1140
  function readImportedName(specifier) {
941
1141
  if (specifier.type === "ImportDefaultSpecifier") return "default";
@@ -948,7 +1148,10 @@ function readImportKind(specifier) {
948
1148
  return "named";
949
1149
  }
950
1150
  function isSdkImportSource(source) {
951
- return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas") || source.endsWith("/tempo-sdk/canvas/svelte") || source.endsWith("/tempo-sdk/canvas/astro");
1151
+ for (const sdkSource of SDK_IMPORT_SOURCES) {
1152
+ if (source === sdkSource || source.endsWith(`/${sdkSource}`)) return true;
1153
+ }
1154
+ return false;
952
1155
  }
953
1156
  function isWrongTempoSdkCanvasImportSource(source) {
954
1157
  return (source === "tempo-sdk" || source.startsWith("tempo-sdk/")) && !isSdkImportSource(source);
@@ -996,30 +1199,58 @@ function moduleIdentity(file, specifier, resolved) {
996
1199
  const target = bundled === void 0 ? specifier : bundled.replace(/\bt=\d{13}&?\b/, "").replace(/[?&]$/, "");
997
1200
  if (target.startsWith("\0")) return target;
998
1201
  const suffixAt = target.search(/[?#]/);
999
- let path = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1202
+ let path2 = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1000
1203
  /\\/g,
1001
1204
  "/"
1002
1205
  );
1003
1206
  const suffix = suffixAt < 0 || target.endsWith(".astro?tempo-component") ? "" : target.slice(suffixAt);
1004
- if (bundled === void 0 && path.startsWith("."))
1005
- path = resolve(dirname(file), path);
1006
- if (!isAbsolute(path) && !/^[A-Za-z]:\//.test(path)) return target;
1207
+ if (bundled === void 0 && path2.startsWith("."))
1208
+ path2 = resolve(dirname(file), path2);
1209
+ if (!isAbsolute(path2) && !/^[A-Za-z]:\//.test(path2)) return target;
1007
1210
  if (bundled !== void 0) {
1008
1211
  try {
1009
- path = realpathSync.native(path);
1212
+ path2 = realpathSync2.native(path2);
1010
1213
  } catch {
1011
1214
  }
1012
1215
  }
1013
- return normalize(path).replace(/\\/g, "/") + suffix;
1216
+ return normalize(path2).replace(/\\/g, "/") + suffix;
1014
1217
  }
1015
- function canvasComponentAnnotations(file, source, resolved) {
1218
+ function canvasComponentAnnotations(file, source, resolved, hostRoot) {
1016
1219
  const result = /* @__PURE__ */ new Map();
1017
1220
  if (!source.includes("tempo-sdk/canvas")) return result;
1018
1221
  const parsed = parseCanvasFile(file, source);
1019
1222
  for (const board of parsed.storyboards) {
1020
- const ref = board.component;
1021
- if (board.kind !== "component" || !ref?.localName || board.openingElementSpan === void 0)
1223
+ if (board.kind !== "component" || board.openingElementSpan === void 0)
1022
1224
  continue;
1225
+ const flutterPreview = board.preview ? parseFlutterPreview(board.preview) : null;
1226
+ if (flutterPreview && !("error" in flutterPreview) && hostRoot) {
1227
+ let key;
1228
+ try {
1229
+ const absolute = resolve(
1230
+ dirname(canonicalPathAllowMissing(file)),
1231
+ flutterPreview.file
1232
+ );
1233
+ key = flutterPreviewKey(
1234
+ hostRoot,
1235
+ absolute,
1236
+ flutterPreview.functionName
1237
+ );
1238
+ } catch {
1239
+ continue;
1240
+ }
1241
+ result.set(board.openingElementSpan.start, {
1242
+ [FLUTTER_PREVIEW_KEY_ATTRIBUTE]: key,
1243
+ [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1244
+ "flutter",
1245
+ key.slice(0, key.lastIndexOf("#")),
1246
+ flutterPreview.functionName
1247
+ ]),
1248
+ "data-tempo-external-component": "true"
1249
+ });
1250
+ continue;
1251
+ }
1252
+ const ref = board.component;
1253
+ if (!ref?.localName) continue;
1023
1254
  const member = ref.expression.match(
1024
1255
  /^\s*([$\w]+)(?:\s*\.\s*([$\w]+))?\s*$/
1025
1256
  );
@@ -1058,7 +1289,7 @@ import { dirname as dirname3, resolve as resolve2 } from "path";
1058
1289
  import { createFilter } from "@rollup/pluginutils";
1059
1290
 
1060
1291
  // annotation-strategy.ts
1061
- import { realpathSync as realpathSync2, statSync } from "fs";
1292
+ import { realpathSync as realpathSync3, statSync } from "fs";
1062
1293
  import { relative } from "path";
1063
1294
 
1064
1295
  // ../../modules/annotation/expression-facts.ts
@@ -1198,7 +1429,7 @@ function cleanModuleId(id) {
1198
1429
  }
1199
1430
  function resolveCanonicalRoot(root) {
1200
1431
  try {
1201
- return realpathSync2.native(root);
1432
+ return realpathSync3.native(root);
1202
1433
  } catch {
1203
1434
  return root;
1204
1435
  }
@@ -1275,7 +1506,7 @@ function getFileAnnotationContext(params) {
1275
1506
  let cleanFilename = rawCleanFilename;
1276
1507
  if (params.canonicalizeFilename) {
1277
1508
  try {
1278
- cleanFilename = realpathSync2.native(rawCleanFilename);
1509
+ cleanFilename = realpathSync3.native(rawCleanFilename);
1279
1510
  } catch {
1280
1511
  cleanFilename = rawCleanFilename;
1281
1512
  }
@@ -1291,7 +1522,7 @@ function getFileAnnotationContext(params) {
1291
1522
  }
1292
1523
 
1293
1524
  // sdk-package-files.ts
1294
- import { readFileSync, realpathSync as realpathSync3 } from "fs";
1525
+ import { readFileSync, realpathSync as realpathSync4 } from "fs";
1295
1526
  import { dirname as dirname2, join } from "path";
1296
1527
  var SDK_PACKAGE_NAME = "tempo-sdk";
1297
1528
  var SDK_NODE_MODULES_SEGMENT = `/node_modules/${SDK_PACKAGE_NAME}/`;
@@ -1326,7 +1557,7 @@ function createSdkFileMatcher() {
1326
1557
  }
1327
1558
  let realFile = file;
1328
1559
  try {
1329
- realFile = realpathSync3.native(file);
1560
+ realFile = realpathSync4.native(file);
1330
1561
  } catch {
1331
1562
  }
1332
1563
  return nearestPackageIsSdk(dirname2(realFile));
@@ -1519,7 +1750,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1519
1750
  },
1520
1751
  visitor: {
1521
1752
  Program: {
1522
- enter(path, state) {
1753
+ enter(path2, state) {
1523
1754
  if (!enabled) return;
1524
1755
  const options = { ...rawOptions, ...state.opts };
1525
1756
  const filename = resolveFilename(state);
@@ -1538,13 +1769,15 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1538
1769
  return;
1539
1770
  }
1540
1771
  if (context.filepath === "index.js") {
1541
- injectProjectRootMeta(api, path, root);
1772
+ injectProjectRootMeta(api, path2, root);
1542
1773
  }
1543
1774
  const componentReferences = canvasComponentAnnotations(
1544
1775
  filename,
1545
- source
1776
+ source,
1777
+ void 0,
1778
+ root
1546
1779
  );
1547
- path.traverse({
1780
+ path2.traverse({
1548
1781
  JSXElement(elementPath) {
1549
1782
  const element = elementPath.node;
1550
1783
  const tagName = getBabelTagName(element.openingElement.name);
@@ -1587,4 +1820,4 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1587
1820
  export {
1588
1821
  tempoExpoBabelPlugin
1589
1822
  };
1590
- //# sourceMappingURL=chunk-Q2A46HHW.js.map
1823
+ //# sourceMappingURL=chunk-XFPFWTWX.js.map