@makeswift/runtime 0.4.2 → 0.5.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 (92) hide show
  1. package/dist/Box.cjs.js +5 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +5 -3
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +3 -3
  6. package/dist/Button.es.js +3 -3
  7. package/dist/Carousel.cjs.js +5 -3
  8. package/dist/Carousel.cjs.js.map +1 -1
  9. package/dist/Carousel.es.js +5 -3
  10. package/dist/Carousel.es.js.map +1 -1
  11. package/dist/Countdown.cjs.js +3 -3
  12. package/dist/Countdown.es.js +3 -3
  13. package/dist/Divider.cjs.js +3 -3
  14. package/dist/Divider.es.js +3 -3
  15. package/dist/Embed.cjs.js +3 -3
  16. package/dist/Embed.es.js +3 -3
  17. package/dist/Form.cjs.js +3 -3
  18. package/dist/Form.es.js +3 -3
  19. package/dist/Image.cjs.js +20 -12
  20. package/dist/Image.cjs.js.map +1 -1
  21. package/dist/Image.es.js +20 -12
  22. package/dist/Image.es.js.map +1 -1
  23. package/dist/LiveProvider.cjs.js +62 -0
  24. package/dist/LiveProvider.cjs.js.map +1 -0
  25. package/dist/LiveProvider.es.js +60 -0
  26. package/dist/LiveProvider.es.js.map +1 -0
  27. package/dist/Navigation.cjs.js +5 -3
  28. package/dist/Navigation.cjs.js.map +1 -1
  29. package/dist/Navigation.es.js +5 -3
  30. package/dist/Navigation.es.js.map +1 -1
  31. package/dist/{react-builder-preview.cjs.js → PreviewProvider.cjs.js} +43 -16
  32. package/dist/PreviewProvider.cjs.js.map +1 -0
  33. package/dist/{react-builder-preview.es.js → PreviewProvider.es.js} +47 -15
  34. package/dist/PreviewProvider.es.js.map +1 -0
  35. package/dist/Root.cjs.js +5 -3
  36. package/dist/Root.cjs.js.map +1 -1
  37. package/dist/Root.es.js +5 -3
  38. package/dist/Root.es.js.map +1 -1
  39. package/dist/SocialLinks.cjs.js +3 -3
  40. package/dist/SocialLinks.es.js +3 -3
  41. package/dist/Text.cjs.js +3 -3
  42. package/dist/Text.cjs.js.map +1 -1
  43. package/dist/Text.es.js +3 -3
  44. package/dist/Text.es.js.map +1 -1
  45. package/dist/Video.cjs.js +3 -3
  46. package/dist/Video.es.js +3 -3
  47. package/dist/actions.es.js +1 -1
  48. package/dist/components.cjs.js +5 -3
  49. package/dist/components.cjs.js.map +1 -1
  50. package/dist/components.es.js +5 -3
  51. package/dist/components.es.js.map +1 -1
  52. package/dist/grid-item.cjs.js +12 -1
  53. package/dist/grid-item.cjs.js.map +1 -1
  54. package/dist/grid-item.es.js +12 -1
  55. package/dist/grid-item.es.js.map +1 -1
  56. package/dist/index.cjs.js +40 -65
  57. package/dist/index.cjs.js.map +1 -1
  58. package/dist/index.cjs2.js +6 -7
  59. package/dist/index.cjs2.js.map +1 -1
  60. package/dist/index.es.js +35 -65
  61. package/dist/index.es.js.map +1 -1
  62. package/dist/index.es2.js +6 -7
  63. package/dist/index.es2.js.map +1 -1
  64. package/dist/next-version.cjs.js +10 -0
  65. package/dist/next-version.cjs.js.map +1 -0
  66. package/dist/next-version.es.js +5 -0
  67. package/dist/next-version.es.js.map +1 -0
  68. package/dist/next.cjs.js +3 -3
  69. package/dist/next.es.js +4 -4
  70. package/dist/react-page.es.js +1 -1
  71. package/dist/react.cjs.js +4 -4
  72. package/dist/react.es.js +4 -4
  73. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  74. package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
  75. package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  76. package/dist/types/src/components/shared/Link/index.d.ts.map +1 -1
  77. package/dist/types/src/next/client.d.ts +1 -0
  78. package/dist/types/src/next/client.d.ts.map +1 -1
  79. package/dist/types/src/next/index.d.ts.map +1 -1
  80. package/dist/types/src/next/next-version.d.ts +3 -0
  81. package/dist/types/src/next/next-version.d.ts.map +1 -0
  82. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +11 -0
  83. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -0
  84. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +11 -0
  85. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -0
  86. package/dist/types/src/runtimes/react/index.d.ts +3 -1
  87. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  88. package/dist/types/src/state/react-builder-preview.d.ts +3 -1
  89. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  90. package/package.json +4 -4
  91. package/dist/react-builder-preview.cjs.js.map +0 -1
  92. package/dist/react-builder-preview.es.js.map +0 -1
