@makeswift/runtime 0.26.1-canary.0 → 0.26.1-canary.2
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/graphql/client.js +7 -2
- package/dist/cjs/api/graphql/client.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/builder/index.js +4 -4
- package/dist/cjs/builder/index.js.map +1 -1
- package/dist/cjs/client/index.js +10 -6
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js +2 -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 +2 -2
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-register-document.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +1 -2
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/state/actions/index.js +2 -2
- package/dist/cjs/state/actions/index.js.map +1 -1
- package/dist/cjs/state/actions/internal.js +31 -0
- package/dist/cjs/state/actions/internal.js.map +1 -1
- package/dist/cjs/state/{builder-api.js → builder-api/actions.js} +10 -11
- 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 +21 -7
- package/dist/cjs/state/host-api.js.map +1 -1
- package/dist/cjs/state/makeswift-api-client.js +2 -2
- package/dist/cjs/state/makeswift-api-client.js.map +1 -1
- package/dist/cjs/state/react-builder-preview.js +72 -99
- package/dist/cjs/state/react-builder-preview.js.map +1 -1
- package/dist/cjs/state/shared-api.js +1 -39
- package/dist/cjs/state/shared-api.js.map +1 -1
- package/dist/esm/api/graphql/client.js +7 -2
- package/dist/esm/api/graphql/client.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/builder/index.js +6 -4
- package/dist/esm/builder/index.js.map +1 -1
- package/dist/esm/client/index.js +10 -6
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js +1 -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 +1 -1
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-register-document.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +1 -2
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/state/actions/index.js +1 -1
- package/dist/esm/state/actions/index.js.map +1 -1
- package/dist/esm/state/actions/internal.js +27 -0
- package/dist/esm/state/actions/internal.js.map +1 -1
- package/dist/esm/state/{builder-api.js → builder-api/actions.js} +6 -7
- 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 +19 -6
- package/dist/esm/state/host-api.js.map +1 -1
- package/dist/esm/state/makeswift-api-client.js +1 -1
- package/dist/esm/state/makeswift-api-client.js.map +1 -1
- package/dist/esm/state/react-builder-preview.js +72 -117
- package/dist/esm/state/react-builder-preview.js.map +1 -1
- package/dist/esm/state/shared-api.js +1 -35
- package/dist/esm/state/shared-api.js.map +1 -1
- package/dist/types/api/graphql/client.d.ts +2 -1
- package/dist/types/api/graphql/client.d.ts.map +1 -1
- package/dist/types/builder/index.d.ts +3 -3
- package/dist/types/builder/index.d.ts.map +1 -1
- package/dist/types/client/index.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/react-runtime-core.d.ts.map +1 -1
- package/dist/types/state/actions/index.d.ts +5 -5
- package/dist/types/state/actions/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal.d.ts +29 -2
- package/dist/types/state/actions/internal.d.ts.map +1 -1
- package/dist/types/state/{builder-api.d.ts → builder-api/actions.d.ts} +14 -20
- 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 +22 -20
- package/dist/types/state/host-api.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/shared-api.d.ts +1 -36
- package/dist/types/state/shared-api.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/state/builder-api.js.map +0 -1
- package/dist/esm/state/builder-api.js.map +0 -1
- package/dist/types/state/builder-api.d.ts.map +0 -1
|
@@ -23,6 +23,8 @@ __export(internal_exports, {
|
|
|
23
23
|
changeElementTree: () => changeElementTree,
|
|
24
24
|
createElementTree: () => createElementTree,
|
|
25
25
|
deleteElementTree: () => deleteElementTree,
|
|
26
|
+
registerComponent: () => registerComponent,
|
|
27
|
+
registerComponentEffect: () => registerComponentEffect,
|
|
26
28
|
registerComponentHandle: () => registerComponentHandle,
|
|
27
29
|
registerComponentHandleEffect: () => registerComponentHandleEffect,
|
|
28
30
|
registerMeasurable: () => registerMeasurable,
|
|
@@ -30,6 +32,8 @@ __export(internal_exports, {
|
|
|
30
32
|
registerPropControllers: () => registerPropControllers,
|
|
31
33
|
registerPropControllersHandle: () => registerPropControllersHandle,
|
|
32
34
|
registerReactComponentEffect: () => registerReactComponentEffect,
|
|
35
|
+
setIsInBuilder: () => setIsInBuilder,
|
|
36
|
+
unregisterComponent: () => unregisterComponent,
|
|
33
37
|
unregisterMeasurable: () => unregisterMeasurable,
|
|
34
38
|
unregisterPropControllers: () => unregisterPropControllers,
|
|
35
39
|
unregisterPropControllersHandle: () => unregisterPropControllersHandle,
|
|
@@ -41,6 +45,8 @@ const InternalActionTypes = {
|
|
|
41
45
|
CREATE_ELEMENT_TREE: "CREATE_ELEMENT_TREE",
|
|
42
46
|
DELETE_ELEMENT_TREE: "DELETE_ELEMENT_TREE",
|
|
43
47
|
CHANGE_ELEMENT_TREE: "CHANGE_ELEMENT_TREE",
|
|
48
|
+
REGISTER_COMPONENT: "REGISTER_COMPONENT",
|
|
49
|
+
UNREGISTER_COMPONENT: "UNREGISTER_COMPONENT",
|
|
44
50
|
REGISTER_COMPONENT_HANDLE: "REGISTER_COMPONENT_HANDLE",
|
|
45
51
|
UNREGISTER_COMPONENT_HANDLE: "UNREGISTER_COMPONENT_HANDLE",
|
|
46
52
|
REGISTER_MEASURABLE: "REGISTER_MEASURABLE",
|
|
@@ -51,6 +57,7 @@ const InternalActionTypes = {
|
|
|
51
57
|
UNREGISTER_PROP_CONTROLLERS_HANDLE: "UNREGISTER_PROP_CONTROLLERS_HANDLE",
|
|
52
58
|
REGISTER_REACT_COMPONENT: "REGISTER_REACT_COMPONENT",
|
|
53
59
|
UNREGISTER_REACT_COMPONENT: "UNREGISTER_REACT_COMPONENT",
|
|
60
|
+
SET_IS_IN_BUILDER: "SET_IS_IN_BUILDER",
|
|
54
61
|
UPDATE_API_CLIENT_CACHE: "UPDATE_API_CLIENT_CACHE"
|
|
55
62
|
};
|
|
56
63
|
function apiResourceFulfilled(resourceType, resourceId, resource, locale) {
|
|
@@ -74,6 +81,23 @@ function changeElementTree(payload) {
|
|
|
74
81
|
payload
|
|
75
82
|
};
|
|
76
83
|
}
|
|
84
|
+
function registerComponent(type, meta, propControllerDescriptors) {
|
|
85
|
+
return {
|
|
86
|
+
type: InternalActionTypes.REGISTER_COMPONENT,
|
|
87
|
+
payload: { type, meta, propControllerDescriptors }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function unregisterComponent(type) {
|
|
91
|
+
return { type: InternalActionTypes.UNREGISTER_COMPONENT, payload: { type } };
|
|
92
|
+
}
|
|
93
|
+
function registerComponentEffect(type, meta, propControllerDescriptors) {
|
|
94
|
+
return (dispatch) => {
|
|
95
|
+
dispatch(registerComponent(type, meta, propControllerDescriptors));
|
|
96
|
+
return () => {
|
|
97
|
+
dispatch(unregisterComponent(type));
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
77
101
|
function registerComponentHandle(documentKey, elementKey, componentHandle) {
|
|
78
102
|
return {
|
|
79
103
|
type: InternalActionTypes.REGISTER_COMPONENT_HANDLE,
|
|
@@ -149,6 +173,9 @@ function registerReactComponentEffect(type, component) {
|
|
|
149
173
|
};
|
|
150
174
|
};
|
|
151
175
|
}
|
|
176
|
+
function setIsInBuilder(isInBuilder) {
|
|
177
|
+
return { type: InternalActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder };
|
|
178
|
+
}
|
|
152
179
|
function updateAPIClientCache(payload) {
|
|
153
180
|
return { type: InternalActionTypes.UPDATE_API_CLIENT_CACHE, payload };
|
|
154
181
|
}
|
|
@@ -159,6 +186,8 @@ function updateAPIClientCache(payload) {
|
|
|
159
186
|
changeElementTree,
|
|
160
187
|
createElementTree,
|
|
161
188
|
deleteElementTree,
|
|
189
|
+
registerComponent,
|
|
190
|
+
registerComponentEffect,
|
|
162
191
|
registerComponentHandle,
|
|
163
192
|
registerComponentHandleEffect,
|
|
164
193
|
registerMeasurable,
|
|
@@ -166,6 +195,8 @@ function updateAPIClientCache(payload) {
|
|
|
166
195
|
registerPropControllers,
|
|
167
196
|
registerPropControllersHandle,
|
|
168
197
|
registerReactComponentEffect,
|
|
198
|
+
setIsInBuilder,
|
|
199
|
+
unregisterComponent,
|
|
169
200
|
unregisterMeasurable,
|
|
170
201
|
unregisterPropControllers,
|
|
171
202
|
unregisterPropControllersHandle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/actions/internal.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\n\nimport { type APIResource, APIResourceType, APIResourceLocale } from '../../api/types'\n\nimport { type Measurable } from '../modules/box-models'\nimport { type PropControllersHandle } from '../modules/prop-controller-handles'\nimport { type ComponentType } from '../modules/react-components'\nimport { type DescriptorsByComponentType } from '../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../shared-api'\nimport { type SerializedState as APIClientCache } from '../makeswift-api-client'\n\nexport const InternalActionTypes = {\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n} as const\n\ntype APIResourceFulfilledAction = {\n type: typeof InternalActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: InternalActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\ntype CreateElementTreeAction = {\n type: typeof InternalActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof InternalActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\ntype ChangeElementTreeAction = {\n type: typeof InternalActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof InternalActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof InternalActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof InternalActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof InternalActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof InternalActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof InternalActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof InternalActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof InternalActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof InternalActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof InternalActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\ntype UpdateAPIClientCache = {\n type: typeof InternalActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\nexport type InternalAction =\n | APIResourceFulfilledAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | ChangeElementTreeAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | UpdateAPIClientCache\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: InternalActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: InternalActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: InternalActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: InternalActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: InternalActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: InternalActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: InternalActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: InternalActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: InternalActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: InternalActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: InternalActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: InternalActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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S,uBAAuB,MAAM,SAAS,CAAC;AAEhD,WAAO,MAAM;AACX,eAAS,yBAAyB,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,oBAAoB,yBAAyB,QAAQ;AACtE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/actions/internal.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\n\nimport { type APIResource, APIResourceType, APIResourceLocale } from '../../api/types'\nimport { type Descriptor as PropControllerDescriptor } from '../../prop-controllers/descriptors'\n\nimport { type Measurable } from '../modules/box-models'\nimport { type ComponentMeta } from '../modules/components-meta'\nimport { type PropControllersHandle } from '../modules/prop-controller-handles'\nimport { type ComponentType } from '../modules/react-components'\nimport { type DescriptorsByComponentType } from '../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../shared-api'\nimport { type SerializedState as APIClientCache } from '../makeswift-api-client'\n\nexport const InternalActionTypes = {\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n} as const\n\ntype APIResourceFulfilledAction = {\n type: typeof InternalActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype CreateElementTreeAction = {\n type: typeof InternalActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof InternalActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\ntype ChangeElementTreeAction = {\n type: typeof InternalActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterComponentAction = {\n type: typeof InternalActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\ntype UnregisterComponentAction = {\n type: typeof InternalActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof InternalActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof InternalActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof InternalActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof InternalActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof InternalActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof InternalActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof InternalActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof InternalActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof InternalActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof InternalActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof InternalActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype UpdateAPIClientCache = {\n type: typeof InternalActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\nexport type InternalAction =\n | APIResourceFulfilledAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | ChangeElementTreeAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | SetIsInBuilderAction\n | UpdateAPIClientCache\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: InternalActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: InternalActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: InternalActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: InternalActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: InternalActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: InternalActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: InternalActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: InternalActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: InternalActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: InternalActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: InternalActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: InternalActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: InternalActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: InternalActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, InternalAction> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: InternalActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: InternalActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\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;AAmBO,MAAM,sBAAsB;AAAA,EACjC,wBAAwB;AAAA,EAExB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EAEtB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EAEvB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,kCAAkC;AAAA,EAClC,oCAAoC;AAAA,EAEpC,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,mBAAmB;AAAA,EAEnB,yBAAyB;AAC3B;AAkIO,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AAuB,MAAM,SAAS,CAAC;AAEhD,WAAO,MAAM;AACX,eAAS,yBAAyB,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,SAAS,eAAe,aAA4C;AACzE,SAAO,EAAE,MAAM,oBAAoB,mBAAmB,SAAS,YAAY;AAC7E;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,oBAAoB,yBAAyB,QAAQ;AACtE;","names":[]}
|
|
@@ -16,14 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var actions_exports = {};
|
|
20
|
+
__export(actions_exports, {
|
|
21
21
|
BuilderActionTypes: () => BuilderActionTypes,
|
|
22
22
|
changeDocumentElementSize: () => changeDocumentElementSize,
|
|
23
23
|
changeElementBoxModels: () => changeElementBoxModels,
|
|
24
24
|
elementFromPointChange: () => elementFromPointChange,
|
|
25
25
|
handlePointerMove: () => handlePointerMove,
|
|
26
26
|
handleWheel: () => handleWheel,
|
|
27
|
+
hasTransferables: () => hasTransferables,
|
|
27
28
|
makeswiftConnectionCheck: () => makeswiftConnectionCheck,
|
|
28
29
|
messageBuilderPropController: () => messageBuilderPropController,
|
|
29
30
|
mountComponent: () => mountComponent,
|
|
@@ -31,13 +32,12 @@ __export(builder_api_exports, {
|
|
|
31
32
|
registerBuilderComponent: () => registerBuilderComponent,
|
|
32
33
|
registerBuilderDocument: () => registerBuilderDocument,
|
|
33
34
|
registerBuilderDocumentsEffect: () => registerBuilderDocumentsEffect,
|
|
34
|
-
setIsInBuilder: () => setIsInBuilder,
|
|
35
35
|
unmountComponent: () => unmountComponent,
|
|
36
36
|
unregisterBuilderComponent: () => unregisterBuilderComponent,
|
|
37
37
|
unregisterBuilderDocument: () => unregisterBuilderDocument
|
|
38
38
|
});
|
|
39
|
-
module.exports = __toCommonJS(
|
|
40
|
-
var import_shared_api = require("
|
|
39
|
+
module.exports = __toCommonJS(actions_exports);
|
|
40
|
+
var import_shared_api = require("../shared-api");
|
|
41
41
|
const BuilderActionTypes = {
|
|
42
42
|
...import_shared_api.SharedActionTypes,
|
|
43
43
|
MAKESWIFT_CONNECTION_CHECK: "MAKESWIFT_CONNECTION_CHECK",
|
|
@@ -49,7 +49,6 @@ const BuilderActionTypes = {
|
|
|
49
49
|
HANDLE_WHEEL: "HANDLE_WHEEL",
|
|
50
50
|
HANDLE_POINTER_MOVE: "HANDLE_POINTER_MOVE",
|
|
51
51
|
ELEMENT_FROM_POINT_CHANGE: "ELEMENT_FROM_POINT_CHANGE",
|
|
52
|
-
SET_IS_IN_BUILDER: "SET_IS_IN_BUILDER",
|
|
53
52
|
REGISTER_BUILDER_DOCUMENT: "REGISTER_BUILDER_DOCUMENT",
|
|
54
53
|
UNREGISTER_BUILDER_DOCUMENT: "UNREGISTER_BUILDER_DOCUMENT",
|
|
55
54
|
REGISTER_BUILDER_COMPONENT: "REGISTER_BUILDER_COMPONENT",
|
|
@@ -97,9 +96,6 @@ function handlePointerMove(payload) {
|
|
|
97
96
|
function elementFromPointChange(keys) {
|
|
98
97
|
return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } };
|
|
99
98
|
}
|
|
100
|
-
function setIsInBuilder(isInBuilder) {
|
|
101
|
-
return { type: BuilderActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder };
|
|
102
|
-
}
|
|
103
99
|
function registerBuilderDocument(document) {
|
|
104
100
|
return {
|
|
105
101
|
type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,
|
|
@@ -127,6 +123,9 @@ function registerBuilderComponent(payload, transferables) {
|
|
|
127
123
|
function unregisterBuilderComponent(payload) {
|
|
128
124
|
return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload };
|
|
129
125
|
}
|
|
126
|
+
function hasTransferables(action) {
|
|
127
|
+
return "transferables" in action && Array.isArray(action.transferables);
|
|
128
|
+
}
|
|
130
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
131
130
|
0 && (module.exports = {
|
|
132
131
|
BuilderActionTypes,
|
|
@@ -135,6 +134,7 @@ function unregisterBuilderComponent(payload) {
|
|
|
135
134
|
elementFromPointChange,
|
|
136
135
|
handlePointerMove,
|
|
137
136
|
handleWheel,
|
|
137
|
+
hasTransferables,
|
|
138
138
|
makeswiftConnectionCheck,
|
|
139
139
|
messageBuilderPropController,
|
|
140
140
|
mountComponent,
|
|
@@ -142,9 +142,8 @@ function unregisterBuilderComponent(payload) {
|
|
|
142
142
|
registerBuilderComponent,
|
|
143
143
|
registerBuilderDocument,
|
|
144
144
|
registerBuilderDocumentsEffect,
|
|
145
|
-
setIsInBuilder,
|
|
146
145
|
unmountComponent,
|
|
147
146
|
unregisterBuilderComponent,
|
|
148
147
|
unregisterBuilderDocument
|
|
149
148
|
});
|
|
150
|
-
//# sourceMappingURL=
|
|
149
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +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 BoxModel } from '../modules/box-models'\nimport { type ComponentMeta } from '../modules/components-meta'\n\nimport { type Size } from '../react-builder-preview'\nimport { type DocumentPayload, type SharedAction, SharedActionTypes } from '../shared-api'\n\nexport const BuilderActionTypes = {\n ...SharedActionTypes,\n\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\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 ChangeElementBoxModelsAction = {\n type: typeof BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\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: Size }\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 | ChangeElementBoxModelsAction\n | MountComponentAction\n | UnmountComponentAction\n | ChangeDocumentElementSizeAction\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 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 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: Size): ChangeDocumentElementSizeAction {\n return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,wBAA2E;AAEpE,MAAM,qBAAqB;AAAA,EAChC,GAAG;AAAA,EAEH,4BAA4B;AAAA,EAE5B,2BAA2B;AAAA,EAE3B,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EAEnB,8BAA8B;AAAA,EAC9B,iCAAiC;AAAA,EAEjC,cAAc;AAAA,EACd,qBAAqB;AAAA,EAErB,2BAA2B;AAAA,EAE3B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,4BAA4B;AAAA,EAC5B,8BAA8B;AAAA,EAE9B,sBAAsB;AACxB;AAiGO,SAAS,yBACd,SACgC;AAChC,SAAO,EAAE,MAAM,mBAAmB,4BAA4B,QAAQ;AACxE;AAEO,SAAS,uBACd,yBAC8B;AAC9B,SAAO;AAAA,IACL,MAAM,m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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,62 @@
|
|
|
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 message_channel_exports = {};
|
|
20
|
+
__export(message_channel_exports, {
|
|
21
|
+
MessageChannel: () => MessageChannel
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(message_channel_exports);
|
|
24
|
+
class MessageChannel {
|
|
25
|
+
appOrigin;
|
|
26
|
+
channel = null;
|
|
27
|
+
bufferedMessages = [];
|
|
28
|
+
constructor({ appOrigin }) {
|
|
29
|
+
this.appOrigin = appOrigin;
|
|
30
|
+
}
|
|
31
|
+
postMessage(message, transferables) {
|
|
32
|
+
if (this.channel) {
|
|
33
|
+
this.channel.postMessage(message, transferables ?? []);
|
|
34
|
+
} else {
|
|
35
|
+
this.bufferedMessages.push([message, transferables]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
setup(onMessage) {
|
|
39
|
+
const channel = new window.MessageChannel();
|
|
40
|
+
channel.port1.onmessage = onMessage;
|
|
41
|
+
window.parent.postMessage(channel.port2, this.appOrigin, [channel.port2]);
|
|
42
|
+
this.channel = channel.port1;
|
|
43
|
+
}
|
|
44
|
+
dispatchBuffered() {
|
|
45
|
+
console.assert(this.channel != null, "channel is not setup");
|
|
46
|
+
this.bufferedMessages.forEach(([message, transferables]) => {
|
|
47
|
+
this.channel?.postMessage(message, transferables ?? []);
|
|
48
|
+
});
|
|
49
|
+
this.bufferedMessages = [];
|
|
50
|
+
}
|
|
51
|
+
teardown() {
|
|
52
|
+
if (this.channel) {
|
|
53
|
+
this.channel.onmessage = null;
|
|
54
|
+
this.channel.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
MessageChannel
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=message-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/message-channel.ts"],"sourcesContent":["export 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: (event: MessageEvent) => void) {\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\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 public teardown() {\n if (this.channel) {\n this.channel.onmessage = null\n this.channel.close()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe;AAAA,EACT;AAAA,EACT,UAA8B;AAAA,EAC9B,mBAA6C,CAAC;AAAA,EAEtD,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,YAAY;AAAA,EACnB;AAAA,EAEO,YAAY,SAAc,eAAgC;AAC/D,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,YAAY,SAAS,iBAAiB,CAAC,CAAC;AAAA,IACvD,OAAO;AACL,WAAK,iBAAiB,KAAK,CAAC,SAAS,aAAa,CAAC;AAAA,IACrD;AAAA,EACF;AAAA,EAEO,MAAM,WAA0C;AACrD,UAAM,UAAU,IAAI,OAAO,eAAe;AAC1C,YAAQ,MAAM,YAAY;AAI1B,WAAO,OAAO,YAAY,QAAQ,OAAO,KAAK,WAAW,CAAC,QAAQ,KAAK,CAAC;AAExE,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA,EAEO,mBAAmB;AACxB,YAAQ,OAAO,KAAK,WAAW,MAAM,sBAAsB;AAE3D,SAAK,iBAAiB,QAAQ,CAAC,CAAC,SAAS,aAAa,MAAM;AAC1D,WAAK,SAAS,YAAY,SAAS,iBAAiB,CAAC,CAAC;AAAA,IACxD,CAAC;AAED,SAAK,mBAAmB,CAAC;AAAA,EAC3B;AAAA,EAEO,WAAW;AAChB,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,YAAY;AACzB,WAAK,QAAQ,MAAM;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 proxy_exports = {};
|
|
20
|
+
__export(proxy_exports, {
|
|
21
|
+
BuilderAPIProxy: () => BuilderAPIProxy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(proxy_exports);
|
|
24
|
+
var import_host_api = require("../host-api");
|
|
25
|
+
var import_actions = require("./actions");
|
|
26
|
+
var import_message_channel = require("./message-channel");
|
|
27
|
+
class BuilderAPIProxy {
|
|
28
|
+
messageChannel;
|
|
29
|
+
constructor({ appOrigin }) {
|
|
30
|
+
this.messageChannel = new import_message_channel.MessageChannel({ appOrigin });
|
|
31
|
+
}
|
|
32
|
+
// low-level, action-based API
|
|
33
|
+
setup({ onHostAction }) {
|
|
34
|
+
this.messageChannel.setup((event) => {
|
|
35
|
+
const action = event.data;
|
|
36
|
+
if (!(0, import_host_api.isHostAction)(action)) {
|
|
37
|
+
console.warn("Unexpected host action", action);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
onHostAction(action);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
execute(action) {
|
|
44
|
+
if ((0, import_actions.hasTransferables)(action)) {
|
|
45
|
+
const { transferables, ...forwardedAction } = action;
|
|
46
|
+
this.messageChannel.postMessage(forwardedAction, transferables);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.messageChannel.postMessage(action);
|
|
50
|
+
}
|
|
51
|
+
dispatchBuffered() {
|
|
52
|
+
this.messageChannel.dispatchBuffered();
|
|
53
|
+
}
|
|
54
|
+
teardown() {
|
|
55
|
+
this.messageChannel.teardown();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
BuilderAPIProxy
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +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 }): void {\n this.messageChannel.setup((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 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 teardown(): void {\n this.messageChannel.teardown()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8C;AAE9C,qBAAqD;AACrD,6BAA+B;AAExB,MAAM,gBAAgB;AAAA,EACnB;AAAA,EAER,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,iBAAiB,IAAI,sCAAe,EAAE,UAAU,CAAC;AAAA,EACxD;AAAA;AAAA,EAIA,MAAM,EAAE,aAAa,GAAyD;AAC5E,SAAK,eAAe,MAAM,CAAC,UAAwB;AACjD,YAAM,SAAS,MAAM;AAErB,UAAI,KAAC,8BAAa,MAAM,GAAG;AACzB,gBAAQ,KAAK,0BAA0B,MAAM;AAC7C;AAAA,MACF;AAEA,mBAAa,MAAM;AAAA,IACrB,CAAC;AAAA,EACH;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;AAAA,EAEA,WAAiB;AACf,SAAK,eAAe,SAAS;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -26,24 +26,27 @@ __export(host_api_exports, {
|
|
|
26
26
|
cleanUp: () => cleanUp,
|
|
27
27
|
evictApiResource: () => evictApiResource,
|
|
28
28
|
init: () => init,
|
|
29
|
+
isHostAction: () => isHostAction,
|
|
29
30
|
messageHostPropController: () => messageHostPropController,
|
|
30
31
|
scrollDocumentElement: () => scrollDocumentElement,
|
|
31
32
|
setBuilderEditMode: () => setBuilderEditMode,
|
|
32
|
-
|
|
33
|
+
setLocalizedResourceId: () => setLocalizedResourceId
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(host_api_exports);
|
|
36
|
+
var import_toolkit = require("@reduxjs/toolkit");
|
|
37
|
+
var import_shared_api = require("./shared-api");
|
|
35
38
|
const HostActionTypes = {
|
|
39
|
+
...import_shared_api.SharedActionTypes,
|
|
36
40
|
INIT: "INIT",
|
|
37
41
|
CLEAN_UP: "CLEAN_UP",
|
|
38
42
|
CHANGE_DOCUMENT: "CHANGE_DOCUMENT",
|
|
39
43
|
CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP: "CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP",
|
|
40
44
|
SCROLL_DOCUMENT_ELEMENT: "SCROLL_DOCUMENT_ELEMENT",
|
|
41
|
-
REGISTER_PROP_CONTROLLERS: "REGISTER_PROP_CONTROLLERS",
|
|
42
|
-
UNREGISTER_PROP_CONTROLLERS: "UNREGISTER_PROP_CONTROLLERS",
|
|
43
45
|
MESSAGE_HOST_PROP_CONTROLLER: "MESSAGE_HOST_PROP_CONTROLLER",
|
|
44
46
|
CHANGE_API_RESOURCE: "CHANGE_API_RESOURCE",
|
|
45
47
|
EVICT_API_RESOURCE: "EVICT_API_RESOURCE",
|
|
46
48
|
SET_BUILDER_EDIT_MODE: "SET_BUILDER_EDIT_MODE",
|
|
49
|
+
SET_LOCALIZED_RESOURCE_ID: "SET_LOCALIZED_RESOURCE_ID",
|
|
47
50
|
BUILDER_POINTER_MOVE: "BUILDER_POINTER_MOVE"
|
|
48
51
|
};
|
|
49
52
|
function init() {
|
|
@@ -61,9 +64,6 @@ function changeDocumentElementScrollTop(scrollTop) {
|
|
|
61
64
|
function scrollDocumentElement(scrollTopDelta) {
|
|
62
65
|
return { type: HostActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } };
|
|
63
66
|
}
|
|
64
|
-
function unregisterPropControllers(documentKey, elementKey) {
|
|
65
|
-
return { type: HostActionTypes.UNREGISTER_PROP_CONTROLLERS, payload: { documentKey, elementKey } };
|
|
66
|
-
}
|
|
67
67
|
function messageHostPropController(documentKey, elementKey, propName, message) {
|
|
68
68
|
return {
|
|
69
69
|
type: HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER,
|
|
@@ -82,9 +82,22 @@ function setBuilderEditMode(editMode) {
|
|
|
82
82
|
payload: { editMode }
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
function setLocalizedResourceId({
|
|
86
|
+
resourceId,
|
|
87
|
+
localizedResourceId,
|
|
88
|
+
locale
|
|
89
|
+
}) {
|
|
90
|
+
return {
|
|
91
|
+
type: HostActionTypes.SET_LOCALIZED_RESOURCE_ID,
|
|
92
|
+
payload: { resourceId, localizedResourceId, locale }
|
|
93
|
+
};
|
|
94
|
+
}
|
|
85
95
|
function builderPointerMove(pointer) {
|
|
86
96
|
return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } };
|
|
87
97
|
}
|
|
98
|
+
function isHostAction(action) {
|
|
99
|
+
return (0, import_toolkit.isAction)(action) && Object.hasOwn(HostActionTypes, action.type);
|
|
100
|
+
}
|
|
88
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
102
|
0 && (module.exports = {
|
|
90
103
|
HostActionTypes,
|
|
@@ -95,9 +108,10 @@ function builderPointerMove(pointer) {
|
|
|
95
108
|
cleanUp,
|
|
96
109
|
evictApiResource,
|
|
97
110
|
init,
|
|
111
|
+
isHostAction,
|
|
98
112
|
messageHostPropController,
|
|
99
113
|
scrollDocumentElement,
|
|
100
114
|
setBuilderEditMode,
|
|
101
|
-
|
|
115
|
+
setLocalizedResourceId
|
|
102
116
|
});
|
|
103
117
|
//# sourceMappingURL=host-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/host-api.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/state/host-api.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\nimport { type Operation } from 'ot-json0'\n\nimport { type PropControllerMessage } from '../prop-controllers/instances'\nimport { type APIResource, APIResourceLocale } from '../api/types'\n\nimport { BuilderEditMode } from './modules/builder-edit-mode'\nimport { type Point } from './modules/pointer'\n\nimport { type SharedAction, SharedActionTypes } from './shared-api'\n\nexport const HostActionTypes = {\n ...SharedActionTypes,\n\n INIT: 'INIT',\n CLEAN_UP: 'CLEAN_UP',\n\n CHANGE_DOCUMENT: 'CHANGE_DOCUMENT',\n\n CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP: 'CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP',\n SCROLL_DOCUMENT_ELEMENT: 'SCROLL_DOCUMENT_ELEMENT',\n\n MESSAGE_HOST_PROP_CONTROLLER: 'MESSAGE_HOST_PROP_CONTROLLER',\n\n CHANGE_API_RESOURCE: 'CHANGE_API_RESOURCE',\n EVICT_API_RESOURCE: 'EVICT_API_RESOURCE',\n\n SET_BUILDER_EDIT_MODE: 'SET_BUILDER_EDIT_MODE',\n SET_LOCALIZED_RESOURCE_ID: 'SET_LOCALIZED_RESOURCE_ID',\n\n BUILDER_POINTER_MOVE: 'BUILDER_POINTER_MOVE',\n} as const\n\ntype InitAction = { type: typeof HostActionTypes.INIT }\n\ntype CleanUpAction = { type: typeof HostActionTypes.CLEAN_UP }\n\ntype ChangeDocumentAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT\n payload: { documentKey: string; operation: Operation }\n}\n\ntype ChangeDocumentElementScrollTopAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP\n payload: { scrollTop: number }\n}\n\ntype ScrollDocumentElementAction = {\n type: typeof HostActionTypes.SCROLL_DOCUMENT_ELEMENT\n payload: { scrollTopDelta: number }\n}\n\ntype MessageHostPropControllerAction<T = PropControllerMessage> = {\n type: typeof HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype ChangeAPIResourceAction = {\n type: typeof HostActionTypes.CHANGE_API_RESOURCE\n payload: { resource: APIResource; locale?: string | null }\n}\n\ntype EvictAPIResourceAction = {\n type: typeof HostActionTypes.EVICT_API_RESOURCE\n payload: { id: string; locale?: string | null }\n}\n\ntype SetBuilderEditModeAction = {\n type: typeof HostActionTypes.SET_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype SetLocalizedResourceIdAction = {\n type: typeof HostActionTypes.SET_LOCALIZED_RESOURCE_ID\n // TODO: make `locale` required once we've upgraded the builder to always provide it\n payload: { locale?: string; resourceId: string; localizedResourceId: string | null }\n}\n\ntype BuilderPointerMoveAction = {\n type: typeof HostActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\nexport type HostAction =\n | SharedAction\n | InitAction\n | CleanUpAction\n | ChangeDocumentAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | MessageHostPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetBuilderEditModeAction\n | SetLocalizedResourceIdAction\n | BuilderPointerMoveAction\n\nexport function init(): InitAction {\n return { type: HostActionTypes.INIT }\n}\n\nexport function cleanUp(): CleanUpAction {\n return { type: HostActionTypes.CLEAN_UP }\n}\n\nexport function changeDocument(documentKey: string, operation: Operation): ChangeDocumentAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } }\n}\n\nexport function changeDocumentElementScrollTop(\n scrollTop: number,\n): ChangeDocumentElementScrollTopAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } }\n}\n\nexport function scrollDocumentElement(scrollTopDelta: number): ScrollDocumentElementAction {\n return { type: HostActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } }\n}\n\nexport function messageHostPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageHostPropControllerAction<T> {\n return {\n type: HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function changeApiResource<R extends APIResource>(\n resource: R,\n locale?: APIResourceLocale<R>,\n): ChangeAPIResourceAction {\n return { type: HostActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } }\n}\n\nexport function evictApiResource(id: string, locale?: string | null): EvictAPIResourceAction {\n return { type: HostActionTypes.EVICT_API_RESOURCE, payload: { id, locale } }\n}\n\nexport function setBuilderEditMode(editMode: BuilderEditMode): SetBuilderEditModeAction {\n return {\n type: HostActionTypes.SET_BUILDER_EDIT_MODE,\n payload: { editMode },\n }\n}\n\nexport function setLocalizedResourceId({\n resourceId,\n localizedResourceId,\n locale,\n}: {\n resourceId: string\n localizedResourceId: string | null\n locale?: string\n}): SetLocalizedResourceIdAction {\n return {\n type: HostActionTypes.SET_LOCALIZED_RESOURCE_ID,\n payload: { resourceId, localizedResourceId, locale },\n }\n}\n\nexport function builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n\nexport function isHostAction(action: unknown): action is HostAction {\n return isAction(action) && Object.hasOwn(HostActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAUzB,wBAAqD;AAE9C,MAAM,kBAAkB;AAAA,EAC7B,GAAG;AAAA,EAEH,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,iBAAiB;AAAA,EAEjB,oCAAoC;AAAA,EACpC,yBAAyB;AAAA,EAEzB,8BAA8B;AAAA,EAE9B,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EAEpB,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAE3B,sBAAsB;AACxB;AAkE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O,OAAO,iBAAiB,OAAO,IAAI;AACvE;","names":[]}
|
|
@@ -39,7 +39,7 @@ var APIResources = __toESM(require("./modules/api-resources"));
|
|
|
39
39
|
var LocalizedResourcesMap = __toESM(require("./modules/localized-resources-map"));
|
|
40
40
|
var import_actions = require("./actions");
|
|
41
41
|
var import_internal = require("./actions/internal");
|
|
42
|
-
var
|
|
42
|
+
var import_host_api = require("./host-api");
|
|
43
43
|
var import_toolkit2 = require("./toolkit");
|
|
44
44
|
var import_api = require("../api");
|
|
45
45
|
const reducer = (0, import_toolkit.combineReducers)({
|
|
@@ -126,7 +126,7 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
126
126
|
`/api/makeswift/localized-global-elements/${resourceId}/${locale}`
|
|
127
127
|
);
|
|
128
128
|
dispatch(
|
|
129
|
-
(0,
|
|
129
|
+
(0, import_host_api.setLocalizedResourceId)({
|
|
130
130
|
locale,
|
|
131
131
|
resourceId,
|
|
132
132
|
localizedResourceId: resource?.id ?? null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal'\nimport { setLocalizedResourceId } from './shared-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchJson = async <T>(url: string): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchJson<Swatch>(`/api/makeswift/swatches/${resourceId}`)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(`/api/makeswift/typographies/${resourceId}`)\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(`/api/makeswift/global-elements/${resourceId}`)\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchJson<PagePathnameSlice>(url.pathname + url.search)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(\n defaultLocale: string | undefined,\n): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: { ...action.payload, locale: locale ?? defaultLocale },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n defaultLocale,\n serializedState,\n}: {\n defaultLocale: string | undefined\n serializedState?: SerializedState\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAEP,mBAA8B;AAC9B,4BAAuC;AACvC,qBAAyC;AACzC,sBAAqC;AACrC,wBAAuC;AACvC,IAAAA,kBAAoE;AAEpE,iBAWO;AAEP,MAAM,cAAU,gCAAgB;AAAA,EAC9B,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAWD,SAAS,uBACP,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,mBAAW,MAAM,UAAiB,yBAAyB,UAAU,EAAE;AACvE;AAAA,MAEF;AACE,mBAAW;AAAA,IACf;AAEA,iBAAS,sCAAqB,cAAc,YAAY,UAAU,MAAM,CAAC;AAEzE,WAAO;AAAA,EACT;AACF;AAIA,SAAS,wBACP,eACuC;AACvC,aAAO,kCAAiB,MAAM,UAAQ;AACpC,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS,EAAE,GAAG,OAAO,SAAS,QAAQ,UAAU,cAAc;AAAA,UAChE,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AACF,GAGG;AACD,aAAO,eAAAC,gBAAoB;AAAA,IACzB;AAAA,IACA,gBAAgB;AAAA,MACd,cAAc,aAAa,gBAAgB,iBAAiB,YAAY;AAAA,MACxE,uBAAuB,sBAAsB;AAAA,QAC3C,iBAAiB;AAAA,MACnB;AAAA,IACF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO,wBAAwB,aAAa,CAAC;AAAA,IAEvF,cAAU,gCAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,2BAAY;AAAA,QACZ,2BAAY;AAAA,QACZ,2BAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","configureReduxStore"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal'\nimport { setLocalizedResourceId } from './host-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchJson = async <T>(url: string): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchJson<Swatch>(`/api/makeswift/swatches/${resourceId}`)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(`/api/makeswift/typographies/${resourceId}`)\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(`/api/makeswift/global-elements/${resourceId}`)\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchJson<PagePathnameSlice>(url.pathname + url.search)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(\n defaultLocale: string | undefined,\n): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: { ...action.payload, locale: locale ?? defaultLocale },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n defaultLocale,\n serializedState,\n}: {\n defaultLocale: string | undefined\n serializedState?: SerializedState\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAEP,mBAA8B;AAC9B,4BAAuC;AACvC,qBAAyC;AACzC,sBAAqC;AACrC,sBAAuC;AACvC,IAAAA,kBAAoE;AAEpE,iBAWO;AAEP,MAAM,cAAU,gCAAgB;AAAA,EAC9B,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAWD,SAAS,uBACP,OACA,QACA,YAC2B;AAC3B,SAAO,sBAAsB;AAAA,IAC3B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,OACA,cACA,YACA,QACS;AACT,UAAQ,cAAc;AAAA,IACpB,KAAK,2BAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aACE,eAAe,QACf,aAAa,kBAAkB,MAAM,cAAc,cAAc,aAAa,MAAM;AAAA,IAGxF;AACE,aAAO,aAAa,kBAAkB,MAAM,cAAc,cAAc,YAAY,MAAM;AAAA,EAC9F;AACF;AAEO,SAAS,eACd,OACA,cACA,YACA,QACgD;AAChD,UAAQ,cAAc;AAAA,IACpB,KAAK,2BAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aAAO,eAAe,OAClB,aAAa,eAAe,MAA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