tempo-sdk 0.0.94 → 0.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3897
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-FH6TMWFA.js +1 -0
  37. package/dist/chunk-GQIOB5SV.js +1 -0
  38. package/dist/chunk-HBQ7FFH7.js +1 -0
  39. package/dist/chunk-JRJOWLCN.js +1 -0
  40. package/dist/chunk-M3GN2KUH.js +1 -0
  41. package/dist/chunk-MPIHFFML.js +1 -0
  42. package/dist/chunk-N2V6XXRK.js +1 -0
  43. package/dist/chunk-QNVQ7U2W.js +1 -0
  44. package/dist/chunk-T5TY3U2H.js +1 -0
  45. package/dist/chunk-TK37FQAR.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-YRBEBVG4.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-3W6B75UK.js +0 -455
  99. package/dist/chunk-3W6B75UK.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6QGMLNO3.js +0 -8337
  105. package/dist/chunk-6QGMLNO3.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYQE3TLC.js +0 -37
  113. package/dist/chunk-CYQE3TLC.js.map +0 -1
  114. package/dist/chunk-DI2ZFAWL.js +0 -14
  115. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  116. package/dist/chunk-EGRHWZRV.js +0 -1
  117. package/dist/chunk-EGRHWZRV.js.map +0 -1
  118. package/dist/chunk-FGWGY3G3.js +0 -157
  119. package/dist/chunk-FGWGY3G3.js.map +0 -1
  120. package/dist/chunk-HOBTDB6G.js +0 -112
  121. package/dist/chunk-HOBTDB6G.js.map +0 -1
  122. package/dist/chunk-JVVHU3A7.js +0 -1077
  123. package/dist/chunk-JVVHU3A7.js.map +0 -1
  124. package/dist/chunk-KY52JZZL.js +0 -3130
  125. package/dist/chunk-KY52JZZL.js.map +0 -1
  126. package/dist/chunk-LEW24RRZ.js +0 -1315
  127. package/dist/chunk-LEW24RRZ.js.map +0 -1
  128. package/dist/chunk-MU7S7NU7.js +0 -183
  129. package/dist/chunk-MU7S7NU7.js.map +0 -1
  130. package/dist/chunk-OX2YKYSL.js +0 -13
  131. package/dist/chunk-OX2YKYSL.js.map +0 -1
  132. package/dist/chunk-OYNR6D7K.js +0 -342
  133. package/dist/chunk-OYNR6D7K.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-REYOX4JT.js +0 -285
  137. package/dist/chunk-REYOX4JT.js.map +0 -1
  138. package/dist/chunk-SGN7BDRE.js +0 -16
  139. package/dist/chunk-SGN7BDRE.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-VRNJI4Y6.js +0 -2657
  145. package/dist/chunk-VRNJI4Y6.js.map +0 -1
  146. package/dist/chunk-WRILG6GR.js +0 -38
  147. package/dist/chunk-WRILG6GR.js.map +0 -1
  148. package/dist/chunk-WTXOWQ7N.js +0 -47
  149. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  150. package/dist/chunk-YHGUAOBM.js +0 -621
  151. package/dist/chunk-YHGUAOBM.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
package/README.md CHANGED
@@ -1,405 +1,5 @@
1
- # tempo-sdk
1
+ # Tempo SDK
2
2
 
3
- Tempo's JSX-annotation plugins for Vite and Next.js. At build time, every JSX
4
- element in your codebase gets `data-tempo-*` attributes that map the rendered
5
- DOM back to the exact source-file location that produced it. Tempo's design
6
- surface uses these attributes to navigate from a clicked element to its source.
3
+ Public authoring declarations and integration adapters for Tempo.
7
4
 
