tempo-sdk 0.0.69 → 0.0.75

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 +17 -11
  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-2YX4WVFH.js} +49 -7
  25. package/dist/chunk-2YX4WVFH.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-FE6TYCLF.js → chunk-5VIBKVFO.js} +2 -2
  29. package/dist/{chunk-FE6TYCLF.js.map → chunk-5VIBKVFO.js.map} +1 -1
  30. package/dist/{chunk-77DZCV5Z.js → chunk-CXIW4IKC.js} +2 -2
  31. package/dist/chunk-CYQE3TLC.js +37 -0
  32. package/dist/chunk-CYQE3TLC.js.map +1 -0
  33. package/dist/{chunk-WTQQOLXM.js → chunk-DNSCVLKV.js} +1571 -1410
  34. package/dist/chunk-DNSCVLKV.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-EYKOOLPL.js → chunk-GKDDNDG3.js} +1039 -134
  38. package/dist/chunk-GKDDNDG3.js.map +1 -0
  39. package/dist/{chunk-KOSJXE4G.js → chunk-H6BQZOAW.js} +4 -3
  40. package/dist/chunk-HOBTDB6G.js +112 -0
  41. package/dist/chunk-HOBTDB6G.js.map +1 -0
  42. package/dist/chunk-HZXQPM4W.js +285 -0
  43. package/dist/chunk-HZXQPM4W.js.map +1 -0
  44. package/dist/chunk-SGN7BDRE.js +16 -0
  45. package/dist/chunk-SGN7BDRE.js.map +1 -0
  46. package/dist/{chunk-F23JGM4U.js → chunk-UBTL6JUF.js} +6 -2
  47. package/dist/{chunk-F23JGM4U.js.map → chunk-UBTL6JUF.js.map} +1 -1
  48. package/dist/{chunk-2JRAG36X.js → chunk-WBMO4ZYO.js} +2 -2
  49. package/dist/chunk-WBMO4ZYO.js.map +1 -0
  50. package/dist/{chunk-K3EYTZLL.js → chunk-WTXOWQ7N.js} +3 -1
  51. package/dist/chunk-WTXOWQ7N.js.map +1 -0
  52. package/dist/{chunk-Q2A46HHW.js → chunk-XFPFWTWX.js} +276 -43
  53. package/dist/chunk-XFPFWTWX.js.map +1 -0
  54. package/dist/chunk-XMFVWJUY.js +342 -0
  55. package/dist/chunk-XMFVWJUY.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,10 +1,11 @@
1
1
  import {
2
2
  installTempoInteractProjectionSource
3
- } from "../chunk-EYKOOLPL.js";
4
- import "../chunk-2JRAG36X.js";
5
- import "../chunk-NSKYOKG5.js";
6
- import "../chunk-6AAE4LYV.js";
3
+ } from "../chunk-GKDDNDG3.js";
4
+ import "../chunk-SGN7BDRE.js";
5
+ import "../chunk-WBMO4ZYO.js";
7
6
  import "../chunk-65B52AR7.js";
7
+ import "../chunk-ZXC7SZIT.js";
8
+ import "../chunk-6AAE4LYV.js";
8
9
  export {
9
10
  installTempoInteractProjectionSource
10
11
  };
@@ -1,5 +1,121 @@
1
1
  import { JSXElement } from 'oxc-parser';
2
2
 
