@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.
- 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/builder.cjs.js +2 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +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/control-serialization.cjs.js +11 -3
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +10 -4
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/index.cjs.js +394 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +387 -61
- 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 +44 -45
- 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/text-input.cjs.js.map +1 -1
- package/dist/text-input.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/builder/serialization/control-serialization.d.ts +2 -0
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/builder/serialization/controls/list.d.ts.map +1 -1
- package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
- package/dist/types/components/builtin/Image/Image.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/controls/shape.d.ts +0 -1
- package/dist/types/controls/shape.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, {
|
|
@@ -2136,7 +2144,8 @@ const Button$1 = forwardRef(function Button2(_m, ref) {
|
|
|
2136
2144
|
color,
|
|
2137
2145
|
textStyle,
|
|
2138
2146
|
width,
|
|
2139
|
-
margin
|
|
2147
|
+
margin,
|
|
2148
|
+
className
|
|
2140
2149
|
} = _n, restOfProps = __objRest(_n, [
|
|
2141
2150
|
"id",
|
|
2142
2151
|
"children",
|
|
@@ -2148,12 +2157,13 @@ const Button$1 = forwardRef(function Button2(_m, ref) {
|
|
|
2148
2157
|
"color",
|
|
2149
2158
|
"textStyle",
|
|
2150
2159
|
"width",
|
|
2151
|
-
"margin"
|
|
2160
|
+
"margin",
|
|
2161
|
+
"className"
|
|
2152
2162
|
]);
|
|
2153
2163
|
return /* @__PURE__ */ jsx(StyledButton$1, __spreadProps(__spreadValues({}, restOfProps), {
|
|
2154
2164
|
ref,
|
|
2155
2165
|
id,
|
|
2156
|
-
className: cx(css$1(responsiveWidth(width, "auto"))),
|
|
2166
|
+
className: cx(css$1(responsiveWidth(width, "auto")), className),
|
|
2157
2167
|
color,
|
|
2158
2168
|
link,
|
|
2159
2169
|
margin,
|
|
@@ -2329,7 +2339,6 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
2329
2339
|
const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder2.dimensions;
|
|
2330
2340
|
const [measuredDimensions, setMeasuredDimensions] = useState(null);
|
|
2331
2341
|
const isInBuilder = useIsInBuilder();
|
|
2332
|
-
const isPrefetching = useIsPrefetching();
|
|
2333
2342
|
useEffect(() => {
|
|
2334
2343
|
if (dataDimensions)
|
|
2335
2344
|
return;
|
|
@@ -2350,8 +2359,6 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
2350
2359
|
if (!dimensions)
|
|
2351
2360
|
return null;
|
|
2352
2361
|
const widthClass = css$1(responsiveWidth(width, `${dimensions.width}px`));
|
|
2353
|
-
if (isPrefetching)
|
|
2354
|
-
return null;
|
|
2355
2362
|
return /* @__PURE__ */ jsx(ImageContainer, {
|
|
2356
2363
|
as: link ? Link : "div",
|
|
2357
2364
|
link,
|
|
@@ -2514,7 +2521,7 @@ const Reel = styled(motion.div)`
|
|
|
2514
2521
|
}
|
|
2515
2522
|
`)}
|
|
2516
2523
|
`;
|
|
2517
|
-
const Page = styled(motion.div)`
|
|
2524
|
+
const Page$1 = styled(motion.div)`
|
|
2518
2525
|
position: relative;
|
|
2519
2526
|
width: 100%;
|
|
2520
2527
|
`;
|
|
@@ -2727,7 +2734,7 @@ const Carousel = forwardRef(function Carousel2({
|
|
|
2727
2734
|
},
|
|
2728
2735
|
children: [/* @__PURE__ */ jsxs(Container$b, {
|
|
2729
2736
|
children: [/* @__PURE__ */ jsx(ClipMask, {
|
|
2730
|
-
children: /* @__PURE__ */ jsx(Page, __spreadProps(__spreadValues({}, bindPage()), {
|
|
2737
|
+
children: /* @__PURE__ */ jsx(Page$1, __spreadProps(__spreadValues({}, bindPage()), {
|
|
2731
2738
|
animate: animation,
|
|
2732
2739
|
children: /* @__PURE__ */ jsx(Reel, {
|
|
2733
2740
|
gap,
|
|
@@ -3516,7 +3523,7 @@ const defaultHtml = `<div style="padding: 24px; background-color: rgba(161, 168,
|
|
|
3516
3523
|
<rect y="160" width="40" height="8" rx="2" fill="#A1A8C2" fill-opacity="0.5"/>
|
|
3517
3524
|
</svg>
|
|
3518
3525
|
</div>`;
|
|
3519
|
-
const SCRIPT_TAG = "script";
|
|
3526
|
+
const SCRIPT_TAG$1 = "script";
|
|
3520
3527
|
const Embed = forwardRef(function Embed2({
|
|
3521
3528
|
id,
|
|
3522
3529
|
width,
|
|
@@ -3534,7 +3541,7 @@ const Embed = forwardRef(function Embed2({
|
|
|
3534
3541
|
return;
|
|
3535
3542
|
const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
3536
3543
|
acceptNode(node) {
|
|
3537
|
-
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;
|
|
3538
3545
|
}
|
|
3539
3546
|
});
|
|
3540
3547
|
const nodes = [];
|
|
@@ -3545,7 +3552,7 @@ const Embed = forwardRef(function Embed2({
|
|
|
3545
3552
|
await new Promise((resolve) => {
|
|
3546
3553
|
var _a, _b;
|
|
3547
3554
|
const node = nodes[i];
|
|
3548
|
-
const script = node.ownerDocument.createElement(SCRIPT_TAG);
|
|
3555
|
+
const script = node.ownerDocument.createElement(SCRIPT_TAG$1);
|
|
3549
3556
|
script.textContent = node.textContent;
|
|
3550
3557
|
Array.from(node.attributes).forEach(({
|
|
3551
3558
|
name,
|
|
@@ -4874,7 +4881,7 @@ function useTableFormFieldRefs(propController, { fieldsCount }) {
|
|
|
4874
4881
|
}
|
|
4875
4882
|
}, [propController, container, items, isInBuilder]);
|
|
4876
4883
|
const itemRefs = useMemo(() => Array.from({ length: fieldsCount + 1 }).map((_, index) => (item) => {
|
|
4877
|
-
setItems((
|
|
4884
|
+
setItems((is2) => [...is2.slice(0, index), item, ...is2.slice(index + 1)]);
|
|
4878
4885
|
}), [fieldsCount, setItems]);
|
|
4879
4886
|
return { container: setContainer, items: itemRefs };
|
|
4880
4887
|
}
|
|
@@ -6200,7 +6207,7 @@ const GridItem = styled.div`
|
|
|
6200
6207
|
align-items: flex-start;
|
|
6201
6208
|
${cssGridItem()}
|
|
6202
6209
|
`;
|
|
6203
|
-
const Root = forwardRef(function
|
|
6210
|
+
const Root = forwardRef(function Page({
|
|
6204
6211
|
children,
|
|
6205
6212
|
backgrounds,
|
|
6206
6213
|
rowGap,
|
|
@@ -7801,6 +7808,325 @@ function registerBuiltinComponents(runtime) {
|
|
|
7801
7808
|
unregisterVideoComponent();
|
|
7802
7809
|
};
|
|
7803
7810
|
}
|
|
7811
|
+
const SCRIPT_TAG = "script";
|
|
7812
|
+
function BodySnippet({
|
|
7813
|
+
code,
|
|
7814
|
+
cleanup
|
|
7815
|
+
}) {
|
|
7816
|
+
useEffect(() => {
|
|
7817
|
+
const container = document.createElement("div");
|
|
7818
|
+
container.innerHTML = code;
|
|
7819
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
7820
|
+
const scripts = [];
|
|
7821
|
+
while (walker.nextNode()) {
|
|
7822
|
+
if (walker.currentNode instanceof HTMLScriptElement)
|
|
7823
|
+
scripts.push(walker.currentNode);
|
|
7824
|
+
}
|
|
7825
|
+
scripts.forEach((inlineScript) => {
|
|
7826
|
+
var _a;
|
|
7827
|
+
const executableScript = document.createElement(SCRIPT_TAG);
|
|
7828
|
+
executableScript.textContent = inlineScript.textContent;
|
|
7829
|
+
Array.from(inlineScript.attributes).forEach(({
|
|
7830
|
+
name,
|
|
7831
|
+
value
|
|
7832
|
+
}) => {
|
|
7833
|
+
executableScript.setAttribute(name, value);
|
|
7834
|
+
});
|
|
7835
|
+
(_a = inlineScript.parentNode) == null ? void 0 : _a.replaceChild(executableScript, inlineScript);
|
|
7836
|
+
});
|
|
7837
|
+
const nodes = Array.from(container.childNodes);
|
|
7838
|
+
document.body.append(...nodes);
|
|
7839
|
+
return () => {
|
|
7840
|
+
nodes.forEach((node) => {
|
|
7841
|
+
var _a;
|
|
7842
|
+
(_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
|
|
7843
|
+
});
|
|
7844
|
+
if (cleanup == null)
|
|
7845
|
+
return;
|
|
7846
|
+
const cleanUp = new Function(cleanup);
|
|
7847
|
+
try {
|
|
7848
|
+
cleanUp();
|
|
7849
|
+
} catch {
|
|
7850
|
+
}
|
|
7851
|
+
};
|
|
7852
|
+
}, [code, cleanup]);
|
|
7853
|
+
return null;
|
|
7854
|
+
}
|
|
7855
|
+
function is(x, y) {
|
|
7856
|
+
if (x === y)
|
|
7857
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
7858
|
+
return x !== x && y !== y;
|
|
7859
|
+
}
|
|
7860
|
+
const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
|
|
7861
|
+
const shallowEqual = (a, b) => {
|
|
7862
|
+
if (is(a, b))
|
|
7863
|
+
return true;
|
|
7864
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
7865
|
+
return false;
|
|
7866
|
+
const keysA = Object.keys(a);
|
|
7867
|
+
const keysB = Object.keys(b);
|
|
7868
|
+
if (keysA.length !== keysB.length)
|
|
7869
|
+
return false;
|
|
7870
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
7871
|
+
if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
|
|
7872
|
+
return false;
|
|
7873
|
+
}
|
|
7874
|
+
return true;
|
|
7875
|
+
};
|
|
7876
|
+
const { hasOwnProperty } = Object.prototype;
|
|
7877
|
+
const deepEqual = (a, b) => {
|
|
7878
|
+
if (shallowEqual(a, b))
|
|
7879
|
+
return true;
|
|
7880
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
7881
|
+
return false;
|
|
7882
|
+
const keysA = Object.keys(a);
|
|
7883
|
+
const keysB = Object.keys(b);
|
|
7884
|
+
if (keysA.length !== keysB.length)
|
|
7885
|
+
return false;
|
|
7886
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
7887
|
+
if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
|
|
7888
|
+
return false;
|
|
7889
|
+
}
|
|
7890
|
+
return true;
|
|
7891
|
+
};
|
|
7892
|
+
const defaultFavicon = {
|
|
7893
|
+
mimetype: "image/png",
|
|
7894
|
+
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"
|
|
7895
|
+
};
|
|
7896
|
+
const VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_.\-\d]*$/;
|
|
7897
|
+
const VALID_HEAD_ELEMENT_TYPES = ["title", "base", "link", "style", "meta", "script", "noscript", "template"];
|
|
7898
|
+
function snippetToElement(snippet) {
|
|
7899
|
+
return Children.map(parse$1(snippet.code), (element) => {
|
|
7900
|
+
if (typeof element === "string")
|
|
7901
|
+
return element;
|
|
7902
|
+
if (!VALID_TAG_REGEX.test(element.type))
|
|
7903
|
+
return null;
|
|
7904
|
+
const key = element.key ? `${snippet.id}:${element.key}` : snippet.id;
|
|
7905
|
+
return createElement(element.type, __spreadProps(__spreadValues({}, element.props), {
|
|
7906
|
+
key
|
|
7907
|
+
}));
|
|
7908
|
+
});
|
|
7909
|
+
}
|
|
7910
|
+
const filterUsedSnippetProperties = ({
|
|
7911
|
+
code,
|
|
7912
|
+
builderEnabled,
|
|
7913
|
+
liveEnabled,
|
|
7914
|
+
location,
|
|
7915
|
+
cleanup
|
|
7916
|
+
}) => ({
|
|
7917
|
+
code,
|
|
7918
|
+
builderEnabled,
|
|
7919
|
+
liveEnabled,
|
|
7920
|
+
location,
|
|
7921
|
+
cleanup
|
|
7922
|
+
});
|
|
7923
|
+
const PAGE_SNIPPETS_QUERY = gql`
|
|
7924
|
+
query PageById($id: ID!) {
|
|
7925
|
+
page(id: $id) {
|
|
7926
|
+
__typename
|
|
7927
|
+
id
|
|
7928
|
+
snippets {
|
|
7929
|
+
__typename
|
|
7930
|
+
id
|
|
7931
|
+
name
|
|
7932
|
+
code
|
|
7933
|
+
cleanup
|
|
7934
|
+
location
|
|
7935
|
+
shouldAddToNewPages
|
|
7936
|
+
liveEnabled
|
|
7937
|
+
builderEnabled
|
|
7938
|
+
}
|
|
7939
|
+
}
|
|
7940
|
+
}
|
|
7941
|
+
`;
|
|
7942
|
+
const SITE_FONTS_QUERY = gql`
|
|
7943
|
+
query SiteById($id: ID!) {
|
|
7944
|
+
site(id: $id) {
|
|
7945
|
+
id
|
|
7946
|
+
googleFonts {
|
|
7947
|
+
edges {
|
|
7948
|
+
activeVariants {
|
|
7949
|
+
specifier
|
|
7950
|
+
}
|
|
7951
|
+
node {
|
|
7952
|
+
family
|
|
7953
|
+
variants {
|
|
7954
|
+
specifier
|
|
7955
|
+
}
|
|
7956
|
+
}
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
`;
|
|
7962
|
+
function Page2({
|
|
7963
|
+
page,
|
|
7964
|
+
preview = false
|
|
7965
|
+
}) {
|
|
7966
|
+
var _a;
|
|
7967
|
+
const isInBuilder = useIsInBuilder();
|
|
7968
|
+
const [snippets, setSnippets] = useState(page.snippets);
|
|
7969
|
+
useQuery(PAGE_SNIPPETS_QUERY, {
|
|
7970
|
+
variables: {
|
|
7971
|
+
id: page.id
|
|
7972
|
+
},
|
|
7973
|
+
skip: isInBuilder === false,
|
|
7974
|
+
fetchPolicy: "cache-only",
|
|
7975
|
+
onCompleted(data) {
|
|
7976
|
+
if (data == null)
|
|
7977
|
+
return;
|
|
7978
|
+
const oldSnippets = snippets.map(filterUsedSnippetProperties);
|
|
7979
|
+
const newSnippets = data.page.snippets.map(filterUsedSnippetProperties);
|
|
7980
|
+
if (deepEqual(newSnippets, oldSnippets))
|
|
7981
|
+
return;
|
|
7982
|
+
setSnippets(data.page.snippets);
|
|
7983
|
+
}
|
|
7984
|
+
});
|
|
7985
|
+
const {
|
|
7986
|
+
data: siteData
|
|
7987
|
+
} = useQuery(SITE_FONTS_QUERY, {
|
|
7988
|
+
variables: {
|
|
7989
|
+
id: page.site.id
|
|
7990
|
+
},
|
|
7991
|
+
skip: isInBuilder === false,
|
|
7992
|
+
fetchPolicy: "cache-only"
|
|
7993
|
+
});
|
|
7994
|
+
const favicon = (_a = page.meta.favicon) != null ? _a : defaultFavicon;
|
|
7995
|
+
const {
|
|
7996
|
+
title,
|
|
7997
|
+
description,
|
|
7998
|
+
keywords,
|
|
7999
|
+
socialImage
|
|
8000
|
+
} = page.meta;
|
|
8001
|
+
const {
|
|
8002
|
+
canonicalUrl,
|
|
8003
|
+
isIndexingBlocked
|
|
8004
|
+
} = page.seo;
|
|
8005
|
+
const fontFamilyParamValue = useMemo(() => {
|
|
8006
|
+
if ((siteData == null ? void 0 : siteData.site) == null) {
|
|
8007
|
+
return page.fonts.map(({
|
|
8008
|
+
family,
|
|
8009
|
+
variants
|
|
8010
|
+
}) => {
|
|
8011
|
+
return `${family.replace(/ /g, "+")}:${variants.join()}`;
|
|
8012
|
+
}).join("|");
|
|
8013
|
+
}
|
|
8014
|
+
return siteData.site.googleFonts.edges.filter((edge) => edge != null).map(({
|
|
8015
|
+
activeVariants,
|
|
8016
|
+
node: {
|
|
8017
|
+
family,
|
|
8018
|
+
variants
|
|
8019
|
+
}
|
|
8020
|
+
}) => {
|
|
8021
|
+
const activeVariantSpecifiers = variants.filter((variant) => activeVariants.some((activeVariant) => activeVariant.specifier === variant.specifier)).map((variant) => variant.specifier).join();
|
|
8022
|
+
return `${family.replace(/ /g, "+")}:${activeVariantSpecifiers}`;
|
|
8023
|
+
}).join("|");
|
|
8024
|
+
}, [siteData, page]);
|
|
8025
|
+
const filteredSnippets = useMemo(() => snippets.filter((snippet) => preview ? snippet.builderEnabled : snippet.liveEnabled), [snippets]);
|
|
8026
|
+
const headSnippets = useMemo(() => filteredSnippets.filter((snippet) => snippet.location === "HEAD"), [filteredSnippets]);
|
|
8027
|
+
const previousHeadSnippets = useRef(null);
|
|
8028
|
+
useEffect(() => {
|
|
8029
|
+
var _a2;
|
|
8030
|
+
const headSnippetsToCleanUp = ((_a2 = previousHeadSnippets.current) != null ? _a2 : []).filter((previousSnippet) => previousSnippet.cleanup != null).filter((previousSnippet) => !headSnippets.some((snippet) => previousSnippet.id === snippet.id));
|
|
8031
|
+
headSnippetsToCleanUp.forEach((snippetToCleanUp) => {
|
|
8032
|
+
if (snippetToCleanUp.cleanup == null)
|
|
8033
|
+
return;
|
|
8034
|
+
const cleanUp = new Function(snippetToCleanUp.cleanup);
|
|
8035
|
+
try {
|
|
8036
|
+
cleanUp();
|
|
8037
|
+
} catch {
|
|
8038
|
+
}
|
|
8039
|
+
});
|
|
8040
|
+
previousHeadSnippets.current = headSnippets;
|
|
8041
|
+
}, [headSnippets]);
|
|
8042
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
8043
|
+
children: [/* @__PURE__ */ jsxs(Head, {
|
|
8044
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
8045
|
+
children: `
|
|
8046
|
+
html {
|
|
8047
|
+
font-family: sans-serif;
|
|
8048
|
+
}
|
|
8049
|
+
div#__next {
|
|
8050
|
+
overflow: hidden;
|
|
8051
|
+
}
|
|
8052
|
+
`
|
|
8053
|
+
}), /* @__PURE__ */ jsx("link", {
|
|
8054
|
+
rel: "icon",
|
|
8055
|
+
type: favicon.mimetype,
|
|
8056
|
+
href: favicon.publicUrl
|
|
8057
|
+
}), canonicalUrl && /* @__PURE__ */ jsx("link", {
|
|
8058
|
+
rel: "canonical",
|
|
8059
|
+
href: canonicalUrl
|
|
8060
|
+
}), isIndexingBlocked && /* @__PURE__ */ jsx("meta", {
|
|
8061
|
+
name: "robots",
|
|
8062
|
+
content: "noindex"
|
|
8063
|
+
}), title && /* @__PURE__ */ jsxs(Fragment, {
|
|
8064
|
+
children: [/* @__PURE__ */ jsx("title", {
|
|
8065
|
+
children: title
|
|
8066
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8067
|
+
property: "og:title",
|
|
8068
|
+
content: title
|
|
8069
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8070
|
+
name: "twitter:title",
|
|
8071
|
+
content: title
|
|
8072
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8073
|
+
itemProp: "name",
|
|
8074
|
+
content: title
|
|
8075
|
+
})]
|
|
8076
|
+
}), description && /* @__PURE__ */ jsxs(Fragment, {
|
|
8077
|
+
children: [/* @__PURE__ */ jsx("meta", {
|
|
8078
|
+
name: "description",
|
|
8079
|
+
content: description
|
|
8080
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8081
|
+
property: "og:description",
|
|
8082
|
+
content: description
|
|
8083
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8084
|
+
name: "twitter:description",
|
|
8085
|
+
content: description
|
|
8086
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8087
|
+
itemProp: "description",
|
|
8088
|
+
content: description
|
|
8089
|
+
})]
|
|
8090
|
+
}), keywords && /* @__PURE__ */ jsx("meta", {
|
|
8091
|
+
name: "keywords",
|
|
8092
|
+
content: keywords
|
|
8093
|
+
}), socialImage && /* @__PURE__ */ jsxs(Fragment, {
|
|
8094
|
+
children: [/* @__PURE__ */ jsx("meta", {
|
|
8095
|
+
property: "og:image",
|
|
8096
|
+
content: socialImage.publicUrl
|
|
8097
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8098
|
+
property: "og:image:type",
|
|
8099
|
+
content: socialImage.publicUrl
|
|
8100
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8101
|
+
name: "twitter:image",
|
|
8102
|
+
content: socialImage.publicUrl
|
|
8103
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8104
|
+
name: "twitter:card",
|
|
8105
|
+
content: socialImage.publicUrl
|
|
8106
|
+
}), /* @__PURE__ */ jsx("meta", {
|
|
8107
|
+
itemProp: "image",
|
|
8108
|
+
content: socialImage.publicUrl
|
|
8109
|
+
})]
|
|
8110
|
+
}), fontFamilyParamValue !== "" && /* @__PURE__ */ jsx(Fragment, {
|
|
8111
|
+
children: /* @__PURE__ */ jsx("link", {
|
|
8112
|
+
rel: "stylesheet",
|
|
8113
|
+
href: `https://fonts.googleapis.com/css?family=${fontFamilyParamValue}&display=swap`
|
|
8114
|
+
})
|
|
8115
|
+
}), headSnippets.map(snippetToElement).map((children) => Children.map(children, (child) => {
|
|
8116
|
+
if (typeof child === "string")
|
|
8117
|
+
return child;
|
|
8118
|
+
if (VALID_HEAD_ELEMENT_TYPES.includes(child.type))
|
|
8119
|
+
return child;
|
|
8120
|
+
return null;
|
|
8121
|
+
}))]
|
|
8122
|
+
}), /* @__PURE__ */ jsx(DocumentReference, {
|
|
8123
|
+
documentReference: createDocumentReference(page.id)
|
|
8124
|
+
}), filteredSnippets.filter((snippet) => snippet.location === "BODY").map((snippet) => /* @__PURE__ */ jsx(BodySnippet, {
|
|
8125
|
+
code: snippet.code,
|
|
8126
|
+
cleanup: snippet.cleanup
|
|
8127
|
+
}, snippet.id))]
|
|
8128
|
+
});
|
|
8129
|
+
}
|
|
7804
8130
|
var _path;
|
|
7805
8131
|
function _extends() {
|
|
7806
8132
|
_extends = Object.assign || function(target) {
|
|
@@ -8177,8 +8503,11 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
8177
8503
|
}
|
|
8178
8504
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
8179
8505
|
const useInsertionEffect = (_ea = React[useInsertionEffectSpecifier]) != null ? _ea : React.useLayoutEffect;
|
|
8506
|
+
const isServer = typeof window === "undefined";
|
|
8180
8507
|
function useFormattedStyle(styleControlData, controlDefinition) {
|
|
8181
8508
|
const style = useStyleControlCssObject(styleControlData, controlDefinition);
|
|
8509
|
+
if (isServer)
|
|
8510
|
+
return css$1(style);
|
|
8182
8511
|
const serialized = serializeStyles([style], cache.registered);
|
|
8183
8512
|
useInsertionEffect(() => {
|
|
8184
8513
|
insertStyles(cache, serialized, false);
|
|
@@ -8242,7 +8571,7 @@ function ShapeControlValue({
|
|
|
8242
8571
|
data,
|
|
8243
8572
|
children
|
|
8244
8573
|
}) {
|
|
8245
|
-
return Object.entries(definition.config.type).
|
|
8574
|
+
return Object.entries(definition.config.type).reduceRight((renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsx(ControlValue, {
|
|
8246
8575
|
definition: controlDefinition,
|
|
8247
8576
|
data: data == null ? void 0 : data[key],
|
|
8248
8577
|
children: (value) => renderFn(__spreadProps(__spreadValues({}, shapeControlValue), {
|
|
@@ -8388,11 +8717,9 @@ function PropsValue({
|
|
|
8388
8717
|
function suppressWarningAndFindDomNode(instance) {
|
|
8389
8718
|
const error = console.error;
|
|
8390
8719
|
console.error = (...args) => {
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
error.apply(console, args);
|
|
8395
|
-
}
|
|
8720
|
+
if (typeof args[0] === "string" && args[0].includes("%s is deprecated in StrictMode."))
|
|
8721
|
+
return;
|
|
8722
|
+
return error.apply(console, args);
|
|
8396
8723
|
};
|
|
8397
8724
|
const foundDomNode = findDOMNode(instance);
|
|
8398
8725
|
console.error = error;
|
|
@@ -8550,11 +8877,10 @@ function useSuppressRefWarning(ownerName) {
|
|
|
8550
8877
|
const patchedRef = useRef(false);
|
|
8551
8878
|
if (patchedRef.current === false) {
|
|
8552
8879
|
console.error = (...args) => {
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
if (!text.includes("Function components cannot be given refs.") || !text.includes(`Check the render method of \`${ownerName}\`.`)) {
|
|
8556
|
-
originalErrorRef.current(...args);
|
|
8880
|
+
if (typeof args[0] === "string" && args[0].includes("Function components cannot be given refs.") && args[0].includes(`Check the render method of \`${ownerName}\`.`)) {
|
|
8881
|
+
return;
|
|
8557
8882
|
}
|
|
8883
|
+
return originalErrorRef.current(...args);
|
|
8558
8884
|
};
|
|
8559
8885
|
patchedRef.current = true;
|
|
8560
8886
|
}
|
|
@@ -8657,21 +8983,21 @@ const Element$1 = memo(forwardRef(function Element2({
|
|
|
8657
8983
|
}, elementKey);
|
|
8658
8984
|
}));
|
|
8659
8985
|
const Document = memo(forwardRef(function Document2({
|
|
8660
|
-
document
|
|
8986
|
+
document: document2
|
|
8661
8987
|
}, ref) {
|
|
8662
8988
|
return /* @__PURE__ */ jsx(DocumentContext.Provider, {
|
|
8663
|
-
value:
|
|
8989
|
+
value: document2.key,
|
|
8664
8990
|
children: /* @__PURE__ */ jsx(Element$1, {
|
|
8665
8991
|
ref,
|
|
8666
|
-
element:
|
|
8992
|
+
element: document2.rootElement
|
|
8667
8993
|
})
|
|
8668
8994
|
});
|
|
8669
8995
|
}));
|
|
8670
8996
|
const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
8671
8997
|
documentReference
|
|
8672
8998
|
}, ref) {
|
|
8673
|
-
const
|
|
8674
|
-
if (
|
|
8999
|
+
const document2 = useDocument(documentReference.key);
|
|
9000
|
+
if (document2 == null) {
|
|
8675
9001
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
8676
9002
|
ref,
|
|
8677
9003
|
text: "Document not found"
|
|
@@ -8679,8 +9005,8 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
8679
9005
|
}
|
|
8680
9006
|
return /* @__PURE__ */ jsx(Document, {
|
|
8681
9007
|
ref,
|
|
8682
|
-
document
|
|
9008
|
+
document: document2
|
|
8683
9009
|
});
|
|
8684
9010
|
}));
|
|
8685
|
-
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,
|
|
9011
|
+
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 };
|
|
8686
9012
|
//# sourceMappingURL=index.es.js.map
|