@makeswift/runtime 0.8.11 → 0.9.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 (182) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +1 -1
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +1 -1
  5. package/dist/Carousel.cjs.js +2 -2
  6. package/dist/Carousel.es.js +2 -2
  7. package/dist/Countdown.cjs.js +1 -1
  8. package/dist/Countdown.es.js +1 -1
  9. package/dist/Divider.cjs.js +1 -1
  10. package/dist/Divider.es.js +1 -1
  11. package/dist/Embed.cjs.js +1 -1
  12. package/dist/Embed.es.js +1 -1
  13. package/dist/Form.cjs.js +1 -1
  14. package/dist/Form.es.js +1 -1
  15. package/dist/Image.cjs.js +1 -1
  16. package/dist/Image.es.js +1 -1
  17. package/dist/LiveProvider.cjs.js +2 -2
  18. package/dist/LiveProvider.es.js +3 -3
  19. package/dist/Navigation.cjs.js +2 -2
  20. package/dist/Navigation.es.js +2 -2
  21. package/dist/PreviewProvider.cjs.js +17 -2
  22. package/dist/PreviewProvider.cjs.js.map +1 -1
  23. package/dist/PreviewProvider.es.js +19 -4
  24. package/dist/PreviewProvider.es.js.map +1 -1
  25. package/dist/ReadOnlyText.cjs.js +10 -9
  26. package/dist/ReadOnlyText.cjs.js.map +1 -1
  27. package/dist/ReadOnlyText.es.js +10 -9
  28. package/dist/ReadOnlyText.es.js.map +1 -1
  29. package/dist/ReadOnlyTextV2.cjs.js +10 -9
  30. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  31. package/dist/ReadOnlyTextV2.es.js +10 -9
  32. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  33. package/dist/Root.cjs.js +1 -1
  34. package/dist/Root.es.js +1 -1
  35. package/dist/SocialLinks.cjs.js +1 -1
  36. package/dist/SocialLinks.es.js +1 -1
  37. package/dist/Text.cjs.js +1 -1
  38. package/dist/Text.es.js +1 -1
  39. package/dist/Video.cjs.js +1 -1
  40. package/dist/Video.es.js +1 -1
  41. package/dist/actions.cjs.js +16 -1
  42. package/dist/actions.cjs.js.map +1 -1
  43. package/dist/actions.es.js +14 -2
  44. package/dist/actions.es.js.map +1 -1
  45. package/dist/components.cjs.js +1 -1
  46. package/dist/components.es.js +1 -1
  47. package/dist/control-serialization.cjs.js +1 -1
  48. package/dist/control-serialization.es.js +2 -2
  49. package/dist/controls.cjs.js +2 -3
  50. package/dist/controls.cjs.js.map +1 -1
  51. package/dist/controls.es.js +1 -2
  52. package/dist/controls.es.js.map +1 -1
  53. package/dist/index.cjs.js +253 -218
  54. package/dist/index.cjs.js.map +1 -1
  55. package/dist/index.cjs10.js +11 -10
  56. package/dist/index.cjs10.js.map +1 -1
  57. package/dist/index.cjs2.js +1 -1
  58. package/dist/index.cjs5.js +0 -522
  59. package/dist/index.cjs5.js.map +1 -1
  60. package/dist/index.cjs6.js +1 -2
  61. package/dist/index.cjs6.js.map +1 -1
  62. package/dist/index.cjs7.js +0 -52
  63. package/dist/index.cjs7.js.map +1 -1
  64. package/dist/index.cjs8.js +1 -1
  65. package/dist/index.cjs9.js +42 -3
  66. package/dist/index.cjs9.js.map +1 -1
  67. package/dist/index.es.js +253 -218
  68. package/dist/index.es.js.map +1 -1
  69. package/dist/index.es10.js +12 -11
  70. package/dist/index.es10.js.map +1 -1
  71. package/dist/index.es2.js +2 -2
  72. package/dist/index.es5.js +2 -514
  73. package/dist/index.es5.js.map +1 -1
  74. package/dist/index.es6.js +1 -2
  75. package/dist/index.es6.js.map +1 -1
  76. package/dist/index.es7.js +2 -53
  77. package/dist/index.es7.js.map +1 -1
  78. package/dist/index.es8.js +1 -1
  79. package/dist/index.es9.js +43 -4
  80. package/dist/index.es9.js.map +1 -1
  81. package/dist/leaf.es.js +1 -1
  82. package/dist/main.cjs.js +3 -0
  83. package/dist/main.cjs.js.map +1 -1
  84. package/dist/main.es.js +2 -2
  85. package/dist/next.cjs.js +1 -1
  86. package/dist/next.es.js +1 -1
  87. package/dist/react-page.cjs.js +711 -61
  88. package/dist/react-page.cjs.js.map +1 -1
  89. package/dist/react-page.es.js +694 -56
  90. package/dist/react-page.es.js.map +1 -1
  91. package/dist/react.cjs.js +1 -1
  92. package/dist/react.es.js +1 -1
  93. package/dist/slate.cjs.js +11 -13
  94. package/dist/slate.cjs.js.map +1 -1
  95. package/dist/slate.es.js +4 -5
  96. package/dist/slate.es.js.map +1 -1
  97. package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
  98. package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
  99. package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
  100. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  101. package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
  102. package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
  103. package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
  104. package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
  105. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  106. package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
  107. package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
  108. package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
  109. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
  110. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  111. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
  112. package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
  113. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +3 -3
  114. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  115. package/dist/types/src/index.d.ts +2 -1
  116. package/dist/types/src/index.d.ts.map +1 -1
  117. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
  118. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  119. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
  120. package/dist/types/src/next/api-handler/index.d.ts +2 -1
  121. package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
  122. package/dist/types/src/next/client.d.ts +7 -7
  123. package/dist/types/src/next/client.d.ts.map +1 -1
  124. package/dist/types/src/next/index.d.ts +8 -5
  125. package/dist/types/src/next/index.d.ts.map +1 -1
  126. package/dist/types/src/next/preview-mode.d.ts +17 -3
  127. package/dist/types/src/next/preview-mode.d.ts.map +1 -1
  128. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  129. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  130. package/dist/types/src/runtimes/react/index.d.ts +3 -1
  131. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  132. package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
  133. package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
  134. package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
  135. package/dist/types/src/slate/BlockPlugin/index.d.ts +26 -3
  136. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  137. package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
  138. package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
  139. package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
  140. package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
  141. package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
  142. package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
  143. package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -1
  144. package/dist/types/src/slate/index.d.ts +0 -1
  145. package/dist/types/src/slate/index.d.ts.map +1 -1
  146. package/dist/types/src/slate/utils/element.d.ts +1 -2
  147. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  148. package/dist/types/src/state/actions.d.ts +26 -1
  149. package/dist/types/src/state/actions.d.ts.map +1 -1
  150. package/dist/types/src/state/modules/components-meta.d.ts +25 -1
  151. package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
  152. package/dist/types/src/state/modules/locales.d.ts +16 -0
  153. package/dist/types/src/state/modules/locales.d.ts.map +1 -0
  154. package/dist/types/src/state/react-builder-preview.d.ts +2 -0
  155. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  156. package/dist/types/src/state/react-page.d.ts +5 -1
  157. package/dist/types/src/state/react-page.d.ts.map +1 -1
  158. package/package.json +6 -3
  159. package/dist/select.cjs.js +0 -8
  160. package/dist/select.cjs.js.map +0 -1
  161. package/dist/select.es.js +0 -6
  162. package/dist/select.es.js.map +0 -1
  163. package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
  164. package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
  165. package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
  166. package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
  167. package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
  168. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
  169. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
  170. package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
  171. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
  172. package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
  173. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
  174. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
  175. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
  176. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
  177. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
  178. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
  179. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
  180. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
  181. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
  182. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/wrapList.d.ts +0 -0