3
+ /**
4
+ * Every storyboard declaration a `<Canvas>` may contain, as data. The parser
5
+ * (import whitelist, children check, kind and framework stamps), the editor's
6
+ * codegen and the canvas all read this table. It is kept free of the parser's
7
+ * dependencies so a renderer module can read a framework's storyboard without
8
+ * loading oxc-parser.
9
+ */
10
+ /** A non-React component runtime a storyboard mounts. Omission means React
11
+ * everywhere; the declaration, the page metadata and Convex carry the same
12
+ * literals. */
13
+ type StoryboardUiFramework = "svelte" | "vue" | "astro";
14
+ /** The board kinds a declaration produces (`ParsedCanvasStoryboard.kind`). */
15
+ type StoryboardKind = "component" | "route" | "html";
16
+ type StoryboardSdkComponentSpec = {
17
+ /** The SDK subpath that exports the component. Each non-React runtime has
18
+ * its own subpath so a React-only canvas never resolves that framework's
19
+ * optional peer dependency. */
20
+ importSource: string;
21
+ kind: StoryboardKind;
22
+ uiFramework?: StoryboardUiFramework;
23
+ /** `component={...}` names what the storyboard renders. Legacy boards carry
24
+ * it on their referenced object instead. */
25
+ requiresComponentProp: boolean;
26
+ allowsVrt: boolean;
27
+ /** The extension a new component file this storyboard mounts is written
28
+ * with (`.tsx` for React). Boards that mount no authored component of
29
+ * their own, and legacy boards, have none. */
30
+ componentFileExtension?: string;
31
+ /** The query the canvas file imports that component with. Astro's
32
+ * `?tempo-component` asks Vite for the component descriptor instead of
33
+ * the server-rendered module. */
34
+ componentImportQuery?: string;
35
+ };
36
+ /** Every storyboard declaration a `<Canvas>` may contain, in the order the
37
+ * children error lists them. The import whitelist, the children check, the
38
+ * kind and framework stamps and the editor's codegen all read this table, so
39
+ * a new framework's storyboard is one row here (plus its literal in
40
+ * `StoryboardUiFramework`). */
41
+ declare const STORYBOARD_SDK_COMPONENT_ROWS: {
42
+ Storyboard: {
43
+ importSource: string;
44
+ kind: "component";
45
+ requiresComponentProp: true;
46
+ allowsVrt: true;
47
+ componentFileExtension: string;
48
+ };
49
+ SvelteStoryboard: {
50
+ importSource: string;
51
+ kind: "component";
52
+ uiFramework: "svelte";
53
+ requiresComponentProp: true;
54
+ allowsVrt: true;
55
+ componentFileExtension: string;
56
+ };
57
+ VueStoryboard: {
58
+ importSource: string;
59
+ kind: "component";
60
+ uiFramework: "vue";
61
+ requiresComponentProp: true;
62
+ allowsVrt: true;
63
+ componentFileExtension: string;
64
+ };
65
+ AstroStoryboard: {
66
+ importSource: string;
67
+ kind: "component";
68
+ uiFramework: "astro";
69
+ requiresComponentProp: true;
70
+ allowsVrt: true;
71
+ componentFileExtension: string;
72
+ componentImportQuery: string;
73
+ };
74
+ FlutterStoryboard: {
75
+ importSource: string;
76
+ kind: "component";
77
+ requiresComponentProp: false;
78
+ allowsVrt: true;
79
+ };
80
+ RouteStoryboard: {
81
+ importSource: string;
82
+ kind: "route";
83
+ requiresComponentProp: false;
84
+ allowsVrt: false;
85
+ };
86
+ HtmlStoryboard: {
87
+ importSource: string;
88
+ kind: "html";
89
+ requiresComponentProp: false;
90
+ allowsVrt: true;
91
+ };
92
+ LegacyStoryboardV1: {
93
+ importSource: string;
94
+ kind: "component";
95
+ requiresComponentProp: false;
96
+ allowsVrt: false;
97
+ };
98
+ };
99
+ type StoryboardSdkComponent = keyof typeof STORYBOARD_SDK_COMPONENT_ROWS;
100
+ /** The table widened to its row type, so optional fields read uniformly. */
101
+ declare const STORYBOARD_SDK_COMPONENTS: Readonly<Record<StoryboardSdkComponent, Readonly<StoryboardSdkComponentSpec>>>;
102
+ /** The `<Canvas>` child that mounts a component authored in `uiFramework`:
103
+ * React, named or omitted, is `<Storyboard>`; any other framework is the
104
+ * row that declares it. Codegen picks a storyboard by framework only here. */
105
+ declare function storyboardComponentForFramework(uiFramework: StoryboardUiFramework | "react" | undefined): StoryboardSdkComponent;
106
+ /** The extension a new component file of `uiFramework` is written with:
107
+ * its storyboard's `componentFileExtension` (`.tsx`, `.svelte`, `.vue`,
108
+ * `.astro`). */
109
+ declare function componentFileExtensionForFramework(uiFramework: StoryboardUiFramework | "react" | undefined): string;
110
+ /** The specifier a canvas file imports `source` with: a component file whose
111
+ * storyboard declares a `componentImportQuery` gets that query appended
112
+ * (`./Card.astro` -> `./Card.astro?tempo-component`); any other path, or one
113
+ * that already carries the query, is returned unchanged. */
114
+ declare function componentImportSpecifier(source: string): string;
115
+ /** The component file a canvas import names, without any storyboard's
116
+ * `componentImportQuery` (`./Card.astro?tempo-component` -> `./Card.astro`). */
117
+ declare function componentImportPath(source: string): string;
118
+
3
119
  type CanvasSourceSpan = {
4
120
  start: number;
5
121
  end: number;
@@ -12,6 +128,18 @@ type CanvasParseError = {
12
128
  * (or the canvas display name) is not statically readable/editable but
13
129
  * identity is intact — readers keep working with fallback values. */
14
130
  kind: "structural" | "degraded";
131
+ /** Set on the structural error for a `<Canvas>` child that a newer
132
+ * tempo-sdk exports as a storyboard component this parser does not know
133
+ * (a `<VueStoryboard>` read by a parser from before Vue support). That
134
+ * board is unreadable, but the canvas's other storyboards are intact, so
135
+ * a reader that works per storyboard, like visual review, may skip just
136
+ * this one. */
137
+ newerSdkStoryboard?: {
138
+ component: string;
139
+ storyboardKey?: string;
140
+ /** Whether the declaration asks for visual-review tracking. */
141
+ vrt: boolean;
142
+ };
15
143
  };
16
144
  type ParsedCanvasImport = {
17
145
  localName: string;
@@ -91,11 +219,14 @@ type ParsedCanvasExpressionReference = {
91
219
  type ParsedCanvasStoryboard = {
92
220
  storyboardKey: string;
93
221
  displayName?: string;
94
- kind: "component" | "route" | "html";
222
+ kind: StoryboardKind;
95
223
  /** Legacy component-runtime field; its published output union stays stable. */
96
224
  uiFramework?: "svelte";
97
- /** Additional component runtimes, without widening the legacy output field. */
225
+ /** Legacy Astro field; its published output union stays stable too. */
98
226
  runtimeFramework?: "astro";
227
+ /** The component's non-React runtime. New consumers should read it through
228
+ * componentFrameworkForStoryboard, which also accepts older parser output. */
229
+ componentFramework?: StoryboardUiFramework;
99
230
  layout: ParsedCanvasLayout;
100
231
  editable: boolean;
101
232
  jsxElementSpan: CanvasSourceSpan;
@@ -123,6 +254,11 @@ type ParsedCanvasStoryboard = {
123
254
  src?: string;
124
255
  srcSpan?: CanvasSourceSpan;
125
256
  srcAttributeSpan?: CanvasSourceSpan;
257
+ /** `<FlutterStoryboard preview>`: `<canvas-relative-file>.dart#<function>` in its
258
+ * nearest Dart package. */
259
+ preview?: string;
260
+ previewSpan?: CanvasSourceSpan;
261
+ previewAttributeSpan?: CanvasSourceSpan;
126
262
  legacyV1?: {
127
263
  storyboard: ParsedCanvasExpressionReference;
128
264
  objectName?: string;
@@ -133,6 +269,9 @@ type ParsedCanvasStoryboard = {
133
269
  };
134
270
  errors: CanvasParseError[];
135
271
  };
272
+ /** The component runtime, including parser output written before the
273
+ * canonical componentFramework field existed. React, routes and HTML omit it. */
274
+ declare function componentFrameworkForStoryboard(storyboard: Pick<ParsedCanvasStoryboard, "componentFramework" | "runtimeFramework" | "uiFramework">): StoryboardUiFramework | undefined;
136
275
  type ParsedCanvasFile = {
137
276
  filePath: string;
138
277
  canvasPath?: string;
@@ -165,4 +304,4 @@ declare function parseComponentRoot(filePath: string, source: string, exportName
165
304
  root: JSXElement;
166
305
  } | null;
167
306
 
168
- export { type CanvasParseError, type CanvasSourceSpan, type MisimportedSdkCanvasImport, NO_CANVAS_DECLARATION_ERROR, type ParsedCanvasComponentReference, type ParsedCanvasExpressionReference, type ParsedCanvasFile, type ParsedCanvasImport, type ParsedCanvasLayout, type ParsedCanvasLayoutSpans, type ParsedCanvasStoryboard, type ParsedStoryboardVrt, type ParsedStoryboardVrtIgnoreRegion, fallbackPageName, misimportedSdkCanvasImportMessage, parseCanvasFile, parseComponentRoot, unwrapTsExpression };
307
+ export { type CanvasParseError, type CanvasSourceSpan, type MisimportedSdkCanvasImport, NO_CANVAS_DECLARATION_ERROR, type ParsedCanvasComponentReference, type ParsedCanvasExpressionReference, type ParsedCanvasFile, type ParsedCanvasImport, type ParsedCanvasLayout, type ParsedCanvasLayoutSpans, type ParsedCanvasStoryboard, type ParsedStoryboardVrt, type ParsedStoryboardVrtIgnoreRegion, STORYBOARD_SDK_COMPONENTS, type StoryboardSdkComponent, type StoryboardSdkComponentSpec, type StoryboardUiFramework, componentFileExtensionForFramework, componentFrameworkForStoryboard, componentImportPath, componentImportSpecifier, fallbackPageName, misimportedSdkCanvasImportMessage, parseCanvasFile, parseComponentRoot, storyboardComponentForFramework, unwrapTsExpression };
@@ -1,17 +1,30 @@
1
1
  import {
2
2
  NO_CANVAS_DECLARATION_ERROR,
3
+ STORYBOARD_SDK_COMPONENTS,
4
+ componentFileExtensionForFramework,
5
+ componentFrameworkForStoryboard,
6
+ componentImportPath,
7
+ componentImportSpecifier,
3
8
  fallbackPageName,
4
9
  misimportedSdkCanvasImportMessage,
5
10
  parseCanvasFile,
6
11
  parseComponentRoot,
12
+ storyboardComponentForFramework,
7
13
  unwrapTsExpression
8
- } from "../chunk-PXDTH36X.js";
14
+ } from "../chunk-Y72PIE3I.js";
15
+ import "../chunk-CYQE3TLC.js";
9
16
  export {
10
17
  NO_CANVAS_DECLARATION_ERROR,
18
+ STORYBOARD_SDK_COMPONENTS,
19
+ componentFileExtensionForFramework,
20
+ componentFrameworkForStoryboard,
21
+ componentImportPath,
22
+ componentImportSpecifier,
11
23
  fallbackPageName,
12
24
  misimportedSdkCanvasImportMessage,
13
25
  parseCanvasFile,
14
26
  parseComponentRoot,
27
+ storyboardComponentForFramework,
15
28
  unwrapTsExpression
16
29
  };
17
30
  //# sourceMappingURL=parser.js.map
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import * as svelte from 'svelte';
3
- import { a as StoryboardLayout, c as StoryboardVrtConfig } from '../storyboard-4YdTYq_e.js';
3
+ import { S as StoryboardLayout, a as StoryboardVrtConfig } from '../storyboard-CMJVBSXn.js';
4
4
  import '../page-DwLnOM5d.js';
5
5
  import '../v1-client-compat-qxaXEDm_.js';
6
6
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  StoryboardSlot
3
- } from "../chunk-6IR5JY6W.js";
4
- import "../chunk-NSKYOKG5.js";
3
+ } from "../chunk-YECMP34I.js";
4
+ import "../chunk-ZXC7SZIT.js";
5
5
  import "../chunk-6AAE4LYV.js";
6
6
 
7
7
  // canvas/svelte.tsx
@@ -0,0 +1,74 @@
1
+ import * as react from 'react';
2
+ import * as vue from 'vue';
3
+ import { S as StoryboardLayout, a as StoryboardVrtConfig } from '../storyboard-CMJVBSXn.js';
4
+ import '../page-DwLnOM5d.js';
5
+ import '../v1-client-compat-qxaXEDm_.js';
6
+
7
+ /** Public Vue 3 component shape. This Vue-specific entrypoint keeps
8
+ * React-only consumers of tempo-sdk/canvas from resolving the optional Vue
9
+ * peer dependency. */
10
+ type VueComponent<Props extends Record<string, unknown> = Record<string, unknown>> = vue.Component<Props>;
11
+ /** The app a storyboard mounts, for `setup` to install plugins on. */
12
+ type VueApp = vue.App;
13
+ /** Where a storyboard's app is being prepared. `renderId` is unique per
14
+ * document (canvas path plus storyboard id); `storyboardId` is the authored
15
+ * id alone, which two canvases may share. */
16
+ interface VueStoryboardContext {
17
+ storyboardId: string;
18
+ renderId: string;
19
+ }
20
+ /** What every Vue storyboard's app goes through before it mounts. The host
21
+ * entry of a meta-framework sidecar installs one: the Nuxt sidecar creates
22
+ * the board's Nuxt app context and applies the app's plugins here. A
23
+ * storyboard's own `setup` runs after it, on the same app. */
24
+ interface VueStoryboardEnvironment {
25
+ setup: ((app: VueApp, context: VueStoryboardContext) => void) | ((app: VueApp, context: VueStoryboardContext) => Promise<void>);
26
+ /** Releases what `setup` bound outside the board's Vue app: the Nuxt
27
+ * sidecar unbinds the board's Nuxt app context, stops its effect scope and
28
+ * removes the global listeners its plugins added. Called once for every
29
+ * app `setup` ran on: after the app unmounts, or when it is discarded
30
+ * without mounting (its setup failed or missed its deadline, or the board
31
+ * went away first). Without it every board remount leaked a whole Nuxt
32
+ * app. */
33
+ teardown?: (app: VueApp, context: VueStoryboardContext) => void;
34
+ /** Names what this board's `setup` is still waiting on (the Nuxt sidecar
35
+ * names the plugins still running), for the board's error when setup
36
+ * misses its deadline. */
37
+ describePendingSetup?: (app: VueApp, context: VueStoryboardContext) => string | undefined;
38
+ }
39
+ /** Runs before a storyboard's app mounts: `app.use(...)` for pinia,
40
+ * vue-router or vue-i18n. May be async; the board stays pending until it
41
+ * settles. A union of two signatures rather than one returning
42
+ * `void | Promise<void>`, so an inline `(app) => app.use(pinia)` (which
43
+ * returns the app) stays assignable, as it was to `(app) => void`. */
44
+ type VueStoryboardSetup = ((app: VueApp) => void) | ((app: VueApp) => Promise<void>);
45
+ /**
46
+ * How long a board's setup (the environment's, then the storyboard's) may
47
+ * take before the board shows an error instead. The canvas declares a board
48
+ * stalled when no first batch has arrived 30 s after it began streaming, and
49
+ * then reloads the whole shared host, sibling boards included, with a
50
+ * generic convergence-stall problem. A setup that never settles (a Nuxt
51
+ * plugin awaiting something the canvas never provides) must become this
52
+ * board's own named error well before that; a setup that waits on the
53
+ * network still has ample time.
54
+ */
55
+ declare const VUE_STORYBOARD_SETUP_TIMEOUT_MS = 15000;
56
+ /** Installs (or with `null` removes) the environment every Vue storyboard
57
+ * in this document is prepared with. Call it before rendering the canvas
58
+ * host; a board prepared earlier keeps the environment it was prepared
59
+ * with. The Vite host configures nothing, so plain Vue projects mount
60
+ * exactly as they did without one. */
61
+ declare function configureVueStoryboards(next: VueStoryboardEnvironment | null): void;
62
+ declare function VueStoryboard<Props extends Record<string, unknown> = Record<string, unknown>>({ id, name, component, layout, props, vrt, setup, }: {
63
+ id: string;
64
+ component: VueComponent<Props>;
65
+ layout: StoryboardLayout;
66
+ name?: string;
67
+ props?: Props;
68
+ vrt?: boolean | StoryboardVrtConfig;
69
+ /** Runs on the storyboard's app before it mounts, after the document's
70
+ * environment, for plugins such as pinia, vue-router or vue-i18n. */
71
+ setup?: VueStoryboardSetup;
72
+ } & Record<`data-tempo-${string}`, unknown>): react.JSX.Element;
73
+
74
+ export { VUE_STORYBOARD_SETUP_TIMEOUT_MS, type VueApp, type VueComponent, VueStoryboard, type VueStoryboardContext, type VueStoryboardEnvironment, type VueStoryboardSetup, configureVueStoryboards };
@@ -0,0 +1,264 @@
1
+ import {
2
+ StoryboardSlot,
3
+ useCanvasStoryboardRenderId
4
+ } from "../chunk-YECMP34I.js";
5
+ import "../chunk-ZXC7SZIT.js";
6
+ import "../chunk-6AAE4LYV.js";
7
+
8
+ // canvas/vue.tsx
9
+ import { useLayoutEffect, useRef, useState } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var environment = null;
12
+ var VUE_STORYBOARD_SETUP_TIMEOUT_MS = 15e3;
13
+ function configureVueStoryboards(next) {
14
+ environment = next;
15
+ }
16
+ var vueRuntimeState = null;
17
+ var RENDER_PHASES = /* @__PURE__ */ new Set([
18
+ "setup function",
19
+ "render function",
20
+ "component update",
21
+ "serverPrefetch hook",
22
+ "beforeCreate hook",
23
+ "created hook",
24
+ "beforeMount hook",
25
+ "mounted hook",
26
+ "beforeUpdate hook",
27
+ "updated",
28
+ "beforeUnmount hook",
29
+ "unmounted hook",
30
+ "activated hook",
31
+ "deactivated hook"
32
+ ]);
33
+ function reportUncaught(error) {
34
+ if (typeof globalThis.reportError === "function")
35
+ globalThis.reportError(error);
36
+ else console.error(error);
37
+ }
38
+ function readVueRuntime() {
39
+ if (vueRuntimeState?.kind === "ready") return vueRuntimeState.runtime;
40
+ if (vueRuntimeState?.kind === "error") throw vueRuntimeState.error;
41
+ if (!vueRuntimeState) {
42
+ const promise = import("vue").then(
43
+ (runtime) => {
44
+ vueRuntimeState = { kind: "ready", runtime };
45
+ },
46
+ (error) => {
47
+ vueRuntimeState = { kind: "error", error };
48
+ }
49
+ );
50
+ vueRuntimeState = { kind: "pending", promise };
51
+ }
52
+ throw vueRuntimeState.promise;
53
+ }
54
+ function VueStoryboard({
55
+ id,
56
+ name,
57
+ component,
58
+ layout,
59
+ props,
60
+ vrt,
61
+ setup
62
+ }) {
63
+ const renderId = useCanvasStoryboardRenderId(id);
64
+ useLayoutEffect(() => () => releaseUnmountedApp(renderId), [renderId]);
65
+ return /* @__PURE__ */ jsx(
66
+ StoryboardSlot,
67
+ {
68
+ "data-tempo-hide-fiber": "true",
69
+ id,
70
+ name,
71
+ layout,
72
+ kind: "component",
73
+ uiFramework: "vue",
74
+ vrt: !!vrt,
75
+ children: /* @__PURE__ */ jsx(
76
+ VueComponentMount,
77
+ {
78
+ storyboardId: id,
79
+ component,
80
+ props,
81
+ setup
82
+ }
83
+ )
84
+ }
85
+ );
86
+ }
87
+ var prepared = /* @__PURE__ */ new Map();
88
+ function sameComponent(current, next) {
89
+ if (current === next) return true;
90
+ const hmrId = (component) => component.__hmrId;
91
+ return hmrId(current) !== void 0 && hmrId(current) === hmrId(next);
92
+ }
93
+ function isThenable(value) {
94
+ return typeof value === "object" && value !== null && typeof value.then === "function";
95
+ }
96
+ function runSetups(entry, setup) {
97
+ const { app, context } = entry;
98
+ const environmentResult = entry.environment?.setup(app, context);
99
+ if (isThenable(environmentResult)) {
100
+ return Promise.resolve(environmentResult).then(() => {
101
+ if (entry.released) return;
102
+ entry.setupPhase = "storyboard";
103
+ return setup?.(app);
104
+ });
105
+ }
106
+ entry.setupPhase = "storyboard";
107
+ const setupResult = setup?.(app);
108
+ return isThenable(setupResult) ? Promise.resolve(setupResult) : null;
109
+ }
110
+ function settleWithinDeadline(entry, setup) {
111
+ return new Promise((resolve) => {
112
+ let settled = false;
113
+ const finish = (setupError) => {
114
+ if (settled) return;
115
+ settled = true;
116
+ clearTimeout(deadline);
117
+ entry.pending = null;
118
+ if (setupError) entry.setupError = setupError;
119
+ resolve();
120
+ };
121
+ const deadline = setTimeout(
122
+ () => finish({ error: setupTimeoutError(entry) }),
123
+ VUE_STORYBOARD_SETUP_TIMEOUT_MS
124
+ );
125
+ entry.stopSetupDeadline = () => clearTimeout(deadline);
126
+ setup.then(
127
+ () => finish(null),
128
+ (error) => finish({ error })
129
+ );
130
+ });
131
+ }
132
+ function setupTimeoutError(entry) {
133
+ const seconds = VUE_STORYBOARD_SETUP_TIMEOUT_MS / 1e3;
134
+ const environmentPending = entry.environment?.describePendingSetup?.(entry.app, entry.context) ?? "the canvas host's setup for it is still running";
135
+ const pending = entry.setupPhase === "storyboard" ? "its own setup is still running" : environmentPending;
136
+ return new Error(
137
+ `Vue storyboard "${entry.context.storyboardId}" did not finish setting up within ${seconds}s: ${pending}.`
138
+ );
139
+ }
140
+ function releasePreparedApp(entry) {
141
+ if (entry.released) return;
142
+ entry.released = true;
143
+ entry.stopSetupDeadline?.();
144
+ try {
145
+ entry.environment?.teardown?.(entry.app, entry.context);
146
+ } catch (error) {
147
+ reportUncaught(error);
148
+ }
149
+ }
150
+ function prepareApp(renderId, storyboardId, runtime, component, props, setup) {
151
+ const existing = prepared.get(renderId);
152
+ if (existing && sameComponent(existing.component, component)) return existing;
153
+ if (existing && !existing.ownedByMountEffect) releasePreparedApp(existing);
154
+ const propsRef = runtime.shallowRef(props);
155
+ const app = runtime.createApp({
156
+ render: () => runtime.h(runtime.Suspense, null, {
157
+ default: () => runtime.h(component, propsRef.value)
158
+ })
159
+ });
160
+ const entry = {
161
+ app,
162
+ context: { storyboardId, renderId },
163
+ environment,
164
+ component,
165
+ propsRef,
166
+ pending: null,
167
+ setupPhase: "environment",
168
+ setupError: null,
169
+ onRenderError: null,
170
+ ownedByMountEffect: false,
171
+ released: false,
172
+ stopSetupDeadline: null
173
+ };
174
+ app.config.errorHandler = (error, _instance, info) => {
175
+ if (!RENDER_PHASES.has(info)) {
176
+ reportUncaught(error);
177
+ return;
178
+ }
179
+ if (entry.onRenderError) entry.onRenderError(error);
180
+ else entry.setupError = { error };
181
+ };
182
+ prepared.set(renderId, entry);
183
+ try {
184
+ const pending = runSetups(entry, setup);
185
+ if (pending) entry.pending = settleWithinDeadline(entry, pending);
186
+ } catch (error) {
187
+ entry.setupError = { error };
188
+ }
189
+ return entry;
190
+ }
191
+ function releaseUnmountedApp(renderId) {
192
+ const entry = prepared.get(renderId);
193
+ if (!entry || entry.ownedByMountEffect) return;
194
+ prepared.delete(renderId);
195
+ releasePreparedApp(entry);
196
+ }
197
+ function VueComponentMount({
198
+ storyboardId,
199
+ component,
200
+ props,
201
+ setup
202
+ }) {
203
+ const renderId = useCanvasStoryboardRenderId(storyboardId);
204
+ const targetRef = useRef(null);
205
+ const [mountError, setMountError] = useState(null);
206
+ if (mountError) throw mountError;
207
+ const runtime = readVueRuntime();
208
+ const entry = prepareApp(
209
+ renderId,
210
+ storyboardId,
211
+ runtime,
212
+ component,
213
+ props ?? {},
214
+ setup
215
+ );
216
+ if (entry.pending) throw entry.pending;
217
+ if (entry.setupError) {
218
+ if (!entry.setupError.released) {
219
+ entry.setupError.released = true;
220
+ setTimeout(() => {
221
+ if (prepared.get(renderId) === entry) prepared.delete(renderId);
222
+ releasePreparedApp(entry);
223
+ }, 0);
224
+ }
225
+ throw entry.setupError.error;
226
+ }
227
+ useLayoutEffect(() => {
228
+ const next = props ?? {};
229
+ if (!shallowEqual(entry.propsRef.value, next)) entry.propsRef.value = next;
230
+ }, [props, entry]);
231
+ useLayoutEffect(() => {
232
+ const target = targetRef.current;
233
+ if (!target) return;
234
+ entry.onRenderError = setMountError;
235
+ entry.ownedByMountEffect = true;
236
+ let mounted = false;
237
+ try {
238
+ entry.app.mount(target);
239
+ mounted = true;
240
+ } catch (error) {
241
+ setMountError(error);
242
+ }
243
+ return () => {
244
+ entry.onRenderError = null;
245
+ if (mounted) entry.app.unmount();
246
+ target.replaceChildren();
247
+ if (prepared.get(renderId) === entry) prepared.delete(renderId);
248
+ releasePreparedApp(entry);
249
+ };
250
+ }, [entry, renderId]);
251
+ return /* @__PURE__ */ jsx("div", { ref: targetRef, "data-tempo-hide-fiber": "true" });
252
+ }
253
+ function shallowEqual(a, b) {
254
+ const aKeys = Object.keys(a);
255
+ const bKeys = new Set(Object.keys(b));
256
+ if (aKeys.length !== bKeys.size) return false;
257
+ return aKeys.every((key) => bKeys.has(key) && Object.is(a[key], b[key]));
258
+ }
259
+ export {
260
+ VUE_STORYBOARD_SETUP_TIMEOUT_MS,
261
+ VueStoryboard,
262
+ configureVueStoryboards
263
+ };
264
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../canvas/vue.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from \"react\";\n\nimport { useCanvasStoryboardRenderId } from \"./canvas\";\nimport {\n StoryboardSlot,\n type StoryboardLayout,\n type StoryboardVrtConfig,\n} from \"./storyboard\";\n\n/** Public Vue 3 component shape. This Vue-specific entrypoint keeps\n * React-only consumers of tempo-sdk/canvas from resolving the optional Vue\n * peer dependency. */\nexport type VueComponent<\n Props extends Record<string, unknown> = Record<string, unknown>,\n> = import(\"vue\").Component<Props>;\n\n/** The app a storyboard mounts, for `setup` to install plugins on. */\nexport type VueApp = import(\"vue\").App;\n\n/** Where a storyboard's app is being prepared. `renderId` is unique per\n * document (canvas path plus storyboard id); `storyboardId` is the authored\n * id alone, which two canvases may share. */\nexport interface VueStoryboardContext {\n storyboardId: string;\n renderId: string;\n}\n\n/** What every Vue storyboard's app goes through before it mounts. The host\n * entry of a meta-framework sidecar installs one: the Nuxt sidecar creates\n * the board's Nuxt app context and applies the app's plugins here. A\n * storyboard's own `setup` runs after it, on the same app. */\nexport interface VueStoryboardEnvironment {\n setup:\n | ((app: VueApp, context: VueStoryboardContext) => void)\n | ((app: VueApp, context: VueStoryboardContext) => Promise<void>);\n /** Releases what `setup` bound outside the board's Vue app: the Nuxt\n * sidecar unbinds the board's Nuxt app context, stops its effect scope and\n * removes the global listeners its plugins added. Called once for every\n * app `setup` ran on: after the app unmounts, or when it is discarded\n * without mounting (its setup failed or missed its deadline, or the board\n * went away first). Without it every board remount leaked a whole Nuxt\n * app. */\n teardown?: (app: VueApp, context: VueStoryboardContext) => void;\n /** Names what this board's `setup` is still waiting on (the Nuxt sidecar\n * names the plugins still running), for the board's error when setup\n * misses its deadline. */\n describePendingSetup?: (\n app: VueApp,\n context: VueStoryboardContext,\n ) => string | undefined;\n}\n\n/** Runs before a storyboard's app mounts: `app.use(...)` for pinia,\n * vue-router or vue-i18n. May be async; the board stays pending until it\n * settles. A union of two signatures rather than one returning\n * `void | Promise<void>`, so an inline `(app) => app.use(pinia)` (which\n * returns the app) stays assignable, as it was to `(app) => void`. */\nexport type VueStoryboardSetup =\n | ((app: VueApp) => void)\n | ((app: VueApp) => Promise<void>);\n\nlet environment: VueStoryboardEnvironment | null = null;\n\n/**\n * How long a board's setup (the environment's, then the storyboard's) may\n * take before the board shows an error instead. The canvas declares a board\n * stalled when no first batch has arrived 30 s after it began streaming, and\n * then reloads the whole shared host, sibling boards included, with a\n * generic convergence-stall problem. A setup that never settles (a Nuxt\n * plugin awaiting something the canvas never provides) must become this\n * board's own named error well before that; a setup that waits on the\n * network still has ample time.\n */\nexport const VUE_STORYBOARD_SETUP_TIMEOUT_MS = 15_000;\n\n/** Installs (or with `null` removes) the environment every Vue storyboard\n * in this document is prepared with. Call it before rendering the canvas\n * host; a board prepared earlier keeps the environment it was prepared\n * with. The Vite host configures nothing, so plain Vue projects mount\n * exactly as they did without one. */\nexport function configureVueStoryboards(\n next: VueStoryboardEnvironment | null,\n): void {\n environment = next;\n}\n\ntype VueRuntime = typeof import(\"vue\");\ntype VueRuntimeState =\n | { kind: \"pending\"; promise: Promise<void> }\n | { kind: \"ready\"; runtime: VueRuntime }\n | { kind: \"error\"; error: unknown };\n\nlet vueRuntimeState: VueRuntimeState | null = null;\n\n/** The phases, as Vue names them in an error handler's `info`\n * (`ErrorTypeStrings` in @vue/runtime-core), in which an error leaves the\n * component unable to render: setup, render, a component update and the\n * lifecycle hooks. Only those replace the board with its error UI. An error\n * in an event handler, a watcher, an async loader or a directive leaves the\n * mounted board standing, as a throw from a React storyboard's event handler\n * does. Production builds spell `info` as a docs link; the canvas host runs\n * Vue's development build. */\nconst RENDER_PHASES = new Set([\n \"setup function\",\n \"render function\",\n \"component update\",\n \"serverPrefetch hook\",\n \"beforeCreate hook\",\n \"created hook\",\n \"beforeMount hook\",\n \"mounted hook\",\n \"beforeUpdate hook\",\n \"updated\",\n \"beforeUnmount hook\",\n \"unmounted hook\",\n \"activated hook\",\n \"deactivated hook\",\n]);\n\n/** Reports an error the board survives the way an uncaught throw is\n * reported: the page's `error` event, which the canvas's runtime problem\n * tracker records. */\nfunction reportUncaught(error: unknown) {\n if (typeof globalThis.reportError === \"function\")\n globalThis.reportError(error);\n else console.error(error);\n}\n\n/** Suspense resource for the optional Vue runtime. The storyboard must not\n * report its React shell as rendered before the authored Vue DOM exists,\n * otherwise the component projection opens with a permanent DOM-only\n * baseline. */\nfunction readVueRuntime(): VueRuntime {\n if (vueRuntimeState?.kind === \"ready\") return vueRuntimeState.runtime;\n if (vueRuntimeState?.kind === \"error\") throw vueRuntimeState.error;\n if (!vueRuntimeState) {\n const promise = import(\"vue\").then(\n (runtime) => {\n vueRuntimeState = { kind: \"ready\", runtime };\n },\n (error: unknown) => {\n vueRuntimeState = { kind: \"error\", error };\n },\n );\n vueRuntimeState = { kind: \"pending\", promise };\n }\n throw vueRuntimeState.promise;\n}\n\nexport function VueStoryboard<\n Props extends Record<string, unknown> = Record<string, unknown>,\n>({\n id,\n name,\n component,\n layout,\n props,\n vrt,\n setup,\n}: {\n id: string;\n component: VueComponent<Props>;\n layout: StoryboardLayout;\n name?: string;\n props?: Props;\n vrt?: boolean | StoryboardVrtConfig;\n /** Runs on the storyboard's app before it mounts, after the document's\n * environment, for plugins such as pinia, vue-router or vue-i18n. */\n setup?: VueStoryboardSetup;\n} & Record<`data-tempo-${string}`, unknown>) {\n const renderId = useCanvasStoryboardRenderId(id);\n // The board's slot (with the Suspense boundary inside it) stays mounted\n // while the Vue mount below suspends on setup. A board removed in that\n // window never commits its mount, so no effect of the mount's own would\n // release the app it prepared; the board does, as it goes.\n useLayoutEffect(() => () => releaseUnmountedApp(renderId), [renderId]);\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"component\"\n uiFramework=\"vue\"\n vrt={!!vrt}\n >\n <VueComponentMount\n storyboardId={id}\n component={component}\n props={props}\n setup={setup}\n />\n </StoryboardSlot>\n );\n}\n\n/** A storyboard's app between creation and unmount. It lives outside React\n * state: a component that suspends on its first render loses its hook\n * state, so an app held in `useState` would be created again on every\n * retry (measured: 15,820 Nuxt apps in a loop). Keyed by the slot's render\n * id, the same key the slot reports as `data-tempo-storyboard-render-id`. */\ninterface PreparedApp {\n app: VueApp;\n context: VueStoryboardContext;\n /** The environment the app was prepared with, which releases it. */\n environment: VueStoryboardEnvironment | null;\n component: VueComponent<Record<string, unknown>>;\n propsRef: import(\"vue\").ShallowRef<Record<string, unknown>>;\n /** Open while the environment's or the storyboard's setup is still\n * running, until the deadline at most; the mount suspends on it. `null`\n * once settled. */\n pending: Promise<void> | null;\n /** Which setup is running, for the deadline's error. */\n setupPhase: \"environment\" | \"storyboard\";\n /** What setup threw or rejected with. Once thrown to React, the entry is\n * released at the end of the task so the storyboard's retry prepares a\n * fresh app. */\n setupError: { error: unknown; released?: boolean } | null;\n /** Routes a render-phase error from Vue's error handler to the mounted\n * React component. Installed by the mount effect, cleared on cleanup. */\n onRenderError: ((error: unknown) => void) | null;\n /** Set once the mount effect takes the app: its cleanup then unmounts and\n * releases it. An app no mount effect took is released where it is\n * dropped. */\n ownedByMountEffect: boolean;\n released: boolean;\n /** Clears the setup deadline, if one is running. */\n stopSetupDeadline: (() => void) | null;\n}\n\nconst prepared = new Map<string, PreparedApp>();\n\n/** Whether two component objects are the same SFC. An HMR update of a\n * component makes Vite serve its importers again, so a canvas file that\n * React Fast Refresh re-evaluates next passes a new object for an SFC that\n * did not change. Vue's HMR runtime has already updated the mounted app in\n * place, keyed by `__hmrId`; a fresh app would only re-run the environment's\n * async setup and leave the board empty meanwhile (the Nuxt sidecar's\n * CardSlots board went empty for 300 ms after every write to AppCard.vue).\n * Production builds carry no `__hmrId`, so identity decides there. */\nfunction sameComponent(\n current: VueComponent<Record<string, unknown>>,\n next: VueComponent<Record<string, unknown>>,\n): boolean {\n if (current === next) return true;\n const hmrId = (component: unknown) =>\n (component as { __hmrId?: string }).__hmrId;\n return hmrId(current) !== undefined && hmrId(current) === hmrId(next);\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<void> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/** Runs the environment's setup and then the storyboard's on the app.\n * Returns `null` when both finished synchronously, so a board without an\n * async step mounts in the same commit it always did, with no Suspense\n * round trip in between. A synchronous throw propagates. */\nfunction runSetups(\n entry: PreparedApp,\n setup: VueStoryboardSetup | undefined,\n): Promise<void> | null {\n const { app, context } = entry;\n const environmentResult = entry.environment?.setup(app, context);\n if (isThenable(environmentResult)) {\n return Promise.resolve(environmentResult).then(() => {\n // The board can disappear or replace its component while its\n // environment is pending. Its released app must acquire no new work.\n if (entry.released) return;\n entry.setupPhase = \"storyboard\";\n return setup?.(app);\n });\n }\n entry.setupPhase = \"storyboard\";\n const setupResult = setup?.(app);\n return isThenable(setupResult) ? Promise.resolve(setupResult) : null;\n}\n\n/** What the mount suspends on: it resolves when setup settles, or at the\n * deadline with an error naming what is still running. The verdict lands on\n * the entry; a setup that settles after the deadline changes nothing (its\n * app is released with the board's error). */\nfunction settleWithinDeadline(\n entry: PreparedApp,\n setup: Promise<void>,\n): Promise<void> {\n return new Promise<void>((resolve) => {\n let settled = false;\n const finish = (setupError: { error: unknown } | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(deadline);\n entry.pending = null;\n if (setupError) entry.setupError = setupError;\n resolve();\n };\n const deadline = setTimeout(\n () => finish({ error: setupTimeoutError(entry) }),\n VUE_STORYBOARD_SETUP_TIMEOUT_MS,\n );\n entry.stopSetupDeadline = () => clearTimeout(deadline);\n setup.then(\n () => finish(null),\n (error: unknown) => finish({ error }),\n );\n });\n}\n\nfunction setupTimeoutError(entry: PreparedApp): Error {\n const seconds = VUE_STORYBOARD_SETUP_TIMEOUT_MS / 1000;\n const environmentPending =\n entry.environment?.describePendingSetup?.(entry.app, entry.context) ??\n \"the canvas host's setup for it is still running\";\n const pending =\n entry.setupPhase === \"storyboard\"\n ? \"its own setup is still running\"\n : environmentPending;\n return new Error(\n `Vue storyboard \"${entry.context.storyboardId}\" did not finish setting up within ${seconds}s: ${pending}.`,\n );\n}\n\n/** Lets the environment release what it bound outside the app, once. The\n * Vue app itself is unmounted by then, or never mounted. */\nfunction releasePreparedApp(entry: PreparedApp): void {\n if (entry.released) return;\n entry.released = true;\n entry.stopSetupDeadline?.();\n try {\n entry.environment?.teardown?.(entry.app, entry.context);\n } catch (error) {\n reportUncaught(error);\n }\n}\n\nfunction prepareApp(\n renderId: string,\n storyboardId: string,\n runtime: VueRuntime,\n component: VueComponent<Record<string, unknown>>,\n props: Record<string, unknown>,\n setup: VueStoryboardSetup | undefined,\n): PreparedApp {\n const existing = prepared.get(renderId);\n if (existing && sameComponent(existing.component, component)) return existing;\n // A replaced component's app is unmounted and released by the mount\n // effect's cleanup, which still holds the old entry; one that never\n // mounted (still suspended on its setup) is released here.\n if (existing && !existing.ownedByMountEffect) releasePreparedApp(existing);\n const propsRef = runtime.shallowRef(props);\n // The wrapper root gives the user's component a parent, so Vue's HMR\n // `reload` re-renders it through that parent; a parentless root would\n // fall back to reloading the whole canvas document. Its Suspense is what\n // lets an async component (`await useFetch(...)` in `<script setup>`)\n // render at all: Vue refuses one without a Suspense ancestor.\n const app = runtime.createApp({\n render: () =>\n runtime.h(runtime.Suspense, null, {\n default: () => runtime.h(component, propsRef.value),\n }),\n });\n const entry: PreparedApp = {\n app,\n context: { storyboardId, renderId },\n environment,\n component,\n propsRef,\n pending: null,\n setupPhase: \"environment\",\n setupError: null,\n onRenderError: null,\n ownedByMountEffect: false,\n released: false,\n stopSetupDeadline: null,\n };\n app.config.errorHandler = (error, _instance, info) => {\n if (!RENDER_PHASES.has(info)) {\n reportUncaught(error);\n return;\n }\n if (entry.onRenderError) entry.onRenderError(error);\n else entry.setupError = { error };\n };\n prepared.set(renderId, entry);\n try {\n const pending = runSetups(entry, setup);\n if (pending) entry.pending = settleWithinDeadline(entry, pending);\n } catch (error) {\n entry.setupError = { error };\n }\n return entry;\n}\n\n/** Releases the board's app if no mount effect took it: the board went away\n * while the app was still suspended on its setup. A mounted app is released\n * by its own mount effect's cleanup. */\nfunction releaseUnmountedApp(renderId: string): void {\n const entry = prepared.get(renderId);\n if (!entry || entry.ownedByMountEffect) return;\n prepared.delete(renderId);\n releasePreparedApp(entry);\n}\n\nfunction VueComponentMount<Props extends Record<string, unknown>>({\n storyboardId,\n component,\n props,\n setup,\n}: {\n storyboardId: string;\n component: VueComponent<Props>;\n props?: Props;\n setup?: VueStoryboardSetup;\n}) {\n const renderId = useCanvasStoryboardRenderId(storyboardId);\n const targetRef = useRef<HTMLDivElement | null>(null);\n const [mountError, setMountError] = useState<unknown>(null);\n if (mountError) throw mountError;\n const runtime = readVueRuntime();\n const entry = prepareApp(\n renderId,\n storyboardId,\n runtime,\n component as VueComponent<Record<string, unknown>>,\n props ?? {},\n setup,\n );\n // Suspend until setup settles: the React shell must not commit before the\n // Vue DOM can exist (see readVueRuntime). The prepared app outlives this\n // suspended render, so the retry picks it up instead of starting over.\n if (entry.pending) throw entry.pending;\n if (entry.setupError) {\n // The storyboard's error UI takes over. React re-renders synchronously\n // once after a thrown error, so the verdict is held for the rest of this\n // task (discarding the entry at once would start a fresh setup inside\n // that re-render and never reach the boundary). The storyboard's retry\n // comes a task later and must prepare a fresh app rather than rethrow.\n if (!entry.setupError.released) {\n entry.setupError.released = true;\n setTimeout(() => {\n if (prepared.get(renderId) === entry) prepared.delete(renderId);\n releasePreparedApp(entry);\n }, 0);\n }\n throw entry.setupError.error;\n }\n\n // Before the mount effect, so a (re)mount reads the latest props. One\n // reactive props holder for the app's lifetime: a props change re-renders\n // the mounted app in place instead of remounting it. `setup` ran when the\n // app was prepared; canvas files pass an inline function whose identity\n // changes on every render, never a reason to remount.\n useLayoutEffect(() => {\n const next = props ?? {};\n if (!shallowEqual(entry.propsRef.value, next)) entry.propsRef.value = next;\n }, [props, entry]);\n\n useLayoutEffect(() => {\n const target = targetRef.current;\n if (!target) return;\n entry.onRenderError = setMountError;\n entry.ownedByMountEffect = true;\n let mounted = false;\n try {\n entry.app.mount(target);\n mounted = true;\n } catch (error) {\n setMountError(error);\n }\n\n return () => {\n entry.onRenderError = null;\n if (mounted) entry.app.unmount();\n target.replaceChildren();\n if (prepared.get(renderId) === entry) prepared.delete(renderId);\n releasePreparedApp(entry);\n };\n }, [entry, renderId]);\n\n return <div ref={targetRef} data-tempo-hide-fiber=\"true\" />;\n}\n\nfunction shallowEqual(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n const aKeys = Object.keys(a);\n const bKeys = new Set(Object.keys(b));\n if (aKeys.length !== bKeys.size) return false;\n return aKeys.every((key) => bKeys.has(key) && Object.is(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