@makeswift/runtime 0.26.0 → 0.26.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/builder/index.js +22 -18
- package/dist/cjs/builder/index.js.map +1 -1
- package/dist/cjs/builder/serialization/control-serialization.js +7 -3
- package/dist/cjs/builder/serialization/control-serialization.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +0 -21
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/cjs/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js +72 -0
- package/dist/cjs/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +1 -0
- package/dist/cjs/controls/visitors/message-port-serializer/function-serialization.js +79 -0
- package/dist/cjs/controls/visitors/message-port-serializer/function-serialization.js.map +1 -0
- package/dist/cjs/controls/visitors/message-port-serializer/index.js +36 -0
- package/dist/cjs/controls/visitors/message-port-serializer/index.js.map +1 -0
- package/dist/cjs/next/hooks/use-router-locale-sync.js +2 -2
- package/dist/cjs/next/hooks/use-router-locale-sync.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js +3 -2
- package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/cjs/runtimes/react/components/PreviewProvider.js +9 -3
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js +5 -10
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-register-document.js +4 -3
- package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +3 -3
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/state/actions/index.js +42 -0
- package/dist/cjs/state/actions/index.js.map +1 -0
- package/dist/cjs/state/actions/internal.js +205 -0
- package/dist/cjs/state/actions/internal.js.map +1 -0
- package/dist/cjs/state/builder-api/actions.js +149 -0
- package/dist/cjs/state/builder-api/actions.js.map +1 -0
- package/dist/cjs/state/builder-api/message-channel.js +62 -0
- package/dist/cjs/state/builder-api/message-channel.js.map +1 -0
- package/dist/cjs/state/builder-api/proxy.js +62 -0
- package/dist/cjs/state/builder-api/proxy.js.map +1 -0
- package/dist/cjs/state/host-api.js +117 -0
- package/dist/cjs/state/host-api.js.map +1 -0
- package/dist/cjs/state/makeswift-api-client.js +4 -2
- package/dist/cjs/state/makeswift-api-client.js.map +1 -1
- package/dist/cjs/state/react-builder-preview.js +73 -97
- package/dist/cjs/state/react-builder-preview.js.map +1 -1
- package/dist/cjs/state/react-page.js +5 -4
- package/dist/cjs/state/react-page.js.map +1 -1
- package/dist/cjs/state/shared-api.js +79 -0
- package/dist/cjs/state/shared-api.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/builder/index.js +15 -9
- package/dist/esm/builder/index.js.map +1 -1
- package/dist/esm/builder/serialization/control-serialization.js +10 -3
- package/dist/esm/builder/serialization/control-serialization.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js +0 -22
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/esm/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js +53 -0
- package/dist/esm/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +1 -0
- package/dist/esm/controls/visitors/message-port-serializer/function-serialization.js +52 -0
- package/dist/esm/controls/visitors/message-port-serializer/function-serialization.js.map +1 -0
- package/dist/esm/controls/visitors/message-port-serializer/index.js +13 -0
- package/dist/esm/controls/visitors/message-port-serializer/index.js.map +1 -0
- package/dist/esm/next/hooks/use-router-locale-sync.js +1 -1
- package/dist/esm/next/hooks/use-router-locale-sync.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js +2 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/esm/runtimes/react/components/PreviewProvider.js +9 -3
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js +5 -10
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-register-document.js +2 -5
- package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/state/actions/index.js +17 -0
- package/dist/esm/state/actions/index.js.map +1 -0
- package/dist/esm/state/actions/internal.js +162 -0
- package/dist/esm/state/actions/internal.js.map +1 -0
- package/dist/esm/state/builder-api/actions.js +109 -0
- package/dist/esm/state/builder-api/actions.js.map +1 -0
- package/dist/esm/state/builder-api/message-channel.js +38 -0
- package/dist/esm/state/builder-api/message-channel.js.map +1 -0
- package/dist/esm/state/builder-api/proxy.js +38 -0
- package/dist/esm/state/builder-api/proxy.js.map +1 -0
- package/dist/esm/state/host-api.js +81 -0
- package/dist/esm/state/host-api.js.map +1 -0
- package/dist/esm/state/makeswift-api-client.js +3 -1
- package/dist/esm/state/makeswift-api-client.js.map +1 -1
- package/dist/esm/state/react-builder-preview.js +72 -115
- package/dist/esm/state/react-builder-preview.js.map +1 -1
- package/dist/esm/state/react-page.js +3 -7
- package/dist/esm/state/react-page.js.map +1 -1
- package/dist/esm/state/shared-api.js +49 -0
- package/dist/esm/state/shared-api.js.map +1 -0
- package/dist/types/builder/index.d.ts +3 -2
- package/dist/types/builder/index.d.ts.map +1 -1
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +16 -16
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +1 -2
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts +9 -0
- package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts.map +1 -0
- package/dist/types/controls/visitors/message-port-serializer/function-serialization.d.ts +16 -0
- package/dist/types/controls/visitors/message-port-serializer/function-serialization.d.ts.map +1 -0
- package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts +2 -0
- package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts.map +1 -0
- package/dist/types/controls/visitors/message-port-serializer/index.d.ts +3 -0
- package/dist/types/controls/visitors/message-port-serializer/index.d.ts.map +1 -0
- package/dist/types/locale.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts +3 -1
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-store.d.ts +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
- package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
- package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/state/actions/index.d.ts +58 -0
- package/dist/types/state/actions/index.d.ts.map +1 -0
- package/dist/types/state/actions/internal.d.ts +181 -0
- package/dist/types/state/actions/internal.d.ts.map +1 -0
- package/dist/types/state/builder-api/actions.d.ts +157 -0
- package/dist/types/state/builder-api/actions.d.ts.map +1 -0
- package/dist/types/state/builder-api/message-channel.d.ts +13 -0
- package/dist/types/state/builder-api/message-channel.d.ts.map +1 -0
- package/dist/types/state/builder-api/proxy.d.ts +15 -0
- package/dist/types/state/builder-api/proxy.d.ts.map +1 -0
- package/dist/types/state/host-api.d.ts +111 -0
- package/dist/types/state/host-api.d.ts.map +1 -0
- package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/state/react-builder-preview.d.ts +5 -7
- package/dist/types/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/state/react-page.d.ts.map +1 -1
- package/dist/types/state/shared-api.d.ts +69 -0
- package/dist/types/state/shared-api.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/cjs/state/actions.js +0 -423
- package/dist/cjs/state/actions.js.map +0 -1
- package/dist/esm/state/actions.js +0 -349
- package/dist/esm/state/actions.js.map +0 -1
- package/dist/types/state/actions.d.ts +0 -461
- package/dist/types/state/actions.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/react-page.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkDispatch,\n type Middleware,\n} from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport {\n createReplacementContext,\n type SerializableReplacementContext,\n type ReplacementContext,\n type MergeContext,\n CopyContext,\n replaceResourceIfNeeded,\n ContextResource,\n} from '@makeswift/controls'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\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 {\n type Action,\n ActionTypes,\n changeElementTree,\n createElementTree,\n deleteElementTree,\n} from './actions'\nimport { copy as copyFromControl, merge } from '../controls/control'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport { withSetupTeardown } from './mixins/setup-teardown'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n elementTrees: ElementTrees.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>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\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 getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(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 getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | 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\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\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 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: CopyContext = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return {\n ...node,\n value: replaceResourceIfNeeded(ContextResource.GlobalElement, node.value, context),\n }\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 mergeElement(\n state: State,\n baseElement: Documents.Element,\n overrideElement: Documents.Element,\n): Documents.Element {\n if (baseElement.type !== overrideElement.type || baseElement.key !== overrideElement.key) {\n throw new Error(`Can't merge elements of different types or keys`)\n }\n\n if (Documents.isElementReference(overrideElement)) return overrideElement\n\n if (Documents.isElementReference(baseElement)) return baseElement\n\n const elementDescriptors = getPropControllerDescriptors(state)\n const descriptors = elementDescriptors.get(baseElement.type)\n\n if (descriptors == null) {\n throw new Error(\n `Can't merge element of type \"${baseElement.type}\" because it has no descriptors`,\n )\n }\n\n const mergedProps = {} as Record<string, Documents.Data>\n\n for (const propName of Object.keys(descriptors)) {\n const descriptor = descriptors[propName]\n const context: MergeContext = {\n mergeElement(base, override) {\n return mergeElement(state, base, override)\n },\n }\n\n mergedProps[propName] = merge(\n descriptor,\n baseElement.props[propName],\n overrideElement.props[propName],\n context,\n )\n }\n\n return { ...baseElement, props: mergedProps }\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 function elementTreeMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return action => {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n dispatch(\n createElementTree({\n document: action.payload.document,\n descriptors: getPropControllerDescriptors(getState()),\n }),\n )\n break\n\n case ActionTypes.CHANGE_DOCUMENT: {\n const { documentKey, operation } = action.payload\n\n const oldDocument = getDocument(getState(), documentKey)\n const result = next(action)\n const newDocument = getDocument(getState(), documentKey)\n\n if (oldDocument != null && newDocument != null && newDocument !== oldDocument) {\n dispatch(\n changeElementTree({\n oldDocument,\n newDocument,\n descriptors: getPropControllerDescriptors(getState()),\n operation,\n }),\n )\n }\n\n return result\n }\n\n case ActionTypes.UNREGISTER_DOCUMENT:\n dispatch(deleteElementTree(action.payload))\n break\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n name,\n preloadedState,\n breakpoints,\n}: {\n name: string\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(elementTreeMiddleware()),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withSetupTeardown(\n () => {},\n () => {},\n ),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n }),\n })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H;AAAA,UACF;AAEA,iBAAO;AAAA,QACT;AAAA,QAEA,KAAK,2BAAY;AACf,uBAAS,kCAAkB,OAAO,OAAO,CAAC;AAC1C;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,aAAO,eAAAC,gBAAoB;AAAA,IACzB;AAAA,IACA,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,aAAa,YAAY,gBAAgB,eAAe,gBAAgB,WAAW;AAAA,IACrF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO,sBAAsB,CAAC;AAAA,IAExE,WAAW,yBACT,oBAAoB,EAAE;AAAA,UACpB;AAAA,QACE,MAAM;AAAA,QAAC;AAAA,QACP,MAAM;AAAA,QAAC;AAAA,MACT;AAAA,IACF;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,IAC5C,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","state","replacementContext","copyFromControl","configureReduxStore"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/react-page.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkDispatch,\n type Middleware,\n} from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport {\n createReplacementContext,\n type SerializableReplacementContext,\n type ReplacementContext,\n type MergeContext,\n CopyContext,\n replaceResourceIfNeeded,\n ContextResource,\n} from '@makeswift/controls'\n\nimport { copy as copyFromControl, merge } from '../controls/control'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\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'\n\nimport { type Action, ActionTypes } from './actions'\nimport { changeElementTree, createElementTree, deleteElementTree } from './actions/internal'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport { withSetupTeardown } from './mixins/setup-teardown'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n elementTrees: ElementTrees.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>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\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 getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(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 getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | 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\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\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 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: CopyContext = {\n replacementContext,\n copyElement: copyElementTreeNode(state, replacementContext),\n }\n\n if (Documents.isElementReference(node)) {\n return {\n ...node,\n value: replaceResourceIfNeeded(ContextResource.GlobalElement, node.value, context),\n }\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 mergeElement(\n state: State,\n baseElement: Documents.Element,\n overrideElement: Documents.Element,\n): Documents.Element {\n if (baseElement.type !== overrideElement.type || baseElement.key !== overrideElement.key) {\n throw new Error(`Can't merge elements of different types or keys`)\n }\n\n if (Documents.isElementReference(overrideElement)) return overrideElement\n\n if (Documents.isElementReference(baseElement)) return baseElement\n\n const elementDescriptors = getPropControllerDescriptors(state)\n const descriptors = elementDescriptors.get(baseElement.type)\n\n if (descriptors == null) {\n throw new Error(\n `Can't merge element of type \"${baseElement.type}\" because it has no descriptors`,\n )\n }\n\n const mergedProps = {} as Record<string, Documents.Data>\n\n for (const propName of Object.keys(descriptors)) {\n const descriptor = descriptors[propName]\n const context: MergeContext = {\n mergeElement(base, override) {\n return mergeElement(state, base, override)\n },\n }\n\n mergedProps[propName] = merge(\n descriptor,\n baseElement.props[propName],\n overrideElement.props[propName],\n context,\n )\n }\n\n return { ...baseElement, props: mergedProps }\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 function elementTreeMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return action => {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n dispatch(\n createElementTree({\n document: action.payload.document,\n descriptors: getPropControllerDescriptors(getState()),\n }),\n )\n break\n\n case ActionTypes.CHANGE_DOCUMENT: {\n const { documentKey, operation } = action.payload\n\n const oldDocument = getDocument(getState(), documentKey)\n const result = next(action)\n const newDocument = getDocument(getState(), documentKey)\n\n if (oldDocument != null && newDocument != null && newDocument !== oldDocument) {\n dispatch(\n changeElementTree({\n oldDocument,\n newDocument,\n descriptors: getPropControllerDescriptors(getState()),\n operation,\n }),\n )\n }\n\n return result\n }\n\n case ActionTypes.UNREGISTER_DOCUMENT:\n dispatch(deleteElementTree(action.payload))\n break\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n name,\n preloadedState,\n breakpoints,\n}: {\n name: string\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(elementTreeMiddleware()),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withSetupTeardown(\n () => {},\n () => {},\n ),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;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ACT;AAAA,QAEA,KAAK,2BAAY;AACf,uBAAS,mCAAkB,OAAO,OAAO,CAAC;AAC1C;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,aAAO,eAAAC,gBAAoB;AAAA,IACzB;AAAA,IACA,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,aAAa,YAAY,gBAAgB,eAAe,gBAAgB,WAAW;AAAA,IACrF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO,sBAAsB,CAAC;AAAA,IAExE,WAAW,yBACT,oBAAoB,EAAE;AAAA,UACpB;AAAA,QACE,MAAM;AAAA,QAAC;AAAA,QACP,MAAM;AAAA,QAAC;AAAA,MACT;AAAA,IACF;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,IAC5C,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","state","replacementContext","copyFromControl","configureReduxStore"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var shared_api_exports = {};
|
|
20
|
+
__export(shared_api_exports, {
|
|
21
|
+
SharedActionTypes: () => SharedActionTypes,
|
|
22
|
+
makeswiftConnectionInit: () => makeswiftConnectionInit,
|
|
23
|
+
registerDocument: () => registerDocument,
|
|
24
|
+
registerDocumentsEffect: () => registerDocumentsEffect,
|
|
25
|
+
setBreakpoints: () => setBreakpoints,
|
|
26
|
+
setLocale: () => setLocale,
|
|
27
|
+
unregisterDocument: () => unregisterDocument
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(shared_api_exports);
|
|
30
|
+
var import_locale = require("../locale");
|
|
31
|
+
const SharedActionTypes = {
|
|
32
|
+
MAKESWIFT_CONNECTION_INIT: "MAKESWIFT_CONNECTION_INIT",
|
|
33
|
+
REGISTER_DOCUMENT: "REGISTER_DOCUMENT",
|
|
34
|
+
UNREGISTER_DOCUMENT: "UNREGISTER_DOCUMENT",
|
|
35
|
+
SET_BREAKPOINTS: "SET_BREAKPOINTS",
|
|
36
|
+
SET_LOCALE: "SET_LOCALE"
|
|
37
|
+
};
|
|
38
|
+
function makeswiftConnectionInit() {
|
|
39
|
+
return {
|
|
40
|
+
type: SharedActionTypes.MAKESWIFT_CONNECTION_INIT
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function registerDocument(document) {
|
|
44
|
+
return {
|
|
45
|
+
type: SharedActionTypes.REGISTER_DOCUMENT,
|
|
46
|
+
payload: { documentKey: document.key, document }
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function unregisterDocument(documentKey) {
|
|
50
|
+
return { type: SharedActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } };
|
|
51
|
+
}
|
|
52
|
+
function registerDocumentsEffect(documents) {
|
|
53
|
+
return (dispatch) => {
|
|
54
|
+
documents.forEach((document) => dispatch(registerDocument(document)));
|
|
55
|
+
return () => {
|
|
56
|
+
documents.forEach((document) => dispatch(unregisterDocument(document.key)));
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function setBreakpoints(breakpoints) {
|
|
61
|
+
return { type: SharedActionTypes.SET_BREAKPOINTS, payload: { breakpoints } };
|
|
62
|
+
}
|
|
63
|
+
function setLocale(locale, pathname) {
|
|
64
|
+
return {
|
|
65
|
+
type: SharedActionTypes.SET_LOCALE,
|
|
66
|
+
payload: { locale: import_locale.localeStringSchema.parse(locale.toString()), pathname }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
SharedActionTypes,
|
|
72
|
+
makeswiftConnectionInit,
|
|
73
|
+
registerDocument,
|
|
74
|
+
registerDocumentsEffect,
|
|
75
|
+
setBreakpoints,
|
|
76
|
+
setLocale,
|
|
77
|
+
unregisterDocument
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=shared-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/state/shared-api.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type LocaleString, localeStringSchema } from '../locale'\n\nimport { type Breakpoints } from './modules/breakpoints'\nimport { type Element, type Document, EMBEDDED_DOCUMENT_TYPE } from './modules/read-only-documents'\n\ntype DocumentPayloadBaseDocument = {\n key: string\n rootElement: Element\n locale?: string | null // older versions of the runtime may not provide this field\n}\n\ntype DocumentPayloadEmbeddedDocument = {\n key: string\n locale: string | null\n id: string\n type: string\n name: string\n rootElement: Element\n meta: { allowLocaleFallback: boolean; requestedLocale: string | null; description?: string }\n __type: typeof EMBEDDED_DOCUMENT_TYPE\n}\n\nexport type DocumentPayload = DocumentPayloadBaseDocument | DocumentPayloadEmbeddedDocument\n\nexport const SharedActionTypes = {\n MAKESWIFT_CONNECTION_INIT: 'MAKESWIFT_CONNECTION_INIT',\n\n REGISTER_DOCUMENT: 'REGISTER_DOCUMENT',\n UNREGISTER_DOCUMENT: 'UNREGISTER_DOCUMENT',\n\n SET_BREAKPOINTS: 'SET_BREAKPOINTS',\n SET_LOCALE: 'SET_LOCALE',\n} as const\n\ntype MakeswiftConnectionInitAction = { type: typeof SharedActionTypes.MAKESWIFT_CONNECTION_INIT }\n\ntype RegisterDocumentAction = {\n type: typeof SharedActionTypes.REGISTER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterDocumentAction = {\n type: typeof SharedActionTypes.UNREGISTER_DOCUMENT\n payload: { documentKey: string }\n}\n\nexport type SetBreakpointsAction = {\n type: typeof SharedActionTypes.SET_BREAKPOINTS\n payload: { breakpoints: Breakpoints }\n}\n\ntype SetLocaleAction = {\n type: typeof SharedActionTypes.SET_LOCALE\n payload: { locale: LocaleString; pathname?: string }\n}\n\nexport type SharedAction =\n | MakeswiftConnectionInitAction\n | RegisterDocumentAction\n | UnregisterDocumentAction\n | SetBreakpointsAction\n | SetLocaleAction\n\nexport function makeswiftConnectionInit(): MakeswiftConnectionInitAction {\n return {\n type: SharedActionTypes.MAKESWIFT_CONNECTION_INIT,\n }\n}\n\nexport function registerDocument(document: Document): RegisterDocumentAction {\n return {\n type: SharedActionTypes.REGISTER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterDocument(documentKey: string): UnregisterDocumentAction {\n return { type: SharedActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, SharedAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterDocument(document.key)))\n }\n }\n}\n\nexport function setBreakpoints(breakpoints: Breakpoints): SetBreakpointsAction {\n return { type: SharedActionTypes.SET_BREAKPOINTS, payload: { breakpoints } }\n}\n\nexport function setLocale(locale: Intl.Locale, pathname?: string): SetLocaleAction {\n return {\n type: SharedActionTypes.SET_LOCALE,\n payload: { locale: localeStringSchema.parse(locale.toString()), pathname },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAsD;AAwB/C,MAAM,oBAAoB;AAAA,EAC/B,2BAA2B;AAAA,EAE3B,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EAErB,iBAAiB;AAAA,EACjB,YAAY;AACd;AA+BO,SAAS,0BAAyD;AACvE,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,EAC1B;AACF;AAEO,SAAS,iBAAiB,UAA4C;AAC3E,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,mBAAmB,aAA+C;AAChF,SAAO,EAAE,MAAM,kBAAkB,qBAAqB,SAAS,EAAE,YAAY,EAAE;AACjF;AAEO,SAAS,wBACd,WACyD;AACzD,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,iBAAiB,QAAQ,CAAC,CAAC;AAElE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,mBAAmB,SAAS,GAAG,CAAC,CAAC;AAAA,IAC1E;AAAA,EACF;AACF;AAEO,SAAS,eAAe,aAAgD;AAC7E,SAAO,EAAE,MAAM,kBAAkB,iBAAiB,SAAS,EAAE,YAAY,EAAE;AAC7E;AAEO,SAAS,UAAU,QAAqB,UAAoC;AACjF,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,SAAS,EAAE,QAAQ,iCAAmB,MAAM,OAAO,SAAS,CAAC,GAAG,SAAS;AAAA,EAC3E;AACF;","names":[]}
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.26.
|
|
11
|
+
version: "0.26.1-canary.1",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
export * from "./serialization";
|
|
2
2
|
export * from "./unstructured-introspection";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
BuilderActionTypes
|
|
5
|
+
} from "../state/builder-api/actions";
|
|
6
|
+
import {
|
|
7
|
+
makeswiftConnectionInit,
|
|
8
|
+
registerDocument,
|
|
9
|
+
unregisterDocument,
|
|
10
|
+
setBreakpoints,
|
|
11
|
+
setLocale
|
|
12
|
+
} from "../state/shared-api";
|
|
13
|
+
import {
|
|
5
14
|
changeDocument,
|
|
6
15
|
changeDocumentElementScrollTop,
|
|
7
16
|
cleanUp,
|
|
@@ -9,23 +18,19 @@ import {
|
|
|
9
18
|
messageHostPropController,
|
|
10
19
|
changeApiResource,
|
|
11
20
|
evictApiResource,
|
|
12
|
-
registerDocument,
|
|
13
21
|
scrollDocumentElement,
|
|
14
|
-
unregisterDocument,
|
|
15
22
|
setBuilderEditMode,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setLocalizedResourceId
|
|
20
|
-
} from "../state/actions";
|
|
23
|
+
setLocalizedResourceId,
|
|
24
|
+
builderPointerMove
|
|
25
|
+
} from "../state/host-api";
|
|
21
26
|
import { createBaseDocument } from "../state/react-page";
|
|
22
27
|
import * as Props from "../prop-controllers/descriptors";
|
|
23
28
|
import { TableFormFieldsMessageType } from "../prop-controllers/instances";
|
|
24
29
|
import * as Introspection from "../prop-controllers/introspection";
|
|
25
30
|
import { DELETED_PROP_CONTROLLER_TYPES } from "../prop-controllers/deleted";
|
|
26
31
|
export {
|
|
27
|
-
ActionTypes,
|
|
28
32
|
DELETED_PROP_CONTROLLER_TYPES,
|
|
33
|
+
BuilderActionTypes as HostToBuilderActionTypes,
|
|
29
34
|
Introspection,
|
|
30
35
|
Props,
|
|
31
36
|
TableFormFieldsMessageType,
|
|
@@ -37,6 +42,7 @@ export {
|
|
|
37
42
|
createBaseDocument,
|
|
38
43
|
evictApiResource,
|
|
39
44
|
init,
|
|
45
|
+
makeswiftConnectionInit,
|
|
40
46
|
messageHostPropController,
|
|
41
47
|
registerDocument,
|
|
42
48
|
scrollDocumentElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\n\nexport {\n type BuilderAction as HostToBuilderAction,\n BuilderActionTypes as HostToBuilderActionTypes,\n} from '../state/builder-api/actions'\n\nexport {\n type SetBreakpointsAction,\n makeswiftConnectionInit,\n registerDocument,\n unregisterDocument,\n setBreakpoints,\n setLocale,\n} from '../state/shared-api'\n\nexport {\n changeDocument,\n changeDocumentElementScrollTop,\n cleanUp,\n init,\n messageHostPropController,\n changeApiResource,\n evictApiResource,\n scrollDocumentElement,\n setBuilderEditMode,\n setLocalizedResourceId,\n builderPointerMove,\n} from '../state/host-api'\n\nexport { type Operation } from '../state/modules/read-write-documents'\n\nexport { createBaseDocument } from '../state/react-page'\n\nexport type {\n Descriptor as PropControllerDescriptor,\n DescriptorValueType as PropControllerDescriptorValueType,\n PanelDescriptor,\n PanelDescriptorType,\n PanelDescriptorValueType,\n} from '../prop-controllers/descriptors'\n\nexport * as Props from '../prop-controllers/descriptors'\nexport type { PropControllerMessage, TableFormFieldsMessage } from '../prop-controllers/instances'\nexport { TableFormFieldsMessageType } from '../prop-controllers/instances'\nexport * as Introspection from '../prop-controllers/introspection'\nexport { DELETED_PROP_CONTROLLER_TYPES } from '../prop-controllers/deleted'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AAEd;AAAA,EAEwB;AAAA,OACjB;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,0BAA0B;AAUnC,YAAY,WAAW;AAEvB,SAAS,kCAAkC;AAC3C,YAAY,mBAAmB;AAC/B,SAAS,qCAAqC;","names":[]}
|
|
@@ -36,6 +36,10 @@ import {
|
|
|
36
36
|
} from "@makeswift/prop-controllers";
|
|
37
37
|
import { isLegacyDescriptor } from "../../prop-controllers/descriptors";
|
|
38
38
|
import { deserializeRecord } from "@makeswift/controls";
|
|
39
|
+
import {
|
|
40
|
+
ClientMessagePortSerializationVisitor,
|
|
41
|
+
functionDeserializationPlugin
|
|
42
|
+
} from "../../controls/visitors/message-port-serializer";
|
|
39
43
|
function serializeShapeControl(control) {
|
|
40
44
|
const { type } = control.options;
|
|
41
45
|
const transferables = [];
|
|
@@ -278,8 +282,9 @@ function serializeControl(control) {
|
|
|
278
282
|
if (isLegacyDescriptor(control)) {
|
|
279
283
|
return serializeLegacyControl(control);
|
|
280
284
|
}
|
|
281
|
-
const
|
|
282
|
-
|
|
285
|
+
const messagePortVisitor = new ClientMessagePortSerializationVisitor();
|
|
286
|
+
const serializedControl = control.accept(messagePortVisitor);
|
|
287
|
+
return [serializedControl, messagePortVisitor.getTransferables()];
|
|
283
288
|
}
|
|
284
289
|
function isSerializedControl(control) {
|
|
285
290
|
return control != null && typeof control === "object" && "type" in control && typeof control.type === "string";
|
|
@@ -375,7 +380,9 @@ function deserializeControl(serializedControl) {
|
|
|
375
380
|
if (isSerializedLegacyControl(serializedControl)) {
|
|
376
381
|
return deserializeLegacyControl(serializedControl);
|
|
377
382
|
}
|
|
378
|
-
return deserializeUnifiedControlDef(
|
|
383
|
+
return deserializeUnifiedControlDef(
|
|
384
|
+
deserializeRecord(serializedControl, [functionDeserializationPlugin])
|
|
385
|
+
);
|
|
379
386
|
}
|
|
380
387
|
function deserializeUnifiedControlDef(record) {
|
|
381
388
|
const deserializeMethod = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/builder/serialization/control-serialization.ts"],"sourcesContent":["import {\n GapData,\n GapX,\n GapYDescriptor,\n GapYPropControllerData,\n ResponsiveLengthOptions,\n ResponsiveLengthPropControllerData,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n type Descriptor,\n type PropDef,\n type OptionsType,\n} from '@makeswift/prop-controllers'\n\nimport {\n type Data,\n type Device,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n type RichTextValue as RichTextControlValue,\n ShapeV2Definition,\n} from '@makeswift/controls'\n\nimport {\n CheckboxDefinition,\n ColorDefinition,\n ComboboxDefinition,\n FontDefinition,\n GroupDefinition,\n IconRadioGroupDefinition,\n ImageDefinition,\n LinkDefinition,\n ListDefinition,\n NumberDefinition,\n RichTextV1Definition,\n RichTextV2Definition,\n SelectDefinition,\n ShapeDefinition,\n SlotDefinition,\n StyleDefinition,\n StyleV2Definition,\n TextAreaDefinition,\n TextInputDefinition,\n unstable_TypographyDefinition,\n} from '../../controls'\n\nimport {\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n Descriptor as ControlDefinition,\n} from '../../prop-controllers/descriptors'\n\nimport {\n DELETED_PROP_CONTROLLER_TYPES,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n RichTextDescriptor as RichTextControl,\n} from '../../prop-controllers/deleted'\n\nimport {\n DeserializedFunction,\n deserializeFunction,\n isSerializedFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\nimport {\n LinkData,\n DateDescriptor as DateControl,\n DatePropControllerData,\n Types as PropControllerTypes,\n ImageDescriptor as ImageControl,\n ImageData as ImageControlValue,\n LinkDescriptor as LinkControl,\n LinkPropControllerData,\n ResponsiveLengthDescriptor,\n NumberOptions,\n NumberPropControllerData,\n NumberDescriptor,\n ResponsiveColorPropControllerData,\n ResponsiveColorDescriptor,\n CheckboxPropControllerData,\n CheckboxDescriptor as CheckboxControl,\n TextStyleDescriptor as TextStyleControl,\n TextStylePropControllerData,\n TextInputDescriptor as TextInputControl,\n} from '@makeswift/prop-controllers'\n\nimport { type LegacyDescriptor, isLegacyDescriptor } from '../../prop-controllers/descriptors'\nimport { deserializeRecord, type DeserializedRecord } from '@makeswift/controls'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\ntype SerializedConfig<T> =\n | T\n | SerializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\nexport type DeserializedConfig<T> =\n | T\n | DeserializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\ntype SerializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: SerializedConfig<OptionsType<P>>\n}\n\nfunction serializeControlDef<P extends PropDef>(\n control: Descriptor<P>,\n): [SerializedControlDef<P>, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\nexport type DeserializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: DeserializedConfig<OptionsType<P>>\n}\n\nfunction deserializeControlDef<P extends PropDef>(\n serializedControl: SerializedControlDef<P>,\n): DeserializedControlDef<P> {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype GapYControlConfig = {\n preset?: GapYPropControllerData\n label?: string\n defaultValue?: GapData\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}\n\ntype SerializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: SerializedConfig<GapYControlConfig>\n}\n\nfunction serializeGapYControl(control: GapYDescriptor): [SerializedGapYControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: DeserializedConfig<GapYControlConfig>\n}\n\nfunction deserializeGapYControl(serializedControl: SerializedGapYControl): DeserializedGapYControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype CheckboxControlConfig = {\n preset?: CheckboxPropControllerData\n label: string\n hidden?: boolean\n}\n\ntype SerializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: SerializedConfig<CheckboxControlConfig>\n}\n\nfunction serializeCheckboxControl(\n control: CheckboxControl,\n): [SerializedCheckboxControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: DeserializedConfig<CheckboxControlConfig>\n}\n\nfunction deserializeCheckboxControl(\n serializedControl: SerializedCheckboxControl,\n): DeserializedCheckboxControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ResponsiveColorControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype SerializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: SerializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction serializeResponsiveColorControl(\n control: ResponsiveColorDescriptor,\n): [SerializedResponsiveColorControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: DeserializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction deserializeResponsiveColorControl(\n serializedControl: SerializedResponsiveColorControl,\n): DeserializedResponsiveColorControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\ntype SerializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: SerializedConfig<NumberOptions>\n}\n\nfunction serializeNumberControl(\n control: NumberDescriptor,\n): [SerializedNumberControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: DeserializedConfig<NumberOptions>\n}\n\nfunction deserializeNumberControl(\n serializedControl: SerializedNumberControl,\n): DeserializedNumberControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype DateControlConfig = { preset?: DatePropControllerData }\n\ntype SerializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: SerializedConfig<DateControlConfig>\n}\n\nfunction serializeDateControl(control: DateControl): [SerializedDateControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: DeserializedConfig<DateControlConfig>\n}\n\nfunction deserializeDateControl(serializedControl: SerializedDateControl): DeserializedDateControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype LinkControlConfig = {\n preset?: LinkPropControllerData\n label?: string\n defaultValue?: LinkPropControllerData\n options?: { value: LinkData['type']; label: string }[]\n hidden?: boolean\n}\n\ntype SerializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: SerializedConfig<LinkControlConfig>\n}\n\nfunction serializeLinkControl(control: LinkControl): [SerializedLinkControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: DeserializedConfig<LinkControlConfig>\n}\n\nfunction deserializeLinkControl(serializedControl: SerializedLinkControl): DeserializedLinkControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype TextInputControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype TextInputControlValue = string\n\ntype SerializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: SerializedConfig<TextInputControlConfig>\n}\n\nfunction serializeTextInputControl(\n control: TextInputControl,\n): [SerializedTextInputControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: DeserializedConfig<TextInputControlConfig>\n}\n\nfunction deserializeTextInputControl(\n serializedControl: SerializedTextInputControl,\n): DeserializedTextInputControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: SerializedConfig<ResponsiveLengthOptions>\n}\n\nfunction serializeResponsiveLengthControl(\n control: ResponsiveLengthDescriptor,\n): [SerializedResponsiveLengthControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: DeserializedConfig<ResponsiveLengthOptions>\n}\n\nfunction deserializeResponsiveLengthControl(\n serializedControl: SerializedResponsiveLengthControl,\n): DeserializedResponsiveLengthControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: SerializedConfig<TextStyleControlConfig>\n}\n\nfunction serializeTextStyleControl(\n control: TextStyleControl,\n): [SerializedTextStyleControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype TextStyleControlConfig = {\n preset?: TextStylePropControllerData\n label?: string\n hidden?: boolean\n}\n\ntype DeserializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: DeserializedConfig<TextStyleControlConfig>\n}\n\nfunction deserializeTextStyleControl(\n serializedControl: SerializedTextStyleControl,\n): DeserializedTextStyleControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ImageControlConfig = { label?: string; hidden?: boolean }\n\ntype SerializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: SerializedConfig<ImageControlConfig>\n}\n\nfunction serializeImageControl(control: ImageControl): [SerializedImageControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: DeserializedConfig<ImageControlConfig>\n}\n\nfunction deserializeImageControl(\n serializedControl: SerializedImageControl,\n): DeserializedImageControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype RichTextControlConfig = { preset?: RichTextControlValue }\n\ntype SerializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: SerializedConfig<RichTextControlConfig>\n}\n\nfunction serializeRichTextControl(\n control: RichTextControl,\n): [SerializedRichTextControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: DeserializedConfig<RichTextControlConfig>\n}\n\nfunction deserializeRichTextControl(\n serializedControl: SerializedRichTextControl,\n): DeserializedRichTextControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\nexport type SerializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | SerializedControlDef<typeof GapX>\n | SerializedGapYControl<T>\n | SerializedControlDef<typeof ResponsiveNumber>\n | SerializedCheckboxControl<T>\n | SerializedResponsiveColorControl<T>\n | SerializedNumberControl<T>\n | SerializedControlDef<typeof ResponsiveIconRadioGroup>\n | SerializedControlDef<typeof ResponsiveSelect>\n | SerializedResponsiveLengthControl<T>\n | SerializedDateControl<T>\n | SerializedLinkControl<T>\n | SerializedTextInputControl<T>\n | SerializedTextStyleControl<T>\n | SerializedImageControl<T>\n | SerializedRichTextControl<T>\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | DeserializedControlDef<typeof GapX>\n | DeserializedGapYControl<T>\n | DeserializedControlDef<typeof ResponsiveNumber>\n | DeserializedCheckboxControl<T>\n | DeserializedResponsiveColorControl<T>\n | DeserializedNumberControl<T>\n | DeserializedControlDef<typeof ResponsiveIconRadioGroup>\n | DeserializedControlDef<typeof ResponsiveSelect>\n | DeserializedResponsiveLengthControl<T>\n | DeserializedDateControl<T>\n | DeserializedLinkControl<T>\n | DeserializedTextInputControl<T>\n | DeserializedTextStyleControl<T>\n | DeserializedImageControl<T>\n | DeserializedRichTextControl<T>\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport type DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nexport function serializeControl<T extends Data>(\n control: ControlDefinition<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const [serializedControl, transferables] = control.serialize()\n return [serializedControl, transferables]\n}\n\nexport function isSerializedControl(control: unknown): control is SerializedControl {\n return (\n control != null &&\n typeof control === 'object' &&\n 'type' in control &&\n typeof control.type === 'string'\n )\n}\n\nfunction serializeLegacyControl<T extends Data>(\n control: LegacyDescriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case PropControllerTypes.Checkbox:\n return serializeCheckboxControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return serializeListControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return serializeShapeControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return serializeTypeaheadControl(control) as [SerializedControl<T>, Transferable[]]\n\n case PropControllerTypes.GapX:\n return serializeControlDef<typeof GapX>(control)\n\n case PropControllerTypes.GapY:\n return serializeGapYControl(control)\n\n case PropControllerTypes.ResponsiveColor:\n return serializeResponsiveColorControl(control)\n\n case PropControllerTypes.ResponsiveNumber:\n return serializeControlDef<typeof ResponsiveNumber>(control)\n\n case PropControllerTypes.Number:\n return serializeNumberControl(control)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return serializeControlDef<typeof ResponsiveIconRadioGroup>(control)\n\n case PropControllerTypes.ResponsiveSelect:\n return serializeControlDef<typeof ResponsiveSelect>(control)\n\n case PropControllerTypes.ResponsiveLength:\n return serializeResponsiveLengthControl(control)\n\n case PropControllerTypes.Date:\n return serializeDateControl(control)\n\n case PropControllerTypes.Link:\n return serializeLinkControl(control)\n\n case PropControllerTypes.TextInput:\n return serializeTextInputControl(control)\n\n case PropControllerTypes.TextStyle:\n return serializeTextStyleControl(control)\n\n case PropControllerTypes.Image:\n return serializeImageControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return serializeRichTextControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport function deserializeLegacyControl<T extends Data>(\n serializedControl: SerializedLegacyControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case PropControllerTypes.Checkbox:\n return deserializeCheckboxControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return deserializeListControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return deserializeShapeControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n case PropControllerTypes.GapX:\n return deserializeControlDef<typeof GapX>(serializedControl)\n\n case PropControllerTypes.GapY:\n return deserializeGapYControl(serializedControl)\n\n case PropControllerTypes.ResponsiveColor:\n return deserializeResponsiveColorControl(serializedControl)\n\n case PropControllerTypes.ResponsiveNumber:\n return deserializeControlDef<typeof ResponsiveNumber>(serializedControl)\n\n case PropControllerTypes.Number:\n return deserializeNumberControl(serializedControl)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return deserializeControlDef<typeof ResponsiveIconRadioGroup>(serializedControl)\n\n case PropControllerTypes.ResponsiveSelect:\n return deserializeControlDef<typeof ResponsiveSelect>(serializedControl)\n\n case PropControllerTypes.ResponsiveLength:\n return deserializeResponsiveLengthControl(serializedControl)\n\n case PropControllerTypes.Date:\n return deserializeDateControl(serializedControl)\n\n case PropControllerTypes.Link:\n return deserializeLinkControl(serializedControl)\n\n case PropControllerTypes.TextInput:\n return deserializeTextInputControl(serializedControl)\n\n case PropControllerTypes.TextStyle:\n return deserializeTextStyleControl(serializedControl)\n\n case PropControllerTypes.Image:\n return deserializeImageControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return deserializeRichTextControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n return deserializeLegacyControl(serializedControl)\n }\n\n return deserializeUnifiedControlDef(deserializeRecord(serializedControl))\n}\n\nexport function deserializeUnifiedControlDef(record: DeserializedRecord): UnifiedControlDefinition {\n type DeserializeMethod = (data: DeserializedRecord) => UnifiedControlDefinition\n const deserializeMethod: Record<string, DeserializeMethod> = {\n [CheckboxDefinition.type]: CheckboxDefinition.deserialize,\n [ColorDefinition.type]: ColorDefinition.deserialize,\n [ComboboxDefinition.type]: ComboboxDefinition.deserialize,\n [FontDefinition.type]: FontDefinition.deserialize,\n [GroupDefinition.type]: record =>\n GroupDefinition.deserialize(record, deserializeUnifiedControlDef),\n [IconRadioGroupDefinition.type]: IconRadioGroupDefinition.deserialize,\n [ImageDefinition.type]: ImageDefinition.deserialize,\n [LinkDefinition.type]: LinkDefinition.deserialize,\n [ListDefinition.type]: record =>\n ListDefinition.deserialize(record, deserializeUnifiedControlDef),\n [NumberDefinition.type]: NumberDefinition.deserialize,\n [RichTextV1Definition.type]: RichTextV1Definition.deserialize,\n [RichTextV2Definition.type]: record =>\n RichTextV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SelectDefinition.type]: SelectDefinition.deserialize,\n [ShapeDefinition.type]: record =>\n ShapeDefinition.deserialize(record, deserializeUnifiedControlDef),\n [ShapeV2Definition.type]: record =>\n ShapeV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SlotDefinition.type]: SlotDefinition.deserialize,\n [StyleDefinition.type]: StyleDefinition.deserialize,\n [StyleV2Definition.type]: record =>\n StyleV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [TextAreaDefinition.type]: TextAreaDefinition.deserialize,\n [TextInputDefinition.type]: TextInputDefinition.deserialize,\n [unstable_TypographyDefinition.type]: unstable_TypographyDefinition.deserialize,\n } as const\n\n const deserialize = deserializeMethod[record.type] ?? null\n if (deserialize == null) {\n throw new Error(`Unknown control type: ${record.type}`)\n }\n\n return deserialize(record)\n}\n\nexport function serializeControls(\n controls: Record<string, ControlDefinition>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n {\n onError,\n }: { onError?: (err: Error, context: { key: string; serializedControl: unknown }) => void } = {},\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n try {\n if (!isSerializedControl(serializedControl)) {\n throw new Error(\n `Expected serialized control data, got ${JSON.stringify(serializedControl)}`,\n )\n }\n const deserializedControl = deserializeControl(serializedControl)\n return { ...deserializedControls, [key]: deserializedControl }\n } catch (err: unknown) {\n const error =\n err instanceof Error\n ? new Error(`Could not deserialize control for \"${key}\": ${err.message}`, {\n cause: err,\n })\n : new Error(`Could not deserialize control for \"${key}\", unknown error: ${err}`)\n\n onError?.(error, { key, serializedControl })\n\n return deserializedControls\n }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"mappings":"AAeA;AAAA,EAME;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP;AAAA,EACE;AAAA,OAUK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP;AAAA,EAIE,SAAS;AAAA,OAgBJ;AAEP,SAAgC,0BAA0B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oBACd,oBACA;AAAA,EACE;AACF,IAA8F,CAAC,GAC1D;AACrC,SAAO,OAAO,QAAQ,kBAAkB,EAAE;AAAA,IACxC,CAAC,sBAAsB,CAAC,KAAK,iBAAiB,MAAM;AAClD,UAAI;AACF,YAAI,CAAC,oBAAoB,iBAAiB,GAAG;AAC3C,gBAAM,IAAI;AAAA,YACR,yCAAyC,KAAK,UAAU,iBAAiB,CAAC;AAAA,UAC5E;AAAA,QACF;AACA,cAAM,sBAAsB,mBAAmB,iBAAiB;AAChE,eAAO,EAAE,GAAG,sBAAsB,CAAC,GAAG,GAAG,oBAAoB;AAAA,MAC/D,SAAS,KAAc;AACrB,cAAM,QACJ,eAAe,QACX,IAAI,MAAM,sCAAsC,GAAG,MAAM,IAAI,OAAO,IAAI;AAAA,UACtE,OAAO;AAAA,QACT,CAAC,IACD,IAAI,MAAM,sCAAsC,GAAG,qBAAqB,GAAG,EAAE;AAEnF,kBAAU,OAAO,EAAE,KAAK,kBAAkB,CAAC;AAE3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["control","record"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/builder/serialization/control-serialization.ts"],"sourcesContent":["import {\n GapData,\n GapX,\n GapYDescriptor,\n GapYPropControllerData,\n ResponsiveLengthOptions,\n ResponsiveLengthPropControllerData,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n type Descriptor,\n type PropDef,\n type OptionsType,\n} from '@makeswift/prop-controllers'\n\nimport {\n type Data,\n type Device,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n type RichTextValue as RichTextControlValue,\n ShapeV2Definition,\n} from '@makeswift/controls'\n\nimport {\n CheckboxDefinition,\n ColorDefinition,\n ComboboxDefinition,\n FontDefinition,\n GroupDefinition,\n IconRadioGroupDefinition,\n ImageDefinition,\n LinkDefinition,\n ListDefinition,\n NumberDefinition,\n RichTextV1Definition,\n RichTextV2Definition,\n SelectDefinition,\n ShapeDefinition,\n SlotDefinition,\n StyleDefinition,\n StyleV2Definition,\n TextAreaDefinition,\n TextInputDefinition,\n unstable_TypographyDefinition,\n} from '../../controls'\n\nimport {\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n Descriptor as ControlDefinition,\n} from '../../prop-controllers/descriptors'\n\nimport {\n DELETED_PROP_CONTROLLER_TYPES,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n RichTextDescriptor as RichTextControl,\n} from '../../prop-controllers/deleted'\n\nimport {\n DeserializedFunction,\n deserializeFunction,\n isSerializedFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\nimport {\n LinkData,\n DateDescriptor as DateControl,\n DatePropControllerData,\n Types as PropControllerTypes,\n ImageDescriptor as ImageControl,\n ImageData as ImageControlValue,\n LinkDescriptor as LinkControl,\n LinkPropControllerData,\n ResponsiveLengthDescriptor,\n NumberOptions,\n NumberPropControllerData,\n NumberDescriptor,\n ResponsiveColorPropControllerData,\n ResponsiveColorDescriptor,\n CheckboxPropControllerData,\n CheckboxDescriptor as CheckboxControl,\n TextStyleDescriptor as TextStyleControl,\n TextStylePropControllerData,\n TextInputDescriptor as TextInputControl,\n} from '@makeswift/prop-controllers'\n\nimport { type LegacyDescriptor, isLegacyDescriptor } from '../../prop-controllers/descriptors'\nimport { deserializeRecord, type DeserializedRecord } from '@makeswift/controls'\nimport {\n ClientMessagePortSerializationVisitor,\n functionDeserializationPlugin,\n} from '../../controls/visitors/message-port-serializer'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\ntype SerializedConfig<T> =\n | T\n | SerializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\nexport type DeserializedConfig<T> =\n | T\n | DeserializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\ntype SerializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: SerializedConfig<OptionsType<P>>\n}\n\nfunction serializeControlDef<P extends PropDef>(\n control: Descriptor<P>,\n): [SerializedControlDef<P>, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\nexport type DeserializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: DeserializedConfig<OptionsType<P>>\n}\n\nfunction deserializeControlDef<P extends PropDef>(\n serializedControl: SerializedControlDef<P>,\n): DeserializedControlDef<P> {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype GapYControlConfig = {\n preset?: GapYPropControllerData\n label?: string\n defaultValue?: GapData\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}\n\ntype SerializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: SerializedConfig<GapYControlConfig>\n}\n\nfunction serializeGapYControl(control: GapYDescriptor): [SerializedGapYControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: DeserializedConfig<GapYControlConfig>\n}\n\nfunction deserializeGapYControl(serializedControl: SerializedGapYControl): DeserializedGapYControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype CheckboxControlConfig = {\n preset?: CheckboxPropControllerData\n label: string\n hidden?: boolean\n}\n\ntype SerializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: SerializedConfig<CheckboxControlConfig>\n}\n\nfunction serializeCheckboxControl(\n control: CheckboxControl,\n): [SerializedCheckboxControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: DeserializedConfig<CheckboxControlConfig>\n}\n\nfunction deserializeCheckboxControl(\n serializedControl: SerializedCheckboxControl,\n): DeserializedCheckboxControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ResponsiveColorControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype SerializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: SerializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction serializeResponsiveColorControl(\n control: ResponsiveColorDescriptor,\n): [SerializedResponsiveColorControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: DeserializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction deserializeResponsiveColorControl(\n serializedControl: SerializedResponsiveColorControl,\n): DeserializedResponsiveColorControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\ntype SerializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: SerializedConfig<NumberOptions>\n}\n\nfunction serializeNumberControl(\n control: NumberDescriptor,\n): [SerializedNumberControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: DeserializedConfig<NumberOptions>\n}\n\nfunction deserializeNumberControl(\n serializedControl: SerializedNumberControl,\n): DeserializedNumberControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype DateControlConfig = { preset?: DatePropControllerData }\n\ntype SerializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: SerializedConfig<DateControlConfig>\n}\n\nfunction serializeDateControl(control: DateControl): [SerializedDateControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: DeserializedConfig<DateControlConfig>\n}\n\nfunction deserializeDateControl(serializedControl: SerializedDateControl): DeserializedDateControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype LinkControlConfig = {\n preset?: LinkPropControllerData\n label?: string\n defaultValue?: LinkPropControllerData\n options?: { value: LinkData['type']; label: string }[]\n hidden?: boolean\n}\n\ntype SerializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: SerializedConfig<LinkControlConfig>\n}\n\nfunction serializeLinkControl(control: LinkControl): [SerializedLinkControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: DeserializedConfig<LinkControlConfig>\n}\n\nfunction deserializeLinkControl(serializedControl: SerializedLinkControl): DeserializedLinkControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype TextInputControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype TextInputControlValue = string\n\ntype SerializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: SerializedConfig<TextInputControlConfig>\n}\n\nfunction serializeTextInputControl(\n control: TextInputControl,\n): [SerializedTextInputControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: DeserializedConfig<TextInputControlConfig>\n}\n\nfunction deserializeTextInputControl(\n serializedControl: SerializedTextInputControl,\n): DeserializedTextInputControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: SerializedConfig<ResponsiveLengthOptions>\n}\n\nfunction serializeResponsiveLengthControl(\n control: ResponsiveLengthDescriptor,\n): [SerializedResponsiveLengthControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: DeserializedConfig<ResponsiveLengthOptions>\n}\n\nfunction deserializeResponsiveLengthControl(\n serializedControl: SerializedResponsiveLengthControl,\n): DeserializedResponsiveLengthControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: SerializedConfig<TextStyleControlConfig>\n}\n\nfunction serializeTextStyleControl(\n control: TextStyleControl,\n): [SerializedTextStyleControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype TextStyleControlConfig = {\n preset?: TextStylePropControllerData\n label?: string\n hidden?: boolean\n}\n\ntype DeserializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: DeserializedConfig<TextStyleControlConfig>\n}\n\nfunction deserializeTextStyleControl(\n serializedControl: SerializedTextStyleControl,\n): DeserializedTextStyleControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ImageControlConfig = { label?: string; hidden?: boolean }\n\ntype SerializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: SerializedConfig<ImageControlConfig>\n}\n\nfunction serializeImageControl(control: ImageControl): [SerializedImageControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: DeserializedConfig<ImageControlConfig>\n}\n\nfunction deserializeImageControl(\n serializedControl: SerializedImageControl,\n): DeserializedImageControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype RichTextControlConfig = { preset?: RichTextControlValue }\n\ntype SerializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: SerializedConfig<RichTextControlConfig>\n}\n\nfunction serializeRichTextControl(\n control: RichTextControl,\n): [SerializedRichTextControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: DeserializedConfig<RichTextControlConfig>\n}\n\nfunction deserializeRichTextControl(\n serializedControl: SerializedRichTextControl,\n): DeserializedRichTextControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\nexport type SerializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | SerializedControlDef<typeof GapX>\n | SerializedGapYControl<T>\n | SerializedControlDef<typeof ResponsiveNumber>\n | SerializedCheckboxControl<T>\n | SerializedResponsiveColorControl<T>\n | SerializedNumberControl<T>\n | SerializedControlDef<typeof ResponsiveIconRadioGroup>\n | SerializedControlDef<typeof ResponsiveSelect>\n | SerializedResponsiveLengthControl<T>\n | SerializedDateControl<T>\n | SerializedLinkControl<T>\n | SerializedTextInputControl<T>\n | SerializedTextStyleControl<T>\n | SerializedImageControl<T>\n | SerializedRichTextControl<T>\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | DeserializedControlDef<typeof GapX>\n | DeserializedGapYControl<T>\n | DeserializedControlDef<typeof ResponsiveNumber>\n | DeserializedCheckboxControl<T>\n | DeserializedResponsiveColorControl<T>\n | DeserializedNumberControl<T>\n | DeserializedControlDef<typeof ResponsiveIconRadioGroup>\n | DeserializedControlDef<typeof ResponsiveSelect>\n | DeserializedResponsiveLengthControl<T>\n | DeserializedDateControl<T>\n | DeserializedLinkControl<T>\n | DeserializedTextInputControl<T>\n | DeserializedTextStyleControl<T>\n | DeserializedImageControl<T>\n | DeserializedRichTextControl<T>\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport type DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nexport function serializeControl<T extends Data>(\n control: ControlDefinition<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const messagePortVisitor = new ClientMessagePortSerializationVisitor()\n const serializedControl = control.accept(messagePortVisitor)\n return [serializedControl, messagePortVisitor.getTransferables()]\n}\n\nexport function isSerializedControl(control: unknown): control is SerializedControl {\n return (\n control != null &&\n typeof control === 'object' &&\n 'type' in control &&\n typeof control.type === 'string'\n )\n}\n\nfunction serializeLegacyControl<T extends Data>(\n control: LegacyDescriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case PropControllerTypes.Checkbox:\n return serializeCheckboxControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return serializeListControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return serializeShapeControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return serializeTypeaheadControl(control) as [SerializedControl<T>, Transferable[]]\n\n case PropControllerTypes.GapX:\n return serializeControlDef<typeof GapX>(control)\n\n case PropControllerTypes.GapY:\n return serializeGapYControl(control)\n\n case PropControllerTypes.ResponsiveColor:\n return serializeResponsiveColorControl(control)\n\n case PropControllerTypes.ResponsiveNumber:\n return serializeControlDef<typeof ResponsiveNumber>(control)\n\n case PropControllerTypes.Number:\n return serializeNumberControl(control)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return serializeControlDef<typeof ResponsiveIconRadioGroup>(control)\n\n case PropControllerTypes.ResponsiveSelect:\n return serializeControlDef<typeof ResponsiveSelect>(control)\n\n case PropControllerTypes.ResponsiveLength:\n return serializeResponsiveLengthControl(control)\n\n case PropControllerTypes.Date:\n return serializeDateControl(control)\n\n case PropControllerTypes.Link:\n return serializeLinkControl(control)\n\n case PropControllerTypes.TextInput:\n return serializeTextInputControl(control)\n\n case PropControllerTypes.TextStyle:\n return serializeTextStyleControl(control)\n\n case PropControllerTypes.Image:\n return serializeImageControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return serializeRichTextControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport function deserializeLegacyControl<T extends Data>(\n serializedControl: SerializedLegacyControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case PropControllerTypes.Checkbox:\n return deserializeCheckboxControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return deserializeListControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return deserializeShapeControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n case PropControllerTypes.GapX:\n return deserializeControlDef<typeof GapX>(serializedControl)\n\n case PropControllerTypes.GapY:\n return deserializeGapYControl(serializedControl)\n\n case PropControllerTypes.ResponsiveColor:\n return deserializeResponsiveColorControl(serializedControl)\n\n case PropControllerTypes.ResponsiveNumber:\n return deserializeControlDef<typeof ResponsiveNumber>(serializedControl)\n\n case PropControllerTypes.Number:\n return deserializeNumberControl(serializedControl)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return deserializeControlDef<typeof ResponsiveIconRadioGroup>(serializedControl)\n\n case PropControllerTypes.ResponsiveSelect:\n return deserializeControlDef<typeof ResponsiveSelect>(serializedControl)\n\n case PropControllerTypes.ResponsiveLength:\n return deserializeResponsiveLengthControl(serializedControl)\n\n case PropControllerTypes.Date:\n return deserializeDateControl(serializedControl)\n\n case PropControllerTypes.Link:\n return deserializeLinkControl(serializedControl)\n\n case PropControllerTypes.TextInput:\n return deserializeTextInputControl(serializedControl)\n\n case PropControllerTypes.TextStyle:\n return deserializeTextStyleControl(serializedControl)\n\n case PropControllerTypes.Image:\n return deserializeImageControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return deserializeRichTextControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n return deserializeLegacyControl(serializedControl)\n }\n\n return deserializeUnifiedControlDef(\n deserializeRecord(serializedControl, [functionDeserializationPlugin]),\n )\n}\n\nexport function deserializeUnifiedControlDef(record: DeserializedRecord): UnifiedControlDefinition {\n type DeserializeMethod = (data: DeserializedRecord) => UnifiedControlDefinition\n const deserializeMethod: Record<string, DeserializeMethod> = {\n [CheckboxDefinition.type]: CheckboxDefinition.deserialize,\n [ColorDefinition.type]: ColorDefinition.deserialize,\n [ComboboxDefinition.type]: ComboboxDefinition.deserialize,\n [FontDefinition.type]: FontDefinition.deserialize,\n [GroupDefinition.type]: record =>\n GroupDefinition.deserialize(record, deserializeUnifiedControlDef),\n [IconRadioGroupDefinition.type]: IconRadioGroupDefinition.deserialize,\n [ImageDefinition.type]: ImageDefinition.deserialize,\n [LinkDefinition.type]: LinkDefinition.deserialize,\n [ListDefinition.type]: record =>\n ListDefinition.deserialize(record, deserializeUnifiedControlDef),\n [NumberDefinition.type]: NumberDefinition.deserialize,\n [RichTextV1Definition.type]: RichTextV1Definition.deserialize,\n [RichTextV2Definition.type]: record =>\n RichTextV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SelectDefinition.type]: SelectDefinition.deserialize,\n [ShapeDefinition.type]: record =>\n ShapeDefinition.deserialize(record, deserializeUnifiedControlDef),\n [ShapeV2Definition.type]: record =>\n ShapeV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SlotDefinition.type]: SlotDefinition.deserialize,\n [StyleDefinition.type]: StyleDefinition.deserialize,\n [StyleV2Definition.type]: record =>\n StyleV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [TextAreaDefinition.type]: TextAreaDefinition.deserialize,\n [TextInputDefinition.type]: TextInputDefinition.deserialize,\n [unstable_TypographyDefinition.type]: unstable_TypographyDefinition.deserialize,\n } as const\n\n const deserialize = deserializeMethod[record.type] ?? null\n if (deserialize == null) {\n throw new Error(`Unknown control type: ${record.type}`)\n }\n\n return deserialize(record)\n}\n\nexport function serializeControls(\n controls: Record<string, ControlDefinition>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n {\n onError,\n }: { onError?: (err: Error, context: { key: string; serializedControl: unknown }) => void } = {},\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n try {\n if (!isSerializedControl(serializedControl)) {\n throw new Error(\n `Expected serialized control data, got ${JSON.stringify(serializedControl)}`,\n )\n }\n const deserializedControl = deserializeControl(serializedControl)\n return { ...deserializedControls, [key]: deserializedControl }\n } catch (err: unknown) {\n const error =\n err instanceof Error\n ? new Error(`Could not deserialize control for \"${key}\": ${err.message}`, {\n cause: err,\n })\n : new Error(`Could not deserialize control for \"${key}\", unknown error: ${err}`)\n\n onError?.(error, { key, serializedControl })\n\n return deserializedControls\n }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"mappings":"AAeA;AAAA,EAME;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP;AAAA,EACE;AAAA,OAUK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP;AAAA,EAIE,SAAS;AAAA,OAgBJ;AAEP,SAAgC,0BAA0B;AAC1D,SAAS,yBAAkD;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAeP,SAAS,sBAIP,SAOA;AACA,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,gBAAgC,CAAC;AACvC,QAAM,iBAAiB,CAAC;AAIxB,SAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAKA,QAAO,MAAM;AAC/C,UAAM,CAAC,mBAAmB,8BAA8B,IAAI,iBAAiBA,QAAO;AAEpF,mBAAe,GAAwB,IAAI;AAC3C,kBAAc,KAAK,GAAG,8BAA8B;AAAA,EACtD,CAAC;AAGD,SAAO,CAAC,EAAE,GAAG,SAAS,SAAS,EAAE,GAAG,QAAQ,SAAS,MAAM,eAAe,EAAE,GAAG,aAAa;AAC9F;AAeA,SAAS,wBAIP,SAIA;AACA,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,mBAAmB,CAAC;AAI1B,SAAO,QAAQ,IAAI,EAAE,QAAQ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,CAAC,IACD,IAAI,MAAM,sCAAsC,GAAG,qBAAqB,GAAG,EAAE;AAEnF,kBAAU,OAAO,EAAE,KAAK,kBAAkB,CAAC;AAE3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["control","record"]}
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
RichTextDefinition as BaseRichTextDefinition,
|
|
5
5
|
isNotNil,
|
|
6
6
|
SerializationSchema,
|
|
7
|
-
serialize,
|
|
8
7
|
StableValue
|
|
9
8
|
} from "@makeswift/controls";
|
|
10
9
|
import { LinkPlugin } from "../../slate/LinkPlugin";
|
|
@@ -86,27 +85,6 @@ class Definition extends BaseRichTextDefinition {
|
|
|
86
85
|
return null;
|
|
87
86
|
return getTranslatableData(Definition.dataToNodes(data), this.config.plugins);
|
|
88
87
|
}
|
|
89
|
-
serialize() {
|
|
90
|
-
const { plugins, ...config } = this.config;
|
|
91
|
-
const pluginDefs = plugins.map(
|
|
92
|
-
({ control }) => control ? {
|
|
93
|
-
control: {
|
|
94
|
-
definition: control.definition,
|
|
95
|
-
// FIXME: remove getValue/onChange stubs once we released a version of the builder
|
|
96
|
-
// built against the runtime where these can be optional
|
|
97
|
-
getValue: () => void 0,
|
|
98
|
-
onChange: () => {
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
} : {}
|
|
102
|
-
);
|
|
103
|
-
return serialize(
|
|
104
|
-
{ ...config, plugins: pluginDefs },
|
|
105
|
-
{
|
|
106
|
-
type: Definition.type
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
88
|
get pluginControls() {
|
|
111
89
|
return this.config.plugins.map((plugin) => plugin.control).filter(isNotNil);
|
|
112
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n StableValue,\n type Data,\n type Resolvable,\n type SendMessage,\n type DeserializedRecord,\n type SchemaType,\n type SchemaTypeAny,\n type RichTextPluginControl,\n type ResourceResolver,\n type Stylesheet,\n type RichTextMode,\n} from '@makeswift/controls'\n\nimport { LinkPlugin } from '../../slate/LinkPlugin'\nimport { InlinePlugin } from '../../slate/InlinePlugin'\nimport { TextAlignPlugin } from '../../slate/TextAlignPlugin'\nimport { BlockPlugin } from '../../slate/BlockPlugin'\nimport { TypographyPlugin } from '../../slate/TypographyPlugin'\nimport { InlineModePlugin } from '../../slate/InlineModePlugin'\nimport { toText } from '../../slate/utils'\n\nimport { renderRichTextV2 } from '../../runtimes/react/controls/rich-text-v2'\n\nimport { RichTextV2Plugin, Plugin } from './plugin'\nimport { RichTextV2Control } from './control'\nimport { getTranslatableData } from './translations/get-translations'\n\ntype DataType = z.infer<typeof Definition.schema.data>\ntype DataV2Type = z.infer<typeof Definition.schema.dataV2>\ntype InstanceType = RichTextV2Control\ntype UserConfig = z.infer<typeof Definition.schema.userConfig>\ntype Config = UserConfig & {\n defaultValue: string\n plugins: RichTextV2Plugin[]\n}\n\nclass Definition extends BaseRichTextDefinition<ReactNode, Config, InstanceType> {\n constructor({ mode, defaultValue }: UserConfig, plugins?: RichTextV2Plugin[]) {\n super({\n mode,\n defaultValue:\n defaultValue ??\n (mode === Definition.Mode.Inline ? 'Edit this text' : Definition.generateParagraph()),\n plugins:\n plugins ??\n (mode === Definition.Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n })\n }\n\n static generateParagraph(): string {\n return ipsum(3)\n }\n\n static deserialize(\n data: DeserializedRecord,\n deserializeCallback: (r: DeserializedRecord) => ControlDefinition,\n ): RichTextV2Definition {\n if (data.type !== Definition.type) {\n throw new Error(`RichText: expected type ${Definition.type}, got ${data.type}`)\n }\n\n const { config } = Definition.fullSchema({\n pluginDef: SerializationSchema.deserializedRecord,\n }).definition.parse(data)\n\n const { plugins, ...userConfig } = config\n\n return new RichTextV2Definition(\n userConfig,\n plugins.map(({ control }) =>\n control ? { control: { definition: deserializeCallback(control?.definition) } } : {},\n ),\n )\n }\n\n static fullSchema<S extends SchemaTypeAny>({ pluginDef }: { pluginDef: S }) {\n const baseSchema = super.schema\n const plugin = z.object({\n control: z\n .object({\n definition: pluginDef,\n })\n .optional(),\n })\n\n const config = baseSchema.userConfig.extend({\n defaultValue: z.string(),\n plugins: z.array(plugin),\n })\n\n return {\n ...baseSchema,\n config,\n definition: z.object({\n type: baseSchema.type,\n config,\n }),\n }\n }\n\n get configSchema(): SchemaType<Config> {\n return Definition.fullSchema({ pluginDef: z.any() as SchemaType<ControlDefinition> }).config\n }\n\n createInstance(sendMessage: SendMessage): InstanceType {\n return new RichTextV2Control(sendMessage, this)\n }\n\n resolveValue(\n data: DataType | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: InstanceType,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: Definition.type,\n read: () => renderRichTextV2(data, this, control ?? null),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n\n getTranslatableData(data: DataType | undefined): Data {\n if (data == null) return null\n return getTranslatableData(Definition.dataToNodes(data), this.config.plugins)\n }\n\n get pluginControls(): RichTextPluginControl[] {\n return this.config.plugins.map(plugin => plugin.control).filter(isNotNil)\n }\n\n pluginControlAt(index: number): RichTextPluginControl | undefined {\n return this.pluginControls[index]\n }\n\n toText(data: DataType | undefined): string {\n if (data == null) return ''\n return toText(Definition.dataToNodes(data), this.config.mode ?? Definition.Mode.Block)\n }\n}\n\nexport class RichTextV2Definition extends Definition {}\n\nexport function RichText(config?: UserConfig): RichTextV2Definition {\n return new RichTextV2Definition(config ?? {})\n}\n\nRichText.Mode = Definition.Mode\nRichText.isV1Data = Definition.isV1Data\nRichText.dataToNodes = Definition.dataToNodes\nRichText.Plugin = Plugin\n\nexport { RichTextMode as RichTextV2Mode, type DataV2Type as RichTextDataV2, RichTextV2Control }\n"],"mappings":"AACA,SAAS,SAAS;AAElB,OAAO,WAAW;AAElB;AAAA,EACE,sBAAsB;AAAA,EACtB;AAAA,EAEA;AAAA,EACA;AAAA,OAWK;AAEP,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAEjC,SAA2B,cAAc;AACzC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAWpC,MAAM,mBAAmB,uBAAwD;AAAA,EAC/E,YAAY,EAAE,MAAM,aAAa,GAAe,SAA8B;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,cACE,iBACC,SAAS,WAAW,KAAK,SAAS,mBAAmB,WAAW,kBAAkB;AAAA,MACrF,SACE,YACC,SAAS,WAAW,KAAK,SACtB,CAAC,iBAAiB,CAAC,IACnB,CAAC,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,GAAG,WAAW,CAAC;AAAA,IAC3F,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,oBAA4B;AACjC,WAAO,MAAM,CAAC;AAAA,EAChB;AAAA,EAEA,OAAO,YACL,MACA,qBACsB;AACtB,QAAI,KAAK,SAAS,WAAW,MAAM;AACjC,YAAM,IAAI,MAAM,2BA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