package/dist/index.cjs.js CHANGED
@@ -35,7 +35,7 @@ var __publicField = (obj, key, value) => {
35
35
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
36
  return value;
37
37
  };
38
- var _c;
38
+ var _e;
39
39
  var React = require("react");
40
40
  var withSelector = require("use-sync-external-store/shim/with-selector");
41
41
  var dynamic = require("next/dynamic");
@@ -47,10 +47,9 @@ var utils = require("@emotion/utils");
47
47
  var jsxRuntime = require("react/jsx-runtime");
48
48
  var textInput = require("./text-input.cjs.js");
49
49
  var combobox = require("./combobox.cjs.js");
50
- var select = require("./select.cjs.js");
51
50
  require("slate");
52
- require("is-hotkey");
53
51
  var state_breakpoints = require("./state/breakpoints.cjs.js");
52
+ require("is-hotkey");
54
53
  require("slate-react");
55
54
  var shim = require("use-sync-external-store/shim");
56
55
  var redux = require("redux");
@@ -62,6 +61,7 @@ var scrollIntoView = require("scroll-into-view-if-needed");
62
61
  var reactDom = require("react-dom");
63
62
  var parse = require("html-react-parser");
64
63
  var Head = require("next/head");
64
+ var zod = require("zod");
65
65
  var createEmotionServer = require("@emotion/server/create-instance");
66
66
  var NextDocument = require("next/document");
67
67
  var Cors = require("cors");
@@ -315,15 +315,6 @@ class GraphQLClient {
315
315
  return body.data;
316
316
  }
317
317
  }
318
- const SwatchFragment = `
319
- fragment Swatch on Swatch {
320
- __typename
321
- id
322
- hue
323
- saturation
324
- lightness
325
- }
326
- `;
327
318
  const FileFragment = `
328
319
  fragment File on File {
329
320
  __typename
@@ -407,16 +398,7 @@ const TableFragment = `
407
398
  }
408
399
  `;
409
400
  const IntrospectedResourcesQuery = `