8
- This package ships two plugins from one workspace:
9
-
10
- - **`tempo-sdk`** — Vite plugin (`tempoVitePlugin`)
11
- - **`tempo-sdk/nextjs`** — Next.js plugin (`tempoNextjsPlugin`)
12
- - **`tempo-sdk/nextjs/plugin`** — default-exported Next.js plugin for ESM config files
13
- - **`tempo-sdk/expo/plugin`** — Expo Babel plugin (`tempoExpoBabelPlugin`)
14
-
15
- Both produce byte-identical `data-tempo-*` output, so downstream consumers
16
- (`source-editor.ts`, `frame-preload.ts`) work the same regardless of which
17
- framework the user's project is on.
18
-
19
- ---
20
-
21
- ## Next.js usage
22
-
23
- ### 1. Install
24
-
25
- In a workspace package:
26
-
27
- ```jsonc
28
- {
29
- "dependencies": { "tempo-sdk": "workspace:*" }
30
- }
31
- ```
32
-
33
- In an external project: `pnpm add tempo-sdk` (or your package manager's equivalent).
34
-
35
- ### 2. Wrap `next.config`
36
-
37
- CommonJS (`next.config.js`):
38
-
39
- ```js
40
- const tempoNextjsPlugin = require("tempo-sdk/nextjs");
41
-
42
- module.exports = tempoNextjsPlugin()({
43
- reactStrictMode: true,
44
- // ...rest of your existing config
45
- });
46
- ```
47
-
48
- ESM (`next.config.mjs` / `next.config.ts`):
49
-
50
- ```ts
51
- import tempoNextjsPlugin from "tempo-sdk/nextjs/plugin";
52
-
53
- export default tempoNextjsPlugin()({
54
- reactStrictMode: true,
55
- });
56
- ```
57
-
58
- You can also use the named export from `tempo-sdk/nextjs`:
59
-
60
- ```ts
61
- import { tempoNextjsPlugin } from "tempo-sdk/nextjs";
62
- ```
63
-
64
- ### 3. Set the `TEMPO` env var when launching dev
65
-
66
- ```bash
67
- TEMPO=true next dev # Turbopack (Next.js 16+ default)
68
- TEMPO=true next dev --webpack # Webpack mode
69
- ```
70
-
71
- Without `TEMPO` set, the plugin is a complete no-op. You can leave
72
- `tempoNextjsPlugin()` in `next.config.js` permanently — there is zero overhead
73
- in normal dev. Tempo's start script sets `TEMPO=true` automatically when
74
- launching the project under Tempo.
75
-
76
- ### 4. App Router — that's it
77
-
78
- The loader auto-injects `<meta name="tempo-project-root">` into the first JSX
79
- `<head>` it sees (typically `app/layout.tsx`). Every JSX element in your project
80
- gets `data-tempo-filepath`, `data-tempo-position`, `data-tempo-modifiedts`, and
81
- `data-tempo-supports-*` attributes baked into the SWC-compiled output.
82
-
83
- Example rendered HTML:
84
-
85
- ```html
86
- <button
87
- data-tempo-filepath="components/Button.tsx"
88
- data-tempo-position="142"
89
- data-tempo-modifiedts="1708900000000"
90
- data-tempo-supports-children="true"
91
- >
92
- Click me
93
- </button>
94
-
95
- <head>
96
- <meta name="tempo-project-root" content="/abs/path/to/project" />
97
- </head>
98
- ```
99
-
100
- ### 5. Pages Router — one extra line in `_document.tsx`
101
-
102
- `<Head>` from `next/document` is a **custom** React component (capital H), not
103
- intrinsic JSX `<head>` (lowercase), so auto-inject doesn't fire there. Add the
104
- project-root meta manually:
105
-
106
- ```tsx
107
- // pages/_document.tsx
108
- import { Html, Head, Main, NextScript } from "next/document";
109
- import { tempoProjectRoot } from "tempo-sdk/nextjs";
110
-
111
- export default function Document() {
112
- return (
113
- <Html>
114
- <Head>
115
- <meta name="tempo-project-root" content={tempoProjectRoot()} />
116
- </Head>
117
- <body>
118
- <Main />
119
- <NextScript />
120
- </body>
121
- </Html>
122
- );
123
- }
124
- ```
125
-
126
- `tempoProjectRoot()` returns the same canonical root the loader uses for
127
- `data-tempo-filepath`, so paths reconstruct correctly.
128
-
129
- ### Options
130
-
131
- All optional:
132
-
133
- ```js
134
- tempoNextjsPlugin({
135
- autoInjectRootMeta: false, // disable head meta auto-inject
136
- productionBuild: true, // run in `next build` too (rare)
137
- computeAnnotatedPropsModule: "./tempo-strategy.js", // custom prop-computation
138
- })(nextConfig);
139
- ```
140
-
141
- `computeAnnotatedPropsModule` is a path (not a function) because Turbopack
142
- requires loader options to be JSON-serializable. The module's default export
143
- must be a function `(info, filepath, modifiedtsMs) => Record<string, PropValue>`.
144
-
145
- ### Composing with other wrappers (`@next/mdx`, etc.)
146
-
147
- `tempoNextjsPlugin` follows the `@next/mdx` higher-order-config pattern, so it
148
- composes naturally:
149
-
150
- ```js
151
- const tempoNextjsPlugin = require("tempo-sdk/nextjs");
152
- const withMDX = require("@next/mdx")();
153
-
154
- module.exports = tempoNextjsPlugin()(
155
- withMDX({ reactStrictMode: true })
156
- );
157
- ```
158
-
159
- `tempoNextjsPlugin` should be the **outermost** wrapper so its webpack/turbopack
160
- chaining sees the inner wrappers' contributions.
161
-
162
- ### Supported Next.js versions
163
-
164
- | Next.js | Webpack | Turbopack | Notes |
165
- |---|---|---|---|
166
- | 16.x | `--webpack` flag | default | Validated end-to-end |
167
- | 15.3 – 15.x | default | `--turbo` flag | Wrapper writes to `turbopack.*` |
168
- | 13.0 – 15.2 | default | `--turbo` flag | Wrapper writes to `experimental.turbo.*` |
169
- | 12.x | default | n/a | Webpack only; turbopack field omitted |
170
- | < 12 | n/a | n/a | Out of scope |
171
-
172
- The wrapper detects the version via `next/package.json` and writes to the
173
- correct field automatically.
174
-
175
- ---
176
-
177
- ## Vite usage
178
-
179
- ```ts
180
- // vite.config.ts
181
- import { defineConfig } from "vite";
182
- import react from "@vitejs/plugin-react";
183
- import { tempoVitePlugin } from "tempo-sdk";
184
-
185
- export default defineConfig({
186
- plugins: [tempoVitePlugin(), react()],
187
- });
188
- ```
189
-
190
- Same `TEMPO` env-var gating, same `data-tempo-*` output as the Next.js plugin.
191
- The Vite plugin additionally exposes an `/__tempo/errors` SSE endpoint for
192
- streaming concrete compile errors to the design surface. It does not publish a
193
- source-update stream or supervise source-to-visible HMR transactions; normal
194
- updates belong to Vite and the official React plugin.
195
-
196
- ### Canvas runtime surface
197
-
198
- `tempo-sdk/canvas` exposes the bundler-agnostic runtime used by the generated
199
- Canvas host:
200
-
201
- - `CanvasHost` accepts either legacy `children` or literal `canvasModules`
202
- loaders. Passing both throws `CanvasHostContractError` instead of silently
203
- rendering an ambiguous host.
204
- - `CanvasImportBoundary` owns lazy import, Suspense, canvas-scoped error
205
- reporting, and current-owner mount success. It does not replay accepted
206
- modules or inspect Vite transactions.
207
- - `getCanvasHostRecoveryFeed()` returns the document-local
208
- `host-recovery-feed`. It carries exactly one product fact
209
- (`module-load-failure`: a canvas import rejection or an HMR
210
- module-evaluation failure) to the generated recovery adapter; no hot
211
- context, cycle number, owner success, or reload command crosses the SDK
212
- boundary.
213
- - `canvasHostCapability` declares protocol version 1 with
214
- `supportsModules: true`. It is defense-in-depth, not the primary
215
- compatibility gate.
216
-
217
- Before generating `.tempo/tempo-host.tsx`, `tempo-devserver` runs the primary
218
- installed-package check. An incompatible SDK fails before browser evaluation
219
- with `canvas_host_sdk_incompatible` and an actionable install command. Tempo's
220
- managed sidecar rollout first runs `ensureTempoSdkLatestSpec`; whether that
221
- upgrade was attempted is included in the typed compatibility error. The rollout
222
- contract is publish the compatible SDK first, verify the packed artifact, then
223
- ship the devserver that requires it.
224
-
225
- ---
226
-
227
- ## Expo usage
228
-
229
- Expo support is for Tempo's web canvas runtime. It annotates Expo web output for
230
- selection and editing; it does not make native-device canvases editable.
231
-
232
- Configure the Tempo-owned Expo sidecar app's Babel config:
233
-
234
- ```js
235
- // tempo/babel.config.js
236
- const path = require("node:path");
237
- const { tempoExpoBabelPlugin } = require("tempo-sdk/expo/plugin");
238
-
239
- module.exports = function (api) {
240
- api.cache(true);
241
- return {
242
- presets: ["babel-preset-expo"],
243
- plugins: [
244
- [
245
- tempoExpoBabelPlugin,
246
- {
247
- root: path.resolve(__dirname, ".."),
248
- },
249
- ],
250
- ],
251
- };
252
- };
253
- ```
254
-
255
- If the Expo app uses NativeWind-style `className`, pass
256
- `reactNativeClassName: true` in the plugin options.
257
-
258
- The sidecar Metro config must watch the parent project so `tempo/` can import
259
- real app components:
260
-
261
- ```js
262
- // tempo/metro.config.js
263
- const path = require("node:path");
264
- const { getDefaultConfig } = require("expo/metro-config");
265
-
266
- const projectRoot = __dirname;
267
- const workspaceRoot = path.resolve(projectRoot, "..");
268
- const sidecarNodeModules = path.join(projectRoot, "node_modules");
269
-
270
- const config = getDefaultConfig(projectRoot);
271
- const sidecarModule = (moduleName) =>
272
- path.join(sidecarNodeModules, ...moduleName.split("/"));
273
- const singletonModules = {
274
- react: sidecarModule("react"),
275
- "react-dom": sidecarModule("react-dom"),
276
- "react-native": sidecarModule("react-native"),
277
- "react-native-web": sidecarModule("react-native-web"),
278
- "react/jsx-runtime": sidecarModule("react/jsx-runtime.js"),
279
- "react/jsx-dev-runtime": sidecarModule("react/jsx-dev-runtime.js"),
280
- };
281
-
282
- config.watchFolders = Array.from(
283
- new Set([...(config.watchFolders ?? []), workspaceRoot]),
284
- );
285
- config.resolver.nodeModulesPaths = Array.from(
286
- new Set([
287
- sidecarNodeModules,
288
- path.join(workspaceRoot, "node_modules"),
289
- ...(config.resolver.nodeModulesPaths ?? []),
290
- ]),
291
- );
292
- config.resolver.disableHierarchicalLookup = true;
293
- config.resolver.extraNodeModules = {
294
- ...(config.resolver.extraNodeModules ?? {}),
295
- ...singletonModules,
296
- };
297
- config.resolver.alias = {
298
- ...(config.resolver.alias ?? {}),
299
- ...singletonModules,
300
- };
301
-
302
- module.exports = config;
303
- ```
304
-
305
- Those singleton aliases are important for sidecar Expo projects. Without them,
306
- Metro can resolve React Native files imported from the parent app against the
307
- parent app's `node_modules` while the sidecar resolves its own runtime against
308
- `tempo/node_modules`, which can produce duplicate React instances and invalid
309
- hook-call failures.
310
-
311
- Launch Expo web with `TEMPO=true`:
312
-
313
- ```bash
314
- TEMPO=true npx expo start --web
315
- ```
316
-
317
- Tempo discovers the printed local URL and probes `/tempo-host`; no fixed port is
318
- required.
319
-
320
- ---
321
-
322
- ## How it works
323
-
324
- The Next.js plugin is a webpack-compatible loader (`nextjs-loader.cjs`) plus a
325
- higher-order config wrapper (`tempoNextjsPlugin`) that registers the loader for
326
- both Webpack and Turbopack from a single user-facing entrypoint.
327
-
328
- The flow per source file:
329
-
330
- 1. Resource gating — `.tsx`/`.jsx` only, exclude `node_modules`, require
331
- `process.env.TEMPO`.
332
- 2. Read mtime via `fs.statSync`.
333
- 3. Compute project-relative filepath via `path.relative(rootContext, …)`.
334
- 4. Call `annotateFile` from `@modules/annotation` with a callback that returns
335
- the `data-tempo-*` props for each JSX element. The walker visits every
336
- `JSXElement`, fragments are skipped, and props are inserted as JSX
337
- attribute strings at the end of each opening tag.
338
- 5. If the file contains an intrinsic JSX `<head>`, splice
339
- `<meta name="tempo-project-root" content="…" />` into the post-annotation
340
- source. The injected meta does not itself carry `data-tempo-*` attrs (it has
341
- no source location), which keeps every other element's `data-tempo-position`
342
- pointing at the byte offset of `<` in the on-disk source file.
343
- 6. Return the annotated source. Errors at any step cause the loader to return
344
- the original source unchanged — `correct or untouched, always`.
345
-
346
- The `tempoNextjsPlugin` wrapper:
347
-
348
- - Adds an `enforce: "pre"` rule under `config.module.rules` for Webpack
349
- (`/.(tsx|jsx)$/`).
350
- - Adds a `*.{tsx,jsx}` rule under `nextConfig.turbopack.rules` for Turbopack
351
- with `condition: { all: [{ not: "foreign" }, "development"] }` (excludes
352
- node_modules / Next internals AND production builds).
353
- - Chains an existing user-supplied `webpack(config, options)` function and
354
- merges with any existing `turbopack.rules` so other plugins are preserved.
355
- - No-ops entirely when `process.env.TEMPO` is not set.
356
-
357
- See `SPEC_NEXTJS.md` for the complete design specification.
358
-
359
- ---
360
-
361
- ## Demo
362
-
363
- ```bash
364
- pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev # Turbopack on :3477
365
- pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev:webpack # Webpack on :3478
366
- ```
367
-
368
- Then:
369
-
370
- ```bash
371
- curl -s localhost:3477/ | grep -oE 'data-tempo-filepath="[^"]+"' | sort -u
372
- ```
373
-
374
- Should print one line per source file rendered on the home page.
375
-
376
- ---
377
-
378
- ## Tests
379
-
380
- ```bash
381
- pnpm test # all 308 tests across both plugins
382
- pnpm test:nextjs # 175 Next.js tests (~24s)
383
- pnpm test:nextjs:unit # fast unit tests, no servers
384
- pnpm test:nextjs:integration # live `next dev` against demo (Turbopack + Webpack)
385
- pnpm test:nextjs:production # `next build` correctness (no annotations in prod)
386
- ```
387
-
388
- Test layers:
389
-
390
- | File | Tests | Coverage |
391
- |---|---|---|
392
- | `nextjs-loader.test.ts` | 41 | Loader function — file filtering, default strategy, auto-inject, error handling |
393
- | `nextjs-wrapper.test.ts` | 26 | `tempoNextjsPlugin` — webpack chaining, turbopack merging, version detection, options |
394
- | `nextjs-fixtures.test.ts` | 40 | Project shapes — App/Pages Router, server/client components, all routing types |
395
- | `nextjs-published.test.ts` | 14 | Built `dist/*.cjs` and `dist/*.js` — CJS callable, ESM imports, parity |
396
- | `nextjs-production.test.ts` | 6 | `next build` produces zero `data-tempo-*` attributes |
397
- | `nextjs-e2e-correctness.test.ts` | — | Live `next dev` against demo (both bundlers); every recorded `data-tempo-position` actually points at `<` in the on-disk source file |
398
-
399
- ---
400
-
401
- ## Related docs
402
-
403
- - `SPEC.md` — Vite plugin specification
404
- - `SPEC_NEXTJS.md` — Next.js plugin specification
405
- - `SPEC_TSC.md` — TypeScript type-analyzer (used by both plugins for `data-tempo-supports-*`)
5
+ This version requires a Tempo application that provides runtime contract 1. Framework integrations run only when Tempo is enabled.
@@ -1,79 +1,57 @@
1
- import { A as AssetEditFailureCode, S as StaticValue } from '../types-C8OIU-kc.js';
1
+ import { A as AssetEditFailureCode, S as StaticValue } from '../types-CfUgM2w4.js';
2
2
 
3
3
  type AssetEditFailure = {
4
- ok: false;
5
- code: AssetEditFailureCode;
6
- message: string;
4
+ ok: false;
5
+ code: AssetEditFailureCode;
6
+ message: string;
7
7
  };
8
8
  type AssetEditSuccess = {
9
- ok: true;
10
- source: string;
11
- /** False when the operation was a no-op (already in the desired state). */
12
- changed: boolean;
9
+ ok: true;
10
+ source: string;
11
+ changed: boolean;
13
12
  };
14
13
  type AssetEditResult = AssetEditSuccess | AssetEditFailure;
15
- type EnsureNamedDefaultExportResult = (AssetEditSuccess & {
16
- bindingName: string;
17
- }) | AssetEditFailure;
18
- /** Fully-static config for `ensureAssetDeclaration` codegen. Values must not
19
- * contain UNRESOLVED markers — this is codegen input, not parse output. */
14
+ type EnsureNamedDefaultExportResult =
15
+ | (AssetEditSuccess & {
16
+ bindingName: string;
17
+ })
18
+ | AssetEditFailure;
20
19
  type AssetInitialConfig = {
21
- usageInstructions?: string;
22
- libraries?: string[];
23
- variants?: Record<string, {
24
- props: Record<string, StaticValue>;
25
- }>;
20
+ usageInstructions?: string;
21
+ libraries?: string[];
22
+ variants?: Record<
23
+ string,
24
+ {
25
+ props: Record<string, StaticValue>;
26
+ }
27
+ >;
26
28
  };
27
- /**
28
- * Name an anonymous `export default` so a statement-form `defineAsset` can
29
- * reference it (§4.2). No-op when the default export already is (or
30
- * references) a named binding. The transform keeps the default export a plain
31
- * identifier reference, so React Fast Refresh's component-only export
32
- * analysis still holds:
33
- *
34
- * export default <expr> => const <name> = <expr>;
35
- * export default <name>;
36
- * export default function () {} => function <name>() {}
37
- * export default <name>;
38
- */
39
- declare function ensureNamedDefaultExport(options: {
40
- filePath: string;
41
- source: string;
29
+ declare function ensureNamedDefaultExport$1(options: {
30
+ filePath: string;
31
+ source: string;
42
32
  }): EnsureNamedDefaultExportResult;
43
- /**
44
- * Add the tempo-sdk/assets import (if absent) and insert a
45
- * `defineAsset(<bindingName>, <initialConfig>)` statement directly after the
46
- * top-level statement declaring the binding, separated by one blank line
47
- * (§4.3). No-op when a clean declaration for the binding already exists.
48
- */
49
- declare function ensureAssetDeclaration(options: {
50
- filePath: string;
51
- source: string;
52
- bindingName: string;
53
- initialConfig?: AssetInitialConfig;
33
+ declare function ensureAssetDeclaration$1(options: {
34
+ filePath: string;
35
+ source: string;
36
+ bindingName: string;
37
+ initialConfig?: AssetInitialConfig;
54
38
  }): AssetEditResult;
55
- /**
56
- * Insert missing names into the declaration's libraries array, creating the
57
- * property when absent. Existing entry order is preserved; already-present
58
- * names are skipped.
59
- */
60
- declare function addLibraries(options: {
61
- filePath: string;
62
- source: string;
63
- bindingName: string;
64
- libraries: string[];
39
+ declare function addLibraries$1(options: {
40
+ filePath: string;
41
+ source: string;
42
+ bindingName: string;
43
+ libraries: string[];
65
44
  }): AssetEditResult;
66
- /**
67
- * Remove matching string entries from the declaration's libraries array.
68
- * Names not present are ignored. When this operation empties the array, the
69
- * whole `libraries` property is removed — a library-less asset carries no
70
- * empty-array residue.
71
- */
72
- declare function removeLibraries(options: {
73
- filePath: string;
74
- source: string;
75
- bindingName: string;
76
- libraries: string[];
45
+ declare function removeLibraries$1(options: {
46
+ filePath: string;
47
+ source: string;
48
+ bindingName: string;
49
+ libraries: string[];
77
50
  }): AssetEditResult;
78
51
 
52
+ declare const ensureNamedDefaultExport: typeof ensureNamedDefaultExport$1;
53
+ declare const ensureAssetDeclaration: typeof ensureAssetDeclaration$1;
54
+ declare const addLibraries: typeof addLibraries$1;
55
+ declare const removeLibraries: typeof removeLibraries$1;
56
+
79
57
  export { type AssetEditFailure, AssetEditFailureCode, type AssetEditResult, type AssetEditSuccess, type AssetInitialConfig, type EnsureNamedDefaultExportResult, addLibraries, ensureAssetDeclaration, ensureNamedDefaultExport, removeLibraries };