@makeswift/runtime 0.0.11 → 0.0.15
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.
- package/dist/actions.cjs.js +6 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +6 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/components.cjs.js +5 -5
- package/dist/components.es.js +3 -5
- package/dist/components.es.js.map +1 -1
- package/dist/constants.cjs.js +128 -1
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +128 -1
- package/dist/constants.es.js.map +1 -1
- package/dist/index.cjs.js +383 -47
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +376 -48
- package/dist/index.es.js.map +1 -1
- package/dist/next.cjs.js +30 -19
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +31 -20
- package/dist/next.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +44 -45
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +43 -44
- package/dist/react-builder-preview.es.js.map +1 -1
- package/dist/react.cjs.js +2 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +2 -3
- package/dist/react.es.js.map +1 -1
- package/dist/types/api/constants.d.ts.map +1 -1
- package/dist/types/api/generated/graphql.d.ts +55 -0
- package/dist/types/api/generated/graphql.d.ts.map +1 -1
- package/dist/types/api/react.d.ts +2 -3
- package/dist/types/api/react.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +2 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/page/Page.d.ts +23 -0
- package/dist/types/components/page/Page.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/next.d.ts +10 -5
- package/dist/types/next.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
- package/dist/types/state/actions.d.ts +13 -1
- package/dist/types/state/actions.d.ts.map +1 -1
- package/dist/types/state/react-builder-preview.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/Page.cjs.js +0 -222
- package/dist/Page.cjs.js.map +0 -1
- package/dist/Page.es.js +0 -216
- package/dist/Page.es.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -43,23 +43,22 @@ import { f as registerComponentHandleEffect, g as mountComponentEffect, h as reg
|
|
|
43
43
|
import styled, { css, keyframes, createGlobalStyle } from "styled-components";
|
|
44
44
|
import { useReducedMotion, useAnimation, motion } from "framer-motion";
|
|
45
45
|
import { cx, css as css$1, cache } from "@emotion/css";
|
|
46
|
-
import { getDataFromTree } from "@apollo/client/react/ssr";
|
|
47
|
-
import { KeyUtils, Value } from "slate";
|
|
48
|
-
import uuid from "uuid/v4";
|
|
49
46
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
50
|
-
import "html-react-parser";
|
|
51
|
-
import "next/head";
|
|
47
|
+
import parse$1 from "html-react-parser";
|
|
48
|
+
import Head from "next/head";
|
|
52
49
|
import { E as ElementID, B as Backgrounds$1, W as Width, R as ResponsiveIconRadioGroup, M as Margin, P as Padding, a as Border, b as BorderRadius, S as Shadows, G as GapY, c as GapX, e as ResponsiveSelect, f as ResponsiveNumber, C as Checkbox$1, g as Grid$2, h as TextInput, L as Link$1, i as ResponsiveColor, j as TextStyle, I as Image$1, k as ResponsiveOpacity, l as Images, N as Number$1, D as Date$1, F as Font, m as ResponsiveLength, n as TextArea$1, o as Table, p as TableFormFields, q as NavigationLinks, r as SocialLinks$1, s as RichText, V as Video$1, T as Types, t as WidthControlValueFormats } from "./descriptors.es.js";
|
|
53
50
|
import ColorHelper from "color";
|
|
54
51
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
55
52
|
import NextLink from "next/link";
|
|
56
53
|
import { useGesture } from "react-use-gesture";
|
|
57
54
|
import { wrap } from "@popmotion/popcorn";
|
|
55
|
+
import uuid from "uuid/v4";
|
|
58
56
|
import NextImage from "next/image";
|
|
59
57
|
import { Field as Field$1, getIn, Formik } from "formik";
|
|
60
58
|
import { p as parse, c as createBox, g as getBox } from "./box-models.es.js";
|
|
61
59
|
import { normalize } from "polished";
|
|
62
60
|
import ReactPlayer from "react-player";
|
|
61
|
+
import { Value } from "slate";
|
|
63
62
|
import Hotkeys from "slate-hotkeys";
|
|
64
63
|
import ipsum from "corporate-ipsum";
|
|
65
64
|
import { isHotkey } from "is-hotkey";
|
|
@@ -284,13 +283,35 @@ const typePolicies = {
|
|
|
284
283
|
__typename: "Table",
|
|
285
284
|
id: args == null ? void 0 : args.id
|
|
286
285
|
}, true);
|
|
286
|
+
},
|
|
287
|
+
page(existingData, {
|
|
288
|
+
args,
|
|
289
|
+
toReference
|
|
290
|
+
}) {
|
|
291
|
+
return existingData != null ? existingData : toReference({
|
|
292
|
+
__typename: "Page",
|
|
293
|
+
id: args == null ? void 0 : args.id
|
|
294
|
+
}, true);
|
|
295
|
+
},
|
|
296
|
+
site(existingData, {
|
|
297
|
+
args,
|
|
298
|
+
toReference
|
|
299
|
+
}) {
|
|
300
|
+
return existingData != null ? existingData : toReference({
|
|
301
|
+
__typename: "Site",
|
|
302
|
+
id: args == null ? void 0 : args.id
|
|
303
|
+
}, true);
|
|
287
304
|
}
|
|
288
305
|
}
|
|
289
306
|
}
|
|
290
307
|
};
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
308
|
+
const isServer$1 = typeof window === "undefined";
|
|
309
|
+
let globalApolloClient = null;
|
|
310
|
+
function garbageCollectGlobalCacheData() {
|
|
311
|
+
globalApolloClient = null;
|
|
312
|
+
}
|
|
313
|
+
function getGlobalCacheData() {
|
|
314
|
+
return globalApolloClient == null ? void 0 : globalApolloClient.cache.extract();
|
|
294
315
|
}
|
|
295
316
|
function createApolloClient({
|
|
296
317
|
uri,
|
|
@@ -303,7 +324,8 @@ function createApolloClient({
|
|
|
303
324
|
cache2.restore(cacheData);
|
|
304
325
|
return new ApolloClient({
|
|
305
326
|
uri,
|
|
306
|
-
cache: cache2
|
|
327
|
+
cache: cache2,
|
|
328
|
+
ssrMode: isServer$1
|
|
307
329
|
});
|
|
308
330
|
}
|
|
309
331
|
class MakeswiftClient {
|
|
@@ -312,25 +334,14 @@ class MakeswiftClient {
|
|
|
312
334
|
cacheData
|
|
313
335
|
}) {
|
|
314
336
|
__publicField(this, "apolloClient");
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
value: true,
|
|
324
|
-
children: /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
325
|
-
client: this,
|
|
326
|
-
rootElements: /* @__PURE__ */ new Map([[id, element]]),
|
|
327
|
-
children: /* @__PURE__ */ jsx(DocumentReference, {
|
|
328
|
-
documentReference: createDocumentReference(id)
|
|
329
|
-
})
|
|
330
|
-
})
|
|
331
|
-
}));
|
|
332
|
-
KeyUtils.resetGenerator();
|
|
333
|
-
return this.apolloClient.cache.extract();
|
|
337
|
+
if (globalApolloClient == null)
|
|
338
|
+
globalApolloClient = createApolloClient({
|
|
339
|
+
uri,
|
|
340
|
+
cacheData
|
|
341
|
+
});
|
|
342
|
+
else if (cacheData != null)
|
|
343
|
+
globalApolloClient.cache.restore(cacheData);
|
|
344
|
+
this.apolloClient = globalApolloClient;
|
|
334
345
|
}
|
|
335
346
|
updateCacheData(cacheData) {
|
|
336
347
|
this.apolloClient.cache.restore(cacheData);
|
|
@@ -1349,9 +1360,6 @@ const BackgroundsContainer$1 = styled(Container$c)`
|
|
|
1349
1360
|
function Backgrounds({
|
|
1350
1361
|
backgrounds
|
|
1351
1362
|
}) {
|
|
1352
|
-
const isPrefetching = useIsPrefetching();
|
|
1353
|
-
if (isPrefetching)
|
|
1354
|
-
return /* @__PURE__ */ jsx(Fragment, {});
|
|
1355
1363
|
if (backgrounds == null)
|
|
1356
1364
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
1357
1365
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
@@ -2331,7 +2339,6 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
2331
2339
|
const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder2.dimensions;
|
|
2332
2340
|
const [measuredDimensions, setMeasuredDimensions] = useState(null);
|
|
2333
2341
|
const isInBuilder = useIsInBuilder();
|
|
2334
|
-
const isPrefetching = useIsPrefetching();
|
|
2335
2342
|
useEffect(() => {
|
|
2336
2343
|
if (dataDimensions)
|
|
2337
2344
|
return;
|
|
@@ -2352,8 +2359,6 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
2352
2359
|
if (!dimensions)
|
|
2353
2360
|
return null;
|
|
2354
2361
|
const widthClass = css$1(responsiveWidth(width, `${dimensions.width}px`));
|
|
2355
|
-
if (isPrefetching)
|
|
2356
|
-
return null;
|
|
2357
2362
|
return /* @__PURE__ */ jsx(ImageContainer, {
|
|
2358
2363
|
as: link ? Link : "div",
|
|
2359
2364
|
link,
|
|
@@ -2516,7 +2521,7 @@ const Reel = styled(motion.div)`
|
|
|
2516
2521
|
}
|
|
2517
2522
|
`)}
|
|
2518
2523
|
`;
|
|
2519
|
-
const Page = styled(motion.div)`
|
|
2524
|
+
const Page$1 = styled(motion.div)`
|
|
2520
2525
|
position: relative;
|
|
2521
2526
|
width: 100%;
|
|
2522
2527
|
`;
|
|
@@ -2729,7 +2734,7 @@ const Carousel = forwardRef(function Carousel2({
|
|
|
2729
2734
|
},
|
|
2730
2735
|
children: [/* @__PURE__ */ jsxs(Container$b, {
|
|
2731
2736
|
children: [/* @__PURE__ */ jsx(ClipMask, {
|
|
2732
|
-
children: /* @__PURE__ */ jsx(Page, __spreadProps(__spreadValues({}, bindPage()), {
|
|
2737
|
+
children: /* @__PURE__ */ jsx(Page$1, __spreadProps(__spreadValues({}, bindPage()), {
|
|
2733
2738
|
animate: animation,
|
|
2734
2739
|
children: /* @__PURE__ */ jsx(Reel, {
|
|
2735
2740
|
gap,
|
|
@@ -3518,7 +3523,7 @@ const defaultHtml = `<div style="padding: 24px; background-color: rgba(161, 168,
|
|
|
3518
3523
|
<rect y="160" width="40" height="8" rx="2" fill="#A1A8C2" fill-opacity="0.5"/>
|
|
3519
3524
|
</svg>
|
|
3520
3525
|
</div>`;
|
|
3521
|
-
const SCRIPT_TAG = "script";
|
|
3526
|
+
const SCRIPT_TAG$1 = "script";
|
|
3522
3527
|
const Embed = forwardRef(function Embed2({
|
|
3523
3528
|
id,
|
|
3524
3529
|
width,
|
|
@@ -3536,7 +3541,7 @@ const Embed = forwardRef(function Embed2({
|
|
|
3536
3541
|
return;
|
|
3537
3542
|
const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
3538
3543
|
acceptNode(node) {
|
|
3539
|
-
return node.tagName.toLowerCase() === SCRIPT_TAG ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
3544
|
+
return node.tagName.toLowerCase() === SCRIPT_TAG$1 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
3540
3545
|
}
|
|
3541
3546
|
});
|
|
3542
3547
|
const nodes = [];
|
|
@@ -3547,7 +3552,7 @@ const Embed = forwardRef(function Embed2({
|
|
|
3547
3552
|
await new Promise((resolve) => {
|
|
3548
3553
|
var _a, _b;
|
|
3549
3554
|
const node = nodes[i];
|
|
3550
|
-
const script = node.ownerDocument.createElement(SCRIPT_TAG);
|
|
3555
|
+
const script = node.ownerDocument.createElement(SCRIPT_TAG$1);
|
|
3551
3556
|
script.textContent = node.textContent;
|
|
3552
3557
|
Array.from(node.attributes).forEach(({
|
|
3553
3558
|
name,
|
|
@@ -4876,7 +4881,7 @@ function useTableFormFieldRefs(propController, { fieldsCount }) {
|
|
|
4876
4881
|
}
|
|
4877
4882
|
}, [propController, container, items, isInBuilder]);
|
|
4878
4883
|
const itemRefs = useMemo(() => Array.from({ length: fieldsCount + 1 }).map((_, index) => (item) => {
|
|
4879
|
-
setItems((
|
|
4884
|
+
setItems((is2) => [...is2.slice(0, index), item, ...is2.slice(index + 1)]);
|
|
4880
4885
|
}), [fieldsCount, setItems]);
|
|
4881
4886
|
return { container: setContainer, items: itemRefs };
|
|
4882
4887
|
}
|
|
@@ -5600,6 +5605,7 @@ const StyledDropDownItem = styled(Link)`
|
|
|
5600
5605
|
color: black;
|
|
5601
5606
|
background-color: transparent;
|
|
5602
5607
|
transition: background-color 0.2s;
|
|
5608
|
+
${cssTextStyle()}
|
|
5603
5609
|
${(p) => cssMediaRules([p.color, p.textStyle], ([color, textStyle = {}]) => {
|
|
5604
5610
|
const fontSize = textStyle.fontSize || {
|
|
5605
5611
|
value: 14,
|
|
@@ -6202,7 +6208,7 @@ const GridItem = styled.div`
|
|
|
6202
6208
|
align-items: flex-start;
|
|
6203
6209
|
${cssGridItem()}
|
|
6204
6210
|
`;
|
|
6205
|
-
const Root = forwardRef(function
|
|
6211
|
+
const Root = forwardRef(function Page({
|
|
6206
6212
|
children,
|
|
6207
6213
|
backgrounds,
|
|
6208
6214
|
rowGap,
|
|
@@ -7803,6 +7809,325 @@ function registerBuiltinComponents(runtime) {
|
|
|
7803
7809
|
unregisterVideoComponent();
|
|
7804
7810
|
};
|
|
7805
7811
|
}
|
|
7812
|
+
const SCRIPT_TAG = "script";
|
|
7813
|
+
function BodySnippet({
|
|
7814
|
+
code,
|
|
7815
|
+
cleanup
|
|
7816
|
+
}) {
|
|
7817
|
+
useEffect(() => {
|
|
7818
|
+
const container = document.createElement("div");
|
|
7819
|
+
container.innerHTML = code;
|
|
7820
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
7821
|
+
const scripts = [];
|
|
7822
|
+
while (walker.nextNode()) {
|
|
7823
|
+
if (walker.currentNode instanceof HTMLScriptElement)
|
|
7824
|
+
scripts.push(walker.currentNode);
|
|
7825
|
+
}
|
|
7826
|
+
scripts.forEach((inlineScript) => {
|
|
7827
|
+
var _a;
|
|
7828
|
+
const executableScript = document.createElement(SCRIPT_TAG);
|
|
7829
|
+
executableScript.textContent = inlineScript.textContent;
|
|
7830
|
+
Array.from(inlineScript.attributes).forEach(({
|
|
7831
|
+
name,
|
|
7832
|
+
value
|
|
7833
|
+
}) => {
|
|
7834
|
+
executableScript.setAttribute(name, value);
|
|
7835
|
+
});
|
|
7836
|
+
(_a = inlineScript.parentNode) == null ? void 0 : _a.replaceChild(executableScript, inlineScript);
|
|
7837
|
+
});
|
|
7838
|
+
const nodes = Array.from(container.childNodes);
|
|
7839
|
+
document.body.append(...nodes);
|
|
7840
|
+
return () => {
|
|
7841
|
+
nodes.forEach((node) => {
|
|
7842
|
+
var _a;
|
|
7843
|
+
(_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
|
|
7844
|
+
});
|
|
7845
|
+
if (cleanup == null)
|
|
7846
|
+
return;
|
|
7847
|
+
const cleanUp = new Function(cleanup);
|
|
7848
|
+
try {
|
|
7849
|
+
cleanUp();
|
|
7850
|
+
} catch {
|
|
7851
|
+
}
|
|
7852
|
+
};
|
|
7853
|
+
}, [code, cleanup]);
|
|
7854
|
+
return null;
|
|
7855
|
+
}
|
|
7856
|
+
function is(x, y) {
|
|
7857
|
+
if (x === y)
|
|
7858
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
7859
|
+
return x !== x && y !== y;
|
|
7860
|
+
}
|
|
7861
|
+
const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
|
|
7862
|
+
const shallowEqual = (a, b) => {
|
|
7863
|
+
if (is(a, b))
|
|
7864
|
+
return true;
|
|
7865
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
7866
|
+
return false;
|
|
7867
|
+
const keysA = Object.keys(a);
|
|
7868
|
+
const keysB = Object.keys(b);
|
|
7869
|
+
if (keysA.length !== keysB.length)
|
|
7870
|
+
return false;
|
|
7871
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
7872
|
+
if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
|
|
7873
|
+
return false;
|
|
7874
|
+
}
|
|
7875
|
+
return true;
|
|
7876
|
+
};
|
|
7877
|
+
const { hasOwnProperty } = Object.prototype;
|
|
7878
|
+
const deepEqual = (a, b) => {
|
|
7879
|
+
if (shallowEqual(a, b))
|
|
7880
|
+
return true;
|
|
7881
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
7882
|
+
return false;
|
|
7883
|
+
const keysA = Object.keys(a);
|
|
7884
|
+
const keysB = Object.keys(b);
|
|
7885
|
+
if (keysA.length !== keysB.length)
|
|
7886
|
+
return false;
|
|
7887
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
7888
|
+
if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
|
|
7889
|
+
return false;
|
|
7890
|
+
}
|
|
7891
|
+
return true;
|
|
7892
|
+
};
|
|
7893
|
+
const defaultFavicon = {
|
|
7894
|
+
mimetype: "image/png",
|
|
7895
|
+
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"
|
|
7896
|
+
};
|
|
7897
|
+
const VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_.\-\d]*$/;
|
|
7898
|
+
const VALID_HEAD_ELEMENT_TYPES = ["title", "base", "link", "style", "meta", "script", "noscript", "template"];
|
|
7899
|
+
function snippetToElement(snippet) {
|
|
7900
|
+
return Children.map(parse$1(snippet.code), (element) => {
|
|
7901
|
+
if (typeof element === "string")
|
|
7902
|
+
return element;
|
|
7903
|
+
if (!VALID_TAG_REGEX.test(element.type))
|
|
7904
|
+
return null;
|
|
7905
|
+
const key = element.key ? `${snippet.id}:${element.key}` : snippet.id;
|
|
7906
|
+
return createElement(element.type, __spreadProps(__spreadValues({}, element.props), {
|
|
7907
|
+
key
|
|
7908
|
+
}));
|
|
7909
|
+
});
|
|
7910
|
+
}
|
|
7911
|
+
const filterUsedSnippetProperties = ({
|
|
7912
|
+
code,
|
|
7913
|
+
builderEnabled,
|
|
7914
|
+
liveEnabled,
|
|
7915
|
+
location,
|
|
7916
|
+
cleanup
|
|
7917
|
+
}) => ({
|
|
7918
|
+
code,
|
|
7919
|
+
builderEnabled,
|
|
7920
|
+
liveEnabled,
|
|
7921
|
+
location,
|
|
7922
|
+
cleanup
|
|
7923
|
+
});
|
|
7924
|
+
const PAGE_SNIPPETS_QUERY = gql`
|
|
7925
|
+
query PageById($id: ID!) {
|
|
7926
|
+
page(id: $id) {
|
|
7927
|
+
__typename
|
|
7928
|
+
id
|
|
7929
|
+
snippets {
|
|
7930
|
+
__typename
|
|
7931
|
+
id
|
|
7932
|
+
name
|
|
7933
|
+
code
|
|
7934
|
+
cleanup
|
|
7935
|
+
location
|
|
7936
|
+
shouldAddToNewPages
|
|
7937
|
+
liveEnabled
|
|
7938
|
+
builderEnabled
|
|
7939
|
+
}
|
|
7940
|
+
}
|
|
7941
|
+
}
|
|
7942
|
+
`;
|
|
7943
|
+
const SITE_FONTS_QUERY = gql`
|
|
7944
|
+
query SiteById($id: ID!) {
|
|
7945
|
+
site(id: $id) {
|
|
7946
|
+
id
|
|
7947
|
+
googleFonts {
|
|
7948
|
+
edges {
|
|
7949
|
+
activeVariants {
|
|
7950
|
+
specifier
|
|
7951
|
+
}
|
|
7952
|
+
node {
|
|
7953
|
+
family
|
|
7954
|
+
variants {
|
|
7955
|
+
specifier
|
|
7956
|
+
}
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
}
|
|
7962
|
+
`;
|
|
7963
|
+
function Page2({
|
|
7964
|
+
page,
|
|
7965
|
+
preview = false
|
|
7966
|
+
}) {
|
|
7967
|
+
var _a;
|
|
7968
|
+
const isInBuilder = useIsInBuilder();
|
|
7969
|
+
const [snippets, setSnippets] = useState(page.snippets);
|
|
7970
|
+
useQuery(PAGE_SNIPPETS_QUERY, {
|
|
7971
|
+
variables: {
|
|
7972
|
+
id: page.id
|
|
7973
|
+
},
|
|
7974
|
+
skip: isInBuilder === false,
|
|
7975
|
+
fetchPolicy: "cache-only",
|
|
7976
|
+
onCompleted(data) {
|
|
7977
|
+
if (data == null)
|
|
7978
|
+
return;
|
|
7979
|
+
const oldSnippets = snippets.map(filterUsedSnippetProperties);
|
|
7980
|
+
const newSnippets = data.page.snippets.map(filterUsedSnippetProperties);
|
|
7981
|
+
if (deepEqual(newSnippets, oldSnippets))
|
|
7982
|
+
return;
|
|
7983
|
+
setSnippets(data.page.snippets);
|
|
7984
|
+
}
|
|
7985
|
+
});
|
|
7986
|
+
const {
|
|
7987
|
+
data: siteData
|
|
7988
|
+
} = useQuery(SITE_FONTS_QUERY, {
|
|
7989
|
+
variables: {
|
|
7990
|
+
id: page.site.id
|
|
7991
|
+
},
|
|
7992
|
+
skip: isInBuilder === false,
|
|
7993
|
+
fetchPolicy: "cache-only"
|
|
7994
|
+
});
|
|
7995
|
+
const favicon = (_a = page.meta.favicon) != null ? _a : defaultFavicon;
|
|
7996
|
+
const {
|
|
7997
|
+
title,
|
|
7998
|
+
description,
|
|
7999
|
+
keywords,
|
|
8000
|
+
socialImage
|
|
8001
|
+
} = page.meta;
|
|
8002
|
+
const {
|
|
8003
|
+
canonicalUrl,
|
|
8004
|
+
isIndexingBlocked
|
|
8005
|
+
} = page.seo;
|
|
8006
|
+
const fontFamilyParamValue = useMemo(() => {
|
|
8007
|
+
if ((siteData == null ? void 0 : siteData.site) == null) {
|
|
8008
|
+
return page.fonts.map(({
|
|
8009
|
+
family,
|
|
8010
|
+
variants
|
|
8011
|
+
}) => {
|
|
8012
|
+
return `${family.replace(/ /g, "+")}:${variants.join()}`;
|
|
8013
|
+
}).join("|");
|
|
8014
|
+
}
|
|
8015
|
+
return siteData.site.googleFonts.edges.filter((edge) => edge != null).map(({
|
|
8016
|
+
activeVariants,
|
|
8017
|
+
node: {
|
|
8018
|
+
family,
|
|
8019
|
+
variants
|
|
8020
|
+
}
|
|
8021
|
+
}) => {
|
|
8022
|
+
const activeVariantSpecifiers = variants.filter((variant) => activeVariants.some((activeVariant) => activeVariant.specifier === variant.specifier)).map((variant) => variant.specifier).join();
|
|
8023
|
+
return `${family.replace(/ /g, "+")}:${activeVariantSpecifiers}`;
|
|
8024
|
+
}).join("|");
|
|
8025
|
+
}, [siteData, page]);
|
|
8026
|
+
const filteredSnippets = useMemo(() => snippets.filter((snippet) => preview ? snippet.builderEnabled : snippet.liveEnabled), [snippets]);
|
|
8027
|
+
const headSnippets = useMemo(() => filteredSnippets.filter((snippet) => snippet.location === "HEAD"), [filteredSnippets]);
|
|
8028
|
+
const previousHeadSnippets = useRef(null);
|
|
8029
|
+
useEffect(() => {
|
|
8030
|
+
var _a2;
|
|
8031
|
+
const headSnippetsToCleanUp = ((_a2 = previousHeadSnippets.current) != null ? _a2 : []).filter((previousSnippet) => previousSnippet.cleanup != null).filter((previousSnippet) => !headSnippets.some((snippet) => previousSnippet.id === snippet.id));
|
|
8032
|
+
headSnippetsToCleanUp.forEach((snippetToCleanUp) => {
|
|
8033
|
+
if (snippetToCleanUp.cleanup == null)
|
|
8034
|
+
return;
|
|
8035
|
+
const cleanUp = new Function(snippetToCleanUp.cleanup);
|
|
8036
|
+
try {
|
|
8037
|
+
cleanUp();
|
|
8038
|
+
} catch {
|
|
8039
|
+
}
|
|
8040
|
+
});
|
|
8041
|
+
previousHeadSnippets.current = headSnippets;
|
|
8042
|
+
}, [headSnippets]);
|
|
8043
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
8044
|
+
children: [/* @__PURE__ */ jsxs(Head, {
|
|
8045
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
8046
|
+
children: `
|
|
8047
|
+
html {
|
|
8048
|
+
font-family: sans-serif;
|
|
8049
|
+
}
|
|
8050
|
+
div#__next {
|
|
8051
|
+
overflow: hidden;
|
|
8052
|
+
}
|
|
8053
|
+
`
|
|
8054
|
+
}), /* @__PURE__ */ jsx("link", {
|
|
8055
|
+
rel: "icon",
|
|
8056
|
+
type: favicon.mimetype,
|
|
8057
|
+
href: favicon.publicUrl
|
|
8058
|
+
}), canonicalUrl && /* @__PURE__ */ jsx("link", {
|
|
8059
|
+
rel: "canonical",
|
|
8060
|
+
href: canonicalUrl
|
|
8061
|
+
}), isIndexingBlocked && /* @__PURE__ */ jsx("meta", {
|
|
8062
|
+
name: "robots",
|
|
8063
|
+
content: "noindex"
|
|
8064
|
+
}), title && /* @__PURE__ */ jsxs(Fragment, {
|
|
8065
|
+
children: [/* @__PURE__ */ jsx("title", {
|
|
8066
|
+
children: title
|
|
8067
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8068
|
+
property: "og:title",
|
|
8069
|
+
content: title
|
|
8070
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8071
|
+
name: "twitter:title",
|
|
8072
|
+
content: title
|
|
8073
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8074
|
+
itemProp: "name",
|
|
8075
|
+
content: title
|
|
8076
|
+
})]
|
|
8077
|
+
}), description && /* @__PURE__ */ jsxs(Fragment, {
|
|
8078
|
+
children: [/* @__PURE__ */ jsx("meta", {
|
|
8079
|
+
name: "description",
|
|
8080
|
+
content: description
|
|
8081
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8082
|
+
property: "og:description",
|
|
8083
|
+
content: description
|
|
8084
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8085
|
+
name: "twitter:description",
|
|
8086
|
+
content: description
|
|
8087
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8088
|
+
itemProp: "description",
|
|
8089
|
+
content: description
|
|
8090
|
+
})]
|
|
8091
|
+
}), keywords && /* @__PURE__ */ jsx("meta", {
|
|
8092
|
+
name: "keywords",
|
|
8093
|
+
content: keywords
|
|
8094
|
+
}), socialImage && /* @__PURE__ */ jsxs(Fragment, {
|
|
8095
|
+
children: [/* @__PURE__ */ jsx("meta", {
|
|
8096
|
+
property: "og:image",
|
|
8097
|
+
content: socialImage.publicUrl
|
|
8098
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8099
|
+
property: "og:image:type",
|
|
8100
|
+
content: socialImage.publicUrl
|
|
8101
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8102
|
+
name: "twitter:image",
|
|
8103
|
+
content: socialImage.publicUrl
|
|
8104
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8105
|
+
name: "twitter:card",
|
|
8106
|
+
content: socialImage.publicUrl
|
|
8107
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8108
|
+
itemProp: "image",
|
|
8109
|
+
content: socialImage.publicUrl
|
|
8110
|
+
})]
|
|
8111
|
+
}), fontFamilyParamValue !== "" && /* @__PURE__ */ jsx(Fragment, {
|
|
8112
|
+
children: /* @__PURE__ */ jsx("link", {
|
|
8113
|
+
rel: "stylesheet",
|
|
8114
|
+
href: `https://fonts.googleapis.com/css?family=${fontFamilyParamValue}&display=swap`
|
|
8115
|
+
})
|
|
8116
|
+
}), headSnippets.map(snippetToElement).map((children) => Children.map(children, (child) => {
|
|
8117
|
+
if (typeof child === "string")
|
|
8118
|
+
return child;
|
|
8119
|
+
if (VALID_HEAD_ELEMENT_TYPES.includes(child.type))
|
|
8120
|
+
return child;
|
|
8121
|
+
return null;
|
|
8122
|
+
}))]
|
|
8123
|
+
}), /* @__PURE__ */ jsx(DocumentReference, {
|
|
8124
|
+
documentReference: createDocumentReference(page.id)
|
|
8125
|
+
}), filteredSnippets.filter((snippet) => snippet.location === "BODY").map((snippet) => /* @__PURE__ */ jsx(BodySnippet, {
|
|
8126
|
+
code: snippet.code,
|
|
8127
|
+
cleanup: snippet.cleanup
|
|
8128
|
+
}, snippet.id))]
|
|
8129
|
+
});
|
|
8130
|
+
}
|
|
7806
8131
|
var _path;
|
|
7807
8132
|
function _extends() {
|
|
7808
8133
|
_extends = Object.assign || function(target) {
|
|
@@ -8179,8 +8504,11 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
8179
8504
|
}
|
|
8180
8505
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
8181
8506
|
const useInsertionEffect = (_ea = React[useInsertionEffectSpecifier]) != null ? _ea : React.useLayoutEffect;
|
|
8507
|
+
const isServer = typeof window === "undefined";
|
|
8182
8508
|
function useFormattedStyle(styleControlData, controlDefinition) {
|
|
8183
8509
|
const style = useStyleControlCssObject(styleControlData, controlDefinition);
|
|
8510
|
+
if (isServer)
|
|
8511
|
+
return css$1(style);
|
|
8184
8512
|
const serialized = serializeStyles([style], cache.registered);
|
|
8185
8513
|
useInsertionEffect(() => {
|
|
8186
8514
|
insertStyles(cache, serialized, false);
|
|
@@ -8656,21 +8984,21 @@ const Element$1 = memo(forwardRef(function Element2({
|
|
|
8656
8984
|
}, elementKey);
|
|
8657
8985
|
}));
|
|
8658
8986
|
const Document = memo(forwardRef(function Document2({
|
|
8659
|
-
document
|
|
8987
|
+
document: document2
|
|
8660
8988
|
}, ref) {
|
|
8661
8989
|
return /* @__PURE__ */ jsx(DocumentContext.Provider, {
|
|
8662
|
-
value:
|
|
8990
|
+
value: document2.key,
|
|
8663
8991
|
children: /* @__PURE__ */ jsx(Element$1, {
|
|
8664
8992
|
ref,
|
|
8665
|
-
element:
|
|
8993
|
+
element: document2.rootElement
|
|
8666
8994
|
})
|
|
8667
8995
|
});
|
|
8668
8996
|
}));
|
|
8669
8997
|
const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
8670
8998
|
documentReference
|
|
8671
8999
|
}, ref) {
|
|
8672
|
-
const
|
|
8673
|
-
if (
|
|
9000
|
+
const document2 = useDocument(documentReference.key);
|
|
9001
|
+
if (document2 == null) {
|
|
8674
9002
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
8675
9003
|
ref,
|
|
8676
9004
|
text: "Document not found"
|
|
@@ -8678,8 +9006,8 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
8678
9006
|
}
|
|
8679
9007
|
return /* @__PURE__ */ jsx(Document, {
|
|
8680
9008
|
ref,
|
|
8681
|
-
document
|
|
9009
|
+
document: document2
|
|
8682
9010
|
});
|
|
8683
9011
|
}));
|
|
8684
|
-
export { useBackgrounds as A, Box as B, Carousel as C, DocumentReference as D, Element$1 as E, Form as F, useBorder as G, useBoxShadow as H, ImageComponent as I, useResponsiveColor as J, useFile as K, useMediaQuery as L, usePage as M, Navigation as N, useTable as O, PageProvider as P,
|
|
9012
|
+
export { useBackgrounds as A, Box as B, Carousel as C, DocumentReference as D, Element$1 as E, Form as F, useBorder as G, useBoxShadow as H, ImageComponent as I, useResponsiveColor as J, useFile as K, useMediaQuery as L, usePage as M, Navigation as N, useTable as O, PageProvider as P, PAGE_SNIPPETS_QUERY as Q, RuntimeProvider as R, SocialLinks as S, Text as T, SITE_FONTS_QUERY as U, Page2 as V, garbageCollectGlobalCacheData as W, getGlobalCacheData as X, MakeswiftClient as Y, deepEqual as Z, ReactRuntime as a, usePageId as b, Button$1 as c, Countdown as d, Divider as e, Embed as f, Root as g, registerComponent$c as h, DEFAULT_BOX_ANIMATE_TYPE as i, DEFAULT_BOX_ANIMATE_DELAY as j, DEFAULT_BOX_ANIMATE_DURATION as k, DEFAULT_ITEM_ANIMATE_TYPE as l, DEFAULT_ITEM_ANIMATE_DELAY as m, DEFAULT_ITEM_ANIMATE_DURATION as n, DEFAULT_ITEM_STAGGER_DURATION as o, cssMediaRules as p, cssWidth as q, registerBuiltinComponents as r, cssMargin as s, cssPadding as t, useIsInBuilder as u, cssBorder as v, cssBorderRadius as w, cssBoxShadow as x, cssGridItem as y, cssTextStyle as z };
|
|
8685
9013
|
//# sourceMappingURL=index.es.js.map
|