@makeswift/runtime 0.5.2 → 0.5.4
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 +1 -1
- package/dist/Box.es.js +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/Carousel.cjs.js +1 -1
- package/dist/Carousel.es.js +1 -1
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +1 -1
- package/dist/Divider.es.js +1 -1
- package/dist/Embed.cjs.js +1 -1
- package/dist/Embed.es.js +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +1 -1
- package/dist/Image.cjs.js +1 -1
- package/dist/Image.es.js +1 -1
- package/dist/LiveProvider.cjs.js +3 -3
- package/dist/LiveProvider.es.js +3 -3
- package/dist/Navigation.cjs.js +1 -1
- package/dist/Navigation.es.js +1 -1
- package/dist/PreviewProvider.cjs.js +18 -18
- package/dist/PreviewProvider.es.js +3 -3
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +4 -4
- package/dist/Text.es.js +1 -1
- package/dist/Video.cjs.js +6 -2
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +7 -3
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +1 -6
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +2 -6
- package/dist/actions.es.js.map +1 -1
- package/dist/components.cjs.js +1 -2
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +2 -2
- package/dist/{react-page.cjs.js → constants.cjs.js} +17 -1
- package/dist/constants.cjs.js.map +1 -0
- package/dist/{react-page.es.js → constants.es.js} +17 -2
- package/dist/constants.es.js.map +1 -0
- package/dist/index.cjs.js +42 -66
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +6 -6
- package/dist/index.es.js +7 -30
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +1 -1
- package/dist/main.cjs.js +3 -2
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -1
- package/dist/next.cjs.js +1 -1
- package/dist/next.es.js +2 -2
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/types/src/api/react.d.ts +0 -1
- package/dist/types/src/api/react.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Video/Video.d.ts.map +1 -1
- package/dist/types/src/components/builtin/index.d.ts +0 -1
- package/dist/types/src/components/builtin/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +1 -10
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/makeswift-api-client.d.ts +2 -2
- package/dist/types/src/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/src/state/modules/api-resources.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/react-page.cjs.js.map +0 -1
- package/dist/react-page.es.js.map +0 -1
package/dist/index.cjs2.js
CHANGED
|
@@ -36,7 +36,7 @@ require("use-sync-external-store/shim");
|
|
|
36
36
|
require("./slot.cjs.js");
|
|
37
37
|
var css = require("@emotion/css");
|
|
38
38
|
var jsxRuntime = require("react/jsx-runtime");
|
|
39
|
-
var
|
|
39
|
+
var constants = require("./constants.cjs.js");
|
|
40
40
|
var NextImage = require("next/image");
|
|
41
41
|
var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
|
|
42
42
|
var ReactPlayer = require("react-player");
|
|
@@ -47,9 +47,9 @@ function _interopDefaultLegacy(e) {
|
|
|
47
47
|
var NextImage__default = /* @__PURE__ */ _interopDefaultLegacy(NextImage);
|
|
48
48
|
var ReactPlayer__default = /* @__PURE__ */ _interopDefaultLegacy(ReactPlayer);
|
|
49
49
|
function useBackgrounds(value) {
|
|
50
|
-
const fileIds =
|
|
50
|
+
const fileIds = constants.getBackgroundsFileIds(value);
|
|
51
51
|
const files = next.useFiles(fileIds);
|
|
52
|
-
const swatchIds =
|
|
52
|
+
const swatchIds = constants.getBackgroundsSwatchIds(value);
|
|
53
53
|
const swatches = next.useSwatches(swatchIds);
|
|
54
54
|
return React.useMemo(() => {
|
|
55
55
|
if (value == null)
|
|
@@ -72,7 +72,7 @@ function useBackgrounds(value) {
|
|
|
72
72
|
}
|
|
73
73
|
if (bg.type === "color" && bg.payload != null) {
|
|
74
74
|
const { swatchId, alpha } = bg.payload;
|
|
75
|
-
const swatch = swatches.filter(
|
|
75
|
+
const swatch = swatches.filter(constants.isNonNullable).find((s) => s && s.id === swatchId);
|
|
76
76
|
return { id: bg.id, type: "color", payload: { swatch, alpha } };
|
|
77
77
|
}
|
|
78
78
|
if (bg.type === "gradient" && bg.payload != null && bg.payload.stops.length > 0) {
|
|
@@ -86,7 +86,7 @@ function useBackgrounds(value) {
|
|
|
86
86
|
var _c = _b2, { color } = _c, restOfStop = __objRest(_c, ["color"]);
|
|
87
87
|
return __spreadProps(__spreadValues({}, restOfStop), {
|
|
88
88
|
color: color && {
|
|
89
|
-
swatch: swatches.filter(
|
|
89
|
+
swatch: swatches.filter(constants.isNonNullable).find((s) => s && s.id === color.swatchId),
|
|
90
90
|
alpha: color.alpha
|
|
91
91
|
}
|
|
92
92
|
});
|
|
@@ -106,7 +106,7 @@ function useBackgrounds(value) {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
return null;
|
|
109
|
-
}).filter(
|
|
109
|
+
}).filter(constants.isNonNullable)
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
}, [files, swatches, value]);
|
package/dist/index.es.js
CHANGED
|
@@ -39,8 +39,8 @@ import * as React from "react";
|
|
|
39
39
|
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useCallback, Component, useImperativeHandle, Suspense } from "react";
|
|
40
40
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
41
41
|
import dynamic from "next/dynamic";
|
|
42
|
-
import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, v as getReactComponent } from "./
|
|
43
|
-
import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as
|
|
42
|
+
import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, M as MakeswiftComponentType, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, v as getReactComponent } from "./constants.es.js";
|
|
43
|
+
import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as registerComponentHandleEffect, j as mountComponentEffect, k as registerComponentEffect, l as registerReactComponentEffect } from "./actions.es.js";
|
|
44
44
|
import { cache, cx } from "@emotion/css";
|
|
45
45
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
46
46
|
import { T as Types, E as ElementID, B as Backgrounds, W as Width, h as ResponsiveIconRadioGroup, M as Margin, P as Padding, i as Border, j as BorderRadius, k as Shadows, G as GapY, l as GapX, m as ResponsiveSelect, n as ResponsiveNumber, o as Checkbox, p as Grid, q as TextInput, L as Link, r 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, I as ImageControlType, C as ColorControlType, Q as BorderPropControllerFormat, U as ShadowsPropControllerFormat, X as BorderRadiusPropControllerFormat, Y as MarginPropControllerFormat, Z as PaddingPropControllerFormat, _ as WidthPropControllerFormat, S as SlotControlType, a as StyleControlType } from "./slot.es.js";
|
|
@@ -249,8 +249,6 @@ function getAPIResource$1(state, resourceType, resourceId) {
|
|
|
249
249
|
}
|
|
250
250
|
function reducer$1(state = getInitialState(), action) {
|
|
251
251
|
switch (action.type) {
|
|
252
|
-
case ActionTypes.RESTORE_API_RESOURCES_CACHE:
|
|
253
|
-
return getInitialState(action.payload.serializedState);
|
|
254
252
|
case ActionTypes.API_RESOURCE_FULFILLED: {
|
|
255
253
|
const { resourceType, resourceId, resource } = action.payload;
|
|
256
254
|
return new Map(state).set(resourceType, new Map(state.get(resourceType)).set(resourceId, resource));
|
|
@@ -626,9 +624,6 @@ class MakeswiftClient {
|
|
|
626
624
|
KeyUtils.resetGenerator();
|
|
627
625
|
return getSerializedState(this.makeswiftApiClient.getState());
|
|
628
626
|
}
|
|
629
|
-
updateCacheData(cacheData) {
|
|
630
|
-
this.makeswiftApiClient.dispatch(restoreAPIResourcesCache(cacheData));
|
|
631
|
-
}
|
|
632
627
|
readSwatch(swatchId) {
|
|
633
628
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Swatch, swatchId);
|
|
634
629
|
}
|
|
@@ -1054,7 +1049,7 @@ class Document$1 extends NextDocument {
|
|
|
1054
1049
|
});
|
|
1055
1050
|
}
|
|
1056
1051
|
}
|
|
1057
|
-
const version = "0.5.
|
|
1052
|
+
const version = "0.5.4";
|
|
1058
1053
|
function isErrorWithMessage(error) {
|
|
1059
1054
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
1060
1055
|
}
|
|
@@ -1288,20 +1283,17 @@ async function getServerSideProps(ctx) {
|
|
|
1288
1283
|
const Page = memo(({
|
|
1289
1284
|
snapshot
|
|
1290
1285
|
}) => {
|
|
1291
|
-
const
|
|
1286
|
+
const client = useMemo(() => new MakeswiftClient({
|
|
1292
1287
|
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
1293
1288
|
cacheData: snapshot.cacheData
|
|
1294
|
-
}));
|
|
1295
|
-
useEffect(() => {
|
|
1296
|
-
client.updateCacheData(snapshot.cacheData);
|
|
1297
|
-
}, [client, snapshot]);
|
|
1289
|
+
}), [snapshot]);
|
|
1298
1290
|
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
1299
1291
|
client,
|
|
1300
1292
|
rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
|
|
1301
1293
|
preview: snapshot.preview,
|
|
1302
1294
|
children: /* @__PURE__ */ jsx(Page$1, {
|
|
1303
1295
|
document: snapshot.document
|
|
1304
|
-
})
|
|
1296
|
+
}, snapshot.document.data.key)
|
|
1305
1297
|
});
|
|
1306
1298
|
});
|
|
1307
1299
|
const keys = (o) => Object.keys(o);
|
|
@@ -1367,21 +1359,6 @@ const getDeviceMediaQuery = (device) => {
|
|
|
1367
1359
|
}
|
|
1368
1360
|
return parts.join(" and ");
|
|
1369
1361
|
};
|
|
1370
|
-
const MakeswiftComponentType = {
|
|
1371
|
-
Box: "./components/Box/index.js",
|
|
1372
|
-
Button: "./components/Button/index.js",
|
|
1373
|
-
Carousel: "./components/Carousel/index.js",
|
|
1374
|
-
Countdown: "./components/Countdown/index.js",
|
|
1375
|
-
Divider: "./components/Divider/index.js",
|
|
1376
|
-
Embed: "./components/Embed/index.js",
|
|
1377
|
-
Form: "./components/Form/index.js",
|
|
1378
|
-
Image: "./components/Image/index.js",
|
|
1379
|
-
Navigation: "./components/Navigation/index.js",
|
|
1380
|
-
Root: "./components/Root/index.js",
|
|
1381
|
-
SocialLinks: "./components/SocialLinks/index.js",
|
|
1382
|
-
Text: "./components/Text/index.js",
|
|
1383
|
-
Video: "./components/Video/index.js"
|
|
1384
|
-
};
|
|
1385
1362
|
const DEFAULT_BOX_ANIMATE_TYPE = "none";
|
|
1386
1363
|
const DEFAULT_BOX_ANIMATE_DELAY = 0;
|
|
1387
1364
|
const DEFAULT_BOX_ANIMATE_DURATION = 0.75;
|
|
@@ -3933,5 +3910,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
3933
3910
|
document: document2
|
|
3934
3911
|
});
|
|
3935
3912
|
}));
|
|
3936
|
-
export {
|
|
3913
|
+
export { Makeswift as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, serializeStyles as H, insertStyles as I, useTypography as J, useSwatches as K, shallowMergeFallbacks as L, useFiles as M, usePagePathnameSlice as N, useElementId as O, PageProvider as P, deepEqual as Q, RuntimeProvider as R, Shapes as S, storeContextDefaultValue as T, StoreContext as U, MakeswiftProvider as V, MakeswiftClient as W, getStaticPaths as X, getStaticProps as Y, getServerSideProps as Z, Page as _, ReactRuntime as a, PreviewModeScript as a0, Document$1 as a1, MakeswiftApiHandler as a2, forwardNextDynamicRef as a3, 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, useStyle as o, responsiveWidth as p, responsiveTextStyle as q, responsiveStyle as r, colorToString as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
|
|
3937
3914
|
//# sourceMappingURL=index.es.js.map
|