@makeswift/runtime 0.1.0 → 0.1.3
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/Form.cjs.js +33 -14
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +33 -13
- package/dist/Form.es.js.map +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/components.cjs.js +1 -2
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +1 -1
- package/dist/index.cjs.js +59 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +1 -1
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.es.js +61 -24
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es3.js +2 -2
- package/dist/index.es3.js.map +1 -1
- package/dist/style.cjs.js +5 -2
- package/dist/style.cjs.js.map +1 -1
- package/dist/style.es.js +5 -2
- package/dist/style.es.js.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/index.d.ts +1 -1
- package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -1
- package/dist/types/components/{hooks/useTable.d.ts → builtin/Form/types.d.ts} +2 -6
- package/dist/types/components/builtin/Form/types.d.ts.map +1 -0
- package/dist/types/components/hooks/index.d.ts +0 -1
- package/dist/types/components/hooks/index.d.ts.map +1 -1
- package/dist/types/controls/style.d.ts +65 -0
- package/dist/types/controls/style.d.ts.map +1 -1
- package/dist/types/next.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/dist/useBoxShadow.es.js +1 -1
- package/package.json +1 -1
- package/dist/types/components/hooks/useTable.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -869,29 +869,57 @@ class Document$1 extends NextDocument__default["default"] {
|
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
const REVALIDATE_SECONDS = 1;
|
|
872
|
+
function getApiOrigin() {
|
|
873
|
+
var _a;
|
|
874
|
+
const apiOriginString = (_a = process["env"].MAKESWIFT_API_HOST) != null ? _a : "https://api.makeswift.com";
|
|
875
|
+
try {
|
|
876
|
+
const url = new URL(apiOriginString);
|
|
877
|
+
return url.origin;
|
|
878
|
+
} catch (error) {
|
|
879
|
+
const errorMessage = `"MAKESWIFT_API_HOST" environment variable must be a valid URL. Expected something like "https://api.makeswift.com" but instead received "${apiOriginString}".`;
|
|
880
|
+
throw new Error(errorMessage);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
const uuidRegExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
|
|
884
|
+
function getApiKey() {
|
|
885
|
+
const apiKey = process["env"].MAKESWIFT_SITE_API_KEY;
|
|
886
|
+
if (apiKey == null) {
|
|
887
|
+
const errorMessage = '"MAKESWIFT_SITE_API_KEY" environment variable must be set. Please add your site API key to your `.env.local` file. More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables';
|
|
888
|
+
throw new Error(errorMessage);
|
|
889
|
+
}
|
|
890
|
+
if (!uuidRegExp.test(apiKey)) {
|
|
891
|
+
const errorMEssage = `Invalid Makeswift site API key "${apiKey}". Please check your \`.env.local\` file for the "MAKESWIFT_SITE_API_KEY" environment variable. More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables`;
|
|
892
|
+
throw new Error(errorMEssage);
|
|
893
|
+
}
|
|
894
|
+
return apiKey;
|
|
895
|
+
}
|
|
872
896
|
async function getServerSideProps({
|
|
873
897
|
query: {
|
|
874
898
|
pageId
|
|
875
899
|
}
|
|
876
900
|
}) {
|
|
877
|
-
const url = `${
|
|
901
|
+
const url = `${getApiOrigin()}/v0/preview-page-data?id=${pageId}`;
|
|
878
902
|
const res = await fetch(url, {
|
|
879
903
|
headers: {
|
|
880
|
-
"x-api-key":
|
|
904
|
+
"x-api-key": getApiKey()
|
|
881
905
|
}
|
|
882
906
|
});
|
|
883
|
-
if (res.status
|
|
907
|
+
if (res.status === 404) {
|
|
884
908
|
console.error(await res.json());
|
|
885
909
|
return {
|
|
886
910
|
notFound: true
|
|
887
911
|
};
|
|
888
912
|
}
|
|
913
|
+
if (!res.ok) {
|
|
914
|
+
const json = await res.json();
|
|
915
|
+
throw new Error(json.message);
|
|
916
|
+
}
|
|
889
917
|
const page = await res.json();
|
|
890
918
|
if (page == null)
|
|
891
919
|
return {
|
|
892
920
|
notFound: true
|
|
893
921
|
};
|
|
894
|
-
const makeswiftApiEndpoint = `${
|
|
922
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
895
923
|
const client2 = new MakeswiftClient({
|
|
896
924
|
uri: makeswiftApiEndpoint
|
|
897
925
|
});
|
|
@@ -917,26 +945,30 @@ async function getStaticProps({
|
|
|
917
945
|
const {
|
|
918
946
|
path = []
|
|
919
947
|
} = params;
|
|
920
|
-
const url = `${
|
|
948
|
+
const url = `${getApiOrigin()}/v0/live-page-data?path=${path.join("/")}`;
|
|
921
949
|
const res = await fetch(url, {
|
|
922
950
|
headers: {
|
|
923
|
-
"x-api-key":
|
|
951
|
+
"x-api-key": getApiKey()
|
|
924
952
|
}
|
|
925
953
|
});
|
|
926
|
-
if (res.status
|
|
954
|
+
if (res.status === 404) {
|
|
927
955
|
console.error(await res.json());
|
|
928
956
|
return {
|
|
929
957
|
notFound: true,
|
|
930
958
|
revalidate: REVALIDATE_SECONDS
|
|
931
959
|
};
|
|
932
960
|
}
|
|
961
|
+
if (!res.ok) {
|
|
962
|
+
const json = await res.json();
|
|
963
|
+
throw new Error(json.message);
|
|
964
|
+
}
|
|
933
965
|
const page = await res.json();
|
|
934
966
|
if (page == null)
|
|
935
967
|
return {
|
|
936
968
|
notFound: true,
|
|
937
969
|
revalidate: REVALIDATE_SECONDS
|
|
938
970
|
};
|
|
939
|
-
const makeswiftApiEndpoint = `${
|
|
971
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
940
972
|
const client2 = new MakeswiftClient({
|
|
941
973
|
uri: makeswiftApiEndpoint
|
|
942
974
|
});
|
|
@@ -1550,8 +1582,6 @@ const { Provider } = Context$1;
|
|
|
1550
1582
|
function registerComponent$6(runtime) {
|
|
1551
1583
|
return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
|
|
1552
1584
|
return require("./Form.cjs.js");
|
|
1553
|
-
}).then(function(n) {
|
|
1554
|
-
return n.Form$1;
|
|
1555
1585
|
})))), {
|
|
1556
1586
|
type: "./components/Form/index.js",
|
|
1557
1587
|
label: "Form",
|
|
@@ -2446,10 +2476,11 @@ function useStyleControlCssObject(style$1, controlDefinition) {
|
|
|
2446
2476
|
style$1 == null ? void 0 : style$1.margin,
|
|
2447
2477
|
style$1 == null ? void 0 : style$1.padding,
|
|
2448
2478
|
useBorder(style$1 == null ? void 0 : style$1.border),
|
|
2449
|
-
style$1 == null ? void 0 : style$1.borderRadius
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2479
|
+
style$1 == null ? void 0 : style$1.borderRadius,
|
|
2480
|
+
style$1 == null ? void 0 : style$1.textStyle
|
|
2481
|
+
], ([width, margin, padding, border, borderRadius, textStyle]) => {
|
|
2482
|
+
var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2483
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(style.StyleControlProperty.Width) && {
|
|
2453
2484
|
width: (_a = widthToString(width)) != null ? _a : "100%"
|
|
2454
2485
|
}), properties.includes(style.StyleControlProperty.Margin) && {
|
|
2455
2486
|
marginTop: (_b = marginToString(margin == null ? void 0 : margin.marginTop)) != null ? _b : 0,
|
|
@@ -2471,7 +2502,10 @@ function useStyleControlCssObject(style$1, controlDefinition) {
|
|
|
2471
2502
|
borderTopRightRadius: (_o = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _o : 0,
|
|
2472
2503
|
borderBottomRightRadius: (_p = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomRightRadius)) != null ? _p : 0,
|
|
2473
2504
|
borderBottomLeftRadius: (_q = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomLeftRadius)) != null ? _q : 0
|
|
2474
|
-
})
|
|
2505
|
+
}), properties.includes(style.StyleControlProperty.TextStyle) && __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (textStyle == null ? void 0 : textStyle.fontFamily) && { fontFamily: textStyle.fontFamily }), (textStyle == null ? void 0 : textStyle.letterSpacing) && { letterSpacing: textStyle.letterSpacing }), (textStyle == null ? void 0 : textStyle.fontSize) && { fontSize: fontSizeToString(textStyle.fontSize) }), (textStyle == null ? void 0 : textStyle.fontWeight) && { fontWeight: textStyle.fontWeight }), {
|
|
2506
|
+
textTransform: (_r = textStyle == null ? void 0 : textStyle.textTransform) != null ? _r : [],
|
|
2507
|
+
fontStyle: (_s = textStyle == null ? void 0 : textStyle.fontStyle) != null ? _s : []
|
|
2508
|
+
}));
|
|
2475
2509
|
}));
|
|
2476
2510
|
function widthToString(widthProperty) {
|
|
2477
2511
|
if (widthProperty == null)
|
|
@@ -2501,6 +2535,9 @@ function useStyleControlCssObject(style$1, controlDefinition) {
|
|
|
2501
2535
|
return null;
|
|
2502
2536
|
return `${borderRadius.value}${borderRadius.unit}`;
|
|
2503
2537
|
}
|
|
2538
|
+
function fontSizeToString(fontSize) {
|
|
2539
|
+
return `${fontSize.value}${fontSize.unit}`;
|
|
2540
|
+
}
|
|
2504
2541
|
}
|
|
2505
2542
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
2506
2543
|
const useInsertionEffect = (_e = React__namespace[useInsertionEffectSpecifier]) != null ? _e : React__namespace.useLayoutEffect;
|
|
@@ -2891,17 +2928,17 @@ function useDispatch() {
|
|
|
2891
2928
|
const store = React.useContext(Context);
|
|
2892
2929
|
return store.dispatch;
|
|
2893
2930
|
}
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
if (
|
|
2931
|
+
const originalError = console.error;
|
|
2932
|
+
let patched = false;
|
|
2933
|
+
function suppressRefWarning(ownerName) {
|
|
2934
|
+
if (patched === false) {
|
|
2898
2935
|
console.error = (...args) => {
|
|
2899
2936
|
if (typeof args[0] === "string" && args[0].includes("Function components cannot be given refs.") && args[0].includes(`Check the render method of \`${ownerName}\`.`)) {
|
|
2900
2937
|
return;
|
|
2901
2938
|
}
|
|
2902
|
-
return
|
|
2939
|
+
return originalError(...args);
|
|
2903
2940
|
};
|
|
2904
|
-
|
|
2941
|
+
patched = true;
|
|
2905
2942
|
}
|
|
2906
2943
|
}
|
|
2907
2944
|
const ElementData = React.memo(React.forwardRef(function ElementData2({
|
|
@@ -2911,7 +2948,7 @@ const ElementData = React.memo(React.forwardRef(function ElementData2({
|
|
|
2911
2948
|
const [handle, setHandle] = React.useState(null);
|
|
2912
2949
|
const [foundDomNode, setFoundDomNode] = React.useState(null);
|
|
2913
2950
|
React.useImperativeHandle(ref, () => handle != null ? handle : foundDomNode, [handle, foundDomNode]);
|
|
2914
|
-
|
|
2951
|
+
suppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
|
|
2915
2952
|
if (Component == null) {
|
|
2916
2953
|
return /* @__PURE__ */ jsxRuntime.jsx(FallbackComponent, {
|
|
2917
2954
|
ref,
|