410
- query IntrospectedResources(
411
- $swatchIds: [ID!]!
412
- $fileIds: [ID!]!
413
- $pageIds: [ID!]!
414
- $tableIds: [ID!]!
415
- ) {
416
- swatches(ids: $swatchIds) {
417
- ...Swatch
418
- }
419
-
401
+ query IntrospectedResources($fileIds: [ID!]!, $pageIds: [ID!]!, $tableIds: [ID!]!) {
420
402
  files(ids: $fileIds) {
421
403
  ...File
422
404
  }
@@ -430,20 +412,10 @@ const IntrospectedResourcesQuery = `
430
412
  }
431
413
  }
432
414
 
433
- ${SwatchFragment}
434
415
  ${FileFragment}
435
416
  ${PagePathnameSliceFragment}
436
417
  ${TableFragment}
437
418
  `;
438
- const SwatchQuery = `
439
- query Swatch($swatchId: ID!) {
440
- swatch(id: $swatchId) {
441
- ...Swatch
442
- }
443
- }
444
-
445
- ${SwatchFragment}
446
- `;
447
419
  const FileQuery = `
448
420
  query File($fileId: ID!) {
449
421
  file(id: $fileId) {
@@ -792,12 +764,120 @@ function useCachedSite(siteId) {
792
764
  const site = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
793
765
  return site;
794
766
  }
767
+ const makeswiftSiteVersionSchema = zod.z.enum(["Live", "Working"]);
768
+ const MakeswiftSiteVersion = makeswiftSiteVersionSchema.Enum;
769
+ const makeswiftPreviewDataSchema = zod.z.object({
770
+ makeswift: zod.z.literal(true),
771
+ unstable_siteVersion: makeswiftSiteVersionSchema
772
+ });
773
+ function getMakeswiftSiteVersion(previewData) {
774
+ const result = makeswiftPreviewDataSchema.safeParse(previewData);
775
+ if (result.success)
776
+ return result.data.unstable_siteVersion;
777
+ return null;
778
+ }
779
+ function PreviewModeScript({
780
+ isPreview = false,
781
+ appOrigin = "https://app.makeswift.com"
782
+ }) {
783
+ const previewModeScript = `
784
+ const isPreview = ${isPreview}
785
+ const appOrigin = '${appOrigin.replace("'", "\\'")}'
786
+ const searchParamName = 'x-makeswift-preview-mode'
787
+ const headerName = 'X-Makeswift-Preview-Mode'
788
+ const originalUrl = new URL(window.location.href)
789
+
790
+ if (window.parent !== window) {
791
+ window.addEventListener('message', event => {
792
+ if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
793
+ const { secret } = event.data
794
+
795
+ if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
796
+ const url = new URL(originalUrl)
797
+
798
+ url.searchParams.set(searchParamName, secret)
799
+
800
+ window.location.replace(url)
801
+ } else {
802
+ const originalFetch = window.fetch
803
+
804
+ window.fetch = function patchedFetch(resource, options) {
805
+ const request = new Request(resource, options)
806
+
807
+ if (new URL(request.url).origin !== window.location.origin) {
808
+ return originalFetch.call(this, resource, options)
809
+ }
810
+
811
+ return originalFetch.call(
812
+ this,
813
+ new Request(request, { headers: { [headerName]: secret } }),
814
+ )
815
+ }
816
+ }
817
+ }
818
+ })
819
+
820
+ window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
821
+ }
822
+
823
+ if (originalUrl.searchParams.has(searchParamName)) {
824
+ const url = new URL(originalUrl)
825
+
826
+ url.searchParams.delete(searchParamName)
827
+
828
+ window.history.replaceState(null, '', url)
829
+ }
830
+ `;
831
+ const makeswiftConnectionCheckScript = `
832
+ const appOrigin = '${appOrigin.replace("'", "\\'")}'
833
+
834
+ if (window.parent !== window) {
835
+ window.addEventListener('message', event => {
836
+ if (
837
+ event.origin === appOrigin &&
838
+ event.data.type === '${actions.ActionTypes.MAKESWIFT_CONNECTION_INIT}'
839
+ ) {
840
+ setInterval(() => {
841
+ window.parent.postMessage({
842
+ type: '${actions.ActionTypes.MAKESWIFT_CONNECTION_CHECK}',
843
+ payload: {
844
+ currentUrl: window.location.href
845
+ }
846
+ }, appOrigin)
847
+ }, 20)
848
+ }
849
+ })
850
+
851
+ window.parent.postMessage({ type: '${actions.ActionTypes.MAKESWIFT_CONNECTION_INIT}' }, appOrigin)
852
+ }
853
+ `;
854
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
855
+ children: [/* @__PURE__ */ jsxRuntime.jsx("script", {
856
+ id: "makeswift-preview-mode",
857
+ type: "module",
858
+ dangerouslySetInnerHTML: {
859
+ __html: previewModeScript
860
+ }
861
+ }), /* @__PURE__ */ jsxRuntime.jsx("script", {
862
+ id: "makeswift-connection-check",
863
+ type: "module",
864
+ dangerouslySetInnerHTML: {
865
+ __html: makeswiftConnectionCheckScript
866
+ }
867
+ })]
868
+ });
869
+ }
795
870
  class Makeswift {
796
- constructor(apiKey, { apiOrigin = "https://api.makeswift.com", runtime } = {}) {
871
+ constructor(apiKey, {
872
+ apiOrigin = "https://api.makeswift.com",
873
+ runtime = ReactRuntime,
874
+ unstable_previewData
875
+ } = {}) {
797
876
  __publicField(this, "apiKey");
798
877
  __publicField(this, "apiOrigin");
799
878
  __publicField(this, "graphqlClient");
800
879
  __publicField(this, "runtime");
880
+ __publicField(this, "siteVersion");
801
881
  if (typeof apiKey !== "string") {
802
882
  throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
803
883
  Received "${apiKey}" instead.`);
@@ -810,17 +890,27 @@ Received "${apiKey}" instead.`);
810
890
  }
811
891
  this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
812
892
  this.runtime = runtime;
893
+ this.siteVersion = getMakeswiftSiteVersion(unstable_previewData);
813
894
  }
814
895
  async fetch(path, init) {
896
+ var _a;
815
897
  const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
816
- headers: __spreadProps(__spreadValues({}, init == null ? void 0 : init.headers), { ["X-API-Key"]: this.apiKey })
898
+ headers: __spreadValues({
899
+ ["X-API-Key"]: this.apiKey,
900
+ "Makeswift-Site-API-Key": this.apiKey,
901
+ "Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : MakeswiftSiteVersion.Live
902
+ }, init == null ? void 0 : init.headers)
817
903
  }));
818
904
  return response;
819
905
  }
820
- async getPages(params = {}) {
821
- const searchParams = new URLSearchParams(params);
822
- const response = await this.fetch(`/v1/pages?${searchParams}`);
906
+ async getPages() {
907
+ const response = await this.fetch(`/v2/pages`, {
908
+ headers: {
909
+ "Makeswift-Site-Version": MakeswiftSiteVersion.Live
910
+ }
911
+ });
823
912
  if (!response.ok) {
913
+ console.error("Failed to get pages", await response.json());
824
914
  throw new Error(`Failed to get pages with error: "${response.statusText}"`);
825
915
  }
826
916
  const json = await response.json();
@@ -830,13 +920,35 @@ Received "${apiKey}" instead.`);
830
920
  const result = await this.graphqlClient.request(TypographiesQuery, { typographyIds });
831
921
  return result.typographies;
832
922
  }
