@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.es.js CHANGED
@@ -34,23 +34,22 @@ var __publicField = (obj, key, value) => {
34
34
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
35
  return value;
36
36
  };
37
- var _c;
37
+ var _e;
38
38
  import * as React from "react";
39
39
  import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
40
40
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
41
41
  import dynamic from "next/dynamic";
42
- import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getElementSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, S as ShapeControlType, L as ListControlType, m as Types, E as ElementID, B as Backgrounds, W as Width, n as ResponsiveIconRadioGroup, M as Margin, P as Padding, o as Border, p as BorderRadius, q as Shadows, G as GapY, r as GapX, s as ResponsiveSelect, t as ResponsiveNumber, C as Checkbox, u as Grid, v as TextInput, w as Link, x as ResponsiveColor, y as TextStyle, I as Images, N as Number$1, D as Date$1, F as Font, z as ResponsiveLength, A as TextArea, H as Table, J as TableFormFields, K as Image, O as ResponsiveOpacity, Q as NavigationLinks, U as SocialLinks, V as RichText, X as Video, Y as getBorderSwatchIds, Z as isNonNullable, _ as getBoxShadowsSwatchIds, $ as getResponsiveColorSwatchIds, a0 as StyleControlProperty, a1 as ImageControlValueFormat, a2 as isPropControllersHandle, a3 as StyleControlType, a4 as RichTextV2ControlType, a5 as RichTextControlType, a6 as SlotControlType, a7 as LinkControlType, a8 as ImageControlType, a9 as ColorControlType, aa as getComponentPropControllerDescriptors, ab as getPropControllers, ac as BorderPropControllerFormat, ad as ShadowsPropControllerFormat, ae as BorderRadiusPropControllerFormat, af as MarginPropControllerFormat, ag as PaddingPropControllerFormat, ah as WidthPropControllerFormat, ai as configureStore$1, aj as copyElementTree, ak as getBreakpoints, al as getDocument, am as getElementId, an as getIsPreview, ao as getIsInBuilder, ap as getReactComponent, aq as getBuilderEditMode } from "./react-page.es.js";
43
- import { A as ActionTypes, k as apiResourceFulfilled, l as registerComponentEffect, n as registerReactComponentEffect, o as registerComponentHandleEffect, p as mountComponentEffect } from "./actions.es.js";
42
+ import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getElementSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, S as ShapeControlType, L as ListControlType, m as Types, E as ElementID, B as Backgrounds, W as Width, n as ResponsiveIconRadioGroup, M as Margin, P as Padding, o as Border, p as BorderRadius, q as Shadows, G as GapY, r as GapX, s as ResponsiveSelect, t as ResponsiveNumber, u as Checkbox, v as Grid, w as TextInput, x as Link, y as ResponsiveColor, z as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, A as ResponsiveLength, H as TextArea, J as Table, K as TableFormFields, O as Image, Q as ResponsiveOpacity, U as NavigationLinks, V as SocialLinks, X as RichText, Y as Video, Z as getBorderSwatchIds, _ as isNonNullable, $ as getBoxShadowsSwatchIds, a0 as getResponsiveColorSwatchIds, a1 as StyleControlProperty, a2 as ImageControlValueFormat, a3 as isPropControllersHandle, a4 as StyleControlType, a5 as RichTextV2ControlType, a6 as RichTextControlType, a7 as SlotControlType, a8 as LinkControlType, a9 as ImageControlType, aa as ColorControlType, ab as SelectControlType, ac as getComponentPropControllerDescriptors, ad as getPropControllers, ae as BorderPropControllerFormat, af as ShadowsPropControllerFormat, ag as BorderRadiusPropControllerFormat, ah as MarginPropControllerFormat, ai as PaddingPropControllerFormat, aj as WidthPropControllerFormat, ak as configureStore$1, al as copyElementTree, am as getBreakpoints, an as getDocument, ao as getElementId, ap as getIsPreview, aq as getIsInBuilder, ar as getReactComponent, as as getBuilderEditMode } from "./react-page.es.js";
43
+ import { A as ActionTypes, n as apiResourceFulfilled, o as registerComponentEffect, p as registerReactComponentEffect, q as registerComponentHandleEffect, t as mountComponentEffect } from "./actions.es.js";
44
44
  import { cache, cx } from "@emotion/css";
45
45
  import { serializeStyles } from "@emotion/serialize";
46
46
  import { registerStyles, insertStyles } from "@emotion/utils";
47
47
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
48
48
  import { T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
49
49
  import { C as ComboboxControlType } from "./combobox.es.js";
50
- import { S as SelectControlType } from "./select.es.js";
51
50
  import "slate";
52
- import "is-hotkey";
53
51
  import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, getBreakpoint, getBreakpointMediaQuery, parseBreakpointsInput } from "./state/breakpoints.es.js";
52
+ import "is-hotkey";
54
53
  import "slate-react";
55
54
  import { useSyncExternalStore } from "use-sync-external-store/shim";
56
55
  import { createStore, applyMiddleware } from "redux";
@@ -62,6 +61,7 @@ import scrollIntoView from "scroll-into-view-if-needed";
62
61
  import { findDOMNode } from "react-dom";
63
62
  import parse from "html-react-parser";
