@makeswift/runtime 0.0.10 → 0.0.13

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 (64) hide show
  1. package/dist/actions.cjs.js +6 -1
  2. package/dist/actions.cjs.js.map +1 -1
  3. package/dist/actions.es.js +6 -2
  4. package/dist/actions.es.js.map +1 -1
  5. package/dist/builder.cjs.js +2 -0
  6. package/dist/builder.cjs.js.map +1 -1
  7. package/dist/builder.es.js +1 -1
  8. package/dist/components.cjs.js +5 -5
  9. package/dist/components.es.js +3 -5
  10. package/dist/components.es.js.map +1 -1
  11. package/dist/constants.cjs.js +128 -1
  12. package/dist/constants.cjs.js.map +1 -1
  13. package/dist/constants.es.js +128 -1
  14. package/dist/constants.es.js.map +1 -1
  15. package/dist/control-serialization.cjs.js +11 -3
  16. package/dist/control-serialization.cjs.js.map +1 -1
  17. package/dist/control-serialization.es.js +10 -4
  18. package/dist/control-serialization.es.js.map +1 -1
  19. package/dist/index.cjs.js +394 -60
  20. package/dist/index.cjs.js.map +1 -1
  21. package/dist/index.es.js +387 -61
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/next.cjs.js +30 -19
  24. package/dist/next.cjs.js.map +1 -1
  25. package/dist/next.es.js +31 -20
  26. package/dist/next.es.js.map +1 -1
  27. package/dist/react-builder-preview.cjs.js +44 -45
  28. package/dist/react-builder-preview.cjs.js.map +1 -1
  29. package/dist/react-builder-preview.es.js +44 -45
  30. package/dist/react-builder-preview.es.js.map +1 -1
  31. package/dist/react.cjs.js +2 -3
  32. package/dist/react.cjs.js.map +1 -1
  33. package/dist/react.es.js +2 -3
  34. package/dist/react.es.js.map +1 -1
  35. package/dist/text-input.cjs.js.map +1 -1
  36. package/dist/text-input.es.js.map +1 -1
  37. package/dist/types/api/constants.d.ts.map +1 -1
  38. package/dist/types/api/generated/graphql.d.ts +55 -0
  39. package/dist/types/api/generated/graphql.d.ts.map +1 -1
  40. package/dist/types/api/react.d.ts +2 -3
  41. package/dist/types/api/react.d.ts.map +1 -1
  42. package/dist/types/api/types.d.ts +2 -2
  43. package/dist/types/api/types.d.ts.map +1 -1
  44. package/dist/types/builder/serialization/control-serialization.d.ts +2 -0
  45. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
  46. package/dist/types/builder/serialization/controls/list.d.ts.map +1 -1
  47. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  48. package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
  49. package/dist/types/components/page/Page.d.ts +23 -0
  50. package/dist/types/components/page/Page.d.ts.map +1 -1
  51. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  52. package/dist/types/controls/shape.d.ts +0 -1
  53. package/dist/types/controls/shape.d.ts.map +1 -1
  54. package/dist/types/next.d.ts +10 -5
  55. package/dist/types/next.d.ts.map +1 -1
  56. package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
  57. package/dist/types/state/actions.d.ts +13 -1
  58. package/dist/types/state/actions.d.ts.map +1 -1
  59. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  60. package/package.json +2 -1
  61. package/dist/Page.cjs.js +0 -222
  62. package/dist/Page.cjs.js.map +0 -1
  63. package/dist/Page.es.js +0 -216
  64. package/dist/Page.es.js.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -43,23 +43,22 @@ var actions = require("./actions.cjs.js");
43
43
  var styled = require("styled-components");
44
44
  var framerMotion = require("framer-motion");
45
45
  var css = require("@emotion/css");
46
- var ssr = require("@apollo/client/react/ssr");
47
- var slate = require("slate");
48
- var uuid = require("uuid/v4");
49
46
  var jsxRuntime = require("react/jsx-runtime");
50
- require("html-react-parser");
51
- require("next/head");
47
+ var parse = require("html-react-parser");
48
+ var Head = require("next/head");
52
49
  var descriptors = require("./descriptors.cjs.js");
53
50
  var ColorHelper = require("color");
54
51
  var scrollIntoView = require("scroll-into-view-if-needed");
55
52
  var NextLink = require("next/link");
56
53
  var reactUseGesture = require("react-use-gesture");
57
54
  var popcorn = require("@popmotion/popcorn");
