@webstudio-is/react-sdk 0.36.0 → 0.41.0

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 (79) hide show
  1. package/lib/app/custom-components/shared/remix-link.js +2 -2
  2. package/lib/cjs/app/custom-components/shared/remix-link.cjs +2 -2
  3. package/lib/cjs/components/__generated__/blockquote.props.cjs +2 -2
  4. package/lib/cjs/components/__generated__/body.props.cjs +2 -2
  5. package/lib/cjs/components/__generated__/bold.props.cjs +2 -2
  6. package/lib/cjs/components/__generated__/box.props.cjs +2 -2
  7. package/lib/cjs/components/__generated__/button.props.cjs +2 -2
  8. package/lib/cjs/components/__generated__/code.props.cjs +2 -2
  9. package/lib/cjs/components/__generated__/form.props.cjs +2 -2
  10. package/lib/cjs/components/__generated__/heading.props.cjs +2 -2
  11. package/lib/cjs/components/__generated__/image.props.cjs +2 -2
  12. package/lib/cjs/components/__generated__/input.props.cjs +2 -2
  13. package/lib/cjs/components/__generated__/italic.props.cjs +2 -2
  14. package/lib/cjs/components/__generated__/link.props.cjs +15 -3
  15. package/lib/cjs/components/__generated__/list-item.props.cjs +2 -2
  16. package/lib/cjs/components/__generated__/list.props.cjs +3 -3
  17. package/lib/cjs/components/__generated__/paragraph.props.cjs +2 -2
  18. package/lib/cjs/components/__generated__/rich-text-link.props.cjs +15 -4
  19. package/lib/cjs/components/__generated__/separator.props.cjs +2 -2
  20. package/lib/cjs/components/__generated__/span.props.cjs +2 -2
  21. package/lib/cjs/components/__generated__/subscript.props.cjs +2 -2
  22. package/lib/cjs/components/__generated__/superscript.props.cjs +2 -2
  23. package/lib/cjs/components/__generated__/text-block.props.cjs +2 -2
  24. package/lib/cjs/components/link.cjs +8 -5
  25. package/lib/cjs/components/link.ws.cjs +1 -1
  26. package/lib/cjs/components/rich-text-link.cjs +5 -7
  27. package/lib/cjs/tree/root.cjs +15 -7
  28. package/lib/components/__generated__/blockquote.props.js +2 -2
  29. package/lib/components/__generated__/body.props.js +2 -2
  30. package/lib/components/__generated__/bold.props.js +2 -2
  31. package/lib/components/__generated__/box.props.js +2 -2
  32. package/lib/components/__generated__/button.props.js +2 -2
  33. package/lib/components/__generated__/code.props.js +2 -2
  34. package/lib/components/__generated__/form.props.js +2 -2
  35. package/lib/components/__generated__/heading.props.js +2 -2
  36. package/lib/components/__generated__/image.props.js +2 -2
  37. package/lib/components/__generated__/input.props.js +2 -2
  38. package/lib/components/__generated__/italic.props.js +2 -2
  39. package/lib/components/__generated__/link.props.js +15 -3
  40. package/lib/components/__generated__/list-item.props.js +2 -2
  41. package/lib/components/__generated__/list.props.js +3 -3
  42. package/lib/components/__generated__/paragraph.props.js +2 -2
  43. package/lib/components/__generated__/rich-text-link.props.js +15 -4
  44. package/lib/components/__generated__/separator.props.js +2 -2
  45. package/lib/components/__generated__/span.props.js +2 -2
  46. package/lib/components/__generated__/subscript.props.js +2 -2
  47. package/lib/components/__generated__/superscript.props.js +2 -2
  48. package/lib/components/__generated__/text-block.props.js +2 -2
  49. package/lib/components/link.js +8 -5
  50. package/lib/components/link.ws.js +1 -1
  51. package/lib/components/rich-text-link.js +5 -7
  52. package/lib/tree/root.js +15 -7
  53. package/package.json +9 -9
  54. package/src/app/custom-components/shared/remix-link.tsx +4 -3
  55. package/src/components/__generated__/blockquote.props.ts +2 -2
  56. package/src/components/__generated__/body.props.ts +2 -2
  57. package/src/components/__generated__/bold.props.ts +2 -2
  58. package/src/components/__generated__/box.props.ts +2 -2
  59. package/src/components/__generated__/button.props.ts +2 -2
  60. package/src/components/__generated__/code.props.ts +2 -2
  61. package/src/components/__generated__/form.props.ts +2 -2
  62. package/src/components/__generated__/heading.props.ts +2 -2
  63. package/src/components/__generated__/image.props.ts +2 -2
  64. package/src/components/__generated__/input.props.ts +2 -2
  65. package/src/components/__generated__/italic.props.ts +2 -2
  66. package/src/components/__generated__/link.props.ts +15 -3
  67. package/src/components/__generated__/list-item.props.ts +2 -2
  68. package/src/components/__generated__/list.props.ts +3 -3
  69. package/src/components/__generated__/paragraph.props.ts +2 -2
  70. package/src/components/__generated__/rich-text-link.props.ts +15 -4
  71. package/src/components/__generated__/separator.props.ts +2 -2
  72. package/src/components/__generated__/span.props.ts +2 -2
  73. package/src/components/__generated__/subscript.props.ts +2 -2
  74. package/src/components/__generated__/superscript.props.ts +2 -2
  75. package/src/components/__generated__/text-block.props.ts +2 -2
  76. package/src/components/link.tsx +11 -2
  77. package/src/components/link.ws.tsx +1 -1
  78. package/src/components/rich-text-link.tsx +5 -4
  79. package/src/tree/root.ts +22 -11
