tempo-sdk 0.0.16 → 0.0.18

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 (59) hide show
  1. package/dist/canvas/editor.d.ts +44 -9
  2. package/dist/canvas/editor.js +116 -416
  3. package/dist/canvas/editor.js.map +1 -1
  4. package/dist/canvas/index.d.ts +1 -0
  5. package/dist/canvas/index.js +152 -44
  6. package/dist/canvas/index.js.map +1 -1
  7. package/dist/canvas/parser.d.ts +1 -2
  8. package/dist/canvas/parser.js +1 -3
  9. package/dist/{chunk-ICP7LCPJ.js → chunk-6Q4I3RFN.js} +37 -9
  10. package/dist/chunk-6Q4I3RFN.js.map +1 -0
  11. package/dist/{chunk-77BNMPBS.js → chunk-CB5NJJJT.js} +31 -5
  12. package/dist/chunk-CB5NJJJT.js.map +1 -0
  13. package/dist/expo/plugin.cjs +30 -4
  14. package/dist/expo/plugin.cjs.map +1 -1
  15. package/dist/expo/plugin.js +1 -1
  16. package/dist/expo-babel-plugin.cjs +30 -4
  17. package/dist/expo-babel-plugin.cjs.map +1 -1
  18. package/dist/expo-babel-plugin.d.cts +1 -1
  19. package/dist/expo-babel-plugin.d.ts +1 -1
  20. package/dist/expo-babel-plugin.js +1 -1
  21. package/dist/index.js +26 -6
  22. package/dist/index.js.map +1 -1
  23. package/dist/nextjs-loader.cjs +29 -4
  24. package/dist/nextjs-loader.cjs.map +1 -1
  25. package/package.json +4 -3
  26. package/dist/annotation-strategy-DCJHc--2.d.cts +0 -13
  27. package/dist/annotation-strategy-DCJHc--2.d.ts +0 -13
  28. package/dist/chunk-2LP5G6CD.js +0 -748
  29. package/dist/chunk-2LP5G6CD.js.map +0 -1
  30. package/dist/chunk-77BNMPBS.js.map +0 -1
  31. package/dist/chunk-B3PHU7XX.js +0 -571
  32. package/dist/chunk-B3PHU7XX.js.map +0 -1
  33. package/dist/chunk-EJBWZCEE.js +0 -434
  34. package/dist/chunk-EJBWZCEE.js.map +0 -1
  35. package/dist/chunk-F64WRL4H.js +0 -884
  36. package/dist/chunk-F64WRL4H.js.map +0 -1
  37. package/dist/chunk-G7M57ARC.js +0 -902
  38. package/dist/chunk-G7M57ARC.js.map +0 -1
  39. package/dist/chunk-GHPL4LGE.js +0 -205
  40. package/dist/chunk-GHPL4LGE.js.map +0 -1
  41. package/dist/chunk-ICP7LCPJ.js.map +0 -1
  42. package/dist/chunk-IG3JZVZI.js +0 -846
  43. package/dist/chunk-IG3JZVZI.js.map +0 -1
  44. package/dist/chunk-MBTLXFNP.js +0 -605
  45. package/dist/chunk-MBTLXFNP.js.map +0 -1
  46. package/dist/chunk-MD3HJ7L3.js +0 -457
  47. package/dist/chunk-MD3HJ7L3.js.map +0 -1
  48. package/dist/chunk-O3HYJ6BU.js +0 -433
  49. package/dist/chunk-O3HYJ6BU.js.map +0 -1
  50. package/dist/chunk-WGGLHHC5.js +0 -337
  51. package/dist/chunk-WGGLHHC5.js.map +0 -1
  52. package/dist/chunk-X3K7Z2BH.js +0 -900
  53. package/dist/chunk-X3K7Z2BH.js.map +0 -1
  54. package/dist/chunk-ZHORRCQG.js +0 -756
  55. package/dist/chunk-ZHORRCQG.js.map +0 -1
  56. package/dist/index.cjs +0 -1170
  57. package/dist/index.cjs.map +0 -1
  58. package/dist/index.d.cts +0 -99
  59. package/dist/page-BokkL6FZ.d.ts +0 -35