55
+ var uuid = require("uuid/v4");
58
56
  var NextImage = require("next/image");
59
57
  var formik = require("formik");
60
58
  var boxModels = require("./box-models.cjs.js");
61
59
  var polished = require("polished");
62
60
  var ReactPlayer = require("react-player");
61
+ var slate = require("slate");
63
62
  var Hotkeys = require("slate-hotkeys");
64
63
  var ipsum = require("corporate-ipsum");
65
64
  var isHotkey = require("is-hotkey");
@@ -94,10 +93,12 @@ function _interopNamespace(e) {
94
93
  }
95
94
  var React__namespace = /* @__PURE__ */ _interopNamespace(React);
96
95
  var styled__default = /* @__PURE__ */ _interopDefaultLegacy(styled);
97
- var uuid__default = /* @__PURE__ */ _interopDefaultLegacy(uuid);
96
+ var parse__default = /* @__PURE__ */ _interopDefaultLegacy(parse);
97
+ var Head__default = /* @__PURE__ */ _interopDefaultLegacy(Head);
98
98
  var ColorHelper__default = /* @__PURE__ */ _interopDefaultLegacy(ColorHelper);
99
99
  var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
100
100
  var NextLink__default = /* @__PURE__ */ _interopDefaultLegacy(NextLink);
101
+ var uuid__default = /* @__PURE__ */ _interopDefaultLegacy(uuid);
101
102
  var NextImage__default = /* @__PURE__ */ _interopDefaultLegacy(NextImage);
102
103
  var ReactPlayer__default = /* @__PURE__ */ _interopDefaultLegacy(ReactPlayer);
103
104
  var Hotkeys__default = /* @__PURE__ */ _interopDefaultLegacy(Hotkeys);
@@ -318,13 +319,35 @@ const typePolicies = {
318
319
  __typename: "Table",
319
320
  id: args == null ? void 0 : args.id
320
321
  }, true);
322
+ },
323
+ page(existingData, {
324
+ args,
325
+ toReference
326
+ }) {
327
+ return existingData != null ? existingData : toReference({
328
+ __typename: "Page",
329
+ id: args == null ? void 0 : args.id
330
+ }, true);
331
+ },
332
+ site(existingData, {
333
+ args,
334
+ toReference
335
+ }) {
336
+ return existingData != null ? existingData : toReference({
337
+ __typename: "Site",
338
+ id: args == null ? void 0 : args.id
339
+ }, true);
321
340
  }
322
341
  }
323
342
  }
324
343
  };
