tempo-sdk 0.0.52 → 0.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/assets/index.js +4 -2
  2. package/dist/assets/index.js.map +1 -1
  3. package/dist/canvas/editor.d.ts +11 -16
  4. package/dist/canvas/editor.js +79 -49
  5. package/dist/canvas/editor.js.map +1 -1
  6. package/dist/canvas/index.d.ts +13 -7
  7. package/dist/canvas/index.js +227 -64
  8. package/dist/canvas/index.js.map +1 -1
  9. package/dist/canvas/interact-projection.js +4 -3
  10. package/dist/canvas/parser.d.ts +10 -5
  11. package/dist/canvas/parser.js +3 -1
  12. package/dist/canvas/svelte.d.ts +8 -5
  13. package/dist/canvas/svelte.js +20 -5
  14. package/dist/canvas/svelte.js.map +1 -1
  15. package/dist/chunk-2IQD2KPS.js +219 -0
  16. package/dist/chunk-2IQD2KPS.js.map +1 -0
  17. package/dist/chunk-5BHIHP25.js +410 -0
  18. package/dist/chunk-5BHIHP25.js.map +1 -0
  19. package/dist/{chunk-PULSTDX2.js → chunk-7DT5DDSH.js} +284 -46
  20. package/dist/chunk-7DT5DDSH.js.map +1 -0
  21. package/dist/{chunk-7Y7XNHUM.js → chunk-FQSZRVSL.js} +18 -3
  22. package/dist/chunk-FQSZRVSL.js.map +1 -0
  23. package/dist/{chunk-ZZYNOX24.js → chunk-MXKZZOLM.js} +1717 -2460
  24. package/dist/chunk-MXKZZOLM.js.map +1 -0
  25. package/dist/{chunk-DX6XAXCK.js → chunk-N2TYN3RB.js} +189 -420
  26. package/dist/chunk-N2TYN3RB.js.map +1 -0
  27. package/dist/chunk-OTVBSF7U.js +1585 -0
  28. package/dist/chunk-OTVBSF7U.js.map +1 -0
  29. package/dist/chunk-TL4MGN7E.js +2570 -0
  30. package/dist/chunk-TL4MGN7E.js.map +1 -0
  31. package/dist/{chunk-QP2NTODB.js → chunk-VMTQDG4U.js} +117 -27
  32. package/dist/chunk-VMTQDG4U.js.map +1 -0
  33. package/dist/expo/plugin.cjs +1256 -16
  34. package/dist/expo/plugin.cjs.map +1 -1
  35. package/dist/expo/plugin.d.cts +0 -1
  36. package/dist/expo/plugin.d.ts +0 -1
  37. package/dist/expo/plugin.js +1 -1
  38. package/dist/expo-babel-plugin.cjs +1258 -16
  39. package/dist/expo-babel-plugin.cjs.map +1 -1
  40. package/dist/expo-babel-plugin.d.cts +8 -5
  41. package/dist/expo-babel-plugin.d.ts +8 -5
  42. package/dist/expo-babel-plugin.js +1 -1
  43. package/dist/index.d.ts +5 -1
  44. package/dist/index.js +647 -166
  45. package/dist/index.js.map +1 -1
  46. package/dist/nextjs/plugin.cjs +151 -0
  47. package/dist/nextjs/plugin.cjs.map +1 -1
  48. package/dist/nextjs/plugin.d.cts +1 -1
  49. package/dist/nextjs/plugin.d.ts +1 -1
  50. package/dist/nextjs/plugin.js +1 -1
  51. package/dist/nextjs-loader.cjs +1432 -35
  52. package/dist/nextjs-loader.cjs.map +1 -1
  53. package/dist/nextjs.cjs +17 -2
  54. package/dist/nextjs.cjs.map +1 -1
  55. package/dist/nextjs.d.cts +14 -3
  56. package/dist/nextjs.d.ts +14 -3
  57. package/dist/nextjs.js +1 -1
  58. package/dist/{page-xi1aI5a7.d.ts → page-DwLnOM5d.d.ts} +12 -6
  59. package/dist/{storyboard-DbtzTPvI.d.ts → storyboard-DjOF61B_.d.ts} +35 -15
  60. package/dist/svelte.d.ts +3 -2
  61. package/dist/svelte.js +103 -29
  62. package/dist/svelte.js.map +1 -1
  63. package/dist/v1-client-compat-qxaXEDm_.d.ts +23 -0
  64. package/package.json +5 -2
  65. package/dist/chunk-57KAYXHF.js +0 -19
  66. package/dist/chunk-57KAYXHF.js.map +0 -1
  67. package/dist/chunk-7Y7XNHUM.js.map +0 -1
  68. package/dist/chunk-CB5NJJJT.js +0 -345
  69. package/dist/chunk-CB5NJJJT.js.map +0 -1
  70. package/dist/chunk-DX6XAXCK.js.map +0 -1
  71. package/dist/chunk-F3KJDCMU.js +0 -19
  72. package/dist/chunk-F3KJDCMU.js.map +0 -1
  73. package/dist/chunk-PULSTDX2.js.map +0 -1
  74. package/dist/chunk-QP2NTODB.js.map +0 -1
  75. package/dist/chunk-ZZYNOX24.js.map +0 -1