@@ -127,14 +127,13 @@ const Link = React.forwardRef(function Link2(_a, ref) {
127
127
  }
128
128
  }
129
129
  if (useNextLink && href != null) {
130
- return /* @__PURE__ */ jsxRuntime.jsx(NextLink__default["default"], {
130
+ return /* @__PURE__ */ jsxRuntime.jsx(NextLink__default["default"], __spreadProps(__spreadValues({}, restOfProps), {
131
+ ref,
132
+ target,
133
+ onClick: handleClick,
131
134
  href,
132
- children: /* @__PURE__ */ jsxRuntime.jsx("a", __spreadProps(__spreadValues({}, restOfProps), {
133
- ref,
134
- target,
135
- onClick: handleClick
136
- }))
137
- });
135
+ legacyBehavior: false
136
+ }));
138
137
  }
139
138
  return /* @__PURE__ */ jsxRuntime.jsx("a", __spreadProps(__spreadValues({}, restOfProps), {
140
139
  ref,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs2.js","sources":["../src/components/shared/Link/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef, MouseEvent } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport NextLink from 'next/link'\n\nimport { LinkValue as LinkPropControllerValue } from '../../../prop-controllers/descriptors'\nimport { useElementId } from '../../../runtimes/react'\nimport { usePagePathnameSlice } from '../../../runtimes/react/hooks/makeswift-api'\n\ntype BaseProps = {\n link?: LinkPropControllerValue\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'a'>, keyof BaseProps>\n\nexport const Link = forwardRef<HTMLAnchorElement, Props>(function Link(\n { link, onClick = () => {}, ...restOfProps }: Props,\n ref,\n) {\n const pageId = link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null\n const page = usePagePathnameSlice(pageId ?? null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n // We don't want to use `next/link` with relative paths because Next.js will attempt to normalize\n // it and mess up the path.\n let useNextLink: boolean | undefined\n let href: string | undefined\n let target: '_blank' | '_self' | undefined\n let block: 'start' | 'center' | 'end' | undefined\n\n if (link) {\n switch (link.type) {\n case 'OPEN_PAGE': {\n if (page) {\n useNextLink = true\n\n href = `/${page.pathname}`\n }\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n useNextLink = true\n\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n useNextLink = false\n\n const { to, subject = '', body = '' } = link.payload\n\n if (to != null) href = `mailto:${to}?subject=${subject}&body=${body}`\n\n break\n }\n\n case 'CALL_PHONE': {\n useNextLink = false\n\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n useNextLink = false\n\n href = `#${elementId ?? ''}`\n\n block = link.payload.block\n\n break\n }\n\n default:\n throw new RangeError(`Invalid link type \"${(link as any).type}.\"`)\n }\n }\n\n function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n onClick(event)\n\n if (event.defaultPrevented) return\n\n /**\n * When we introduced `next/link` instead of just `a` element slate no longer prevented link from navigating within\n * content mode. This is a hack to compensate for what would be expected as slate's default behavior.\n * On upgrade of slate this can be reevaluated.\n */\n if (event.currentTarget.isContentEditable) return event.preventDefault()\n\n if (link && link.type === 'SCROLL_TO_ELEMENT') {\n let hash: string | undefined\n\n try {\n if (href != null) hash = new URL(`http://www.example.com/${href}`).hash\n } catch (error) {\n console.error(`Link received invalid href: ${href}`, error)\n }\n\n if (href != null && hash != null && href === hash) {\n event.preventDefault()\n const view = event.view as unknown as Window\n\n scrollIntoView(view.document.querySelector(hash)!, {\n behavior: 'smooth',\n block,\n })\n\n if (view.location.hash !== hash) view.history.pushState({}, '', hash)\n }\n }\n }\n\n if (useNextLink && href != null) {\n return (\n <NextLink href={href}>\n {/* eslint-disable-next-line */}\n <a {...restOfProps} ref={ref} target={target} onClick={handleClick} />\n </NextLink>\n )\n }\n\n // eslint-disable-next-line\n return <a {...restOfProps} ref={ref} href={href} target={target} onClick={handleClick} />\n})\n"],"names":["Link","forwardRef","ref","link","onClick","restOfProps","pageId","type","payload","page","usePagePathnameSlice","elementKey","elementIdConfig","elementId","useElementId","useNextLink","href","target","block","pathname","openInNewTab","url","to","subject","body","phoneNumber","RangeError","handleClick","event","defaultPrevented","currentTarget","isContentEditable","preventDefault","hash","URL","error","view","scrollIntoView","document","querySelector","behavior","location","history","pushState","NextLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeaA,MAAAA,OAAOC,MAAAA,WAAqC,eACvD,IACAC,KACA;AAFA,eAAEC;AAAAA;AAAAA,IAAMC,UAAU,MAAM;AAAA,IAAE;AAAA,MAA1B,IAA+BC,wBAA/B,IAA+BA;AAAAA,IAA7BF;AAAAA,IAAMC;AAAAA;;AAGR,QAAME,SAASH,QAAQA,KAAKI,SAAS,cAAcJ,KAAKK,QAAQF,SAAS;AACnEG,QAAAA,OAAOC,KAAAA,qBAAqBJ,0BAAU,IAAX;AACjC,QAAMK,aACJR,8BAAMI,UAAS,sBAAsBJ,YAAKK,QAAQI,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,kBAAaH,UAAD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B,MAAM;AACjDL,cAAMI,eAAN;AACMI,cAAAA,OAAOR,MAAMQ;AAEnBC,gCAAAA,WAAeD,KAAKE,SAASC,cAAcN,IAA5B,GAAoC;AAAA,UACjDO,UAAU;AAAA,UACVtB;AAAAA,QAAAA,CAFY;AAKVkB,YAAAA,KAAKK,SAASR,SAASA;AAAMG,eAAKM,QAAQC,UAAU,IAAI,IAAIV,IAA/B;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEGlB,MAAAA,eAAeC,QAAQ,MAAM;AAC/B,0CACG4B,kBAAAA,YAAD;AAAA,MAAU;AAAA,MAAV,+EAESvC;QAAa;AAAA,QAAU;AAAA,QAAgB,SAASsB;AAAAA,MAAAA,EAAvD;AAAA,IAAA,CAHJ;AAAA,EAMD;AAGD,8EAActB;IAAa;AAAA,IAAU;AAAA,IAAY;AAAA,IAAgB,SAASsB;AAAAA,EAAAA,EAA1E;AACD,CAxH6B;;"}
1
+ {"version":3,"file":"index.cjs2.js","sources":["../src/components/shared/Link/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef, MouseEvent } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport NextLink from 'next/link'\n\nimport { LinkValue as LinkPropControllerValue } from '../../../prop-controllers/descriptors'\nimport { useElementId } from '../../../runtimes/react'\nimport { usePagePathnameSlice } from '../../../runtimes/react/hooks/makeswift-api'\n\ntype BaseProps = {\n link?: LinkPropControllerValue\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'a'>, keyof BaseProps>\n\nexport const Link = forwardRef<HTMLAnchorElement, Props>(function Link(\n { link, onClick = () => {}, ...restOfProps }: Props,\n ref,\n) {\n const pageId = link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null\n const page = usePagePathnameSlice(pageId ?? null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n // We don't want to use `next/link` with relative paths because Next.js will attempt to normalize\n // it and mess up the path.\n let useNextLink: boolean | undefined\n let href: string | undefined\n let target: '_blank' | '_self' | undefined\n let block: 'start' | 'center' | 'end' | undefined\n\n if (link) {\n switch (link.type) {\n case 'OPEN_PAGE': {\n if (page) {\n useNextLink = true\n\n href = `/${page.pathname}`\n }\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n useNextLink = true\n\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n useNextLink = false\n\n const { to, subject = '', body = '' } = link.payload\n\n if (to != null) href = `mailto:${to}?subject=${subject}&body=${body}`\n\n break\n }\n\n case 'CALL_PHONE': {\n useNextLink = false\n\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n useNextLink = false\n\n href = `#${elementId ?? ''}`\n\n block = link.payload.block\n\n break\n }\n\n default:\n throw new RangeError(`Invalid link type \"${(link as any).type}.\"`)\n }\n }\n\n function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n onClick(event)\n\n if (event.defaultPrevented) return\n\n /**\n * When we introduced `next/link` instead of just `a` element slate no longer prevented link from navigating within\n * content mode. This is a hack to compensate for what would be expected as slate's default behavior.\n * On upgrade of slate this can be reevaluated.\n */\n if (event.currentTarget.isContentEditable) return event.preventDefault()\n\n if (link && link.type === 'SCROLL_TO_ELEMENT') {\n let hash: string | undefined\n\n try {\n if (href != null) hash = new URL(`http://www.example.com/${href}`).hash\n } catch (error) {\n console.error(`Link received invalid href: ${href}`, error)\n }\n\n if (href != null && hash != null && href === hash) {\n event.preventDefault()\n const view = event.view as unknown as Window\n\n scrollIntoView(view.document.querySelector(hash)!, {\n behavior: 'smooth',\n block,\n })\n\n if (view.location.hash !== hash) view.history.pushState({}, '', hash)\n }\n }\n }\n\n if (useNextLink && href != null) {\n return (\n <NextLink\n {...restOfProps}\n ref={ref}\n target={target}\n onClick={handleClick}\n href={href}\n // Next.js v12 has legacyBehavior set to true by default\n legacyBehavior={false}\n />\n )\n }\n\n // eslint-disable-next-line\n return <a {...restOfProps} ref={ref} href={href} target={target} onClick={handleClick} />\n})\n"],"names":["Link","forwardRef","ref","link","onClick","restOfProps","pageId","type","payload","page","usePagePathnameSlice","elementKey","elementIdConfig","elementId","useElementId","useNextLink","href","target","block","pathname","openInNewTab","url","to","subject","body","phoneNumber","RangeError","handleClick","event","defaultPrevented","currentTarget","isContentEditable","preventDefault","hash","URL","error","view","scrollIntoView","document","querySelector","behavior","location","history","pushState","NextLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeaA,MAAAA,OAAOC,MAAAA,WAAqC,eACvD,IACAC,KACA;AAFA,eAAEC;AAAAA;AAAAA,IAAMC,UAAU,MAAM;AAAA,IAAE;AAAA,MAA1B,IAA+BC,wBAA/B,IAA+BA;AAAAA,IAA7BF;AAAAA,IAAMC;AAAAA;;AAGR,QAAME,SAASH,QAAQA,KAAKI,SAAS,cAAcJ,KAAKK,QAAQF,SAAS;AACnEG,QAAAA,OAAOC,KAAAA,qBAAqBJ,0BAAU,IAAX;AACjC,QAAMK,aACJR,8BAAMI,UAAS,sBAAsBJ,YAAKK,QAAQI,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,kBAAaH,UAAD;AAI1BI,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AAEJ,MAAIf,MAAM;AACAA,YAAAA,KAAKI;AAAAA,WACN,aAAa;AAChB,YAAIE,MAAM;AACM,wBAAA;AAEdO,iBAAQ,IAAGP,KAAKU;AAAAA,QACjB;AAEQhB,iBAAAA,KAAKK,QAAQY,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,YAAY;AACD,sBAAA;AAEdJ,eAAOb,KAAKK,QAAQa;AAEXlB,iBAAAA,KAAKK,QAAQY,eA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A,YAAD,iCACMvC,cADN;AAAA,MAEE;AAAA,MACA;AAAA,MACA,SAASsB;AAAAA,MACT;AAAA,MAEA,gBAAgB;AAAA,IAAA,EARpB;AAAA,EAWD;AAGD,8EAActB;IAAa;AAAA,IAAU;AAAA,IAAY;AAAA,IAAgB,SAASsB;AAAAA,EAAAA,EAA1E;AACD,CA7H6B;;"}
package/dist/index.es.js CHANGED
@@ -38,20 +38,20 @@ var _c;
38
38
  import * as React from "react";
39
39
  import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useLayoutEffect, useCallback, Component, useImperativeHandle, Suspense } from "react";
40
40
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
41
- 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, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, c as createDocument, v as getReactComponent } from "./react-page.es.js";
42
- import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as restoreAPIResourcesCache, j as registerDocumentEffect, k as registerComponentHandleEffect, l as mountComponentEffect, n as registerComponentEffect, o as registerReactComponentEffect } from "./actions.es.js";
43
41
  import dynamic from "next/dynamic";
44
- import { KeyUtils } from "slate";
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, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, v as getReactComponent } from "./react-page.es.js";
43
+ import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as restoreAPIResourcesCache, j as registerComponentHandleEffect, k as mountComponentEffect, l as registerComponentEffect, n as registerReactComponentEffect } from "./actions.es.js";
44
+ import { cache, cx } from "@emotion/css";
45
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
45
46
  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, a as StyleControlType } from "./slot.es.js";
47
+ import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
48
+ import { C as ComboboxControlType } from "./combobox.es.js";
46
49
  import { S as ShapeControlType, L as ListControlType, b as LinkControlType } from "./control.es.js";
50
+ import { useSyncExternalStore } from "use-sync-external-store/shim";
51
+ import { KeyUtils } from "slate";
47
52
  import { createStore, applyMiddleware } from "redux";
48
53
  import thunk from "redux-thunk";
49
54
  import { A as APIResourceType } from "./types.es.js";
50
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
51
- import { cache, cx } from "@emotion/css";
52
- import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
53
- import { C as ComboboxControlType } from "./combobox.es.js";
54
- import { useSyncExternalStore } from "use-sync-external-store/shim";
55
55
  import ColorHelper from "color";
56
56
  import scrollIntoView from "scroll-into-view-if-needed";
57
57
  import { g as getBox } from "./box-models.es.js";
@@ -647,17 +647,17 @@ class MakeswiftClient {
647
647
  return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Snippet, snippetId);
648
648
  }
