tempo-sdk 0.0.69 → 0.0.76

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 (109) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +2 -2
  3. package/dist/astro.js +24 -14
  4. package/dist/astro.js.map +1 -1
  5. package/dist/canvas/astro.d.ts +1 -1
  6. package/dist/canvas/astro.js +2 -2
  7. package/dist/canvas/editor.d.ts +15 -5
  8. package/dist/canvas/editor.js +13 -8
  9. package/dist/canvas/editor.js.map +1 -1
  10. package/dist/canvas/flutter-preview.d.ts +18 -0
  11. package/dist/canvas/flutter-preview.js +9 -0
  12. package/dist/canvas/flutter-preview.js.map +1 -0
  13. package/dist/canvas/index.d.ts +33 -2
  14. package/dist/canvas/index.js +1134 -26
  15. package/dist/canvas/index.js.map +1 -1
  16. package/dist/canvas/interact-projection.js +5 -4
  17. package/dist/canvas/parser.d.ts +142 -3
  18. package/dist/canvas/parser.js +14 -1
  19. package/dist/canvas/svelte.d.ts +1 -1
  20. package/dist/canvas/svelte.js +2 -2
  21. package/dist/canvas/vue.d.ts +74 -0
  22. package/dist/canvas/vue.js +264 -0
  23. package/dist/canvas/vue.js.map +1 -0
  24. package/dist/{chunk-6BSLP7P3.js → chunk-3W4CVWTK.js} +49 -7
  25. package/dist/chunk-3W4CVWTK.js.map +1 -0
  26. package/dist/chunk-5HIIF354.js +67 -0
  27. package/dist/chunk-5HIIF354.js.map +1 -0
  28. package/dist/chunk-5LUQSXSP.js +342 -0
  29. package/dist/chunk-5LUQSXSP.js.map +1 -0
  30. package/dist/{chunk-FE6TYCLF.js → chunk-5VIBKVFO.js} +2 -2
  31. package/dist/{chunk-FE6TYCLF.js.map → chunk-5VIBKVFO.js.map} +1 -1
  32. package/dist/{chunk-77DZCV5Z.js → chunk-CXIW4IKC.js} +2 -2
  33. package/dist/chunk-CYQE3TLC.js +37 -0
  34. package/dist/chunk-CYQE3TLC.js.map +1 -0
  35. package/dist/chunk-EGRHWZRV.js +1 -0
  36. package/dist/chunk-EGRHWZRV.js.map +1 -0
  37. package/dist/chunk-GCGRJTTS.js +285 -0
  38. package/dist/chunk-GCGRJTTS.js.map +1 -0
  39. package/dist/{chunk-EYKOOLPL.js → chunk-GKDDNDG3.js} +1039 -134
  40. package/dist/chunk-GKDDNDG3.js.map +1 -0
  41. package/dist/{chunk-KOSJXE4G.js → chunk-H6BQZOAW.js} +4 -3
  42. package/dist/chunk-HOBTDB6G.js +112 -0
  43. package/dist/chunk-HOBTDB6G.js.map +1 -0
  44. package/dist/{chunk-WTQQOLXM.js → chunk-R3RYGAPB.js} +1571 -1410
  45. package/dist/chunk-R3RYGAPB.js.map +1 -0
  46. package/dist/chunk-SGN7BDRE.js +16 -0
  47. package/dist/chunk-SGN7BDRE.js.map +1 -0
  48. package/dist/{chunk-F23JGM4U.js → chunk-UBTL6JUF.js} +6 -2
  49. package/dist/{chunk-F23JGM4U.js.map → chunk-UBTL6JUF.js.map} +1 -1
  50. package/dist/{chunk-2JRAG36X.js → chunk-WBMO4ZYO.js} +2 -2
  51. package/dist/chunk-WBMO4ZYO.js.map +1 -0
  52. package/dist/{chunk-K3EYTZLL.js → chunk-WTXOWQ7N.js} +3 -1
  53. package/dist/chunk-WTXOWQ7N.js.map +1 -0
  54. package/dist/{chunk-Q2A46HHW.js → chunk-XFPFWTWX.js} +276 -43
  55. package/dist/chunk-XFPFWTWX.js.map +1 -0
  56. package/dist/{chunk-PXDTH36X.js → chunk-Y72PIE3I.js} +212 -20
  57. package/dist/chunk-Y72PIE3I.js.map +1 -0
  58. package/dist/{chunk-6IR5JY6W.js → chunk-YECMP34I.js} +41 -9
  59. package/dist/chunk-YECMP34I.js.map +1 -0
  60. package/dist/{chunk-NSKYOKG5.js → chunk-ZXC7SZIT.js} +278 -26
  61. package/dist/chunk-ZXC7SZIT.js.map +1 -0
  62. package/dist/{controls-reader-SNMI2UY7.js → controls-reader-Z7OQWYWQ.js} +4 -3
  63. package/dist/{controls-reader-SNMI2UY7.js.map → controls-reader-Z7OQWYWQ.js.map} +1 -1
  64. package/dist/expo/plugin.cjs +301 -58
  65. package/dist/expo/plugin.cjs.map +1 -1
  66. package/dist/expo/plugin.js +1 -1
  67. package/dist/expo-babel-plugin.cjs +301 -58
  68. package/dist/expo-babel-plugin.cjs.map +1 -1
  69. package/dist/expo-babel-plugin.js +1 -1
  70. package/dist/flutter-preview-path.d.ts +9 -0
  71. package/dist/flutter-preview-path.js +16 -0
  72. package/dist/flutter-preview-path.js.map +1 -0
  73. package/dist/index.d.ts +16 -15
  74. package/dist/index.js +9 -6
  75. package/dist/nextjs/plugin.cjs +46 -5
  76. package/dist/nextjs/plugin.cjs.map +1 -1
  77. package/dist/nextjs/plugin.js +1 -1
  78. package/dist/nextjs-loader.cjs +343 -68
  79. package/dist/nextjs-loader.cjs.map +1 -1
  80. package/dist/nextjs.cjs +48 -6
  81. package/dist/nextjs.cjs.map +1 -1
  82. package/dist/nextjs.d.cts +9 -1
  83. package/dist/nextjs.d.ts +9 -1
  84. package/dist/nextjs.js +1 -1
  85. package/dist/nuxt/runtime/identity.d.ts +24 -0
  86. package/dist/nuxt/runtime/identity.js +18 -0
  87. package/dist/nuxt/runtime/identity.js.map +1 -0
  88. package/dist/nuxt.d.ts +102 -0
  89. package/dist/nuxt.js +5673 -0
  90. package/dist/nuxt.js.map +1 -0
  91. package/dist/{storyboard-4YdTYq_e.d.ts → storyboard-CMJVBSXn.d.ts} +9 -3
  92. package/dist/svelte.d.ts +4 -2
  93. package/dist/svelte.js +21 -88
  94. package/dist/svelte.js.map +1 -1
  95. package/dist/vue.d.ts +66 -0
  96. package/dist/vue.js +1403 -0
  97. package/dist/vue.js.map +1 -0
  98. package/package.json +48 -5
  99. package/dist/chunk-2JRAG36X.js.map +0 -1
  100. package/dist/chunk-6BSLP7P3.js.map +0 -1
  101. package/dist/chunk-6IR5JY6W.js.map +0 -1
  102. package/dist/chunk-EYKOOLPL.js.map +0 -1
  103. package/dist/chunk-K3EYTZLL.js.map +0 -1
  104. package/dist/chunk-NSKYOKG5.js.map +0 -1
  105. package/dist/chunk-PXDTH36X.js.map +0 -1
  106. package/dist/chunk-Q2A46HHW.js.map +0 -1
  107. package/dist/chunk-WTQQOLXM.js.map +0 -1
  108. /package/dist/{chunk-77DZCV5Z.js.map → chunk-CXIW4IKC.js.map} +0 -0
  109. /package/dist/{chunk-KOSJXE4G.js.map → chunk-H6BQZOAW.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tempoExpoBabelPlugin
3
- } from "../chunk-Q2A46HHW.js";
3
+ } from "../chunk-XFPFWTWX.js";
4
4
  export {
5
5
  tempoExpoBabelPlugin as default,
6
6
  tempoExpoBabelPlugin
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // expo-babel-plugin.ts
@@ -26,25 +36,152 @@ __export(expo_babel_plugin_exports, {
26
36
  module.exports = __toCommonJS(expo_babel_plugin_exports);
27
37
 
28
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
29
75
  var import_node_fs = require("fs");
30
- var import_node_path = require("path");
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
+ }
31
103
 
32
104
  // canvas/parser.ts
33
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
34
172
  var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set([
35
173
  "tempo-sdk/canvas",
36
- "tempo-sdk/canvas/svelte",
37
- "tempo-sdk/canvas/astro"
174
+ ...STORYBOARD_SDK_COMPONENT_NAMES.map(
175
+ (component) => STORYBOARD_SDK_COMPONENTS[component].importSource
176
+ )
38
177
  ]);
39
178
  var SDK_COMPONENTS = /* @__PURE__ */ new Set([
40
179
  "Canvas",
41
- "Storyboard",
42
- "SvelteStoryboard",
43
- "AstroStoryboard",
44
- "LegacyStoryboardV1",
45
- "RouteStoryboard",
46
- "HtmlStoryboard"
180
+ ...STORYBOARD_SDK_COMPONENT_NAMES
47
181
  ]);
182
+ var CANVAS_CHILDREN_ERROR = `<Canvas> children must be ${formatAlternatives(
183
+ STORYBOARD_SDK_COMPONENT_NAMES.map((component) => `<${component}>`)
184
+ )} declarations`;
48
185
  var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
49
186
  "Canvas",
50
187
  "CanvasContext",
@@ -62,6 +199,7 @@ var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
62
199
  "getCanvasHostRuntime",
63
200
  "getOptionalCanvasHostRuntime",
64
201
  "useActiveState",
202
+ "FlutterStoryboard",
65
203
  "HtmlStoryboard",
66
204
  "LegacyStoryboardV1",
67
205
  "RouteStoryboard",
@@ -185,7 +323,7 @@ function parseCanvasFile(filePath, source) {
185
323
  "name",
186
324
  objectStringBindings
187
325
  );
188
- const path = readStringAttribute(openingElement, "path");
326
+ const path2 = readStringAttribute(openingElement, "path");
189
327
  const backgroundColor = readResolvableStringAttribute(
190
328
  openingElement,
191
329
  "backgroundColor",
@@ -204,7 +342,7 @@ function parseCanvasFile(filePath, source) {
204
342
  }
205
343
  return {
206
344
  filePath,
207
- canvasPath: path?.value,
345
+ canvasPath: path2?.value,
208
346
  pageName: name?.value ?? fallbackPageName(filePath),
209
347
  backgroundColor: backgroundColor?.value,
210
348
  canvasElementSpan: toSpan(canvasElement),
@@ -212,8 +350,8 @@ function parseCanvasFile(filePath, source) {
212
350
  canvasChildrenInsertionOffset: typeof canvasElement?.closingElement?.start === "number" ? canvasElement.closingElement.start : void 0,
213
351
  nameSpan: name?.valueSpan,
214
352
  nameAttributeSpan: name?.attributeSpan,
215
- pathSpan: path?.valueSpan,
216
- pathAttributeSpan: path?.attributeSpan,
353
+ pathSpan: path2?.valueSpan,
354
+ pathAttributeSpan: path2?.attributeSpan,
217
355
  backgroundColorSpan: backgroundColor?.valueSpan,
218
356
  backgroundColorAttributeSpan: backgroundColor?.attributeSpan,
219
357
  imports: imports.all,
@@ -432,7 +570,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
432
570
  }
433
571
  ])
434
572
  } : readLayout(openingElement, component);
435
- const kind = component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" ? "component" : component === "RouteStoryboard" ? "route" : "html";
573
+ const spec = STORYBOARD_SDK_COMPONENTS[component];
436
574
  if (!id) {
437
575
  errors.push({
438
576
  message: `<${component}> must include a literal "id" prop`,
@@ -446,8 +584,9 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
446
584
  const storyboard = {
447
585
  storyboardKey: id?.value ?? "",
448
586
  displayName: name?.value ?? legacyObject?.displayName,
449
- kind,
450
- ...component === "SvelteStoryboard" ? { uiFramework: "svelte" } : component === "AstroStoryboard" ? { runtimeFramework: "astro" } : {},
587
+ kind: spec.kind,
588
+ ...spec.uiFramework ? { componentFramework: spec.uiFramework } : {},
589
+ ...spec.uiFramework === "svelte" ? { uiFramework: spec.uiFramework } : spec.uiFramework === "astro" ? { runtimeFramework: spec.uiFramework } : {},
451
590
  layout: layout.value,
452
591
  editable: Boolean(id) && layout.errors.length === 0,
453
592
  jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
@@ -470,7 +609,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
470
609
  } : void 0,
471
610
  errors
472
611
  };
473
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard") {
612
+ if (spec.requiresComponentProp) {
474
613
  const componentReference = readComponentReference(
475
614
  openingElement,
476
615
  imports,
@@ -486,7 +625,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
486
625
  });
487
626
  }
488
627
  }
489
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "HtmlStoryboard") {
628
+ if (spec.allowsVrt) {
490
629
  const vrt = readVrt(openingElement, errors);
491
630
  if (vrt) {
492
631
  if (vrt.value) {
@@ -526,6 +665,27 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
526
665
  });
527
666
  }
528
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
+ }
529
689
  globalErrors.push(...errors);
