tempo-sdk 0.0.99 → 0.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3926
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-CXCUJCXD.js +1 -0
  37. package/dist/chunk-FH6TMWFA.js +1 -0
  38. package/dist/chunk-FL7FSJSL.js +1 -0
  39. package/dist/chunk-GQIOB5SV.js +1 -0
  40. package/dist/chunk-HBQ7FFH7.js +1 -0
  41. package/dist/chunk-JRJOWLCN.js +1 -0
  42. package/dist/chunk-LJCBFTMP.js +1 -0
  43. package/dist/chunk-M3GN2KUH.js +1 -0
  44. package/dist/chunk-MPIHFFML.js +1 -0
  45. package/dist/chunk-T5TY3U2H.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-ZXBMP6RV.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-27WT3XUG.js +0 -455
  99. package/dist/chunk-27WT3XUG.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6HYKKP5N.js +0 -2658
  105. package/dist/chunk-6HYKKP5N.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYDF4LYJ.js +0 -342
  113. package/dist/chunk-CYDF4LYJ.js.map +0 -1
  114. package/dist/chunk-CYQE3TLC.js +0 -37
  115. package/dist/chunk-CYQE3TLC.js.map +0 -1
  116. package/dist/chunk-DI2ZFAWL.js +0 -14
  117. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  118. package/dist/chunk-EGRHWZRV.js +0 -1
  119. package/dist/chunk-EGRHWZRV.js.map +0 -1
  120. package/dist/chunk-FGWGY3G3.js +0 -157
  121. package/dist/chunk-FGWGY3G3.js.map +0 -1
  122. package/dist/chunk-HOBTDB6G.js +0 -112
  123. package/dist/chunk-HOBTDB6G.js.map +0 -1
  124. package/dist/chunk-I7VF4ZOV.js +0 -630
  125. package/dist/chunk-I7VF4ZOV.js.map +0 -1
  126. package/dist/chunk-JVVHU3A7.js +0 -1077
  127. package/dist/chunk-JVVHU3A7.js.map +0 -1
  128. package/dist/chunk-MIXQVPDH.js +0 -8606
  129. package/dist/chunk-MIXQVPDH.js.map +0 -1
  130. package/dist/chunk-MU7S7NU7.js +0 -183
  131. package/dist/chunk-MU7S7NU7.js.map +0 -1
  132. package/dist/chunk-OX2YKYSL.js +0 -13
  133. package/dist/chunk-OX2YKYSL.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-SGN7BDRE.js +0 -16
  137. package/dist/chunk-SGN7BDRE.js.map +0 -1
  138. package/dist/chunk-SGTGDLOX.js +0 -285
  139. package/dist/chunk-SGTGDLOX.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-WTXOWQ7N.js +0 -47
  145. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  146. package/dist/chunk-X5DJKVBT.js +0 -1308
  147. package/dist/chunk-X5DJKVBT.js.map +0 -1
  148. package/dist/chunk-ZT7HJ6YU.js +0 -38
  149. package/dist/chunk-ZT7HJ6YU.js.map +0 -1
  150. package/dist/chunk-ZW26VZHX.js +0 -3169
  151. package/dist/chunk-ZW26VZHX.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