649
649
  }
650
- const Context$2 = createContext(new MakeswiftClient({
650
+ const Context$1 = createContext(new MakeswiftClient({
651
651
  uri: "https://api.makeswift.com/graphql"
652
652
  }));
653
653
  function useMakeswiftClient() {
654
- return useContext(Context$2);
654
+ return useContext(Context$1);
655
655
  }
656
656
  function MakeswiftProvider({
657
657
  client,
658
658
  children
659
659
  }) {
660
- return /* @__PURE__ */ jsx(Context$2.Provider, {
660
+ return /* @__PURE__ */ jsx(Context$1.Provider, {
661
661
  value: client,
662
662
  children
663
663
  });
@@ -929,10 +929,10 @@ Received "${apiKey}" instead.`);
929
929
  const json = await response.json();
930
930
  return json;
931
931
  }
932
- async createSnapshot(document2) {
932
+ async createSnapshot(document2, preview) {
933
933
  const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
934
934
  const cacheData = await client.prefetch(document2.data);
935
- return { document: document2, apiOrigin: this.apiOrigin.href, cacheData };
935
+ return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
936
936
  }
937
937
  async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
938
938
  const searchParams = new URLSearchParams({ preview: String(preview) });
@@ -943,7 +943,7 @@ Received "${apiKey}" instead.`);
943
943
  throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
944
944
  }
945
945
  const document2 = await response.json();
946
- return await this.createSnapshot(document2);
946
+ return await this.createSnapshot(document2, preview);
947
947
  }
948
948
  async getPageSnapshot(path, { preview } = {}) {
949
949
  const [page] = await this.getPages({ path });
@@ -1050,7 +1050,7 @@ class Document$1 extends NextDocument {
1050
1050
  });
1051
1051
  }
1052
1052
  }
1053
- const version = "0.4.2";
1053
+ const version = "0.5.0";
1054
1054
  function isErrorWithMessage(error) {
1055
1055
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1056
1056
  }
@@ -1068,7 +1068,7 @@ function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com",
1068
1068
  Received "${apiKey}" instead.`);
1069
1069
  }
1070
1070
  return async function makeswiftApiHandler(req, res) {
1071
- var _a, _b;
1071
+ var _a;
1072
1072
  await new Promise((resolve2, reject) => {
1073
1073
  cors(req, res, (err) => {
1074
1074
  if (err instanceof Error)
@@ -1100,7 +1100,7 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
1100
1100
  if (typeof req.query.path !== "string") {
1101
1101
  return res.status(400).json({ message: "Bad Request" });
1102
1102
  }
1103
- const revalidate = (_a = res.revalidate) != null ? _a : res.unstable_revalidate;
1103
+ const revalidate = res.revalidate;
1104
1104
  if (typeof revalidate !== "function") {
1105
1105
  const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
1106
1106
  Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
@@ -1147,7 +1147,7 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
1147
1147
  }));
1148
1148
  }
1149
1149
  case "fonts": {
1150
- const fonts = (_b = await (getFonts == null ? void 0 : getFonts())) != null ? _b : [];
1150
+ const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1151
1151
  return res.json(fonts);
1152
1152
  }
1153
1153
  case "element-tree": {
@@ -1294,6 +1294,7 @@ const Page = memo(({
1294
1294
  return /* @__PURE__ */ jsx(RuntimeProvider, {
1295
1295
  client,
1296
1296
  rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
1297
+ preview: snapshot.preview,
1297
1298
  children: /* @__PURE__ */ jsx(Page$1, {
1298
1299
  document: snapshot.document
1299
1300
  })
@@ -1838,11 +1839,11 @@ const Contrasts = Object.freeze({
1838
1839
  LIGHT: "light",
1839
1840
  DARK: "dark"
1840
1841
  });
1841
- const Context$1 = createContext({});
1842
+ const Context = createContext({});
1842
1843
  function useFormContext() {
1843
- return useContext(Context$1);
1844
+ return useContext(Context);
1844
1845
  }
1845
- const { Provider } = Context$1;
1846
+ const { Provider } = Context;
1846
1847
  function registerComponent$6(runtime) {
1847
1848
  return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Form.es.js")))), {
1848
1849
  type: MakeswiftComponentType.Form,
@@ -3726,47 +3727,16 @@ function createReactRuntime(store) {
3726
3727
  }
3727
3728
  const ReactRuntime = createReactRuntime(storeContextDefaultValue);
3728
3729
  registerBuiltinComponents(ReactRuntime);
3729
- const Context = createContext(storeContextDefaultValue);
3730
- function RuntimeProvider({
3731
- client,
3732
- children,
3733
- rootElements
3734
- }) {
3735
- const [store, setStore] = useState(() => {
3736
- const store2 = configureStore$1({
3737
- preloadedState: storeContextDefaultValue.getState(),
3738
- rootElements
3739
- });
3740
- return store2;
3741
- });
3742
- useEffect(() => {
3743
- var _a;
3744
- const unregisterDocuments = Array.from((_a = rootElements == null ? void 0 : rootElements.entries()) != null ? _a : []).map(([documentKey, rootElement]) => store.dispatch(registerDocumentEffect(createDocument(documentKey, rootElement))));
3745
- return () => {
3746
- unregisterDocuments.forEach((unregisterDocument) => {
3747
- unregisterDocument();
3748
- });
3749
- };
3750
- }, [store, rootElements]);
3751
- useEffect(() => {
3752
- const isInBuilder = window.parent !== window;
3753
- if (isInBuilder)
3754
- setReactBuilderPreviewStore();
3755
- async function setReactBuilderPreviewStore() {
3756
- const ReactBuilderPreview = await import("./react-builder-preview.es.js");
3757
- setStore((store2) => ReactBuilderPreview.configureStore({
3758
- preloadedState: store2.getState(),
3759
- client
3760
- }));
3761
- }
3762
- }, [client]);
3763
- return /* @__PURE__ */ jsx(Context.Provider, {
3764
- value: store,
3765
- children: /* @__PURE__ */ jsx(MakeswiftProvider, {
3766
- client,
3767
- children
3768
- })
3769
- });
3730
+ const StoreContext = createContext(storeContextDefaultValue);
3731
+ const PreviewProvider = dynamic(() => import("./PreviewProvider.es.js"));
3732
+ const LiveProvider = dynamic(() => import("./LiveProvider.es.js"));
3733
+ function RuntimeProvider(_j) {
3734
+ var _k = _j, {
3735
+ preview
3736
+ } = _k, props = __objRest(_k, [
3737
+ "preview"
3738
+ ]);
3739
+ return preview ? /* @__PURE__ */ jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsx(LiveProvider, __spreadValues({}, props));
3770
3740
  }
3771
3741
  const PageContext = createContext(null);
3772
3742
  function usePageIdOrNull() {
@@ -3792,7 +3762,7 @@ function useDocumentKey() {
3792
3762
  return useContext(DocumentContext);
3793
3763
  }
3794
3764
  function useStore() {
3795
- return useContext(Context);
3765
+ return useContext(StoreContext);
3796
3766
  }
3797
3767
  function useSelector(selector) {
3798
3768
  const store = useStore();
@@ -3812,7 +3782,7 @@ function useIsInBuilder() {
3812
3782
  return useSelector((state) => getIsInBuilder(state));
3813
3783
  }
3814
3784
  function useDispatch() {
3815
- const store = useContext(Context);
3785
+ const store = useContext(StoreContext);
3816
3786
  return store.dispatch;
3817
3787
  }
3818
3788
  const originalError = console.error;
@@ -3932,5 +3902,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
3932
3902
  document: document2
3933
3903
  });
3934
3904
  }));
3935
- export { PreviewModeScript as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, serializeStyles as H, insertStyles as I, useTypography as J, useSwatches as K, shallowMergeFallbacks as L, MakeswiftComponentType as M, useFiles as N, getDeviceMediaQuery as O, PageProvider as P, usePagePathnameSlice as Q, RuntimeProvider as R, Shapes as S, useElementId as T, deepEqual as U, MakeswiftClient as V, getStaticPaths as W, getStaticProps as X, getServerSideProps as Y, Page as Z, Makeswift as _, ReactRuntime as a, Document$1 as a0, MakeswiftApiHandler as a1, forwardNextDynamicRef as a2, 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, Page$1 as m, useStyle as n, responsiveWidth as o, responsiveTextStyle as p, colorToString as q, responsiveStyle as r, useIsomorphicLayoutEffect as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3905
+ export { getServerSideProps as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, serializeStyles as H, insertStyles as I, useTypography as J, useSwatches as K, shallowMergeFallbacks as L, MakeswiftComponentType as M, useFiles as N, getDeviceMediaQuery as O, PageProvider as P, usePagePathnameSlice as Q, RuntimeProvider as R, Shapes as S, useElementId as T, deepEqual as U, storeContextDefaultValue as V, StoreContext as W, MakeswiftProvider 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, forwardNextDynamicRef as a5, 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, Page$1 as m, useStyle as n, responsiveWidth as o, responsiveTextStyle as p, colorToString as q, responsiveStyle as r, useIsomorphicLayoutEffect as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3936
3906
  //# sourceMappingURL=index.es.js.map