@makeswift/runtime 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +14 -14
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Button.cjs.js +23 -23
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Carousel.cjs.js +8 -8
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +13 -13
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Divider.cjs.js +4 -4
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Embed.cjs.js +2 -2
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Form.cjs.js +72 -72
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Image.cjs2.js +10 -10
- package/dist/Image.cjs2.js.map +1 -1
- package/dist/Navigation.cjs.js +17 -17
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Root.cjs.js +2 -2
- package/dist/Root.cjs.js.map +1 -1
- package/dist/SocialLinks.cjs.js +3 -3
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/Text.cjs.js +21 -21
- package/dist/Text.cjs.js.map +1 -1
- package/dist/actions.es.js +1 -1
- package/dist/components.cjs.js +18 -18
- package/dist/cssMediaRules.cjs.js +7 -7
- package/dist/cssMediaRules.cjs.js.map +1 -1
- package/dist/index.cjs.js +374 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +10 -10
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +3 -3
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.es.js +367 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js.map +1 -1
- package/dist/next.cjs.js +22 -402
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +12 -388
- package/dist/next.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +11 -11
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +1 -1
- package/dist/react.cjs.js +8 -8
- package/dist/types/src/next/api-handler.d.ts +25 -1
- package/dist/types/src/next/api-handler.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/use-style.d.ts.map +1 -1
- package/dist/useBoxShadow.cjs.js +3 -3
- package/dist/useBoxShadow.cjs.js.map +1 -1
- package/dist/useMediaQuery.cjs.js +6 -6
- package/dist/useMediaQuery.cjs.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -59,12 +59,12 @@ var boxModels = require("./box-models.cjs.js");
|
|
|
59
59
|
var reactDom = require("react-dom");
|
|
60
60
|
var parse = require("html-react-parser");
|
|
61
61
|
var Head = require("next/head");
|
|
62
|
-
require("@emotion/server/create-instance");
|
|
63
|
-
require("next/document");
|
|
64
|
-
require("cookie");
|
|
65
|
-
require("cors");
|
|
66
|
-
require("http-proxy");
|
|
67
|
-
require("set-cookie-parser");
|
|
62
|
+
var createEmotionServer = require("@emotion/server/create-instance");
|
|
63
|
+
var NextDocument = require("next/document");
|
|
64
|
+
var cookie = require("cookie");
|
|
65
|
+
var Cors = require("cors");
|
|
66
|
+
var httpProxy = require("http-proxy");
|
|
67
|
+
var setCookieParser = require("set-cookie-parser");
|
|
68
68
|
var uuid = require("uuid/v4");
|
|
69
69
|
var ipsum = require("corporate-ipsum");
|
|
70
70
|
function _interopDefaultLegacy(e) {
|
|
@@ -97,6 +97,9 @@ var ColorHelper__default = /* @__PURE__ */ _interopDefaultLegacy(ColorHelper);
|
|
|
97
97
|
var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
|
|
98
98
|
var parse__default = /* @__PURE__ */ _interopDefaultLegacy(parse);
|
|
99
99
|
var Head__default = /* @__PURE__ */ _interopDefaultLegacy(Head);
|
|
100
|
+
var createEmotionServer__default = /* @__PURE__ */ _interopDefaultLegacy(createEmotionServer);
|
|
101
|
+
var NextDocument__default = /* @__PURE__ */ _interopDefaultLegacy(NextDocument);
|
|
102
|
+
var Cors__default = /* @__PURE__ */ _interopDefaultLegacy(Cors);
|
|
100
103
|
var uuid__default = /* @__PURE__ */ _interopDefaultLegacy(uuid);
|
|
101
104
|
var ipsum__default = /* @__PURE__ */ _interopDefaultLegacy(ipsum);
|
|
102
105
|
const SCRIPT_TAG = "script";
|
|
@@ -678,7 +681,7 @@ const SITE_FONTS_QUERY = client.gql`
|
|
|
678
681
|
}
|
|
679
682
|
}
|
|
680
683
|
`;
|
|
681
|
-
function Page({
|
|
684
|
+
function Page$1({
|
|
682
685
|
document: page
|
|
683
686
|
}) {
|
|
684
687
|
var _a;
|
|
@@ -845,6 +848,256 @@ function Page({
|
|
|
845
848
|
}, snippet.id))]
|
|
846
849
|
});
|
|
847
850
|
}
|
|
851
|
+
class Makeswift {
|
|
852
|
+
constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
|
|
853
|
+
__publicField(this, "apiKey");
|
|
854
|
+
__publicField(this, "apiOrigin");
|
|
855
|
+
if (typeof apiKey !== "string") {
|
|
856
|
+
throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
|
|
857
|
+
Received "${apiKey}" instead.`);
|
|
858
|
+
}
|
|
859
|
+
this.apiKey = apiKey;
|
|
860
|
+
try {
|
|
861
|
+
this.apiOrigin = new URL(apiOrigin);
|
|
862
|
+
} catch {
|
|
863
|
+
throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
async fetch(path, init) {
|
|
867
|
+
const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
|
|
868
|
+
headers: __spreadProps(__spreadValues({}, init == null ? void 0 : init.headers), { ["X-API-Key"]: this.apiKey })
|
|
869
|
+
}));
|
|
870
|
+
return response;
|
|
871
|
+
}
|
|
872
|
+
async getPages(params = {}) {
|
|
873
|
+
const searchParams = new URLSearchParams(params);
|
|
874
|
+
const response = await this.fetch(`/v1/pages?${searchParams}`);
|
|
875
|
+
if (!response.ok) {
|
|
876
|
+
throw new Error(`Failed to get pages with error: "${response.statusText}"`);
|
|
877
|
+
}
|
|
878
|
+
const json = await response.json();
|
|
879
|
+
return json;
|
|
880
|
+
}
|
|
881
|
+
async createSnapshot(document2) {
|
|
882
|
+
const client2 = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
|
|
883
|
+
const cacheData = await client2.prefetch(document2.data);
|
|
884
|
+
return { document: document2, apiOrigin: this.apiOrigin.href, cacheData };
|
|
885
|
+
}
|
|
886
|
+
async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
|
|
887
|
+
const searchParams = new URLSearchParams({ preview: String(preview) });
|
|
888
|
+
const response = await this.fetch(`/v1/pages/${pageId}/document?${searchParams}`);
|
|
889
|
+
if (!response.ok) {
|
|
890
|
+
if (response.status === 404)
|
|
891
|
+
return null;
|
|
892
|
+
throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
|
|
893
|
+
}
|
|
894
|
+
const document2 = await response.json();
|
|
895
|
+
return await this.createSnapshot(document2);
|
|
896
|
+
}
|
|
897
|
+
async getPageSnapshot(path, { preview } = {}) {
|
|
898
|
+
const [page] = await this.getPages({ path });
|
|
899
|
+
if (page == null)
|
|
900
|
+
return null;
|
|
901
|
+
const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
|
|
902
|
+
return snapshot;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function PreviewModeScript({
|
|
906
|
+
isPreview = false,
|
|
907
|
+
appOrigin = "https://app.makeswift.com"
|
|
908
|
+
}) {
|
|
909
|
+
const __html = `
|
|
910
|
+
const isPreview = ${isPreview}
|
|
911
|
+
const appOrigin = '${appOrigin.replace("'", "\\'")}'
|
|
912
|
+
const searchParamName = 'x-makeswift-preview-mode'
|
|
913
|
+
const headerName = 'X-Makeswift-Preview-Mode'
|
|
914
|
+
const originalUrl = new URL(window.location.href)
|
|
915
|
+
|
|
916
|
+
if (window.parent !== window) {
|
|
917
|
+
window.addEventListener('message', event => {
|
|
918
|
+
if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
|
|
919
|
+
const { secret } = event.data
|
|
920
|
+
|
|
921
|
+
if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
|
|
922
|
+
const url = new URL(originalUrl)
|
|
923
|
+
|
|
924
|
+
url.searchParams.set(searchParamName, secret)
|
|
925
|
+
|
|
926
|
+
window.location.replace(url)
|
|
927
|
+
} else {
|
|
928
|
+
const originalFetch = window.fetch
|
|
929
|
+
|
|
930
|
+
window.fetch = function patchedFetch(input, init) {
|
|
931
|
+
return originalFetch.call(this, input, {
|
|
932
|
+
...init,
|
|
933
|
+
headers: { ...init?.headers, [headerName]: secret },
|
|
934
|
+
})
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
})
|
|
939
|
+
|
|
940
|
+
window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
if (originalUrl.searchParams.has(searchParamName)) {
|
|
944
|
+
const url = new URL(originalUrl)
|
|
945
|
+
|
|
946
|
+
url.searchParams.delete(searchParamName)
|
|
947
|
+
|
|
948
|
+
window.history.replaceState(null, '', url)
|
|
949
|
+
}
|
|
950
|
+
`;
|
|
951
|
+
return /* @__PURE__ */ jsxRuntime.jsx("script", {
|
|
952
|
+
id: "makeswift-preview-mode",
|
|
953
|
+
type: "module",
|
|
954
|
+
dangerouslySetInnerHTML: {
|
|
955
|
+
__html
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
class Document$1 extends NextDocument__default["default"] {
|
|
960
|
+
static async getInitialProps(ctx) {
|
|
961
|
+
const sheet = new styled.ServerStyleSheet();
|
|
962
|
+
const originalRenderPage = ctx.renderPage;
|
|
963
|
+
try {
|
|
964
|
+
ctx.renderPage = () => originalRenderPage({
|
|
965
|
+
enhanceApp: (App) => (props) => sheet.collectStyles(/* @__PURE__ */ jsxRuntime.jsx(App, __spreadValues({}, props)))
|
|
966
|
+
});
|
|
967
|
+
const initialProps = await NextDocument__default["default"].getInitialProps(ctx);
|
|
968
|
+
slate.KeyUtils.resetGenerator();
|
|
969
|
+
const {
|
|
970
|
+
extractCritical
|
|
971
|
+
} = createEmotionServer__default["default"](css.cache);
|
|
972
|
+
const {
|
|
973
|
+
ids,
|
|
974
|
+
css: css$1
|
|
975
|
+
} = extractCritical(initialProps.html);
|
|
976
|
+
return __spreadProps(__spreadValues({}, initialProps), {
|
|
977
|
+
styles: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
978
|
+
children: [initialProps.styles, sheet.getStyleElement(), /* @__PURE__ */ jsxRuntime.jsx("style", {
|
|
979
|
+
"data-emotion": `css ${ids.join(" ")}`,
|
|
980
|
+
dangerouslySetInnerHTML: {
|
|
981
|
+
__html: css$1
|
|
982
|
+
}
|
|
983
|
+
})]
|
|
984
|
+
})
|
|
985
|
+
});
|
|
986
|
+
} finally {
|
|
987
|
+
sheet.seal();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
render() {
|
|
991
|
+
const {
|
|
992
|
+
isPreview
|
|
993
|
+
} = this.props.__NEXT_DATA__;
|
|
994
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(NextDocument.Html, {
|
|
995
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(NextDocument.Head, {
|
|
996
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PreviewModeScript, {
|
|
997
|
+
isPreview
|
|
998
|
+
})
|
|
999
|
+
}), /* @__PURE__ */ jsxRuntime.jsxs("body", {
|
|
1000
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(NextDocument.Main, {}), /* @__PURE__ */ jsxRuntime.jsx(NextDocument.NextScript, {})]
|
|
1001
|
+
})]
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
const version = "0.2.4";
|
|
1006
|
+
function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com", getFonts } = {}) {
|
|
1007
|
+
const cors = Cors__default["default"]({ origin: appOrigin });
|
|
1008
|
+
const previewModeProxy = httpProxy.createProxyServer();
|
|
1009
|
+
previewModeProxy.on("proxyReq", (proxyReq) => {
|
|
1010
|
+
proxyReq.removeHeader("X-Makeswift-Preview-Mode");
|
|
1011
|
+
const url = new URL(proxyReq.path, "http://n");
|
|
1012
|
+
url.searchParams.delete("x-makeswift-preview-mode");
|
|
1013
|
+
proxyReq.path = url.pathname + url.search;
|
|
1014
|
+
});
|
|
1015
|
+
if (typeof apiKey !== "string") {
|
|
1016
|
+
throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
|
|
1017
|
+
Received "${apiKey}" instead.`);
|
|
1018
|
+
}
|
|
1019
|
+
return async function makeswiftApiHandler(req, res) {
|
|
1020
|
+
var _a, _b;
|
|
1021
|
+
await new Promise((resolve2, reject) => {
|
|
1022
|
+
cors(req, res, (err) => {
|
|
1023
|
+
if (err instanceof Error)
|
|
1024
|
+
reject(err);
|
|
1025
|
+
else
|
|
1026
|
+
resolve2();
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
const { makeswift } = req.query;
|
|
1030
|
+
if (!Array.isArray(makeswift)) {
|
|
1031
|
+
throw new Error(`The Makeswift Next.js API handler must be used in a dynamic catch-all route named \`[...makeswift]\`.
|
|
1032
|
+
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
1033
|
+
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
|
|
1034
|
+
}
|
|
1035
|
+
const action = makeswift.join("/");
|
|
1036
|
+
switch (action) {
|
|
1037
|
+
case "manifest": {
|
|
1038
|
+
if (req.query.secret !== apiKey)
|
|
1039
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
1040
|
+
return res.json({
|
|
1041
|
+
version,
|
|
1042
|
+
previewMode: true
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
case "revalidate": {
|
|
1046
|
+
if (req.query.secret !== apiKey) {
|
|
1047
|
+
return res.status(401).json({ message: "Unauthorized" });
|
|
1048
|
+
}
|
|
1049
|
+
if (typeof req.query.path !== "string") {
|
|
1050
|
+
return res.status(400).json({ message: "Bad Request" });
|
|
1051
|
+
}
|
|
1052
|
+
const revalidate = (_a = res.revalidate) != null ? _a : res.unstable_revalidate;
|
|
1053
|
+
if (typeof revalidate !== "function") {
|
|
1054
|
+
const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
|
|
1055
|
+
Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
|
|
1056
|
+
console.warn(message);
|
|
1057
|
+
return res.json({ revalidated: false });
|
|
1058
|
+
}
|
|
1059
|
+
try {
|
|
1060
|
+
await revalidate(req.query.path);
|
|
1061
|
+
return res.json({ revalidated: true });
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
return res.status(500).json({ message: "Error Revalidating" });
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
case "proxy-preview-mode": {
|
|
1067
|
+
if (req.query.secret !== apiKey)
|
|
1068
|
+
return res.status(401).send("Unauthorized");
|
|
1069
|
+
const host = req.headers.host;
|
|
1070
|
+
if (host == null)
|
|
1071
|
+
return res.status(400).send("Bad Request");
|
|
1072
|
+
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
1073
|
+
const proto = typeof forwardedProto === "string" ? forwardedProto : "http";
|
|
1074
|
+
let target = `${proto}://${host}`;
|
|
1075
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
1076
|
+
const port = req.socket.localPort;
|
|
1077
|
+
if (port != null)
|
|
1078
|
+
target = `http://localhost:${port}`;
|
|
1079
|
+
}
|
|
1080
|
+
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
1081
|
+
res.removeHeader("Set-Cookie");
|
|
1082
|
+
if (!Array.isArray(setCookie))
|
|
1083
|
+
return res.status(500).send("Internal Server Error");
|
|
1084
|
+
const cookie$1 = setCookieParser.parse(setCookie).map((cookie2) => cookie.serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
1085
|
+
return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie: cookie$1 } }, (err) => {
|
|
1086
|
+
if (err)
|
|
1087
|
+
reject(err);
|
|
1088
|
+
else
|
|
1089
|
+
resolve2();
|
|
1090
|
+
}));
|
|
1091
|
+
}
|
|
1092
|
+
case "fonts": {
|
|
1093
|
+
const fonts = (_b = await (getFonts == null ? void 0 : getFonts())) != null ? _b : [];
|
|
1094
|
+
return res.json(fonts);
|
|
1095
|
+
}
|
|
1096
|
+
default:
|
|
1097
|
+
return res.status(404).json({ message: "Not Found" });
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
848
1101
|
const FORWARDED_NEXT_DYNAMIC_REF_KEY = "__forwarded_next_dynamic_ref__";
|
|
849
1102
|
function saveForwardedRef(props, ref) {
|
|
850
1103
|
return __spreadProps(__spreadValues({}, props), {
|
|
@@ -871,6 +1124,111 @@ function forwardNextDynamicRef(nextDynamicThunk) {
|
|
|
871
1124
|
})));
|
|
872
1125
|
return React.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(Dynamic, __spreadValues({}, saveForwardedRef(props, ref))));
|
|
873
1126
|
}
|
|
1127
|
+
function getApiOrigin() {
|
|
1128
|
+
var _a;
|
|
1129
|
+
const apiOriginString = (_a = process["env"].MAKESWIFT_API_HOST) != null ? _a : "https://api.makeswift.com";
|
|
1130
|
+
try {
|
|
1131
|
+
const url = new URL(apiOriginString);
|
|
1132
|
+
return url.origin;
|
|
1133
|
+
} catch (error) {
|
|
1134
|
+
const errorMessage = `"MAKESWIFT_API_HOST" environment variable must be a valid URL. Expected something like "https://api.makeswift.com" but instead received "${apiOriginString}".`;
|
|
1135
|
+
throw new Error(errorMessage);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
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}$/;
|
|
1139
|
+
function getApiKey() {
|
|
1140
|
+
const apiKey = process["env"].MAKESWIFT_SITE_API_KEY;
|
|
1141
|
+
if (apiKey == null) {
|
|
1142
|
+
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';
|
|
1143
|
+
throw new Error(errorMessage);
|
|
1144
|
+
}
|
|
1145
|
+
if (!uuidRegExp.test(apiKey)) {
|
|
1146
|
+
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`;
|
|
1147
|
+
throw new Error(errorMEssage);
|
|
1148
|
+
}
|
|
1149
|
+
return apiKey;
|
|
1150
|
+
}
|
|
1151
|
+
function deprecationWarning(methodName) {
|
|
1152
|
+
const warningMessage = `The \`${methodName}\` export has been deprecated and will be removed in the next minor version. More info: https://github.com/makeswift/makeswift/releases/tag/%40makeswift%2Fruntime%400.2.0`;
|
|
1153
|
+
if (process.env["NODE_ENV"] !== "production")
|
|
1154
|
+
console.warn(warningMessage);
|
|
1155
|
+
}
|
|
1156
|
+
async function getStaticPaths() {
|
|
1157
|
+
deprecationWarning("getStaticPaths");
|
|
1158
|
+
const makeswift = new Makeswift(getApiKey(), {
|
|
1159
|
+
apiOrigin: getApiOrigin()
|
|
1160
|
+
});
|
|
1161
|
+
const pages = await makeswift.getPages();
|
|
1162
|
+
return {
|
|
1163
|
+
paths: pages.map((page) => ({
|
|
1164
|
+
params: {
|
|
1165
|
+
path: page.path.split("/").filter((segment) => segment !== "")
|
|
1166
|
+
}
|
|
1167
|
+
})),
|
|
1168
|
+
fallback: "blocking"
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
const REVALIDATE_SECONDS = 1;
|
|
1172
|
+
async function getStaticProps(ctx) {
|
|
1173
|
+
var _a, _b, _c;
|
|
1174
|
+
deprecationWarning("getStaticProps");
|
|
1175
|
+
const makeswift = new Makeswift(getApiKey(), {
|
|
1176
|
+
apiOrigin: getApiOrigin()
|
|
1177
|
+
});
|
|
1178
|
+
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1179
|
+
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1180
|
+
preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
|
|
1181
|
+
});
|
|
1182
|
+
if (snapshot == null)
|
|
1183
|
+
return {
|
|
1184
|
+
notFound: true,
|
|
1185
|
+
revalidate: REVALIDATE_SECONDS
|
|
1186
|
+
};
|
|
1187
|
+
return {
|
|
1188
|
+
props: {
|
|
1189
|
+
snapshot
|
|
1190
|
+
},
|
|
1191
|
+
revalidate: REVALIDATE_SECONDS
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
async function getServerSideProps(ctx) {
|
|
1195
|
+
var _a, _b;
|
|
1196
|
+
deprecationWarning("getServerSideProps");
|
|
1197
|
+
const makeswift = new Makeswift(getApiKey(), {
|
|
1198
|
+
apiOrigin: getApiOrigin()
|
|
1199
|
+
});
|
|
1200
|
+
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
1201
|
+
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
1202
|
+
preview: true
|
|
1203
|
+
});
|
|
1204
|
+
if (snapshot == null)
|
|
1205
|
+
return {
|
|
1206
|
+
notFound: true
|
|
1207
|
+
};
|
|
1208
|
+
return {
|
|
1209
|
+
props: {
|
|
1210
|
+
snapshot
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
const Page = React.memo(({
|
|
1215
|
+
snapshot
|
|
1216
|
+
}) => {
|
|
1217
|
+
const [client2] = React.useState(() => new MakeswiftClient({
|
|
1218
|
+
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
1219
|
+
cacheData: snapshot.cacheData
|
|
1220
|
+
}));
|
|
1221
|
+
React.useEffect(() => {
|
|
1222
|
+
client2.updateCacheData(snapshot.cacheData);
|
|
1223
|
+
}, [client2, snapshot]);
|
|
1224
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuntimeProvider, {
|
|
1225
|
+
client: client2,
|
|
1226
|
+
rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
|
|
1227
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Page$1, {
|
|
1228
|
+
document: snapshot.document
|
|
1229
|
+
})
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
874
1232
|
const keys = (o) => Object.keys(o);
|
|
875
1233
|
const coalesce = (...args) => {
|
|
876
1234
|
let i;
|
|
@@ -3170,14 +3528,19 @@ exports.DEFAULT_ITEM_ANIMATE_DURATION = DEFAULT_ITEM_ANIMATE_DURATION;
|
|
|
3170
3528
|
exports.DEFAULT_ITEM_ANIMATE_TYPE = DEFAULT_ITEM_ANIMATE_TYPE;
|
|
3171
3529
|
exports.DEFAULT_ITEM_STAGGER_DURATION = DEFAULT_ITEM_STAGGER_DURATION;
|
|
3172
3530
|
exports.DEVICES = DEVICES;
|
|
3531
|
+
exports.Document = Document$1;
|
|
3173
3532
|
exports.DocumentReference = DocumentReference;
|
|
3174
3533
|
exports.Element = Element;
|
|
3175
3534
|
exports.FILES_BY_ID = FILES_BY_ID;
|
|
3535
|
+
exports.Makeswift = Makeswift;
|
|
3536
|
+
exports.MakeswiftApiHandler = MakeswiftApiHandler;
|
|
3176
3537
|
exports.MakeswiftClient = MakeswiftClient;
|
|
3177
3538
|
exports.MakeswiftComponentType = MakeswiftComponentType;
|
|
3178
3539
|
exports.PAGE_SNIPPETS_QUERY = PAGE_SNIPPETS_QUERY;
|
|
3179
|
-
exports.Page = Page;
|
|
3540
|
+
exports.Page = Page$1;
|
|
3541
|
+
exports.Page$1 = Page;
|
|
3180
3542
|
exports.PageProvider = PageProvider;
|
|
3543
|
+
exports.PreviewModeScript = PreviewModeScript;
|
|
3181
3544
|
exports.Provider = Provider;
|
|
3182
3545
|
exports.ReactRuntime = ReactRuntime;
|
|
3183
3546
|
exports.RuntimeProvider = RuntimeProvider;
|
|
@@ -3194,6 +3557,9 @@ exports.forwardNextDynamicRef = forwardNextDynamicRef;
|
|
|
3194
3557
|
exports.getDevice = getDevice;
|
|
3195
3558
|
exports.getDeviceMediaQuery = getDeviceMediaQuery;
|
|
3196
3559
|
exports.getIndexes = getIndexes;
|
|
3560
|
+
exports.getServerSideProps = getServerSideProps;
|
|
3561
|
+
exports.getStaticPaths = getStaticPaths;
|
|
3562
|
+
exports.getStaticProps = getStaticProps;
|
|
3197
3563
|
exports.isNonNullable = isNonNullable;
|
|
3198
3564
|
exports.join = join;
|
|
3199
3565
|
exports.shallowMergeFallbacks = shallowMergeFallbacks;
|