@makeswift/runtime 0.12.3 → 0.13.0
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/LiveProvider.es.js +1 -1
- package/dist/PreviewProvider.es.js +1 -1
- package/dist/ReadOnlyText.es.js +1 -1
- package/dist/ReadOnlyTextV2.es.js +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +8 -1
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -2
- package/dist/index.cjs.js +69 -99
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +71 -101
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es5.js +1 -1
- package/dist/index.es6.js +1 -1
- package/dist/index.es8.js +1 -1
- package/dist/index.es9.js +1 -1
- package/dist/number.cjs.js +11 -2
- package/dist/number.cjs.js.map +1 -1
- package/dist/number.es.js +8 -3
- package/dist/number.es.js.map +1 -1
- package/dist/react-page.cjs.js +11 -3
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +8 -4
- package/dist/react-page.es.js.map +1 -1
- package/dist/slate.es.js +1 -1
- package/dist/toText.es.js +1 -1
- package/dist/types/src/controls/checkbox.d.ts +9 -1
- package/dist/types/src/controls/checkbox.d.ts.map +1 -1
- package/dist/types/src/controls/color.d.ts +1 -2
- package/dist/types/src/controls/color.d.ts.map +1 -1
- package/dist/types/src/controls/control-data-type-key.d.ts +2 -0
- package/dist/types/src/controls/control-data-type-key.d.ts.map +1 -0
- package/dist/types/src/controls/number.d.ts +9 -1
- package/dist/types/src/controls/number.d.ts.map +1 -1
- package/dist/types/src/controls/text-area.d.ts +9 -1
- package/dist/types/src/controls/text-area.d.ts.map +1 -1
- package/dist/types/src/controls/text-input.d.ts +10 -1
- package/dist/types/src/controls/text-input.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +1 -2
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts +1 -2
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +14 -16
- 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/checkbox.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/number.d.ts +2 -2
- package/dist/types/src/runtimes/react/controls/number.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/text-area.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/text-input.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/LiveProvider.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { a as ReactRuntime, K as StoreContext, M as MakeswiftProvider } from "./index.es.js";
|
|
3
|
-
import {
|
|
3
|
+
import { az as configureStore } from "./react-page.es.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import "use-sync-external-store/shim/with-selector";
|
|
6
6
|
import "next/dynamic";
|
|
@@ -23,7 +23,7 @@ import { J as ElementImperativeHandle, a as ReactRuntime, K as StoreContext, M a
|
|
|
23
23
|
import { createStore, applyMiddleware, combineReducers } from "redux";
|
|
24
24
|
import thunk from "redux-thunk";
|
|
25
25
|
import Router from "next/router";
|
|
26
|
-
import {
|
|
26
|
+
import { ce as getInitialState$3, cf as reducer$4, cg as getDocument$1, c as createDocument, ch as getComponentsMeta$1, ci as getComponentPropControllerDescriptors$1, aB as getBreakpoints, f as deepEqual, aI as getBuilderEditMode, cj as BuilderEditMode, ck as getDocumentKeysSortedByDepth, cl as getPropController, cm as getPropControllersHandle, cn as getElement, co as getElementPropControllerDescriptors, cp as createPropController, j as isElementReference, a4 as isPropControllersHandle, cq as reducer$5, cr as reducer$7, cs as reducer$8, ct as reducer$9, cu as reducer$a, cv as reducer$b, cw as reducer$c, cx as getInitialState$4 } from "./react-page.es.js";
|
|
27
27
|
import { removeIn, setIn } from "immutable";
|
|
28
28
|
import { A as ActionTypes, v as unregisterMeasurable, w as registerMeasurable, x as registerBuilderComponent, j as setBreakpoints, k as setLocale, y as changePathnameStart, z as changePathnameComplete, B as changeElementBoxModels, C as changeDocumentElementSize, D as handleWheel, E as handlePointerMove, F as elementFromPointChange, G as setIsInBuilder, H as unregisterBuilderComponent, I as unregisterPropControllers, J as registerPropControllers, K as registerPropControllersHandle, r as registerDocument, L as registerComponentHandle, M as messageBuilderPropController, N as registerDocumentEffect } from "./actions.es.js";
|
|
29
29
|
import { i as isMeasurable, a as getMeasurables$1, b as getBoxModels$1, m as measure, d as getBoxModel$1, r as reducer$6 } from "./box-models.es.js";
|
package/dist/ReadOnlyText.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { cx } from "@emotion/css";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { L as useEnhancedTypography, N as useTypographyClassName, n as useResponsiveStyle } from "./index.es.js";
|
|
4
4
|
import "ts-pattern";
|
|
5
|
-
import {
|
|
5
|
+
import { bH as richTextDTOtoDAO, _ as useStyle, c5 as BlockType, c6 as InlineType } from "./react-page.es.js";
|
|
6
6
|
import "./actions.es.js";
|
|
7
7
|
import "slate";
|
|
8
8
|
import "uuid";
|
|
@@ -15,7 +15,7 @@ var __objRest = (source, exclude) => {
|
|
|
15
15
|
};
|
|
16
16
|
import { forwardRef } from "react";
|
|
17
17
|
import "ts-pattern";
|
|
18
|
-
import {
|
|
18
|
+
import { bK as RichTextV2Mode, c1 as InlineModePlugin, b$ as BlockPlugin, bW as TypographyPlugin, c3 as TextAlignPlugin, c9 as InlinePlugin, _ as useStyle } from "./react-page.es.js";
|
|
19
19
|
import "./actions.es.js";
|
|
20
20
|
import "slate";
|
|
21
21
|
import "uuid";
|
|
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
const import_meta = {};
|
|
33
33
|
import "ts-pattern";
|
|
34
34
|
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
35
|
-
import {
|
|
35
|
+
import { ah as ListControlType, ai as ShapeControlType, ag as StyleV2ControlType, ad as RichTextV2ControlType, as as Types } from "./react-page.es.js";
|
|
36
36
|
import "./actions.es.js";
|
|
37
37
|
import "uuid";
|
|
38
38
|
import "slate";
|
package/dist/controls.cjs.js
CHANGED
|
@@ -22,14 +22,17 @@ require("@emotion/css");
|
|
|
22
22
|
require("@emotion/serialize");
|
|
23
23
|
require("@emotion/utils");
|
|
24
24
|
exports.Checkbox = number.Checkbox;
|
|
25
|
+
exports.CheckboxControlDataTypeKey = number.CheckboxControlDataTypeKey;
|
|
26
|
+
exports.CheckboxControlDataTypeValueV1 = number.CheckboxControlDataTypeValueV1;
|
|
25
27
|
exports.CheckboxControlType = number.CheckboxControlType;
|
|
26
28
|
exports.Number = number.Number;
|
|
29
|
+
exports.NumberControlDataTypeKey = number.NumberControlDataTypeKey;
|
|
30
|
+
exports.NumberControlDataTypeValueV1 = number.NumberControlDataTypeValueV1;
|
|
27
31
|
exports.NumberControlType = number.NumberControlType;
|
|
28
32
|
exports.Color = reactPage.Color;
|
|
29
33
|
exports.ColorControlDataTypeKey = reactPage.ColorControlDataTypeKey;
|
|
30
34
|
exports.ColorControlDataTypeValueV1 = reactPage.ColorControlDataTypeValueV1;
|
|
31
35
|
exports.ColorControlType = reactPage.ColorControlType;
|
|
32
|
-
exports.ControlDataTypeKey = reactPage.ControlDataTypeKey;
|
|
33
36
|
exports.IconRadioGroupControlType = reactPage.IconRadioGroupControlType;
|
|
34
37
|
exports.Image = reactPage.Image$1;
|
|
35
38
|
exports.ImageControlType = reactPage.ImageControlType;
|
|
@@ -68,8 +71,12 @@ exports.StyleV2Control = reactPage.StyleV2Control;
|
|
|
68
71
|
exports.StyleV2ControlMessageType = reactPage.StyleV2ControlMessageType;
|
|
69
72
|
exports.StyleV2ControlType = reactPage.StyleV2ControlType;
|
|
70
73
|
exports.TextArea = reactPage.TextArea$1;
|
|
74
|
+
exports.TextAreaControlDataTypeKey = reactPage.TextAreaControlDataTypeKey;
|
|
75
|
+
exports.TextAreaControlDataTypeValueV1 = reactPage.TextAreaControlDataTypeValueV1;
|
|
71
76
|
exports.TextAreaControlType = reactPage.TextAreaControlType;
|
|
72
77
|
exports.TextInput = reactPage.TextInput$1;
|
|
78
|
+
exports.TextInputControlDataTypeKey = reactPage.TextInputControlDataTypeKey;
|
|
79
|
+
exports.TextInputControlDataTypeValueV1 = reactPage.TextInputControlDataTypeValueV1;
|
|
73
80
|
exports.TextInputControlType = reactPage.TextInputControlType;
|
|
74
81
|
exports.TypographyControlType = reactPage.TypographyControlType;
|
|
75
82
|
exports.copy = reactPage.copy$3;
|
package/dist/controls.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controls.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/controls.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { e as Checkbox, C as CheckboxControlDataTypeKey, a as CheckboxControlDataTypeValueV1, d as CheckboxControlType, f as Number, N as NumberControlDataTypeKey, b as NumberControlDataTypeValueV1, c as NumberControlType } from "./number.es.js";
|
|
2
|
+
export { aP as Color, aN as ColorControlDataTypeKey, aO as ColorControlDataTypeValueV1, am as ColorControlType, al as IconRadioGroupControlType, aX as Image, ak as ImageControlType, a3 as ImageControlValueFormat, aZ as Link, aj as LinkControlType, a$ as List, b1 as ListControl, b0 as ListControlMessageType, ah as ListControlType, bD as ObjectType, Y as RichText, bF as RichTextControl, bE as RichTextControlMessageType, ae as RichTextControlType, bM as RichTextV2Control, bL as RichTextV2ControlMessageType, ad as RichTextV2ControlType, bK as RichTextV2Mode, ba as Select, an as SelectControlType, bb as Shape, bd as ShapeControl, bc as ShapeControlMessageType, ai as ShapeControlType, bm as Slot, bo as SlotControl, bn as SlotControlMessageType, af as SlotControlType, bs as Style, bu as StyleControl, bt as StyleControlMessageType, a2 as StyleControlProperty, ac as StyleControlType, bz as StyleV2Control, by as StyleV2ControlMessageType, ag as StyleV2ControlType, bA as TextArea, a6 as TextAreaControlDataTypeKey, a7 as TextAreaControlDataTypeValueV1, ao as TextAreaControlType, bB as TextInput, a8 as TextInputControlDataTypeKey, a9 as TextInputControlDataTypeValueV1, ap as TextInputControlType, ab as TypographyControlType, aR as copy, aQ as copyColorData, aY as copyImageData, a_ as copyLinkData, b2 as copyListData, bC as copyRichTextData, be as copyShapeData, bp as copySlotData, bv as copyStyleData, bP as createRichTextV2Plugin, b3 as getListElementChildren, b5 as getListFileIds, b7 as getListPageIds, b4 as getListSwatchIds, b8 as getListTranslatableData, b6 as getListTypographyIds, bf as getShapeElementChildren, bj as getShapeFileIds, bi as getShapePageIds, bg as getShapeSwatchIds, bk as getShapeTranslatableData, bh as getShapeTypographyIds, aT as getTranslatableData, bR as getTypographySwatchIds, bS as getTypographyTypographyIds, a5 as isRichTextV1Data, aS as merge, b9 as mergeListTranslatedData, bl as mergeShapeTranslatedData, br as mergeSlotControlTranslatedData, bq as mergeSlotData, aU as mergeTranslatedData, bJ as richTextDAOToDTO, bH as richTextDTOtoDAO, bG as richTextDTOtoSelection, bN as richTextV2DataToDescendents, bO as richTextV2DescendentsToData, bI as toSelectionDTO, aW as unstable_IconRadioGroup, aV as unstable_IconRadioGroupIcon, bx as unstable_StyleV2, bQ as unstable_Typography, bw as unstable_useStyleV2ClassName } from "./react-page.es.js";
|
|
3
3
|
export { a as Combobox, C as ComboboxControlType } from "./combobox.es.js";
|
|
4
4
|
import "redux";
|
|
5
5
|
import "redux-thunk";
|
package/dist/index.cjs.js
CHANGED
|
@@ -810,16 +810,11 @@ const getPageAPISchema = zod.z.object({
|
|
|
810
810
|
}))
|
|
811
811
|
});
|
|
812
812
|
class Makeswift {
|
|
813
|
-
constructor(apiKey, {
|
|
814
|
-
apiOrigin = "https://api.makeswift.com",
|
|
815
|
-
runtime = ReactRuntime,
|
|
816
|
-
siteVersion
|
|
817
|
-
} = {}) {
|
|
813
|
+
constructor(apiKey, { apiOrigin = "https://api.makeswift.com", runtime = ReactRuntime } = {}) {
|
|
818
814
|
__publicField(this, "apiKey");
|
|
819
815
|
__publicField(this, "apiOrigin");
|
|
820
816
|
__publicField(this, "graphqlClient");
|
|
821
817
|
__publicField(this, "runtime");
|
|
822
|
-
__publicField(this, "siteVersion");
|
|
823
818
|
if (typeof apiKey !== "string") {
|
|
824
819
|
throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
|
|
825
820
|
Received "${apiKey}" instead.`);
|
|
@@ -832,29 +827,25 @@ Received "${apiKey}" instead.`);
|
|
|
832
827
|
}
|
|
833
828
|
this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
|
|
834
829
|
this.runtime = runtime;
|
|
835
|
-
this.siteVersion = siteVersion != null ? siteVersion : null;
|
|
836
830
|
}
|
|
837
831
|
static getSiteVersion(previewData) {
|
|
838
832
|
var _a;
|
|
839
833
|
return (_a = getMakeswiftSiteVersion(previewData)) != null ? _a : MakeswiftSiteVersion.Live;
|
|
840
834
|
}
|
|
841
|
-
async fetch(path, init) {
|
|
842
|
-
var _a;
|
|
835
|
+
async fetch(path, siteVersion = MakeswiftSiteVersion.Live, init) {
|
|
843
836
|
const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
|
|
844
837
|
headers: __spreadValues({
|
|
845
838
|
["X-API-Key"]: this.apiKey,
|
|
846
839
|
"Makeswift-Site-API-Key": this.apiKey,
|
|
847
|
-
"Makeswift-Site-Version":
|
|
840
|
+
"Makeswift-Site-Version": siteVersion
|
|
848
841
|
}, init == null ? void 0 : init.headers)
|
|
849
842
|
}));
|
|
850
843
|
return response;
|
|
851
844
|
}
|
|
852
|
-
async getPages(
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
});
|
|
845
|
+
async getPages({
|
|
846
|
+
siteVersion = MakeswiftSiteVersion.Live
|
|
847
|
+
} = {}) {
|
|
848
|
+
const response = await this.fetch(`v3/pages`, siteVersion);
|
|
858
849
|
if (!response.ok) {
|
|
859
850
|
console.error("Failed to get pages", await response.json());
|
|
860
851
|
throw new Error(`Failed to get pages with error: "${response.statusText}"`);
|
|
@@ -863,17 +854,13 @@ Received "${apiKey}" instead.`);
|
|
|
863
854
|
return json;
|
|
864
855
|
}
|
|
865
856
|
async getPage(pathname, {
|
|
866
|
-
|
|
857
|
+
siteVersion = MakeswiftSiteVersion.Live,
|
|
867
858
|
locale: localeInput
|
|
868
859
|
} = {}) {
|
|
869
|
-
|
|
870
|
-
const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
|
|
871
|
-
const url = new URL(`${this.siteVersion == null ? "v1" : "v2"}/pages/${encodeURIComponent(pathname)}`, this.apiOrigin);
|
|
860
|
+
const url = new URL(`v2/pages/${encodeURIComponent(pathname)}`, this.apiOrigin);
|
|
872
861
|
if (localeInput)
|
|
873
862
|
url.searchParams.set("locale", localeInput);
|
|
874
|
-
const response = await this.fetch(url.pathname + url.search,
|
|
875
|
-
headers: { "Makeswift-Site-Version": siteVersion }
|
|
876
|
-
});
|
|
863
|
+
const response = await this.fetch(url.pathname + url.search, siteVersion);
|
|
877
864
|
if (!response.ok) {
|
|
878
865
|
if (response.status === 404)
|
|
879
866
|
return null;
|
|
@@ -883,19 +870,14 @@ Received "${apiKey}" instead.`);
|
|
|
883
870
|
const json = await response.json();
|
|
884
871
|
return getPageAPISchema.parse(json);
|
|
885
872
|
}
|
|
886
|
-
async getTypographies(typographyIds,
|
|
887
|
-
var _a;
|
|
873
|
+
async getTypographies(typographyIds, siteVersion) {
|
|
888
874
|
if (typographyIds.length === 0)
|
|
889
875
|
return [];
|
|
890
|
-
const url = new URL(
|
|
876
|
+
const url = new URL(`v2/typographies/bulk`, this.apiOrigin);
|
|
891
877
|
typographyIds.forEach((id) => {
|
|
892
878
|
url.searchParams.append("ids", id);
|
|
893
879
|
});
|
|
894
|
-
const response = await this.fetch(url.pathname + url.search,
|
|
895
|
-
headers: {
|
|
896
|
-
"Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : preview ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
|
|
897
|
-
}
|
|
898
|
-
});
|
|
880
|
+
const response = await this.fetch(url.pathname + url.search, siteVersion);
|
|
899
881
|
if (!response.ok) {
|
|
900
882
|
console.error("Failed to get typographies", await response.json());
|
|
901
883
|
return [];
|
|
@@ -903,36 +885,31 @@ Received "${apiKey}" instead.`);
|
|
|
903
885
|
const body = await response.json();
|
|
904
886
|
return body;
|
|
905
887
|
}
|
|
906
|
-
async getSwatches(ids,
|
|
907
|
-
var _a;
|
|
888
|
+
async getSwatches(ids, siteVersion) {
|
|
908
889
|
if (ids.length === 0)
|
|
909
890
|
return [];
|
|
910
|
-
const url = new URL(
|
|
891
|
+
const url = new URL(`v2/swatches/bulk`, this.apiOrigin);
|
|
911
892
|
ids.forEach((id) => {
|
|
912
893
|
url.searchParams.append("ids", id);
|
|
913
894
|
});
|
|
914
|
-
const response = await this.fetch(url.pathname + url.search,
|
|
915
|
-
headers: {
|
|
916
|
-
"Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : preview ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
|
|
917
|
-
}
|
|
918
|
-
});
|
|
895
|
+
const response = await this.fetch(url.pathname + url.search, siteVersion);
|
|
919
896
|
if (!response.ok) {
|
|
920
897
|
console.error("Failed to get swatches", await response.json());
|
|
921
898
|
return [];
|
|
922
899
|
}
|
|
923
900
|
return await response.json();
|
|
924
901
|
}
|
|
925
|
-
async getIntrospectedResources(_a,
|
|
902
|
+
async getIntrospectedResources(_a, siteVersion) {
|
|
926
903
|
var _b = _a, {
|
|
927
904
|
swatchIds
|
|
928
905
|
} = _b, introspectedResourceIds = __objRest(_b, [
|
|
929
906
|
"swatchIds"
|
|
930
907
|
]);
|
|
931
908
|
const result = await this.graphqlClient.request(IntrospectedResourcesQuery, introspectedResourceIds);
|
|
932
|
-
const swatches = await this.getSwatches(swatchIds,
|
|
909
|
+
const swatches = await this.getSwatches(swatchIds, siteVersion);
|
|
933
910
|
return __spreadProps(__spreadValues({}, result), { swatches });
|
|
934
911
|
}
|
|
935
|
-
async introspect(element,
|
|
912
|
+
async introspect(element, siteVersion, locale) {
|
|
936
913
|
var _a;
|
|
937
914
|
const runtime = this.runtime;
|
|
938
915
|
const descriptors = reactPage.getPropControllerDescriptors(runtime.store.getState());
|
|
@@ -968,10 +945,10 @@ Received "${apiKey}" instead.`);
|
|
|
968
945
|
let element2;
|
|
969
946
|
if (reactPage.isElementReference(current)) {
|
|
970
947
|
const globalElementId = current.value;
|
|
971
|
-
const globalElement = await this.getGlobalElement(globalElementId);
|
|
948
|
+
const globalElement = await this.getGlobalElement(globalElementId, siteVersion);
|
|
972
949
|
let elementData = globalElement == null ? void 0 : globalElement.data;
|
|
973
950
|
if (locale) {
|
|
974
|
-
const localizedGlobalElement = await this.getLocalizedGlobalElement(globalElementId, locale);
|
|
951
|
+
const localizedGlobalElement = await this.getLocalizedGlobalElement(globalElementId, locale, siteVersion);
|
|
975
952
|
localizedResourcesMap.set(globalElementId, (_a = localizedGlobalElement == null ? void 0 : localizedGlobalElement.id) != null ? _a : null);
|
|
976
953
|
if (localizedGlobalElement) {
|
|
977
954
|
elementData = localizedGlobalElement.data;
|
|
@@ -990,7 +967,7 @@ Received "${apiKey}" instead.`);
|
|
|
990
967
|
continue;
|
|
991
968
|
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
992
969
|
}
|
|
993
|
-
const typographies = await this.getTypographies([...typographyIds],
|
|
970
|
+
const typographies = await this.getTypographies([...typographyIds], siteVersion);
|
|
994
971
|
typographies.forEach((typography) => {
|
|
995
972
|
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
996
973
|
var _a2;
|
|
@@ -999,12 +976,12 @@ Received "${apiKey}" instead.`);
|
|
|
999
976
|
swatchIds.add(swatchId);
|
|
1000
977
|
});
|
|
1001
978
|
});
|
|
1002
|
-
const pagePathnames = await this.getPagePathnameSlices([...pageIds], {
|
|
979
|
+
const pagePathnames = await this.getPagePathnameSlices([...pageIds], siteVersion, { locale });
|
|
1003
980
|
const { swatches, files, tables } = await this.getIntrospectedResources({
|
|
1004
981
|
swatchIds: [...swatchIds],
|
|
1005
982
|
fileIds: [...fileIds],
|
|
1006
983
|
tableIds: [...tableIds]
|
|
1007
|
-
},
|
|
984
|
+
}, siteVersion);
|
|
1008
985
|
const cacheData = {
|
|
1009
986
|
[types.APIResourceType.Swatch]: [...swatchIds].map((id) => {
|
|
1010
987
|
var _a2;
|
|
@@ -1052,19 +1029,13 @@ Received "${apiKey}" instead.`);
|
|
|
1052
1029
|
};
|
|
1053
1030
|
return { cacheData, localizedResourcesMap: Object.fromEntries(localizedResourcesMap.entries()) };
|
|
1054
1031
|
}
|
|
1055
|
-
async getPageSnapshot(pathname, {
|
|
1056
|
-
|
|
1057
|
-
locale: localeInput
|
|
1058
|
-
} = {}) {
|
|
1059
|
-
var _a, _b;
|
|
1060
|
-
const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
|
|
1032
|
+
async getPageSnapshot(pathname, { siteVersion, locale: localeInput }) {
|
|
1033
|
+
var _a;
|
|
1061
1034
|
const searchParams = new URLSearchParams();
|
|
1062
1035
|
if (localeInput) {
|
|
1063
1036
|
searchParams.set("locale", localeInput);
|
|
1064
1037
|
}
|
|
1065
|
-
const response = await this.fetch(
|
|
1066
|
-
headers: { "Makeswift-Site-Version": siteVersion }
|
|
1067
|
-
});
|
|
1038
|
+
const response = await this.fetch(`v3/pages/${encodeURIComponent(pathname)}/document?${searchParams.toString()}`, siteVersion);
|
|
1068
1039
|
if (!response.ok) {
|
|
1069
1040
|
if (response.status === 404)
|
|
1070
1041
|
return null;
|
|
@@ -1074,7 +1045,7 @@ Received "${apiKey}" instead.`);
|
|
|
1074
1045
|
const document2 = await response.json();
|
|
1075
1046
|
const baseLocalizedPage = document2.localizedPages.find(({ parentId }) => parentId == null);
|
|
1076
1047
|
const locale = document2.locale;
|
|
1077
|
-
const { cacheData, localizedResourcesMap } = await this.introspect((
|
|
1048
|
+
const { cacheData, localizedResourcesMap } = await this.introspect((_a = baseLocalizedPage == null ? void 0 : baseLocalizedPage.data) != null ? _a : document2.data, siteVersion, locale != null ? locale : void 0);
|
|
1078
1049
|
const apiOrigin = this.apiOrigin.href;
|
|
1079
1050
|
const preview = siteVersion === MakeswiftSiteVersion.Working;
|
|
1080
1051
|
return {
|
|
@@ -1086,8 +1057,8 @@ Received "${apiKey}" instead.`);
|
|
|
1086
1057
|
locale
|
|
1087
1058
|
};
|
|
1088
1059
|
}
|
|
1089
|
-
async getSwatch(swatchId) {
|
|
1090
|
-
const response = await this.fetch(
|
|
1060
|
+
async getSwatch(swatchId, siteVersion) {
|
|
1061
|
+
const response = await this.fetch(`v2/swatches/${swatchId}`, siteVersion);
|
|
1091
1062
|
if (!response.ok) {
|
|
1092
1063
|
if (response.status !== 404)
|
|
1093
1064
|
console.error("Failed to get swatch", await response.json());
|
|
@@ -1100,8 +1071,8 @@ Received "${apiKey}" instead.`);
|
|
|
1100
1071
|
const result = await this.graphqlClient.request(FileQuery, { fileId });
|
|
1101
1072
|
return result.file;
|
|
1102
1073
|
}
|
|
1103
|
-
async getTypography(typographyId) {
|
|
1104
|
-
const response = await this.fetch(
|
|
1074
|
+
async getTypography(typographyId, siteVersion) {
|
|
1075
|
+
const response = await this.fetch(`v2/typographies/${typographyId}`, siteVersion);
|
|
1105
1076
|
if (!response.ok) {
|
|
1106
1077
|
if (response.status !== 404)
|
|
1107
1078
|
console.error("Failed to get typography", await response.json());
|
|
@@ -1110,8 +1081,8 @@ Received "${apiKey}" instead.`);
|
|
|
1110
1081
|
const typography = await response.json();
|
|
1111
1082
|
return typography;
|
|
1112
1083
|
}
|
|
1113
|
-
async getGlobalElement(globalElementId) {
|
|
1114
|
-
const response = await this.fetch(
|
|
1084
|
+
async getGlobalElement(globalElementId, siteVersion) {
|
|
1085
|
+
const response = await this.fetch(`v2/global-elements/${globalElementId}`, siteVersion);
|
|
1115
1086
|
if (!response.ok) {
|
|
1116
1087
|
if (response.status !== 404)
|
|
1117
1088
|
console.error("Failed to get global element", await response.json());
|
|
@@ -1120,8 +1091,8 @@ Received "${apiKey}" instead.`);
|
|
|
1120
1091
|
const globalElement = await response.json();
|
|
1121
1092
|
return globalElement;
|
|
1122
1093
|
}
|
|
1123
|
-
async getLocalizedGlobalElement(globalElementId, locale) {
|
|
1124
|
-
const response = await this.fetch(
|
|
1094
|
+
async getLocalizedGlobalElement(globalElementId, locale, siteVersion) {
|
|
1095
|
+
const response = await this.fetch(`v2/localized-global-elements/${globalElementId}?locale=${locale}`, siteVersion);
|
|
1125
1096
|
if (!response.ok) {
|
|
1126
1097
|
if (response.status !== 404)
|
|
1127
1098
|
console.error("Failed to get localized global element", await response.json());
|
|
@@ -1130,19 +1101,14 @@ Received "${apiKey}" instead.`);
|
|
|
1130
1101
|
const localizedGlobalElement = await response.json();
|
|
1131
1102
|
return localizedGlobalElement;
|
|
1132
1103
|
}
|
|
1133
|
-
async getPagePathnameSlices(pageIds, {
|
|
1134
|
-
var _a;
|
|
1104
|
+
async getPagePathnameSlices(pageIds, siteVersion, { locale }) {
|
|
1135
1105
|
if (pageIds.length === 0)
|
|
1136
1106
|
return [];
|
|
1137
|
-
const url = new URL(
|
|
1107
|
+
const url = new URL(`v2/page-pathname-slices/bulk`, this.apiOrigin);
|
|
1138
1108
|
pageIds.forEach((id) => url.searchParams.append("ids", id));
|
|
1139
1109
|
if (locale != null)
|
|
1140
1110
|
url.searchParams.set("locale", locale);
|
|
1141
|
-
const response = await this.fetch(url.pathname + url.search,
|
|
1142
|
-
headers: {
|
|
1143
|
-
"Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1111
|
+
const response = await this.fetch(url.pathname + url.search, siteVersion);
|
|
1146
1112
|
if (!response.ok) {
|
|
1147
1113
|
console.error("Failed to get page pathname slices", await response.json());
|
|
1148
1114
|
return [];
|
|
@@ -1159,9 +1125,9 @@ Received "${apiKey}" instead.`);
|
|
|
1159
1125
|
};
|
|
1160
1126
|
});
|
|
1161
1127
|
}
|
|
1162
|
-
async getPagePathnameSlice(pageId, {
|
|
1128
|
+
async getPagePathnameSlice(pageId, siteVersion, { locale } = {}) {
|
|
1163
1129
|
var _a;
|
|
1164
|
-
const pagePathnameSlices = await this.getPagePathnameSlices([pageId], {
|
|
1130
|
+
const pagePathnameSlices = await this.getPagePathnameSlices([pageId], siteVersion, { locale });
|
|
1165
1131
|
return (_a = pagePathnameSlices.at(0)) != null ? _a : null;
|
|
1166
1132
|
}
|
|
1167
1133
|
async getTable(tableId) {
|
|
@@ -1251,8 +1217,8 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1251
1217
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1252
1218
|
return res.json(fonts2);
|
|
1253
1219
|
}
|
|
1254
|
-
const version = "0.
|
|
1255
|
-
async function handler(req, res, { apiKey
|
|
1220
|
+
const version = "0.13.0";
|
|
1221
|
+
async function handler(req, res, { apiKey }) {
|
|
1256
1222
|
if (req.query.secret !== apiKey) {
|
|
1257
1223
|
return res.status(401).json({ message: "Unauthorized" });
|
|
1258
1224
|
}
|
|
@@ -1263,8 +1229,8 @@ async function handler(req, res, { apiKey, siteVersions }) {
|
|
|
1263
1229
|
clientSideNavigation: true,
|
|
1264
1230
|
elementFromPoint: false,
|
|
1265
1231
|
customBreakpoints: true,
|
|
1266
|
-
siteVersions,
|
|
1267
|
-
unstable_siteVersions:
|
|
1232
|
+
siteVersions: true,
|
|
1233
|
+
unstable_siteVersions: true,
|
|
1268
1234
|
localizedPageSSR: true
|
|
1269
1235
|
});
|
|
1270
1236
|
}
|
|
@@ -1381,7 +1347,6 @@ function MakeswiftApiHandler(apiKey, {
|
|
|
1381
1347
|
appOrigin = "https://app.makeswift.com",
|
|
1382
1348
|
apiOrigin = "https://api.makeswift.com",
|
|
1383
1349
|
getFonts,
|
|
1384
|
-
siteVersions = false,
|
|
1385
1350
|
runtime = ReactRuntime
|
|
1386
1351
|
} = {}) {
|
|
1387
1352
|
const cors = Cors__default["default"]({ origin: appOrigin });
|
|
@@ -1404,16 +1369,13 @@ Received "${apiKey}" instead.`);
|
|
|
1404
1369
|
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
1405
1370
|
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
|
|
1406
1371
|
}
|
|
1407
|
-
const client = new Makeswift(apiKey, {
|
|
1408
|
-
|
|
1409
|
-
siteVersion: siteVersions ? Makeswift.getSiteVersion(req.previewData) : void 0,
|
|
1410
|
-
runtime
|
|
1411
|
-
});
|
|
1372
|
+
const client = new Makeswift(apiKey, { apiOrigin, runtime });
|
|
1373
|
+
const siteVersion = Makeswift.getSiteVersion(req.previewData);
|
|
1412
1374
|
const action = "/" + makeswift.join("/");
|
|
1413
1375
|
const matches = (pattern) => pathToRegexp.match(pattern, { decode: decodeURIComponent })(action);
|
|
1414
1376
|
let m;
|
|
1415
1377
|
if (matches("/manifest"))
|
|
1416
|
-
return handler(req, res, { apiKey
|
|
1378
|
+
return handler(req, res, { apiKey });
|
|
1417
1379
|
if (matches("/revalidate"))
|
|
1418
1380
|
return revalidate(req, res, { apiKey });
|
|
1419
1381
|
if (matches("/proxy-preview-mode"))
|
|
@@ -1428,23 +1390,23 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
|
|
|
1428
1390
|
return mergeTranslatedData(req, res, client);
|
|
1429
1391
|
const handleResource = (resource) => resource === null ? res.status(404).json({ message: "Not Found" }) : res.json(resource);
|
|
1430
1392
|
if (m = matches("/swatches/:id")) {
|
|
1431
|
-
return client.getSwatch(m.params.id).then(handleResource);
|
|
1393
|
+
return client.getSwatch(m.params.id, siteVersion).then(handleResource);
|
|
1432
1394
|
}
|
|
1433
1395
|
if (m = matches("/files/:id")) {
|
|
1434
1396
|
return client.getFile(m.params.id).then(handleResource);
|
|
1435
1397
|
}
|
|
1436
1398
|
if (m = matches("/typographies/:id")) {
|
|
1437
|
-
return client.getTypography(m.params.id).then(handleResource);
|
|
1399
|
+
return client.getTypography(m.params.id, siteVersion).then(handleResource);
|
|
1438
1400
|
}
|
|
1439
1401
|
if (m = matches("/global-elements/:id")) {
|
|
1440
|
-
return client.getGlobalElement(m.params.id).then(handleResource);
|
|
1402
|
+
return client.getGlobalElement(m.params.id, siteVersion).then(handleResource);
|
|
1441
1403
|
}
|
|
1442
1404
|
if (m = matches("/localized-global-elements/:globalElementId/:locale")) {
|
|
1443
|
-
return client.getLocalizedGlobalElement(m.params.globalElementId, m.params.locale).then((resource) => resource === null ? res.json({ message: "Not Found" }) : res.json(resource));
|
|
1405
|
+
return client.getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion).then((resource) => resource === null ? res.json({ message: "Not Found" }) : res.json(resource));
|
|
1444
1406
|
}
|
|
1445
1407
|
if (m = matches("/page-pathname-slices/:id")) {
|
|
1446
1408
|
const locale = typeof req.query.locale === "string" ? req.query.locale : void 0;
|
|
1447
|
-
return client.getPagePathnameSlice(m.params.id, { locale }).then(handleResource);
|
|
1409
|
+
return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource);
|
|
1448
1410
|
}
|
|
1449
1411
|
if (m = matches("/tables/:id")) {
|
|
1450
1412
|
return client.getTable(m.params.id).then(handleResource);
|
|
@@ -1524,14 +1486,14 @@ async function getStaticPaths() {
|
|
|
1524
1486
|
}
|
|
1525
1487
|
const REVALIDATE_SECONDS = 1;
|
|
1526
1488
|
async function getStaticProps(ctx) {
|
|
1527
|
-
var _a, _b
|
|
1489
|
+
var _a, _b;
|
|
1528
1490
|
deprecationWarning("getStaticProps");
|
|
1529
1491
|
const makeswift = new Makeswift(getApiKey(), {
|
|
1530
1492
|
apiOrigin: getApiOrigin()
|
|
1531
1493
|
});
|
|
1532
1494
|
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1533
1495
|
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1534
|
-
|
|
1496
|
+
siteVersion: Makeswift.getSiteVersion(ctx.previewData)
|
|
1535
1497
|
});
|
|
1536
1498
|
if (snapshot == null)
|
|
1537
1499
|
return {
|
|
@@ -1553,7 +1515,7 @@ async function getServerSideProps(ctx) {
|
|
|
1553
1515
|
});
|
|
1554
1516
|
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1555
1517
|
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1556
|
-
|
|
1518
|
+
siteVersion: MakeswiftSiteVersion.Working
|
|
1557
1519
|
});
|
|
1558
1520
|
if (snapshot == null)
|
|
1559
1521
|
return {
|
|
@@ -3122,7 +3084,9 @@ function RenderHook({
|
|
|
3122
3084
|
return children(useHook(...parameters));
|
|
3123
3085
|
}
|
|
3124
3086
|
function useCheckboxControlValue(data, definition) {
|
|
3125
|
-
|
|
3087
|
+
var _a;
|
|
3088
|
+
const value = (_a = tsPattern.match(data).with({ [number.CheckboxControlDataTypeKey]: number.CheckboxControlDataTypeValueV1 }, (val) => val.value).otherwise((val) => val)) != null ? _a : definition.config.defaultValue;
|
|
3089
|
+
return value;
|
|
3126
3090
|
}
|
|
3127
3091
|
function useColorValue(data, definition) {
|
|
3128
3092
|
var _a, _b;
|
|
@@ -3255,8 +3219,10 @@ function ListControlValue({
|
|
|
3255
3219
|
children: (value) => renderFn([value, ...listControlValue])
|
|
3256
3220
|
}), children)([]);
|
|
3257
3221
|
}
|
|
3258
|
-
function useNumber(
|
|
3259
|
-
|
|
3222
|
+
function useNumber(data, definition) {
|
|
3223
|
+
var _a;
|
|
3224
|
+
const value = (_a = tsPattern.match(data).with({ [number.NumberControlDataTypeKey]: number.NumberControlDataTypeValueV1 }, (val) => val.value).otherwise((val) => val)) != null ? _a : definition.config.defaultValue;
|
|
3225
|
+
return value;
|
|
3260
3226
|
}
|
|
3261
3227
|
const EditableText$1 = forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
|
|
3262
3228
|
return require("./index.cjs8.js");
|
|
@@ -3524,10 +3490,14 @@ function StyleV2ControlValue({
|
|
|
3524
3490
|
})([]);
|
|
3525
3491
|
}
|
|
3526
3492
|
function useTextAreaValue(data, definition) {
|
|
3527
|
-
|
|
3493
|
+
var _a;
|
|
3494
|
+
const value = (_a = tsPattern.match(data).with({ [reactPage.TextAreaControlDataTypeKey]: reactPage.TextAreaControlDataTypeValueV1 }, (val) => val.value).otherwise((val) => val)) != null ? _a : definition.config.defaultValue;
|
|
3495
|
+
return value;
|
|
3528
3496
|
}
|
|
3529
3497
|
function useTextInputValue(data, definition) {
|
|
3530
|
-
|
|
3498
|
+
var _a;
|
|
3499
|
+
const value = (_a = tsPattern.match(data).with({ [reactPage.TextInputControlDataTypeKey]: reactPage.TextInputControlDataTypeValueV1 }, (val) => val.value).otherwise((val) => val)) != null ? _a : definition.config.defaultValue;
|
|
3500
|
+
return value;
|
|
3531
3501
|
}
|
|
3532
3502
|
function typographyFragementToTypographyControlData(typography) {
|
|
3533
3503
|
if (typography == null)
|