64
63
  import Head from "next/head";
64
+ import { z } from "zod";
65
65
  import createEmotionServer from "@emotion/server/create-instance";
66
66
  import NextDocument, { Html, Head as Head$1, Main, NextScript } from "next/document";
67
67
  import Cors from "cors";
@@ -281,15 +281,6 @@ class GraphQLClient {
281
281
  return body.data;
282
282
  }
283
283
  }
284
- const SwatchFragment = `
285
- fragment Swatch on Swatch {
286
- __typename
287
- id
288
- hue
289
- saturation
290
- lightness
291
- }
292
- `;
293
284
  const FileFragment = `
294
285
  fragment File on File {
295
286
  __typename
@@ -373,16 +364,7 @@ const TableFragment = `
373
364
  }
374
365
  `;
375
366
  const IntrospectedResourcesQuery = `
376
- query IntrospectedResources(
377
- $swatchIds: [ID!]!
378
- $fileIds: [ID!]!
379
- $pageIds: [ID!]!
380
- $tableIds: [ID!]!
381
- ) {
382
- swatches(ids: $swatchIds) {
383
- ...Swatch
384
- }
385
-
367
+ query IntrospectedResources($fileIds: [ID!]!, $pageIds: [ID!]!, $tableIds: [ID!]!) {
386
368
  files(ids: $fileIds) {
387
369
  ...File
388
370
  }
@@ -396,20 +378,10 @@ const IntrospectedResourcesQuery = `
396
378
  }
397
379
  }
398
380
 
399
- ${SwatchFragment}
400
381
  ${FileFragment}
401
382
  ${PagePathnameSliceFragment}
402
383
  ${TableFragment}
403
384
  `;
404
- const SwatchQuery = `
405
- query Swatch($swatchId: ID!) {
406
- swatch(id: $swatchId) {
407
- ...Swatch
408
- }
409
- }
410
-
411
- ${SwatchFragment}
412
- `;
413
385
  const FileQuery = `
414
386
  query File($fileId: ID!) {
415
387
  file(id: $fileId) {
@@ -758,12 +730,120 @@ function useCachedSite(siteId) {
758
730
  const site = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
759
731
  return site;
760
732
  }
733
+ const makeswiftSiteVersionSchema = z.enum(["Live", "Working"]);
734
+ const MakeswiftSiteVersion = makeswiftSiteVersionSchema.Enum;
735
+ const makeswiftPreviewDataSchema = z.object({
736
+ makeswift: z.literal(true),
737
+ unstable_siteVersion: makeswiftSiteVersionSchema
738
+ });
739
+ function getMakeswiftSiteVersion(previewData) {
740
+ const result = makeswiftPreviewDataSchema.safeParse(previewData);
741
+ if (result.success)
742
+ return result.data.unstable_siteVersion;
743
+ return null;
744
+ }
745
+ function PreviewModeScript({
746
+ isPreview = false,
747
+ appOrigin = "https://app.makeswift.com"
748
+ }) {
749
+ const previewModeScript = `
750
+ const isPreview = ${isPreview}
751
+ const appOrigin = '${appOrigin.replace("'", "\\'")}'
752
+ const searchParamName = 'x-makeswift-preview-mode'
753
+ const headerName = 'X-Makeswift-Preview-Mode'
754
+ const originalUrl = new URL(window.location.href)
755
+
756
+ if (window.parent !== window) {
757
+ window.addEventListener('message', event => {
758
+ if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
759
+ const { secret } = event.data
760
+
761
+ if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
762
+ const url = new URL(originalUrl)
763
+
764
+ url.searchParams.set(searchParamName, secret)
765
+
766
+ window.location.replace(url)
767
+ } else {
768
+ const originalFetch = window.fetch
769
+
770
+ window.fetch = function patchedFetch(resource, options) {
771
+ const request = new Request(resource, options)
772
+
773
+ if (new URL(request.url).origin !== window.location.origin) {
774
+ return originalFetch.call(this, resource, options)
775
+ }
776
+
777
+ return originalFetch.call(
778
+ this,
779
+ new Request(request, { headers: { [headerName]: secret } }),
780
+ )
781
+ }
782
+ }
783
+ }
784
+ })
785
+
786
+ window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
787
+ }
788
+
789
+ if (originalUrl.searchParams.has(searchParamName)) {
790
+ const url = new URL(originalUrl)
791
+
792
+ url.searchParams.delete(searchParamName)
793
+
794
+ window.history.replaceState(null, '', url)
795
+ }
796
+ `;
797
+ const makeswiftConnectionCheckScript = `
798
+ const appOrigin = '${appOrigin.replace("'", "\\'")}'
799
+
800
+ if (window.parent !== window) {
801
+ window.addEventListener('message', event => {
802
+ if (
803
+ event.origin === appOrigin &&
804
+ event.data.type === '${ActionTypes.MAKESWIFT_CONNECTION_INIT}'
805
+ ) {
806
+ setInterval(() => {
807
+ window.parent.postMessage({
808
+ type: '${ActionTypes.MAKESWIFT_CONNECTION_CHECK}',
809
+ payload: {
810
+ currentUrl: window.location.href
811
+ }
812
+ }, appOrigin)
813
+ }, 20)
814
+ }
815
+ })
816
+
817
+ window.parent.postMessage({ type: '${ActionTypes.MAKESWIFT_CONNECTION_INIT}' }, appOrigin)
818
+ }
819
+ `;
820
+ return /* @__PURE__ */ jsxs(Fragment, {
821
+ children: [/* @__PURE__ */ jsx("script", {
822
+ id: "makeswift-preview-mode",
823
+ type: "module",
824
+ dangerouslySetInnerHTML: {
825
+ __html: previewModeScript
826
+ }
827
+ }), /* @__PURE__ */ jsx("script", {
828
+ id: "makeswift-connection-check",
829
+ type: "module",
830
+ dangerouslySetInnerHTML: {
831
+ __html: makeswiftConnectionCheckScript
832
+ }
833
+ })]
834
+ });
835
+ }
761
836
  class Makeswift {
762
- constructor(apiKey, { apiOrigin = "https://api.makeswift.com", runtime } = {}) {
837
+ constructor(apiKey, {
838
+ apiOrigin = "https://api.makeswift.com",
839
+ runtime = ReactRuntime,
840
+ unstable_previewData
841
+ } = {}) {
763
842
  __publicField(this, "apiKey");
764
843
  __publicField(this, "apiOrigin");
765
844
  __publicField(this, "graphqlClient");
766
845
  __publicField(this, "runtime");
846
+ __publicField(this, "siteVersion");
767
847
  if (typeof apiKey !== "string") {
768
848
  throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
769
849
  Received "${apiKey}" instead.`);