package/dist/nextjs.cjs CHANGED
@@ -1,485 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // nextjs.ts
21
- var nextjs_exports = {};
22
- __export(nextjs_exports, {
23
- _internal: () => _internal,
24
- _resetTempoProjectRoot: () => _resetTempoProjectRoot,
25
- default: () => nextjs_default,
26
- tempoHostIdentity: () => tempoHostIdentity,
27
- tempoNextjsPlugin: () => tempoNextjsPlugin,
28
- tempoProjectRoot: () => tempoProjectRoot
29
- });
30
- module.exports = __toCommonJS(nextjs_exports);
31
- var import_node_fs2 = require("fs");
32
- var import_node_module = require("module");
33
- var import_node_path2 = require("path");
34
-
35
- // host-identity.ts
36
- var import_node_fs = require("fs");
37
- var import_node_path = require("path");
38
-
39
- // package.json
40
- var package_default = {
41
- name: "tempo-sdk",
42
- version: "0.0.99",
43
- publishConfig: {
44
- tag: "sdk-v2-latest"
45
- },
46
- type: "module",
47
- description: "Tempo SDK \u2014 Vite, Next.js, Nuxt, Expo, Svelte, Vue and Astro canvas integration, source annotations and storyboard types",
48
- repository: {
49
- type: "git",
50
- url: "git+https://github.com/TempoLabsAI/tempo-monorepo.git",
51
- directory: "tempo-modules/tempo-sdk"
52
- },
53
- exports: {
54
- "./astro/controls": {
55
- types: "./dist/astro/controls.d.ts",
56
- import: "./dist/astro/controls.js",
57
- default: "./dist/astro/controls.js"
58
- },
59
- "./astro": {
60
- types: "./dist/astro.d.ts",
61
- import: "./dist/astro.js"
62
- },
63
- "./astro/client": {
64
- types: "./astro/client.d.ts"
65
- },
66
- "./canvas/astro": {
67
- types: "./dist/canvas/astro.d.ts",
68
- import: "./dist/canvas/astro.js"
69
- },
70
- "./canvas/astro-contract": {
71
- types: "./dist/canvas/astro-contract.d.ts",
72
- import: "./dist/canvas/astro-contract.js"
73
- },
74
- ".": {
75
- types: "./dist/index.d.ts",
76
- import: "./dist/index.js"
77
- },
78
- "./canvas": {
79
- types: "./dist/canvas/index.d.ts",
80
- import: "./dist/canvas/index.js"
81
- },
82
- "./canvas/svelte": {
83
- types: "./dist/canvas/svelte.d.ts",
84
- import: "./dist/canvas/svelte.js"
85
- },
86
- "./canvas/vue": {
87
- types: "./dist/canvas/vue.d.ts",
88
- import: "./dist/canvas/vue.js"
89
- },
90
- "./canvas/interact-projection": {
91
- types: "./dist/canvas/interact-projection.d.ts",
92
- import: "./dist/canvas/interact-projection.js"
93
- },
94
- "./canvas/parser": {
95
- types: "./dist/canvas/parser.d.ts",
96
- import: "./dist/canvas/parser.js"
97
- },
98
- "./canvas/editor": {
99
- types: "./dist/canvas/editor.d.ts",
100
- import: "./dist/canvas/editor.js"
101
- },
102
- "./assets": {
103
- types: "./dist/assets/index.d.ts",
104
- import: "./dist/assets/index.js"
105
- },
106
- "./assets/parser": {
107
- types: "./dist/assets/parser.d.ts",
108
- import: "./dist/assets/parser.js"
109
- },
110
- "./assets/editor": {
111
- types: "./dist/assets/editor.d.ts",
112
- import: "./dist/assets/editor.js"
113
- },
114
- "./nextjs": {
115
- types: "./dist/nextjs.d.ts",
116
- import: "./dist/nextjs.js",
117
- require: "./dist/nextjs.cjs"
118
- },
119
- "./nextjs/plugin": {
120
- types: "./dist/nextjs/plugin.d.ts",
121
- import: "./dist/nextjs/plugin.js"
122
- },
123
- "./nuxt": {
124
- types: "./dist/nuxt.d.ts",
125
- import: "./dist/nuxt.js"
126
- },
127
- "./expo": {
128
- types: "./dist/expo-babel-plugin.d.ts",
129
- import: "./dist/expo-babel-plugin.js",
130
- require: "./dist/expo-babel-plugin.cjs"
131
- },
132
- "./expo/plugin": {
133
- types: "./dist/expo/plugin.d.ts",
134
- import: "./dist/expo/plugin.js",
135
- require: "./dist/expo/plugin.cjs"
136
- },
137
- "./svelte": {
138
- types: "./dist/svelte.d.ts",
139
- import: "./dist/svelte.js"
140
- },
141
- "./vue": {
142
- types: "./dist/vue.d.ts",
143
- import: "./dist/vue.js"
144
- },
145
- "./astro/asset-preview-client": {
146
- types: "./dist/astro/asset-preview-client.d.ts",
147
- import: "./dist/astro/asset-preview-client.js"
148
- },
149
- "./flutter-preview-path": {
150
- types: "./dist/flutter-preview-path.d.ts",
151
- import: "./dist/flutter-preview-path.js"
152
- },
153
- "./canvas/flutter-preview": {
154
- types: "./dist/canvas/flutter-preview.d.ts",
155
- import: "./dist/canvas/flutter-preview.js"
156
- }
157
- },
158
- files: [
159
- "dist",
160
- "astro/client.d.ts"
161
- ],
162
- scripts: {
163
- clean: "rm -rf dist",
164
- build: "pnpm run clean && tsup",
165
- "build:if-missing": "test -f dist/index.js || pnpm run build",
166
- prepare: "pnpm run build",
167
- prepublishOnly: "pnpm build",
168
- demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
169
- "demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
170
- "demo:nuxt": "pnpm --filter @tempo-modules/tempo-sdk-nuxt-demo dev",
171
- test: "vitest run",
172
- "test:browser": "vitest run canvas-dependency-scan-browser.test.ts pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts flutter-storyboard-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts astro-integration.test.ts astro-storyboard-routing.test.ts astro-react-integration.test.ts astro-descriptor-browser.test.ts astro-packed.test.ts",
173
- "test:watch": "vitest",
174
- "test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
175
- "test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
176
- "test:nextjs:production": "vitest run nextjs-production.test.ts",
177
- "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"
178
- },
179
- dependencies: {
180
- "@rollup/pluginutils": "^5.1.0",
181
- "oxc-parser": "^0.110.0"
182
- },
183
- optionalDependencies: {
184
- "@astrojs/compiler-rs": "0.5.1"
185
- },
186
- peerDependencies: {
187
- astro: "^7.0.0",
188
- "@babel/core": "^7.0.0",
189
- h3: "^1.12.0",
190
- next: "^13 || ^14 || ^15 || ^16",
191
- nuxt: "^3.18.0 || ^4.0.0",
192
- react: "^18 || ^19",
193
- svelte: "^5.0.0",
194
- vite: "^5 || ^6 || ^7 || ^8",
195
- vue: "^3.3.0"
196
- },
197
- peerDependenciesMeta: {
198
- astro: {
199
- optional: true
200
- },
201
- react: {
202
- optional: true
203
- },
204
- "@babel/core": {
205
- optional: true
206
- },
207
- h3: {
208
- optional: true
209
- },
210
- next: {
211
- optional: true
212
- },
213
- nuxt: {
214
- optional: true
215
- },
216
- svelte: {
217
- optional: true
218
- },
219
- vite: {
220
- optional: true
221
- },
222
- vue: {
223
- optional: true
224
- }
225
- },
226
- devDependencies: {
227
- "@astrojs/react": "7.0.1",
228
- "@babel/core": "^7.29.0",
229
- "@babel/types": "^7.29.0",
230
- "@modules/annotation": "workspace:*",
231
- "@modules/astro-editor": "workspace:*",
232
- "@modules/file-parser": "workspace:*",
233
- "@modules/frame-pool": "workspace:*",
234
- "@modules/iframe-projection": "workspace:*",
235
- "@modules/svelte-editor": "workspace:*",
236
- "@modules/vue-editor": "workspace:*",
237
- "@nuxt/kit": "^4.6.2",
238
- "@types/babel__core": "^7.20.5",
239
- "@types/node": "^25.0.8",
240
- "@types/react": "catalog:",
241
- "@types/react-dom": "catalog:",
242
- "@vitejs/plugin-react": "catalog:",
243
- "@vitejs/plugin-vue": "6.0.10",
244
- astro: "7.3.8",
245
- h3: "^1.15.11",
246
- "magic-string": "^0.30.21",
247
- nuxt: "^4.6.2",
248
- playwright: "^1.58.2",
249
- "react-dom": "catalog:",
250
- "react-dom18": "npm:react-dom@18.3.1",
251
- react18: "npm:react@18.3.1",
252
- svelte: "5.56.9",
253
- tsup: "^8.5.1",
254
- typescript: "catalog:",
255
- vite: "catalog:",
256
- vitest: "catalog:",
257
- vue: "3.5.44"
258
- }
259
- };
260
-
261
- // release-channel.ts
262
- var TEMPO_SDK_CHANNEL = package_default.publishConfig.tag;
263
- function sdkChannelGeneration(channel) {
264
- if (typeof channel !== "string") return null;
265
- const match = /^sdk-v([1-9]\d*)-latest$/.exec(channel);
266
- return match ? Number(match[1]) : null;
267
- }
268
- if (sdkChannelGeneration(TEMPO_SDK_CHANNEL) === null) {
269
- throw new Error("tempo-sdk publishConfig.tag must be sdk-v<N>-latest");
270
- }
271
-
272
- // host-identity.ts
273
- var TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;
274
- var TEMPO_WORKSPACE_NONCE_ENV = "TEMPO_WORKSPACE_NONCE";
275
- var WORKSPACE_NONCE_RELATIVE_PATH = ".tempo/workspace-nonce";
276
- var MAX_WORKSPACE_NONCE_LENGTH = 128;
277
- function normalizeWorkspaceNonce(value) {
278
- const nonce = value?.trim() ?? "";
279
- return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH ? nonce : "";
280
- }
281
- function readTempoWorkspaceNonce(root = process.cwd()) {
282
- const fromEnvironment = normalizeWorkspaceNonce(
283
- process.env[TEMPO_WORKSPACE_NONCE_ENV]
284
- );
285
- if (fromEnvironment) return fromEnvironment;
286
- try {
287
- return normalizeWorkspaceNonce(
288
- (0, import_node_fs.readFileSync)((0, import_node_path.resolve)(root, WORKSPACE_NONCE_RELATIVE_PATH), "utf-8")
289
- );
290
- } catch {
291
- return "";
292
- }
293
- }
294
- function createTempoHostIdentity(framework, options = {}) {
295
- return {
296
- tempoHost: true,
297
- contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,
298
- workspaceNonce: readTempoWorkspaceNonce(options.root),
299
- sdkVersion: package_default.version,
300
- sdkChannel: TEMPO_SDK_CHANNEL,
301
- pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),
302
- framework,
303
- ...options.capabilities ? { capabilities: options.capabilities } : {}
304
- };
305
- }
306
-
307
- // nextjs.ts
308
- var import_meta = {};
309
- var TURBOPACK_RULE_KEY = "*.{tsx,jsx}";
310
- var requireFromHere = (0, import_node_module.createRequire)(
311
- typeof import_meta.url === "string" && import_meta.url.length > 0 ? import_meta.url : __filename
312
- );
313
- function resolveLoaderPath() {
314
- for (const candidate of ["./nextjs-loader.cjs", "./dist/nextjs-loader.cjs"]) {
315
- try {
316
- return requireFromHere.resolve(candidate);
317
- } catch {
318
- }
319
- }
320
- throw new Error(
321
- "tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. Run `pnpm build` in the tempo-sdk package to produce the dist/ output."
322
- );
323
- }
324
- function detectNextVersion() {
325
- try {
326
- const pkg = requireFromHere("next/package.json");
327
- const m = /^(\d+)\.(\d+)/.exec(pkg.version);
328
- if (!m) return null;
329
- return { major: Number(m[1]), minor: Number(m[2]) };
330
- } catch {
331
- return null;
332
- }
333
- }
334
- function useExperimentalTurbo(version) {
335
- if (!version) return false;
336
- if (version.major < 15) return true;
337
- if (version.major === 15 && version.minor < 3) return true;
338
- return false;
339
- }
340
- function shouldOmitTurbopack(version) {
341
- if (!version) return false;
342
- return version.major < 13;
343
- }
344
- function buildTurbopackRule(loaderPath, options) {
345
- const loaderOptions = {};
346
- if (options.computeAnnotatedPropsModule !== void 0) {
347
- loaderOptions.computeAnnotatedPropsModule = options.computeAnnotatedPropsModule;
348
- }
349
- if (options.autoInjectRootMeta !== void 0) {
350
- loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;
351
- }
352
- const condition = options.productionBuild ? { not: "foreign" } : { all: [{ not: "foreign" }, "development"] };
353
- return {
354
- condition,
355
- loaders: [{ loader: loaderPath, options: loaderOptions }]
356
- };
357
- }
358
- function mergeTurbopackRules(existing, newRule) {
359
- const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];
360
- let mergedRule;
361
- if (!existingRule) {
362
- mergedRule = newRule;
363
- } else if (Array.isArray(existingRule)) {
364
- mergedRule = [...existingRule, newRule];
365
- } else {
366
- mergedRule = [existingRule, newRule];
367
- }
368
- return {
369
- ...existing,
370
- rules: {
371
- ...existing?.rules,
372
- [TURBOPACK_RULE_KEY]: mergedRule
373
- }
374
- };
375
- }
376
- function buildWebpackHook(loaderPath, options, userWebpack) {
377
- const loaderOptions = {};
378
- if (options.computeAnnotatedPropsModule !== void 0) {
379
- loaderOptions.computeAnnotatedPropsModule = options.computeAnnotatedPropsModule;
380
- }
381
- if (options.autoInjectRootMeta !== void 0) {
382
- loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;
383
- }
384
- const allowProduction = options.productionBuild === true;
385
- return (configIn, context) => {
386
- var _a;
387
- const config = configIn;
388
- const ctx = context;
389
- if (ctx.dev || allowProduction) {
390
- config.module ?? (config.module = {});
391
- (_a = config.module).rules ?? (_a.rules = []);
392
- config.module.rules.push({
393
- test: /\.(tsx|jsx)$/,
394
- exclude: /node_modules/,
395
- enforce: "pre",
396
- use: [{ loader: loaderPath, options: loaderOptions }]
397
- });
398
- }
399
- if (typeof userWebpack === "function") {
400
- return userWebpack(config, context);
401
- }
402
- return config;
403
- };
404
- }
405
- var cachedTempoProjectRoot = null;
406
- function tempoProjectRoot() {
407
- if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;
408
- let dir = process.cwd();
409
- while (true) {
410
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.resolve)(dir, "package.json"))) break;
411
- const parent = (0, import_node_path2.dirname)(dir);
412
- if (parent === dir) break;
413
- dir = parent;
414
- }
415
- let canonical = dir;
416
- try {
417
- canonical = import_node_fs2.realpathSync.native(dir);
418
- } catch {
419
- }
420
- cachedTempoProjectRoot = canonical;
421
- return canonical;
422
- }
423
- function tempoHostIdentity() {
424
- return createTempoHostIdentity("nextjs");
425
- }
426
- function _resetTempoProjectRoot() {
427
- cachedTempoProjectRoot = null;
428
- }
429
- function tempoNextjsPlugin(pluginOptions = {}) {
430
- return (inputConfigArg) => {
431
- const inputConfig = inputConfigArg ?? {};
432
- if (!process.env.TEMPO) return inputConfig;
433
- const loaderPath = _internal.resolveLoaderPath();
434
- const version = _internal.detectNextVersion();
435
- const omitTurbopack = _internal.shouldOmitTurbopack(version);
436
- const useExperimental = _internal.useExperimentalTurbo(version);
437
- const newRule = buildTurbopackRule(loaderPath, pluginOptions);
438
- const existingTurbo = useExperimental ? inputConfig.experimental?.turbo : inputConfig.turbopack;
439
- const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);
440
- const webpackHook = buildWebpackHook(
441
- loaderPath,
442
- pluginOptions,
443
- inputConfig.webpack ?? null
444
- );
445
- const next = {
446
- ...inputConfig,
447
- webpack: webpackHook
448
- };
449
- const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;
450
- if (distDirOverride) {
451
- next.distDir = distDirOverride;
452
- }
453
- if (!omitTurbopack) {
454
- if (useExperimental) {
455
- next.experimental = {
456
- ...inputConfig.experimental,
457
- turbo: mergedTurbo
458
- };
459
- } else {
460
- next.turbopack = mergedTurbo;
461
- }
462
- }
463
- return next;
464
- };
465
- }
466
- var nextjs_default = tempoNextjsPlugin;
467
- var _internal = {
468
- buildTurbopackRule,
469
- mergeTurbopackRules,
470
- buildWebpackHook,
471
- detectNextVersion,
472
- useExperimentalTurbo,
473
- shouldOmitTurbopack,
474
- resolveLoaderPath
475
- };
476
- // Annotate the CommonJS export names for ESM import in node:
477
- 0 && (module.exports = {
478
- _internal,
479
- _resetTempoProjectRoot,
480
- tempoHostIdentity,
481
- tempoNextjsPlugin,
482
- tempoProjectRoot
483
- });
1
+ "use strict";var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var i=(e,t)=>x(e,"name",{value:t,configurable:!0});var J=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},Y=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of q(t))!B.call(e,r)&&r!==n&&x(e,r,{get:()=>t[r],enumerable:!(o=U(t,r))||o.enumerable});return e};var G=e=>Y(x({},"__esModule",{value:!0}),e);var ft={};J(ft,{_internal:()=>f,_resetTempoProjectRoot:()=>dt,default:()=>lt,tempoHostIdentity:()=>mt,tempoNextjsPlugin:()=>K,tempoProjectRoot:()=>pt});module.exports=G(ft);var R=require("crypto"),l=require("fs"),y=require("module"),s=require("path"),w=require("url");var A=require("fs"),O=require("path");var C={version:"0.0.102"};var I="latest";var z=1,Q="TEMPO_WORKSPACE_NONCE";var Z=".tempo/workspace-nonce",tt=128;function P(e){let t=e?.trim()??"";return t.length>0&&t.length<=tt?t:""}i(P,"normalizeWorkspaceNonce");function et(e=process.cwd()){let t=P(process.env[Q]);if(t)return t;try{return P((0,A.readFileSync)((0,O.resolve)(e,Z),"utf-8"))}catch{return""}}i(et,"readTempoWorkspaceNonce");function M(e,t={}){return{tempoHost:!0,contractVersion:z,workspaceNonce:et(t.root),sdkVersion:C.version,sdkChannel:I,tempoRuntimeContract:1,pluginActive:t.pluginActive??!!process.env.TEMPO,framework:e,...t.capabilities?{capabilities:t.capabilities}:{}}}i(M,"createTempoHostIdentity");var $={};var v=1,N="TEMPO_SDK_RUNTIME_PATH",ot=typeof $.url=="string"?$.url:(0,w.pathToFileURL)(__filename).href,yt=(0,y.createRequire)(ot);var S=new Map;function p(e){return new Error(`Tempo SDK runtime unavailable: ${e}. Start this project with an updated Tempo host, or provision its matching runtime and set ${N}.`)}i(p,"runtimeError");function rt(){let e=process.env[N];if(!e||!(0,s.isAbsolute)(e))throw p("an absolute runtime directory was not supplied");let t=(0,s.resolve)(e),n;try{n=JSON.parse((0,l.readFileSync)((0,s.resolve)(t,"runtime.json"),"utf8"))}catch{throw p("runtime.json could not be read")}if(n?.tempoRuntimeContract!==v)throw p(`contract ${n?.tempoRuntimeContract} does not match ${v}`);return{root:t,manifest:n}}i(rt,"readRuntimeManifest");function H(e,t,n){if(!n||typeof n.file!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw p(`the ${t} entry is missing or invalid`);let o=(0,s.resolve)(e,n.file),r=(0,s.relative)(e,o);if((0,s.isAbsolute)(r)||r===".."||r.startsWith(`..${s.sep}`))throw p(`the ${t} entry escapes its runtime directory`);let u;try{let a=(0,s.relative)((0,l.realpathSync)(e),(0,l.realpathSync)(o));if((0,s.isAbsolute)(a)||a===".."||a.startsWith(`..${s.sep}`))throw p(`the ${t} entry escapes its runtime directory`);u=(0,l.readFileSync)(o)}catch{throw p(`the ${t} artifact could not be read`)}if((0,R.createHash)("sha256").update(u).digest("hex")!==n.sha256)throw p(`the ${t} artifact failed its integrity check`);return o}i(H,"verifyArtifact");function E(e){let t=process.env[N];if(!t||!(0,s.isAbsolute)(t))throw p("an absolute runtime directory was not supplied");let n=(0,s.resolve)(t),o=`${n}\0${e}`,r=S.get(o);if(r)return r;let{manifest:u}=rt(),a=u.node?.[e],c=H(n,e,a),d=u.browser,m=d&&H(n,"browser",d),g={sha256:d?(0,R.createHash)("sha256").update(a.sha256).update(d.sha256).digest("hex"):a.sha256,dependencies:[(0,s.resolve)(n,"runtime.json"),c,...m?[m]:[]]};return S.set(o,g),g}i(E,"nodeRuntimeIdentity");var h=require("fs"),L=require("module"),b=require("path");var _={};var it=["*.{tsx,jsx}","*.{js,mjs}"],V=(0,L.createRequire)(typeof _.url=="string"&&_.url.length>0?_.url:__filename);function st(){for(let e of["./nextjs-loader.cjs","./dist/nextjs-loader.cjs"])try{return V.resolve(e)}catch{}throw new Error("tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. Run `pnpm build` in the tempo-sdk package to produce the dist/ output.")}i(st,"resolveLoaderPath");function at(){try{let e=V("next/package.json"),t=/^(\d+)\.(\d+)/.exec(e.version);return t?{major:Number(t[1]),minor:Number(t[2])}:null}catch{return null}}i(at,"detectNextVersion");function ct(e){return e?e.major<15||e.major===15&&e.minor<3:!1}i(ct,"useExperimentalTurbo");function ut(e){return e?e.major<13:!1}i(ut,"shouldOmitTurbopack");function D(e,t){let n={tempoRuntimeHash:E("nextjs-loader").sha256};return t.computeAnnotatedPropsModule!==void 0&&(n.computeAnnotatedPropsModule=t.computeAnnotatedPropsModule),t.autoInjectRootMeta!==void 0&&(n.autoInjectRootMeta=t.autoInjectRootMeta),{condition:t.productionBuild?{not:"foreign"}:{all:[{not:"foreign"},"development"]},loaders:[{loader:e,options:n}]}}i(D,"buildTurbopackRule");function F(e,t){let n={...e?.rules};for(let o of it){let r=n[o];r?Array.isArray(r)?n[o]=[...r,t]:n[o]=[r,t]:n[o]=t}return{...e,rules:n}}i(F,"mergeTurbopackRules");function W(e,t,n){let o={tempoRuntimeHash:E("nextjs-loader").sha256};t.computeAnnotatedPropsModule!==void 0&&(o.computeAnnotatedPropsModule=t.computeAnnotatedPropsModule),t.autoInjectRootMeta!==void 0&&(o.autoInjectRootMeta=t.autoInjectRootMeta);let r=t.productionBuild===!0;return(u,a)=>{var m;let c=u;return(a.dev||r)&&(c.module??(c.module={}),(m=c.module).rules??(m.rules=[]),c.module.rules.push({test:/\.(tsx|jsx|m?js)$/,exclude:/node_modules/,enforce:"pre",use:[{loader:e,options:o}]})),typeof n=="function"?n(c,a):c}}i(W,"buildWebpackHook");var T=null;function pt(){if(T!==null)return T;let e=process.cwd();for(;!(0,h.existsSync)((0,b.resolve)(e,"package.json"));){let n=(0,b.dirname)(e);if(n===e)break;e=n}let t=e;try{t=h.realpathSync.native(e)}catch{}return T=t,t}i(pt,"tempoProjectRoot");function mt(){return M("nextjs")}i(mt,"tempoHostIdentity");function dt(){T=null}i(dt,"_resetTempoProjectRoot");function K(e={}){return t=>{let n=t??{};if(!process.env.TEMPO)return n;let o=f.resolveLoaderPath(),r=f.detectNextVersion(),u=f.shouldOmitTurbopack(r),a=f.useExperimentalTurbo(r),c=D(o,e),d=a?n.experimental?.turbo:n.turbopack,m=F(d,c),g=W(o,e,n.webpack??null),k={...n,webpack:g},j=process.env.TEMPO_NEXT_DIST_DIR;return j&&(k.distDir=j),u||(a?k.experimental={...n.experimental,turbo:m}:k.turbopack=m),k}}i(K,"tempoNextjsPlugin");var lt=K,f={buildTurbopackRule:D,mergeTurbopackRules:F,buildWebpackHook:W,detectNextVersion:at,useExperimentalTurbo:ct,shouldOmitTurbopack:ut,resolveLoaderPath:st};0&&(module.exports={_internal,_resetTempoProjectRoot,tempoHostIdentity,tempoNextjsPlugin,tempoProjectRoot});
484
2
  module.exports = Object.assign(module.exports.default, module.exports);
485
- //# sourceMappingURL=nextjs.cjs.map
package/dist/nextjs.d.cts CHANGED
@@ -2,23 +2,15 @@ import { JSXElement } from 'oxc-parser';
2
2
 
3
3
  interface ElementInfo {
4
4
  element: JSXElement;
5
- /** e.g. "div", "Button", "Foo.Bar" */
6
5
  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
6
  parentType?: string | null;
10
- /** An unconditional element inside a braced JSX child, including type-only wrappers. */
11
7
  isStaticJsxChild?: boolean;
12
8
  }
13
- /** Supported prop value types. `undefined` values are skipped. */
14
9
  type PropValue = string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) | object;
