tempo-sdk 0.0.99 → 0.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3926
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-CXCUJCXD.js +1 -0
  37. package/dist/chunk-FH6TMWFA.js +1 -0
  38. package/dist/chunk-FL7FSJSL.js +1 -0
  39. package/dist/chunk-GQIOB5SV.js +1 -0
  40. package/dist/chunk-HBQ7FFH7.js +1 -0
  41. package/dist/chunk-JRJOWLCN.js +1 -0
  42. package/dist/chunk-LJCBFTMP.js +1 -0
  43. package/dist/chunk-M3GN2KUH.js +1 -0
  44. package/dist/chunk-MPIHFFML.js +1 -0
  45. package/dist/chunk-T5TY3U2H.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-ZXBMP6RV.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-27WT3XUG.js +0 -455
  99. package/dist/chunk-27WT3XUG.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6HYKKP5N.js +0 -2658
  105. package/dist/chunk-6HYKKP5N.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYDF4LYJ.js +0 -342
  113. package/dist/chunk-CYDF4LYJ.js.map +0 -1
  114. package/dist/chunk-CYQE3TLC.js +0 -37
  115. package/dist/chunk-CYQE3TLC.js.map +0 -1
  116. package/dist/chunk-DI2ZFAWL.js +0 -14
  117. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  118. package/dist/chunk-EGRHWZRV.js +0 -1
  119. package/dist/chunk-EGRHWZRV.js.map +0 -1
  120. package/dist/chunk-FGWGY3G3.js +0 -157
  121. package/dist/chunk-FGWGY3G3.js.map +0 -1
  122. package/dist/chunk-HOBTDB6G.js +0 -112
  123. package/dist/chunk-HOBTDB6G.js.map +0 -1
  124. package/dist/chunk-I7VF4ZOV.js +0 -630
  125. package/dist/chunk-I7VF4ZOV.js.map +0 -1
  126. package/dist/chunk-JVVHU3A7.js +0 -1077
  127. package/dist/chunk-JVVHU3A7.js.map +0 -1
  128. package/dist/chunk-MIXQVPDH.js +0 -8606
  129. package/dist/chunk-MIXQVPDH.js.map +0 -1
  130. package/dist/chunk-MU7S7NU7.js +0 -183
  131. package/dist/chunk-MU7S7NU7.js.map +0 -1
  132. package/dist/chunk-OX2YKYSL.js +0 -13
  133. package/dist/chunk-OX2YKYSL.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-SGN7BDRE.js +0 -16
  137. package/dist/chunk-SGN7BDRE.js.map +0 -1
  138. package/dist/chunk-SGTGDLOX.js +0 -285
  139. package/dist/chunk-SGTGDLOX.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-WTXOWQ7N.js +0 -47
  145. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  146. package/dist/chunk-X5DJKVBT.js +0 -1308
  147. package/dist/chunk-X5DJKVBT.js.map +0 -1
  148. package/dist/chunk-ZT7HJ6YU.js +0 -38
  149. package/dist/chunk-ZT7HJ6YU.js.map +0 -1
  150. package/dist/chunk-ZW26VZHX.js +0 -3169
  151. package/dist/chunk-ZW26VZHX.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
package/package.json CHANGED
@@ -1,18 +1,13 @@
1
1
  {
2
2
  "name": "tempo-sdk",
3
- "version": "0.0.99",
4
-
5
- "publishConfig": {
6
- "tag": "sdk-v2-latest"
7
- },
8
- "type": "module",
9
- "description": "Tempo SDK \u2014 Vite, Next.js, Nuxt, Expo, Svelte, Vue and Astro canvas integration, source annotations and storyboard types",
10
-
3
+ "version": "0.0.102",
4
+ "description": "Tempo SDK — Vite, Next.js, Nuxt, Expo, Svelte, Vue and Astro canvas integration, source annotations and storyboard types",
11
5
  "repository": {
12
6
  "type": "git",
13
7
  "url": "git+https://github.com/TempoLabsAI/tempo-monorepo.git",
14
8
  "directory": "tempo-modules/tempo-sdk"
15
9
  },
10
+ "type": "module",
16
11
  "exports": {
17
12
  "./astro/controls": {
18
13
  "types": "./dist/astro/controls.d.ts",
@@ -118,27 +113,6 @@
118
113
  "import": "./dist/canvas/flutter-preview.js"
119
114
  }
120
115
  },
121
- "files": [
122
- "dist",
123
- "astro/client.d.ts"
124
- ],
125
- "scripts": {
126
- "clean": "rm -rf dist",
127
- "build": "pnpm run clean && tsup",
128
- "build:if-missing": "test -f dist/index.js || pnpm run build",
129
- "prepare": "pnpm run build",
130
- "prepublishOnly": "pnpm build",
131
- "demo": "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
132
- "demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
133
- "demo:nuxt": "pnpm --filter @tempo-modules/tempo-sdk-nuxt-demo dev",
134
- "test": "vitest run",
135
- "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 flutter-storyboard-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts astro-integration.test.ts astro-storyboard-routing.test.ts astro-react-integration.test.ts astro-descriptor-browser.test.ts astro-packed.test.ts",
136
- "test:watch": "vitest",
137
- "test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
138
- "test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
139
- "test:nextjs:production": "vitest run nextjs-production.test.ts",
140
- "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"
141
- },
142
116
  "dependencies": {
143
117
  "@rollup/pluginutils": "^5.1.0",
144
118
  "oxc-parser": "^0.110.0"
@@ -186,37 +160,13 @@
186
160
  "optional": true
187
161
  }
188
162
  },
