@makeswift/runtime 0.8.6 → 0.8.8

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.
Files changed (90) hide show
  1. package/dist/LiveProvider.cjs.js +4 -3
  2. package/dist/LiveProvider.cjs.js.map +1 -1
  3. package/dist/LiveProvider.es.js +5 -4
  4. package/dist/LiveProvider.es.js.map +1 -1
  5. package/dist/PreviewProvider.cjs.js +4 -3
  6. package/dist/PreviewProvider.cjs.js.map +1 -1
  7. package/dist/PreviewProvider.es.js +5 -4
  8. package/dist/PreviewProvider.es.js.map +1 -1
  9. package/dist/actions.es.js +1 -1
  10. package/dist/constants.cjs.js +6 -2
  11. package/dist/constants.cjs.js.map +1 -1
  12. package/dist/constants.es.js +8 -4
  13. package/dist/constants.es.js.map +1 -1
  14. package/dist/index.cjs.js +83 -50
  15. package/dist/index.cjs.js.map +1 -1
  16. package/dist/index.cjs5.js +260 -106
  17. package/dist/index.cjs5.js.map +1 -1
  18. package/dist/index.cjs7.js.map +1 -1
  19. package/dist/index.es.js +86 -52
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/index.es5.js +260 -106
  22. package/dist/index.es5.js.map +1 -1
  23. package/dist/index.es7.js +1 -1
  24. package/dist/index.es7.js.map +1 -1
  25. package/dist/leaf.es.js +1 -1
  26. package/dist/next.es.js +1 -1
  27. package/dist/state/breakpoints.cjs.js +44 -10
  28. package/dist/state/breakpoints.cjs.js.map +1 -1
  29. package/dist/state/breakpoints.es.js +44 -10
  30. package/dist/state/breakpoints.es.js.map +1 -1
  31. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  32. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +1 -0
  33. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  34. package/dist/types/src/next/client.d.ts +4 -1
  35. package/dist/types/src/next/client.d.ts.map +1 -1
  36. package/dist/types/src/next/index.d.ts +3 -1
  37. package/dist/types/src/next/index.d.ts.map +1 -1
  38. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +3 -1
  39. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  40. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +3 -1
  41. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
  42. package/dist/types/src/runtimes/react/index.d.ts +19 -5
  43. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  44. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +2 -2
  45. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -1
  46. package/dist/types/src/slate/BlockPlugin/index.d.ts +4 -0
  47. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  48. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +7 -4
  49. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -1
  50. package/dist/types/src/slate/BlockPlugin/types.d.ts +2 -2
  51. package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
  52. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +4 -0
  53. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -0
  54. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +4 -0
  55. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -0
  56. package/dist/types/src/slate/ListPlugin/toggleList.d.ts +2 -1
  57. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
  58. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts +6 -2
  59. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -1
  60. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts +0 -1
  61. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -1
  62. package/dist/types/src/slate/ListPlugin/wrapList.d.ts +2 -1
  63. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
  64. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +6 -2
  65. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -1
  66. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +6 -2
  67. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -1
  68. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +6 -2
  69. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
  70. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  71. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +6 -2
  72. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -1
  73. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +6 -2
  74. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
  75. package/dist/types/src/slate/selectors.d.ts +19 -0
  76. package/dist/types/src/slate/selectors.d.ts.map +1 -0
  77. package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
  78. package/dist/types/src/slate/utils/element.d.ts +2 -1
  79. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  80. package/dist/types/src/slate/utils/unhangRange.d.ts +10 -0
  81. package/dist/types/src/slate/utils/unhangRange.d.ts.map +1 -0
  82. package/dist/types/src/state/modules/breakpoints.d.ts +3 -4
  83. package/dist/types/src/state/modules/breakpoints.d.ts.map +1 -1
  84. package/dist/types/src/state/modules/breakpoints.test.d.ts +2 -0
  85. package/dist/types/src/state/modules/breakpoints.test.d.ts.map +1 -0
  86. package/dist/types/src/state/react-page.d.ts +2 -1
  87. package/dist/types/src/state/react-page.d.ts.map +1 -1
  88. package/dist/types/src/utils/isNonNullable.d.ts +2 -0
  89. package/dist/types/src/utils/isNonNullable.d.ts.map +1 -0
  90. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/state/modules/prop-controller-handles.ts","../src/state/modules/is-in-builder.ts","../src/state/modules/is-preview.ts","../src/state/react-page.ts","../src/components/builtin/constants.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nexport function getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type { Component, PropsWithoutRef, ReactElement, RefAttributes } from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactElement<any, any> | null)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropController> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n","import { Action } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(isPreview = false): State {\n return isPreview\n}\n\nexport function getIsPreview(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action): State {\n switch (action.type) {\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\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 Breakpoints from './modules/breakpoints'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\nimport { copyElementReference } from '../prop-controllers/copy'\nimport { copy as copyFromControl } from '../controls/control'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.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 breakpoints: Breakpoints.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function 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\nexport function getPropControllers(state: State, documentKey: string, elementKey: string) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n *\n * @todo Make this selector more efficient.\n */\nexport function getDocumentKeysSortedByDepth(state: State): string[] {\n const documents = Documents.getDocuments(getDocumentsStateSlice(state))\n const keys = Array.from(documents.keys())\n\n if (keys.length < 2) return keys\n\n const elements = new Map<string, Map<string, Documents.Element>>()\n\n keys.forEach(key => {\n elements.set(key, getDocumentElements(state, key))\n })\n\n keys.sort((a, b) => (elements.get(a)?.has(b) ? -1 : 1))\n\n return keys\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport type ReplacementContext = {\n elementHtmlIds: Set<string>\n elementKeys: Map<string, string>\n swatchIds: Map<string, string>\n fileIds: Map<string, string>\n typographyIds: Map<string, string>\n tableIds: Map<string, string>\n tableColumnIds: Map<string, string>\n pageIds: Map<string, string>\n globalElementIds: Map<string, string>\n globalElementData: Map<string, Documents.ElementData>\n}\n\nexport type SerializableReplacementContext = {\n elementHtmlIds: string[]\n elementKeys: { [s: string]: string }\n swatchIds: { [s: string]: string }\n fileIds: { [s: string]: string }\n typographyIds: { [s: string]: string }\n tableIds: { [s: string]: string }\n tableColumnIds: { [s: string]: string }\n pageIds: { [s: string]: string }\n globalElementIds: { [s: string]: string }\n globalElementData: { [s: string]: Documents.ElementData }\n}\n\nexport function createReplacementContext(\n serializableReplacementContext: SerializableReplacementContext,\n): ReplacementContext {\n const rc: ReplacementContext = {\n elementHtmlIds: new Set(serializableReplacementContext.elementHtmlIds),\n elementKeys: new Map(\n serializableReplacementContext.elementKeys &&\n Object.entries(serializableReplacementContext.elementKeys),\n ),\n swatchIds: new Map(\n serializableReplacementContext.swatchIds &&\n Object.entries(serializableReplacementContext.swatchIds),\n ),\n fileIds: new Map(\n serializableReplacementContext.fileIds &&\n Object.entries(serializableReplacementContext.fileIds),\n ),\n typographyIds: new Map(\n serializableReplacementContext.typographyIds &&\n Object.entries(serializableReplacementContext.typographyIds),\n ),\n tableIds: new Map(\n serializableReplacementContext.tableIds &&\n Object.entries(serializableReplacementContext.tableIds),\n ),\n tableColumnIds: new Map(\n serializableReplacementContext.tableColumnIds &&\n Object.entries(serializableReplacementContext.tableColumnIds),\n ),\n pageIds: new Map(\n serializableReplacementContext.pageIds &&\n Object.entries(serializableReplacementContext.pageIds),\n ),\n globalElementIds: new Map(\n serializableReplacementContext.globalElementIds &&\n Object.entries(serializableReplacementContext.globalElementIds),\n ),\n globalElementData: new Map(\n serializableReplacementContext.globalElementData &&\n Object.entries(serializableReplacementContext.globalElementData),\n ),\n }\n\n return rc\n}\n\nexport type CopyContext = {\n replacementContext: ReplacementContext\n copyElement: (node: Documents.Element) => Documents.Element\n}\n\nexport function copyElementTree(\n state: State,\n elementTree: Documents.ElementData,\n replacementContext: SerializableReplacementContext,\n) {\n /*\n * This is structured a bit weird.\n *\n * This is done so that we can pass a callable function into some of the copy functions\n * themselves, to enable mutual recursion.\n *\n * Consider the slot control. It has to iterate through its elements, and for each of them,\n * call some version of the below function.\n *\n * That is how the recursing through the tree happens.\n */\n function copyElementTreeNode(state: State, replacementContext: ReplacementContext) {\n return function (node: Documents.Element) {\n const context = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return { ...node, value: copyElementReference(node.value, context) }\n }\n\n const descriptors = getComponentPropControllerDescriptors(state, node.type)\n\n if (descriptors == null) return node\n\n for (const [propKey, descriptor] of Object.entries(descriptors)) {\n node.props[propKey] = copyFromControl(descriptor, node.props[propKey], context)\n }\n\n return node\n }\n }\n\n const copy = JSON.parse(JSON.stringify(elementTree)) as Documents.ElementData\n\n return copyElementTreeNode(state, createReplacementContext(replacementContext))(copy)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsPreview(state: State): boolean {\n return IsPreview.getIsPreview(state.isPreview)\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n","/**\n * These are the element types that have been used since the beginning of Makeswift and are saved in\n * the database.\n */\nexport const MakeswiftComponentType = {\n Box: './components/Box/index.js',\n Button: './components/Button/index.js',\n Carousel: './components/Carousel/index.js',\n Countdown: './components/Countdown/index.js',\n Divider: './components/Divider/index.js',\n Embed: './components/Embed/index.js',\n Form: './components/Form/index.js',\n Image: './components/Image/index.js',\n Navigation: './components/Navigation/index.js',\n Root: './components/Root/index.js',\n SocialLinks: './components/SocialLinks/index.js',\n Text: './components/Text/index.js',\n Video: './components/Video/index.js',\n} as const\n"],"names":["getInitialState","ActionTypes","reactComponents","Map","state","type","getReactComponents","get","action","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","getPropControllers","combineReducers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Breakpoints.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","PropControllerHandles.getPropControllers","Documents.isElementReference","Introspection.getElementChildren","Documents.getDocuments","Introspection.getElementId","copyElementReference","descriptors","copyFromControl","IsPreview.getIsPreview","createStore","Documents.getInitialState","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AAChF,SAAO,CAAa,YAAA;AACtB;AAMO,iCAAiC,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;AAOO,wBAAwB,KAAa,aAAgC;AACnE,SAAA,EAAE,KAAK;AAChB;AAIgC,2BAAA;AAAA,EAC9B,mCAAmB,IAAI;AAAA,IACoB,IAAW;AAChD,QAAA,mCAAmB;AAEZ,eAAA,QAAQ,CAAC,aAAa,gBAAgB;AACjD,iBAAa,IAAI,aAAa,eAAe,aAAa,WAAW,CAAC;AAAA,EAAA,CACvE;AAEM,SAAA;AACT;AAEO,sBAAsB,OAAqC;AACzD,SAAA;AACT;AAEO,uBAAqB,OAAc,aAAsC;;AAC9E,SAAO,mBAAa,KAAK,EAAE,IAAI,WAAW,MAAnC,YAAwC;AACjD;AAEwB,mBAAA,QAAeA,kBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACRC,QAAY,YAAA;AACR,aAAA,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,OAAO,QAAQ,QAAQ;AAAA,SAE1EA,QAAAA,YAAY,qBAAqB;AAC9B,YAAA,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,WAAW;AAE3D,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA;AAGS,aAAA;AAAA;AAEb;AC3DgC,2BAAA;AAAA,EAC9BC,sCAAsBC,IAAJ;AAAA,IACkC,IAAW;AACxDD,SAAAA;AACR;AAED,4BAA4BE,OAA0C;AAC7DA,SAAAA;AACR;AAEM,6BAA2BA,OAAcC,MAAoC;;AAC3EC,SAAAA,yBAAmBF,KAAD,EAAQG,IAAIF,IAA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gBAAc,sCAAsC,QAAO,KAAK,IAAI;AAE1E,UAAIA,iBAAe;AAAa,eAAA;AAEhC,iBAAW,CAAC,SAAS,eAAe,OAAO,QAAQA,aAAW,GAAG;AAC/D,aAAK,MAAM,WAAWC,iBAAgB,YAAY,KAAK,MAAM,UAAU,OAAO;AAAA,MAChF;AAEO,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,OAAO,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAEnD,SAAO,oBAAoB,OAAO,yBAAyB,kBAAkB,CAAC,EAAE,IAAI;AACtF;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,sBAAsB,OAAuB;AAC3C,SAAAC,eAAuB,MAAM,SAAS;AAC/C;AAEO,4BAA4B,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,wBAAwB,OAAiC;AAC9D,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,IAIE,IAAW;AACb,SAAOC,MACL,YAAA,SACA,iCAAK,iBAAL,EAAqB,WAAWC,kBAA0B,EAAE,aAAc,CAAA,EAC1E,IAAAC,sBAAgBC,eAAAA,UAAK,CACvB;AACF;AC7VO,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.cjs.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/state/modules/prop-controller-handles.ts","../src/state/modules/is-in-builder.ts","../src/state/modules/is-preview.ts","../src/state/react-page.ts","../src/components/builtin/constants.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nexport function getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type { Component, PropsWithoutRef, ReactElement, RefAttributes } from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactElement<any, any> | null)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropController> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n","import { Action } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(isPreview = false): State {\n return isPreview\n}\n\nexport function getIsPreview(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action): State {\n switch (action.type) {\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\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 Breakpoints from './modules/breakpoints'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\nimport { copyElementReference } from '../prop-controllers/copy'\nimport { copy as copyFromControl } from '../controls/control'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.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 breakpoints: Breakpoints.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function 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\nexport function getPropControllers(state: State, documentKey: string, elementKey: string) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n *\n * @todo Make this selector more efficient.\n */\nexport function getDocumentKeysSortedByDepth(state: State): string[] {\n const documents = Documents.getDocuments(getDocumentsStateSlice(state))\n const keys = Array.from(documents.keys())\n\n if (keys.length < 2) return keys\n\n const elements = new Map<string, Map<string, Documents.Element>>()\n\n keys.forEach(key => {\n elements.set(key, getDocumentElements(state, key))\n })\n\n keys.sort((a, b) => (elements.get(a)?.has(b) ? -1 : 1))\n\n return keys\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport type ReplacementContext = {\n elementHtmlIds: Set<string>\n elementKeys: Map<string, string>\n swatchIds: Map<string, string>\n fileIds: Map<string, string>\n typographyIds: Map<string, string>\n tableIds: Map<string, string>\n tableColumnIds: Map<string, string>\n pageIds: Map<string, string>\n globalElementIds: Map<string, string>\n globalElementData: Map<string, Documents.ElementData>\n}\n\nexport type SerializableReplacementContext = {\n elementHtmlIds: string[]\n elementKeys: { [s: string]: string }\n swatchIds: { [s: string]: string }\n fileIds: { [s: string]: string }\n typographyIds: { [s: string]: string }\n tableIds: { [s: string]: string }\n tableColumnIds: { [s: string]: string }\n pageIds: { [s: string]: string }\n globalElementIds: { [s: string]: string }\n globalElementData: { [s: string]: Documents.ElementData }\n}\n\nexport function createReplacementContext(\n serializableReplacementContext: SerializableReplacementContext,\n): ReplacementContext {\n const rc: ReplacementContext = {\n elementHtmlIds: new Set(serializableReplacementContext.elementHtmlIds),\n elementKeys: new Map(\n serializableReplacementContext.elementKeys &&\n Object.entries(serializableReplacementContext.elementKeys),\n ),\n swatchIds: new Map(\n serializableReplacementContext.swatchIds &&\n Object.entries(serializableReplacementContext.swatchIds),\n ),\n fileIds: new Map(\n serializableReplacementContext.fileIds &&\n Object.entries(serializableReplacementContext.fileIds),\n ),\n typographyIds: new Map(\n serializableReplacementContext.typographyIds &&\n Object.entries(serializableReplacementContext.typographyIds),\n ),\n tableIds: new Map(\n serializableReplacementContext.tableIds &&\n Object.entries(serializableReplacementContext.tableIds),\n ),\n tableColumnIds: new Map(\n serializableReplacementContext.tableColumnIds &&\n Object.entries(serializableReplacementContext.tableColumnIds),\n ),\n pageIds: new Map(\n serializableReplacementContext.pageIds &&\n Object.entries(serializableReplacementContext.pageIds),\n ),\n globalElementIds: new Map(\n serializableReplacementContext.globalElementIds &&\n Object.entries(serializableReplacementContext.globalElementIds),\n ),\n globalElementData: new Map(\n serializableReplacementContext.globalElementData &&\n Object.entries(serializableReplacementContext.globalElementData),\n ),\n }\n\n return rc\n}\n\nexport type CopyContext = {\n replacementContext: ReplacementContext\n copyElement: (node: Documents.Element) => Documents.Element\n}\n\nexport function copyElementTree(\n state: State,\n elementTree: Documents.ElementData,\n replacementContext: SerializableReplacementContext,\n) {\n /*\n * This is structured a bit weird.\n *\n * This is done so that we can pass a callable function into some of the copy functions\n * themselves, to enable mutual recursion.\n *\n * Consider the slot control. It has to iterate through its elements, and for each of them,\n * call some version of the below function.\n *\n * That is how the recursing through the tree happens.\n */\n function copyElementTreeNode(state: State, replacementContext: ReplacementContext) {\n return function (node: Documents.Element) {\n const context = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return { ...node, value: copyElementReference(node.value, context) }\n }\n\n const descriptors = getComponentPropControllerDescriptors(state, node.type)\n\n if (descriptors == null) return node\n\n for (const [propKey, descriptor] of Object.entries(descriptors)) {\n node.props[propKey] = copyFromControl(descriptor, node.props[propKey], context)\n }\n\n return node\n }\n }\n\n const copy = JSON.parse(JSON.stringify(elementTree)) as Documents.ElementData\n\n return copyElementTreeNode(state, createReplacementContext(replacementContext))(copy)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsPreview(state: State): boolean {\n return IsPreview.getIsPreview(state.isPreview)\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n breakpoints,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n breakpoints?: Breakpoints.State\n} = {}): Store {\n return createStore(\n reducer,\n {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n applyMiddleware(thunk),\n )\n}\n","/**\n * These are the element types that have been used since the beginning of Makeswift and are saved in\n * the database.\n */\nexport const MakeswiftComponentType = {\n Box: './components/Box/index.js',\n Button: './components/Button/index.js',\n Carousel: './components/Carousel/index.js',\n Countdown: './components/Countdown/index.js',\n Divider: './components/Divider/index.js',\n Embed: './components/Embed/index.js',\n Form: './components/Form/index.js',\n Image: './components/Image/index.js',\n Navigation: './components/Navigation/index.js',\n Root: './components/Root/index.js',\n SocialLinks: './components/SocialLinks/index.js',\n Text: './components/Text/index.js',\n Video: './components/Video/index.js',\n} as const\n"],"names":["getInitialState","ActionTypes","reactComponents","Map","state","type","getReactComponents","get","action","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","getPropControllers","combineReducers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Breakpoints.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","PropControllerHandles.getPropControllers","Documents.isElementReference","Introspection.getElementChildren","Documents.getDocuments","Introspection.getElementId","copyElementReference","descriptors","copyFromControl","IsPreview.getIsPreview","createStore","Documents.getInitialState","Breakpoints.getInitialState","apply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A,aAAW,GAAG;AAC/D,aAAK,MAAM,WAAWC,iBAAgB,YAAY,KAAK,MAAM,UAAU,OAAO;AAAA,MAChF;AAEO,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,OAAO,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAEnD,SAAO,oBAAoB,OAAO,yBAAyB,kBAAkB,CAAC,EAAE,IAAI;AACtF;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,sBAAsB,OAAuB;AAC3C,SAAAC,eAAuB,MAAM,SAAS;AAC/C;AAEO,4BAA4B,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,wBAAwB,OAAiC;AAC9D,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,IAKE,IAAW;AACb,SAAOC,MAAAA,YACL,SACA,iCACK,iBADL;AAAA,IAEE,WAAWC,kBAA0B,EAAE,cAAc;AAAA,IACrD,aAAaC,kBAA4B,gBAAA,oCAAe,iDAAgB,WAAW;AAAA,EAAA,IAErFC,MAAgB,gBAAAC,eAAK,UAAA,CACvB;AACF;ACnWO,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -21,7 +21,7 @@ import { combineReducers, createStore, applyMiddleware } from "redux";
21
21
  import thunk from "redux-thunk";
22
22
  import { A as ActionTypes } from "./actions.es.js";
23
23
  import { r as reducer$8, c as copyElementReference, a as copy } from "./descriptors.es.js";
24
- import { reducer as reducer$9 } from "./state/breakpoints.es.js";
24
+ import { reducer as reducer$9, getInitialState as getInitialState$7 } from "./state/breakpoints.es.js";
25
25
  import { g as getElementId$1, a as getElementChildren } from "./introspection.es.js";
26
26
  function isElementReference(element) {
27
27
  return !("props" in element);
@@ -361,9 +361,13 @@ function getBreakpoints(state) {
361
361
  }
362
362
  function configureStore({
363
363
  rootElements,
364
- preloadedState
364
+ preloadedState,
365
+ breakpoints
365
366
  } = {}) {
366
- return createStore(reducer, __spreadProps(__spreadValues({}, preloadedState), { documents: getInitialState$6({ rootElements }) }), applyMiddleware(thunk));
367
+ return createStore(reducer, __spreadProps(__spreadValues({}, preloadedState), {
368
+ documents: getInitialState$6({ rootElements }),
369
+ breakpoints: getInitialState$7(breakpoints != null ? breakpoints : preloadedState == null ? void 0 : preloadedState.breakpoints)
370
+ }), applyMiddleware(thunk));
367
371
  }
368
372
  const MakeswiftComponentType = {
369
373
  Box: "./components/Box/index.js",
@@ -380,5 +384,5 @@ const MakeswiftComponentType = {
380
384
  Text: "./components/Text/index.js",
381
385
  Video: "./components/Video/index.js"
382
386
  };
383
- export { reducer$6 as A, reducer$5 as B, reducer$4 as C, reducer$3 as D, reducer$2 as E, reducer$1 as F, getInitialState as G, MakeswiftComponentType as M, createDocumentReference as a, isPropControllersHandle as b, createDocument as c, getComponentPropControllerDescriptors as d, getPropControllers as e, configureStore as f, getPropControllerDescriptors as g, getDocument as h, isElementReference as i, getBreakpoints as j, getElementId as k, getIsPreview as l, getIsInBuilder as m, copyElementTree as n, getReactComponent as o, getBuilderEditMode as p, getInitialState$6 as q, reducer$7 as r, getDocument$1 as s, getComponentsMeta as t, getComponentPropControllerDescriptors$1 as u, getDocumentKeysSortedByDepth as v, getPropController as w, getPropControllersHandle as x, getElement as y, getElementPropControllerDescriptors as z };
387
+ export { reducer$6 as A, reducer$5 as B, reducer$4 as C, reducer$3 as D, reducer$2 as E, reducer$1 as F, getInitialState as G, MakeswiftComponentType as M, createDocumentReference as a, isPropControllersHandle as b, createDocument as c, getComponentPropControllerDescriptors as d, getPropControllers as e, configureStore as f, getPropControllerDescriptors as g, copyElementTree as h, isElementReference as i, getBreakpoints as j, getDocument as k, getElementId as l, getIsPreview as m, getIsInBuilder as n, getReactComponent as o, getBuilderEditMode as p, getInitialState$6 as q, reducer$7 as r, getDocument$1 as s, getComponentsMeta as t, getComponentPropControllerDescriptors$1 as u, getDocumentKeysSortedByDepth as v, getPropController as w, getPropControllersHandle as x, getElement as y, getElementPropControllerDescriptors as z };
384
388
  //# sourceMappingURL=constants.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.es.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/state/modules/prop-controller-handles.ts","../src/state/modules/is-in-builder.ts","../src/state/modules/is-preview.ts","../src/state/react-page.ts","../src/components/builtin/constants.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nexport function getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type { Component, PropsWithoutRef, ReactElement, RefAttributes } from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactElement<any, any> | null)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropController> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n","import { Action } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(isPreview = false): State {\n return isPreview\n}\n\nexport function getIsPreview(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action): State {\n switch (action.type) {\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\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 Breakpoints from './modules/breakpoints'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\nimport { copyElementReference } from '../prop-controllers/copy'\nimport { copy as copyFromControl } from '../controls/control'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.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 breakpoints: Breakpoints.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function 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\nexport function getPropControllers(state: State, documentKey: string, elementKey: string) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n *\n * @todo Make this selector more efficient.\n */\nexport function getDocumentKeysSortedByDepth(state: State): string[] {\n const documents = Documents.getDocuments(getDocumentsStateSlice(state))\n const keys = Array.from(documents.keys())\n\n if (keys.length < 2) return keys\n\n const elements = new Map<string, Map<string, Documents.Element>>()\n\n keys.forEach(key => {\n elements.set(key, getDocumentElements(state, key))\n })\n\n keys.sort((a, b) => (elements.get(a)?.has(b) ? -1 : 1))\n\n return keys\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport type ReplacementContext = {\n elementHtmlIds: Set<string>\n elementKeys: Map<string, string>\n swatchIds: Map<string, string>\n fileIds: Map<string, string>\n typographyIds: Map<string, string>\n tableIds: Map<string, string>\n tableColumnIds: Map<string, string>\n pageIds: Map<string, string>\n globalElementIds: Map<string, string>\n globalElementData: Map<string, Documents.ElementData>\n}\n\nexport type SerializableReplacementContext = {\n elementHtmlIds: string[]\n elementKeys: { [s: string]: string }\n swatchIds: { [s: string]: string }\n fileIds: { [s: string]: string }\n typographyIds: { [s: string]: string }\n tableIds: { [s: string]: string }\n tableColumnIds: { [s: string]: string }\n pageIds: { [s: string]: string }\n globalElementIds: { [s: string]: string }\n globalElementData: { [s: string]: Documents.ElementData }\n}\n\nexport function createReplacementContext(\n serializableReplacementContext: SerializableReplacementContext,\n): ReplacementContext {\n const rc: ReplacementContext = {\n elementHtmlIds: new Set(serializableReplacementContext.elementHtmlIds),\n elementKeys: new Map(\n serializableReplacementContext.elementKeys &&\n Object.entries(serializableReplacementContext.elementKeys),\n ),\n swatchIds: new Map(\n serializableReplacementContext.swatchIds &&\n Object.entries(serializableReplacementContext.swatchIds),\n ),\n fileIds: new Map(\n serializableReplacementContext.fileIds &&\n Object.entries(serializableReplacementContext.fileIds),\n ),\n typographyIds: new Map(\n serializableReplacementContext.typographyIds &&\n Object.entries(serializableReplacementContext.typographyIds),\n ),\n tableIds: new Map(\n serializableReplacementContext.tableIds &&\n Object.entries(serializableReplacementContext.tableIds),\n ),\n tableColumnIds: new Map(\n serializableReplacementContext.tableColumnIds &&\n Object.entries(serializableReplacementContext.tableColumnIds),\n ),\n pageIds: new Map(\n serializableReplacementContext.pageIds &&\n Object.entries(serializableReplacementContext.pageIds),\n ),\n globalElementIds: new Map(\n serializableReplacementContext.globalElementIds &&\n Object.entries(serializableReplacementContext.globalElementIds),\n ),\n globalElementData: new Map(\n serializableReplacementContext.globalElementData &&\n Object.entries(serializableReplacementContext.globalElementData),\n ),\n }\n\n return rc\n}\n\nexport type CopyContext = {\n replacementContext: ReplacementContext\n copyElement: (node: Documents.Element) => Documents.Element\n}\n\nexport function copyElementTree(\n state: State,\n elementTree: Documents.ElementData,\n replacementContext: SerializableReplacementContext,\n) {\n /*\n * This is structured a bit weird.\n *\n * This is done so that we can pass a callable function into some of the copy functions\n * themselves, to enable mutual recursion.\n *\n * Consider the slot control. It has to iterate through its elements, and for each of them,\n * call some version of the below function.\n *\n * That is how the recursing through the tree happens.\n */\n function copyElementTreeNode(state: State, replacementContext: ReplacementContext) {\n return function (node: Documents.Element) {\n const context = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return { ...node, value: copyElementReference(node.value, context) }\n }\n\n const descriptors = getComponentPropControllerDescriptors(state, node.type)\n\n if (descriptors == null) return node\n\n for (const [propKey, descriptor] of Object.entries(descriptors)) {\n node.props[propKey] = copyFromControl(descriptor, node.props[propKey], context)\n }\n\n return node\n }\n }\n\n const copy = JSON.parse(JSON.stringify(elementTree)) as Documents.ElementData\n\n return copyElementTreeNode(state, createReplacementContext(replacementContext))(copy)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsPreview(state: State): boolean {\n return IsPreview.getIsPreview(state.isPreview)\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n","/**\n * These are the element types that have been used since the beginning of Makeswift and are saved in\n * the database.\n */\nexport const MakeswiftComponentType = {\n Box: './components/Box/index.js',\n Button: './components/Button/index.js',\n Carousel: './components/Carousel/index.js',\n Countdown: './components/Countdown/index.js',\n Divider: './components/Divider/index.js',\n Embed: './components/Embed/index.js',\n Form: './components/Form/index.js',\n Image: './components/Image/index.js',\n Navigation: './components/Navigation/index.js',\n Root: './components/Root/index.js',\n SocialLinks: './components/SocialLinks/index.js',\n Text: './components/Text/index.js',\n Video: './components/Video/index.js',\n} as const\n"],"names":["getInitialState","reactComponents","Map","state","type","getReactComponents","get","action","ActionTypes","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","getPropControllers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Breakpoints.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","PropControllerHandles.getPropControllers","Documents.isElementReference","Introspection.getElementChildren","Documents.getDocuments","Introspection.getElementId","copyFromControl","copy","IsPreview.getIsPreview","Documents.getInitialState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AAChF,SAAO,CAAa,YAAA;AACtB;AAMO,iCAAiC,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;AAOO,wBAAwB,KAAa,aAAgC;AACnE,SAAA,EAAE,KAAK;AAChB;AAIgC,2BAAA;AAAA,EAC9B,mCAAmB,IAAI;AAAA,IACoB,IAAW;AAChD,QAAA,mCAAmB;AAEZ,eAAA,QAAQ,CAAC,aAAa,gBAAgB;AACjD,iBAAa,IAAI,aAAa,eAAe,aAAa,WAAW,CAAC;AAAA,EAAA,CACvE;AAEM,SAAA;AACT;AAEO,sBAAsB,OAAqC;AACzD,SAAA;AACT;AAEO,uBAAqB,OAAc,aAAsC;;AAC9E,SAAO,mBAAa,KAAK,EAAE,IAAI,WAAW,MAAnC,YAAwC;AACjD;AAEwB,mBAAA,QAAeA,kBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACR,YAAY;AACR,aAAA,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,OAAO,QAAQ,QAAQ;AAAA,SAE1E,YAAY,qBAAqB;AAC9B,YAAA,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,WAAW;AAE3D,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA;AAGS,aAAA;AAA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;AACtC,eAAO,iCAAK,OAAL,EAAW,OAAO,qBAAqB,KAAK,OAAO,OAAO;MACnE;AAEA,YAAM,cAAc,sCAAsC,QAAO,KAAK,IAAI;AAE1E,UAAI,eAAe;AAAa,eAAA;AAEhC,iBAAW,CAAC,SAAS,eAAe,OAAO,QAAQ,WAAW,GAAG;AAC/D,aAAK,MAAM,WAAWI,KAAgB,YAAY,KAAK,MAAM,UAAU,OAAO;AAAA,MAChF;AAEO,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAMC,SAAO,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAEnD,SAAO,oBAAoB,OAAO,yBAAyB,kBAAkB,CAAC,EAAEA,MAAI;AACtF;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,sBAAsB,OAAuB;AAC3C,SAAAC,eAAuB,MAAM,SAAS;AAC/C;AAEO,4BAA4B,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,wBAAwB,OAAiC;AAC9D,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,IAIE,IAAW;AACb,SAAO,YACL,SACA,iCAAK,iBAAL,EAAqB,WAAWC,kBAA0B,EAAE,aAAc,CAAA,EAC1E,IAAA,gBAAgB,KAAK,CACvB;AACF;AC7VO,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AACT;;"}
1
+ {"version":3,"file":"constants.es.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/state/modules/prop-controller-handles.ts","../src/state/modules/is-in-builder.ts","../src/state/modules/is-preview.ts","../src/state/react-page.ts","../src/components/builtin/constants.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nexport function getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type { Component, PropsWithoutRef, ReactElement, RefAttributes } from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactElement<any, any> | null)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport type { DescriptorsPropControllers, PropController } from '../../prop-controllers/instances'\nimport type { Descriptor } from '../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, PropController>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropController> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): PropController | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n","import { Action } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(isPreview = false): State {\n return isPreview\n}\n\nexport function getIsPreview(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action): State {\n switch (action.type) {\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\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 Breakpoints from './modules/breakpoints'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\nimport { copyElementReference } from '../prop-controllers/copy'\nimport { copy as copyFromControl } from '../controls/control'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.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 breakpoints: Breakpoints.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function 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\nexport function getPropControllers(state: State, documentKey: string, elementKey: string) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n *\n * @todo Make this selector more efficient.\n */\nexport function getDocumentKeysSortedByDepth(state: State): string[] {\n const documents = Documents.getDocuments(getDocumentsStateSlice(state))\n const keys = Array.from(documents.keys())\n\n if (keys.length < 2) return keys\n\n const elements = new Map<string, Map<string, Documents.Element>>()\n\n keys.forEach(key => {\n elements.set(key, getDocumentElements(state, key))\n })\n\n keys.sort((a, b) => (elements.get(a)?.has(b) ? -1 : 1))\n\n return keys\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport type ReplacementContext = {\n elementHtmlIds: Set<string>\n elementKeys: Map<string, string>\n swatchIds: Map<string, string>\n fileIds: Map<string, string>\n typographyIds: Map<string, string>\n tableIds: Map<string, string>\n tableColumnIds: Map<string, string>\n pageIds: Map<string, string>\n globalElementIds: Map<string, string>\n globalElementData: Map<string, Documents.ElementData>\n}\n\nexport type SerializableReplacementContext = {\n elementHtmlIds: string[]\n elementKeys: { [s: string]: string }\n swatchIds: { [s: string]: string }\n fileIds: { [s: string]: string }\n typographyIds: { [s: string]: string }\n tableIds: { [s: string]: string }\n tableColumnIds: { [s: string]: string }\n pageIds: { [s: string]: string }\n globalElementIds: { [s: string]: string }\n globalElementData: { [s: string]: Documents.ElementData }\n}\n\nexport function createReplacementContext(\n serializableReplacementContext: SerializableReplacementContext,\n): ReplacementContext {\n const rc: ReplacementContext = {\n elementHtmlIds: new Set(serializableReplacementContext.elementHtmlIds),\n elementKeys: new Map(\n serializableReplacementContext.elementKeys &&\n Object.entries(serializableReplacementContext.elementKeys),\n ),\n swatchIds: new Map(\n serializableReplacementContext.swatchIds &&\n Object.entries(serializableReplacementContext.swatchIds),\n ),\n fileIds: new Map(\n serializableReplacementContext.fileIds &&\n Object.entries(serializableReplacementContext.fileIds),\n ),\n typographyIds: new Map(\n serializableReplacementContext.typographyIds &&\n Object.entries(serializableReplacementContext.typographyIds),\n ),\n tableIds: new Map(\n serializableReplacementContext.tableIds &&\n Object.entries(serializableReplacementContext.tableIds),\n ),\n tableColumnIds: new Map(\n serializableReplacementContext.tableColumnIds &&\n Object.entries(serializableReplacementContext.tableColumnIds),\n ),\n pageIds: new Map(\n serializableReplacementContext.pageIds &&\n Object.entries(serializableReplacementContext.pageIds),\n ),\n globalElementIds: new Map(\n serializableReplacementContext.globalElementIds &&\n Object.entries(serializableReplacementContext.globalElementIds),\n ),\n globalElementData: new Map(\n serializableReplacementContext.globalElementData &&\n Object.entries(serializableReplacementContext.globalElementData),\n ),\n }\n\n return rc\n}\n\nexport type CopyContext = {\n replacementContext: ReplacementContext\n copyElement: (node: Documents.Element) => Documents.Element\n}\n\nexport function copyElementTree(\n state: State,\n elementTree: Documents.ElementData,\n replacementContext: SerializableReplacementContext,\n) {\n /*\n * This is structured a bit weird.\n *\n * This is done so that we can pass a callable function into some of the copy functions\n * themselves, to enable mutual recursion.\n *\n * Consider the slot control. It has to iterate through its elements, and for each of them,\n * call some version of the below function.\n *\n * That is how the recursing through the tree happens.\n */\n function copyElementTreeNode(state: State, replacementContext: ReplacementContext) {\n return function (node: Documents.Element) {\n const context = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return { ...node, value: copyElementReference(node.value, context) }\n }\n\n const descriptors = getComponentPropControllerDescriptors(state, node.type)\n\n if (descriptors == null) return node\n\n for (const [propKey, descriptor] of Object.entries(descriptors)) {\n node.props[propKey] = copyFromControl(descriptor, node.props[propKey], context)\n }\n\n return node\n }\n }\n\n const copy = JSON.parse(JSON.stringify(elementTree)) as Documents.ElementData\n\n return copyElementTreeNode(state, createReplacementContext(replacementContext))(copy)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsPreview(state: State): boolean {\n return IsPreview.getIsPreview(state.isPreview)\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n breakpoints,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n breakpoints?: Breakpoints.State\n} = {}): Store {\n return createStore(\n reducer,\n {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n applyMiddleware(thunk),\n )\n}\n","/**\n * These are the element types that have been used since the beginning of Makeswift and are saved in\n * the database.\n */\nexport const MakeswiftComponentType = {\n Box: './components/Box/index.js',\n Button: './components/Button/index.js',\n Carousel: './components/Carousel/index.js',\n Countdown: './components/Countdown/index.js',\n Divider: './components/Divider/index.js',\n Embed: './components/Embed/index.js',\n Form: './components/Form/index.js',\n Image: './components/Image/index.js',\n Navigation: './components/Navigation/index.js',\n Root: './components/Root/index.js',\n SocialLinks: './components/SocialLinks/index.js',\n Text: './components/Text/index.js',\n Video: './components/Video/index.js',\n} as const\n"],"names":["getInitialState","reactComponents","Map","state","type","getReactComponents","get","action","ActionTypes","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","getPropControllers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Breakpoints.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","PropControllerHandles.getPropControllers","Documents.isElementReference","Introspection.getElementChildren","Documents.getDocuments","Introspection.getElementId","copyFromControl","copy","IsPreview.getIsPreview","Documents.getInitialState","Breakpoints.getInitialState"],"m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W,CAAC;AAEnD,SAAO,oBAAoB,OAAO,yBAAyB,kBAAkB,CAAC,EAAEA,MAAI;AACtF;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,sBAAsB,OAAuB;AAC3C,SAAAC,eAAuB,MAAM,SAAS;AAC/C;AAEO,4BAA4B,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,wBAAwB,OAAiC;AAC9D,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,IAKE,IAAW;AACb,SAAO,YACL,SACA,iCACK,iBADL;AAAA,IAEE,WAAWC,kBAA0B,EAAE,cAAc;AAAA,IACrD,aAAaC,kBAA4B,oCAAe,iDAAgB,WAAW;AAAA,EAAA,IAErF,gBAAgB,KAAK,CACvB;AACF;ACnWO,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AACT;;"}
package/dist/index.cjs.js CHANGED
@@ -792,10 +792,11 @@ function useCachedSite(siteId) {
792
792
  return site;
793
793
  }
794
794
  class Makeswift {
795
- constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
795
+ constructor(apiKey, { apiOrigin = "https://api.makeswift.com", runtime } = {}) {
796
796
  __publicField(this, "apiKey");
797
797
  __publicField(this, "apiOrigin");
798
798
  __publicField(this, "graphqlClient");
799
+ __publicField(this, "runtime");
799
800
  if (typeof apiKey !== "string") {
800
801
  throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
801
802
  Received "${apiKey}" instead.`);
@@ -807,6 +808,7 @@ Received "${apiKey}" instead.`);
807
808
  throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
808
809
  }
809
810
  this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href);
811
+ this.runtime = runtime;
810
812
  }
811
813
  async fetch(path, init) {
812
814
  const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
@@ -832,7 +834,9 @@ Received "${apiKey}" instead.`);
832
834
  return result;
833
835
  }
834
836
  async introspect(element) {
835
- const descriptors$1 = constants.getPropControllerDescriptors(storeContextDefaultValue.getState());
837
+ var _a;
838
+ const runtime = (_a = this.runtime) != null ? _a : ReactRuntime;
839
+ const descriptors$1 = constants.getPropControllerDescriptors(runtime.store.getState());
836
840
  const swatchIds = /* @__PURE__ */ new Set();
837
841
  const fileIds = /* @__PURE__ */ new Set();
838
842
  const typographyIds = /* @__PURE__ */ new Set();
@@ -907,8 +911,8 @@ Received "${apiKey}" instead.`);
907
911
  const typographies = await this.getTypographies([...typographyIds]);
908
912
  typographies.forEach((typography) => {
909
913
  typography == null ? void 0 : typography.style.forEach((style) => {
910
- var _a;
911
- const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
914
+ var _a2;
915
+ const swatchId = (_a2 = style.value.color) == null ? void 0 : _a2.swatchId;
912
916
  if (swatchId != null)
913
917
  swatchIds.add(swatchId);
914
918
  });
@@ -924,38 +928,38 @@ Received "${apiKey}" instead.`);
924
928
  }));
925
929
  return {
926
930
  [types.APIResourceType.Swatch]: [...swatchIds].map((id) => {
927
- var _a;
931
+ var _a2;
928
932
  return {
929
933
  id,
930
- value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
934
+ value: (_a2 = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a2 : null
931
935
  };
932
936
  }),
933
937
  [types.APIResourceType.File]: [...fileIds].map((id) => {
934
- var _a;
938
+ var _a2;
935
939
  return {
936
940
  id,
937
- value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
941
+ value: (_a2 = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a2 : null
938
942
  };
939
943
  }),
940
944
  [types.APIResourceType.Typography]: [...typographyIds].map((id) => {
941
- var _a;
945
+ var _a2;
942
946
  return {
943
947
  id,
944
- value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
948
+ value: (_a2 = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a2 : null
945
949
  };
946
950
  }),
947
951
  [types.APIResourceType.Table]: [...tableIds].map((id) => {
948
- var _a;
952
+ var _a2;
949
953
  return {
950
954
  id,
951
- value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
955
+ value: (_a2 = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a2 : null
952
956
  };
953
957
  }),
954
958
  [types.APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
955
- var _a;
959
+ var _a2;
956
960
  return {
957
961
  id,
958
- value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
962
+ value: (_a2 = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a2 : null
959
963
  };
960
964
  }),
961
965
  [types.APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
@@ -1157,7 +1161,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1157
1161
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1158
1162
  return res.json(fonts2);
1159
1163
  }
1160
- const version = "0.8.6";
1164
+ const version = "0.8.8";
1161
1165
  async function handler(req, res, { apiKey }) {
1162
1166
  if (req.query.secret !== apiKey) {
1163
1167
  return res.status(401).json({ message: "Unauthorized" });
@@ -1167,7 +1171,8 @@ async function handler(req, res, { apiKey }) {
1167
1171
  previewMode: true,
1168
1172
  interactionMode: true,
1169
1173
  clientSideNavigation: true,
1170
- elementFromPoint: false
1174
+ elementFromPoint: false,
1175
+ customBreakpoints: true
1171
1176
  });
1172
1177
  }
1173
1178
  async function proxyPreviewMode(req, res, { apiKey }) {
@@ -1412,7 +1417,8 @@ async function getServerSideProps(ctx) {
1412
1417
  };
1413
1418
  }
1414
1419
  const Page = React.memo(({
1415
- snapshot
1420
+ snapshot,
1421
+ runtime
1416
1422
  }) => {
1417
1423
  const client = React.useMemo(() => new MakeswiftClient({
1418
1424
  uri: new URL("graphql", snapshot.apiOrigin).href,
@@ -1422,6 +1428,7 @@ const Page = React.memo(({
1422
1428
  client,
1423
1429
  rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
1424
1430
  preview: snapshot.preview,
1431
+ runtime,
1425
1432
  children: /* @__PURE__ */ jsxRuntime.jsx(Page$1, {
1426
1433
  document: snapshot.document
1427
1434
  }, snapshot.document.data.key)
@@ -3688,41 +3695,68 @@ function isDomNodeHandle(value) {
3688
3695
  }
3689
3696
  return false;
3690
3697
  }
3691
- const storeContextDefaultValue = constants.configureStore();
3692
- function createReactRuntime(store) {
3693
- return {
3694
- registerComponent(component, {
3695
- type,
3698
+ class ReactRuntime {
3699
+ constructor({
3700
+ breakpoints
3701
+ }) {
3702
+ __publicField(this, "store");
3703
+ this.store = constants.configureStore({
3704
+ breakpoints: breakpoints ? state_breakpoints.parseBreakpointsInput(breakpoints) : void 0
3705
+ });
3706
+ registerBuiltinComponents(this);
3707
+ }
3708
+ static registerComponent(component, {
3709
+ type,
3710
+ label,
3711
+ icon = "Cube40",
3712
+ hidden = false,
3713
+ props
3714
+ }) {
3715
+ const unregisterComponent = this.store.dispatch(actions.registerComponentEffect(type, {
3696
3716
  label,
3697
- icon = "Cube40",
3698
- hidden = false,
3699
- props
3700
- }) {
3701
- const unregisterComponent = store.dispatch(actions.registerComponentEffect(type, {
3702
- label,
3703
- icon,
3704
- hidden
3705
- }, props != null ? props : {}));
3706
- const unregisterReactComponent = store.dispatch(actions.registerReactComponentEffect(type, component));
3707
- return () => {
3708
- unregisterComponent();
3709
- unregisterReactComponent();
3710
- };
3711
- },
3712
- copyElementTree(elementTree2, replacementContext) {
3713
- return constants.copyElementTree(store.getState(), elementTree2, replacementContext);
3714
- },
3715
- getBreakpoints() {
3716
- return constants.getBreakpoints(store.getState());
3717
- },
3718
- unstable_setBreakpoints(breakpoints) {
3719
- return store.dispatch(actions.setBreakpoints(state_breakpoints.parseBreakpointsInput(breakpoints)));
3720
- }
3721
- };
3717
+ icon,
3718
+ hidden
3719
+ }, props != null ? props : {}));
3720
+ const unregisterReactComponent = this.store.dispatch(actions.registerReactComponentEffect(type, component));
3721
+ return () => {
3722
+ unregisterComponent();
3723
+ unregisterReactComponent();
3724
+ };
3725
+ }
3726
+ static copyElementTree(elementTree2, replacementContext) {
3727
+ return constants.copyElementTree(this.store.getState(), elementTree2, replacementContext);
3728
+ }
3729
+ static getBreakpoints() {
3730
+ return constants.getBreakpoints(this.store.getState());
3731
+ }
3732
+ registerComponent(component, {
3733
+ type,
3734
+ label,
3735
+ icon = "Cube40",
3736
+ hidden = false,
3737
+ props
3738
+ }) {
3739
+ const unregisterComponent = this.store.dispatch(actions.registerComponentEffect(type, {
3740
+ label,
3741
+ icon,
3742
+ hidden
3743
+ }, props != null ? props : {}));
3744
+ const unregisterReactComponent = this.store.dispatch(actions.registerReactComponentEffect(type, component));
3745
+ return () => {
3746
+ unregisterComponent();
3747
+ unregisterReactComponent();
3748
+ };
3749
+ }
3750
+ copyElementTree(elementTree2, replacementContext) {
3751
+ return constants.copyElementTree(this.store.getState(), elementTree2, replacementContext);
3752
+ }
3753
+ getBreakpoints() {
3754
+ return constants.getBreakpoints(this.store.getState());
3755
+ }
3722
3756
  }
3723
- const ReactRuntime = createReactRuntime(storeContextDefaultValue);
3757
+ __publicField(ReactRuntime, "store", constants.configureStore());
3724
3758
  registerBuiltinComponents(ReactRuntime);
3725
- const StoreContext = React.createContext(storeContextDefaultValue);
3759
+ const StoreContext = React.createContext(ReactRuntime.store);
3726
3760
  const PreviewProvider = dynamic__default["default"](() => Promise.resolve().then(function() {
3727
3761
  return require("./PreviewProvider.cjs.js");
3728
3762
  }));
@@ -3966,7 +4000,6 @@ exports.getServerSideProps = getServerSideProps;
3966
4000
  exports.getStaticPaths = getStaticPaths;
3967
4001
  exports.getStaticProps = getStaticProps;
3968
4002
  exports.pollBoxModel = pollBoxModel;
3969
- exports.storeContextDefaultValue = storeContextDefaultValue;
3970
4003
  exports.useBorder = useBorder;
3971
4004
  exports.useBoxShadow = useBoxShadow;
3972
4005
  exports.useBreakpoints = useBreakpoints;