tempo-sdk 0.0.60 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro/client.d.ts +4 -0
- package/dist/assets/editor.js +1 -1
- package/dist/assets/index.d.ts +10 -63
- package/dist/assets/index.js +12 -32
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/parser.js +1 -1
- package/dist/astro/asset-preview-client.d.ts +4 -0
- package/dist/astro/asset-preview-client.js +93 -0
- package/dist/astro/asset-preview-client.js.map +1 -0
- package/dist/astro/controls.d.ts +7 -0
- package/dist/astro/controls.js +7 -0
- package/dist/astro/controls.js.map +1 -0
- package/dist/astro/document-client.d.ts +10 -0
- package/dist/astro/document-client.js +78 -0
- package/dist/astro/document-client.js.map +1 -0
- package/dist/astro/runtime.d.ts +15 -0
- package/dist/astro/runtime.js +86 -0
- package/dist/astro/runtime.js.map +1 -0
- package/dist/astro.d.ts +21 -0
- package/dist/astro.js +749 -0
- package/dist/astro.js.map +1 -0
- package/dist/canvas/astro-contract.d.ts +21 -0
- package/dist/canvas/astro-contract.js +9 -0
- package/dist/canvas/astro-contract.js.map +1 -0
- package/dist/canvas/astro.d.ts +18 -0
- package/dist/canvas/astro.js +42 -0
- package/dist/canvas/astro.js.map +1 -0
- package/dist/canvas/editor.d.ts +1 -1
- package/dist/canvas/editor.js +3 -2
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +40 -16
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -4
- package/dist/canvas/parser.d.ts +3 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.d.ts +1 -1
- package/dist/canvas/svelte.js +3 -3
- package/dist/{chunk-5BHIHP25.js → chunk-2JRAG36X.js} +37 -11
- package/dist/chunk-2JRAG36X.js.map +1 -0
- package/dist/{chunk-N2TYN3RB.js → chunk-6AAE4LYV.js} +123 -123
- package/dist/chunk-6AAE4LYV.js.map +1 -0
- package/dist/{chunk-7DT5DDSH.js → chunk-6IR5JY6W.js} +106 -7
- package/dist/chunk-6IR5JY6W.js.map +1 -0
- package/dist/{chunk-FQSZRVSL.js → chunk-6W6UKDSY.js} +45 -4
- package/dist/chunk-6W6UKDSY.js.map +1 -0
- package/dist/chunk-77DZCV5Z.js +38 -0
- package/dist/chunk-77DZCV5Z.js.map +1 -0
- package/dist/chunk-DELFOKU3.js +2495 -0
- package/dist/chunk-DELFOKU3.js.map +1 -0
- package/dist/{chunk-MXKZZOLM.js → chunk-EYKOOLPL.js} +368 -32
- package/dist/chunk-EYKOOLPL.js.map +1 -0
- package/dist/chunk-F23JGM4U.js +107 -0
- package/dist/chunk-F23JGM4U.js.map +1 -0
- package/dist/chunk-FE6TYCLF.js +1514 -0
- package/dist/chunk-FE6TYCLF.js.map +1 -0
- package/dist/chunk-H6OZIX2U.js +133 -0
- package/dist/chunk-H6OZIX2U.js.map +1 -0
- package/dist/chunk-JVVHU3A7.js +1077 -0
- package/dist/chunk-JVVHU3A7.js.map +1 -0
- package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
- package/dist/chunk-KOSJXE4G.js.map +1 -0
- package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
- package/dist/chunk-NSKYOKG5.js.map +1 -0
- package/dist/chunk-OX2YKYSL.js +13 -0
- package/dist/chunk-OX2YKYSL.js.map +1 -0
- package/dist/{chunk-VMTQDG4U.js → chunk-PXDTH36X.js} +12 -10
- package/dist/chunk-PXDTH36X.js.map +1 -0
- package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
- package/dist/chunk-PYAJHLXO.js.map +1 -0
- package/dist/{chunk-OTVBSF7U.js → chunk-Q2A46HHW.js} +17 -12
- package/dist/chunk-Q2A46HHW.js.map +1 -0
- package/dist/controls-reader-SNMI2UY7.js +191 -0
- package/dist/controls-reader-SNMI2UY7.js.map +1 -0
- package/dist/controls-uCaQ3CNX.d.ts +61 -0
- package/dist/expo/plugin.cjs +16 -11
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +16 -11
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -2465
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.cjs +44 -3
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +60 -14
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +44 -3
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +4 -4
- package/dist/nextjs.d.ts +4 -4
- package/dist/nextjs.js +1 -1
- package/dist/{storyboard-DjOF61B_.d.ts → storyboard-4YdTYq_e.d.ts} +1 -1
- package/dist/svelte.js +7 -1075
- package/dist/svelte.js.map +1 -1
- package/package.json +44 -3
- package/dist/chunk-2IQD2KPS.js.map +0 -1
- package/dist/chunk-5BHIHP25.js.map +0 -1
- package/dist/chunk-7DT5DDSH.js.map +0 -1
- package/dist/chunk-FQSZRVSL.js.map +0 -1
- package/dist/chunk-MXKZZOLM.js.map +0 -1
- package/dist/chunk-N2TYN3RB.js.map +0 -1
- package/dist/chunk-OTVBSF7U.js.map +0 -1
- package/dist/chunk-TL4MGN7E.js.map +0 -1
- package/dist/chunk-VMTQDG4U.js.map +0 -1
- package/dist/chunk-XLEKCOB7.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempo-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"tag": "sdk-v2-latest"
|
|
6
6
|
},
|
|
7
7
|
"type": "module",
|
|
8
|
-
"description": "Tempo SDK — Vite, Next.js, and
|
|
8
|
+
"description": "Tempo SDK — Vite, Next.js, Expo, Svelte and Astro canvas integration, source annotations and storyboard types",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/TempoLabsAI/tempo-monorepo.git",
|
|
12
12
|
"directory": "tempo-modules/tempo-sdk"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
|
+
"./astro/controls": {
|
|
16
|
+
"types": "./dist/astro/controls.d.ts",
|
|
17
|
+
"import": "./dist/astro/controls.js",
|
|
18
|
+
"default": "./dist/astro/controls.js"
|
|
19
|
+
},
|
|
20
|
+
"./astro": {
|
|
21
|
+
"types": "./dist/astro.d.ts",
|
|
22
|
+
"import": "./dist/astro.js"
|
|
23
|
+
},
|
|
24
|
+
"./astro/client": {
|
|
25
|
+
"types": "./astro/client.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./canvas/astro": {
|
|
28
|
+
"types": "./dist/canvas/astro.d.ts",
|
|
29
|
+
"import": "./dist/canvas/astro.js"
|
|
30
|
+
},
|
|
31
|
+
"./canvas/astro-contract": {
|
|
32
|
+
"types": "./dist/canvas/astro-contract.d.ts",
|
|
33
|
+
"import": "./dist/canvas/astro-contract.js"
|
|
34
|
+
},
|
|
15
35
|
".": {
|
|
16
36
|
"types": "./dist/index.d.ts",
|
|
17
37
|
"import": "./dist/index.js"
|
|
@@ -70,10 +90,15 @@
|
|
|
70
90
|
"./svelte": {
|
|
71
91
|
"types": "./dist/svelte.d.ts",
|
|
72
92
|
"import": "./dist/svelte.js"
|
|
93
|
+
},
|
|
94
|
+
"./astro/asset-preview-client": {
|
|
95
|
+
"types": "./dist/astro/asset-preview-client.d.ts",
|
|
96
|
+
"import": "./dist/astro/asset-preview-client.js"
|
|
73
97
|
}
|
|
74
98
|
},
|
|
75
99
|
"files": [
|
|
76
|
-
"dist"
|
|
100
|
+
"dist",
|
|
101
|
+
"astro/client.d.ts"
|
|
77
102
|
],
|
|
78
103
|
"scripts": {
|
|
79
104
|
"clean": "rm -rf dist",
|
|
@@ -95,7 +120,11 @@
|
|
|
95
120
|
"@rollup/pluginutils": "^5.1.0",
|
|
96
121
|
"oxc-parser": "^0.110.0"
|
|
97
122
|
},
|
|
123
|
+
"optionalDependencies": {
|
|
124
|
+
"@astrojs/compiler-rs": "0.5.1"
|
|
125
|
+
},
|
|
98
126
|
"peerDependencies": {
|
|
127
|
+
"astro": "^7.0.0",
|
|
99
128
|
"@babel/core": "^7.0.0",
|
|
100
129
|
"next": "^13 || ^14 || ^15 || ^16",
|
|
101
130
|
"react": "^18 || ^19",
|
|
@@ -103,6 +132,12 @@
|
|
|
103
132
|
"vite": "^5 || ^6 || ^7 || ^8"
|
|
104
133
|
},
|
|
105
134
|
"peerDependenciesMeta": {
|
|
135
|
+
"astro": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"react": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
106
141
|
"@babel/core": {
|
|
107
142
|
"optional": true
|
|
108
143
|
},
|
|
@@ -117,9 +152,11 @@
|
|
|
117
152
|
}
|
|
118
153
|
},
|
|
119
154
|
"devDependencies": {
|
|
155
|
+
"@astrojs/react": "7.0.1",
|
|
120
156
|
"@babel/core": "^7.29.0",
|
|
121
157
|
"@babel/types": "^7.29.0",
|
|
122
158
|
"@modules/annotation": "workspace:*",
|
|
159
|
+
"@modules/astro-editor": "workspace:*",
|
|
123
160
|
"@modules/file-parser": "workspace:*",
|
|
124
161
|
"@modules/svelte-editor": "workspace:*",
|
|
125
162
|
"@types/babel__core": "^7.20.5",
|
|
@@ -127,8 +164,12 @@
|
|
|
127
164
|
"@types/react": "catalog:",
|
|
128
165
|
"@types/react-dom": "catalog:",
|
|
129
166
|
"@vitejs/plugin-react": "catalog:",
|
|
167
|
+
"astro": "7.3.8",
|
|
168
|
+
"magic-string": "^0.30.21",
|
|
130
169
|
"playwright": "^1.58.2",
|
|
131
170
|
"react-dom": "catalog:",
|
|
171
|
+
"react-dom18": "npm:react-dom@18.3.1",
|
|
172
|
+
"react18": "npm:react@18.3.1",
|
|
132
173
|
"svelte": "5.56.9",
|
|
133
174
|
"tsup": "^8.5.1",
|
|
134
175
|
"typescript": "catalog:",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../modules/annotation/source-version.ts","../annotation-strategy.ts","../../../modules/annotation/expression-facts.ts"],"sourcesContent":["/**\n * Canvas source-version identity.\n *\n * `sourceVersionHash` maps the exact text of a source file to a 16-hex-character\n * token identifying that content. It is the version stamp the canvas edit/\n * reconcile loop uses to answer \"has the host caught up to write W?\": the SDK\n * JSX transforms stamp `data-tempo-source-version` with the hash of the source\n * they annotate, and the write pipeline (`applyWrites` → `sourceVersionsByFile`)\n * reports the hash of the exact bytes it wrote. A captured element's stamp is\n * compared for EQUALITY against a write's version — never ordered, never\n * subtracted, never used as a high-water mark. Two identical contents MUST\n * produce the same token; two different contents MUST (for identity purposes)\n * produce different tokens.\n *\n * Because coverage is an equality test across independently-computed hashes,\n * every producer of a version — this function's callers in the vite/next/expo\n * transforms and in `applyWrites` — MUST route through THIS function so the\n * tokens are bit-identical. Changing the algorithm requires changing it for all\n * producers in lockstep, or old stamps and new write-versions stop matching.\n *\n * The token concatenates two independent 32-bit rolling hashes over the string's\n * UTF-16 code units — djb2 and sdbm — each rendered as unsigned 8-char hex. Two\n * independent hash families make an accidental collision between distinct source\n * contents vanishingly unlikely for version-identity use, while the function\n * stays dependency-free and single-pass (fast enough to run once per file per\n * transform on the devserver hot path).\n */\nexport function sourceVersionHash(content: string): string {\n let djb2 = 5381;\n let sdbm = 0;\n for (let i = 0; i < content.length; i++) {\n const c = content.charCodeAt(i);\n // djb2: hash * 33 ^ c. The trailing `^ c` keeps the value inside 32-bit\n // signed range every iteration, so no explicit coercion is needed.\n djb2 = ((djb2 << 5) + djb2) ^ c;\n // sdbm: c + hash*65599. The final term is an arithmetic subtraction, so\n // coerce back to a 32-bit int each step to prevent float drift.\n sdbm = (c + (sdbm << 6) + (sdbm << 16) - sdbm) | 0;\n }\n return toHex8(djb2) + toHex8(sdbm);\n}\n\n/** Render a 32-bit value as unsigned, zero-padded 8-char lowercase hex. */\nfunction toHex8(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n","import { realpathSync, statSync } from \"node:fs\";\nimport { relative } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n EXPRESSION_FACTS_ATTRIBUTE,\n expressionFacts,\n} from \"../../modules/annotation/expression-facts.ts\";\nimport { sourceVersionHash } from \"../../modules/annotation/source-version.ts\";\n\nexport const DEFAULT_EXCLUDE = [\"**/node_modules/**\"] as const;\n\n/**\n * Static per-component declaration of whether a custom component accepts\n * `children`. Supplied by callers that know this from a fixed table (e.g. the\n * Expo plugin's React Native host-component overrides). The Vite/Next.js\n * plugins supply no overrides — custom components are left without a\n * `supports-children` flag and consumers treat their support as unknown.\n */\nexport interface ElementTypeSupport {\n supportsChildren: boolean;\n}\n\n/** HTML void elements that cannot have children (self-closing only). */\nexport const HTML_VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n) => Record<string, PropValue>;\n\nexport function cleanModuleId(id: string): string {\n return id.replace(/[?#].*$/, \"\");\n}\n\nexport function resolveCanonicalRoot(root: string): string {\n try {\n return realpathSync.native(root);\n } catch {\n return root;\n }\n}\n\nexport function isIntrinsicElement(tagName: string): boolean {\n return tagName.length > 0 && tagName[0] === tagName[0]!.toLowerCase();\n}\n\nexport function hasJsxAttribute(info: ElementInfo, attrName: string): boolean {\n for (const attr of info.element.openingElement.attributes) {\n const name = (attr as { name?: { name?: unknown } }).name;\n if (name?.name === attrName) return true;\n }\n return false;\n}\n\nexport function defaultComputeAnnotatedProps(\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): Record<string, PropValue> {\n return {\n \"data-tempo-filepath\": filepath,\n \"data-tempo-position\": info.element.openingElement.start,\n \"data-tempo-modifiedts\": modifiedtsMs,\n // Content-hash identity of the file this element was annotated from. The\n // canvas reconcile loop equality-compares it against the write pipeline's\n // computed version to decide whether a capture reflects a given edit.\n \"data-tempo-source-version\": sourceVersion,\n };\n}\n\n/**\n * Appends the module version record: one guarded statement that runs when the\n * browser evaluates the module and pushes `{file, modifiedTs, sourceVersion}`\n * onto `globalThis.__TEMPO_MODULE_VERSIONS__`, keyed by the same `filepath`\n * the element stamps carry. The projection producer joins these records to\n * React's refresh so the canvas learns that a write reached the host even\n * when the write left no element of the file on a board (V2-498).\n *\n * It is appended to every filtered module, JSX or not: a write that removes a\n * file's last element is exactly the case that needs it. It goes at the end\n * so it never displaces a leading directive such as \"use client\", and adds no\n * line above existing code so positions and source maps are unchanged. The\n * `window` guard keeps server-side evaluation (Next server components, SSR)\n * from recording anything.\n */\nexport function appendModuleVersionRecord(\n source: string,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): string {\n const record = JSON.stringify({\n file: filepath,\n modifiedTs: modifiedtsMs,\n sourceVersion,\n });\n return `${source}\\n;typeof window !== \"undefined\" && (globalThis.__TEMPO_MODULE_VERSIONS__ || (globalThis.__TEMPO_MODULE_VERSIONS__ = [])).push(${record});\\n`;\n}\n\nexport function computeTempoAnnotatedProps(params: {\n info: ElementInfo;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n elementSupportOverrides?: ReadonlyMap<string, ElementTypeSupport>;\n}): Record<string, PropValue> {\n const {\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n computeAnnotatedProps,\n elementSupportOverrides,\n } = params;\n\n const userProps = {\n ...(computeAnnotatedProps\n ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion)\n : defaultComputeAnnotatedProps(\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n )),\n // Only a caller that knows the parent can say whether the slot is a JSX\n // child; without it every element would read as a dynamic slot.\n ...(info.parentType !== undefined &&\n !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE)\n ? {\n [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(\n info.element,\n info.parentType,\n ),\n }\n : {}),\n };\n\n if (isIntrinsicElement(info.tagName)) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : !HTML_VOID_ELEMENTS.has(info.tagName),\n };\n }\n\n const override = elementSupportOverrides?.get(info.tagName);\n if (override) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : override.supportsChildren,\n };\n }\n\n // Custom component with no static override: emit no `data-tempo-supports-*`\n // flags. Determining them required a per-file TypeScript program, which was\n // removed for being the dominant cost of devserver startup. Consumers treat\n // the absent flags as \"unknown\" and fall back to their own defaults.\n return userProps;\n}\n\nexport function getFileAnnotationContext(params: {\n source: string;\n filename: string;\n root: string;\n canonicalizeFilename?: boolean;\n}): {\n cleanFilename: string;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n} {\n const rawCleanFilename = cleanModuleId(params.filename);\n let cleanFilename = rawCleanFilename;\n if (params.canonicalizeFilename) {\n try {\n cleanFilename = realpathSync.native(rawCleanFilename);\n } catch {\n cleanFilename = rawCleanFilename;\n }\n }\n return {\n cleanFilename,\n filepath: relative(params.root, cleanFilename),\n modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),\n // Hashed once per file per transform (the context is built once, reused\n // for every element) so the per-element funnel just forwards the token.\n sourceVersion: sourceVersionHash(params.source),\n };\n}\n","/**\n * Expression facts: which parts of one JSX element's source are runtime\n * expressions, stamped as `data-tempo-expr` so the canvas can know before an\n * edit that the edit's operand is not literal source.\n *\n * The value is a space-separated token list. Each token is a fact, never a\n * decision:\n * - `#slot`: the element's own slot is not a JSX child. Its syntactic parent\n * is a `.map` callback, a conditional, a `return`, a prop value or a `{}`\n * container. The `#` keeps it apart from attribute names.\n * - `<name>`: the attribute is written at the callsite and its value is an\n * expression, or a later spread may override it.\n * - `style` alone: the style value is not an object literal, or a later\n * spread may override it. Every style key is then an expression.\n * - `style.<key>`: that key of a style object literal is an expression, a\n * shorthand, or a later spread or computed key may override it.\n *\n * A fact is written only when the file proves it, and exactly where the\n * checked writer refuses (`main/literal-writes.ts` planAttribute and\n * planInlineStyles, `astParentKind` for the slot; pinned cell by cell in\n * `literal-writes.expression-facts.test.ts`). Both read JSX in order:\n * - a spread (or a computed key in a style object) overrides only what comes\n * before it, so an attribute or key before one is a fact and one after it\n * is not;\n * - of repeated occurrences the last renders, so only the last is judged\n * and the writer edits that one.\n * What the file leaves open, such as an attribute absent at a callsite with\n * a spread, gets no token.\n *\n * Works on oxc (ESTree) and Babel JSX trees alike.\n */\n\nexport const EXPRESSION_FACTS_ATTRIBUTE = \"data-tempo-expr\";\nexport const DYNAMIC_SLOT_FACT = \"#slot\";\n\ntype Node = { type: string; [key: string]: unknown };\n\n/**\n * The stamp for one element, or undefined when there is nothing to write.\n * An element with a spread attribute always gets a stamp, empty when it has\n * no fact: annotations land after every spread, so its own value replaces\n * one a caller's props would otherwise carry onto it.\n */\nexport function expressionFacts(\n element: unknown,\n parentType: string | null,\n): string | undefined {\n const opening = (element as { openingElement: { attributes: Node[] } })\n .openingElement;\n const attributes = opening.attributes;\n const facts: string[] = [];\n if (parentType !== \"JSXElement\" && parentType !== \"JSXFragment\")\n facts.push(DYNAMIC_SLOT_FACT);\n\n // The writer reads an attribute's last occurrence, so only that one counts.\n const last = new Map<string, number>();\n attributes.forEach((attribute, index) => {\n const name = attributeName(attribute);\n if (name !== null) last.set(name, index);\n });\n let lastSpread = -1;\n attributes.forEach((attribute, index) => {\n if (attribute.type === \"JSXSpreadAttribute\") lastSpread = index;\n });\n for (const [name, index] of last) {\n if (unstamped(name)) continue;\n const overridden = index < lastSpread;\n const value = attributes[index]!.value as Node | null;\n // A bare attribute is `true`, not an expression.\n if (value === null) continue;\n if (name === \"style\" && !overridden) {\n facts.push(...styleFacts(value));\n continue;\n }\n if (overridden || !isLiteralValue(value)) facts.push(name);\n }\n\n if (facts.length > 0) return facts.join(\" \");\n return lastSpread >= 0 ? \"\" : undefined;\n}\n\n/** The facts one stamp holds, the inverse of `expressionFacts`. No stamp\n * holds none. */\nexport function stampedFacts(stamp: string | undefined): ReadonlySet<string> {\n return new Set((stamp ?? \"\").split(\" \").filter(Boolean));\n}\n\nfunction attributeName(attribute: Node): string | null {\n if (attribute.type !== \"JSXAttribute\") return null;\n const name = attribute.name as Node;\n if (name.type === \"JSXIdentifier\") return name.name as string;\n if (name.type === \"JSXNamespacedName\") {\n const namespace = (name.namespace as Node).name as string;\n return `${namespace}:${(name.name as Node).name as string}`;\n }\n return null;\n}\n\n/** Props the stamp leaves out: Tempo's own annotations, and `key`, which\n * the canvas reads from the layer. A handler, `ref` or `children` is\n * stamped although no canvas edit writes it: it renders no DOM attribute,\n * so this is where the canvas learns that an element is not plain rich\n * text (review2 r2 R3-A: un-bold of `<b onClick={f}>` deleted the handler). */\nfunction unstamped(name: string): boolean {\n return name === \"key\" || name.startsWith(\"data-tempo-\");\n}\n\nfunction styleFacts(value: Node): string[] {\n const expression =\n value.type === \"JSXExpressionContainer\"\n ? unwrap(value.expression as Node)\n : value;\n if (expression.type !== \"ObjectExpression\") return [\"style\"];\n const properties = expression.properties as Node[];\n const last = new Map<string, number>();\n properties.forEach((property, index) => {\n const key = styleKey(property);\n if (key !== null) last.set(key, index);\n });\n const facts: string[] = [];\n for (const [key, index] of last) {\n const property = properties[index]!;\n const overridden = properties\n .slice(index + 1)\n .some((later) => later.type === \"SpreadElement\" || later.computed);\n const literal =\n property.type !== \"ObjectMethod\" &&\n !property.shorthand &&\n isLiteral(property.value as Node);\n if (overridden || !literal) facts.push(`style.${key}`);\n }\n return facts;\n}\n\n/** A property's key as the writer names it; computed keys have no name. */\nfunction styleKey(property: Node): string | null {\n const isProperty =\n property.type === \"Property\" ||\n property.type === \"ObjectProperty\" ||\n property.type === \"ObjectMethod\";\n if (!isProperty || property.computed) return null;\n const key = property.key as Node;\n if (key.type === \"Identifier\") return key.name as string;\n const isString =\n (key.type === \"Literal\" || key.type === \"StringLiteral\") &&\n typeof key.value === \"string\";\n return isString ? (key.value as string) : null;\n}\n\n/** An attribute value the writer can rewrite in place: a JSX string, or a\n * container holding one literal. */\nfunction isLiteralValue(value: Node): boolean {\n if (value.type === \"Literal\" || value.type === \"StringLiteral\") return true;\n if (value.type !== \"JSXExpressionContainer\") return false;\n return isLiteral(value.expression as Node);\n}\n\n/** The writer's literal: a string, a finite number, a boolean, or a signed\n * number, inside any parentheses. */\nfunction isLiteral(node: Node): boolean {\n const current = unwrap(node);\n if (current.type === \"UnaryExpression\") {\n const signed = current.operator === \"-\" || current.operator === \"+\";\n return signed && isNumber(current.argument as Node);\n }\n if (isNumber(current)) return true;\n if (current.type === \"StringLiteral\" || current.type === \"BooleanLiteral\")\n return true;\n const value = current.value;\n return (\n current.type === \"Literal\" &&\n (typeof value === \"string\" || typeof value === \"boolean\")\n );\n}\n\nfunction isNumber(node: Node): boolean {\n const numeric = node.type === \"Literal\" || node.type === \"NumericLiteral\";\n return (\n numeric && typeof node.value === \"number\" && Number.isFinite(node.value)\n );\n}\n\nfunction unwrap(node: Node): Node {\n let current = node;\n while (current.type === \"ParenthesizedExpression\")\n current = current.expression as Node;\n return current;\n}\n"],"mappings":";AA2BO,SAAS,kBAAkB,SAAyB;AACzD,MAAI,OAAO;AACX,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,WAAW,CAAC;AAG9B,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AAG;AAAA,MACH,gCAAgC;AAAA,QAC9B;AAAA,QACA;AAAA,MACF,IACI,SACA,SAAS;AAAA,IACf;AAAA,EACF;AAMA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 /** 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 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 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): MutationObserver => {\n const observer = new MutationObserver((mutations) => {\n const details = this.readRelevantMutations(mutations, head);\n if (!details) return;\n notify(details);\n });\n observer.observe(head, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n return observer;\n };\n\n if (doc.head) {\n return { observer: observeHead(doc.head), subscriptions, 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 bootstrap = new MutationObserver(() => {\n const head = doc.head;\n if (!head) return;\n bootstrap.disconnect();\n state.observer = observeHead(head);\n notify({ stylesheetPaths: [] });\n });\n bootstrap.observe(doc, { childList: true, subtree: true });\n const state: DocObserverState = {\n observer: bootstrap,\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 if (tagName === \"META\") {\n const httpEquiv = child.getAttribute(\"http-equiv\")?.toLowerCase();\n const name = child.getAttribute(\"name\")?.toLowerCase();\n if (\n httpEquiv === \"content-security-policy\" ||\n name === \"content-security-policy\"\n ) {\n continue;\n }\n }\n\n // Clone and resolve URLs\n let clone = child.cloneNode(true) as Element;\n materializeStyleElementCssom(child, clone);\n if (tagName === \"LINK\") {\n clone = materializeStylesheetLinkCssom(child, clone);\n }\n resolveUrls(clone, baseURI);\n\n // Strip crossorigin from stylesheet links so they load in no-cors mode\n // in srcdoc projection iframes (which have a null origin that won't\n // match any server's Access-Control-Allow-Origin header)\n if (clone.tagName === \"LINK\") {\n clone.removeAttribute(\"crossorigin\");\n } else if (clone.tagName === \"STYLE\") {\n // 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\n/** Original identity metadata survives CSSOM comment removal; visual CSS stays CSSOM. */\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) return;\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) || url.startsWith(\"data:\");\n}\n"],"mappings":";;;;;;AAmBA,IAAM,eAAe,oBAAI,IAAI,CAAC,SAAS,QAAQ,QAAQ,MAAM,CAAC;AAG9D,IAAM,oBAAoB,oBAAI,IAAI,CAAC,YAAY,CAAC;AA0ChD,IAAI,WAAmC;AAKhC,SAAS,iBAA8B;AAC5C,MAAI,CAAC,UAAU;AACb,eAAW,IAAI,gBAAgB;AAAA,EACjC;AACA,SAAO;AACT;AAYA,IAAM,uBAAN,MAAuD;AAAA,EAMrD,YACE,KACA,UACA,eACA;AATF,wBAAe;AAUb,SAAK,MAAM;AACX,SAAK,WAAW;AAChB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAM,WAAwC;AAC5C,QAAI,CAAC,aAAa,CAAC,KAAK,cAAc;AACpC,aAAO;AAAA,IACT;AACA,SAAK,eAAe;AACpB,WAAO,YAAY,KAAK,GAAG;AAAA,EAC7B;AAAA,EAEA,cAAoB;AAClB,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA,EAGA,eAAe,SAAoC;AACjD,SAAK,eAAe;AACpB,SAAK,SAAS,OAAO;AAAA,EACvB;AACF;AASA,IAAM,kBAAN,MAA6C;AAAA,EAA7C;AACE,SAAQ,eAAe,oBAAI,IAAgC;AAC3D,SAAQ,sBAAsB;AAAA;AAAA,EAE9B,UACE,KACA,YACkB;AAClB,QAAI,WAAW,KAAK,aAAa,IAAI,GAAG;AAGxC,QAAI,CAAC,UAAU;AACb,iBAAW,KAAK,kBAAkB,GAAG;AACrC,WAAK,aAAa,IAAI,KAAK,QAAQ;AAAA,IACrC;AAEA,UAAM,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KAAK,GAAG,QAAQ,KAAK,CAAC,GAAG,KAAK;AAAA,EACzC,EACC;AAAA,IACC;AAAA,IACA,CAAC,QAAQ,OAAe,UACtB,WAAW,KAAK,GAAG,QAAQ,KAAK,CAAC,GAAG,KAAK;AAAA,EAC7C;AACJ;AAEA,SAAS,kBAAkB,SAA2B;AACpD,QAAM,MAAM,QAAQ,aAAa,KAAK;AACtC,MAAI,CAAC,KAAK;AACR,WAAO;AAAA,EACT;AACA,SAAO,IACJ,YAAY,EACZ,MAAM,KAAK,EACX,KAAK,CAAC,UAAU,kBAAkB,IAAI,KAAK,CAAC;AACjD;AAEA,SAAS,qBAAqB,SAA2B;AACvD,QAAM,OAAO;AACb,SAAO,KAAK,YAAY,KAAK,OAAO,aAAa;AACnD;AAKA,SAAS,YAAY,SAAkB,SAAuB;AAK5D,QAAM,OAAO,QAAQ,aAAa,MAAM;AACxC,MAAI,QAAQ,CAAC,cAAc,IAAI,GAAG;AAChC,QAAI;AACF,cAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,EAAE,IAAI;AAAA,IAC1D,QAAQ;AAAA,IAER;AAAA,EACF;AAGA,QAAM,MAAM,QAAQ,aAAa,KAAK;AACtC,MAAI,OAAO,CAAC,cAAc,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":["source"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../canvas/ids.ts","../canvas/canvas.tsx","../canvas/runtime-context.ts","../canvas/storyboard.tsx","../canvas/admission-budget.ts","../canvas/canvas-pending-marker.tsx","../canvas/portal-tracking.ts","../canvas/render-error-recovery.ts","../canvas/responsive-slot-size.ts","../canvas/client-protocol.ts","../canvas/v1-client-compat.ts"],"sourcesContent":["export function normalizeId(value: string | undefined, label: string): string {\n const normalized = value?.trim();\n if (!normalized) {\n throw new Error(`${label} is required.`);\n }\n return normalized;\n}\n\n/** Canvas and editor previews use the same key for an unkeyed declaration. */\nexport function getStoryboardKey(id: string): string {\n return `storyboard:${id}`;\n}\n","import {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useContext,\n useMemo,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\n\nimport { getStoryboardKey, normalizeId } from \"./ids\";\n\n/**\n * What the canvas needs from the page beside its storyboards, stamped on the\n * Canvas element as one JSON attribute; each Storyboard shell carries its\n * own. The projection carries both as ordinary layer props; the canvas\n * validates what it reads, so nothing is checked here.\n */\nexport interface CanvasDeclaration {\n path: string;\n /** Absent when the Canvas has no name; the canvas then names the page\n * after its file. */\n name?: string;\n backgroundColor?: string;\n defaultViewport?: { x: number; y: number; zoom: number };\n}\n\ntype CanvasIdentity = {\n path: string;\n};\n\nconst CanvasIdentityContext = createContext<CanvasIdentity | null>(null);\n\nexport function getCanvasStoryboardRenderId(\n canvasPath: string,\n storyboardId: string,\n): string {\n return `canvas:${encodeURIComponent(\n normalizeId(canvasPath, \"Canvas path\"),\n )}#storyboard:${encodeURIComponent(\n normalizeId(storyboardId, \"Storyboard id\"),\n )}`;\n}\n\nexport function useCanvasIdentity(): CanvasIdentity | null {\n return useContext(CanvasIdentityContext);\n}\n\nexport function useCanvasStoryboardRenderId(storyboardId: string): string {\n const canvas = useCanvasIdentity();\n const normalizedId = normalizeId(storyboardId, \"Storyboard id\");\n return canvas\n ? getCanvasStoryboardRenderId(canvas.path, normalizedId)\n : normalizedId;\n}\n\nexport function Canvas({\n children,\n name,\n path,\n backgroundColor,\n defaultViewport,\n ...sourceAnnotations\n}: {\n children?: ReactNode;\n name?: string;\n path?: string;\n backgroundColor?: string;\n defaultViewport?: { x: number; y: number; zoom: number };\n} & Record<`data-tempo-${string}`, unknown>) {\n const contextIdentity = useCanvasIdentity();\n // A Canvas without a name, or with a blank one, still declares its page\n // and the canvas names it after its file (V2-446). Throwing here kept the\n // page root from ever publishing, so the page stayed loading.\n const canvasName = name?.trim() || undefined;\n const canvasPath =\n path === undefined\n ? contextIdentity?.path\n : normalizeId(path, \"Canvas path\");\n\n if (!canvasPath) {\n throw new Error(\n '<Canvas> must be rendered inside <CanvasContext path=\"...\"> or receive a path prop.',\n );\n }\n\n const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);\n const declaration: CanvasDeclaration = {\n path: canvasPath,\n ...(canvasName ? { name: canvasName } : {}),\n backgroundColor,\n defaultViewport,\n };\n\n // Key each storyboard child by its declared id so React reconciles slots\n // by STORYBOARD IDENTITY rather than child position. Canvas files declare\n // storyboards as static JSX siblings (no keys), and positional\n // reconciliation reuses one storyboard's slot DOM node for another when\n // an edit inserts or removes a sibling above it — but slot DOM identity\n // is load-bearing: capture watchers, portal tracking, and the pool's\n // render-content wrappers all anchor to the slot node, and a reused node\n // silently starts feeding one storyboard's pipeline with another's\n // render.\n const keyedChildren = useMemo(() => {\n const automatic = new Set<string>();\n const flattened = Children.map(children, (child) => {\n if (isValidElement(child) && child.key == null) {\n const id = (child.props as { id?: unknown }).id;\n if (typeof id === \"string\" && id.length) automatic.add(id);\n }\n return child;\n });\n // Apply automatic keys AFTER Children.map: keys returned from its callback\n // are combined with the original sibling position, so deleting a board\n // would otherwise remount every unkeyed sibling after it. Authored keys\n // retain React's normal nested-array scoping.\n return flattened?.map((child) => {\n if (!isValidElement(child)) return child;\n const id = (child.props as { id?: unknown }).id;\n return typeof id === \"string\" && automatic.has(id)\n ? cloneElement(child, { key: getStoryboardKey(id) })\n : child;\n });\n }, [children]);\n\n return (\n <CanvasIdentityContext.Provider value={identity}>\n <div\n {...(sourceAnnotations as HTMLAttributes<HTMLDivElement>)}\n data-tempo-canvas={canvasName}\n data-tempo-canvas-path={canvasPath}\n data-tempo-canvas-declaration={JSON.stringify(declaration)}\n >\n {keyedChildren}\n </div>\n </CanvasIdentityContext.Provider>\n );\n}\n\nexport function CanvasContext({\n children,\n path,\n}: {\n children?: ReactNode;\n path: string;\n}) {\n const canvasPath = normalizeId(path, \"Canvas path\");\n const identity = useMemo(() => ({ path: canvasPath }), [canvasPath]);\n return (\n <CanvasIdentityContext.Provider value={identity}>\n {children}\n </CanvasIdentityContext.Provider>\n );\n}\n","import { createContext, useCallback, useContext } from \"react\";\n\nimport { useCanvasStoryboardRenderId } from \"./canvas\";\nimport type { V1RenderSizeCompat } from \"./v1-client-compat\";\n\nexport type CanvasHostRuntimeError = {\n message: string;\n stack?: string;\n componentStack?: string;\n};\n\nexport type CanvasHostRuntimeSize = V1RenderSizeCompat & {\n width?: number | string;\n height?: number | string;\n revision?: number;\n};\n\nexport type CanvasHostRuntimePlacement = {\n left: number;\n top: number;\n};\n\nexport type CanvasHostRuntime = {\n getStoryboardStatus(storyboardId: string): \"active\" | \"cached\" | \"unmounted\";\n getStoryboardSize(storyboardId: string): CanvasHostRuntimeSize | undefined;\n getStoryboardPlacement(\n storyboardId: string,\n ): CanvasHostRuntimePlacement | undefined;\n /** Reset capture-only inputs after imports, before a fresh user-tree mount.\n * Only the direct URL's selected storyboard may reset the document RNG. */\n prepareStoryboardCapture?(storyboardId: string): void;\n markStoryboardRendered(storyboardId: string): void;\n markStoryboardUnmounted(storyboardId: string): void;\n reportStoryboardError(\n storyboardId: string,\n error: CanvasHostRuntimeError,\n ): void;\n clearStoryboardError(storyboardId: string): void;\n reportCanvasImportError(\n canvasPath: string,\n error: CanvasHostRuntimeError,\n ): void;\n clearCanvasImportError(canvasPath: string): void;\n /**\n * Declares a canvas path as a problem-attribution candidate while its\n * boundary is mounted. Host-level Vite diagnostics that uniquely name a\n * registered canvas's source are scoped to that canvas instead of being\n * shown host-wide on every sibling. Returns the unregister disposer.\n */\n registerCanvasProblemScope(canvasPath: string): () => void;\n};\n\nexport const CanvasHostContext = createContext<CanvasHostRuntime | null>(null);\n\nexport function useRequiredCanvasHost(): CanvasHostRuntime {\n const host = useContext(CanvasHostContext);\n if (!host) {\n throw new Error(\n \"Tempo canvas components must be rendered inside <CanvasHost>.\",\n );\n }\n return host;\n}\n\nexport function useActiveState(storyboardId: string): boolean {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardStatus(renderId) !== \"unmounted\";\n}\n\nexport function useStoryboardStatus(\n storyboardId: string,\n): \"active\" | \"cached\" | \"unmounted\" {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardStatus(renderId);\n}\n\nexport function useStoryboardRendered(storyboardId: string): () => void {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return useCallback(() => {\n host.markStoryboardRendered(renderId);\n }, [host, renderId]);\n}\n\nexport function useStoryboardUnmounted(storyboardId: string): () => void {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const { markStoryboardUnmounted } = useRequiredCanvasHost();\n return useCallback(() => {\n markStoryboardUnmounted(renderId);\n }, [markStoryboardUnmounted, renderId]);\n}\n\nexport function useStoryboardErrorReporter(storyboardId: string): {\n reportError(error: CanvasHostRuntimeError): void;\n clearError(): void;\n} {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n const reportError = useCallback(\n (error: CanvasHostRuntimeError) => {\n host.reportStoryboardError(renderId, error);\n },\n [host, renderId],\n );\n const clearError = useCallback(() => {\n host.clearStoryboardError(renderId);\n }, [host, renderId]);\n return { reportError, clearError };\n}\n\nexport function useStoryboardSize(\n storyboardId: string,\n): CanvasHostRuntimeSize | undefined {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardSize(renderId);\n}\n\nexport function useStoryboardPlacement(\n storyboardId: string,\n): CanvasHostRuntimePlacement | undefined {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const host = useRequiredCanvasHost();\n return host.getStoryboardPlacement(renderId);\n}\n","import {\n Children,\n Component,\n type ComponentType,\n cloneElement,\n type ErrorInfo,\n isValidElement,\n type ReactNode,\n Suspense,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { PROJECTION_ROOT_ATTRIBUTE } from \"../../../modules/iframe-projection/combined/projection-layer-snapshot\";\nimport { PROJECTION_SCOPE_ROLE } from \"../../../modules/iframe-projection/fiber/projection-scope\";\n\nimport type { TempoStoryboard } from \"../page\";\nimport { beginAdmissionWindow } from \"./admission-budget\";\nimport { useCanvasIdentity, useCanvasStoryboardRenderId } from \"./canvas\";\nimport { CanvasPendingMarker } from \"./canvas-pending-marker\";\nimport {\n syncStoryboardPortals,\n trackStoryboardPortals,\n} from \"./portal-tracking\";\nimport { useRenderErrorRecovery } from \"./render-error-recovery\";\nimport { observeResponsiveSlotSize } from \"./responsive-slot-size\";\nimport {\n useRequiredCanvasHost,\n useStoryboardErrorReporter,\n useStoryboardPlacement,\n useStoryboardRendered,\n useStoryboardSize,\n useStoryboardStatus,\n useStoryboardUnmounted,\n} from \"./runtime-context\";\nimport {\n isV1CanvasClient,\n type V1LayoutCompat,\n v1SourceAnnotations,\n v1StoryboardSlotStyle,\n} from \"./v1-client-compat\";\n\nexport interface StoryboardLayout extends V1LayoutCompat {\n x: number;\n y: number;\n width?: number;\n height?: number;\n zIndex?: number;\n}\n\n/** A storyboard's declaration as its shell stamps it (one JSON attribute):\n * the Storyboard callsite's props, without the source annotations. */\nexport interface StoryboardDeclaration {\n id: string;\n name?: string;\n kind: \"component\" | \"route\" | \"html\";\n layout: {\n x: number;\n y: number;\n width?: number;\n height?: number;\n zIndex?: number;\n };\n route?: string;\n filepath?: string;\n /** @deprecated Retained for v2 clients; prefer filepath for local HTML. */\n src?: string;\n vrt?: boolean;\n uiFramework?: \"svelte\";\n}\n\nexport interface StoryboardVrtIgnoreRegion {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/**\n * Opt-in visual-regression tracking config (TEM-1775). The `vrt` prop is a\n * static, build-time mark read by AST enumeration (`parseCanvasFile`) — it\n * has no runtime behavior. Values must be literals to be tracked.\n */\nexport interface StoryboardVrtConfig {\n /** Per-storyboard pixelmatch threshold override (0..0.5). */\n threshold?: number;\n /** Temporarily untracked without losing config. */\n skip?: boolean;\n /** Regions (storyboard-local px) excluded from comparison. */\n ignore?: StoryboardVrtIgnoreRegion[];\n}\n\nexport function Storyboard<Props extends object = object>({\n id,\n name,\n component,\n layout,\n props,\n vrt,\n ...annotations\n}: {\n id: string;\n component: ComponentType<Props>;\n layout: StoryboardLayout;\n name?: string;\n props?: Props;\n [annotation: `data-tempo-${string}`]: unknown;\n /** Opt this storyboard into visual regression testing (static mark). */\n vrt?: boolean | StoryboardVrtConfig;\n} & Record<`data-tempo-${string}`, unknown>) {\n const Component = component as ComponentType<Props>;\n const content = isV1CanvasClient() ? (\n <Component\n {...(props ?? ({} as Props))}\n {...v1SourceAnnotations(annotations)}\n />\n ) : (\n <Component {...(props ?? ({} as Props))} />\n );\n\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"component\"\n vrt={!!vrt}\n >\n <ProjectionContent>{content}</ProjectionContent>\n </StoryboardSlot>\n );\n}\n\nexport function LegacyStoryboardV1({\n id,\n storyboard,\n}: {\n id: string;\n storyboard: TempoStoryboard;\n}) {\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={storyboard.name}\n layout={storyboard.layout}\n kind=\"component\"\n >\n <LegacyStoryboardV1Render render={storyboard.render} />\n </StoryboardSlot>\n );\n}\n\nfunction LegacyStoryboardV1Render({\n render,\n}: {\n render: TempoStoryboard[\"render\"];\n}) {\n return <>{render()}</>;\n}\n\nexport function RouteStoryboard({\n id,\n name,\n route,\n layout,\n ...annotations\n}: {\n id: string;\n route: string;\n layout: StoryboardLayout & { width: number; height: number };\n name?: string;\n} & Record<`data-tempo-${string}`, unknown>) {\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"route\"\n route={route}\n />\n );\n}\n\nexport function HtmlStoryboard({\n id,\n name,\n filepath,\n src,\n layout,\n vrt,\n ...annotations\n}: {\n id: string;\n layout: StoryboardLayout & { width: number; height: number };\n filepath?: string;\n /** @deprecated Retained for v2 clients; prefer filepath for local HTML. */\n src?: string;\n name?: string;\n /** Opt this local HTML storyboard into visual regression testing. */\n vrt?: boolean | StoryboardVrtConfig;\n} & Record<`data-tempo-${string}`, unknown>) {\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"html\"\n filepath={filepath}\n src={src}\n vrt={!!vrt}\n />\n );\n}\n\n/**\n * The shell every storyboard kind renders. It is SDK plumbing between the\n * public component (the callsite the compiler annotates) and the shell\n * element, so every caller hides its fiber: the projection then sees the\n * public component as the shell's parent, which the canvas reads as the\n * storyboard's root layer.\n */\nexport function StoryboardSlot({\n children,\n id,\n kind,\n layout,\n name,\n route,\n filepath,\n src,\n vrt,\n uiFramework,\n}: {\n \"data-tempo-hide-fiber\": \"true\";\n vrt?: boolean;\n uiFramework?: \"svelte\";\n children?: ReactNode;\n id: string;\n kind: \"component\" | \"route\" | \"html\";\n layout: StoryboardLayout;\n name?: string;\n route?: string;\n filepath?: string;\n /** @deprecated Retained for v2 clients; prefer filepath for local HTML. */\n src?: string;\n}) {\n const renderId = useCanvasStoryboardRenderId(id);\n const canvas = useCanvasIdentity();\n const status = useStoryboardStatus(id);\n const renderSize = useStoryboardSize(id);\n const placement = useStoryboardPlacement(id);\n const markRendered = useStoryboardRendered(id);\n const markUnmounted = useStoryboardUnmounted(id);\n const { reportError, clearError } = useStoryboardErrorReporter(id);\n const legacyResponsive = layout.intrinsicSizing === \"root-element\";\n const declaredWidth = legacyResponsive ? undefined : layout.width;\n const declaredHeight = legacyResponsive ? undefined : layout.height;\n // An explicit runtime entry owns the slot even when it carries no size.\n const renderWidth =\n renderSize === undefined ? declaredWidth : renderSize.width;\n const renderHeight =\n renderSize === undefined ? declaredHeight : renderSize.height;\n const fixed = renderWidth !== undefined && renderHeight !== undefined;\n const renderRevision = renderSize?.revision ?? 0;\n const resetKey = `${renderId}:${renderRevision}`;\n const contentRef = useRef<HTMLDivElement | null>(null);\n // Phase 1 commits this slot's own elements with no user code under them, so\n // the projection root can register off a DOM node that exists whatever the\n // storyboard's component does; phase 2 admits the user tree one task later,\n // by which point the registration command has been answered. Keying the\n // admission by render id gives every projection identity its own phase 1.\n // Server rendering has no live document to register against and no event\n // loop to keep responsive, so there the whole tree is admitted at once.\n const [admittedRenderId, setAdmittedRenderId] = useState<string | null>(\n typeof document === \"undefined\" ? renderId : null,\n );\n const admitted = admittedRenderId === renderId;\n const errorBoundaryRef = useRef<StoryboardErrorBoundary | null>(null);\n const lastReportedCommitRef = useRef<string | null>(null);\n const previousChildrenRef = useRef(children);\n const [recoveryRevision, setRecoveryRevision] = useState(0);\n const commitKey = `${resetKey}:${recoveryRevision}`;\n // Bumping the recovery revision after a successful boundary reset remounts\n // the commit signal, so a recovery is re-reported (clearError) instead of\n // being swallowed by the commit-key dedupe.\n const retryRenderNow = useCallback(() => {\n if (!errorBoundaryRef.current?.retry()) return false;\n setRecoveryRevision((revision) => revision + 1);\n return true;\n }, []);\n const { noteRenderError, noteRecovered } =\n useRenderErrorRecovery(retryRenderNow);\n const handleRenderError = useCallback(\n (error: { message: string; stack?: string; componentStack?: string }) => {\n noteRenderError();\n reportError(error);\n },\n [noteRenderError, reportError],\n );\n // React finishes the remaining layout effects after capturing a sibling\n // layout-effect error, so the commit signal is provisional. Report success\n // in the next task, after the boundary has had a chance to record the error.\n const pendingRenderedReportRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const handleRendered = useCallback(\n (reportedCommitKey: string) => {\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n }\n pendingRenderedReportRef.current = setTimeout(() => {\n pendingRenderedReportRef.current = null;\n if (errorBoundaryRef.current?.hasError()) return;\n noteRecovered();\n if (lastReportedCommitRef.current === reportedCommitKey) return;\n lastReportedCommitRef.current = reportedCommitKey;\n clearError();\n markRendered();\n }, 0);\n },\n [clearError, markRendered, noteRecovered],\n );\n useEffect(\n () => () => {\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n pendingRenderedReportRef.current = null;\n }\n },\n [],\n );\n useLayoutEffect(() => {\n if (status !== \"unmounted\") return;\n // The slot survives render-cache eviction even though its content does\n // not. A direct URL can remount that content with the SAME commit key;\n // it must report the new commit after the runtime forgot the old render.\n lastReportedCommitRef.current = null;\n if (pendingRenderedReportRef.current !== null) {\n clearTimeout(pendingRenderedReportRef.current);\n pendingRenderedReportRef.current = null;\n }\n }, [status]);\n const renderChildren = useMemo(() => {\n if (isValidElement(children)) return cloneElement(children);\n return Children.map(children, (child) =>\n isValidElement(child) ? cloneElement(child) : child,\n );\n }, [children]);\n\n useLayoutEffect(() => {\n if (\n isV1CanvasClient() ||\n fixed ||\n status === \"unmounted\" ||\n !contentRef.current\n )\n return;\n return observeResponsiveSlotSize(contentRef.current);\n }, [fixed, renderId, status]);\n\n useEffect(() => markUnmounted, [markUnmounted]);\n\n // A passive effect, deliberately: React flushes these in a scheduler task of\n // their own, so the microtask checkpoint between phase 1's commit and this\n // admission is where the frame's registration observer gets to run.\n useEffect(() => {\n setAdmittedRenderId(renderId);\n }, [renderId]);\n\n useEffect(() => {\n const childrenChanged = previousChildrenRef.current !== children;\n previousChildrenRef.current = children;\n if (childrenChanged) retryRenderNow();\n }, [children, retryRenderNow]);\n\n useEffect(() => {\n if (!contentRef.current || status === \"unmounted\") return;\n return trackStoryboardPortals(renderId, contentRef.current, status);\n }, [renderId, status]);\n\n useEffect(() => {\n if (status === \"unmounted\") return;\n syncStoryboardPortals(renderId, status);\n }, [renderId, status]);\n\n // The shell is this storyboard's declaration on the page root's layer\n // stream, so it exists whether or not the content renders; the annotated\n // Storyboard callsite above it carries the source facts.\n const declaration = JSON.stringify({\n id: id.trim(),\n name,\n kind,\n layout: {\n x: layout.x,\n y: layout.y,\n width: declaredWidth,\n height: declaredHeight,\n zIndex: layout.zIndex,\n },\n route,\n filepath,\n src,\n vrt,\n uiFramework,\n } satisfies StoryboardDeclaration);\n\n if (status === \"unmounted\")\n return (\n <div\n data-tempo-storyboard-declaration={declaration}\n data-tempo-storyboard-id={id}\n hidden\n />\n );\n return (\n <div\n data-render-id={renderId}\n data-render-status={status}\n data-tempo-storyboard-render-id={renderId}\n data-tempo-storyboard-declaration={declaration}\n data-tempo-storyboard-id={id}\n data-tempo-canvas-path={canvas?.path}\n data-tempo-storyboard-name={name}\n data-tempo-storyboard-kind={kind}\n data-tempo-storyboard-route={route}\n data-tempo-storyboard-filepath={filepath}\n data-tempo-storyboard-src={src}\n style={\n isV1CanvasClient()\n ? v1StoryboardSlotStyle({\n kind,\n layout,\n renderSize,\n placement,\n status,\n })\n : {\n position: \"absolute\",\n left: placement?.left ?? (fixed ? layout.x : 0),\n top: placement?.top ?? (fixed ? layout.y : 0),\n ...(fixed ? { width: renderWidth, height: renderHeight } : {}),\n zIndex: layout.zIndex,\n // A hidden shell is already out of hit testing. It must not also\n // say pointer-events none: the producer records every element's\n // computed pointer-events as an app fact, and a full taken while\n // a restored shell is still cached would mark all of its content\n // click-through.\n visibility: status === \"active\" ? \"visible\" : \"hidden\",\n }\n }\n >\n <div\n data-render-content={renderId}\n // Phase 2's marker: the producer registers off the shell but waits for\n // this before opening its watch, so no baseline is ever taken from the\n // placeholder-only phase 1.\n data-render-admitted={admitted ? \"true\" : undefined}\n data-tempo-render-mode={kind === \"html\" ? \"static-dom\" : undefined}\n data-tempo-hide-fiber=\"true\"\n // The content root's own element: the page root above it stops\n // here, so a storyboard's content is published by one root only.\n {...{ [PROJECTION_ROOT_ATTRIBUTE]: \"true\" }}\n ref={contentRef}\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <StoryboardErrorBoundary\n ref={errorBoundaryRef}\n onError={handleRenderError}\n resetKey={resetKey}\n >\n {admitted ? (\n <Suspense fallback={<CanvasPendingMarker />}>\n <StoryboardAdmission renderId={renderId}>\n {renderChildren}\n </StoryboardAdmission>\n <StoryboardCommitSignal\n key={commitKey}\n commitKey={commitKey}\n onCommit={handleRendered}\n />\n </Suspense>\n ) : (\n // An established watch can rebind to this shell after a remount,\n // before the passive admission effect runs. Mark that loading\n // phase so it holds the preview instead of publishing an empty\n // baseline. Admitted components may still intentionally return null.\n <CanvasPendingMarker />\n )}\n </StoryboardErrorBoundary>\n </div>\n </div>\n );\n}\n\n/** Opens the admission budget for the user tree React is about to render\n * under it. Rendering this component is what arms the counter, so it must sit\n * directly above the user tree and below the error boundary that catches the\n * budget's throw. */\nfunction StoryboardAdmission({\n children,\n renderId,\n}: {\n children?: ReactNode;\n renderId: string;\n}) {\n const host = useRequiredCanvasHost();\n // Imports can consume random values on a cold page but stay cached on a\n // reused page. Reset once, after those imports and before the user tree's\n // render/effects; ordinary updates must keep advancing the same sequence.\n useState(() => host.prepareStoryboardCapture?.(renderId));\n beginAdmissionWindow();\n return children;\n}\n\nfunction StoryboardCommitSignal({\n commitKey,\n onCommit,\n}: {\n commitKey: string;\n onCommit(commitKey: string): void;\n}) {\n const onCommitRef = useRef(onCommit);\n onCommitRef.current = onCommit;\n useLayoutEffect(() => onCommitRef.current(commitKey), [commitKey]);\n return null;\n}\n\ntype StoryboardErrorBoundaryProps = {\n children?: ReactNode;\n onError(error: {\n message: string;\n stack?: string;\n componentStack?: string;\n }): void;\n resetKey: string;\n};\n\ntype StoryboardErrorBoundaryState = {\n error: Error | null;\n componentStack?: string;\n resetKey: string;\n};\n\n/** React emits one component-stack frame per fiber, so a storyboard that\n * recursed until it hit the admission budget produces a megabyte of stack in\n * which every frame after the first few is the same repeated line. The whole\n * string is reported onto the storyboard's problem lane and read back by the\n * Tempo renderer, so it is cut where it stops being evidence. */\nconst maxReportedComponentStackFrames = 40;\n\nfunction boundComponentStack(\n componentStack: string | null | undefined,\n): string | undefined {\n if (!componentStack) return undefined;\n const frames = componentStack.split(\"\\n\");\n if (frames.length <= maxReportedComponentStackFrames) return componentStack;\n const dropped = frames.length - maxReportedComponentStackFrames;\n return [\n ...frames.slice(0, maxReportedComponentStackFrames),\n ` ... ${dropped} more frames`,\n ].join(\"\\n\");\n}\n\nclass StoryboardErrorBoundary extends Component<\n StoryboardErrorBoundaryProps,\n StoryboardErrorBoundaryState\n> {\n state: StoryboardErrorBoundaryState = {\n error: null,\n componentStack: undefined,\n resetKey: this.props.resetKey,\n };\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n static getDerivedStateFromProps(\n props: StoryboardErrorBoundaryProps,\n state: StoryboardErrorBoundaryState,\n ) {\n if (props.resetKey !== state.resetKey) {\n return {\n error: null,\n componentStack: undefined,\n resetKey: props.resetKey,\n };\n }\n return null;\n }\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n const componentStack = boundComponentStack(info.componentStack);\n this.setState({ componentStack });\n this.props.onError({\n message: error.message,\n stack: error.stack,\n componentStack,\n });\n }\n\n hasError(): boolean {\n return this.state.error !== null;\n }\n\n retry(): boolean {\n if (!this.state.error) return false;\n this.setState((state) =>\n state.error\n ? { error: null, componentStack: undefined, resetKey: state.resetKey }\n : null,\n );\n return true;\n }\n\n render() {\n if (this.state.error) {\n return (\n <div\n data-render-error=\"true\"\n data-render-error-message={this.state.error.message}\n style={{ width: \"100%\", height: \"100%\" }}\n />\n );\n }\n return this.props.children;\n }\n}\n\n/** Declares the hosted invocation's output without adding a DOM wrapper or\n * passing framework instrumentation into the user's component props. */\nconst ProjectionContent = Object.assign(\n function ProjectionContent({ children }: { children: ReactNode }) {\n return children;\n },\n { [PROJECTION_SCOPE_ROLE]: \"output\" as const },\n);\nObject.assign(StoryboardAdmission, { [PROJECTION_SCOPE_ROLE]: \"transparent\" });\nObject.assign(StoryboardCommitSignal, {\n [PROJECTION_SCOPE_ROLE]: \"transparent\",\n});\nObject.assign(StoryboardErrorBoundary, {\n [PROJECTION_SCOPE_ROLE]: \"transparent\",\n});\n","import * as React from \"react\";\n\n/**\n * A bound on how much render work can happen in one uninterrupted burst.\n *\n * A user can write `const Loop = () => <Loop/>` — or split the same cycle\n * across two modules that import each other — into any storyboard file. React\n * then allocates fibers until the renderer dies at V8's 4 GB heap limit. No\n * timer, watchdog, or IPC message can intervene, because the render loop is\n * synchronous and never yields the thread: nothing else in the document runs\n * again, ever. The bound therefore has to be enforced from inside the render\n * itself.\n *\n * React transitions its hooks dispatcher on entry to and exit from every\n * function component (`renderWithHooks` / `finishRenderingHooks` both assign\n * `ReactSharedInternals.H`), so an accessor on that one property counts render\n * work across arbitrary user code with nothing injected into user modules.\n * Past the budget the accessor throws, which is an ordinary render-phase\n * throw: React unwinds to the nearest storyboard error boundary, every sibling\n * in the same pass still renders and commits, and an infinite recursion\n * becomes one storyboard showing a problem instead of a dead canvas.\n *\n * The counter re-arms on the first microtask after any step, which is what\n * makes the bound *per burst* rather than per render pass. A synchronous React\n * pass never reaches a microtask checkpoint, so a runaway drains one budget and\n * throws, while ordinary work is handed a full budget again the moment the\n * thread returns to the event loop. Bounding bursts rather than passes is what\n * catches the common case: a user edits an already-mounted storyboard into a\n * recursive one, and Fast Refresh re-renders that component's own fiber without\n * ever re-rendering the storyboard slot above it.\n */\n\n/**\n * Dispatcher transitions one burst may spend. React transitions twice per\n * function component, so this is roughly 50k component instantiations: orders\n * of magnitude above any real storyboard (a large one costs a few thousand)\n * and orders of magnitude below the fiber count that exhausts the heap.\n */\nexport const admissionRenderStepBudget = 100_000;\n\n/** Thrown from inside the render that exceeded {@link admissionRenderStepBudget}. */\nexport class AdmissionBudgetError extends Error {\n constructor() {\n super(\n \"This storyboard renders itself recursively: it kept creating \" +\n \"components without ever finishing a render. Check for a component \" +\n \"that returns itself, or two components that render each other.\",\n );\n this.name = \"AdmissionBudgetError\";\n }\n}\n\n/**\n * Where React keeps the current hooks dispatcher: `H` on React 19's client\n * internals, `ReactCurrentDispatcher.current` on React 18. Both are assigned\n * on every function component render, which is the only property of them this\n * module depends on.\n */\nfunction findDispatcherSlot(): {\n holder: Record<string, unknown>;\n key: string;\n} | null {\n const react = React as unknown as Record<string, Record<string, unknown>>;\n const modern =\n react.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;\n if (modern && \"H\" in modern) return { holder: modern, key: \"H\" };\n const legacy = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentDispatcher as Record<string, unknown> | undefined;\n if (legacy && \"current\" in legacy) return { holder: legacy, key: \"current\" };\n return null;\n}\n\nlet stepsRemaining = admissionRenderStepBudget;\nlet rearmScheduled = false;\nlet counterState: \"uninstalled\" | \"installed\" | \"unavailable\" = \"uninstalled\";\n\nfunction scheduleRearm(): void {\n if (rearmScheduled) return;\n rearmScheduled = true;\n queueMicrotask(() => {\n rearmScheduled = false;\n stepsRemaining = admissionRenderStepBudget;\n });\n}\n\nfunction installCounter(): boolean {\n if (counterState !== \"uninstalled\") return counterState === \"installed\";\n const slot = findDispatcherSlot();\n if (!slot) {\n // A React whose dispatcher lives somewhere else still renders storyboards\n // correctly; it just runs without this bound. Failing open is deliberate:\n // an internals rename must never stop storyboards from rendering, and the\n // projection stall watchdog remains the outcome-based net underneath.\n counterState = \"unavailable\";\n return false;\n }\n const { holder, key } = slot;\n let dispatcher = holder[key];\n Object.defineProperty(holder, key, {\n configurable: true,\n get: () => dispatcher,\n set: (value: unknown) => {\n dispatcher = value;\n scheduleRearm();\n stepsRemaining -= 1;\n if (stepsRemaining > 0) return;\n // Re-arming as it throws lets React's unwinding assignments through, and\n // hands React's one automatic retry of the failed root a fresh budget so\n // the retry trips the same way and the boundary finally sees the error.\n stepsRemaining = admissionRenderStepBudget;\n throw new AdmissionBudgetError();\n },\n });\n counterState = \"installed\";\n return true;\n}\n\n/**\n * Charges the storyboard about to render its own budget, so one pass covering\n * many storyboards cannot accumulate their work into a single overrun. Called\n * during render, immediately above the user tree.\n */\nexport function beginAdmissionWindow(): void {\n if (!installCounter()) return;\n stepsRemaining = admissionRenderStepBudget;\n}\n","import { PROJECTION_SCOPE_ROLE } from \"../../../modules/iframe-projection/fiber/projection-scope\";\nimport { PROJECTION_PENDING_ATTRIBUTE } from \"../../../modules/iframe-projection/combined/projection-pending\";\n\n/**\n * The placeholder Tempo-owned admission and Suspense boundaries render\n * while they wait.\n *\n * A not-yet-admitted or suspended subtree reaches the DOM as an empty one,\n * which is indistinguishable from a subtree that intentionally emptied. This\n * marker makes the difference observable to the projection producer, which treats a root\n * whose children are all markers as pending and holds the mirror's last-good\n * content instead of publishing the blank.\n *\n * Only Tempo's own boundaries render it. A user's Suspense inside their\n * storyboard keeps mirroring faithfully: their fallback — even `null` —\n * renders inside the root with no marker beside it, so their loading state\n * stays a real state the mirror shows.\n *\n * It carries no layout of its own: the host document must look the same with a\n * subtree pending as it does with that subtree absent.\n */\nexport function CanvasPendingMarker() {\n return (\n <div\n {...{ [PROJECTION_PENDING_ATTRIBUTE]: \"\" }}\n data-tempo-hide-fiber=\"true\"\n style={{ display: \"none\" }}\n aria-hidden=\"true\"\n />\n );\n}\n\n// Both the wrapper and its sentinel host are SDK plumbing, never authored layers.\nObject.assign(CanvasPendingMarker, { [PROJECTION_SCOPE_ROLE]: \"transparent\" });\n","type FiberLike = {\n return: FiberLike | null;\n stateNode: unknown;\n};\n\ntype PortalWatcher = {\n element: Element;\n onPortalFound(portalRoot: Element): void;\n onPortalRemoved(portalRoot: Element): void;\n};\n\ntype PortalInlineStyleValue = {\n value: string;\n priority: string;\n};\n\ntype PortalInlineStyle = {\n visibility: PortalInlineStyleValue;\n pointerEvents: PortalInlineStyleValue;\n contentVisibility: PortalInlineStyleValue;\n transition: PortalInlineStyleValue;\n animation: PortalInlineStyleValue;\n};\n\ntype PortalManagedProperty = {\n // The PortalInlineStyle field that holds this property's saved baseline.\n key: keyof PortalInlineStyle;\n // The CSS property name as written in inline styles.\n cssName: string;\n // The value forced (with !important) while the portal is hidden.\n hiddenValue: string;\n};\n\n// Single source of truth for the inline-style properties this module overrides\n// to hide cached/inactive portals, so the hide path and the restore path can't\n// drift out of sync.\nconst PORTAL_MANAGED_PROPERTIES: readonly PortalManagedProperty[] = [\n { key: \"visibility\", cssName: \"visibility\", hiddenValue: \"hidden\" },\n { key: \"pointerEvents\", cssName: \"pointer-events\", hiddenValue: \"none\" },\n {\n key: \"contentVisibility\",\n cssName: \"content-visibility\",\n hiddenValue: \"hidden\",\n },\n { key: \"transition\", cssName: \"transition\", hiddenValue: \"none\" },\n { key: \"animation\", cssName: \"animation\", hiddenValue: \"none\" },\n];\n\nconst portalElementsByRenderId = new Map<string, Set<Element>>();\nconst portalOwnerRenderIdsByElement = new Map<Element, Set<string>>();\nconst portalInlineStyleByElement = new Map<Element, PortalInlineStyle>();\nconst renderStatusById = new Map<string, \"active\" | \"cached\">();\nconst projectionPortalIdAttribute = \"data-projection-portal-id\";\nlet nextSdkPortalId = 1;\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n}\n\nfunction ensureProjectionPortalId(portalRoot: Element): string {\n const existingId = portalRoot.getAttribute(projectionPortalIdAttribute);\n if (existingId) return existingId;\n\n const id = `tempo-sdk-portal-${nextSdkPortalId++}`;\n portalRoot.setAttribute(projectionPortalIdAttribute, id);\n return id;\n}\n\nfunction buildProjectionPortalSelector(portalRoot: Element): string {\n return `[${projectionPortalIdAttribute}=\"${escapeAttributeValue(\n ensureProjectionPortalId(portalRoot),\n )}\"]`;\n}\n\nfunction findFiberKey(element: Element): string | null {\n return (\n Object.keys(element).find(\n (key) =>\n key.startsWith(\"__reactFiber$\") ||\n key.startsWith(\"__reactInternalInstance$\"),\n ) ?? null\n );\n}\n\nfunction findContainerKey(element: Element): string | null {\n return Object.keys(element).find((key) => key.startsWith(\"__reactContainer$\")) ?? null;\n}\n\nfunction getFiberFromElement(element: Element): FiberLike | null {\n const fiberKey = findFiberKey(element);\n if (fiberKey) {\n return (\n (element as unknown as Record<string, FiberLike | undefined>)[fiberKey] ??\n null\n );\n }\n\n const containerKey = findContainerKey(element);\n if (containerKey) {\n return (\n (element as unknown as Record<string, FiberLike | undefined>)[\n containerKey\n ] ?? null\n );\n }\n\n return null;\n}\n\nclass PortalTracker {\n private readonly watchers = new Set<PortalWatcher>();\n private readonly ownerWatchersByPortalRoot = new Map<\n Element,\n Set<PortalWatcher>\n >();\n private observer: MutationObserver | null = null;\n\n register(watcher: PortalWatcher): () => void {\n this.watchers.add(watcher);\n\n if (this.watchers.size === 1) {\n this.startObserving();\n }\n\n if (typeof document !== \"undefined\" && document.body) {\n this.checkExistingElements();\n queueMicrotask(() => this.checkExistingElements());\n }\n\n return () => this.unregister(watcher);\n }\n\n private checkExistingElements(): void {\n if (typeof document === \"undefined\" || !document.body) return;\n for (const child of Array.from(document.body.children)) {\n this.checkElement(child);\n }\n }\n\n private unregister(watcher: PortalWatcher): void {\n this.watchers.delete(watcher);\n\n for (const [portalRoot, owners] of this.ownerWatchersByPortalRoot) {\n owners.delete(watcher);\n if (owners.size === 0) {\n this.ownerWatchersByPortalRoot.delete(portalRoot);\n }\n }\n\n if (this.watchers.size === 0) {\n this.stopObserving();\n }\n }\n\n private startObserving(): void {\n if (\n this.observer ||\n typeof document === \"undefined\" ||\n !document.body ||\n typeof MutationObserver === \"undefined\"\n ) {\n return;\n }\n\n this.observer = new MutationObserver(this.handleMutations);\n this.observer.observe(document.body, { childList: true });\n }\n\n private stopObserving(): void {\n this.observer?.disconnect();\n this.observer = null;\n }\n\n private handleMutations = (mutations: MutationRecord[]): void => {\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (node instanceof Element) {\n queueMicrotask(() => this.checkElement(node));\n }\n }\n\n for (const node of mutation.removedNodes) {\n if (!(node instanceof Element)) continue;\n const owners = this.ownerWatchersByPortalRoot.get(node);\n if (!owners) continue;\n for (const owner of owners) {\n owner.onPortalRemoved(node);\n }\n this.ownerWatchersByPortalRoot.delete(node);\n }\n }\n };\n\n private checkElement(element: Element): void {\n const ancestorDomNodes = this.getDomAncestorsViaFiber(element);\n if (ancestorDomNodes.length === 0) return;\n\n let owners = this.ownerWatchersByPortalRoot.get(element);\n for (const watcher of this.watchers) {\n const belongsToWatcher = ancestorDomNodes.some(\n (node) => watcher.element.contains(node) || watcher.element === node,\n );\n if (!belongsToWatcher) continue;\n\n if (!owners) {\n owners = new Set<PortalWatcher>();\n this.ownerWatchersByPortalRoot.set(element, owners);\n }\n if (owners.has(watcher)) continue;\n\n owners.add(watcher);\n watcher.onPortalFound(element);\n }\n }\n\n private getDomAncestorsViaFiber(element: Element): Element[] {\n const fiber = getFiberFromElement(element);\n if (!fiber) return [];\n\n const domNodes: Element[] = [];\n let current: FiberLike | null = fiber.return;\n while (current) {\n if (current.stateNode instanceof Element) {\n domNodes.push(current.stateNode);\n }\n current = current.return;\n }\n return domNodes;\n }\n}\n\nlet portalTracker: PortalTracker | null = null;\n\nfunction getPortalTracker(): PortalTracker {\n if (!portalTracker) {\n portalTracker = new PortalTracker();\n }\n return portalTracker;\n}\n\nfunction getStylablePortalElement(\n portalRoot: Element,\n): HTMLElement | SVGElement | null {\n if (portalRoot instanceof HTMLElement || portalRoot instanceof SVGElement) {\n return portalRoot;\n }\n return null;\n}\n\nfunction ensurePortalInlineStyle(portalRoot: Element): PortalInlineStyle {\n const existing = portalInlineStyleByElement.get(portalRoot);\n if (existing) return existing;\n\n const stylableElement = getStylablePortalElement(portalRoot);\n const baseline = {\n visibility: readInlineStyleValue(stylableElement, \"visibility\"),\n pointerEvents: readInlineStyleValue(stylableElement, \"pointer-events\"),\n contentVisibility: readInlineStyleValue(\n stylableElement,\n \"content-visibility\",\n ),\n transition: readInlineStyleValue(stylableElement, \"transition\"),\n animation: readInlineStyleValue(stylableElement, \"animation\"),\n };\n portalInlineStyleByElement.set(portalRoot, baseline);\n return baseline;\n}\n\nfunction readInlineStyleValue(\n element: HTMLElement | SVGElement | null,\n propertyName: string,\n): PortalInlineStyleValue {\n return {\n value: element?.style.getPropertyValue(propertyName) ?? \"\",\n priority: element?.style.getPropertyPriority(propertyName) ?? \"\",\n };\n}\n\nfunction restoreInlineStyleValue(\n style: CSSStyleDeclaration,\n propertyName: string,\n baseline: PortalInlineStyleValue,\n): void {\n if (baseline.value) {\n style.setProperty(propertyName, baseline.value, baseline.priority);\n return;\n }\n style.removeProperty(propertyName);\n}\n\nfunction restorePortalInlineStyle(portalRoot: Element): void {\n const stylableElement = getStylablePortalElement(portalRoot);\n const baseline = portalInlineStyleByElement.get(portalRoot);\n if (!stylableElement || !baseline) return;\n\n for (const property of PORTAL_MANAGED_PROPERTIES) {\n restoreInlineStyleValue(\n stylableElement.style,\n property.cssName,\n baseline[property.key],\n );\n }\n}\n\nfunction syncPortalVisibility(portalRoot: Element): void {\n const owners = portalOwnerRenderIdsByElement.get(portalRoot);\n if (!owners || owners.size === 0) {\n restorePortalInlineStyle(portalRoot);\n portalInlineStyleByElement.delete(portalRoot);\n return;\n }\n\n const stylableElement = getStylablePortalElement(portalRoot);\n if (!stylableElement) return;\n\n const shouldBeVisible = [...owners].some(\n (renderId) => renderStatusById.get(renderId) === \"active\",\n );\n\n if (shouldBeVisible) {\n restorePortalInlineStyle(portalRoot);\n portalInlineStyleByElement.delete(portalRoot);\n return;\n }\n\n ensurePortalInlineStyle(portalRoot);\n for (const property of PORTAL_MANAGED_PROPERTIES) {\n stylableElement.style.setProperty(\n property.cssName,\n property.hiddenValue,\n \"important\",\n );\n }\n}\n\nfunction trackPortal(renderId: string, portalRoot: Element): void {\n ensureProjectionPortalId(portalRoot);\n\n const portals = portalElementsByRenderId.get(renderId) ?? new Set<Element>();\n portals.add(portalRoot);\n portalElementsByRenderId.set(renderId, portals);\n\n const owners = portalOwnerRenderIdsByElement.get(portalRoot) ?? new Set<string>();\n owners.add(renderId);\n portalOwnerRenderIdsByElement.set(portalRoot, owners);\n syncPortalVisibility(portalRoot);\n}\n\nfunction untrackPortal(renderId: string, portalRoot: Element): void {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return;\n\n portals.delete(portalRoot);\n if (portals.size === 0) {\n portalElementsByRenderId.delete(renderId);\n }\n\n const owners = portalOwnerRenderIdsByElement.get(portalRoot);\n if (owners) {\n owners.delete(renderId);\n if (owners.size === 0) {\n portalOwnerRenderIdsByElement.delete(portalRoot);\n }\n }\n syncPortalVisibility(portalRoot);\n}\n\nexport function releaseStoryboardPortals(renderId: string): void {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) {\n renderStatusById.delete(renderId);\n return;\n }\n\n for (const portalRoot of [...portals]) {\n untrackPortal(renderId, portalRoot);\n }\n renderStatusById.delete(renderId);\n}\n\nexport function getStoryboardPortalSelectors(renderId: string): string[] {\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return [];\n return [...portals]\n .filter((portalRoot) => portalRoot.isConnected)\n .map(buildProjectionPortalSelector);\n}\n\nexport function syncStoryboardPortals(\n renderId: string,\n status: \"active\" | \"cached\",\n): void {\n renderStatusById.set(renderId, status);\n const portals = portalElementsByRenderId.get(renderId);\n if (!portals) return;\n for (const portalRoot of portals) {\n syncPortalVisibility(portalRoot);\n }\n}\n\nexport function trackStoryboardPortals(\n renderId: string,\n element: Element,\n status: \"active\" | \"cached\",\n): () => void {\n syncStoryboardPortals(renderId, status);\n const unregister = getPortalTracker().register({\n element,\n onPortalFound(portalRoot) {\n trackPortal(renderId, portalRoot);\n },\n onPortalRemoved(portalRoot) {\n untrackPortal(renderId, portalRoot);\n },\n });\n\n return () => {\n unregister();\n releaseStoryboardPortals(renderId);\n };\n}\n","import { useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Self-contained recovery for storyboard render errors.\n *\n * A render error unmounts the throwing subtree, so React Fast Refresh alone\n * cannot repair it: refresh only re-renders mounted fibers, and the fixed\n * component has none. The design shell repairs this by advancing the render\n * revision (which resets the boundary), but a host page without the shell —\n * a direct `/tempo-host?canvasPath=...` document — has no revision driver at\n * all. Recovery must therefore be armed from inside the SDK:\n *\n * - a retry timer with exponential backoff, armed while a boundary is\n * errored — the universal mechanism, needing no signal from anyone; and\n * - an immediate retry on an HMR beat, when one is observable — new code\n * just arrived, so waiting out the backoff would be pure latency.\n *\n * The beat arrives over a window-global bus (create-if-absent on both sides,\n * mirroring the host-recovery feed) from the devserver-generated Vite\n * recovery adapter, which owns `import.meta.hot`. This module must stay free\n * of literal `import.meta` itself: the built bundle is force-resolved into\n * Expo's Metro web bundle, which runs as a classic script where that token\n * is a parse error that kills the whole document (TEM-1409). The beat is\n * best-effort by design — hosts without the adapter (Expo, a bare\n * `/tempo-host?canvasPath=...` document) never see one. That asymmetry is\n * why the backoff cap stays low: without a beat, the cap IS the worst-case\n * fix-to-recovery latency.\n */\n\n/** First retry after a fresh error; also the rung the ladder resets to. */\nexport const renderErrorRetryBaseDelayMs = 1_000;\n/**\n * Backoff cap. Doubling stops here (1s → 2s → 4s → 8s) so a persistently\n * broken storyboard costs at most one re-render per 8s — negligible even for\n * expensive trees — while a fix still becomes visible within 8s when no HMR\n * beat is observable.\n */\nexport const renderErrorRetryMaxDelayMs = 8_000;\n\ntype RenderErrorRecoveryBeatBus = {\n emit(): void;\n subscribe(listener: () => void): () => void;\n};\n\nconst BEAT_BUS_KEY = \"__tempoRenderErrorRecoveryBeatBus\";\n\nfunction createBeatBus(): RenderErrorRecoveryBeatBus {\n const listeners = new Set<() => void>();\n return {\n emit() {\n for (const listener of [...listeners]) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n// The beat is a document-lifetime fact, not a per-storyboard one, and its\n// producer (the generated Vite adapter) must not import the SDK — so the bus\n// lives on the window global with create-if-absent semantics on both sides,\n// exactly like the host-recovery feed: whichever party evaluates first\n// creates it, the other reuses it.\nfunction getRenderErrorRecoveryBeatBus(): RenderErrorRecoveryBeatBus {\n const globals = globalThis as typeof globalThis & {\n [BEAT_BUS_KEY]?: RenderErrorRecoveryBeatBus;\n };\n return (globals[BEAT_BUS_KEY] ??= createBeatBus());\n}\n\n/**\n * Announces \"new code may have arrived\" to every errored boundary. Exported\n * so tests can drive beats directly; production beats come from the\n * devserver-generated Vite recovery adapter emitting on the shared bus.\n */\nexport function emitRenderErrorRecoveryBeat(): void {\n getRenderErrorRecoveryBeatBus().emit();\n}\n\n/**\n * Owns the retry schedule for one storyboard's error boundary. The caller\n * reports the boundary's state transitions (`noteRenderError` from every\n * catch, `noteRecovered` from every healthy commit) and supplies `retryNow`,\n * which resets the boundary and returns whether it was actually errored.\n *\n * The normal still-broken loop is: timer fires → retry → children throw →\n * catch calls `noteRenderError` → next rung is armed. A retry that sticks\n * leads to a commit, whose `noteRecovered` clears the pending state and\n * resets the ladder.\n */\nexport function useRenderErrorRecovery(retryNow: () => boolean): {\n noteRenderError(): void;\n noteRecovered(): void;\n} {\n const retryNowRef = useRef(retryNow);\n retryNowRef.current = retryNow;\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const nextDelayRef = useRef(renderErrorRetryBaseDelayMs);\n const erroredRef = useRef(false);\n\n const clearTimer = useCallback(() => {\n if (timerRef.current === null) return;\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }, []);\n\n const noteRenderError = useCallback(() => {\n erroredRef.current = true;\n // A pending timer already covers this error (e.g. a children-change\n // retry failed while the scheduled one was still counting down).\n if (timerRef.current !== null) return;\n const delay = nextDelayRef.current;\n nextDelayRef.current = Math.min(delay * 2, renderErrorRetryMaxDelayMs);\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n retryNowRef.current();\n }, delay);\n }, []);\n\n const noteRecovered = useCallback(() => {\n erroredRef.current = false;\n nextDelayRef.current = renderErrorRetryBaseDelayMs;\n clearTimer();\n }, [clearTimer]);\n\n useEffect(() => {\n const onBeat = () => {\n // Fresh code deserves a fresh ladder: whether the immediate retry\n // below succeeds or re-catches, the next scheduled attempt starts\n // from the base delay again.\n nextDelayRef.current = renderErrorRetryBaseDelayMs;\n if (!erroredRef.current) return;\n clearTimer();\n retryNowRef.current();\n };\n const unsubscribe = getRenderErrorRecoveryBeatBus().subscribe(onBeat);\n return () => {\n unsubscribe();\n clearTimer();\n };\n }, [clearTimer]);\n\n return { noteRenderError, noteRecovered };\n}\n","/**\n * Absolutely positioned component roots do not contribute to shrink-to-fit\n * layout. Give a responsive slot a minimum enclosing their positive extents,\n * so the slot, projection size and capture selector all describe the same box.\n * Authored elements are never restyled. Fixed slots never install this helper.\n */\nexport function observeResponsiveSlotSize(content: HTMLElement): () => void {\n const slot = content.parentElement;\n const view = content.ownerDocument.defaultView;\n if (!slot || !view) return () => {};\n const previousWidth = slot.style.minWidth;\n const previousHeight = slot.style.minHeight;\n const previousContentHeight = content.style.minHeight;\n // A percentage height does not resolve against a parent's min-height.\n // The capture selector is the content wrapper, so it must share that minimum.\n content.style.minHeight = \"inherit\";\n const roots = new Set<Element>();\n let disposed = false;\n let scheduledFrame: number | null = null;\n\n const measure = () => {\n if (disposed) return;\n for (const root of roots) {\n if (root.parentElement !== content) {\n resize.unobserve(root);\n roots.delete(root);\n }\n }\n for (const root of content.children) {\n if (!roots.has(root)) {\n roots.add(root);\n resize.observe(root, { box: \"border-box\" });\n }\n }\n // Measure natural layout each time. Measuring against our previous minimum\n // would prevent shrinking and retain a phantom box after removing the root.\n slot.style.minWidth = previousWidth;\n slot.style.minHeight = previousHeight;\n const natural = slot.getBoundingClientRect();\n let width = natural.width;\n let height = natural.height;\n for (const root of roots) {\n if (view.getComputedStyle(root).position !== \"absolute\") continue;\n const rect = root.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) continue;\n width = Math.max(width, rect.right - natural.left);\n height = Math.max(height, rect.bottom - natural.top);\n }\n if (width > natural.width) slot.style.minWidth = `${Math.ceil(width)}px`;\n if (height > natural.height)\n slot.style.minHeight = `${Math.ceil(height)}px`;\n };\n // A root can resize during layout (fonts, stylesheets, responsive CSS).\n // Resizing its observed ancestor in the same delivery causes skipped resize\n // notifications. Coalesce later measurements before the next paint instead.\n const scheduleMeasure = () => {\n if (disposed || scheduledFrame !== null) return;\n scheduledFrame = view.requestAnimationFrame(() => {\n scheduledFrame = null;\n measure();\n });\n };\n const resize = new view.ResizeObserver(scheduleMeasure);\n const mutations = new view.MutationObserver((records) => {\n // Descendant edits are covered by the root's ResizeObserver. Only root\n // replacement and root attributes can change the bounds without resizing.\n if (\n records.some((record) =>\n record.type === \"childList\"\n ? record.target === content\n : record.target.parentElement === content,\n )\n )\n scheduleMeasure();\n });\n resize.observe(slot, { box: \"border-box\" });\n // Position/class edits and root replacement need a measure even when the\n // zero-size wrapper itself never receives a ResizeObserver notification.\n mutations.observe(content, {\n childList: true,\n subtree: true,\n attributes: true,\n });\n measure();\n return () => {\n disposed = true;\n if (scheduledFrame !== null) view.cancelAnimationFrame(scheduledFrame);\n resize.disconnect();\n mutations.disconnect();\n content.style.minHeight = previousContentHeight;\n slot.style.minWidth = previousWidth;\n slot.style.minHeight = previousHeight;\n };\n}\n","/**\n * The canvas protocol a Tempo client declares on every host document URL it\n * loads: `?canvasProtocol=<CANVAS_CLIENT_PROTOCOL>`. Released V1 clients send\n * nothing, which means protocol 1. Host behavior that differs between clients\n * is gated on this number, never on an app version: local builds report 0.0.2\n * and the headless capture CLI carries its own version.\n *\n * Dependency-light on purpose: the client's direct-render URL builder is\n * bundled into a published CLI and imports the two constants from here.\n */\nexport const CANVAS_CLIENT_PROTOCOL = 2;\n\nexport const CANVAS_CLIENT_PROTOCOL_PARAM = \"canvasProtocol\";\n\n/** The protocol of the client that loaded this document; 1 when the URL\n * carries no usable value or there is no window (server rendering). */\nexport function canvasClientProtocol(): number {\n if (typeof window === \"undefined\") return 1;\n const value = new URLSearchParams(window.location.search).get(\n CANVAS_CLIENT_PROTOCOL_PARAM,\n );\n if (value === null) return 1;\n const protocol = Number(value.trim());\n return Number.isInteger(protocol) && protocol >= 1 ? protocol : 1;\n}\n","/**\n * @deprecated V1 client compat.\n *\n * Everything a released V1 Tempo client (app 0.0.114, driving tempo-sdk\n * 0.0.51 behavior) still expects from this host and that V2 no longer does.\n * A workspace's installed tempo-sdk follows registry `latest` independently\n * of the desktop app's update cadence, so a V1 client keeps loading hosts\n * built from this SDK until the force-upgrade floor ages it out.\n *\n * Every call site gates on `isV1CanvasClient()`, so a V2 client runs today's\n * code paths untouched. Delete this file once no protocol-1 client is\n * supported; the compiler then lists every call site to remove.\n */\nimport type { CSSProperties } from \"react\";\n\nimport { canvasClientProtocol } from \"./client-protocol\";\nimport type {\n CanvasHostRuntimePlacement,\n CanvasHostRuntimeSize,\n} from \"./runtime-context\";\nimport type { StoryboardLayout } from \"./storyboard\";\n\n/** The layout spelling a V1 client still writes and type-checks\n * (`tsc --noEmit` over canvases against `TempoStoryboard`). */\nexport type V1LayoutCompat = {\n /** @deprecated A legacy responsive marker: the width and height beside it\n * are first-paint hints, not a frame. V2 reads the triple as responsive. */\n intrinsicSizing?: \"root-element\";\n};\n\n/** The V1 render request's hug flag: the slot hugs its rendered root, with\n * the supplied width and height as its minimum. */\nexport type V1RenderSizeCompat = {\n /** @deprecated V2 clients never send it. */\n intrinsicSize?: boolean;\n};\n\nexport function isV1CanvasClient(): boolean {\n return canvasClientProtocol() < 2;\n}\n\n/** The render command's `intrinsicSize`, read the way 0.0.51 did. */\nexport function v1RenderRequestSize(\n payload: Record<string, unknown>,\n): V1RenderSizeCompat {\n return { intrinsicSize: payload.intrinsicSize === true ? true : undefined };\n}\n\n// `intrinsicSize=1` (or any value but \"0\"/\"false\") is the direct-URL spelling\n// of the render command's flag, so a V1 capture driver expresses an intrinsic\n// capture before the storyboard mounts instead of resizing it afterwards.\nfunction readDirectUrlFlag(value: string | null): boolean {\n if (value === null) return false;\n const normalized = value.trim().toLowerCase();\n return normalized !== \"0\" && normalized !== \"false\";\n}\n\n/** The direct URL's size, read the way 0.0.51 did: no size params means no\n * runtime entry (the slot keeps its declared box), a lone dimension is an\n * error, and `intrinsicSize` rides along. */\nexport function v1DirectUrlSize(\n params: URLSearchParams,\n readDimension: (value: string) => number | string,\n): CanvasHostRuntimeSize | undefined {\n const width = params.get(\"width\")?.trim();\n const height = params.get(\"height\")?.trim();\n const intrinsicSize = readDirectUrlFlag(params.get(\"intrinsicSize\"));\n if (!width && !height) {\n return intrinsicSize ? { intrinsicSize: true, revision: 1 } : undefined;\n }\n if (!width || !height) {\n throw new Error(\"Direct URL width and height must be provided together\");\n }\n return {\n width: readDimension(width),\n height: readDimension(height),\n ...(intrinsicSize ? { intrinsicSize: true } : {}),\n revision: 1,\n };\n}\n\n/** The `data-tempo-*` annotations of a Storyboard callsite. 0.0.51 forwarded\n * them onto the rendered component, and the V1 client roots the storyboard's\n * layer tree at the outermost annotated component and edits the callsite's\n * `props` through it. */\nexport function v1SourceAnnotations(\n props: Record<string, unknown>,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(props).filter(([key]) => key.startsWith(\"data-tempo-\")),\n );\n}\n\n/** The storyboard shell's inline style as 0.0.51 computed it: a runtime\n * entry without a size keeps the declared box, an intrinsic slot hugs its\n * content, and a cached slot is click-through. */\nexport function v1StoryboardSlotStyle(slot: {\n kind: \"component\" | \"route\" | \"html\";\n layout: StoryboardLayout;\n renderSize: CanvasHostRuntimeSize | undefined;\n placement: CanvasHostRuntimePlacement | undefined;\n status: \"active\" | \"cached\";\n}): CSSProperties {\n const { kind, layout, renderSize, placement, status } = slot;\n const renderWidth = renderSize?.width;\n const renderHeight = renderSize?.height;\n const intrinsicSize =\n renderSize?.intrinsicSize ??\n (kind === \"component\" && layout.intrinsicSizing === \"root-element\");\n return {\n position: \"absolute\",\n left: placement?.left ?? layout.x,\n top: placement?.top ?? layout.y,\n width: intrinsicSize ? \"max-content\" : (renderWidth ?? layout.width),\n height: intrinsicSize ? \"max-content\" : (renderHeight ?? layout.height),\n minWidth: intrinsicSize ? renderWidth : undefined,\n minHeight: intrinsicSize ? renderHeight : undefined,\n zIndex: layout.zIndex,\n visibility: status === \"active\" ? \"visible\" : \"hidden\",\n pointerEvents: status === \"active\" ? \"auto\" : \"none\",\n };\n}\n"],"mappings":";;;;;;;AAAO,SAAS,YAAY,OAA2B,OAAuB;AAC5E,QAAM,aAAa,OAAO,KAAK;AAC/B,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,GAAG,KAAK,eAAe;AAAA,EACzC;AACA,SAAO;AACT;AAGO,SAAS,iBAAiB,IAAoB;AACnD,SAAO,cAAc,EAAE;AACzB;;;ACXA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAuHD;AAhGN,IAAM,wBAAwB,cAAqC,IAAI;AAEhE,SAAS,4BACd,YACA,cACQ;AACR,SAAO,UAAU;AAAA,IACf,YAAY,YAAY,aAAa;AAAA,EACvC,CAAC,eAAe;AAAA,IACd,YAAY,cAAc,eAAe;AAAA,EAC3C,CAAC;AACH;AAEO,SAAS,oBAA2C;AACzD,SAAO,WAAW,qBAAqB;AACzC;AAEO,SAAS,4BAA4B,cAA8B;AACxE,QAAM,SAAS,kBAAkB;AACjC,QAAM,eAAe,YAAY,cAAc,eAAe;AAC9D,SAAO,SACH,4BAA4B,OAAO,MAAM,YAAY,IACrD;AACN;AAEO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAM6C;AAC3C,QAAM,kBAAkB,kBAAkB;AAI1C,QAAM,aAAa,MAAM,KAAK,KAAK;AACnC,QAAM,aACJ,SAAS,SACL,iBAAiB,OACjB,YAAY,MAAM,aAAa;AAErC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,QAAQ,OAAO,EAAE,MAAM,WAAW,IAAI,CAAC,UAAU,CAAC;AACnE,QAAM,cAAiC;AAAA,IACrC,MAAM;AAAA,I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AAClB,WAAO,KAAK,MAAM,UAAU;AAAA,EAC9B;AAAA,EAEA,QAAiB;AACf,QAAI,CAAC,KAAK,MAAM,MAAO,QAAO;AAC9B,SAAK;AAAA,MAAS,CAAC,UACb,MAAM,QACF,EAAE,OAAO,MAAM,gBAAgB,QAAW,UAAU,MAAM,SAAS,IACnE;AAAA,IACN;AACA,WAAO;AAAA,EACT;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,MAAM,OAAO;AACpB,aACE,gBAAAF;AAAA,QAAC;AAAA;AAAA,UACC,qBAAkB;AAAA,UAClB,6BAA2B,KAAK,MAAM,MAAM;AAAA,UAC5C,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO;AAAA;AAAA,MACzC;AAAA,IAEJ;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAIA,IAAM,oBAAoB,OAAO;AAAA,EAC/B,SAASS,mBAAkB,EAAE,SAAS,GAA4B;AAChE,WAAO;AAAA,EACT;AAAA,EACA,EAAE,CAAC,qBAAqB,GAAG,SAAkB;AAC/C;AACA,OAAO,OAAO,qBAAqB,EAAE,CAAC,qBAAqB,GAAG,cAAc,CAAC;AAC7E,OAAO,OAAO,wBAAwB;AAAA,EACpC,CAAC,qBAAqB,GAAG;AAC3B,CAAC;AACD,OAAO,OAAO,yBAAyB;AAAA,EACrC,CAAC,qBAAqB,GAAG;AAC3B,CAAC;","names":["createContext","useContext","createContext","useContext","Children","cloneElement","isValidElement","useCallback","useEffect","useMemo","useRef","jsx","useCallback","useCallback","jsx","Component","useRef","useCallback","useEffect","useMemo","isValidElement","cloneElement","Children","ProjectionContent"]}
|
|
@@ -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.60\",\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 canvas-dependency-scan-browser.test.ts 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;AAC9B,SAAS,SAAS,WAAAA,gBAAe;;;ACnBjC,SAAS,oBAAoB;AAC7B,SAAS,eAAe;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gCAAgC;AAAA,MAC9B,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AA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