189
- "devDependencies": {
190
- "@astrojs/react": "7.0.1",
191
- "@babel/core": "^7.29.0",
192
- "@babel/types": "^7.29.0",
193
- "@modules/annotation": "workspace:*",
194
- "@modules/astro-editor": "workspace:*",
195
- "@modules/file-parser": "workspace:*",
196
- "@modules/frame-pool": "workspace:*",
197
- "@modules/iframe-projection": "workspace:*",
198
- "@modules/svelte-editor": "workspace:*",
199
- "@modules/vue-editor": "workspace:*",
200
- "@nuxt/kit": "^4.6.2",
201
- "@types/babel__core": "^7.20.5",
202
- "@types/node": "^25.0.8",
203
- "@types/react": "catalog:",
204
- "@types/react-dom": "catalog:",
205
- "@vitejs/plugin-react": "catalog:",
206
- "@vitejs/plugin-vue": "6.0.10",
207
- "astro": "7.3.8",
208
- "h3": "^1.15.11",
209
- "magic-string": "^0.30.21",
210
- "nuxt": "^4.6.2",
211
- "playwright": "^1.58.2",
212
- "react-dom": "catalog:",
213
- "react-dom18": "npm:react-dom@18.3.1",
214
- "react18": "npm:react@18.3.1",
215
- "svelte": "5.56.9",
216
- "tsup": "^8.5.1",
217
- "typescript": "catalog:",
218
- "vite": "catalog:",
219
- "vitest": "catalog:",
220
- "vue": "3.5.44"
221
- }
163
+ "tempoRuntimeContract": 1,
164
+ "publishConfig": {
165
+ "tag": "latest",
166
+ "access": "public"
167
+ },
168
+ "files": [
169
+ "dist",
170
+ "astro/client.d.ts"
171
+ ]
222
172
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../assets/editor.ts"],"sourcesContent":["/**\n * Span-based source editor for `defineAsset` declarations\n * (specs/asset-libraries.md §4). Mirrors canvas/editor.ts: every operation\n * re-parses internally, validates its precondition against the fresh parse,\n * and splices at recorded spans — unrelated file bytes stay untouched.\n * Bad state produces a typed failure ({@link AssetEditFailure}), never a\n * guessed edit.\n *\n * Operations:\n * ensureNamedDefaultExport({ filePath, source })\n * ensureAssetDeclaration({ filePath, source, bindingName, initialConfig })\n * addLibraries({ filePath, source, bindingName, libraries })\n * removeLibraries({ filePath, source, bindingName, libraries })\n */\nimport {\n ASSET_SDK_IMPORT_SOURCE,\n collectIdentifierNames,\n collectTopLevelScope,\n hasTopLevelDefineAssetCallFor,\n parseAssetFile,\n parseAssetProgram,\n readAssetImports,\n toSourceSpan,\n unwrapTsExpression,\n} from \"./parser\";\nimport {\n isUnresolvedValue,\n type AssetEditFailureCode,\n type AssetSourceSpan,\n type ParsedAssetDeclaration,\n type StaticValue,\n} from \"./types\";\n\nexport type { AssetEditFailureCode } from \"./types\";\n\nexport type AssetEditFailure = {\n ok: false;\n code: AssetEditFailureCode;\n message: string;\n};\n\nexport type AssetEditSuccess = {\n ok: true;\n source: string;\n /** False when the operation was a no-op (already in the desired state). */\n changed: boolean;\n};\n\nexport type AssetEditResult = AssetEditSuccess | AssetEditFailure;\n\nexport type EnsureNamedDefaultExportResult =\n | (AssetEditSuccess & { bindingName: string })\n | AssetEditFailure;\n\n/** Fully-static config for `ensureAssetDeclaration` codegen. Values must not\n * contain UNRESOLVED markers — this is codegen input, not parse output. */\nexport type AssetInitialConfig = {\n usageInstructions?: string;\n libraries?: string[];\n variants?: Record<string, { props: Record<string, StaticValue> }>;\n};\n\n/**\n * Name an anonymous `export default` so a statement-form `defineAsset` can\n * reference it (§4.2). No-op when the default export already is (or\n * references) a named binding. The transform keeps the default export a plain\n * identifier reference, so React Fast Refresh's component-only export\n * analysis still holds:\n *\n * export default <expr> => const <name> = <expr>;\n * export default <name>;\n * export default function () {} => function <name>() {}\n * export default <name>;\n */\nexport function ensureNamedDefaultExport(options: {\n filePath: string;\n source: string;\n}): EnsureNamedDefaultExportResult {\n const { program, errors } = parseAssetProgram(options.filePath, options.source);\n if (!program) {\n return failure(\n \"not_definable\",\n errors[0]?.message ?? \"asset source has syntax errors\",\n );\n }\n\n const statement = (program.body ?? []).find(\n (node: any) => node?.type === \"ExportDefaultDeclaration\",\n );\n if (!statement) {\n return failure(\"export_not_found\", `no default export in ${options.filePath}`);\n }\n\n const declaration = statement.declaration;\n const isDeclarationForm =\n declaration?.type === \"FunctionDeclaration\" ||\n declaration?.type === \"ClassDeclaration\";\n if (isDeclarationForm && typeof declaration.id?.name === \"string\") {\n return {\n ok: true,\n source: options.source,\n changed: false,\n bindingName: declaration.id.name,\n };\n }\n if (!isDeclarationForm) {\n const expression = unwrapTsExpression(declaration);\n if (expression?.type === \"Identifier\") {\n return {\n ok: true,\n source: options.source,\n changed: false,\n bindingName: expression.name,\n };\n }\n }\n\n const statementSpan = toSourceSpan(statement);\n const declarationSpan = toSourceSpan(declaration);\n if (!statementSpan || !declarationSpan) {\n return failure(\"not_definable\", \"default export has no source span\");\n }\n\n const bindingName = pickAvailableName(\n deriveDefaultExportName(options.filePath),\n collectIdentifierNames(program),\n );\n if (bindingName === undefined) {\n return failure(\n \"not_definable\",\n \"could not derive a free identifier for the default export\",\n );\n }\n const newline = detectNewline(options.source);\n\n let edits: SourceEdit[];\n if (isDeclarationForm) {\n // Anonymous declaration form: drop the `export default ` prefix, insert\n // the name after the function/class keyword, re-export by name.\n const head = options.source.slice(\n declarationSpan.start,\n declarationSpan.start + 64,\n );\n const keyword =\n declaration.type === \"FunctionDeclaration\"\n ? head.match(/^(?:async\\s+)?function(?:\\s*\\*)?/)\n : head.match(/^class\\b/);\n if (!keyword) {\n return failure(\"not_definable\", \"unsupported default export shape\");\n }\n // Replace the whitespace run after the keyword (\"function () {\" already\n // has one) so the named form carries exactly one space on each side —\n // none before the parameter list, one before a class body.\n const nameOffset = declarationSpan.start + keyword[0].length;\n let nameEnd = nameOffset;\n while (\n nameEnd < options.source.length &&\n /\\s/.test(options.source[nameEnd] ?? \"\")\n ) {\n nameEnd++;\n }\n const nameValue =\n options.source[nameEnd] === \"(\" ? ` ${bindingName}` : ` ${bindingName} `;\n edits = [\n { start: statementSpan.start, end: declarationSpan.start, value: \"\" },\n { start: nameOffset, end: nameEnd, value: nameValue },\n {\n start: statementSpan.end,\n end: statementSpan.end,\n value: `${newline}export default ${bindingName};`,\n },\n ];\n } else {\n // Expression form: bind the expression to a const, re-export by name.\n // The trailing splice replaces the original semicolon (when present).\n edits = [\n {\n start: statementSpan.start,\n end: declarationSpan.start,\n value: `const ${bindingName} = `,\n },\n {\n start: declarationSpan.end,\n end: statementSpan.end,\n value: `;${newline}export default ${bindingName};`,\n },\n ];\n }\n\n return { ...applyEdits(options.source, edits), bindingName };\n}\n\n/**\n * Add the tempo-sdk/assets import (if absent) and insert a\n * `defineAsset(<bindingName>, <initialConfig>)` statement directly after the\n * top-level statement declaring the binding, separated by one blank line\n * (§4.3). No-op when a clean declaration for the binding already exists.\n */\nexport function ensureAssetDeclaration(options: {\n filePath: string;\n source: string;\n bindingName: string;\n initialConfig?: AssetInitialConfig;\n}): AssetEditResult {\n const { program, errors } = parseAssetProgram(options.filePath, options.source);\n if (!program) {\n return failure(\n \"not_definable\",\n errors[0]?.message ?? \"asset source has syntax errors\",\n );\n }\n\n const parsed = parseAssetFile(options.filePath, options.source);\n if (\n parsed.declarations.some(\n (declaration) => declaration.bindingName === options.bindingName,\n )\n ) {\n return { ok: true, source: options.source, changed: false };\n }\n\n const imports = readAssetImports(program);\n if (\n hasTopLevelDefineAssetCallFor(\n program,\n imports.trustedDefineAssetNames,\n options.bindingName,\n )\n ) {\n return failure(\n \"config_not_editable\",\n `an existing defineAsset declaration for \"${options.bindingName}\" has structural errors — fix it instead of adding another`,\n );\n }\n\n const binding = collectTopLevelScope(program).bindings.get(\n options.bindingName,\n );\n if (!binding) {\n const importSource = imports.importedBindings.get(options.bindingName);\n return failure(\n \"not_definable\",\n importSource !== undefined\n ? `\"${options.bindingName}\" is imported from \"${importSource}\" — defineAsset must live in the file that defines the component`\n : `no top-level binding \"${options.bindingName}\" in ${options.filePath}`,\n );\n }\n\n const style = detectCodeStyle(options.source);\n const edits: SourceEdit[] = [];\n\n let callName: string;\n if (imports.trustedDefineAssetNames.size > 0) {\n callName = imports.trustedDefineAssetNames.values().next().value as string;\n } else {\n const identifiers = collectIdentifierNames(program);\n if (identifiers.has(\"defineAsset\")) {\n const picked = pickAvailableName(\"defineAsset\", identifiers);\n if (picked === undefined) {\n return failure(\n \"not_definable\",\n \"could not derive a free identifier for the defineAsset import\",\n );\n }\n callName = picked;\n } else {\n callName = \"defineAsset\";\n }\n const specifier =\n callName === \"defineAsset\" ? \"defineAsset\" : `defineAsset as ${callName}`;\n const importLine = `import { ${specifier} } from ${quoteString(\n ASSET_SDK_IMPORT_SOURCE,\n style.quote,\n )};`;\n edits.push(\n buildImportInsertionEdit(\n options.source,\n imports.importDeclarationSpans,\n importLine,\n style.newline,\n ),\n );\n }\n\n const callText = serializeDefineAssetCall(\n callName,\n options.bindingName,\n options.initialConfig ?? {},\n style,\n );\n const insertionOffset = statementInsertionOffset(\n options.source,\n binding.statementSpan.end,\n );\n edits.push({\n start: insertionOffset,\n end: insertionOffset,\n value: `${style.newline}${style.newline}${callText}`,\n });\n\n return applyEdits(options.source, edits);\n}\n\n/**\n * Insert missing names into the declaration's libraries array, creating the\n * property when absent. Existing entry order is preserved; already-present\n * names are skipped.\n */\nexport function addLibraries(options: {\n filePath: string;\n source: string;\n bindingName: string;\n libraries: string[];\n}): AssetEditResult {\n const located = locateDeclaration(options);\n if (!located.ok) return located;\n const { declaration } = located;\n\n const names: string[] = [];\n for (const name of options.libraries) {\n if (name === \"\") continue;\n if (declaration.libraries.includes(name)) continue;\n if (names.includes(name)) continue;\n names.push(name);\n }\n if (names.length === 0) {\n return { ok: true, source: options.source, changed: false };\n }\n\n const style = detectCodeStyle(options.source);\n const serialized = names\n .map((name) => quoteString(name, style.quote))\n .join(\", \");\n const spans = declaration.spans;\n\n if (spans.libraries) {\n const lastItem = spans.libraryItems[spans.libraryItems.length - 1];\n if (lastItem) {\n return applyEdits(options.source, [\n { start: lastItem.end, end: lastItem.end, value: `, ${serialized}` },\n ]);\n }\n // No statically-known entries — but non-literal entries the parser\n // dropped may still occupy the array, so prepend rather than assume\n // emptiness.\n const inner = options.source.slice(\n spans.libraries.start + 1,\n spans.libraries.end - 1,\n );\n const offset = spans.libraries.start + 1;\n const value = inner.trim() === \"\" ? serialized : `${serialized}, `;\n return applyEdits(options.source, [{ start: offset, end: offset, value }]);\n }\n\n if (spans.librariesProperty) {\n return failure(\n \"config_not_editable\",\n `the libraries property of \"${options.bindingName}\" is not an editable array literal`,\n );\n }\n\n return applyEdits(options.source, [\n insertConfigProperty(\n options.source,\n spans.config,\n `libraries: [${serialized}]`,\n style,\n ),\n ]);\n}\n\n/**\n * Remove matching string entries from the declaration's libraries array.\n * Names not present are ignored. When this operation empties the array, the\n * whole `libraries` property is removed — a library-less asset carries no\n * empty-array residue.\n */\nexport function removeLibraries(options: {\n filePath: string;\n source: string;\n bindingName: string;\n libraries: string[];\n}): AssetEditResult {\n const targets = new Set(options.libraries.filter((name) => name !== \"\"));\n let located = locateDeclaration(options);\n if (!located.ok) return located;\n\n // A dynamic `libraries: <expr>` value can't be inspected, so \"ignore names\n // not present\" can't be honored — refuse rather than guess.\n if (\n targets.size > 0 &&\n located.declaration.spans.librariesProperty &&\n !located.declaration.spans.libraries\n ) {\n return failure(\n \"config_not_editable\",\n `the libraries property of \"${options.bindingName}\" is not an editable array literal`,\n );\n }\n\n let source = options.source;\n let changed = false;\n\n // The parser dedupes duplicated source entries, surfacing them one parse at\n // a time — loop until no target name remains in the parsed list.\n for (let iteration = 0; iteration < 32; iteration++) {\n const declaration = located.declaration;\n const removals: AssetSourceSpan[] = [];\n declaration.libraries.forEach((name, index) => {\n const span = declaration.spans.libraryItems[index];\n if (targets.has(name) && span) {\n removals.push(expandListItemRemoval(source, span));\n }\n });\n if (removals.length === 0) break;\n\n source = spliceRemovals(source, removals);\n changed = true;\n\n const relocated = locateDeclaration({ ...options, source });\n // The declaration cannot vanish mid-edit; fail typed rather than guess.\n if (!relocated.ok) return relocated;\n located = relocated;\n }\n\n // Property cleanup only when THIS operation emptied the array — entries the\n // parser dropped (non-literal expressions) still count as occupants, and a\n // pre-existing empty array on a no-op call stays untouched.\n if (changed) {\n const spans = located.declaration.spans;\n if (\n spans.libraries &&\n spans.librariesProperty &&\n /^\\s*$/.test(\n source.slice(spans.libraries.start + 1, spans.libraries.end - 1),\n )\n ) {\n source = spliceRemovals(source, [\n expandListItemRemoval(source, spans.librariesProperty),\n ]);\n }\n }\n\n return { ok: true, source, changed };\n}\n\ntype LocatedDeclaration =\n | { ok: true; declaration: ParsedAssetDeclaration }\n | AssetEditFailure;\n\nfunction locateDeclaration(options: {\n filePath: string;\n source: string;\n bindingName: string;\n}): LocatedDeclaration {\n const { program, errors } = parseAssetProgram(options.filePath, options.source);\n if (!program) {\n return failure(\n \"config_not_editable\",\n errors[0]?.message ?? \"asset source has syntax errors\",\n );\n }\n\n const parsed = parseAssetFile(options.filePath, options.source);\n const declaration = parsed.declarations.find(\n (candidate) => candidate.bindingName === options.bindingName,\n );\n if (declaration) return { ok: true, declaration };\n\n const imports = readAssetImports(program);\n if (\n hasTopLevelDefineAssetCallFor(\n program,\n imports.trustedDefineAssetNames,\n options.bindingName,\n )\n ) {\n return failure(\n \"config_not_editable\",\n `the defineAsset declaration for \"${options.bindingName}\" has structural errors and cannot be edited`,\n );\n }\n return failure(\n \"asset_not_found\",\n `no defineAsset declaration for \"${options.bindingName}\" in ${options.filePath}`,\n );\n}\n\nfunction failure(code: AssetEditFailureCode, message: string): AssetEditFailure {\n return { ok: false, code, message };\n}\n\ntype SourceEdit = { start: number; end: number; value: string };\n\nfunction applyEdits(source: string, edits: SourceEdit[]): AssetEditSuccess {\n const sorted = [...edits].sort((left, right) => right.start - left.start);\n let previousStart = source.length + 1;\n let next = source;\n\n for (const edit of sorted) {\n if (edit.start < 0 || edit.end < edit.start || edit.end > previousStart) {\n throw new Error(\n `Invalid overlapping asset source edit ${edit.start}:${edit.end}`,\n );\n }\n next = next.slice(0, edit.start) + edit.value + next.slice(edit.end);\n previousStart = edit.start;\n }\n\n return { ok: true, source: next, changed: next !== source };\n}\n\nfunction spliceRemovals(source: string, spans: AssetSourceSpan[]): string {\n const sorted = [...spans].sort((left, right) => left.start - right.start);\n // Adjacent removals expand into shared commas/whitespace — merge overlaps\n // so the splice stays well-formed.\n const merged: AssetSourceSpan[] = [];\n for (const span of sorted) {\n const last = merged[merged.length - 1];\n if (last && span.start <= last.end) {\n last.end = Math.max(last.end, span.end);\n } else {\n merged.push({ ...span });\n }\n }\n\n let result = source;\n for (let index = merged.length - 1; index >= 0; index--) {\n const span = merged[index];\n result = result.slice(0, span.start) + result.slice(span.end);\n }\n return result;\n}\n\n/**\n * Expand an array-element or object-property span so its removal leaves a\n * well-formed container and no residue: consume the following comma (and a\n * now-blank line) when present, else the preceding comma, else — for the only\n * item — the surrounding whitespace so single-line containers collapse\n * cleanly (`{ x }` → `{}`).\n */\nfunction expandListItemRemoval(\n source: string,\n span: AssetSourceSpan,\n): AssetSourceSpan {\n let { start, end } = span;\n\n let forward = end;\n while (forward < source.length && /\\s/.test(source[forward] ?? \"\")) forward++;\n if (source[forward] === \",\") {\n end = forward + 1;\n while (\n end < source.length &&\n (source[end] === \" \" || source[end] === \"\\t\")\n ) {\n end++;\n }\n return expandBlankLine(source, { start, end });\n }\n\n let backward = start;\n while (backward > 0 && /\\s/.test(source[backward - 1] ?? \"\")) backward--;\n if (source[backward - 1] === \",\") {\n return { start: backward - 1, end };\n }\n\n while (start > 0 && /\\s/.test(source[start - 1] ?? \"\")) start--;\n while (end < source.length && /\\s/.test(source[end] ?? \"\")) end++;\n return { start, end };\n}\n\n/** Widen a removal to its whole line when only indentation would remain. */\nfunction expandBlankLine(\n source: string,\n span: AssetSourceSpan,\n): AssetSourceSpan {\n const lineStart = source.lastIndexOf(\"\\n\", span.start - 1) + 1;\n if (!/^[ \\t]*$/.test(source.slice(lineStart, span.start))) return span;\n if (source.startsWith(\"\\r\\n\", span.end)) {\n return { start: lineStart, end: span.end + 2 };\n }\n if (source[span.end] === \"\\n\") {\n return { start: lineStart, end: span.end + 1 };\n }\n return span;\n}\n\n/** Insert a property before the config object's closing brace, matching the\n * object's single-line/multiline shape. */\nfunction insertConfigProperty(\n source: string,\n configSpan: AssetSourceSpan,\n propertyText: string,\n style: CodeStyle,\n): SourceEdit {\n const closeOffset = configSpan.end - 1;\n let offset = closeOffset;\n while (offset > configSpan.start + 1 && /\\s/.test(source[offset - 1] ?? \"\")) {\n offset--;\n }\n const previous = source[offset - 1] ?? \"\";\n const multiline = source\n .slice(configSpan.start, configSpan.end)\n .includes(\"\\n\");\n\n if (!multiline) {\n if (previous === \"{\") {\n // Empty object: replace any inner whitespace wholesale ({} → { x }).\n return { start: offset, end: closeOffset, value: ` ${propertyText} ` };\n }\n return {\n start: offset,\n end: offset,\n value: previous === \",\" ? ` ${propertyText}` : `, ${propertyText}`,\n };\n }\n\n if (previous === \"{\") {\n const baseIndent = lineIndentAt(source, configSpan.start);\n return {\n start: offset,\n end: offset,\n value: `${style.newline}${baseIndent}${style.indent}${propertyText},`,\n };\n }\n const propertyIndent = lineIndentAt(source, offset);\n return {\n start: offset,\n end: offset,\n value: `${previous === \",\" ? \"\" : \",\"}${style.newline}${propertyIndent}${propertyText},`,\n };\n}\n\nfunction buildImportInsertionEdit(\n source: string,\n importSpans: AssetSourceSpan[],\n importLine: string,\n newline: string,\n): SourceEdit {\n const last = importSpans[importSpans.length - 1];\n if (last) {\n return { start: last.end, end: last.end, value: `${newline}${importLine}` };\n }\n const offset = topLevelInsertionOffset(source);\n const nextChar = source[offset] ?? \"\";\n // A blank line separates the import from a directive prologue above it and\n // from the code below it (unless one already follows).\n const prefix = offset > 0 ? newline : \"\";\n const suffix =\n nextChar === \"\\n\" || nextChar === \"\\r\" || nextChar === \"\"\n ? newline\n : `${newline}${newline}`;\n return {\n start: offset,\n end: offset,\n value: `${prefix}${importLine}${suffix}`,\n };\n}\n\n/** First offset where a top-level statement may be inserted: after a shebang\n * and any `\"use client\"`-style directive prologue. */\nfunction topLevelInsertionOffset(source: string): number {\n let offset = 0;\n if (source.startsWith(\"#!\")) {\n const newline = source.indexOf(\"\\n\");\n offset = newline >= 0 ? newline + 1 : source.length;\n }\n\n while (true) {\n const nextLineEnd = source.indexOf(\"\\n\", offset);\n const end = nextLineEnd >= 0 ? nextLineEnd + 1 : source.length;\n const line = source.slice(offset, end).trim();\n if (!/^[\"']use [^\"']+[\"'];?$/.test(line)) break;\n offset = end;\n }\n\n return offset;\n}\n\n/** Insertion point for a statement that follows `statementEnd`: keeps a\n * trailing same-line `// comment` attached to its statement. */\nfunction statementInsertionOffset(source: string, statementEnd: number): number {\n let offset = statementEnd;\n while (offset < source.length && (source[offset] === \" \" || source[offset] === \"\\t\")) {\n offset++;\n }\n if (source[offset] === \"/\" && source[offset + 1] === \"/\") {\n while (\n offset < source.length &&\n source[offset] !== \"\\n\" &&\n source[offset] !== \"\\r\"\n ) {\n offset++;\n }\n return offset;\n }\n return statementEnd;\n}\n\nfunction serializeDefineAssetCall(\n callName: string,\n bindingName: string,\n config: AssetInitialConfig,\n style: CodeStyle,\n): string {\n // Deterministic key order: usageInstructions, libraries, variants (§4.1).\n const entries: [string, StaticValue][] = [];\n if (config.usageInstructions !== undefined) {\n entries.push([\"usageInstructions\", config.usageInstructions]);\n }\n if (config.libraries !== undefined) {\n entries.push([\"libraries\", config.libraries]);\n }\n if (config.variants !== undefined) {\n entries.push([\"variants\", config.variants as StaticValue]);\n }\n\n if (entries.length === 0) return `${callName}(${bindingName}, {});`;\n\n const body = entries\n .map(\n ([key, value]) =>\n `${style.indent}${key}: ${serializeStaticValue(value, style, 1)},`,\n )\n .join(style.newline);\n return `${callName}(${bindingName}, {${style.newline}${body}${style.newline}});`;\n}\n\n/** Serialize a static value: primitive-only arrays/objects inline, anything\n * nested goes multiline at the given depth. */\nfunction serializeStaticValue(\n value: StaticValue,\n style: CodeStyle,\n depth: number,\n): string {\n if (isUnresolvedValue(value)) {\n throw new Error(\n \"ensureAssetDeclaration initialConfig values must be fully static\",\n );\n }\n if (value === null) return \"null\";\n if (typeof value === \"string\") return quoteString(value, style.quote);\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n if (value.every(isPrimitiveStaticValue)) {\n return `[${value\n .map((item) => serializeStaticValue(item, style, depth))\n .join(\", \")}]`;\n }\n const inner = value\n .map(\n (item) =>\n `${style.indent.repeat(depth + 1)}${serializeStaticValue(item, style, depth + 1)},`,\n )\n .join(style.newline);\n return `[${style.newline}${inner}${style.newline}${style.indent.repeat(depth)}]`;\n }\n\n const entries = Object.entries(value);\n if (entries.length === 0) return \"{}\";\n if (entries.every(([, item]) => isPrimitiveStaticValue(item))) {\n return `{ ${entries\n .map(\n ([key, item]) =>\n `${serializeObjectKey(key, style)}: ${serializeStaticValue(item, style, depth)}`,\n )\n .join(\", \")} }`;\n }\n const inner = entries\n .map(\n ([key, item]) =>\n `${style.indent.repeat(depth + 1)}${serializeObjectKey(key, style)}: ${serializeStaticValue(item, style, depth + 1)},`,\n )\n .join(style.newline);\n return `{${style.newline}${inner}${style.newline}${style.indent.repeat(depth)}}`;\n}\n\nfunction isPrimitiveStaticValue(value: StaticValue): boolean {\n return (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n );\n}\n\nfunction serializeObjectKey(key: string, style: CodeStyle): string {\n return /^[A-Za-z_$][\\w$]*$/.test(key) ? key : quoteString(key, style.quote);\n}\n\nfunction quoteString(value: string, quote: '\"' | \"'\"): string {\n const json = JSON.stringify(value);\n if (quote === '\"') return json;\n const inner = json.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\");\n return `'${inner}'`;\n}\n\ntype CodeStyle = { quote: '\"' | \"'\"; indent: string; newline: \"\\n\" | \"\\r\\n\" };\n\n/** Cheap dominant-style detection; defaults to two-space/double-quote/LF\n * (matching canvas codegen output) when the file gives no signal. */\nfunction detectCodeStyle(source: string): CodeStyle {\n const doubles = (source.match(/\"/g) ?? []).length;\n const singles = (source.match(/'/g) ?? []).length;\n\n let sawTab = false;\n let minSpaces = Number.POSITIVE_INFINITY;\n for (const line of source.split(\"\\n\")) {\n const match = line.match(/^([ \\t]+)\\S/);\n if (!match) continue;\n if (match[1].includes(\"\\t\")) {\n sawTab = true;\n break;\n }\n minSpaces = Math.min(minSpaces, match[1].length);\n }\n\n return {\n quote: singles > doubles ? \"'\" : '\"',\n indent: sawTab\n ? \"\\t\"\n : Number.isFinite(minSpaces)\n ? \" \".repeat(minSpaces)\n : \" \",\n newline: detectNewline(source),\n };\n}\n\nfunction detectNewline(source: string): \"\\n\" | \"\\r\\n\" {\n return source.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n}\n\nfunction lineIndentAt(source: string, offset: number): string {\n const lineStart = Math.max(source.lastIndexOf(\"\\n\", offset - 1) + 1, 0);\n const linePrefix = source.slice(lineStart, offset);\n return linePrefix.match(/^[ \\t]*/)?.[0] ?? \"\";\n}\n\n/** Pick `base`, or the first free `base<N>` suffix, that isn't already taken.\n * Returns undefined only if every candidate up to the cap collides — callers\n * surface that as a typed failure rather than letting it throw. */\nfunction pickAvailableName(\n base: string,\n taken: Set<string>,\n): string | undefined {\n if (!taken.has(base)) return base;\n for (let index = 2; index < 10_000; index++) {\n const candidate = `${base}${index}`;\n if (!taken.has(candidate)) return candidate;\n }\n return undefined;\n}\n\nfunction deriveDefaultExportName(filePath: string): string {\n const normalized = filePath.replace(/\\\\/g, \"/\");\n const segments = normalized.split(\"/\").filter(Boolean);\n const fileName = segments[segments.length - 1] ?? \"\";\n\n // Canvas page files are all named index.canvas.tsx — the folder carries\n // the identity, so the generated name does too.\n if (/^index\\.canvas\\.[tj]sx?$/.test(fileName)) {\n const parent = segments[segments.length - 2] ?? \"\";\n const base = pascalCase(parent);\n return base === \"\" ? \"Canvas\" : `${base}Canvas`;\n }\n\n const name = pascalCase(fileName.replace(/\\.[tj]sx?$/, \"\"));\n if (name === \"\") return \"DefaultExport\";\n return /^[0-9]/.test(name) ? `Component${name}` : name;\n}\n\nfunction pascalCase(value: string): string {\n return value\n .split(/[^A-Za-z0-9]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0EO,SAAS,yBAAyB,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AAS,SAAS,SAAS,CAAC,KAAK;AAIlD,MAAI,2BAA2B,KAAK,QAAQ,GAAG;AAC7C,UAAM,SAAS,SAAS,SAAS,SAAS,CAAC,KAAK;AAChD,UAAM,OAAO,WAAW,MAAM;AAC9B,WAAO,SAAS,KAAK,WAAW,GAAG,IAAI;AAAA,EACzC;AAEA,QAAM,OAAO,WAAW,SAAS,QAAQ,cAAc,EAAE,CAAC;AAC1D,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO,SAAS,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK;AACpD;AAEA,SAAS,WAAW,OAAuB;AACzC,SAAO,MACJ,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;","names":["inner"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../assets/controls.ts","../../assets/prop-overrides.ts","../../assets/live-preview.tsx","../../assets/snapshot.ts","../../assets/index.ts"],"sourcesContent":["/** Browser-safe control definitions shared by authoring, parsing and the editor. */\nexport type AssetOption = string | number | boolean;\n\nexport type AssetControlDefinition =\n | false\n | { type: \"text\" | \"boolean\" | \"color\" | \"object\" | \"date\" }\n | { type: \"number\"; min?: number; max?: number; step?: number }\n | { type: \"range\"; min: number; max: number; step?: number }\n | {\n type:\n | \"select\"\n | \"radio\"\n | \"inline-radio\"\n | \"check\"\n | \"inline-check\"\n | \"multi-select\";\n options?: readonly AssetOption[];\n }\n | { type: \"file\"; accept?: string };\n\ntype Choices<T> = Extract<NonNullable<T>, AssetOption>;\ntype ObjectValue<T> = Exclude<Extract<NonNullable<T>, object>, Function>;\n\n/** A control must produce values the prop actually accepts. */\nexport type AssetPropControl<T> =\n | false\n | (string extends T ? { type: \"text\" | \"color\" } : never)\n | (boolean extends T ? { type: \"boolean\" } : never)\n | (number extends T\n ?\n | { type: \"number\"; min?: number; max?: number; step?: number }\n | { type: \"range\"; min: number; max: number; step?: number }\n | { type: \"date\" }\n : never)\n | ([Choices<T>] extends [never]\n ? never\n : {\n type: \"select\" | \"radio\" | \"inline-radio\";\n options?: readonly Choices<T>[];\n })\n | (NonNullable<T> extends readonly (infer E)[]\n ? {\n type: \"check\" | \"inline-check\" | \"multi-select\";\n options?: readonly Choices<E>[];\n }\n : never)\n | ([ObjectValue<T>] extends [never] ? never : { type: \"object\" })\n | (string[] extends T ? { type: \"file\"; accept?: string } : never);\n\n/** Index signatures do not establish that a particular named prop exists. */\nexport type AssetComponentProps<P> = {\n [K in keyof P as string extends K\n ? never\n : number extends K\n ? never\n : symbol extends K\n ? never\n : K extends \"key\" | \"ref\"\n ? never\n : K]: P[K];\n};\n\nexport type AssetControls<P> = {\n [K in keyof AssetComponentProps<P>]?: AssetPropControl<P[K]>;\n};\n\n/** Legacy radio declarations remain accepted, but are read as dropdowns. */\nexport function normalizeAssetControl(\n control: AssetControlDefinition,\n): AssetControlDefinition {\n return control &&\n (control.type === \"radio\" || control.type === \"inline-radio\")\n ? { ...control, type: \"select\" }\n : control;\n}\n\n/** Validate the literal configuration independently of the component contract. */\nexport function assetControlDefinitionError(value: unknown): string | null {\n if (value === false) return null;\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"Use a control object with a type, or false\";\n }\n const control = value as Record<string, unknown>;\n const type = control.type;\n const fields: Record<string, readonly string[]> = {\n text: [],\n boolean: [],\n color: [],\n object: [],\n date: [],\n number: [\"min\", \"max\", \"step\"],\n range: [\"min\", \"max\", \"step\"],\n select: [\"options\"],\n radio: [\"options\"],\n \"inline-radio\": [\"options\"],\n check: [\"options\"],\n \"inline-check\": [\"options\"],\n \"multi-select\": [\"options\"],\n file: [\"accept\"],\n };\n if (\n typeof type !== \"string\" ||\n !Object.prototype.hasOwnProperty.call(fields, type)\n )\n return \"Unknown control type\";\n for (const key of Object.keys(control)) {\n if (key !== \"type\" && !fields[type]?.includes(key))\n return `Unsupported setting \"${key}\" for ${type}`;\n }\n for (const key of [\"min\", \"max\", \"step\"]) {\n if (\n key in control &&\n (typeof control[key] !== \"number\" || !Number.isFinite(control[key]))\n ) {\n return `${key} must be a finite number`;\n }\n }\n if (\n type === \"range\" &&\n (control.min === undefined || control.max === undefined)\n )\n return \"A range needs min and max\";\n if (\n typeof control.min === \"number\" &&\n typeof control.max === \"number\" &&\n control.min > control.max\n )\n return \"min must not exceed max\";\n if (typeof control.step === \"number\" && control.step <= 0)\n return \"step must be positive\";\n if (\n \"options\" in control &&\n (!Array.isArray(control.options) ||\n control.options.length === 0 ||\n control.options.some(\n (option) =>\n ![\"string\", \"number\", \"boolean\"].includes(typeof option) ||\n (typeof option === \"number\" && !Number.isFinite(option)),\n ))\n )\n return \"options must be a non-empty array of strings, numbers or booleans\";\n if (\"accept\" in control && typeof control.accept !== \"string\")\n return \"accept must be a string\";\n return null;\n}\n","/** Internal, JSON-safe omission marker. Never emitted as a component prop. */\nexport const OMIT_ASSET_PROP = { __tempo_omit_prop__: true } as const;\n\nexport function applyPropOverrides<T>(\n props: Readonly<Record<string, T>>,\n edits?: Readonly<Record<string, T>>,\n): Record<string, T> {\n const result = { ...props };\n for (const [name, value] of Object.entries(edits ?? {})) {\n if (\n value &&\n typeof value === \"object\" &&\n Object.keys(value).length === 1 &&\n (value as Record<string, unknown>).__tempo_omit_prop__ === true\n ) {\n delete result[name];\n } else\n Object.defineProperty(result, name, {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n return result;\n}\n","import { applyPropOverrides } from \"./prop-overrides\";\nimport {\n Component,\n createElement,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport {\n getAssetConfig,\n type AssetDefinitionVariant,\n} from \"./index\";\nimport { getAssetConfigSnapshot } from \"./snapshot\";\nimport { captureAssetPreview } from \"./preview-snapshot\";\n\nexport const ASSET_PREVIEW_MESSAGE = \"tempo:asset-live-preview\";\n\nexport type AssetLivePreviewUpdate = {\n variant: string | null;\n edits: Record<string, unknown>;\n};\n\nclass PreviewBoundary extends Component<\n {\n children: ReactNode;\n update: AssetLivePreviewUpdate;\n },\n { error: string | null; update: AssetLivePreviewUpdate | null }\n> {\n state = {\n error: null as string | null,\n update: null as AssetLivePreviewUpdate | null,\n };\n static getDerivedStateFromProps(\n props: { update: AssetLivePreviewUpdate },\n state: { update: AssetLivePreviewUpdate | null },\n ) {\n return props.update !== state.update\n ? { update: props.update, error: null }\n : null;\n }\n static getDerivedStateFromError(error: Error) {\n return { error: error.message };\n }\n render() {\n return this.state.error ? (\n <p role=\"alert\" style={{ padding: 12, fontSize: 12 }}>\n {this.state.error}\n </p>\n ) : (\n this.props.children\n );\n }\n}\n\n/** One mounted component, driven by its editor. No file writes or captures on\n * variant/prop changes. Imports and source updates remain owned by Vite. */\nexport function AssetLivePreview({\n component,\n sessionId,\n}: {\n component: ComponentType<any>;\n sessionId: string;\n}) {\n const [update, setUpdate] = useState<AssetLivePreviewUpdate>({\n variant: null,\n edits: {},\n });\n const peer = useRef<{ origin: string } | null>(null);\n const viewport = useRef<HTMLDivElement>(null);\n const contentRoot = useRef<HTMLDivElement>(null);\n const [fit, setFit] = useState({ width: 0, height: 0, scale: 1 });\n const boundary = useRef<PreviewBoundary>(null);\n const [captureRequest, setCaptureRequest] = useState<string | null>(null);\n const lastMetadata = useRef(\"\");\n useLayoutEffect(() => {\n const frame = viewport.current!;\n const content = contentRoot.current!;\n const measure = () => {\n // Measure layout dimensions, not the transformed preview. The same\n // 16px inset and no-upscaling rule apply to its cached screenshot.\n const width = content.offsetWidth;\n const height = content.offsetHeight;\n const scale = Math.min(\n 1,\n Math.max(0, frame.clientWidth - 32) / (width || 1),\n Math.max(0, frame.clientHeight - 32) / (height || 1),\n );\n setFit((previous) =>\n previous.width === width &&\n previous.height === height &&\n previous.scale === scale\n ? previous\n : { width, height, scale },\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(frame);\n observer.observe(content);\n return () => observer.disconnect();\n }, []);\n const publish = () => {\n if (!peer.current) return;\n const metadata = getAssetConfigSnapshot(component);\n const serialized = JSON.stringify(metadata);\n if (lastMetadata.current === serialized) return;\n lastMetadata.current = serialized;\n window.parent.postMessage(\n {\n type: ASSET_PREVIEW_MESSAGE,\n sessionId,\n kind: \"metadata\",\n metadata,\n captureVersion: 1,\n },\n peer.current.origin,\n );\n };\n const publishRef = useRef(publish);\n publishRef.current = publish;\n useEffect(() => {\n const receive = (event: MessageEvent) => {\n if (\n event.source !== window.parent ||\n event.data?.type !== ASSET_PREVIEW_MESSAGE ||\n event.data.sessionId !== sessionId\n )\n return;\n if (event.data.kind === \"connect\") {\n peer.current = { origin: event.origin === \"null\" ? \"*\" : event.origin };\n lastMetadata.current = \"\";\n publishRef.current();\n } else if (\n (event.data.kind === \"update\" || event.data.kind === \"capture\") &&\n peer.current\n ) {\n const next = event.data.update;\n if (\n next &&\n (next.variant === null || typeof next.variant === \"string\") &&\n next.edits &&\n typeof next.edits === \"object\" &&\n !Array.isArray(next.edits)\n ) {\n setUpdate(next);\n if (\n event.data.kind === \"capture\" &&\n typeof event.data.requestId === \"string\"\n )\n setCaptureRequest(event.data.requestId);\n }\n }\n };\n window.addEventListener(\"message\", receive);\n // The parent may have received iframe.load before this lazy storyboard mounted.\n window.parent.postMessage(\n { type: ASSET_PREVIEW_MESSAGE, sessionId, kind: \"ready\" },\n \"*\",\n );\n return () => window.removeEventListener(\"message\", receive);\n }, [sessionId]);\n useLayoutEffect(() => {\n if (!captureRequest || !peer.current) return;\n // Capture after React has committed the EXACT props from the request, even\n // when Insert follows the last keystroke before its update message arrived.\n const frame = requestAnimationFrame(() => {\n let snapshot = null;\n try {\n if (contentRoot.current && !boundary.current?.state.error)\n snapshot = captureAssetPreview(contentRoot.current);\n } catch {\n // Snapshotting is an optimization; an unusual DOM must not block Add.\n }\n window.parent.postMessage(\n {\n type: ASSET_PREVIEW_MESSAGE,\n sessionId,\n kind: \"captured\",\n requestId: captureRequest,\n snapshot,\n },\n peer.current!.origin,\n );\n setCaptureRequest(null);\n });\n return () => cancelAnimationFrame(frame);\n }, [captureRequest, update, sessionId]);\n // A hot update can change metadata without changing the component identity.\n useEffect(publish);\n const config = getAssetConfig(component);\n const variant = (\n update.variant &&\n Object.prototype.hasOwnProperty.call(config?.variants ?? {}, update.variant)\n ? config?.variants?.[update.variant]\n : undefined\n ) as AssetDefinitionVariant<Record<string, unknown>> | undefined;\n const render =\n variant && \"render\" in variant ? variant.render : undefined;\n const content =\n update.variant === null\n ? null\n : render\n ? createElement(render)\n : createElement(\n component,\n applyPropOverrides(variant?.props ?? {}, update.edits),\n );\n return (\n <div\n ref={viewport}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 16,\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n flexShrink: 0,\n width: fit.width * fit.scale,\n height: fit.height * fit.scale,\n }}\n >\n <div\n ref={contentRoot}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"max-content\",\n height: \"max-content\",\n transform: `scale(${fit.scale})`,\n transformOrigin: \"top left\",\n }}\n >\n <PreviewBoundary ref={boundary} update={update}>\n {content}\n </PreviewBoundary>\n </div>\n </div>\n </div>\n );\n}\n","import { getAssetConfig, getComponentControls } from \"./index\";\nimport { UNRESOLVED_VALUE, type StaticValue } from \"./types\";\n\n/** Browser-side metadata transport. Unsupported values stay visible; JSON must\n * never silently drop a function, JSX child, cyclic object, or undefined prop. */\nfunction snapshot(value: unknown): StaticValue {\n function copy(value: unknown, seen: Set<object>, depth: number): StaticValue {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n )\n return value;\n if (typeof value === \"number\")\n return Number.isFinite(value) ? value : UNRESOLVED_VALUE;\n if (!value || typeof value !== \"object\" || depth > 16 || seen.has(value))\n return UNRESOLVED_VALUE;\n if (\n !Array.isArray(value) &&\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n )\n return UNRESOLVED_VALUE;\n if (\"$$typeof\" in value) return UNRESOLVED_VALUE;\n const next = new Set(seen).add(value);\n if (Array.isArray(value))\n return value.map((item) => copy(item, next, depth + 1));\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n copy(child, next, depth + 1),\n ]),\n );\n }\n return copy(value, new Set(), 0);\n}\n\nexport function getComponentControlsSnapshot(component: unknown): StaticValue {\n return snapshot(getComponentControls(component));\n}\nexport function getAssetConfigSnapshot(component: unknown): StaticValue {\n return snapshot({\n asset: getAssetConfig(component),\n ...getComponentControls(component),\n });\n}\n","/**\n * tempo-sdk/assets — runtime authoring surface for asset declarations.\n *\n * `defineAsset(Component, { ... })` marks a component (or canvas component)\n * as a design asset: library membership, usage instructions, and named prop\n * variants. `defineControls` independently describes prop editors. Tempo\n * discovers assets statically and reads explicit controls from the running\n * component. Source analysis supplies prop types and portable JSX for insertion.\n *\n * This subpath must stay browser-safe (no node imports): user component\n * files import it from app code, unlike the root entry's Vite plugin.\n * See specs/asset-libraries.md §2.\n */\nimport type { ComponentProps, ComponentType, ReactNode } from \"react\";\nimport type { AstroComponent } from \"../canvas/astro-contract\";\nimport {\n normalizeAssetControl,\n type AssetComponentProps,\n type AssetControls,\n type AssetControlDefinition,\n} from \"./controls\";\nexport { AssetLivePreview } from \"./live-preview\";\nexport type {\n AssetControlDefinition,\n AssetControls,\n AssetPropControl,\n} from \"./controls\";\n\n/** Property key `defineAsset` attaches its config under. Non-enumerable so it\n * never leaks into spreads or serialization of the component value. */\nexport const TEMPO_ASSET_CONFIG_PROPERTY = \"__tempoAssetConfig\";\n\nexport type AssetVariant<P> = {\n /** Must satisfy the component's prop types. Kept required for source\n * compatibility with the original public asset-reader contract. */\n props: P;\n};\n\nexport type AssetRenderVariant = {\n props?: never;\n render: () => ReactNode;\n};\n\nexport type AssetDefinitionVariant<P> =\n | (AssetVariant<P> & { render?: never })\n | AssetRenderVariant;\n\nexport type AssetVariants<P> = Record<string, AssetVariant<P>>;\n\nexport type AssetConfigBase = {\n /** What this asset is and when to reach for it — and when not (e.g. \"form\n * submits, CTAs — not navigation (use Link)\"). Shown on the asset detail\n * page and returned by the asset MCP tools. */\n usageInstructions?: string;\n /** Library names this asset belongs to. Arbitrary non-empty strings; a\n * library exists iff some asset names it. Unset/empty = library-less\n * (still an asset, still shown in the Assets tab). */\n libraries?: string[];\n};\n\n/**\n * `variants` is required exactly when the component has required props. This\n * preserves the public reader guarantees from the first published asset API.\n * `defineAsset` also accepts metadata-only and render-only declarations through\n * its additive authoring input below.\n */\nexport type AssetConfig<C extends ComponentType<any>> = AssetConfigBase &\n ({} extends ComponentProps<C>\n ? { variants?: AssetVariants<ComponentProps<C>> }\n : { variants: AssetVariants<ComponentProps<C>> });\n\nexport type AssetDefinitionConfig<C extends ComponentType<any>> =\n AssetConfigBase & {\n variants?: Record<string, AssetDefinitionVariant<ComponentProps<C>>>;\n };\n\ntype AssetTarget = ComponentType<any> | AstroComponent<any>;\ntype AssetTargetProps<C extends AssetTarget> =\n C extends ComponentType<any>\n ? ComponentProps<C>\n : C extends AstroComponent<infer Props>\n ? Props\n : never;\n\n/**\n * Declare a component or canvas as a design asset.\n *\n * Two supported shapes, both top-level statements. Prefer a declaration in a\n * canvas that curates the component — the\n * declaring canvas becomes the component's linked canvas:\n *\n * import { Button } from \"@/components/Button\";\n *\n * defineAsset(Button, {\n * usageInstructions: \"form submits, CTAs — not navigation (use Link)\",\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * A legacy shape is the same statement in the file that defines the\n * component, placed after its definition — keeps working:\n *\n * export const Button = ({ label }: ButtonProps) => <button>{label}</button>;\n *\n * defineAsset(Button, {\n * libraries: [\"core\"],\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * Returns void deliberately: `export default defineAsset(App, {...})` would\n * turn the export into a call expression and break React Fast Refresh's\n * component-only export analysis, so the wrapper form is a type error.\n */\nexport function defineAsset<C extends AssetTarget>(\n component: C,\n config: AssetConfigBase & {\n variants?: Record<\n string,\n C extends AstroComponent<any>\n ? AssetVariant<AssetTargetProps<C>>\n : AssetDefinitionVariant<AssetTargetProps<C>>\n >;\n },\n): void {\n try {\n // Re-runs on every hot update, re-attaching the current config —\n // configurable so the redefinition is legal.\n Object.defineProperty(component, TEMPO_ASSET_CONFIG_PROPERTY, {\n value: config,\n enumerable: false,\n configurable: true,\n writable: false,\n });\n } catch {\n // Frozen or exotic component values must never crash the user's app.\n }\n}\n\n/** Loosely-typed read shape: callers of getAssetConfig don't know the\n * component's prop types. */\nexport type ReadAssetConfig = AssetConfigBase & {\n variants?: AssetVariants<Record<string, unknown>>;\n};\n\n/** Read a config previously attached by `defineAsset`, if any. */\nexport function getAssetConfig(\n component: unknown,\n): ReadAssetConfig | undefined {\n if (\n (typeof component !== \"function\" && typeof component !== \"object\") ||\n component === null\n ) {\n return undefined;\n }\n const config = (component as Record<string, unknown>)[\n TEMPO_ASSET_CONFIG_PROPERTY\n ];\n return config === undefined\n ? (config as undefined)\n : (config as ReadAssetConfig);\n}\n\nexport {\n getAssetConfigSnapshot,\n getComponentControlsSnapshot,\n} from \"./snapshot\";\n\nexport type ComponentControls<P> = AssetControls<P>;\nexport type ComponentControlsTarget = {\n filePath: string;\n name: string;\n exportName?: string;\n};\nexport const TEMPO_CONTROLS_CONFIG_PROPERTY = \"__tempoControlsConfig\";\n\ntype ControlsRegistration = {\n controls: Record<string, import(\"./controls\").AssetControlDefinition>;\n};\n\n/** Describe real prop editors once, independently of assets and libraries.\n * New components keep this call in their own file. Existing components may use\n * tempo/controls.ts to avoid editing app source. Both work across every canvas.\n * Legacy canvas declarations remain supported.\n * The returned cleanup is used by Tempo's development transform during HMR.\n */\nexport function defineControls<\n C extends AssetTarget,\n const Controls extends AssetControls<AssetTargetProps<NoInfer<C>>>,\n>(\n component: C,\n controls: Controls &\n Record<\n Exclude<\n keyof Controls,\n keyof AssetComponentProps<AssetTargetProps<NoInfer<C>>>\n >,\n never\n >,\n): () => void {\n const registration: ControlsRegistration = {\n controls: Object.fromEntries(\n Object.entries(controls).map(([name, control]) => [\n name,\n normalizeAssetControl(control as AssetControlDefinition),\n ]),\n ),\n };\n let registrations: Set<ControlsRegistration>;\n try {\n const previous = (component as unknown as Record<string, unknown>)[\n TEMPO_CONTROLS_CONFIG_PROPERTY\n ] as Set<ControlsRegistration> | undefined;\n registrations = previous ?? new Set();\n registrations.add(registration);\n Object.defineProperty(component, TEMPO_CONTROLS_CONFIG_PROPERTY, {\n value: registrations,\n enumerable: false,\n configurable: true,\n });\n } catch {\n /* Frozen components still render; use a local wrapper to attach controls. */\n return () => {};\n }\n return () => registrations.delete(registration);\n}\n\nexport function getComponentControls(component: unknown): {\n controls?: Record<string, import(\"./controls\").AssetControlDefinition>;\n error?: string;\n} {\n if (\n !component ||\n (typeof component !== \"function\" && typeof component !== \"object\")\n )\n return {};\n const registrations = (component as Record<string, unknown>)[\n TEMPO_CONTROLS_CONFIG_PROPERTY\n ] as Set<ControlsRegistration> | undefined;\n const astro = (component as import(\"../canvas/astro-contract\").AstroComponent)\n .__tempoAstroControls;\n if (astro && (astro.controls || astro.error)) {\n if (registrations?.size && (!astro.shared || registrations.size > 1))\n return {\n error:\n \"Keep one controls declaration for this Astro component; remove the duplicate shared declaration.\",\n };\n return {\n ...astro,\n ...(astro.controls && {\n controls: Object.fromEntries(\n Object.entries(astro.controls).map(([name, control]) => [\n name,\n normalizeAssetControl(control as AssetControlDefinition),\n ]),\n ),\n }),\n } as ReturnType<typeof getComponentControls>;\n }\n if (!registrations?.size) return {};\n if (registrations.size > 1)\n return {\n error:\n \"Multiple defineControls declarations for this component. Keep one declaration in the component file or tempo/controls.ts; remove the duplicate.\",\n };\n return registrations.values().next().value ?? {};\n}\n"],"mappings":";;;;;;;;;;AAmEO,SAAS,sBACd,SACwB;AACxB,SAAO,YACJ,QAAQ,SAAS,WAAW,QAAQ,SAAS,kBAC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IAAI,CAAC,CAAC,MAAM,OAAO,MAAM;AAAA,YACtD;AAAA,YACA,sBAAsB,OAAiC;AAAA,UACzD,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,eAAe,KAAM,QAAO,CAAC;AAClC,MAAI,cAAc,OAAO;AACvB,WAAO;AAAA,MACL,OACE;AAAA,IACJ;AACF,SAAO,cAAc,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC;AACjD;","names":["value","content","snapshot"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../astro/asset-preview-client.ts"],"sourcesContent":["import { captureAssetPreview } from \"../assets/preview-snapshot\";\n\nconst messageType = \"tempo:asset-live-preview\";\n/** Native document navigation re-runs Astro's renderer for each transient prop set. */\nexport function startAstroAssetPreview(): void {\n const meta = document.querySelector<HTMLMetaElement>(\n 'meta[name=\"tempo-astro-asset-preview\"]',\n );\n if (!meta) return;\n const { sessionId, metadata } = JSON.parse(meta.content);\n let peer: string | undefined;\n const send = (kind: string, detail: object = {}) =>\n window.parent.postMessage(\n { type: messageType, sessionId, kind, ...detail },\n peer ?? \"*\",\n );\n const captureKey = `tempo:astro-capture:${sessionId}`;\n async function capture(requestId: string) {\n await document.fonts.ready;\n await Promise.all(\n [...document.images].map((image) => image.decode().catch(() => {})),\n );\n const deadline = performance.now() + 10000;\n while (\n document.querySelector(\"script[data-island-id]\") ||\n [...document.querySelectorAll(\"astro-island[ssr]\")].some((island) => {\n const client = island.getAttribute(\"client\");\n if (client === \"media\") {\n try {\n return matchMedia(\n JSON.parse(island.getAttribute(\"opts\") ?? \"{}\").value,\n ).matches;\n } catch {\n return true;\n }\n }\n if (client === \"visible\")\n return [...island.children].some((child) => {\n const rect = child.getBoundingClientRect();\n return (\n rect.bottom > 0 &&\n rect.right > 0 &&\n rect.top < innerHeight &&\n rect.left < innerWidth &&\n (rect.width > 0 || rect.height > 0)\n );\n });\n return true;\n })\n ) {\n if (performance.now() > deadline) {\n send(\"captured\", { requestId, snapshot: null });\n return;\n }\n await new Promise(requestAnimationFrame);\n }\n await new Promise(requestAnimationFrame);\n send(\"captured\", {\n requestId,\n snapshot: captureAssetPreview(document.body),\n });\n }\n window.addEventListener(\"message\", (event) => {\n const data = event.data;\n if (\n event.source !== window.parent ||\n data?.type !== messageType ||\n data.sessionId !== sessionId\n )\n return;\n if (data.kind === \"connect\") {\n peer = event.origin === \"null\" ? \"*\" : event.origin;\n send(\"metadata\", { metadata, captureVersion: 1 });\n const pending = sessionStorage.getItem(captureKey);\n if (pending) {\n sessionStorage.removeItem(captureKey);\n void capture(pending);\n }\n return;\n }\n if (\n !peer ||\n (peer !== \"*\" && event.origin !== peer) ||\n ![\"update\", \"capture\"].includes(data.kind)\n )\n return;\n const update = data.update;\n if (\n !update ||\n !(update.variant === null || typeof update.variant === \"string\") ||\n !update.edits ||\n typeof update.edits !== \"object\" ||\n Array.isArray(update.edits)\n )\n return;\n const json = JSON.stringify(update);\n if (json.length > 64000) return;\n const url = new URL(location.href);\n if (url.searchParams.get(\"__tempo_asset_update\") !== json) {\n if (data.kind === \"capture\" && typeof data.requestId === \"string\")\n sessionStorage.setItem(captureKey, data.requestId);\n url.searchParams.set(\"__tempo_asset_update\", json);\n location.replace(url);\n } else if (data.kind === \"capture\" && typeof data.requestId === \"string\")\n void capture(data.requestId);\n });\n send(\"ready\");\n}\n"],"mappings":";;;;;;;AAEA,IAAM,cAAc;AAEb,SAAS,yBAA+B;AAC7C,QAAM,OAAO,SAAS;AAAA,IACpB;AAAA,EACF;AACA,MAAI,CAAC,KAAM;AACX,QAAM,EAAE,WAAW,SAAS,IAAI,KAAK,MAAM,KAAK,OAAO;AACvD,MAAI;AACJ,QAAM,OAAO,CAAC,MAAc,SAAiB,CAAC,MAC5C,OAAO,OAAO;AAAA,IACZ,EAAE,MAAM,aAAa,WAAW,MAAM,GAAG,OAAO;AAAA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AAM,WAAW,OAAO,UACxB,MAAM,SAAS,eACf,KAAK,cAAc;AAEnB;AACF,QAAI,KAAK,SAAS,WAAW;AAC3B,aAAO,MAAM,WAAW,SAAS,MAAM,MAAM;AAC7C,WAAK,YAAY,EAAE,UAAU,gBAAgB,EAAE,CAAC;AAChD,YAAM,UAAU,eAAe,QAAQ,UAAU;AACjD,UAAI,SAAS;AACX,uBAAe,WAAW,UAAU;AACpC,aAAK,QAAQ,OAAO;AAAA,MACtB;AACA;AAAA,IACF;AACA,QACE,CAAC,QACA,SAAS,OAAO,MAAM,WAAW,QAClC,CAAC,CAAC,UAAU,SAAS,EAAE,SAAS,KAAK,IAAI;AAEzC;AACF,UAAM,SAAS,KAAK;AACpB,QACE,CAAC,UACD,EAAE,OAAO,YAAY,QAAQ,OAAO,OAAO,YAAY,aACvD,CAAC,OAAO,SACR,OAAO,OAAO,UAAU,YACxB,MAAM,QAAQ,OAAO,KAAK;AAE1B;AACF,UAAM,OAAO,KAAK,UAAU,MAAM;AAClC,QAAI,KAAK,SAAS,KAAO;AACzB,UAAM,MAAM,IAAI,IAAI,SAAS,IAAI;AACjC,QAAI,IAAI,aAAa,IAAI,sBAAsB,MAAM,MAAM;AACzD,UAAI,KAAK,SAAS,aAAa,OAAO,KAAK,cAAc;AACvD,uBAAe,QAAQ,YAAY,KAAK,SAAS;AACnD,UAAI,aAAa,IAAI,wBAAwB,IAAI;AACjD,eAAS,QAAQ,GAAG;AAAA,IACtB,WAAW,KAAK,SAAS,aAAa,OAAO,KAAK,cAAc;AAC9D,WAAK,QAAQ,KAAK,SAAS;AAAA,EAC/B,CAAC;AACD,OAAK,OAAO;AACd;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../astro/controls.ts"],"sourcesContent":["import type { AssetControls } from \"../assets/controls\";\n\n/** Describe this Astro file's props. Tempo reads this declaration statically;\n * it never executes the component frontmatter to discover controls. */\nexport function defineAstroControls<Props extends object>(\n _controls: AssetControls<Props>,\n): void {}\n"],"mappings":";AAIO,SAAS,oBACd,WACM;AAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../astro/document-client.ts"],"sourcesContent":["import type { ViteHotContext } from \"vite/types/hot.js\";\n\n/** React Refresh updates hydrated islands, but cannot update a server-only\n * occurrence of the same module or a deferred island's still-visible SSR HTML.\n * Use Vite's existing update event and the document's actual source evidence;\n * there is no separate module registry or source-update transport. */\nexport function needsAstroDocumentReload(\n document: Document,\n paths: readonly string[],\n): boolean {\n const changed = paths.map((path) => {\n try {\n return decodeURIComponent(path.split(/[?#]/)[0]!);\n } catch {\n return path;\n }\n });\n const matches = (file: string) => {\n file = file.replaceAll(\"\\\\\", \"/\").replace(/^\\/+/, \"\");\n return changed.some((path) => path === file || path.endsWith(`/${file}`));\n };\n if (\n [\n ...document.querySelectorAll(\n \"[data-tempo-filepath][data-tempo-source-version]\",\n ),\n ].some((element) => {\n if (!matches(element.getAttribute(\"data-tempo-filepath\")!)) return false;\n const island = element.closest(\"astro-island\");\n return !island || island.hasAttribute(\"ssr\");\n })\n )\n return true;\n // A component returning null has no host attributes. Completed server\n // boundaries still identify its defining module. Hydrated islands (even\n // empty ones) remain owned by React Refresh and keep their live state.\n const marker = (node: Node, kind: \"b\" | \"e\") => {\n if (\n node.nodeType !== 8 ||\n !node.textContent?.startsWith(`tempo:astro:${kind}:`)\n )\n return null;\n try {\n return JSON.parse(decodeURIComponent(node.textContent.slice(14)));\n } catch {\n return null;\n }\n };\n const comments = document.createTreeWalker(document, 128);\n for (let begin = comments.nextNode(); begin; begin = comments.nextNode()) {\n const value = marker(begin, \"b\");\n const definition = value?.definition;\n if (\n typeof value?.occurrence !== \"string\" ||\n typeof definition?.filepath !== \"string\" ||\n !definition.sourceVersion ||\n !matches(definition.filepath)\n )\n continue;\n let hydrated = false,\n server = false;\n for (let node = begin.nextSibling; node; node = node.nextSibling) {\n if (marker(node, \"e\")?.occurrence === value.occurrence) {\n if (server || !hydrated) return true;\n break;\n }\n if (node.nodeType === 1) {\n const element = node as Element;\n if (element.localName === \"astro-island\") {\n hydrated = true;\n server ||= element.hasAttribute(\"ssr\");\n } else if (\n ![\"script\", \"style\", \"link\", \"template\"].includes(element.localName)\n )\n server = true;\n } else if (node.nodeType === 3 && node.textContent?.trim()) server = true;\n }\n }\n return false;\n}\n\nexport function startAstroDocumentClient(\n hot: ViteHotContext | undefined,\n): void {\n if (!hot) return;\n const update = (payload: { updates: { type: string; path: string }[] }) => {\n const paths = payload.updates\n .filter((update) => update.type === \"js-update\")\n .map((update) => update.path);\n if (paths.length && needsAstroDocumentReload(document, paths))\n location.reload();\n };\n // Vite closes its websocket on pagehide. A persisted document needs a fresh\n // client connection and server render when browser history restores it.\n const restore = (event: PageTransitionEvent) => {\n if (event.persisted) location.reload();\n };\n hot.on(\"vite:afterUpdate\", update);\n window.addEventListener(\"pageshow\", restore);\n hot.dispose(() => {\n hot.off(\"vite:afterUpdate\", update);\n window.removeEventListener(\"pageshow\", restore);\n });\n}\n"],"mappings":";AAMO,SAAS,yBACdA,WACA,OACS;AACT,QAAM,UAAU,MAAM,IAAI,CAAC,SAAS;AAClC,QAAI;AACF,aAAO,mBAAmB,KAAK,MAAM,MAAM,EAAE,CAAC,CAAE;AAAA,IAClD,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,QAAM,UAAU,CAAC,SAAiB;AAChC,WAAO,KAAK,WAAW,MAAM,GAAG,EAAE,QAAQ,QAAQ,EAAE;AACpD,WAAO,QAAQ,KAAK,CAAC,SAAS,SAAS,QAAQ,KAAK,SAAS,IAAI,IAAI,EAAE,CAAC;AAAA,EAC1E;AACA,MACE;AAAA,IACE,GAAGA,UAAS;AAAA,MACV;AAAA,IACF;AAAA,EACF,EAAE,KAAK,CAAC,YAAY;AAClB,QAAI,CAAC,QAAQ,QAAQ,aAAa,qBAAqB,CAAE,EAAG,QAAO;AACnE,UAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,WAAO,CAAC,UAAU,OAA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SAAS,WAAW,EAC9C,IAAI,CAACA,YAAWA,QAAO,IAAI;AAC9B,QAAI,MAAM,UAAU,yBAAyB,UAAU,KAAK;AAC1D,eAAS,OAAO;AAAA,EACpB;AAGA,QAAM,UAAU,CAAC,UAA+B;AAC9C,QAAI,MAAM,UAAW,UAAS,OAAO;AAAA,EACvC;AACA,MAAI,GAAG,oBAAoB,MAAM;AACjC,SAAO,iBAAiB,YAAY,OAAO;AAC3C,MAAI,QAAQ,MAAM;AAChB,QAAI,IAAI,oBAAoB,MAAM;AAClC,WAAO,oBAAoB,YAAY,OAAO;AAAA,EAChD,CAAC;AACH;","names":["document","update"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../astro/runtime.ts"],"sourcesContent":["/** Server-only Astro 7 adapter. It has no producer, browser hooks or request-global state. */\nimport { markHTMLString } from \"astro/runtime/server/index.js\";\nimport type {\n AstroCallsiteSource,\n AstroModuleSource,\n} from \"@modules/astro-editor\";\n\nconst CALLSITE_PROP = \"__tempo_astro_callsite__\";\nconst definition = Symbol.for(\"tempo.astro.definition\");\nconst template = Symbol.for(\"astro.renderTemplateResult\");\nconst headAndContent = Symbol.for(\"astro.headAndContent\");\n\n/** Attach the defining module's exact transform receipt to server component\n * exports. Re-exports keep the original receipt, and client modules are never\n * transformed by this path. No request-global component registry is needed. */\nexport function instrumentFrameworkComponent<T>(\n component: T,\n metadata: AstroModuleSource & { exportName?: string },\n): T {\n if (\n (typeof component === \"function\" ||\n (component &&\n typeof component === \"object\" &&\n \"$$typeof\" in component)) &&\n Object.isExtensible(component) &&\n !Object.prototype.hasOwnProperty.call(component, definition)\n )\n Object.defineProperty(component, definition, { value: metadata });\n return component;\n}\n\ntype Destination = { write(chunk: unknown): void };\ntype RenderInstance = { render(destination: Destination): unknown };\ntype AnyFunction = (...args: any[]) => any;\n\n/** Each server-emitted occurrence gets a token. Browser clones copy it, not its ownership. */\nexport function astroHostId(): string {\n return globalThis.crypto.randomUUID();\n}\n\n/** Escapes hyphens too: a filename containing `-->` must not terminate a comment. */\nfunction comment(kind: string, data?: unknown): string {\n return `<!--tempo:astro:${kind}${data === undefined ? \"\" : `:${encodeURIComponent(JSON.stringify(data)).replaceAll(\"-\", \"%2D\")}`}-->`;\n}\n\nfunction thenOrValue<T, R>(\n value: T | Promise<T>,\n fn: (value: T) => R,\n): R | Promise<R> {\n return value && typeof (value as Promise<T>).then === \"function\"\n ? Promise.resolve(value).then(fn)\n : fn(value as T);\n}\n\nfunction withReceipt(value: any, metadata: AstroModuleSource): any {\n if (!value || typeof value !== \"object\") return value;\n if (value[headAndContent] && value.content) {\n return { ...value, content: withReceipt(value.content, metadata) };\n }\n if (!value[template]) return value;\n // Astro's streaming engine reads htmlParts directly, bypassing render(). Keep\n // its template/async/head semantics and append the receipt after successful output.\n const parts = [...value.htmlParts];\n parts[parts.length - 1] += comment(\"m\", metadata);\n return Object.assign(Object.create(Object.getPrototypeOf(value)), value, {\n htmlParts: parts,\n });\n}\n\nexport function instrumentCreateComponent(\n original: AnyFunction,\n metadata: AstroModuleSource,\n): AnyFunction {\n return (...args: any[]) => {\n const wrap = (factory: AnyFunction) =>\n function (this: unknown, ...factoryArgs: any[]) {\n return thenOrValue(factory.apply(this, factoryArgs), (value) =>\n withReceipt(value, metadata),\n );\n };\n const first = args[0];\n const component =\n typeof first === \"function\"\n ? original(wrap(first), ...args.slice(1))\n : original(\n { ...first, factory: wrap(first.factory) },\n ...args.slice(1),\n );\n Object.defineProperty(component, definition, { value: metadata });\n return component;\n };\n}\n\nexport function instrumentRenderComponent(original: AnyFunction): AnyFunction {\n return (\n result: unknown,\n displayName: string,\n component: any,\n props: Record<string, unknown> = {},\n ...rest: unknown[]\n ) => {\n const source = props[CALLSITE_PROP] as AstroCallsiteSource | undefined;\n if (!source)\n return original(result, displayName, component, props, ...rest);\n const cleanProps = { ...props };\n delete cleanProps[CALLSITE_PROP];\n // Call the real helper immediately: eager slots and head propagation registration\n // must occur in Astro's original order. Only emission is bracketed by comments.\n return thenOrValue(\n original(result, displayName, component, cleanProps, ...rest),\n (instance: RenderInstance) => ({\n render(destination: Destination) {\n const occurrence = astroHostId();\n destination.write(\n markHTMLString(\n comment(\"b\", {\n occurrence,\n source,\n definition: component?.[definition] ?? null,\n }),\n ),\n );\n return thenOrValue(instance.render(destination), () =>\n destination.write(markHTMLString(comment(\"e\", { occurrence }))),\n );\n },\n }),\n );\n };\n}\n"],"mappings":";AACA,SAAS,sBAAsB;AAM/B,IAAM,gBAAgB;AACtB,IAAM,aAAa,uBAAO,IAAI,wBAAwB;AACtD,IAAM,WAAW,uBAAO,IAAI,4BAA4B;AACxD,IAAM,iBAAiB,uBAAO,IAAI,sBAAsB;AAKjD,SAAS,6BACd,WACA,UACG;AACH,OACG,OAAO,cAAc,cACnB,aACC,OAAO,cAAc,YACrB,cAAc,cAClB,OAAO,aAAa,SAAS,KAC7B,CAAC,OAAO,UAAU,eAAe,KAAK,WAAW,UAAU;AAE3D,WAAO,eAAe,WAAW,YAAY,EAAE,OAAO,SAAS,CAAC;AAClE,SAAO;AACT;AAOO,SAAS,cAAsB;AACpC,SAAO,WAAW,OAAO,WAAW;AACtC;AAGA,SAAS,QAAQ,MAAc,MAAwB;AACrD,SAAO,mBAAmB,IAAI,GAAG,SAAS,SAAY,KAAK,IAAI,mBAAmB,KAAK,UAAU,IAAI,CAAC,EAAE,WAAW,KAAK,KAAK,CAAC,EAAE;AAClI;AAEA,SAAS,YACP,OACA,IACgB;AAChB,SAAO,SAAS,OAAQ,MAAqB,SAAS,aAClD,QAAQ,QAAQ,KAAK,EAAE,KAAK,EAAE,IAC9B,GAAG,KAAU;AACnB;AAEA,SAAS,YAAY,OAAY,UAAkC;AACjE,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,MAAI,MAAM,cAAc,KAAK,MAAM,SAAS;AAC1C,WAAO,EAAE,GAAG,OAAO,SAAS,YAAY,MAAM,SAAS,QAAQ,EAAE;AAAA,EACnE;AACA,MAAI,CAAC,MAAM,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,gBACA,YAAY,YAAY,UAAU,KAAK;AAAA,cACzC,CAAC;AAAA,YACH;AAAA,UACF;AACA,iBAAO;AAAA,YAAY,SAAS,OAAO,WAAW;AAAA,YAAG,MAC/C,YAAY,MAAM,eAAe,QAAQ,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;AAAA,UAChE;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/dist/astro.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../astro.ts","../astro/compiler-adapter.ts","../astro/storyboards.ts","../astro/json.ts","../astro/project-context.ts","../astro/tailwind.ts"],"sourcesContent":["import {\n closeSync,\n fstatSync,\n openSync,\n readFileSync,\n realpathSync,\n} from \"node:fs\";\nimport { isAbsolute, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createRequire } from \"node:module\";\nimport type { AstroIntegration, AstroUserConfig } from \"astro\";\nimport type { Plugin } from \"vite\";\nimport {\n annotateAstroSource,\n parseAstroSource,\n type AstroModuleSource,\n} from \"@modules/astro-editor\";\nimport {\n instrumentAstroModule,\n instrumentFrameworkModule,\n} from \"./astro/compiler-adapter\";\nimport { sourceVersionHash } from \"@modules/annotation/source-version\";\nimport { createAstroStoryboardRegistry } from \"./astro/storyboards\";\nimport {\n astroProjectContext,\n discoverAstroStyles,\n} from \"./astro/project-context\";\nimport { astroTailwindSources } from \"./astro/tailwind\";\nimport { tempoVitePlugin } from \"./index\";\nimport {\n createTempoHostIdentity,\n TEMPO_HOST_IDENTITY_CAPABILITY_HEADER,\n TEMPO_HOST_IDENTITY_ENDPOINT,\n} from \"./host-identity\";\n\nexport interface TempoAstroOptions {\n /** Annotation root; the application root by default. */\n root?: string;\n enabled?: boolean;\n /** Canvas declarations to expose as isolated documents. Defaults to tempo/designs. */\n canvasesRoot?: string;\n /** App-relative CSS entries for isolated components. Defaults to layout/global CSS discovery. */\n styles?: string[];\n}\n\n/** Native Astro server instrumentation. Inert for builds, previews and normal dev. */\nexport function tempoAstro(options: TempoAstroOptions = {}): AstroIntegration {\n return {\n name: \"tempo-astro\",\n hooks: {\n \"astro:config:setup\"({\n config,\n command,\n updateConfig,\n injectRoute,\n createCodegenDir,\n injectScript,\n }) {\n if (\n command !== \"dev\" ||\n !(options.enabled ?? Boolean(process.env.TEMPO))\n )\n return;\n const [nodeMajor, nodeMinor] = process.versions.node\n .split(\".\")\n .map(Number);\n if (nodeMajor! < 22 || (nodeMajor === 22 && nodeMinor! < 12))\n throw new Error(\"Tempo Astro support requires Node 22.12 or newer\");\n const appRequire = createRequire(new URL(\"package.json\", config.root));\n const version = appRequire(\"astro/package.json\").version as string;\n if (!version.startsWith(\"7.\"))\n throw new Error(\n `Tempo native Astro support requires Astro 7; this app uses ${version}`,\n );\n const appRoot = realpathSync.native(fileURLToPath(config.root));\n const { root, tempoRoot, canvasesRoot } = astroProjectContext(\n appRoot,\n options.root,\n options.canvasesRoot,\n );\n const generatedRoot = fileURLToPath(createCodegenDir());\n const canvasRoots = [\n canvasesRoot,\n resolve(tempoRoot, \".tempo/library-canvases\"),\n resolve(tempoRoot, \".tempo/asset-edit-previews\"),\n ];\n const registry = createAstroStoryboardRegistry(\n root,\n canvasRoots,\n generatedRoot,\n options.styles?.map((file) => resolve(appRoot, file)) ??\n discoverAstroStyles(appRoot),\n );\n injectRoute({\n pattern: \"/__tempo/astro/[...storyboard]\",\n entrypoint: registry.entrypoint,\n prerender: false,\n });\n injectScript(\n \"head-inline\",\n `if(!document.querySelector('meta[name=\"tempo-project-root\"]')){const m=document.createElement('meta');m.name='tempo-project-root';m.content=${JSON.stringify(root).replaceAll(\"<\", \"\\\\u003c\")};document.head.append(m)}`,\n );\n const documentClient = fileURLToPath(\n new URL(\n import.meta.url.endsWith(\".ts\")\n ? \"./astro/document-client.ts\"\n : \"./astro/document-client.js\",\n import.meta.url,\n ),\n );\n injectScript(\n \"page\",\n `import { startAstroDocumentClient } from ${JSON.stringify(documentClient)}; startAstroDocumentClient(import.meta.hot);`,\n );\n const identity: Plugin = {\n name: \"tempo:astro-identity\",\n // The generic annotation plugin also serves /__tempo/identity.\n // Register Astro's capability first, before its pre-enforced middleware.\n enforce: \"pre\",\n configureServer(server) {\n server.middlewares.use((req, res, next) => {\n if (\n req.method !== \"GET\" ||\n req.url?.split(\"?\")[0] !== TEMPO_HOST_IDENTITY_ENDPOINT\n )\n return next();\n res.setHeader(TEMPO_HOST_IDENTITY_CAPABILITY_HEADER, \"1\");\n res.setHeader(\"Cache-Control\", \"no-store\");\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(\n JSON.stringify({\n ...createTempoHostIdentity(\"astro\", {\n root: tempoRoot,\n pluginActive: true,\n }),\n capabilities: { astroComponents: 1 },\n }),\n );\n });\n },\n };\n updateConfig({\n vite: {\n plugins: [\n identity,\n astroTailwindSources(root, [\n ...canvasRoots,\n // Request-time registry data contains paths, never utilities.\n // Scanning it makes Tailwind reload pages on every board add.\n resolve(generatedRoot, \"*.astro\"),\n ]),\n ...astroAnnotationPlugins(root, generatedRoot),\n tempoVitePlugin({ root, enabled: true }),\n registry.plugin,\n ],\n },\n });\n },\n },\n };\n}\n\nexport function astroAnnotationPlugins(\n root: string,\n generatedRoot?: string,\n): Plugin[] {\n // Astro has separate SSR and prerender transform chains for the same module id.\n const environments = new WeakMap<\n object,\n Map<string, { metadata: AstroModuleSource; occurrenceFactory?: string }>\n >();\n const receiptMap = (environment: object) => {\n let map = environments.get(environment);\n if (!map) {\n map = new Map();\n environments.set(environment, map);\n }\n return map;\n };\n const runtime = fileURLToPath(new URL(\"./astro/runtime.js\", import.meta.url));\n // Development from source; published SDKs contain the .js sibling.\n const runtimeId = import.meta.url.endsWith(\".ts\")\n ? runtime.replace(/\\.js$/, \".ts\")\n : runtime;\n return [\n {\n name: \"tempo:astro-source\",\n enforce: \"pre\",\n transform: {\n order: \"pre\",\n handler(source, id, options) {\n const astro = id.endsWith(\".astro\");\n const framework = options?.ssr && /\\.[jt]sx?$/.test(id);\n if ((!astro && !framework) || id.includes(\"?\") || !isAbsolute(id))\n return;\n const receipts = receiptMap(this.environment);\n receipts.delete(id);\n let physical: string;\n try {\n physical = realpathSync.native(id);\n } catch {\n // Other integrations can emit virtual JS modules with file-like\n // ids. Only exact, on-disk source can authorize an edit receipt.\n return;\n }\n if (\n generatedRoot &&\n !relative(generatedRoot, physical).startsWith(\"..\")\n )\n return;\n const filepath = relative(root, physical).replaceAll(\"\\\\\", \"/\");\n if (\n !filepath ||\n filepath.startsWith(\"../\") ||\n isAbsolute(filepath) ||\n filepath.split(\"/\").includes(\"node_modules\")\n )\n return;\n // One descriptor ties disk bytes and stats to this transform, not a watcher cache.\n const fd = openSync(physical, \"r\");\n let metadata: AstroModuleSource;\n try {\n const before = fstatSync(fd);\n const raw = readFileSync(fd, \"utf8\");\n const after = fstatSync(fd);\n if (\n source !== raw ||\n !([\"mtimeMs\", \"ctimeMs\", \"size\", \"ino\", \"dev\"] as const).every(\n (key) => before[key] === after[key],\n )\n )\n return;\n const parsed = astro ? parseAstroSource(source) : null;\n if (parsed && parsed.kind !== \"ok\") return;\n metadata = {\n filepath,\n sourceVersion: parsed?.sourceVersion ?? sourceVersionHash(source),\n modifiedTs: Math.trunc(before.mtimeMs),\n };\n } finally {\n closeSync(fd);\n }\n if (framework) {\n receipts.set(id, { metadata });\n return;\n }\n const transformed = annotateAstroSource(source, metadata, id);\n if (transformed.kind !== \"ok\") this.error(transformed.message);\n receipts.set(id, {\n metadata,\n occurrenceFactory: transformed.occurrenceFactory,\n });\n return { code: transformed.code, map: transformed.map };\n },\n },\n },\n {\n name: \"tempo:astro-compiled\",\n enforce: \"post\",\n transform: {\n order: \"post\",\n handler(code, id) {\n if (\n generatedRoot &&\n id.endsWith(\".astro\") &&\n !relative(generatedRoot, id).startsWith(\"..\")\n ) {\n return instrumentAstroModule(\n code,\n id,\n null,\n runtimeId,\n \"$$tempoStoryboardHostId\",\n );\n }\n const receipts = receiptMap(this.environment);\n const receipt = receipts.get(id);\n if (!receipt) return;\n receipts.delete(id);\n if (!receipt.occurrenceFactory)\n return instrumentFrameworkModule(\n code,\n id,\n receipt.metadata,\n runtimeId,\n );\n return instrumentAstroModule(\n code,\n id,\n receipt.metadata,\n runtimeId,\n receipt.occurrenceFactory,\n );\n },\n },\n },\n ];\n}\n\nexport default tempoAstro;\n\n/** Preserve the app's complete config and integrate only at Astro's dev hook. */\nexport function withTempoAstro<T extends AstroUserConfig>(config: T): T;\nexport function withTempoAstro<T extends AstroUserConfig>(\n config: Promise<T>,\n): Promise<T>;\nexport function withTempoAstro<T extends AstroUserConfig>(\n config: T | Promise<T>,\n): T | Promise<T> {\n if (config instanceof Promise)\n return config.then((value) => withTempoAstro(value));\n return {\n ...config,\n integrations: [...(config.integrations ?? []), tempoAstro()],\n };\n}\n","import MagicString from \"magic-string\";\nimport { parseSync } from \"oxc-parser\";\nimport type { AstroModuleSource } from \"@modules/astro-editor\";\n\n/** SSR-only framework exports carry the same definition receipt as native\n * Astro factories, including when React renders null or an empty fragment. */\nexport function instrumentFrameworkModule(\n code: string,\n id: string,\n metadata: AstroModuleSource,\n runtimeId: string,\n) {\n const parsed = parseSync(`${id}.js`, code);\n if (parsed.errors.length) return;\n let name = \"$$tempoFrameworkComponent\";\n while (code.includes(name)) name += \"_\";\n const output = new MagicString(code);\n const bindings = new Map<string, string>();\n let wrapped = false;\n for (const node of parsed.program.body) {\n if (node.type === \"ExportDefaultDeclaration\") {\n const value = node.declaration;\n if (value.type === \"Identifier\") bindings.set(value.name, \"default\");\n else if (\n (value.type === \"FunctionDeclaration\" ||\n value.type === \"ClassDeclaration\") &&\n value.id\n )\n bindings.set(value.id.name, \"default\");\n else {\n output.prependLeft(value.start, `${name}(`);\n output.appendLeft(\n value.end,\n `, ${JSON.stringify({ ...metadata, exportName: \"default\" })})`,\n );\n wrapped = true;\n }\n } else if (node.type === \"ExportNamedDeclaration\" && !node.source) {\n const value = node.declaration;\n if (value?.type === \"VariableDeclaration\") {\n for (const declaration of value.declarations)\n if (declaration.id.type === \"Identifier\")\n bindings.set(declaration.id.name, declaration.id.name);\n } else if (\n (value?.type === \"FunctionDeclaration\" ||\n value?.type === \"ClassDeclaration\") &&\n value.id\n )\n bindings.set(value.id.name, value.id.name);\n for (const specifier of node.specifiers)\n if (specifier.local.type === \"Identifier\")\n bindings.set(\n specifier.local.name,\n specifier.exported.type === \"Identifier\"\n ? specifier.exported.name\n : specifier.exported.value,\n );\n }\n }\n if (!wrapped && !bindings.size) return;\n output.prepend(\n `import { instrumentFrameworkComponent as ${name} } from ${JSON.stringify(runtimeId)};\\n`,\n );\n for (const [binding, exportName] of bindings)\n output.append(\n `\\n${name}(${binding}, ${JSON.stringify({ ...metadata, exportName })});`,\n );\n return {\n code: output.toString(),\n map: output.generateMap({ source: id, includeContent: true, hires: true }),\n };\n}\n\n/** One isolated Astro 7 compiled-helper contract, validated before running any user code. */\nexport function instrumentAstroModule(\n code: string,\n id: string,\n metadata: AstroModuleSource | null,\n runtimeId: string,\n occurrenceFactory: string,\n) {\n const parsed = parseSync(`${id}.js`, code);\n if (parsed.errors.length)\n throw new Error(`Tempo could not parse Astro's compiled module: ${id}`);\n const output = new MagicString(code);\n let prefix = \"$$tempo\";\n while (code.includes(prefix)) prefix += \"_\";\n const wrappers: string[] = [];\n let hasFactory = false;\n for (const node of parsed.program.body) {\n if (node.type !== \"ImportDeclaration\") continue;\n const runtime = node.source.value;\n if (\n runtime !== \"astro/runtime/server/index.js\" &&\n runtime !== \"astro/compiler-runtime\" &&\n runtime !== \"astro/runtime/compiler/index.js\" &&\n !runtime.endsWith(\"/astro/dist/runtime/compiler/index.js\")\n )\n continue;\n for (const specifier of node.specifiers) {\n if (\n specifier.type !== \"ImportSpecifier\" ||\n specifier.imported.type !== \"Identifier\"\n )\n continue;\n const imported = specifier.imported.name;\n if (imported !== \"createComponent\" && imported !== \"renderComponent\")\n continue;\n if (imported === \"createComponent\" && !metadata) {\n hasFactory = true;\n continue;\n }\n const local = specifier.local;\n const original = `${prefix}_${imported}`;\n output.overwrite(\n specifier.start,\n specifier.end,\n `${imported} as ${original}`,\n );\n const helper =\n imported === \"createComponent\"\n ? \"instrumentCreateComponent\"\n : \"instrumentRenderComponent\";\n wrappers.push(\n `const ${local.name} = ${prefix}_${helper}(${original}${imported === \"createComponent\" ? `, ${JSON.stringify(metadata)}` : \"\"});`,\n );\n if (imported === \"createComponent\") hasFactory = true;\n }\n }\n if (!hasFactory)\n throw new Error(\n `Unsupported Astro compiler output for ${id}; Tempo requires Astro 7 createComponent (${parsed.program.body\n .filter((n) => n.type === \"ImportDeclaration\")\n .map((n) => n.source.value)\n .join(\", \")})`,\n );\n output.prepend(\n `import { astroHostId as ${occurrenceFactory}, instrumentCreateComponent as ${prefix}_instrumentCreateComponent, instrumentRenderComponent as ${prefix}_instrumentRenderComponent } from ${JSON.stringify(runtimeId)};\\n${wrappers.join(\"\\n\")}\\n`,\n );\n return {\n code: output.toString(),\n map: output.generateMap({ source: id, includeContent: true, hires: true }),\n };\n}\n","import { createHash } from \"node:crypto\";\nimport {\n existsSync,\n readFileSync,\n readdirSync,\n mkdirSync,\n writeFileSync,\n openSync,\n closeSync,\n fstatSync,\n} from \"node:fs\";\nimport { sourceVersionHash } from \"@modules/annotation/source-version\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\nimport {\n componentFrameworkForStoryboard,\n parseCanvasFile,\n} from \"../canvas/parser\";\nimport { astroStoryboardPath } from \"../canvas/astro-contract\";\nimport { readAstroStoryboardProps } from \"./json\";\nimport { parseSync } from \"oxc-parser\";\n\ninterface AstroStoryboardRoute {\n path: string;\n file: string;\n source: string;\n revision: string;\n}\n\n// A document can receive its HTML before a canvas write, then connect to Vite\n// after that write's full-reload event. Reconcile on connection so the missed\n// event cannot leave the newly opened storyboard showing old props forever.\nconst revisionClient = `<script>\nconst hot = import.meta.hot;\nif (hot) {\n const receipt = () => JSON.parse(document.querySelector('meta[name=\"tempo-astro-storyboard\"]')?.getAttribute('content') ?? 'null');\n const check = () => hot.send('tempo:astro:revision-request', { path: location.pathname, revision: receipt()?.revision });\n const accept = (data) => {\n if (data.path === location.pathname && data.revision !== receipt()?.revision) location.reload();\n };\n hot.on('tempo:astro:revision', accept);\n hot.on('vite:ws:connect', check);\n check();\n hot.dispose(() => {\n hot.off('tempo:astro:revision', accept);\n hot.off('vite:ws:connect', check);\n });\n}\n</script>`;\n\nfunction filesUnder(root: string): string[] {\n if (!existsSync(root)) return [];\n return readdirSync(root, { withFileTypes: true }).flatMap((entry) => {\n if (entry.isSymbolicLink()) return [];\n const file = join(root, entry.name);\n return entry.isDirectory()\n ? filesUnder(file)\n : entry.name.endsWith(\".canvas.tsx\")\n ? [file]\n : [];\n });\n}\n\n/** Only the owning canvas is parsed. Its module and frontmatter are never executed. */\nexport function collectAstroStoryboards(\n root: string,\n canvasesRoot: string | string[],\n generatedRoot: string,\n styles: string[] = [],\n): AstroStoryboardRoute[] {\n const routes: AstroStoryboardRoute[] = [];\n for (const canvasFile of new Set(\n (Array.isArray(canvasesRoot) ? canvasesRoot : [canvasesRoot]).flatMap(\n filesUnder,\n ),\n )) {\n const fd = openSync(canvasFile, \"r\");\n let source: string, modifiedTs: number;\n try {\n const before = fstatSync(fd);\n source = readFileSync(fd, \"utf8\");\n const after = fstatSync(fd);\n if (\n !([\"mtimeMs\", \"ctimeMs\", \"size\", \"ino\", \"dev\"] as const).every(\n (key) => before[key] === after[key],\n )\n )\n throw new Error(`Canvas changed while reading: ${canvasFile}`);\n modifiedTs = Math.trunc(before.mtimeMs);\n } finally {\n closeSync(fd);\n }\n const canvas = parseCanvasFile(canvasFile, source);\n const canvasPath =\n canvas.canvasPath ??\n relative(root, dirname(canvasFile)).replaceAll(\"\\\\\", \"/\");\n for (const storyboard of canvas.storyboards) {\n if (componentFrameworkForStoryboard(storyboard) !== \"astro\") continue;\n const path = astroStoryboardPath(canvasPath, storyboard.storyboardKey);\n const file = join(\n generatedRoot,\n `${createHash(\"sha256\").update(path).digest(\"hex\")}.astro`,\n );\n const revision = createHash(\"sha256\").update(source).digest(\"hex\");\n let generated: string;\n try {\n if (\n canvas.errors.some((error) => error.kind === \"structural\") ||\n storyboard.errors.length\n )\n throw new Error(\n \"Fix the Astro storyboard's canvas declaration before rendering it\",\n );\n const imported = storyboard.component?.import;\n if (\n !imported ||\n imported.kind !== \"default\" ||\n !imported.source.endsWith(\".astro?tempo-component\")\n )\n throw new Error(\n \"AstroStoryboard requires a default .astro?tempo-component import; use an authored .astro fixture for slots and server data\",\n );\n const module = imported.source.slice(0, -\"?tempo-component\".length);\n const specifier = module.startsWith(\".\")\n ? resolve(dirname(canvasFile), module).replaceAll(\"\\\\\", \"/\")\n : module;\n const props = JSON.stringify(\n readAstroStoryboardProps(storyboard.props?.expression),\n ).replaceAll(\"<\", \"\\\\u003c\");\n const callsite = JSON.stringify({\n filepath: relative(root, canvasFile).replaceAll(\"\\\\\", \"/\"),\n sourceVersion: sourceVersionHash(source),\n modifiedTs,\n position: storyboard.jsxElementSpan.start,\n name: storyboard.component?.localName ?? \"Component\",\n });\n const receipt = JSON.stringify({\n canvasPath,\n storyboardId: storyboard.storyboardKey,\n revision,\n });\n let preview: Record<string, unknown> | undefined;\n if (\n canvasFile\n .replaceAll(\"\\\\\", \"/\")\n .includes(\"/.tempo/asset-edit-previews/\")\n ) {\n for (const statement of parseSync(canvasFile, source).program.body) {\n if (\n statement.type !== \"ExportNamedDeclaration\" ||\n statement.declaration?.type !== \"VariableDeclaration\"\n )\n continue;\n for (const declaration of statement.declaration.declarations)\n if (\n declaration.id.type === \"Identifier\" &&\n declaration.id.name === \"__tempoAstroAssetPreview\" &&\n declaration.init\n )\n preview = readAstroStoryboardProps(\n source.slice(declaration.init.start, declaration.init.end),\n );\n }\n }\n generated = `---\\nimport Component from ${JSON.stringify(specifier)};\\nimport ComponentMetadata from ${JSON.stringify(specifier + \"?tempo-component\")};\\n${styles.map((file) => `import ${JSON.stringify(file.replaceAll(\"\\\\\", \"/\"))};`).join(\"\\n\")}\\nconst props = ${props};\\nconst controls = JSON.stringify(ComponentMetadata.__tempoAstroControls ?? {});\\n---\\n<!doctype html><html><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /><meta name=\"tempo-project-root\" content={${JSON.stringify(root)}} /><meta name=\"tempo-astro-storyboard\" content={${JSON.stringify(receipt)}} /></head><body style=\"margin:0\"><Component {...props} __tempo_astro_callsite__={${callsite}} /><pre hidden data-asset-definition={controls}>Component controls</pre></body></html>`;\n if (preview) {\n const client = fileURLToPath(\n new URL(\n import.meta.url.endsWith(\".ts\")\n ? \"./asset-preview-client.ts\"\n : \"./astro/asset-preview-client.js\",\n import.meta.url,\n ),\n );\n generated = generated\n .replace(\n `const props = ${props};`,\n `const preview = ${JSON.stringify(preview).replaceAll(\"<\", \"\\\\u003c\")};\nconst raw = Astro.url.searchParams.get(\"__tempo_asset_update\");\nif (raw && raw.length > 64000) throw new Error(\"Astro preview props are too large\");\nconst update = raw ? JSON.parse(raw) : {variant:null,edits:{}};\nif (!(update.variant === null || typeof update.variant === \"string\") || !update.edits || typeof update.edits !== \"object\" || Array.isArray(update.edits)) throw new Error(\"Invalid Astro preview props\");\nconst variant = update.variant !== null && Object.hasOwn(preview.asset.variants,update.variant) ? preview.asset.variants[update.variant] : undefined;\nif (update.variant !== null && (!variant || variant.error)) throw new Error(variant?.error ?? \"The Astro asset variant no longer exists\");\nconst props = {...variant?.props};\nfor (const [key,value] of Object.entries(update.edits)) { if(value && typeof value === \"object\" && Object.keys(value).length===1 && value.__tempo_omit_prop__===true) delete props[key]; else Object.defineProperty(props,key,{value,enumerable:true,configurable:true}); }\nconst assetMetadata = JSON.stringify({sessionId:preview.sessionId,metadata:{asset:preview.asset,...ComponentMetadata.__tempoAstroControls}});`,\n )\n .replace(\n \"</head>\",\n `<meta name=\"tempo-astro-asset-preview\" content={assetMetadata} /></head>`,\n )\n .replace(\n `<Component {...props} __tempo_astro_callsite__={${callsite}} />`,\n `{update.variant !== null && <Component {...props} __tempo_astro_callsite__={${callsite}} />}`,\n )\n .replace(\n \"</body>\",\n `<script>import {startAstroAssetPreview} from ${JSON.stringify(client)}; startAstroAssetPreview();</script></body>`,\n );\n }\n } catch (error) {\n // A broken board fails in its own route without importing or breaking siblings.\n generated = `---\\nthrow new Error(${JSON.stringify(error instanceof Error ? error.message : String(error))});\\n---`;\n }\n generated = generated.replace(\"</body>\", `${revisionClient}</body>`);\n routes.push({ path, file, source: generated, revision });\n }\n }\n const seen = new Set<string>();\n for (const route of routes) {\n if (seen.has(route.path))\n throw new Error(`Duplicate Astro storyboard address: ${route.path}`);\n seen.add(route.path);\n }\n return routes;\n}\n\nfunction writeChanged(file: string, source: string) {\n const exists = existsSync(file);\n if (exists && readFileSync(file, \"utf8\") === source) return;\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, source);\n return exists ? \"updated\" : \"created\";\n}\n\nfunction storyboardEntrypoint(registryFile: string): string {\n // Astro's normal page CSS collector traverses every statically known import,\n // including lazy glob imports. Use its content asset boundary to collect only\n // the selected document's assets. This is an Astro 7 adapter: the real-server\n // tests pin both the propagation module and native SSR result contracts.\n return String.raw`---\nimport { readFileSync } from \"node:fs\";\nimport { createComponent } from \"astro/runtime/server/index.js\";\nconst base = import.meta.env.BASE_URL.replace(/\\/$/, \"\");\nconst pathname = Astro.url.pathname.slice(base.length).replace(/\\/$/, \"\");\nconst routes = JSON.parse(readFileSync(${JSON.stringify(registryFile)}, \"utf8\"));\nconst route = routes.find((entry) => entry.path === pathname);\nif (!route) return new Response(\"Astro storyboard not found\", { status: 404 });\n// Do not turn these into a glob or a static import map: unopened boards may\n// contain broken imports, and their global CSS must never enter this document.\nconst { default: assets } = await import(/* @vite-ignore */ route.file + \"?astroPropagatedAssets\");\nconst { default: Page } = await assets.getMod();\nconst Preview = createComponent((result, props, slots) => {\n // The generated document owns its <head>. It was loaded during frontmatter,\n // after Astro computed the dispatch page's static head metadata.\n result._metadata.headInTree = true;\n result._metadata.routeHasPropagation = true;\n for (const style of assets.collectedStyles) {\n result.styles.add({ props: { \"data-vite-dev-id\": style.id }, children: style.content });\n const src = style.id.startsWith(\"/@id/\") ? style.id : \"/@fs/\" + style.id.replace(/^\\//, \"\");\n result.scripts.add({ props: { type: \"module\", src: base + src }, children: \"\" });\n }\n for (const href of assets.collectedLinks) {\n result.links.add({ props: { rel: \"stylesheet\", href }, children: \"\" });\n }\n return Page(result, props, slots);\n});\n---\n<Preview />`;\n}\n\n/** A permanent route dispatches into isolated native documents without restarting Astro. */\nexport function createAstroStoryboardRegistry(\n root: string,\n canvasesRoot: string | string[],\n generatedRoot: string,\n styles: string[] = [],\n) {\n const roots = Array.isArray(canvasesRoot) ? canvasesRoot : [canvasesRoot];\n const routes = collectAstroStoryboards(root, roots, generatedRoot, styles);\n let currentRoutes = routes;\n const registryFile = join(generatedRoot, \"routes.json\");\n const entrypoint = join(generatedRoot, \"storyboards.astro\");\n const shape = (items: AstroStoryboardRoute[]) =>\n JSON.stringify(\n items.map(({ path, file }) => ({\n path,\n file: file.replaceAll(\"\\\\\", \"/\"),\n })),\n );\n const unmodifiedNewFiles = new Set<string>();\n const writeDocument = (route: AstroStoryboardRoute) => {\n const change = writeChanged(route.file, route.source);\n const file = route.file.replaceAll(\"\\\\\", \"/\");\n if (change === \"created\") unmodifiedNewFiles.add(file);\n // Do not suppress a delayed create event after a second write: a client\n // may already have rendered the first version, and still needs HMR.\n else if (change === \"updated\") unmodifiedNewFiles.delete(file);\n return change;\n };\n for (const route of routes) writeDocument(route);\n writeChanged(registryFile, shape(routes));\n writeChanged(entrypoint, storyboardEntrypoint(registryFile));\n let synchronizeCanvas: ((file: string) => void) | undefined;\n const plugin: Plugin = {\n name: \"tempo:astro-storyboards\",\n hotUpdate: {\n order: \"pre\",\n async handler({ type, file, modules, read }) {\n if (this.environment.name === \"client\" && file.endsWith(\".canvas.tsx\")) {\n // Native change events can arrive between truncate and write. Vite's\n // read waits for the writer to supply content; a raw watcher callback\n // can publish an empty registry and lose the coalesced final event.\n if (type !== \"delete\") await read();\n synchronizeCanvas?.(file);\n }\n // A new document may be requested before its watcher add event arrives.\n // Astro then sees an already-loaded SSR module and reloads every page,\n // even though nobody has rendered an older version of this new file.\n // Real changes still use Astro's ordinary invalidation and HMR path.\n if (type === \"create\" && unmodifiedNewFiles.has(file))\n return modules.filter((module) => module.file !== file);\n },\n },\n configureServer(server) {\n const changed = (file: string) => {\n if (\n !file.endsWith(\".canvas.tsx\") ||\n !roots.some((root) => {\n const path = relative(root, file);\n return !isAbsolute(path) && !path.startsWith(\"../\");\n })\n )\n return;\n try {\n const next = collectAstroStoryboards(\n root,\n roots,\n generatedRoot,\n styles,\n );\n const updatedFiles = next\n .filter((route) => writeDocument(route) === \"updated\")\n .map((route) => route.file);\n const nextFiles = new Set(\n next.map((route) => route.file.replaceAll(\"\\\\\", \"/\")),\n );\n for (const file of unmodifiedNewFiles)\n if (!nextFiles.has(file)) unmodifiedNewFiles.delete(file);\n currentRoutes = next;\n // This is request-time data, never an Astro config watch file or a\n // static module import. Registry membership cannot restart Vite.\n writeChanged(registryFile, shape(next));\n // These writes are already known; don't depend on a second native\n // event to invalidate Astro's compiled output. A newly generated\n // document can be imported before its directory is being watched,\n // especially while the replacement watcher is starting after restart.\n for (const file of updatedFiles) server.watcher.emit(\"change\", file);\n } catch (error) {\n server.config.logger.error(String(error));\n }\n };\n synchronizeCanvas = changed;\n server.watcher.add(roots);\n const verifyRevision = (\n data: { path?: string; revision?: string },\n client: {\n send(payload: { type: \"custom\"; event: string; data: unknown }): void;\n },\n ) => {\n if (typeof data?.path !== \"string\" || typeof data.revision !== \"string\")\n return;\n const base = server.config.base.replace(/\\/$/, \"\");\n const pathname =\n base && data.path.startsWith(`${base}/`)\n ? data.path.slice(base.length)\n : data.path;\n const route = currentRoutes.find((route) => route.path === pathname);\n if (route)\n client.send({\n type: \"custom\",\n event: \"tempo:astro:revision\",\n data: { path: data.path, revision: route.revision },\n });\n };\n server.ws.on(\"tempo:astro:revision-request\", verifyRevision);\n const dispose = () => {\n server.ws.off(\"tempo:astro:revision-request\", verifyRevision);\n };\n // Vite creates the next server before closing the old one. A shared\n // closeBundle callback would tear down the new server's registrations.\n server.httpServer?.once(\"close\", dispose);\n },\n };\n return { routes, registryFile, entrypoint, plugin };\n}\n","import { parseSync } from \"oxc-parser\";\nimport type { AstroJson } from \"../canvas/astro-contract\";\n\n/** Static data extraction only. Reject syntax which could execute frontmatter or canvas code. */\nexport function readAstroStoryboardProps(\n expression?: string,\n): Record<string, AstroJson> {\n if (!expression) return {};\n const parsed = parseSync(\"props.ts\", `(${expression})`);\n if (parsed.errors.length)\n throw new Error(\"Astro storyboard props must be a JSON object literal\");\n const read = (node: any): AstroJson => {\n if (node?.type === \"ParenthesizedExpression\") return read(node.expression);\n if (\n node?.type === \"Literal\" &&\n (node.value === null ||\n [\"string\", \"boolean\"].includes(typeof node.value) ||\n (typeof node.value === \"number\" && Number.isFinite(node.value)))\n )\n return node.value;\n if (\n node?.type === \"UnaryExpression\" &&\n [\"-\", \"+\"].includes(node.operator) &&\n node.argument?.type === \"Literal\" &&\n typeof node.argument.value === \"number\" &&\n Number.isFinite(node.argument.value)\n )\n return node.operator === \"-\" ? -node.argument.value : node.argument.value;\n if (node?.type === \"ArrayExpression\") return node.elements.map(read);\n if (node?.type === \"ObjectExpression\") {\n const value: Record<string, AstroJson> = Object.create(null);\n for (const property of node.properties) {\n if (\n property.type !== \"Property\" ||\n property.computed ||\n property.method ||\n property.shorthand ||\n property.kind !== \"init\"\n )\n throw new Error(\n \"Astro storyboard props cannot contain expressions, spreads or getters\",\n );\n const key =\n property.key.type === \"Identifier\"\n ? property.key.name\n : property.key.value;\n if (typeof key !== \"string\" && typeof key !== \"number\")\n throw new Error(\"Astro storyboard props require literal keys\");\n value[key] = read(property.value);\n }\n return value;\n }\n throw new Error(\n \"Astro storyboard props must be static JSON; use an authored .astro fixture for server data or slots\",\n );\n };\n const statement = parsed.program.body[0];\n const value = read(\n statement?.type === \"ExpressionStatement\"\n ? statement.expression\n : undefined,\n );\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new Error(\"Astro storyboard props must be a JSON object literal\");\n return value;\n}\n","import { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { parseAstroSource } from \"@modules/astro-editor\";\n\n/** Locate the workspace owning this app without assuming the app is at its root. */\nexport function astroProjectContext(\n appRoot: string,\n rootOverride?: string,\n canvasesOverride?: string,\n) {\n let root = resolve(rootOverride ?? appRoot);\n if (!rootOverride) {\n for (let candidate = root; ; candidate = dirname(candidate)) {\n const file = join(candidate, \"tempo/tempo.config.json\");\n if (existsSync(file)) {\n const config = JSON.parse(readFileSync(file, \"utf8\"));\n if (\n candidate === appRoot ||\n resolve(\n candidate,\n config.apps?.[0]?.appDir ?? config.appDir ?? \".\",\n ) === appRoot\n ) {\n root = candidate;\n break;\n }\n }\n if (dirname(candidate) === candidate) break;\n }\n }\n const tempoRoot = join(root, \"tempo\");\n const configFile = join(tempoRoot, \"tempo.config.json\");\n const config = existsSync(configFile)\n ? JSON.parse(readFileSync(configFile, \"utf8\"))\n : {};\n return {\n root,\n tempoRoot,\n canvasesRoot: canvasesOverride\n ? resolve(root, canvasesOverride)\n : resolve(tempoRoot, config.paths?.canvases ?? \"designs\"),\n };\n}\n\n/** Components inherit the app's stylesheet entry, including its Tailwind theme. */\nexport function discoverAstroStyles(appRoot: string): string[] {\n const styles = new Set<string>();\n const scan = (directory: string, depth: number) => {\n if (!existsSync(directory) || depth > 5) return;\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n if (entry.isSymbolicLink()) continue;\n const file = join(directory, entry.name);\n if (entry.isDirectory()) scan(file, depth + 1);\n else if (entry.name.endsWith(\".astro\")) {\n const source = readFileSync(file, \"utf8\");\n const parsed = parseAstroSource(source);\n if (parsed.kind !== \"ok\") continue;\n for (const declaration of parsed.imports) {\n const specifier = (declaration.source as { value?: unknown })?.value;\n if (\n typeof specifier !== \"string\" ||\n !specifier.endsWith(\".css\") ||\n specifier.endsWith(\".module.css\")\n )\n continue;\n const style = specifier.startsWith(\".\")\n ? resolve(dirname(file), specifier)\n : specifier;\n if (!specifier.startsWith(\".\") || existsSync(style))\n styles.add(style);\n }\n }\n }\n };\n scan(join(appRoot, \"src/layouts\"), 0);\n if (!styles.size) scan(join(appRoot, \"src/pages\"), 0);\n if (!styles.size)\n for (const file of [\n \"src/styles/global.css\",\n \"src/styles/tailwind.css\",\n \"src/styles.css\",\n \"src/index.css\",\n ]) {\n const candidate = resolve(appRoot, file);\n if (existsSync(candidate)) {\n styles.add(candidate);\n break;\n }\n }\n return [...styles];\n}\n","import { isAbsolute, relative } from \"node:path\";\nimport type { Plugin } from \"vite\";\n\n/** The app owns CSS compilation. Include generated/native storyboard sources\n * even when Tailwind's automatic scan omits gitignored or sibling directories. */\nexport function astroTailwindSources(root: string, sources: string[]): Plugin {\n return {\n name: \"tempo:astro-tailwind-sources\",\n enforce: \"pre\",\n transform: {\n order: \"pre\",\n handler(code, id) {\n const file = id.split(\"?\")[0]!;\n if (\n !file.endsWith(\".css\") ||\n file.replaceAll(\"\\\\\", \"/\").includes(\"/node_modules/\")\n )\n return;\n const path = relative(root, file);\n if (path.startsWith(\"..\") || isAbsolute(path)) return;\n if (\n !/@import\\s+(?:url\\(\\s*)?[\"']tailwindcss(?:\\/[\\w.-]+)?[\"']/.test(code)\n )\n return;\n return {\n code: `${code}\\n${sources.map((directory) => `@source ${JSON.stringify(directory.replaceAll(\"\\\\\", \"/\"))};`).join(\"\\n\")}\\n`,\n map: null,\n };\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE,aAAAA;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,gBAAAC;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAAC,aAAY,Y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N,SAAS;AAAA,MACT,WAAW;AAAA,QACT,OAAO;AAAA,QACP,QAAQ,MAAM,IAAI;AAChB,cACE,iBACA,GAAG,SAAS,QAAQ,KACpB,CAACJ,UAAS,eAAe,EAAE,EAAE,WAAW,IAAI,GAC5C;AACA,mBAAO;AAAA,cACL;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AACA,gBAAM,WAAW,WAAW,KAAK,WAAW;AAC5C,gBAAM,UAAU,SAAS,IAAI,EAAE;AAC/B,cAAI,CAAC,QAAS;AACd,mBAAS,OAAO,EAAE;AAClB,cAAI,CAAC,QAAQ;AACX,mBAAO;AAAA,cACL;AAAA,cACA;AAAA,cACA,QAAQ;AAAA,cACR;AAAA,YACF;AACF,iBAAO;AAAA,YACL;AAAA,YACA;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,YACA,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;AAOR,SAAS,eACd,QACgB;AAChB,MAAI,kBAAkB;AACpB,WAAO,OAAO,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC;AACrD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,CAAC,GAAI,OAAO,gBAAgB,CAAC,GAAI,WAAW,CAAC;AAAA,EAC7D;AACF;","names":["closeSync","fstatSync","openSync","readFileSync","isAbsolute","relative","resolve","fileURLToPath","parseSync","value","parseSync","file","root","route","existsSync","readFileSync","readdirSync","dirname","join","resolve","resolve","dirname","join","existsSync","config","readFileSync","readdirSync","isAbsolute","relative","fileURLToPath","resolve","isAbsolute","relative","openSync","fstatSync","readFileSync","closeSync"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../canvas/astro.tsx"],"sourcesContent":["import {\n isAstroComponent,\n type AstroComponent,\n type AstroJson,\n} from \"./astro-contract\";\nimport {\n StoryboardSlot,\n type StoryboardLayout,\n type StoryboardVrtConfig,\n} from \"./storyboard\";\n\nexport { astroStoryboardPath, isAstroComponent } from \"./astro-contract\";\nexport type { AstroComponent, AstroJson } from \"./astro-contract\";\n\n/** Native Astro components render as application documents, never in this React shell. */\nexport function AstroStoryboard<\n Props extends object = Record<string, AstroJson>,\n>({\n id,\n name,\n component,\n layout,\n vrt,\n}: {\n id: string;\n name?: string;\n component: AstroComponent<Props>;\n props?: Props;\n layout: StoryboardLayout;\n vrt?: boolean | StoryboardVrtConfig;\n} & Record<`data-tempo-${string}`, unknown>) {\n if (!isAstroComponent(component))\n throw new Error(\n \"AstroStoryboard requires a .astro?tempo-component descriptor import\",\n );\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"component\"\n uiFramework=\"astro\"\n vrt={!!vrt}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAoCI;AArBG,SAAS,gBAEd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAO6C;AAC3C,MAAI,CAAC,iBAAiB,SAAS;AAC7B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,yBAAsB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,aAAY;AAAA,MACZ,KAAK,CAAC,CAAC;AAAA;AAAA,EACT;AAEJ;","names":[]}