15
10
 
16
- type TempoHostFramework = "vite" | "nextjs" | "nuxt" | "astro";
17
- /** Optional features a host's served identity vouches for. */
11
+ type TempoHostFramework = "vite" | "nextjs" | "nuxt" | "astro" | "expo";
18
12
  interface TempoHostIdentityCapabilities {
19
- /** 1 when the server renders Astro components for the canvas. */
20
13
  astroComponents?: number;
21
- /** 1 when `tempoVuePlugin()` annotates this Vite server's `.vue` files. */
22
14
  vueSourceAnnotation?: number;
23
15
  }
24
16
  interface TempoHostIdentity<Framework extends TempoHostFramework = TempoHostFramework> {
@@ -27,43 +19,18 @@ interface TempoHostIdentity<Framework extends TempoHostFramework = TempoHostFram
27
19
  workspaceNonce: string;
28
20
  sdkVersion: string;
29
21
  sdkChannel: string;
22
+ tempoRuntimeContract?: number;
30
23
  pluginActive: boolean;
31
24
  framework: Framework;
32
25
  capabilities?: TempoHostIdentityCapabilities;
33
26
  }
34
27
 
35
- /**
36
- * Next.js plugin that registers the tempo-annotate loader for Webpack and
37
- * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order
38
- * function that takes plugin options, returns a function that takes the user's
39
- * `next.config`, and returns a new config with the plugin's loader rules
40
- * merged in.
41
- *
42
- * See SPEC_NEXTJS.md (in this directory) for the full design rationale.
43
- *
44
- * @example
45
- * ```js
46
- * // next.config.js
47
- * const tempoNextjsPlugin = require("tempo-sdk/nextjs");
48
- * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });
49
- * ```
50
- */
51
-
52
28
  type ComputeAnnotatedProps = (info: ElementInfo, filepath: string, modifiedtsMs: number) => Record<string, PropValue>;
