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,23 +1,150 @@
1
1
  // canvas-component-reference.ts
2
- import { realpathSync } from "fs";
2
+ import { realpathSync as realpathSync2 } from "fs";
3
3
  import { dirname, isAbsolute, normalize, posix, resolve } from "path";
4
4
 
5
+ // canvas/flutter-preview.ts
6
+ function parseFlutterPreview(value) {
7
+ const prefix = `preview ${JSON.stringify(value)}`;
8
+ if (value.includes("\\"))
9
+ return {
10
+ error: `${prefix} uses a backslash; use "/" (paths in canvases are POSIX).`
11
+ };
12
+ const hash = value.lastIndexOf("#");
13
+ if (hash < 0)
14
+ return {
15
+ error: `${prefix} needs "#<function>" after the file, e.g. "../../lib/cards.dart#productCard".`
16
+ };
17
+ const file = value.slice(0, hash);
18
+ const functionName = value.slice(hash + 1);
19
+ if (!file.startsWith("./") && !file.startsWith("../"))
20
+ return {
21
+ 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.`
22
+ };
23
+ if (!file.endsWith(".dart"))
24
+ return { error: `${prefix} must name a .dart file.` };
25
+ if (/[?#]/.test(file) || file.includes("//"))
26
+ return {
27
+ error: `${prefix} must not contain "?", "#", or empty path segments.`
28
+ };
29
+ if (!/^[A-Za-z$][A-Za-z0-9_$]*$/.test(functionName))
30
+ return {
31
+ error: `${prefix}: ${JSON.stringify(functionName)} is not a public Dart function name.`
32
+ };
33
+ return { file, functionName };
34
+ }
35
+ var FLUTTER_PREVIEW_KEY_ATTRIBUTE = "data-tempo-flutter-preview-key";
36
+
37
+ // flutter-preview-path.ts
38
+ import { lstatSync, realpathSync } from "fs";
39
+ import path from "path";
40
+ function canonicalPathAllowMissing(file) {
41
+ const absolute = path.resolve(file);
42
+ try {
43
+ return realpathSync.native(absolute);
44
+ } catch (error) {
45
+ const code = error.code;
46
+ if (code !== "ENOENT" && code !== "ENOTDIR") throw error;
47
+ let isLink = false;
48
+ try {
49
+ isLink = lstatSync(absolute).isSymbolicLink();
50
+ } catch (statError) {
51
+ if (statError.code !== "ENOENT" && statError.code !== "ENOTDIR")
52
+ throw statError;
53
+ }
54
+ if (isLink) throw error;
55
+ const parent = path.dirname(absolute);
56
+ if (parent === absolute) throw error;
57
+ return path.join(
58
+ canonicalPathAllowMissing(parent),
59
+ path.basename(absolute)
60
+ );
61
+ }
62
+ }
63
+ function flutterPreviewKey(hostRoot, file, functionName) {
64
+ return `${path.relative(canonicalPathAllowMissing(hostRoot), canonicalPathAllowMissing(file)).split(path.sep).join("/")}#${functionName}`;
65
+ }
66
+
5
67
  // canvas/parser.ts
6
68
  import { parseSync } from "oxc-parser";
69
+
70
+ // canvas/storyboard-components.ts
71
+ var STORYBOARD_SDK_COMPONENT_ROWS = {
72
+ Storyboard: {
73
+ importSource: "tempo-sdk/canvas",
74
+ kind: "component",
75
+ requiresComponentProp: true,
76
+ allowsVrt: true,
77
+ componentFileExtension: ".tsx"
78
+ },
79
+ SvelteStoryboard: {
80
+ importSource: "tempo-sdk/canvas/svelte",
81
+ kind: "component",
82
+ uiFramework: "svelte",
83
+ requiresComponentProp: true,
84
+ allowsVrt: true,
85
+ componentFileExtension: ".svelte"
86
+ },
87
+ VueStoryboard: {
88
+ importSource: "tempo-sdk/canvas/vue",
89
+ kind: "component",
90
+ uiFramework: "vue",
91
+ requiresComponentProp: true,
92
+ allowsVrt: true,
93
+ componentFileExtension: ".vue"
94
+ },
95
+ AstroStoryboard: {
96
+ importSource: "tempo-sdk/canvas/astro",
97
+ kind: "component",
98
+ uiFramework: "astro",
99
+ requiresComponentProp: true,
100
+ allowsVrt: true,
101
+ componentFileExtension: ".astro",
102
+ componentImportQuery: "?tempo-component"
103
+ },
104
+ FlutterStoryboard: {
105
+ importSource: "tempo-sdk/canvas",
106
+ kind: "component",
107
+ requiresComponentProp: false,
108
+ allowsVrt: true
109
+ },
110
+ RouteStoryboard: {
111
+ importSource: "tempo-sdk/canvas",
112
+ kind: "route",
113
+ requiresComponentProp: false,
114
+ allowsVrt: false
115
+ },
116
+ HtmlStoryboard: {
117
+ importSource: "tempo-sdk/canvas",
118
+ kind: "html",
119
+ requiresComponentProp: false,
120
+ allowsVrt: true
121
+ },
122
+ LegacyStoryboardV1: {
123
+ importSource: "tempo-sdk/canvas",
124
+ kind: "component",
125
+ requiresComponentProp: false,
126
+ allowsVrt: false
127
+ }
128
+ };
129
+ var STORYBOARD_SDK_COMPONENTS = STORYBOARD_SDK_COMPONENT_ROWS;
130
+ var STORYBOARD_SDK_COMPONENT_NAMES = Object.keys(
131
+ STORYBOARD_SDK_COMPONENTS
132
+ );
133
+
134
+ // canvas/parser.ts
7
135
  var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set([
8
136
  "tempo-sdk/canvas",
9
- "tempo-sdk/canvas/svelte",
10
- "tempo-sdk/canvas/astro"
137
+ ...STORYBOARD_SDK_COMPONENT_NAMES.map(
138
+ (component) => STORYBOARD_SDK_COMPONENTS[component].importSource
139
+ )
11
140
  ]);
12
141
  var SDK_COMPONENTS = /* @__PURE__ */ new Set([
13
142
  "Canvas",
14
- "Storyboard",
15
- "SvelteStoryboard",
16
- "AstroStoryboard",
17
- "LegacyStoryboardV1",
18
- "RouteStoryboard",
19
- "HtmlStoryboard"
143
+ ...STORYBOARD_SDK_COMPONENT_NAMES
20
144
  ]);
145
+ var CANVAS_CHILDREN_ERROR = `<Canvas> children must be ${formatAlternatives(
146
+ STORYBOARD_SDK_COMPONENT_NAMES.map((component) => `<${component}>`)
147
+ )} declarations`;
21
148
  var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
22
149
  "Canvas",
23
150
  "CanvasContext",
@@ -35,6 +162,7 @@ var SDK_CANVAS_VALUE_EXPORTS = /* @__PURE__ */ new Set([
35
162
  "getCanvasHostRuntime",
36
163
  "getOptionalCanvasHostRuntime",
37
164
  "useActiveState",
165
+ "FlutterStoryboard",
38
166
  "HtmlStoryboard",
39
167
  "LegacyStoryboardV1",
40
168
  "RouteStoryboard",
@@ -158,7 +286,7 @@ function parseCanvasFile(filePath, source) {
158
286
  "name",
159
287
  objectStringBindings
160
288
  );
161
- const path = readStringAttribute(openingElement, "path");
289
+ const path2 = readStringAttribute(openingElement, "path");
162
290
  const backgroundColor = readResolvableStringAttribute(
163
291
  openingElement,
164
292
  "backgroundColor",
@@ -177,7 +305,7 @@ function parseCanvasFile(filePath, source) {
177
305
  }
178
306
  return {
179
307
  filePath,
180
- canvasPath: path?.value,
308
+ canvasPath: path2?.value,
181
309
  pageName: name?.value ?? fallbackPageName(filePath),
182
310
  backgroundColor: backgroundColor?.value,
183
311
  canvasElementSpan: toSpan(canvasElement),
@@ -185,8 +313,8 @@ function parseCanvasFile(filePath, source) {
185
313
  canvasChildrenInsertionOffset: typeof canvasElement?.closingElement?.start === "number" ? canvasElement.closingElement.start : void 0,
186
314
  nameSpan: name?.valueSpan,
187
315
  nameAttributeSpan: name?.attributeSpan,
188
- pathSpan: path?.valueSpan,
189
- pathAttributeSpan: path?.attributeSpan,
316
+ pathSpan: path2?.valueSpan,
317
+ pathAttributeSpan: path2?.attributeSpan,
190
318
  backgroundColorSpan: backgroundColor?.valueSpan,
191
319
  backgroundColorAttributeSpan: backgroundColor?.attributeSpan,
192
320
  imports: imports.all,
@@ -405,7 +533,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
405
533
  }
406
534
  ])
407
535
  } : readLayout(openingElement, component);
408
- const kind = component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" ? "component" : component === "RouteStoryboard" ? "route" : "html";
536
+ const spec = STORYBOARD_SDK_COMPONENTS[component];
409
537
  if (!id) {
410
538
  errors.push({
411
539
  message: `<${component}> must include a literal "id" prop`,
@@ -419,8 +547,9 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
419
547
  const storyboard = {
420
548
  storyboardKey: id?.value ?? "",
421
549
  displayName: name?.value ?? legacyObject?.displayName,
422
- kind,
423
- ...component === "SvelteStoryboard" ? { uiFramework: "svelte" } : component === "AstroStoryboard" ? { runtimeFramework: "astro" } : {},
550
+ kind: spec.kind,
551
+ ...spec.uiFramework ? { componentFramework: spec.uiFramework } : {},
552
+ ...spec.uiFramework === "svelte" ? { uiFramework: spec.uiFramework } : spec.uiFramework === "astro" ? { runtimeFramework: spec.uiFramework } : {},
424
553
  layout: layout.value,
425
554
  editable: Boolean(id) && layout.errors.length === 0,
426
555
  jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
@@ -443,7 +572,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
443
572
  } : void 0,
444
573
  errors
445
574
  };
446
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard") {
575
+ if (spec.requiresComponentProp) {
447
576
  const componentReference = readComponentReference(
448
577
  openingElement,
449
578
  imports,
@@ -459,7 +588,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
459
588
  });
460
589
  }
461
590
  }
462
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "HtmlStoryboard") {
591
+ if (spec.allowsVrt) {
463
592
  const vrt = readVrt(openingElement, errors);
464
593
  if (vrt) {
465
594
  if (vrt.value) {
@@ -499,6 +628,27 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
499
628
  });
500
629
  }
501
630
  }
631
+ if (component === "FlutterStoryboard") {
632
+ const preview = readStringAttribute(openingElement, "preview");
633
+ if (preview?.value.trim()) {
634
+ storyboard.preview = preview.value;
635
+ storyboard.previewSpan = preview.valueSpan;
636
+ storyboard.previewAttributeSpan = preview.attributeSpan;
637
+ const parsedPreview = parseFlutterPreview(preview.value);
638
+ if ("error" in parsedPreview)
639
+ errors.push({
640
+ message: `flutter_preview_invalid: ${parsedPreview.error}`,
641
+ span: preview.valueSpan,
642
+ kind: "structural"
643
+ });
644
+ } else {
645
+ errors.push({
646
+ message: '<FlutterStoryboard> must include a literal "preview" prop naming a Flutter @Preview function, e.g. preview="../../lib/cards.dart#productCard"',
647
+ span: toSpan(getAttribute(openingElement, "preview") ?? openingElement),
648
+ kind: "structural"
649
+ });
650
+ }
651
+ }
502
652
  globalErrors.push(...errors);
503
653
  return storyboard;
504
654
  }
