@makeswift/runtime 0.7.19 → 0.8.1
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 +13 -10
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +8 -5
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +39 -36
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +14 -11
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +36 -33
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +11 -8
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +29 -53
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +4 -28
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +10 -34
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +4 -28
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +5 -29
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +4 -28
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +75 -72
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +13 -10
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +21 -18
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +14 -11
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +11 -8
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +11 -8
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +39 -36
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +13 -10
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +11 -8
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +11 -8
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +18 -15
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +14 -11
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +12 -9
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +10 -7
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +15 -12
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +8 -5
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +6 -3
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +7 -4
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +5 -29
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +4 -28
- 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/components.cjs.js +11 -8
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +11 -8
- package/dist/components.es.js.map +1 -1
- package/dist/controls.cjs.js +1 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -1
- package/dist/descriptors.cjs.js +13 -0
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js +13 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/index.cjs.js +368 -1508
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +22 -20
- 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 +4 -4
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +6 -3
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +19 -16
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.es.js +334 -1454
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +4 -2
- 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 +6 -3
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +15 -12
- package/dist/index.es7.js.map +1 -1
- package/dist/introspection.cjs.js +2 -5
- package/dist/introspection.cjs.js.map +1 -1
- package/dist/introspection.es.js +2 -4
- 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 +1 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +8 -6
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +9 -6
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +1 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react.cjs.js +6 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +6 -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/slate.cjs.js +5 -25
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +5 -25
- 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/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +1 -0
- package/dist/types/src/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/index.d.ts +1 -0
- package/dist/types/src/components/builtin/Form/components/Field/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/components/Spinner/index.d.ts +1 -0
- package/dist/types/src/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts +1 -0
- package/dist/types/src/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts +1 -0
- package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts +1 -0
- package/dist/types/src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/options.d.ts +1 -0
- package/dist/types/src/components/builtin/SocialLinks/options.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +1 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/src/components/page/Page.d.ts +1 -0
- package/dist/types/src/components/page/Page.d.ts.map +1 -1
- package/dist/types/src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts +1 -0
- package/dist/types/src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
- package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts +1 -0
- package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/types.d.ts +20 -6
- 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/document.d.ts +1 -0
- package/dist/types/src/next/document.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/next/preview-mode.d.ts +1 -0
- package/dist/types/src/next/preview-mode.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/components/render-hook.d.ts +1 -0
- package/dist/types/src/runtimes/react/components/render-hook.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +1 -0
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/list.d.ts +1 -0
- package/dist/types/src/runtimes/react/controls/list.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/shape.d.ts +1 -0
- package/dist/types/src/runtimes/react/controls/shape.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls.d.ts +1 -0
- package/dist/types/src/runtimes/react/controls.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/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,35 @@ 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, useId, 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 StyleControlType, U as RichTextControlType, b as SlotControlType, X as LinkControlType, I as ImageControlType, C as ColorControlType, Y as BorderPropControllerFormat, Z as ShadowsPropControllerFormat, _ as BorderRadiusPropControllerFormat, $ as MarginPropControllerFormat, a0 as PaddingPropControllerFormat, a1 as WidthPropControllerFormat } from "./descriptors.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 { 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, 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 StyleControlType, U as RichTextControlType, b as SlotControlType, X as LinkControlType, I as ImageControlType, C as ColorControlType, Y as BorderPropControllerFormat, Z as ShadowsPropControllerFormat, _ as BorderRadiusPropControllerFormat, $ as MarginPropControllerFormat, a0 as PaddingPropControllerFormat, a1 as WidthPropControllerFormat } from "./descriptors.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";
|
|
52
49
|
import "slate-react";
|
|
53
50
|
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";
|
|
51
|
+
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";
|
|
52
|
+
import { i as isNonNullable } from "./isNonNullable.es.js";
|
|
58
53
|
import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
|
|
59
54
|
import ColorHelper from "color";
|
|
60
55
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
56
|
+
import { cache, cx } from "@emotion/css";
|
|
61
57
|
import { findDOMNode } from "react-dom";
|
|
62
58
|
import parse from "html-react-parser";
|
|
63
59
|
import Head from "next/head";
|
|
60
|
+
import { A as APIResourceType } from "./types.es.js";
|
|
64
61
|
import createEmotionServer from "@emotion/server/create-instance";
|
|
65
62
|
import NextDocument, { Html, Head as Head$1, Main, NextScript } from "next/document";
|
|
66
|
-
import { serialize } from "cookie";
|
|
67
63
|
import Cors from "cors";
|
|
64
|
+
import { match } from "path-to-regexp";
|
|
65
|
+
import { serialize } from "cookie";
|
|
68
66
|
import { createProxyServer } from "http-proxy";
|
|
69
67
|
import { parse as parse$1 } from "set-cookie-parser";
|
|
70
68
|
import { v4 } from "uuid";
|
|
@@ -113,661 +111,6 @@ function BodySnippet({
|
|
|
113
111
|
}, [code, cleanup]);
|
|
114
112
|
return null;
|
|
115
113
|
}
|
|
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
114
|
const SnippetLocation = {
|
|
772
115
|
Body: "BODY",
|
|
773
116
|
Head: "HEAD"
|
|
@@ -968,11 +311,11 @@ function useCachedSite(siteId) {
|
|
|
968
311
|
const site = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
969
312
|
return site;
|
|
970
313
|
}
|
|
971
|
-
const version = "0.7.19";
|
|
972
314
|
class Makeswift {
|
|
973
315
|
constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
|
|
974
316
|
__publicField(this, "apiKey");
|
|
975
317
|
__publicField(this, "apiOrigin");
|
|
318
|
+
__publicField(this, "graphqlClient");
|
|
976
319
|
if (typeof apiKey !== "string") {
|
|
977
320
|
throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
|
|
978
321
|
Received "${apiKey}" instead.`);
|
|
@@ -983,6 +326,7 @@ Received "${apiKey}" instead.`);
|
|
|
983
326
|
} catch {
|
|
984
327
|
throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
|
|
985
328
|
}
|
|
329
|
+
this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
|
|
986
330
|
}
|
|
987
331
|
async fetch(path, init) {
|
|
988
332
|
const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
|
|
@@ -999,9 +343,149 @@ Received "${apiKey}" instead.`);
|
|
|
999
343
|
const json = await response.json();
|
|
1000
344
|
return json;
|
|
1001
345
|
}
|
|
346
|
+
async getTypographies(typographyIds) {
|
|
347
|
+
const result = await this.graphqlClient.request(TypographiesQuery, { typographyIds });
|
|
348
|
+
return result.typographies;
|
|
349
|
+
}
|
|
350
|
+
async getIntrospectedResources(introspectedResourceIds) {
|
|
351
|
+
const result = await this.graphqlClient.request(IntrospectedResourcesQuery, introspectedResourceIds);
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
async introspect(element) {
|
|
355
|
+
const descriptors = getPropControllerDescriptors(storeContextDefaultValue.getState());
|
|
356
|
+
const swatchIds = /* @__PURE__ */ new Set();
|
|
357
|
+
const fileIds = /* @__PURE__ */ new Set();
|
|
358
|
+
const typographyIds = /* @__PURE__ */ new Set();
|
|
359
|
+
const tableIds = /* @__PURE__ */ new Set();
|
|
360
|
+
const pageIds = /* @__PURE__ */ new Set();
|
|
361
|
+
const globalElements = /* @__PURE__ */ new Map();
|
|
362
|
+
const remaining = [element];
|
|
363
|
+
const seen = /* @__PURE__ */ new Set();
|
|
364
|
+
let current;
|
|
365
|
+
while (current = remaining.pop()) {
|
|
366
|
+
let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
|
|
367
|
+
Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
|
|
368
|
+
getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
|
|
369
|
+
swatchIds.add(swatchId);
|
|
370
|
+
});
|
|
371
|
+
getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
|
|
372
|
+
getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
|
|
373
|
+
getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
|
|
374
|
+
getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
|
|
375
|
+
getElementChildren(descriptor, props[propName]).forEach((child) => {
|
|
376
|
+
if (!seen.has(child.key)) {
|
|
377
|
+
seen.add(child.key);
|
|
378
|
+
remaining.push(child);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
if (descriptor.type === ShapeControlType) {
|
|
382
|
+
const prop = props[propName];
|
|
383
|
+
if (prop == null)
|
|
384
|
+
return;
|
|
385
|
+
getResourcesFromElementDescriptors(descriptor.config.type, prop);
|
|
386
|
+
}
|
|
387
|
+
if (descriptor.type === ListControlType) {
|
|
388
|
+
const prop = props[propName];
|
|
389
|
+
if (prop == null)
|
|
390
|
+
return;
|
|
391
|
+
prop.forEach((item) => {
|
|
392
|
+
getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (descriptor.type === Types.Shape) {
|
|
396
|
+
const prop = props[propName];
|
|
397
|
+
if (prop == null)
|
|
398
|
+
return;
|
|
399
|
+
getResourcesFromElementDescriptors(descriptor.options.type, prop);
|
|
400
|
+
}
|
|
401
|
+
if (descriptor.type === Types.List) {
|
|
402
|
+
const prop = props[propName];
|
|
403
|
+
if (prop == null)
|
|
404
|
+
return;
|
|
405
|
+
prop.forEach((item) => {
|
|
406
|
+
getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
let element2;
|
|
412
|
+
if (isElementReference(current)) {
|
|
413
|
+
const globalElement = await this.getGlobalElement(current.value);
|
|
414
|
+
globalElements.set(current.value, globalElement);
|
|
415
|
+
const elementData = globalElement == null ? void 0 : globalElement.data;
|
|
416
|
+
if (elementData == null)
|
|
417
|
+
continue;
|
|
418
|
+
element2 = elementData;
|
|
419
|
+
} else {
|
|
420
|
+
element2 = current;
|
|
421
|
+
}
|
|
422
|
+
const elementDescriptors = descriptors.get(element2.type);
|
|
423
|
+
if (elementDescriptors == null)
|
|
424
|
+
continue;
|
|
425
|
+
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
426
|
+
}
|
|
427
|
+
const typographies = await this.getTypographies([...typographyIds]);
|
|
428
|
+
typographies.forEach((typography) => {
|
|
429
|
+
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
430
|
+
var _a;
|
|
431
|
+
const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
|
|
432
|
+
if (swatchId != null)
|
|
433
|
+
swatchIds.add(swatchId);
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
const { swatches, files, tables, pagePathnamesById } = await this.getIntrospectedResources({
|
|
437
|
+
swatchIds: [...swatchIds],
|
|
438
|
+
fileIds: [...fileIds],
|
|
439
|
+
tableIds: [...tableIds],
|
|
440
|
+
pageIds: [...pageIds]
|
|
441
|
+
});
|
|
442
|
+
const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
|
|
443
|
+
id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
|
|
444
|
+
}));
|
|
445
|
+
return {
|
|
446
|
+
[APIResourceType.Swatch]: [...swatchIds].map((id) => {
|
|
447
|
+
var _a;
|
|
448
|
+
return {
|
|
449
|
+
id,
|
|
450
|
+
value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
|
|
451
|
+
};
|
|
452
|
+
}),
|
|
453
|
+
[APIResourceType.File]: [...fileIds].map((id) => {
|
|
454
|
+
var _a;
|
|
455
|
+
return {
|
|
456
|
+
id,
|
|
457
|
+
value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
|
|
458
|
+
};
|
|
459
|
+
}),
|
|
460
|
+
[APIResourceType.Typography]: [...typographyIds].map((id) => {
|
|
461
|
+
var _a;
|
|
462
|
+
return {
|
|
463
|
+
id,
|
|
464
|
+
value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
|
|
465
|
+
};
|
|
466
|
+
}),
|
|
467
|
+
[APIResourceType.Table]: [...tableIds].map((id) => {
|
|
468
|
+
var _a;
|
|
469
|
+
return {
|
|
470
|
+
id,
|
|
471
|
+
value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
|
|
472
|
+
};
|
|
473
|
+
}),
|
|
474
|
+
[APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
|
|
475
|
+
var _a;
|
|
476
|
+
return {
|
|
477
|
+
id,
|
|
478
|
+
value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
|
|
479
|
+
};
|
|
480
|
+
}),
|
|
481
|
+
[APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
|
|
482
|
+
id,
|
|
483
|
+
value
|
|
484
|
+
}))
|
|
485
|
+
};
|
|
486
|
+
}
|
|
1002
487
|
async createSnapshot(document2, preview) {
|
|
1003
|
-
const
|
|
1004
|
-
const cacheData = await client.prefetch(document2.data);
|
|
488
|
+
const cacheData = await this.introspect(document2.data);
|
|
1005
489
|
return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
|
|
1006
490
|
}
|
|
1007
491
|
async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
|
|
@@ -1022,161 +506,30 @@ Received "${apiKey}" instead.`);
|
|
|
1022
506
|
const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
|
|
1023
507
|
return snapshot;
|
|
1024
508
|
}
|
|
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
|
-
};
|
|
509
|
+
async getSwatch(swatchId) {
|
|
510
|
+
const result = await this.graphqlClient.request(SwatchQuery, { swatchId });
|
|
511
|
+
return result.swatch;
|
|
1037
512
|
}
|
|
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;
|
|
513
|
+
async getFile(fileId) {
|
|
514
|
+
const result = await this.graphqlClient.request(FileQuery, { fileId });
|
|
515
|
+
return result.file;
|
|
1047
516
|
}
|
|
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 };
|
|
517
|
+
async getTypography(typographyId) {
|
|
518
|
+
const result = await this.graphqlClient.request(TypographyQuery, { typographyId });
|
|
519
|
+
return result.typography;
|
|
1077
520
|
}
|
|
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
|
-
};
|
|
521
|
+
async getGlobalElement(globalElementId) {
|
|
522
|
+
const result = await this.graphqlClient.request(GlobalElementQuery, { globalElementId });
|
|
523
|
+
return result.globalElement;
|
|
1165
524
|
}
|
|
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
|
-
];
|
|
525
|
+
async getPagePathnameSlice(pageId) {
|
|
526
|
+
var _a;
|
|
527
|
+
const result = await this.graphqlClient.request(PagePathnamesByIdQuery, { pageIds: [pageId] });
|
|
528
|
+
return (_a = result.pagePathnamesById.at(0)) != null ? _a : null;
|
|
529
|
+
}
|
|
530
|
+
async getTable(tableId) {
|
|
531
|
+
const result = await this.graphqlClient.request(TableQuery, { tableId });
|
|
532
|
+
return result.table;
|
|
1180
533
|
}
|
|
1181
534
|
}
|
|
1182
535
|
function PreviewModeScript({
|
|
@@ -1306,17 +659,40 @@ class Document$1 extends NextDocument {
|
|
|
1306
659
|
});
|
|
1307
660
|
}
|
|
1308
661
|
}
|
|
1309
|
-
function
|
|
1310
|
-
|
|
662
|
+
async function elementTree(req, res) {
|
|
663
|
+
const elementTree2 = req.body.elementTree;
|
|
664
|
+
const replacementContext = req.body.replacementContext;
|
|
665
|
+
if (elementTree2 == null) {
|
|
666
|
+
return res.status(400).json({ message: "elementTree must be defined" });
|
|
667
|
+
}
|
|
668
|
+
if (replacementContext == null) {
|
|
669
|
+
return res.status(400).json({ message: "replacementContext must be defined" });
|
|
670
|
+
}
|
|
671
|
+
const generatedElementTree = ReactRuntime.copyElementTree(elementTree2, replacementContext);
|
|
672
|
+
const response = { elementTree: generatedElementTree };
|
|
673
|
+
return res.json(response);
|
|
1311
674
|
}
|
|
1312
|
-
function
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
675
|
+
async function fonts(_req, res, { getFonts } = {}) {
|
|
676
|
+
var _a;
|
|
677
|
+
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
678
|
+
return res.json(fonts2);
|
|
679
|
+
}
|
|
680
|
+
const version = "0.8.1";
|
|
681
|
+
async function handler(req, res, { apiKey }) {
|
|
682
|
+
if (req.query.secret !== apiKey) {
|
|
683
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
684
|
+
}
|
|
685
|
+
return res.json({
|
|
686
|
+
version,
|
|
687
|
+
previewMode: true,
|
|
688
|
+
interactionMode: true,
|
|
689
|
+
clientSideNavigation: true,
|
|
690
|
+
elementFromPoint: false
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
async function proxyPreviewMode(req, res, { apiKey }) {
|
|
1318
694
|
const previewModeProxy = createProxyServer();
|
|
1319
|
-
previewModeProxy.
|
|
695
|
+
previewModeProxy.once("proxyReq", (proxyReq) => {
|
|
1320
696
|
proxyReq.removeHeader("X-Makeswift-Preview-Mode");
|
|
1321
697
|
proxyReq.removeHeader("X-Invoke-Path");
|
|
1322
698
|
proxyReq.removeHeader("X-Invoke-Query");
|
|
@@ -1324,12 +700,74 @@ function MakeswiftApiHandler(apiKey, {
|
|
|
1324
700
|
url.searchParams.delete("x-makeswift-preview-mode");
|
|
1325
701
|
proxyReq.path = url.pathname + url.search;
|
|
1326
702
|
});
|
|
703
|
+
if (req.query.secret !== apiKey)
|
|
704
|
+
return res.status(401).send("Unauthorized");
|
|
705
|
+
const host = req.headers.host;
|
|
706
|
+
if (host == null)
|
|
707
|
+
return res.status(400).send("Bad Request");
|
|
708
|
+
const forwardedProtoHeader = req.headers["x-forwarded-proto"];
|
|
709
|
+
let forwardedProto = [];
|
|
710
|
+
if (Array.isArray(forwardedProtoHeader)) {
|
|
711
|
+
forwardedProto = forwardedProtoHeader;
|
|
712
|
+
} else if (typeof forwardedProtoHeader === "string") {
|
|
713
|
+
forwardedProto = forwardedProtoHeader.split(",");
|
|
714
|
+
}
|
|
715
|
+
const isForwardedProtoHttps = forwardedProto.includes("https");
|
|
716
|
+
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
717
|
+
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
718
|
+
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
719
|
+
let target = `${proto}://${host}`;
|
|
720
|
+
const secure = process.env["NODE_ENV"] === "production";
|
|
721
|
+
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
722
|
+
res.removeHeader("Set-Cookie");
|
|
723
|
+
if (!Array.isArray(setCookie))
|
|
724
|
+
return res.status(500).send("Internal Server Error");
|
|
725
|
+
const cookie = parse$1(setCookie).map((cookie2) => serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
726
|
+
return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie }, secure }, (err) => {
|
|
727
|
+
if (err)
|
|
728
|
+
reject(err);
|
|
729
|
+
else
|
|
730
|
+
resolve2();
|
|
731
|
+
}));
|
|
732
|
+
}
|
|
733
|
+
function isErrorWithMessage(error) {
|
|
734
|
+
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
735
|
+
}
|
|
736
|
+
async function revalidate(req, res, { apiKey }) {
|
|
737
|
+
if (req.query.secret !== apiKey) {
|
|
738
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
739
|
+
}
|
|
740
|
+
if (typeof req.query.path !== "string") {
|
|
741
|
+
return res.status(400).json({ message: "Bad Request" });
|
|
742
|
+
}
|
|
743
|
+
const revalidate2 = res.revalidate;
|
|
744
|
+
if (typeof revalidate2 !== "function") {
|
|
745
|
+
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.
|
|
746
|
+
Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
|
|
747
|
+
console.warn(message);
|
|
748
|
+
return res.json({ revalidated: false });
|
|
749
|
+
}
|
|
750
|
+
try {
|
|
751
|
+
await revalidate2(req.query.path);
|
|
752
|
+
return res.json({ revalidated: true });
|
|
753
|
+
} catch (error) {
|
|
754
|
+
if (isErrorWithMessage(error)) {
|
|
755
|
+
return res.status(500).json({ message: error.message });
|
|
756
|
+
}
|
|
757
|
+
return res.status(500).json({ message: "Error Revalidating" });
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function MakeswiftApiHandler(apiKey, {
|
|
761
|
+
appOrigin = "https://app.makeswift.com",
|
|
762
|
+
apiOrigin = "https://api.makeswift.com",
|
|
763
|
+
getFonts
|
|
764
|
+
} = {}) {
|
|
765
|
+
const cors = Cors({ origin: appOrigin });
|
|
1327
766
|
if (typeof apiKey !== "string") {
|
|
1328
767
|
throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
|
|
1329
768
|
Received "${apiKey}" instead.`);
|
|
1330
769
|
}
|
|
1331
770
|
return async function makeswiftApiHandler(req, res) {
|
|
1332
|
-
var _a;
|
|
1333
771
|
await new Promise((resolve2, reject) => {
|
|
1334
772
|
cors(req, res, (err) => {
|
|
1335
773
|
if (err instanceof Error)
|
|
@@ -1344,224 +782,40 @@ Received "${apiKey}" instead.`);
|
|
|
1344
782
|
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
1345
783
|
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
|
|
1346
784
|
}
|
|
1347
|
-
const
|
|
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
|
-
|
|
1380
|
-
|
|
1381
|
-
return res.status(500).json({ message: "Error Revalidating" });
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
case "proxy-preview-mode": {
|
|
1385
|
-
if (req.query.secret !== apiKey)
|
|
1386
|
-
return res.status(401).send("Unauthorized");
|
|
1387
|
-
const host = req.headers.host;
|
|
1388
|
-
if (host == null)
|
|
1389
|
-
return res.status(400).send("Bad Request");
|
|
1390
|
-
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
1391
|
-
const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
|
|
1392
|
-
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
1393
|
-
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
1394
|
-
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
1395
|
-
let target = `${proto}://${host}`;
|
|
1396
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
1397
|
-
const port = req.socket.localPort;
|
|
1398
|
-
if (port != null)
|
|
1399
|
-
target = `http://localhost:${port}`;
|
|
1400
|
-
}
|
|
1401
|
-
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
1402
|
-
res.removeHeader("Set-Cookie");
|
|
1403
|
-
if (!Array.isArray(setCookie))
|
|
1404
|
-
return res.status(500).send("Internal Server Error");
|
|
1405
|
-
const cookie = parse$1(setCookie).map((cookie2) => serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
1406
|
-
return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie } }, (err) => {
|
|
1407
|
-
if (err)
|
|
1408
|
-
reject(err);
|
|
1409
|
-
else
|
|
1410
|
-
resolve2();
|
|
1411
|
-
}));
|
|
1412
|
-
}
|
|
1413
|
-
case "fonts": {
|
|
1414
|
-
const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1415
|
-
return res.json(fonts);
|
|
1416
|
-
}
|
|
1417
|
-
case "element-tree": {
|
|
1418
|
-
const elementTree = req.body.elementTree;
|
|
1419
|
-
const replacementContext = req.body.replacementContext;
|
|
1420
|
-
if (elementTree == null) {
|
|
1421
|
-
return res.status(400).json({ message: "elementTree must be defined" });
|
|
1422
|
-
}
|
|
1423
|
-
if (replacementContext == null) {
|
|
1424
|
-
return res.status(400).json({ message: "replacementContext must be defined" });
|
|
1425
|
-
}
|
|
1426
|
-
const generatedElementTree = ReactRuntime.copyElementTree(elementTree, replacementContext);
|
|
1427
|
-
const response = { elementTree: generatedElementTree };
|
|
1428
|
-
return res.json(response);
|
|
1429
|
-
}
|
|
1430
|
-
case "snapshot": {
|
|
1431
|
-
let validateBody = function(body2) {
|
|
1432
|
-
if (body2.pageId == null) {
|
|
1433
|
-
return res.status(400).json({ message: "Must define pageId." });
|
|
1434
|
-
}
|
|
1435
|
-
if (body2.currentSnapshot == null && body2.publishedElementTree == null) {
|
|
1436
|
-
return res.status(400).json({ message: "Either currentSnapshot or publishedElementTree must be defined." });
|
|
1437
|
-
}
|
|
1438
|
-
};
|
|
1439
|
-
const body = req.body;
|
|
1440
|
-
validateBody(body);
|
|
1441
|
-
const client = new Makeswift(apiKey, {
|
|
1442
|
-
apiOrigin
|
|
1443
|
-
});
|
|
1444
|
-
const makeswiftApiClient = new MakeswiftClient({ uri: new URL("graphql", apiOrigin).href });
|
|
1445
|
-
async function formMakeswiftResources(publishedResources) {
|
|
1446
|
-
var _a2, _b, _c2, _d, _e, _f, _g, _h;
|
|
1447
|
-
const publishedResourcesInMakeswiftSnapshotFormat = {
|
|
1448
|
-
swatches: [],
|
|
1449
|
-
typographies: [],
|
|
1450
|
-
files: [],
|
|
1451
|
-
tables: [],
|
|
1452
|
-
pagePathnameSlices: [],
|
|
1453
|
-
globalElements: [],
|
|
1454
|
-
snippets: [],
|
|
1455
|
-
fonts: [],
|
|
1456
|
-
pageMetadata: publishedResources == null ? void 0 : publishedResources.pageMetadata,
|
|
1457
|
-
pageSeo: publishedResources == null ? void 0 : publishedResources.pageSeo
|
|
1458
|
-
};
|
|
1459
|
-
if (publishedResources == null) {
|
|
1460
|
-
return publishedResourcesInMakeswiftSnapshotFormat;
|
|
1461
|
-
}
|
|
1462
|
-
for await (const swatchId of publishedResources.swatches || []) {
|
|
1463
|
-
const swatch = await makeswiftApiClient.fetchSwatch(swatchId);
|
|
1464
|
-
if (swatch != null) {
|
|
1465
|
-
(_a2 = publishedResourcesInMakeswiftSnapshotFormat.swatches) == null ? void 0 : _a2.push({
|
|
1466
|
-
id: swatchId,
|
|
1467
|
-
value: swatch
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
for await (const typographyId of publishedResources.typographies || []) {
|
|
1472
|
-
const typography = await makeswiftApiClient.fetchTypography(typographyId);
|
|
1473
|
-
if (typography != null) {
|
|
1474
|
-
(_b = publishedResourcesInMakeswiftSnapshotFormat.typographies) == null ? void 0 : _b.push({
|
|
1475
|
-
id: typographyId,
|
|
1476
|
-
value: typography
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
for await (const fileId of publishedResources.files || []) {
|
|
1481
|
-
const file = await makeswiftApiClient.fetchFile(fileId);
|
|
1482
|
-
if (file != null) {
|
|
1483
|
-
(_c2 = publishedResourcesInMakeswiftSnapshotFormat.files) == null ? void 0 : _c2.push({
|
|
1484
|
-
id: fileId,
|
|
1485
|
-
value: fileToFileSnapshot(file)
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
for await (const tableId of publishedResources.tables || []) {
|
|
1490
|
-
const table = await makeswiftApiClient.fetchTable(tableId);
|
|
1491
|
-
if (table != null) {
|
|
1492
|
-
(_d = publishedResourcesInMakeswiftSnapshotFormat.tables) == null ? void 0 : _d.push({
|
|
1493
|
-
id: tableId,
|
|
1494
|
-
value: table
|
|
1495
|
-
});
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
for await (const pageId of publishedResources.pagePathnameSlices || []) {
|
|
1499
|
-
const pagePathnameSlice = await makeswiftApiClient.fetchPagePathnameSlice(pageId);
|
|
1500
|
-
if (pagePathnameSlice != null) {
|
|
1501
|
-
(_e = publishedResourcesInMakeswiftSnapshotFormat.pagePathnameSlices) == null ? void 0 : _e.push({
|
|
1502
|
-
id: pageId,
|
|
1503
|
-
value: pagePathnameSlice
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
for await (const globalElementId of publishedResources.globalElements || []) {
|
|
1508
|
-
const globalElement = await makeswiftApiClient.fetchGlobalElement(globalElementId);
|
|
1509
|
-
if (globalElement != null) {
|
|
1510
|
-
(_f = publishedResourcesInMakeswiftSnapshotFormat.globalElements) == null ? void 0 : _f.push({
|
|
1511
|
-
id: globalElementId,
|
|
1512
|
-
value: globalElement
|
|
1513
|
-
});
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
if (publishedResources.snippets != null || publishedResources.fonts != null) {
|
|
1517
|
-
const response2 = await fetch(new URL(`/v1/pages/${body.pageId}/document?preview=false`, apiOrigin).toString(), {
|
|
1518
|
-
headers: { ["X-API-Key"]: apiKey }
|
|
1519
|
-
});
|
|
1520
|
-
if (!response2.ok) {
|
|
1521
|
-
throw new Error(`Failed to hit live page endpoint: "${response2.statusText}"`);
|
|
1522
|
-
}
|
|
1523
|
-
const document2 = await response2.json();
|
|
1524
|
-
const availableSnippets = document2.snippets;
|
|
1525
|
-
const availableFonts = document2.fonts;
|
|
1526
|
-
for await (const snippetId of publishedResources.snippets || []) {
|
|
1527
|
-
const snippet = availableSnippets.find((availableSnippet) => availableSnippet.id === snippetId);
|
|
1528
|
-
if (snippet != null) {
|
|
1529
|
-
(_g = publishedResourcesInMakeswiftSnapshotFormat.snippets) == null ? void 0 : _g.push({
|
|
1530
|
-
id: snippetId,
|
|
1531
|
-
value: snippet
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
for await (const family of publishedResources.fonts || []) {
|
|
1536
|
-
const font = availableFonts.find((availableFont) => availableFont.family === family);
|
|
1537
|
-
if (font != null) {
|
|
1538
|
-
(_h = publishedResourcesInMakeswiftSnapshotFormat.fonts) == null ? void 0 : _h.push({
|
|
1539
|
-
id: family,
|
|
1540
|
-
value: font
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
return publishedResourcesInMakeswiftSnapshotFormat;
|
|
1546
|
-
}
|
|
1547
|
-
const snapshot = await client.unstable_createSnapshot({
|
|
1548
|
-
publishedResources: await formMakeswiftResources(body.publishedResources),
|
|
1549
|
-
deletedResources: body.deletedResources,
|
|
1550
|
-
publishedElementTree: body.publishedElementTree,
|
|
1551
|
-
currentSnapshot: body.currentSnapshot
|
|
1552
|
-
});
|
|
1553
|
-
const usedResources = client.unstable_getSnapshotResourceMapping(snapshot);
|
|
1554
|
-
const response = {
|
|
1555
|
-
pageId: body.pageId,
|
|
1556
|
-
snapshot,
|
|
1557
|
-
livePageChanges: body.livePageChanges,
|
|
1558
|
-
usedResources
|
|
1559
|
-
};
|
|
1560
|
-
return res.json(response);
|
|
1561
|
-
}
|
|
1562
|
-
default:
|
|
1563
|
-
return res.status(404).json({ message: "Not Found" });
|
|
1564
|
-
}
|
|
785
|
+
const client = new Makeswift(apiKey, { apiOrigin });
|
|
786
|
+
const action = "/" + makeswift.join("/");
|
|
787
|
+
const matches = (pattern) => match(pattern, { decode: decodeURIComponent })(action);
|
|
788
|
+
let m;
|
|
789
|
+
if (matches("/manifest"))
|
|
790
|
+
return handler(req, res, { apiKey });
|
|
791
|
+
if (matches("/revalidate"))
|
|
792
|
+
return revalidate(req, res, { apiKey });
|
|
793
|
+
if (matches("/proxy-preview-mode"))
|
|
794
|
+
return proxyPreviewMode(req, res, { apiKey });
|
|
795
|
+
if (matches("/fonts"))
|
|
796
|
+
return fonts(req, res, { getFonts });
|
|
797
|
+
if (matches("/element-tree"))
|
|
798
|
+
return elementTree(req, res);
|
|
799
|
+
const handleResource = (resource) => resource === null ? res.status(404).json({ message: "Not Found" }) : res.json(resource);
|
|
800
|
+
if (m = matches("/swatches/:id")) {
|
|
801
|
+
return client.getSwatch(m.params.id).then(handleResource);
|
|
802
|
+
}
|
|
803
|
+
if (m = matches("/files/:id")) {
|
|
804
|
+
return client.getFile(m.params.id).then(handleResource);
|
|
805
|
+
}
|
|
806
|
+
if (m = matches("/typographies/:id")) {
|
|
807
|
+
return client.getTypography(m.params.id).then(handleResource);
|
|
808
|
+
}
|
|
809
|
+
if (m = matches("/global-elements/:id")) {
|
|
810
|
+
return client.getGlobalElement(m.params.id).then(handleResource);
|
|
811
|
+
}
|
|
812
|
+
if (m = matches("/page-pathname-slices/:id")) {
|
|
813
|
+
return client.getPagePathnameSlice(m.params.id).then(handleResource);
|
|
814
|
+
}
|
|
815
|
+
if (m = matches("/tables/:id")) {
|
|
816
|
+
return client.getTable(m.params.id).then(handleResource);
|
|
817
|
+
}
|
|
818
|
+
return res.status(404).json({ message: "Not Found" });
|
|
1565
819
|
};
|
|
1566
820
|
}
|
|
1567
821
|
const FORWARDED_NEXT_DYNAMIC_REF_KEY = "__forwarded_next_dynamic_ref__";
|
|
@@ -1636,14 +890,14 @@ async function getStaticPaths() {
|
|
|
1636
890
|
}
|
|
1637
891
|
const REVALIDATE_SECONDS = 1;
|
|
1638
892
|
async function getStaticProps(ctx) {
|
|
1639
|
-
var _a, _b,
|
|
893
|
+
var _a, _b, _c;
|
|
1640
894
|
deprecationWarning("getStaticProps");
|
|
1641
895
|
const makeswift = new Makeswift(getApiKey(), {
|
|
1642
896
|
apiOrigin: getApiOrigin()
|
|
1643
897
|
});
|
|
1644
898
|
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1645
899
|
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1646
|
-
preview: ((
|
|
900
|
+
preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
|
|
1647
901
|
});
|
|
1648
902
|
if (snapshot == null)
|
|
1649
903
|
return {
|
|
@@ -1693,69 +947,6 @@ const Page = memo(({
|
|
|
1693
947
|
}, snapshot.document.data.key)
|
|
1694
948
|
});
|
|
1695
949
|
});
|
|
1696
|
-
const keys = (o) => Object.keys(o);
|
|
1697
|
-
const coalesce = (...args) => {
|
|
1698
|
-
let i;
|
|
1699
|
-
for (i = 0; i < args.length - 1; i += 1) {
|
|
1700
|
-
if (args[i] != null)
|
|
1701
|
-
return args[i];
|
|
1702
|
-
}
|
|
1703
|
-
return args[i];
|
|
1704
|
-
};
|
|
1705
|
-
function shallowMerge(a, b) {
|
|
1706
|
-
const bKeys = keys(b);
|
|
1707
|
-
const merged = __spreadValues({}, a);
|
|
1708
|
-
bKeys.forEach((key) => {
|
|
1709
|
-
merged[key] = coalesce(merged[key], b[key]);
|
|
1710
|
-
});
|
|
1711
|
-
return merged;
|
|
1712
|
-
}
|
|
1713
|
-
const DEVICES = [
|
|
1714
|
-
{ id: "desktop", minWidth: 769 },
|
|
1715
|
-
{ id: "tablet", minWidth: 576, maxWidth: 768 },
|
|
1716
|
-
{ id: "mobile", maxWidth: 575 }
|
|
1717
|
-
];
|
|
1718
|
-
const getDevice = (deviceId) => {
|
|
1719
|
-
const device = DEVICES.find(({ id }) => id === deviceId);
|
|
1720
|
-
if (device == null)
|
|
1721
|
-
throw new Error(`Unrecognized device ID: "${deviceId}".`);
|
|
1722
|
-
return device;
|
|
1723
|
-
};
|
|
1724
|
-
function defaultStrategy(value, fallbacks) {
|
|
1725
|
-
return value || fallbacks[0];
|
|
1726
|
-
}
|
|
1727
|
-
function shallowMergeFallbacks(value, fallbacks) {
|
|
1728
|
-
return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
|
|
1729
|
-
deviceId: a.deviceId || b.deviceId,
|
|
1730
|
-
value: shallowMerge(a.value, b.value)
|
|
1731
|
-
}));
|
|
1732
|
-
}
|
|
1733
|
-
function findDeviceOverride(values = [], deviceId, strategy = defaultStrategy) {
|
|
1734
|
-
const value = values.find(({ deviceId: d }) => d === deviceId);
|
|
1735
|
-
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));
|
|
1736
|
-
return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
|
|
1737
|
-
}
|
|
1738
|
-
function join(responsiveValues, joinFn, strategy) {
|
|
1739
|
-
return DEVICES.map(({ id }) => id).map((deviceId) => {
|
|
1740
|
-
const value = joinFn(responsiveValues.map((responsiveValue) => {
|
|
1741
|
-
const deviceValue = responsiveValue && findDeviceOverride(responsiveValue, deviceId, strategy);
|
|
1742
|
-
return deviceValue == null ? void 0 : deviceValue.value;
|
|
1743
|
-
}));
|
|
1744
|
-
if (value == null)
|
|
1745
|
-
return null;
|
|
1746
|
-
return { deviceId, value };
|
|
1747
|
-
}).filter((override) => Boolean(override));
|
|
1748
|
-
}
|
|
1749
|
-
const getDeviceMediaQuery = (device) => {
|
|
1750
|
-
const parts = ["@media only screen"];
|
|
1751
|
-
if (device.minWidth != null) {
|
|
1752
|
-
parts.push(`(min-width: ${device.minWidth}px)`);
|
|
1753
|
-
}
|
|
1754
|
-
if (device.maxWidth != null) {
|
|
1755
|
-
parts.push(`(max-width: ${device.maxWidth}px)`);
|
|
1756
|
-
}
|
|
1757
|
-
return parts.join(" and ");
|
|
1758
|
-
};
|
|
1759
950
|
const DEFAULT_BOX_ANIMATE_TYPE = "none";
|
|
1760
951
|
const DEFAULT_BOX_ANIMATE_DELAY = 0;
|
|
1761
952
|
const DEFAULT_BOX_ANIMATE_DURATION = 0.75;
|
|
@@ -2029,7 +1220,7 @@ function registerComponent$a(runtime) {
|
|
|
2029
1220
|
defaultValue: { value: 0, unit: "px" }
|
|
2030
1221
|
}),
|
|
2031
1222
|
autoplay: Checkbox({ label: "Autoplay" }),
|
|
2032
|
-
delay: Number
|
|
1223
|
+
delay: Number((props) => ({
|
|
2033
1224
|
label: "Delay",
|
|
2034
1225
|
preset: 5,
|
|
2035
1226
|
min: 1,
|
|
@@ -2710,19 +1901,6 @@ function registerBuiltinComponents(runtime) {
|
|
|
2710
1901
|
unregisterVideoComponent();
|
|
2711
1902
|
};
|
|
2712
1903
|
}
|
|
2713
|
-
const isServer = typeof window === "undefined";
|
|
2714
|
-
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
2715
|
-
const useInsertionEffect = (_c = React[useInsertionEffectSpecifier]) != null ? _c : React.useLayoutEffect;
|
|
2716
|
-
function useStyle(style) {
|
|
2717
|
-
const serialized = serializeStyles([style], cache.registered);
|
|
2718
|
-
registerStyles(cache, serialized, false);
|
|
2719
|
-
useInsertionEffect(() => {
|
|
2720
|
-
insertStyles(cache, serialized, false);
|
|
2721
|
-
});
|
|
2722
|
-
if (isServer)
|
|
2723
|
-
insertStyles(cache, serialized, false);
|
|
2724
|
-
return `${cache.key}-${serialized.name}`;
|
|
2725
|
-
}
|
|
2726
1904
|
var _path;
|
|
2727
1905
|
function _extends() {
|
|
2728
1906
|
_extends = Object.assign || function(target) {
|
|
@@ -2774,104 +1952,12 @@ const FallbackComponent = forwardRef(function FallbackComponent2({
|
|
|
2774
1952
|
})]
|
|
2775
1953
|
});
|
|
2776
1954
|
});
|
|
2777
|
-
function
|
|
2778
|
-
|
|
2779
|
-
const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
|
|
2780
|
-
const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch);
|
|
2781
|
-
useEffect(() => {
|
|
2782
|
-
if (swatchId != null)
|
|
2783
|
-
client.fetchSwatch(swatchId).catch(console.error);
|
|
2784
|
-
}, [client, swatchId]);
|
|
2785
|
-
return swatch;
|
|
2786
|
-
}
|
|
2787
|
-
function useSwatches(swatchIds) {
|
|
2788
|
-
const client = useMakeswiftClient();
|
|
2789
|
-
const lastSnapshot = useRef();
|
|
2790
|
-
function getSnapshot() {
|
|
2791
|
-
const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
|
|
2792
|
-
if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
|
|
2793
|
-
return lastSnapshot.current;
|
|
2794
|
-
}
|
|
2795
|
-
return lastSnapshot.current = swatches2;
|
|
2796
|
-
}
|
|
2797
|
-
const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
2798
|
-
useEffect(() => {
|
|
2799
|
-
Promise.all(swatchIds.map((swatchId) => client.fetchSwatch(swatchId))).catch(console.error);
|
|
2800
|
-
}, [client, swatchIds]);
|
|
2801
|
-
return swatches;
|
|
2802
|
-
}
|
|
2803
|
-
function useFile(fileId) {
|
|
2804
|
-
const client = useMakeswiftClient();
|
|
2805
|
-
const readFile = () => fileId == null ? null : client.readFile(fileId);
|
|
2806
|
-
const file = useSyncExternalStore(client.subscribe, readFile, readFile);
|
|
2807
|
-
useEffect(() => {
|
|
2808
|
-
if (fileId != null)
|
|
2809
|
-
client.fetchFile(fileId);
|
|
2810
|
-
}, [client, fileId]);
|
|
2811
|
-
return file;
|
|
2812
|
-
}
|
|
2813
|
-
function useFiles(fileIds) {
|
|
2814
|
-
const client = useMakeswiftClient();
|
|
2815
|
-
const lastSnapshot = useRef();
|
|
2816
|
-
function getSnapshot() {
|
|
2817
|
-
const files2 = fileIds.map((fileId) => client.readFile(fileId));
|
|
2818
|
-
if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
|
|
2819
|
-
return lastSnapshot.current;
|
|
2820
|
-
}
|
|
2821
|
-
return lastSnapshot.current = files2;
|
|
2822
|
-
}
|
|
2823
|
-
const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
|
|
2824
|
-
useEffect(() => {
|
|
2825
|
-
Promise.all(fileIds.map((fileId) => client.fetchFile(fileId))).catch(console.error);
|
|
2826
|
-
}, [client, fileIds]);
|
|
2827
|
-
return files;
|
|
2828
|
-
}
|
|
2829
|
-
function useTypography(typographyId) {
|
|
2830
|
-
const client = useMakeswiftClient();
|
|
2831
|
-
const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
|
|
2832
|
-
const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography);
|
|
2833
|
-
useEffect(() => {
|
|
2834
|
-
if (typographyId != null)
|
|
2835
|
-
client.fetchTypography(typographyId).catch(console.error);
|
|
2836
|
-
}, [client, typographyId]);
|
|
2837
|
-
return typography;
|
|
2838
|
-
}
|
|
2839
|
-
function useGlobalElement(globalElementId) {
|
|
2840
|
-
const client = useMakeswiftClient();
|
|
2841
|
-
const readGlobalElement = () => globalElementId == null ? null : client.readGlobalElement(globalElementId);
|
|
2842
|
-
const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement);
|
|
2843
|
-
useEffect(() => {
|
|
2844
|
-
if (globalElementId != null)
|
|
2845
|
-
client.fetchGlobalElement(globalElementId).catch(console.error);
|
|
2846
|
-
}, [client, globalElementId]);
|
|
2847
|
-
return globalElement;
|
|
2848
|
-
}
|
|
2849
|
-
function usePagePathnameSlice(pageId) {
|
|
2850
|
-
const client = useMakeswiftClient();
|
|
2851
|
-
const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice(pageId);
|
|
2852
|
-
const pagePathnameSlice = useSyncExternalStore(client.subscribe, readPagePathnameSlice, readPagePathnameSlice);
|
|
2853
|
-
useEffect(() => {
|
|
2854
|
-
if (pageId != null)
|
|
2855
|
-
client.fetchPagePathnameSlice(pageId).catch(console.error);
|
|
2856
|
-
}, [client, pageId]);
|
|
2857
|
-
return pagePathnameSlice;
|
|
2858
|
-
}
|
|
2859
|
-
function useTable(tableId) {
|
|
2860
|
-
const client = useMakeswiftClient();
|
|
2861
|
-
const readTable = () => tableId == null ? null : client.readTable(tableId);
|
|
2862
|
-
const table = useSyncExternalStore(client.subscribe, readTable, readTable);
|
|
2863
|
-
useEffect(() => {
|
|
2864
|
-
if (tableId != null)
|
|
2865
|
-
client.fetchTable(tableId).catch(console.error);
|
|
2866
|
-
}, [client, tableId]);
|
|
2867
|
-
return table;
|
|
2868
|
-
}
|
|
2869
|
-
function mapSideColor(swatches, _d) {
|
|
2870
|
-
var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
|
|
1955
|
+
function mapSideColor(swatches, _c) {
|
|
1956
|
+
var _d = _c, { color } = _d, restOfSide = __objRest(_d, ["color"]);
|
|
2871
1957
|
return __spreadProps(__spreadValues({}, restOfSide), {
|
|
2872
1958
|
color: color && {
|
|
2873
1959
|
alpha: color.alpha,
|
|
2874
|
-
swatch: swatches.filter(isNonNullable
|
|
1960
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId)
|
|
2875
1961
|
}
|
|
2876
1962
|
});
|
|
2877
1963
|
}
|
|
@@ -2917,7 +2003,7 @@ function useBoxShadow(value) {
|
|
|
2917
2003
|
return __spreadProps(__spreadValues({}, restOfShadow), {
|
|
2918
2004
|
payload: {
|
|
2919
2005
|
color: color != null ? {
|
|
2920
|
-
swatch: swatches.filter(isNonNullable
|
|
2006
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId),
|
|
2921
2007
|
alpha: color.alpha
|
|
2922
2008
|
} : null,
|
|
2923
2009
|
inset: inset != null ? inset : ShadowDefaultValue.inset,
|
|
@@ -2941,7 +2027,7 @@ function useResponsiveColor(color) {
|
|
|
2941
2027
|
const { swatchId, alpha } = v;
|
|
2942
2028
|
const swatch = swatches.find((s) => s && s.id === swatchId);
|
|
2943
2029
|
return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
|
|
2944
|
-
}).filter(isNonNullable
|
|
2030
|
+
}).filter(isNonNullable);
|
|
2945
2031
|
}
|
|
2946
2032
|
const DEVICE_QUERIES = DEVICES.map((device) => ({
|
|
2947
2033
|
id: device.id,
|
|
@@ -2972,212 +2058,6 @@ function useMediaQuery(responsiveValue) {
|
|
|
2972
2058
|
}
|
|
2973
2059
|
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
2974
2060
|
}
|
|
2975
|
-
const getIndexes = (spans, index) => {
|
|
2976
|
-
const flattened = spans.reduce((a, s) => a.concat(s), []);
|
|
2977
|
-
if (index < 0 || index > flattened.length)
|
|
2978
|
-
throw new RangeError();
|
|
2979
|
-
let remainder = index;
|
|
2980
|
-
let rowIndex = 0;
|
|
2981
|
-
while (rowIndex < spans.length - 1 && remainder >= spans[rowIndex].length) {
|
|
2982
|
-
remainder -= spans[rowIndex].length;
|
|
2983
|
-
rowIndex += 1;
|
|
2984
|
-
}
|
|
2985
|
-
return [rowIndex, remainder];
|
|
2986
|
-
};
|
|
2987
|
-
function lengthDataToString(data) {
|
|
2988
|
-
if (typeof data === "object")
|
|
2989
|
-
return `${data.value}${data.unit}`;
|
|
2990
|
-
if (typeof data === "number")
|
|
2991
|
-
return `${data}px`;
|
|
2992
|
-
return data;
|
|
2993
|
-
}
|
|
2994
|
-
function paddingPropertyDataToStyle(data, defaultValue = {}) {
|
|
2995
|
-
var _a, _b, _c2, _d;
|
|
2996
|
-
const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
|
|
2997
|
-
const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
|
|
2998
|
-
const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
|
|
2999
|
-
const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
|
|
3000
|
-
const style = {};
|
|
3001
|
-
if (paddingTop != null)
|
|
3002
|
-
style.paddingTop = lengthDataToString(paddingTop);
|
|
3003
|
-
if (paddingRight != null)
|
|
3004
|
-
style.paddingRight = lengthDataToString(paddingRight);
|
|
3005
|
-
if (paddingBottom != null)
|
|
3006
|
-
style.paddingBottom = lengthDataToString(paddingBottom);
|
|
3007
|
-
if (paddingLeft != null)
|
|
3008
|
-
style.paddingLeft = lengthDataToString(paddingLeft);
|
|
3009
|
-
return style;
|
|
3010
|
-
}
|
|
3011
|
-
function marginPropertyDataToStyle(data, defaultValue = {}) {
|
|
3012
|
-
var _a, _b, _c2, _d;
|
|
3013
|
-
const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
|
|
3014
|
-
const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
|
|
3015
|
-
const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
|
|
3016
|
-
const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
|
|
3017
|
-
const style = {};
|
|
3018
|
-
if (marginTop != null)
|
|
3019
|
-
style.marginTop = lengthDataToString(marginTop);
|
|
3020
|
-
if (marginRight != null)
|
|
3021
|
-
style.marginRight = lengthDataToString(marginRight);
|
|
3022
|
-
if (marginBottom != null)
|
|
3023
|
-
style.marginBottom = lengthDataToString(marginBottom);
|
|
3024
|
-
if (marginLeft != null)
|
|
3025
|
-
style.marginLeft = lengthDataToString(marginLeft);
|
|
3026
|
-
return style;
|
|
3027
|
-
}
|
|
3028
|
-
function lengthPercentageDataToString(data) {
|
|
3029
|
-
if (typeof data === "object")
|
|
3030
|
-
return `${data.value}${data.unit}`;
|
|
3031
|
-
if (typeof data === "number")
|
|
3032
|
-
return `${data}px`;
|
|
3033
|
-
return data;
|
|
3034
|
-
}
|
|
3035
|
-
function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
|
|
3036
|
-
var _a, _b, _c2, _d;
|
|
3037
|
-
const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
|
|
3038
|
-
const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
|
|
3039
|
-
const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
|
|
3040
|
-
const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
|
|
3041
|
-
const style = {};
|
|
3042
|
-
if (borderTopLeftRadius != null) {
|
|
3043
|
-
style.borderTopLeftRadius = lengthPercentageDataToString(borderTopLeftRadius);
|
|
3044
|
-
}
|
|
3045
|
-
if (borderTopRightRadius != null) {
|
|
3046
|
-
style.borderTopRightRadius = lengthPercentageDataToString(borderTopRightRadius);
|
|
3047
|
-
}
|
|
3048
|
-
if (borderBottomRightRadius != null) {
|
|
3049
|
-
style.borderBottomRightRadius = lengthPercentageDataToString(borderBottomRightRadius);
|
|
3050
|
-
}
|
|
3051
|
-
if (borderBottomLeftRadius != null) {
|
|
3052
|
-
style.borderBottomLeftRadius = lengthPercentageDataToString(borderBottomLeftRadius);
|
|
3053
|
-
}
|
|
3054
|
-
return style;
|
|
3055
|
-
}
|
|
3056
|
-
function colorToString(color) {
|
|
3057
|
-
return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
|
|
3058
|
-
}
|
|
3059
|
-
function borderPropertyDataToStyle(data, defaultValue = {}) {
|
|
3060
|
-
var _a, _b, _c2, _d;
|
|
3061
|
-
const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
|
|
3062
|
-
const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
|
|
3063
|
-
const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
|
|
3064
|
-
const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
|
|
3065
|
-
const style = {};
|
|
3066
|
-
if (borderTop != null)
|
|
3067
|
-
style.borderTop = borderSideToString(borderTop);
|
|
3068
|
-
if (borderRight != null)
|
|
3069
|
-
style.borderRight = borderSideToString(borderRight);
|
|
3070
|
-
if (borderBottom != null)
|
|
3071
|
-
style.borderBottom = borderSideToString(borderBottom);
|
|
3072
|
-
if (borderLeft != null)
|
|
3073
|
-
style.borderLeft = borderSideToString(borderLeft);
|
|
3074
|
-
return style;
|
|
3075
|
-
}
|
|
3076
|
-
function borderSideToString(borderSide) {
|
|
3077
|
-
if (typeof borderSide === "string")
|
|
3078
|
-
return borderSide;
|
|
3079
|
-
if (typeof borderSide === "number")
|
|
3080
|
-
return `${borderSide}px`;
|
|
3081
|
-
const { width, color, style } = borderSide;
|
|
3082
|
-
return `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : "black"}`;
|
|
3083
|
-
}
|
|
3084
|
-
function responsiveStyle(responsiveValues, join$1, strategy) {
|
|
3085
|
-
return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
|
|
3086
|
-
const device = getDevice(deviceId);
|
|
3087
|
-
const mediaQuery = getDeviceMediaQuery(device);
|
|
3088
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
3089
|
-
[mediaQuery]: __spreadValues(__spreadValues({}, acc[mediaQuery]), value)
|
|
3090
|
-
});
|
|
3091
|
-
}, {});
|
|
3092
|
-
}
|
|
3093
|
-
function responsiveWidth(widthData, defaultValue = "100%") {
|
|
3094
|
-
return __spreadValues({
|
|
3095
|
-
maxWidth: "100%"
|
|
3096
|
-
}, responsiveStyle([widthData], ([width = defaultValue]) => ({
|
|
3097
|
-
width: typeof width === "object" ? `${width.value}${width.unit}` : width
|
|
3098
|
-
})));
|
|
3099
|
-
}
|
|
3100
|
-
function responsivePadding(paddingData, defaultValue = {}) {
|
|
3101
|
-
return responsiveStyle([paddingData], ([padding = {}]) => paddingPropertyDataToStyle(padding, Object.assign({ paddingTop: 0, paddingRight: 0, paddingBottom: 0, paddingLeft: 0 }, defaultValue)));
|
|
3102
|
-
}
|
|
3103
|
-
function responsiveMargin(marginData, defaultValue = {}) {
|
|
3104
|
-
return responsiveStyle([marginData], ([margin = {}]) => marginPropertyDataToStyle(margin, Object.assign({ marginTop: 0, marginRight: "auto", marginBottom: 0, marginLeft: "auto" }, defaultValue)));
|
|
3105
|
-
}
|
|
3106
|
-
function responsiveBorderRadius(borderRadiusData, defaultValue = {}) {
|
|
3107
|
-
return responsiveStyle([borderRadiusData], ([borderRadius = {}]) => borderRadiusPropertyDataToStyle(borderRadius, Object.assign({
|
|
3108
|
-
borderTopLeftRadius: 0,
|
|
3109
|
-
borderTopRightRadius: 0,
|
|
3110
|
-
borderBottomRightRadius: 0,
|
|
3111
|
-
borderBottomLeftRadius: 0
|
|
3112
|
-
}, defaultValue)));
|
|
3113
|
-
}
|
|
3114
|
-
function responsiveBorder(borderData, defaultValue = {}) {
|
|
3115
|
-
return responsiveStyle([borderData], ([border = {}]) => borderPropertyDataToStyle(border, Object.assign({
|
|
3116
|
-
borderTop: "0px solid black",
|
|
3117
|
-
borderRight: "0px solid black",
|
|
3118
|
-
borderBottom: "0px solid black",
|
|
3119
|
-
borderLeft: "0px solid black"
|
|
3120
|
-
}, defaultValue)));
|
|
3121
|
-
}
|
|
3122
|
-
const floor = (d) => (v) => Math.floor(10 ** d * v) / 10 ** d;
|
|
3123
|
-
function responsiveGridItem(props) {
|
|
3124
|
-
return __spreadValues({
|
|
3125
|
-
display: "flex"
|
|
3126
|
-
}, responsiveStyle([props.grid, props.columnGap, props.rowGap], ([
|
|
3127
|
-
{ spans, count } = { spans: [[12]], count: 12 },
|
|
3128
|
-
columnGap = { value: 0, unit: "px" },
|
|
3129
|
-
rowGap = { value: 0, unit: "px" }
|
|
3130
|
-
]) => {
|
|
3131
|
-
const [rowIndex, columnIndex] = getIndexes(spans, props.index);
|
|
3132
|
-
const firstCol = columnIndex === 0;
|
|
3133
|
-
const lastCol = columnIndex === spans[rowIndex].length - 1;
|
|
3134
|
-
const span = spans[rowIndex][columnIndex];
|
|
3135
|
-
const fraction = floor(5)(span / count);
|
|
3136
|
-
const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`;
|
|
3137
|
-
const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${columnGap.unit} / 2`;
|
|
3138
|
-
const iePrecisionError = "0.01px";
|
|
3139
|
-
const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`;
|
|
3140
|
-
const firstRow = rowIndex === 0;
|
|
3141
|
-
const lastRow = rowIndex === spans.length - 1;
|
|
3142
|
-
return span === 0 ? { display: "none" } : {
|
|
3143
|
-
flexBasis,
|
|
3144
|
-
minWidth: flexBasis,
|
|
3145
|
-
maxWidth: flexBasis,
|
|
3146
|
-
paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
|
|
3147
|
-
paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
|
|
3148
|
-
paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,
|
|
3149
|
-
paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`
|
|
3150
|
-
};
|
|
3151
|
-
}));
|
|
3152
|
-
}
|
|
3153
|
-
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();
|
|
3154
|
-
function responsiveShadow(value) {
|
|
3155
|
-
return responsiveStyle([value], ([shadow = []]) => ({
|
|
3156
|
-
boxShadow: getBoxShadow(shadow)
|
|
3157
|
-
}));
|
|
3158
|
-
}
|
|
3159
|
-
function responsiveTextStyle(value) {
|
|
3160
|
-
return responsiveStyle([value], ([
|
|
3161
|
-
textStyle = {
|
|
3162
|
-
fontFamily: null,
|
|
3163
|
-
letterSpacing: null,
|
|
3164
|
-
fontSize: null,
|
|
3165
|
-
fontWeight: null,
|
|
3166
|
-
textTransform: [],
|
|
3167
|
-
fontStyle: []
|
|
3168
|
-
}
|
|
3169
|
-
]) => {
|
|
3170
|
-
const {
|
|
3171
|
-
fontSize,
|
|
3172
|
-
fontWeight,
|
|
3173
|
-
fontStyle = [],
|
|
3174
|
-
textTransform = [],
|
|
3175
|
-
letterSpacing,
|
|
3176
|
-
fontFamily
|
|
3177
|
-
} = textStyle;
|
|
3178
|
-
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" } : {});
|
|
3179
|
-
});
|
|
3180
|
-
}
|
|
3181
2061
|
const defaultMargin = {
|
|
3182
2062
|
marginTop: 0,
|
|
3183
2063
|
marginRight: "auto",
|
|
@@ -3202,14 +2082,14 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
3202
2082
|
style == null ? void 0 : style.borderRadius,
|
|
3203
2083
|
style == null ? void 0 : style.textStyle
|
|
3204
2084
|
], ([width, margin, padding, border, borderRadius, textStyle]) => {
|
|
3205
|
-
var _a, _b,
|
|
2085
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3206
2086
|
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(StyleControlProperty.Width) && {
|
|
3207
2087
|
width: (_a = widthToString(width)) != null ? _a : "100%"
|
|
3208
2088
|
}), properties.includes(StyleControlProperty.Margin) && marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(StyleControlProperty.Padding) && paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(StyleControlProperty.Border) && {
|
|
3209
|
-
borderTop: (_b =
|
|
3210
|
-
borderRight: (
|
|
3211
|
-
borderBottom: (_d =
|
|
3212
|
-
borderLeft: (_e =
|
|
2089
|
+
borderTop: (_b = borderSideToString(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
|
|
2090
|
+
borderRight: (_c = borderSideToString(border == null ? void 0 : border.borderRight)) != null ? _c : "0 solid black",
|
|
2091
|
+
borderBottom: (_d = borderSideToString(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
|
|
2092
|
+
borderLeft: (_e = borderSideToString(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
|
|
3213
2093
|
}), properties.includes(StyleControlProperty.BorderRadius) && {
|
|
3214
2094
|
borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
|
|
3215
2095
|
borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
|
|
@@ -3225,7 +2105,7 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
3225
2105
|
return null;
|
|
3226
2106
|
return lengthPercentageDataToString(widthProperty);
|
|
3227
2107
|
}
|
|
3228
|
-
function
|
|
2108
|
+
function borderSideToString(borderSide) {
|
|
3229
2109
|
if (borderSide == null)
|
|
3230
2110
|
return null;
|
|
3231
2111
|
const { width, color, style: style2 } = borderSide;
|
|
@@ -3470,13 +2350,13 @@ function useSlot(data, control) {
|
|
|
3470
2350
|
}, element.key))
|
|
3471
2351
|
});
|
|
3472
2352
|
}
|
|
3473
|
-
function Slot(
|
|
3474
|
-
var
|
|
2353
|
+
function Slot(_e) {
|
|
2354
|
+
var _f = _e, {
|
|
3475
2355
|
as,
|
|
3476
2356
|
control,
|
|
3477
2357
|
children,
|
|
3478
2358
|
className
|
|
3479
|
-
} =
|
|
2359
|
+
} = _f, restOfProps = __objRest(_f, [
|
|
3480
2360
|
"as",
|
|
3481
2361
|
"control",
|
|
3482
2362
|
"children",
|
|
@@ -3505,15 +2385,15 @@ function Slot(_f) {
|
|
|
3505
2385
|
}
|
|
3506
2386
|
Slot.Placeholder = SlotPlaceholder;
|
|
3507
2387
|
Slot.Item = SlotItem;
|
|
3508
|
-
function SlotItem(
|
|
3509
|
-
var
|
|
2388
|
+
function SlotItem(_g) {
|
|
2389
|
+
var _h = _g, {
|
|
3510
2390
|
as,
|
|
3511
2391
|
control,
|
|
3512
2392
|
grid,
|
|
3513
2393
|
index,
|
|
3514
2394
|
children,
|
|
3515
2395
|
className
|
|
3516
|
-
} =
|
|
2396
|
+
} = _h, restOfProps = __objRest(_h, [
|
|
3517
2397
|
"as",
|
|
3518
2398
|
"control",
|
|
3519
2399
|
"grid",
|
|
@@ -3733,7 +2613,7 @@ function PropsValue({
|
|
|
3733
2613
|
return getPropControllers(state, documentKey, element.key);
|
|
3734
2614
|
});
|
|
3735
2615
|
return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
|
|
3736
|
-
var _a2, _b,
|
|
2616
|
+
var _a2, _b, _c;
|
|
3737
2617
|
switch (descriptor.type) {
|
|
3738
2618
|
case CheckboxControlType:
|
|
3739
2619
|
case NumberControlType:
|
|
@@ -3775,7 +2655,7 @@ function PropsValue({
|
|
|
3775
2655
|
}, descriptor.type);
|
|
3776
2656
|
}
|
|
3777
2657
|
case SlotControlType: {
|
|
3778
|
-
const control = (
|
|
2658
|
+
const control = (_c = propControllers == null ? void 0 : propControllers[propName]) != null ? _c : null;
|
|
3779
2659
|
return /* @__PURE__ */ jsx(RenderHook, {
|
|
3780
2660
|
hook: useSlot,
|
|
3781
2661
|
parameters: [props[propName], control],
|
|
@@ -3957,7 +2837,7 @@ function isDomNodeHandle(value) {
|
|
|
3957
2837
|
}
|
|
3958
2838
|
return false;
|
|
3959
2839
|
}
|
|
3960
|
-
const storeContextDefaultValue = configureStore
|
|
2840
|
+
const storeContextDefaultValue = configureStore();
|
|
3961
2841
|
function createReactRuntime(store) {
|
|
3962
2842
|
return {
|
|
3963
2843
|
registerComponent(component, {
|
|
@@ -3978,8 +2858,8 @@ function createReactRuntime(store) {
|
|
|
3978
2858
|
unregisterReactComponent();
|
|
3979
2859
|
};
|
|
3980
2860
|
},
|
|
3981
|
-
copyElementTree(
|
|
3982
|
-
return copyElementTree(store.getState(),
|
|
2861
|
+
copyElementTree(elementTree2, replacementContext) {
|
|
2862
|
+
return copyElementTree(store.getState(), elementTree2, replacementContext);
|
|
3983
2863
|
}
|
|
3984
2864
|
};
|
|
3985
2865
|
}
|
|
@@ -3988,10 +2868,10 @@ registerBuiltinComponents(ReactRuntime);
|
|
|
3988
2868
|
const StoreContext = createContext(storeContextDefaultValue);
|
|
3989
2869
|
const PreviewProvider = dynamic(() => import("./PreviewProvider.es.js"));
|
|
3990
2870
|
const LiveProvider = dynamic(() => import("./LiveProvider.es.js"));
|
|
3991
|
-
function RuntimeProvider(
|
|
3992
|
-
var
|
|
2871
|
+
function RuntimeProvider(_i) {
|
|
2872
|
+
var _j = _i, {
|
|
3993
2873
|
preview
|
|
3994
|
-
} =
|
|
2874
|
+
} = _j, props = __objRest(_j, [
|
|
3995
2875
|
"preview"
|
|
3996
2876
|
]);
|
|
3997
2877
|
return preview ? /* @__PURE__ */ jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsx(LiveProvider, __spreadValues({}, props));
|
|
@@ -4189,5 +3069,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4189
3069
|
document: document2
|
|
4190
3070
|
});
|
|
4191
3071
|
}));
|
|
4192
|
-
export {
|
|
3072
|
+
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 };
|
|
4193
3073
|
//# sourceMappingURL=index.es.js.map
|