@makeswift/runtime 0.6.3 → 0.6.4

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 (71) hide show
  1. package/dist/EditableText.cjs.js +12 -3
  2. package/dist/EditableText.cjs.js.map +1 -1
  3. package/dist/EditableText.es.js +13 -4
  4. package/dist/EditableText.es.js.map +1 -1
  5. package/dist/PreviewProvider.cjs.js +53 -16
  6. package/dist/PreviewProvider.cjs.js.map +1 -1
  7. package/dist/PreviewProvider.es.js +55 -19
  8. package/dist/PreviewProvider.es.js.map +1 -1
  9. package/dist/ReadOnlyText.cjs.js +5 -2
  10. package/dist/ReadOnlyText.cjs.js.map +1 -1
  11. package/dist/ReadOnlyText.es.js +5 -2
  12. package/dist/ReadOnlyText.es.js.map +1 -1
  13. package/dist/actions.cjs.js +11 -1
  14. package/dist/actions.cjs.js.map +1 -1
  15. package/dist/actions.es.js +11 -2
  16. package/dist/actions.es.js.map +1 -1
  17. package/dist/builder.cjs.js +1 -0
  18. package/dist/builder.cjs.js.map +1 -1
  19. package/dist/builder.es.js +1 -0
  20. package/dist/builder.es.js.map +1 -1
  21. package/dist/constants.cjs.js +6 -1
  22. package/dist/constants.cjs.js.map +1 -1
  23. package/dist/constants.es.js +7 -3
  24. package/dist/constants.es.js.map +1 -1
  25. package/dist/controls.cjs.js +1 -0
  26. package/dist/controls.cjs.js.map +1 -1
  27. package/dist/controls.es.js +2 -1
  28. package/dist/controls.es.js.map +1 -1
  29. package/dist/index.cjs.js +45 -8
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.es.js +48 -12
  32. package/dist/index.es.js.map +1 -1
  33. package/dist/index.es2.js +1 -1
  34. package/dist/index.es6.js +2 -2
  35. package/dist/main.cjs.js +1 -0
  36. package/dist/main.cjs.js.map +1 -1
  37. package/dist/main.es.js +1 -1
  38. package/dist/next.es.js +1 -1
  39. package/dist/prop-controllers.cjs.js +1 -0
  40. package/dist/prop-controllers.cjs.js.map +1 -1
  41. package/dist/prop-controllers.es.js +1 -0
  42. package/dist/prop-controllers.es.js.map +1 -1
  43. package/dist/rich-text.cjs.js +20 -4
  44. package/dist/rich-text.cjs.js.map +1 -1
  45. package/dist/rich-text.es.js +19 -5
  46. package/dist/rich-text.es.js.map +1 -1
  47. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +1 -1
  48. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  49. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  50. package/dist/types/src/controls/rich-text.d.ts +1 -1
  51. package/dist/types/src/controls/rich-text.d.ts.map +1 -1
  52. package/dist/types/src/index.d.ts +1 -1
  53. package/dist/types/src/index.d.ts.map +1 -1
  54. package/dist/types/src/next/api-handler.d.ts +1 -0
  55. package/dist/types/src/next/api-handler.d.ts.map +1 -1
  56. package/dist/types/src/next/preview-mode.d.ts.map +1 -1
  57. package/dist/types/src/prop-controllers/instances.d.ts +1 -1
  58. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  59. package/dist/types/src/runtimes/react/index.d.ts +2 -0
  60. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  61. package/dist/types/src/state/actions.d.ts +12 -1
  62. package/dist/types/src/state/actions.d.ts.map +1 -1
  63. package/dist/types/src/state/modules/builder-edit-mode.d.ts +11 -0
  64. package/dist/types/src/state/modules/builder-edit-mode.d.ts.map +1 -0
  65. package/dist/types/src/state/react-builder-preview.d.ts +2 -0
  66. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  67. package/dist/types/src/state/react-page.d.ts +3 -0
  68. package/dist/types/src/state/react-page.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/dist/types/src/utils/constants.d.ts +0 -6
  71. package/dist/types/src/utils/constants.d.ts.map +0 -1
package/dist/index.es.js CHANGED
@@ -39,13 +39,13 @@ import * as React from "react";
39
39
  import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, 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 { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, M as MakeswiftComponentType, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as isPropControllersHandle, p as getComponentPropControllerDescriptors, q as getPropControllers, r as configureStore$1, s as getDocument, t as getElementId, u as getIsPreview, v as getIsInBuilder, w as copyElementTree, x as getReactComponent } from "./constants.es.js";