53
29
  interface TempoNextjsOptions {
54
- /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`
55
- * function. Resolved relative to the project root (CWD where the user
56
- * invokes `next dev` / `next build`). Turbopack does not allow function-
57
- * valued loader options, so this must be a path. */
58
30
  computeAnnotatedPropsModule?: string;
59
- /** File patterns to include. Default: `["**\/*.tsx", "**\/*.jsx"]`. */
60
31
  include?: string | RegExp | Array<string | RegExp>;
61
- /** File patterns to exclude. Default: `["**\/node_modules\/**"]`. */
62
32
  exclude?: string | RegExp | Array<string | RegExp>;
63
- /** Auto-inject `<meta name="tempo-project-root">` into JSX `<head>`.
64
- * Default: `true`. */
65
33
  autoInjectRootMeta?: boolean;
66
- /** Run the loader during production builds too. Default: `false`. */
67
34
  productionBuild?: boolean;
68
35
  }
69
36
  interface TurbopackRule {
@@ -95,37 +62,14 @@ interface NextVersionInfo {
95
62
  minor: number;
96
63
  }
97
64
  declare function detectNextVersion(): NextVersionInfo | null;
98
- /** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */
99
65
  declare function useExperimentalTurbo(version: NextVersionInfo | null): boolean;
100
- /** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions
101
- * error on unknown config keys. */
102
66
  declare function shouldOmitTurbopack(version: NextVersionInfo | null): boolean;
103
67
  declare function buildTurbopackRule(loaderPath: string, options: TempoNextjsOptions): TurbopackRule;
104
68
  declare function mergeTurbopackRules(existing: TurbopackConfig | undefined, newRule: TurbopackRule): TurbopackConfig;
105
69
  declare function buildWebpackHook(loaderPath: string, options: TempoNextjsOptions, userWebpack: NextConfigLike["webpack"]): NonNullable<NextConfigLike["webpack"]>;
106
- /**
107
- * Returns the canonical project root that the Tempo loader uses to compute
108
- * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the
109
- * content of `<meta name="tempo-project-root">`, ensuring the manual meta tag
110
- * value matches what the loader produces.
111
- */
112
70
  declare function tempoProjectRoot(): string;
113
- /** Request-time identity for a Next route served by a Tempo-enabled host. */
114
71
  declare function tempoHostIdentity(): TempoHostIdentity<"nextjs">;
115
- /** Reset the cached project root. For tests only. */
116
72
  declare function _resetTempoProjectRoot(): void;
117
- /**
118
- * Higher-order function that wraps a Next.js config to register the
119
- * tempo-annotate loader with both Webpack and Turbopack. No-op when
120
- * `process.env.TEMPO` is not set.
121
- *
122
- * @example
123
- * ```js
124
- * // next.config.js
125
- * const tempoNextjsPlugin = require("tempo-sdk/nextjs");
126
- * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });
127
- * ```
128
- */
129
73
  declare function tempoNextjsPlugin(pluginOptions?: TempoNextjsOptions): (inputConfig?: NextConfigLike) => NextConfigLike;
130
74
 
131
75
  declare const _internal: {