tempo-sdk 0.0.66 → 0.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/astro.js.map CHANGED
@@ -1 +1 @@
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 addWatchFile,\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 for (const route of registry.routes)\n injectRoute({\n pattern: route.path,\n entrypoint: route.file,\n prerender: false,\n });\n addWatchFile(registry.registryFile);\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, [...canvasRoots, generatedRoot]),\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 { parseCanvasFile } 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 (storyboard.runtimeFramework !== \"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 if (existsSync(file) && readFileSync(file, \"utf8\") === source) return;\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, source);\n}\n\n/** Static routes isolate CSS, scripts and failing imports. Only registry shape changes restart 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 shape = (items: AstroStoryboardRoute[]) =>\n JSON.stringify(items.map(({ path, file }) => ({ path, file })));\n for (const route of routes) writeChanged(route.file, route.source);\n writeChanged(registryFile, shape(routes));\n let dispose: (() => void) | undefined;\n const plugin: Plugin = {\n name: \"tempo:astro-storyboards\",\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 for (const route of next) writeChanged(route.file, route.source);\n currentRoutes = next;\n // Astro owns restarting from a changed integration watch file.\n writeChanged(registryFile, shape(next));\n } catch (error) {\n server.config.logger.error(String(error));\n }\n };\n server.watcher.add(roots);\n server.watcher\n .on(\"add\", changed)\n .on(\"change\", changed)\n .on(\"unlink\", changed);\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 dispose = () => {\n server.ws.off(\"tempo:astro:revision-request\", verifyRevision);\n server.watcher\n .off(\"add\", changed)\n .off(\"change\", changed)\n .off(\"unlink\", changed);\n };\n },\n closeBundle() {\n dispose?.();\n dispose = undefined;\n },\n };\n return { routes, registryFile, 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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;AAC5D,cAAI,YAAY,SAAS,KAAM,MAAK,MAAM,YAAY,OAAO;AAC7D,mBAAS,IAAI,IAAI;AAAA,YACf;AAAA,YACA,mBAAmB,YAAY;AAAA,UACjC,CAAC;AACD,iBAAO,EAAE,MAAM,YAAY,MAAM,KAAK,YAAY,IAAI;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,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
+ {"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 { parseCanvasFile } 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 (storyboard.runtimeFramework !== \"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 const plugin: Plugin = {\n name: \"tempo:astro-storyboards\",\n hotUpdate: {\n order: \"pre\",\n handler({ type, file, modules }) {\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 server.watcher.add(roots);\n server.watcher\n .on(\"add\", changed)\n .on(\"change\", changed)\n .on(\"unlink\", changed);\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 server.watcher\n .off(\"add\", changed)\n .off(\"change\", changed)\n .off(\"unlink\", changed);\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,YAAAC,WAAU,WAAAC,gBAAe;AAC9C,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,qBAAqB;;;ACR9B,SAAS,iBAAiB;AAKnB,SAAS,0BACd,MACA,IACA,UACA,WACA;AACA,QAAM,SAAS,UAAU,GAAG,EAAE,OAAO,IAAI;AACzC,MAAI,OAAO,OAAO,OAAQ;AAC1B,MAAI,OAAO;AACX,SAAO,KAAK,SAAS,IAAI,EAAG,SAAQ;AACpC,QAAM,SAAS,IAAI,YAAY,IAAI;AACnC,QAAM,WAAW,oBAAI,IAAoB;AACzC,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BAAS,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"]}
@@ -10,7 +10,7 @@ import { resolve } from "path";
10
10
  // package.json
