@makeswift/runtime 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +14 -14
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Button.cjs.js +23 -23
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Carousel.cjs.js +8 -8
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Countdown.cjs.js +13 -13
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Divider.cjs.js +4 -4
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Embed.cjs.js +2 -2
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Form.cjs.js +72 -72
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Image.cjs2.js +10 -10
- package/dist/Image.cjs2.js.map +1 -1
- package/dist/Navigation.cjs.js +17 -17
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Root.cjs.js +2 -2
- package/dist/Root.cjs.js.map +1 -1
- package/dist/SocialLinks.cjs.js +3 -3
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/Text.cjs.js +21 -21
- package/dist/Text.cjs.js.map +1 -1
- package/dist/actions.es.js +1 -1
- package/dist/components.cjs.js +18 -18
- package/dist/cssMediaRules.cjs.js +7 -7
- package/dist/cssMediaRules.cjs.js.map +1 -1
- package/dist/index.cjs.js +374 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +10 -10
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +3 -3
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.es.js +367 -12
- package/dist/index.es.js.map +1 -1
- package/dist/next.cjs.js +22 -406
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +12 -392
- package/dist/next.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +11 -11
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +1 -1
- package/dist/react.cjs.js +8 -8
- package/dist/types/src/next/index.d.ts +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/useBoxShadow.cjs.js +3 -3
- package/dist/useBoxShadow.cjs.js.map +1 -1
- package/dist/useMediaQuery.cjs.js +6 -6
- package/dist/useMediaQuery.cjs.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-builder-preview.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { ApolloClient, NormalizedCacheObject } from '@apollo/client'\nimport { Fragments } from '../api'\nimport { serializeControls } from '../builder'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.addEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n const messageChannel = new MessageChannel()\n let cleanUp = () => {}\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\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 break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction apolloClientCacheSyncMiddleware(\n client: ApolloClient<NormalizedCacheObject>,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource } = action.payload\n\n client.cache.writeFragment({\n id: client.cache.identify(resource),\n fragment: Fragments[resource.__typename],\n data: resource,\n })\n\n break\n }\n\n case ActionTypes.EVICT_API_RESOURCE:\n client.cache.evict({ id: action.payload.id })\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n preloadedState,\n client,\n}: {\n preloadedState?: PreloadedState<State>\n client: ApolloClient<NormalizedCacheObject>\n}): Store {\n return createStore(\n reducer,\n preloadedState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n apolloClientCacheSyncMiddleware(client),\n ),\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAUC,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAUA,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,yBAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOC,UAAkB,gBAAgB,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,aAAwD;AAChG,SAAOC,UAAkB,cAAY,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEwB,mBAAA,QAAe,gBAAgB,GAAG,QAAuB;;AAC/E,QAAM,YAAYC,UAAAA,QAA0B,OAAO,MAAM;AAEzD,UAAQ,OAAO;AAAA,SACRC,QAAAA,YAAY,iBAAiB;AAChC,YAAM,qBAAqB,kBAAY,WAAW,OAAO,QAAQ,WAAW,MAAjD,mBAAoD;AAE/E,UAAI,sBAAsB;AAAa,eAAA;AAEvC,YAAM,kBAAkB,MAAM,oBAAoB,OAAO,QAAQ,SAAS;AAE1E,aAAO,uBAAuB,k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3D;AAAA,QACF;AAAA,aAEKpC,QAAAA,YAAY,8BAA8B;AAC7C,gBAAM,iBAAiBqC,UAAAA,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;AAwCA,yCACE,QACuC;AAChC,SAAA,MAAM,CAAC,SAAgC;AAC5C,WAAO,CAAC,WAA2B;AACjC,cAAQ,OAAO;AAAA,aACRrC,QAAAA,YAAY,qBAAqB;AAC9B,gBAAA,EAAE,aAAa,OAAO;AAE5B,iBAAO,MAAM,cAAc;AAAA,YACzB,IAAI,OAAO,MAAM,SAAS,QAAQ;AAAA,YAClC,UAAUsC,UAAAA,UAAU,SAAS;AAAA,YAC7B,MAAM;AAAA,UAAA,CACP;AAED;AAAA,QACF;AAAA,aAEKtC,QAAY,YAAA;AACf,iBAAO,MAAM,MAAM,EAAE,IAAI,OAAO,QAAQ,IAAI;AAC5C;AAAA;AAGJ,aAAO,KAAK,MAAM;AAAA,IAAA;AAAA,EACpB;AAEJ;AAI+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,GAIQ;AACR,SAAOuC,MACL,YAAA,SACA,gBACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react-builder-preview.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/react-builder-preview.ts"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { ApolloClient, NormalizedCacheObject } from '@apollo/client'\nimport { Fragments } from '../api'\nimport { serializeControls } from '../builder'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.addEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n const messageChannel = new MessageChannel()\n let cleanUp = () => {}\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\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 break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const handle = { setPropControllers: fn() }\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(handle.setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction apolloClientCacheSyncMiddleware(\n client: ApolloClient<NormalizedCacheObject>,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource } = action.payload\n\n client.cache.writeFragment({\n id: client.cache.identify(resource),\n fragment: Fragments[resource.__typename],\n data: resource,\n })\n\n break\n }\n\n case ActionTypes.EVICT_API_RESOURCE:\n client.cache.evict({ id: action.payload.id })\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n preloadedState,\n client,\n}: {\n preloadedState?: PreloadedState<State>\n client: ApolloClient<NormalizedCacheObject>\n}): Store {\n return createStore(\n reducer,\n preloadedState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n apolloClientCacheSyncMiddleware(client),\n ),\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","Fragments","createStore","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MA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OAAO,MAAM,SAAS,QAAQ;AAAA,YAClC,UAAUsC,UAAAA,UAAU,SAAS;AAAA,YAC7B,MAAM;AAAA,UAAA,CACP;AAED;AAAA,QACF;AAAA,aAEKtC,QAAY,YAAA;AACf,iBAAO,MAAM,MAAM,EAAE,IAAI,OAAO,QAAQ,IAAI;AAC5C;AAAA;AAGJ,aAAO,MAAK,MAAM;AAAA,IAAA;AAAA,EACpB;AAEJ;AAI+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,GAIQ;AACR,SAAOuC,MACL,YAAA,SACA,gBACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,gCAAgC,MAAM,CACxC,CACF;AACF;;;;;;;;"}
|
|
@@ -19,7 +19,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { combineReducers, createStore, applyMiddleware } from "redux";
|
|
21
21
|
import thunk from "redux-thunk";
|
|
22
|
-
import {
|
|
22
|
+
import { Q as deepEqual } from "./index.es.js";
|
|
23
23
|
import { removeIn, setIn } from "immutable";
|
|
24
24
|
import { r as getInitialState$1, s as reducer$2, t as getDocument$1, c as createDocument, u as reducer$3, v as reducer$5, w as reducer$6, x as reducer$7, y as reducer$8, z as getComponentsMeta$1, A as getComponentPropControllerDescriptors$1, B as getPropController, C as getPropControllersHandle, D as getElement, E as getElementPropControllerDescriptors, i as isElementReference, F as isPropControllersHandle } from "./react-page.es.js";
|
|
25
25
|
import { A as ActionTypes, l as changeElementBoxModels, n as changeDocumentElementSize, o as handleWheel, p as setIsInBuilder, q as registerBuilderComponent, t as unregisterBuilderComponent, v as unregisterMeasurable, w as registerMeasurable, x as unregisterPropControllers, y as registerPropControllers, z as registerPropControllersHandle, B as messageBuilderPropController } from "./actions.es.js";
|
package/dist/react.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
var actions = require("./actions.cjs.js");
|
|
4
|
-
var
|
|
4
|
+
var next = require("./index.cjs.js");
|
|
5
5
|
require("react");
|
|
6
6
|
require("use-sync-external-store/shim/with-selector");
|
|
7
7
|
require("./react-page.cjs.js");
|
|
@@ -37,11 +37,11 @@ require("uuid/v4");
|
|
|
37
37
|
require("corporate-ipsum");
|
|
38
38
|
exports.ActionTypes = actions.ActionTypes;
|
|
39
39
|
exports.changeDocument = actions.changeDocument;
|
|
40
|
-
exports.DocumentReference =
|
|
41
|
-
exports.Element =
|
|
42
|
-
exports.PageProvider =
|
|
43
|
-
exports.ReactRuntime =
|
|
44
|
-
exports.RuntimeProvider =
|
|
45
|
-
exports.useIsInBuilder =
|
|
46
|
-
exports.usePageId =
|
|
40
|
+
exports.DocumentReference = next.DocumentReference;
|
|
41
|
+
exports.Element = next.Element;
|
|
42
|
+
exports.PageProvider = next.PageProvider;
|
|
43
|
+
exports.ReactRuntime = next.ReactRuntime;
|
|
44
|
+
exports.RuntimeProvider = next.RuntimeProvider;
|
|
45
|
+
exports.useIsInBuilder = next.useIsInBuilder;
|
|
46
|
+
exports.usePageId = next.usePageId;
|
|
47
47
|
//# sourceMappingURL=react.cjs.js.map
|
|
@@ -15,7 +15,7 @@ export declare function getStaticProps(ctx: GetStaticPropsContext<ParsedUrlQuery
|
|
|
15
15
|
export declare function getServerSideProps(ctx: GetServerSidePropsContext<{
|
|
16
16
|
path?: string[];
|
|
17
17
|
}>): Promise<GetServerSidePropsResult<PageProps>>;
|
|
18
|
-
export declare
|
|
18
|
+
export declare const Page: import("react").MemoExoticComponent<({ snapshot }: PageProps) => JSX.Element>;
|
|
19
19
|
export * from './client';
|
|
20
20
|
export * from './preview-mode';
|
|
21
21
|
export * from './document';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/next/index.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,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AA6CrD,aAAK,cAAc,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAUzC,wBAAsB,cAAc,IAAI,OAAO,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CAYpF;AAID,wBAAsB,cAAc,CAClC,GAAG,EAAE,qBAAqB,CAAC,cAAc,EAAE,oBAAoB,CAAC,GAC/D,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAY1C;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,yBAAyB,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GAClD,OAAO,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CAU9C;AAED,eAAO,MAAM,IAAI,qDAAuB,SAAS,iBAqB/C,CAAA;AAEF,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
|
package/dist/useBoxShadow.cjs.js
CHANGED
|
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
}
|
|
31
31
|
return target;
|
|
32
32
|
};
|
|
33
|
-
var
|
|
33
|
+
var next = require("./index.cjs.js");
|
|
34
34
|
const ShadowDefaultValue = {
|
|
35
35
|
inset: false,
|
|
36
36
|
offsetX: 0,
|
|
@@ -41,10 +41,10 @@ const ShadowDefaultValue = {
|
|
|
41
41
|
};
|
|
42
42
|
function useBoxShadow(value) {
|
|
43
43
|
const swatchIds = value == null ? [] : [
|
|
44
|
-
...Array.from(new Set(value.map(({ value: shadows }) => shadows.map(({ payload: { color } }) => color && color.swatchId)).reduce((a, b) => a.concat(b), []).filter(
|
|
44
|
+
...Array.from(new Set(value.map(({ value: shadows }) => shadows.map(({ payload: { color } }) => color && color.swatchId)).reduce((a, b) => a.concat(b), []).filter(next.isNonNullable)))
|
|
45
45
|
];
|
|
46
46
|
const skip = value == null || swatchIds.length === 0;
|
|
47
|
-
const { error, data = {} } =
|
|
47
|
+
const { error, data = {} } = next.useQuery(next.SWATCHES_BY_ID, { skip, variables: { ids: swatchIds } });
|
|
48
48
|
if (value == null || error != null)
|
|
49
49
|
return null;
|
|
50
50
|
const { swatches = [] } = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBoxShadow.cjs.js","sources":["../src/components/hooks/useBoxShadow.ts"],"sourcesContent":["import { isNonNullable } from '../utils/isNonNullable'\nimport type { ColorValue as Color } from '../utils/types'\nimport { SWATCHES_BY_ID } from '../utils/queries'\nimport type { ResponsiveValue } from '../../prop-controllers'\nimport type { ShadowsValue as ResponsiveShadowsValue } from '../../prop-controllers/descriptors'\nimport { useQuery } from '../../api/react'\n\ntype ShadowData = {\n id: string\n payload: {\n inset: boolean\n offsetX: number\n offsetY: number\n blurRadius: number\n spreadRadius: number\n color: Color | null | undefined\n }\n}\n\nconst ShadowDefaultValue = {\n inset: false,\n offsetX: 0,\n offsetY: 2,\n blurRadius: 4,\n spreadRadius: 0,\n color: null,\n} as const\n\nexport type BoxShadowData = Array<ShadowData>\n\nexport type BoxShadowPropControllerData = ResponsiveValue<BoxShadowData>\n\nexport function useBoxShadow(\n value: ResponsiveShadowsValue | null | undefined,\n): BoxShadowPropControllerData | null | undefined {\n const swatchIds =\n value == null\n ? []\n : [\n ...Array.from(\n new Set(\n value\n .map(({ value: shadows }) =>\n shadows.map(({ payload: { color } }) => color && color.swatchId),\n )\n .reduce((a, b) => a.concat(b), [])\n .filter(isNonNullable),\n ),\n ),\n ]\n\n const skip = value == null || swatchIds.length === 0\n const { error, data = {} } = useQuery(SWATCHES_BY_ID, { skip, variables: { ids: swatchIds } })\n\n if (value == null || error != null) return null\n\n const { swatches = [] } = data\n\n return value.map(({ value: shadows, ...restOfValue }) => ({\n ...restOfValue,\n value: shadows.map(\n ({\n payload: { color, inset, offsetX, offsetY, blurRadius, spreadRadius },\n ...restOfShadow\n }) => ({\n ...restOfShadow,\n payload: {\n color:\n color != null\n ? {\n swatch: swatches.find((s: any) => s && s.id === color.swatchId),\n alpha: color.alpha,\n }\n : null,\n inset: inset ?? ShadowDefaultValue.inset,\n offsetX: offsetX ?? ShadowDefaultValue.offsetX,\n offsetY: offsetY ?? ShadowDefaultValue.offsetY,\n blurRadius: blurRadius ?? ShadowDefaultValue.blurRadius,\n spreadRadius: spreadRadius ?? ShadowDefaultValue.spreadRadius,\n },\n }),\n ),\n }))\n}\n"],"names":["isNonNullable","useQuery","SWATCHES_BY_ID"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,qBAAqB;AAAA,EACzB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,OAAO;AACT;AAMO,sBACL,OACgD;AAChD,QAAM,YACJ,SAAS,OACL,KACA;AAAA,IACE,GAAG,MAAM,KACP,IAAI,IACF,MACG,IAAI,CAAC,EAAE,OAAO,cACb,QAAQ,IAAI,CAAC,EAAE,SAAS,EAAE,cAAc,SAAS,MAAM,QAAQ,CACjE,EACC,OAAO,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,CAAA,CAAE,EAChC,OAAOA,
|
|
1
|
+
{"version":3,"file":"useBoxShadow.cjs.js","sources":["../src/components/hooks/useBoxShadow.ts"],"sourcesContent":["import { isNonNullable } from '../utils/isNonNullable'\nimport type { ColorValue as Color } from '../utils/types'\nimport { SWATCHES_BY_ID } from '../utils/queries'\nimport type { ResponsiveValue } from '../../prop-controllers'\nimport type { ShadowsValue as ResponsiveShadowsValue } from '../../prop-controllers/descriptors'\nimport { useQuery } from '../../api/react'\n\ntype ShadowData = {\n id: string\n payload: {\n inset: boolean\n offsetX: number\n offsetY: number\n blurRadius: number\n spreadRadius: number\n color: Color | null | undefined\n }\n}\n\nconst ShadowDefaultValue = {\n inset: false,\n offsetX: 0,\n offsetY: 2,\n blurRadius: 4,\n spreadRadius: 0,\n color: null,\n} as const\n\nexport type BoxShadowData = Array<ShadowData>\n\nexport type BoxShadowPropControllerData = ResponsiveValue<BoxShadowData>\n\nexport function useBoxShadow(\n value: ResponsiveShadowsValue | null | undefined,\n): BoxShadowPropControllerData | null | undefined {\n const swatchIds =\n value == null\n ? []\n : [\n ...Array.from(\n new Set(\n value\n .map(({ value: shadows }) =>\n shadows.map(({ payload: { color } }) => color && color.swatchId),\n )\n .reduce((a, b) => a.concat(b), [])\n .filter(isNonNullable),\n ),\n ),\n ]\n\n const skip = value == null || swatchIds.length === 0\n const { error, data = {} } = useQuery(SWATCHES_BY_ID, { skip, variables: { ids: swatchIds } })\n\n if (value == null || error != null) return null\n\n const { swatches = [] } = data\n\n return value.map(({ value: shadows, ...restOfValue }) => ({\n ...restOfValue,\n value: shadows.map(\n ({\n payload: { color, inset, offsetX, offsetY, blurRadius, spreadRadius },\n ...restOfShadow\n }) => ({\n ...restOfShadow,\n payload: {\n color:\n color != null\n ? {\n swatch: swatches.find((s: any) => s && s.id === color.swatchId),\n alpha: color.alpha,\n }\n : null,\n inset: inset ?? ShadowDefaultValue.inset,\n offsetX: offsetX ?? ShadowDefaultValue.offsetX,\n offsetY: offsetY ?? ShadowDefaultValue.offsetY,\n blurRadius: blurRadius ?? ShadowDefaultValue.blurRadius,\n spreadRadius: spreadRadius ?? ShadowDefaultValue.spreadRadius,\n },\n }),\n ),\n }))\n}\n"],"names":["isNonNullable","useQuery","SWATCHES_BY_ID"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,qBAAqB;AAAA,EACzB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,OAAO;AACT;AAMO,sBACL,OACgD;AAChD,QAAM,YACJ,SAAS,OAC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2
|
var React = require("react");
|
|
3
|
-
var
|
|
3
|
+
var next = require("./index.cjs.js");
|
|
4
4
|
function useMediaQuery(responsiveValue) {
|
|
5
|
-
const [deviceId, setDeviceId] = React.useState(
|
|
6
|
-
const { value } =
|
|
7
|
-
|
|
5
|
+
const [deviceId, setDeviceId] = React.useState(next.DEVICES[0].id);
|
|
6
|
+
const { value } = next.findDeviceOverride(responsiveValue, deviceId) || {};
|
|
7
|
+
next.useIsomorphicLayoutEffect(() => {
|
|
8
8
|
if (responsiveValue == null || window == null)
|
|
9
9
|
return () => {
|
|
10
10
|
};
|
|
11
|
-
const cleanUpFns =
|
|
12
|
-
const mediaQueryList = window.matchMedia(
|
|
11
|
+
const cleanUpFns = next.DEVICES.map((device) => {
|
|
12
|
+
const mediaQueryList = window.matchMedia(next.getDeviceMediaQuery(device).replace("@media", ""));
|
|
13
13
|
const listener = () => {
|
|
14
14
|
if (mediaQueryList.matches)
|
|
15
15
|
setDeviceId(device.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.cjs.js","sources":["../src/components/hooks/useMediaQuery.ts"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState } from 'react'\n\nimport { DeviceOverride } from '../../prop-controllers'\nimport { DEVICES, findDeviceOverride, getDeviceMediaQuery } from '../utils/devices'\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'\n\nexport function useMediaQuery<S>(responsiveValue?: Array<DeviceOverride<S>>): S | void {\n const [deviceId, setDeviceId] = useState(DEVICES[0].id)\n const { value } = findDeviceOverride(responsiveValue, deviceId) || {}\n\n useIsomorphicLayoutEffect(() => {\n if (responsiveValue == null || window == null) return () => {}\n\n const cleanUpFns = DEVICES.map(device => {\n const mediaQueryList = window.matchMedia(getDeviceMediaQuery(device).replace('@media', ''))\n\n const listener = () => {\n if (mediaQueryList.matches) setDeviceId(device.id)\n }\n\n listener()\n mediaQueryList.addListener(listener)\n\n return () => mediaQueryList.removeListener(listener)\n })\n\n return () => cleanUpFns.forEach(fn => fn())\n })\n\n return value\n}\n"],"names":["useState","DEVICES","findDeviceOverride","useIsomorphicLayoutEffect","getDeviceMediaQuery"],"mappings":";;;AAQO,uBAA0B,iBAAsD;AACrF,QAAM,CAAC,UAAU,eAAeA,MAAAA,SAASC,
|
|
1
|
+
{"version":3,"file":"useMediaQuery.cjs.js","sources":["../src/components/hooks/useMediaQuery.ts"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState } from 'react'\n\nimport { DeviceOverride } from '../../prop-controllers'\nimport { DEVICES, findDeviceOverride, getDeviceMediaQuery } from '../utils/devices'\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'\n\nexport function useMediaQuery<S>(responsiveValue?: Array<DeviceOverride<S>>): S | void {\n const [deviceId, setDeviceId] = useState(DEVICES[0].id)\n const { value } = findDeviceOverride(responsiveValue, deviceId) || {}\n\n useIsomorphicLayoutEffect(() => {\n if (responsiveValue == null || window == null) return () => {}\n\n const cleanUpFns = DEVICES.map(device => {\n const mediaQueryList = window.matchMedia(getDeviceMediaQuery(device).replace('@media', ''))\n\n const listener = () => {\n if (mediaQueryList.matches) setDeviceId(device.id)\n }\n\n listener()\n mediaQueryList.addListener(listener)\n\n return () => mediaQueryList.removeListener(listener)\n })\n\n return () => cleanUpFns.forEach(fn => fn())\n })\n\n return value\n}\n"],"names":["useState","DEVICES","findDeviceOverride","useIsomorphicLayoutEffect","getDeviceMediaQuery"],"mappings":";;;AAQO,uBAA0B,iBAAsD;AACrF,QAAM,CAAC,UAAU,eAAeA,MAAAA,SAASC,KAAAA,QAAQ,GAAG,EAAE;AACtD,QAAM,EAAE,UAAUC,KAAAA,mBAAmB,iBAAiB,QAAQ,KAAK;AAEnEC,OAAAA,0BAA0B,MAAM;AAC1B,QAAA,mBAAmB,QAAQ,UAAU;AAAM,aAAO,MAAM;AAAA,MAAA;AAEtD,UAAA,aAAaF,KAAAA,QAAQ,IAAI,CAAU,WAAA;AACjC,YAAA,iBAAiB,OAAO,WAAWG,KAAA,oBAAoB,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC;AAE1F,YAAM,WAAW,MAAM;AACrB,YAAI,eAAe;AAAS,sBAAY,OAAO,EAAE;AAAA,MAAA;AAG1C;AACT,qBAAe,YAAY,QAAQ;AAE5B,aAAA,MAAM,eAAe,eAAe,QAAQ;AAAA,IAAA,CACpD;AAED,WAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,GAAI,CAAA;AAAA,EAAA,CAC3C;AAEM,SAAA;AACT;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/main.cjs",
|
|
6
6
|
"module": "dist/main.es",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@convertkit/slate-lists": "^0.2.4",
|
|
104
104
|
"@emotion/css": "^11.9.0",
|
|
105
105
|
"@emotion/server": "^11.4.0",
|
|
106
|
-
"@makeswift/next-plugin": "0.1.
|
|
106
|
+
"@makeswift/next-plugin": "0.1.5",
|
|
107
107
|
"@popmotion/popcorn": "^0.4.4",
|
|
108
108
|
"@types/cookie": "^0.5.1",
|
|
109
109
|
"@types/http-proxy": "^1.17.9",
|