43
- import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as registerComponentHandleEffect, j as mountComponentEffect, k as registerComponentEffect, l as registerReactComponentEffect } from "./actions.es.js";
42
+ import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, M as MakeswiftComponentType, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as isPropControllersHandle, p as getComponentPropControllerDescriptors, q as getPropControllers, r as configureStore$1, s as getDocument, t as getElementId, u as getIsPreview, v as getIsInBuilder, w as copyElementTree, x as getReactComponent, y as getBuilderEditMode } from "./constants.es.js";
43
+ import { A as ActionTypes, g as introspectedResourcesFulfilled, h as apiResourceFulfilled, t as typographiesFulfilled, j as registerComponentHandleEffect, k as mountComponentEffect, l as registerComponentEffect, n as registerReactComponentEffect } 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
- import { T as Types, E as ElementID, B as Backgrounds, W as Width, h as ResponsiveIconRadioGroup, M as Margin, P as Padding, i as Border, j as BorderRadius, k as Shadows, G as GapY, l as GapX, m as ResponsiveSelect, n as ResponsiveNumber, o as Checkbox, p as Grid, q as TextInput, L as Link, r as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, I as ImageControlType, C as ColorControlType, Q as BorderPropControllerFormat, U as ShadowsPropControllerFormat, X as BorderRadiusPropControllerFormat, Y as MarginPropControllerFormat, Z as PaddingPropControllerFormat, _ as WidthPropControllerFormat, S as SlotControlType, $ as RichTextControlType, a as StyleControlType } from "./rich-text.es.js";
48
+ import { T as Types, E as ElementID, B as Backgrounds, W as Width, h as ResponsiveIconRadioGroup, M as Margin, P as Padding, i as Border, j as BorderRadius, k as Shadows, G as GapY, l as GapX, m as ResponsiveSelect, n as ResponsiveNumber, o as Checkbox, p as Grid, q as TextInput, L as Link, s as ResponsiveColor, t as TextStyle, u as Images, N as Number$1, D as Date$1, F as Font, v as ResponsiveLength, w as TextArea, x as Table, y as TableFormFields, z as Image, A as ResponsiveOpacity, H as NavigationLinks, J as SocialLinks, K as RichText, V as Video, O as StyleControlProperty, Q as ImageControlValueFormat, I as ImageControlType, C as ColorControlType, U as BorderPropControllerFormat, X as ShadowsPropControllerFormat, Y as BorderRadiusPropControllerFormat, Z as MarginPropControllerFormat, _ as PaddingPropControllerFormat, $ as WidthPropControllerFormat, S as SlotControlType, a0 as RichTextControlType, a as StyleControlType } from "./rich-text.es.js";
49
49
  import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
50
50
  import { C as ComboboxControlType } from "./combobox.es.js";
51
51
  import { S as ShapeControlType, L as ListControlType, b as LinkControlType } from "./control.es.js";