833
- async getIntrospectedResources(introspectedResourceIds) {
923
+ async getSwatches(ids, preview) {
924
+ var _a;
925
+ const url = new URL(`v1/swatches/bulk`, this.apiOrigin);
926
+ ids.forEach((id) => {
927
+ url.searchParams.append("ids", id);
928
+ });
929
+ const response = await this.fetch(url.pathname + url.search, {
930
+ headers: {
931
+ "Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : preview ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
932
+ }
933
+ });
934
+ if (!response.ok) {
935
+ console.error("Failed to get swatches", await response.json());
936
+ return [];
937
+ }
938
+ return await response.json();
939
+ }
940
+ async getIntrospectedResources(_a, preview) {
941
+ var _b = _a, {
942
+ swatchIds
943
+ } = _b, introspectedResourceIds = __objRest(_b, [
944
+ "swatchIds"
945
+ ]);
834
946
  const result = await this.graphqlClient.request(IntrospectedResourcesQuery, introspectedResourceIds);
835
- return result;
947
+ const swatches = await this.getSwatches(swatchIds, preview);
948
+ return __spreadProps(__spreadValues({}, result), { swatches });
836
949
  }
837
- async introspect(element) {
838
- var _a;
839
- const runtime = (_a = this.runtime) != null ? _a : ReactRuntime;
950
+ async introspect(element, preview) {
951
+ const runtime = this.runtime;
840
952
  const descriptors = reactPage.getPropControllerDescriptors(runtime.store.getState());
841
953
  const swatchIds = /* @__PURE__ */ new Set();
842
954
  const fileIds = /* @__PURE__ */ new Set();
@@ -912,8 +1024,8 @@ Received "${apiKey}" instead.`);
912
1024
  const typographies = await this.getTypographies([...typographyIds]);
913
1025
  typographies.forEach((typography) => {
914
1026
  typography == null ? void 0 : typography.style.forEach((style) => {
915
- var _a2;
916
- const swatchId = (_a2 = style.value.color) == null ? void 0 : _a2.swatchId;
1027
+ var _a;
1028
+ const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
917
1029
  if (swatchId != null)
918
1030
  swatchIds.add(swatchId);
919
1031
  });
@@ -923,44 +1035,44 @@ Received "${apiKey}" instead.`);
923
1035
  fileIds: [...fileIds],
924
1036
  tableIds: [...tableIds],
925
1037
  pageIds: [...pageIds]
926
- });
1038
+ }, preview);
927
1039
  const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
928
1040
  id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
929
1041
  }));