package/dist/nextjs.cjs CHANGED
@@ -39,7 +39,10 @@ var import_node_path = require("path");
39
39
  // package.json
40
40
  var package_default = {
41
41
  name: "tempo-sdk",
42
- version: "0.0.52",
42
+ version: "0.0.60",
43
+ publishConfig: {
44
+ tag: "sdk-v2-latest"
45
+ },
43
46
  type: "module",
44
47
  description: "Tempo SDK \u2014 Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
45
48
  repository: {
@@ -120,7 +123,7 @@ var package_default = {
120
123
  demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
121
124
  "demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
122
125
  test: "vitest run",
123
- "test:browser": "vitest run 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",
126
+ "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",
124
127
  "test:watch": "vitest",
125
128
  "test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
126
129
  "test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
@@ -173,6 +176,17 @@ var package_default = {
173
176
  }
174
177
  };
175
178
 
179
+ // release-channel.ts
180
+ var TEMPO_SDK_CHANNEL = package_default.publishConfig.tag;
181
+ function sdkChannelGeneration(channel) {
182
+ if (typeof channel !== "string") return null;
183
+ const match = /^sdk-v([1-9]\d*)-latest$/.exec(channel);
184
+ return match ? Number(match[1]) : null;
185
+ }
186
+ if (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {
187
+ throw new Error("tempo-sdk publishConfig.tag must be sdk-v<N>-latest");
188
+ }
189
+
176
190
  // host-identity.ts
177
191
  var TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;
178
192
  var TEMPO_WORKSPACE_NONCE_ENV = "TEMPO_WORKSPACE_NONCE";
@@ -201,6 +215,7 @@ function createTempoHostIdentity(framework, options = {}) {
201
215
  contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,
202
216
  workspaceNonce: readTempoWorkspaceNonce(options.root),
203
217
  sdkVersion: package_default.version,
218
+ sdkChannel: TEMPO_SDK_CHANNEL,
204
219
  pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),
205
220
  framework
206
221
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../nextjs.ts","../host-identity.ts","../package.json"],"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 { ElementInfo, PropValue } from \"@modules/annotation\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type { ElementInfo, PropValue } from \"@modules/annotation\";\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 sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER =\n \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\";\n\nexport interface TempoHostIdentity {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n pluginActive: boolean;\n framework: TempoHostFramework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity(\n framework: TempoHostFramework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.52\",\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"peerDependencies\": {\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,IAAAA,kBAAyC;AACzC,yBAA8B;AAC9B,IAAAC,oBAAiC;;;ACnBjC,qBAA6B;AAC7B,uBAAwB;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gCAAgC;AAAA,MAC9B,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;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AACzC;AAGO,SAAS,yBAA+B;AAC7C,2BAAyB;AAC3B;AAkBO,SAAS,kBACd,gBAAoC,CAAC,GACa;AAClD,SAAO,CAAC,mBAAoD;AAC1D,UAAM,cAA8B,kBAAkB,CAAC;AAEvD,QAAI,CAAC,QAAQ,IAAI,MAAO,QAAO;AAI/B,UAAM,aAAa,UAAU,kBAAkB;AAC/C,UAAM,UAAU,UAAU,kBAAkB;AAC5C,UAAM,gBAAgB,UAAU,oBAAoB,OAAO;AAC3D,UAAM,kBAAkB,UAAU,qBAAqB,OAAO;AAE9D,UAAM,UAAU,mBAAmB,YAAY,aAAa;AAE5D,UAAM,gBAAgB,kBAClB,YAAY,cAAc,QAC1B,YAAY;AAChB,UAAM,cAAc,oBAAoB,eAAe,OAAO;AAE9D,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA,YAAY,WAAW;AAAA,IACzB;AAEA,UAAM,OAAuB;AAAA,MAC3B,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAMA,UAAM,kBAAkB,QAAQ,IAAI;AACpC,QAAI,iBAAiB;AACnB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,CAAC,eAAe;AAClB,UAAI,iBAAiB;AACnB,aAAK,eAAe;AAAA,UAClB,GAAG,YAAY;AAAA,UACf,OAAO;AAAA,QACT;AAAA,MACF,OAAO;AACL,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAEA,IAAO,iBAAQ;AASR,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["import_node_fs","import_node_path"]}
1
+ {"version":3,"sources":["../nextjs.ts","../host-identity.ts","../package.json","../release-channel.ts"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { TEMPO_SDK_CHANNEL } from \"./release-channel\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER = \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\";\n\nexport interface TempoHostIdentity {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n sdkChannel: string;\n pluginActive: boolean;\n framework: TempoHostFramework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity(\n framework: TempoHostFramework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n sdkChannel: TEMPO_SDK_CHANNEL,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.60\",\n \"publishConfig\": {\n \"tag\": \"sdk-v2-latest\"\n },\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"peerDependencies\": {\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import sdkPackage from \"./package.json\" with { type: \"json\" };\n\n/** Shared by the app, generated projects and the SDK host identity. */\nexport const TEMPO_SDK_CHANNEL = sdkPackage.publishConfig.tag;\n\nexport function sdkChannelGeneration(channel: unknown): number | null {\n if (typeof channel !== \"string\") return null;\n const match = /^sdk-v([1-9]\\d*)-latest$/.exec(channel);\n return match ? Number(match[1]) : null;\n}\n\nif (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {\n throw new Error(\"tempo-sdk publishConfig.tag must be sdk-v<N>-latest\");\n}\n\n/** Preserve local development links; registry installs follow the app channel. */\nexport function managedTempoSdkSpec(spec: string): string {\n const generation = sdkChannelGeneration(spec);\n if (\n generation !== null &&\n generation > sdkChannelGeneration(TEMPO_SDK_CHANNEL)!\n ) {\n throw new Error(\n `This project requires tempo-sdk@${spec}. Update Tempo before opening it; this app supports ${TEMPO_SDK_CHANNEL}.`,\n );\n }\n if (/^(workspace:|file:|link:|portal:|git|https?:|ssh:|github:)/.test(spec))\n return spec;\n return TEMPO_SDK_CHANNEL;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,IAAAA,kBAAyC;AACzC,yBAA8B;AAC9B,IAAAC,oBAAiC;;;ACnBjC,qBAA6B;AAC7B,uBAAwB;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gCAAgC;AAAA,MAC9B,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AA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ACnB;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":["import_node_fs","import_node_path"]}
package/dist/nextjs.d.cts CHANGED
@@ -1,5 +1,15 @@
1
- import { ElementInfo, PropValue } from '@modules/annotation';
2
- export { ElementInfo, PropValue } from '@modules/annotation';
1
+ import { JSXElement } from 'oxc-parser';
2
+
3
+ interface ElementInfo {
4
+ element: JSXElement;
5
+ /** e.g. "div", "Button", "Foo.Bar" */
6
+ tagName: string;
7
+ /** The AST type of the element's syntactic parent ("JSXElement" for a
8
+ * JSX child, "ArrowFunctionExpression" for a `.map` callback root, ...). */
9
+ parentType?: string | null;
10
+ }
11
+ /** Supported prop value types. `undefined` values are skipped. */
12
+ type PropValue = string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) | object;
3
13
 
4
14
  type TempoHostFramework = "vite" | "nextjs";
5
15
  interface TempoHostIdentity {
@@ -7,6 +17,7 @@ interface TempoHostIdentity {
7
17
  contractVersion: number;
8
18
  workspaceNonce: string;
9
19
  sdkVersion: string;
20
+ sdkChannel: string;
10
21
  pluginActive: boolean;
11
22
  framework: TempoHostFramework;
12
23
  }
@@ -117,4 +128,4 @@ declare const _internal: {
117
128
  resolveLoaderPath: typeof resolveLoaderPath;
118
129
  };
119
130
 
120
- export { type ComputeAnnotatedProps, type TempoNextjsOptions, _internal, _resetTempoProjectRoot, tempoNextjsPlugin as default, tempoHostIdentity, tempoNextjsPlugin, tempoProjectRoot };
131
+ export { type ComputeAnnotatedProps, type ElementInfo, type PropValue, type TempoNextjsOptions, _internal, _resetTempoProjectRoot, tempoNextjsPlugin as default, tempoHostIdentity, tempoNextjsPlugin, tempoProjectRoot };
package/dist/nextjs.d.ts CHANGED
@@ -1,5 +1,15 @@
1
- import { ElementInfo, PropValue } from '@modules/annotation';
2
- export { ElementInfo, PropValue } from '@modules/annotation';
1
+ import { JSXElement } from 'oxc-parser';
2
+
3
+ interface ElementInfo {
4
+ element: JSXElement;
5
+ /** e.g. "div", "Button", "Foo.Bar" */
6
+ tagName: string;
7
+ /** The AST type of the element's syntactic parent ("JSXElement" for a
8
+ * JSX child, "ArrowFunctionExpression" for a `.map` callback root, ...). */
9
+ parentType?: string | null;
10
+ }
11
+ /** Supported prop value types. `undefined` values are skipped. */
12
+ type PropValue = string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) | object;
3
13
 
4
14
  type TempoHostFramework = "vite" | "nextjs";
5
15
  interface TempoHostIdentity {
@@ -7,6 +17,7 @@ interface TempoHostIdentity {
7
17
  contractVersion: number;
8
18
  workspaceNonce: string;
9
19
  sdkVersion: string;
20
+ sdkChannel: string;
10
21
  pluginActive: boolean;
11
22
  framework: TempoHostFramework;
12
23
  }
@@ -117,4 +128,4 @@ declare const _internal: {
117
128
  resolveLoaderPath: typeof resolveLoaderPath;
118
129
  };
119
130
 
120
- export { type ComputeAnnotatedProps, type TempoNextjsOptions, _internal, _resetTempoProjectRoot, tempoNextjsPlugin as default, tempoHostIdentity, tempoNextjsPlugin, tempoProjectRoot };
131
+ export { type ComputeAnnotatedProps, type ElementInfo, type PropValue, type TempoNextjsOptions, _internal, _resetTempoProjectRoot, tempoNextjsPlugin as default, tempoHostIdentity, tempoNextjsPlugin, tempoProjectRoot };
package/dist/nextjs.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tempoHostIdentity,
6
6
  tempoNextjsPlugin,
7
7
  tempoProjectRoot
8
- } from "./chunk-7Y7XNHUM.js";
8
+ } from "./chunk-FQSZRVSL.js";
9
9
  export {
10
10
  _internal,
11
11
  _resetTempoProjectRoot,
@@ -1,4 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
+ import { V as V1LayoutCompat } from './v1-client-compat-qxaXEDm_.js';
2
3
 
3
4
  interface TempoCanvasConfig {
4
5
  name: string;
@@ -9,13 +10,12 @@ interface TempoCanvasConfig {
9
10
  /** @deprecated Renamed to {@link TempoCanvasConfig}. Kept as an alias for
10
11
  * backwards compatibility with canvas files authored against older SDKs. */
11
12
  type TempoPage = TempoCanvasConfig;
12
- interface StoryboardLayout {
13
+ interface StoryboardLayout extends V1LayoutCompat {
13
14
  x: number;
14
15
  y: number;
15
- width: number;
16
- height: number;
16
+ width?: number;
17
+ height?: number;
17
18
  zIndex?: number;
18
- intrinsicSizing?: "root-element";
19
19
  }
20
20
  interface TempoStoryboard {
21
21
  render: () => ReactElement;
@@ -25,12 +25,18 @@ interface TempoStoryboard {
25
25
  interface TempoRouteStoryboard {
26
26
  route: string;
27
27
  name?: string;
28
- layout: StoryboardLayout;
28
+ layout: StoryboardLayout & {
29
+ width: number;
30
+ height: number;
31
+ };
29
32
  }
30
33
  interface TempoHtmlStoryboard {
31
34
  filepath: string;
32
35
  name?: string;
33
- layout: StoryboardLayout;
36
+ layout: StoryboardLayout & {
37
+ width: number;
38
+ height: number;
39
+ };
34
40
  }
35
41
 
36
42
  export type { StoryboardLayout as S, TempoCanvasConfig as T, TempoHtmlStoryboard as a, TempoPage as b, TempoRouteStoryboard as c, TempoStoryboard as d };
@@ -1,14 +1,14 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { d as TempoStoryboard } from './page-xi1aI5a7.js';
3
+ import { d as TempoStoryboard } from './page-DwLnOM5d.js';
4
+ import { V as V1LayoutCompat } from './v1-client-compat-qxaXEDm_.js';
4
5
 
5
- interface StoryboardLayout {
6
+ interface StoryboardLayout extends V1LayoutCompat {
6
7
  x: number;
7
8
  y: number;
8
- width: number;
9
- height: number;
9
+ width?: number;
10
+ height?: number;
10
11
  zIndex?: number;
11
- intrinsicSizing?: "root-element";
12
12
  }
13
13
  interface StoryboardVrtIgnoreRegion {
14
14
  x: number;
@@ -29,7 +29,7 @@ interface StoryboardVrtConfig {
29
29
  /** Regions (storyboard-local px) excluded from comparison. */
30
30
  ignore?: StoryboardVrtIgnoreRegion[];
31
31
  }
32
- declare function Storyboard<Props extends object = object>({ id, name, component, layout, props, ...annotations }: {
32
+ declare function Storyboard<Props extends object = object>({ id, name, component, layout, props, vrt, ...annotations }: {
33
33
  id: string;
34
34
  component: ComponentType<Props>;
35
35
  layout: StoryboardLayout;
@@ -38,25 +38,44 @@ declare function Storyboard<Props extends object = object>({ id, name, component
38
38
  [annotation: `data-tempo-${string}`]: unknown;
39
39
  /** Opt this storyboard into visual regression testing (static mark). */
40
40
  vrt?: boolean | StoryboardVrtConfig;
41
- }): react.JSX.Element;
41
+ } & Record<`data-tempo-${string}`, unknown>): react.JSX.Element;
42
42
  declare function LegacyStoryboardV1({ id, storyboard, }: {
43
43
  id: string;
44
44
  storyboard: TempoStoryboard;
45
45
  }): react.JSX.Element;
46
- declare function RouteStoryboard({ id, name, route, layout, }: {
46
+ declare function RouteStoryboard({ id, name, route, layout, ...annotations }: {
47
47
  id: string;
48
48
  route: string;
49
- layout: StoryboardLayout;
49
+ layout: StoryboardLayout & {
50
+ width: number;
51
+ height: number;
52
+ };
50
53
  name?: string;
51
- }): react.JSX.Element;
52
- declare function HtmlStoryboard({ id, name, filepath, src, layout, }: {
54
+ } & Record<`data-tempo-${string}`, unknown>): react.JSX.Element;
55
+ declare function HtmlStoryboard({ id, name, filepath, src, layout, vrt, ...annotations }: {
53
56
  id: string;
54
- layout: StoryboardLayout;
57
+ layout: StoryboardLayout & {
58
+ width: number;
59
+ height: number;
60
+ };
55
61
  filepath?: string;
62
+ /** @deprecated Retained for v2 clients; prefer filepath for local HTML. */
56
63
  src?: string;
57
64
  name?: string;
58
- }): react.JSX.Element;
59
- declare function StoryboardSlot({ children, id, kind, layout, name, route, filepath, src, }: {
65
+ /** Opt this local HTML storyboard into visual regression testing. */
66
+ vrt?: boolean | StoryboardVrtConfig;
67
+ } & Record<`data-tempo-${string}`, unknown>): react.JSX.Element;
68
+ /**
69
+ * The shell every storyboard kind renders. It is SDK plumbing between the
70
+ * public component (the callsite the compiler annotates) and the shell
71
+ * element, so every caller hides its fiber: the projection then sees the
72
+ * public component as the shell's parent, which the canvas reads as the
73
+ * storyboard's root layer.
74
+ */
75
+ declare function StoryboardSlot({ children, id, kind, layout, name, route, filepath, src, vrt, uiFramework, }: {
76
+ "data-tempo-hide-fiber": "true";
77
+ vrt?: boolean;
78
+ uiFramework?: "svelte";
60
79
  children?: ReactNode;
61
80
  id: string;
62
81
  kind: "component" | "route" | "html";
@@ -64,7 +83,8 @@ declare function StoryboardSlot({ children, id, kind, layout, name, route, filep
64
83
  name?: string;
65
84
  route?: string;
66
85
  filepath?: string;
86
+ /** @deprecated Retained for v2 clients; prefer filepath for local HTML. */
67
87
  src?: string;
68
- }): react.JSX.Element | null;
88
+ }): react.JSX.Element;
69
89
 
70
90
  export { HtmlStoryboard as H, LegacyStoryboardV1 as L, RouteStoryboard as R, Storyboard as S, type StoryboardLayout as a, StoryboardSlot as b, type StoryboardVrtConfig as c, type StoryboardVrtIgnoreRegion as d };
package/dist/svelte.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as svelte_compiler from 'svelte/compiler';
1
+ import { PreprocessorGroup } from 'svelte/compiler';
2
2
 
3
3
  /**
4
4
  * Svelte-specific Tempo source annotation.
@@ -7,6 +7,7 @@ import * as svelte_compiler from 'svelte/compiler';
7
7
  * filesystem/project identity; parsing and annotation remain isolated in the
8
8
  * framework-focused @modules/svelte-editor package.
9
9
  */
10
+
10
11
  interface TempoSveltePreprocessOptions {
11
12
  /** Annotation identity root. Defaults to the process working directory. */
12
13
  root?: string;
@@ -16,6 +17,6 @@ interface TempoSveltePreprocessOptions {
16
17
  /** Override the normal TEMPO environment gate, primarily for tests. */
17
18
  enabled?: boolean;
18
19
  }
19
- declare function tempoSveltePreprocess(options?: TempoSveltePreprocessOptions): svelte_compiler.PreprocessorGroup;
20
+ declare function tempoSveltePreprocess(options?: TempoSveltePreprocessOptions): PreprocessorGroup;
20
21
 
21
22
  export { type TempoSveltePreprocessOptions, tempoSveltePreprocess };
package/dist/svelte.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
+ appendModuleVersionRecord,
2
3
  sourceVersionHash
3
- } from "./chunk-F3KJDCMU.js";
4
+ } from "./chunk-2IQD2KPS.js";
4
5
 
5
6
  // svelte.ts
6
- import { statSync } from "fs";
7
+ import { readFileSync, statSync } from "fs";
7
8
  import { isAbsolute, relative, resolve } from "path";
8
9
 
9
10
  // ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -1306,10 +1307,7 @@ function walk(ast, { enter, leave }) {
1306
1307
  }
1307
1308
 
1308
1309
  // ../../modules/svelte-editor/parse.ts
1309
- import {
1310
- compile,
1311
- parse
1312
- } from "svelte/compiler";
1310
+ import { compile, parse } from "svelte/compiler";
1313
1311
  function parseSvelteSourceInternal(source, filename, validation = "compiler") {
1314
1312
  const cacheKey = `${validation}\0${filename}\0${source}`;
1315
1313
  const cached = parseCache.get(cacheKey);
@@ -1328,10 +1326,22 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
1328
1326
  const targetNodes = /* @__PURE__ */ new Map();
1329
1327
  const elementStack = [];
1330
1328
  const fragmentOwnerTypes = /* @__PURE__ */ new WeakMap();
1329
+ const templateScopes = /* @__PURE__ */ new WeakMap();
1330
+ const scopeStack = [];
1331
1331
  walk(ast, {
1332
1332
  enter(node, parent) {
1333
1333
  const svelteNode = node;
1334
1334
  if (svelteNode.type === "Fragment") {
1335
+ const fragment = node;
1336
+ const owner = parent;
1337
+ const inherits = owner?.type === "RegularElement" && !owner.attributes.some(
1338
+ (attribute) => attribute.type === "LetDirective"
1339
+ ) && !fragment.nodes.some(
1340
+ (child) => child.type === "ConstTag" || child.type === "SnippetBlock"
1341
+ );
1342
+ const scope = inherits ? scopeStack[scopeStack.length - 1] ?? fragment : fragment;
1343
+ templateScopes.set(fragment, scope);
1344
+ scopeStack.push(scope);
1335
1345
  fragmentOwnerTypes.set(
1336
1346
  node,
1337
1347
  parent?.type ?? null
@@ -1341,6 +1351,8 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
1341
1351
  node
1342
1352
  );
1343
1353
  if (target) {
1354
+ const fragment = parent;
1355
+ target.parentFragmentOwnerType = fragment?.type === "Fragment" ? fragmentOwnerTypes.get(fragment) ?? null : null;
1344
1356
  targets.set(target.start, target);
1345
1357
  targetNodes.set(
1346
1358
  target.start,
@@ -1392,9 +1404,16 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
1392
1404
  leave(node) {
1393
1405
  const svelteNode = node;
1394
1406
  if (svelteNode.type === "RegularElement") elementStack.pop();
1407
+ if (svelteNode.type === "Fragment") scopeStack.pop();
1395
1408
  }
1396
1409
  });
1397
- const result = { kind: "ok", elements, targets, targetNodes };
1410
+ const result = {
1411
+ kind: "ok",
1412
+ elements,
1413
+ templateScopes,
1414
+ targets,
1415
+ targetNodes
1416
+ };
1398
1417
  rememberParse(cacheKey, result);
1399
1418
  return result;
1400
1419
  } catch (error) {
@@ -1632,11 +1651,18 @@ function annotateSvelteSource(options) {
1632
1651
  })
1633
1652
  });
1634
1653
  }
1635
- const annotatedCode = applyStringEdits(inputSource, edits);
1654
+ const startEdit = {
1655
+ start: 0,
1656
+ end: 0,
1657
+ replacement: `{@html '<!--${TEMPO_SVELTE_SOURCE_REGISTRY_ATTRIBUTE}-->'}`
1658
+ };
1659
+ const annotationEdits = [startEdit, ...edits];
1660
+ const annotatedCode = applyStringEdits(inputSource, annotationEdits);
1636
1661
  const sourceRecords = buildSourceRecords({
1662
+ source: inputSource,
1637
1663
  parsed,
1638
1664
  removalEdits,
1639
- annotationEdits: edits,
1665
+ annotationEdits,
1640
1666
  annotatedCode
1641
1667
  });
1642
1668
  const registry = {
@@ -1654,7 +1680,7 @@ function annotateSvelteSource(options) {
1654
1680
  <template ${TEMPO_SVELTE_SOURCE_REGISTRY_ATTRIBUTE}="${escapeSvelteAttributeValue(JSON.stringify(registry), '"')}"></template>
1655
1681
  `
1656
1682
  };
1657
- const transformEdits = [...edits, registryEdit];
1683
+ const transformEdits = [...annotationEdits, registryEdit];
1658
1684
  const code = applyStringEdits(inputSource, transformEdits);
1659
1685
  try {
1660
1686
  if (validation === "compiler") {
@@ -1705,7 +1731,7 @@ function removeGeneratedSourceRegistries(source) {
1705
1731
  /[.*+?^${}()|[\]\\]/g,
1706
1732
  "\\$&"
1707
1733
  );
1708
- return source.replace(
1734
+ return source.replace(`{@html '<!--${TEMPO_SVELTE_SOURCE_REGISTRY_ATTRIBUTE}-->'}`, "").replace(
1709
1735
  new RegExp(
1710
1736
  `\\n?<template\\s+${escaped}=(?:"[^"]*"|'[^']*')\\s*><\\/template>\\n?`,
1711
1737
  "g"
@@ -1736,6 +1762,20 @@ function buildSourceRecords(options) {
1736
1762
  const hasSpread = target.hasSpreadAttributes === true;
1737
1763
  const directives = new Set(target.directiveTypes ?? []);
1738
1764
  const attributes = new Set(target.attributeNames ?? []);
1765
+ const blockChild = /Block$/.test(target.parentFragmentOwnerType ?? "");
1766
+ const node = options.parsed.targetNodes.get(target.start);
1767
+ const directiveFacts = (node?.attributes ?? []).flatMap((attribute) => {
1768
+ if (attribute.type === "Attribute" || attribute.type === "SpreadAttribute")
1769
+ return [];
1770
+ if (attribute.type === "AttachTag") return ["@attach"];
1771
+ const written = options.source.slice(attribute.start, attribute.end);
1772
+ return [written.split("=")[0].trim()];
1773
+ });
1774
+ const expressions = [
1775
+ ...blockChild ? ["#slot"] : [],
1776
+ ...[...attributes].filter((name) => target.staticAttributes?.[name] === void 0).map((name) => name === "class" ? "className" : name),
1777
+ ...directiveFacts
1778
+ ].join(" ");
1739
1779
  const common = {
1740
1780
  name: target.tagName,
1741
1781
  line: location.line,
@@ -1744,6 +1784,8 @@ function buildSourceRecords(options) {
1744
1784
  ...typeof classValue === "string" ? { className: classValue } : {},
1745
1785
  ...typeof styleValue === "string" ? { style: styleValue } : {},
1746
1786
  ...lockValue === true || lockValue === "true" || lockValue === "" ? { locked: true } : lockValue === "false" ? { locked: false } : {},
1787
+ // A spread gets a stamp even with no fact, as JSX's does.
1788
+ ...expressions || hasSpread ? { expressions } : {},
1747
1789
  supportsClassName: !hasSpread && !directives.has("ClassDirective") && (!attributes.has("class") || typeof classValue === "string"),
1748
1790
  supportsStyle: !hasSpread && !directives.has("StyleDirective") && (!attributes.has("style") || typeof styleValue === "string")
1749
1791
  };
@@ -1866,36 +1908,68 @@ function serializeAnnotations(metadata) {
1866
1908
  }
1867
1909
 
1868
1910
  // ../../modules/svelte-editor/plan.ts
1869
- import {
1870
- compile as compile3,
1871
- parse as parse2
1872
- } from "svelte/compiler";
1911
+ import { compile as compile3, parse as parse2 } from "svelte/compiler";
1873
1912
 
1874
1913
  // ../../modules/svelte-editor/transfer.ts
1875
1914
  import { parse as parse3 } from "svelte/compiler";
1876
1915
 
1877
1916
  // svelte.ts
1917
+ var MODULE_SCRIPT = /<script\b[^>]*\b(?:module\b|context\s*=\s*["']module["'])[^>]*>/;
1878
1918
  function tempoSveltePreprocess(options = {}) {
1879
1919
  const root = resolve(options.root ?? process.cwd());
1880
1920
  const sourceRoot = resolve(options.sourceRoot ?? root);
1881
1921
  const enabled = options.enabled ?? Boolean(process.env.TEMPO);
1882
- return createSvelteAnnotationPreprocessor({
1883
- metadata({ filename }) {
1884
- if (!enabled || !filename) return null;
1885
- const absoluteFilename = resolve(filename);
1886
- if (!absoluteFilename.endsWith(".svelte")) return null;
1887
- const sourcePath = relative(sourceRoot, absoluteFilename);
1888
- if (!sourcePath || sourcePath.startsWith("../") || isAbsolute(sourcePath) || sourcePath.split(/[\\/]/).includes("node_modules")) {
1889
- return null;
1890
- }
1891
- const filepath = relative(root, absoluteFilename).replace(/\\/g, "/");
1892
- if (!filepath || isAbsolute(filepath)) return null;
1922
+ const metadata = ({ filename }) => {
1923
+ if (!enabled || !filename) return null;
1924
+ const absoluteFilename = resolve(filename);
1925
+ if (!absoluteFilename.endsWith(".svelte")) return null;
1926
+ const sourcePath = relative(sourceRoot, absoluteFilename);
1927
+ if (!sourcePath || sourcePath.startsWith("../") || isAbsolute(sourcePath) || sourcePath.split(/[\\/]/).includes("node_modules")) {
1928
+ return null;
1929
+ }
1930
+ const filepath = relative(root, absoluteFilename).replace(/\\/g, "/");
1931
+ if (!filepath || isAbsolute(filepath)) return null;
1932
+ return {
1933
+ filepath,
1934
+ modifiedTs: Math.trunc(statSync(absoluteFilename).mtimeMs)
1935
+ };
1936
+ };
1937
+ const annotation = createSvelteAnnotationPreprocessor({ metadata });
1938
+ return {
1939
+ name: "svelte-source-annotation",
1940
+ // The annotation, plus an empty module script when the file has none:
1941
+ // the module version record must run once per module evaluation, which
1942
+ // is what a module script's top level does (V2-498).
1943
+ markup(input) {
1944
+ const result = annotation.markup?.(input);
1945
+ if (!result || !("code" in result)) return result;
1946
+ if (MODULE_SCRIPT.test(result.code)) return result;
1947
+ return {
1948
+ ...result,
1949
+ code: `${result.code}
1950
+ <script module></script>
1951
+ `
1952
+ };
1953
+ },
1954
+ // The module version record ends the module script, as it ends every
1955
+ // annotated JSX module. The file's own bytes name its version, the same
1956
+ // raw-source hash the element stamps carry.
1957
+ script({ content, attributes, filename }) {
1958
+ const moduleScript = attributes.module === true || attributes.context === "module";
1959
+ if (!moduleScript) return void 0;
1960
+ const identity = metadata({ filename });
1961
+ if (!identity || !filename) return void 0;
1962
+ const sourceVersion = sourceVersionHash(readFileSync(filename, "utf8"));
1893
1963
  return {
1894
- filepath,
1895
- modifiedTs: Math.trunc(statSync(absoluteFilename).mtimeMs)
1964
+ code: appendModuleVersionRecord(
1965
+ content,
1966
+ identity.filepath,
1967
+ identity.modifiedTs,
1968
+ sourceVersion
1969
+ )
1896
1970
  };
1897
1971
  }
1898
- });
1972
+ };
1899
1973
  }
1900
1974
  export {
1901
1975
  tempoSveltePreprocess