@makeswift/runtime 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +1 -3
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -4
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +4 -4
- package/dist/Button.es.js +5 -5
- package/dist/Carousel.cjs.js +3 -3
- package/dist/Carousel.es.js +4 -4
- package/dist/Countdown.cjs.js +1 -3
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +2 -4
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +1 -3
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +2 -4
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +13 -13
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +5 -5
- package/dist/Image.cjs.js +13 -13
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +13 -13
- package/dist/LiveProvider.cjs.js +1 -3
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +3 -5
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +12 -12
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +12 -12
- package/dist/PreviewProvider.cjs.js +1 -3
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +3 -5
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +7 -6
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +4 -3
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +7 -60
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +9 -62
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -3
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +2 -4
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +6 -6
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +7 -7
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -1
- package/dist/Video.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 +3 -3
- package/dist/components.es.js +3 -3
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +1 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +120 -256
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +107 -21
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +57 -16
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +42 -81
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +82 -17
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +18 -377
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +258 -181
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +343 -0
- package/dist/index.cjs9.js.map +1 -0
- package/dist/index.es.js +125 -260
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es3.js +103 -22
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +57 -16
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +42 -80
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +81 -17
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +18 -371
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +259 -182
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +336 -0
- package/dist/index.es9.js.map +1 -0
- 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 -3
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +2 -4
- 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-page.cjs.js +26 -6
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +26 -7
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -3
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +9 -6
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +9 -7
- package/dist/slate.es.js.map +1 -1
- package/dist/toText.cjs.js +67 -0
- package/dist/toText.cjs.js.map +1 -0
- package/dist/toText.es.js +66 -0
- package/dist/toText.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/utils/index.d.ts +2 -0
- package/dist/types/src/slate/utils/index.d.ts.map +1 -0
- package/dist/types/src/slate/utils/toText.d.ts +4 -0
- package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewProvider.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\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 Router from 'next/router'\n\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 IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\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 handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\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 isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.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 getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\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 startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\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\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = 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 = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\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 let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\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 const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state)\n const defaultLocale = ReactPage.getDefaultLocale(state)\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null && locales.some(locale => locale.toString() === routerLocale)) {\n messageChannel.port1.postMessage(setLocale(new Intl.Locale(routerLocale)))\n }\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\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 case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\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.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname: currentPathname, query } = Router\n const pathname = (action.payload.pathname ?? currentPathname).replace(/^\\//, '/')\n\n Router.replace({ pathname, query }, undefined, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","handlePointerMove","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","changeDocumentElementSize","ReactPage.getDocumentKeysSortedByDepth","elementFromPointChange","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","ReactPage.getBreakpoints","setBreakpoints","ReactPage.getLocales","ReactPage.getDefaultLocale","Router","setLocales","setDefaultLocale","setLocale","changePathnameStart","changePathnameComplete","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","createStore","applyMiddleware","thunk","ElementImperativeHandle","registerDocument","ReactPage.createDocument","registerComponentHandle","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx","StoreContext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1C,WAAWC,kBAA0B,EAAE,cAAc;AAAA,IACrD,WAAWC,UAAU,kBAAgB,IAAI;AAAA,EAAA;AAG3C,SAAOR,MACL,YAAA,SACA,cACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,iCAAiC,MAAM,CACzC,CACF;AACF;ACtuBwC,yBAAA;AAAA,EACtCO;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,GACqB;AACfC,QAAAA,QAAQC,cACZ,MACEC,eAAmC;AAAA,IACjCC,gBAAgBJ,UAAUA,QAAQC,MAAMI,aAAaC,KAAAA,aAAaL,MAAMI,SADvC;AAAA,IAEjCN;AAAAA,IACAF;AAAAA,EAHF,CAAA,GAKF,CAACA,QAAQE,cAAcC,OAAvB,CAPmB;AAUrBO,QAAAA,UAAU,MAAM;;AACRC,UAAAA,sBAAsBC,MAAMC,KAAKX,mDAAcY,cAAdZ,YAA2B,CAAA,CAAtC,EAA0Ca,IACpE,CAAC,CAACC,aAAaC,iBACbb,MAAMc,SAASC,QAAuBC,uBAAAA,yBAAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOF,YAAR,CAXM;AAcP,SAAAqB,2BAAA,IAACC,kBAAa,UAAd;AAAA,IAAuB,OAAOpB;AAAAA,IAA9B,yCACGqB,wBAAD;AAAA,MAAmB;AAAA,MAAiBxB;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
|
|
1
|
+
{"version":3,"file":"PreviewProvider.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\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 Router from 'next/router'\n\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 IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\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 handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\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 isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.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 getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\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 startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\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\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = 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 = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\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 let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\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 const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state)\n const defaultLocale = ReactPage.getDefaultLocale(state)\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null && locales.some(locale => locale.toString() === routerLocale)) {\n messageChannel.port1.postMessage(setLocale(new Intl.Locale(routerLocale)))\n }\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\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 case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\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.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname: currentPathname, query } = Router\n const pathname = (action.payload.pathname ?? currentPathname).replace(/^\\//, '/')\n\n Router.replace({ pathname, query }, undefined, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","handlePointerMove","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","changeDocumentElementSize","ReactPage.getDocumentKeysSortedByDepth","elementFromPointChange","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","ReactPage.getBreakpoints","setBreakpoints","ReactPage.getLocales","ReactPage.getDefaultLocale","Router","setLocales","setDefaultLocale","setLocale","changePathnameStart","changePathnameComplete","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","createStore","applyMiddleware","thunk","ElementImperativeHandle","registerDocument","ReactPage.createDocument","registerComponentHandle","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx","StoreContext","MakeswiftProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAUC,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAUA,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,2BAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOC,UAAkB,gBAAgB,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,a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AAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOF,YAAR,CAXM;AAcP,SAAAqB,2BAAA,IAACC,kBAAa,UAAd;AAAA,IAAuB,OAAOpB;AAAAA,IAA9B,yCACGqB,wBAAD;AAAA,MAAmB;AAAA,MAAiBxB;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
|
|
@@ -19,11 +19,11 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
const import_meta = {};
|
|
21
21
|
import { useMemo, useEffect } from "react";
|
|
22
|
-
import {
|
|
22
|
+
import { J as ElementImperativeHandle, a as ReactRuntime, K as StoreContext, M as MakeswiftProvider } from "./index.es.js";
|
|
23
23
|
import { createStore, applyMiddleware, combineReducers } from "redux";
|
|
24
24
|
import thunk from "redux-thunk";
|
|
25
25
|
import Router from "next/router";
|
|
26
|
-
import { bW as getInitialState$3, bX as reducer$4, bY as getDocument$1, c as createDocument, bZ as getComponentsMeta$1, b_ as getComponentPropControllerDescriptors$1,
|
|
26
|
+
import { bW as getInitialState$3, bX as reducer$4, bY as getDocument$1, c as createDocument, bZ as getComponentsMeta$1, b_ as getComponentPropControllerDescriptors$1, au as getBreakpoints, h as getLocales, f as getDefaultLocale, a as deepEqual, aA as getBuilderEditMode, b$ as BuilderEditMode, c0 as getDocumentKeysSortedByDepth, c1 as getPropController, c2 as getPropControllersHandle, c3 as getElement, c4 as getElementPropControllerDescriptors, c5 as createPropController, e as isElementReference, a3 as isPropControllersHandle, c6 as reducer$5, c7 as reducer$7, c8 as reducer$8, c9 as reducer$9, ca as reducer$a, cb as reducer$b, cc as reducer$c, cd as reducer$e, ce as getInitialState$4 } from "./react-page.es.js";
|
|
27
27
|
import { removeIn, setIn } from "immutable";
|
|
28
28
|
import { A as ActionTypes, w as unregisterMeasurable, x as registerMeasurable, y as registerBuilderComponent, j as setBreakpoints, l as setLocales, z as setDefaultLocale, k as setLocale, B as changePathnameStart, C as changePathnameComplete, D as changeElementBoxModels, E as changeDocumentElementSize, F as handleWheel, G as handlePointerMove, H as elementFromPointChange, I as setIsInBuilder, J as unregisterBuilderComponent, K as unregisterPropControllers, L as registerPropControllers, M as registerPropControllersHandle, r as registerDocument, N as registerComponentHandle, O as messageBuilderPropController, P as registerDocumentEffect } from "./actions.es.js";
|
|
29
29
|
import { i as isMeasurable, a as getMeasurables$1, b as getBoxModels$1, m as measure, d as getBoxModel$1, r as reducer$6 } from "./box-models.es.js";
|
|
@@ -54,11 +54,9 @@ import "http-proxy";
|
|
|
54
54
|
import "set-cookie-parser";
|
|
55
55
|
import "./constants.es.js";
|
|
56
56
|
import "corporate-ipsum";
|
|
57
|
-
import "is-hotkey";
|
|
58
|
-
import "slate-react";
|
|
59
|
-
import "next/link";
|
|
60
57
|
import "@emotion/serialize";
|
|
61
58
|
import "@emotion/utils";
|
|
59
|
+
import "is-hotkey";
|
|
62
60
|
import "css-box-model";
|
|
63
61
|
function apply(data, operation) {
|
|
64
62
|
let applied = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewProvider.es.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\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 Router from 'next/router'\n\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 IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\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 handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\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 isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.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 getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\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 startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\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\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = 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 = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\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 let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\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 const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state)\n const defaultLocale = ReactPage.getDefaultLocale(state)\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null && locales.some(locale => locale.toString() === routerLocale)) {\n messageChannel.port1.postMessage(setLocale(new Intl.Locale(routerLocale)))\n }\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\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 case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\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.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname: currentPathname, query } = Router\n const pathname = (action.payload.pathname ?? currentPathname).replace(/^\\//, '/')\n\n Router.replace({ pathname, query }, undefined, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","ReactPage.getDocumentKeysSortedByDepth","BoxModels.isMeasurable","ReactPage.getBreakpoints","ReactPage.getLocales","ReactPage.getDefaultLocale","ReactPage.getElementPropControllerDescriptors","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropControllersHandle","PropControllerHandles.getPropController","ReactPage.createDocument","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx"],"m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ADF,GAKC,CAAClB,OAAOF,YAAR,CAXM;AAcP,SAAAqB,oBAAC,aAAa,UAAd;AAAA,IAAuB,OAAOnB;AAAAA,IAA9B,8BACG,mBAAD;AAAA,MAAmB;AAAA,MAAiBH;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
|
|
1
|
+
{"version":3,"file":"PreviewProvider.es.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\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 Router from 'next/router'\n\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 IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\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 handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\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 isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.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 getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\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 startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\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\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = 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 = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\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 let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\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 const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state)\n const defaultLocale = ReactPage.getDefaultLocale(state)\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null && locales.some(locale => locale.toString() === routerLocale)) {\n messageChannel.port1.postMessage(setLocale(new Intl.Locale(routerLocale)))\n }\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\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 case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\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.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname: currentPathname, query } = Router\n const pathname = (action.payload.pathname ?? currentPathname).replace(/^\\//, '/')\n\n Router.replace({ pathname, query }, undefined, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(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 setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\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(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","ReactPage.getDocumentKeysSortedByDepth","BoxModels.isMeasurable","ReactPage.getBreakpoints","ReactPage.getLocales","ReactPage.getDefaultLocale","ReactPage.getElementPropControllerDescriptors","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropControllersHandle","PropControllerHandles.getPropController","ReactPage.createDocument","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,2BAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOA,kBAAkC,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;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GACzB,gCAAgC,GAChC,iCAAiC,MAAM,CACzC,CACF;AACF;ACtuBwC,yBAAA;AAAA,EACtCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,GACqB;AACfC,QAAAA,QAAQC,QACZ,MACEC,eAAmC;AAAA,IACjCC,gBAAgBJ,UAAUA,QAAQC,MAAMI,aAAaC,aAAaL,MAAMI,SADvC;AAAA,IAEjCN;AAAAA,IACAF;AAAAA,EAHF,CAAA,GAKF,CAACA,QAAQE,cAAcC,OAAvB,CAPmB;AAUrBO,YAAU,MAAM;;AACRC,UAAAA,sBAAsBC,MAAMC,KAAKX,mDAAcY,cAAdZ,YAA2B,CAAA,CAAtC,EAA0Ca,IACpE,CAAC,CAACC,aAAaC,iBACbb,MAAMc,SAASC,uBAAuBC,eAAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOF,YAAR,CAXM;AAcP,SAAAqB,oBAAC,aAAa,UAAd;AAAA,IAAuB,OAAOnB;AAAAA,IAA9B,8BACG,mBAAD;AAAA,MAAmB;AAAA,MAAiBH;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
|
package/dist/ReadOnlyText.cjs.js
CHANGED
|
@@ -11,6 +11,7 @@ require("./state/breakpoints.cjs.js");
|
|
|
11
11
|
require("is-hotkey");
|
|
12
12
|
var jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
require("slate-react");
|
|
14
|
+
var index = require("./index.cjs3.js");
|
|
14
15
|
require("use-sync-external-store/shim/with-selector");
|
|
15
16
|
require("next/dynamic");
|
|
16
17
|
require("./text-input.cjs.js");
|
|
@@ -36,9 +37,9 @@ require("http-proxy");
|
|
|
36
37
|
require("set-cookie-parser");
|
|
37
38
|
require("./constants.cjs.js");
|
|
38
39
|
require("corporate-ipsum");
|
|
39
|
-
require("next/link");
|
|
40
40
|
require("@emotion/serialize");
|
|
41
41
|
require("@emotion/utils");
|
|
42
|
+
require("next/link");
|
|
42
43
|
const ReadOnlyText = React.forwardRef(function ReadOnlyText2({
|
|
43
44
|
id,
|
|
44
45
|
text,
|
|
@@ -113,7 +114,7 @@ function InlineElement({
|
|
|
113
114
|
})
|
|
114
115
|
});
|
|
115
116
|
case reactPage.InlineType.Link:
|
|
116
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Link, {
|
|
117
118
|
className: linkClassName,
|
|
118
119
|
link: (_a = descendant.link) != null ? _a : void 0,
|
|
119
120
|
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
@@ -241,11 +242,11 @@ function Descendants({
|
|
|
241
242
|
descendants
|
|
242
243
|
}) {
|
|
243
244
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
244
|
-
children: descendants.map((descendant,
|
|
245
|
+
children: descendants.map((descendant, index2) => {
|
|
245
246
|
if (isText(descendant)) {
|
|
246
247
|
return /* @__PURE__ */ jsxRuntime.jsx(TextElement, {
|
|
247
248
|
descendant
|
|
248
|
-
},
|
|
249
|
+
}, index2);
|
|
249
250
|
}
|
|
250
251
|
switch (descendant.type) {
|
|
251
252
|
case reactPage.InlineType.Link:
|
|
@@ -254,7 +255,7 @@ function Descendants({
|
|
|
254
255
|
case reactPage.InlineType.SuperScript:
|
|
255
256
|
return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, {
|
|
256
257
|
descendant
|
|
257
|
-
},
|
|
258
|
+
}, index2);
|
|
258
259
|
case reactPage.BlockType.Heading1:
|
|
259
260
|
case reactPage.BlockType.Heading2:
|
|
260
261
|
case reactPage.BlockType.Heading3:
|
|
@@ -270,7 +271,7 @@ function Descendants({
|
|
|
270
271
|
case reactPage.BlockType.ListItemChild:
|
|
271
272
|
return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, {
|
|
272
273
|
descendant
|
|
273
|
-
},
|
|
274
|
+
}, index2);
|
|
274
275
|
default:
|
|
275
276
|
return null;
|
|
276
277
|
}
|