@@ -776,17 +856,27 @@ Received "${apiKey}" instead.`);
776
856
  }
777
857
  this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
778
858
  this.runtime = runtime;
859
+ this.siteVersion = getMakeswiftSiteVersion(unstable_previewData);
779
860
  }
780
861
  async fetch(path, init) {
862
+ var _a;
781
863
  const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
782
- headers: __spreadProps(__spreadValues({}, init == null ? void 0 : init.headers), { ["X-API-Key"]: this.apiKey })
864
+ headers: __spreadValues({
865
+ ["X-API-Key"]: this.apiKey,
866
+ "Makeswift-Site-API-Key": this.apiKey,
867
+ "Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : MakeswiftSiteVersion.Live
868
+ }, init == null ? void 0 : init.headers)
783
869
  }));
784
870
  return response;
785
871
  }
786
- async getPages(params = {}) {
787
- const searchParams = new URLSearchParams(params);
788
- const response = await this.fetch(`/v1/pages?${searchParams}`);
872
+ async getPages() {
873
+ const response = await this.fetch(`/v2/pages`, {
874
+ headers: {
875
+ "Makeswift-Site-Version": MakeswiftSiteVersion.Live
876
+ }
877
+ });
789
878
  if (!response.ok) {
879
+ console.error("Failed to get pages", await response.json());
790
880
  throw new Error(`Failed to get pages with error: "${response.statusText}"`);
791
881
  }
792
882
  const json = await response.json();
@@ -796,13 +886,35 @@ Received "${apiKey}" instead.`);
796
886
  const result = await this.graphqlClient.request(TypographiesQuery, { typographyIds });
797
887
  return result.typographies;
798
888
  }
799
- async getIntrospectedResources(introspectedResourceIds) {
889
+ async getSwatches(ids, preview) {
890
+ var _a;
891
+ const url = new URL(`v1/swatches/bulk`, this.apiOrigin);
892
+ ids.forEach((id) => {
893
+ url.searchParams.append("ids", id);
894
+ });
895
+ const response = await this.fetch(url.pathname + url.search, {
896
+ headers: {
897
+ "Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : preview ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
898
+ }
899
+ });
900
+ if (!response.ok) {
901
+ console.error("Failed to get swatches", await response.json());
902
+ return [];
903
+ }
904
+ return await response.json();
905
+ }
906
+ async getIntrospectedResources(_a, preview) {
907
+ var _b = _a, {
908
+ swatchIds
909
+ } = _b, introspectedResourceIds = __objRest(_b, [
910
+ "swatchIds"
911
+ ]);
800
912
  const result = await this.graphqlClient.request(IntrospectedResourcesQuery, introspectedResourceIds);
801
- return result;
913
+ const swatches = await this.getSwatches(swatchIds, preview);
914
+ return __spreadProps(__spreadValues({}, result), { swatches });
802
915
  }
803
- async introspect(element) {
804
- var _a;
805
- const runtime = (_a = this.runtime) != null ? _a : ReactRuntime;
916
+ async introspect(element, preview) {
917
+ const runtime = this.runtime;
806
918
  const descriptors = getPropControllerDescriptors(runtime.store.getState());
807
919
  const swatchIds = /* @__PURE__ */ new Set();
808
920
  const fileIds = /* @__PURE__ */ new Set();
@@ -878,8 +990,8 @@ Received "${apiKey}" instead.`);
878
990
  const typographies = await this.getTypographies([...typographyIds]);
879
991
  typographies.forEach((typography) => {
880
992
  typography == null ? void 0 : typography.style.forEach((style) => {
881
- var _a2;
882
- const swatchId = (_a2 = style.value.color) == null ? void 0 : _a2.swatchId;
993
+ var _a;
994
+ const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
883
995
  if (swatchId != null)
884
996
  swatchIds.add(swatchId);
885
997
  });
@@ -889,44 +1001,44 @@ Received "${apiKey}" instead.`);
889
1001
  fileIds: [...fileIds],
890
1002
  tableIds: [...tableIds],
891
1003
  pageIds: [...pageIds]
892
- });
1004
+ }, preview);
893
1005
  const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
