@makeswift/runtime 0.0.0-20230407200421 → 0.0.0-20230410231005
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/Box.cjs.js +14 -10
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +9 -5
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +40 -36
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +15 -11
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +38 -34
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +13 -9
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +30 -54
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +5 -29
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +11 -35
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +5 -29
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +6 -30
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +5 -29
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +76 -72
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +14 -10
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +22 -18
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +15 -11
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +14 -10
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +14 -10
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +41 -37
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +15 -11
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +12 -8
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +12 -8
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +71 -67
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +15 -11
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +13 -9
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +11 -7
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +16 -12
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +9 -5
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +7 -3
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +8 -4
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +6 -30
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +5 -29
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +0 -13
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +1 -12
- package/dist/actions.es.js.map +1 -1
- package/dist/api.cjs.js +1 -1
- package/dist/api.es.js +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +14 -10
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +14 -10
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +37 -36
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +2 -1
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +22 -22
- package/dist/controls.es.js +2 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +548 -1689
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +23 -21
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +2 -1
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +2 -2
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +20 -20
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +7 -3
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +50 -46
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.es.js +329 -1450
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +5 -3
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es3.js +2 -1
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +1 -1
- package/dist/index.es5.js +3 -3
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +7 -3
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +16 -12
- package/dist/index.es7.js.map +1 -1
- package/dist/introspection.cjs.js +21 -23
- package/dist/introspection.cjs.js.map +1 -1
- package/dist/introspection.es.js +4 -5
- package/dist/introspection.es.js.map +1 -1
- package/dist/isNonNullable.cjs.js +6 -0
- package/dist/isNonNullable.cjs.js.map +1 -0
- package/dist/isNonNullable.es.js +5 -0
- package/dist/isNonNullable.es.js.map +1 -0
- package/dist/leaf.cjs.js +11 -11
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +2 -2
- package/dist/main.cjs.js +2 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +2 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +9 -6
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +10 -6
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +3 -1
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +3 -1
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react.cjs.js +7 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +7 -3
- package/dist/react.es.js.map +1 -1
- package/dist/responsive-style.cjs.js +917 -0
- package/dist/responsive-style.cjs.js.map +1 -0
- package/dist/responsive-style.es.js +853 -0
- package/dist/responsive-style.es.js.map +1 -0
- package/dist/rich-text.cjs.js +61 -1319
- package/dist/rich-text.cjs.js.map +1 -1
- package/dist/rich-text.es.js +17 -1217
- package/dist/rich-text.es.js.map +1 -1
- package/dist/slate.cjs.js +8 -28
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +8 -28
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts +0 -2
- package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/types.d.ts +0 -70
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/api/react.d.ts +0 -3
- package/dist/types/src/api/react.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/types.d.ts +1 -16
- package/dist/types/src/controls/rich-text/types.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/element-tree.d.ts +12 -0
- package/dist/types/src/next/api-handler/handlers/element-tree.d.ts.map +1 -0
- package/dist/types/src/next/api-handler/handlers/fonts.d.ts +18 -0
- package/dist/types/src/next/api-handler/handlers/fonts.d.ts.map +1 -0
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +17 -0
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -0
- package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts +8 -0
- package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -0
- package/dist/types/src/next/api-handler/handlers/revalidate.d.ts +13 -0
- package/dist/types/src/next/api-handler/handlers/revalidate.d.ts.map +1 -0
- package/dist/types/src/next/api-handler/index.d.ts +19 -0
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -0
- package/dist/types/src/next/client.d.ts +11 -35
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +1 -6
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +2 -22
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/makeswift-api-client.d.ts +4 -9
- package/dist/types/src/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/src/state/modules/api-resources.d.ts +4 -4
- package/dist/types/src/state/modules/api-resources.d.ts.map +1 -1
- package/dist/types.cjs.js +1272 -10
- package/dist/types.cjs.js.map +1 -1
- package/dist/types.cjs2.js +14 -0
- package/dist/types.cjs2.js.map +1 -0
- package/dist/types.es.js +1207 -10
- package/dist/types.es.js.map +1 -1
- package/dist/types.es2.js +13 -0
- package/dist/types.es2.js.map +1 -0
- package/package.json +3 -2
- package/dist/types/src/api/introspection.d.ts +0 -11
- package/dist/types/src/api/introspection.d.ts.map +0 -1
- package/dist/types/src/next/api-handler.d.ts +0 -48
- package/dist/types/src/next/api-handler.d.ts.map +0 -1
- package/dist/types/src/next/snapshots.d.ts +0 -152
- package/dist/types/src/next/snapshots.d.ts.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -34,37 +34,36 @@ var __publicField = (obj, key, value) => {
|
|
|
34
34
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
35
|
return value;
|
|
36
36
|
};
|
|
37
|
-
var _c;
|
|
38
37
|
import * as React from "react";
|
|
39
|
-
import { useEffect,
|
|
38
|
+
import { useEffect, useState, useMemo, useRef, Children, createElement, forwardRef, memo, createContext, useContext, useCallback, useImperativeHandle, Component, Suspense } from "react";
|
|
40
39
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
41
40
|
import dynamic from "next/dynamic";
|
|
42
|
-
import {
|
|
43
|
-
import { A as ActionTypes, j as
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
48
|
-
import { S as ShapeControlType, L as ListControlType, T as Types, E as ElementID, B as Backgrounds, W as Width, f as ResponsiveIconRadioGroup, M as Margin, P as Padding, g as Border, h as BorderRadius, i as Shadows, G as GapY, j as GapX, k as ResponsiveSelect, l as ResponsiveNumber, m as Checkbox, n as Grid, o as TextInput, p as Link, q as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, Q as RichTextControlType, b as SlotControlType, U as LinkControlType, I as ImageControlType, C as ColorControlType, X as BorderPropControllerFormat, Y as ShadowsPropControllerFormat, Z as BorderRadiusPropControllerFormat, _ as MarginPropControllerFormat, $ as PaddingPropControllerFormat, a0 as WidthPropControllerFormat, a1 as StyleControlType } from "./rich-text.es.js";
|
|
41
|
+
import { a as createDocumentReference, g as getPropControllerDescriptors, i as isElementReference, M as MakeswiftComponentType, b as isPropControllersHandle, d as getComponentPropControllerDescriptors, e as getPropControllers, f as configureStore, h as getDocument, j as getElementId, k as getIsPreview, l as getIsInBuilder, m as copyElementTree, n as getReactComponent, o as getBuilderEditMode } from "./constants.es.js";
|
|
42
|
+
import { A as ActionTypes, j as registerComponentHandleEffect, k as mountComponentEffect, l as registerComponentEffect, n as registerReactComponentEffect } from "./actions.es.js";
|
|
43
|
+
import { d as deepEqual, u as useMakeswiftClient, G as GraphQLClient, T as TypographiesQuery, I as IntrospectedResourcesQuery, S as SwatchQuery, F as FileQuery, a as TypographyQuery, b as GlobalElementQuery, P as PagePathnamesByIdQuery, c as TableQuery, M as MakeswiftClient, f as findDeviceOverride, e as useStyle, g as useSwatches, D as DEVICES, h as getDeviceMediaQuery, r as responsiveStyle, m as marginPropertyDataToStyle, p as paddingPropertyDataToStyle, l as lengthPercentageDataToString, i as colorToString, j as useSwatch, k as useFile, n as usePagePathnameSlice, o as getIndexes, q as responsiveWidth, s as responsivePadding, t as responsiveMargin, v as responsiveBorderRadius, w as responsiveShadow, x as responsiveBorder, y as useGlobalElement } from "./responsive-style.es.js";
|
|
44
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
45
|
+
import { T as Types, E as ElementID, p as Backgrounds, W as Width, R as ResponsiveIconRadioGroup, M as Margin, P as Padding, q as Border, r as BorderRadius, s as Shadows, G as GapY, t as GapX, u as ResponsiveSelect, v as ResponsiveNumber, w as Checkbox, x as Grid, y as TextInput, z as Link, A as ResponsiveColor, D as TextStyle, F as Images, N as Number, H as Date$1, J as Font, K as ResponsiveLength, O as TextArea, Q as Table, U as TableFormFields, V as Image, X as ResponsiveOpacity, Y as NavigationLinks, Z as SocialLinks, _ as RichText, $ as Video, a0 as StyleControlProperty, a1 as ImageControlValueFormat, L as LinkControlType, I as ImageControlType, C as ColorControlType, a2 as BorderPropControllerFormat, a3 as ShadowsPropControllerFormat, a4 as BorderRadiusPropControllerFormat, a5 as MarginPropControllerFormat, a6 as PaddingPropControllerFormat, a7 as WidthPropControllerFormat, S as StyleControlType } from "./types.es.js";
|
|
49
46
|
import "slate";
|
|
50
47
|
import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
51
48
|
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
49
|
+
import { S as ShapeControlType, L as ListControlType, d as RichTextControlType, b as SlotControlType } from "./rich-text.es.js";
|
|
52
50
|
import "slate-react";
|
|
53
51
|
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
54
|
-
import { b as getElementSwatchIds, c as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, a as getElementChildren, h as getBorderSwatchIds, j as
|
|
55
|
-
import {
|
|
56
|
-
import thunk from "redux-thunk";
|
|
57
|
-
import { A as APIResourceType } from "./types.es.js";
|
|
52
|
+
import { b as getElementSwatchIds, c as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, a as getElementChildren, h as getBorderSwatchIds, j as getBoxShadowsSwatchIds, k as getResponsiveColorSwatchIds } from "./introspection.es.js";
|
|
53
|
+
import { i as isNonNullable } from "./isNonNullable.es.js";
|
|
58
54
|
import ColorHelper from "color";
|
|
59
55
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
56
|
+
import { cache, cx } from "@emotion/css";
|
|
60
57
|
import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
|
|
61
58
|
import { findDOMNode } from "react-dom";
|
|
62
59
|
import parse from "html-react-parser";
|
|
63
60
|
import Head from "next/head";
|
|
61
|
+
import { A as APIResourceType } from "./types.es2.js";
|
|
64
62
|
import createEmotionServer from "@emotion/server/create-instance";
|
|
65
63
|
import NextDocument, { Html, Head as Head$1, Main, NextScript } from "next/document";
|
|
66
|
-
import { serialize } from "cookie";
|
|
67
64
|
import Cors from "cors";
|
|
65
|
+
import { match } from "path-to-regexp";
|
|
66
|
+
import { serialize } from "cookie";
|
|
68
67
|
import { createProxyServer } from "http-proxy";
|
|
69
68
|
import { parse as parse$1 } from "set-cookie-parser";
|
|
70
69
|
import { v4 } from "uuid";
|
|
@@ -113,661 +112,6 @@ function BodySnippet({
|
|
|
113
112
|
}, [code, cleanup]);
|
|
114
113
|
return null;
|
|
115
114
|
}
|
|
116
|
-
async function introspect(element, client, store) {
|
|
117
|
-
const descriptors = getPropControllerDescriptors(store.getState());
|
|
118
|
-
const swatchIds = /* @__PURE__ */ new Set();
|
|
119
|
-
const fileIds = /* @__PURE__ */ new Set();
|
|
120
|
-
const typographyIds = /* @__PURE__ */ new Set();
|
|
121
|
-
const tableIds = /* @__PURE__ */ new Set();
|
|
122
|
-
const pageIds = /* @__PURE__ */ new Set();
|
|
123
|
-
const remaining = [element];
|
|
124
|
-
const seen = /* @__PURE__ */ new Set();
|
|
125
|
-
let current;
|
|
126
|
-
while (current = remaining.pop()) {
|
|
127
|
-
let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
|
|
128
|
-
Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
|
|
129
|
-
getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
|
|
130
|
-
swatchIds.add(swatchId);
|
|
131
|
-
});
|
|
132
|
-
getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
|
|
133
|
-
getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
|
|
134
|
-
getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
|
|
135
|
-
getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
|
|
136
|
-
getElementChildren(descriptor, props[propName]).forEach((child) => {
|
|
137
|
-
if (!seen.has(child.key)) {
|
|
138
|
-
seen.add(child.key);
|
|
139
|
-
remaining.push(child);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
if (descriptor.type === ShapeControlType) {
|
|
143
|
-
const prop = props[propName];
|
|
144
|
-
if (prop == null)
|
|
145
|
-
return;
|
|
146
|
-
getResourcesFromElementDescriptors(descriptor.config.type, prop);
|
|
147
|
-
}
|
|
148
|
-
if (descriptor.type === ListControlType) {
|
|
149
|
-
const prop = props[propName];
|
|
150
|
-
if (prop == null)
|
|
151
|
-
return;
|
|
152
|
-
prop.forEach((item) => {
|
|
153
|
-
getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (descriptor.type === Types.Shape) {
|
|
157
|
-
const prop = props[propName];
|
|
158
|
-
if (prop == null)
|
|
159
|
-
return;
|
|
160
|
-
getResourcesFromElementDescriptors(descriptor.options.type, prop);
|
|
161
|
-
}
|
|
162
|
-
if (descriptor.type === Types.List) {
|
|
163
|
-
const prop = props[propName];
|
|
164
|
-
if (prop == null)
|
|
165
|
-
return;
|
|
166
|
-
prop.forEach((item) => {
|
|
167
|
-
getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
let element2;
|
|
173
|
-
if (isElementReference(current)) {
|
|
174
|
-
const globalElement = await client.fetchGlobalElement(current.value);
|
|
175
|
-
const elementData = globalElement == null ? void 0 : globalElement.data;
|
|
176
|
-
if (elementData == null)
|
|
177
|
-
continue;
|
|
178
|
-
element2 = elementData;
|
|
179
|
-
} else {
|
|
180
|
-
element2 = current;
|
|
181
|
-
}
|
|
182
|
-
const elementDescriptors = descriptors.get(element2.type);
|
|
183
|
-
if (elementDescriptors == null)
|
|
184
|
-
continue;
|
|
185
|
-
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
186
|
-
}
|
|
187
|
-
const typographies = await client.fetchTypographies([...typographyIds]);
|
|
188
|
-
typographies.forEach((typography) => {
|
|
189
|
-
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
190
|
-
var _a;
|
|
191
|
-
const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
|
|
192
|
-
if (swatchId != null)
|
|
193
|
-
swatchIds.add(swatchId);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
return {
|
|
197
|
-
swatchIds: [...swatchIds],
|
|
198
|
-
fileIds: [...fileIds],
|
|
199
|
-
typographyIds: [...typographyIds],
|
|
200
|
-
tableIds: [...tableIds],
|
|
201
|
-
pageIds: [...pageIds]
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function normalizeToMakeswiftResources(partialResources) {
|
|
205
|
-
const resources = {
|
|
206
|
-
swatches: (partialResources == null ? void 0 : partialResources.swatches) || [],
|
|
207
|
-
typographies: (partialResources == null ? void 0 : partialResources.typographies) || [],
|
|
208
|
-
files: (partialResources == null ? void 0 : partialResources.files) || [],
|
|
209
|
-
tables: (partialResources == null ? void 0 : partialResources.tables) || [],
|
|
210
|
-
pagePathnameSlices: (partialResources == null ? void 0 : partialResources.pagePathnameSlices) || [],
|
|
211
|
-
globalElements: (partialResources == null ? void 0 : partialResources.globalElements) || [],
|
|
212
|
-
snippets: (partialResources == null ? void 0 : partialResources.snippets) || [],
|
|
213
|
-
fonts: (partialResources == null ? void 0 : partialResources.fonts) || [],
|
|
214
|
-
pageMetadata: (partialResources == null ? void 0 : partialResources.pageMetadata) || {},
|
|
215
|
-
pageSeo: (partialResources == null ? void 0 : partialResources.pageSeo) || {}
|
|
216
|
-
};
|
|
217
|
-
return resources;
|
|
218
|
-
}
|
|
219
|
-
function fileToFileSnapshot(file) {
|
|
220
|
-
return file;
|
|
221
|
-
}
|
|
222
|
-
function is(x, y) {
|
|
223
|
-
if (x === y)
|
|
224
|
-
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
225
|
-
return x !== x && y !== y;
|
|
226
|
-
}
|
|
227
|
-
const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
|
|
228
|
-
const shallowEqual = (a, b) => {
|
|
229
|
-
if (is(a, b))
|
|
230
|
-
return true;
|
|
231
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
232
|
-
return false;
|
|
233
|
-
const keysA = Object.keys(a);
|
|
234
|
-
const keysB = Object.keys(b);
|
|
235
|
-
if (keysA.length !== keysB.length)
|
|
236
|
-
return false;
|
|
237
|
-
for (let i = 0; i < keysA.length; i += 1) {
|
|
238
|
-
if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
return true;
|
|
242
|
-
};
|
|
243
|
-
const { hasOwnProperty } = Object.prototype;
|
|
244
|
-
const deepEqual = (a, b) => {
|
|
245
|
-
if (shallowEqual(a, b))
|
|
246
|
-
return true;
|
|
247
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
248
|
-
return false;
|
|
249
|
-
const keysA = Object.keys(a);
|
|
250
|
-
const keysB = Object.keys(b);
|
|
251
|
-
if (keysA.length !== keysB.length)
|
|
252
|
-
return false;
|
|
253
|
-
for (let i = 0; i < keysA.length; i += 1) {
|
|
254
|
-
if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
return true;
|
|
258
|
-
};
|
|
259
|
-
function isNonNullable(value) {
|
|
260
|
-
return value != null;
|
|
261
|
-
}
|
|
262
|
-
function getSnapshotResourcesFromSerializedState(serializedState) {
|
|
263
|
-
const resources = {
|
|
264
|
-
swatches: serializedState.Swatch.filter((_) => true),
|
|
265
|
-
typographies: serializedState.Typography.filter((_) => true),
|
|
266
|
-
files: serializedState.File.map(({ id, value }) => value.__typename === APIResourceType.File ? { id, value: fileToFileSnapshot(value) } : null).filter(isNonNullable),
|
|
267
|
-
tables: serializedState.Table.filter((_) => true),
|
|
268
|
-
pagePathnameSlices: serializedState.PagePathnameSlice.filter((_) => true),
|
|
269
|
-
globalElements: serializedState.GlobalElement.filter((_) => true)
|
|
270
|
-
};
|
|
271
|
-
return resources;
|
|
272
|
-
}
|
|
273
|
-
function getInitialState(serializedState = {
|
|
274
|
-
Swatch: [],
|
|
275
|
-
File: [],
|
|
276
|
-
Typography: [],
|
|
277
|
-
PagePathnameSlice: [],
|
|
278
|
-
GlobalElement: [],
|
|
279
|
-
Table: [],
|
|
280
|
-
Snippet: [],
|
|
281
|
-
Page: [],
|
|
282
|
-
Site: []
|
|
283
|
-
}) {
|
|
284
|
-
return new Map(Object.entries(serializedState).map(([apiResourceType, resources]) => [
|
|
285
|
-
apiResourceType,
|
|
286
|
-
new Map(resources.map(({ id, value }) => [id, value]))
|
|
287
|
-
]));
|
|
288
|
-
}
|
|
289
|
-
function getSerializedState$1(state) {
|
|
290
|
-
const resourceMap = {
|
|
291
|
-
Swatch: [],
|
|
292
|
-
File: [],
|
|
293
|
-
Typography: [],
|
|
294
|
-
PagePathnameSlice: [],
|
|
295
|
-
GlobalElement: [],
|
|
296
|
-
Table: [],
|
|
297
|
-
Snippet: [],
|
|
298
|
-
Page: [],
|
|
299
|
-
Site: []
|
|
300
|
-
};
|
|
301
|
-
Array.from(state.entries()).forEach(([resourceType, resources]) => {
|
|
302
|
-
const particularResourceMap = [];
|
|
303
|
-
Array.from(resources.entries()).forEach(([id, value]) => {
|
|
304
|
-
if (value != null) {
|
|
305
|
-
particularResourceMap.push({ id, value });
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
resourceMap[resourceType] = particularResourceMap;
|
|
309
|
-
});
|
|
310
|
-
return resourceMap;
|
|
311
|
-
}
|
|
312
|
-
function getHasAPIResource$1(state, resourceType, resourceId) {
|
|
313
|
-
var _a, _b;
|
|
314
|
-
return (_b = (_a = state.get(resourceType)) == null ? void 0 : _a.has(resourceId)) != null ? _b : false;
|
|
315
|
-
}
|
|
316
|
-
function getAPIResource$1(state, resourceType, resourceId) {
|
|
317
|
-
var _a;
|
|
318
|
-
const resource = (_a = state.get(resourceType)) == null ? void 0 : _a.get(resourceId);
|
|
319
|
-
return (resource == null ? void 0 : resource.__typename) === resourceType ? resource : null;
|
|
320
|
-
}
|
|
321
|
-
function reducer$1(state = getInitialState(), action) {
|
|
322
|
-
switch (action.type) {
|
|
323
|
-
case ActionTypes.API_RESOURCE_FULFILLED: {
|
|
324
|
-
const { resourceType, resourceId, resource } = action.payload;
|
|
325
|
-
return new Map(state).set(resourceType, new Map(state.get(resourceType)).set(resourceId, resource));
|
|
326
|
-
}
|
|
327
|
-
case ActionTypes.INTROSPECTED_RESOURCES_FULFILLED: {
|
|
328
|
-
const { introspectedResourceIds, introspectedResources } = action.payload;
|
|
329
|
-
const swatches = new Map(state.get(APIResourceType.Swatch));
|
|
330
|
-
const files = new Map(state.get(APIResourceType.File));
|
|
331
|
-
const typographies = new Map(state.get(APIResourceType.Typography));
|
|
332
|
-
const pagePathnameSlices = new Map(state.get(APIResourceType.PagePathnameSlice));
|
|
333
|
-
const tables = new Map(state.get(APIResourceType.Table));
|
|
334
|
-
introspectedResourceIds.swatchIds.forEach((swatchId, idx) => {
|
|
335
|
-
swatches.set(swatchId, introspectedResources.swatches[idx]);
|
|
336
|
-
});
|
|
337
|
-
introspectedResourceIds.fileIds.forEach((fileId, idx) => {
|
|
338
|
-
files.set(fileId, introspectedResources.files[idx]);
|
|
339
|
-
});
|
|
340
|
-
introspectedResourceIds.typographyIds.forEach((typographyId, idx) => {
|
|
341
|
-
typographies.set(typographyId, introspectedResources.typographies[idx]);
|
|
342
|
-
});
|
|
343
|
-
introspectedResourceIds.pageIds.forEach((pageId, idx) => {
|
|
344
|
-
const pagePathnameSlice = introspectedResources.pagePathnamesById[idx];
|
|
345
|
-
if (pagePathnameSlice == null) {
|
|
346
|
-
pagePathnameSlices.set(pageId, pagePathnameSlice);
|
|
347
|
-
} else {
|
|
348
|
-
const nodeId = Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64");
|
|
349
|
-
pagePathnameSlices.set(nodeId, __spreadProps(__spreadValues({}, pagePathnameSlice), { id: nodeId }));
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
introspectedResourceIds.tableIds.forEach((tableId, idx) => {
|
|
353
|
-
tables.set(tableId, introspectedResources.tables[idx]);
|
|
354
|
-
});
|
|
355
|
-
return new Map(state).set(APIResourceType.Swatch, swatches).set(APIResourceType.File, files).set(APIResourceType.Typography, typographies).set(APIResourceType.PagePathnameSlice, pagePathnameSlices).set(APIResourceType.Table, tables);
|
|
356
|
-
}
|
|
357
|
-
case ActionTypes.TYPOGRAPHIES_FULFILLED: {
|
|
358
|
-
const typographies = new Map(state.get(APIResourceType.Typography));
|
|
359
|
-
action.payload.typographyIds.forEach((typographyId, idx) => {
|
|
360
|
-
typographies.set(typographyId, action.payload.typographies[idx]);
|
|
361
|
-
});
|
|
362
|
-
return new Map(state).set(APIResourceType.Typography, typographies);
|
|
363
|
-
}
|
|
364
|
-
case ActionTypes.CHANGE_API_RESOURCE: {
|
|
365
|
-
const existingApiResource = getAPIResource$1(state, action.payload.resource.__typename, action.payload.resource.id);
|
|
366
|
-
if (deepEqual(existingApiResource, action.payload.resource))
|
|
367
|
-
return state;
|
|
368
|
-
return new Map(state).set(action.payload.resource.__typename, new Map(state.get(action.payload.resource.__typename)).set(action.payload.resource.id, action.payload.resource));
|
|
369
|
-
}
|
|
370
|
-
case ActionTypes.EVICT_API_RESOURCE: {
|
|
371
|
-
const [resourceType, resourceId] = action.payload.id.split(":");
|
|
372
|
-
if (!(resourceType in APIResourceType))
|
|
373
|
-
return state;
|
|
374
|
-
const resources = new Map(state.get(resourceType));
|
|
375
|
-
const deleted = resources.delete(resourceId);
|
|
376
|
-
return deleted ? new Map(state).set(resourceType, resources) : state;
|
|
377
|
-
}
|
|
378
|
-
default:
|
|
379
|
-
return state;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
const SwatchFragment = `
|
|
383
|
-
fragment Swatch on Swatch {
|
|
384
|
-
__typename
|
|
385
|
-
id
|
|
386
|
-
hue
|
|
387
|
-
saturation
|
|
388
|
-
lightness
|
|
389
|
-
}
|
|
390
|
-
`;
|
|
391
|
-
const FileFragment = `
|
|
392
|
-
fragment File on File {
|
|
393
|
-
__typename
|
|
394
|
-
id
|
|
395
|
-
name
|
|
396
|
-
publicUrl: publicUrlV2
|
|
397
|
-
extension
|
|
398
|
-
dimensions {
|
|
399
|
-
width
|
|
400
|
-
height
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
`;
|
|
404
|
-
const TypographyFragment = `
|
|
405
|
-
fragment Typography on Typography {
|
|
406
|
-
__typename
|
|
407
|
-
id
|
|
408
|
-
name
|
|
409
|
-
style {
|
|
410
|
-
deviceId
|
|
411
|
-
value {
|
|
412
|
-
fontFamily
|
|
413
|
-
fontSize {
|
|
414
|
-
value
|
|
415
|
-
unit
|
|
416
|
-
}
|
|
417
|
-
color {
|
|
418
|
-
swatchId
|
|
419
|
-
alpha
|
|
420
|
-
}
|
|
421
|
-
lineHeight
|
|
422
|
-
letterSpacing
|
|
423
|
-
fontWeight
|
|
424
|
-
textAlign
|
|
425
|
-
uppercase
|
|
426
|
-
underline
|
|
427
|
-
strikethrough
|
|
428
|
-
italic
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
`;
|
|
433
|
-
const PagePathnameSliceFragment = `
|
|
434
|
-
fragment PagePathnameSlice on PagePathnameSlice {
|
|
435
|
-
__typename
|
|
436
|
-
id
|
|
437
|
-
pathname
|
|
438
|
-
}
|
|
439
|
-
`;
|
|
440
|
-
const GlobalElementFragment = `
|
|
441
|
-
fragment GlobalElement on GlobalElement {
|
|
442
|
-
__typename
|
|
443
|
-
id
|
|
444
|
-
data
|
|
445
|
-
}
|
|
446
|
-
`;
|
|
447
|
-
const TableFragment = `
|
|
448
|
-
fragment Table on Table {
|
|
449
|
-
__typename
|
|
450
|
-
id
|
|
451
|
-
name
|
|
452
|
-
columns {
|
|
453
|
-
__typename
|
|
454
|
-
id
|
|
455
|
-
name
|
|
456
|
-
|
|
457
|
-
... on MultipleSelectTableColumn {
|
|
458
|
-
options {
|
|
459
|
-
id
|
|
460
|
-
name
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
... on SingleSelectTableColumn {
|
|
465
|
-
options {
|
|
466
|
-
id
|
|
467
|
-
name
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
`;
|
|
473
|
-
const IntrospectedResourcesQuery = `
|
|
474
|
-
query IntrospectedResources(
|
|
475
|
-
$swatchIds: [ID!]!
|
|
476
|
-
$fileIds: [ID!]!
|
|
477
|
-
$typographyIds: [ID!]!
|
|
478
|
-
$pageIds: [ID!]!
|
|
479
|
-
$tableIds: [ID!]!
|
|
480
|
-
) {
|
|
481
|
-
swatches(ids: $swatchIds) {
|
|
482
|
-
...Swatch
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
files(ids: $fileIds) {
|
|
486
|
-
...File
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
typographies(ids: $typographyIds) {
|
|
490
|
-
...Typography
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
pagePathnamesById(ids: $pageIds) {
|
|
494
|
-
...PagePathnameSlice
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
tables(ids: $tableIds) {
|
|
498
|
-
...Table
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
${SwatchFragment}
|
|
503
|
-
${FileFragment}
|
|
504
|
-
${TypographyFragment}
|
|
505
|
-
${PagePathnameSliceFragment}
|
|
506
|
-
${TableFragment}
|
|
507
|
-
`;
|
|
508
|
-
const SwatchQuery = `
|
|
509
|
-
query Swatch($swatchId: ID!) {
|
|
510
|
-
swatch(id: $swatchId) {
|
|
511
|
-
...Swatch
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
${SwatchFragment}
|
|
516
|
-
`;
|
|
517
|
-
const FileQuery = `
|
|
518
|
-
query File($fileId: ID!) {
|
|
519
|
-
file(id: $fileId) {
|
|
520
|
-
...File
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
${FileFragment}
|
|
525
|
-
`;
|
|
526
|
-
const TypographyQuery = `
|
|
527
|
-
query Typography($typographyId: ID!) {
|
|
528
|
-
typography(id: $typographyId) {
|
|
529
|
-
...Typography
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
${TypographyFragment}
|
|
534
|
-
`;
|
|
535
|
-
const PagePathnamesByIdQuery = `
|
|
536
|
-
query PagePathnamesById($pageIds: [ID!]!) {
|
|
537
|
-
pagePathnamesById(ids: $pageIds) {
|
|
538
|
-
...PagePathnameSlice
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
${PagePathnameSliceFragment}
|
|
543
|
-
`;
|
|
544
|
-
const TableQuery = `
|
|
545
|
-
query Table($tableId: ID!) {
|
|
546
|
-
table(id: $tableId) {
|
|
547
|
-
...Table
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
${TableFragment}
|
|
552
|
-
`;
|
|
553
|
-
const TypographiesQuery = `
|
|
554
|
-
query Typographies($typographyIds: [ID!]!) {
|
|
555
|
-
typographies(ids: $typographyIds) {
|
|
556
|
-
...Typography
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
${TypographyFragment}
|
|
561
|
-
`;
|
|
562
|
-
const GlobalElementQuery = `
|
|
563
|
-
query GlobalElement($globalElementId: ID!) {
|
|
564
|
-
globalElement(id: $globalElementId) {
|
|
565
|
-
...GlobalElement
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
${GlobalElementFragment}
|
|
570
|
-
`;
|
|
571
|
-
const CreateTableRecordMutation = `
|
|
572
|
-
mutation CreateTableRecord($input: CreateTableRecordInput!) {
|
|
573
|
-
createTableRecord(input: $input) {
|
|
574
|
-
tableRecord {
|
|
575
|
-
id
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
`;
|
|
580
|
-
const reducer = reducer$1;
|
|
581
|
-
function getSerializedState(state) {
|
|
582
|
-
return getSerializedState$1(state);
|
|
583
|
-
}
|
|
584
|
-
function getHasAPIResource(state, resourceType, resourceId) {
|
|
585
|
-
return getHasAPIResource$1(state, resourceType, resourceId);
|
|
586
|
-
}
|
|
587
|
-
function getAPIResource(state, resourceType, resourceId) {
|
|
588
|
-
return getAPIResource$1(state, resourceType, resourceId);
|
|
589
|
-
}
|
|
590
|
-
function fetchAPIResource(resourceType, resourceId) {
|
|
591
|
-
return async (dispatch, getState, client) => {
|
|
592
|
-
var _a;
|
|
593
|
-
const state = getState();
|
|
594
|
-
if (getHasAPIResource(state, resourceType, resourceId)) {
|
|
595
|
-
return getAPIResource(state, resourceType, resourceId);
|
|
596
|
-
}
|
|
597
|
-
let resource;
|
|
598
|
-
switch (resourceType) {
|
|
599
|
-
case APIResourceType.Swatch:
|
|
600
|
-
resource = (await client.request(SwatchQuery, {
|
|
601
|
-
swatchId: resourceId
|
|
602
|
-
})).swatch;
|
|
603
|
-
break;
|
|
604
|
-
case APIResourceType.File:
|
|
605
|
-
resource = (await client.request(FileQuery, {
|
|
606
|
-
fileId: resourceId
|
|
607
|
-
})).file;
|
|
608
|
-
break;
|
|
609
|
-
case APIResourceType.Typography:
|
|
610
|
-
resource = (await client.request(TypographyQuery, {
|
|
611
|
-
typographyId: resourceId
|
|
612
|
-
})).typography;
|
|
613
|
-
break;
|
|
614
|
-
case APIResourceType.GlobalElement:
|
|
615
|
-
resource = (await client.request(GlobalElementQuery, { globalElementId: resourceId })).globalElement;
|
|
616
|
-
break;
|
|
617
|
-
case APIResourceType.PagePathnameSlice:
|
|
618
|
-
resource = (_a = (await client.request(PagePathnamesByIdQuery, { pageIds: [resourceId] })).pagePathnamesById[0]) != null ? _a : null;
|
|
619
|
-
break;
|
|
620
|
-
case APIResourceType.Table:
|
|
621
|
-
resource = (await client.request(TableQuery, {
|
|
622
|
-
tableId: resourceId
|
|
623
|
-
})).table;
|
|
624
|
-
break;
|
|
625
|
-
default:
|
|
626
|
-
resource = null;
|
|
627
|
-
}
|
|
628
|
-
dispatch(apiResourceFulfilled(resourceType, resourceId, resource));
|
|
629
|
-
return resource;
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
function fetchIntrospectedResources(introspectedResourceIds) {
|
|
633
|
-
return async (dispatch, _getState, client) => {
|
|
634
|
-
const introspectedResources = await client.request(IntrospectedResourcesQuery, introspectedResourceIds);
|
|
635
|
-
dispatch(introspectedResourcesFulfilled(introspectedResourceIds, introspectedResources));
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
function fetchTypographies(typographyIds) {
|
|
639
|
-
return async (dispatch, getState, client) => {
|
|
640
|
-
const state = getState();
|
|
641
|
-
if (typographyIds.every((typographyId) => getHasAPIResource(state, APIResourceType.Typography, typographyId))) {
|
|
642
|
-
return typographyIds.map((typographyId) => getAPIResource(state, APIResourceType.Typography, typographyId));
|
|
643
|
-
}
|
|
644
|
-
const { typographies } = await client.request(TypographiesQuery, { typographyIds });
|
|
645
|
-
dispatch(typographiesFulfilled(typographyIds, typographies));
|
|
646
|
-
return typographies;
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
function configureStore({
|
|
650
|
-
graphqlClient,
|
|
651
|
-
serializedState
|
|
652
|
-
}) {
|
|
653
|
-
return createStore(reducer, getInitialState(serializedState), applyMiddleware(thunk.withExtraArgument(graphqlClient)));
|
|
654
|
-
}
|
|
655
|
-
class GraphQLClient {
|
|
656
|
-
constructor(endpoint) {
|
|
657
|
-
__publicField(this, "endpoint");
|
|
658
|
-
this.endpoint = endpoint;
|
|
659
|
-
}
|
|
660
|
-
async request(query, variables = {}) {
|
|
661
|
-
const response = await fetch(this.endpoint, {
|
|
662
|
-
method: "POST",
|
|
663
|
-
headers: { "Content-Type": "application/json" },
|
|
664
|
-
body: JSON.stringify({ query, variables })
|
|
665
|
-
});
|
|
666
|
-
if (!response.ok && response.status !== 400) {
|
|
667
|
-
throw new Error(`${response.status} ${response.statusText}`);
|
|
668
|
-
}
|
|
669
|
-
const body = await response.json();
|
|
670
|
-
if (body.errors != null) {
|
|
671
|
-
console.error(body);
|
|
672
|
-
throw new Error("GraphQL response contains errors, check the console.");
|
|
673
|
-
}
|
|
674
|
-
return body.data;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
class MakeswiftClient {
|
|
678
|
-
constructor({
|
|
679
|
-
uri,
|
|
680
|
-
cacheData
|
|
681
|
-
}) {
|
|
682
|
-
__publicField(this, "graphqlClient");
|
|
683
|
-
__publicField(this, "makeswiftApiClient");
|
|
684
|
-
__publicField(this, "subscribe");
|
|
685
|
-
this.graphqlClient = new GraphQLClient(uri);
|
|
686
|
-
this.makeswiftApiClient = configureStore({
|
|
687
|
-
graphqlClient: this.graphqlClient,
|
|
688
|
-
serializedState: cacheData
|
|
689
|
-
});
|
|
690
|
-
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
691
|
-
}
|
|
692
|
-
async prefetch(element) {
|
|
693
|
-
const introspectionData = await introspect(element, this, storeContextDefaultValue);
|
|
694
|
-
await this.makeswiftApiClient.dispatch(fetchIntrospectedResources(introspectionData));
|
|
695
|
-
return getSerializedState(this.makeswiftApiClient.getState());
|
|
696
|
-
}
|
|
697
|
-
readSwatch(swatchId) {
|
|
698
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Swatch, swatchId);
|
|
699
|
-
}
|
|
700
|
-
async fetchSwatch(swatchId) {
|
|
701
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.Swatch, swatchId));
|
|
702
|
-
}
|
|
703
|
-
readFile(fileId) {
|
|
704
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.File, fileId);
|
|
705
|
-
}
|
|
706
|
-
async fetchFile(fileId) {
|
|
707
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.File, fileId));
|
|
708
|
-
}
|
|
709
|
-
readTypography(typographyId) {
|
|
710
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Typography, typographyId);
|
|
711
|
-
}
|
|
712
|
-
async fetchTypography(typographyId) {
|
|
713
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.Typography, typographyId));
|
|
714
|
-
}
|
|
715
|
-
async fetchTypographies(typographyIds) {
|
|
716
|
-
return await this.makeswiftApiClient.dispatch(fetchTypographies(typographyIds));
|
|
717
|
-
}
|
|
718
|
-
readGlobalElement(globalElementId) {
|
|
719
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.GlobalElement, globalElementId);
|
|
720
|
-
}
|
|
721
|
-
async fetchGlobalElement(globalElementId) {
|
|
722
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.GlobalElement, globalElementId));
|
|
723
|
-
}
|
|
724
|
-
readPagePathnameSlice(pageId) {
|
|
725
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.PagePathnameSlice, pageId);
|
|
726
|
-
}
|
|
727
|
-
async fetchPagePathnameSlice(pageId) {
|
|
728
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.PagePathnameSlice, pageId));
|
|
729
|
-
}
|
|
730
|
-
readTable(tableId) {
|
|
731
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Table, tableId);
|
|
732
|
-
}
|
|
733
|
-
async fetchTable(tableId) {
|
|
734
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.Table, tableId));
|
|
735
|
-
}
|
|
736
|
-
async createTableRecord(tableId, columns) {
|
|
737
|
-
await this.graphqlClient.request(CreateTableRecordMutation, {
|
|
738
|
-
input: {
|
|
739
|
-
data: {
|
|
740
|
-
tableId,
|
|
741
|
-
columns
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
readSite(siteId) {
|
|
747
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Site, siteId);
|
|
748
|
-
}
|
|
749
|
-
readPage(pageId) {
|
|
750
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Page, pageId);
|
|
751
|
-
}
|
|
752
|
-
readSnippet(snippetId) {
|
|
753
|
-
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Snippet, snippetId);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
const Context$1 = createContext(new MakeswiftClient({
|
|
757
|
-
uri: "https://api.makeswift.com/graphql"
|
|
758
|
-
}));
|
|
759
|
-
function useMakeswiftClient() {
|
|
760
|
-
return useContext(Context$1);
|
|
761
|
-
}
|
|
762
|
-
function MakeswiftProvider({
|
|
763
|
-
client,
|
|
764
|
-
children
|
|
765
|
-
}) {
|
|
766
|
-
return /* @__PURE__ */ jsx(Context$1.Provider, {
|
|
767
|
-
value: client,
|
|
768
|
-
children
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
115
|
const SnippetLocation = {
|
|
772
116
|
Body: "BODY",
|
|
773
117
|
Head: "HEAD"
|
|
@@ -968,11 +312,11 @@ function useCachedSite(siteId) {
|
|
|
968
312
|
const site = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
969
313
|
return site;
|
|
970
314
|
}
|
|
971
|
-
const version = "0.0.0-20230407200421";
|
|
972
315
|
class Makeswift {
|
|
973
316
|
constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
|
|
974
317
|
__publicField(this, "apiKey");
|
|
975
318
|
__publicField(this, "apiOrigin");
|
|
319
|
+
__publicField(this, "graphqlClient");
|
|
976
320
|
if (typeof apiKey !== "string") {
|
|
977
321
|
throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
|
|
978
322
|
Received "${apiKey}" instead.`);
|
|
@@ -983,6 +327,7 @@ Received "${apiKey}" instead.`);
|
|
|
983
327
|
} catch {
|
|
984
328
|
throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
|
|
985
329
|
}
|
|
330
|
+
this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
|
|
986
331
|
}
|
|
987
332
|
async fetch(path, init) {
|
|
988
333
|
const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
|
|
@@ -999,9 +344,149 @@ Received "${apiKey}" instead.`);
|
|
|
999
344
|
const json = await response.json();
|
|
1000
345
|
return json;
|
|
1001
346
|
}
|
|
347
|
+
async getTypographies(typographyIds) {
|
|
348
|
+
const result = await this.graphqlClient.request(TypographiesQuery, { typographyIds });
|
|
349
|
+
return result.typographies;
|
|
350
|
+
}
|
|
351
|
+
async getIntrospectedResources(introspectedResourceIds) {
|
|
352
|
+
const result = await this.graphqlClient.request(IntrospectedResourcesQuery, introspectedResourceIds);
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
async introspect(element) {
|
|
356
|
+
const descriptors = getPropControllerDescriptors(storeContextDefaultValue.getState());
|
|
357
|
+
const swatchIds = /* @__PURE__ */ new Set();
|
|
358
|
+
const fileIds = /* @__PURE__ */ new Set();
|
|
359
|
+
const typographyIds = /* @__PURE__ */ new Set();
|
|
360
|
+
const tableIds = /* @__PURE__ */ new Set();
|
|
361
|
+
const pageIds = /* @__PURE__ */ new Set();
|
|
362
|
+
const globalElements = /* @__PURE__ */ new Map();
|
|
363
|
+
const remaining = [element];
|
|
364
|
+
const seen = /* @__PURE__ */ new Set();
|
|
365
|
+
let current;
|
|
366
|
+
while (current = remaining.pop()) {
|
|
367
|
+
let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
|
|
368
|
+
Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
|
|
369
|
+
getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
|
|
370
|
+
swatchIds.add(swatchId);
|
|
371
|
+
});
|
|
372
|
+
getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
|
|
373
|
+
getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
|
|
374
|
+
getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
|
|
375
|
+
getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
|
|
376
|
+
getElementChildren(descriptor, props[propName]).forEach((child) => {
|
|
377
|
+
if (!seen.has(child.key)) {
|
|
378
|
+
seen.add(child.key);
|
|
379
|
+
remaining.push(child);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
if (descriptor.type === ShapeControlType) {
|
|
383
|
+
const prop = props[propName];
|
|
384
|
+
if (prop == null)
|
|
385
|
+
return;
|
|
386
|
+
getResourcesFromElementDescriptors(descriptor.config.type, prop);
|
|
387
|
+
}
|
|
388
|
+
if (descriptor.type === ListControlType) {
|
|
389
|
+
const prop = props[propName];
|
|
390
|
+
if (prop == null)
|
|
391
|
+
return;
|
|
392
|
+
prop.forEach((item) => {
|
|
393
|
+
getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (descriptor.type === Types.Shape) {
|
|
397
|
+
const prop = props[propName];
|
|
398
|
+
if (prop == null)
|
|
399
|
+
return;
|
|
400
|
+
getResourcesFromElementDescriptors(descriptor.options.type, prop);
|
|
401
|
+
}
|
|
402
|
+
if (descriptor.type === Types.List) {
|
|
403
|
+
const prop = props[propName];
|
|
404
|
+
if (prop == null)
|
|
405
|
+
return;
|
|
406
|
+
prop.forEach((item) => {
|
|
407
|
+
getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
let element2;
|
|
413
|
+
if (isElementReference(current)) {
|
|
414
|
+
const globalElement = await this.getGlobalElement(current.value);
|
|
415
|
+
globalElements.set(current.value, globalElement);
|
|
416
|
+
const elementData = globalElement == null ? void 0 : globalElement.data;
|
|
417
|
+
if (elementData == null)
|
|
418
|
+
continue;
|
|
419
|
+
element2 = elementData;
|
|
420
|
+
} else {
|
|
421
|
+
element2 = current;
|
|
422
|
+
}
|
|
423
|
+
const elementDescriptors = descriptors.get(element2.type);
|
|
424
|
+
if (elementDescriptors == null)
|
|
425
|
+
continue;
|
|
426
|
+
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
427
|
+
}
|
|
428
|
+
const typographies = await this.getTypographies([...typographyIds]);
|
|
429
|
+
typographies.forEach((typography) => {
|
|
430
|
+
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
431
|
+
var _a;
|
|
432
|
+
const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
|
|
433
|
+
if (swatchId != null)
|
|
434
|
+
swatchIds.add(swatchId);
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
const { swatches, files, tables, pagePathnamesById } = await this.getIntrospectedResources({
|
|
438
|
+
swatchIds: [...swatchIds],
|
|
439
|
+
fileIds: [...fileIds],
|
|
440
|
+
tableIds: [...tableIds],
|
|
441
|
+
pageIds: [...pageIds]
|
|
442
|
+
});
|
|
443
|
+
const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
|
|
444
|
+
id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
|
|
445
|
+
}));
|
|
446
|
+
return {
|
|
447
|
+
[APIResourceType.Swatch]: [...swatchIds].map((id) => {
|
|
448
|
+
var _a;
|
|
449
|
+
return {
|
|
450
|
+
id,
|
|
451
|
+
value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
|
|
452
|
+
};
|
|
453
|
+
}),
|
|
454
|
+
[APIResourceType.File]: [...fileIds].map((id) => {
|
|
455
|
+
var _a;
|
|
456
|
+
return {
|
|
457
|
+
id,
|
|
458
|
+
value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
|
|
459
|
+
};
|
|
460
|
+
}),
|
|
461
|
+
[APIResourceType.Typography]: [...typographyIds].map((id) => {
|
|
462
|
+
var _a;
|
|
463
|
+
return {
|
|
464
|
+
id,
|
|
465
|
+
value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
|
|
466
|
+
};
|
|
467
|
+
}),
|
|
468
|
+
[APIResourceType.Table]: [...tableIds].map((id) => {
|
|
469
|
+
var _a;
|
|
470
|
+
return {
|
|
471
|
+
id,
|
|
472
|
+
value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
|
|
473
|
+
};
|
|
474
|
+
}),
|
|
475
|
+
[APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
|
|
476
|
+
var _a;
|
|
477
|
+
return {
|
|
478
|
+
id,
|
|
479
|
+
value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
|
|
480
|
+
};
|
|
481
|
+
}),
|
|
482
|
+
[APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
|
|
483
|
+
id,
|
|
484
|
+
value
|
|
485
|
+
}))
|
|
486
|
+
};
|
|
487
|
+
}
|
|
1002
488
|
async createSnapshot(document2, preview) {
|
|
1003
|
-
const
|
|
1004
|
-
const cacheData = await client.prefetch(document2.data);
|
|
489
|
+
const cacheData = await this.introspect(document2.data);
|
|
1005
490
|
return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
|
|
1006
491
|
}
|
|
1007
492
|
async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
|
|
@@ -1022,161 +507,30 @@ Received "${apiKey}" instead.`);
|
|
|
1022
507
|
const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
|
|
1023
508
|
return snapshot;
|
|
1024
509
|
}
|
|
1025
|
-
async
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
return null;
|
|
1029
|
-
const document2 = await this.getDocumentForPage(page.id);
|
|
1030
|
-
const snapshot = await this.unstable_createSnapshotOnDemand({ document: document2, pageId: page.id });
|
|
1031
|
-
return {
|
|
1032
|
-
pageId: page.id,
|
|
1033
|
-
siteId: document2.site.id,
|
|
1034
|
-
snapshot,
|
|
1035
|
-
options: { preview: preview || false, apiOrigin: this.apiOrigin.href }
|
|
1036
|
-
};
|
|
510
|
+
async getSwatch(swatchId) {
|
|
511
|
+
const result = await this.graphqlClient.request(SwatchQuery, { swatchId });
|
|
512
|
+
return result.swatch;
|
|
1037
513
|
}
|
|
1038
|
-
async
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
if (response.status === 404)
|
|
1042
|
-
throw Error("Document not found.");
|
|
1043
|
-
throw new Error(`Failed to create snapshot with error: "${response.statusText}"`);
|
|
1044
|
-
}
|
|
1045
|
-
const document2 = await response.json();
|
|
1046
|
-
return document2;
|
|
514
|
+
async getFile(fileId) {
|
|
515
|
+
const result = await this.graphqlClient.request(FileQuery, { fileId });
|
|
516
|
+
return result.file;
|
|
1047
517
|
}
|
|
1048
|
-
async
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}) {
|
|
1052
|
-
let fetchedDocument = document2;
|
|
1053
|
-
if (fetchedDocument == null) {
|
|
1054
|
-
const response = await this.fetch(`/v1/pages/${pageId}/document?preview=false`);
|
|
1055
|
-
if (!response.ok) {
|
|
1056
|
-
if (response.status === 404) {
|
|
1057
|
-
throw new Error("Not found");
|
|
1058
|
-
}
|
|
1059
|
-
throw new Error(`Failed to create snapshot with error: "${response.statusText}"`);
|
|
1060
|
-
}
|
|
1061
|
-
fetchedDocument = await response.json();
|
|
1062
|
-
}
|
|
1063
|
-
if (fetchedDocument == null) {
|
|
1064
|
-
throw Error("fetchedDocument should never be null");
|
|
1065
|
-
}
|
|
1066
|
-
const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
|
|
1067
|
-
const prefetchedResources = await client.prefetch(fetchedDocument.data);
|
|
1068
|
-
const resources = normalizeToMakeswiftResources(getSnapshotResourcesFromSerializedState(prefetchedResources));
|
|
1069
|
-
resources.snippets = fetchedDocument.snippets.map((snippet) => ({
|
|
1070
|
-
id: snippet.id,
|
|
1071
|
-
value: snippet
|
|
1072
|
-
}));
|
|
1073
|
-
resources.pageMetadata = fetchedDocument.meta;
|
|
1074
|
-
resources.pageSeo = fetchedDocument.seo;
|
|
1075
|
-
resources.fonts = fetchedDocument.fonts.map((font) => ({ id: font.family, value: font }));
|
|
1076
|
-
return { resources, elementTree: fetchedDocument.data, runtimeVersion: version };
|
|
518
|
+
async getTypography(typographyId) {
|
|
519
|
+
const result = await this.graphqlClient.request(TypographyQuery, { typographyId });
|
|
520
|
+
return result.typography;
|
|
1077
521
|
}
|
|
1078
|
-
async
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
publishedElementTree,
|
|
1082
|
-
currentSnapshot
|
|
1083
|
-
}) {
|
|
1084
|
-
const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
|
|
1085
|
-
function mergeResources({
|
|
1086
|
-
resourcesFromPublishedElementTree: resourcesFromPublishedElementTree2,
|
|
1087
|
-
resourcesFromCurrentSnapshot: resourcesFromCurrentSnapshot2,
|
|
1088
|
-
publishedResources: publishedResources2,
|
|
1089
|
-
deletedResources: deletedResources2
|
|
1090
|
-
}) {
|
|
1091
|
-
function mergeIdSpecifiedResource(resourceSet, deletedResources3) {
|
|
1092
|
-
const map = new Map(resourceSet.map(({ id, value }) => [id, value]));
|
|
1093
|
-
deletedResources3 == null ? void 0 : deletedResources3.forEach((id) => map.delete(id));
|
|
1094
|
-
const finalResourceSet = [];
|
|
1095
|
-
Array.from(map.entries()).forEach(([id, value]) => {
|
|
1096
|
-
if (value != null) {
|
|
1097
|
-
finalResourceSet.push({ id, value });
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
return finalResourceSet;
|
|
1101
|
-
}
|
|
1102
|
-
const resources2 = {
|
|
1103
|
-
swatches: mergeIdSpecifiedResource([
|
|
1104
|
-
...resourcesFromPublishedElementTree2.swatches,
|
|
1105
|
-
...resourcesFromCurrentSnapshot2.swatches,
|
|
1106
|
-
...publishedResources2.swatches
|
|
1107
|
-
], deletedResources2 == null ? void 0 : deletedResources2.swatches),
|
|
1108
|
-
files: mergeIdSpecifiedResource([
|
|
1109
|
-
...resourcesFromPublishedElementTree2.files,
|
|
1110
|
-
...resourcesFromCurrentSnapshot2.files,
|
|
1111
|
-
...publishedResources2.files
|
|
1112
|
-
], deletedResources2 == null ? void 0 : deletedResources2.files),
|
|
1113
|
-
tables: mergeIdSpecifiedResource([
|
|
1114
|
-
...resourcesFromPublishedElementTree2.tables,
|
|
1115
|
-
...resourcesFromCurrentSnapshot2.tables,
|
|
1116
|
-
...publishedResources2.tables
|
|
1117
|
-
], deletedResources2 == null ? void 0 : deletedResources2.tables),
|
|
1118
|
-
typographies: mergeIdSpecifiedResource([
|
|
1119
|
-
...resourcesFromPublishedElementTree2.typographies,
|
|
1120
|
-
...resourcesFromCurrentSnapshot2.typographies,
|
|
1121
|
-
...publishedResources2.typographies
|
|
1122
|
-
], deletedResources2 == null ? void 0 : deletedResources2.typographies),
|
|
1123
|
-
pagePathnameSlices: mergeIdSpecifiedResource([
|
|
1124
|
-
...resourcesFromPublishedElementTree2.pagePathnameSlices,
|
|
1125
|
-
...resourcesFromCurrentSnapshot2.pagePathnameSlices,
|
|
1126
|
-
...publishedResources2.pagePathnameSlices
|
|
1127
|
-
], deletedResources2 == null ? void 0 : deletedResources2.pagePathnameSlices),
|
|
1128
|
-
globalElements: mergeIdSpecifiedResource([
|
|
1129
|
-
...resourcesFromPublishedElementTree2.globalElements,
|
|
1130
|
-
...resourcesFromCurrentSnapshot2.globalElements,
|
|
1131
|
-
...publishedResources2.globalElements
|
|
1132
|
-
], deletedResources2 == null ? void 0 : deletedResources2.globalElements),
|
|
1133
|
-
snippets: mergeIdSpecifiedResource([
|
|
1134
|
-
...resourcesFromPublishedElementTree2.snippets,
|
|
1135
|
-
...resourcesFromCurrentSnapshot2.snippets,
|
|
1136
|
-
...publishedResources2.snippets
|
|
1137
|
-
], deletedResources2 == null ? void 0 : deletedResources2.snippets),
|
|
1138
|
-
fonts: mergeIdSpecifiedResource([
|
|
1139
|
-
...resourcesFromPublishedElementTree2.fonts,
|
|
1140
|
-
...resourcesFromCurrentSnapshot2.fonts,
|
|
1141
|
-
...publishedResources2.fonts
|
|
1142
|
-
], deletedResources2 == null ? void 0 : deletedResources2.fonts),
|
|
1143
|
-
pageMetadata: __spreadValues(__spreadValues({}, resourcesFromCurrentSnapshot2.pageMetadata), publishedResources2.pageMetadata),
|
|
1144
|
-
pageSeo: __spreadValues(__spreadValues({}, resourcesFromCurrentSnapshot2.pageSeo), publishedResources2.pageSeo)
|
|
1145
|
-
};
|
|
1146
|
-
return resources2;
|
|
1147
|
-
}
|
|
1148
|
-
const resourcesFromPublishedElementTree = publishedElementTree != null ? normalizeToMakeswiftResources(getSnapshotResourcesFromSerializedState(await client.prefetch(publishedElementTree))) : normalizeToMakeswiftResources({});
|
|
1149
|
-
const resourcesFromCurrentSnapshot = normalizeToMakeswiftResources((currentSnapshot == null ? void 0 : currentSnapshot.resources) || {});
|
|
1150
|
-
const resources = mergeResources({
|
|
1151
|
-
resourcesFromPublishedElementTree,
|
|
1152
|
-
resourcesFromCurrentSnapshot,
|
|
1153
|
-
publishedResources: normalizeToMakeswiftResources(publishedResources),
|
|
1154
|
-
deletedResources
|
|
1155
|
-
});
|
|
1156
|
-
const elementTree = publishedElementTree || (currentSnapshot == null ? void 0 : currentSnapshot.elementTree);
|
|
1157
|
-
if (elementTree == null) {
|
|
1158
|
-
throw Error("elementTree should not be null; something went wrong.");
|
|
1159
|
-
}
|
|
1160
|
-
return {
|
|
1161
|
-
resources,
|
|
1162
|
-
elementTree,
|
|
1163
|
-
runtimeVersion: version
|
|
1164
|
-
};
|
|
522
|
+
async getGlobalElement(globalElementId) {
|
|
523
|
+
const result = await this.graphqlClient.request(GlobalElementQuery, { globalElementId });
|
|
524
|
+
return result.globalElement;
|
|
1165
525
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
...resources.tables.map(parseResourceIds),
|
|
1175
|
-
...resources.typographies.map(parseResourceIds),
|
|
1176
|
-
...resources.pagePathnameSlices.map(parseResourceIds),
|
|
1177
|
-
...resources.globalElements.map(parseResourceIds),
|
|
1178
|
-
...resources.snippets.map(parseResourceIds)
|
|
1179
|
-
];
|
|
526
|
+
async getPagePathnameSlice(pageId) {
|
|
527
|
+
var _a;
|
|
528
|
+
const result = await this.graphqlClient.request(PagePathnamesByIdQuery, { pageIds: [pageId] });
|
|
529
|
+
return (_a = result.pagePathnamesById.at(0)) != null ? _a : null;
|
|
530
|
+
}
|
|
531
|
+
async getTable(tableId) {
|
|
532
|
+
const result = await this.graphqlClient.request(TableQuery, { tableId });
|
|
533
|
+
return result.table;
|
|
1180
534
|
}
|
|
1181
535
|
}
|
|
1182
536
|
function PreviewModeScript({
|
|
@@ -1306,28 +660,111 @@ class Document$1 extends NextDocument {
|
|
|
1306
660
|
});
|
|
1307
661
|
}
|
|
1308
662
|
}
|
|
663
|
+
async function elementTree(req, res) {
|
|
664
|
+
const elementTree2 = req.body.elementTree;
|
|
665
|
+
const replacementContext = req.body.replacementContext;
|
|
666
|
+
if (elementTree2 == null) {
|
|
667
|
+
return res.status(400).json({ message: "elementTree must be defined" });
|
|
668
|
+
}
|
|
669
|
+
if (replacementContext == null) {
|
|
670
|
+
return res.status(400).json({ message: "replacementContext must be defined" });
|
|
671
|
+
}
|
|
672
|
+
const generatedElementTree = ReactRuntime.copyElementTree(elementTree2, replacementContext);
|
|
673
|
+
const response = { elementTree: generatedElementTree };
|
|
674
|
+
return res.json(response);
|
|
675
|
+
}
|
|
676
|
+
async function fonts(_req, res, { getFonts } = {}) {
|
|
677
|
+
var _a;
|
|
678
|
+
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
679
|
+
return res.json(fonts2);
|
|
680
|
+
}
|
|
681
|
+
const version = "0.0.0-20230410231005";
|
|
682
|
+
async function handler(req, res, { apiKey }) {
|
|
683
|
+
if (req.query.secret !== apiKey) {
|
|
684
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
685
|
+
}
|
|
686
|
+
return res.json({
|
|
687
|
+
version,
|
|
688
|
+
previewMode: true,
|
|
689
|
+
interactionMode: true,
|
|
690
|
+
clientSideNavigation: true,
|
|
691
|
+
elementFromPoint: false
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
const previewModeProxy = createProxyServer();
|
|
695
|
+
async function proxyPreviewMode(req, res, { apiKey }) {
|
|
696
|
+
previewModeProxy.on("proxyReq", (proxyReq) => {
|
|
697
|
+
proxyReq.removeHeader("X-Makeswift-Preview-Mode");
|
|
698
|
+
const url = new URL(proxyReq.path, "http://n");
|
|
699
|
+
url.searchParams.delete("x-makeswift-preview-mode");
|
|
700
|
+
proxyReq.path = url.pathname + url.search;
|
|
701
|
+
});
|
|
702
|
+
if (req.query.secret !== apiKey)
|
|
703
|
+
return res.status(401).send("Unauthorized");
|
|
704
|
+
const host = req.headers.host;
|
|
705
|
+
if (host == null)
|
|
706
|
+
return res.status(400).send("Bad Request");
|
|
707
|
+
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
708
|
+
const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
|
|
709
|
+
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
710
|
+
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
711
|
+
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
712
|
+
let target = `${proto}://${host}`;
|
|
713
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
714
|
+
const port = req.socket.localPort;
|
|
715
|
+
if (port != null)
|
|
716
|
+
target = `http://localhost:${port}`;
|
|
717
|
+
}
|
|
718
|
+
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
719
|
+
res.removeHeader("Set-Cookie");
|
|
720
|
+
if (!Array.isArray(setCookie))
|
|
721
|
+
return res.status(500).send("Internal Server Error");
|
|
722
|
+
const cookie = parse$1(setCookie).map((cookie2) => serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
723
|
+
return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie } }, (err) => {
|
|
724
|
+
if (err)
|
|
725
|
+
reject(err);
|
|
726
|
+
else
|
|
727
|
+
resolve2();
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
1309
730
|
function isErrorWithMessage(error) {
|
|
1310
731
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
1311
732
|
}
|
|
733
|
+
async function revalidate(req, res, { apiKey }) {
|
|
734
|
+
if (req.query.secret !== apiKey) {
|
|
735
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
736
|
+
}
|
|
737
|
+
if (typeof req.query.path !== "string") {
|
|
738
|
+
return res.status(400).json({ message: "Bad Request" });
|
|
739
|
+
}
|
|
740
|
+
const revalidate2 = res.revalidate;
|
|
741
|
+
if (typeof revalidate2 !== "function") {
|
|
742
|
+
const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
|
|
743
|
+
Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
|
|
744
|
+
console.warn(message);
|
|
745
|
+
return res.json({ revalidated: false });
|
|
746
|
+
}
|
|
747
|
+
try {
|
|
748
|
+
await revalidate2(req.query.path);
|
|
749
|
+
return res.json({ revalidated: true });
|
|
750
|
+
} catch (error) {
|
|
751
|
+
if (isErrorWithMessage(error)) {
|
|
752
|
+
return res.status(500).json({ message: error.message });
|
|
753
|
+
}
|
|
754
|
+
return res.status(500).json({ message: "Error Revalidating" });
|
|
755
|
+
}
|
|
756
|
+
}
|
|
1312
757
|
function MakeswiftApiHandler(apiKey, {
|
|
1313
758
|
appOrigin = "https://app.makeswift.com",
|
|
1314
759
|
apiOrigin = "https://api.makeswift.com",
|
|
1315
760
|
getFonts
|
|
1316
761
|
} = {}) {
|
|
1317
762
|
const cors = Cors({ origin: appOrigin });
|
|
1318
|
-
const previewModeProxy = createProxyServer();
|
|
1319
|
-
previewModeProxy.on("proxyReq", (proxyReq) => {
|
|
1320
|
-
proxyReq.removeHeader("X-Makeswift-Preview-Mode");
|
|
1321
|
-
const url = new URL(proxyReq.path, "http://n");
|
|
1322
|
-
url.searchParams.delete("x-makeswift-preview-mode");
|
|
1323
|
-
proxyReq.path = url.pathname + url.search;
|
|
1324
|
-
});
|
|
1325
763
|
if (typeof apiKey !== "string") {
|
|
1326
764
|
throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
|
|
1327
765
|
Received "${apiKey}" instead.`);
|
|
1328
766
|
}
|
|
1329
767
|
return async function makeswiftApiHandler(req, res) {
|
|
1330
|
-
var _a;
|
|
1331
768
|
await new Promise((resolve2, reject) => {
|
|
1332
769
|
cors(req, res, (err) => {
|
|
1333
770
|
if (err instanceof Error)
|
|
@@ -1342,224 +779,40 @@ Received "${apiKey}" instead.`);
|
|
|
1342
779
|
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
1343
780
|
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
|
|
1344
781
|
}
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
return res.status(500).json({ message: "Error Revalidating" });
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
case "proxy-preview-mode": {
|
|
1383
|
-
if (req.query.secret !== apiKey)
|
|
1384
|
-
return res.status(401).send("Unauthorized");
|
|
1385
|
-
const host = req.headers.host;
|
|
1386
|
-
if (host == null)
|
|
1387
|
-
return res.status(400).send("Bad Request");
|
|
1388
|
-
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
1389
|
-
const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
|
|
1390
|
-
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
1391
|
-
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
1392
|
-
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
1393
|
-
let target = `${proto}://${host}`;
|
|
1394
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
1395
|
-
const port = req.socket.localPort;
|
|
1396
|
-
if (port != null)
|
|
1397
|
-
target = `http://localhost:${port}`;
|
|
1398
|
-
}
|
|
1399
|
-
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
1400
|
-
res.removeHeader("Set-Cookie");
|
|
1401
|
-
if (!Array.isArray(setCookie))
|
|
1402
|
-
return res.status(500).send("Internal Server Error");
|
|
1403
|
-
const cookie = parse$1(setCookie).map((cookie2) => serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
1404
|
-
return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie } }, (err) => {
|
|
1405
|
-
if (err)
|
|
1406
|
-
reject(err);
|
|
1407
|
-
else
|
|
1408
|
-
resolve2();
|
|
1409
|
-
}));
|
|
1410
|
-
}
|
|
1411
|
-
case "fonts": {
|
|
1412
|
-
const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1413
|
-
return res.json(fonts);
|
|
1414
|
-
}
|
|
1415
|
-
case "element-tree": {
|
|
1416
|
-
const elementTree = req.body.elementTree;
|
|
1417
|
-
const replacementContext = req.body.replacementContext;
|
|
1418
|
-
if (elementTree == null) {
|
|
1419
|
-
return res.status(400).json({ message: "elementTree must be defined" });
|
|
1420
|
-
}
|
|
1421
|
-
if (replacementContext == null) {
|
|
1422
|
-
return res.status(400).json({ message: "replacementContext must be defined" });
|
|
1423
|
-
}
|
|
1424
|
-
const generatedElementTree = ReactRuntime.copyElementTree(elementTree, replacementContext);
|
|
1425
|
-
const response = { elementTree: generatedElementTree };
|
|
1426
|
-
return res.json(response);
|
|
1427
|
-
}
|
|
1428
|
-
case "snapshot": {
|
|
1429
|
-
let validateBody = function(body2) {
|
|
1430
|
-
if (body2.pageId == null) {
|
|
1431
|
-
return res.status(400).json({ message: "Must define pageId." });
|
|
1432
|
-
}
|
|
1433
|
-
if (body2.currentSnapshot == null && body2.publishedElementTree == null) {
|
|
1434
|
-
return res.status(400).json({ message: "Either currentSnapshot or publishedElementTree must be defined." });
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
const body = req.body;
|
|
1438
|
-
validateBody(body);
|
|
1439
|
-
const client = new Makeswift(apiKey, {
|
|
1440
|
-
apiOrigin
|
|
1441
|
-
});
|
|
1442
|
-
const makeswiftApiClient = new MakeswiftClient({ uri: new URL("graphql", apiOrigin).href });
|
|
1443
|
-
async function formMakeswiftResources(publishedResources) {
|
|
1444
|
-
var _a2, _b, _c2, _d, _e, _f, _g, _h;
|
|
1445
|
-
const publishedResourcesInMakeswiftSnapshotFormat = {
|
|
1446
|
-
swatches: [],
|
|
1447
|
-
typographies: [],
|
|
1448
|
-
files: [],
|
|
1449
|
-
tables: [],
|
|
1450
|
-
pagePathnameSlices: [],
|
|
1451
|
-
globalElements: [],
|
|
1452
|
-
snippets: [],
|
|
1453
|
-
fonts: [],
|
|
1454
|
-
pageMetadata: publishedResources == null ? void 0 : publishedResources.pageMetadata,
|
|
1455
|
-
pageSeo: publishedResources == null ? void 0 : publishedResources.pageSeo
|
|
1456
|
-
};
|
|
1457
|
-
if (publishedResources == null) {
|
|
1458
|
-
return publishedResourcesInMakeswiftSnapshotFormat;
|
|
1459
|
-
}
|
|
1460
|
-
for await (const swatchId of publishedResources.swatches || []) {
|
|
1461
|
-
const swatch = await makeswiftApiClient.fetchSwatch(swatchId);
|
|
1462
|
-
if (swatch != null) {
|
|
1463
|
-
(_a2 = publishedResourcesInMakeswiftSnapshotFormat.swatches) == null ? void 0 : _a2.push({
|
|
1464
|
-
id: swatchId,
|
|
1465
|
-
value: swatch
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
for await (const typographyId of publishedResources.typographies || []) {
|
|
1470
|
-
const typography = await makeswiftApiClient.fetchTypography(typographyId);
|
|
1471
|
-
if (typography != null) {
|
|
1472
|
-
(_b = publishedResourcesInMakeswiftSnapshotFormat.typographies) == null ? void 0 : _b.push({
|
|
1473
|
-
id: typographyId,
|
|
1474
|
-
value: typography
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
for await (const fileId of publishedResources.files || []) {
|
|
1479
|
-
const file = await makeswiftApiClient.fetchFile(fileId);
|
|
1480
|
-
if (file != null) {
|
|
1481
|
-
(_c2 = publishedResourcesInMakeswiftSnapshotFormat.files) == null ? void 0 : _c2.push({
|
|
1482
|
-
id: fileId,
|
|
1483
|
-
value: fileToFileSnapshot(file)
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
for await (const tableId of publishedResources.tables || []) {
|
|
1488
|
-
const table = await makeswiftApiClient.fetchTable(tableId);
|
|
1489
|
-
if (table != null) {
|
|
1490
|
-
(_d = publishedResourcesInMakeswiftSnapshotFormat.tables) == null ? void 0 : _d.push({
|
|
1491
|
-
id: tableId,
|
|
1492
|
-
value: table
|
|
1493
|
-
});
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
for await (const pageId of publishedResources.pagePathnameSlices || []) {
|
|
1497
|
-
const pagePathnameSlice = await makeswiftApiClient.fetchPagePathnameSlice(pageId);
|
|
1498
|
-
if (pagePathnameSlice != null) {
|
|
1499
|
-
(_e = publishedResourcesInMakeswiftSnapshotFormat.pagePathnameSlices) == null ? void 0 : _e.push({
|
|
1500
|
-
id: pageId,
|
|
1501
|
-
value: pagePathnameSlice
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
for await (const globalElementId of publishedResources.globalElements || []) {
|
|
1506
|
-
const globalElement = await makeswiftApiClient.fetchGlobalElement(globalElementId);
|
|
1507
|
-
if (globalElement != null) {
|
|
1508
|
-
(_f = publishedResourcesInMakeswiftSnapshotFormat.globalElements) == null ? void 0 : _f.push({
|
|
1509
|
-
id: globalElementId,
|
|
1510
|
-
value: globalElement
|
|
1511
|
-
});
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
if (publishedResources.snippets != null || publishedResources.fonts != null) {
|
|
1515
|
-
const response2 = await fetch(new URL(`/v1/pages/${body.pageId}/document?preview=false`, apiOrigin).toString(), {
|
|
1516
|
-
headers: { ["X-API-Key"]: apiKey }
|
|
1517
|
-
});
|
|
1518
|
-
if (!response2.ok) {
|
|
1519
|
-
throw new Error(`Failed to hit live page endpoint: "${response2.statusText}"`);
|
|
1520
|
-
}
|
|
1521
|
-
const document2 = await response2.json();
|
|
1522
|
-
const availableSnippets = document2.snippets;
|
|
1523
|
-
const availableFonts = document2.fonts;
|
|
1524
|
-
for await (const snippetId of publishedResources.snippets || []) {
|
|
1525
|
-
const snippet = availableSnippets.find((availableSnippet) => availableSnippet.id === snippetId);
|
|
1526
|
-
if (snippet != null) {
|
|
1527
|
-
(_g = publishedResourcesInMakeswiftSnapshotFormat.snippets) == null ? void 0 : _g.push({
|
|
1528
|
-
id: snippetId,
|
|
1529
|
-
value: snippet
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
for await (const family of publishedResources.fonts || []) {
|
|
1534
|
-
const font = availableFonts.find((availableFont) => availableFont.family === family);
|
|
1535
|
-
if (font != null) {
|
|
1536
|
-
(_h = publishedResourcesInMakeswiftSnapshotFormat.fonts) == null ? void 0 : _h.push({
|
|
1537
|
-
id: family,
|
|
1538
|
-
value: font
|
|
1539
|
-
});
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
return publishedResourcesInMakeswiftSnapshotFormat;
|
|
1544
|
-
}
|
|
1545
|
-
const snapshot = await client.unstable_createSnapshot({
|
|
1546
|
-
publishedResources: await formMakeswiftResources(body.publishedResources),
|
|
1547
|
-
deletedResources: body.deletedResources,
|
|
1548
|
-
publishedElementTree: body.publishedElementTree,
|
|
1549
|
-
currentSnapshot: body.currentSnapshot
|
|
1550
|
-
});
|
|
1551
|
-
const usedResources = client.unstable_getSnapshotResourceMapping(snapshot);
|
|
1552
|
-
const response = {
|
|
1553
|
-
pageId: body.pageId,
|
|
1554
|
-
snapshot,
|
|
1555
|
-
livePageChanges: body.livePageChanges,
|
|
1556
|
-
usedResources
|
|
1557
|
-
};
|
|
1558
|
-
return res.json(response);
|
|
1559
|
-
}
|
|
1560
|
-
default:
|
|
1561
|
-
return res.status(404).json({ message: "Not Found" });
|
|
1562
|
-
}
|
|
782
|
+
const client = new Makeswift(apiKey, { apiOrigin });
|
|
783
|
+
const action = "/" + makeswift.join("/");
|
|
784
|
+
const matches = (pattern) => match(pattern, { decode: decodeURIComponent })(action);
|
|
785
|
+
let m;
|
|
786
|
+
if (matches("/manifest"))
|
|
787
|
+
return handler(req, res, { apiKey });
|
|
788
|
+
if (matches("/revalidate"))
|
|
789
|
+
return revalidate(req, res, { apiKey });
|
|
790
|
+
if (matches("/proxy-preview-mode"))
|
|
791
|
+
return proxyPreviewMode(req, res, { apiKey });
|
|
792
|
+
if (matches("/fonts"))
|
|
793
|
+
return fonts(req, res, { getFonts });
|
|
794
|
+
if (matches("/element-tree"))
|
|
795
|
+
return elementTree(req, res);
|
|
796
|
+
const handleResource = (resource) => resource === null ? res.status(404).json({ message: "Not Found" }) : res.json(resource);
|
|
797
|
+
if (m = matches("/swatches/:id")) {
|
|
798
|
+
return client.getSwatch(m.params.id).then(handleResource);
|
|
799
|
+
}
|
|
800
|
+
if (m = matches("/files/:id")) {
|
|
801
|
+
return client.getFile(m.params.id).then(handleResource);
|
|
802
|
+
}
|
|
803
|
+
if (m = matches("/typographies/:id")) {
|
|
804
|
+
return client.getTypography(m.params.id).then(handleResource);
|
|
805
|
+
}
|
|
806
|
+
if (m = matches("/global-elements/:id")) {
|
|
807
|
+
return client.getGlobalElement(m.params.id).then(handleResource);
|
|
808
|
+
}
|
|
809
|
+
if (m = matches("/page-pathname-slices/:id")) {
|
|
810
|
+
return client.getPagePathnameSlice(m.params.id).then(handleResource);
|
|
811
|
+
}
|
|
812
|
+
if (m = matches("/tables/:id")) {
|
|
813
|
+
return client.getTable(m.params.id).then(handleResource);
|
|
814
|
+
}
|
|
815
|
+
return res.status(404).json({ message: "Not Found" });
|
|
1563
816
|
};
|
|
1564
817
|
}
|
|
1565
818
|
const FORWARDED_NEXT_DYNAMIC_REF_KEY = "__forwarded_next_dynamic_ref__";
|
|
@@ -1634,14 +887,14 @@ async function getStaticPaths() {
|
|
|
1634
887
|
}
|
|
1635
888
|
const REVALIDATE_SECONDS = 1;
|
|
1636
889
|
async function getStaticProps(ctx) {
|
|
1637
|
-
var _a, _b,
|
|
890
|
+
var _a, _b, _c;
|
|
1638
891
|
deprecationWarning("getStaticProps");
|
|
1639
892
|
const makeswift = new Makeswift(getApiKey(), {
|
|
1640
893
|
apiOrigin: getApiOrigin()
|
|
1641
894
|
});
|
|
1642
895
|
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1643
896
|
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1644
|
-
preview: ((
|
|
897
|
+
preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
|
|
1645
898
|
});
|
|
1646
899
|
if (snapshot == null)
|
|
1647
900
|
return {
|
|
@@ -1691,69 +944,6 @@ const Page = memo(({
|
|
|
1691
944
|
}, snapshot.document.data.key)
|
|
1692
945
|
});
|
|
1693
946
|
});
|
|
1694
|
-
const keys = (o) => Object.keys(o);
|
|
1695
|
-
const coalesce = (...args) => {
|
|
1696
|
-
let i;
|
|
1697
|
-
for (i = 0; i < args.length - 1; i += 1) {
|
|
1698
|
-
if (args[i] != null)
|
|
1699
|
-
return args[i];
|
|
1700
|
-
}
|
|
1701
|
-
return args[i];
|
|
1702
|
-
};
|
|
1703
|
-
function shallowMerge(a, b) {
|
|
1704
|
-
const bKeys = keys(b);
|
|
1705
|
-
const merged = __spreadValues({}, a);
|
|
1706
|
-
bKeys.forEach((key) => {
|
|
1707
|
-
merged[key] = coalesce(merged[key], b[key]);
|
|
1708
|
-
});
|
|
1709
|
-
return merged;
|
|
1710
|
-
}
|
|
1711
|
-
const DEVICES = [
|
|
1712
|
-
{ id: "desktop", minWidth: 769 },
|
|
1713
|
-
{ id: "tablet", minWidth: 576, maxWidth: 768 },
|
|
1714
|
-
{ id: "mobile", maxWidth: 575 }
|
|
1715
|
-
];
|
|
1716
|
-
const getDevice = (deviceId) => {
|
|
1717
|
-
const device = DEVICES.find(({ id }) => id === deviceId);
|
|
1718
|
-
if (device == null)
|
|
1719
|
-
throw new Error(`Unrecognized device ID: "${deviceId}".`);
|
|
1720
|
-
return device;
|
|
1721
|
-
};
|
|
1722
|
-
function defaultStrategy(value, fallbacks) {
|
|
1723
|
-
return value || fallbacks[0];
|
|
1724
|
-
}
|
|
1725
|
-
function shallowMergeFallbacks(value, fallbacks) {
|
|
1726
|
-
return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
|
|
1727
|
-
deviceId: a.deviceId || b.deviceId,
|
|
1728
|
-
value: shallowMerge(a.value, b.value)
|
|
1729
|
-
}));
|
|
1730
|
-
}
|
|
1731
|
-
function findDeviceOverride(values = [], deviceId, strategy = defaultStrategy) {
|
|
1732
|
-
const value = values.find(({ deviceId: d }) => d === deviceId);
|
|
1733
|
-
const fallbacks = DEVICES.slice(0, DEVICES.findIndex((d) => d.id === deviceId) + 1).reverse().map((d) => values.find((v) => v.deviceId === d.id)).filter((override) => Boolean(override));
|
|
1734
|
-
return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
|
|
1735
|
-
}
|
|
1736
|
-
function join(responsiveValues, joinFn, strategy) {
|
|
1737
|
-
return DEVICES.map(({ id }) => id).map((deviceId) => {
|
|
1738
|
-
const value = joinFn(responsiveValues.map((responsiveValue) => {
|
|
1739
|
-
const deviceValue = responsiveValue && findDeviceOverride(responsiveValue, deviceId, strategy);
|
|
1740
|
-
return deviceValue == null ? void 0 : deviceValue.value;
|
|
1741
|
-
}));
|
|
1742
|
-
if (value == null)
|
|
1743
|
-
return null;
|
|
1744
|
-
return { deviceId, value };
|
|
1745
|
-
}).filter((override) => Boolean(override));
|
|
1746
|
-
}
|
|
1747
|
-
const getDeviceMediaQuery = (device) => {
|
|
1748
|
-
const parts = ["@media only screen"];
|
|
1749
|
-
if (device.minWidth != null) {
|
|
1750
|
-
parts.push(`(min-width: ${device.minWidth}px)`);
|
|
1751
|
-
}
|
|
1752
|
-
if (device.maxWidth != null) {
|
|
1753
|
-
parts.push(`(max-width: ${device.maxWidth}px)`);
|
|
1754
|
-
}
|
|
1755
|
-
return parts.join(" and ");
|
|
1756
|
-
};
|
|
1757
947
|
const DEFAULT_BOX_ANIMATE_TYPE = "none";
|
|
1758
948
|
const DEFAULT_BOX_ANIMATE_DELAY = 0;
|
|
1759
949
|
const DEFAULT_BOX_ANIMATE_DURATION = 0.75;
|
|
@@ -2027,7 +1217,7 @@ function registerComponent$a(runtime) {
|
|
|
2027
1217
|
defaultValue: { value: 0, unit: "px" }
|
|
2028
1218
|
}),
|
|
2029
1219
|
autoplay: Checkbox({ label: "Autoplay" }),
|
|
2030
|
-
delay: Number
|
|
1220
|
+
delay: Number((props) => ({
|
|
2031
1221
|
label: "Delay",
|
|
2032
1222
|
preset: 5,
|
|
2033
1223
|
min: 1,
|
|
@@ -2708,19 +1898,6 @@ function registerBuiltinComponents(runtime) {
|
|
|
2708
1898
|
unregisterVideoComponent();
|
|
2709
1899
|
};
|
|
2710
1900
|
}
|
|
2711
|
-
const isServer = typeof window === "undefined";
|
|
2712
|
-
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
2713
|
-
const useInsertionEffect = (_c = React[useInsertionEffectSpecifier]) != null ? _c : React.useLayoutEffect;
|
|
2714
|
-
function useStyle(style) {
|
|
2715
|
-
const serialized = serializeStyles([style], cache.registered);
|
|
2716
|
-
registerStyles(cache, serialized, false);
|
|
2717
|
-
useInsertionEffect(() => {
|
|
2718
|
-
insertStyles(cache, serialized, false);
|
|
2719
|
-
});
|
|
2720
|
-
if (isServer)
|
|
2721
|
-
insertStyles(cache, serialized, false);
|
|
2722
|
-
return `${cache.key}-${serialized.name}`;
|
|
2723
|
-
}
|
|
2724
1901
|
var _path;
|
|
2725
1902
|
function _extends() {
|
|
2726
1903
|
_extends = Object.assign || function(target) {
|
|
@@ -2772,104 +1949,12 @@ const FallbackComponent = forwardRef(function FallbackComponent2({
|
|
|
2772
1949
|
})]
|
|
2773
1950
|
});
|
|
2774
1951
|
});
|
|
2775
|
-
function
|
|
2776
|
-
|
|
2777
|
-
const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
|
|
2778
|
-
const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch);
|
|
2779
|
-
useEffect(() => {
|
|
2780
|
-
if (swatchId != null)
|
|
2781
|
-
client.fetchSwatch(swatchId).catch(console.error);
|
|
2782
|
-
}, [client, swatchId]);
|
|
2783
|
-
return swatch;
|
|
2784
|
-
}
|
|
2785
|
-
function useSwatches(swatchIds) {
|
|
2786
|
-
const client = useMakeswiftClient();
|
|
2787
|
-
const lastSnapshot = useRef();
|
|
2788
|
-
function getSnapshot() {
|
|
2789
|
-
const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
|
|
2790
|
-
if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
|
|
2791
|
-
return lastSnapshot.current;
|
|
2792
|
-
}
|
|
2793
|
-
return lastSnapshot.current = swatches2;
|
|
2794
|
-
}
|
|
2795
|
-
const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
2796
|
-
useEffect(() => {
|
|
2797
|
-
Promise.all(swatchIds.map((swatchId) => client.fetchSwatch(swatchId))).catch(console.error);
|
|
2798
|
-
}, [client, swatchIds]);
|
|
2799
|
-
return swatches;
|
|
2800
|
-
}
|
|
2801
|
-
function useFile(fileId) {
|
|
2802
|
-
const client = useMakeswiftClient();
|
|
2803
|
-
const readFile = () => fileId == null ? null : client.readFile(fileId);
|
|
2804
|
-
const file = useSyncExternalStore(client.subscribe, readFile, readFile);
|
|
2805
|
-
useEffect(() => {
|
|
2806
|
-
if (fileId != null)
|
|
2807
|
-
client.fetchFile(fileId);
|
|
2808
|
-
}, [client, fileId]);
|
|
2809
|
-
return file;
|
|
2810
|
-
}
|
|
2811
|
-
function useFiles(fileIds) {
|
|
2812
|
-
const client = useMakeswiftClient();
|
|
2813
|
-
const lastSnapshot = useRef();
|
|
2814
|
-
function getSnapshot() {
|
|
2815
|
-
const files2 = fileIds.map((fileId) => client.readFile(fileId));
|
|
2816
|
-
if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
|
|
2817
|
-
return lastSnapshot.current;
|
|
2818
|
-
}
|
|
2819
|
-
return lastSnapshot.current = files2;
|
|
2820
|
-
}
|
|
2821
|
-
const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
2822
|
-
useEffect(() => {
|
|
2823
|
-
Promise.all(fileIds.map((fileId) => client.fetchFile(fileId))).catch(console.error);
|
|
2824
|
-
}, [client, fileIds]);
|
|
2825
|
-
return files;
|
|
2826
|
-
}
|
|
2827
|
-
function useTypography(typographyId) {
|
|
2828
|
-
const client = useMakeswiftClient();
|
|
2829
|
-
const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
|
|
2830
|
-
const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography);
|
|
2831
|
-
useEffect(() => {
|
|
2832
|
-
if (typographyId != null)
|
|
2833
|
-
client.fetchTypography(typographyId).catch(console.error);
|
|
2834
|
-
}, [client, typographyId]);
|
|
2835
|
-
return typography;
|
|
2836
|
-
}
|
|
2837
|
-
function useGlobalElement(globalElementId) {
|
|
2838
|
-
const client = useMakeswiftClient();
|
|
2839
|
-
const readGlobalElement = () => globalElementId == null ? null : client.readGlobalElement(globalElementId);
|
|
2840
|
-
const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement);
|
|
2841
|
-
useEffect(() => {
|
|
2842
|
-
if (globalElementId != null)
|
|
2843
|
-
client.fetchGlobalElement(globalElementId).catch(console.error);
|
|
2844
|
-
}, [client, globalElementId]);
|
|
2845
|
-
return globalElement;
|
|
2846
|
-
}
|
|
2847
|
-
function usePagePathnameSlice(pageId) {
|
|
2848
|
-
const client = useMakeswiftClient();
|
|
2849
|
-
const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice(pageId);
|
|
2850
|
-
const pagePathnameSlice = useSyncExternalStore(client.subscribe, readPagePathnameSlice, readPagePathnameSlice);
|
|
2851
|
-
useEffect(() => {
|
|
2852
|
-
if (pageId != null)
|
|
2853
|
-
client.fetchPagePathnameSlice(pageId).catch(console.error);
|
|
2854
|
-
}, [client, pageId]);
|
|
2855
|
-
return pagePathnameSlice;
|
|
2856
|
-
}
|
|
2857
|
-
function useTable(tableId) {
|
|
2858
|
-
const client = useMakeswiftClient();
|
|
2859
|
-
const readTable = () => tableId == null ? null : client.readTable(tableId);
|
|
2860
|
-
const table = useSyncExternalStore(client.subscribe, readTable, readTable);
|
|
2861
|
-
useEffect(() => {
|
|
2862
|
-
if (tableId != null)
|
|
2863
|
-
client.fetchTable(tableId).catch(console.error);
|
|
2864
|
-
}, [client, tableId]);
|
|
2865
|
-
return table;
|
|
2866
|
-
}
|
|
2867
|
-
function mapSideColor(swatches, _d) {
|
|
2868
|
-
var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
|
|
1952
|
+
function mapSideColor(swatches, _c) {
|
|
1953
|
+
var _d = _c, { color } = _d, restOfSide = __objRest(_d, ["color"]);
|
|
2869
1954
|
return __spreadProps(__spreadValues({}, restOfSide), {
|
|
2870
1955
|
color: color && {
|
|
2871
1956
|
alpha: color.alpha,
|
|
2872
|
-
swatch: swatches.filter(isNonNullable
|
|
1957
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId)
|
|
2873
1958
|
}
|
|
2874
1959
|
});
|
|
2875
1960
|
}
|
|
@@ -2915,7 +2000,7 @@ function useBoxShadow(value) {
|
|
|
2915
2000
|
return __spreadProps(__spreadValues({}, restOfShadow), {
|
|
2916
2001
|
payload: {
|
|
2917
2002
|
color: color != null ? {
|
|
2918
|
-
swatch: swatches.filter(isNonNullable
|
|
2003
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId),
|
|
2919
2004
|
alpha: color.alpha
|
|
2920
2005
|
} : null,
|
|
2921
2006
|
inset: inset != null ? inset : ShadowDefaultValue.inset,
|
|
@@ -2939,7 +2024,7 @@ function useResponsiveColor(color) {
|
|
|
2939
2024
|
const { swatchId, alpha } = v;
|
|
2940
2025
|
const swatch = swatches.find((s) => s && s.id === swatchId);
|
|
2941
2026
|
return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
|
|
2942
|
-
}).filter(isNonNullable
|
|
2027
|
+
}).filter(isNonNullable);
|
|
2943
2028
|
}
|
|
2944
2029
|
const DEVICE_QUERIES = DEVICES.map((device) => ({
|
|
2945
2030
|
id: device.id,
|
|
@@ -2970,212 +2055,6 @@ function useMediaQuery(responsiveValue) {
|
|
|
2970
2055
|
}
|
|
2971
2056
|
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
2972
2057
|
}
|
|
2973
|
-
const getIndexes = (spans, index) => {
|
|
2974
|
-
const flattened = spans.reduce((a, s) => a.concat(s), []);
|
|
2975
|
-
if (index < 0 || index > flattened.length)
|
|
2976
|
-
throw new RangeError();
|
|
2977
|
-
let remainder = index;
|
|
2978
|
-
let rowIndex = 0;
|
|
2979
|
-
while (rowIndex < spans.length - 1 && remainder >= spans[rowIndex].length) {
|
|
2980
|
-
remainder -= spans[rowIndex].length;
|
|
2981
|
-
rowIndex += 1;
|
|
2982
|
-
}
|
|
2983
|
-
return [rowIndex, remainder];
|
|
2984
|
-
};
|
|
2985
|
-
function lengthDataToString(data) {
|
|
2986
|
-
if (typeof data === "object")
|
|
2987
|
-
return `${data.value}${data.unit}`;
|
|
2988
|
-
if (typeof data === "number")
|
|
2989
|
-
return `${data}px`;
|
|
2990
|
-
return data;
|
|
2991
|
-
}
|
|
2992
|
-
function paddingPropertyDataToStyle(data, defaultValue = {}) {
|
|
2993
|
-
var _a, _b, _c2, _d;
|
|
2994
|
-
const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
|
|
2995
|
-
const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
|
|
2996
|
-
const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
|
|
2997
|
-
const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
|
|
2998
|
-
const style = {};
|
|
2999
|
-
if (paddingTop != null)
|
|
3000
|
-
style.paddingTop = lengthDataToString(paddingTop);
|
|
3001
|
-
if (paddingRight != null)
|
|
3002
|
-
style.paddingRight = lengthDataToString(paddingRight);
|
|
3003
|
-
if (paddingBottom != null)
|
|
3004
|
-
style.paddingBottom = lengthDataToString(paddingBottom);
|
|
3005
|
-
if (paddingLeft != null)
|
|
3006
|
-
style.paddingLeft = lengthDataToString(paddingLeft);
|
|
3007
|
-
return style;
|
|
3008
|
-
}
|
|
3009
|
-
function marginPropertyDataToStyle(data, defaultValue = {}) {
|
|
3010
|
-
var _a, _b, _c2, _d;
|
|
3011
|
-
const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
|
|
3012
|
-
const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
|
|
3013
|
-
const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
|
|
3014
|
-
const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
|
|
3015
|
-
const style = {};
|
|
3016
|
-
if (marginTop != null)
|
|
3017
|
-
style.marginTop = lengthDataToString(marginTop);
|
|
3018
|
-
if (marginRight != null)
|
|
3019
|
-
style.marginRight = lengthDataToString(marginRight);
|
|
3020
|
-
if (marginBottom != null)
|
|
3021
|
-
style.marginBottom = lengthDataToString(marginBottom);
|
|
3022
|
-
if (marginLeft != null)
|
|
3023
|
-
style.marginLeft = lengthDataToString(marginLeft);
|
|
3024
|
-
return style;
|
|
3025
|
-
}
|
|
3026
|
-
function lengthPercentageDataToString(data) {
|
|
3027
|
-
if (typeof data === "object")
|
|
3028
|
-
return `${data.value}${data.unit}`;
|
|
3029
|
-
if (typeof data === "number")
|
|
3030
|
-
return `${data}px`;
|
|
3031
|
-
return data;
|
|
3032
|
-
}
|
|
3033
|
-
function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
|
|
3034
|
-
var _a, _b, _c2, _d;
|
|
3035
|
-
const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
|
|
3036
|
-
const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
|
|
3037
|
-
const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
|
|
3038
|
-
const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
|
|
3039
|
-
const style = {};
|
|
3040
|
-
if (borderTopLeftRadius != null) {
|
|
3041
|
-
style.borderTopLeftRadius = lengthPercentageDataToString(borderTopLeftRadius);
|
|
3042
|
-
}
|
|
3043
|
-
if (borderTopRightRadius != null) {
|
|
3044
|
-
style.borderTopRightRadius = lengthPercentageDataToString(borderTopRightRadius);
|
|
3045
|
-
}
|
|
3046
|
-
if (borderBottomRightRadius != null) {
|
|
3047
|
-
style.borderBottomRightRadius = lengthPercentageDataToString(borderBottomRightRadius);
|
|
3048
|
-
}
|
|
3049
|
-
if (borderBottomLeftRadius != null) {
|
|
3050
|
-
style.borderBottomLeftRadius = lengthPercentageDataToString(borderBottomLeftRadius);
|
|
3051
|
-
}
|
|
3052
|
-
return style;
|
|
3053
|
-
}
|
|
3054
|
-
function colorToString(color) {
|
|
3055
|
-
return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
|
|
3056
|
-
}
|
|
3057
|
-
function borderPropertyDataToStyle(data, defaultValue = {}) {
|
|
3058
|
-
var _a, _b, _c2, _d;
|
|
3059
|
-
const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
|
|
3060
|
-
const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
|
|
3061
|
-
const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
|
|
3062
|
-
const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
|
|
3063
|
-
const style = {};
|
|
3064
|
-
if (borderTop != null)
|
|
3065
|
-
style.borderTop = borderSideToString(borderTop);
|
|
3066
|
-
if (borderRight != null)
|
|
3067
|
-
style.borderRight = borderSideToString(borderRight);
|
|
3068
|
-
if (borderBottom != null)
|
|
3069
|
-
style.borderBottom = borderSideToString(borderBottom);
|
|
3070
|
-
if (borderLeft != null)
|
|
3071
|
-
style.borderLeft = borderSideToString(borderLeft);
|
|
3072
|
-
return style;
|
|
3073
|
-
}
|
|
3074
|
-
function borderSideToString(borderSide) {
|
|
3075
|
-
if (typeof borderSide === "string")
|
|
3076
|
-
return borderSide;
|
|
3077
|
-
if (typeof borderSide === "number")
|
|
3078
|
-
return `${borderSide}px`;
|
|
3079
|
-
const { width, color, style } = borderSide;
|
|
3080
|
-
return `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : "black"}`;
|
|
3081
|
-
}
|
|
3082
|
-
function responsiveStyle(responsiveValues, join$1, strategy) {
|
|
3083
|
-
return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
|
|
3084
|
-
const device = getDevice(deviceId);
|
|
3085
|
-
const mediaQuery = getDeviceMediaQuery(device);
|
|
3086
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
3087
|
-
[mediaQuery]: __spreadValues(__spreadValues({}, acc[mediaQuery]), value)
|
|
3088
|
-
});
|
|
3089
|
-
}, {});
|
|
3090
|
-
}
|
|
3091
|
-
function responsiveWidth(widthData, defaultValue = "100%") {
|
|
3092
|
-
return __spreadValues({
|
|
3093
|
-
maxWidth: "100%"
|
|
3094
|
-
}, responsiveStyle([widthData], ([width = defaultValue]) => ({
|
|
3095
|
-
width: typeof width === "object" ? `${width.value}${width.unit}` : width
|
|
3096
|
-
})));
|
|
3097
|
-
}
|
|
3098
|
-
function responsivePadding(paddingData, defaultValue = {}) {
|
|
3099
|
-
return responsiveStyle([paddingData], ([padding = {}]) => paddingPropertyDataToStyle(padding, Object.assign({ paddingTop: 0, paddingRight: 0, paddingBottom: 0, paddingLeft: 0 }, defaultValue)));
|
|
3100
|
-
}
|
|
3101
|
-
function responsiveMargin(marginData, defaultValue = {}) {
|
|
3102
|
-
return responsiveStyle([marginData], ([margin = {}]) => marginPropertyDataToStyle(margin, Object.assign({ marginTop: 0, marginRight: "auto", marginBottom: 0, marginLeft: "auto" }, defaultValue)));
|
|
3103
|
-
}
|
|
3104
|
-
function responsiveBorderRadius(borderRadiusData, defaultValue = {}) {
|
|
3105
|
-
return responsiveStyle([borderRadiusData], ([borderRadius = {}]) => borderRadiusPropertyDataToStyle(borderRadius, Object.assign({
|
|
3106
|
-
borderTopLeftRadius: 0,
|
|
3107
|
-
borderTopRightRadius: 0,
|
|
3108
|
-
borderBottomRightRadius: 0,
|
|
3109
|
-
borderBottomLeftRadius: 0
|
|
3110
|
-
}, defaultValue)));
|
|
3111
|
-
}
|
|
3112
|
-
function responsiveBorder(borderData, defaultValue = {}) {
|
|
3113
|
-
return responsiveStyle([borderData], ([border = {}]) => borderPropertyDataToStyle(border, Object.assign({
|
|
3114
|
-
borderTop: "0px solid black",
|
|
3115
|
-
borderRight: "0px solid black",
|
|
3116
|
-
borderBottom: "0px solid black",
|
|
3117
|
-
borderLeft: "0px solid black"
|
|
3118
|
-
}, defaultValue)));
|
|
3119
|
-
}
|
|
3120
|
-
const floor = (d) => (v) => Math.floor(10 ** d * v) / 10 ** d;
|
|
3121
|
-
function responsiveGridItem(props) {
|
|
3122
|
-
return __spreadValues({
|
|
3123
|
-
display: "flex"
|
|
3124
|
-
}, responsiveStyle([props.grid, props.columnGap, props.rowGap], ([
|
|
3125
|
-
{ spans, count } = { spans: [[12]], count: 12 },
|
|
3126
|
-
columnGap = { value: 0, unit: "px" },
|
|
3127
|
-
rowGap = { value: 0, unit: "px" }
|
|
3128
|
-
]) => {
|
|
3129
|
-
const [rowIndex, columnIndex] = getIndexes(spans, props.index);
|
|
3130
|
-
const firstCol = columnIndex === 0;
|
|
3131
|
-
const lastCol = columnIndex === spans[rowIndex].length - 1;
|
|
3132
|
-
const span = spans[rowIndex][columnIndex];
|
|
3133
|
-
const fraction = floor(5)(span / count);
|
|
3134
|
-
const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`;
|
|
3135
|
-
const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${columnGap.unit} / 2`;
|
|
3136
|
-
const iePrecisionError = "0.01px";
|
|
3137
|
-
const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`;
|
|
3138
|
-
const firstRow = rowIndex === 0;
|
|
3139
|
-
const lastRow = rowIndex === spans.length - 1;
|
|
3140
|
-
return span === 0 ? { display: "none" } : {
|
|
3141
|
-
flexBasis,
|
|
3142
|
-
minWidth: flexBasis,
|
|
3143
|
-
maxWidth: flexBasis,
|
|
3144
|
-
paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
|
|
3145
|
-
paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
|
|
3146
|
-
paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,
|
|
3147
|
-
paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`
|
|
3148
|
-
};
|
|
3149
|
-
}));
|
|
3150
|
-
}
|
|
3151
|
-
const getBoxShadow = (shadows) => shadows.map(({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) => `${inset ? "inset " : ""}${offsetX.toFixed(1)}px ${offsetY.toFixed(1)}px ${blurRadius}px ${spreadRadius}px ${color != null ? colorToString(color) : "rgba(0,0,0,0.2)"}`).filter(Boolean).join();
|
|
3152
|
-
function responsiveShadow(value) {
|
|
3153
|
-
return responsiveStyle([value], ([shadow = []]) => ({
|
|
3154
|
-
boxShadow: getBoxShadow(shadow)
|
|
3155
|
-
}));
|
|
3156
|
-
}
|
|
3157
|
-
function responsiveTextStyle(value) {
|
|
3158
|
-
return responsiveStyle([value], ([
|
|
3159
|
-
textStyle = {
|
|
3160
|
-
fontFamily: null,
|
|
3161
|
-
letterSpacing: null,
|
|
3162
|
-
fontSize: null,
|
|
3163
|
-
fontWeight: null,
|
|
3164
|
-
textTransform: [],
|
|
3165
|
-
fontStyle: []
|
|
3166
|
-
}
|
|
3167
|
-
]) => {
|
|
3168
|
-
const {
|
|
3169
|
-
fontSize,
|
|
3170
|
-
fontWeight,
|
|
3171
|
-
fontStyle = [],
|
|
3172
|
-
textTransform = [],
|
|
3173
|
-
letterSpacing,
|
|
3174
|
-
fontFamily
|
|
3175
|
-
} = textStyle;
|
|
3176
|
-
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, fontFamily == null ? {} : { fontFamily: `"${fontFamily}"` }), fontWeight == null ? {} : { fontWeight }), letterSpacing == null ? {} : { letterSpacing }), fontSize == null ? {} : { fontSize: `${fontSize.value}${fontSize.unit}` }), textTransform.includes("uppercase") ? { textTransform: "uppercase" } : {}), fontStyle.includes("italic") ? { fontStyle: "italic" } : {});
|
|
3177
|
-
});
|
|
3178
|
-
}
|
|
3179
2058
|
const defaultMargin = {
|
|
3180
2059
|
marginTop: 0,
|
|
3181
2060
|
marginRight: "auto",
|
|
@@ -3200,14 +2079,14 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
3200
2079
|
style == null ? void 0 : style.borderRadius,
|
|
3201
2080
|
style == null ? void 0 : style.textStyle
|
|
3202
2081
|
], ([width, margin, padding, border, borderRadius, textStyle]) => {
|
|
3203
|
-
var _a, _b,
|
|
2082
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3204
2083
|
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(StyleControlProperty.Width) && {
|
|
3205
2084
|
width: (_a = widthToString(width)) != null ? _a : "100%"
|
|
3206
2085
|
}), properties.includes(StyleControlProperty.Margin) && marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(StyleControlProperty.Padding) && paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(StyleControlProperty.Border) && {
|
|
3207
|
-
borderTop: (_b =
|
|
3208
|
-
borderRight: (
|
|
3209
|
-
borderBottom: (_d =
|
|
3210
|
-
borderLeft: (_e =
|
|
2086
|
+
borderTop: (_b = borderSideToString(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
|
|
2087
|
+
borderRight: (_c = borderSideToString(border == null ? void 0 : border.borderRight)) != null ? _c : "0 solid black",
|
|
2088
|
+
borderBottom: (_d = borderSideToString(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
|
|
2089
|
+
borderLeft: (_e = borderSideToString(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
|
|
3211
2090
|
}), properties.includes(StyleControlProperty.BorderRadius) && {
|
|
3212
2091
|
borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
|
|
3213
2092
|
borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
|
|
@@ -3223,7 +2102,7 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
3223
2102
|
return null;
|
|
3224
2103
|
return lengthPercentageDataToString(widthProperty);
|
|
3225
2104
|
}
|
|
3226
|
-
function
|
|
2105
|
+
function borderSideToString(borderSide) {
|
|
3227
2106
|
if (borderSide == null)
|
|
3228
2107
|
return null;
|
|
3229
2108
|
const { width, color, style: style2 } = borderSide;
|
|
@@ -3446,13 +2325,13 @@ function useSlot(data, control) {
|
|
|
3446
2325
|
}, element.key))
|
|
3447
2326
|
});
|
|
3448
2327
|
}
|
|
3449
|
-
function Slot(
|
|
3450
|
-
var
|
|
2328
|
+
function Slot(_e) {
|
|
2329
|
+
var _f = _e, {
|
|
3451
2330
|
as,
|
|
3452
2331
|
control,
|
|
3453
2332
|
children,
|
|
3454
2333
|
className
|
|
3455
|
-
} =
|
|
2334
|
+
} = _f, restOfProps = __objRest(_f, [
|
|
3456
2335
|
"as",
|
|
3457
2336
|
"control",
|
|
3458
2337
|
"children",
|
|
@@ -3481,15 +2360,15 @@ function Slot(_f) {
|
|
|
3481
2360
|
}
|
|
3482
2361
|
Slot.Placeholder = SlotPlaceholder;
|
|
3483
2362
|
Slot.Item = SlotItem;
|
|
3484
|
-
function SlotItem(
|
|
3485
|
-
var
|
|
2363
|
+
function SlotItem(_g) {
|
|
2364
|
+
var _h = _g, {
|
|
3486
2365
|
as,
|
|
3487
2366
|
control,
|
|
3488
2367
|
grid,
|
|
3489
2368
|
index,
|
|
3490
2369
|
children,
|
|
3491
2370
|
className
|
|
3492
|
-
} =
|
|
2371
|
+
} = _h, restOfProps = __objRest(_h, [
|
|
3493
2372
|
"as",
|
|
3494
2373
|
"control",
|
|
3495
2374
|
"grid",
|
|
@@ -3924,7 +2803,7 @@ function isDomNodeHandle(value) {
|
|
|
3924
2803
|
}
|
|
3925
2804
|
return false;
|
|
3926
2805
|
}
|
|
3927
|
-
const storeContextDefaultValue = configureStore
|
|
2806
|
+
const storeContextDefaultValue = configureStore();
|
|
3928
2807
|
function createReactRuntime(store) {
|
|
3929
2808
|
return {
|
|
3930
2809
|
registerComponent(component, {
|
|
@@ -3945,8 +2824,8 @@ function createReactRuntime(store) {
|
|
|
3945
2824
|
unregisterReactComponent();
|
|
3946
2825
|
};
|
|
3947
2826
|
},
|
|
3948
|
-
copyElementTree(
|
|
3949
|
-
return copyElementTree(store.getState(),
|
|
2827
|
+
copyElementTree(elementTree2, replacementContext) {
|
|
2828
|
+
return copyElementTree(store.getState(), elementTree2, replacementContext);
|
|
3950
2829
|
}
|
|
3951
2830
|
};
|
|
3952
2831
|
}
|
|
@@ -3955,10 +2834,10 @@ registerBuiltinComponents(ReactRuntime);
|
|
|
3955
2834
|
const StoreContext = createContext(storeContextDefaultValue);
|
|
3956
2835
|
const PreviewProvider = dynamic(() => import("./PreviewProvider.es.js"));
|
|
3957
2836
|
const LiveProvider = dynamic(() => import("./LiveProvider.es.js"));
|
|
3958
|
-
function RuntimeProvider(
|
|
3959
|
-
var
|
|
2837
|
+
function RuntimeProvider(_i) {
|
|
2838
|
+
var _j = _i, {
|
|
3960
2839
|
preview
|
|
3961
|
-
} =
|
|
2840
|
+
} = _j, props = __objRest(_j, [
|
|
3962
2841
|
"preview"
|
|
3963
2842
|
]);
|
|
3964
2843
|
return preview ? /* @__PURE__ */ jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsx(LiveProvider, __spreadValues({}, props));
|
|
@@ -4156,5 +3035,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4156
3035
|
document: document2
|
|
4157
3036
|
});
|
|
4158
3037
|
}));
|
|
4159
|
-
export {
|
|
3038
|
+
export { Alignments as A, getStaticPaths as B, Contrasts as C, DocumentReference as D, Element$1 as E, getStaticProps as F, getServerSideProps as G, Page as H, PreviewModeScript as I, Document$1 as J, MakeswiftApiHandler as K, Makeswift as M, PageProvider as P, RuntimeProvider as R, Shapes as S, ReactRuntime as a, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, useMediaQuery as m, Page$1 as n, Sizes as o, useFormContext as p, Provider as q, forwardNextDynamicRef as r, useIsPreview as s, useElementId as t, useIsInBuilder as u, ElementImperativeHandle as v, storeContextDefaultValue as w, StoreContext as x, useBuilderEditMode as y, pollBoxModel as z };
|
|
4160
3039
|
//# sourceMappingURL=index.es.js.map
|