930
1042
  return {
931
1043
  [types.APIResourceType.Swatch]: [...swatchIds].map((id) => {
932
- var _a2;
1044
+ var _a;
933
1045
  return {
934
1046
  id,
935
- value: (_a2 = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a2 : null
1047
+ value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
936
1048
  };
937
1049
  }),
938
1050
  [types.APIResourceType.File]: [...fileIds].map((id) => {
939
- var _a2;
1051
+ var _a;
940
1052
  return {
941
1053
  id,
942
- value: (_a2 = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a2 : null
1054
+ value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
943
1055
  };
944
1056
  }),
945
1057
  [types.APIResourceType.Typography]: [...typographyIds].map((id) => {
946
- var _a2;
1058
+ var _a;
947
1059
  return {
948
1060
  id,
949
- value: (_a2 = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a2 : null
1061
+ value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
950
1062
  };
951
1063
  }),
952
1064
  [types.APIResourceType.Table]: [...tableIds].map((id) => {
953
- var _a2;
1065
+ var _a;
954
1066
  return {
955
1067
  id,
956
- value: (_a2 = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a2 : null
1068
+ value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
957
1069
  };
958
1070
  }),
959
1071
  [types.APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
960
- var _a2;
1072
+ var _a;
961
1073
  return {
962
1074
  id,
963
- value: (_a2 = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a2 : null
1075
+ value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
964
1076
  };
965
1077
  }),
966
1078
  [types.APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
@@ -969,31 +1081,33 @@ Received "${apiKey}" instead.`);
969
1081
  }))
970
1082
  };
971
1083
  }
972
- async createSnapshot(document2, preview) {
973
- const cacheData = await this.introspect(document2.data);
974
- return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
975
- }
976
- async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
977
- const searchParams = new URLSearchParams({ preview: String(preview) });
978
- const response = await this.fetch(`/v1/pages/${pageId}/document?${searchParams}`);
1084
+ async getPageSnapshot(pathname, { preview: previewOverride = false } = {}) {
1085
+ var _a;
1086
+ const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
1087
+ const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document`, {
1088
+ headers: { "Makeswift-Site-Version": siteVersion }
1089
+ });
979
1090
  if (!response.ok) {
980
1091
  if (response.status === 404)
981
1092
  return null;
982
- throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
1093
+ console.error("Failed to get page snapshot", await response.json());
1094
+ throw new Error(`Failed to get page snapshot with error: "${response.statusText}"`);
983
1095
  }
984
1096
  const document2 = await response.json();
985
- return await this.createSnapshot(document2, preview);
986
- }
987
- async getPageSnapshot(path, { preview } = {}) {
988
- const [page] = await this.getPages({ path });
989
- if (page == null)
990
- return null;
991
- const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
992
- return snapshot;
1097
+ const cacheData = await this.introspect(document2.data, previewOverride);
1098
+ const apiOrigin = this.apiOrigin.href;
1099
+ const preview = siteVersion === MakeswiftSiteVersion.Working;
1100
+ return { document: document2, cacheData, apiOrigin, preview };
993
1101
  }
994
1102
  async getSwatch(swatchId) {
995
- const result = await this.graphqlClient.request(SwatchQuery, { swatchId });
996
- return result.swatch;
1103
+ const response = await this.fetch(`v1/swatches/${swatchId}`);
1104
+ if (!response.ok) {
1105
+ if (response.status !== 404)
1106
+ console.error("Failed to get swatch", await response.json());
1107
+ return null;
1108
+ }
1109
+ const swatch = await response.json();
1110
+ return swatch;
997
1111
  }
998
1112
  async getFile(fileId) {
999
1113
  const result = await this.graphqlClient.request(FileQuery, { fileId });
@@ -1017,97 +1131,6 @@ Received "${apiKey}" instead.`);
1017
1131
  return result.table;
1018
1132
  }
1019
1133
  }
1020
- function PreviewModeScript({
1021
- isPreview = false,
1022
- appOrigin = "https://app.makeswift.com"
1023
- }) {
1024
- const previewModeScript = `
1025
- const isPreview = ${isPreview}
1026
- const appOrigin = '${appOrigin.replace("'", "\\'")}'
1027
- const searchParamName = 'x-makeswift-preview-mode'
1028
- const headerName = 'X-Makeswift-Preview-Mode'
1029
- const originalUrl = new URL(window.location.href)
1030
-
1031
- if (window.parent !== window) {
1032
- window.addEventListener('message', event => {
1033
- if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
1034
- const { secret } = event.data
1035
-
1036
- if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
1037
- const url = new URL(originalUrl)
1038
-
1039
- url.searchParams.set(searchParamName, secret)
1040
-
1041
- window.location.replace(url)
1042
- } else {
1043
- const originalFetch = window.fetch
1044
-
1045
- window.fetch = function patchedFetch(resource, options) {
1046
- const request = new Request(resource, options)
1047
-
1048
- if (new URL(request.url).origin !== window.location.origin) {
1049
- return originalFetch.call(this, resource, options)
1050
- }
1051
-
1052
- return originalFetch.call(
1053
- this,
1054
- new Request(request, { headers: { [headerName]: secret } }),
1055
- )
1056
- }
1057
- }
1058
- }
1059
- })
1060
-
1061
- window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
1062
- }
1063
-
1064
- if (originalUrl.searchParams.has(searchParamName)) {
1065
- const url = new URL(originalUrl)
1066
-
1067
- url.searchParams.delete(searchParamName)
1068
-
1069
- window.history.replaceState(null, '', url)
1070
- }
1071
- `;
1072
- const makeswiftConnectionCheckScript = `
1073
- const appOrigin = '${appOrigin.replace("'", "\\'")}'
1074
-
1075
- if (window.parent !== window) {
1076
- window.addEventListener('message', event => {
1077
- if (
1078
- event.origin === appOrigin &&
1079
- event.data.type === '${actions.ActionTypes.MAKESWIFT_CONNECTION_INIT}'
1080
- ) {
1081
- setInterval(() => {
1082
- window.parent.postMessage({
1083
- type: '${actions.ActionTypes.MAKESWIFT_CONNECTION_CHECK}',
1084
- payload: {
1085
- currentUrl: window.location.href
1086
- }
1087
- }, appOrigin)
1088
- }, 20)
1089
- }
1090
- })
1091
-
1092
- window.parent.postMessage({ type: '${actions.ActionTypes.MAKESWIFT_CONNECTION_INIT}' }, appOrigin)
1093
- }
1094
- `;
1095
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
1096
- children: [/* @__PURE__ */ jsxRuntime.jsx("script", {
1097
- id: "makeswift-preview-mode",
1098
- type: "module",
1099
- dangerouslySetInnerHTML: {
1100
- __html: previewModeScript
1101
- }
1102
- }), /* @__PURE__ */ jsxRuntime.jsx("script", {
1103
- id: "makeswift-connection-check",
1104
- type: "module",
1105
- dangerouslySetInnerHTML: {
1106
- __html: makeswiftConnectionCheckScript
1107
- }
1108
- })]
1109
- });
1110
- }
1111
1134
  class Document$1 extends NextDocument__default["default"] {
1112
1135
  static async getInitialProps(ctx) {
1113
1136
  const initialProps = await NextDocument__default["default"].getInitialProps(ctx);
@@ -1162,8 +1185,8 @@ async function fonts(_req, res, { getFonts } = {}) {
1162
1185
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1163
1186
  return res.json(fonts2);
1164
1187
  }
1165
- const version = "0.8.11";
1166
- async function handler(req, res, { apiKey }) {
1188
+ const version = "0.9.0";
1189
+ async function handler(req, res, { apiKey, unstable_siteVersions }) {
1167
1190
  if (req.query.secret !== apiKey) {
1168
1191
  return res.status(401).json({ message: "Unauthorized" });
1169
1192
  }
@@ -1173,7 +1196,8 @@ async function handler(req, res, { apiKey }) {
1173
1196
  interactionMode: true,
1174
1197
  clientSideNavigation: true,
1175
1198
  elementFromPoint: false,
1176
- customBreakpoints: true
1199
+ customBreakpoints: true,
1200
+ unstable_siteVersions
1177
1201
  });
1178
1202
  }
1179
1203
  async function proxyPreviewMode(req, res, { apiKey }) {
@@ -1204,7 +1228,11 @@ async function proxyPreviewMode(req, res, { apiKey }) {
1204
1228
  const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
1205
1229
  let target = `${proto}://${host}`;
1206
1230
  const secure = process.env["NODE_ENV"] === "production";
1207
- const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
1231
+ const previewData = {
1232
+ makeswift: true,
1233
+ unstable_siteVersion: MakeswiftSiteVersion.Working
1234
+ };
1235
+ const setCookie = res.setPreviewData(previewData).getHeader("Set-Cookie");
1208
1236
  res.removeHeader("Set-Cookie");
1209
1237
  if (!Array.isArray(setCookie))
1210
1238
  return res.status(500).send("Internal Server Error");
@@ -1246,7 +1274,8 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
1246
1274
  function MakeswiftApiHandler(apiKey, {
1247
1275
  appOrigin = "https://app.makeswift.com",
1248
1276
  apiOrigin = "https://api.makeswift.com",
1249
- getFonts
1277
+ getFonts,
1278
+ unstable_siteVersions = false
1250
1279
  } = {}) {
1251
1280
  const cors = Cors__default["default"]({ origin: appOrigin });
1252
1281
  if (typeof apiKey !== "string") {
@@ -1268,12 +1297,12 @@ Received "${apiKey}" instead.`);
1268
1297
  Received "${makeswift}" for the \`makeswift\` param instead.
1269
1298
  Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
1270
1299
  }
1271
- const client = new Makeswift(apiKey, { apiOrigin });
1300
+ const client = new Makeswift(apiKey, { apiOrigin, unstable_previewData: req.previewData });
1272
1301
  const action = "/" + makeswift.join("/");
1273
1302
  const matches = (pattern) => pathToRegexp.match(pattern, { decode: decodeURIComponent })(action);
1274
1303
  let m;
1275
1304
  if (matches("/manifest"))
1276
- return handler(req, res, { apiKey });
1305
+ return handler(req, res, { apiKey, unstable_siteVersions });
1277
1306
  if (matches("/revalidate"))
1278
1307
  return revalidate(req, res, { apiKey });
1279
1308
  if (matches("/proxy-preview-mode"))
@@ -1310,10 +1339,10 @@ function saveForwardedRef(props, ref) {
1310
1339
  [FORWARDED_NEXT_DYNAMIC_REF_KEY]: ref
1311
1340
  });
1312
1341
  }
1313
- function loadForwardedRef(_a) {
1314
- var _b = _a, {
1342
+ function loadForwardedRef(_c) {
1343
+ var _d = _c, {
1315
1344
  [FORWARDED_NEXT_DYNAMIC_REF_KEY]: ref
1316
- } = _b, props = __objRest(_b, [
1345
+ } = _d, props = __objRest(_d, [
1317
1346
  __restKey(FORWARDED_NEXT_DYNAMIC_REF_KEY)
1318
1347
  ]);
1319
1348
  return __spreadProps(__spreadValues({}, props), {
@@ -1376,14 +1405,15 @@ async function getStaticPaths() {
1376
1405
  }
1377
1406
  const REVALIDATE_SECONDS = 1;
1378
1407
  async function getStaticProps(ctx) {
1379
- var _a, _b, _c2;
1408
+ var _a, _b, _c;
1380
1409
  deprecationWarning("getStaticProps");
1381
1410
  const makeswift = new Makeswift(getApiKey(), {
1382
- apiOrigin: getApiOrigin()
1411
+ apiOrigin: getApiOrigin(),
1412
+ unstable_previewData: ctx.previewData
1383
1413
  });
1384
1414
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1385
1415
  const snapshot = await makeswift.getPageSnapshot(path, {
1386
- preview: ((_c2 = ctx.previewData) == null ? void 0 : _c2.makeswift) === true
1416
+ preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
1387
1417
  });
1388
1418
  if (snapshot == null)
1389
1419
  return {
@@ -1401,7 +1431,8 @@ async function getServerSideProps(ctx) {
1401
1431
  var _a, _b;
1402
1432
  deprecationWarning("getServerSideProps");
1403
1433
  const makeswift = new Makeswift(getApiKey(), {
1404
- apiOrigin: getApiOrigin()
1434
+ apiOrigin: getApiOrigin(),
1435
+ unstable_previewData: ctx.previewData
1405
1436
  });
1406
1437
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1407
1438
  const snapshot = await makeswift.getPageSnapshot(path, {
@@ -1660,7 +1691,7 @@ function registerComponent$a(runtime) {
1660
1691
  })))), {
1661
1692
  type: constants.MakeswiftComponentType.Carousel,
1662
1693
  label: "Carousel",
1663
- icon: "Carousel40",
1694
+ icon: reactPage.ComponentIcon.Carousel,
1664
1695
  props: {
1665
1696
  id: reactPage.ElementID(),
1666
1697
  images: reactPage.Images({
@@ -1760,7 +1791,7 @@ function registerComponent$9(runtime) {
1760
1791
  })))), {
1761
1792
  type: constants.MakeswiftComponentType.Countdown,
1762
1793
  label: "Countdown",
1763
- icon: "Countdown40",
1794
+ icon: reactPage.ComponentIcon.Countdown,
1764
1795
  props: {
1765
1796
  id: reactPage.ElementID(),
1766
1797
  date: reactPage.Date(() => ({
@@ -1854,7 +1885,7 @@ function registerComponent$8(runtime) {
1854
1885
  })))), {
1855
1886
  type: constants.MakeswiftComponentType.Divider,
1856
1887
  label: "Divider",
1857
- icon: "Divider40",
1888
+ icon: reactPage.ComponentIcon.Divider,
1858
1889
  props: {
1859
1890
  id: reactPage.ElementID(),
1860
1891
  variant: reactPage.ResponsiveSelect({
@@ -1888,7 +1919,7 @@ function registerComponent$7(runtime) {
1888
1919
  })))), {
1889
1920
  type: constants.MakeswiftComponentType.Embed,
1890
1921
  label: "Embed",
1891
- icon: "Code40",
1922
+ icon: reactPage.ComponentIcon.Code,
1892
1923
  props: {
1893
1924
  id: reactPage.ElementID(),
1894
1925
  html: reactPage.TextArea({ label: "Code", rows: 20 }),
@@ -1927,7 +1958,7 @@ function registerComponent$6(runtime) {
1927
1958
  })))), {
1928
1959
  type: constants.MakeswiftComponentType.Form,
1929
1960
  label: "Form",
1930
- icon: "Form40",
1961
+ icon: reactPage.ComponentIcon.Form,
1931
1962
  props: {
1932
1963
  id: reactPage.ElementID(),
1933
1964
  tableId: reactPage.Table(),
@@ -2076,7 +2107,7 @@ function registerComponent$4(runtime) {
2076
2107
  })))), {
2077
2108
  type: constants.MakeswiftComponentType.Navigation,
2078
2109
  label: "Navigation",
2079
- icon: "Navigation40",
2110
+ icon: reactPage.ComponentIcon.Navigation,
2080
2111
  props: {
2081
2112
  id: reactPage.ElementID(),
2082
2113
  links: reactPage.NavigationLinks(),
@@ -2198,7 +2229,7 @@ function registerComponent$2(runtime) {
2198
2229
  })))), {
2199
2230
  type: constants.MakeswiftComponentType.SocialLinks,
2200
2231
  label: "Social Links",
2201
- icon: "SocialLinks40",
2232
+ icon: reactPage.ComponentIcon.SocialLinks,
2202
2233
  props: {
2203
2234
  id: reactPage.ElementID(),
2204
2235
  links: reactPage.SocialLinks({
@@ -2409,7 +2440,7 @@ function registerComponent(runtime) {
2409
2440
  })))), {
2410
2441
  type: constants.MakeswiftComponentType.Video,
2411
2442
  label: "Video",
2412
- icon: "Video40",
2443
+ icon: reactPage.ComponentIcon.Video,
2413
2444
  props: {
2414
2445
  id: reactPage.ElementID(),
2415
2446
  video: reactPage.Video({ preset: { controls: true } }),
@@ -2454,7 +2485,7 @@ function registerBuiltinComponents(runtime) {
2454
2485
  }
2455
2486
  const isServer = typeof window === "undefined";
2456
2487
  const useInsertionEffectSpecifier = "useInsertionEffect";
2457
- const useInsertionEffect = (_c = React__namespace[useInsertionEffectSpecifier]) != null ? _c : React__namespace.useLayoutEffect;
2488
+ const useInsertionEffect = (_e = React__namespace[useInsertionEffectSpecifier]) != null ? _e : React__namespace.useLayoutEffect;
2458
2489
  function useStyle(style) {
2459
2490
  const serialized = serialize.serializeStyles([style], css.cache.registered);
2460
2491
  utils.registerStyles(css.cache, serialized, false);
@@ -2608,8 +2639,8 @@ function useTable(tableId) {
2608
2639
  }, [client, tableId]);
2609
2640
  return table;
2610
2641
  }
2611
- function mapSideColor(swatches, _d) {
2612
- var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
2642
+ function mapSideColor(swatches, _f) {
2643
+ var _g = _f, { color } = _g, restOfSide = __objRest(_g, ["color"]);
2613
2644
  return __spreadProps(__spreadValues({}, restOfSide), {
2614
2645
  color: color && {
2615
2646
  alpha: color.alpha,
@@ -2705,10 +2736,10 @@ function lengthDataToString(data) {
2705
2736
  return data;
2706
2737
  }
2707
2738
  function paddingPropertyDataToStyle(data, defaultValue = {}) {
2708
- var _a, _b, _c2, _d;
2739
+ var _a, _b, _c, _d;
2709
2740
  const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
2710
2741
  const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
2711
- const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
2742
+ const paddingBottom = (_c = data.paddingBottom) != null ? _c : defaultValue.paddingBottom;
2712
2743
  const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
2713
2744
  const style = {};
2714
2745
  if (paddingTop != null)
@@ -2722,10 +2753,10 @@ function paddingPropertyDataToStyle(data, defaultValue = {}) {
2722
2753
  return style;
2723
2754
  }
2724
2755
  function marginPropertyDataToStyle(data, defaultValue = {}) {
2725
- var _a, _b, _c2, _d;
2756
+ var _a, _b, _c, _d;
2726
2757
  const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
2727
2758
  const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
2728
- const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
2759
+ const marginBottom = (_c = data.marginBottom) != null ? _c : defaultValue.marginBottom;
2729
2760
  const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
2730
2761
  const style = {};
2731
2762
  if (marginTop != null)
@@ -2746,10 +2777,10 @@ function lengthPercentageDataToString(data) {
2746
2777
  return data;
2747
2778
  }
2748
2779
  function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
2749
- var _a, _b, _c2, _d;
2780
+ var _a, _b, _c, _d;
2750
2781
  const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
2751
2782
  const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
2752
- const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
2783
+ const borderBottomRightRadius = (_c = data.borderBottomRightRadius) != null ? _c : defaultValue.borderBottomRightRadius;
2753
2784
  const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
2754
2785
  const style = {};
2755
2786
  if (borderTopLeftRadius != null) {
@@ -2770,10 +2801,10 @@ function colorToString(color) {
2770
2801
  return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
2771
2802
  }
2772
2803
  function borderPropertyDataToStyle(data, defaultValue = {}) {
2773
- var _a, _b, _c2, _d;
2804
+ var _a, _b, _c, _d;
2774
2805
  const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
2775
2806
  const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
2776
- const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
2807
+ const borderBottom = (_c = data.borderBottom) != null ? _c : defaultValue.borderBottom;
2777
2808
  const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
2778
2809
  const style = {};
2779
2810
  if (borderTop != null)
@@ -2939,14 +2970,14 @@ function useStyleControlCssObject(style, controlDefinition) {
2939
2970
  style == null ? void 0 : style.borderRadius,
2940
2971
  style == null ? void 0 : style.textStyle
2941
2972
  ], ([width, margin, padding, border, borderRadius, textStyle]) => {
2942
- var _a, _b, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
2973
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
2943
2974
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(reactPage.StyleControlProperty.Width) && {
2944
2975
  width: (_a = widthToString(width)) != null ? _a : "100%"
2945
2976
  }), properties.includes(reactPage.StyleControlProperty.Margin) && marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(reactPage.StyleControlProperty.Padding) && paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(reactPage.StyleControlProperty.Border) && {
2946
2977
  borderTop: (_b = borderSideToString2(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
2947
- borderRight: (_c2 = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c2 : "0 solid black",
2978
+ borderRight: (_c = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c : "0 solid black",
2948
2979
  borderBottom: (_d = borderSideToString2(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
2949
- borderLeft: (_e = borderSideToString2(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
2980
+ borderLeft: (_e2 = borderSideToString2(border == null ? void 0 : border.borderLeft)) != null ? _e2 : "0 solid black"
2950
2981
  }), properties.includes(reactPage.StyleControlProperty.BorderRadius) && {
2951
2982
  borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
2952
2983
  borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
@@ -3225,13 +3256,13 @@ function useSlot(data, control) {
3225
3256
  }, element.key))
3226
3257
  });
3227
3258
  }
3228
- function Slot(_f) {
3229
- var _g = _f, {
3259
+ function Slot(_h) {
3260
+ var _i = _h, {
3230
3261
  as,
3231
3262
  control,
3232
3263
  children,
3233
3264
  className
3234
- } = _g, restOfProps = __objRest(_g, [
3265
+ } = _i, restOfProps = __objRest(_i, [
3235
3266
  "as",
3236
3267
  "control",
3237
3268
  "children",
@@ -3260,15 +3291,15 @@ function Slot(_f) {
3260
3291
  }
3261
3292
  Slot.Placeholder = SlotPlaceholder;
3262
3293
  Slot.Item = SlotItem;
3263
- function SlotItem(_h) {
3264
- var _i = _h, {
3294
+ function SlotItem(_j) {
3295
+ var _k = _j, {
3265
3296
  as,
3266
3297
  control,
3267
3298
  grid,
3268
3299
  index,
3269
3300
  children,
3270
3301
  className
3271
- } = _i, restOfProps = __objRest(_i, [
3302
+ } = _k, restOfProps = __objRest(_k, [
3272
3303
  "as",
3273
3304
  "control",
3274
3305
  "grid",
@@ -3387,7 +3418,7 @@ function ControlValue({
3387
3418
  parameters: [data, definition],
3388
3419
  children: (value) => children(value)
3389
3420
  }, definition.type);
3390
- case select.SelectControlType:
3421
+ case reactPage.SelectControlType:
3391
3422
  return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
3392
3423
  hook: useSelectControlValue,
3393
3424
  parameters: [data, definition],
@@ -3494,13 +3525,13 @@ function PropsValue({
3494
3525
  return reactPage.getPropControllers(state, documentKey, element.key);
3495
3526
  });
3496
3527
  return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
3497
- var _a2, _b, _c2, _d;
3528
+ var _a2, _b, _c, _d;
3498
3529
  switch (descriptor.type) {
3499
3530
  case textInput.CheckboxControlType:
3500
3531
  case textInput.NumberControlType:
3501
3532
  case textInput.TextInputControlType:
3502
3533
  case textInput.TextAreaControlType:
3503
- case select.SelectControlType:
3534
+ case reactPage.SelectControlType:
3504
3535
  case reactPage.ColorControlType:
3505
3536
  case reactPage.ImageControlType:
3506
3537
  case combobox.ComboboxControlType:
@@ -3536,7 +3567,7 @@ function PropsValue({
3536
3567
  }, descriptor.type);
3537
3568
  }
3538
3569
  case reactPage.RichTextV2ControlType: {
3539
- const control = (_c2 = propControllers == null ? void 0 : propControllers[propName]) != null ? _c2 : null;
3570
+ const control = (_c = propControllers == null ? void 0 : propControllers[propName]) != null ? _c : null;
3540
3571
  return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
3541
3572
  hook: useRichTextV2,
3542
3573
  parameters: [props[propName], control],
@@ -3730,18 +3761,22 @@ function isDomNodeHandle(value) {
3730
3761
  }
3731
3762
  class ReactRuntime {
3732
3763
  constructor({
3733
- breakpoints
3734
- }) {
3764
+ breakpoints,
3765
+ unstable_i18n
3766
+ } = {}) {
3735
3767
  __publicField(this, "store");
3736
3768
  this.store = reactPage.configureStore({
3737
- breakpoints: breakpoints ? state_breakpoints.parseBreakpointsInput(breakpoints) : void 0
3769
+ breakpoints: breakpoints ? state_breakpoints.parseBreakpointsInput(breakpoints) : void 0,
3770
+ locales: unstable_i18n ? __spreadProps(__spreadValues({}, unstable_i18n), {
3771
+ locale: null
3772
+ }) : void 0
3738
3773
  });
3739
3774
  registerBuiltinComponents(this);
3740
3775
  }
3741
3776
  static registerComponent(component, {
3742
3777
  type,
3743
3778
  label,
3744
- icon = "Cube40",
3779
+ icon = reactPage.ComponentIcon.Code,
3745
3780
  hidden = false,
3746
3781
  props
3747
3782
  }) {
@@ -3765,7 +3800,7 @@ class ReactRuntime {
3765
3800
  registerComponent(component, {
3766
3801
  type,
3767
3802
  label,
3768
- icon = "Cube40",
3803
+ icon = reactPage.ComponentIcon.Cube,
3769
3804
  hidden = false,
3770
3805
  props
3771
3806
  }) {
@@ -3796,10 +3831,10 @@ const PreviewProvider = dynamic__default["default"](() => Promise.resolve().then
3796
3831
  const LiveProvider = dynamic__default["default"](() => Promise.resolve().then(function() {
3797
3832
  return require("./LiveProvider.cjs.js");
3798
3833
  }));
3799
- function RuntimeProvider(_j) {
3800
- var _k = _j, {
3834
+ function RuntimeProvider(_l) {
3835
+ var _m = _l, {
3801
3836
  preview
3802
- } = _k, props = __objRest(_k, [
3837
+ } = _m, props = __objRest(_m, [
3803
3838
  "preview"
3804
3839
  ]);
3805
3840
  return preview ? /* @__PURE__ */ jsxRuntime.jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsxRuntime.jsx(LiveProvider, __spreadValues({}, props));