@@ -120,7 +120,7 @@ export const props: Record<string, PropMeta> = {
120
120
  description:
121
121
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
122
122
  required: false,
123
- control: "radio",
123
+ control: "select",
124
124
  type: "string",
125
125
  options: ["list", "none", "inline", "both"],
126
126
  },
@@ -422,7 +422,7 @@ export const props: Record<string, PropMeta> = {
422
422
  description:
423
423
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
424
424
  required: false,
425
- control: "radio",
425
+ control: "select",
426
426
  type: "string",
427
427
  options: ["none", "ascending", "descending", "other"],
428
428
  },
@@ -104,7 +104,7 @@ export const props: Record<string, PropMeta> = {
104
104
  description:
105
105
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
106
106
  required: false,
107
- control: "radio",
107
+ control: "select",
108
108
  type: "string",
109
109
  options: ["inline", "list", "none", "both"],
110
110
  },
@@ -406,7 +406,7 @@ export const props: Record<string, PropMeta> = {
406
406
  description:
407
407
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
408
408
  required: false,
409
- control: "radio",
409
+ control: "select",
410
410
  type: "string",
411
411
  options: ["none", "ascending", "descending", "other"],
412
412
  },
@@ -111,7 +111,7 @@ export const props: Record<string, PropMeta> = {
111
111
  description:
112
112
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
113
113
  required: false,
114
- control: "radio",
114
+ control: "select",
115
115
  type: "string",
116
116
  options: ["list", "none", "inline", "both"],
117
117
  },
