@makeswift/runtime 0.9.8 → 0.9.10
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/PreviewProvider.es.js +2 -2
- package/dist/ReadOnlyText.es.js +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +3 -1
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +4 -2
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/api.cjs.js +19 -0
- package/dist/api.cjs.js.map +1 -1
- package/dist/api.es.js +19 -0
- package/dist/api.es.js.map +1 -1
- package/dist/controls.cjs.js +2 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -1
- package/dist/index.cjs.js +119 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +6 -2
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs5.js +30 -75
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs9.js +4 -1
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +120 -29
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +8 -4
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es5.js +31 -73
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -1
- package/dist/index.es9.js +5 -2
- package/dist/index.es9.js.map +1 -1
- package/dist/react-page.cjs.js +38 -21
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +37 -22
- package/dist/react-page.es.js.map +1 -1
- package/dist/slate.cjs.js +69 -6
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +69 -7
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/fragments.d.ts +1 -0
- package/dist/types/src/api/graphql/documents/fragments.d.ts.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts +1 -0
- 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 +1 -0
- 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 +17 -0
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/api/graphql/types.d.ts +3 -3
- package/dist/types/src/api/graphql/types.d.ts.map +1 -1
- package/dist/types/src/api/react.d.ts +13 -2
- package/dist/types/src/api/react.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +1 -1
- 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.map +1 -1
- package/dist/types/src/components/page/Page.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/fixtures/empty-blocks.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/fixtures/v2-data-types.d.ts +3 -0
- package/dist/types/src/controls/rich-text/fixtures/v2-data-types.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/index.d.ts +1 -0
- package/dist/types/src/controls/rich-text-v2/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +15 -11
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts +5 -0
- package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -0
- package/dist/types/src/controls/typography.d.ts +2 -2
- 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 +7 -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/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/typography.d.ts +5 -5
- package/dist/types/src/runtimes/react/controls/typography.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/hooks/makeswift-api.d.ts +2 -1
- package/dist/types/src/runtimes/react/hooks/makeswift-api.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/getValue.d.ts +1 -1
- package/dist/types/src/slate/TypographyPlugin/getValue.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.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/api-resources.d.ts.map +1 -1
- package/dist/types.cjs.js +1 -0
- package/dist/types.cjs.js.map +1 -1
- package/dist/types.cjs2.js +1 -5
- package/dist/types.cjs2.js.map +1 -1
- package/dist/types.es.js +1 -0
- package/dist/types.es.js.map +1 -1
- package/dist/types.es2.js +2 -6
- 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/index.es.js
CHANGED
|
@@ -157,7 +157,8 @@ function getInitialState(serializedState = {
|
|
|
157
157
|
Table: [],
|
|
158
158
|
Snippet: [],
|
|
159
159
|
Page: [],
|
|
160
|
-
Site: []
|
|
160
|
+
Site: [],
|
|
161
|
+
LocalizedGlobalElement: []
|
|
161
162
|
}) {
|
|
162
163
|
return new Map(Object.entries(serializedState).map(([apiResourceType, resources]) => [
|
|
163
164
|
apiResourceType,
|
|
@@ -218,7 +219,7 @@ async function fetchJson(url) {
|
|
|
218
219
|
}
|
|
219
220
|
return response.json();
|
|
220
221
|
}
|
|
221
|
-
function fetchAPIResource(resourceType, resourceId) {
|
|
222
|
+
function fetchAPIResource(resourceType, resourceId, locale) {
|
|
222
223
|
return async (dispatch, getState) => {
|
|
223
224
|
const state = getState();
|
|
224
225
|
if (getHasAPIResource(state, resourceType, resourceId)) {
|
|
@@ -238,6 +239,12 @@ function fetchAPIResource(resourceType, resourceId) {
|
|
|
238
239
|
case APIResourceType.GlobalElement:
|
|
239
240
|
resource = await fetchJson(`/api/makeswift/global-elements/${resourceId}`);
|
|
240
241
|
break;
|
|
242
|
+
case APIResourceType.LocalizedGlobalElement: {
|
|
243
|
+
if (locale == null)
|
|
244
|
+
throw new Error("Locale is required to fetch LocalizedGlobalElement");
|
|
245
|
+
resource = await fetchJson(`/api/makeswift/localized-global-elements/${resourceId}/${locale}`);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
241
248
|
case APIResourceType.PagePathnameSlice:
|
|
242
249
|
resource = await fetchJson(`/api/makeswift/page-pathname-slices/${resourceId}`);
|
|
243
250
|
break;
|
|
@@ -332,6 +339,13 @@ const GlobalElementFragment = `
|
|
|
332
339
|
data
|
|
333
340
|
}
|
|
334
341
|
`;
|
|
342
|
+
const LocalizedGlobalElementFragment = `
|
|
343
|
+
fragment LocalizedGlobalElement on LocalizedGlobalElement {
|
|
344
|
+
__typename
|
|
345
|
+
id
|
|
346
|
+
data
|
|
347
|
+
}
|
|
348
|
+
`;
|
|
335
349
|
const TableFragment = `
|
|
336
350
|
fragment Table on Table {
|
|
337
351
|
__typename
|
|
@@ -431,6 +445,15 @@ const GlobalElementQuery = `
|
|
|
431
445
|
|
|
432
446
|
${GlobalElementFragment}
|
|
433
447
|
`;
|
|
448
|
+
const LocalizedGlobalElementQuery = `
|
|
449
|
+
query LocalizedGlobalElement($globalElementId: ID!, $locale: Locale!) {
|
|
450
|
+
localizedGlobalElement(globalElementId: $globalElementId, locale: $locale) {
|
|
451
|
+
...LocalizedGlobalElement
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
${LocalizedGlobalElementFragment}
|
|
456
|
+
`;
|
|
434
457
|
const CreateTableRecordMutation = `
|
|
435
458
|
mutation CreateTableRecord($input: CreateTableRecordInput!) {
|
|
436
459
|
createTableRecord(input: $input) {
|
|
@@ -443,16 +466,22 @@ const CreateTableRecordMutation = `
|
|
|
443
466
|
class MakeswiftClient {
|
|
444
467
|
constructor({
|
|
445
468
|
uri,
|
|
446
|
-
cacheData
|
|
469
|
+
cacheData,
|
|
470
|
+
localizedResourcesMap = {},
|
|
471
|
+
locale
|
|
447
472
|
}) {
|
|
448
473
|
__publicField(this, "graphqlClient");
|
|
449
474
|
__publicField(this, "makeswiftApiClient");
|
|
450
475
|
__publicField(this, "subscribe");
|
|
476
|
+
__publicField(this, "localizedResourcesMap");
|
|
477
|
+
__publicField(this, "locale");
|
|
451
478
|
this.graphqlClient = new GraphQLClient(uri);
|
|
452
479
|
this.makeswiftApiClient = configureStore({
|
|
453
480
|
serializedState: cacheData
|
|
454
481
|
});
|
|
455
482
|
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
483
|
+
this.localizedResourcesMap = new Map(Object.entries(localizedResourcesMap));
|
|
484
|
+
this.locale = locale;
|
|
456
485
|
}
|
|
457
486
|
readSwatch(swatchId) {
|
|
458
487
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Swatch, swatchId);
|
|
@@ -478,6 +507,21 @@ class MakeswiftClient {
|
|
|
478
507
|
async fetchGlobalElement(globalElementId) {
|
|
479
508
|
return await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.GlobalElement, globalElementId));
|
|
480
509
|
}
|
|
510
|
+
readLocalizedGlobalElement(globalElementId) {
|
|
511
|
+
const localizedGlobalElementId = this.getLocalizedResourceId(globalElementId);
|
|
512
|
+
if (localizedGlobalElementId == null)
|
|
513
|
+
return null;
|
|
514
|
+
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.LocalizedGlobalElement, localizedGlobalElementId);
|
|
515
|
+
}
|
|
516
|
+
async fetchLocalizedGlobalElement(globalElementId) {
|
|
517
|
+
const locale = this.locale;
|
|
518
|
+
if (locale == null)
|
|
519
|
+
return null;
|
|
520
|
+
const result = await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, locale));
|
|
521
|
+
if (result != null)
|
|
522
|
+
this.setLocalizedResourceId(globalElementId, result.id);
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
481
525
|
readPagePathnameSlice(pageId) {
|
|
482
526
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.PagePathnameSlice, pageId);
|
|
483
527
|
}
|
|
@@ -509,6 +553,13 @@ class MakeswiftClient {
|
|
|
509
553
|
readSnippet(snippetId) {
|
|
510
554
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Snippet, snippetId);
|
|
511
555
|
}
|
|
556
|
+
getLocalizedResourceId(resourceId) {
|
|
557
|
+
var _a, _b;
|
|
558
|
+
return (_b = (_a = this.localizedResourcesMap) == null ? void 0 : _a.get(resourceId)) != null ? _b : null;
|
|
559
|
+
}
|
|
560
|
+
setLocalizedResourceId(resourceId, localizedResourceId) {
|
|
561
|
+
this.localizedResourcesMap.set(resourceId, localizedResourceId);
|
|
562
|
+
}
|
|
512
563
|
}
|
|
513
564
|
const Context$1 = createContext(new MakeswiftClient({
|
|
514
565
|
uri: "https://api.makeswift.com/graphql"
|
|
@@ -563,7 +614,7 @@ const filterUsedSnippetProperties = ({
|
|
|
563
614
|
function Page$1({
|
|
564
615
|
document: page
|
|
565
616
|
}) {
|
|
566
|
-
var _a, _b;
|
|
617
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
567
618
|
const isInBuilder = useIsInBuilder();
|
|
568
619
|
const [snippets, setSnippets] = useState(page.snippets);
|
|
569
620
|
const cachedPage = useCachedPage(isInBuilder ? page.id : null);
|
|
@@ -577,17 +628,16 @@ function Page$1({
|
|
|
577
628
|
setSnippets(cachedPage.snippets);
|
|
578
629
|
}, [cachedPage]);
|
|
579
630
|
const site = useCachedSite(isInBuilder ? page.site.id : null);
|
|
631
|
+
const baseLocalizedPage = page.localizedPages.find(({
|
|
632
|
+
parentId
|
|
633
|
+
}) => parentId == null);
|
|
580
634
|
const favicon = (_a = page.meta.favicon) != null ? _a : defaultFavicon;
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const {
|
|
588
|
-
canonicalUrl,
|
|
589
|
-
isIndexingBlocked
|
|
590
|
-
} = page.seo;
|
|
635
|
+
const title = (_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.meta.title) != null ? _b : page.meta.title;
|
|
636
|
+
const description = (_c = baseLocalizedPage == null ? void 0 : baseLocalizedPage.meta.description) != null ? _c : page.meta.description;
|
|
637
|
+
const keywords = (_d = baseLocalizedPage == null ? void 0 : baseLocalizedPage.meta.keywords) != null ? _d : page.meta.keywords;
|
|
638
|
+
const socialImage = (_e = baseLocalizedPage == null ? void 0 : baseLocalizedPage.meta.socialImage) != null ? _e : page.meta.socialImage;
|
|
639
|
+
const canonicalUrl = (_f = baseLocalizedPage == null ? void 0 : baseLocalizedPage.seo.canonicalUrl) != null ? _f : page.seo.canonicalUrl;
|
|
640
|
+
const isIndexingBlocked = (_g = baseLocalizedPage == null ? void 0 : baseLocalizedPage.seo.isIndexingBlocked) != null ? _g : page.seo.isIndexingBlocked;
|
|
591
641
|
const fontFamilyParamValue = useMemo(() => {
|
|
592
642
|
if (site == null) {
|
|
593
643
|
return page.fonts.map(({
|
|
@@ -625,10 +675,7 @@ function Page$1({
|
|
|
625
675
|
});
|
|
626
676
|
previousHeadSnippets.current = headSnippets;
|
|
627
677
|
}, [headSnippets]);
|
|
628
|
-
const
|
|
629
|
-
parentId
|
|
630
|
-
}) => parentId == null);
|
|
631
|
-
const documentId = (_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.elementTreeId) != null ? _b : page.id;
|
|
678
|
+
const documentId = (_h = baseLocalizedPage == null ? void 0 : baseLocalizedPage.elementTreeId) != null ? _h : page.id;
|
|
632
679
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
633
680
|
children: [/* @__PURE__ */ jsxs(Head, {
|
|
634
681
|
children: [/* @__PURE__ */ jsx("style", {
|
|
@@ -912,7 +959,7 @@ Received "${apiKey}" instead.`);
|
|
|
912
959
|
const swatches = await this.getSwatches(swatchIds, preview);
|
|
913
960
|
return __spreadProps(__spreadValues({}, result), { swatches });
|
|
914
961
|
}
|
|
915
|
-
async introspect(element, preview) {
|
|
962
|
+
async introspect(element, preview, locale) {
|
|
916
963
|
const runtime = this.runtime;
|
|
917
964
|
const descriptors = getPropControllerDescriptors(runtime.store.getState());
|
|
918
965
|
const swatchIds = /* @__PURE__ */ new Set();
|
|
@@ -921,6 +968,8 @@ Received "${apiKey}" instead.`);
|
|
|
921
968
|
const tableIds = /* @__PURE__ */ new Set();
|
|
922
969
|
const pageIds = /* @__PURE__ */ new Set();
|
|
923
970
|
const globalElements = /* @__PURE__ */ new Map();
|
|
971
|
+
const localizedGlobalElements = /* @__PURE__ */ new Map();
|
|
972
|
+
const localizedResourcesMap = /* @__PURE__ */ new Map();
|
|
924
973
|
const remaining = [element];
|
|
925
974
|
const seen = /* @__PURE__ */ new Set();
|
|
926
975
|
let current;
|
|
@@ -944,9 +993,18 @@ Received "${apiKey}" instead.`);
|
|
|
944
993
|
};
|
|
945
994
|
let element2;
|
|
946
995
|
if (isElementReference(current)) {
|
|
947
|
-
const
|
|
948
|
-
|
|
949
|
-
|
|
996
|
+
const globalElementId = current.value;
|
|
997
|
+
const globalElement = await this.getGlobalElement(globalElementId);
|
|
998
|
+
let elementData = globalElement == null ? void 0 : globalElement.data;
|
|
999
|
+
if (locale) {
|
|
1000
|
+
const localizedGlobalElement = await this.getLocalizedGlobalElement(globalElementId, locale);
|
|
1001
|
+
if (localizedGlobalElement) {
|
|
1002
|
+
elementData = localizedGlobalElement.data;
|
|
1003
|
+
localizedResourcesMap.set(globalElementId, localizedGlobalElement.id);
|
|
1004
|
+
localizedGlobalElements.set(localizedGlobalElement.id, localizedGlobalElement);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
globalElements.set(globalElementId, globalElement);
|
|
950
1008
|
if (elementData == null)
|
|
951
1009
|
continue;
|
|
952
1010
|
element2 = elementData;
|
|
@@ -976,7 +1034,7 @@ Received "${apiKey}" instead.`);
|
|
|
976
1034
|
const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
|
|
977
1035
|
id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
|
|
978
1036
|
}));
|
|
979
|
-
|
|
1037
|
+
const cacheData = {
|
|
980
1038
|
[APIResourceType.Swatch]: [...swatchIds].map((id) => {
|
|
981
1039
|
var _a;
|
|
982
1040
|
return {
|
|
@@ -1015,8 +1073,13 @@ Received "${apiKey}" instead.`);
|
|
|
1015
1073
|
[APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
|
|
1016
1074
|
id,
|
|
1017
1075
|
value
|
|
1076
|
+
})),
|
|
1077
|
+
[APIResourceType.LocalizedGlobalElement]: [...localizedGlobalElements.entries()].map(([id, value]) => ({
|
|
1078
|
+
id,
|
|
1079
|
+
value
|
|
1018
1080
|
}))
|
|
1019
1081
|
};
|
|
1082
|
+
return { cacheData, localizedResourcesMap: Object.fromEntries(localizedResourcesMap.entries()) };
|
|
1020
1083
|
}
|
|
1021
1084
|
async getPageSnapshot(pathname, {
|
|
1022
1085
|
preview: previewOverride = false,
|
|
@@ -1037,10 +1100,17 @@ Received "${apiKey}" instead.`);
|
|
|
1037
1100
|
throw new Error(`Failed to get page snapshot with error: "${response.statusText}"`);
|
|
1038
1101
|
}
|
|
1039
1102
|
const document2 = await response.json();
|
|
1040
|
-
const cacheData = await this.introspect(document2.data, previewOverride);
|
|
1103
|
+
const { cacheData, localizedResourcesMap } = await this.introspect(document2.data, previewOverride, unstable_locale);
|
|
1041
1104
|
const apiOrigin = this.apiOrigin.href;
|
|
1042
1105
|
const preview = siteVersion === MakeswiftSiteVersion.Working;
|
|
1043
|
-
return {
|
|
1106
|
+
return {
|
|
1107
|
+
document: document2,
|
|
1108
|
+
cacheData,
|
|
1109
|
+
apiOrigin,
|
|
1110
|
+
preview,
|
|
1111
|
+
localizedResourcesMap,
|
|
1112
|
+
locale: unstable_locale != null ? unstable_locale : null
|
|
1113
|
+
};
|
|
1044
1114
|
}
|
|
1045
1115
|
async getSwatch(swatchId) {
|
|
1046
1116
|
const response = await this.fetch(`v1/swatches/${swatchId}`);
|
|
@@ -1064,6 +1134,10 @@ Received "${apiKey}" instead.`);
|
|
|
1064
1134
|
const result = await this.graphqlClient.request(GlobalElementQuery, { globalElementId });
|
|
1065
1135
|
return result.globalElement;
|
|
1066
1136
|
}
|
|
1137
|
+
async getLocalizedGlobalElement(globalElementId, locale) {
|
|
1138
|
+
const result = await this.graphqlClient.request(LocalizedGlobalElementQuery, { globalElementId, locale });
|
|
1139
|
+
return result.localizedGlobalElement;
|
|
1140
|
+
}
|
|
1067
1141
|
async getPagePathnameSlice(pageId) {
|
|
1068
1142
|
var _a;
|
|
1069
1143
|
const result = await this.graphqlClient.request(PagePathnamesByIdQuery, { pageIds: [pageId] });
|
|
@@ -1128,7 +1202,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1128
1202
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1129
1203
|
return res.json(fonts2);
|
|
1130
1204
|
}
|
|
1131
|
-
const version = "0.9.
|
|
1205
|
+
const version = "0.9.10";
|
|
1132
1206
|
async function handler(req, res, { apiKey, unstable_siteVersions }) {
|
|
1133
1207
|
if (req.query.secret !== apiKey) {
|
|
1134
1208
|
return res.status(401).json({ message: "Unauthorized" });
|
|
@@ -1267,6 +1341,9 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
|
|
|
1267
1341
|
if (m = matches("/global-elements/:id")) {
|
|
1268
1342
|
return client.getGlobalElement(m.params.id).then(handleResource);
|
|
1269
1343
|
}
|
|
1344
|
+
if (m = matches("/localized-global-elements/:globalElementId/:locale")) {
|
|
1345
|
+
return client.getLocalizedGlobalElement(m.params.globalElementId, m.params.locale).then(handleResource);
|
|
1346
|
+
}
|
|
1270
1347
|
if (m = matches("/page-pathname-slices/:id")) {
|
|
1271
1348
|
return client.getPagePathnameSlice(m.params.id).then(handleResource);
|
|
1272
1349
|
}
|
|
@@ -1397,7 +1474,8 @@ const Page = memo(({
|
|
|
1397
1474
|
}) => {
|
|
1398
1475
|
const client = useMemo(() => new MakeswiftClient({
|
|
1399
1476
|
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
1400
|
-
cacheData: snapshot.cacheData
|
|
1477
|
+
cacheData: snapshot.cacheData,
|
|
1478
|
+
localizedResourcesMap: snapshot.localizedResourcesMap
|
|
1401
1479
|
}), [snapshot]);
|
|
1402
1480
|
const rootElements = /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]);
|
|
1403
1481
|
snapshot.document.localizedPages.forEach((localizedPage) => {
|
|
@@ -2527,6 +2605,17 @@ function useGlobalElement(globalElementId) {
|
|
|
2527
2605
|
}, [client, globalElementId]);
|
|
2528
2606
|
return globalElement;
|
|
2529
2607
|
}
|
|
2608
|
+
function useLocalizedGlobalElement(globalElementId) {
|
|
2609
|
+
const client = useMakeswiftClient();
|
|
2610
|
+
const readLocalizedGlobalElement = () => globalElementId == null ? null : client.readLocalizedGlobalElement(globalElementId);
|
|
2611
|
+
const localizedGlobalElement = useSyncExternalStore(client.subscribe, readLocalizedGlobalElement, readLocalizedGlobalElement);
|
|
2612
|
+
useEffect(() => {
|
|
2613
|
+
if (globalElementId != null) {
|
|
2614
|
+
client.fetchLocalizedGlobalElement(globalElementId).catch(console.error);
|
|
2615
|
+
}
|
|
2616
|
+
}, [client, globalElementId]);
|
|
2617
|
+
return localizedGlobalElement;
|
|
2618
|
+
}
|
|
2530
2619
|
function usePagePathnameSlice(pageId) {
|
|
2531
2620
|
const client = useMakeswiftClient();
|
|
2532
2621
|
const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice(pageId);
|
|
@@ -4031,8 +4120,10 @@ const DisableRegisterElement = createContext(false);
|
|
|
4031
4120
|
const ElementReference = memo(forwardRef(function ElementReference2({
|
|
4032
4121
|
elementReference
|
|
4033
4122
|
}, ref) {
|
|
4123
|
+
var _a;
|
|
4034
4124
|
const globalElement = useGlobalElement(elementReference.value);
|
|
4035
|
-
const
|
|
4125
|
+
const localizedGlobalElement = useLocalizedGlobalElement(elementReference.value);
|
|
4126
|
+
const globalElementData = (_a = localizedGlobalElement == null ? void 0 : localizedGlobalElement.data) != null ? _a : globalElement == null ? void 0 : globalElement.data;
|
|
4036
4127
|
const elementReferenceDocument = useDocument(elementReference.key);
|
|
4037
4128
|
const documentKey = elementReference.key;
|
|
4038
4129
|
const documentKeys = useContext(DocumentCyclesContext);
|
|
@@ -4132,5 +4223,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4132
4223
|
document: document2
|
|
4133
4224
|
});
|
|
4134
4225
|
}));
|
|
4135
|
-
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,
|
|
4226
|
+
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, shallowEqual as K, deepEqual 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 };
|
|
4136
4227
|
//# sourceMappingURL=index.es.js.map
|