@makeswift/runtime 0.28.0-canary.3 → 0.28.0
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/client/index.js +5 -4
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/global.d.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/style-control/fixtures.js +38 -2
- package/dist/cjs/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/cjs/next/fetch.js +30 -0
- package/dist/cjs/next/fetch.js.map +1 -0
- package/dist/cjs/next/index.js +5 -2
- package/dist/cjs/next/index.js.map +1 -1
- package/dist/cjs/next/runtime.js +2 -5
- package/dist/cjs/next/runtime.js.map +1 -1
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js +1 -2
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -1
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +33 -0
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/style.js +3 -1
- package/dist/cjs/runtimes/react/controls/style.js.map +1 -1
- package/dist/cjs/state/builder-api/actions.js +2 -2
- package/dist/cjs/state/builder-api/actions.js.map +1 -1
- package/dist/cjs/state/builder-api/api.js +17 -0
- package/dist/cjs/state/builder-api/api.js.map +1 -0
- package/dist/cjs/state/builder-api/message-channel.js +35 -31
- package/dist/cjs/state/builder-api/message-channel.js.map +1 -1
- package/dist/cjs/state/builder-api/navigation-listener.js +90 -0
- package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -0
- package/dist/cjs/state/builder-api/proxy.js +19 -9
- package/dist/cjs/state/builder-api/proxy.js.map +1 -1
- package/dist/cjs/state/middleware/read-write/builder-api/index.js +3 -0
- package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/cjs/state/read-write-state.js +1 -1
- package/dist/cjs/state/read-write-state.js.map +1 -1
- package/dist/cjs/state/store.js +2 -2
- package/dist/cjs/state/store.js.map +1 -1
- package/dist/cjs/unstable-framework-support/index.js +3 -0
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +5 -4
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/global.d.js.map +1 -1
- package/dist/esm/next/components/tests/controls/style-control/fixtures.js +35 -1
- package/dist/esm/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/esm/next/fetch.js +6 -0
- package/dist/esm/next/fetch.js.map +1 -0
- package/dist/esm/next/index.js +3 -1
- package/dist/esm/next/index.js.map +1 -1
- package/dist/esm/next/runtime.js +2 -5
- package/dist/esm/next/runtime.js.map +1 -1
- package/dist/esm/runtimes/react/components/GoogleFontLink.js +1 -2
- package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -1
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js +9 -0
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
- package/dist/esm/runtimes/react/controls/style.js +3 -1
- package/dist/esm/runtimes/react/controls/style.js.map +1 -1
- package/dist/esm/state/builder-api/actions.js +2 -2
- package/dist/esm/state/builder-api/actions.js.map +1 -1
- package/dist/esm/state/builder-api/api.js +1 -0
- package/dist/esm/state/builder-api/api.js.map +1 -0
- package/dist/esm/state/builder-api/message-channel.js +35 -31
- package/dist/esm/state/builder-api/message-channel.js.map +1 -1
- package/dist/esm/state/builder-api/navigation-listener.js +66 -0
- package/dist/esm/state/builder-api/navigation-listener.js.map +1 -0
- package/dist/esm/state/builder-api/proxy.js +20 -10
- package/dist/esm/state/builder-api/proxy.js.map +1 -1
- package/dist/esm/state/middleware/read-write/builder-api/index.js +3 -0
- package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/esm/state/read-write-state.js +1 -1
- package/dist/esm/state/read-write-state.js.map +1 -1
- package/dist/esm/state/store.js +2 -2
- package/dist/esm/state/store.js.map +1 -1
- package/dist/esm/unstable-framework-support/index.js +2 -0
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/types/client/index.d.ts +3 -0
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts +2 -0
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts.map +1 -1
- package/dist/types/next/fetch.d.ts +3 -0
- package/dist/types/next/fetch.d.ts.map +1 -0
- package/dist/types/next/index.d.ts +1 -0
- package/dist/types/next/index.d.ts.map +1 -1
- package/dist/types/next/runtime.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/GoogleFontLink.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +7 -0
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
- package/dist/types/state/builder-api/actions.d.ts +3 -7
- package/dist/types/state/builder-api/actions.d.ts.map +1 -1
- package/dist/types/state/builder-api/api.d.ts +8 -0
- package/dist/types/state/builder-api/api.d.ts.map +1 -0
- package/dist/types/state/builder-api/message-channel.d.ts +3 -6
- package/dist/types/state/builder-api/message-channel.d.ts.map +1 -1
- package/dist/types/state/builder-api/navigation-listener.d.ts +6 -0
- package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -0
- package/dist/types/state/builder-api/proxy.d.ts +4 -3
- package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
- package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -1
- package/dist/types/state/read-write-state.d.ts +1 -1
- package/dist/types/state/read-write-state.d.ts.map +1 -1
- package/dist/types/unstable-framework-support/index.d.ts +1 -0
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type ComponentMeta } from '../modules/components-meta'\nimport { type BoxModel } from '../modules/read-write/box-models'\n\nimport { type ElementSize } from '../middleware/read-write/builder-api/element-size'\nimport { type DocumentPayload, type SharedAction, SharedActionTypes } from '../shared-api'\n\nexport * from '../shared-api'\n\n// actions dispatched by the host to the builder (\"Builder API\")\n// note that some of these actions, in addition to being dispatched to the builder,\n// might also be internally intercepted by the host as a part of maintaining the\n// runtime's \"read-write\" state\nexport const BuilderActionTypes = {\n ...SharedActionTypes,\n\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n HANDLE_HOST_NAVIGATE: 'HANDLE_HOST_NAVIGATE',\n} as const\n\ntype ActionWithTransferables<A> = A & {\n transferables?: Transferable[]\n}\n\ntype MakeswiftConnectionCheckAction = {\n type: typeof BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK\n payload: { currentUrl: string }\n}\n\ntype MountComponentAction = {\n type: typeof BuilderActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof BuilderActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: ElementSize }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype HandleWheelAction = {\n type: typeof BuilderActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof BuilderActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype HandleHostNavigateAction = {\n type: typeof BuilderActionTypes.HANDLE_HOST_NAVIGATE\n payload: { url: string | null }\n}\n\nexport type BuilderAction =\n | SharedAction\n | MakeswiftConnectionCheckAction\n | MountComponentAction\n | UnmountComponentAction\n | ChangeDocumentElementSizeAction\n | ChangeElementBoxModelsAction\n | MessageBuilderPropControllerAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | ElementFromPointChangeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | HandleHostNavigateAction\n\nexport function makeswiftConnectionCheck(\n payload: MakeswiftConnectionCheckAction['payload'],\n): MakeswiftConnectionCheckAction {\n return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function changeDocumentElementSize(size: ElementSize): ChangeDocumentElementSizeAction {\n return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return {\n type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,\n payload: { changedElementBoxModels },\n }\n}\n\nexport function messageBuilderPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageBuilderPropControllerAction<T> {\n return {\n type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: BuilderActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerBuilderDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterBuilderDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): ActionWithTransferables<RegisterBuilderComponentAction> {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nexport function hasTransferables<A extends BuilderAction>(\n action: A,\n): action is ActionWithTransferables<A> {\n return 'transferables' in action && Array.isArray(action.transferables)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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vC,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,YAAY,UAAU,QAAQ;AAAA,EACxD;AACF;AAEO,SAAS,YAAY,SAAgE;AAC1F,SAAO,EAAE,MAAM,mBAAmB,cAAc,QAAQ;AAC1D;AAEO,SAAS,kBAAkB,SAGN;AAC1B,SAAO,EAAE,MAAM,mBAAmB,qBAAqB,QAAQ;AACjE;AAEO,SAAS,uBACd,MAI8B;AAC9B,SAAO,EAAE,MAAM,mBAAmB,2BAA2B,SAAS,EAAE,KAAK,EAAE;AACjF;AAEO,SAAS,wBAAwB,UAAmD;AACzF,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,0BAA0B,aAAsD;AAC9F,SAAO,EAAE,MAAM,mBAAmB,6BAA6B,SAAS,EAAE,YAAY,EAAE;AAC1F;AAEO,SAAS,+BACd,WAC0D;AAC1D,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,wBAAwB,QAAQ,CAAC,CAAC;AAEzE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,0BAA0B,SAAS,GAAG,CAAC,CAAC;AAAA,IACjF;AAAA,EACF;AACF;AAEO,SAAS,yBACd,SACA,eACyD;AACzD,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type ComponentMeta } from '../modules/components-meta'\nimport { type BoxModel } from '../modules/read-write/box-models'\n\nimport { type ElementSize } from '../middleware/read-write/builder-api/element-size'\nimport { type DocumentPayload, type SharedAction, SharedActionTypes } from '../shared-api'\n\nimport { type HostNavigationEvent } from './api'\n\nexport * from '../shared-api'\n\n// actions dispatched by the host to the builder (\"Builder API\")\n// note that some of these actions, in addition to being dispatched to the builder,\n// might also be internally intercepted by the host as a part of maintaining the\n// runtime's \"read-write\" state\nexport const BuilderActionTypes = {\n ...SharedActionTypes,\n\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n HANDLE_HOST_NAVIGATE: 'HANDLE_HOST_NAVIGATE',\n} as const\n\ntype ActionWithTransferables<A> = A & {\n transferables?: Transferable[]\n}\n\ntype MakeswiftConnectionCheckAction = {\n type: typeof BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK\n}\n\ntype MountComponentAction = {\n type: typeof BuilderActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof BuilderActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: ElementSize }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype HandleWheelAction = {\n type: typeof BuilderActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof BuilderActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype HandleHostNavigateAction = {\n type: typeof BuilderActionTypes.HANDLE_HOST_NAVIGATE\n payload: HostNavigationEvent\n}\n\nexport type BuilderAction =\n | SharedAction\n | MakeswiftConnectionCheckAction\n | MountComponentAction\n | UnmountComponentAction\n | ChangeDocumentElementSizeAction\n | ChangeElementBoxModelsAction\n | MessageBuilderPropControllerAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | ElementFromPointChangeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | HandleHostNavigateAction\n\nexport function makeswiftConnectionCheck(): MakeswiftConnectionCheckAction {\n return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function changeDocumentElementSize(size: ElementSize): ChangeDocumentElementSizeAction {\n return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return {\n type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,\n payload: { changedElementBoxModels },\n }\n}\n\nexport function messageBuilderPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageBuilderPropControllerAction<T> {\n return {\n type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: BuilderActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerBuilderDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterBuilderDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): ActionWithTransferables<RegisterBuilderComponentAction> {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nexport function hasTransferables<A extends BuilderAction>(\n action: A,\n): action is ActionWithTransferables<A> {\n return 'transferables' in action && Array.isArray(action.transferables)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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F;AAEO,SAAS,YAAY,SAAgE;AAC1F,SAAO,EAAE,MAAM,mBAAmB,cAAc,QAAQ;AAC1D;AAEO,SAAS,kBAAkB,SAGN;AAC1B,SAAO,EAAE,MAAM,mBAAmB,qBAAqB,QAAQ;AACjE;AAEO,SAAS,uBACd,MAI8B;AAC9B,SAAO,EAAE,MAAM,mBAAmB,2BAA2B,SAAS,EAAE,KAAK,EAAE;AACjF;AAEO,SAAS,wBAAwB,UAAmD;AACzF,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,0BAA0B,aAAsD;AAC9F,SAAO,EAAE,MAAM,mBAAmB,6BAA6B,SAAS,EAAE,YAAY,EAAE;AAC1F;AAEO,SAAS,+BACd,WAC0D;AAC1D,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,wBAAwB,QAAQ,CAAC,CAAC;AAEzE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,0BAA0B,SAAS,GAAG,CAAC,CAAC;AAAA,IACjF;AAAA,EACF;AACF;AAEO,SAAS,yBACd,SACA,eACyD;AACzD,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var api_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(api_exports);
|
|
17
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/api.ts"],"sourcesContent":["export type HostNavigationEvent = {\n url: string | null\n initialPageLoad: boolean\n}\n\nexport type BuilderApi = {\n handleHostNavigate(event: HostNavigationEvent): void\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -28,7 +28,6 @@ class MessageChannel {
|
|
|
28
28
|
appOrigin;
|
|
29
29
|
channel = null;
|
|
30
30
|
bufferedMessages = [];
|
|
31
|
-
connectionCheckIntervalID = null;
|
|
32
31
|
constructor({ appOrigin }) {
|
|
33
32
|
this.appOrigin = appOrigin;
|
|
34
33
|
}
|
|
@@ -39,12 +38,20 @@ class MessageChannel {
|
|
|
39
38
|
this.bufferedMessages.push([message, transferables]);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
setup(onMessage) {
|
|
43
|
-
this.
|
|
41
|
+
setup({ onMessage }) {
|
|
42
|
+
const cleanupConnectionCheck = setupConnectionCheck(this.appOrigin);
|
|
44
43
|
const channel = new window.MessageChannel();
|
|
45
44
|
channel.port1.onmessage = onMessage;
|
|
46
45
|
window.parent.postMessage(channel.port2, this.appOrigin, [channel.port2]);
|
|
47
46
|
this.channel = channel.port1;
|
|
47
|
+
return () => {
|
|
48
|
+
cleanupConnectionCheck();
|
|
49
|
+
if (this.channel) {
|
|
50
|
+
this.channel.onmessage = null;
|
|
51
|
+
this.channel.close();
|
|
52
|
+
this.channel = null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
48
55
|
}
|
|
49
56
|
dispatchBuffered() {
|
|
50
57
|
console.assert(this.channel != null, "channel is not setup");
|
|
@@ -53,38 +60,35 @@ class MessageChannel {
|
|
|
53
60
|
});
|
|
54
61
|
this.bufferedMessages = [];
|
|
55
62
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
}
|
|
64
|
+
function setupConnectionCheck(appOrigin) {
|
|
65
|
+
class Interval {
|
|
66
|
+
id = null;
|
|
67
|
+
setInterval(callback, delay) {
|
|
68
|
+
this.clear();
|
|
69
|
+
this.id = window.setInterval(callback, delay);
|
|
61
70
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
teardownConnectionCheck() {
|
|
68
|
-
window.removeEventListener("message", this.connectionCheckHandler);
|
|
69
|
-
if (this.connectionCheckIntervalID != null) {
|
|
70
|
-
window.clearInterval(this.connectionCheckIntervalID);
|
|
71
|
-
this.connectionCheckIntervalID = null;
|
|
71
|
+
clear() {
|
|
72
|
+
if (this.id != null) {
|
|
73
|
+
window.clearInterval(this.id);
|
|
74
|
+
this.id = null;
|
|
75
|
+
}
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
this.connectionCheckIntervalID = window.setInterval(() => {
|
|
83
|
-
window.parent.postMessage((0, import_actions.makeswiftConnectionCheck)({ currentUrl: window.location.href }), {
|
|
84
|
-
targetOrigin: this.appOrigin
|
|
85
|
-
});
|
|
86
|
-
}, CONNECTION_PING_INTERVAL_MS);
|
|
78
|
+
const connectionCheckInterval = new Interval();
|
|
79
|
+
function connectionCheckHandler(event) {
|
|
80
|
+
if (event.origin === appOrigin && event.data.type === import_shared_api.SharedActionTypes.MAKESWIFT_CONNECTION_INIT) {
|
|
81
|
+
connectionCheckInterval.setInterval(
|
|
82
|
+
() => window.parent.postMessage((0, import_actions.makeswiftConnectionCheck)(), { targetOrigin: appOrigin }),
|
|
83
|
+
CONNECTION_PING_INTERVAL_MS
|
|
84
|
+
);
|
|
87
85
|
}
|
|
86
|
+
}
|
|
87
|
+
window.addEventListener("message", connectionCheckHandler);
|
|
88
|
+
window.parent.postMessage((0, import_shared_api.makeswiftConnectionInit)(), { targetOrigin: appOrigin });
|
|
89
|
+
return () => {
|
|
90
|
+
window.removeEventListener("message", connectionCheckHandler);
|
|
91
|
+
connectionCheckInterval.clear();
|
|
88
92
|
};
|
|
89
93
|
}
|
|
90
94
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/builder-api/message-channel.ts"],"sourcesContent":["import { SharedActionTypes, makeswiftConnectionInit } from '../shared-api'\nimport { makeswiftConnectionCheck } from './actions'\n\nconst CONNECTION_PING_INTERVAL_MS = 20\n\nexport class MessageChannel {\n private readonly appOrigin: string\n private channel: MessagePort | null = null\n private bufferedMessages: [any, Transferable[]?][] = []\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/message-channel.ts"],"sourcesContent":["import { SharedActionTypes, makeswiftConnectionInit } from '../shared-api'\nimport { makeswiftConnectionCheck } from './actions'\n\nconst CONNECTION_PING_INTERVAL_MS = 20\n\nexport class MessageChannel {\n private readonly appOrigin: string\n private channel: MessagePort | null = null\n private bufferedMessages: [any, Transferable[]?][] = []\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.appOrigin = appOrigin\n }\n\n public postMessage(message: any, transferables?: Transferable[]) {\n if (this.channel) {\n this.channel.postMessage(message, transferables ?? [])\n } else {\n this.bufferedMessages.push([message, transferables])\n }\n }\n\n public setup({ onMessage }: { onMessage: (event: MessageEvent) => void }): VoidFunction {\n const cleanupConnectionCheck = setupConnectionCheck(this.appOrigin)\n\n const channel = new window.MessageChannel()\n channel.port1.onmessage = onMessage\n\n // connect channel to the parent window, see\n // https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API\n window.parent.postMessage(channel.port2, this.appOrigin, [channel.port2])\n\n this.channel = channel.port1\n\n return () => {\n cleanupConnectionCheck()\n\n if (this.channel) {\n this.channel.onmessage = null\n this.channel.close()\n this.channel = null\n }\n }\n }\n\n public dispatchBuffered() {\n console.assert(this.channel != null, 'channel is not setup')\n\n this.bufferedMessages.forEach(([message, transferables]) => {\n this.channel?.postMessage(message, transferables ?? [])\n })\n\n this.bufferedMessages = []\n }\n}\n\n// FIXME: instead of `window.parent.postMessage`, the connection check should\n// probably use the message channel itself: after all, it's meant to check\n// the health of the builder <> host connection, and whether we can reach the\n// builder through `window.parent.postMessage` is not indicative of the health\n// of the message channel itself, which is what the builder <> host\n// communication relies on.\nfunction setupConnectionCheck(appOrigin: string): VoidFunction {\n class Interval {\n private id: number | null = null\n\n setInterval(callback: () => void, delay: number) {\n this.clear()\n this.id = window.setInterval(callback, delay)\n }\n\n clear() {\n if (this.id != null) {\n window.clearInterval(this.id)\n this.id = null\n }\n }\n }\n\n const connectionCheckInterval = new Interval()\n\n function connectionCheckHandler(event: MessageEvent) {\n if (\n event.origin === appOrigin &&\n event.data.type === SharedActionTypes.MAKESWIFT_CONNECTION_INIT\n ) {\n connectionCheckInterval.setInterval(\n () => window.parent.postMessage(makeswiftConnectionCheck(), { targetOrigin: appOrigin }),\n CONNECTION_PING_INTERVAL_MS,\n )\n }\n }\n\n window.addEventListener('message', connectionCheckHandler)\n window.parent.postMessage(makeswiftConnectionInit(), { targetOrigin: appOrigin })\n\n return () => {\n window.removeEventListener('message', connectionCheckHandler)\n connectionCheckInterval.clear()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;A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N,UAAI,KAAK,MAAM,MAAM;AACnB,eAAO,cAAc,KAAK,EAAE;AAC5B,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,QAAM,0BAA0B,IAAI,SAAS;AAE7C,WAAS,uBAAuB,OAAqB;AACnD,QACE,MAAM,WAAW,aACjB,MAAM,KAAK,SAAS,oCAAkB,2BACtC;AACA,8BAAwB;AAAA,QACtB,MAAM,OAAO,OAAO,gBAAY,yCAAyB,GAAG,EAAE,cAAc,UAAU,CAAC;AAAA,QACvF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,iBAAiB,WAAW,sBAAsB;AACzD,SAAO,OAAO,gBAAY,2CAAwB,GAAG,EAAE,cAAc,UAAU,CAAC;AAEhF,SAAO,MAAM;AACX,WAAO,oBAAoB,WAAW,sBAAsB;AAC5D,4BAAwB,MAAM;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 navigation_listener_exports = {};
|
|
20
|
+
__export(navigation_listener_exports, {
|
|
21
|
+
setupNavigationListener: () => setupNavigationListener
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(navigation_listener_exports);
|
|
24
|
+
const CLICK_NAVIGATION_THRESHOLD_MS = 100;
|
|
25
|
+
const LOCATION_CHECK_DELAY_MS = 700;
|
|
26
|
+
function setupNavigationListener(callback) {
|
|
27
|
+
let previousLocation = null;
|
|
28
|
+
const handleNavigate = (event) => {
|
|
29
|
+
if (event.url === previousLocation)
|
|
30
|
+
return;
|
|
31
|
+
callback(event);
|
|
32
|
+
previousLocation = event.url;
|
|
33
|
+
};
|
|
34
|
+
handleNavigate({ url: windowLocation(), initialPageLoad: true });
|
|
35
|
+
if (typeof window === "undefined") {
|
|
36
|
+
return () => {
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const unsubscribes = [];
|
|
40
|
+
if ("navigation" in window && window.navigation) {
|
|
41
|
+
const navigation = window.navigation;
|
|
42
|
+
const handler = ({ destination }) => handleNavigate({ url: destination.url, initialPageLoad: false });
|
|
43
|
+
navigation.addEventListener("navigate", handler);
|
|
44
|
+
unsubscribes.push(() => navigation.removeEventListener("navigate", handler));
|
|
45
|
+
return () => {
|
|
46
|
+
unsubscribes.forEach((u) => u());
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let lastClickEvent = null;
|
|
50
|
+
const clickHandler = (e) => {
|
|
51
|
+
const a = e.composedPath?.()?.find((n) => n instanceof HTMLAnchorElement) ?? (e.target instanceof Element && e.target.closest?.("a"));
|
|
52
|
+
if (!a)
|
|
53
|
+
return;
|
|
54
|
+
lastClickEvent = { href: a.href, timestamp: Date.now() };
|
|
55
|
+
window.setTimeout(
|
|
56
|
+
() => handleNavigate({ url: windowLocation(), initialPageLoad: false }),
|
|
57
|
+
LOCATION_CHECK_DELAY_MS
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
window.document.addEventListener(
|
|
61
|
+
"click",
|
|
62
|
+
clickHandler,
|
|
63
|
+
{ capture: true }
|
|
64
|
+
// run before bubbling to fortify against `stopPropagation()` calls
|
|
65
|
+
);
|
|
66
|
+
unsubscribes.push(
|
|
67
|
+
() => window.document.removeEventListener("click", clickHandler, { capture: true })
|
|
68
|
+
);
|
|
69
|
+
const unloadHandler = () => {
|
|
70
|
+
if (!lastClickEvent)
|
|
71
|
+
return;
|
|
72
|
+
const msSinceLastClick = Date.now() - lastClickEvent.timestamp;
|
|
73
|
+
handleNavigate({
|
|
74
|
+
url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? lastClickEvent.href ?? null : null,
|
|
75
|
+
initialPageLoad: false
|
|
76
|
+
});
|
|
77
|
+
lastClickEvent = null;
|
|
78
|
+
};
|
|
79
|
+
window.addEventListener("beforeunload", unloadHandler);
|
|
80
|
+
unsubscribes.push(() => window.removeEventListener("beforeunload", unloadHandler));
|
|
81
|
+
return () => {
|
|
82
|
+
unsubscribes.forEach((u) => u());
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const windowLocation = () => typeof window !== "undefined" ? window.location.href : null;
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
setupNavigationListener
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=navigation-listener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/navigation-listener.ts"],"sourcesContent":["export type SiteNavigationEvent = {\n url: string | null\n initialPageLoad: boolean\n}\n\ntype ClickEvent = {\n href: string\n timestamp: number\n}\n\nconst CLICK_NAVIGATION_THRESHOLD_MS = 100\nconst LOCATION_CHECK_DELAY_MS = 700 // give the host generous time to perform the navigation\n\nexport function setupNavigationListener(\n callback: (args: SiteNavigationEvent) => void,\n): VoidFunction {\n let previousLocation: string | null = null\n\n const handleNavigate = (event: SiteNavigationEvent) => {\n if (event.url === previousLocation) return\n\n callback(event)\n previousLocation = event.url\n }\n\n // trigger navigation callback on initial page load\n handleNavigate({ url: windowLocation(), initialPageLoad: true })\n\n if (typeof window === 'undefined') {\n return () => {}\n }\n\n const unsubscribes: (() => void)[] = []\n\n // check for availability of the Navigation API (baseline feature since January 2026),\n // see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n if ('navigation' in window && window.navigation) {\n const navigation = window.navigation\n\n const handler = ({ destination }: NavigateEvent) =>\n handleNavigate({ url: destination.url, initialPageLoad: false })\n\n // note that in order to capture destination URLs that might not be Makeswift-enabled,\n // we send a `SiteNavigationEvent` at the start of navigation, but do not track whether\n // the navigation was successful or not (possible future improvement)\n navigation.addEventListener('navigate', handler)\n unsubscribes.push(() => navigation.removeEventListener('navigate', handler))\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n }\n\n // for browsers lacking Navigation API support, we manually track:\n // - link clicks to capture destination URLs\n // - page unload events to detect cross-page navigation\n let lastClickEvent: ClickEvent | null = null\n\n const clickHandler = (e: MouseEvent) => {\n const a =\n e.composedPath?.()?.find(n => n instanceof HTMLAnchorElement) ??\n (e.target instanceof Element && e.target.closest?.('a'))\n\n if (!a) return\n\n lastClickEvent = { href: a.href, timestamp: Date.now() }\n\n // handle navigation between pages in the host; note that we intentionally are\n // not cancelling the timer on cleanup to ensure we report the navigation\n window.setTimeout(\n () => handleNavigate({ url: windowLocation(), initialPageLoad: false }),\n LOCATION_CHECK_DELAY_MS,\n )\n }\n\n window.document.addEventListener(\n 'click',\n clickHandler,\n { capture: true }, // run before bubbling to fortify against `stopPropagation()` calls\n )\n\n unsubscribes.push(() =>\n window.document.removeEventListener('click', clickHandler, { capture: true }),\n )\n\n // handle external navigation\n const unloadHandler = () => {\n if (!lastClickEvent) return\n\n const msSinceLastClick = Date.now() - lastClickEvent.timestamp\n handleNavigate({\n url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? (lastClickEvent.href ?? null) : null,\n initialPageLoad: false,\n })\n\n lastClickEvent = null\n }\n\n window.addEventListener('beforeunload', unloadHandler)\n unsubscribes.push(() => window.removeEventListener('beforeunload', unloadHandler))\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n}\n\nconst windowLocation = (): string | null =>\n typeof window !== 'undefined' ? window.location.href : null\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,MAAM,gCAAgC;AACtC,MAAM,0BAA0B;AAEzB,SAAS,wBACd,UACc;AACd,MAAI,mBAAkC;AAEtC,QAAM,iBAAiB,CAAC,UAA+B;AACrD,QAAI,MAAM,QAAQ;AAAkB;AAEpC,aAAS,KAAK;AACd,uBAAmB,MAAM;AAAA,EAC3B;AAGA,iBAAe,EAAE,KAAK,eAAe,GAAG,iBAAiB,KAAK,CAAC;AAE/D,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAEA,QAAM,eAA+B,CAAC;AAItC,MAAI,gBAAgB,UAAU,OAAO,YAAY;AAC/C,UAAM,aAAa,OAAO;AAE1B,UAAM,UAAU,CAAC,EAAE,YAAY,MAC7B,eAAe,EAAE,KAAK,YAAY,KAAK,iBAAiB,MAAM,CAAC;AAKjE,eAAW,iBAAiB,YAAY,OAAO;AAC/C,iBAAa,KAAK,MAAM,WAAW,oBAAoB,YAAY,OAAO,CAAC;AAE3E,WAAO,MAAM;AACX,mBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,IAC/B;AAAA,EACF;AAKA,MAAI,iBAAoC;AAExC,QAAM,eAAe,CAAC,MAAkB;AACtC,UAAM,IACJ,EAAE,eAAe,GAAG,KAAK,OAAK,aAAa,iBAAiB,MAC3D,EAAE,kBAAkB,WAAW,EAAE,OAAO,UAAU,GAAG;AAExD,QAAI,CAAC;AAAG;AAER,qBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,KAAK,IAAI,EAAE;AAIvD,WAAO;AAAA,MACL,MAAM,eAAe,EAAE,KAAK,eAAe,GAAG,iBAAiB,MAAM,CAAC;AAAA,MACtE;AAAA,IACF;AAAA,EACF;AAEA,SAAO,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA,EAAE,SAAS,KAAK;AAAA;AAAA,EAClB;AAEA,eAAa;AAAA,IAAK,MAChB,OAAO,SAAS,oBAAoB,SAAS,cAAc,EAAE,SAAS,KAAK,CAAC;AAAA,EAC9E;AAGA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,CAAC;AAAgB;AAErB,UAAM,mBAAmB,KAAK,IAAI,IAAI,eAAe;AACrD,mBAAe;AAAA,MACb,KAAK,mBAAmB,gCAAiC,eAAe,QAAQ,OAAQ;AAAA,MACxF,iBAAiB;AAAA,IACnB,CAAC;AAED,qBAAiB;AAAA,EACnB;AAEA,SAAO,iBAAiB,gBAAgB,aAAa;AACrD,eAAa,KAAK,MAAM,OAAO,oBAAoB,gBAAgB,aAAa,CAAC;AAEjF,SAAO,MAAM;AACX,iBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,EAC/B;AACF;AAEA,MAAM,iBAAiB,MACrB,OAAO,WAAW,cAAc,OAAO,SAAS,OAAO;","names":[]}
|
|
@@ -24,21 +24,34 @@ module.exports = __toCommonJS(proxy_exports);
|
|
|
24
24
|
var import_host_api = require("../host-api");
|
|
25
25
|
var import_actions = require("./actions");
|
|
26
26
|
var import_message_channel = require("./message-channel");
|
|
27
|
+
var import_navigation_listener = require("./navigation-listener");
|
|
27
28
|
class BuilderAPIProxy {
|
|
28
29
|
messageChannel;
|
|
29
30
|
constructor({ appOrigin }) {
|
|
30
31
|
this.messageChannel = new import_message_channel.MessageChannel({ appOrigin });
|
|
31
32
|
}
|
|
33
|
+
handleHostNavigate(event) {
|
|
34
|
+
this.execute({ type: import_actions.BuilderActionTypes.HANDLE_HOST_NAVIGATE, payload: event });
|
|
35
|
+
}
|
|
32
36
|
// low-level, action-based API
|
|
33
37
|
setup({ onHostAction }) {
|
|
34
|
-
this.messageChannel.setup(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const channelCleanup = this.messageChannel.setup({
|
|
39
|
+
onMessage: (event) => {
|
|
40
|
+
const action = event.data;
|
|
41
|
+
if (!(0, import_host_api.isHostAction)(action)) {
|
|
42
|
+
console.warn("Unexpected host action", action);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
onHostAction(action);
|
|
39
46
|
}
|
|
40
|
-
onHostAction(action);
|
|
41
47
|
});
|
|
48
|
+
const navigationListenerCleanup = (0, import_navigation_listener.setupNavigationListener)(
|
|
49
|
+
(event) => this.handleHostNavigate(event)
|
|
50
|
+
);
|
|
51
|
+
return () => {
|
|
52
|
+
channelCleanup();
|
|
53
|
+
navigationListenerCleanup();
|
|
54
|
+
};
|
|
42
55
|
}
|
|
43
56
|
execute(action) {
|
|
44
57
|
if ((0, import_actions.hasTransferables)(action)) {
|
|
@@ -51,9 +64,6 @@ class BuilderAPIProxy {
|
|
|
51
64
|
dispatchBuffered() {
|
|
52
65
|
this.messageChannel.dispatchBuffered();
|
|
53
66
|
}
|
|
54
|
-
teardown() {
|
|
55
|
-
this.messageChannel.teardown();
|
|
56
|
-
}
|
|
57
67
|
}
|
|
58
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
69
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/builder-api/proxy.ts"],"sourcesContent":["import { type HostAction, isHostAction } from '../host-api'\n\nimport { type BuilderAction, hasTransferables } from './actions'\nimport { MessageChannel } from './message-channel'\n\nexport class BuilderAPIProxy {\n private messageChannel: MessageChannel\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.messageChannel = new MessageChannel({ appOrigin })\n }\n\n // low-level, action-based API\n\n setup({ onHostAction }: { onHostAction: (action: HostAction) => void }):
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/proxy.ts"],"sourcesContent":["import { type HostAction, isHostAction } from '../host-api'\n\nimport { type BuilderAction, BuilderActionTypes, hasTransferables } from './actions'\nimport { MessageChannel } from './message-channel'\nimport { setupNavigationListener } from './navigation-listener'\nimport { type BuilderApi, type HostNavigationEvent } from './api'\n\nexport class BuilderAPIProxy implements BuilderApi {\n private messageChannel: MessageChannel\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.messageChannel = new MessageChannel({ appOrigin })\n }\n\n handleHostNavigate(event: HostNavigationEvent) {\n this.execute({ type: BuilderActionTypes.HANDLE_HOST_NAVIGATE, payload: event })\n }\n\n // low-level, action-based API\n\n setup({ onHostAction }: { onHostAction: (action: HostAction) => void }): VoidFunction {\n const channelCleanup = this.messageChannel.setup({\n onMessage: (event: MessageEvent) => {\n const action = event.data\n\n if (!isHostAction(action)) {\n console.warn('Unexpected host action', action)\n return\n }\n\n onHostAction(action)\n },\n })\n\n const navigationListenerCleanup = setupNavigationListener(event =>\n this.handleHostNavigate(event),\n )\n\n return () => {\n channelCleanup()\n navigationListenerCleanup()\n }\n }\n\n execute(action: BuilderAction): void {\n if (hasTransferables(action)) {\n const { transferables, ...forwardedAction } = action\n this.messageChannel.postMessage(forwardedAction, transferables)\n return\n }\n\n this.messageChannel.postMessage(action)\n }\n\n dispatchBuffered(): void {\n this.messageChannel.dispatchBuffered()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8C;AAE9C,qBAAyE;AACzE,6BAA+B;AAC/B,iCAAwC;AAGjC,MAAM,gBAAsC;AAAA,EACzC;AAAA,EAER,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,iBAAiB,IAAI,sCAAe,EAAE,UAAU,CAAC;AAAA,EACxD;AAAA,EAEA,mBAAmB,OAA4B;AAC7C,SAAK,QAAQ,EAAE,MAAM,kCAAmB,sBAAsB,SAAS,MAAM,CAAC;AAAA,EAChF;AAAA;AAAA,EAIA,MAAM,EAAE,aAAa,GAAiE;AACpF,UAAM,iBAAiB,KAAK,eAAe,MAAM;AAAA,MAC/C,WAAW,CAAC,UAAwB;AAClC,cAAM,SAAS,MAAM;AAErB,YAAI,KAAC,8BAAa,MAAM,GAAG;AACzB,kBAAQ,KAAK,0BAA0B,MAAM;AAC7C;AAAA,QACF;AAEA,qBAAa,MAAM;AAAA,MACrB;AAAA,IACF,CAAC;AAED,UAAM,gCAA4B;AAAA,MAAwB,WACxD,KAAK,mBAAmB,KAAK;AAAA,IAC/B;AAEA,WAAO,MAAM;AACX,qBAAe;AACf,gCAA0B;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,QAAQ,QAA6B;AACnC,YAAI,iCAAiB,MAAM,GAAG;AAC5B,YAAM,EAAE,eAAe,GAAG,gBAAgB,IAAI;AAC9C,WAAK,eAAe,YAAY,iBAAiB,aAAa;AAC9D;AAAA,IACF;AAEA,SAAK,eAAe,YAAY,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAyB;AACvB,SAAK,eAAe,iBAAiB;AAAA,EACvC;AACF;","names":[]}
|
|
@@ -59,10 +59,13 @@ function builderAPIMiddleware(builderProxy) {
|
|
|
59
59
|
window.getSelection()?.removeAllRanges();
|
|
60
60
|
break;
|
|
61
61
|
case import_host_api.HostActionTypes.INIT:
|
|
62
|
+
cleanUp();
|
|
62
63
|
cleanUp = dispatch((0, import_initialize_connection.initializeBuilderConnection)(builderProxy));
|
|
63
64
|
break;
|
|
64
65
|
case import_host_api.HostActionTypes.CLEAN_UP:
|
|
65
66
|
cleanUp();
|
|
67
|
+
cleanUp = () => {
|
|
68
|
+
};
|
|
66
69
|
break;
|
|
67
70
|
}
|
|
68
71
|
return next(action);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/actions'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,kBAAmC;AAEnC,IAAAC,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS,qBACd,cACuC;AACvC,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,QAAI,OAAO,WAAW;AAAa,aAAO,CAAC,WAAmB,KAAK,MAAM;AAEzE,QAAI,UAAU,MAAM;AAAA,IAAC;AACrB,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AACtB,uBAAa,QAAQ,MAAM;AAC3B;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,YAAY,OAAO,QAAQ;AAC3D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,aAAa,OAAO,QAAQ;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,aAAa,GAAG,gBAAgB;AACvC;AAAA,QAEF,KAAK,gCAAgB;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/actions'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n // and in response to host's client-side navigation\n cleanUp() // cleanup existing connection setup, if any\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n cleanU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;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_toolkit"]}
|
|
@@ -106,7 +106,7 @@ function getElementImperativeHandlesContainingElement(state, element) {
|
|
|
106
106
|
}
|
|
107
107
|
function setupBuilderProxy(builderProxy) {
|
|
108
108
|
return (dispatch) => {
|
|
109
|
-
builderProxy.setup({ onHostAction: (action) => dispatch(action) });
|
|
109
|
+
return builderProxy.setup({ onHostAction: (action) => dispatch(action) });
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<
|
|
1
|
+
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<VoidFunction, State, unknown, Action> {\n return dispatch => {\n return builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsE;AAEtE,gBAA2B;AAC3B,gBAA2B;AAC3B,cAAyB;AACzB,+BAA0C;AAO1C,oBAA+B;AAI/B,wBAAyC;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,aAAO,gCAAgB,QAAQ;AACjC;AAWA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,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js/state/store.js
CHANGED
|
@@ -114,10 +114,10 @@ function configureStore({
|
|
|
114
114
|
const builderProxy = new BuilderAPIProxy({ appOrigin });
|
|
115
115
|
readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy });
|
|
116
116
|
const dispatch = store.dispatch;
|
|
117
|
-
dispatch(setupBuilderProxy(builderProxy));
|
|
117
|
+
const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy));
|
|
118
118
|
readWriteCleanup = () => {
|
|
119
119
|
readWriteMiddlewareRef.current = null;
|
|
120
|
-
|
|
120
|
+
builderProxyCleanup();
|
|
121
121
|
};
|
|
122
122
|
})();
|
|
123
123
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\n\nimport { type Action } from './actions'\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\n\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\ninterface ReadWriteStateMixin {\n loadReadWriteState: ({ isReadOnly }: { isReadOnly: boolean }) => Promise<() => void>\n}\n\nfunction withReadWriteState(\n loadReadWriteState: ReadWriteStateMixin['loadReadWriteState'],\n): StoreEnhancer<ReadWriteStateMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n loadReadWriteState,\n })\n}\n\nexport function configureStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n breakpoints,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxy.teardown()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ]),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withReadWriteState(async ({ isReadOnly }) => {\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', {\n isReadOnly,\n refCount,\n })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n }),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAIP,IAAAA,kBAAoE;AACpE,qBAAmC;AACnC,sBAAgC;AAEhC,kBAA6B;AAE7B,oCAA8C;AAI9C,oBAA+B;AAQ/B,uCAAiD;AAU1C,SAAS,+BACd,eACuC;AACvC,MAAI,wBAAkC,CAAC;AACvC,MAAI,cAA0C;AAC9C,MAAI,mBAAoC;AAExC,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,YAAM,QAAQ,SAAS;AAEvB,UAAI,cAAc,WAAW,MAAM;AACjC,YAAI,CAAC,MAAM,YAAY;AAIrB,gCAAsB,KAAK,MAAM;AAAA,QACnC;AAEA,eAAO,KAAK,MAAM;AAAA,MACpB;AAEA,UAAI,MAAM,YAAY;AACpB,gBAAQ,MAAM,6BAA6B;AAAA,UACzC,YAAY,MAAM;AAAA,UAClB,eAAe,cAAc;AAAA,UAC7B,aAAa,MAAM;AAAA,QACrB,CAAC;AAAA,MACH;AAGA,UAAI,oBAAoB,QAAQ,gBAAgB,cAAc,SAAS;AACrE,sBAAc,cAAc;AAE5B,cAAM,gBAAgB,EAAE,UAAU,SAAS;AAK3C,+BA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"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\n\nimport { type Action } from './actions'\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\n\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\ninterface ReadWriteStateMixin {\n loadReadWriteState: ({ isReadOnly }: { isReadOnly: boolean }) => Promise<() => void>\n}\n\nfunction withReadWriteState(\n loadReadWriteState: ReadWriteStateMixin['loadReadWriteState'],\n): StoreEnhancer<ReadWriteStateMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n loadReadWriteState,\n })\n}\n\nexport function configureStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n breakpoints,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ]),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withReadWriteState(async ({ isReadOnly }) => {\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', {\n isReadOnly,\n refCount,\n })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n }),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;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C,+BAA+B,sBAAsB;AAAA,IACvD,CAAC;AAAA,IAEH,WAAW,yBACT,oBAAoB,EAAE;AAAA,MACpB,mBAAmB,OAAO,EAAE,WAAW,MAAM;AAC3C,YAAI,YAAY;AACd,cAAI,WAAW,GAAG;AAChB,oBAAQ,MAAM,6BAA6B;AAAA,cACzC;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH;AAEA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,cAAM,mBAAmB;AACzB,oBAAY;AAEZ,YAAI,aAAa;AACjB,eAAO,MAAM;AACX,cAAI,YAAY;AACd;AAAA,UACF;AAEA,uBAAa;AACb,sBAAY;AACZ,cAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,6BAAiB;AACjB,+BAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gCAAgB;AAAA,QAChB,kCAAmB;AAAA,QACnB,kCAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":["import_toolkit","configureReduxStore"]}
|
|
@@ -26,6 +26,7 @@ __export(unstable_framework_support_exports, {
|
|
|
26
26
|
MAKESWIFT_SITE_VERSION_COOKIE: () => import_preview.MAKESWIFT_SITE_VERSION_COOKIE,
|
|
27
27
|
MakeswiftClient: () => import_client.MakeswiftClient,
|
|
28
28
|
MakeswiftComponent: () => import_MakeswiftComponent.MakeswiftComponent,
|
|
29
|
+
MakeswiftFonts: () => import_MakeswiftFonts.MakeswiftFonts,
|
|
29
30
|
Page: () => import_page.Page,
|
|
30
31
|
REDIRECT_SEARCH_PARAM: () => import_redirect_live.REDIRECT_SEARCH_PARAM,
|
|
31
32
|
ReactRuntime: () => import_react_runtime.ReactRuntime,
|
|
@@ -60,6 +61,7 @@ var import_page = require("../runtimes/react/components/page");
|
|
|
60
61
|
var import_RuntimeProvider = require("../runtimes/react/components/RuntimeProvider");
|
|
61
62
|
var import_Slot = require("../runtimes/react/components/Slot");
|
|
62
63
|
var import_GoogleFontLink = require("../runtimes/react/components/GoogleFontLink");
|
|
64
|
+
var import_MakeswiftFonts = require("../runtimes/react/components/MakeswiftFonts");
|
|
63
65
|
var import_root_style_registry = require("../runtimes/react/root-style-registry");
|
|
64
66
|
var import_react_runtime = require("../runtimes/react/react-runtime");
|
|
65
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -72,6 +74,7 @@ var import_react_runtime = require("../runtimes/react/react-runtime");
|
|
|
72
74
|
MAKESWIFT_SITE_VERSION_COOKIE,
|
|
73
75
|
MakeswiftClient,
|
|
74
76
|
MakeswiftComponent,
|
|
77
|
+
MakeswiftFonts,
|
|
75
78
|
Page,
|
|
76
79
|
REDIRECT_SEARCH_PARAM,
|
|
77
80
|
ReactRuntime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,4BAA+B;AAE/B,iCAMO;AAEP,2BAA6B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,4BAA+B;AAC/B,4BAA+B;AAE/B,iCAMO;AAEP,2BAA6B;","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.28.0
|
|
11
|
+
version: "0.28.0",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
package/dist/esm/client/index.js
CHANGED
|
@@ -179,7 +179,8 @@ const getFontsAPISchema = z.object({
|
|
|
179
179
|
googleFonts: z.array(z.object({
|
|
180
180
|
family: z.string(),
|
|
181
181
|
variants: z.array(z.string())
|
|
182
|
-
}))
|
|
182
|
+
})),
|
|
183
|
+
siteId: z.string()
|
|
183
184
|
});
|
|
184
185
|
class MakeswiftClient {
|
|
185
186
|
graphqlClient;
|
|
@@ -194,7 +195,7 @@ Received "${apiKey}" instead.`
|
|
|
194
195
|
}
|
|
195
196
|
this.apiKey = apiKey;
|
|
196
197
|
this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
|
|
197
|
-
"makeswift-runtime-version": "0.28.0
|
|
198
|
+
"makeswift-runtime-version": "0.28.0"
|
|
198
199
|
});
|
|
199
200
|
this.runtime = runtime;
|
|
200
201
|
}
|
|
@@ -206,7 +207,7 @@ Received "${apiKey}" instead.`
|
|
|
206
207
|
const requestHeaders = new Headers({
|
|
207
208
|
"x-api-key": this.apiKey,
|
|
208
209
|
"makeswift-site-api-key": this.apiKey,
|
|
209
|
-
"makeswift-runtime-version": "0.28.0
|
|
210
|
+
"makeswift-runtime-version": "0.28.0"
|
|
210
211
|
});
|
|
211
212
|
if (siteVersion?.token) {
|
|
212
213
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -664,7 +665,7 @@ Received "${apiKey}" instead.`
|
|
|
664
665
|
headers: {
|
|
665
666
|
"x-api-key": this.apiKey,
|
|
666
667
|
"makeswift-site-api-key": this.apiKey,
|
|
667
|
-
"makeswift-runtime-version": "0.28.0
|
|
668
|
+
"makeswift-runtime-version": "0.28.0",
|
|
668
669
|
"content-type": "application/json"
|
|
669
670
|
},
|
|
670
671
|
body: JSON.stringify({ token }),
|