@@ -1,434 +0,0 @@
1
- // canvas/parser.ts
2
- import { parseSync } from "oxc-parser";
3
- var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set(["tempo-sdk/canvas"]);
4
- var SDK_COMPONENTS = /* @__PURE__ */ new Set([
5
- "Canvas",
6
- "Storyboard",
7
- "RouteStoryboard",
8
- "HtmlStoryboard"
9
- ]);
10
- var DEFAULT_LAYOUT = {
11
- x: 0,
12
- y: 0,
13
- width: 600,
14
- height: 400
15
- };
16
- function parseCanvasFile(filePath, source) {
17
- const errors = [];
18
- let program;
19
- try {
20
- const result = parseSync(filePath, source);
21
- program = result.program;
22
- for (const error of result.errors ?? []) {
23
- errors.push({
24
- message: error.message ?? "Unable to parse canvas source",
25
- span: toSpan(error) ?? toSpan(error?.labels?.[0])
26
- });
27
- }
28
- } catch (error) {
29
- return {
30
- filePath,
31
- pageName: fallbackPageName(filePath),
32
- imports: [],
33
- storyboards: [],
34
- errors: [
35
- {
36
- message: error instanceof Error ? error.message : "Unable to parse canvas source"
37
- }
38
- ]
39
- };
40
- }
41
- const imports = readImports(program);
42
- const storyboards = [];
43
- let canvasElement = null;
44
- walk(program, (node) => {
45
- if (node.type !== "JSXElement") return;
46
- const component = resolveSdkComponent(node.openingElement?.name, imports);
47
- if (component === "Canvas" && !canvasElement) {
48
- canvasElement = node;
49
- return;
50
- }
51
- if (component === "Storyboard" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
52
- storyboards.push(readStoryboard(node, component, imports, source, errors));
53
- }
54
- });
55
- if (!canvasElement) {
56
- errors.push({ message: "No <Canvas> declaration found in canvas file" });
57
- }
58
- const openingElement = canvasElement?.openingElement;
59
- const name = readStringAttribute(openingElement, "name");
60
- const path = readStringAttribute(openingElement, "path");
61
- const backgroundColor = readStringAttribute(openingElement, "backgroundColor") ?? readStringAttribute(openingElement, "background");
62
- if (openingElement && !name) {
63
- errors.push({
64
- message: '<Canvas> must include a literal "name" prop',
65
- span: toSpan(openingElement)
66
- });
67
- }
68
- if (openingElement && !path) {
69
- errors.push({
70
- message: '<Canvas> must include a literal "path" prop',
71
- span: toSpan(openingElement)
72
- });
73
- }
74
- validateDuplicateStoryboardKeys(storyboards, errors);
75
- return {
76
- filePath,
77
- canvasPath: path?.value,
78
- pageName: name?.value ?? fallbackPageName(filePath),
79
- backgroundColor: backgroundColor?.value,
80
- canvasElementSpan: toSpan(canvasElement),
81
- canvasOpeningElementSpan: toSpan(openingElement),
82
- canvasChildrenInsertionOffset: typeof canvasElement?.closingElement?.start === "number" ? canvasElement.closingElement.start : void 0,
83
- nameSpan: name?.valueSpan,
84
- nameAttributeSpan: name?.attributeSpan,
85
- pathSpan: path?.valueSpan,
86
- pathAttributeSpan: path?.attributeSpan,
87
- backgroundColorSpan: backgroundColor?.valueSpan,
88
- backgroundColorAttributeSpan: backgroundColor?.attributeSpan,
89
- imports: imports.all,
90
- storyboards,
91
- errors
92
- };
93
- }
94
- var parseCanvasSource = parseCanvasFile;
95
- function readImports(program) {
96
- const all = [];
97
- const byLocalName = /* @__PURE__ */ new Map();
98
- const sdkLocalNames = /* @__PURE__ */ new Map();
99
- const sdkNamespaces = /* @__PURE__ */ new Set();
100
- for (const statement of program?.body ?? []) {
101
- if (statement?.type !== "ImportDeclaration" || typeof statement.source?.value !== "string") {
102
- continue;
103
- }
104
- const source = statement.source.value;
105
- const isSdkImport = isSdkImportSource(source);
106
- for (const specifier of statement.specifiers ?? []) {
107
- const localName = specifier.local?.name;
108
- if (typeof localName !== "string") continue;
109
- const importedName = readImportedName(specifier);
110
- const imported = {
111
- localName,
112
- source,
113
- importedName,
114
- kind: readImportKind(specifier),
115
- span: toSpan(specifier) ?? toSpan(statement) ?? { start: 0, end: 0 },
116
- declarationSpan: toSpan(statement) ?? { start: 0, end: 0 },
117
- specifierCount: statement.specifiers?.length ?? 0
118
- };
119
- all.push(imported);
120
- byLocalName.set(localName, imported);
121
- if (!isSdkImport) continue;
122
- if (specifier.type === "ImportNamespaceSpecifier") {
123
- sdkNamespaces.add(localName);
124
- continue;
125
- }
126
- if (SDK_COMPONENTS.has(importedName)) {
127
- sdkLocalNames.set(localName, importedName);
128
- }
129
- }
130
- }
131
- return { all, byLocalName, sdkLocalNames, sdkNamespaces };
132
- }
133
- function readStoryboard(element, component, imports, source, globalErrors) {
134
- const openingElement = element.openingElement;
135
- const errors = [];
136
- const id = readStringAttribute(openingElement, "id");
137
- const name = readStringAttribute(openingElement, "name");
138
- const layout = readLayout(openingElement, component);
139
- const kind = component === "Storyboard" ? "component" : component === "RouteStoryboard" ? "route" : "html";
140
- if (!id) {
141
- errors.push({
142
- message: `<${component}> must include a literal "id" prop`,
143
- span: toSpan(openingElement)
144
- });
145
- }
146
- if (layout.errors.length > 0) {
147
- errors.push(...layout.errors);
148
- }
149
- const storyboard = {
150
- storyboardKey: id?.value ?? "",
151
- displayName: name?.value,
152
- kind,
153
- layout: layout.value,
154
- editable: Boolean(id) && layout.errors.length === 0,
155
- jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
156
- openingElementSpan: toSpan(openingElement),
157
- idSpan: id?.valueSpan,
158
- idAttributeSpan: id?.attributeSpan,
159
- nameSpan: name?.valueSpan,
160
- nameAttributeSpan: name?.attributeSpan,
161
- layoutAttributeSpan: layout.attributeSpan,
162
- layoutSpans: layout.spans,
163
- errors
164
- };
165
- if (component === "Storyboard") {
166
- const componentReference = readComponentReference(
167
- openingElement,
168
- imports,
169
- source
170
- );
171
- if (componentReference) {
172
- storyboard.component = componentReference;
173
- } else {
174
- errors.push({
175
- message: '<Storyboard> must include a "component" expression prop',
176
- span: toSpan(openingElement)
177
- });
178
- }
179
- }
180
- if (component === "RouteStoryboard") {
181
- const route = readStringAttribute(openingElement, "route");
182
- if (route) {
183
- storyboard.route = route.value;
184
- storyboard.routeSpan = route.valueSpan;
185
- storyboard.routeAttributeSpan = route.attributeSpan;
186
- } else {
187
- errors.push({
188
- message: '<RouteStoryboard> must include a literal "route" prop',
189
- span: toSpan(openingElement)
190
- });
191
- }
192
- }
193
- if (component === "HtmlStoryboard") {
194
- const filepath = readStringAttribute(openingElement, "filepath");
195
- const src = readStringAttribute(openingElement, "src");
196
- storyboard.filepath = filepath?.value;
197
- storyboard.filepathSpan = filepath?.valueSpan;
198
- storyboard.filepathAttributeSpan = filepath?.attributeSpan;
199
- storyboard.src = src?.value;
200
- storyboard.srcSpan = src?.valueSpan;
201
- storyboard.srcAttributeSpan = src?.attributeSpan;
202
- if (!filepath && !src) {
203
- errors.push({
204
- message: '<HtmlStoryboard> must include a literal "filepath" or "src" prop',
205
- span: toSpan(openingElement)
206
- });
207
- }
208
- }
209
- globalErrors.push(...errors);
210
- return storyboard;
211
- }
212
- function readComponentReference(openingElement, imports, source) {
213
- const attribute = getAttribute(openingElement, "component");
214
- const expression = unwrapAttributeExpression(attribute?.value);
215
- const span = toSpan(expression);
216
- if (!expression || !span) return null;
217
- const localName = expression.type === "Identifier" ? expression.name : expression.type === "MemberExpression" && expression.object?.type === "Identifier" ? expression.object.name : void 0;
218
- return {
219
- expression: source.slice(span.start, span.end),
220
- span,
221
- localName,
222
- import: localName ? imports.byLocalName.get(localName) : void 0
223
- };
224
- }
225
- function readLayout(openingElement, componentName) {
226
- const errors = [];
227
- const attribute = getAttribute(openingElement, "layout");
228
- const expression = unwrapAttributeExpression(attribute?.value);
229
- if (!expression) {
230
- return {
231
- value: DEFAULT_LAYOUT,
232
- attributeSpan: toSpan(attribute),
233
- errors: [
234
- {
235
- message: `<${componentName}> must include a literal "layout" object prop`,
236
- span: toSpan(openingElement)
237
- }
238
- ]
239
- };
240
- }
241
- if (expression.type !== "ObjectExpression") {
242
- return {
243
- value: DEFAULT_LAYOUT,
244
- attributeSpan: toSpan(attribute),
245
- spans: { layoutClose: readLayoutClose(expression) },
246
- errors: [
247
- {
248
- message: `<${componentName}> layout must be an object literal`,
249
- span: toSpan(expression)
250
- }
251
- ]
252
- };
253
- }
254
- const spans = {
255
- layoutClose: readLayoutClose(expression)
256
- };
257
- const layout = { ...DEFAULT_LAYOUT };
258
- for (const key of ["x", "y", "width", "height"]) {
259
- const property = getObjectProperty(expression, key);
260
- const value = property ? readNumberLiteral(property.value) : null;
261
- if (value) {
262
- layout[key] = value.value;
263
- spans[key] = value.span;
264
- } else {
265
- errors.push({
266
- message: `<${componentName}> layout.${key} must be a number literal`,
267
- span: toSpan(property ?? expression)
268
- });
269
- }
270
- }
271
- const zIndex = getObjectProperty(expression, "zIndex");
272
- if (zIndex) {
273
- const value = readNumberLiteral(zIndex.value);
274
- if (value) {
275
- layout.zIndex = value.value;
276
- spans.zIndex = value.span;
277
- } else {
278
- errors.push({
279
- message: `<${componentName}> layout.zIndex must be a number literal`,
280
- span: toSpan(zIndex)
281
- });
282
- }
283
- }
284
- const intrinsicSizing = getObjectProperty(expression, "intrinsicSizing");
285
- if (intrinsicSizing) {
286
- if (intrinsicSizing.value?.type === "Literal" && intrinsicSizing.value.value === "root-element") {
287
- layout.intrinsicSizing = "root-element";
288
- spans.intrinsicSizing = toSpan(intrinsicSizing.value);
289
- } else {
290
- errors.push({
291
- message: `<${componentName}> layout.intrinsicSizing must be "root-element" when set`,
292
- span: toSpan(intrinsicSizing)
293
- });
294
- }
295
- }
296
- return { value: layout, attributeSpan: toSpan(attribute), spans, errors };
297
- }
298
- function readStringAttribute(openingElement, name) {
299
- const attribute = getAttribute(openingElement, name);
300
- if (!attribute) return null;
301
- const value = attribute.value;
302
- if (value?.type === "Literal" && typeof value.value === "string") {
303
- return {
304
- value: value.value,
305
- valueSpan: toSpan(value) ?? toSpan(attribute) ?? { start: 0, end: 0 },
306
- attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
307
- };
308
- }
309
- const expression = unwrapAttributeExpression(value);
310
- if (expression?.type === "Literal" && typeof expression.value === "string") {
311
- return {
312
- value: expression.value,
313
- valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
314
- attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
315
- };
316
- }
317
- return null;
318
- }
319
- function getAttribute(openingElement, name) {
320
- for (const attribute of openingElement?.attributes ?? []) {
321
- if (attribute?.type === "JSXAttribute" && attribute.name?.type === "JSXIdentifier" && attribute.name.name === name) {
322
- return attribute;
323
- }
324
- }
325
- return null;
326
- }
327
- function unwrapAttributeExpression(value) {
328
- if (!value) return null;
329
- if (value.type === "JSXExpressionContainer") {
330
- return value.expression;
331
- }
332
- return value;
333
- }
334
- function getObjectProperty(objectExpression, name) {
335
- if (objectExpression?.type !== "ObjectExpression") return null;
336
- for (const property of objectExpression.properties ?? []) {
337
- if (property?.type !== "Property" || property.computed) continue;
338
- const propertyName = property.key?.type === "Identifier" ? property.key.name : property.key?.type === "Literal" && typeof property.key.value === "string" ? property.key.value : null;
339
- if (propertyName === name) return property;
340
- }
341
- return null;
342
- }
343
- function readNumberLiteral(node) {
344
- if (node?.type === "Literal" && typeof node.value === "number" && Number.isFinite(node.value)) {
345
- return { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } };
346
- }
347
- if (node?.type === "UnaryExpression" && node.operator === "-" && node.argument?.type === "Literal" && typeof node.argument.value === "number" && Number.isFinite(node.argument.value)) {
348
- return {
349
- value: -node.argument.value,
350
- span: toSpan(node) ?? { start: 0, end: 0 }
351
- };
352
- }
353
- return null;
354
- }
355
- function resolveSdkComponent(nameNode, imports) {
356
- if (nameNode?.type === "JSXIdentifier") {
357
- return imports.sdkLocalNames.get(nameNode.name) ?? null;
358
- }
359
- if (nameNode?.type === "JSXMemberExpression" && nameNode.object?.type === "JSXIdentifier" && nameNode.property?.type === "JSXIdentifier" && imports.sdkNamespaces.has(nameNode.object.name) && SDK_COMPONENTS.has(nameNode.property.name)) {
360
- return nameNode.property.name;
361
- }
362
- return null;
363
- }
364
- function readImportedName(specifier) {
365
- if (specifier.type === "ImportDefaultSpecifier") return "default";
366
- if (specifier.type === "ImportNamespaceSpecifier") return "*";
367
- return specifier.imported?.name ?? specifier.local?.name ?? "unknown";
368
- }
369
- function readImportKind(specifier) {
370
- if (specifier.type === "ImportDefaultSpecifier") return "default";
371
- if (specifier.type === "ImportNamespaceSpecifier") return "namespace";
372
- return "named";
373
- }
374
- function isSdkImportSource(source) {
375
- return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas");
376
- }
377
- function validateDuplicateStoryboardKeys(storyboards, errors) {
378
- const firstByKey = /* @__PURE__ */ new Map();
379
- for (const storyboard of storyboards) {
380
- if (!storyboard.storyboardKey) continue;
381
- const first = firstByKey.get(storyboard.storyboardKey);
382
- if (!first) {
383
- firstByKey.set(storyboard.storyboardKey, storyboard);
384
- continue;
385
- }
386
- const error = {
387
- message: `Duplicate storyboard id "${storyboard.storyboardKey}"`,
388
- span: storyboard.idSpan ?? storyboard.jsxElementSpan
389
- };
390
- storyboard.errors.push(error);
391
- errors.push(error);
392
- if (first.errors.every((item) => item.message !== error.message)) {
393
- first.errors.push({
394
- message: `Duplicate storyboard id "${storyboard.storyboardKey}"`,
395
- span: first.idSpan ?? first.jsxElementSpan
396
- });
397
- }
398
- }
399
- }
400
- function readLayoutClose(node) {
401
- return typeof node?.end === "number" && Number.isFinite(node.end) ? node.end - 1 : void 0;
402
- }
403
- function fallbackPageName(filePath) {
404
- const normalized = filePath.replace(/\\/g, "/");
405
- const segments = normalized.split("/").filter(Boolean);
406
- const fileName = segments.length > 0 ? segments[segments.length - 1] : filePath;
407
- const parentName = segments.length > 1 ? segments[segments.length - 2] : fileName;
408
- const baseName = /^index\.canvas\.[tj]sx?$/.test(fileName) ? parentName : fileName.replace(/\.canvas\.[tj]sx?$/, "");
409
- return baseName.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
410
- }
411
- function toSpan(node) {
412
- 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;
413
- }
414
- function walk(node, visitor, seen = /* @__PURE__ */ new Set()) {
415
- if (!node || typeof node !== "object" || seen.has(node)) return;
416
- seen.add(node);
417
- visitor(node);
418
- for (const value of Object.values(node)) {
419
- if (!value) continue;
420
- if (Array.isArray(value)) {
421
- for (const item of value) {
422
- walk(item, visitor, seen);
423
- }
424
- } else if (typeof value === "object") {
425
- walk(value, visitor, seen);
426
- }
427
- }
428
- }
429
-
430
- export {
431
- parseCanvasFile,
432
- parseCanvasSource
433
- };
434
- //# sourceMappingURL=chunk-EJBWZCEE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas/parser.ts"],"sourcesContent":["import { parseSync } from \"oxc-parser\";\n\nexport type CanvasSourceSpan = { start: number; end: number };\n\nexport type CanvasParseError = {\n message: string;\n span?: CanvasSourceSpan;\n};\n\nexport type ParsedCanvasImport = {\n localName: string;\n source: string;\n importedName: string;\n kind: \"default\" | \"named\" | \"namespace\";\n span: CanvasSourceSpan;\n declarationSpan: CanvasSourceSpan;\n specifierCount: number;\n};\n\nexport type ParsedCanvasLayout = {\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex?: number;\n intrinsicSizing?: \"root-element\";\n};\n\nexport type ParsedCanvasLayoutSpans = {\n x?: CanvasSourceSpan;\n y?: CanvasSourceSpan;\n width?: CanvasSourceSpan;\n height?: CanvasSourceSpan;\n zIndex?: CanvasSourceSpan;\n intrinsicSizing?: CanvasSourceSpan;\n layoutClose?: number;\n};\n\nexport type ParsedCanvasComponentReference = {\n expression: string;\n span: CanvasSourceSpan;\n localName?: string;\n import?: ParsedCanvasImport;\n};\n\nexport type ParsedCanvasStoryboard = {\n storyboardKey: string;\n displayName?: string;\n kind: \"component\" | \"route\" | \"html\";\n layout: ParsedCanvasLayout;\n editable: boolean;\n jsxElementSpan: CanvasSourceSpan;\n openingElementSpan?: CanvasSourceSpan;\n idSpan?: CanvasSourceSpan;\n idAttributeSpan?: CanvasSourceSpan;\n nameSpan?: CanvasSourceSpan;\n nameAttributeSpan?: CanvasSourceSpan;\n layoutAttributeSpan?: CanvasSourceSpan;\n layoutSpans?: ParsedCanvasLayoutSpans;\n component?: ParsedCanvasComponentReference;\n route?: string;\n routeSpan?: CanvasSourceSpan;\n routeAttributeSpan?: CanvasSourceSpan;\n filepath?: string;\n filepathSpan?: CanvasSourceSpan;\n filepathAttributeSpan?: CanvasSourceSpan;\n src?: string;\n srcSpan?: CanvasSourceSpan;\n srcAttributeSpan?: CanvasSourceSpan;\n errors: CanvasParseError[];\n};\n\nexport type ParsedCanvasFile = {\n filePath: string;\n canvasPath?: string;\n pageName: string;\n backgroundColor?: string;\n canvasElementSpan?: CanvasSourceSpan;\n canvasOpeningElementSpan?: CanvasSourceSpan;\n canvasChildrenInsertionOffset?: number;\n nameSpan?: CanvasSourceSpan;\n nameAttributeSpan?: CanvasSourceSpan;\n pathSpan?: CanvasSourceSpan;\n pathAttributeSpan?: CanvasSourceSpan;\n backgroundColorSpan?: CanvasSourceSpan;\n backgroundColorAttributeSpan?: CanvasSourceSpan;\n imports: ParsedCanvasImport[];\n storyboards: ParsedCanvasStoryboard[];\n errors: CanvasParseError[];\n};\n\ntype SdkComponent =\n | \"Canvas\"\n | \"Storyboard\"\n | \"RouteStoryboard\"\n | \"HtmlStoryboard\";\n\ntype ParsedImports = {\n all: ParsedCanvasImport[];\n byLocalName: Map<string, ParsedCanvasImport>;\n sdkLocalNames: Map<string, SdkComponent>;\n sdkNamespaces: Set<string>;\n};\n\nconst SDK_IMPORT_SOURCES = new Set([\"tempo-sdk/canvas\"]);\n\nconst SDK_COMPONENTS = new Set<SdkComponent>([\n \"Canvas\",\n \"Storyboard\",\n \"RouteStoryboard\",\n \"HtmlStoryboard\",\n]);\n\nconst DEFAULT_LAYOUT: ParsedCanvasLayout = {\n x: 0,\n y: 0,\n width: 600,\n height: 400,\n};\n\nexport function parseCanvasFile(\n filePath: string,\n source: string,\n): ParsedCanvasFile {\n const errors: CanvasParseError[] = [];\n let program: any;\n\n try {\n const result = parseSync(filePath, source) as any;\n program = result.program;\n for (const error of result.errors ?? []) {\n errors.push({\n message: error.message ?? \"Unable to parse canvas source\",\n span: toSpan(error) ?? toSpan(error?.labels?.[0]),\n });\n }\n } catch (error) {\n return {\n filePath,\n pageName: fallbackPageName(filePath),\n imports: [],\n storyboards: [],\n errors: [\n {\n message:\n error instanceof Error\n ? error.message\n : \"Unable to parse canvas source\",\n },\n ],\n };\n }\n\n const imports = readImports(program);\n const storyboards: ParsedCanvasStoryboard[] = [];\n let canvasElement: any | null = null;\n\n walk(program, (node) => {\n if (node.type !== \"JSXElement\") return;\n\n const component = resolveSdkComponent(node.openingElement?.name, imports);\n if (component === \"Canvas\" && !canvasElement) {\n canvasElement = node;\n return;\n }\n\n if (\n component === \"Storyboard\" ||\n component === \"RouteStoryboard\" ||\n component === \"HtmlStoryboard\"\n ) {\n storyboards.push(readStoryboard(node, component, imports, source, errors));\n }\n });\n\n if (!canvasElement) {\n errors.push({ message: \"No <Canvas> declaration found in canvas file\" });\n }\n\n const openingElement = canvasElement?.openingElement;\n const name = readStringAttribute(openingElement, \"name\");\n const path = readStringAttribute(openingElement, \"path\");\n const backgroundColor =\n readStringAttribute(openingElement, \"backgroundColor\") ??\n readStringAttribute(openingElement, \"background\");\n\n if (openingElement && !name) {\n errors.push({\n message: '<Canvas> must include a literal \"name\" prop',\n span: toSpan(openingElement),\n });\n }\n\n if (openingElement && !path) {\n errors.push({\n message: '<Canvas> must include a literal \"path\" prop',\n span: toSpan(openingElement),\n });\n }\n\n validateDuplicateStoryboardKeys(storyboards, errors);\n\n return {\n filePath,\n canvasPath: path?.value,\n pageName: name?.value ?? fallbackPageName(filePath),\n backgroundColor: backgroundColor?.value,\n canvasElementSpan: toSpan(canvasElement),\n canvasOpeningElementSpan: toSpan(openingElement),\n canvasChildrenInsertionOffset:\n typeof canvasElement?.closingElement?.start === \"number\"\n ? canvasElement.closingElement.start\n : undefined,\n nameSpan: name?.valueSpan,\n nameAttributeSpan: name?.attributeSpan,\n pathSpan: path?.valueSpan,\n pathAttributeSpan: path?.attributeSpan,\n backgroundColorSpan: backgroundColor?.valueSpan,\n backgroundColorAttributeSpan: backgroundColor?.attributeSpan,\n imports: imports.all,\n storyboards,\n errors,\n };\n}\n\nexport const parseCanvasSource = parseCanvasFile;\n\nfunction readImports(program: any): ParsedImports {\n const all: ParsedCanvasImport[] = [];\n const byLocalName = new Map<string, ParsedCanvasImport>();\n const sdkLocalNames = new Map<string, SdkComponent>();\n const sdkNamespaces = new Set<string>();\n\n for (const statement of program?.body ?? []) {\n if (\n statement?.type !== \"ImportDeclaration\" ||\n typeof statement.source?.value !== \"string\"\n ) {\n continue;\n }\n\n const source = statement.source.value;\n const isSdkImport = isSdkImportSource(source);\n\n for (const specifier of statement.specifiers ?? []) {\n const localName = specifier.local?.name;\n if (typeof localName !== \"string\") continue;\n\n const importedName = readImportedName(specifier);\n const imported: ParsedCanvasImport = {\n localName,\n source,\n importedName,\n kind: readImportKind(specifier),\n span: toSpan(specifier) ?? toSpan(statement) ?? { start: 0, end: 0 },\n declarationSpan: toSpan(statement) ?? { start: 0, end: 0 },\n specifierCount: statement.specifiers?.length ?? 0,\n };\n\n all.push(imported);\n byLocalName.set(localName, imported);\n\n if (!isSdkImport) continue;\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n sdkNamespaces.add(localName);\n continue;\n }\n\n if (SDK_COMPONENTS.has(importedName as SdkComponent)) {\n sdkLocalNames.set(localName, importedName as SdkComponent);\n }\n }\n }\n\n return { all, byLocalName, sdkLocalNames, sdkNamespaces };\n}\n\nfunction readStoryboard(\n element: any,\n component: Exclude<SdkComponent, \"Canvas\">,\n imports: ParsedImports,\n source: string,\n globalErrors: CanvasParseError[],\n): ParsedCanvasStoryboard {\n const openingElement = element.openingElement;\n const errors: CanvasParseError[] = [];\n const id = readStringAttribute(openingElement, \"id\");\n const name = readStringAttribute(openingElement, \"name\");\n const layout = readLayout(openingElement, component);\n const kind =\n component === \"Storyboard\"\n ? \"component\"\n : component === \"RouteStoryboard\"\n ? \"route\"\n : \"html\";\n\n if (!id) {\n errors.push({\n message: `<${component}> must include a literal \"id\" prop`,\n span: toSpan(openingElement),\n });\n }\n\n if (layout.errors.length > 0) {\n errors.push(...layout.errors);\n }\n\n const storyboard: ParsedCanvasStoryboard = {\n storyboardKey: id?.value ?? \"\",\n displayName: name?.value,\n kind,\n layout: layout.value,\n editable: Boolean(id) && layout.errors.length === 0,\n jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },\n openingElementSpan: toSpan(openingElement),\n idSpan: id?.valueSpan,\n idAttributeSpan: id?.attributeSpan,\n nameSpan: name?.valueSpan,\n nameAttributeSpan: name?.attributeSpan,\n layoutAttributeSpan: layout.attributeSpan,\n layoutSpans: layout.spans,\n errors,\n };\n\n if (component === \"Storyboard\") {\n const componentReference = readComponentReference(\n openingElement,\n imports,\n source,\n );\n if (componentReference) {\n storyboard.component = componentReference;\n } else {\n errors.push({\n message: '<Storyboard> must include a \"component\" expression prop',\n span: toSpan(openingElement),\n });\n }\n }\n\n if (component === \"RouteStoryboard\") {\n const route = readStringAttribute(openingElement, \"route\");\n if (route) {\n storyboard.route = route.value;\n storyboard.routeSpan = route.valueSpan;\n storyboard.routeAttributeSpan = route.attributeSpan;\n } else {\n errors.push({\n message: '<RouteStoryboard> must include a literal \"route\" prop',\n span: toSpan(openingElement),\n });\n }\n }\n\n if (component === \"HtmlStoryboard\") {\n const filepath = readStringAttribute(openingElement, \"filepath\");\n const src = readStringAttribute(openingElement, \"src\");\n storyboard.filepath = filepath?.value;\n storyboard.filepathSpan = filepath?.valueSpan;\n storyboard.filepathAttributeSpan = filepath?.attributeSpan;\n storyboard.src = src?.value;\n storyboard.srcSpan = src?.valueSpan;\n storyboard.srcAttributeSpan = src?.attributeSpan;\n if (!filepath && !src) {\n errors.push({\n message:\n '<HtmlStoryboard> must include a literal \"filepath\" or \"src\" prop',\n span: toSpan(openingElement),\n });\n }\n }\n\n globalErrors.push(...errors);\n return storyboard;\n}\n\nfunction readComponentReference(\n openingElement: any,\n imports: ParsedImports,\n source: string,\n): ParsedCanvasComponentReference | null {\n const attribute = getAttribute(openingElement, \"component\");\n const expression = unwrapAttributeExpression(attribute?.value);\n const span = toSpan(expression);\n if (!expression || !span) return null;\n\n const localName =\n expression.type === \"Identifier\"\n ? expression.name\n : expression.type === \"MemberExpression\" &&\n expression.object?.type === \"Identifier\"\n ? expression.object.name\n : undefined;\n\n return {\n expression: source.slice(span.start, span.end),\n span,\n localName,\n import: localName ? imports.byLocalName.get(localName) : undefined,\n };\n}\n\nfunction readLayout(\n openingElement: any,\n componentName: string,\n): {\n value: ParsedCanvasLayout;\n attributeSpan?: CanvasSourceSpan;\n spans?: ParsedCanvasLayoutSpans;\n errors: CanvasParseError[];\n} {\n const errors: CanvasParseError[] = [];\n const attribute = getAttribute(openingElement, \"layout\");\n const expression = unwrapAttributeExpression(attribute?.value);\n\n if (!expression) {\n return {\n value: DEFAULT_LAYOUT,\n attributeSpan: toSpan(attribute),\n errors: [\n {\n message: `<${componentName}> must include a literal \"layout\" object prop`,\n span: toSpan(openingElement),\n },\n ],\n };\n }\n\n if (expression.type !== \"ObjectExpression\") {\n return {\n value: DEFAULT_LAYOUT,\n attributeSpan: toSpan(attribute),\n spans: { layoutClose: readLayoutClose(expression) },\n errors: [\n {\n message: `<${componentName}> layout must be an object literal`,\n span: toSpan(expression),\n },\n ],\n };\n }\n\n const spans: ParsedCanvasLayoutSpans = {\n layoutClose: readLayoutClose(expression),\n };\n const layout: ParsedCanvasLayout = { ...DEFAULT_LAYOUT };\n\n for (const key of [\"x\", \"y\", \"width\", \"height\"] as const) {\n const property = getObjectProperty(expression, key);\n const value = property ? readNumberLiteral(property.value) : null;\n if (value) {\n layout[key] = value.value;\n spans[key] = value.span;\n } else {\n errors.push({\n message: `<${componentName}> layout.${key} must be a number literal`,\n span: toSpan(property ?? expression),\n });\n }\n }\n\n const zIndex = getObjectProperty(expression, \"zIndex\");\n if (zIndex) {\n const value = readNumberLiteral(zIndex.value);\n if (value) {\n layout.zIndex = value.value;\n spans.zIndex = value.span;\n } else {\n errors.push({\n message: `<${componentName}> layout.zIndex must be a number literal`,\n span: toSpan(zIndex),\n });\n }\n }\n\n const intrinsicSizing = getObjectProperty(expression, \"intrinsicSizing\");\n if (intrinsicSizing) {\n if (\n intrinsicSizing.value?.type === \"Literal\" &&\n intrinsicSizing.value.value === \"root-element\"\n ) {\n layout.intrinsicSizing = \"root-element\";\n spans.intrinsicSizing = toSpan(intrinsicSizing.value);\n } else {\n errors.push({\n message: `<${componentName}> layout.intrinsicSizing must be \"root-element\" when set`,\n span: toSpan(intrinsicSizing),\n });\n }\n }\n\n return { value: layout, attributeSpan: toSpan(attribute), spans, errors };\n}\n\nfunction readStringAttribute(\n openingElement: any,\n name: string,\n): {\n value: string;\n valueSpan: CanvasSourceSpan;\n attributeSpan: CanvasSourceSpan;\n} | null {\n const attribute = getAttribute(openingElement, name);\n if (!attribute) return null;\n\n const value = attribute.value;\n if (value?.type === \"Literal\" && typeof value.value === \"string\") {\n return {\n value: value.value,\n valueSpan: toSpan(value) ?? toSpan(attribute) ?? { start: 0, end: 0 },\n attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 },\n };\n }\n\n const expression = unwrapAttributeExpression(value);\n if (expression?.type === \"Literal\" && typeof expression.value === \"string\") {\n return {\n value: expression.value,\n valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },\n attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 },\n };\n }\n return null;\n}\n\nfunction getAttribute(openingElement: any, name: string): any | null {\n for (const attribute of openingElement?.attributes ?? []) {\n if (\n attribute?.type === \"JSXAttribute\" &&\n attribute.name?.type === \"JSXIdentifier\" &&\n attribute.name.name === name\n ) {\n return attribute;\n }\n }\n return null;\n}\n\nfunction unwrapAttributeExpression(value: any): any | null {\n if (!value) return null;\n if (value.type === \"JSXExpressionContainer\") {\n return value.expression;\n }\n return value;\n}\n\nfunction getObjectProperty(objectExpression: any, name: string): any | null {\n if (objectExpression?.type !== \"ObjectExpression\") return null;\n for (const property of objectExpression.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) continue;\n const propertyName =\n property.key?.type === \"Identifier\"\n ? property.key.name\n : property.key?.type === \"Literal\" &&\n typeof property.key.value === \"string\"\n ? property.key.value\n : null;\n if (propertyName === name) return property;\n }\n return null;\n}\n\nfunction readNumberLiteral(\n node: any,\n): { value: number; span: CanvasSourceSpan } | null {\n if (\n node?.type === \"Literal\" &&\n typeof node.value === \"number\" &&\n Number.isFinite(node.value)\n ) {\n return { value: node.value, span: toSpan(node) ?? { start: 0, end: 0 } };\n }\n\n if (\n node?.type === \"UnaryExpression\" &&\n node.operator === \"-\" &&\n node.argument?.type === \"Literal\" &&\n typeof node.argument.value === \"number\" &&\n Number.isFinite(node.argument.value)\n ) {\n return {\n value: -node.argument.value,\n span: toSpan(node) ?? { start: 0, end: 0 },\n };\n }\n\n return null;\n}\n\nfunction resolveSdkComponent(\n nameNode: any,\n imports: ParsedImports,\n): SdkComponent | null {\n if (nameNode?.type === \"JSXIdentifier\") {\n return imports.sdkLocalNames.get(nameNode.name) ?? null;\n }\n\n if (\n nameNode?.type === \"JSXMemberExpression\" &&\n nameNode.object?.type === \"JSXIdentifier\" &&\n nameNode.property?.type === \"JSXIdentifier\" &&\n imports.sdkNamespaces.has(nameNode.object.name) &&\n SDK_COMPONENTS.has(nameNode.property.name as SdkComponent)\n ) {\n return nameNode.property.name as SdkComponent;\n }\n\n return null;\n}\n\nfunction readImportedName(specifier: any): string {\n if (specifier.type === \"ImportDefaultSpecifier\") return \"default\";\n if (specifier.type === \"ImportNamespaceSpecifier\") return \"*\";\n return specifier.imported?.name ?? specifier.local?.name ?? \"unknown\";\n}\n\nfunction readImportKind(specifier: any): ParsedCanvasImport[\"kind\"] {\n if (specifier.type === \"ImportDefaultSpecifier\") return \"default\";\n if (specifier.type === \"ImportNamespaceSpecifier\") return \"namespace\";\n return \"named\";\n}\n\nfunction isSdkImportSource(source: string): boolean {\n return SDK_IMPORT_SOURCES.has(source) || source.endsWith(\"/tempo-sdk/canvas\");\n}\n\nfunction validateDuplicateStoryboardKeys(\n storyboards: ParsedCanvasStoryboard[],\n errors: CanvasParseError[],\n) {\n const firstByKey = new Map<string, ParsedCanvasStoryboard>();\n for (const storyboard of storyboards) {\n if (!storyboard.storyboardKey) continue;\n const first = firstByKey.get(storyboard.storyboardKey);\n if (!first) {\n firstByKey.set(storyboard.storyboardKey, storyboard);\n continue;\n }\n\n const error = {\n message: `Duplicate storyboard id \"${storyboard.storyboardKey}\"`,\n span: storyboard.idSpan ?? storyboard.jsxElementSpan,\n };\n storyboard.errors.push(error);\n errors.push(error);\n\n if (first.errors.every((item) => item.message !== error.message)) {\n first.errors.push({\n message: `Duplicate storyboard id \"${storyboard.storyboardKey}\"`,\n span: first.idSpan ?? first.jsxElementSpan,\n });\n }\n }\n}\n\nfunction readLayoutClose(node: any): number | undefined {\n return typeof node?.end === \"number\" && Number.isFinite(node.end)\n ? node.end - 1\n : undefined;\n}\n\nfunction fallbackPageName(filePath: string): string {\n const normalized = filePath.replace(/\\\\/g, \"/\");\n const segments = normalized.split(\"/\").filter(Boolean);\n const fileName =\n segments.length > 0 ? segments[segments.length - 1] : filePath;\n const parentName =\n segments.length > 1 ? segments[segments.length - 2] : fileName;\n const baseName = /^index\\.canvas\\.[tj]sx?$/.test(fileName)\n ? parentName\n : fileName.replace(/\\.canvas\\.[tj]sx?$/, \"\");\n\n return baseName\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n}\n\nfunction toSpan(node: any): CanvasSourceSpan | undefined {\n return typeof node?.start === \"number\" &&\n Number.isFinite(node.start) &&\n typeof node?.end === \"number\" &&\n Number.isFinite(node.end)\n ? { start: node.start, end: node.end }\n : undefined;\n}\n\nfunction walk(node: any, visitor: (node: any) => void, seen = new Set<any>()) {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n visitor(node);\n\n for (const value of Object.values(node)) {\n if (!value) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n walk(item, visitor, seen);\n }\n } else if (typeof value === \"object\") {\n walk(value, visitor, seen);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAwG1B,IAAM,qBAAqB,oBAAI,IAAI,CAAC,kBAAkB,CAAC;AAEvD,IAAM,iBAAiB,oBAAI,IAAkB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,iBAAqC;AAAA,EACzC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,SAAS,gBACd,UACA,QACkB;AA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