@@ -956,7 +956,7 @@ function PreviewModeScript({
956
956
  isPreview = false,
957
957
  appOrigin = "https://app.makeswift.com"
958
958
  }) {
959
- const __html = `
959
+ const previewModeScript = `
960
960
  const isPreview = ${isPreview}
961
961
  const appOrigin = '${appOrigin.replace("'", "\\'")}'
962
962
  const searchParamName = 'x-makeswift-preview-mode'
@@ -1004,12 +1004,43 @@ if (originalUrl.searchParams.has(searchParamName)) {
1004
1004
  window.history.replaceState(null, '', url)
1005
1005
  }
1006
1006
  `;
1007
- return /* @__PURE__ */ jsx("script", {
1008
- id: "makeswift-preview-mode",
1009
- type: "module",
1010
- dangerouslySetInnerHTML: {
1011
- __html
1007
+ const makeswiftConnectionCheckScript = `
1008
+ const appOrigin = '${appOrigin.replace("'", "\\'")}'
1009
+
1010
+ if (window.parent !== window) {
1011
+ window.addEventListener('message', event => {
1012
+ if (
1013
+ event.origin === appOrigin &&
1014
+ event.data.type === '${ActionTypes.MAKESWIFT_CONNECTION_INIT}'
1015
+ ) {
1016
+ setInterval(() => {
1017
+ window.parent.postMessage({
1018
+ type: '${ActionTypes.MAKESWIFT_CONNECTION_CHECK}',
1019
+ payload: {
1020
+ currentUrl: window.location.href
1021
+ }
1022
+ }, appOrigin)
1023
+ }, 20)
1012
1024
  }
1025
+ })
1026
+
1027
+ window.parent.postMessage({ type: '${ActionTypes.MAKESWIFT_CONNECTION_INIT}' }, appOrigin)
1028
+ }
1029
+ `;
1030
+ return /* @__PURE__ */ jsxs(Fragment, {
1031
+ children: [/* @__PURE__ */ jsx("script", {
1032
+ id: "makeswift-preview-mode",
1033
+ type: "module",
1034
+ dangerouslySetInnerHTML: {
1035
+ __html: previewModeScript
1036
+ }
1037
+ }), /* @__PURE__ */ jsx("script", {
1038
+ id: "makeswift-connection-check",
1039
+ type: "module",
1040
+ dangerouslySetInnerHTML: {
1041
+ __html: makeswiftConnectionCheckScript
1042
+ }
1043
+ })]
1013
1044
  });
1014
1045
  }
1015
1046
  class Document$1 extends NextDocument {
@@ -1048,7 +1079,7 @@ class Document$1 extends NextDocument {
1048
1079
  });
1049
1080
  }
1050
1081
  }
1051
- const version = "0.6.3";
1082
+ const version = "0.6.4";
1052
1083
  function isErrorWithMessage(error) {
1053
1084
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1054
1085
  }
@@ -1088,7 +1119,8 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
1088
1119
  return res.status(401).json({ message: "Unauthorized" });
1089
1120
  return res.json({
1090
1121
  version,
1091
- previewMode: true
1122
+ previewMode: true,
1123
+ interactionMode: true
1092
1124
  });
1093
1125
  }
1094
1126
  case "revalidate": {
@@ -2202,6 +2234,7 @@ function registerComponent$1(runtime) {
2202
2234
  text: RichText(() => ({
2203
2235
  preset: {
2204
2236
  document: {
2237
+ object: "document",
2205
2238
  nodes: [
2206
2239
  {
2207
2240
  object: "block",
@@ -3574,6 +3607,9 @@ function useIsInBuilder() {
3574
3607
  function useIsPreview() {
3575
3608
  return useSelector((state) => getIsPreview(state));
3576
3609
  }
3610
+ function useBuilderEditMode() {
3611
+ return useSelector((state) => getBuilderEditMode(state));
3612
+ }
3577
3613
  function useDispatch() {
3578
3614
  const store = useContext(StoreContext);
3579
3615
  return store.dispatch;
@@ -3705,5 +3741,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
3705
3741
  document: document2
3706
3742
  });
3707
3743
  }));
3708
- export { Page as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, forwardNextDynamicRef as H, useIsPreview as I, useFiles as J, useSwatches as K, usePagePathnameSlice as L, useElementId as M, deepEqual as N, storeContextDefaultValue as O, PageProvider as P, StoreContext as Q, RuntimeProvider as R, Shapes as S, MakeswiftProvider as T, pollBoxModel as U, useTypography as V, shallowMergeFallbacks as W, MakeswiftClient as X, getStaticPaths as Y, getStaticProps as Z, getServerSideProps as _, ReactRuntime as a, Makeswift as a0, PreviewModeScript as a1, Document$1 as a2, MakeswiftApiHandler as a3, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, useMediaQuery as m, Page$1 as n, useStyle as o, responsiveWidth as p, responsiveTextStyle as q, responsiveStyle as r, colorToString as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3744
+ export { getServerSideProps as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, forwardNextDynamicRef as H, useIsPreview as I, useFiles as J, useSwatches as K, usePagePathnameSlice as L, useElementId as M, deepEqual as N, storeContextDefaultValue as O, PageProvider as P, StoreContext as Q, RuntimeProvider as R, Shapes as S, MakeswiftProvider as T, useBuilderEditMode as U, pollBoxModel as V, useTypography as W, shallowMergeFallbacks as X, MakeswiftClient as Y, getStaticPaths as Z, getStaticProps as _, ReactRuntime as a, Page as a0, Makeswift as a1, PreviewModeScript as a2, Document$1 as a3, MakeswiftApiHandler as a4, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, useMediaQuery as m, Page$1 as n, useStyle as o, responsiveWidth as p, responsiveTextStyle as q, responsiveStyle as r, colorToString as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3709
3745
  //# sourceMappingURL=index.es.js.map