325
- const PrefetchContext = React.createContext(false);
326
- function useIsPrefetching() {
327
- return React.useContext(PrefetchContext);
344
+ const isServer$1 = typeof window === "undefined";
345
+ let globalApolloClient = null;
346
+ function garbageCollectGlobalCacheData() {
347
+ globalApolloClient = null;
348
+ }
349
+ function getGlobalCacheData() {
350
+ return globalApolloClient == null ? void 0 : globalApolloClient.cache.extract();
328
351
  }
329
352
  function createApolloClient({
330
353
  uri,
@@ -337,7 +360,8 @@ function createApolloClient({
337
360
  cache.restore(cacheData);
338
361
  return new client.ApolloClient({
339
362
  uri,
340
- cache
363
+ cache,
364
+ ssrMode: isServer$1
341
365
  });
342
366
  }
343
367
  class MakeswiftClient {
@@ -346,25 +370,14 @@ class MakeswiftClient {
346
370
  cacheData
347
371
  }) {
348
372
  __publicField(this, "apolloClient");
349
- this.apolloClient = createApolloClient({
350
- uri,
351
- cacheData
352
- });
353
- }
354
- async prefetch(element) {
355
- const id = uuid__default["default"]();
356
- await ssr.getDataFromTree(/* @__PURE__ */ jsxRuntime.jsx(PrefetchContext.Provider, {
357
- value: true,
358
- children: /* @__PURE__ */ jsxRuntime.jsx(RuntimeProvider, {
359
- client: this,
360
- rootElements: /* @__PURE__ */ new Map([[id, element]]),
361
- children: /* @__PURE__ */ jsxRuntime.jsx(DocumentReference, {
362
- documentReference: reactPage.createDocumentReference(id)
363
- })
364
- })
365
- }));
366
- slate.KeyUtils.resetGenerator();
367
- return this.apolloClient.cache.extract();
373
+ if (globalApolloClient == null)
374
+ globalApolloClient = createApolloClient({
375
+ uri,
376
+ cacheData
377
+ });
378
+ else if (cacheData != null)
379
+ globalApolloClient.cache.restore(cacheData);
380
+ this.apolloClient = globalApolloClient;
368
381
  }
369
382
  updateCacheData(cacheData) {
370
383
  this.apolloClient.cache.restore(cacheData);
@@ -1383,9 +1396,6 @@ const BackgroundsContainer$1 = styled__default["default"](Container$c)`
1383
1396
  function Backgrounds({
1384
1397
  backgrounds
1385
1398
  }) {
1386
- const isPrefetching = useIsPrefetching();
1387
- if (isPrefetching)
1388
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1389
1399
  if (backgrounds == null)
1390
1400
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1391
1401
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
@@ -2170,7 +2180,8 @@ const Button$1 = React.forwardRef(function Button2(_m, ref) {
2170
2180
  color,
2171
2181
  textStyle,
2172
2182
  width,
2173
- margin
2183
+ margin,
2184
+ className
2174
2185
  } = _n, restOfProps = __objRest(_n, [
2175
2186
  "id",
2176
2187
  "children",
@@ -2182,12 +2193,13 @@ const Button$1 = React.forwardRef(function Button2(_m, ref) {
2182
2193
  "color",
2183
2194
  "textStyle",
2184
2195
  "width",
2185
- "margin"
2196
+ "margin",
2197
+ "className"
2186
2198
  ]);
2187
2199
  return /* @__PURE__ */ jsxRuntime.jsx(StyledButton$1, __spreadProps(__spreadValues({}, restOfProps), {
2188
2200
  ref,
2189
2201
  id,
2190
- className: css.cx(css.css(responsiveWidth(width, "auto"))),
2202
+ className: css.cx(css.css(responsiveWidth(width, "auto")), className),
2191
2203
  color,
2192
2204
  link,
2193
2205
  margin,
@@ -2363,7 +2375,6 @@ const ImageComponent = React.forwardRef(function Image2({
2363
2375
  const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder2.dimensions;
2364
2376
  const [measuredDimensions, setMeasuredDimensions] = React.useState(null);
2365
2377
  const isInBuilder = useIsInBuilder();
2366
- const isPrefetching = useIsPrefetching();
2367
2378
  React.useEffect(() => {
2368
2379
  if (dataDimensions)
2369
2380
  return;
@@ -2384,8 +2395,6 @@ const ImageComponent = React.forwardRef(function Image2({
2384
2395
  if (!dimensions)
2385
2396
  return null;
2386
2397
  const widthClass = css.css(responsiveWidth(width, `${dimensions.width}px`));
2387
- if (isPrefetching)
2388
- return null;
2389
2398
  return /* @__PURE__ */ jsxRuntime.jsx(ImageContainer, {
2390
2399
  as: link ? Link : "div",
2391
2400
  link,
@@ -2548,7 +2557,7 @@ const Reel = styled__default["default"](framerMotion.motion.div)`
2548
2557
  }
2549
2558
  `)}
2550
2559
  `;
2551
- const Page = styled__default["default"](framerMotion.motion.div)`
2560
+ const Page$1 = styled__default["default"](framerMotion.motion.div)`
2552
2561
  position: relative;
2553
2562
  width: 100%;
2554
2563
  `;
@@ -2761,7 +2770,7 @@ const Carousel = React.forwardRef(function Carousel2({
2761
2770
  },
2762
2771
  children: [/* @__PURE__ */ jsxRuntime.jsxs(Container$b, {
2763
2772
  children: [/* @__PURE__ */ jsxRuntime.jsx(ClipMask, {
2764
- children: /* @__PURE__ */ jsxRuntime.jsx(Page, __spreadProps(__spreadValues({}, bindPage()), {
2773
+ children: /* @__PURE__ */ jsxRuntime.jsx(Page$1, __spreadProps(__spreadValues({}, bindPage()), {
2765
2774
  animate: animation,
2766
2775
  children: /* @__PURE__ */ jsxRuntime.jsx(Reel, {
2767
2776
  gap,
@@ -3550,7 +3559,7 @@ const defaultHtml = `<div style="padding: 24px; background-color: rgba(161, 168,
3550
3559
  <rect y="160" width="40" height="8" rx="2" fill="#A1A8C2" fill-opacity="0.5"/>
3551
3560
  </svg>
3552
3561
  </div>`;
3553
- const SCRIPT_TAG = "script";
3562
+ const SCRIPT_TAG$1 = "script";
3554
3563
  const Embed = React.forwardRef(function Embed2({
3555
3564
  id,
3556
3565
  width,
@@ -3568,7 +3577,7 @@ const Embed = React.forwardRef(function Embed2({
3568
3577
  return;
3569
3578
  const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
3570
3579
  acceptNode(node) {
3571
- return node.tagName.toLowerCase() === SCRIPT_TAG ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
3580
+ return node.tagName.toLowerCase() === SCRIPT_TAG$1 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
3572
3581
  }
3573
3582
  });
3574
3583
  const nodes = [];
@@ -3579,7 +3588,7 @@ const Embed = React.forwardRef(function Embed2({
3579
3588
  await new Promise((resolve) => {
3580
3589
  var _a, _b;
3581
3590
  const node = nodes[i];
3582
- const script = node.ownerDocument.createElement(SCRIPT_TAG);
3591
+ const script = node.ownerDocument.createElement(SCRIPT_TAG$1);
3583
3592
  script.textContent = node.textContent;
3584
3593
  Array.from(node.attributes).forEach(({
3585
3594
  name,
@@ -4908,7 +4917,7 @@ function useTableFormFieldRefs(propController, { fieldsCount }) {
4908
4917
  }
4909
4918
  }, [propController, container, items, isInBuilder]);
4910
4919
  const itemRefs = React.useMemo(() => Array.from({ length: fieldsCount + 1 }).map((_, index) => (item) => {
4911
- setItems((is) => [...is.slice(0, index), item, ...is.slice(index + 1)]);
4920
+ setItems((is2) => [...is2.slice(0, index), item, ...is2.slice(index + 1)]);
4912
4921
  }), [fieldsCount, setItems]);
4913
4922
  return { container: setContainer, items: itemRefs };
4914
4923
  }
@@ -7835,6 +7844,325 @@ function registerBuiltinComponents(runtime) {
7835
7844
  unregisterVideoComponent();
7836
7845
  };
7837
7846
  }
7847
+ const SCRIPT_TAG = "script";
7848
+ function BodySnippet({
7849
+ code,
7850
+ cleanup
7851
+ }) {
7852
+ React.useEffect(() => {
7853
+ const container = document.createElement("div");
7854
+ container.innerHTML = code;
7855
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
7856
+ const scripts = [];
7857
+ while (walker.nextNode()) {
7858
+ if (walker.currentNode instanceof HTMLScriptElement)
7859
+ scripts.push(walker.currentNode);
7860
+ }
7861
+ scripts.forEach((inlineScript) => {
7862
+ var _a;
7863
+ const executableScript = document.createElement(SCRIPT_TAG);
7864
+ executableScript.textContent = inlineScript.textContent;
7865
+ Array.from(inlineScript.attributes).forEach(({
7866
+ name,
7867
+ value
7868
+ }) => {
7869
+ executableScript.setAttribute(name, value);
7870
+ });
7871
+ (_a = inlineScript.parentNode) == null ? void 0 : _a.replaceChild(executableScript, inlineScript);
7872
+ });
7873
+ const nodes = Array.from(container.childNodes);
7874
+ document.body.append(...nodes);
7875
+ return () => {
7876
+ nodes.forEach((node) => {
7877
+ var _a;
7878
+ (_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
7879
+ });
7880
+ if (cleanup == null)
7881
+ return;
7882
+ const cleanUp = new Function(cleanup);
7883
+ try {
7884
+ cleanUp();
7885
+ } catch {
7886
+ }
7887
+ };
7888
+ }, [code, cleanup]);
7889
+ return null;
7890
+ }
7891
+ function is(x, y) {
7892
+ if (x === y)
7893
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
7894
+ return x !== x && y !== y;
7895
+ }
7896
+ const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
7897
+ const shallowEqual = (a, b) => {
7898
+ if (is(a, b))
7899
+ return true;
7900
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
7901
+ return false;
7902
+ const keysA = Object.keys(a);
7903
+ const keysB = Object.keys(b);
7904
+ if (keysA.length !== keysB.length)
7905
+ return false;
7906
+ for (let i = 0; i < keysA.length; i += 1) {
7907
+ if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
7908
+ return false;
7909
+ }
7910
+ return true;
7911
+ };
7912
+ const { hasOwnProperty } = Object.prototype;
7913
+ const deepEqual = (a, b) => {
7914
+ if (shallowEqual(a, b))
7915
+ return true;
7916
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
7917
+ return false;
7918
+ const keysA = Object.keys(a);
7919
+ const keysB = Object.keys(b);
7920
+ if (keysA.length !== keysB.length)
7921
+ return false;
7922
+ for (let i = 0; i < keysA.length; i += 1) {
7923
+ if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
7924
+ return false;
7925
+ }
7926
+ return true;
7927
+ };
7928
+ const defaultFavicon = {
7929
+ mimetype: "image/png",
7930
+ publicUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAACXBIWXMAABcRAAAXEQHKJvM/AAABjElEQVRYhc2XzU3EMBCFB8TddAAXn6EE6GCpgNABZ1/IXnymBOgAOmA7YM8+ABVsXEHQQFaKQryeN3Yk3ilKJtEnv/nLUd/3pFG0riGi88yrnQn+UfJ5FUi0riWiB2H4nQn+KRd0DFP8agXEfkqCYJBoHdtxIQxfm+DfFgEhoith3NYE30o/qgGR2BJB+xY7kdYEL8oNFUi0jiFMJuxVWrJqEMFxsyUNCsE6AeNztvBp7aJ143vXksoRnwhYtmNdSoIQa6RlO9YXEWW7KgoCleOgxgTf1QZBT+RZ2lXFING6UxCCq+ceeUE8fYdknY599v9sJvzGBP+yCEgC7GPmETc0OJ+0awAlkhe2pAbIXAeFZ8xe2g2Nk3c3ub0xwWt6zY9qbmiqGVMbZK21ZC/YmhlbeBMTzZNDQqcvDb1kM1x32iqZSt1HaqukfKvq34BAOTLsrH+ETNmUkKHHA+428RgeclPVWozeSyAI2EdWB34jtqXNTAySOY3i/KgFIlqOa4GkFmBegorzg4joG07he/M7zl6jAAAAAElFTkSuQmCC"
7931
+ };
7932
+ const VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_.\-\d]*$/;
7933
+ const VALID_HEAD_ELEMENT_TYPES = ["title", "base", "link", "style", "meta", "script", "noscript", "template"];
7934
+ function snippetToElement(snippet) {
7935
+ return React.Children.map(parse__default["default"](snippet.code), (element) => {
7936
+ if (typeof element === "string")
7937
+ return element;
7938
+ if (!VALID_TAG_REGEX.test(element.type))
7939
+ return null;
7940
+ const key = element.key ? `${snippet.id}:${element.key}` : snippet.id;
7941
+ return React.createElement(element.type, __spreadProps(__spreadValues({}, element.props), {
7942
+ key
7943
+ }));
7944
+ });
7945
+ }
7946
+ const filterUsedSnippetProperties = ({
7947
+ code,
7948
+ builderEnabled,
7949
+ liveEnabled,
7950
+ location,
7951
+ cleanup
7952
+ }) => ({
7953
+ code,
7954
+ builderEnabled,
7955
+ liveEnabled,
7956
+ location,
7957
+ cleanup
7958
+ });
7959
+ const PAGE_SNIPPETS_QUERY = client.gql`
7960
+ query PageById($id: ID!) {
7961
+ page(id: $id) {
7962
+ __typename
7963
+ id
7964
+ snippets {
7965
+ __typename
7966
+ id
7967
+ name
7968
+ code
7969
+ cleanup
7970
+ location
7971
+ shouldAddToNewPages
7972
+ liveEnabled
7973
+ builderEnabled
7974
+ }
7975
+ }
7976
+ }
7977
+ `;
7978
+ const SITE_FONTS_QUERY = client.gql`
7979
+ query SiteById($id: ID!) {
7980
+ site(id: $id) {
7981
+ id
7982
+ googleFonts {
7983
+ edges {
7984
+ activeVariants {
7985
+ specifier
7986
+ }
7987
+ node {
7988
+ family
7989
+ variants {
7990
+ specifier
7991
+ }
7992
+ }
7993
+ }
7994
+ }
7995
+ }
7996
+ }
7997
+ `;
7998
+ function Page({
7999
+ page,
8000
+ preview = false
8001
+ }) {
8002
+ var _a;
8003
+ const isInBuilder = useIsInBuilder();
8004
+ const [snippets, setSnippets] = React.useState(page.snippets);
8005
+ useQuery(PAGE_SNIPPETS_QUERY, {
8006
+ variables: {
8007
+ id: page.id
8008
+ },
8009
+ skip: isInBuilder === false,
8010
+ fetchPolicy: "cache-only",
8011
+ onCompleted(data) {
8012
+ if (data == null)
8013
+ return;
8014
+ const oldSnippets = snippets.map(filterUsedSnippetProperties);
8015
+ const newSnippets = data.page.snippets.map(filterUsedSnippetProperties);
8016
+ if (deepEqual(newSnippets, oldSnippets))
8017
+ return;
8018
+ setSnippets(data.page.snippets);
8019
+ }
8020
+ });
8021
+ const {
8022
+ data: siteData
8023
+ } = useQuery(SITE_FONTS_QUERY, {
8024
+ variables: {
8025
+ id: page.site.id
8026
+ },
8027
+ skip: isInBuilder === false,
8028
+ fetchPolicy: "cache-only"
8029
+ });
8030
+ const favicon = (_a = page.meta.favicon) != null ? _a : defaultFavicon;
8031
+ const {
8032
+ title,
8033
+ description,
8034
+ keywords,
8035
+ socialImage
8036
+ } = page.meta;
8037
+ const {
8038
+ canonicalUrl,
8039
+ isIndexingBlocked
8040
+ } = page.seo;
8041
+ const fontFamilyParamValue = React.useMemo(() => {
8042
+ if ((siteData == null ? void 0 : siteData.site) == null) {
8043
+ return page.fonts.map(({
8044
+ family,
8045
+ variants
8046
+ }) => {
8047
+ return `${family.replace(/ /g, "+")}:${variants.join()}`;
8048
+ }).join("|");
8049
+ }
8050
+ return siteData.site.googleFonts.edges.filter((edge) => edge != null).map(({
8051
+ activeVariants,
8052
+ node: {
8053
+ family,
8054
+ variants
8055
+ }
8056
+ }) => {
8057
+ const activeVariantSpecifiers = variants.filter((variant) => activeVariants.some((activeVariant) => activeVariant.specifier === variant.specifier)).map((variant) => variant.specifier).join();
8058
+ return `${family.replace(/ /g, "+")}:${activeVariantSpecifiers}`;
8059
+ }).join("|");
8060
+ }, [siteData, page]);
8061
+ const filteredSnippets = React.useMemo(() => snippets.filter((snippet) => preview ? snippet.builderEnabled : snippet.liveEnabled), [snippets]);
8062
+ const headSnippets = React.useMemo(() => filteredSnippets.filter((snippet) => snippet.location === "HEAD"), [filteredSnippets]);
8063
+ const previousHeadSnippets = React.useRef(null);
8064
+ React.useEffect(() => {
8065
+ var _a2;
8066
+ const headSnippetsToCleanUp = ((_a2 = previousHeadSnippets.current) != null ? _a2 : []).filter((previousSnippet) => previousSnippet.cleanup != null).filter((previousSnippet) => !headSnippets.some((snippet) => previousSnippet.id === snippet.id));
8067
+ headSnippetsToCleanUp.forEach((snippetToCleanUp) => {
8068
+ if (snippetToCleanUp.cleanup == null)
8069
+ return;
8070
+ const cleanUp = new Function(snippetToCleanUp.cleanup);
8071
+ try {
8072
+ cleanUp();
8073
+ } catch {
8074
+ }
8075
+ });
8076
+ previousHeadSnippets.current = headSnippets;
8077
+ }, [headSnippets]);
8078
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
8079
+ children: [/* @__PURE__ */ jsxRuntime.jsxs(Head__default["default"], {
8080
+ children: [/* @__PURE__ */ jsxRuntime.jsx("style", {
8081
+ children: `
8082
+ html {
8083
+ font-family: sans-serif;
8084
+ }
8085
+ div#__next {
8086
+ overflow: hidden;
8087
+ }
8088
+ `
8089
+ }), /* @__PURE__ */ jsxRuntime.jsx("link", {
8090
+ rel: "icon",
8091
+ type: favicon.mimetype,
8092
+ href: favicon.publicUrl
8093
+ }), canonicalUrl && /* @__PURE__ */ jsxRuntime.jsx("link", {
8094
+ rel: "canonical",
8095
+ href: canonicalUrl
8096
+ }), isIndexingBlocked && /* @__PURE__ */ jsxRuntime.jsx("meta", {
8097
+ name: "robots",
8098
+ content: "noindex"
8099
+ }), title && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
8100
+ children: [/* @__PURE__ */ jsxRuntime.jsx("title", {
8101
+ children: title
8102
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8103
+ property: "og:title",
8104
+ content: title
8105
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8106
+ name: "twitter:title",
8107
+ content: title
8108
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8109
+ itemProp: "name",
8110
+ content: title
8111
+ })]
8112
+ }), description && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
8113
+ children: [/* @__PURE__ */ jsxRuntime.jsx("meta", {
8114
+ name: "description",
8115
+ content: description
8116
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8117
+ property: "og:description",
8118
+ content: description
8119
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8120
+ name: "twitter:description",
8121
+ content: description
8122
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8123
+ itemProp: "description",
8124
+ content: description
8125
+ })]
8126
+ }), keywords && /* @__PURE__ */ jsxRuntime.jsx("meta", {
8127
+ name: "keywords",
8128
+ content: keywords
8129
+ }), socialImage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
8130
+ children: [/* @__PURE__ */ jsxRuntime.jsx("meta", {
8131
+ property: "og:image",
8132
+ content: socialImage.publicUrl
8133
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8134
+ property: "og:image:type",
8135
+ content: socialImage.publicUrl
8136
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8137
+ name: "twitter:image",
8138
+ content: socialImage.publicUrl
8139
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8140
+ name: "twitter:card",
8141
+ content: socialImage.publicUrl
8142
+ }), /* @__PURE__ */ jsxRuntime.jsx("meta", {
8143
+ itemProp: "image",
8144
+ content: socialImage.publicUrl
8145
+ })]
8146
+ }), fontFamilyParamValue !== "" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
8147
+ children: /* @__PURE__ */ jsxRuntime.jsx("link", {
8148
+ rel: "stylesheet",
8149
+ href: `https://fonts.googleapis.com/css?family=${fontFamilyParamValue}&display=swap`
8150
+ })
8151
+ }), headSnippets.map(snippetToElement).map((children) => React.Children.map(children, (child) => {
8152
+ if (typeof child === "string")
8153
+ return child;
8154
+ if (VALID_HEAD_ELEMENT_TYPES.includes(child.type))
8155
+ return child;
8156
+ return null;
8157
+ }))]
8158
+ }), /* @__PURE__ */ jsxRuntime.jsx(DocumentReference, {
8159
+ documentReference: reactPage.createDocumentReference(page.id)
8160
+ }), filteredSnippets.filter((snippet) => snippet.location === "BODY").map((snippet) => /* @__PURE__ */ jsxRuntime.jsx(BodySnippet, {
8161
+ code: snippet.code,
8162
+ cleanup: snippet.cleanup
8163
+ }, snippet.id))]
8164
+ });
8165
+ }
7838
8166
  var _path;
