@makeswift/runtime 0.9.4 → 0.9.6
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 +3 -3
- package/dist/Box.es.js +3 -3
- package/dist/Button.cjs.js +3 -3
- package/dist/Button.es.js +3 -3
- package/dist/Carousel.cjs.js +3 -3
- package/dist/Carousel.es.js +3 -3
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +3 -3
- package/dist/Divider.es.js +3 -3
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +1 -0
- package/dist/Embed.es.js.map +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 +4 -4
- package/dist/LiveProvider.es.js +5 -5
- package/dist/Navigation.cjs.js +2 -2
- package/dist/Navigation.es.js +2 -2
- package/dist/PreviewProvider.cjs.js +8 -7
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +11 -10
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +3 -2
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +5 -4
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +12 -12
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +14 -14
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +3 -3
- package/dist/SocialLinks.es.js +3 -3
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +1 -0
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +467 -3
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +467 -4
- package/dist/actions.es.js.map +1 -1
- package/dist/api.cjs.js +20 -1
- package/dist/api.cjs.js.map +1 -1
- package/dist/api.es.js +20 -1
- package/dist/api.es.js.map +1 -1
- package/dist/box-model.cjs.js +1 -0
- package/dist/box-model.cjs.js.map +1 -1
- package/dist/box-model.es.js +1 -0
- package/dist/box-model.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +1 -1
- package/dist/control-serialization.cjs.js +1 -0
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +1 -0
- package/dist/control-serialization.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 +2 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +71 -41
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +5 -4
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +1 -0
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +30 -14
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs9.js +4 -4
- package/dist/index.es.js +74 -45
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +7 -6
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +2 -1
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es5.js +32 -16
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -1
- package/dist/index.es8.js +1 -1
- package/dist/index.es9.js +6 -6
- 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 +1 -1
- package/dist/next.es.js +2 -2
- 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-page.cjs.js +27 -32
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +27 -14
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/slate.cjs.js +25 -67
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +31 -71
- package/dist/slate.es.js.map +1 -1
- package/dist/state/breakpoints.cjs.js +14 -0
- package/dist/state/breakpoints.cjs.js.map +1 -1
- package/dist/state/breakpoints.es.js +14 -1
- package/dist/state/breakpoints.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/fragments.d.ts +1 -1
- package/dist/types/src/api/graphql/documents/fragments.d.ts.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/fragment-document-nodes.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/types.d.ts +12 -0
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/api/react.d.ts +3 -1
- 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/page/Page.d.ts.map +1 -1
- package/dist/types/src/controls/icon-radio-group.d.ts +1 -1
- package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -1
- package/dist/types/src/controls/link.d.ts +1 -1
- package/dist/types/src/controls/link.d.ts.map +1 -1
- package/dist/types/src/controls/select.d.ts +1 -1
- package/dist/types/src/controls/select.d.ts.map +1 -1
- package/dist/types/src/controls/typography.d.ts +1 -1
- package/dist/types/src/controls/typography.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +11 -2
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/typography.d.ts +2 -2
- package/dist/types/src/runtimes/react/controls/typography.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/getValue.d.ts +1 -1
- package/dist/types/src/slate/InlinePlugin/getValue.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/getValue.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/getValue.d.ts +4 -0
- package/dist/types/src/slate/TextAlignPlugin/getValue.d.ts.map +1 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/getValue.d.ts +4 -0
- package/dist/types/src/slate/TypographyPlugin/getValue.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +0 -1
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/utils/responsive.d.ts +3 -5
- package/dist/types/src/slate/utils/responsive.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +7 -7
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/makeswift-api-client.d.ts +1 -1
- package/dist/types/src/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/src/state/modules/breakpoints.d.ts +2 -0
- package/dist/types/src/state/modules/breakpoints.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts +6 -7
- package/dist/types/src/state/modules/locales.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +3 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/types/types/locale.d.ts +9 -0
- package/dist/types/types/locale.d.ts.map +1 -0
- package/dist/types.cjs2.js +8 -11
- package/dist/types.cjs2.js.map +1 -1
- package/dist/types.es2.js +9 -12
- package/dist/types.es2.js.map +1 -1
- package/dist/typography.cjs.js.map +1 -1
- package/dist/typography.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/src/slate/ColorPlugin/index.d.ts +0 -10
- package/dist/types/src/slate/ColorPlugin/index.d.ts.map +0 -1
package/dist/index.cjs8.js
CHANGED
|
@@ -9,6 +9,7 @@ require("./react-page.cjs.js");
|
|
|
9
9
|
require("redux");
|
|
10
10
|
require("redux-thunk");
|
|
11
11
|
require("./actions.cjs.js");
|
|
12
|
+
require("zod");
|
|
12
13
|
require("./state/breakpoints.cjs.js");
|
|
13
14
|
require("@emotion/css");
|
|
14
15
|
require("@emotion/serialize");
|
|
@@ -26,7 +27,6 @@ require("scroll-into-view-if-needed");
|
|
|
26
27
|
require("react-dom");
|
|
27
28
|
require("html-react-parser");
|
|
28
29
|
require("next/head");
|
|
29
|
-
require("zod");
|
|
30
30
|
require("@emotion/server/create-instance");
|
|
31
31
|
require("next/document");
|
|
32
32
|
require("cors");
|
package/dist/index.cjs9.js
CHANGED
|
@@ -37,9 +37,6 @@ var isHotkey = require("is-hotkey");
|
|
|
37
37
|
var slateHistory = require("slate-history");
|
|
38
38
|
var slateReact = require("slate-react");
|
|
39
39
|
var reactPage = require("./react-page.cjs.js");
|
|
40
|
-
var css = require("@emotion/css");
|
|
41
|
-
require("@emotion/serialize");
|
|
42
|
-
require("@emotion/utils");
|
|
43
40
|
var next = require("./index.cjs.js");
|
|
44
41
|
require("./state/breakpoints.cjs.js");
|
|
45
42
|
require("./types.cjs2.js");
|
|
@@ -47,10 +44,13 @@ var index = require("./index.cjs6.js");
|
|
|
47
44
|
var index$1 = require("./index.cjs7.js");
|
|
48
45
|
var jsxRuntime = require("react/jsx-runtime");
|
|
49
46
|
require("./index.cjs3.js");
|
|
47
|
+
var css = require("@emotion/css");
|
|
50
48
|
var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
|
|
49
|
+
require("./actions.cjs.js");
|
|
51
50
|
require("redux");
|
|
52
51
|
require("redux-thunk");
|
|
53
|
-
require("
|
|
52
|
+
require("@emotion/serialize");
|
|
53
|
+
require("@emotion/utils");
|
|
54
54
|
require("use-sync-external-store/shim/with-selector");
|
|
55
55
|
require("next/dynamic");
|
|
56
56
|
require("./typography.cjs.js");
|
package/dist/index.es.js
CHANGED
|
@@ -38,8 +38,8 @@ import * as React from "react";
|
|
|
38
38
|
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
|
|
39
39
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
40
40
|
import dynamic from "next/dynamic";
|
|
41
|
-
import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, E as ElementID, B as Backgrounds, W as Width, m as ResponsiveIconRadioGroup, M as Margin, P as Padding, n as Border, o as BorderRadius, S as Shadows, G as GapY, p as GapX, q as ResponsiveSelect, r as ResponsiveNumber, s as Checkbox, t as Grid, u as TextInput, L as Link, v as ResponsiveColor, w as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, x as ResponsiveLength, y as TextArea, z as Table, A as TableFormFields, H as Image, J as ResponsiveOpacity, K as NavigationLinks, O as SocialLinks, Q as RichText, V as Video, U as useStyle, X as getBorderSwatchIds, Y as isNonNullable$1, Z as getBoxShadowsSwatchIds, _ as getResponsiveColorSwatchIds, $ as StyleControlProperty, a0 as ImageControlValueFormat, a1 as isPropControllersHandle, a2 as StyleControlType, a3 as RichTextV2ControlType, a4 as RichTextControlType, a5 as SlotControlType, a6 as StyleV2ControlType, a7 as ListControlType, a8 as ShapeControlType, a9 as LinkControlType, aa as ImageControlType, ab as ColorControlType, ac as getComponentPropControllerDescriptors, ad as getPropControllers, ae as Types, af as BorderPropControllerFormat, ag as ShadowsPropControllerFormat, ah as BorderRadiusPropControllerFormat, ai as MarginPropControllerFormat, aj as PaddingPropControllerFormat, ak as WidthPropControllerFormat, al as configureStore$1, am as copyElementTree, an as getBreakpoints, ao as
|
|
42
|
-
import { A as ActionTypes,
|
|
41
|
+
import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, E as ElementID, B as Backgrounds, W as Width, m as ResponsiveIconRadioGroup, M as Margin, P as Padding, n as Border, o as BorderRadius, S as Shadows, G as GapY, p as GapX, q as ResponsiveSelect, r as ResponsiveNumber, s as Checkbox, t as Grid, u as TextInput, L as Link, v as ResponsiveColor, w as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, x as ResponsiveLength, y as TextArea, z as Table, A as TableFormFields, H as Image, J as ResponsiveOpacity, K as NavigationLinks, O as SocialLinks, Q as RichText, V as Video, U as useStyle, X as getBorderSwatchIds, Y as isNonNullable$1, Z as getBoxShadowsSwatchIds, _ as getResponsiveColorSwatchIds, $ as StyleControlProperty, a0 as ImageControlValueFormat, a1 as isPropControllersHandle, a2 as StyleControlType, a3 as RichTextV2ControlType, a4 as RichTextControlType, a5 as SlotControlType, a6 as StyleV2ControlType, a7 as ListControlType, a8 as ShapeControlType, a9 as LinkControlType, aa as ImageControlType, ab as ColorControlType, ac as getComponentPropControllerDescriptors, ad as getPropControllers, ae as Types, af as BorderPropControllerFormat, ag as ShadowsPropControllerFormat, ah as BorderRadiusPropControllerFormat, ai as MarginPropControllerFormat, aj as PaddingPropControllerFormat, ak as WidthPropControllerFormat, al as configureStore$1, am as copyElementTree, an as getBreakpoints, ao as parseLocalesInput, ap as getDocument, aq as getElementId, ar as getIsPreview, as as getIsInBuilder, at as getReactComponent, au as getBuilderEditMode } from "./react-page.es.js";
|
|
42
|
+
import { A as ActionTypes, o as apiResourceFulfilled, p as registerComponentEffect, q as registerReactComponentEffect, t as registerComponentHandleEffect, v as mountComponentEffect } from "./actions.es.js";
|
|
43
43
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
44
44
|
import { T as TypographyControlType, I as IconRadioGroupControlType, S as SelectControlType, a as TextAreaControlType, b as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./typography.es.js";
|
|
45
45
|
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
@@ -48,13 +48,11 @@ import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
|
48
48
|
import { createStore, applyMiddleware } from "redux";
|
|
49
49
|
import thunk from "redux-thunk";
|
|
50
50
|
import { A as APIResourceType } from "./types.es.js";
|
|
51
|
-
import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, getBreakpoint, getBreakpointMediaQuery, shallowMergeFallbacks, parseBreakpointsInput } from "./state/breakpoints.es.js";
|
|
51
|
+
import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, getBreakpoint, getBreakpointMediaQuery, mergeOrCoalesceFallbacks, shallowMergeFallbacks, parseBreakpointsInput } from "./state/breakpoints.es.js";
|
|
52
52
|
import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
|
|
53
53
|
import ColorHelper from "color";
|
|
54
|
-
import { cache, cx } from "@emotion/css";
|
|
55
|
-
import "@emotion/serialize";
|
|
56
|
-
import "@emotion/utils";
|
|
57
54
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
55
|
+
import { cache, cx } from "@emotion/css";
|
|
58
56
|
import { findDOMNode } from "react-dom";
|
|
59
57
|
import parse from "html-react-parser";
|
|
60
58
|
import Head from "next/head";
|
|
@@ -220,7 +218,7 @@ async function fetchJson(url) {
|
|
|
220
218
|
}
|
|
221
219
|
return response.json();
|
|
222
220
|
}
|
|
223
|
-
function fetchAPIResource(resourceType, resourceId) {
|
|
221
|
+
function fetchAPIResource(resourceType, resourceId, locale) {
|
|
224
222
|
return async (dispatch, getState) => {
|
|
225
223
|
const state = getState();
|
|
226
224
|
if (getHasAPIResource(state, resourceType, resourceId)) {
|
|
@@ -238,7 +236,7 @@ function fetchAPIResource(resourceType, resourceId) {
|
|
|
238
236
|
resource = await fetchJson(`/api/makeswift/typographies/${resourceId}`);
|
|
239
237
|
break;
|
|
240
238
|
case APIResourceType.GlobalElement:
|
|
241
|
-
resource = await fetchJson(`/api/makeswift/global-elements/${resourceId}`);
|
|
239
|
+
resource = await fetchJson(`/api/makeswift/global-elements/${resourceId}?locale=${locale == null ? void 0 : locale.toString()}`);
|
|
242
240
|
break;
|
|
243
241
|
case APIResourceType.PagePathnameSlice:
|
|
244
242
|
resource = await fetchJson(`/api/makeswift/page-pathname-slices/${resourceId}`);
|
|
@@ -332,6 +330,12 @@ const GlobalElementFragment = `
|
|
|
332
330
|
__typename
|
|
333
331
|
id
|
|
334
332
|
data
|
|
333
|
+
|
|
334
|
+
localized(locale: $locale) {
|
|
335
|
+
__typename
|
|
336
|
+
id
|
|
337
|
+
data
|
|
338
|
+
}
|
|
335
339
|
}
|
|
336
340
|
`;
|
|
337
341
|
const TableFragment = `
|
|
@@ -425,9 +429,15 @@ const TypographiesQuery = `
|
|
|
425
429
|
${TypographyFragment}
|
|
426
430
|
`;
|
|
427
431
|
const GlobalElementQuery = `
|
|
428
|
-
query GlobalElement($globalElementId: ID
|
|
432
|
+
query GlobalElement($globalElementId: ID!, $locale: Locale) {
|
|
429
433
|
globalElement(id: $globalElementId) {
|
|
430
434
|
...GlobalElement
|
|
435
|
+
|
|
436
|
+
localized(locale: $locale) {
|
|
437
|
+
__typename
|
|
438
|
+
id
|
|
439
|
+
data
|
|
440
|
+
}
|
|
431
441
|
}
|
|
432
442
|
}
|
|
433
443
|
|
|
@@ -445,16 +455,19 @@ const CreateTableRecordMutation = `
|
|
|
445
455
|
class MakeswiftClient {
|
|
446
456
|
constructor({
|
|
447
457
|
uri,
|
|
448
|
-
cacheData
|
|
458
|
+
cacheData,
|
|
459
|
+
locale
|
|
449
460
|
}) {
|
|
450
461
|
__publicField(this, "graphqlClient");
|
|
451
462
|
__publicField(this, "makeswiftApiClient");
|
|
452
463
|
__publicField(this, "subscribe");
|
|
464
|
+
__publicField(this, "locale");
|
|
453
465
|
this.graphqlClient = new GraphQLClient(uri);
|
|
454
466
|
this.makeswiftApiClient = configureStore({
|
|
455
467
|
serializedState: cacheData
|
|
456
468
|
});
|
|
457
469
|
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
470
|
+
this.locale = locale;
|
|
458
471
|
}
|
|
459
472
|
readSwatch(swatchId) {
|
|
460
473
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Swatch, swatchId);
|
|
@@ -478,7 +491,7 @@ class MakeswiftClient {
|
|
|
478
491
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.GlobalElement, globalElementId);
|
|
479
492
|
}
|
|
480
493
|
async fetchGlobalElement(globalElementId) {
|
|
481
|
-
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.GlobalElement, globalElementId));
|
|
494
|
+
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.GlobalElement, globalElementId, this.locale));
|
|
482
495
|
}
|
|
483
496
|
readPagePathnameSlice(pageId) {
|
|
484
497
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.PagePathnameSlice, pageId);
|
|
@@ -565,7 +578,7 @@ const filterUsedSnippetProperties = ({
|
|
|
565
578
|
function Page$1({
|
|
566
579
|
document: page
|
|
567
580
|
}) {
|
|
568
|
-
var _a;
|
|
581
|
+
var _a, _b;
|
|
569
582
|
const isInBuilder = useIsInBuilder();
|
|
570
583
|
const [snippets, setSnippets] = useState(page.snippets);
|
|
571
584
|
const cachedPage = useCachedPage(isInBuilder ? page.id : null);
|
|
@@ -627,6 +640,10 @@ function Page$1({
|
|
|
627
640
|
});
|
|
628
641
|
previousHeadSnippets.current = headSnippets;
|
|
629
642
|
}, [headSnippets]);
|
|
643
|
+
const baseLocalizedPage = page.localizedPages.find(({
|
|
644
|
+
parentId
|
|
645
|
+
}) => parentId == null);
|
|
646
|
+
const documentId = (_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.elementTreeId) != null ? _b : page.id;
|
|
630
647
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
631
648
|
children: [/* @__PURE__ */ jsxs(Head, {
|
|
632
649
|
children: [/* @__PURE__ */ jsx("style", {
|
|
@@ -708,7 +725,7 @@ function Page$1({
|
|
|
708
725
|
return null;
|
|
709
726
|
}))]
|
|
710
727
|
}), /* @__PURE__ */ jsx(DocumentReference, {
|
|
711
|
-
documentReference: createDocumentReference(
|
|
728
|
+
documentReference: createDocumentReference(documentId)
|
|
712
729
|
}), filteredSnippets.filter((snippet) => snippet.location === SnippetLocation.Body).map((snippet) => /* @__PURE__ */ jsx(BodySnippet, {
|
|
713
730
|
code: snippet.code,
|
|
714
731
|
cleanup: snippet.cleanup
|
|
@@ -910,7 +927,8 @@ Received "${apiKey}" instead.`);
|
|
|
910
927
|
const swatches = await this.getSwatches(swatchIds, preview);
|
|
911
928
|
return __spreadProps(__spreadValues({}, result), { swatches });
|
|
912
929
|
}
|
|
913
|
-
async introspect(element, preview) {
|
|
930
|
+
async introspect(element, preview, locale) {
|
|
931
|
+
var _a, _b;
|
|
914
932
|
const runtime = this.runtime;
|
|
915
933
|
const descriptors = getPropControllerDescriptors(runtime.store.getState());
|
|
916
934
|
const swatchIds = /* @__PURE__ */ new Set();
|
|
@@ -942,9 +960,9 @@ Received "${apiKey}" instead.`);
|
|
|
942
960
|
};
|
|
943
961
|
let element2;
|
|
944
962
|
if (isElementReference(current)) {
|
|
945
|
-
const globalElement = await this.getGlobalElement(current.value);
|
|
963
|
+
const globalElement = await this.getGlobalElement(current.value, locale);
|
|
946
964
|
globalElements.set(current.value, globalElement);
|
|
947
|
-
const elementData = globalElement == null ? void 0 : globalElement.data;
|
|
965
|
+
const elementData = (_b = (_a = globalElement == null ? void 0 : globalElement.localized) == null ? void 0 : _a.data) != null ? _b : globalElement == null ? void 0 : globalElement.data;
|
|
948
966
|
if (elementData == null)
|
|
949
967
|
continue;
|
|
950
968
|
element2 = elementData;
|
|
@@ -959,8 +977,8 @@ Received "${apiKey}" instead.`);
|
|
|
959
977
|
const typographies = await this.getTypographies([...typographyIds]);
|
|
960
978
|
typographies.forEach((typography) => {
|
|
961
979
|
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
962
|
-
var
|
|
963
|
-
const swatchId = (
|
|
980
|
+
var _a2;
|
|
981
|
+
const swatchId = (_a2 = style.value.color) == null ? void 0 : _a2.swatchId;
|
|
964
982
|
if (swatchId != null)
|
|
965
983
|
swatchIds.add(swatchId);
|
|
966
984
|
});
|
|
@@ -976,38 +994,38 @@ Received "${apiKey}" instead.`);
|
|
|
976
994
|
}));
|
|
977
995
|
return {
|
|
978
996
|
[APIResourceType.Swatch]: [...swatchIds].map((id) => {
|
|
979
|
-
var
|
|
997
|
+
var _a2;
|
|
980
998
|
return {
|
|
981
999
|
id,
|
|
982
|
-
value: (
|
|
1000
|
+
value: (_a2 = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a2 : null
|
|
983
1001
|
};
|
|
984
1002
|
}),
|
|
985
1003
|
[APIResourceType.File]: [...fileIds].map((id) => {
|
|
986
|
-
var
|
|
1004
|
+
var _a2;
|
|
987
1005
|
return {
|
|
988
1006
|
id,
|
|
989
|
-
value: (
|
|
1007
|
+
value: (_a2 = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a2 : null
|
|
990
1008
|
};
|
|
991
1009
|
}),
|
|
992
1010
|
[APIResourceType.Typography]: [...typographyIds].map((id) => {
|
|
993
|
-
var
|
|
1011
|
+
var _a2;
|
|
994
1012
|
return {
|
|
995
1013
|
id,
|
|
996
|
-
value: (
|
|
1014
|
+
value: (_a2 = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a2 : null
|
|
997
1015
|
};
|
|
998
1016
|
}),
|
|
999
1017
|
[APIResourceType.Table]: [...tableIds].map((id) => {
|
|
1000
|
-
var
|
|
1018
|
+
var _a2;
|
|
1001
1019
|
return {
|
|
1002
1020
|
id,
|
|
1003
|
-
value: (
|
|
1021
|
+
value: (_a2 = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a2 : null
|
|
1004
1022
|
};
|
|
1005
1023
|
}),
|
|
1006
1024
|
[APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
|
|
1007
|
-
var
|
|
1025
|
+
var _a2;
|
|
1008
1026
|
return {
|
|
1009
1027
|
id,
|
|
1010
|
-
value: (
|
|
1028
|
+
value: (_a2 = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a2 : null
|
|
1011
1029
|
};
|
|
1012
1030
|
}),
|
|
1013
1031
|
[APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
|
|
@@ -1016,10 +1034,16 @@ Received "${apiKey}" instead.`);
|
|
|
1016
1034
|
}))
|
|
1017
1035
|
};
|
|
1018
1036
|
}
|
|
1019
|
-
async getPageSnapshot(pathname, {
|
|
1037
|
+
async getPageSnapshot(pathname, {
|
|
1038
|
+
preview: previewOverride = false,
|
|
1039
|
+
unstable_locale
|
|
1040
|
+
} = {}) {
|
|
1020
1041
|
var _a;
|
|
1021
1042
|
const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
|
|
1022
|
-
const
|
|
1043
|
+
const searchParams = new URLSearchParams();
|
|
1044
|
+
if (unstable_locale)
|
|
1045
|
+
searchParams.set("locale", unstable_locale);
|
|
1046
|
+
const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document?${searchParams.toString()}`, {
|
|
1023
1047
|
headers: { "Makeswift-Site-Version": siteVersion }
|
|
1024
1048
|
});
|
|
1025
1049
|
if (!response.ok) {
|
|
@@ -1029,10 +1053,10 @@ Received "${apiKey}" instead.`);
|
|
|
1029
1053
|
throw new Error(`Failed to get page snapshot with error: "${response.statusText}"`);
|
|
1030
1054
|
}
|
|
1031
1055
|
const document2 = await response.json();
|
|
1032
|
-
const cacheData = await this.introspect(document2.data, previewOverride);
|
|
1056
|
+
const cacheData = await this.introspect(document2.data, previewOverride, unstable_locale);
|
|
1033
1057
|
const apiOrigin = this.apiOrigin.href;
|
|
1034
1058
|
const preview = siteVersion === MakeswiftSiteVersion.Working;
|
|
1035
|
-
return { document: document2, cacheData, apiOrigin, preview };
|
|
1059
|
+
return { document: document2, cacheData, apiOrigin, preview, locale: unstable_locale != null ? unstable_locale : null };
|
|
1036
1060
|
}
|
|
1037
1061
|
async getSwatch(swatchId) {
|
|
1038
1062
|
const response = await this.fetch(`v1/swatches/${swatchId}`);
|
|
@@ -1052,8 +1076,8 @@ Received "${apiKey}" instead.`);
|
|
|
1052
1076
|
const result = await this.graphqlClient.request(TypographyQuery, { typographyId });
|
|
1053
1077
|
return result.typography;
|
|
1054
1078
|
}
|
|
1055
|
-
async getGlobalElement(globalElementId) {
|
|
1056
|
-
const result = await this.graphqlClient.request(GlobalElementQuery, { globalElementId });
|
|
1079
|
+
async getGlobalElement(globalElementId, locale) {
|
|
1080
|
+
const result = await this.graphqlClient.request(GlobalElementQuery, { globalElementId, locale: locale != null ? locale : null });
|
|
1057
1081
|
return result.globalElement;
|
|
1058
1082
|
}
|
|
1059
1083
|
async getPagePathnameSlice(pageId) {
|
|
@@ -1120,7 +1144,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1120
1144
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1121
1145
|
return res.json(fonts2);
|
|
1122
1146
|
}
|
|
1123
|
-
const version = "0.9.
|
|
1147
|
+
const version = "0.9.6";
|
|
1124
1148
|
async function handler(req, res, { apiKey, unstable_siteVersions }) {
|
|
1125
1149
|
if (req.query.secret !== apiKey) {
|
|
1126
1150
|
return res.status(401).json({ message: "Unauthorized" });
|
|
@@ -1257,7 +1281,8 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
|
|
|
1257
1281
|
return client.getTypography(m.params.id).then(handleResource);
|
|
1258
1282
|
}
|
|
1259
1283
|
if (m = matches("/global-elements/:id")) {
|
|
1260
|
-
|
|
1284
|
+
const locale = typeof req.query.locale === "string" ? req.query.locale : void 0;
|
|
1285
|
+
return client.getGlobalElement(m.params.id, locale).then(handleResource);
|
|
1261
1286
|
}
|
|
1262
1287
|
if (m = matches("/page-pathname-slices/:id")) {
|
|
1263
1288
|
return client.getPagePathnameSlice(m.params.id).then(handleResource);
|
|
@@ -1389,11 +1414,16 @@ const Page = memo(({
|
|
|
1389
1414
|
}) => {
|
|
1390
1415
|
const client = useMemo(() => new MakeswiftClient({
|
|
1391
1416
|
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
1392
|
-
cacheData: snapshot.cacheData
|
|
1417
|
+
cacheData: snapshot.cacheData,
|
|
1418
|
+
locale: snapshot.locale == null ? void 0 : new Intl.Locale(snapshot.locale)
|
|
1393
1419
|
}), [snapshot]);
|
|
1420
|
+
const rootElements = /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]);
|
|
1421
|
+
snapshot.document.localizedPages.forEach((localizedPage) => {
|
|
1422
|
+
rootElements.set(localizedPage.elementTreeId, localizedPage.data);
|
|
1423
|
+
});
|
|
1394
1424
|
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
1395
1425
|
client,
|
|
1396
|
-
rootElements
|
|
1426
|
+
rootElements,
|
|
1397
1427
|
preview: snapshot.preview,
|
|
1398
1428
|
runtime,
|
|
1399
1429
|
children: /* @__PURE__ */ jsx(Page$1, {
|
|
@@ -3278,10 +3308,10 @@ function SlotPlaceholder({
|
|
|
3278
3308
|
function useStyleControlCssObject(styleControlData, controlDefinition) {
|
|
3279
3309
|
var _a;
|
|
3280
3310
|
const breakpoints = useBreakpoints();
|
|
3281
|
-
return __spreadValues(__spreadValues({}, controlDefinition.config.getStyle((_a = findBreakpointOverride(breakpoints, styleControlData, getBaseBreakpoint(breakpoints).id)) == null ? void 0 : _a.value)), breakpoints.reduce((styles, breakpoint) => {
|
|
3311
|
+
return __spreadValues(__spreadValues({}, controlDefinition.config.getStyle((_a = findBreakpointOverride(breakpoints, styleControlData, getBaseBreakpoint(breakpoints).id, mergeOrCoalesceFallbacks)) == null ? void 0 : _a.value)), breakpoints.reduce((styles, breakpoint) => {
|
|
3282
3312
|
var _a2;
|
|
3283
3313
|
return __spreadProps(__spreadValues({}, styles), {
|
|
3284
|
-
[getBreakpointMediaQuery(breakpoint)]: controlDefinition.config.getStyle((_a2 = findBreakpointOverride(breakpoints, styleControlData, breakpoint.id)) == null ? void 0 : _a2.value)
|
|
3314
|
+
[getBreakpointMediaQuery(breakpoint)]: controlDefinition.config.getStyle((_a2 = findBreakpointOverride(breakpoints, styleControlData, breakpoint.id, mergeOrCoalesceFallbacks)) == null ? void 0 : _a2.value)
|
|
3285
3315
|
});
|
|
3286
3316
|
}, {}));
|
|
3287
3317
|
}
|
|
@@ -3852,9 +3882,7 @@ class ReactRuntime {
|
|
|
3852
3882
|
__publicField(this, "store");
|
|
3853
3883
|
this.store = configureStore$1({
|
|
3854
3884
|
breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0,
|
|
3855
|
-
locales: unstable_i18n ?
|
|
3856
|
-
locale: null
|
|
3857
|
-
}) : void 0
|
|
3885
|
+
locales: unstable_i18n ? parseLocalesInput(unstable_i18n) : void 0
|
|
3858
3886
|
});
|
|
3859
3887
|
registerBuiltinComponents(this);
|
|
3860
3888
|
}
|
|
@@ -4015,8 +4043,9 @@ const DisableRegisterElement = createContext(false);
|
|
|
4015
4043
|
const ElementReference = memo(forwardRef(function ElementReference2({
|
|
4016
4044
|
elementReference
|
|
4017
4045
|
}, ref) {
|
|
4046
|
+
var _a, _b;
|
|
4018
4047
|
const globalElement = useGlobalElement(elementReference.value);
|
|
4019
|
-
const globalElementData = globalElement == null ? void 0 : globalElement.data;
|
|
4048
|
+
const globalElementData = (_b = (_a = globalElement == null ? void 0 : globalElement.localized) == null ? void 0 : _a.data) != null ? _b : globalElement == null ? void 0 : globalElement.data;
|
|
4020
4049
|
const elementReferenceDocument = useDocument(elementReference.key);
|
|
4021
4050
|
const documentKey = elementReference.key;
|
|
4022
4051
|
const documentKeys = useContext(DocumentCyclesContext);
|
|
@@ -4116,5 +4145,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4116
4145
|
document: document2
|
|
4117
4146
|
});
|
|
4118
4147
|
}));
|
|
4119
|
-
export {
|
|
4148
|
+
export { Makeswift as $, Alignments as A, forwardNextDynamicRef as B, Contrasts as C, DocumentReference as D, Element$1 as E, useIsPreview as F, useFiles as G, useSwatches as H, usePagePathnameSlice as I, useElementId as J, deepEqual as K, shallowEqual as L, ElementImperativeHandle as M, StoreContext as N, MakeswiftProvider as O, PageProvider as P, ControlValue as Q, RuntimeProvider as R, Shapes as S, useBuilderEditMode as T, pollBoxModel as U, useEnhancedTypography as V, useTypographyClassName 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, 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, Page$1 as m, useResponsiveStyle as n, useResponsiveWidth as o, useResponsiveTextStyle as p, colorToString as q, useBreakpoints as r, Sizes as s, useFormContext as t, useIsInBuilder as u, useResponsiveGridItem as v, useTable as w, useMakeswiftClient as x, Provider as y, useFile as z };
|
|
4120
4149
|
//# sourceMappingURL=index.es.js.map
|