@@ -558,18 +708,61 @@ function validateCanvasChildren(canvasElement, imports) {
558
708
  child.openingElement?.name,
559
709
  imports
560
710
  );
561
- if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
711
+ if (isStoryboardSdkComponent(component)) continue;
712
+ const newerComponent = resolveNewerSdkStoryboardComponent(
713
+ child.openingElement?.name,
714
+ imports
715
+ );
716
+ if (newerComponent) {
717
+ errors.push(newerSdkStoryboardError(child, newerComponent));
562
718
  continue;
563
719
  }
564
720
  }
565
721
  errors.push({
566
- message: "<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <AstroStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations",
722
+ message: CANVAS_CHILDREN_ERROR,
567
723
  span: toSpan(child),
568
724
  kind: "structural"
569
725
  });
570
726
  }
571
727
  return errors;
572
728
  }
729
+ var SDK_CANVAS_SUBPATH = /(^|\/)tempo-sdk\/canvas(\/[^/]+)?$/;
730
+ function resolveNewerSdkStoryboardComponent(nameNode, imports) {
731
+ let importedName;
732
+ let source;
733
+ if (nameNode?.type === "JSXIdentifier") {
734
+ const imported = imports.byLocalName.get(nameNode.name);
735
+ if (imported?.kind !== "named") return null;
736
+ importedName = imported.importedName;
737
+ source = imported.source;
738
+ } else if (nameNode?.type === "JSXMemberExpression" && nameNode.object?.type === "JSXIdentifier" && nameNode.property?.type === "JSXIdentifier") {
739
+ const imported = imports.byLocalName.get(nameNode.object.name);
740
+ if (imported?.kind !== "namespace") return null;
741
+ importedName = nameNode.property.name;
742
+ source = imported.source;
743
+ } else {
744
+ return null;
745
+ }
746
+ const fromSdkCanvas = SDK_CANVAS_SUBPATH.test(source);
747
+ const namesStoryboard = importedName.endsWith("Storyboard");
748
+ return fromSdkCanvas && namesStoryboard ? importedName : null;
749
+ }
750
+ function newerSdkStoryboardError(element, component) {
751
+ const openingElement = element.openingElement;
752
+ const storyboardKey = readStringAttribute(openingElement, "id")?.value;
753
+ const vrt = readVrt(openingElement, [])?.value != null;
754
+ const named = storyboardKey ? ` id="${storyboardKey}"` : "";
755
+ return {
756
+ message: `<${component}${named}> is a storyboard from a newer tempo-sdk than this reader supports`,
757
+ span: toSpan(element),
758
+ kind: "structural",
759
+ newerSdkStoryboard: {
760
+ component,
761
+ ...storyboardKey ? { storyboardKey } : {},
762
+ vrt
763
+ }
764
+ };
765
+ }
573
766
  function readVrt(openingElement, errors) {
574
767
  const attribute = getAttribute(openingElement, "vrt");
575
768
  if (!attribute) return null;
@@ -716,7 +909,7 @@ function isIdentifierExpression(expression) {
716
909
  return /^[A-Za-z_$][\w$]*$/.test(expression);
717
910
  }
718
911
  function readLayout(openingElement, componentName) {
719
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
912
+ const isViewport = requiresFixedLayoutSize(componentName);
720
913
  const attribute = getAttribute(openingElement, "layout");
721
914
  const expression = unwrapAttributeExpression(attribute?.value);
722
915
  if (!expression) {
@@ -740,7 +933,7 @@ function readLayout(openingElement, componentName) {
740
933
  }
741
934
  function readLayoutExpression(expression, componentName) {
742
935
  const errors = [];
743
- const isViewport = componentName === "RouteStoryboard" || componentName === "HtmlStoryboard";
936
+ const isViewport = requiresFixedLayoutSize(componentName);
744
937
  if (expression.type !== "ObjectExpression") {
745
938
  return {
746
939
  value: isViewport ? DEFAULT_VIEWPORT_LAYOUT : DEFAULT_LAYOUT,
@@ -935,7 +1128,14 @@ function resolveMisimportedNamespaceSdkComponent(nameNode, imports, misimportedS
935
1128
  ) ?? null;
936
1129
  }
937
1130
  function isStoryboardSdkComponent(component) {
938
- return component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard";
1131
+ return component !== null && component !== "Canvas";
1132
+ }
1133
+ function formatAlternatives(items) {
1134
+ if (items.length <= 1) return items.join("");
1135
+ return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
1136
+ }
1137
+ function requiresFixedLayoutSize(componentName) {
1138
+ return componentName === "RouteStoryboard" || componentName === "HtmlStoryboard" || componentName === "FlutterStoryboard";
939
1139
  }
940
1140
  function readImportedName(specifier) {
941
1141
  if (specifier.type === "ImportDefaultSpecifier") return "default";
@@ -948,7 +1148,10 @@ function readImportKind(specifier) {
948
1148
  return "named";
949
1149
  }
950
1150
  function isSdkImportSource(source) {
951
- return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas") || source.endsWith("/tempo-sdk/canvas/svelte") || source.endsWith("/tempo-sdk/canvas/astro");
1151
+ for (const sdkSource of SDK_IMPORT_SOURCES) {
1152
+ if (source === sdkSource || source.endsWith(`/${sdkSource}`)) return true;
1153
+ }
1154
+ return false;
952
1155
  }
953
1156
  function isWrongTempoSdkCanvasImportSource(source) {
954
1157
  return (source === "tempo-sdk" || source.startsWith("tempo-sdk/")) && !isSdkImportSource(source);
@@ -996,30 +1199,58 @@ function moduleIdentity(file, specifier, resolved) {
996
1199
  const target = bundled === void 0 ? specifier : bundled.replace(/\bt=\d{13}&?\b/, "").replace(/[?&]$/, "");
997
1200
  if (target.startsWith("\0")) return target;
998
1201
  const suffixAt = target.search(/[?#]/);
999
- let path = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1202
+ let path2 = (suffixAt < 0 ? target : target.slice(0, suffixAt)).replace(
1000
1203
  /\\/g,
1001
1204
  "/"
1002
1205
  );
1003
1206
  const suffix = suffixAt < 0 || target.endsWith(".astro?tempo-component") ? "" : target.slice(suffixAt);
1004
- if (bundled === void 0 && path.startsWith("."))
1005
- path = resolve(dirname(file), path);
1006
- if (!isAbsolute(path) && !/^[A-Za-z]:\//.test(path)) return target;
1207
+ if (bundled === void 0 && path2.startsWith("."))
1208
+ path2 = resolve(dirname(file), path2);
1209
+ if (!isAbsolute(path2) && !/^[A-Za-z]:\//.test(path2)) return target;
1007
1210
  if (bundled !== void 0) {
1008
1211
  try {
1009
- path = realpathSync.native(path);
1212
+ path2 = realpathSync2.native(path2);
1010
1213
  } catch {
1011
1214
  }
1012
1215
  }
1013
- return normalize(path).replace(/\\/g, "/") + suffix;
1216
+ return normalize(path2).replace(/\\/g, "/") + suffix;
1014
1217
  }
1015
- function canvasComponentAnnotations(file, source, resolved) {
1218
+ function canvasComponentAnnotations(file, source, resolved, hostRoot) {
1016
1219
  const result = /* @__PURE__ */ new Map();
1017
1220
  if (!source.includes("tempo-sdk/canvas")) return result;
1018
1221
  const parsed = parseCanvasFile(file, source);
1019
1222
  for (const board of parsed.storyboards) {
1020
- const ref = board.component;
1021
- if (board.kind !== "component" || !ref?.localName || board.openingElementSpan === void 0)
1223
+ if (board.kind !== "component" || board.openingElementSpan === void 0)
1022
1224
  continue;
1225
+ const flutterPreview = board.preview ? parseFlutterPreview(board.preview) : null;
1226
+ if (flutterPreview && !("error" in flutterPreview) && hostRoot) {
1227
+ let key;
1228
+ try {
1229
+ const absolute = resolve(
1230
+ dirname(canonicalPathAllowMissing(file)),
1231
+ flutterPreview.file
1232
+ );
1233
+ key = flutterPreviewKey(
1234
+ hostRoot,
1235
+ absolute,
1236
+ flutterPreview.functionName
1237
+ );
1238
+ } catch {
1239
+ continue;
1240
+ }
1241
+ result.set(board.openingElementSpan.start, {
1242
+ [FLUTTER_PREVIEW_KEY_ATTRIBUTE]: key,
1243
+ [COMPONENT_REFERENCE_ATTRIBUTE]: JSON.stringify([
1244
+ "flutter",
1245
+ key.slice(0, key.lastIndexOf("#")),
1246
+ flutterPreview.functionName
1247
+ ]),
1248
+ "data-tempo-external-component": "true"
1249
+ });
1250
+ continue;
1251
+ }
1252
+ const ref = board.component;
1253
+ if (!ref?.localName) continue;
1023
1254
  const member = ref.expression.match(
1024
1255
  /^\s*([$\w]+)(?:\s*\.\s*([$\w]+))?\s*$/
1025
1256
  );
@@ -1058,7 +1289,7 @@ import { dirname as dirname3, resolve as resolve2 } from "path";
1058
1289
  import { createFilter } from "@rollup/pluginutils";
1059
1290
 
1060
1291
  // annotation-strategy.ts
1061
- import { realpathSync as realpathSync2, statSync } from "fs";
1292
+ import { realpathSync as realpathSync3, statSync } from "fs";
1062
1293
  import { relative } from "path";
1063
1294
 
1064
1295
  // ../../modules/annotation/expression-facts.ts
@@ -1198,7 +1429,7 @@ function cleanModuleId(id) {
1198
1429
  }
1199
1430
  function resolveCanonicalRoot(root) {
1200
1431
  try {
1201
- return realpathSync2.native(root);
1432
+ return realpathSync3.native(root);
1202
1433
  } catch {
1203
1434
  return root;
1204
1435
  }
@@ -1275,7 +1506,7 @@ function getFileAnnotationContext(params) {
1275
1506
  let cleanFilename = rawCleanFilename;
1276
1507
  if (params.canonicalizeFilename) {
1277
1508
  try {
1278
- cleanFilename = realpathSync2.native(rawCleanFilename);
1509
+ cleanFilename = realpathSync3.native(rawCleanFilename);
1279
1510
  } catch {
1280
1511
  cleanFilename = rawCleanFilename;
1281
1512
  }
@@ -1291,7 +1522,7 @@ function getFileAnnotationContext(params) {
1291
1522
  }
1292
1523
 
1293
1524
  // sdk-package-files.ts
1294
- import { readFileSync, realpathSync as realpathSync3 } from "fs";
1525
+ import { readFileSync, realpathSync as realpathSync4 } from "fs";
1295
1526
  import { dirname as dirname2, join } from "path";
1296
1527
  var SDK_PACKAGE_NAME = "tempo-sdk";
1297
1528
  var SDK_NODE_MODULES_SEGMENT = `/node_modules/${SDK_PACKAGE_NAME}/`;
@@ -1326,7 +1557,7 @@ function createSdkFileMatcher() {
1326
1557
  }
1327
1558
  let realFile = file;
1328
1559
  try {
1329
- realFile = realpathSync3.native(file);
1560
+ realFile = realpathSync4.native(file);
1330
1561
  } catch {
1331
1562
  }
1332
1563
  return nearestPackageIsSdk(dirname2(realFile));
@@ -1519,7 +1750,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1519
1750
  },
1520
1751
  visitor: {
1521
1752
  Program: {
1522
- enter(path, state) {
1753
+ enter(path2, state) {
1523
1754
  if (!enabled) return;
1524
1755
  const options = { ...rawOptions, ...state.opts };
1525
1756
  const filename = resolveFilename(state);
@@ -1538,13 +1769,15 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1538
1769
  return;
1539
1770
  }
1540
1771
  if (context.filepath === "index.js") {
1541
- injectProjectRootMeta(api, path, root);
1772
+ injectProjectRootMeta(api, path2, root);
1542
1773
  }
1543
1774
  const componentReferences = canvasComponentAnnotations(
1544
1775
  filename,
1545
- source
1776
+ source,
1777
+ void 0,
1778
+ root
1546
1779
  );
1547
- path.traverse({
1780
+ path2.traverse({
1548
1781
  JSXElement(elementPath) {
1549
1782
  const element = elementPath.node;
1550
1783
  const tagName = getBabelTagName(element.openingElement.name);
@@ -1587,4 +1820,4 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1587
1820
  export {
1588
1821
  tempoExpoBabelPlugin
1589
1822
  };
1590
- //# sourceMappingURL=chunk-Q2A46HHW.js.map
1823
+ //# sourceMappingURL=chunk-XFPFWTWX.js.map