11
11
  var package_default = {
12
12
  name: "tempo-sdk",
13
- version: "0.0.66",
13
+ version: "0.0.69",
14
14
  publishConfig: {
15
15
  tag: "sdk-v2-latest"
16
16
  },
@@ -119,7 +119,7 @@ var package_default = {
119
119
  demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
120
120
  "demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
121
121
  test: "vitest run",
122
- "test:browser": "vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
122
+ "test:browser": "vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts astro-integration.test.ts astro-storyboard-routing.test.ts astro-react-integration.test.ts astro-descriptor-browser.test.ts astro-packed.test.ts",
123
123
  "test:watch": "vitest",
124
124
  "test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
125
125
  "test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
@@ -410,4 +410,4 @@ export {
410
410
  nextjs_default,
411
411
  _internal
412
412
  };
413
- //# sourceMappingURL=chunk-6W6UKDSY.js.map
413
+ //# sourceMappingURL=chunk-6BSLP7P3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../nextjs.ts","../host-identity.ts","../package.json","../release-channel.ts"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity<\"nextjs\"> {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { TEMPO_SDK_CHANNEL } from \"./release-channel\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER = \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\" | \"astro\";\n\nexport interface TempoHostIdentity<\n Framework extends TempoHostFramework = TempoHostFramework,\n> {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n sdkChannel: string;\n pluginActive: boolean;\n framework: Framework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity<Framework extends TempoHostFramework>(\n framework: Framework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity<Framework> {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n sdkChannel: TEMPO_SDK_CHANNEL,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.66\",\n \"publishConfig\": {\n \"tag\": \"sdk-v2-latest\"\n },\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, Expo, Svelte and Astro canvas integration, source annotations and storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \"./astro/controls\": {\n \"types\": \"./dist/astro/controls.d.ts\",\n \"import\": \"./dist/astro/controls.js\",\n \"default\": \"./dist/astro/controls.js\"\n },\n \"./astro\": {\n \"types\": \"./dist/astro.d.ts\",\n \"import\": \"./dist/astro.js\"\n },\n \"./astro/client\": {\n \"types\": \"./astro/client.d.ts\"\n },\n \"./canvas/astro\": {\n \"types\": \"./dist/canvas/astro.d.ts\",\n \"import\": \"./dist/canvas/astro.js\"\n },\n \"./canvas/astro-contract\": {\n \"types\": \"./dist/canvas/astro-contract.d.ts\",\n \"import\": \"./dist/canvas/astro-contract.js\"\n },\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n },\n \"./astro/asset-preview-client\": {\n \"types\": \"./dist/astro/asset-preview-client.d.ts\",\n \"import\": \"./dist/astro/asset-preview-client.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"astro/client.d.ts\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"optionalDependencies\": {\n \"@astrojs/compiler-rs\": \"0.5.1\"\n },\n \"peerDependencies\": {\n \"astro\": \"^7.0.0\",\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"astro\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@astrojs/react\": \"7.0.1\",\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/astro-editor\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"astro\": \"7.3.8\",\n \"magic-string\": \"^0.30.21\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"react-dom18\": \"npm:react-dom@18.3.1\",\n \"react18\": \"npm:react@18.3.1\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import sdkPackage from \"./package.json\" with { type: \"json\" };\n\n/** Shared by the app, generated projects and the SDK host identity. */\nexport const TEMPO_SDK_CHANNEL = sdkPackage.publishConfig.tag;\n\nexport function sdkChannelGeneration(channel: unknown): number | null {\n if (typeof channel !== \"string\") return null;\n const match = /^sdk-v([1-9]\\d*)-latest$/.exec(channel);\n return match ? Number(match[1]) : null;\n}\n\nif (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {\n throw new Error(\"tempo-sdk publishConfig.tag must be sdk-v<N>-latest\");\n}\n\n/** Preserve local development links; registry installs follow the app channel. */\nexport function managedTempoSdkSpec(spec: string): string {\n const generation = sdkChannelGeneration(spec);\n if (\n generation !== null &&\n generation > sdkChannelGeneration(TEMPO_SDK_CHANNEL)!\n ) {\n throw new Error(\n `This project requires tempo-sdk@${spec}. Update Tempo before opening it; this app supports ${TEMPO_SDK_CHANNEL}.`,\n );\n }\n if (/^(workspace:|file:|link:|portal:|git|https?:|ssh:|github:)/.test(spec))\n return spec;\n return TEMPO_SDK_CHANNEL;\n}\n"],"mappings":";AAiBA,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,WAAAA,gBAAe;;;ACnBjC,SAAS,oBAAoB;AAC7B,SAAS,eAAe;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,oBAAoB;AAAA,MAClB,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,kBAAkB;AAAA,MAChB,OAAS;AAAA,IACX;AAAA,IACA,kBAAkB;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js.ts","../host-identity.ts","../package.json","../release-channel.ts"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity<\"nextjs\"> {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { TEMPO_SDK_CHANNEL } from \"./release-channel\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER = \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\" | \"astro\";\n\nexport interface TempoHostIdentity<\n Framework extends TempoHostFramework = TempoHostFramework,\n> {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n sdkChannel: string;\n pluginActive: boolean;\n framework: Framework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity<Framework extends TempoHostFramework>(\n framework: Framework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity<Framework> {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n sdkChannel: TEMPO_SDK_CHANNEL,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.69\",\n \"publishConfig\": {\n \"tag\": \"sdk-v2-latest\"\n },\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, Expo, Svelte and Astro canvas integration, source annotations and storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \"./astro/controls\": {\n \"types\": \"./dist/astro/controls.d.ts\",\n \"import\": \"./dist/astro/controls.js\",\n \"default\": \"./dist/astro/controls.js\"\n },\n \"./astro\": {\n \"types\": \"./dist/astro.d.ts\",\n \"import\": \"./dist/astro.js\"\n },\n \"./astro/client\": {\n \"types\": \"./astro/client.d.ts\"\n },\n \"./canvas/astro\": {\n \"types\": \"./dist/canvas/astro.d.ts\",\n \"import\": \"./dist/canvas/astro.js\"\n },\n \"./canvas/astro-contract\": {\n \"types\": \"./dist/canvas/astro-contract.d.ts\",\n \"import\": \"./dist/canvas/astro-contract.js\"\n },\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n },\n \"./astro/asset-preview-client\": {\n \"types\": \"./dist/astro/asset-preview-client.d.ts\",\n \"import\": \"./dist/astro/asset-preview-client.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"astro/client.d.ts\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts astro-integration.test.ts astro-storyboard-routing.test.ts astro-react-integration.test.ts astro-descriptor-browser.test.ts astro-packed.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"optionalDependencies\": {\n \"@astrojs/compiler-rs\": \"0.5.1\"\n },\n \"peerDependencies\": {\n \"astro\": \"^7.0.0\",\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"astro\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@astrojs/react\": \"7.0.1\",\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/astro-editor\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"astro\": \"7.3.8\",\n \"magic-string\": \"^0.30.21\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"react-dom18\": \"npm:react-dom@18.3.1\",\n \"react18\": \"npm:react@18.3.1\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import sdkPackage from \"./package.json\" with { type: \"json\" };\n\n/** Shared by the app, generated projects and the SDK host identity. */\nexport const TEMPO_SDK_CHANNEL = sdkPackage.publishConfig.tag;\n\nexport function sdkChannelGeneration(channel: unknown): number | null {\n if (typeof channel !== \"string\") return null;\n const match = /^sdk-v([1-9]\\d*)-latest$/.exec(channel);\n return match ? Number(match[1]) : null;\n}\n\nif (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {\n throw new Error(\"tempo-sdk publishConfig.tag must be sdk-v<N>-latest\");\n}\n\n/** Preserve local development links; registry installs follow the app channel. */\nexport function managedTempoSdkSpec(spec: string): string {\n const generation = sdkChannelGeneration(spec);\n if (\n generation !== null &&\n generation > sdkChannelGeneration(TEMPO_SDK_CHANNEL)!\n ) {\n throw new Error(\n `This project requires tempo-sdk@${spec}. Update Tempo before opening it; this app supports ${TEMPO_SDK_CHANNEL}.`,\n );\n }\n if (/^(workspace:|file:|link:|portal:|git|https?:|ssh:|github:)/.test(spec))\n return spec;\n return TEMPO_SDK_CHANNEL;\n}\n"],"mappings":";AAiBA,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,WAAAA,gBAAe;;;ACnBjC,SAAS,oBAAoB;AAC7B,SAAS,eAAe;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,oBAAoB;AAAA,MAClB,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,kBAAkB;AAAA,MAChB,OAAS;AAAA,IACX;AAAA,IACA,kBAAkB;AAAA,MAChB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,2BAA2B;AAAA,MACzB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gCAAgC;AAAA,MAC9B,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,I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AAM,gBAAgB,kBAClB,YAAY,cAAc,QAC1B,YAAY;AAChB,UAAM,cAAc,oBAAoB,eAAe,OAAO;AAE9D,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA,YAAY,WAAW;AAAA,IACzB;AAEA,UAAM,OAAuB;AAAA,MAC3B,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAMA,UAAM,kBAAkB,QAAQ,IAAI;AACpC,QAAI,iBAAiB;AACnB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,CAAC,eAAe;AAClB,UAAI,iBAAiB;AACnB,aAAK,eAAe;AAAA,UAClB,GAAG,YAAY;AAAA,UACf,OAAO;AAAA,QACT;AAAA,MACF,OAAO;AACL,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAEA,IAAO,iBAAQ;AAYR,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["resolve","resolve"]}
@@ -377,7 +377,7 @@ import { resolve as resolve4 } from "path";
377
377
  // package.json
378
378
  var package_default = {
379
379
  name: "tempo-sdk",
380
- version: "0.0.66",
380
+ version: "0.0.69",
381
381
  publishConfig: {
382
382
  tag: "sdk-v2-latest"
383
383
  },
@@ -486,7 +486,7 @@ var package_default = {
486
486
  demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
487
487
  "demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
488
488
  test: "vitest run",
489
- "test:browser": "vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
489
+ "test:browser": "vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts astro-integration.test.ts astro-storyboard-routing.test.ts astro-react-integration.test.ts astro-descriptor-browser.test.ts astro-packed.test.ts",
490
490
  "test:watch": "vitest",
491
491
  "test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
492
492
  "test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
@@ -2492,4 +2492,4 @@ export {
2492
2492
  tempoVitePlugin,
2493
2493
  tempoAnnotate
2494
2494
  };
2495
- //# sourceMappingURL=chunk-DELFOKU3.js.map
2495
+ //# sourceMappingURL=chunk-WTQQOLXM.js.map