530
690
  return storyboard;
531
691
  }
@@ -585,18 +745,61 @@ function validateCanvasChildren(canvasElement, imports) {
585
745
  child.openingElement?.name,
586
746
  imports
587
747
  );
588
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
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));
589
755
  continue;
590
756
  }
591
757
  }
592
758
  errors.push({
593
- message: "<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <AstroStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations",
759
+ message: CANVAS_CHILDREN_ERROR,
594
760
  span: toSpan(child),
595
761
  kind: "structural"
596
762
  });
597
763
  }
598
764
  return errors;
599
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
+ }
600
803
  function readVrt(openingElement, errors) {
601
804
  const attribute = getAttribute(openingElement, "vrt");
602
805
  if (!attribute) return null;
@@ -743,7 +946,7 @@ function isIdentifierExpression(expression) {
743
946
  return /^[A-Za-z_$][\w$]*$/.test(expression);
744
947
  }
745
948
  function readLayout(openingElement, componentName) {
746
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
949
+ const isViewport = requiresFixedLayoutSize(componentName);
747
950
  const attribute = getAttribute(openingElement, "layout");
748
951
  const expression = unwrapAttributeExpression(attribute?.value);
749
952
  if (!expression) {
@@ -767,7 +970,7 @@ function readLayout(openingElement, componentName) {
767
970
  }
768
971
  function readLayoutExpression(expression, componentName) {
769
972
  const errors = [];
770
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
973
+ const isViewport = requiresFixedLayoutSize(componentName);
771
974
  if (expression.type !== "ObjectExpression") {
772
975
  return {
773
976
  value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : DEFAULT_LAYOUT,
@@ -962,7 +1165,14 @@ function resolveMisimportedNamespaceSdkComponent(nameNode, imports, misimportedS
962
1165
  ) ?? null;
963
1166
  }
964
1167
  function isStoryboardSdkComponent(component) {
965
- return component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard";
1168
+ return component !== null && component !== "Canvas";
1169
+ }
1170
+ function formatAlternatives(items) {
1171
+ if (items.length <= 1) return items.join("");
1172
+ return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
1173
+ }
1174
+ function requiresFixedLayoutSize(componentName) {
1175
+ return componentName === "RouteStoryboard" || componentName === "HtmlStoryboard" || componentName === "FlutterStoryboard";
966
1176
  }
967
1177
  function readImportedName(specifier) {
968
1178
  if (specifier.type === "ImportDefaultSpecifier") return "default";
@@ -975,7 +1185,10 @@ function readImportKind(specifier) {
975
1185
  return "named";
976
1186
  }
977
1187
  function isSdkImportSource(source) {
978
- return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas") || source.endsWith("/tempo-sdk/canvas/svelte") || source.endsWith("/tempo-sdk/canvas/astro");
1188
+ for (const sdkSource of SDK_IMPORT_SOURCES) {
1189
+ if (source === sdkSource || source.endsWith(`/${sdkSource}`)) return true;
1190
+ }
1191
+ return false;
979
1192
  }
980
1193
  function isWrongTempoSdkCanvasImportSource(source) {
981
1194
  return (source === "tempo-sdk" || source.startsWith("tempo-sdk/")) && !isSdkImportSource(source);
@@ -1023,30 +1236,58 @@ function moduleIdentity(file, specifier, resolved) {
1023
1236
  const target = bundled === void 0 ? specifier : bundled.replace(/\bt=\d{13}&?\b/, "").replace(/[?&]$/, "");
1024
1237
  if (target.startsWith("\0")) return target;
1025
1238
  const suffixAt = target.search(/[?#]/);
1026
- let path = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1239
+ let path2 = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1027
1240
  /\\/g,
1028
1241
  "/"
1029
1242
  );
1030
1243
  const suffix = suffixAt < 0 || target.endsWith(".astro?tempo-component") ? "" : target.slice(suffixAt);
1031
- if (bundled === void 0 && path.startsWith("."))
1032
- path = (0, import_node_path.resolve)((0, import_node_path.dirname)(file), path);
1033
- if (!(0, import_node_path.isAbsolute)(path) && !/^[A-Za-z]:\//.test(path)) return target;
1244
+ if (bundled === void 0 && path2.startsWith("."))
1245
+ path2 = (0, import_node_path2.resolve)((0, import_node_path2.dirname)(file), path2);
1246
+ if (!(0, import_node_path2.isAbsolute)(path2) && !/^[A-Za-z]:\//.test(path2)) return target;
1034
1247
  if (bundled !== void 0) {
1035
1248
  try {
1036
- path = import_node_fs.realpathSync.native(path);
1249
+ path2 = import_node_fs2.realpathSync.native(path2);
1037
1250
  } catch {
1038
1251
  }
1039
1252
  }
1040
- return (0, import_node_path.normalize)(path).replace(/\\/g, "/") + suffix;
1253
+ return (0, import_node_path2.normalize)(path2).replace(/\\/g, "/") + suffix;
1041
1254
  }
1042
- function canvasComponentAnnotations(file, source, resolved) {
1255
+ function canvasComponentAnnotations(file, source, resolved, hostRoot) {
1043
1256
  const result = /* @__PURE__ */ new Map();
1044
1257
  if (!source.includes("tempo-sdk/canvas")) return result;
1045
1258
  const parsed = parseCanvasFile(file, source);
1046
1259
  for (const board of parsed.storyboards) {
1047
- const ref = board.component;
1048
- if (board.kind !== "component" || !ref?.localName || board.openingElementSpan === void 0)
1260
+ if (board.kind !== "component" || board.openingElementSpan === void 0)
1049
1261
  continue;
1262
+ const flutterPreview = board.preview ? parseFlutterPreview(board.preview) : null;
1263
+ if (flutterPreview && !("error" in flutterPreview) && hostRoot) {
1264
+ let key;
1265
+ try {
1266
+ const absolute = (0, import_node_path2.resolve)(
1267
+ (0, import_node_path2.dirname)(canonicalPathAllowMissing(file)),
1268
+ flutterPreview.file
1269
+ );
1270
+ key = flutterPreviewKey(
1271
+ hostRoot,
1272
+ absolute,
1273
+ flutterPreview.functionName
1274
+ );
1275
+ } catch {
1276
+ continue;
1277
+ }
1278
+ result.set(board.openingElementSpan.start, {
1279
+ [FLUTTER_PREVIEW_KEY_ATTRIBUTE]: key,
1280
+ [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1281
+ "flutter",
1282
+ key.slice(0, key.lastIndexOf("#")),
1283
+ flutterPreview.functionName
1284
+ ]),
1285
+ "data-tempo-external-component": "true"
1286
+ });
1287
+ continue;
1288
+ }
1289
+ const ref = board.component;
1290
+ if (!ref?.localName) continue;
1050
1291
  const member = ref.expression.match(
1051
1292
  /^\s*([$\w]+)(?:\s*\.\s*([$\w]+))?\s*$/
1052
1293
  );
@@ -1065,8 +1306,8 @@ function canvasComponentAnnotations(file, source, resolved) {
1065
1306
  name = ref.localName;
1066
1307
  }
1067
1308
  const specifier = ref.import?.source.replace(/\\/g, "/").replace(/[?#].*/, "");
1068
- const canvasDir = import_node_path.posix.dirname(file.replace(/\\/g, "/"));
1069
- const external = specifier !== void 0 && (!specifier.startsWith(".") || !import_node_path.posix.join(canvasDir, specifier).startsWith(`${canvasDir}/`));
1309
+ const canvasDir = import_node_path2.posix.dirname(file.replace(/\\/g, "/"));
1310
+ const external = specifier !== void 0 && (!specifier.startsWith(".") || !import_node_path2.posix.join(canvasDir, specifier).startsWith(`${canvasDir}/`));
1070
1311
  result.set(board.openingElementSpan.start, {
1071
1312
  [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1072
1313
  ref.import ? "import" : "local",
@@ -1080,13 +1321,13 @@ function canvasComponentAnnotations(file, source, resolved) {
1080
1321
  }
1081
1322
 
1082
1323
  // expo-babel-plugin.ts
1083
- var import_node_fs4 = require("fs");
1084
- var import_node_path4 = require("path");
1324
+ var import_node_fs5 = require("fs");
1325
+ var import_node_path5 = require("path");
1085
1326
  var import_pluginutils = require("@rollup/pluginutils");
1086
1327
 
1087
1328
  // annotation-strategy.ts
1088
- var import_node_fs2 = require("fs");
1089
- var import_node_path2 = require("path");
1329
+ var import_node_fs3 = require("fs");
1330
+ var import_node_path3 = require("path");
1090
1331
 
1091
1332
  // ../../modules/annotation/expression-facts.ts
1092
1333
  var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
@@ -1225,7 +1466,7 @@ function cleanModuleId(id) {
1225
1466
  }
1226
1467
  function resolveCanonicalRoot(root) {
1227
1468
  try {
1228
- return import_node_fs2.realpathSync.native(root);
1469
+ return import_node_fs3.realpathSync.native(root);
1229
1470
  } catch {
1230
1471
  return root;
1231
1472
  }
@@ -1302,15 +1543,15 @@ function getFileAnnotationContext(params) {
1302
1543
  let cleanFilename = rawCleanFilename;
1303
1544
  if (params.canonicalizeFilename) {
1304
1545
  try {
1305
- cleanFilename = import_node_fs2.realpathSync.native(rawCleanFilename);
1546
+ cleanFilename = import_node_fs3.realpathSync.native(rawCleanFilename);
1306
1547
  } catch {
1307
1548
  cleanFilename = rawCleanFilename;
1308
1549
  }
1309
1550
  }
1310
1551
  return {
1311
1552
  cleanFilename,
1312
- filepath: (0, import_node_path2.relative)(params.root, cleanFilename),
1313
- modifiedtsMs: Math.trunc((0, import_node_fs2.statSync)(cleanFilename).mtimeMs),
1553
+ filepath: (0, import_node_path3.relative)(params.root, cleanFilename),
1554
+ modifiedtsMs: Math.trunc((0, import_node_fs3.statSync)(cleanFilename).mtimeMs),
1314
1555
  // Hashed once per file per transform (the context is built once, reused
1315
1556
  // for every element) so the per-element funnel just forwards the token.
1316
1557
  sourceVersion: sourceVersionHash(params.source)
@@ -1318,8 +1559,8 @@ function getFileAnnotationContext(params) {
1318
1559
  }
1319
1560
 
1320
1561
  // sdk-package-files.ts
1321
- var import_node_fs3 = require("fs");
1322
- var import_node_path3 = require("path");
1562
+ var import_node_fs4 = require("fs");
1563
+ var import_node_path4 = require("path");
1323
1564
  var SDK_PACKAGE_NAME = "tempo-sdk";
1324
1565
  var SDK_NODE_MODULES_SEGMENT = `/node_modules/${SDK_PACKAGE_NAME}/`;
1325
1566
  function createSdkFileMatcher() {
@@ -1340,7 +1581,7 @@ function createSdkFileMatcher() {
1340
1581
  isSdk = manifest?.name === SDK_PACKAGE_NAME;
1341
1582
  break;
1342
1583
  }
1343
- const parent = (0, import_node_path3.dirname)(directory);
1584
+ const parent = (0, import_node_path4.dirname)(directory);
1344
1585
  if (parent === directory) break;
1345
1586
  directory = parent;
1346
1587
  }
@@ -1353,16 +1594,16 @@ function createSdkFileMatcher() {
1353
1594
  }
1354
1595
  let realFile = file;
1355
1596
  try {
1356
- realFile = import_node_fs3.realpathSync.native(file);
1597
+ realFile = import_node_fs4.realpathSync.native(file);
1357
1598
  } catch {
1358
1599
  }
1359
- return nearestPackageIsSdk((0, import_node_path3.dirname)(realFile));
1600
+ return nearestPackageIsSdk((0, import_node_path4.dirname)(realFile));
1360
1601
  };
1361
1602
  }
1362
1603
  function readPackageManifest(directory) {
1363
1604
  let text;
1364
1605
  try {
1365
- text = (0, import_node_fs3.readFileSync)((0, import_node_path3.join)(directory, "package.json"), "utf8");
1606
+ text = (0, import_node_fs4.readFileSync)((0, import_node_path4.join)(directory, "package.json"), "utf8");
1366
1607
  } catch {
1367
1608
  return void 0;
1368
1609
  }
@@ -1505,16 +1746,16 @@ function injectProjectRootMeta(api, programPath, root) {
1505
1746
  }
1506
1747
  function resolveBabelRoot(state, options, filename) {
1507
1748
  return resolveCanonicalRoot(
1508
- (0, import_node_path4.resolve)(
1749
+ (0, import_node_path5.resolve)(
1509
1750
  options.root ?? findNearestPackageRoot(filename) ?? state.cwd ?? state.file.opts.cwd ?? state.file.opts.root ?? process.cwd()
1510
1751
  )
1511
1752
  );
1512
1753
  }
1513
1754
  function findNearestPackageRoot(filename) {
1514
- let current = (0, import_node_path4.dirname)(filename);
1755
+ let current = (0, import_node_path5.dirname)(filename);
1515
1756
  while (true) {
1516
- if ((0, import_node_fs4.existsSync)((0, import_node_path4.resolve)(current, "package.json"))) return current;
1517
- const parent = (0, import_node_path4.dirname)(current);
1757
+ if ((0, import_node_fs5.existsSync)((0, import_node_path5.resolve)(current, "package.json"))) return current;
1758
+ const parent = (0, import_node_path5.dirname)(current);
1518
1759
  if (parent === current) return null;
1519
1760
  current = parent;
1520
1761
  }
@@ -1522,7 +1763,7 @@ function findNearestPackageRoot(filename) {
1522
1763
  function resolveFilename(state) {
1523
1764
  const filename = state.filename ?? state.file.opts.filename;
1524
1765
  if (!filename) return null;
1525
- return (0, import_node_path4.resolve)(cleanModuleId(filename));
1766
+ return (0, import_node_path5.resolve)(cleanModuleId(filename));
1526
1767
  }
1527
1768
  function tempoExpoBabelPlugin(api, rawOptions = {}) {
1528
1769
  api.assertVersion(7);
@@ -1546,7 +1787,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1546
1787
  },
1547
1788
  visitor: {
1548
1789
  Program: {
1549
- enter(path, state) {
1790
+ enter(path2, state) {
1550
1791
  if (!enabled) return;
1551
1792
  const options = { ...rawOptions, ...state.opts };
1552
1793
  const filename = resolveFilename(state);
@@ -1565,13 +1806,15 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1565
1806
  return;
1566
1807
  }
1567
1808
  if (context.filepath === "index.js") {
1568
- injectProjectRootMeta(api, path, root);
1809
+ injectProjectRootMeta(api, path2, root);
1569
1810
  }
1570
1811
  const componentReferences = canvasComponentAnnotations(
1571
1812
  filename,
1572
- source
1813
+ source,
1814
+ void 0,
1815
+ root
1573
1816
  );
1574
- path.traverse({
1817
+ path2.traverse({
1575
1818
  JSXElement(elementPath) {
1576
1819
  const element = elementPath.node;
1577
1820
  const tagName = getBabelTagName(element.openingElement.name);