@makeswift/runtime 0.2.3 → 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/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/next.cjs.js +22 -406
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +12 -392
- 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/index.d.ts +1 -1
- package/dist/types/src/next/index.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 +2 -2
package/dist/next.es.js
CHANGED
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __publicField = (obj, key, value) => {
|
|
21
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
import { useState, useEffect } from "react";
|
|
25
|
-
import { Q as MakeswiftClient, R as RuntimeProvider, o as Page$1 } from "./index.es.js";
|
|
26
|
-
export { Q as MakeswiftClient, U as forwardNextDynamicRef } from "./index.es.js";
|
|
27
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
28
|
-
import { cache } from "@emotion/css";
|
|
29
|
-
import createEmotionServer from "@emotion/server/create-instance";
|
|
30
|
-
import NextDocument, { Html, Head, Main, NextScript } from "next/document";
|
|
31
|
-
import { KeyUtils } from "slate";
|
|
32
|
-
import { ServerStyleSheet } from "styled-components";
|
|
33
|
-
import { serialize } from "cookie";
|
|
34
|
-
import Cors from "cors";
|
|
35
|
-
import { createProxyServer } from "http-proxy";
|
|
36
|
-
import { parse } from "set-cookie-parser";
|
|
1
|
+
import "react";
|
|
2
|
+
export { $ as Document, Z as Makeswift, a0 as MakeswiftApiHandler, U as MakeswiftClient, Y as Page, _ as PreviewModeScript, a1 as forwardNextDynamicRef, X as getServerSideProps, V as getStaticPaths, W as getStaticProps } from "./index.es.js";
|
|
3
|
+
import "react/jsx-runtime";
|
|
37
4
|
import "use-sync-external-store/shim/with-selector";
|
|
38
5
|
import "./react-page.es.js";
|
|
39
6
|
import "redux";
|
|
@@ -45,9 +12,12 @@ import "./slot.es.js";
|
|
|
45
12
|
import "next/dynamic";
|
|
46
13
|
import "@apollo/client";
|
|
47
14
|
import "@apollo/client/link/batch-http";
|
|
15
|
+
import "slate";
|
|
48
16
|
import "./graphql.es.js";
|
|
49
17
|
import "./shape.es.js";
|
|
18
|
+
import "styled-components";
|
|
50
19
|
import "./text-input.es.js";
|
|
20
|
+
import "@emotion/css";
|
|
51
21
|
import "color";
|
|
52
22
|
import "scroll-into-view-if-needed";
|
|
53
23
|
import "./box-models.es.js";
|
|
@@ -55,362 +25,12 @@ import "css-box-model";
|
|
|
55
25
|
import "react-dom";
|
|
56
26
|
import "html-react-parser";
|
|
57
27
|
import "next/head";
|
|
28
|
+
import "@emotion/server/create-instance";
|
|
29
|
+
import "next/document";
|
|
30
|
+
import "cookie";
|
|
31
|
+
import "cors";
|
|
32
|
+
import "http-proxy";
|
|
33
|
+
import "set-cookie-parser";
|
|
58
34
|
import "uuid/v4";
|
|
59
35
|
import "corporate-ipsum";
|
|
60
|
-
class Makeswift {
|
|
61
|
-
constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
|
|
62
|
-
__publicField(this, "apiKey");
|
|
63
|
-
__publicField(this, "apiOrigin");
|
|
64
|
-
if (typeof apiKey !== "string") {
|
|
65
|
-
throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
|
|
66
|
-
Received "${apiKey}" instead.`);
|
|
67
|
-
}
|
|
68
|
-
this.apiKey = apiKey;
|
|
69
|
-
try {
|
|
70
|
-
this.apiOrigin = new URL(apiOrigin);
|
|
71
|
-
} catch {
|
|
72
|
-
throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async fetch(path, init) {
|
|
76
|
-
const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
|
|
77
|
-
headers: __spreadProps(__spreadValues({}, init == null ? void 0 : init.headers), { ["X-API-Key"]: this.apiKey })
|
|
78
|
-
}));
|
|
79
|
-
return response;
|
|
80
|
-
}
|
|
81
|
-
async getPages(params = {}) {
|
|
82
|
-
const searchParams = new URLSearchParams(params);
|
|
83
|
-
const response = await this.fetch(`/v1/pages?${searchParams}`);
|
|
84
|
-
if (!response.ok) {
|
|
85
|
-
throw new Error(`Failed to get pages with error: "${response.statusText}"`);
|
|
86
|
-
}
|
|
87
|
-
const json = await response.json();
|
|
88
|
-
return json;
|
|
89
|
-
}
|
|
90
|
-
async createSnapshot(document) {
|
|
91
|
-
const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
|
|
92
|
-
const cacheData = await client.prefetch(document.data);
|
|
93
|
-
return { document, apiOrigin: this.apiOrigin.href, cacheData };
|
|
94
|
-
}
|
|
95
|
-
async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
|
|
96
|
-
const searchParams = new URLSearchParams({ preview: String(preview) });
|
|
97
|
-
const response = await this.fetch(`/v1/pages/${pageId}/document?${searchParams}`);
|
|
98
|
-
if (!response.ok) {
|
|
99
|
-
if (response.status === 404)
|
|
100
|
-
return null;
|
|
101
|
-
throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
|
|
102
|
-
}
|
|
103
|
-
const document = await response.json();
|
|
104
|
-
return await this.createSnapshot(document);
|
|
105
|
-
}
|
|
106
|
-
async getPageSnapshot(path, { preview } = {}) {
|
|
107
|
-
const [page] = await this.getPages({ path });
|
|
108
|
-
if (page == null)
|
|
109
|
-
return null;
|
|
110
|
-
const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
|
|
111
|
-
return snapshot;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function PreviewModeScript({
|
|
115
|
-
isPreview = false,
|
|
116
|
-
appOrigin = "https://app.makeswift.com"
|
|
117
|
-
}) {
|
|
118
|
-
const __html = `
|
|
119
|
-
const isPreview = ${isPreview}
|
|
120
|
-
const appOrigin = '${appOrigin.replace("'", "\\'")}'
|
|
121
|
-
const searchParamName = 'x-makeswift-preview-mode'
|
|
122
|
-
const headerName = 'X-Makeswift-Preview-Mode'
|
|
123
|
-
const originalUrl = new URL(window.location.href)
|
|
124
|
-
|
|
125
|
-
if (window.parent !== window) {
|
|
126
|
-
window.addEventListener('message', event => {
|
|
127
|
-
if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {
|
|
128
|
-
const { secret } = event.data
|
|
129
|
-
|
|
130
|
-
if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {
|
|
131
|
-
const url = new URL(originalUrl)
|
|
132
|
-
|
|
133
|
-
url.searchParams.set(searchParamName, secret)
|
|
134
|
-
|
|
135
|
-
window.location.replace(url)
|
|
136
|
-
} else {
|
|
137
|
-
const originalFetch = window.fetch
|
|
138
|
-
|
|
139
|
-
window.fetch = function patchedFetch(input, init) {
|
|
140
|
-
return originalFetch.call(this, input, {
|
|
141
|
-
...init,
|
|
142
|
-
headers: { ...init?.headers, [headerName]: secret },
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (originalUrl.searchParams.has(searchParamName)) {
|
|
153
|
-
const url = new URL(originalUrl)
|
|
154
|
-
|
|
155
|
-
url.searchParams.delete(searchParamName)
|
|
156
|
-
|
|
157
|
-
window.history.replaceState(null, '', url)
|
|
158
|
-
}
|
|
159
|
-
`;
|
|
160
|
-
return /* @__PURE__ */ jsx("script", {
|
|
161
|
-
id: "makeswift-preview-mode",
|
|
162
|
-
type: "module",
|
|
163
|
-
dangerouslySetInnerHTML: {
|
|
164
|
-
__html
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
class Document extends NextDocument {
|
|
169
|
-
static async getInitialProps(ctx) {
|
|
170
|
-
const sheet = new ServerStyleSheet();
|
|
171
|
-
const originalRenderPage = ctx.renderPage;
|
|
172
|
-
try {
|
|
173
|
-
ctx.renderPage = () => originalRenderPage({
|
|
174
|
-
enhanceApp: (App) => (props) => sheet.collectStyles(/* @__PURE__ */ jsx(App, __spreadValues({}, props)))
|
|
175
|
-
});
|
|
176
|
-
const initialProps = await NextDocument.getInitialProps(ctx);
|
|
177
|
-
KeyUtils.resetGenerator();
|
|
178
|
-
const {
|
|
179
|
-
extractCritical
|
|
180
|
-
} = createEmotionServer(cache);
|
|
181
|
-
const {
|
|
182
|
-
ids,
|
|
183
|
-
css
|
|
184
|
-
} = extractCritical(initialProps.html);
|
|
185
|
-
return __spreadProps(__spreadValues({}, initialProps), {
|
|
186
|
-
styles: /* @__PURE__ */ jsxs(Fragment, {
|
|
187
|
-
children: [initialProps.styles, sheet.getStyleElement(), /* @__PURE__ */ jsx("style", {
|
|
188
|
-
"data-emotion": `css ${ids.join(" ")}`,
|
|
189
|
-
dangerouslySetInnerHTML: {
|
|
190
|
-
__html: css
|
|
191
|
-
}
|
|
192
|
-
})]
|
|
193
|
-
})
|
|
194
|
-
});
|
|
195
|
-
} finally {
|
|
196
|
-
sheet.seal();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
render() {
|
|
200
|
-
const {
|
|
201
|
-
isPreview
|
|
202
|
-
} = this.props.__NEXT_DATA__;
|
|
203
|
-
return /* @__PURE__ */ jsxs(Html, {
|
|
204
|
-
children: [/* @__PURE__ */ jsx(Head, {
|
|
205
|
-
children: /* @__PURE__ */ jsx(PreviewModeScript, {
|
|
206
|
-
isPreview
|
|
207
|
-
})
|
|
208
|
-
}), /* @__PURE__ */ jsxs("body", {
|
|
209
|
-
children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(NextScript, {})]
|
|
210
|
-
})]
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const version = "0.2.3";
|
|
215
|
-
function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com", getFonts } = {}) {
|
|
216
|
-
const cors = Cors({ origin: appOrigin });
|
|
217
|
-
const previewModeProxy = createProxyServer();
|
|
218
|
-
previewModeProxy.on("proxyReq", (proxyReq) => {
|
|
219
|
-
proxyReq.removeHeader("X-Makeswift-Preview-Mode");
|
|
220
|
-
const url = new URL(proxyReq.path, "http://n");
|
|
221
|
-
url.searchParams.delete("x-makeswift-preview-mode");
|
|
222
|
-
proxyReq.path = url.pathname + url.search;
|
|
223
|
-
});
|
|
224
|
-
if (typeof apiKey !== "string") {
|
|
225
|
-
throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
|
|
226
|
-
Received "${apiKey}" instead.`);
|
|
227
|
-
}
|
|
228
|
-
return async function makeswiftApiHandler(req, res) {
|
|
229
|
-
var _a, _b;
|
|
230
|
-
await new Promise((resolve, reject) => {
|
|
231
|
-
cors(req, res, (err) => {
|
|
232
|
-
if (err instanceof Error)
|
|
233
|
-
reject(err);
|
|
234
|
-
else
|
|
235
|
-
resolve();
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
const { makeswift } = req.query;
|
|
239
|
-
if (!Array.isArray(makeswift)) {
|
|
240
|
-
throw new Error(`The Makeswift Next.js API handler must be used in a dynamic catch-all route named \`[...makeswift]\`.
|
|
241
|
-
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
242
|
-
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
|
|
243
|
-
}
|
|
244
|
-
const action = makeswift.join("/");
|
|
245
|
-
switch (action) {
|
|
246
|
-
case "manifest": {
|
|
247
|
-
if (req.query.secret !== apiKey)
|
|
248
|
-
return res.status(401).json({ message: "Unauthorized" });
|
|
249
|
-
return res.json({
|
|
250
|
-
version,
|
|
251
|
-
previewMode: true
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
case "revalidate": {
|
|
255
|
-
if (req.query.secret !== apiKey) {
|
|
256
|
-
return res.status(401).json({ message: "Unauthorized" });
|
|
257
|
-
}
|
|
258
|
-
if (typeof req.query.path !== "string") {
|
|
259
|
-
return res.status(400).json({ message: "Bad Request" });
|
|
260
|
-
}
|
|
261
|
-
const revalidate = (_a = res.revalidate) != null ? _a : res.unstable_revalidate;
|
|
262
|
-
if (typeof revalidate !== "function") {
|
|
263
|
-
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.
|
|
264
|
-
Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
|
|
265
|
-
console.warn(message);
|
|
266
|
-
return res.json({ revalidated: false });
|
|
267
|
-
}
|
|
268
|
-
try {
|
|
269
|
-
await revalidate(req.query.path);
|
|
270
|
-
return res.json({ revalidated: true });
|
|
271
|
-
} catch (error) {
|
|
272
|
-
return res.status(500).json({ message: "Error Revalidating" });
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
case "proxy-preview-mode": {
|
|
276
|
-
if (req.query.secret !== apiKey)
|
|
277
|
-
return res.status(401).send("Unauthorized");
|
|
278
|
-
const host = req.headers.host;
|
|
279
|
-
if (host == null)
|
|
280
|
-
return res.status(400).send("Bad Request");
|
|
281
|
-
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
282
|
-
const proto = typeof forwardedProto === "string" ? forwardedProto : "http";
|
|
283
|
-
let target = `${proto}://${host}`;
|
|
284
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
285
|
-
const port = req.socket.localPort;
|
|
286
|
-
if (port != null)
|
|
287
|
-
target = `http://localhost:${port}`;
|
|
288
|
-
}
|
|
289
|
-
const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
|
|
290
|
-
res.removeHeader("Set-Cookie");
|
|
291
|
-
if (!Array.isArray(setCookie))
|
|
292
|
-
return res.status(500).send("Internal Server Error");
|
|
293
|
-
const cookie = parse(setCookie).map((cookie2) => serialize(cookie2.name, cookie2.value, cookie2)).join(";");
|
|
294
|
-
return await new Promise((resolve, reject) => previewModeProxy.web(req, res, { target, headers: { cookie } }, (err) => {
|
|
295
|
-
if (err)
|
|
296
|
-
reject(err);
|
|
297
|
-
else
|
|
298
|
-
resolve();
|
|
299
|
-
}));
|
|
300
|
-
}
|
|
301
|
-
case "fonts": {
|
|
302
|
-
const fonts = (_b = await (getFonts == null ? void 0 : getFonts())) != null ? _b : [];
|
|
303
|
-
return res.json(fonts);
|
|
304
|
-
}
|
|
305
|
-
default:
|
|
306
|
-
return res.status(404).json({ message: "Not Found" });
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function getApiOrigin() {
|
|
311
|
-
var _a;
|
|
312
|
-
const apiOriginString = (_a = process["env"].MAKESWIFT_API_HOST) != null ? _a : "https://api.makeswift.com";
|
|
313
|
-
try {
|
|
314
|
-
const url = new URL(apiOriginString);
|
|
315
|
-
return url.origin;
|
|
316
|
-
} catch (error) {
|
|
317
|
-
const errorMessage = `"MAKESWIFT_API_HOST" environment variable must be a valid URL. Expected something like "https://api.makeswift.com" but instead received "${apiOriginString}".`;
|
|
318
|
-
throw new Error(errorMessage);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
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}$/;
|
|
322
|
-
function getApiKey() {
|
|
323
|
-
const apiKey = process["env"].MAKESWIFT_SITE_API_KEY;
|
|
324
|
-
if (apiKey == null) {
|
|
325
|
-
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';
|
|
326
|
-
throw new Error(errorMessage);
|
|
327
|
-
}
|
|
328
|
-
if (!uuidRegExp.test(apiKey)) {
|
|
329
|
-
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`;
|
|
330
|
-
throw new Error(errorMEssage);
|
|
331
|
-
}
|
|
332
|
-
return apiKey;
|
|
333
|
-
}
|
|
334
|
-
function deprecationWarning(methodName) {
|
|
335
|
-
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`;
|
|
336
|
-
if (process.env["NODE_ENV"] !== "production")
|
|
337
|
-
console.warn(warningMessage);
|
|
338
|
-
}
|
|
339
|
-
async function getStaticPaths() {
|
|
340
|
-
deprecationWarning("getStaticPaths");
|
|
341
|
-
const makeswift = new Makeswift(getApiKey(), {
|
|
342
|
-
apiOrigin: getApiOrigin()
|
|
343
|
-
});
|
|
344
|
-
const pages = await makeswift.getPages();
|
|
345
|
-
return {
|
|
346
|
-
paths: pages.map((page) => ({
|
|
347
|
-
params: {
|
|
348
|
-
path: page.path.split("/").filter((segment) => segment !== "")
|
|
349
|
-
}
|
|
350
|
-
})),
|
|
351
|
-
fallback: "blocking"
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
const REVALIDATE_SECONDS = 1;
|
|
355
|
-
async function getStaticProps(ctx) {
|
|
356
|
-
var _a, _b, _c;
|
|
357
|
-
deprecationWarning("getStaticProps");
|
|
358
|
-
const makeswift = new Makeswift(getApiKey(), {
|
|
359
|
-
apiOrigin: getApiOrigin()
|
|
360
|
-
});
|
|
361
|
-
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
362
|
-
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
363
|
-
preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
|
|
364
|
-
});
|
|
365
|
-
if (snapshot == null)
|
|
366
|
-
return {
|
|
367
|
-
notFound: true,
|
|
368
|
-
revalidate: REVALIDATE_SECONDS
|
|
369
|
-
};
|
|
370
|
-
return {
|
|
371
|
-
props: {
|
|
372
|
-
snapshot
|
|
373
|
-
},
|
|
374
|
-
revalidate: REVALIDATE_SECONDS
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
async function getServerSideProps(ctx) {
|
|
378
|
-
var _a, _b;
|
|
379
|
-
deprecationWarning("getServerSideProps");
|
|
380
|
-
const makeswift = new Makeswift(getApiKey(), {
|
|
381
|
-
apiOrigin: getApiOrigin()
|
|
382
|
-
});
|
|
383
|
-
const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
|
|
384
|
-
const snapshot = await makeswift.getPageSnapshot(path, {
|
|
385
|
-
preview: true
|
|
386
|
-
});
|
|
387
|
-
if (snapshot == null)
|
|
388
|
-
return {
|
|
389
|
-
notFound: true
|
|
390
|
-
};
|
|
391
|
-
return {
|
|
392
|
-
props: {
|
|
393
|
-
snapshot
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
function Page({
|
|
398
|
-
snapshot
|
|
399
|
-
}) {
|
|
400
|
-
const [client] = useState(() => new MakeswiftClient({
|
|
401
|
-
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
402
|
-
cacheData: snapshot.cacheData
|
|
403
|
-
}));
|
|
404
|
-
useEffect(() => {
|
|
405
|
-
client.updateCacheData(snapshot.cacheData);
|
|
406
|
-
}, [client, snapshot]);
|
|
407
|
-
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
408
|
-
client,
|
|
409
|
-
rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
|
|
410
|
-
children: /* @__PURE__ */ jsx(Page$1, {
|
|
411
|
-
document: snapshot.document
|
|
412
|
-
})
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
export { Document, Makeswift, MakeswiftApiHandler, Page, PreviewModeScript, getServerSideProps, getStaticPaths, getStaticProps };
|
|
416
36
|
//# sourceMappingURL=next.es.js.map
|
package/dist/next.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.es.js","sources":["../src/next/client.ts","../src/next/preview-mode.tsx","../src/next/document.tsx","../src/next/api-handler.ts","../src/next/index.tsx"],"sourcesContent":["import { NormalizedCacheObject } from '@apollo/client'\nimport { MakeswiftClient } from '../api/react'\nimport { Element } from '../state/react-page'\n\nexport type MakeswiftPage = {\n id: string\n path: string\n}\n\nexport type MakeswiftPageDocument = {\n id: string\n site: { id: string }\n data: Element\n snippets: {\n id: string\n code: string\n location: 'HEAD' | 'BODY'\n liveEnabled: boolean\n builderEnabled: boolean\n cleanup: string | null\n }[]\n fonts: { family: string; variants: string[] }[]\n meta: {\n title: string | null\n description: string | null\n keywords: string | null\n socialImage: {\n id: string\n publicUrl: string\n mimetype: string\n } | null\n favicon: {\n id: string\n publicUrl: string\n mimetype: string\n } | null\n }\n seo: {\n canonicalUrl: string | null\n isIndexingBlocked: boolean | null\n }\n}\n\nexport type MakeswiftPageSnapshot = {\n document: MakeswiftPageDocument\n apiOrigin: string\n cacheData: NormalizedCacheObject\n}\n\ntype MakeswiftConfig = {\n apiOrigin?: string\n}\n\nexport class Makeswift {\n private apiKey: string\n private apiOrigin: URL\n\n constructor(apiKey: string, { apiOrigin = 'https://api.makeswift.com' }: MakeswiftConfig = {}) {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift client must be passed a valid Makeswift site API key: ' +\n \"`new Makeswift('<makeswift_site_api_key>')`\\n\" +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n this.apiKey = apiKey\n\n try {\n this.apiOrigin = new URL(apiOrigin)\n } catch {\n throw new Error(\n `The Makeswift client received an invalid \\`apiOrigin\\` parameter: \"${apiOrigin}\".`,\n )\n }\n }\n\n private async fetch(path: string, init?: RequestInit): Promise<Response> {\n const response = await fetch(new URL(path, this.apiOrigin).toString(), {\n ...init,\n headers: { ...init?.headers, ['X-API-Key']: this.apiKey },\n })\n\n return response\n }\n\n async getPages(params: { path?: string } = {}): Promise<MakeswiftPage[]> {\n const searchParams = new URLSearchParams(params)\n const response = await this.fetch(`/v1/pages?${searchParams}`)\n\n if (!response.ok) {\n throw new Error(`Failed to get pages with error: \"${response.statusText}\"`)\n }\n\n const json = await response.json()\n\n return json\n }\n\n private async createSnapshot(document: MakeswiftPageDocument): Promise<MakeswiftPageSnapshot> {\n const client = new MakeswiftClient({ uri: new URL('graphql', this.apiOrigin).href })\n const cacheData = await client.prefetch(document.data)\n\n return { document, apiOrigin: this.apiOrigin.href, cacheData }\n }\n\n private async getPageSnapshotByPageId(\n pageId: string,\n { preview = false }: { preview?: boolean } = {},\n ): Promise<MakeswiftPageSnapshot | null> {\n const searchParams = new URLSearchParams({ preview: String(preview) })\n const response = await this.fetch(`/v1/pages/${pageId}/document?${searchParams}`)\n\n if (!response.ok) {\n if (response.status === 404) return null\n\n throw new Error(`Failed to get snapshot with error: \"${response.statusText}\"`)\n }\n\n const document: MakeswiftPageDocument = await response.json()\n\n return await this.createSnapshot(document)\n }\n\n async getPageSnapshot(\n path: string,\n { preview }: { preview?: boolean } = {},\n ): Promise<MakeswiftPageSnapshot | null> {\n const [page] = await this.getPages({ path })\n\n if (page == null) return null\n\n const snapshot = this.getPageSnapshotByPageId(page.id, { preview })\n\n return snapshot\n }\n}\n","type Props = {\n isPreview?: boolean\n appOrigin?: string\n}\n\nexport function PreviewModeScript({\n isPreview = false,\n appOrigin = 'https://app.makeswift.com',\n}: Props) {\n const __html = `\nconst isPreview = ${isPreview}\nconst appOrigin = '${appOrigin.replace(\"'\", \"\\\\'\")}'\nconst searchParamName = 'x-makeswift-preview-mode'\nconst headerName = 'X-Makeswift-Preview-Mode'\nconst originalUrl = new URL(window.location.href)\n\nif (window.parent !== window) {\n window.addEventListener('message', event => {\n if (event.origin === appOrigin && event.data.type === 'makeswift_preview_mode') {\n const { secret } = event.data\n\n if (!isPreview && !originalUrl.searchParams.has(searchParamName)) {\n const url = new URL(originalUrl)\n\n url.searchParams.set(searchParamName, secret)\n\n window.location.replace(url)\n } else {\n const originalFetch = window.fetch\n\n window.fetch = function patchedFetch(input, init) {\n return originalFetch.call(this, input, {\n ...init,\n headers: { ...init?.headers, [headerName]: secret },\n })\n }\n }\n }\n })\n\n window.parent.postMessage({ type: 'makeswift_preview_mode' }, appOrigin)\n}\n\nif (originalUrl.searchParams.has(searchParamName)) {\n const url = new URL(originalUrl)\n\n url.searchParams.delete(searchParamName)\n\n window.history.replaceState(null, '', url)\n}\n`\n\n return <script id=\"makeswift-preview-mode\" type=\"module\" dangerouslySetInnerHTML={{ __html }} />\n}\n\nexport type MakeswiftPreviewData = { makeswift: true }\n","import { cache } from '@emotion/css'\nimport createEmotionServer from '@emotion/server/create-instance'\nimport NextDocument, {\n DocumentContext,\n DocumentInitialProps,\n Head,\n Html,\n Main,\n NextScript,\n} from 'next/document'\nimport { KeyUtils } from 'slate'\nimport { ServerStyleSheet } from 'styled-components'\nimport { PreviewModeScript } from './preview-mode'\n\nexport class Document extends NextDocument {\n static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {\n const sheet = new ServerStyleSheet()\n const originalRenderPage = ctx.renderPage\n\n try {\n ctx.renderPage = () =>\n originalRenderPage({\n enhanceApp: App => props => sheet.collectStyles(<App {...props} />),\n })\n\n const initialProps = await NextDocument.getInitialProps(ctx)\n\n KeyUtils.resetGenerator()\n\n const { extractCritical } = createEmotionServer(cache)\n const { ids, css } = extractCritical(initialProps.html)\n\n return {\n ...initialProps,\n styles: (\n <>\n {initialProps.styles}\n {sheet.getStyleElement()}\n <style\n data-emotion={`css ${ids.join(' ')}`}\n dangerouslySetInnerHTML={{ __html: css }}\n />\n </>\n ),\n }\n } finally {\n sheet.seal()\n }\n }\n\n render() {\n const { isPreview } = this.props.__NEXT_DATA__\n\n return (\n <Html>\n <Head>\n <PreviewModeScript isPreview={isPreview} />\n </Head>\n <body>\n <Main />\n <NextScript />\n </body>\n </Html>\n )\n }\n}\n","import { CookieSerializeOptions, serialize } from 'cookie'\nimport Cors from 'cors'\nimport { createProxyServer } from 'http-proxy'\nimport { NextApiHandler } from 'next'\nimport { parse } from 'set-cookie-parser'\nimport { version } from '../../package.json'\n\ntype Fonts = Font[]\n\ntype Font = {\n family: string\n variants: FontVariant[]\n}\n\ntype FontVariant = { weight: string; style: 'italic' | 'normal'; src?: string }\n\ntype MakeswiftApiHandlerConfig = {\n appOrigin?: string\n getFonts?: () => Fonts | Promise<Fonts>\n}\n\nexport type MakeswiftApiHandlerErrorResponse = { message: string }\nexport type MakeswiftApiHandlerRevalidateErrorResponse = string\nexport type MakeswiftApiHandlerRevalidateResponse = { revalidated: boolean }\nexport type MakeswiftApiHandlerManifestResponse = { version: string; previewMode: boolean }\nexport type MakeswiftApiHandlerFontsResponse = Fonts\n\nexport type MakeswiftApiHandlerResponse =\n | MakeswiftApiHandlerErrorResponse\n | MakeswiftApiHandlerRevalidateErrorResponse\n | MakeswiftApiHandlerRevalidateResponse\n | MakeswiftApiHandlerManifestResponse\n | MakeswiftApiHandlerFontsResponse\n\nexport function MakeswiftApiHandler(\n apiKey: string,\n { appOrigin = 'https://app.makeswift.com', getFonts }: MakeswiftApiHandlerConfig = {},\n): NextApiHandler<MakeswiftApiHandlerResponse> {\n const cors = Cors({ origin: appOrigin })\n const previewModeProxy = createProxyServer()\n\n previewModeProxy.on('proxyReq', proxyReq => {\n proxyReq.removeHeader('X-Makeswift-Preview-Mode')\n\n const url = new URL(proxyReq.path, 'http://n')\n\n url.searchParams.delete('x-makeswift-preview-mode')\n\n proxyReq.path = url.pathname + url.search\n })\n\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift Next.js API handler must be passed a valid Makeswift site API key: ' +\n \"`MakeswiftApiHandler('<makeswift_site_api_key>')`\\n\" +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function makeswiftApiHandler(req, res) {\n await new Promise<void>((resolve, reject) => {\n cors(req, res, err => {\n if (err instanceof Error) reject(err)\n else resolve()\n })\n })\n\n const { makeswift } = req.query\n\n if (!Array.isArray(makeswift)) {\n throw new Error(\n 'The Makeswift Next.js API handler must be used in a dynamic catch-all route named `[...makeswift]`.\\n' +\n `Received \"${makeswift}\" for the \\`makeswift\\` param instead.\\n` +\n 'Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes',\n )\n }\n\n const action = makeswift.join('/')\n\n switch (action) {\n case 'manifest': {\n if (req.query.secret !== apiKey) return res.status(401).json({ message: 'Unauthorized' })\n\n return res.json({\n version,\n previewMode: true,\n })\n }\n\n case 'revalidate': {\n if (req.query.secret !== apiKey) {\n return res.status(401).json({ message: 'Unauthorized' })\n }\n\n if (typeof req.query.path !== 'string') {\n return res.status(400).json({ message: 'Bad Request' })\n }\n\n const revalidate = res.revalidate ?? res.unstable_revalidate\n\n if (typeof revalidate !== 'function') {\n const message =\n `Cannot revalidate path \"${req.query.path}\" because \\`revalidate\\` function does not exist in API handler response. ` +\n 'Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.\\n' +\n 'Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable'\n\n console.warn(message)\n\n return res.json({ revalidated: false })\n }\n\n try {\n await revalidate(req.query.path)\n\n return res.json({ revalidated: true })\n } catch (error) {\n return res.status(500).json({ message: 'Error Revalidating' })\n }\n }\n\n case 'proxy-preview-mode': {\n if (req.query.secret !== apiKey) return res.status(401).send('Unauthorized')\n\n const host = req.headers.host\n\n if (host == null) return res.status(400).send('Bad Request')\n\n const forwardedProto = req.headers['x-forwarded-proto']\n\n const proto = typeof forwardedProto === 'string' ? forwardedProto : 'http'\n let target = `${proto}://${host}`\n\n // During local development we want to use the local Next.js address for proxying. The\n // reason we want to do this is that the user might be using a local SSL proxy to deal with\n // mixed content browser limitations. If the user generates a locally-trusted CA for their\n // SSL cert, it's likely that Node.js won't trust this CA unless they used the\n // `NODE_EXTRA_CA_CERTS` option (see https://stackoverflow.com/a/68135600). To provide a\n // better developer experience, instead of requiring the user to provide the CA to Node.js,\n // we just proxy directly to the running Next.js process.\n if (process.env['NODE_ENV'] !== 'production') {\n const port = req.socket.localPort\n\n if (port != null) target = `http://localhost:${port}`\n }\n\n const setCookie = res.setPreviewData({ makeswift: true }).getHeader('Set-Cookie')\n res.removeHeader('Set-Cookie')\n\n if (!Array.isArray(setCookie)) return res.status(500).send('Internal Server Error')\n\n const cookie = parse(setCookie)\n .map(cookie => serialize(cookie.name, cookie.value, cookie as CookieSerializeOptions))\n .join(';')\n\n return await new Promise<void>((resolve, reject) =>\n previewModeProxy.web(req, res, { target, headers: { cookie } }, err => {\n if (err) reject(err)\n else resolve()\n }),\n )\n }\n\n case 'fonts': {\n const fonts = (await getFonts?.()) ?? []\n return res.json(fonts)\n }\n\n default:\n return res.status(404).json({ message: 'Not Found' })\n }\n }\n}\n","import { useEffect, useState } from 'react'\n\nimport { RuntimeProvider } from '../runtimes/react'\nimport { Page as PageMeta } from '../components/page'\nimport { MakeswiftClient } from '../api/react'\nimport { MakeswiftPageSnapshot } from './client'\n\nexport { MakeswiftClient }\n\nexport type PageProps = {\n snapshot: MakeswiftPageSnapshot\n}\n\nimport {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport { Makeswift } from './client'\nimport { MakeswiftPreviewData } from './preview-mode'\n\nfunction getApiOrigin(): string {\n const apiOriginString = process['env'].MAKESWIFT_API_HOST ?? 'https://api.makeswift.com'\n\n try {\n const url = new URL(apiOriginString)\n\n return url.origin\n } catch (error) {\n const errorMessage =\n '\"MAKESWIFT_API_HOST\" environment variable must be a valid URL. ' +\n `Expected something like \"https://api.makeswift.com\" but instead received \"${apiOriginString}\".`\n\n throw new Error(errorMessage)\n }\n}\n\nconst uuidRegExp =\n /^[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}$/\n\nfunction getApiKey(): string {\n const apiKey = process['env'].MAKESWIFT_SITE_API_KEY\n\n if (apiKey == null) {\n const errorMessage =\n '\"MAKESWIFT_SITE_API_KEY\" environment variable must be set. ' +\n 'Please add your site API key to your `.env.local` file. ' +\n 'More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables'\n\n throw new Error(errorMessage)\n }\n\n if (!uuidRegExp.test(apiKey)) {\n const errorMEssage =\n `Invalid Makeswift site API key \"${apiKey}\". ` +\n 'Please check your `.env.local` file for the \"MAKESWIFT_SITE_API_KEY\" environment variable. ' +\n 'More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables'\n\n throw new Error(errorMEssage)\n }\n\n return apiKey\n}\n\ntype ParsedUrlQuery = { path?: string[] }\n\nfunction deprecationWarning(methodName: string): void {\n const warningMessage =\n `The \\`${methodName}\\` export has been deprecated and will be removed in the next minor version. ` +\n 'More info: https://github.com/makeswift/makeswift/releases/tag/%40makeswift%2Fruntime%400.2.0'\n\n if (process.env['NODE_ENV'] !== 'production') console.warn(warningMessage)\n}\n\nexport async function getStaticPaths(): Promise<GetStaticPathsResult<ParsedUrlQuery>> {\n deprecationWarning('getStaticPaths')\n\n const makeswift = new Makeswift(getApiKey(), { apiOrigin: getApiOrigin() })\n const pages = await makeswift.getPages()\n\n return {\n paths: pages.map(page => ({\n params: { path: page.path.split('/').filter(segment => segment !== '') },\n })),\n fallback: 'blocking',\n }\n}\n\nconst REVALIDATE_SECONDS = 1\n\nexport async function getStaticProps(\n ctx: GetStaticPropsContext<ParsedUrlQuery, MakeswiftPreviewData>,\n): Promise<GetStaticPropsResult<PageProps>> {\n deprecationWarning('getStaticProps')\n\n const makeswift = new Makeswift(getApiKey(), { apiOrigin: getApiOrigin() })\n const path = '/' + (ctx.params?.path ?? []).join('/')\n const snapshot = await makeswift.getPageSnapshot(path, {\n preview: ctx.previewData?.makeswift === true,\n })\n\n if (snapshot == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n\n return { props: { snapshot }, revalidate: REVALIDATE_SECONDS }\n}\n\nexport async function getServerSideProps(\n ctx: GetServerSidePropsContext<{ path?: string[] }>,\n): Promise<GetServerSidePropsResult<PageProps>> {\n deprecationWarning('getServerSideProps')\n\n const makeswift = new Makeswift(getApiKey(), { apiOrigin: getApiOrigin() })\n const path = '/' + (ctx.params?.path ?? []).join('/')\n const snapshot = await makeswift.getPageSnapshot(path, { preview: true })\n\n if (snapshot == null) return { notFound: true }\n\n return { props: { snapshot } }\n}\n\nexport function Page({ snapshot }: PageProps) {\n const [client] = useState(\n () =>\n new MakeswiftClient({\n uri: new URL('graphql', snapshot.apiOrigin).href,\n cacheData: snapshot.cacheData,\n }),\n )\n\n useEffect(() => {\n client.updateCacheData(snapshot.cacheData)\n }, [client, snapshot])\n\n return (\n <RuntimeProvider\n client={client}\n rootElements={new Map([[snapshot.document.id, snapshot.document.data]])}\n >\n <PageMeta document={snapshot.document} />\n </RuntimeProvider>\n )\n}\n\nexport * from './client'\nexport * from './preview-mode'\nexport * from './document'\nexport * from './api-handler'\nexport * from './dynamic'\n"],"names":["isPreview","appOrigin","__html","replace","Document","NextDocument","getInitialProps","ctx","sheet","ServerStyleSheet","originalRenderPage","renderPage","enhanceApp","App","props","collectStyles","initialProps","KeyUtils","resetGenerator","extractCritical","createEmotionServer","cache","ids","css","html","styles","_Fragment","getStyleElement","join","seal","render","__NEXT_DATA__","_jsx","_jsxs","apiOriginString","process","MAKESWIFT_API_HOST","url","URL","origin","error","errorMessage","Error","uuidRegExp","apiKey","MAKESWIFT_SITE_API_KEY","test","errorMEssage","methodName","warningMessage","env","console","warn","deprecationWarning","makeswift","Makeswift","getApiKey","apiOrigin","getApiOrigin","pages","getPages","paths","map","page","params","path","split","filter","segment","fallback","REVALIDATE_SECONDS","snapshot","getPageSnapshot","preview","previewData","notFound","revalidate","client","useState","MakeswiftClient","uri","href","cacheData","useEffect","updateCacheData","Map","document","id","data","PageMeta"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDO,MAAM,UAAU;AAAA,EAIrB,YAAY,QAAgB,EAAE,YAAY,gCAAiD,CAAA,GAAI;AAHvF;AACA;AAGF,QAAA,OAAO,WAAW,UAAU;AAC9B,YAAM,IAAI,MACR;AAAA,YAEe,kBACjB;AAAA,IACF;AAEA,SAAK,SAAS;AAEV,QAAA;AACG,WAAA,YAAY,IAAI,IAAI,SAAS;AAAA,IAAA,QAClC;AACM,YAAA,IAAI,MACR,sEAAsE,aACxE;AAAA,IACF;AAAA,EACF;AAAA,QAEc,MAAM,MAAc,MAAuC;AACjE,UAAA,WAAW,MAAM,MAAM,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,YAAY,iCAClE,OADkE;AAAA,MAErE,SAAS,iCAAK,6BAAM,UAAX,GAAqB,cAAc,KAAK,OAAO;AAAA,IAAA,EACzD;AAEM,WAAA;AAAA,EACT;AAAA,QAEM,SAAS,SA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AAM;AAAA,IAAEQ,SAAS;AAAA,EAAA,CAA3C;AAEvB,MAAIF,YAAY;AAAa,WAAA;AAAA,MAAEI,UAAU;AAAA,IAAA;AAElC,SAAA;AAAA,IAAE7D,OAAO;AAAA,MAAEyD;AAAAA,IAAF;AAAA,EAAA;AACjB;AAEoB,cAAA;AAAA,EAAEA;AAAAA,GAAuB;AACtC,QAAA,CAACM,UAAUC,SACf,MACE,IAAIC,gBAAgB;AAAA,IAClBC,KAAK,IAAI1C,IAAI,WAAWiC,SAASd,SAA5B,EAAuCwB;AAAAA,IAC5CC,WAAWX,SAASW;AAAAA,EAFtB,CAAA,CAFqB;AAQzBC,YAAU,MAAM;AACPC,WAAAA,gBAAgBb,SAASW,SAAhC;AAAA,EAAA,GACC,CAACL,QAAQN,QAAT,CAFM;AAIT,6BACG,iBAAD;AAAA,IACE;AAAA,IACA,cAAc,oBAAIc,IAAI,CAAC,CAACd,SAASe,SAASC,IAAIhB,SAASe,SAASE,IAAzC,CAAD,CAAR;AAAA,IAFhB,8BAIGC,QAAD;AAAA,MAAU,UAAUlB,SAASe;AAAAA,IAAAA,CAA7B;AAAA,EAAA,CALJ;AAQD;;"}
|
|
1
|
+
{"version":3,"file":"next.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,7 +21,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21
21
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
22
22
|
var redux = require("redux");
|
|
23
23
|
var thunk = require("redux-thunk");
|
|
24
|
-
var
|
|
24
|
+
var next = require("./index.cjs.js");
|
|
25
25
|
var immutable = require("immutable");
|
|
26
26
|
var reactPage = require("./react-page.cjs.js");
|
|
27
27
|
var actions = require("./actions.cjs.js");
|
|
@@ -170,7 +170,7 @@ function measureElements() {
|
|
|
170
170
|
const changedDocumentBoxModels = /* @__PURE__ */ new Map();
|
|
171
171
|
measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {
|
|
172
172
|
const currentBoxModel = getBoxModel(getState(), documentKey, elementKey);
|
|
173
|
-
if (currentBoxModel == null || !
|
|
173
|
+
if (currentBoxModel == null || !next.deepEqual(currentBoxModel, measuredBoxModel)) {
|
|
174
174
|
changedDocumentBoxModels.set(elementKey, measuredBoxModel);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
@@ -247,7 +247,7 @@ function startMeasuringDocumentElement() {
|
|
|
247
247
|
};
|
|
248
248
|
function handleAnimationFrameRequest() {
|
|
249
249
|
const nextSize = getElementSize(window.document.documentElement);
|
|
250
|
-
if (!
|
|
250
|
+
if (!next.deepEqual(lastSize, nextSize)) {
|
|
251
251
|
lastSize = nextSize;
|
|
252
252
|
dispatch(actions.changeDocumentElementSize(nextSize));
|
|
253
253
|
}
|
|
@@ -272,7 +272,7 @@ function initialize() {
|
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
function measureBoxModelsMiddleware() {
|
|
275
|
-
return ({ dispatch }) => (
|
|
275
|
+
return ({ dispatch }) => (next2) => {
|
|
276
276
|
return (action) => {
|
|
277
277
|
switch (action.type) {
|
|
278
278
|
case actions.ActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
@@ -285,12 +285,12 @@ function measureBoxModelsMiddleware() {
|
|
|
285
285
|
dispatch(actions.unregisterMeasurable(action.payload.documentKey, action.payload.elementKey));
|
|
286
286
|
break;
|
|
287
287
|
}
|
|
288
|
-
return
|
|
288
|
+
return next2(action);
|
|
289
289
|
};
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
292
|
function messageChannelMiddleware() {
|
|
293
|
-
return ({ dispatch, getState }) => (
|
|
293
|
+
return ({ dispatch, getState }) => (next2) => {
|
|
294
294
|
const messageChannel = new MessageChannel();
|
|
295
295
|
let cleanUp = () => {
|
|
296
296
|
};
|
|
@@ -337,7 +337,7 @@ function messageChannelMiddleware() {
|
|
|
337
337
|
cleanUp();
|
|
338
338
|
break;
|
|
339
339
|
}
|
|
340
|
-
return
|
|
340
|
+
return next2(action);
|
|
341
341
|
};
|
|
342
342
|
};
|
|
343
343
|
}
|
|
@@ -355,7 +355,7 @@ function createAndRegisterPropControllers(documentKey, elementKey) {
|
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
function propControllerHandlesMiddleware() {
|
|
358
|
-
return ({ dispatch, getState }) => (
|
|
358
|
+
return ({ dispatch, getState }) => (next2) => {
|
|
359
359
|
return (action) => {
|
|
360
360
|
switch (action.type) {
|
|
361
361
|
case actions.ActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
@@ -381,12 +381,12 @@ function propControllerHandlesMiddleware() {
|
|
|
381
381
|
propController.recv(action.payload.message);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
return
|
|
384
|
+
return next2(action);
|
|
385
385
|
};
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
388
|
function apolloClientCacheSyncMiddleware(client) {
|
|
389
|
-
return () => (
|
|
389
|
+
return () => (next2) => {
|
|
390
390
|
return (action) => {
|
|
391
391
|
switch (action.type) {
|
|
392
392
|
case actions.ActionTypes.CHANGE_API_RESOURCE: {
|
|
@@ -402,7 +402,7 @@ function apolloClientCacheSyncMiddleware(client) {
|
|
|
402
402
|
client.cache.evict({ id: action.payload.id });
|
|
403
403
|
break;
|
|
404
404
|
}
|
|
405
|
-
return
|
|
405
|
+
return next2(action);
|
|
406
406
|
};
|
|
407
407
|
};
|
|
408
408
|
}
|