@makeswift/runtime 0.0.13 → 0.0.17
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/builder.cjs.js +1 -1
- package/dist/builder.es.js +1 -1
- package/dist/components.cjs.js +4 -3
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +4 -3
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +43 -3
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +41 -1
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +7 -5
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -2
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/index.cjs.js +82 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +46 -22
- package/dist/index.es.js.map +1 -1
- package/dist/next.cjs.js +16 -24
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +18 -26
- package/dist/next.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +4 -3
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +5 -4
- package/dist/react-builder-preview.es.js.map +1 -1
- package/dist/react.cjs.js +4 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +4 -3
- package/dist/react.es.js.map +1 -1
- package/dist/shape.cjs.js +20 -0
- package/dist/shape.cjs.js.map +1 -0
- package/dist/shape.es.js +14 -0
- package/dist/shape.es.js.map +1 -0
- package/dist/text-input.cjs.js +0 -6
- package/dist/text-input.cjs.js.map +1 -1
- package/dist/text-input.es.js +1 -5
- package/dist/text-input.es.js.map +1 -1
- package/dist/types/api/react.d.ts +3 -2
- package/dist/types/api/react.d.ts.map +1 -1
- package/dist/types/builder/serialization/control-serialization.d.ts +3 -3
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/builder/serialization/controls/combobox.d.ts +5 -0
- package/dist/types/builder/serialization/controls/combobox.d.ts.map +1 -0
- package/dist/types/builder/serialization/controls/shape.d.ts +5 -0
- package/dist/types/builder/serialization/controls/shape.d.ts.map +1 -0
- package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/controls/combobox.d.ts +22 -0
- package/dist/types/controls/combobox.d.ts.map +1 -0
- package/dist/types/controls/control.d.ts +3 -2
- package/dist/types/controls/control.d.ts.map +1 -1
- package/dist/types/controls/index.d.ts +1 -0
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/types.d.ts +3 -0
- package/dist/types/controls/types.d.ts.map +1 -1
- package/dist/types/next.d.ts +4 -8
- package/dist/types/next.d.ts.map +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts +4 -3
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/combobox.d.ts +4 -0
- package/dist/types/runtimes/react/controls/combobox.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/list.cjs.js +0 -8
- package/dist/list.cjs.js.map +0 -1
- package/dist/list.es.js +0 -6
- package/dist/list.es.js.map +0 -1
package/dist/next.cjs.js
CHANGED
|
@@ -26,7 +26,6 @@ var slate = require("slate");
|
|
|
26
26
|
var createEmotionServer = require("@emotion/server/create-instance");
|
|
27
27
|
var css = require("@emotion/css");
|
|
28
28
|
var index = require("./index.cjs.js");
|
|
29
|
-
var ssr = require("@apollo/client/react/ssr");
|
|
30
29
|
var jsxRuntime = require("react/jsx-runtime");
|
|
31
30
|
require("use-sync-external-store/shim/with-selector");
|
|
32
31
|
require("@apollo/client");
|
|
@@ -37,6 +36,8 @@ require("./actions.cjs.js");
|
|
|
37
36
|
require("./descriptors.cjs.js");
|
|
38
37
|
require("./style.cjs.js");
|
|
39
38
|
require("framer-motion");
|
|
39
|
+
require("@apollo/client/react/ssr");
|
|
40
|
+
require("uuid/v4");
|
|
40
41
|
require("html-react-parser");
|
|
41
42
|
require("next/head");
|
|
42
43
|
require("color");
|
|
@@ -44,7 +45,6 @@ require("scroll-into-view-if-needed");
|
|
|
44
45
|
require("next/link");
|
|
45
46
|
require("react-use-gesture");
|
|
46
47
|
require("@popmotion/popcorn");
|
|
47
|
-
require("uuid/v4");
|
|
48
48
|
require("next/image");
|
|
49
49
|
require("formik");
|
|
50
50
|
require("./box-models.cjs.js");
|
|
@@ -57,7 +57,7 @@ require("is-hotkey");
|
|
|
57
57
|
require("slate-react");
|
|
58
58
|
require("@convertkit/slate-lists");
|
|
59
59
|
require("./text-input.cjs.js");
|
|
60
|
-
require("./
|
|
60
|
+
require("./shape.cjs.js");
|
|
61
61
|
require("react-dom");
|
|
62
62
|
function _interopDefaultLegacy(e) {
|
|
63
63
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -65,31 +65,15 @@ function _interopDefaultLegacy(e) {
|
|
|
65
65
|
var NextDocument__default = /* @__PURE__ */ _interopDefaultLegacy(NextDocument);
|
|
66
66
|
var createEmotionServer__default = /* @__PURE__ */ _interopDefaultLegacy(createEmotionServer);
|
|
67
67
|
class Document extends NextDocument__default["default"] {
|
|
68
|
-
constructor(props) {
|
|
69
|
-
super(props);
|
|
70
|
-
const {
|
|
71
|
-
__NEXT_DATA__,
|
|
72
|
-
cacheData
|
|
73
|
-
} = props;
|
|
74
|
-
__NEXT_DATA__.props.pageProps.cacheData = cacheData;
|
|
75
|
-
}
|
|
76
68
|
static async getInitialProps(ctx) {
|
|
77
69
|
const sheet = new styled.ServerStyleSheet();
|
|
78
70
|
const originalRenderPage = ctx.renderPage;
|
|
79
|
-
let appProps;
|
|
80
71
|
try {
|
|
81
72
|
ctx.renderPage = () => originalRenderPage({
|
|
82
|
-
enhanceApp: (App) => (props) => {
|
|
83
|
-
if (appProps == null)
|
|
84
|
-
appProps = props;
|
|
85
|
-
return sheet.collectStyles(/* @__PURE__ */ jsxRuntime.jsx(App, __spreadValues({}, props)));
|
|
86
|
-
}
|
|
73
|
+
enhanceApp: (App) => (props) => sheet.collectStyles(/* @__PURE__ */ jsxRuntime.jsx(App, __spreadValues({}, props)))
|
|
87
74
|
});
|
|
88
|
-
index.garbageCollectGlobalCacheData();
|
|
89
|
-
await ctx.renderPage();
|
|
90
|
-
await ssr.getDataFromTree(/* @__PURE__ */ jsxRuntime.jsx(ctx.AppTree, __spreadValues({}, appProps)));
|
|
91
|
-
slate.KeyUtils.resetGenerator();
|
|
92
75
|
const initialProps = await NextDocument__default["default"].getInitialProps(ctx);
|
|
76
|
+
slate.KeyUtils.resetGenerator();
|
|
93
77
|
const {
|
|
94
78
|
extractCritical
|
|
95
79
|
} = createEmotionServer__default["default"](css.cache);
|
|
@@ -98,7 +82,6 @@ class Document extends NextDocument__default["default"] {
|
|
|
98
82
|
css: css$1
|
|
99
83
|
} = extractCritical(initialProps.html);
|
|
100
84
|
return __spreadProps(__spreadValues({}, initialProps), {
|
|
101
|
-
cacheData: index.getGlobalCacheData(),
|
|
102
85
|
styles: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
103
86
|
children: [initialProps.styles, sheet.getStyleElement(), /* @__PURE__ */ jsxRuntime.jsx("style", {
|
|
104
87
|
"data-emotion": `css ${ids.join(" ")}`,
|
|
@@ -137,11 +120,16 @@ async function getServerSideProps({
|
|
|
137
120
|
notFound: true
|
|
138
121
|
};
|
|
139
122
|
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
123
|
+
const client = new index.MakeswiftClient({
|
|
124
|
+
uri: makeswiftApiEndpoint
|
|
125
|
+
});
|
|
126
|
+
const cacheData = await client.prefetch(page.data);
|
|
140
127
|
return {
|
|
141
128
|
props: {
|
|
142
129
|
page,
|
|
143
130
|
rootElement: page.data,
|
|
144
131
|
makeswiftApiEndpoint,
|
|
132
|
+
cacheData,
|
|
145
133
|
preview: true
|
|
146
134
|
}
|
|
147
135
|
};
|
|
@@ -177,11 +165,16 @@ async function getStaticProps({
|
|
|
177
165
|
revalidate: REVALIDATE_SECONDS
|
|
178
166
|
};
|
|
179
167
|
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
168
|
+
const client = new index.MakeswiftClient({
|
|
169
|
+
uri: makeswiftApiEndpoint
|
|
170
|
+
});
|
|
171
|
+
const cacheData = await client.prefetch(page.data);
|
|
180
172
|
return {
|
|
181
173
|
props: {
|
|
182
174
|
page,
|
|
183
175
|
rootElement: page.data,
|
|
184
176
|
makeswiftApiEndpoint,
|
|
177
|
+
cacheData,
|
|
185
178
|
preview: false
|
|
186
179
|
},
|
|
187
180
|
revalidate: REVALIDATE_SECONDS
|
|
@@ -205,8 +198,7 @@ function Page({
|
|
|
205
198
|
cacheData
|
|
206
199
|
}));
|
|
207
200
|
React.useEffect(() => {
|
|
208
|
-
|
|
209
|
-
client.updateCacheData(cacheData);
|
|
201
|
+
client.updateCacheData(cacheData);
|
|
210
202
|
}, [client, cacheData]);
|
|
211
203
|
return /* @__PURE__ */ jsxRuntime.jsx(index.RuntimeProvider, {
|
|
212
204
|
client,
|
package/dist/next.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.cjs.js","sources":["../src/next.tsx"],"sourcesContent":["import {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps
|
|
1
|
+
{"version":3,"file":"next.cjs.js","sources":["../src/next.tsx"],"sourcesContent":["import { NormalizedCacheObject } from '@apollo/client'\nimport {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { useEffect, useState } from 'react'\nimport { ServerStyleSheet } from 'styled-components'\nimport { KeyUtils } from 'slate'\nimport createEmotionServer from '@emotion/server/create-instance'\nimport { cache } from '@emotion/css'\n\nimport { MakeswiftClient } from './api/react'\nimport { Element } from './state/react-page'\nimport { RuntimeProvider } from './runtimes/react'\nimport { Page as PageMeta, PageData } from './components'\n\nexport { MakeswiftClient }\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\nconst REVALIDATE_SECONDS = 1\n\nexport type PageProps = {\n page: PageData\n rootElement: Element\n makeswiftApiEndpoint: string\n cacheData: NormalizedCacheObject\n preview: boolean\n}\n\ntype APIResult = PageData & {\n data: any\n}\n\nexport async function getServerSideProps({\n query: { pageId },\n}: GetServerSidePropsContext): Promise<GetServerSidePropsResult<PageProps>> {\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/preview-page-data?id=${pageId}`\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n preview: true,\n },\n }\n}\n\nexport async function getStaticProps({\n params,\n}: GetStaticPropsContext<{ path: string[] }>): Promise<GetStaticPropsResult<PageProps>> {\n if (params == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n const { path = [] } = params\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/live-page-data?path=${path.join('/')}`\n\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true, revalidate: REVALIDATE_SECONDS }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n preview: false,\n },\n revalidate: REVALIDATE_SECONDS,\n }\n}\n\nexport async function getStaticPaths(): Promise<GetStaticPathsResult> {\n return { paths: [], fallback: 'blocking' }\n}\n\nexport function Page({ page, rootElement, makeswiftApiEndpoint, cacheData, preview }: PageProps) {\n const [client] = useState(() => new MakeswiftClient({ uri: makeswiftApiEndpoint, cacheData }))\n\n useEffect(() => {\n client.updateCacheData(cacheData)\n }, [client, cacheData])\n\n return (\n <RuntimeProvider client={client} rootElements={new Map([[page.id, rootElement]])}>\n <PageMeta page={page} preview={preview} />\n </RuntimeProvider>\n )\n}\n"],"names":["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","__html","seal","REVALIDATE_SECONDS","query","pageId","url","process","MAKESWIFT_API_HOST","res","fetch","headers","MAKESWIFT_SITE_API_KEY","status","console","error","json","notFound","page","makeswiftApiEndpoint","client","MakeswiftClient","uri","cacheData","prefetch","data","rootElement","preview","params","revalidate","path","paths","fallback","useState","useEffect","updateCacheData","RuntimeProvider","Map","id","PageMeta"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAMA,iBAAiBC,sBAAAA,WAAa;AAAA,eAC5BC,gBAAgBC,KAAqD;AAC1EC,UAAAA,QAAQ,IAAIC,OAAAA;AAClB,UAAMC,qBAAqBH,IAAII;AAE3B,QAAA;AACEA,UAAAA,aAAa,MACfD,mBAAmB;AAAA,QACjBE,YAAYC,CAAOC,QAAAA,CAAAA,UAASN,MAAMO,6CAAe,KAAQD,mBAAAA,MAA7B,CAAA;AAAA,MAAA,CADZ;AAIdE,YAAAA,eAAe,MAAMX,sBAAAA,WAAaC,gBAAgBC,GAA7B;AAE3BU,YAAAA,SAASC,eAAT;AAEM,YAAA;AAAA,QAAEC;AAAAA,UAAoBC,6BAAAA,WAAoBC,IAAAA,KAAD;AACzC,YAAA;AAAA,QAAEC;AAAAA,QAAAA,KAAKC;AAAAA,UAAQJ,gBAAgBH,aAAaQ,IAAd;AAE7B,aAAA,iCACFR,eADE;AAAA,QAELS,wCACEC,qBAAA;AAAA,UACGV,UAAAA,CAAAA,aAAaS,QACbjB,MAAMmB,kDACP,SAAA;AAAA,YACE,gBAAe,OAAML,IAAIM,KAAK,GAAT;AAAA,YACrB,yBAAyB;AAAA,cAAEC,QAAQN;AAAAA,YAAV;AAAA,UAAA,CAL7B,CAAA;AAAA,QAAA,CAAA;AAAA,MAAA;AAAA,IAHJ,UAaQ;AACRf,YAAMsB,KAAN;AA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AY;AAAA,IAAA,CAAtB;AAAA,EAAA,CAFJ;AAKD;;;;;;;"}
|
package/dist/next.es.js
CHANGED
|
@@ -23,9 +23,8 @@ import { ServerStyleSheet } from "styled-components";
|
|
|
23
23
|
import { KeyUtils } from "slate";
|
|
24
24
|
import createEmotionServer from "@emotion/server/create-instance";
|
|
25
25
|
import { cache } from "@emotion/css";
|
|
26
|
-
import { W as
|
|
27
|
-
export {
|
|
28
|
-
import { getDataFromTree } from "@apollo/client/react/ssr";
|
|
26
|
+
import { W as MakeswiftClient, R as RuntimeProvider, V as Page$1 } from "./index.es.js";
|
|
27
|
+
export { W as MakeswiftClient } from "./index.es.js";
|
|
29
28
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
30
29
|
import "use-sync-external-store/shim/with-selector";
|
|
31
30
|
import "@apollo/client";
|
|
@@ -36,6 +35,8 @@ import "./actions.es.js";
|
|
|
36
35
|
import "./descriptors.es.js";
|
|
37
36
|
import "./style.es.js";
|
|
38
37
|
import "framer-motion";
|
|
38
|
+
import "@apollo/client/react/ssr";
|
|
39
|
+
import "uuid/v4";
|
|
39
40
|
import "html-react-parser";
|
|
40
41
|
import "next/head";
|
|
41
42
|
import "color";
|
|
@@ -43,7 +44,6 @@ import "scroll-into-view-if-needed";
|
|
|
43
44
|
import "next/link";
|
|
44
45
|
import "react-use-gesture";
|
|
45
46
|
import "@popmotion/popcorn";
|
|
46
|
-
import "uuid/v4";
|
|
47
47
|
import "next/image";
|
|
48
48
|
import "formik";
|
|
49
49
|
import "./box-models.es.js";
|
|
@@ -56,34 +56,18 @@ import "is-hotkey";
|
|
|
56
56
|
import "slate-react";
|
|
57
57
|
import "@convertkit/slate-lists";
|
|
58
58
|
import "./text-input.es.js";
|
|
59
|
-
import "./
|
|
59
|
+
import "./shape.es.js";
|
|
60
60
|
import "react-dom";
|
|
61
61
|
class Document extends NextDocument {
|
|
62
|
-
constructor(props) {
|
|
63
|
-
super(props);
|
|
64
|
-
const {
|
|
65
|
-
__NEXT_DATA__,
|
|
66
|
-
cacheData
|
|
67
|
-
} = props;
|
|
68
|
-
__NEXT_DATA__.props.pageProps.cacheData = cacheData;
|
|
69
|
-
}
|
|
70
62
|
static async getInitialProps(ctx) {
|
|
71
63
|
const sheet = new ServerStyleSheet();
|
|
72
64
|
const originalRenderPage = ctx.renderPage;
|
|
73
|
-
let appProps;
|
|
74
65
|
try {
|
|
75
66
|
ctx.renderPage = () => originalRenderPage({
|
|
76
|
-
enhanceApp: (App) => (props) => {
|
|
77
|
-
if (appProps == null)
|
|
78
|
-
appProps = props;
|
|
79
|
-
return sheet.collectStyles(/* @__PURE__ */ jsx(App, __spreadValues({}, props)));
|
|
80
|
-
}
|
|
67
|
+
enhanceApp: (App) => (props) => sheet.collectStyles(/* @__PURE__ */ jsx(App, __spreadValues({}, props)))
|
|
81
68
|
});
|
|
82
|
-
garbageCollectGlobalCacheData();
|
|
83
|
-
await ctx.renderPage();
|
|
84
|
-
await getDataFromTree(/* @__PURE__ */ jsx(ctx.AppTree, __spreadValues({}, appProps)));
|
|
85
|
-
KeyUtils.resetGenerator();
|
|
86
69
|
const initialProps = await NextDocument.getInitialProps(ctx);
|
|
70
|
+
KeyUtils.resetGenerator();
|
|
87
71
|
const {
|
|
88
72
|
extractCritical
|
|
89
73
|
} = createEmotionServer(cache);
|
|
@@ -92,7 +76,6 @@ class Document extends NextDocument {
|
|
|
92
76
|
css
|
|
93
77
|
} = extractCritical(initialProps.html);
|
|
94
78
|
return __spreadProps(__spreadValues({}, initialProps), {
|
|
95
|
-
cacheData: getGlobalCacheData(),
|
|
96
79
|
styles: /* @__PURE__ */ jsxs(Fragment, {
|
|
97
80
|
children: [initialProps.styles, sheet.getStyleElement(), /* @__PURE__ */ jsx("style", {
|
|
98
81
|
"data-emotion": `css ${ids.join(" ")}`,
|
|
@@ -131,11 +114,16 @@ async function getServerSideProps({
|
|
|
131
114
|
notFound: true
|
|
132
115
|
};
|
|
133
116
|
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
117
|
+
const client = new MakeswiftClient({
|
|
118
|
+
uri: makeswiftApiEndpoint
|
|
119
|
+
});
|
|
120
|
+
const cacheData = await client.prefetch(page.data);
|
|
134
121
|
return {
|
|
135
122
|
props: {
|
|
136
123
|
page,
|
|
137
124
|
rootElement: page.data,
|
|
138
125
|
makeswiftApiEndpoint,
|
|
126
|
+
cacheData,
|
|
139
127
|
preview: true
|
|
140
128
|
}
|
|
141
129
|
};
|
|
@@ -171,11 +159,16 @@ async function getStaticProps({
|
|
|
171
159
|
revalidate: REVALIDATE_SECONDS
|
|
172
160
|
};
|
|
173
161
|
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
162
|
+
const client = new MakeswiftClient({
|
|
163
|
+
uri: makeswiftApiEndpoint
|
|
164
|
+
});
|
|
165
|
+
const cacheData = await client.prefetch(page.data);
|
|
174
166
|
return {
|
|
175
167
|
props: {
|
|
176
168
|
page,
|
|
177
169
|
rootElement: page.data,
|
|
178
170
|
makeswiftApiEndpoint,
|
|
171
|
+
cacheData,
|
|
179
172
|
preview: false
|
|
180
173
|
},
|
|
181
174
|
revalidate: REVALIDATE_SECONDS
|
|
@@ -199,8 +192,7 @@ function Page({
|
|
|
199
192
|
cacheData
|
|
200
193
|
}));
|
|
201
194
|
useEffect(() => {
|
|
202
|
-
|
|
203
|
-
client.updateCacheData(cacheData);
|
|
195
|
+
client.updateCacheData(cacheData);
|
|
204
196
|
}, [client, cacheData]);
|
|
205
197
|
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
206
198
|
client,
|
package/dist/next.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.es.js","sources":["../src/next.tsx"],"sourcesContent":["import {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps
|
|
1
|
+
{"version":3,"file":"next.es.js","sources":["../src/next.tsx"],"sourcesContent":["import { NormalizedCacheObject } from '@apollo/client'\nimport {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { useEffect, useState } from 'react'\nimport { ServerStyleSheet } from 'styled-components'\nimport { KeyUtils } from 'slate'\nimport createEmotionServer from '@emotion/server/create-instance'\nimport { cache } from '@emotion/css'\n\nimport { MakeswiftClient } from './api/react'\nimport { Element } from './state/react-page'\nimport { RuntimeProvider } from './runtimes/react'\nimport { Page as PageMeta, PageData } from './components'\n\nexport { MakeswiftClient }\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\nconst REVALIDATE_SECONDS = 1\n\nexport type PageProps = {\n page: PageData\n rootElement: Element\n makeswiftApiEndpoint: string\n cacheData: NormalizedCacheObject\n preview: boolean\n}\n\ntype APIResult = PageData & {\n data: any\n}\n\nexport async function getServerSideProps({\n query: { pageId },\n}: GetServerSidePropsContext): Promise<GetServerSidePropsResult<PageProps>> {\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/preview-page-data?id=${pageId}`\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n preview: true,\n },\n }\n}\n\nexport async function getStaticProps({\n params,\n}: GetStaticPropsContext<{ path: string[] }>): Promise<GetStaticPropsResult<PageProps>> {\n if (params == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n const { path = [] } = params\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/live-page-data?path=${path.join('/')}`\n\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true, revalidate: REVALIDATE_SECONDS }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n preview: false,\n },\n revalidate: REVALIDATE_SECONDS,\n }\n}\n\nexport async function getStaticPaths(): Promise<GetStaticPathsResult> {\n return { paths: [], fallback: 'blocking' }\n}\n\nexport function Page({ page, rootElement, makeswiftApiEndpoint, cacheData, preview }: PageProps) {\n const [client] = useState(() => new MakeswiftClient({ uri: makeswiftApiEndpoint, cacheData }))\n\n useEffect(() => {\n client.updateCacheData(cacheData)\n }, [client, cacheData])\n\n return (\n <RuntimeProvider client={client} rootElements={new Map([[page.id, rootElement]])}>\n <PageMeta page={page} preview={preview} />\n </RuntimeProvider>\n )\n}\n"],"names":["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","__html","seal","REVALIDATE_SECONDS","query","pageId","url","process","MAKESWIFT_API_HOST","res","fetch","headers","MAKESWIFT_SITE_API_KEY","status","console","error","json","notFound","page","makeswiftApiEndpoint","client","MakeswiftClient","uri","cacheData","prefetch","data","rootElement","preview","params","revalidate","path","paths","fallback","useState","useEffect","updateCacheData","Map","id","PageMeta"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAMA,iBAAiBC,aAAa;AAAA,eAC5BC,gBAAgBC,KAAqD;AAC1EC,UAAAA,QAAQ,IAAIC;AAClB,UAAMC,qBAAqBH,IAAII;AAE3B,QAAA;AACEA,UAAAA,aAAa,MACfD,mBAAmB;AAAA,QACjBE,YAAYC,CAAOC,QAAAA,CAAAA,UAASN,MAAMO,kCAAe,KAAQD,mBAAAA,MAA7B,CAAA;AAAA,MAAA,CADZ;AAIdE,YAAAA,eAAe,MAAMX,aAAaC,gBAAgBC,GAA7B;AAE3BU,eAASC,eAAT;AAEM,YAAA;AAAA,QAAEC;AAAAA,UAAoBC,oBAAoBC,KAAD;AACzC,YAAA;AAAA,QAAEC;AAAAA,QAAKC;AAAAA,UAAQJ,gBAAgBH,aAAaQ,IAAd;AAE7B,aAAA,iCACFR,eADE;AAAA,QAELS,6BACEC,UAAA;AAAA,UACGV,UAAAA,CAAAA,aAAaS,QACbjB,MAAMmB,uCACP,SAAA;AAAA,YACE,gBAAe,OAAML,IAAIM,KAAK,GAAT;AAAA,YACrB,yBAAyB;AAAA,cAAEC,QAAQN;AAAAA,YAAV;AAAA,UAAA,CAL7B,CAAA;AAAA,QAAA,CAAA;AAAA,MAAA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AAAA,MAAU;AAAA,MAAY;AAAA,IAAA,CAAtB;AAAA,EAAA,CAFJ;AAKD;;"}
|
|
@@ -35,6 +35,9 @@ require("@apollo/client");
|
|
|
35
35
|
require("styled-components");
|
|
36
36
|
require("framer-motion");
|
|
37
37
|
require("@emotion/css");
|
|
38
|
+
require("@apollo/client/react/ssr");
|
|
39
|
+
require("slate");
|
|
40
|
+
require("uuid/v4");
|
|
38
41
|
require("react/jsx-runtime");
|
|
39
42
|
require("html-react-parser");
|
|
40
43
|
require("next/head");
|
|
@@ -45,19 +48,17 @@ require("scroll-into-view-if-needed");
|
|
|
45
48
|
require("next/link");
|
|
46
49
|
require("react-use-gesture");
|
|
47
50
|
require("@popmotion/popcorn");
|
|
48
|
-
require("uuid/v4");
|
|
49
51
|
require("next/image");
|
|
50
52
|
require("formik");
|
|
51
53
|
require("polished");
|
|
52
54
|
require("react-player");
|
|
53
|
-
require("slate");
|
|
54
55
|
require("slate-hotkeys");
|
|
55
56
|
require("corporate-ipsum");
|
|
56
57
|
require("is-hotkey");
|
|
57
58
|
require("slate-react");
|
|
58
59
|
require("@convertkit/slate-lists");
|
|
59
60
|
require("./text-input.cjs.js");
|
|
60
|
-
require("./
|
|
61
|
+
require("./shape.cjs.js");
|
|
61
62
|
require("react-dom");
|
|
62
63
|
require("css-box-model");
|
|
63
64
|
function _interopDefaultLegacy(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-builder-preview.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return state.instances.get(documentKey)?.get(elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { ApolloClient, NormalizedCacheObject } from '@apollo/client'\nimport { Fragments } from '../api'\nimport { serializeControls } from '../builder'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.addEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n const messageChannel = new MessageChannel()\n let cleanUp = () => {}\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction registerAndSetPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllerHandles.PropControllersHandle,\n): ThunkAction<void, State, unknown, Action> {\n return dispatch => {\n dispatch(registerPropControllersHandle(documentKey, elementKey, handle))\n\n const propControllers = dispatch(createAndRegisterPropControllers(documentKey, elementKey))\n\n handle.setPropControllers(propControllers)\n }\n}\n\nfunction unregisterAndUnsetPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const element = ReactPage.getElement(\n getState(),\n action.payload.documentKey,\n action.payload.elementKey,\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)\n ) {\n dispatch(\n registerAndSetPropControllersHandle(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(\n unregisterAndUnsetPropControllersHandle(\n action.payload.documentKey,\n action.payload.elementKey,\n ),\n )\n break\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction apolloClientCacheSyncMiddleware(\n client: ApolloClient<NormalizedCacheObject>,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource } = action.payload\n\n client.cache.writeFragment({\n id: client.cache.identify(resource),\n fragment: Fragments[resource.__typename],\n data: resource,\n })\n\n break\n }\n\n case ActionTypes.EVICT_API_RESOURCE:\n client.cache.evict({ id: action.payload.id })\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n preloadedState,\n client,\n}: {\n preloadedState?: PreloadedState<State>\n client: ApolloClient<NormalizedCacheObject>\n}): Store {\n return createStore(\n reducer,\n preloadedState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n apolloClientCacheSyncMiddleware(client),\n ),\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAUC,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAUA,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,2BAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOC,UAAkB,gBAAgB,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,aAAwD;AAChG,SAAOC,UAAkB,cAAY,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEwB,mBAAA,QAAeC,kBAAgB,GAAG,QAAuB;;AAC/E,QAAM,YAAYC,UAAAA,QAA0B,OAAO,MAAM;AAEzD,UAAQ,OAAO;AAAA,SACRC,QAAAA,YAAY,iBAAiB;AAChC,YAAM,qBAAqB,kBAAY,WAAW,OAAO,QAAQ,WAAW,MAAjD,mBAAoD;AAE/E,UAAI,sBAAsB;AAAa,eAAA;AAEvC,YAAM,kBAAkB,MAAM,oBAAoB,OAAO,QAAQ,SAAS;AAE1E,aAAO,uB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AS;AAAA,YAC7B,MAAM;AAAA,UAAA,CACP;AAED;AAAA,QACF;AAAA,aAEKtC,QAAY,YAAA;AACf,iBAAO,MAAM,MAAM,EAAE,IAAI,OAAO,QAAQ,IAAI;AAC5C;AAAA;AAGJ,aAAO,KAAK,MAAM;AAAA,IAAA;AAAA,EACpB;AAEJ;AAI+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,GAIQ;AACR,SAAOuC,MACL,YAAA,SACA,gBACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react-builder-preview.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return state.instances.get(documentKey)?.get(elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { ApolloClient, NormalizedCacheObject } from '@apollo/client'\nimport { Fragments } from '../api'\nimport { serializeControls } from '../builder'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.addEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n const messageChannel = new MessageChannel()\n let cleanUp = () => {}\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction registerAndSetPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllerHandles.PropControllersHandle,\n): ThunkAction<void, State, unknown, Action> {\n return dispatch => {\n dispatch(registerPropControllersHandle(documentKey, elementKey, handle))\n\n const propControllers = dispatch(createAndRegisterPropControllers(documentKey, elementKey))\n\n handle.setPropControllers(propControllers)\n }\n}\n\nfunction unregisterAndUnsetPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const element = ReactPage.getElement(\n getState(),\n action.payload.documentKey,\n action.payload.elementKey,\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)\n ) {\n dispatch(\n registerAndSetPropControllersHandle(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(\n unregisterAndUnsetPropControllersHandle(\n action.payload.documentKey,\n action.payload.elementKey,\n ),\n )\n break\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction apolloClientCacheSyncMiddleware(\n client: ApolloClient<NormalizedCacheObject>,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource } = action.payload\n\n client.cache.writeFragment({\n id: client.cache.identify(resource),\n fragment: Fragments[resource.__typename],\n data: resource,\n })\n\n break\n }\n\n case ActionTypes.EVICT_API_RESOURCE:\n client.cache.evict({ id: action.payload.id })\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n preloadedState,\n client,\n}: {\n preloadedState?: PreloadedState<State>\n client: ApolloClient<NormalizedCacheObject>\n}): Store {\n return createStore(\n reducer,\n preloadedState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n apolloClientCacheSyncMiddleware(client),\n ),\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAA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a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { combineReducers, createStore, applyMiddleware } from "redux";
|
|
21
21
|
import thunk from "redux-thunk";
|
|
22
|
-
import {
|
|
22
|
+
import { X as deepEqual } from "./index.es.js";
|
|
23
23
|
import { removeIn, setIn } from "immutable";
|
|
24
24
|
import { j as getInitialState$2, r as reducer$3, k as getDocument$1, c as createDocument, l as reducer$4, m as reducer$6, n as reducer$7, o as reducer$8, p as getComponentsMeta$1, q as getComponentPropControllerDescriptors$1, s as getElement, i as isElementReference, t as getElementPropControllerDescriptors } from "./react-page.es.js";
|
|
25
25
|
import { A as ActionTypes, l as changeElementBoxModels, n as changeDocumentElementSize, o as handleWheel, p as setIsInBuilder, q as registerBuilderComponent, t as unregisterBuilderComponent, v as unregisterMeasurable, w as registerMeasurable, x as unregisterPropControllers, y as registerPropControllersHandle, z as registerPropControllers, B as messageBuilderPropController } from "./actions.es.js";
|
|
@@ -34,6 +34,9 @@ import "@apollo/client";
|
|
|
34
34
|
import "styled-components";
|
|
35
35
|
import "framer-motion";
|
|
36
36
|
import "@emotion/css";
|
|
37
|
+
import "@apollo/client/react/ssr";
|
|
38
|
+
import "slate";
|
|
39
|
+
import "uuid/v4";
|
|
37
40
|
import "react/jsx-runtime";
|
|
38
41
|
import "html-react-parser";
|
|
39
42
|
import "next/head";
|
|
@@ -44,19 +47,17 @@ import "scroll-into-view-if-needed";
|
|
|
44
47
|
import "next/link";
|
|
45
48
|
import "react-use-gesture";
|
|
46
49
|
import "@popmotion/popcorn";
|
|
47
|
-
import "uuid/v4";
|
|
48
50
|
import "next/image";
|
|
49
51
|
import "formik";
|
|
50
52
|
import "polished";
|
|
51
53
|
import "react-player";
|
|
52
|
-
import "slate";
|
|
53
54
|
import "slate-hotkeys";
|
|
54
55
|
import "corporate-ipsum";
|
|
55
56
|
import "is-hotkey";
|
|
56
57
|
import "slate-react";
|
|
57
58
|
import "@convertkit/slate-lists";
|
|
58
59
|
import "./text-input.es.js";
|
|
59
|
-
import "./
|
|
60
|
+
import "./shape.es.js";
|
|
60
61
|
import "react-dom";
|
|
61
62
|
import "css-box-model";
|
|
62
63
|
function apply(data, operation) {
|