@@ -413,7 +413,7 @@ export const props: Record<string, PropMeta> = {
413
413
  description:
414
414
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
415
415
  required: false,
416
- control: "radio",
416
+ control: "select",
417
417
  type: "string",
418
418
  options: ["none", "ascending", "descending", "other"],
419
419
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -144,7 +144,7 @@ export const props: Record<string, PropMeta> = {
144
144
  description:
145
145
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
146
146
  required: false,
147
- control: "radio",
147
+ control: "select",
148
148
  type: "string",
149
149
  options: ["list", "none", "inline", "both"],
150
150
  },
@@ -446,7 +446,7 @@ export const props: Record<string, PropMeta> = {
446
446
  description:
447
447
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
448
448
  required: false,
449
- control: "radio",
449
+ control: "select",
450
450
  type: "string",
451
451
  options: ["none", "ascending", "descending", "other"],
452
452
  },
@@ -141,7 +141,7 @@ export const props: Record<string, PropMeta> = {
141
141
  description:
142
142
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
143
143
  required: false,
144
- control: "radio",
144
+ control: "select",
145
145
  type: "string",
146
146
  options: ["list", "none", "inline", "both"],
147
147
  },
@@ -443,7 +443,7 @@ export const props: Record<string, PropMeta> = {
443
443
  description:
444
444
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
445
445
  required: false,
446
- control: "radio",
446
+ control: "select",
447
447
  type: "string",
448
448
  options: ["none", "ascending", "descending", "other"],
449
449
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -10,7 +10,13 @@ export const props: Record<string, PropMeta> = {
10
10
  media: { required: false, control: "text", type: "string" },
11
11
  ping: { required: false, control: "text", type: "string" },
12
12
  rel: { required: false, control: "text", type: "string" },
13
- target: { required: false, control: "text", type: "string" },
13
+ target: {
14
+ required: false,
15
+ control: "select",
16
+ type: "string",
17
+ defaultValue: "self",
18
+ options: ["self", "blank", "parent", "top"],
19
+ },
14
20
  type: { required: false, control: "text", type: "string" },
15
21
  referrerPolicy: {
16
22
  required: false,
@@ -127,7 +133,7 @@ export const props: Record<string, PropMeta> = {
127
133
  description:
128
134
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
129
135
  required: false,
130
- control: "radio",
136
+ control: "select",
131
137
  type: "string",
132
138
  options: ["list", "none", "inline", "both"],
133
139
  },
@@ -429,7 +435,7 @@ export const props: Record<string, PropMeta> = {
429
435
  description:
430
436
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
431
437
  required: false,
432
- control: "radio",
438
+ control: "select",
433
439
  type: "string",
434
440
  options: ["none", "ascending", "descending", "other"],
435
441
  },
@@ -459,4 +465,10 @@ export const props: Record<string, PropMeta> = {
459
465
  control: "text",
460
466
  type: "string",
461
467
  },
468
+ prefetch: {
469
+ required: false,
470
+ control: "radio",
471
+ type: "string",
472
+ options: ["none", "intent", "render"],
473
+ },
462
474
  };
@@ -104,7 +104,7 @@ export const props: Record<string, PropMeta> = {
104
104
  description:
105
105
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
106
106
  required: false,
107
- control: "radio",
107
+ control: "select",
108
108
  type: "string",
109
109
  options: ["list", "none", "inline", "both"],
110
110
  },
@@ -406,7 +406,7 @@ export const props: Record<string, PropMeta> = {
406
406
  description:
407
407
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
408
408
  required: false,
409
- control: "radio",
409
+ control: "select",
410
410
  type: "string",
411
411
  options: ["none", "ascending", "descending", "other"],
412
412
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -439,7 +439,7 @@ export const props: Record<string, PropMeta> = {
439
439
  start: { required: false, control: "number", type: "number" },
440
440
  type: {
441
441
  required: false,
442
- control: "radio",
442
+ control: "select",
443
443
  type: "string",
444
444
  options: ["a", "i", "1", "A", "I"],
445
445
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -5,12 +5,17 @@ export const props: Record<string, PropMeta> = {
5
5
  style: { required: false, control: "text", type: "string" },
6
6
  title: { required: false, control: "text", type: "string" },
7
7
  download: { required: false, control: "text", type: "string" },
8
- href: { required: false, control: "text", type: "string", defaultValue: "" },
8
+ href: { required: false, control: "text", type: "string" },
9
9
  hrefLang: { required: false, control: "text", type: "string" },
10
10
  media: { required: false, control: "text", type: "string" },
11
11
  ping: { required: false, control: "text", type: "string" },
12
12
  rel: { required: false, control: "text", type: "string" },
13
- target: { required: false, control: "text", type: "string" },
13
+ target: {
14
+ required: false,
15
+ control: "select",
16
+ type: "string",
17
+ options: ["self", "blank", "parent", "top"],
18
+ },
14
19
  type: { required: false, control: "text", type: "string" },
15
20
  referrerPolicy: {
16
21
  required: false,
@@ -127,7 +132,7 @@ export const props: Record<string, PropMeta> = {
127
132
  description:
128
133
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
129
134
  required: false,
130
- control: "radio",
135
+ control: "select",
131
136
  type: "string",
132
137
  options: ["list", "none", "inline", "both"],
133
138
  },
@@ -429,7 +434,7 @@ export const props: Record<string, PropMeta> = {
429
434
  description:
430
435
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
431
436
  required: false,
432
- control: "radio",
437
+ control: "select",
433
438
  type: "string",
434
439
  options: ["none", "ascending", "descending", "other"],
435
440
  },
@@ -459,4 +464,10 @@ export const props: Record<string, PropMeta> = {
459
464
  control: "text",
460
465
  type: "string",
461
466
  },
467
+ prefetch: {
468
+ required: false,
469
+ control: "radio",
470
+ type: "string",
471
+ options: ["none", "intent", "render"],
472
+ },
462
473
  };
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -103,7 +103,7 @@ export const props: Record<string, PropMeta> = {
103
103
  description:
104
104
  "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
105
105
  required: false,
106
- control: "radio",
106
+ control: "select",
107
107
  type: "string",
108
108
  options: ["list", "none", "inline", "both"],
109
109
  },
@@ -405,7 +405,7 @@ export const props: Record<string, PropMeta> = {
405
405
  description:
406
406
  "Indicates if items in a table or grid are sorted in ascending or descending order.",
407
407
  required: false,
408
- control: "radio",
408
+ control: "select",
409
409
  type: "string",
410
410
  options: ["none", "ascending", "descending", "other"],
411
411
  },
@@ -1,9 +1,18 @@
1
1
  import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
2
 
3
- type Props = Omit<ComponentProps<"a">, "href"> & { href?: string };
3
+ // @todo props that come from remix link, shouldn't be here at all
4
+ // - prefetch should be only on remix component and it already is
5
+ // - props meta should be generated from Remix link
6
+ type Props = Omit<ComponentProps<"a">, "href" | "target"> & {
7
+ href?: string;
8
+ target?: "self" | "blank" | "parent" | "top";
9
+ prefetch?: "none" | "intent" | "render";
10
+ };
4
11
 
5
12
  export const Link = forwardRef<ElementRef<"a">, Props>(
6
- ({ href = "", ...props }, ref) => <a {...props} href={href} ref={ref} />
13
+ ({ href = "", target = "self", ...props }, ref) => {
14
+ return <a {...props} target={`_${target}`} href={href} ref={ref} />;
15
+ }
7
16
  );
8
17
 
9
18
  Link.displayName = "Link";
@@ -24,5 +24,5 @@ export const meta: WsComponentMeta = {
24
24
 
25
25
  export const propsMeta: WsComponentPropsMeta = {
26
26
  props,
27
- initialProps: ["href"],
27
+ initialProps: ["href", "target", "prefetch"],
28
28
  };
@@ -1,9 +1,10 @@
1
1
  import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+ import { Link } from "./link";
2
3
 
3
- type Props = Omit<ComponentProps<"a">, "href"> & { href?: string };
4
+ type Props = ComponentProps<typeof Link>;
4
5
 
5
- export const RichTextLink = forwardRef<ElementRef<"a">, Props>(
6
- ({ href = "", ...props }, ref) => <a {...props} href={href} ref={ref} />
7
- );
6
+ export const RichTextLink = forwardRef<ElementRef<"a">, Props>((props, ref) => (
7
+ <Link {...props} ref={ref} />
8
+ ));
8
9
 
9
10
  RichTextLink.displayName = "RichTextLink";
package/src/tree/root.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { ComponentProps } from "react";
2
2
  import { atom } from "nanostores";
3
3
  import type {
4
+ Build,
4
5
  Instance,
5
6
  Instances,
6
7
  InstancesItem,
7
- Tree,
8
+ Page,
8
9
  } from "@webstudio-is/project-build";
9
10
  import type { Asset } from "@webstudio-is/asset-uploader";
10
11
  import { createElementsTree } from "./create-elements-tree";
@@ -16,7 +17,8 @@ import { getPropsByInstanceId } from "../props";
16
17
  import type { GetComponent } from "../components/components-utils";
17
18
 
18
19
  export type Data = {
19
- tree: Tree | null;
20
+ page: Page;
21
+ build: Build;
20
22
  assets: Array<Asset>;
21
23
  params?: Params;
22
24
  };
@@ -28,7 +30,10 @@ type RootProps = {
28
30
  getComponent: GetComponent;
29
31
  };
30
32
 
31
- const denormalizeTree = (instances: Instances) => {
33
+ const denormalizeTree = (
34
+ instances: Instances,
35
+ rootInstanceId: Instance["id"]
36
+ ) => {
32
37
  const convertTree = (instance: InstancesItem) => {
33
38
  const legacyInstance: Instance = {
34
39
  type: "instance",
@@ -48,7 +53,11 @@ const denormalizeTree = (instances: Instances) => {
48
53
  }
49
54
  return legacyInstance;
50
55
  };
51
- return convertTree(Array.from(instances.values())[0]);
56
+ const rootInstance = instances.get(rootInstanceId);
57
+ if (rootInstance === undefined) {
58
+ return undefined;
59
+ }
60
+ return convertTree(rootInstance);
52
61
  };
53
62
 
54
63
  export const InstanceRoot = ({
@@ -57,18 +66,20 @@ export const InstanceRoot = ({
57
66
  customComponents = defaultCustomComponents,
58
67
  getComponent,
59
68
  }: RootProps): JSX.Element | null => {
60
- if (data.tree === null) {
61
- throw new Error("Tree is null");
62
- }
63
-
64
69
  setParams(data.params ?? null);
65
70
 
66
71
  registerComponents(customComponents);
67
-
72
+ const instance = denormalizeTree(
73
+ new Map(data.build.instances),
74
+ data.page.rootInstanceId
75
+ );
76
+ if (instance === undefined) {
77
+ return null;
78
+ }
68
79
  return createElementsTree({
69
- instance: denormalizeTree(new Map(data.tree.instances)),
80
+ instance,
70
81
  propsByInstanceIdStore: atom(
71
- getPropsByInstanceId(new Map(data.tree.props))
82
+ getPropsByInstanceId(new Map(data.build.props))
72
83
  ),
73
84
  assetsStore: atom(new Map(data.assets.map((asset) => [asset.id, asset]))),
74
85
  Component: Component ?? WebstudioComponent,