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
@@ -1,1928 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // expo-babel-plugin.ts
31
- var expo_babel_plugin_exports = {};
32
- __export(expo_babel_plugin_exports, {
33
- default: () => tempoExpoBabelPlugin,
34
- tempoExpoBabelPlugin: () => tempoExpoBabelPlugin
35
- });
36
- module.exports = __toCommonJS(expo_babel_plugin_exports);
37
-
38
- // canvas-component-reference.ts
39
- var import_node_fs2 = require("fs");
40
- var import_node_path2 = require("path");
41
-
42
- // canvas/flutter-preview.ts
43
- function parseFlutterPreview(value) {
44
- const prefix = `preview ${JSON.stringify(value)}`;
45
- if (value.includes("\\"))
46
- return {
47
- error: `${prefix} uses a backslash; use "/" (paths in canvases are POSIX).`
48
- };
49
- const hash = value.lastIndexOf("#");
50
- if (hash < 0)
51
- return {
52
- error: `${prefix} needs "#<function>" after the file, e.g. "../../lib/cards.dart#productCard".`
53
- };
54
- const file = value.slice(0, hash);
55
- const functionName = value.slice(hash + 1);
56
- if (!file.startsWith("./") && !file.startsWith("../"))
57
- return {
58
- error: file.startsWith("lib/") ? `${prefix} is no longer relative to a Flutter app folder; write the path from this canvas file, starting with "./" or "../".` : `${prefix} must be a path relative to this canvas file and start with "./" or "../", like a relative import.`
59
- };
60
- if (!file.endsWith(".dart"))
61
- return { error: `${prefix} must name a .dart file.` };
62
- if (/[?#]/.test(file) || file.includes("//"))
63
- return {
64
- error: `${prefix} must not contain "?", "#", or empty path segments.`
65
- };
66
- if (!/^[A-Za-z$][A-Za-z0-9_$]*$/.test(functionName))
67
- return {
68
- error: `${prefix}: ${JSON.stringify(functionName)} is not a public Dart function name.`
69
- };
70
- return { file, functionName };
71
- }
72
- var FLUTTER_PREVIEW_KEY_ATTRIBUTE = "data-tempo-flutter-preview-key";
73
-
74
- // flutter-preview-path.ts
75
- var import_node_fs = require("fs");
76
- var import_node_path = __toESM(require("path"), 1);
77
- function canonicalPathAllowMissing(file) {
78
- const absolute = import_node_path.default.resolve(file);
79
- try {
80
- return import_node_fs.realpathSync.native(absolute);
81
- } catch (error) {
82
- const code = error.code;
83
- if (code !== "ENOENT" && code !== "ENOTDIR") throw error;
84
- let isLink = false;
85
- try {
86
- isLink = (0, import_node_fs.lstatSync)(absolute).isSymbolicLink();
87
- } catch (statError) {
88
- if (statError.code !== "ENOENT" && statError.code !== "ENOTDIR")
89
- throw statError;
90
- }
91
- if (isLink) throw error;
92
- const parent = import_node_path.default.dirname(absolute);
93
- if (parent === absolute) throw error;
94
- return import_node_path.default.join(
95
- canonicalPathAllowMissing(parent),
96
- import_node_path.default.basename(absolute)
97
- );
98
- }
99
- }
100
- function flutterPreviewKey(hostRoot, file, functionName) {
101
- return `${import_node_path.default.relative(canonicalPathAllowMissing(hostRoot), canonicalPathAllowMissing(file)).split(import_node_path.default.sep).join("/")}#${functionName}`;
102
- }
103
-
104
- // canvas/parser.ts
105
- var import_oxc_parser = require("oxc-parser");
106
-
107
- // canvas/storyboard-components.ts
108
- var STORYBOARD_SDK_COMPONENT_ROWS = {
109
- Storyboard: {
110
- importSource: "tempo-sdk/canvas",
111
- kind: "component",
112
- requiresComponentProp: true,
113
- allowsVrt: true,
114
- componentFileExtension: ".tsx"
115
- },
116
- SvelteStoryboard: {
117
- importSource: "tempo-sdk/canvas/svelte",
118
- kind: "component",
119
- uiFramework: "svelte",
120
- requiresComponentProp: true,
121
- allowsVrt: true,
122
- componentFileExtension: ".svelte"
123
- },
124
- VueStoryboard: {
125
- importSource: "tempo-sdk/canvas/vue",
126
- kind: "component",
127
- uiFramework: "vue",
128
- requiresComponentProp: true,
129
- allowsVrt: true,
130
- componentFileExtension: ".vue"
131
- },
132
- AstroStoryboard: {
133
- importSource: "tempo-sdk/canvas/astro",
134
- kind: "component",
135
- uiFramework: "astro",
136
- requiresComponentProp: true,
137
- allowsVrt: true,
138
- componentFileExtension: ".astro",
139
- componentImportQuery: "?tempo-component"
140
- },
141
- FlutterStoryboard: {
142
- importSource: "tempo-sdk/canvas",
143
- kind: "component",
144
- requiresComponentProp: false,
145
- allowsVrt: true
146
- },
147
- RouteStoryboard: {
148
- importSource: "tempo-sdk/canvas",
149
- kind: "route",
150
- requiresComponentProp: false,
151
- allowsVrt: false
152
- },
153
- HtmlStoryboard: {
154
- importSource: "tempo-sdk/canvas",
155
- kind: "html",
156
- requiresComponentProp: false,
157
- allowsVrt: true
158
- },
159
- LegacyStoryboardV1: {
160
- importSource: "tempo-sdk/canvas",
161
- kind: "component",
162
- requiresComponentProp: false,
163
- allowsVrt: false
164
- }
165
- };
166
- var STORYBOARD_SDK_COMPONENTS = STORYBOARD_SDK_COMPONENT_ROWS;
167
- var STORYBOARD_SDK_COMPONENT_NAMES = Object.keys(
168
- STORYBOARD_SDK_COMPONENTS
169
- );
170
-
171
- // canvas/parser.ts
172
- var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set([
173
- "tempo-sdk/canvas",
174
- ...STORYBOARD_SDK_COMPONENT_NAMES.map(
175
- (component) => STORYBOARD_SDK_COMPONENTS[component].importSource
176
- )
177
- ]);
178
- var SDK_COMPONENTS = /* @__PURE__ */ new Set([
179
- "Canvas",
180
- ...STORYBOARD_SDK_COMPONENT_NAMES
181
- ]);
182
- var CANVAS_CHILDREN_ERROR = `<Canvas> children must be ${formatAlternatives(
183
- STORYBOARD_SDK_COMPONENT_NAMES.map((component) => `<${component}>`)
184
- )} declarations`;
185
- var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
186
- "Canvas",
187
- "CanvasContext",
188
- "getCanvasStoryboardRenderId",
189
- "CanvasHost",
190
- "buildRenderContentFiberSelector",
191
- "buildRenderContentSelector",
192
- "buildRenderSelector",
193
- "captureStoryboardCombined",
194
- "captureStoryboardHtml",
195
- "captureStoryboardImage",
196
- "stripRenderContentWrapperAttributes",
197
- "stripRenderContentWrapperFromCombinedCapture",
198
- "watchStoryboardCombined",
199
- "getCanvasHostRuntime",
200
- "getOptionalCanvasHostRuntime",
201
- "useActiveState",
202
- "FlutterStoryboard",
203
- "HtmlStoryboard",
204
- "LegacyStoryboardV1",
205
- "RouteStoryboard",
206
- "Storyboard",
207
- "StoryboardSlot"
208
- ]);
209
- var DEFAULT_LAYOUT = {
210
- x: 0,
211
- y: 0
212
- };
213
- var DEFAULT_VIEWPORT_LAYOUT = {
214
- ...DEFAULT_LAYOUT,
215
- width: 600,
216
- height: 400
217
- };
218
- var NO_CANVAS_DECLARATION_ERROR = "No <Canvas> declaration found in canvas file";
219
- function parseCanvasFile(filePath, source) {
220
- const errors = [];
221
- let program;
222
- try {
223
- const result = (0, import_oxc_parser.parseSync)(filePath, source);
224
- program = result.program;
225
- for (const error of result.errors ?? []) {
226
- errors.push({
227
- message: error.message ?? "Unable to parse canvas source",
228
- span: toSpan(error) ?? toSpan(error?.labels?.[0]),
229
- kind: "structural"
230
- });
231
- }
232
- } catch (error) {
233
- return {
234
- filePath,
235
- pageName: fallbackPageName(filePath),
236
- imports: [],
237
- misimportedSdkCanvasImports: [],
238
- storyboards: [],
239
- errors: [
240
- {
241
- message: error instanceof Error ? error.message : "Unable to parse canvas source",
242
- kind: "structural"
243
- }
244
- ]
245
- };
246
- }
247
- const imports = readImports(program);
248
- const misimportedSdkCanvasImports = readMisimportedSdkCanvasImports(program);
249
- const { legacyObjects, stringBindings: objectStringBindings } = readObjectExpressionBindings(program, imports, source);
250
- let canvasElement = null;
251
- const allStoryboardElements = [];
252
- walk(program, (node) => {
253
- if (node.type !== "JSXElement") return;
254
- const component = resolveSdkComponent(node.openingElement?.name, imports);
255
- const namespaceMisimport = resolveMisimportedNamespaceSdkComponent(
256
- node.openingElement?.name,
257
- imports,
258
- misimportedSdkCanvasImports
259
- );
260
- if (namespaceMisimport) {
261
- misimportedSdkCanvasImports.add(namespaceMisimport);
262
- }
263
- if (component === "Canvas") {
264
- if (!canvasElement) {
265
- canvasElement = node;
266
- } else {
267
- errors.push({
268
- message: "Canvas file must declare exactly one <Canvas> element",
269
- span: toSpan(node),
270
- kind: "structural"
271
- });
272
- }
273
- return;
274
- }
275
- if (isStoryboardSdkComponent(component)) {
276
- allStoryboardElements.push({ element: node, component });
277
- }
278
- });
279
- const directStoryboardElements = canvasElement ? readDirectCanvasStoryboardElements(canvasElement, imports) : [];
280
- const directStoryboardElementSet = new Set(
281
- directStoryboardElements.map((item) => item.element)
282
- );
283
- const storyboards = directStoryboardElements.map(
284
- (item) => readStoryboard(
285
- item.element,
286
- item.component,
287
- imports,
288
- legacyObjects,
289
- source,
290
- errors
291
- )
292
- );
293
- for (const item of allStoryboardElements) {
294
- if (directStoryboardElementSet.has(item.element)) continue;
295
- errors.push({
296
- message: `<${item.component}> declarations must be direct children of the <Canvas> element`,
297
- span: toSpan(item.element),
298
- kind: "structural"
299
- });
300
- }
301
- reportDuplicateStoryboardIds(storyboards, errors);
302
- if (!canvasElement) {
303
- if (misimportedSdkCanvasImports.all.length > 0) {
304
- for (const entry of misimportedSdkCanvasImports.all) {
305
- errors.push({
306
- message: misimportedSdkCanvasImportMessage(entry),
307
- span: entry.sourceSpan,
308
- kind: "structural"
309
- });
310
- }
311
- } else {
312
- errors.push({
313
- message: NO_CANVAS_DECLARATION_ERROR,
314
- kind: "structural"
315
- });
316
- }
317
- } else {
318
- errors.push(...validateCanvasChildren(canvasElement, imports));
319
- }
320
- const openingElement = canvasElement?.openingElement;
321
- const name = readResolvableStringAttribute(
322
- openingElement,
323
- "name",
324
- objectStringBindings
325
- );
326
- const path2 = readStringAttribute(openingElement, "path");
327
- const backgroundColor = readResolvableStringAttribute(
328
- openingElement,
329
- "backgroundColor",
330
- objectStringBindings
331
- ) ?? readResolvableStringAttribute(
332
- openingElement,
333
- "background",
334
- objectStringBindings
335
- );
336
- if (openingElement && !name) {
337
- errors.push({
338
- message: '<Canvas> must include a literal "name" prop',
339
- span: toSpan(openingElement),
340
- kind: "degraded"
341
- });
342
- }
343
- return {
344
- filePath,
345
- canvasPath: path2?.value,
346
- pageName: name?.value ?? fallbackPageName(filePath),
347
- backgroundColor: backgroundColor?.value,
348
- canvasElementSpan: toSpan(canvasElement),
349
- canvasOpeningElementSpan: toSpan(openingElement),
350
- canvasChildrenInsertionOffset: typeof canvasElement?.closingElement?.start === "number" ? canvasElement.closingElement.start : void 0,
351
- nameSpan: name?.valueSpan,
352
- nameAttributeSpan: name?.attributeSpan,
353
- pathSpan: path2?.valueSpan,
354
- pathAttributeSpan: path2?.attributeSpan,
355
- backgroundColorSpan: backgroundColor?.valueSpan,
356
- backgroundColorAttributeSpan: backgroundColor?.attributeSpan,
357
- imports: imports.all,
358
- misimportedSdkCanvasImports: misimportedSdkCanvasImports.all,
359
- storyboards,
360
- errors
361
- };
362
- }
363
- function misimportedSdkCanvasImportMessage(entry) {
364
- return `Tempo canvas components must be imported from "tempo-sdk/canvas" \u2014 found import of ${entry.importedNames.join(", ")} from "${entry.source}"`;
365
- }
366
- function readMisimportedSdkCanvasImports(program) {
367
- const all = [];
368
- const byDeclarationKey = /* @__PURE__ */ new Map();
369
- const namespaceCandidatesByLocalName = /* @__PURE__ */ new Map();
370
- const add = (entry) => {
371
- const key = spanKey(entry.sourceSpan);
372
- if (byDeclarationKey.has(key)) return;
373
- byDeclarationKey.set(key, entry);
374
- all.push(entry);
375
- };
376
- for (const statement of program?.body ?? []) {
377
- if (statement?.type !== "ImportDeclaration" || typeof statement.source?.value !== "string" || !isWrongTempoSdkCanvasImportSource(statement.source.value) || statement.importKind === "type") {
378
- continue;
379
- }
380
- const source = statement.source.value;
381
- const sourceSpan = toSpan(statement.source);
382
- if (!sourceSpan) continue;
383
- const valueSpecifiers = (statement.specifiers ?? []).filter(
384
- (specifier) => specifier?.importKind !== "type"
385
- );
386
- const importedNames = valueSpecifiers.map(readImportedName);
387
- const entry = {
388
- source,
389
- sourceSpan,
390
- importedNames,
391
- rewritable: valueSpecifiers.length > 0 && valueSpecifiers.every(
392
- (specifier) => specifier?.type === "ImportSpecifier" && SDK_CANVAS_VALUE_EXPORTS.has(readImportedName(specifier))
393
- )
394
- };
395
- const hasMisimportedNamedSdkComponent = valueSpecifiers.some(
396
- (specifier) => specifier?.type === "ImportSpecifier" && SDK_COMPONENTS.has(readImportedName(specifier))
397
- );
398
- if (hasMisimportedNamedSdkComponent) {
399
- add(entry);
400
- }
401
- for (const specifier of valueSpecifiers) {
402
- if (specifier?.type !== "ImportNamespaceSpecifier") continue;
403
- const localName = specifier.local?.name;
404
- if (typeof localName === "string") {
405
- namespaceCandidatesByLocalName.set(localName, entry);
406
- }
407
- }
408
- }
409
- return { all, byDeclarationKey, namespaceCandidatesByLocalName, add };
410
- }
411
- function readImports(program) {
412
- const all = [];
413
- const byLocalName = /* @__PURE__ */ new Map();
414
- const sdkLocalNames = /* @__PURE__ */ new Map();
415
- const sdkNamespaces = /* @__PURE__ */ new Set();
416
- for (const statement of program?.body ?? []) {
417
- if (statement?.type !== "ImportDeclaration" || typeof statement.source?.value !== "string") {
418
- continue;
419
- }
420
- const source = statement.source.value;
421
- const isSdkImport = isSdkImportSource(source);
422
- for (const specifier of statement.specifiers ?? []) {
423
- const localName = specifier.local?.name;
424
- if (typeof localName !== "string") continue;
425
- const importedName = readImportedName(specifier);
426
- const imported = {
427
- localName,
428
- source,
429
- importedName,
430
- kind: readImportKind(specifier),
431
- importKind: specifier.importKind === "type" ? "type" : "value",
432
- span: toSpan(specifier) ?? toSpan(statement) ?? { start: 0, end: 0 },
433
- declarationSpan: toSpan(statement) ?? { start: 0, end: 0 },
434
- specifierCount: statement.specifiers?.length ?? 0,
435
- namedSpecifierCount: (statement.specifiers ?? []).filter(
436
- (item) => item?.type === "ImportSpecifier"
437
- ).length,
438
- hasDefaultSpecifier: (statement.specifiers ?? []).some(
439
- (item) => item?.type === "ImportDefaultSpecifier"
440
- ),
441
- hasNamespaceSpecifier: (statement.specifiers ?? []).some(
442
- (item) => item?.type === "ImportNamespaceSpecifier"
443
- )
444
- };
445
- all.push(imported);
446
- byLocalName.set(localName, imported);
447
- if (!isSdkImport) continue;
448
- if (specifier.type === "ImportNamespaceSpecifier") {
449
- sdkNamespaces.add(localName);
450
- continue;
451
- }
452
- if (SDK_COMPONENTS.has(importedName)) {
453
- sdkLocalNames.set(localName, importedName);
454
- }
455
- }
456
- }
457
- return { all, byLocalName, sdkLocalNames, sdkNamespaces };
458
- }
459
- function readObjectExpressionBindings(program, imports, source) {
460
- const legacyObjects = /* @__PURE__ */ new Map();
461
- const stringBindings = /* @__PURE__ */ new Map();
462
- for (const node of readTopLevelVariableDeclarators(program)) {
463
- if (node.id?.type !== "Identifier") {
464
- continue;
465
- }
466
- const objectExpression = unwrapTsExpression(node.init);
467
- if (objectExpression?.type !== "ObjectExpression") continue;
468
- const bindingName = node.id.name;
469
- legacyObjects.set(
470
- bindingName,
471
- readLegacyStoryboardObject(
472
- bindingName,
473
- objectExpression,
474
- imports,
475
- source
476
- )
477
- );
478
- const stringProperties = readObjectStringProperties(objectExpression);
479
- if (stringProperties.size > 0) {
480
- stringBindings.set(bindingName, stringProperties);
481
- }
482
- }
483
- return { legacyObjects, stringBindings };
484
- }
485
- function readTopLevelVariableDeclarators(program) {
486
- const declarators = [];
487
- for (const statement of program?.body ?? []) {
488
- const declaration = statement?.type === "VariableDeclaration" ? statement : statement?.type === "ExportNamedDeclaration" && statement.declaration?.type === "VariableDeclaration" ? statement.declaration : null;
489
- if (!declaration) continue;
490
- declarators.push(...declaration.declarations ?? []);
491
- }
492
- return declarators;
493
- }
494
- function readLegacyStoryboardObject(bindingName, objectExpression, imports, source) {
495
- const errors = [];
496
- const nameProperty = getObjectProperty(objectExpression, "name");
497
- const name = nameProperty ? readStringLiteralValue(nameProperty.value) : null;
498
- const layoutProperty = getObjectProperty(objectExpression, "layout");
499
- const layout = layoutProperty ? readLayoutExpression(layoutProperty.value, "LegacyStoryboardV1") : {
500
- value: DEFAULT_LAYOUT,
501
- errors: [
502
- {
503
- message: '<LegacyStoryboardV1> storyboard object must include a literal "layout" object',
504
- span: toSpan(objectExpression),
505
- kind: "degraded"
506
- }
507
- ]
508
- };
509
- const renderProperty = getObjectProperty(objectExpression, "render");
510
- const component = readRenderComponentReference(
511
- renderProperty?.value,
512
- imports,
513
- source
514
- );
515
- if (nameProperty && !name) {
516
- errors.push({
517
- message: "<LegacyStoryboardV1> storyboard.name must be a string literal when set",
518
- span: toSpan(nameProperty),
519
- kind: "degraded"
520
- });
521
- }
522
- errors.push(...layout.errors);
523
- return {
524
- bindingName,
525
- displayName: name?.value,
526
- component: component ?? void 0,
527
- objectSpan: toSpan(objectExpression),
528
- objectClose: readLayoutClose(objectExpression),
529
- nameSpan: name?.span,
530
- namePropertySpan: toSpan(nameProperty),
531
- layoutPropertySpan: toSpan(layoutProperty),
532
- layout: layout.value,
533
- layoutSpans: layout.spans,
534
- errors
535
- };
536
- }
537
- function readObjectStringProperties(objectExpression) {
538
- const properties = /* @__PURE__ */ new Map();
539
- for (const property of objectExpression.properties ?? []) {
540
- if (property?.type !== "Property" || property.computed) continue;
541
- const propertyName = readPropertyKeyName(property.key);
542
- const value = readStringLiteralValue(property.value);
543
- if (!propertyName || !value) continue;
544
- properties.set(propertyName, value);
545
- }
546
- return properties;
547
- }
548
- function readStoryboard(element, component, imports, legacyObjects, source, globalErrors) {
549
- const openingElement = element.openingElement;
550
- const errors = [];
551
- const id = readStringAttribute(openingElement, "id");
552
- const name = readStringAttribute(openingElement, "name");
553
- const legacyReference = component === "LegacyStoryboardV1" ? readExpressionReference(openingElement, "storyboard", source) : void 0;
554
- const legacyObject = legacyReference?.expression && isIdentifierExpression(legacyReference.expression) ? legacyObjects.get(legacyReference.expression) : void 0;
555
- const layout = component === "LegacyStoryboardV1" ? {
556
- value: legacyObject?.layout ?? DEFAULT_LAYOUT,
557
- spans: legacyObject?.layoutSpans,
558
- attributeSpan: void 0,
559
- errors: legacyObject?.errors ?? (legacyReference ? [
560
- {
561
- message: "<LegacyStoryboardV1> storyboard prop must reference a same-file object literal",
562
- span: legacyReference.span,
563
- kind: "degraded"
564
- }
565
- ] : [
566
- {
567
- message: '<LegacyStoryboardV1> must include a "storyboard" expression prop',
568
- span: toSpan(openingElement),
569
- kind: "degraded"
570
- }
571
- ])
572
- } : readLayout(openingElement, component);
573
- const spec = STORYBOARD_SDK_COMPONENTS[component];
574
- if (!id) {
575
- errors.push({
576
- message: `<${component}> must include a literal "id" prop`,
577
- span: toSpan(openingElement),
578
- kind: "structural"
579
- });
580
- }
581
- if (layout.errors.length > 0) {
582
- errors.push(...layout.errors);
583
- }
584
- const storyboard = {
585
- storyboardKey: id?.value ?? "",
586
- displayName: name?.value ?? legacyObject?.displayName,
587
- kind: spec.kind,
588
- ...spec.uiFramework ? { componentFramework: spec.uiFramework } : {},
589
- ...spec.uiFramework === "svelte" ? { uiFramework: spec.uiFramework } : spec.uiFramework === "astro" ? { runtimeFramework: spec.uiFramework } : {},
590
- layout: layout.value,
591
- editable: Boolean(id) && layout.errors.length === 0,
592
- jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
593
- openingElementSpan: toSpan(openingElement),
594
- idSpan: id?.valueSpan,
595
- idAttributeSpan: id?.attributeSpan,
596
- nameSpan: name?.valueSpan ?? legacyObject?.nameSpan,
597
- nameAttributeSpan: name?.attributeSpan ?? legacyObject?.namePropertySpan,
598
- layoutAttributeSpan: layout.attributeSpan,
599
- layoutSpans: layout.spans,
600
- props: readExpressionReference(openingElement, "props", source),
601
- component: legacyObject?.component,
602
- legacyV1: legacyReference ? {
603
- storyboard: legacyReference,
604
- objectName: legacyObject?.bindingName,
605
- objectSpan: legacyObject?.objectSpan,
606
- objectClose: legacyObject?.objectClose,
607
- namePropertySpan: legacyObject?.namePropertySpan,
608
- layoutPropertySpan: legacyObject?.layoutPropertySpan
609
- } : void 0,
610
- errors
611
- };
612
- if (spec.requiresComponentProp) {
613
- const componentReference = readComponentReference(
614
- openingElement,
615
- imports,
616
- source
617
- );
618
- if (componentReference) {
619
- storyboard.component = componentReference;
620
- } else {
621
- errors.push({
622
- message: `<${component}> must include a "component" expression prop`,
623
- span: toSpan(openingElement),
624
- kind: "degraded"
625
- });
626
- }
627
- }
628
- if (spec.allowsVrt) {
629
- const vrt = readVrt(openingElement, errors);
630
- if (vrt) {
631
- if (vrt.value) {
632
- storyboard.vrt = vrt.value;
633
- }
634
- storyboard.vrtAttributeSpan = vrt.attributeSpan;
635
- }
636
- }
637
- if (component === "RouteStoryboard") {
638
- const route = readStringAttribute(openingElement, "route");
639
- if (route) {
640
- storyboard.route = route.value;
641
- storyboard.routeSpan = route.valueSpan;
642
- storyboard.routeAttributeSpan = route.attributeSpan;
643
- } else {
644
- errors.push({
645
- message: '<RouteStoryboard> must include a literal "route" prop',
646
- span: toSpan(openingElement),
647
- kind: "degraded"
648
- });
649
- }
650
- }
651
- if (component === "HtmlStoryboard") {
652
- const filepath = readStringAttribute(openingElement, "filepath");
653
- const src = readStringAttribute(openingElement, "src");
654
- storyboard.filepath = filepath?.value.trim() ? filepath.value : void 0;
655
- storyboard.filepathSpan = filepath?.valueSpan;
656
- storyboard.filepathAttributeSpan = filepath?.attributeSpan;
657
- storyboard.src = src?.value;
658
- storyboard.srcSpan = src?.valueSpan;
659
- storyboard.srcAttributeSpan = src?.attributeSpan;
660
- if (!filepath?.value.trim() && !src?.value.trim()) {
661
- errors.push({
662
- message: '<HtmlStoryboard> must include a literal "filepath" or "src" prop',
663
- span: toSpan(openingElement),
664
- kind: "degraded"
665
- });
666
- }
667
- }
668
- if (component === "FlutterStoryboard") {
669
- const preview = readStringAttribute(openingElement, "preview");
670
- if (preview?.value.trim()) {
671
- storyboard.preview = preview.value;
672
- storyboard.previewSpan = preview.valueSpan;
673
- storyboard.previewAttributeSpan = preview.attributeSpan;
674
- const parsedPreview = parseFlutterPreview(preview.value);
675
- if ("error" in parsedPreview)
676
- errors.push({
677
- message: `flutter_preview_invalid: ${parsedPreview.error}`,
678
- span: preview.valueSpan,
679
- kind: "structural"
680
- });
681
- } else {
682
- errors.push({
683
- message: '<FlutterStoryboard> must include a literal "preview" prop naming a Flutter @Preview function, e.g. preview="../../lib/cards.dart#productCard"',
684
- span: toSpan(getAttribute(openingElement, "preview") ?? openingElement),
685
- kind: "structural"
686
- });
687
- }
688
- }
689
- globalErrors.push(...errors);
690
- return storyboard;
691
- }
692
- function readDirectCanvasStoryboardElements(canvasElement, imports) {
693
- const elements = [];
694
- for (const child of canvasElement.children ?? []) {
695
- if (child?.type !== "JSXElement") continue;
696
- const component = resolveSdkComponent(child.openingElement?.name, imports);
697
- if (isStoryboardSdkComponent(component)) {
698
- elements.push({ element: child, component });
699
- }
700
- }
701
- return elements;
702
- }
703
- function reportDuplicateStoryboardIds(storyboards, errors) {
704
- const byId = /* @__PURE__ */ new Map();
705
- for (const storyboard of storyboards) {
706
- if (!storyboard.storyboardKey) continue;
707
- const matching = byId.get(storyboard.storyboardKey);
708
- if (matching) {
709
- matching.push(storyboard);
710
- } else {
711
- byId.set(storyboard.storyboardKey, [storyboard]);
712
- }
713
- }
714
- for (const [storyboardKey, matching] of byId) {
715
- if (matching.length < 2) continue;
716
- errors.push({
717
- message: `Duplicate storyboard id "${storyboardKey}" (${matching.length} declarations) \u2014 storyboard ids must be unique`,
718
- span: matching[1]?.jsxElementSpan,
719
- kind: "structural"
720
- });
721
- }
722
- }
723
- function validateCanvasChildren(canvasElement, imports) {
724
- const errors = [];
725
- for (const child of canvasElement.children ?? []) {
726
- if (!child) continue;
727
- if (child.type === "JSXText") {
728
- if (typeof child.value === "string" && child.value.trim() === "") {
729
- continue;
730
- }
731
- }
732
- if (child.type === "JSXExpressionContainer") {
733
- if (child.expression?.type === "JSXEmptyExpression") {
734
- continue;
735
- }
736
- errors.push({
737
- message: "<Canvas> children must be static storyboard declarations, not expressions",
738
- span: toSpan(child),
739
- kind: "structural"
740
- });
741
- continue;
742
- }
743
- if (child.type === "JSXElement") {
744
- const component = resolveSdkComponent(
745
- child.openingElement?.name,
746
- imports
747
- );
748
- if (isStoryboardSdkComponent(component)) continue;
749
- const newerComponent = resolveNewerSdkStoryboardComponent(
750
- child.openingElement?.name,
751
- imports
752
- );
753
- if (newerComponent) {
754
- errors.push(newerSdkStoryboardError(child, newerComponent));
755
- continue;
756
- }
757
- }
758
- errors.push({
759
- message: CANVAS_CHILDREN_ERROR,
760
- span: toSpan(child),
761
- kind: "structural"
762
- });
763
- }
764
- return errors;
765
- }
766
- var SDK_CANVAS_SUBPATH = /(^|\/)tempo-sdk\/canvas(\/[^/]+)?$/;
767
- function resolveNewerSdkStoryboardComponent(nameNode, imports) {
768
- let importedName;
769
- let source;
770
- if (nameNode?.type === "JSXIdentifier") {
771
- const imported = imports.byLocalName.get(nameNode.name);
772
- if (imported?.kind !== "named") return null;
773
- importedName = imported.importedName;
774
- source = imported.source;
775
- } else if (nameNode?.type === "JSXMemberExpression" && nameNode.object?.type === "JSXIdentifier" && nameNode.property?.type === "JSXIdentifier") {
776
- const imported = imports.byLocalName.get(nameNode.object.name);
777
- if (imported?.kind !== "namespace") return null;
778
- importedName = nameNode.property.name;
779
- source = imported.source;
780
- } else {
781
- return null;
782
- }
783
- const fromSdkCanvas = SDK_CANVAS_SUBPATH.test(source);
784
- const namesStoryboard = importedName.endsWith("Storyboard");
785
- return fromSdkCanvas && namesStoryboard ? importedName : null;
786
- }
787
- function newerSdkStoryboardError(element, component) {
788
- const openingElement = element.openingElement;
789
- const storyboardKey = readStringAttribute(openingElement, "id")?.value;
790
- const vrt = readVrt(openingElement, [])?.value != null;
791
- const named = storyboardKey ? ` id="${storyboardKey}"` : "";
792
- return {
793
- message: `<${component}${named}> is a storyboard from a newer tempo-sdk than this reader supports`,
794
- span: toSpan(element),
795
- kind: "structural",
796
- newerSdkStoryboard: {
797
- component,
798
- ...storyboardKey ? { storyboardKey } : {},
799
- vrt
800
- }
801
- };
802
- }
803
- function readVrt(openingElement, errors) {
804
- const attribute = getAttribute(openingElement, "vrt");
805
- if (!attribute) return null;
806
- const attributeSpan = toSpan(attribute);
807
- if (attribute.value == null) {
808
- return { value: {}, attributeSpan };
809
- }
810
- const expression = unwrapTsExpression(
811
- unwrapAttributeExpression(attribute.value)
812
- );
813
- if (expression?.type === "Literal" && expression.value === true) {
814
- return { value: {}, attributeSpan };
815
- }
816
- if (expression?.type === "Literal" && expression.value === false) {
817
- return { value: null, attributeSpan };
818
- }
819
- if (expression?.type !== "ObjectExpression") {
820
- errors.push({
821
- message: "<Storyboard> vrt must be a boolean literal or an object literal ({ threshold?, skip?, ignore? })",
822
- span: toSpan(expression) ?? attributeSpan,
823
- kind: "degraded"
824
- });
825
- return { value: null, attributeSpan };
826
- }
827
- const value = {};
828
- for (const property of expression.properties ?? []) {
829
- if (property?.type !== "Property" || property.computed) {
830
- errors.push({
831
- message: "<Storyboard> vrt must contain only literal properties",
832
- span: toSpan(property ?? expression),
833
- kind: "degraded"
834
- });
835
- continue;
836
- }
837
- const key = readPropertyKeyName(property.key);
838
- if (key === "threshold") {
839
- const threshold = readNumberLiteral(property.value);
840
- if (threshold && threshold.value >= 0 && threshold.value <= 0.5) {
841
- value.threshold = threshold.value;
842
- } else {
843
- errors.push({
844
- message: "<Storyboard> vrt.threshold must be a number literal between 0 and 0.5",
845
- span: toSpan(property),
846
- kind: "degraded"
847
- });
848
- }
849
- continue;
850
- }
851
- if (key === "skip") {
852
- if (property.value?.type === "Literal" && typeof property.value.value === "boolean") {
853
- if (property.value.value) value.skip = true;
854
- } else {
855
- errors.push({
856
- message: "<Storyboard> vrt.skip must be a boolean literal",
857
- span: toSpan(property),
858
- kind: "degraded"
859
- });
860
- }
861
- continue;
862
- }
863
- if (key === "ignore") {
864
- const regions = readVrtIgnoreRegions(property.value, errors);
865
- if (regions) value.ignore = regions;
866
- continue;
867
- }
868
- errors.push({
869
- message: `<Storyboard> vrt has unknown property "${key ?? "?"}" \u2014 expected threshold, skip, or ignore`,
870
- span: toSpan(property),
871
- kind: "degraded"
872
- });
873
- }
874
- return { value, attributeSpan };
875
- }
876
- function readVrtIgnoreRegions(node, errors) {
877
- if (node?.type !== "ArrayExpression") {
878
- errors.push({
879
- message: "<Storyboard> vrt.ignore must be an array of { x, y, w, h } literals",
880
- span: toSpan(node),
881
- kind: "degraded"
882
- });
883
- return null;
884
- }
885
- const regions = [];
886
- for (const element of node.elements ?? []) {
887
- const region = {};
888
- for (const key of ["x", "y", "w", "h"]) {
889
- const property = getObjectProperty(element, key);
890
- const number = property ? readNumberLiteral(property.value) : null;
891
- if (number) region[key] = number.value;
892
- }
893
- if (region.x === void 0 || region.y === void 0 || region.w === void 0 || region.h === void 0) {
894
- errors.push({
895
- message: "<Storyboard> vrt.ignore regions must be { x, y, w, h } number literals",
896
- span: toSpan(element) ?? toSpan(node),
897
- kind: "degraded"
898
- });
899
- return null;
900
- }
901
- regions.push(region);
902
- }
903
- return regions;
904
- }
905
- function readComponentReference(openingElement, imports, source) {
906
- const attribute = getAttribute(openingElement, "component");
907
- const expression = unwrapAttributeExpression(attribute?.value);
908
- const span = toSpan(expression);
909
- if (!expression || !span) return null;
910
- const localName = expression.type === "Identifier" ? expression.name : expression.type === "MemberExpression" && expression.object?.type === "Identifier" ? expression.object.name : void 0;
911
- return {
912
- expression: source.slice(span.start, span.end),
913
- span,
914
- attributeSpan: toSpan(attribute),
915
- localName,
916
- import: localName ? imports.byLocalName.get(localName) : void 0
917
- };
918
- }
919
- function readRenderComponentReference(renderValue, imports, source) {
920
- if (renderValue?.type !== "ArrowFunctionExpression") return null;
921
- const body = unwrapTsExpression(renderValue.body);
922
- if (body?.type !== "JSXElement") return null;
923
- const name = body.openingElement?.name;
924
- if (name?.type !== "JSXIdentifier") return null;
925
- const span = toSpan(name);
926
- if (!span || typeof name.name !== "string") return null;
927
- return {
928
- expression: source.slice(span.start, span.end),
929
- span,
930
- localName: name.name,
931
- import: imports.byLocalName.get(name.name)
932
- };
933
- }
934
- function readExpressionReference(openingElement, name, source) {
935
- const attribute = getAttribute(openingElement, name);
936
- const expression = unwrapAttributeExpression(attribute?.value);
937
- const span = toSpan(expression);
938
- if (!expression || !span) return void 0;
939
- return {
940
- expression: source.slice(span.start, span.end),
941
- span,
942
- attributeSpan: toSpan(attribute)
943
- };
944
- }
945
- function isIdentifierExpression(expression) {
946
- return /^[A-Za-z_$][\w$]*$/.test(expression);
947
- }
948
- function readLayout(openingElement, componentName) {
949
- const isViewport = requiresFixedLayoutSize(componentName);
950
- const attribute = getAttribute(openingElement, "layout");
951
- const expression = unwrapAttributeExpression(attribute?.value);
952
- if (!expression) {
953
- return {
954
- value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : DEFAULT_LAYOUT,
955
- attributeSpan: toSpan(attribute),
956
- errors: [
957
- {
958
- message: `<${componentName}> must include a literal "layout" object prop`,
959
- span: toSpan(openingElement),
960
- kind: "degraded"
961
- }
962
- ]
963
- };
964
- }
965
- const layout = readLayoutExpression(expression, componentName);
966
- return {
967
- ...layout,
968
- attributeSpan: toSpan(attribute)
969
- };
970
- }
971
- function readLayoutExpression(expression, componentName) {
972
- const errors = [];
973
- const isViewport = requiresFixedLayoutSize(componentName);
974
- if (expression.type !== "ObjectExpression") {
975
- return {
976
- value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : DEFAULT_LAYOUT,
977
- spans: { layoutClose: readLayoutClose(expression) },
978
- errors: [
979
- {
980
- message: `<${componentName}> layout must be an object literal`,
981
- span: toSpan(expression),
982
- kind: "degraded"
983
- }
984
- ]
985
- };
986
- }
987
- const spans = {
988
- layoutClose: readLayoutClose(expression)
989
- };
990
- const layout = { ...DEFAULT_LAYOUT };
991
- const width = getObjectProperty(expression, "width");
992
- const height = getObjectProperty(expression, "height");
993
- const legacySizing = getObjectProperty(expression, "intrinsicSizing");
994
- const legacyResponsiveFlag = legacySizing?.value?.value === "root-element";
995
- const hasBothSizes = Boolean(width && height);
996
- const readSize = isViewport || hasBothSizes && !legacyResponsiveFlag;
997
- const incompleteSize = !isViewport && Boolean(width) !== Boolean(height);
998
- if (incompleteSize) {
999
- errors.push({
1000
- message: "layout.width and layout.height must be set together",
1001
- span: toSpan(expression),
1002
- kind: "degraded"
1003
- });
1004
- }
1005
- const size = readSize ? {
1006
- width: width ? readNumberLiteral(width.value) : null,
1007
- height: height ? readNumberLiteral(height.value) : null
1008
- } : null;
1009
- const keys = readSize ? ["x", "y", "width", "height"] : ["x", "y"];
1010
- for (const key of keys) {
1011
- const property = key === "width" ? width : key === "height" ? height : getObjectProperty(expression, key);
1012
- const value = key === "width" || key === "height" ? size?.[key] : property ? readNumberLiteral(property.value) : null;
1013
- const keepValue = key === "x" || key === "y" || isViewport || Boolean(size?.width && size.height);
1014
- if (!value) {
1015
- errors.push({
1016
- message: `<${componentName}> layout.${key} must be a number literal`,
1017
- span: toSpan(property ?? expression),
1018
- kind: "degraded"
1019
- });
1020
- continue;
1021
- }
1022
- if (!keepValue) continue;
1023
- layout[key] = value.value;
1024
- spans[key] = value.span;
1025
- }
1026
- const zIndex = getObjectProperty(expression, "zIndex");
1027
- if (zIndex) {
1028
- const value = readNumberLiteral(zIndex.value);
1029
- if (value) {
1030
- layout.zIndex = value.value;
1031
- spans.zIndex = value.span;
1032
- } else {
1033
- errors.push({
1034
- message: `<${componentName}> layout.zIndex must be a number literal`,
1035
- span: toSpan(zIndex),
1036
- kind: "degraded"
1037
- });
1038
- }
1039
- }
1040
- const invalidLegacyFlag = legacySizing && (legacySizing.value?.type !== "Literal" || !legacyResponsiveFlag);
1041
- if (invalidLegacyFlag) {
1042
- errors.push({
1043
- message: `<${componentName}> layout.intrinsicSizing must be "root-element" when set`,
1044
- span: toSpan(legacySizing),
1045
- kind: "degraded"
1046
- });
1047
- }
1048
- return { value: layout, spans, errors };
1049
- }
1050
- function readStringLiteralValue(node) {
1051
- return node?.type === "Literal" && typeof node.value === "string" ? { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } } : null;
1052
- }
1053
- function unwrapTsExpression(node) {
1054
- let current = node;
1055
- while (current?.type === "TSSatisfiesExpression" || current?.type === "TSAsExpression" || current?.type === "TSNonNullExpression" || current?.type === "ParenthesizedExpression") {
1056
- current = current.expression;
1057
- }
1058
- return current;
1059
- }
1060
- function readResolvableStringAttribute(openingElement, name, bindings) {
1061
- const literal = readStringAttribute(openingElement, name);
1062
- if (literal) return literal;
1063
- const attribute = getAttribute(openingElement, name);
1064
- const expression = unwrapAttributeExpression(attribute?.value);
1065
- const expressionSpan = toSpan(expression);
1066
- const attributeSpan = toSpan(attribute);
1067
- if (!expression || !expressionSpan || !attributeSpan) return null;
1068
- const resolved = resolveStringMemberExpression(expression, bindings);
1069
- return resolved ? {
1070
- value: resolved.value,
1071
- valueSpan: expressionSpan,
1072
- attributeSpan
1073
- } : null;
1074
- }
1075
- function resolveStringMemberExpression(expression, bindings) {
1076
- if (expression?.type !== "MemberExpression") return null;
1077
- if (expression.object?.type !== "Identifier") return null;
1078
- const propertyName = readPropertyKeyName(expression.property);
1079
- if (!propertyName) return null;
1080
- return bindings.get(expression.object.name)?.get(propertyName) ?? null;
1081
- }
1082
- function readStringAttribute(openingElement, name) {
1083
- const attribute = getAttribute(openingElement, name);
1084
- if (!attribute) return null;
1085
- const value = attribute.value;
1086
- if (value?.type === "Literal" && typeof value.value === "string") {
1087
- return {
1088
- value: value.value,
1089
- valueSpan: toSpan(value) ?? toSpan(attribute) ?? { start: 0, end: 0 },
1090
- attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
1091
- };
1092
- }
1093
- const expression = unwrapTsExpression(unwrapAttributeExpression(value));
1094
- const fixed = expression?.type === "Literal" && typeof expression.value === "string" ? expression.value : expression?.type === "TemplateLiteral" && (expression.expressions?.length ?? 0) === 0 && expression.quasis?.length === 1 && typeof expression.quasis[0]?.value?.cooked === "string" ? expression.quasis[0].value.cooked : null;
1095
- if (fixed !== null) {
1096
- return {
1097
- value: fixed,
1098
- valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
1099
- attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
1100
- };
1101
- }
1102
- return null;
1103
- }
1104
- function getAttribute(openingElement, name) {
1105
- for (const attribute of openingElement?.attributes ?? []) {
1106
- if (attribute?.type === "JSXAttribute" && attribute.name?.type === "JSXIdentifier" && attribute.name.name === name) {
1107
- return attribute;
1108
- }
1109
- }
1110
- return null;
1111
- }
1112
- function unwrapAttributeExpression(value) {
1113
- if (!value) return null;
1114
- if (value.type === "JSXExpressionContainer") {
1115
- return value.expression;
1116
- }
1117
- return value;
1118
- }
1119
- function readPropertyKeyName(key) {
1120
- if (key?.type === "Identifier") return key.name;
1121
- if (key?.type === "Literal" && typeof key.value === "string") {
1122
- return key.value;
1123
- }
1124
- return null;
1125
- }
1126
- function getObjectProperty(objectExpression, name) {
1127
- if (objectExpression?.type !== "ObjectExpression") return null;
1128
- for (const property of objectExpression.properties ?? []) {
1129
- if (property?.type !== "Property" || property.computed) continue;
1130
- const propertyName = readPropertyKeyName(property.key);
1131
- if (propertyName === name) return property;
1132
- }
1133
- return null;
1134
- }
1135
- function readNumberLiteral(node) {
1136
- if (node?.type === "Literal" && typeof node.value === "number" && Number.isFinite(node.value)) {
1137
- return { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } };
1138
- }
1139
- if (node?.type === "UnaryExpression" && node.operator === "-" && node.argument?.type === "Literal" && typeof node.argument.value === "number" && Number.isFinite(node.argument.value)) {
1140
- return {
1141
- value: -node.argument.value,
1142
- span: toSpan(node) ?? { start: 0, end: 0 }
1143
- };
1144
- }
1145
- return null;
1146
- }
1147
- function resolveSdkComponent(nameNode, imports) {
1148
- if (nameNode?.type === "JSXIdentifier") {
1149
- return imports.sdkLocalNames.get(nameNode.name) ?? null;
1150
- }
1151
- if (nameNode?.type === "JSXMemberExpression" && nameNode.object?.type === "JSXIdentifier" && nameNode.property?.type === "JSXIdentifier" && imports.sdkNamespaces.has(nameNode.object.name) && SDK_COMPONENTS.has(nameNode.property.name)) {
1152
- return nameNode.property.name;
1153
- }
1154
- return null;
1155
- }
1156
- function resolveMisimportedNamespaceSdkComponent(nameNode, imports, misimportedSdkCanvasImports) {
1157
- if (nameNode?.type !== "JSXMemberExpression" || nameNode.object?.type !== "JSXIdentifier" || nameNode.property?.type !== "JSXIdentifier" || !SDK_COMPONENTS.has(nameNode.property.name)) {
1158
- return null;
1159
- }
1160
- const imported = imports.byLocalName.get(nameNode.object.name);
1161
- if (imported?.kind !== "namespace" || !isWrongTempoSdkCanvasImportSource(imported.source)) {
1162
- return null;
1163
- }
1164
- return misimportedSdkCanvasImports.namespaceCandidatesByLocalName.get(
1165
- nameNode.object.name
1166
- ) ?? null;
1167
- }
1168
- function isStoryboardSdkComponent(component) {
1169
- return component !== null && component !== "Canvas";
1170
- }
1171
- function formatAlternatives(items) {
1172
- if (items.length <= 1) return items.join("");
1173
- return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
1174
- }
1175
- function requiresFixedLayoutSize(componentName) {
1176
- return componentName === "RouteStoryboard" || componentName === "HtmlStoryboard" || componentName === "FlutterStoryboard";
1177
- }
1178
- function readImportedName(specifier) {
1179
- if (specifier.type === "ImportDefaultSpecifier") return "default";
1180
- if (specifier.type === "ImportNamespaceSpecifier") return "*";
1181
- return specifier.imported?.name ?? specifier.local?.name ?? "unknown";
1182
- }
1183
- function readImportKind(specifier) {
1184
- if (specifier.type === "ImportDefaultSpecifier") return "default";
1185
- if (specifier.type === "ImportNamespaceSpecifier") return "namespace";
1186
- return "named";
1187
- }
1188
- function isSdkImportSource(source) {
1189
- for (const sdkSource of SDK_IMPORT_SOURCES) {
1190
- if (source === sdkSource || source.endsWith(`/${sdkSource}`)) return true;
1191
- }
1192
- return false;
1193
- }
1194
- function isWrongTempoSdkCanvasImportSource(source) {
1195
- return (source === "tempo-sdk" || source.startsWith("tempo-sdk/")) && !isSdkImportSource(source);
1196
- }
1197
- function spanKey(span) {
1198
- return `${span.start}:${span.end}`;
1199
- }
1200
- function readLayoutClose(node) {
1201
- return typeof node?.end === "number" && Number.isFinite(node.end) ? node.end - 1 : void 0;
1202
- }
1203
- function fallbackPageName(filePath) {
1204
- const normalized = filePath.replace(/\\/g, "/");
1205
- const segments = normalized.split("/").filter(Boolean);
1206
- const fileName = segments.length > 0 ? segments[segments.length - 1] : filePath;
1207
- const parentName = segments.length > 1 ? segments[segments.length - 2] : fileName;
1208
- const baseName = /^index\.canvas\.[tj]sx?$/.test(fileName) ? parentName : fileName.replace(/\.canvas\.[tj]sx?$/, "");
1209
- return baseName.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
1210
- }
1211
- function toSpan(node) {
1212
- return typeof node?.start === "number" && Number.isFinite(node.start) && typeof node?.end === "number" && Number.isFinite(node.end) ? { start: node.start, end: node.end } : void 0;
1213
- }
1214
- function walk(node, visitor, seen = /* @__PURE__ */ new Set()) {
1215
- if (!node || typeof node !== "object" || seen.has(node)) return;
1216
- seen.add(node);
1217
- visitor(node);
1218
- for (const value of Object.values(node)) {
1219
- if (!value) continue;
1220
- if (Array.isArray(value)) {
1221
- for (const item of value) {
1222
- walk(item, visitor, seen);
1223
- }
1224
- } else if (typeof value === "object") {
1225
- walk(value, visitor, seen);
1226
- }
1227
- }
1228
- }
1229
-
1230
- // canvas-component-reference.ts
1231
- var COMPONENT_REFERENCE_ATTRIBUTE = "data-tempo-component-reference";
1232
- function moduleIdentity(file, specifier, resolved) {
1233
- const resolvedId = resolved?.get(specifier);
1234
- const bundled = resolvedId?.startsWith("\0tempo:astro-component:") ? decodeURIComponent(
1235
- resolvedId.slice("\0tempo:astro-component:".length, -3)
1236
- ) : resolvedId;
1237
- const target = bundled === void 0 ? specifier : bundled.replace(/\bt=\d{13}&?\b/, "").replace(/[?&]$/, "");
1238
- if (target.startsWith("\0")) return target;
1239
- const suffixAt = target.search(/[?#]/);
1240
- let path2 = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1241
- /\\/g,
1242
- "/"
1243
- );
1244
- const suffix = suffixAt < 0 || target.endsWith(".astro?tempo-component") ? "" : target.slice(suffixAt);
1245
- if (bundled === void 0 && path2.startsWith("."))
1246
- path2 = (0, import_node_path2.resolve)((0, import_node_path2.dirname)(file), path2);
1247
- if (!(0, import_node_path2.isAbsolute)(path2) && !/^[A-Za-z]:\//.test(path2)) return target;
1248
- if (bundled !== void 0) {
1249
- try {
1250
- path2 = import_node_fs2.realpathSync.native(path2);
1251
- } catch {
1252
- }
1253
- }
1254
- return (0, import_node_path2.normalize)(path2).replace(/\\/g, "/") + suffix;
1255
- }
1256
- function canvasComponentAnnotations(file, source, resolved, hostRoot) {
1257
- const result = /* @__PURE__ */ new Map();
1258
- if (!source.includes("tempo-sdk/canvas")) return result;
1259
- const parsed = parseCanvasFile(file, source);
1260
- for (const board of parsed.storyboards) {
1261
- if (board.kind !== "component" || board.openingElementSpan === void 0)
1262
- continue;
1263
- const flutterPreview = board.preview ? parseFlutterPreview(board.preview) : null;
1264
- if (flutterPreview && !("error" in flutterPreview) && hostRoot) {
1265
- let key;
1266
- try {
1267
- const absolute = (0, import_node_path2.resolve)(
1268
- (0, import_node_path2.dirname)(canonicalPathAllowMissing(file)),
1269
- flutterPreview.file
1270
- );
1271
- key = flutterPreviewKey(
1272
- hostRoot,
1273
- absolute,
1274
- flutterPreview.functionName
1275
- );
1276
- } catch {
1277
- continue;
1278
- }
1279
- result.set(board.openingElementSpan.start, {
1280
- [FLUTTER_PREVIEW_KEY_ATTRIBUTE]: key,
1281
- [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1282
- "flutter",
1283
- key.slice(0, key.lastIndexOf("#")),
1284
- flutterPreview.functionName
1285
- ]),
1286
- "data-tempo-external-component": "true"
1287
- });
1288
- continue;
1289
- }
1290
- const ref = board.component;
1291
- if (!ref?.localName) continue;
1292
- const member = ref.expression.match(
1293
- /^\s*([$\w]+)(?:\s*\.\s*([$\w]+))?\s*$/
1294
- );
1295
- if (!member) continue;
1296
- let name;
1297
- if (ref.import) {
1298
- if (ref.import.kind === "namespace") {
1299
- if (!member[2]) continue;
1300
- name = member[2];
1301
- } else {
1302
- if (member[2]) continue;
1303
- name = ref.import.importedName;
1304
- }
1305
- } else {
1306
- if (member[2]) continue;
1307
- name = ref.localName;
1308
- }
1309
- const specifier = ref.import?.source.replace(/\\/g, "/").replace(/[?#].*/, "");
1310
- const canvasDir = import_node_path2.posix.dirname(file.replace(/\\/g, "/"));
1311
- const external = specifier !== void 0 && (!specifier.startsWith(".") || !import_node_path2.posix.join(canvasDir, specifier).startsWith(`${canvasDir}/`));
1312
- result.set(board.openingElementSpan.start, {
1313
- [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1314
- ref.import ? "import" : "local",
1315
- moduleIdentity(file, ref.import?.source ?? file, resolved),
1316
- name
1317
- ]),
1318
- ...external ? { "data-tempo-external-component": "true" } : {}
1319
- });
1320
- }
1321
- return result;
1322
- }
1323
-
1324
- // expo-babel-plugin.ts
1325
- var import_node_fs5 = require("fs");
1326
- var import_node_path5 = require("path");
1327
- var import_pluginutils = require("@rollup/pluginutils");
1328
-
1329
- // annotation-strategy.ts
1330
- var import_node_fs3 = require("fs");
1331
- var import_node_path3 = require("path");
1332
-
1333
- // ../../modules/annotation/literal-expression.ts
1334
- function unwrapLiteralExpression(node) {
1335
- let current = node;
1336
- while ([
1337
- "ParenthesizedExpression",
1338
- "TSAsExpression",
1339
- "TSSatisfiesExpression",
1340
- "TSTypeAssertion",
1341
- "TSNonNullExpression",
1342
- "TSInstantiationExpression"
1343
- ].includes(current.type)) {
1344
- const expression = current.expression;
1345
- if (!expression) break;
1346
- current = expression;
1347
- }
1348
- return current;
1349
- }
1350
- function readLiteralExpression(node) {
1351
- const value = unwrapLiteralExpression(node);
1352
- if (["Literal", "StringLiteral", "NumericLiteral", "BooleanLiteral"].includes(
1353
- value.type
1354
- )) {
1355
- if (typeof value.value === "string" || typeof value.value === "boolean")
1356
- return value.value;
1357
- if (typeof value.value === "number" && Number.isFinite(value.value))
1358
- return value.value;
1359
- }
1360
- if (value.type === "TemplateLiteral") {
1361
- const expressions = value.expressions;
1362
- const quasis = value.quasis;
1363
- if (expressions.length === 0 && quasis.length === 1 && typeof quasis[0]?.value.cooked === "string")
1364
- return quasis[0].value.cooked;
1365
- }
1366
- if (value.type === "UnaryExpression" && (value.operator === "-" || value.operator === "+")) {
1367
- const argument = readLiteralExpression(value.argument);
1368
- if (typeof argument === "number")
1369
- return value.operator === "-" ? -argument : argument;
1370
- }
1371
- if (value.type === "BinaryExpression" && ["+", "-", "*", "/"].includes(value.operator)) {
1372
- const left = readLiteralExpression(value.left);
1373
- const right = readLiteralExpression(value.right);
1374
- if (typeof left !== "number" || typeof right !== "number") return null;
1375
- const result = value.operator === "+" ? left + right : value.operator === "-" ? left - right : value.operator === "*" ? left * right : left / right;
1376
- return Number.isFinite(result) ? result : null;
1377
- }
1378
- return null;
1379
- }
1380
- function literalJsxChild(node) {
1381
- if (node.type !== "JSXExpressionContainer") return null;
1382
- const root = unwrapLiteralExpression(
1383
- node.expression
1384
- );
1385
- return root.type === "JSXElement" ? root : null;
1386
- }
1387
- function literalPropertyName(key, computed = false) {
1388
- if (!computed && key.type === "Identifier")
1389
- return typeof key.name === "string" ? key.name : null;
1390
- const value = readLiteralExpression(key);
1391
- return typeof value === "string" || typeof value === "number" ? String(value) : null;
1392
- }
1393
-
1394
- // ../../modules/annotation/expression-facts.ts
1395
- var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
1396
- var DYNAMIC_SLOT_FACT = "#slot";
1397
- function expressionFacts(element, parentType, isStaticJsxChild = false) {
1398
- const opening = element.openingElement;
1399
- const attributes = opening.attributes;
1400
- const facts = [];
1401
- if (!isStaticJsxChild && parentType !== "JSXElement" && parentType !== "JSXFragment")
1402
- facts.push(DYNAMIC_SLOT_FACT);
1403
- const last = /* @__PURE__ */ new Map();
1404
- attributes.forEach((attribute, index) => {
1405
- const name = attributeName(attribute);
1406
- if (name !== null) last.set(name, index);
1407
- });
1408
- let lastSpread = -1;
1409
- attributes.forEach((attribute, index) => {
1410
- if (attribute.type === "JSXSpreadAttribute") lastSpread = index;
1411
- });
1412
- for (const [name, index] of last) {
1413
- if (unstamped(name)) continue;
1414
- const overridden = index < lastSpread;
1415
- const value = attributes[index].value;
1416
- if (value === null) continue;
1417
- if (name === "style" && !overridden) {
1418
- facts.push(...styleFacts(value));
1419
- continue;
1420
- }
1421
- if (overridden) facts.push(name);
1422
- else if (name === "className" && isClassHelperCall(value)) continue;
1423
- else if (!isLiteralValue(value)) facts.push(name);
1424
- }
1425
- if (facts.length > 0) return facts.join(" ");
1426
- return lastSpread >= 0 ? "" : void 0;
1427
- }
1428
- function attributeName(attribute) {
1429
- if (attribute.type !== "JSXAttribute") return null;
1430
- const name = attribute.name;
1431
- if (name.type === "JSXIdentifier") return name.name;
1432
- if (name.type === "JSXNamespacedName") {
1433
- const namespace = name.namespace.name;
1434
- return `${namespace}:${name.name.name}`;
1435
- }
1436
- return null;
1437
- }
1438
- function unstamped(name) {
1439
- return name === "key" || name.startsWith("data-tempo-");
1440
- }
1441
- function styleFacts(value) {
1442
- const expression = value.type === "JSXExpressionContainer" ? unwrap(value.expression) : value;
1443
- if (expression.type !== "ObjectExpression") return ["style"];
1444
- const properties = expression.properties;
1445
- const last = /* @__PURE__ */ new Map();
1446
- properties.forEach((property, index) => {
1447
- const key = styleKey(property);
1448
- if (key !== null) last.set(key, index);
1449
- });
1450
- const facts = [];
1451
- for (const [key, index] of last) {
1452
- const property = properties[index];
1453
- const overridden = properties.slice(index + 1).some(
1454
- (later) => later.type === "SpreadElement" || later.computed && styleKey(later) === null
1455
- );
1456
- const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
1457
- if (overridden || !literal) facts.push(`style.${key}`);
1458
- }
1459
- return facts;
1460
- }
1461
- function styleKey(property) {
1462
- const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
1463
- if (!isProperty) return null;
1464
- return literalPropertyName(property.key, Boolean(property.computed));
1465
- }
1466
- function isLiteralValue(value) {
1467
- if (value.type === "Literal" || value.type === "StringLiteral") return true;
1468
- if (value.type !== "JSXExpressionContainer") return false;
1469
- return isLiteral(value.expression);
1470
- }
1471
- var CLASS_HELPERS = /* @__PURE__ */ new Set(["cn", "clsx", "twMerge", "cx", "classNames"]);
1472
- function isClassHelperCall(value) {
1473
- if (value.type !== "JSXExpressionContainer") return false;
1474
- const call = value.expression;
1475
- if (call.type !== "CallExpression") return false;
1476
- const callee = call.callee;
1477
- if (callee.type !== "Identifier" || !CLASS_HELPERS.has(callee.name))
1478
- return false;
1479
- return call.arguments.every(
1480
- (argument) => (argument.type === "Literal" || argument.type === "StringLiteral") && typeof argument.value === "string" || argument.type === "TemplateLiteral" && argument.expressions.length === 0
1481
- );
1482
- }
1483
- function isLiteral(node) {
1484
- return readLiteralExpression(node) !== null;
1485
- }
1486
- function unwrap(node) {
1487
- return unwrapLiteralExpression(node);
1488
- }
1489
-
1490
- // ../../modules/annotation/source-version.ts
1491
- function sourceVersionHash(content) {
1492
- let djb2 = 5381;
1493
- let sdbm = 0;
1494
- for (let i = 0; i < content.length; i++) {
1495
- const c = content.charCodeAt(i);
1496
- djb2 = (djb2 << 5) + djb2 ^ c;
1497
- sdbm = c + (sdbm << 6) + (sdbm << 16) - sdbm | 0;
1498
- }
1499
- return toHex8(djb2) + toHex8(sdbm);
1500
- }
1501
- function toHex8(n) {
1502
- return (n >>> 0).toString(16).padStart(8, "0");
1503
- }
1504
-
1505
- // annotation-strategy.ts
1506
- var DEFAULT_EXCLUDE = ["**/node_modules/**"];
1507
- var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
1508
- "area",
1509
- "base",
1510
- "br",
1511
- "col",
1512
- "embed",
1513
- "hr",
1514
- "img",
1515
- "input",
1516
- "link",
1517
- "meta",
1518
- "param",
1519
- "source",
1520
- "track",
1521
- "wbr"
1522
- ]);
1523
- function cleanModuleId(id) {
1524
- return id.replace(/[?#].*$/, "");
1525
- }
1526
- function resolveCanonicalRoot(root) {
1527
- try {
1528
- return import_node_fs3.realpathSync.native(root);
1529
- } catch {
1530
- return root;
1531
- }
1532
- }
1533
- function isIntrinsicElement(tagName) {
1534
- return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
1535
- }
1536
- function hasJsxAttribute(info, attrName) {
1537
- for (const attr of info.element.openingElement.attributes) {
1538
- const name = attr.name;
1539
- if (name?.name === attrName) return true;
1540
- }
1541
- return false;
1542
- }
1543
- function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) {
1544
- return {
1545
- "data-tempo-filepath": filepath,
1546
- "data-tempo-position": info.element.openingElement.start,
1547
- // Runtime display names can differ from the JSX used at this callsite
1548
- // (imports, member expressions, memo and forwardRef wrappers).
1549
- "data-tempo-source-tag": info.tagName,
1550
- "data-tempo-modifiedts": modifiedtsMs,
1551
- // Content-hash identity of the file this element was annotated from. The
1552
- // canvas reconcile loop equality-compares it against the write pipeline's
1553
- // computed version to decide whether a capture reflects a given edit.
1554
- "data-tempo-source-version": sourceVersion
1555
- };
1556
- }
1557
- function computeTempoAnnotatedProps(params) {
1558
- const {
1559
- info,
1560
- filepath,
1561
- modifiedtsMs,
1562
- sourceVersion,
1563
- computeAnnotatedProps,
1564
- elementSupportOverrides
1565
- } = params;
1566
- const userProps = {
1567
- ...computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) : defaultComputeAnnotatedProps(
1568
- info,
1569
- filepath,
1570
- modifiedtsMs,
1571
- sourceVersion
1572
- ),
1573
- // Only a caller that knows the parent can say whether the slot is a JSX
1574
- // child; without it every element would read as a dynamic slot.
1575
- ...info.parentType !== void 0 && !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE) ? {
1576
- [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(
1577
- info.element,
1578
- info.parentType,
1579
- info.isStaticJsxChild
1580
- )
1581
- } : {}
1582
- };
1583
- if (isIntrinsicElement(info.tagName)) {
1584
- return {
1585
- ...userProps,
1586
- "data-tempo-supports-children": hasJsxAttribute(
1587
- info,
1588
- "data-tempo-supports-children"
1589
- ) ? void 0 : !HTML_VOID_ELEMENTS.has(info.tagName)
1590
- };
1591
- }
1592
- const override = elementSupportOverrides?.get(info.tagName);
1593
- if (override) {
1594
- return {
1595
- ...userProps,
1596
- "data-tempo-supports-children": hasJsxAttribute(
1597
- info,
1598
- "data-tempo-supports-children"
1599
- ) ? void 0 : override.supportsChildren
1600
- };
1601
- }
1602
- return userProps;
1603
- }
1604
- function getFileAnnotationContext(params) {
1605
- const rawCleanFilename = cleanModuleId(params.filename);
1606
- let cleanFilename = rawCleanFilename;
1607
- if (params.canonicalizeFilename) {
1608
- try {
1609
- cleanFilename = import_node_fs3.realpathSync.native(rawCleanFilename);
1610
- } catch {
1611
- cleanFilename = rawCleanFilename;
1612
- }
1613
- }
1614
- return {
1615
- cleanFilename,
1616
- filepath: (0, import_node_path3.relative)(params.root, cleanFilename),
1617
- modifiedtsMs: Math.trunc((0, import_node_fs3.statSync)(cleanFilename).mtimeMs),
1618
- // Hashed once per file per transform (the context is built once, reused
1619
- // for every element) so the per-element funnel just forwards the token.
1620
- sourceVersion: sourceVersionHash(params.source)
1621
- };
1622
- }
1623
-
1624
- // sdk-package-files.ts
1625
- var import_node_fs4 = require("fs");
1626
- var import_node_path4 = require("path");
1627
- var SDK_PACKAGE_NAME = "tempo-sdk";
1628
- var SDK_NODE_MODULES_SEGMENT = `/node_modules/${SDK_PACKAGE_NAME}/`;
1629
- function createSdkFileMatcher() {
1630
- const ownerIsSdkByDirectory = /* @__PURE__ */ new Map();
1631
- const nearestPackageIsSdk = (startDirectory) => {
1632
- const visited = [];
1633
- let directory = startDirectory;
1634
- let isSdk = false;
1635
- while (true) {
1636
- const cached = ownerIsSdkByDirectory.get(directory);
1637
- if (cached !== void 0) {
1638
- isSdk = cached;
1639
- break;
1640
- }
1641
- visited.push(directory);
1642
- const manifest = readPackageManifest(directory);
1643
- if (manifest !== void 0) {
1644
- isSdk = manifest?.name === SDK_PACKAGE_NAME;
1645
- break;
1646
- }
1647
- const parent = (0, import_node_path4.dirname)(directory);
1648
- if (parent === directory) break;
1649
- directory = parent;
1650
- }
1651
- for (const entry of visited) ownerIsSdkByDirectory.set(entry, isSdk);
1652
- return isSdk;
1653
- };
1654
- return (file) => {
1655
- if (file.replace(/\\/g, "/").includes(SDK_NODE_MODULES_SEGMENT)) {
1656
- return true;
1657
- }
1658
- let realFile = file;
1659
- try {
1660
- realFile = import_node_fs4.realpathSync.native(file);
1661
- } catch {
1662
- }
1663
- return nearestPackageIsSdk((0, import_node_path4.dirname)(realFile));
1664
- };
1665
- }
1666
- function readPackageManifest(directory) {
1667
- let text;
1668
- try {
1669
- text = (0, import_node_fs4.readFileSync)((0, import_node_path4.join)(directory, "package.json"), "utf8");
1670
- } catch {
1671
- return void 0;
1672
- }
1673
- try {
1674
- const manifest = JSON.parse(text);
1675
- return manifest && typeof manifest === "object" ? manifest : null;
1676
- } catch {
1677
- return null;
1678
- }
1679
- }
1680
-
1681
- // expo-babel-plugin.ts
1682
- var EXPO_DEFAULT_INCLUDE = ["**/*.tsx", "**/*.jsx", "**/*.js"];
1683
- var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"]);
1684
- var REACT_NATIVE_HOST_COMPONENTS = /* @__PURE__ */ new Set([
1685
- "ActivityIndicator",
1686
- "Button",
1687
- "FlatList",
1688
- "Image",
1689
- "ImageBackground",
1690
- "KeyboardAvoidingView",
1691
- "Modal",
1692
- "Pressable",
1693
- "RefreshControl",
1694
- "SafeAreaView",
1695
- "ScrollView",
1696
- "SectionList",
1697
- "Switch",
1698
- "Text",
1699
- "TextInput",
1700
- "TouchableHighlight",
1701
- "TouchableNativeFeedback",
1702
- "TouchableOpacity",
1703
- "TouchableWithoutFeedback",
1704
- "View",
1705
- "VirtualizedList"
1706
- ]);
1707
- var REACT_NATIVE_NO_CHILDREN_COMPONENTS = /* @__PURE__ */ new Set([
1708
- "ActivityIndicator",
1709
- "Image",
1710
- "RefreshControl",
1711
- "Switch"
1712
- ]);
1713
- var REACT_NATIVE_SUPPORT_OVERRIDES = new Map(
1714
- [...REACT_NATIVE_HOST_COMPONENTS].map((tagName) => [
1715
- tagName,
1716
- { supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName) }
1717
- ])
1718
- );
1719
- function hasParserPlugin(plugins, name) {
1720
- return plugins.some(
1721
- (plugin) => Array.isArray(plugin) ? plugin[0] === name : plugin === name
1722
- );
1723
- }
1724
- function getBabelTagName(name) {
1725
- switch (name.type) {
1726
- case "JSXIdentifier":
1727
- return name.name;
1728
- case "JSXNamespacedName":
1729
- return `${name.namespace.name}:${name.name.name}`;
1730
- case "JSXMemberExpression":
1731
- return `${getBabelTagName(name.object)}.${name.property.name}`;
1732
- }
1733
- }
1734
- function hasAttribute(node, attrName) {
1735
- return node.attributes.some(
1736
- (attr) => attr.type === "JSXAttribute" && attr.name.name === attrName
1737
- );
1738
- }
1739
- function propValueToExpression(api, value) {
1740
- if (typeof value === "function") {
1741
- return api.template.expression(value.toString())();
1742
- }
1743
- return api.types.valueToNode(value);
1744
- }
1745
- function dataAttrToDataSetKey(attrName) {
1746
- return attrName.replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
1747
- }
1748
- function findDataSetAttribute(openingElement) {
1749
- return openingElement.attributes.find(
1750
- (attr) => attr.type === "JSXAttribute" && attr.name.name === "dataSet"
1751
- );
1752
- }
1753
- function addAnnotations(api, tagName, openingElement, props) {
1754
- const t = api.types;
1755
- if (isIntrinsicElement(tagName)) {
1756
- for (const [key, value] of Object.entries(props)) {
1757
- if (value === void 0 || hasAttribute(openingElement, key)) continue;
1758
- openingElement.attributes.push(
1759
- t.jsxAttribute(
1760
- t.jsxIdentifier(key),
1761
- t.jsxExpressionContainer(propValueToExpression(api, value))
1762
- )
1763
- );
1764
- }
1765
- return;
1766
- }
1767
- const dataSetProps = [];
1768
- for (const [key, value] of Object.entries(props)) {
1769
- if (value === void 0) continue;
1770
- dataSetProps.push(
1771
- t.objectProperty(
1772
- t.identifier(dataAttrToDataSetKey(key)),
1773
- propValueToExpression(api, value)
1774
- )
1775
- );
1776
- }
1777
- if (dataSetProps.length === 0) return;
1778
- const existing = findDataSetAttribute(openingElement);
1779
- if (!existing) {
1780
- openingElement.attributes.push(
1781
- t.jsxAttribute(
1782
- t.jsxIdentifier("dataSet"),
1783
- t.jsxExpressionContainer(t.objectExpression(dataSetProps))
1784
- )
1785
- );
1786
- return;
1787
- }
1788
- if (existing.value?.type === "JSXExpressionContainer" && existing.value.expression.type !== "JSXEmptyExpression") {
1789
- existing.value.expression = t.objectExpression([
1790
- t.spreadElement(existing.value.expression),
1791
- ...dataSetProps
1792
- ]);
1793
- }
1794
- }
1795
- var ROOT_META_NAME = "tempo-project-root";
1796
- function injectProjectRootMeta(api, programPath, root) {
1797
- const setter = api.template.statement(`
1798
- if (typeof document !== "undefined") {
1799
- var __tempoRootMeta = document.querySelector('meta[name="${ROOT_META_NAME}"]');
1800
- if (!__tempoRootMeta) {
1801
- __tempoRootMeta = document.createElement("meta");
1802
- __tempoRootMeta.setAttribute("name", "${ROOT_META_NAME}");
1803
- document.head.appendChild(__tempoRootMeta);
1804
- }
1805
- __tempoRootMeta.setAttribute("content", ${JSON.stringify(root)});
1806
- }
1807
- `)();
1808
- programPath.pushContainer("body", setter);
1809
- }
1810
- function resolveBabelRoot(state, options, filename) {
1811
- return resolveCanonicalRoot(
1812
- (0, import_node_path5.resolve)(
1813
- options.root ?? findNearestPackageRoot(filename) ?? state.cwd ?? state.file.opts.cwd ?? state.file.opts.root ?? process.cwd()
1814
- )
1815
- );
1816
- }
1817
- function findNearestPackageRoot(filename) {
1818
- let current = (0, import_node_path5.dirname)(filename);
1819
- while (true) {
1820
- if ((0, import_node_fs5.existsSync)((0, import_node_path5.resolve)(current, "package.json"))) return current;
1821
- const parent = (0, import_node_path5.dirname)(current);
1822
- if (parent === current) return null;
1823
- current = parent;
1824
- }
1825
- }
1826
- function resolveFilename(state) {
1827
- const filename = state.filename ?? state.file.opts.filename;
1828
- if (!filename) return null;
1829
- return (0, import_node_path5.resolve)(cleanModuleId(filename));
1830
- }
1831
- function tempoExpoBabelPlugin(api, rawOptions = {}) {
1832
- api.assertVersion(7);
1833
- const enabled = rawOptions.enabled ?? !!process.env.TEMPO;
1834
- const include = rawOptions.include === void 0 ? EXPO_DEFAULT_INCLUDE : rawOptions.include;
1835
- const exclude = rawOptions.exclude === void 0 ? DEFAULT_EXCLUDE : rawOptions.exclude;
1836
- const userFilter = (0, import_pluginutils.createFilter)(include, exclude);
1837
- const isSdkFile = createSdkFileMatcher();
1838
- const filter = (id) => userFilter(id) && !isSdkFile(id);
1839
- return {
1840
- name: "tempo-expo-annotate",
1841
- manipulateOptions(opts, parserOpts) {
1842
- parserOpts.plugins ?? (parserOpts.plugins = []);
1843
- if (!hasParserPlugin(parserOpts.plugins, "jsx")) {
1844
- parserOpts.plugins.push("jsx");
1845
- }
1846
- const filename = opts.filename ?? "";
1847
- if (/\.(ts|tsx)$/.test(filename) && !hasParserPlugin(parserOpts.plugins, "typescript")) {
1848
- parserOpts.plugins.push("typescript");
1849
- }
1850
- },
1851
- visitor: {
1852
- Program: {
1853
- enter(path2, state) {
1854
- if (!enabled) return;
1855
- const options = { ...rawOptions, ...state.opts };
1856
- const filename = resolveFilename(state);
1857
- if (!filename || !filter(filename)) return;
1858
- const source = state.file.code;
1859
- const root = resolveBabelRoot(state, options, filename);
1860
- let context;
1861
- try {
1862
- context = getFileAnnotationContext({
1863
- source,
1864
- filename,
1865
- root,
1866
- canonicalizeFilename: true
1867
- });
1868
- } catch {
1869
- return;
1870
- }
1871
- if (context.filepath === "index.js") {
1872
- injectProjectRootMeta(api, path2, root);
1873
- }
1874
- const componentReferences = canvasComponentAnnotations(
1875
- filename,
1876
- source,
1877
- void 0,
1878
- root
1879
- );
1880
- path2.traverse({
1881
- JSXElement(elementPath) {
1882
- const element = elementPath.node;
1883
- const tagName = getBabelTagName(element.openingElement.name);
1884
- if (FRAGMENT_TAG_NAMES.has(tagName)) return;
1885
- let container = elementPath.parentPath;
1886
- while (container && unwrapLiteralExpression(container.node) === element)
1887
- container = container.parentPath;
1888
- const isStaticJsxChild = !!container && literalJsxChild(container.node) === element && (container.parent.type === "JSXElement" || container.parent.type === "JSXFragment");
1889
- const info = {
1890
- element,
1891
- tagName,
1892
- parentType: elementPath.parent.type,
1893
- isStaticJsxChild
1894
- };
1895
- const props = computeTempoAnnotatedProps({
1896
- info,
1897
- filepath: context.filepath,
1898
- modifiedtsMs: context.modifiedtsMs,
1899
- sourceVersion: context.sourceVersion,
1900
- computeAnnotatedProps: options.computeAnnotatedProps,
1901
- elementSupportOverrides: REACT_NATIVE_SUPPORT_OVERRIDES
1902
- });
1903
- addAnnotations(api, tagName, element.openingElement, props);
1904
- const annotations = componentReferences.get(
1905
- element.openingElement.start ?? -1
1906
- );
1907
- for (const [name, value] of Object.entries(annotations ?? {})) {
1908
- element.openingElement.attributes.push(
1909
- api.types.jsxAttribute(
1910
- api.types.jsxIdentifier(name),
1911
- api.types.jsxExpressionContainer(
1912
- api.types.stringLiteral(value)
1913
- )
1914
- )
1915
- );
1916
- }
1917
- }
1918
- });
1919
- }
1920
- }
1921
- }
1922
- };
1923
- }
1924
- // Annotate the CommonJS export names for ESM import in node:
1925
- 0 && (module.exports = {
1926
- tempoExpoBabelPlugin
1927
- });
1928
- //# sourceMappingURL=expo-babel-plugin.cjs.map
1
+ "use strict";var l=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var s=(t,e)=>l(t,"name",{value:e,configurable:!0});var M=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},Z=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of X(e))!Q.call(t,i)&&i!==n&&l(t,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return t};var tt=t=>Z(l({},"__esModule",{value:!0}),t);var ft={};M(ft,{default:()=>dt,tempoExpoBabelPlugin:()=>J});module.exports=tt(ft);var q=require("crypto"),m=require("fs"),f=require("module"),r=require("path"),d=require("url");var T={};M(T,{TEMPO_HOST_IDENTITY_CAPABILITY_HEADER:()=>ot,TEMPO_HOST_IDENTITY_CONTRACT_VERSION:()=>D,TEMPO_HOST_IDENTITY_ENDPOINT:()=>nt,TEMPO_VUE_ANNOTATION_PLUGIN_NAME:()=>at,TEMPO_WORKSPACE_NONCE_ENV:()=>K,TEMPO_WORKSPACE_NONCE_META_NAME:()=>rt,createTempoHostIdentity:()=>ct,readTempoWorkspaceNonce:()=>W});var H=require("fs"),F=require("path");var v={version:"0.0.102"};var $="latest";var nt="/__tempo/identity",ot="x-tempo-host-identity",D=1,K="TEMPO_WORKSPACE_NONCE",rt="tempo-workspace-nonce",it=".tempo/workspace-nonce",st=128,at="tempo-vue-source-annotation";function j(t){let e=t?.trim()??"";return e.length>0&&e.length<=st?e:""}s(j,"normalizeWorkspaceNonce");function W(t=process.cwd()){let e=j(process.env[K]);if(e)return e;try{return j((0,H.readFileSync)((0,F.resolve)(t,it),"utf-8"))}catch{return""}}s(W,"readTempoWorkspaceNonce");function ct(t,e={}){return{tempoHost:!0,contractVersion:D,workspaceNonce:W(e.root),sdkVersion:v.version,sdkChannel:$,tempoRuntimeContract:1,pluginActive:e.pluginActive??!!process.env.TEMPO,framework:t,...e.capabilities?{capabilities:e.capabilities}:{}}}s(ct,"createTempoHostIdentity");var V={};var w=1,_="TEMPO_SDK_RUNTIME_PATH",R=typeof V.url=="string"?V.url:(0,d.pathToFileURL)(__filename).href,y=(0,f.createRequire)(R),B=new Map,g=new Map;var E;function ut(t){if(!E){let n=(0,r.dirname)((0,d.fileURLToPath)(R));for(;;){try{if(JSON.parse((0,m.readFileSync)((0,r.resolve)(n,"package.json"),"utf8")).name==="tempo-sdk"){E=n;break}}catch{}let o=(0,r.dirname)(n);if(n===o)throw p("the SDK package directory could not be found");n=o}}let e=(0,d.fileURLToPath)(R).endsWith(".ts");return(0,d.pathToFileURL)((0,r.resolve)(E,e?t:`dist/${t.replace(/\.tsx?$/,".js")}`)).href}s(ut,"sdkModuleUrl");function p(t){return new Error(`Tempo SDK runtime unavailable: ${t}. Start this project with an updated Tempo host, or provision its matching runtime and set ${_}.`)}s(p,"runtimeError");function pt(){let t=process.env[_];if(!t||!(0,r.isAbsolute)(t))throw p("an absolute runtime directory was not supplied");let e=(0,r.resolve)(t),n;try{n=JSON.parse((0,m.readFileSync)((0,r.resolve)(e,"runtime.json"),"utf8"))}catch{throw p("runtime.json could not be read")}if(n?.tempoRuntimeContract!==w)throw p(`contract ${n?.tempoRuntimeContract} does not match ${w}`);return{root:e,manifest:n}}s(pt,"readRuntimeManifest");function U(t,e,n){if(!n||typeof n.file!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw p(`the ${e} entry is missing or invalid`);let o=(0,r.resolve)(t,n.file),i=(0,r.relative)(t,o);if((0,r.isAbsolute)(i)||i===".."||i.startsWith(`..${r.sep}`))throw p(`the ${e} entry escapes its runtime directory`);let c;try{let u=(0,r.relative)((0,m.realpathSync)(t),(0,m.realpathSync)(o));if((0,r.isAbsolute)(u)||u===".."||u.startsWith(`..${r.sep}`))throw p(`the ${e} entry escapes its runtime directory`);c=(0,m.readFileSync)(o)}catch{throw p(`the ${e} artifact could not be read`)}if((0,q.createHash)("sha256").update(c).digest("hex")!==n.sha256)throw p(`the ${e} artifact failed its integrity check`);return o}s(U,"verifyArtifact");function x(t){if(typeof t=="string")return t;if(Array.isArray(t)){for(let e of t){let n=x(e);if(n)return n}return}if(!(!t||typeof t!="object"))for(let[e,n]of Object.entries(t)){if(!(["node","import","default"].includes(e)||e==="module-sync"&&process.features.require_module))continue;let i=x(n);if(i)return i}}s(x,"importExportTarget");function mt(t,e){if((0,f.isBuiltin)(t))return t;let n=e.resolve(`${t}/package.json`),o=JSON.parse((0,m.readFileSync)(n,"utf8")),i=o.exports,c=i===void 0?o.module??o.main:x(i?.["."]??i);if(typeof c!="string")throw p(`${t} has no supported Node import entry`);return(0,d.pathToFileURL)((0,r.resolve)((0,r.dirname)(n),c)).href}s(mt,"resolveProjectImport");function L(t,e=process.cwd(),n={}){let o=process.env[_];if(!o||!(0,r.isAbsolute)(o))throw p("an absolute runtime directory was not supplied");let i=(0,r.resolve)(o),c=(0,r.resolve)(e),u=`${i}\0${c}\0${t}`;if(g.has(u))return g.get(u);let{manifest:b}=pt(),k=b.node?.[t],G=U(i,t,k);y(U(i,"serverBrowser",b.serverBrowser));let N=`${i}\0${c}\0${k.file}`,A=B.get(N);if(A){let a=A.getEntry(t);return g.set(u,a),a}let h=y(G);if(h.tempoRuntimeContract!==w||typeof h.createRuntime!="function")throw p(`the ${t} factory has an incompatible contract`);let P=(0,f.createRequire)((0,r.resolve)(c,"package.json")),O=s(a=>(0,f.isBuiltin)(a)||a==="oxc-parser"||a.startsWith("oxc-parser/")||a.startsWith("@astrojs/compiler-")?y:P,"from"),C=Object.assign(a=>a==="@tempo-sdk-public/host-identity"?T:Object.hasOwn(n,a)?n[a]:O(a)(a),P,{resolve:s((a,Y)=>O(a).resolve(a,Y),"resolve")}),I=h.createRuntime({require:C,projectRoot:c,import:s(a=>import(mt(a,C)),"import"),sdkModuleUrl:ut});B.set(N,I);let S=I.getEntry(t);return g.set(u,S),S}s(L,"getNodeRuntime");var J=s(function(t,e={}){return e.enabled??!!process.env.TEMPO?L("expo-babel-plugin",e.root).tempoExpoBabelPlugin(t,e):(t.assertVersion(7),{name:"tempo-expo-annotate",manipulateOptions(n,o){o.plugins??(o.plugins=[]);let i=s(c=>o.plugins.some(u=>(Array.isArray(u)?u[0]:u)===c),"has");i("jsx")||o.plugins.push("jsx"),/\.(ts|tsx)$/.test(n.filename??"")&&!i("typescript")&&o.plugins.push("typescript")},visitor:{Program:{enter(){}}}})},"tempoExpoBabelPlugin"),dt=J;0&&(module.exports={tempoExpoBabelPlugin});