894
1006
  id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
895
1007
  }));
896
1008
  return {
897
1009
  [APIResourceType.Swatch]: [...swatchIds].map((id) => {
898
- var _a2;
1010
+ var _a;
899
1011
  return {
900
1012
  id,
901
- value: (_a2 = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a2 : null
1013
+ value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
902
1014
  };
903
1015
  }),
904
1016
  [APIResourceType.File]: [...fileIds].map((id) => {
905
- var _a2;
1017
+ var _a;
906
1018
  return {
907
1019
  id,
908
- value: (_a2 = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a2 : null
1020
+ value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
909
1021
  };
910
1022
  }),
911
1023
  [APIResourceType.Typography]: [...typographyIds].map((id) => {
912
- var _a2;
1024
+ var _a;
913
1025
  return {
914
1026
  id,
915
- value: (_a2 = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a2 : null
1027
+ value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
916
1028
  };
917
1029
  }),
918
1030
  [APIResourceType.Table]: [...tableIds].map((id) => {
919
- var _a2;
1031
+ var _a;
920
1032
  return {
921
1033
  id,
922
- value: (_a2 = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a2 : null
1034
+ value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
923
1035
  };
924
1036
  }),
925
1037
  [APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
926
- var _a2;
1038
+ var _a;
927
1039
  return {
928
1040
  id,
929
- value: (_a2 = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a2 : null
1041
+ value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
930
1042
  };
931
1043
  }),
932
1044
  [APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
@@ -935,31 +1047,33 @@ Received "${apiKey}" instead.`);
935
1047
  }))
936
1048
  };
937
1049
  }
938
- async createSnapshot(document2, preview) {
939
- const cacheData = await this.introspect(document2.data);
940
- return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
941
- }
942
- async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
943
- const searchParams = new URLSearchParams({ preview: String(preview) });
944
- const response = await this.fetch(`/v1/pages/${pageId}/document?${searchParams}`);
1050
+ async getPageSnapshot(pathname, { preview: previewOverride = false } = {}) {
1051
+ var _a;
1052
+ const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
1053
+ const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document`, {
1054
+ headers: { "Makeswift-Site-Version": siteVersion }
1055
+ });
945
1056
  if (!response.ok) {
946
1057
  if (response.status === 404)
947
1058
  return null;
948
- throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
1059
+ console.error("Failed to get page snapshot", await response.json());
1060
+ throw new Error(`Failed to get page snapshot with error: "${response.statusText}"`);
949
1061
  }
950
1062
  const document2 = await response.json();
951
- return await this.createSnapshot(document2, preview);
952
- }
953
- async getPageSnapshot(path, { preview } = {}) {
954
- const [page] = await this.getPages({ path });
955
- if (page == null)
956
- return null;
957
- const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
958
- return snapshot;
1063
+ const cacheData = await this.introspect(document2.data, previewOverride);
1064
+ const apiOrigin = this.apiOrigin.href;
1065
+ const preview = siteVersion === MakeswiftSiteVersion.Working;
1066
+ return { document: document2, cacheData, apiOrigin, preview };
959
1067
  }
960
1068
  async getSwatch(swatchId) {
961
- const result = await this.graphqlClient.request(SwatchQuery, { swatchId });
962
- return result.swatch;
1069
+ const response = await this.fetch(`v1/swatches/${swatchId}`);
1070
+ if (!response.ok) {
1071
+ if (response.status !== 404)
1072
+ console.error("Failed to get swatch", await response.json());
1073
+ return null;
1074
+ }
1075
+ const swatch = await response.json();
1076
+ return swatch;
963
1077
  }
964
1078
  async getFile(fileId) {
965
1079
  const result = await this.graphqlClient.request(FileQuery, { fileId });
@@ -983,97 +1097,6 @@ Received "${apiKey}" instead.`);
983
1097
  return result.table;
984
1098
  }
985
1099
  }
986
- function PreviewModeScript({
987
- isPreview = false,
988
- appOrigin = "https://app.makeswift.com"
989
- }) {
990
- const previewModeScript = `
991
- const isPreview = ${isPreview}
992
- const appOrigin = '${appOrigin.replace("'", "\\'")}'
993
- const searchParamName = 'x-makeswift-preview-mode'
994
- const headerName = 'X-Makeswift-Preview-Mode'
995
- const originalUrl = new URL(window.location.href)
996
-
997
- if (window.parent !== window) {
998
- window.addEventListener('message', event => {
999
- if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
1000
- const { secret } = event.data
1001
-
1002
- if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
1003
- const url = new URL(originalUrl)
1004
-
1005
- url.searchParams.set(searchParamName, secret)
1006
-
1007
- window.location.replace(url)
1008
- } else {
1009
- const originalFetch = window.fetch
1010
-
1011
- window.fetch = function patchedFetch(resource, options) {
1012
- const request = new Request(resource, options)
1013
-
1014
- if (new URL(request.url).origin !== window.location.origin) {
1015
- return originalFetch.call(this, resource, options)
1016
- }
1017
-
1018
- return originalFetch.call(
1019
- this,
1020
- new Request(request, { headers: { [headerName]: secret } }),
1021
- )
1022
- }
1023
- }
1024
- }
1025
- })
1026
-
1027
- window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
1028
- }
1029
-
1030
- if (originalUrl.searchParams.has(searchParamName)) {
1031
- const url = new URL(originalUrl)
1032
-
1033
- url.searchParams.delete(searchParamName)
1034
-
1035
- window.history.replaceState(null, '', url)
1036
- }
1037
- `;
1038
- const makeswiftConnectionCheckScript = `
1039
- const appOrigin = '${appOrigin.replace("'", "\\'")}'
1040
-
1041
- if (window.parent !== window) {
1042
- window.addEventListener('message', event => {
1043
- if (
1044
- event.origin === appOrigin &&
1045
- event.data.type === '${ActionTypes.MAKESWIFT_CONNECTION_INIT}'
1046
- ) {
1047
- setInterval(() => {
1048
- window.parent.postMessage({
1049
- type: '${ActionTypes.MAKESWIFT_CONNECTION_CHECK}',
1050
- payload: {
1051
- currentUrl: window.location.href
1052
- }
1053
- }, appOrigin)
1054
- }, 20)
1055
- }
1056
- })
1057
-
1058
- window.parent.postMessage({ type: '${ActionTypes.MAKESWIFT_CONNECTION_INIT}' }, appOrigin)
1059
- }
1060
- `;
1061
- return /* @__PURE__ */ jsxs(Fragment, {
1062
- children: [/* @__PURE__ */ jsx("script", {
1063
- id: "makeswift-preview-mode",
1064
- type: "module",
1065
- dangerouslySetInnerHTML: {
1066
- __html: previewModeScript
1067
- }
1068
- }), /* @__PURE__ */ jsx("script", {
1069
- id: "makeswift-connection-check",
1070
- type: "module",
1071
- dangerouslySetInnerHTML: {
1072
- __html: makeswiftConnectionCheckScript
1073
- }
1074
- })]
1075
- });
1076
- }
1077
1100
  class Document$1 extends NextDocument {
1078
1101
  static async getInitialProps(ctx) {
1079
1102
  const initialProps = await NextDocument.getInitialProps(ctx);
@@ -1128,8 +1151,8 @@ async function fonts(_req, res, { getFonts } = {}) {
1128
1151
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1129
1152
  return res.json(fonts2);
1130
1153
  }
1131
- const version = "0.8.11";
1132
- async function handler(req, res, { apiKey }) {
1154
+ const version = "0.9.0";
1155
+ async function handler(req, res, { apiKey, unstable_siteVersions }) {
1133
1156
  if (req.query.secret !== apiKey) {
1134
1157
  return res.status(401).json({ message: "Unauthorized" });
1135
1158
  }
@@ -1139,7 +1162,8 @@ async function handler(req, res, { apiKey }) {
1139
1162
  interactionMode: true,
1140
1163
  clientSideNavigation: true,
1141
1164
  elementFromPoint: false,
1142
- customBreakpoints: true
1165
+ customBreakpoints: true,
1166
+ unstable_siteVersions
1143
1167
  });
1144
1168
  }
1145
1169
  async function proxyPreviewMode(req, res, { apiKey }) {
@@ -1170,7 +1194,11 @@ async function proxyPreviewMode(req, res, { apiKey }) {
1170
1194
  const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
1171
1195
  let target = `${proto}://${host}`;
1172
1196
  const secure = process.env["NODE_ENV"] === "production";
1173
- const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
1197
+ const previewData = {
1198
+ makeswift: true,
1199
+ unstable_siteVersion: MakeswiftSiteVersion.Working
1200
+ };
1201
+ const setCookie = res.setPreviewData(previewData).getHeader("Set-Cookie");
1174
1202
  res.removeHeader("Set-Cookie");
1175
1203
  if (!Array.isArray(setCookie))
1176
1204
  return res.status(500).send("Internal Server Error");
@@ -1212,7 +1240,8 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
1212
1240
  function MakeswiftApiHandler(apiKey, {
1213
1241
  appOrigin = "https://app.makeswift.com",
1214
1242
  apiOrigin = "https://api.makeswift.com",
1215
- getFonts
1243
+ getFonts,
1244
+ unstable_siteVersions = false
1216
1245
  } = {}) {
1217
1246
  const cors = Cors({ origin: appOrigin });
1218
1247
  if (typeof apiKey !== "string") {
@@ -1234,12 +1263,12 @@ Received "${apiKey}" instead.`);
1234
1263
  Received "${makeswift}" for the \`makeswift\` param instead.
1235
1264
  Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
1236
1265
  }
1237
- const client = new Makeswift(apiKey, { apiOrigin });
1266
+ const client = new Makeswift(apiKey, { apiOrigin, unstable_previewData: req.previewData });
1238
1267
  const action = "/" + makeswift.join("/");
1239
1268
  const matches = (pattern) => match(pattern, { decode: decodeURIComponent })(action);
1240
1269
  let m;
1241
1270
  if (matches("/manifest"))
1242
- return handler(req, res, { apiKey });
1271
+ return handler(req, res, { apiKey, unstable_siteVersions });
1243
1272
  if (matches("/revalidate"))
1244
1273
  return revalidate(req, res, { apiKey });
1245
1274
  if (matches("/proxy-preview-mode"))
@@ -1276,10 +1305,10 @@ function saveForwardedRef(props, ref) {
1276
1305
  [FORWARDED_NEXT_DYNAMIC_REF_KEY]: ref
1277
1306
  });
1278
1307
  }
1279
- function loadForwardedRef(_a) {
1280
- var _b = _a, {
1308
+ function loadForwardedRef(_c) {
1309
+ var _d = _c, {
1281
1310
  [FORWARDED_NEXT_DYNAMIC_REF_KEY]: ref
1282
- } = _b, props = __objRest(_b, [
1311
+ } = _d, props = __objRest(_d, [
1283
1312
  __restKey(FORWARDED_NEXT_DYNAMIC_REF_KEY)
1284
1313
  ]);
1285
1314
  return __spreadProps(__spreadValues({}, props), {
@@ -1342,14 +1371,15 @@ async function getStaticPaths() {
1342
1371
  }
1343
1372
  const REVALIDATE_SECONDS = 1;
1344
1373
  async function getStaticProps(ctx) {
1345
- var _a, _b, _c2;
1374
+ var _a, _b, _c;
1346
1375
  deprecationWarning("getStaticProps");
1347
1376
  const makeswift = new Makeswift(getApiKey(), {
1348
- apiOrigin: getApiOrigin()
1377
+ apiOrigin: getApiOrigin(),
1378
+ unstable_previewData: ctx.previewData
1349
1379
  });
1350
1380
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1351
1381
  const snapshot = await makeswift.getPageSnapshot(path, {
1352
- preview: ((_c2 = ctx.previewData) == null ? void 0 : _c2.makeswift) === true
1382
+ preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
1353
1383
  });
1354
1384
  if (snapshot == null)
1355
1385
  return {
@@ -1367,7 +1397,8 @@ async function getServerSideProps(ctx) {
1367
1397
  var _a, _b;
1368
1398
  deprecationWarning("getServerSideProps");
1369
1399
  const makeswift = new Makeswift(getApiKey(), {
1370
- apiOrigin: getApiOrigin()
1400
+ apiOrigin: getApiOrigin(),
1401
+ unstable_previewData: ctx.previewData
1371
1402
  });
1372
1403
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1373
1404
  const snapshot = await makeswift.getPageSnapshot(path, {
@@ -1620,7 +1651,7 @@ function registerComponent$a(runtime) {
1620
1651
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Carousel.es.js")))), {
1621
1652
  type: MakeswiftComponentType.Carousel,
1622
1653
  label: "Carousel",
1623
- icon: "Carousel40",
1654
+ icon: ComponentIcon.Carousel,
1624
1655
  props: {
1625
1656
  id: ElementID(),
1626
1657
  images: Images({
@@ -1718,7 +1749,7 @@ function registerComponent$9(runtime) {
1718
1749
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Countdown.es.js")))), {
1719
1750
  type: MakeswiftComponentType.Countdown,
1720
1751
  label: "Countdown",
1721
- icon: "Countdown40",
1752
+ icon: ComponentIcon.Countdown,
1722
1753
  props: {
1723
1754
  id: ElementID(),
1724
1755
  date: Date$1(() => ({
@@ -1810,7 +1841,7 @@ function registerComponent$8(runtime) {
1810
1841
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Divider.es.js")))), {
1811
1842
  type: MakeswiftComponentType.Divider,
1812
1843
  label: "Divider",
1813
- icon: "Divider40",
1844
+ icon: ComponentIcon.Divider,
1814
1845
  props: {
1815
1846
  id: ElementID(),
1816
1847
  variant: ResponsiveSelect({
@@ -1842,7 +1873,7 @@ function registerComponent$7(runtime) {
1842
1873
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Embed.es.js")))), {
1843
1874
  type: MakeswiftComponentType.Embed,
1844
1875
  label: "Embed",
1845
- icon: "Code40",
1876
+ icon: ComponentIcon.Code,
1846
1877
  props: {
1847
1878
  id: ElementID(),
1848
1879
  html: TextArea({ label: "Code", rows: 20 }),
@@ -1879,7 +1910,7 @@ function registerComponent$6(runtime) {
1879
1910
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Form.es.js")))), {
1880
1911
  type: MakeswiftComponentType.Form,
1881
1912
  label: "Form",
1882
- icon: "Form40",
1913
+ icon: ComponentIcon.Form,
1883
1914
  props: {
1884
1915
  id: ElementID(),
1885
1916
  tableId: Table(),
@@ -2024,7 +2055,7 @@ function registerComponent$4(runtime) {
2024
2055
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Navigation.es.js")))), {
2025
2056
  type: MakeswiftComponentType.Navigation,
2026
2057
  label: "Navigation",
2027
- icon: "Navigation40",
2058
+ icon: ComponentIcon.Navigation,
2028
2059
  props: {
2029
2060
  id: ElementID(),
2030
2061
  links: NavigationLinks(),
@@ -2142,7 +2173,7 @@ function registerComponent$2(runtime) {
2142
2173
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./SocialLinks.es.js")))), {
2143
2174
  type: MakeswiftComponentType.SocialLinks,
2144
2175
  label: "Social Links",
2145
- icon: "SocialLinks40",
2176
+ icon: ComponentIcon.SocialLinks,
2146
2177
  props: {
2147
2178
  id: ElementID(),
2148
2179
  links: SocialLinks({
@@ -2349,7 +2380,7 @@ function registerComponent(runtime) {
2349
2380
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Video.es.js")))), {
2350
2381
  type: MakeswiftComponentType.Video,
2351
2382
  label: "Video",
2352
- icon: "Video40",
2383
+ icon: ComponentIcon.Video,
2353
2384
  props: {
2354
2385
  id: ElementID(),
2355
2386
  video: Video({ preset: { controls: true } }),
@@ -2394,7 +2425,7 @@ function registerBuiltinComponents(runtime) {
2394
2425
  }
2395
2426
  const isServer = typeof window === "undefined";
2396
2427
  const useInsertionEffectSpecifier = "useInsertionEffect";
2397
- const useInsertionEffect = (_c = React[useInsertionEffectSpecifier]) != null ? _c : React.useLayoutEffect;
2428
+ const useInsertionEffect = (_e = React[useInsertionEffectSpecifier]) != null ? _e : React.useLayoutEffect;
2398
2429
  function useStyle(style) {
2399
2430
  const serialized = serializeStyles([style], cache.registered);
2400
2431
  registerStyles(cache, serialized, false);
@@ -2548,8 +2579,8 @@ function useTable(tableId) {
2548
2579
  }, [client, tableId]);
2549
2580
  return table;
2550
2581
  }
2551
- function mapSideColor(swatches, _d) {
2552
- var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
2582
+ function mapSideColor(swatches, _f) {
2583
+ var _g = _f, { color } = _g, restOfSide = __objRest(_g, ["color"]);
2553
2584
  return __spreadProps(__spreadValues({}, restOfSide), {
2554
2585
  color: color && {
2555
2586
  alpha: color.alpha,
@@ -2645,10 +2676,10 @@ function lengthDataToString(data) {
2645
2676
  return data;
2646
2677
  }
2647
2678
  function paddingPropertyDataToStyle(data, defaultValue = {}) {
2648
- var _a, _b, _c2, _d;
2679
+ var _a, _b, _c, _d;
2649
2680
  const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
2650
2681
  const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
2651
- const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
2682
+ const paddingBottom = (_c = data.paddingBottom) != null ? _c : defaultValue.paddingBottom;
2652
2683
  const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
2653
2684
  const style = {};
2654
2685
  if (paddingTop != null)
@@ -2662,10 +2693,10 @@ function paddingPropertyDataToStyle(data, defaultValue = {}) {
2662
2693
  return style;
2663
2694
  }
2664
2695
  function marginPropertyDataToStyle(data, defaultValue = {}) {
2665
- var _a, _b, _c2, _d;
2696
+ var _a, _b, _c, _d;
2666
2697
  const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
2667
2698
  const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
2668
- const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
2699
+ const marginBottom = (_c = data.marginBottom) != null ? _c : defaultValue.marginBottom;
2669
2700
  const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
2670
2701
  const style = {};
2671
2702
  if (marginTop != null)
@@ -2686,10 +2717,10 @@ function lengthPercentageDataToString(data) {
2686
2717
  return data;
2687
2718
  }
2688
2719
  function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
2689
- var _a, _b, _c2, _d;
2720
+ var _a, _b, _c, _d;
2690
2721
  const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
2691
2722
  const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
2692
- const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
2723
+ const borderBottomRightRadius = (_c = data.borderBottomRightRadius) != null ? _c : defaultValue.borderBottomRightRadius;
2693
2724
  const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
2694
2725
  const style = {};
2695
2726
  if (borderTopLeftRadius != null) {
@@ -2710,10 +2741,10 @@ function colorToString(color) {
2710
2741
  return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
2711
2742
  }
2712
2743
  function borderPropertyDataToStyle(data, defaultValue = {}) {
2713
- var _a, _b, _c2, _d;
2744
+ var _a, _b, _c, _d;
2714
2745
  const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
2715
2746
  const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
2716
- const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
2747
+ const borderBottom = (_c = data.borderBottom) != null ? _c : defaultValue.borderBottom;
2717
2748
  const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
2718
2749
  const style = {};
2719
2750
  if (borderTop != null)
@@ -2879,14 +2910,14 @@ function useStyleControlCssObject(style, controlDefinition) {
2879
2910
  style == null ? void 0 : style.borderRadius,
2880
2911
  style == null ? void 0 : style.textStyle
2881
2912
  ], ([width, margin, padding, border, borderRadius, textStyle]) => {
2882
- var _a, _b, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
2913
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
2883
2914
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(StyleControlProperty.Width) && {
2884
2915
  width: (_a = widthToString(width)) != null ? _a : "100%"
2885
2916
  }), properties.includes(StyleControlProperty.Margin) && marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(StyleControlProperty.Padding) && paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(StyleControlProperty.Border) && {
2886
2917
  borderTop: (_b = borderSideToString2(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
2887
- borderRight: (_c2 = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c2 : "0 solid black",
2918
+ borderRight: (_c = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c : "0 solid black",
2888
2919
  borderBottom: (_d = borderSideToString2(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
2889
- borderLeft: (_e = borderSideToString2(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
2920
+ borderLeft: (_e2 = borderSideToString2(border == null ? void 0 : border.borderLeft)) != null ? _e2 : "0 solid black"
2890
2921
  }), properties.includes(StyleControlProperty.BorderRadius) && {
2891
2922
  borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
2892
2923
  borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
@@ -3159,13 +3190,13 @@ function useSlot(data, control) {
3159
3190
  }, element.key))
3160
3191
  });
3161
3192
  }
3162
- function Slot(_f) {
3163
- var _g = _f, {
3193
+ function Slot(_h) {
3194
+ var _i = _h, {
3164
3195
  as,
3165
3196
  control,
3166
3197
  children,
3167
3198
  className
3168
- } = _g, restOfProps = __objRest(_g, [
3199
+ } = _i, restOfProps = __objRest(_i, [
3169
3200
  "as",
3170
3201
  "control",
3171
3202
  "children",
@@ -3194,15 +3225,15 @@ function Slot(_f) {
3194
3225
  }
3195
3226
  Slot.Placeholder = SlotPlaceholder;
3196
3227
  Slot.Item = SlotItem;
3197
- function SlotItem(_h) {
3198
- var _i = _h, {
3228
+ function SlotItem(_j) {
3229
+ var _k = _j, {
3199
3230
  as,
3200
3231
  control,
3201
3232
  grid,
3202
3233
  index,
3203
3234
  children,
3204
3235
  className
3205
- } = _i, restOfProps = __objRest(_i, [
3236
+ } = _k, restOfProps = __objRest(_k, [
3206
3237
  "as",
3207
3238
  "control",
3208
3239
  "grid",
@@ -3428,7 +3459,7 @@ function PropsValue({
3428
3459
  return getPropControllers(state, documentKey, element.key);
3429
3460
  });
3430
3461
  return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
3431
- var _a2, _b, _c2, _d;
3462
+ var _a2, _b, _c, _d;
3432
3463
  switch (descriptor.type) {
3433
3464
  case CheckboxControlType:
3434
3465
  case NumberControlType:
@@ -3470,7 +3501,7 @@ function PropsValue({
3470
3501
  }, descriptor.type);
3471
3502
  }
3472
3503
  case RichTextV2ControlType: {
3473
- const control = (_c2 = propControllers == null ? void 0 : propControllers[propName]) != null ? _c2 : null;
3504
+ const control = (_c = propControllers == null ? void 0 : propControllers[propName]) != null ? _c : null;
3474
3505
  return /* @__PURE__ */ jsx(RenderHook, {
3475
3506
  hook: useRichTextV2,
3476
3507
  parameters: [props[propName], control],
@@ -3664,18 +3695,22 @@ function isDomNodeHandle(value) {
3664
3695
  }
3665
3696
  class ReactRuntime {
3666
3697
  constructor({
3667
- breakpoints
3668
- }) {
3698
+ breakpoints,
3699
+ unstable_i18n
3700
+ } = {}) {
3669
3701
  __publicField(this, "store");
3670
3702
  this.store = configureStore$1({
3671
- breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0
3703
+ breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0,
3704
+ locales: unstable_i18n ? __spreadProps(__spreadValues({}, unstable_i18n), {
3705
+ locale: null
3706
+ }) : void 0
3672
3707
  });
3673
3708
  registerBuiltinComponents(this);
3674
3709
  }
3675
3710
  static registerComponent(component, {
3676
3711
  type,
3677
3712
  label,
3678
- icon = "Cube40",
3713
+ icon = ComponentIcon.Code,
3679
3714
  hidden = false,
3680
3715
  props
3681
3716
  }) {
@@ -3699,7 +3734,7 @@ class ReactRuntime {
3699
3734
  registerComponent(component, {
3700
3735
  type,
3701
3736
  label,
3702
- icon = "Cube40",
3737
+ icon = ComponentIcon.Cube,
3703
3738
  hidden = false,
3704
3739
  props
3705
3740
  }) {
@@ -3726,10 +3761,10 @@ registerBuiltinComponents(ReactRuntime);
3726
3761
  const StoreContext = createContext(ReactRuntime.store);
3727
3762
  const PreviewProvider = dynamic(() => import("./PreviewProvider.es.js"));
3728
3763
  const LiveProvider = dynamic(() => import("./LiveProvider.es.js"));
3729
- function RuntimeProvider(_j) {
3730
- var _k = _j, {
3764
+ function RuntimeProvider(_l) {
3765
+ var _m = _l, {
3731
3766
  preview
3732
- } = _k, props = __objRest(_k, [
3767
+ } = _m, props = __objRest(_m, [
3733
3768
  "preview"
3734
3769
  ]);
3735
3770
  return preview ? /* @__PURE__ */ jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsx(LiveProvider, __spreadValues({}, props));