@makeswift/runtime 0.0.0-f5b044f → 0.0.1
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/controls.js +1 -0
- package/dist/Page.cjs.js +10 -3
- package/dist/Page.cjs.js.map +1 -1
- package/dist/Page.es.js +10 -3
- package/dist/Page.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +1 -0
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +1 -0
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +198 -0
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +198 -0
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +7 -0
- package/dist/controls.cjs.js.map +1 -0
- package/dist/controls.es.js +2 -0
- package/dist/controls.es.js.map +1 -0
- package/dist/descriptors.cjs.js +3 -1
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js +3 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/index.cjs.js +320 -153
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +313 -146
- package/dist/index.es.js.map +1 -1
- package/dist/main.cjs.js +1 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +1 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +1 -0
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +1 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +1 -0
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +1 -0
- package/dist/react-builder-preview.es.js.map +1 -1
- package/dist/react.cjs.js +1 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -0
- package/dist/react.es.js.map +1 -1
- package/dist/style.cjs.js +38 -0
- package/dist/style.cjs.js.map +1 -0
- package/dist/style.es.js +35 -0
- package/dist/style.es.js.map +1 -0
- package/dist/types/builder/serialization/control-serialization.d.ts +156 -3
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/components/builtin/Button/Button.d.ts +2 -1
- package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
- package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
- package/dist/types/components/builtin/Countdown/Countdown.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/Navigation.d.ts.map +1 -1
- package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts.map +1 -1
- package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
- package/dist/types/components/page/Page.d.ts +4 -0
- package/dist/types/components/page/Page.d.ts.map +1 -1
- package/dist/types/controls/index.d.ts +2 -0
- package/dist/types/controls/index.d.ts.map +1 -0
- package/dist/types/controls/style.d.ts +141 -0
- package/dist/types/controls/style.d.ts.map +1 -0
- package/dist/types/controls/types.d.ts +11 -0
- package/dist/types/controls/types.d.ts.map +1 -0
- package/dist/types/prop-controllers/descriptors.d.ts +32 -27
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/prop-controllers/index.d.ts +1 -1
- package/dist/types/prop-controllers/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/style.d.ts +4 -0
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls.d.ts +2 -5
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts +2 -3
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/package.json +10 -3
- package/dist/react.cjs2.js +0 -7992
- package/dist/react.cjs2.js.map +0 -1
- package/dist/react.es2.js +0 -7911
- package/dist/react.es2.js.map +0 -1
- package/dist/types/controls/select.d.ts +0 -19
- package/dist/types/controls/select.d.ts.map +0 -1
- package/dist/types/controls.d.ts +0 -4
- package/dist/types/controls.d.ts.map +0 -1
- package/dist/types/prop-controllers/instances/slot.d.ts +0 -2
- package/dist/types/prop-controllers/instances/slot.d.ts.map +0 -1
- package/dist/types/runtimes/index.d.ts +0 -43
- package/dist/types/runtimes/index.d.ts.map +0 -1
- package/dist/types/runtimes/react/react.d.ts +0 -43
- package/dist/types/runtimes/react/react.d.ts.map +0 -1
- package/dist/types/runtimes/react.d.ts +0 -43
- package/dist/types/runtimes/react.d.ts.map +0 -1
package/dist/main.cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ var reactPage = require("./react-page.cjs.js");
|
|
|
5
5
|
require("redux");
|
|
6
6
|
require("redux-thunk");
|
|
7
7
|
require("./descriptors.cjs.js");
|
|
8
|
+
require("./style.cjs.js");
|
|
8
9
|
exports.ActionTypes = actions.ActionTypes;
|
|
9
10
|
exports.changeApiResource = actions.changeApiResource;
|
|
10
11
|
exports.changeDocument = actions.changeDocument;
|
package/dist/main.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.es.js
CHANGED
package/dist/main.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/dist/next.cjs.js
CHANGED
package/dist/next.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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}\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 },\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 },\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 }: 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} />\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","params","revalidate","path","paths","fallback","useState","useEffect","updateCacheData","RuntimeProvider","Map","id","PageMeta"],"mappings":"
|
|
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}\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 },\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 },\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 }: 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} />\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","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,U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AA,CAACH,UAAUY,eAAS,MAAM,IAAIX,MAAAA,gBAAgB;AAAA,IAAEC,KAAKH;AAAAA,IAAsBI;AAAAA,EAAjD,CAAA,CAAP;AAEzBU,QAAAA,UAAU,MAAM;AACdb,WAAOc,gBAAgBX,SAAvB;AAAA,EAAA,GACC,CAACH,QAAQG,SAAT,CAFM;AAIT,wCACGY,MAAAA,iBAAD;AAAA,IAAiB;AAAA,IAAgB,kCAAkBC,IAAI,CAAC,CAAClB,KAAKmB,IAAIX,WAAV,CAAD,CAAR;AAAA,IAA/C,yCACGY,aAAD;AAAA,MAAU;AAAA,IAAA,CAAV;AAAA,EAAA,CAFJ;AAKD;;;;;;;"}
|
package/dist/next.es.js
CHANGED
package/dist/next.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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}\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 },\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 },\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 }: 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} />\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","params","revalidate","path","paths","fallback","useState","useEffect","updateCacheData","Map","id","PageMeta"],"mappings":"
|
|
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}\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 },\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 },\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 }: 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} />\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","params","revalidate","path","paths","fallback","useState","useEffect","updateCacheData","Map","id","PageMeta"],"mappings":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C,KAAKH;AAAAA,EAAAA,CAA3B;AACTI,QAAAA,YAAY,MAAMH,OAAOI,SAASN,KAAKO,IAArB;AAEjB,SAAA;AAAA,IACLvC,OAAO;AAAA,MACLgC;AAAAA,MACAQ,aAAaR,KAAKO;AAAAA,MAClBN;AAAAA,MACAI;AAAAA,IALG;AAAA,IAOLK,YAAYzB;AAAAA,EAAAA;AAEf;AAEqE,gCAAA;AAC7D,SAAA;AAAA,IAAE2B,OAAO,CAAT;AAAA,IAAaC,UAAU;AAAA,EAAA;AAC/B;AAEoB,cAAA;AAAA,EAAEb;AAAAA,EAAMQ;AAAAA,EAAaP;AAAAA,EAAsBI;AAAAA,GAAwB;AAChF,QAAA,CAACH,UAAUY,SAAS,MAAM,IAAIX,gBAAgB;AAAA,IAAEC,KAAKH;AAAAA,IAAsBI;AAAAA,EAAjD,CAAA,CAAP;AAEzBU,YAAU,MAAM;AACdb,WAAOc,gBAAgBX,SAAvB;AAAA,EAAA,GACC,CAACH,QAAQG,SAAT,CAFM;AAIT,6BACG,iBAAD;AAAA,IAAiB;AAAA,IAAgB,kCAAkBY,IAAI,CAAC,CAACjB,KAAKkB,IAAIV,WAAV,CAAD,CAAR;AAAA,IAA/C,8BACGW,QAAD;AAAA,MAAU;AAAA,IAAA,CAAV;AAAA,EAAA,CAFJ;AAKD;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
var descriptors = require("./descriptors.cjs.js");
|
|
4
4
|
var instances = require("./instances.cjs.js");
|
|
5
|
+
require("./style.cjs.js");
|
|
5
6
|
exports.Props = descriptors.descriptors;
|
|
6
7
|
exports.RichTextPropControllerMessageType = instances.RichTextPropControllerMessageType;
|
|
7
8
|
exports.TableFormFieldsMessageType = instances.TableFormFieldsMessageType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -29,6 +29,7 @@ var instances = require("./instances.cjs.js");
|
|
|
29
29
|
var constants = require("./constants.cjs.js");
|
|
30
30
|
var controlSerialization = require("./control-serialization.cjs.js");
|
|
31
31
|
require("./descriptors.cjs.js");
|
|
32
|
+
require("./style.cjs.js");
|
|
32
33
|
require("css-box-model");
|
|
33
34
|
function _interopDefaultLegacy(e) {
|
|
34
35
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-builder-preview.cjs.js","sources":["../src/utils/is.ts","../src/utils/shallowEqual.ts","../src/utils/deepEqual.ts","../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["export default function is(x: unknown, y: unknown): boolean {\n if (x === y) return x !== 0 || y !== 0 || 1 / x === 1 / y\n\n return x !== x && y !== y\n}\n","import is from './is'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst shallowEqual = (a: unknown, b: unknown): boolean => {\n if (is(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n // @ts-expect-error: {}[string] is OK.\n if (!hasOwnProperty.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]])) return false\n }\n\n return true\n}\n\nexport default shallowEqual\n","import shallowEqual from './shallowEqual'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst deepEqual = (a: unknown, b: unknown): boolean => {\n if (shallowEqual(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n if (\n !hasOwnProperty.call(b, keysA[i]) ||\n // @ts-expect-error: {}[string] is OK.\n !deepEqual(a[keysA[i]], b[keysA[i]])\n )\n return false\n }\n\n return true\n}\n\nexport default deepEqual\n","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 ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\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: (_state: boolean = true, _action: Action): boolean => true,\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 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\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\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 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 if (PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)) {\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\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":["hasOwnProperty","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","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","changeElementBoxModels","changeDocumentElementSize","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAA2B,GAAY,GAAqB;AAC1D,MAAI,MAAM;AAAG,WAAO,MAAM,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI;AAEjD,SAAA,MAAM,KAAK,MAAM;AAC1B;ACFA,MAAM,kBAAEA,qBAAmB,OAAO;AAElC,MAAM,eAAe,CAAC,GAAY,MAAwB;AACpD,MAAA,GAAG,GAAG,CAAC;AAAU,WAAA;AAEjB,MAAA,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM;AAAa,WAAA;AAEjF,QAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,QAAA,QAAQ,OAAO,KAAK,CAAC;AAEvB,MAAA,MAAM,WAAW,MAAM;AAAe,WAAA;AAE1C,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AAExC,QAAI,CAACA,iBAAe,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,KAAK,EAAE,MAAM,GAAG;AAAU,aAAA;AAAA,EACjF;AAEO,SAAA;AACT;AClBA,MAAM,EAAE,mBAAmB,OAAO;AAElC,MAAM,YAAY,CAAC,GAAY,MAAwB;AACjD,MAAA,aAAa,GAAG,CAAC;AAAU,WAAA;AAE3B,MAAA,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM;AAAa,WAAA;AAEjF,QAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,QAAA,QAAQ,OAAO,KAAK,CAAC;AAEvB,MAAA,MAAM,WAAW,MAAM;AAAe,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YAClC,UAAUgC,UAAAA,UAAU,SAAS;AAAA,YAC7B,MAAM;AAAA,UAAA,CACP;AAED;AAAA,QACF;AAAA,aAEKhC,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,SAAOiC,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/utils/is.ts","../src/utils/shallowEqual.ts","../src/utils/deepEqual.ts","../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["export default function is(x: unknown, y: unknown): boolean {\n if (x === y) return x !== 0 || y !== 0 || 1 / x === 1 / y\n\n return x !== x && y !== y\n}\n","import is from './is'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst shallowEqual = (a: unknown, b: unknown): boolean => {\n if (is(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n // @ts-expect-error: {}[string] is OK.\n if (!hasOwnProperty.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]])) return false\n }\n\n return true\n}\n\nexport default shallowEqual\n","import shallowEqual from './shallowEqual'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst deepEqual = (a: unknown, b: unknown): boolean => {\n if (shallowEqual(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n if (\n !hasOwnProperty.call(b, keysA[i]) ||\n // @ts-expect-error: {}[string] is OK.\n !deepEqual(a[keysA[i]], b[keysA[i]])\n )\n return false\n }\n\n return true\n}\n\nexport default deepEqual\n","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 ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\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: (_state: boolean = true, _action: Action): boolean => true,\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 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\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\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 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 if (PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)) {\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\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":["hasOwnProperty","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","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","changeElementBoxModels","changeDocumentElementSize","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAA2B,GAAY,GAAqB;AAC1D,MAAI,MAAM;AAAG,WAAO,MAAM,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI;AAEjD,SAAA,MAAM,KAAK,MAAM;AAC1B;ACFA,MAAM,kBAAEA,qBAAmB,OAAO;AAElC,MAAM,eAAe,CAAC,GAAY,MAAwB;AACpD,MAAA,GAAG,GAAG,CAAC;AAAU,WAAA;AAEjB,MAAA,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM;AAAa,WAAA;AAEjF,QAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,QAAA,QAAQ,OAAO,KAAK,CAAC;AAEvB,MAAA,MAAM,WAAW,MAAM;AAAe,WAAA;AAE1C,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AAExC,QAAI,CAACA,iBAAe,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,KAAK,EAAE,MAAM,GAAG;AAAU,aAAA;AAAA,EACjF;AAEO,SAAA;AACT;AClBA,MAAM,EAAE,mBAAmB,OAAO;AAElC,MAAM,YAAY,CAAC,GAAY,MAAwB;AACjD,MAAA,aAAa,GAAG,CAAC;AAAU,WAAA;AAE3B,MAAA,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM;AAAa,WAAA;AAEjF,QAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,QAAA,QAAQ,OAAO,KAAK,CAAC;AAEvB,MAAA,MAAM,WAAW,MAAM;AAAe,WAAA;AAE1C,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AACxC,QACE,CAAC,eAAe,KAAK,GAAG,MAAM,EAAE,KAEhC,CAAC,UAAU,EA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AAM,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,SAAOiC,MACL,YAAA,SACA,gBACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;;;;;;;"}
|
|
@@ -28,6 +28,7 @@ import { c as createPropController } from "./instances.es.js";
|
|
|
28
28
|
import { F as Fragments } from "./constants.es.js";
|
|
29
29
|
import { s as serializeControls } from "./control-serialization.es.js";
|
|
30
30
|
import "./descriptors.es.js";
|
|
31
|
+
import "./style.es.js";
|
|
31
32
|
import "css-box-model";
|
|
32
33
|
function is(x, y) {
|
|
33
34
|
if (x === y)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-builder-preview.es.js","sources":["../src/utils/is.ts","../src/utils/shallowEqual.ts","../src/utils/deepEqual.ts","../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["export default function is(x: unknown, y: unknown): boolean {\n if (x === y) return x !== 0 || y !== 0 || 1 / x === 1 / y\n\n return x !== x && y !== y\n}\n","import is from './is'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst shallowEqual = (a: unknown, b: unknown): boolean => {\n if (is(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n // @ts-expect-error: {}[string] is OK.\n if (!hasOwnProperty.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]])) return false\n }\n\n return true\n}\n\nexport default shallowEqual\n","import shallowEqual from './shallowEqual'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst deepEqual = (a: unknown, b: unknown): boolean => {\n if (shallowEqual(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n if (\n !hasOwnProperty.call(b, keysA[i]) ||\n // @ts-expect-error: {}[string] is OK.\n !deepEqual(a[keysA[i]], b[keysA[i]])\n )\n return false\n }\n\n return true\n}\n\nexport default deepEqual\n","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 ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\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: (_state: boolean = true, _action: Action): boolean => true,\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 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\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\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 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 if (PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)) {\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\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":["hasOwnProperty","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","BoxModels.isMeasurable","ReactPage.getElementPropControllerDescriptors","PropControllerHandles.getPropControllersHandle","P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Q,YACf,OAAO,QAAQ,eACjB,CACF;AAAA,UACF;AAEA;AAAA,QACF;AAAA,aAEK,YAAY;AACf,mBACE,wCACE,OAAO,QAAQ,aACf,OAAO,QAAQ,UACjB,CACF;AACA;AAAA,aAEG,YAAY,8BAA8B;AAC7C,gBAAM,iBAAiBC,kBACrB,mCAAmC,SAAU,CAAA,GAC7C,OAAO,QAAQ,aACf,OAAO,QAAQ,YACf,OAAO,QAAQ,QACjB;AAEI,cAAA;AAA+B,2BAAA,KAAK,OAAO,QAAQ,OAAO;AAAA,QAChE;AAAA;AAGF,aAAO,KAAK,MAAM;AAAA,IAAA;AAAA,EACpB;AAEN;AAEA,yCACE,QACuC;AAChC,SAAA,MAAM,CAAC,SAAgC;AAC5C,WAAO,CAAC,WAA2B;AACjC,cAAQ,OAAO;AAAA,aACR,YAAY,qBAAqB;AAC9B,gBAAA,EAAE,aAAa,OAAO;AAE5B,iBAAO,MAAM,cAAc;AAAA,YACzB,IAAI,OAAO,MAAM,SAAS,QAAQ;AAAA,YAClC,UAAU,UAAU,SAAS;AAAA,YAC7B,MAAM;AAAA,UAAA,CACP;AAED;AAAA,QACF;AAAA,aAEK,YAAY;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,SAAO,YACL,SACA,gBACA,gBACE,OACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;"}
|
|
1
|
+
{"version":3,"file":"react-builder-preview.es.js","sources":["../src/utils/is.ts","../src/utils/shallowEqual.ts","../src/utils/deepEqual.ts","../src/state/modules/read-write-documents.ts","../src/state/modules/prop-controller-handles.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["export default function is(x: unknown, y: unknown): boolean {\n if (x === y) return x !== 0 || y !== 0 || 1 / x === 1 / y\n\n return x !== x && y !== y\n}\n","import is from './is'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst shallowEqual = (a: unknown, b: unknown): boolean => {\n if (is(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n // @ts-expect-error: {}[string] is OK.\n if (!hasOwnProperty.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]])) return false\n }\n\n return true\n}\n\nexport default shallowEqual\n","import shallowEqual from './shallowEqual'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst deepEqual = (a: unknown, b: unknown): boolean => {\n if (shallowEqual(a, b)) return true\n\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n\n if (keysA.length !== keysB.length) return false\n\n for (let i = 0; i < keysA.length; i += 1) {\n if (\n !hasOwnProperty.call(b, keysA[i]) ||\n // @ts-expect-error: {}[string] is OK.\n !deepEqual(a[keysA[i]], b[keysA[i]])\n )\n return false\n }\n\n return true\n}\n\nexport default deepEqual\n","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 ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\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: (_state: boolean = true, _action: Action): boolean => true,\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 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\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\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 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 if (PropControllerHandles.isPropControllersHandle(action.payload.componentHandle)) {\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\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":["hasOwnProperty","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","BoxModels.isMeasurable","ReactPage.getElementPropControllerDescriptors","PropControllerHandles.getPropControllersHandle","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropController"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAA2B,GAAY,GAAqB;AAC1D,MAAI,MAAM;AAAG,WAAO,MAAM,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI;AAEjD,SAAA,MAAM,KAAK,MAAM;AAC1B;ACFA,MAAM,kBAAEA,qBAAmB,OAAO;AAElC,MAAM,eAAe,CAAC,GAAY,MAAwB;AACpD,MAAA,GAAG,GAAG,CAAC;AAAU,WAAA;AAEjB,MAAA,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM;AAAa,WAAA;AAEjF,QAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,QAAA,QAAQ,OAAO,KAAK,CAAC;AAEvB,MAAA,MAAM,WAAW,MAAM;AAAe,WAAA;AAE1C,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AAExC,QAAI,CAACA,iBAAe,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,KAAK,EAAE,MAAM,GAAG;AAAU,aAAA;AAAA,EACjF;AAEO,SAAA;AACT;AClBA,MAAM,EAAE,mBAAmB,OAAO;AAElC,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Q,IAAI;AAC5C;AAAA;AAGJ,aAAO,KAAK,MAAM;AAAA,IAAA;AAAA,EACpB;AAEJ;AAI+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,GAIQ;AACR,SAAO,YACL,SACA,gBACA,gBACE,OACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;"}
|
package/dist/react.cjs.js
CHANGED
package/dist/react.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/react.es.js
CHANGED
package/dist/react.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const StyleControlType = "makeswift::controls::style";
|
|
3
|
+
const StyleControlProperty = {
|
|
4
|
+
Width: "makeswift::controls::style::property::width",
|
|
5
|
+
Margin: "makeswift::controls::style::property::margin",
|
|
6
|
+
Padding: "makeswift::controls::style::property::padding",
|
|
7
|
+
Border: "makeswift::controls::style::property::border",
|
|
8
|
+
BorderRadius: "makeswift::controls::style::property::border-radius"
|
|
9
|
+
};
|
|
10
|
+
const StyleControlDefaultProperties = [
|
|
11
|
+
StyleControlProperty.Width,
|
|
12
|
+
StyleControlProperty.Margin
|
|
13
|
+
];
|
|
14
|
+
const AllStyleControlProperties = [
|
|
15
|
+
StyleControlProperty.Width,
|
|
16
|
+
StyleControlProperty.Margin,
|
|
17
|
+
StyleControlProperty.Padding,
|
|
18
|
+
StyleControlProperty.Border,
|
|
19
|
+
StyleControlProperty.BorderRadius
|
|
20
|
+
];
|
|
21
|
+
function Style(params) {
|
|
22
|
+
var _a;
|
|
23
|
+
return {
|
|
24
|
+
type: StyleControlType,
|
|
25
|
+
config: { properties: (_a = params == null ? void 0 : params.properties) != null ? _a : StyleControlDefaultProperties }
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
Style.Default = StyleControlDefaultProperties;
|
|
29
|
+
Style.All = AllStyleControlProperties;
|
|
30
|
+
Style.Width = StyleControlProperty.Width;
|
|
31
|
+
Style.Margin = StyleControlProperty.Margin;
|
|
32
|
+
Style.Padding = StyleControlProperty.Padding;
|
|
33
|
+
Style.Border = StyleControlProperty.Border;
|
|
34
|
+
Style.BorderRadius = StyleControlProperty.BorderRadius;
|
|
35
|
+
exports.Style = Style;
|
|
36
|
+
exports.StyleControlProperty = StyleControlProperty;
|
|
37
|
+
exports.StyleControlType = StyleControlType;
|
|
38
|
+
//# sourceMappingURL=style.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.cjs.js","sources":["../src/controls/style.ts"],"sourcesContent":["import { ColorData, ResponsiveValue } from './types'\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/length\n *\n * @todos\n * - Add additional units\n * - Rename `value` field to `amount` or a more descriptive name representative of the \"distance\"\n * represented by a CSS length\n */\nexport type LengthData = { value: number; unit: 'px' }\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/percentage */\nexport type PercentageData = { value: number; unit: '%' }\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/length-percentage */\nexport type LengthPercentageData = LengthData | PercentageData\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/width */\nexport type WidthPropertyData = LengthPercentageData\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#constituent_properties */\nexport type MarginLonghandPropertyData = LengthData | 'auto'\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin\n *\n * @todos\n * - Remove `null` from possible values\n * - Remove `undefined` from possible values and make fields optional\n */\nexport type MarginPropertyData = {\n marginTop: MarginLonghandPropertyData | null | undefined\n marginRight: MarginLonghandPropertyData | null | undefined\n marginBottom: MarginLonghandPropertyData | null | undefined\n marginLeft: MarginLonghandPropertyData | null | undefined\n}\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/padding#constituent_properties */\nexport type PaddingLonghandPropertyData = LengthData\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/padding\n *\n * @todos\n * - Remove `null` from possible values\n * - Remove `undefined` from possible values and make fields optional\n */\nexport type PaddingPropertyData = {\n paddingTop: PaddingLonghandPropertyData | null | undefined\n paddingRight: PaddingLonghandPropertyData | null | undefined\n paddingBottom: PaddingLonghandPropertyData | null | undefined\n paddingLeft: PaddingLonghandPropertyData | null | undefined\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-style\n */\ntype BorderStyle = 'dotted' | 'dashed' | 'solid'\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-top#constituent_properties\n *\n * @todos\n * - Change `width` to be a `Length`\n * - Remove `null` from possible values\n * - Remove `undefined` from possible values and make fields optional\n */\nexport type BorderSideShorthandPropertyData = {\n width: number | null | undefined\n style: BorderStyle\n color?: ColorData | null\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/border\n *\n * @todos\n * - Remove `null` from possible values\n * - Remove `undefined` from possible values and make fields optional\n */\nexport type BorderPropertyData = {\n borderTop: BorderSideShorthandPropertyData | null | undefined\n borderRight: BorderSideShorthandPropertyData | null | undefined\n borderBottom: BorderSideShorthandPropertyData | null | undefined\n borderLeft: BorderSideShorthandPropertyData | null | undefined\n}\n\n/** @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#constituent_properties */\nexport type BorderRadiusLonghandPropertyData = LengthPercentageData\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius\n *\n * @todos\n * - Remove `null` from possible values of longhand properties\n * - Remove `undefined` from possible values and make fields optional\n */\nexport type BorderRadiusPropertyData = {\n borderTopLeftRadius: LengthPercentageData | null | undefined\n borderTopRightRadius: LengthPercentageData | null | undefined\n borderBottomRightRadius: LengthPercentageData | null | undefined\n borderBottomLeftRadius: LengthPercentageData | null | undefined\n}\n\nexport type StyleControlData = {\n width?: ResponsiveValue<WidthPropertyData>\n margin?: ResponsiveValue<MarginPropertyData>\n padding?: ResponsiveValue<PaddingPropertyData>\n border?: ResponsiveValue<BorderPropertyData>\n borderRadius?: ResponsiveValue<BorderRadiusPropertyData>\n}\n\nexport const StyleControlType = 'makeswift::controls::style'\n\nexport const StyleControlProperty = {\n Width: 'makeswift::controls::style::property::width',\n Margin: 'makeswift::controls::style::property::margin',\n Padding: 'makeswift::controls::style::property::padding',\n Border: 'makeswift::controls::style::property::border',\n BorderRadius: 'makeswift::controls::style::property::border-radius',\n} as const\n\nexport type StyleControlProperty = typeof StyleControlProperty[keyof typeof StyleControlProperty]\n\ntype StyleControlParams = { properties?: StyleControlProperty[] }\n\nexport type StyleControlConfig = { properties: StyleControlProperty[] }\n\nconst StyleControlDefaultProperties: StyleControlProperty[] = [\n StyleControlProperty.Width,\n StyleControlProperty.Margin,\n]\n\nconst AllStyleControlProperties: StyleControlProperty[] = [\n StyleControlProperty.Width,\n StyleControlProperty.Margin,\n StyleControlProperty.Padding,\n StyleControlProperty.Border,\n StyleControlProperty.BorderRadius,\n]\n\nexport type StyleControlDefinition = {\n type: typeof StyleControlType\n config: StyleControlConfig\n}\n\n/**\n * @todos\n * - Add support for custom panel labels.\n * - Add support for default values. Internally, default values must be represented with the same\n * format as the underlying data so that controls can show these values.\n */\nexport function Style(params?: StyleControlParams): StyleControlDefinition {\n return {\n type: StyleControlType,\n config: { properties: params?.properties ?? StyleControlDefaultProperties },\n }\n}\n\nStyle.Default = StyleControlDefaultProperties\nStyle.All = AllStyleControlProperties\n\nStyle.Width = StyleControlProperty.Width\nStyle.Margin = StyleControlProperty.Margin\nStyle.Padding = StyleControlProperty.Padding\nStyle.Border = StyleControlProperty.Border\nStyle.BorderRadius = StyleControlProperty.BorderRadius\n"],"names":[],"mappings":";AAiHO,MAAM,mBAAmB;AAEzB,MAAM,uBAAuB;AAAA,EAClC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,cAAc;AAChB;AAQA,MAAM,gCAAwD;AAAA,EAC5D,qBAAqB;AAAA,EACrB,qBAAqB;AACvB;AAEA,MAAM,4BAAoD;AAAA,EACxD,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AACvB;AAaO,eAAe,QAAqD;;AAClE,SAAA;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,YAAY,uCAAQ,eAAR,YAAsB,8BAA8B;AAAA,EAAA;AAE9E;AAEA,MAAM,UAAU;AAChB,MAAM,MAAM;AAEZ,MAAM,QAAQ,qBAAqB;AACnC,MAAM,SAAS,qBAAqB;AACpC,MAAM,UAAU,qBAAqB;AACrC,MAAM,SAAS,qBAAqB;AACpC,MAAM,eAAe,qBAAqB;;;;"}
|