7839
8167
  function _extends() {
7840
8168
  _extends = Object.assign || function(target) {
@@ -8211,8 +8539,11 @@ function useStyleControlCssObject(style$1, controlDefinition) {
8211
8539
  }
8212
8540
  const useInsertionEffectSpecifier = "useInsertionEffect";
8213
8541
  const useInsertionEffect = (_ea = React__namespace[useInsertionEffectSpecifier]) != null ? _ea : React__namespace.useLayoutEffect;
8542
+ const isServer = typeof window === "undefined";
8214
8543
  function useFormattedStyle(styleControlData, controlDefinition) {
8215
8544
  const style2 = useStyleControlCssObject(styleControlData, controlDefinition);
8545
+ if (isServer)
8546
+ return css.css(style2);
8216
8547
  const serialized = serializeStyles([style2], css.cache.registered);
8217
8548
  useInsertionEffect(() => {
8218
8549
  insertStyles(css.cache, serialized, false);
@@ -8276,7 +8607,7 @@ function ShapeControlValue({
8276
8607
  data,
8277
8608
  children
8278
8609
  }) {
8279
- return Object.entries(definition.config.type).reduce((renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsxRuntime.jsx(ControlValue, {
8610
+ return Object.entries(definition.config.type).reduceRight((renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsxRuntime.jsx(ControlValue, {
8280
8611
  definition: controlDefinition,
8281
8612
  data: data == null ? void 0 : data[key],
8282
8613
  children: (value) => renderFn(__spreadProps(__spreadValues({}, shapeControlValue), {
@@ -8422,11 +8753,9 @@ function PropsValue({
8422
8753
  function suppressWarningAndFindDomNode(instance) {
8423
8754
  const error = console.error;
8424
8755
  console.error = (...args) => {
8425
- const [msg, ...substitutions] = args;
8426
- const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
8427
- if (!text.includes("findDOMNode is deprecated in StrictMode.")) {
8428
- error.apply(console, args);
8429
- }
8756
+ if (typeof args[0] === "string" && args[0].includes("%s is deprecated in StrictMode."))
8757
+ return;
8758
+ return error.apply(console, args);
8430
8759
  };
8431
8760
  const foundDomNode = reactDom.findDOMNode(instance);
8432
8761
  console.error = error;
@@ -8586,11 +8915,10 @@ function useSuppressRefWarning(ownerName) {
8586
8915
  const patchedRef = React.useRef(false);
8587
8916
  if (patchedRef.current === false) {
8588
8917
  console.error = (...args) => {
8589
- const [msg, ...substitutions] = args;
8590
- const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
8591
- if (!text.includes("Function components cannot be given refs.") || !text.includes(`Check the render method of \`${ownerName}\`.`)) {
8592
- originalErrorRef.current(...args);
8918
+ if (typeof args[0] === "string" && args[0].includes("Function components cannot be given refs.") && args[0].includes(`Check the render method of \`${ownerName}\`.`)) {
8919
+ return;
8593
8920
  }
8921
+ return originalErrorRef.current(...args);
8594
8922
  };
8595
8923
  patchedRef.current = true;
8596
8924
  }
@@ -8693,21 +9021,21 @@ const Element$1 = React.memo(React.forwardRef(function Element2({
8693
9021
  }, elementKey);
8694
9022
  }));
8695
9023
  const Document = React.memo(React.forwardRef(function Document2({
8696
- document
9024
+ document: document2
8697
9025
  }, ref) {
8698
9026
  return /* @__PURE__ */ jsxRuntime.jsx(DocumentContext.Provider, {
8699
- value: document.key,
9027
+ value: document2.key,
8700
9028
  children: /* @__PURE__ */ jsxRuntime.jsx(Element$1, {
8701
9029
  ref,
8702
- element: document.rootElement
9030
+ element: document2.rootElement
8703
9031
  })
8704
9032
  });
8705
9033
  }));
8706
9034
  const DocumentReference = React.memo(React.forwardRef(function DocumentReference2({
8707
9035
  documentReference
8708
9036
  }, ref) {
8709
- const document = useDocument(documentReference.key);
8710
- if (document == null) {
9037
+ const document2 = useDocument(documentReference.key);
9038
+ if (document2 == null) {
8711
9039
  return /* @__PURE__ */ jsxRuntime.jsx(FallbackComponent, {
8712
9040
  ref,
8713
9041
  text: "Document not found"
@@ -8715,7 +9043,7 @@ const DocumentReference = React.memo(React.forwardRef(function DocumentReference
8715
9043
  }
8716
9044
  return /* @__PURE__ */ jsxRuntime.jsx(Document, {
8717
9045
  ref,
8718
- document
9046
+ document: document2
8719
9047
  });
8720
9048
  }));
8721
9049
  exports.Box = Box;
@@ -8737,10 +9065,13 @@ exports.Form = Form;
8737
9065
  exports.ImageComponent = ImageComponent;
8738
9066
  exports.MakeswiftClient = MakeswiftClient;
8739
9067
  exports.Navigation = Navigation;
9068
+ exports.PAGE_SNIPPETS_QUERY = PAGE_SNIPPETS_QUERY;
9069
+ exports.Page = Page;
8740
9070
  exports.PageProvider = PageProvider;
8741
9071
  exports.ReactRuntime = ReactRuntime;
8742
9072
  exports.Root = Root;
8743
9073
  exports.RuntimeProvider = RuntimeProvider;
9074
+ exports.SITE_FONTS_QUERY = SITE_FONTS_QUERY;
8744
9075
  exports.SocialLinks = SocialLinks;
8745
9076
  exports.Text = Text;
8746
9077
  exports.cssBorder = cssBorder;
@@ -8752,6 +9083,9 @@ exports.cssMediaRules = cssMediaRules;
8752
9083
  exports.cssPadding = cssPadding;
8753
9084
  exports.cssTextStyle = cssTextStyle;
8754
9085
  exports.cssWidth = cssWidth;
9086
+ exports.deepEqual = deepEqual;
9087
+ exports.garbageCollectGlobalCacheData = garbageCollectGlobalCacheData;
9088
+ exports.getGlobalCacheData = getGlobalCacheData;
8755
9089
  exports.registerBuiltinComponents = registerBuiltinComponents;
8756
9090
  exports.registerComponent = registerComponent$c;
8757
9091
  exports.useBackgrounds = useBackgrounds;