@makeswift/runtime 0.26.0 → 0.26.1-canary.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.
Files changed (126) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/builder/index.js +22 -18
  3. package/dist/cjs/builder/index.js.map +1 -1
  4. package/dist/cjs/builder/serialization/control-serialization.js +7 -3
  5. package/dist/cjs/builder/serialization/control-serialization.js.map +1 -1
  6. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +0 -21
  7. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  8. package/dist/cjs/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js +72 -0
  9. package/dist/cjs/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +1 -0
  10. package/dist/cjs/controls/visitors/message-port-serializer/function-serialization.js +79 -0
  11. package/dist/cjs/controls/visitors/message-port-serializer/function-serialization.js.map +1 -0
  12. package/dist/cjs/controls/visitors/message-port-serializer/index.js +36 -0
  13. package/dist/cjs/controls/visitors/message-port-serializer/index.js.map +1 -0
  14. package/dist/cjs/next/hooks/use-router-locale-sync.js +2 -2
  15. package/dist/cjs/next/hooks/use-router-locale-sync.js.map +1 -1
  16. package/dist/cjs/runtimes/react/components/ElementRegistration.js +4 -3
  17. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  18. package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js +5 -10
  19. package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
  20. package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
  21. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  22. package/dist/cjs/runtimes/react/hooks/use-register-document.js +5 -4
  23. package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
  24. package/dist/cjs/runtimes/react/react-runtime-core.js +4 -3
  25. package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
  26. package/dist/cjs/state/actions/index.js +42 -0
  27. package/dist/cjs/state/actions/index.js.map +1 -0
  28. package/dist/cjs/state/actions/internal.js +174 -0
  29. package/dist/cjs/state/actions/internal.js.map +1 -0
  30. package/dist/cjs/state/builder-api.js +150 -0
  31. package/dist/cjs/state/builder-api.js.map +1 -0
  32. package/dist/cjs/state/host-api.js +103 -0
  33. package/dist/cjs/state/host-api.js.map +1 -0
  34. package/dist/cjs/state/makeswift-api-client.js +4 -2
  35. package/dist/cjs/state/makeswift-api-client.js.map +1 -1
  36. package/dist/cjs/state/react-builder-preview.js +21 -18
  37. package/dist/cjs/state/react-builder-preview.js.map +1 -1
  38. package/dist/cjs/state/react-page.js +5 -4
  39. package/dist/cjs/state/react-page.js.map +1 -1
  40. package/dist/cjs/state/shared-api.js +117 -0
  41. package/dist/cjs/state/shared-api.js.map +1 -0
  42. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  43. package/dist/esm/builder/index.js +13 -9
  44. package/dist/esm/builder/index.js.map +1 -1
  45. package/dist/esm/builder/serialization/control-serialization.js +10 -3
  46. package/dist/esm/builder/serialization/control-serialization.js.map +1 -1
  47. package/dist/esm/controls/rich-text-v2/rich-text-v2.js +0 -22
  48. package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  49. package/dist/esm/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js +53 -0
  50. package/dist/esm/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +1 -0
  51. package/dist/esm/controls/visitors/message-port-serializer/function-serialization.js +52 -0
  52. package/dist/esm/controls/visitors/message-port-serializer/function-serialization.js.map +1 -0
  53. package/dist/esm/controls/visitors/message-port-serializer/index.js +13 -0
  54. package/dist/esm/controls/visitors/message-port-serializer/index.js.map +1 -0
  55. package/dist/esm/next/hooks/use-router-locale-sync.js +1 -1
  56. package/dist/esm/next/hooks/use-router-locale-sync.js.map +1 -1
  57. package/dist/esm/runtimes/react/components/ElementRegistration.js +2 -1
  58. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  59. package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js +5 -10
  60. package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -1
  61. package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
  62. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  63. package/dist/esm/runtimes/react/hooks/use-register-document.js +2 -5
  64. package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
  65. package/dist/esm/runtimes/react/react-runtime-core.js +2 -1
  66. package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
  67. package/dist/esm/state/actions/index.js +17 -0
  68. package/dist/esm/state/actions/index.js.map +1 -0
  69. package/dist/esm/state/actions/internal.js +135 -0
  70. package/dist/esm/state/actions/internal.js.map +1 -0
  71. package/dist/esm/state/builder-api.js +110 -0
  72. package/dist/esm/state/builder-api.js.map +1 -0
  73. package/dist/esm/state/host-api.js +68 -0
  74. package/dist/esm/state/host-api.js.map +1 -0
  75. package/dist/esm/state/makeswift-api-client.js +3 -1
  76. package/dist/esm/state/makeswift-api-client.js.map +1 -1
  77. package/dist/esm/state/react-builder-preview.js +10 -8
  78. package/dist/esm/state/react-builder-preview.js.map +1 -1
  79. package/dist/esm/state/react-page.js +3 -7
  80. package/dist/esm/state/react-page.js.map +1 -1
  81. package/dist/esm/state/shared-api.js +83 -0
  82. package/dist/esm/state/shared-api.js.map +1 -0
  83. package/dist/types/builder/index.d.ts +3 -2
  84. package/dist/types/builder/index.d.ts.map +1 -1
  85. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
  86. package/dist/types/client/index.d.ts +16 -16
  87. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +1 -2
  88. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  89. package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts +9 -0
  90. package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts.map +1 -0
  91. package/dist/types/controls/visitors/message-port-serializer/function-serialization.d.ts +16 -0
  92. package/dist/types/controls/visitors/message-port-serializer/function-serialization.d.ts.map +1 -0
  93. package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts +2 -0
  94. package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts.map +1 -0
  95. package/dist/types/controls/visitors/message-port-serializer/index.d.ts +3 -0
  96. package/dist/types/controls/visitors/message-port-serializer/index.d.ts.map +1 -0
  97. package/dist/types/locale.d.ts +1 -1
  98. package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
  99. package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts.map +1 -1
  100. package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
  101. package/dist/types/runtimes/react/hooks/use-store.d.ts +1 -1
  102. package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
  103. package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
  104. package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
  105. package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
  106. package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
  107. package/dist/types/state/actions/index.d.ts +58 -0
  108. package/dist/types/state/actions/index.d.ts.map +1 -0
  109. package/dist/types/state/actions/internal.d.ts +154 -0
  110. package/dist/types/state/actions/internal.d.ts.map +1 -0
  111. package/dist/types/state/builder-api.d.ts +163 -0
  112. package/dist/types/state/builder-api.d.ts.map +1 -0
  113. package/dist/types/state/host-api.d.ts +109 -0
  114. package/dist/types/state/host-api.d.ts.map +1 -0
  115. package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
  116. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  117. package/dist/types/state/react-page.d.ts.map +1 -1
  118. package/dist/types/state/shared-api.d.ts +104 -0
  119. package/dist/types/state/shared-api.d.ts.map +1 -0
  120. package/package.json +3 -3
  121. package/dist/cjs/state/actions.js +0 -423
  122. package/dist/cjs/state/actions.js.map +0 -1
  123. package/dist/esm/state/actions.js +0 -349
  124. package/dist/esm/state/actions.js.map +0 -1
  125. package/dist/types/state/actions.d.ts +0 -461
  126. package/dist/types/state/actions.d.ts.map +0 -1
@@ -1,4 +1,5 @@
1
- import { registerComponentEffect, registerReactComponentEffect } from "../../state/actions";
1
+ import { registerComponentEffect } from "../../state/shared-api";
2
+ import { registerReactComponentEffect } from "../../state/actions/internal";
2
3
  import { ComponentIcon } from "../../state/modules/components-meta";
3
4
  import { RuntimeCore } from "./runtime-core";
4
5
  function validateComponentType(type, component) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/react-runtime-core.ts"],"sourcesContent":["import { ControlDefinition as UnifiedControlDefinition } from '@makeswift/controls'\n\nimport { type LegacyDescriptor, type DescriptorValueType } from '../../prop-controllers/descriptors'\n\nimport { registerComponentEffect, registerReactComponentEffect } from '../../state/actions'\nimport { BreakpointsInput } from '../../state/modules/breakpoints'\nimport { ComponentIcon } from '../../state/modules/components-meta'\nimport type { ComponentType } from '../../state/react-page'\n\nimport { RuntimeCore } from './runtime-core'\n\nfunction validateComponentType(type: string, component?: ComponentType): void {\n const componentName = component?.name ?? 'Component'\n if (typeof type !== 'string' || type === '') {\n throw new Error(\n `${componentName}: A non-empty string \\`type\\` is required for component registration, got ${type}`,\n )\n }\n}\n\nexport class ReactRuntimeCore extends RuntimeCore {\n registerComponent<\n ControlDef extends UnifiedControlDefinition,\n P extends Record<string, LegacyDescriptor | ControlDef>,\n C extends ComponentType<{ [K in keyof P]: DescriptorValueType<P[K]> }>,\n >(\n component: C,\n {\n type,\n label,\n icon = ComponentIcon.Cube,\n hidden = false,\n description,\n builtinSuspense,\n props,\n }: {\n type: string\n label: string\n icon?: ComponentIcon\n hidden?: boolean\n description?: string\n builtinSuspense?: boolean\n props?: P\n },\n ): () => void {\n validateComponentType(type, component as unknown as ComponentType)\n\n const unregisterComponent = this.store.dispatch(\n registerComponentEffect(\n type,\n { label, icon, hidden, description, builtinSuspense },\n props ?? {},\n ),\n )\n\n const unregisterReactComponent = this.store.dispatch(\n registerReactComponentEffect(type, component as unknown as ComponentType),\n )\n\n return () => {\n unregisterComponent()\n unregisterReactComponent()\n }\n }\n\n constructor({ breakpoints }: { breakpoints?: BreakpointsInput } = {}) {\n super({ breakpoints })\n }\n}\n"],"mappings":"AAIA,SAAS,yBAAyB,oCAAoC;AAEtE,SAAS,qBAAqB;AAG9B,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB,MAAc,WAAiC;AAC5E,QAAM,gBAAgB,WAAW,QAAQ;AACzC,MAAI,OAAO,SAAS,YAAY,SAAS,IAAI;AAC3C,UAAM,IAAI;AAAA,MACR,GAAG,aAAa,6EAA6E,IAAI;AAAA,IACnG;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,YAAY;AAAA,EAChD,kBAKE,WACA;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO,cAAc;AAAA,IACrB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EACF,GASY;AACZ,0BAAsB,MAAM,SAAqC;AAEjE,UAAM,sBAAsB,KAAK,MAAM;AAAA,MACrC;AAAA,QACE;AAAA,QACA,EAAE,OAAO,MAAM,QAAQ,aAAa,gBAAgB;AAAA,QACpD,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAEA,UAAM,2BAA2B,KAAK,MAAM;AAAA,MAC1C,6BAA6B,MAAM,SAAqC;AAAA,IAC1E;AAEA,WAAO,MAAM;AACX,0BAAoB;AACpB,+BAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,YAAY,EAAE,YAAY,IAAwC,CAAC,GAAG;AACpE,UAAM,EAAE,YAAY,CAAC;AAAA,EACvB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/react/react-runtime-core.ts"],"sourcesContent":["import { ControlDefinition as UnifiedControlDefinition } from '@makeswift/controls'\n\nimport { type LegacyDescriptor, type DescriptorValueType } from '../../prop-controllers/descriptors'\n\nimport { registerComponentEffect } from '../../state/shared-api'\nimport { registerReactComponentEffect } from '../../state/actions/internal'\n\nimport { BreakpointsInput } from '../../state/modules/breakpoints'\nimport { ComponentIcon } from '../../state/modules/components-meta'\nimport type { ComponentType } from '../../state/react-page'\n\nimport { RuntimeCore } from './runtime-core'\n\nfunction validateComponentType(type: string, component?: ComponentType): void {\n const componentName = component?.name ?? 'Component'\n if (typeof type !== 'string' || type === '') {\n throw new Error(\n `${componentName}: A non-empty string \\`type\\` is required for component registration, got ${type}`,\n )\n }\n}\n\nexport class ReactRuntimeCore extends RuntimeCore {\n registerComponent<\n ControlDef extends UnifiedControlDefinition,\n P extends Record<string, LegacyDescriptor | ControlDef>,\n C extends ComponentType<{ [K in keyof P]: DescriptorValueType<P[K]> }>,\n >(\n component: C,\n {\n type,\n label,\n icon = ComponentIcon.Cube,\n hidden = false,\n description,\n builtinSuspense,\n props,\n }: {\n type: string\n label: string\n icon?: ComponentIcon\n hidden?: boolean\n description?: string\n builtinSuspense?: boolean\n props?: P\n },\n ): () => void {\n validateComponentType(type, component as unknown as ComponentType)\n\n const unregisterComponent = this.store.dispatch(\n registerComponentEffect(\n type,\n { label, icon, hidden, description, builtinSuspense },\n props ?? {},\n ),\n )\n\n const unregisterReactComponent = this.store.dispatch(\n registerReactComponentEffect(type, component as unknown as ComponentType),\n )\n\n return () => {\n unregisterComponent()\n unregisterReactComponent()\n }\n }\n\n constructor({ breakpoints }: { breakpoints?: BreakpointsInput } = {}) {\n super({ breakpoints })\n }\n}\n"],"mappings":"AAIA,SAAS,+BAA+B;AACxC,SAAS,oCAAoC;AAG7C,SAAS,qBAAqB;AAG9B,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB,MAAc,WAAiC;AAC5E,QAAM,gBAAgB,WAAW,QAAQ;AACzC,MAAI,OAAO,SAAS,YAAY,SAAS,IAAI;AAC3C,UAAM,IAAI;AAAA,MACR,GAAG,aAAa,6EAA6E,IAAI;AAAA,IACnG;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,YAAY;AAAA,EAChD,kBAKE,WACA;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO,cAAc;AAAA,IACrB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EACF,GASY;AACZ,0BAAsB,MAAM,SAAqC;AAEjE,UAAM,sBAAsB,KAAK,MAAM;AAAA,MACrC;AAAA,QACE;AAAA,QACA,EAAE,OAAO,MAAM,QAAQ,aAAa,gBAAgB;AAAA,QACpD,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAEA,UAAM,2BAA2B,KAAK,MAAM;AAAA,MAC1C,6BAA6B,MAAM,SAAqC;AAAA,IAC1E;AAEA,WAAO,MAAM;AACX,0BAAoB;AACpB,+BAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,YAAY,EAAE,YAAY,IAAwC,CAAC,GAAG;AACpE,UAAM,EAAE,YAAY,CAAC;AAAA,EACvB;AACF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import { isAction } from "@reduxjs/toolkit";
2
+ import { BuilderActionTypes } from "../builder-api";
3
+ import { HostActionTypes } from "../host-api";
4
+ import { InternalActionTypes } from "./internal";
5
+ const ActionTypes = {
6
+ ...HostActionTypes,
7
+ ...BuilderActionTypes,
8
+ ...InternalActionTypes
9
+ };
10
+ function isKnownAction(action) {
11
+ return isAction(action) && Object.hasOwn(ActionTypes, action.type);
12
+ }
13
+ export {
14
+ ActionTypes,
15
+ isKnownAction
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/actions/index.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\nimport { type BuilderAction, BuilderActionTypes } from '../builder-api'\nimport { type HostAction, HostActionTypes } from '../host-api'\n\nimport { type InternalAction, InternalActionTypes } from './internal'\n\nexport { type UnknownAction } from '@reduxjs/toolkit'\nexport { type DocumentPayload } from '../shared-api'\n\nexport const ActionTypes = {\n ...HostActionTypes,\n ...BuilderActionTypes,\n ...InternalActionTypes,\n} as const\n\nexport type Action = HostAction | BuilderAction | InternalAction\n\nexport function isKnownAction(action: unknown): action is Action {\n return isAction(action) && Object.hasOwn(ActionTypes, action.type)\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAEzB,SAA6B,0BAA0B;AACvD,SAA0B,uBAAuB;AAEjD,SAA8B,2BAA2B;AAKlD,MAAM,cAAc;AAAA,EACzB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAIO,SAAS,cAAc,QAAmC;AAC/D,SAAO,SAAS,MAAM,KAAK,OAAO,OAAO,aAAa,OAAO,IAAI;AACnE;","names":[]}
@@ -0,0 +1,135 @@
1
+ const InternalActionTypes = {
2
+ API_RESOURCE_FULFILLED: "API_RESOURCE_FULFILLED",
3
+ CREATE_ELEMENT_TREE: "CREATE_ELEMENT_TREE",
4
+ DELETE_ELEMENT_TREE: "DELETE_ELEMENT_TREE",
5
+ CHANGE_ELEMENT_TREE: "CHANGE_ELEMENT_TREE",
6
+ REGISTER_COMPONENT_HANDLE: "REGISTER_COMPONENT_HANDLE",
7
+ UNREGISTER_COMPONENT_HANDLE: "UNREGISTER_COMPONENT_HANDLE",
8
+ REGISTER_MEASURABLE: "REGISTER_MEASURABLE",
9
+ UNREGISTER_MEASURABLE: "UNREGISTER_MEASURABLE",
10
+ REGISTER_PROP_CONTROLLERS: "REGISTER_PROP_CONTROLLERS",
11
+ UNREGISTER_PROP_CONTROLLERS: "UNREGISTER_PROP_CONTROLLERS",
12
+ REGISTER_PROP_CONTROLLERS_HANDLE: "REGISTER_PROP_CONTROLLERS_HANDLE",
13
+ UNREGISTER_PROP_CONTROLLERS_HANDLE: "UNREGISTER_PROP_CONTROLLERS_HANDLE",
14
+ REGISTER_REACT_COMPONENT: "REGISTER_REACT_COMPONENT",
15
+ UNREGISTER_REACT_COMPONENT: "UNREGISTER_REACT_COMPONENT",
16
+ UPDATE_API_CLIENT_CACHE: "UPDATE_API_CLIENT_CACHE"
17
+ };
18
+ function apiResourceFulfilled(resourceType, resourceId, resource, locale) {
19
+ return {
20
+ type: InternalActionTypes.API_RESOURCE_FULFILLED,
21
+ payload: { resourceType, resourceId, resource, locale }
22
+ };
23
+ }
24
+ function createElementTree(payload) {
25
+ return {
26
+ type: InternalActionTypes.CREATE_ELEMENT_TREE,
27
+ payload
28
+ };
29
+ }
30
+ function deleteElementTree(payload) {
31
+ return { type: InternalActionTypes.DELETE_ELEMENT_TREE, payload };
32
+ }
33
+ function changeElementTree(payload) {
34
+ return {
35
+ type: InternalActionTypes.CHANGE_ELEMENT_TREE,
36
+ payload
37
+ };
38
+ }
39
+ function registerComponentHandle(documentKey, elementKey, componentHandle) {
40
+ return {
41
+ type: InternalActionTypes.REGISTER_COMPONENT_HANDLE,
42
+ payload: { documentKey, elementKey, componentHandle }
43
+ };
44
+ }
45
+ function unregisterComponentHandle(documentKey, elementKey) {
46
+ return {
47
+ type: InternalActionTypes.UNREGISTER_COMPONENT_HANDLE,
48
+ payload: { documentKey, elementKey }
49
+ };
50
+ }
51
+ function registerComponentHandleEffect(documentKey, elementKey, componentHandle) {
52
+ return (dispatch) => {
53
+ dispatch(registerComponentHandle(documentKey, elementKey, componentHandle));
54
+ return () => {
55
+ dispatch(unregisterComponentHandle(documentKey, elementKey));
56
+ };
57
+ };
58
+ }
59
+ function registerMeasurable(documentKey, elementKey, measurable) {
60
+ return {
61
+ type: InternalActionTypes.REGISTER_MEASURABLE,
62
+ payload: { documentKey, elementKey, measurable }
63
+ };
64
+ }
65
+ function unregisterMeasurable(documentKey, elementKey) {
66
+ return { type: InternalActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } };
67
+ }
68
+ function registerMeasurableEffect(documentKey, elementKey, measurable) {
69
+ return (dispatch) => {
70
+ dispatch(registerMeasurable(documentKey, elementKey, measurable));
71
+ return () => {
72
+ dispatch(unregisterMeasurable(documentKey, elementKey));
73
+ };
74
+ };
75
+ }
76
+ function registerPropControllersHandle(documentKey, elementKey, handle) {
77
+ return {
78
+ type: InternalActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,
79
+ payload: { documentKey, elementKey, handle }
80
+ };
81
+ }
82
+ function unregisterPropControllersHandle(documentKey, elementKey) {
83
+ return {
84
+ type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,
85
+ payload: { documentKey, elementKey }
86
+ };
87
+ }
88
+ function registerPropControllers(documentKey, elementKey, propControllers) {
89
+ return {
90
+ type: InternalActionTypes.REGISTER_PROP_CONTROLLERS,
91
+ payload: { documentKey, elementKey, propControllers }
92
+ };
93
+ }
94
+ function unregisterPropControllers(documentKey, elementKey) {
95
+ return {
96
+ type: InternalActionTypes.UNREGISTER_PROP_CONTROLLERS,
97
+ payload: { documentKey, elementKey }
98
+ };
99
+ }
100
+ function registerReactComponent(type, component) {
101
+ return { type: InternalActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } };
102
+ }
103
+ function unregisterReactComponent(type) {
104
+ return { type: InternalActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } };
105
+ }
106
+ function registerReactComponentEffect(type, component) {
107
+ return (dispatch) => {
108
+ dispatch(registerReactComponent(type, component));
109
+ return () => {
110
+ dispatch(unregisterReactComponent(type));
111
+ };
112
+ };
113
+ }
114
+ function updateAPIClientCache(payload) {
115
+ return { type: InternalActionTypes.UPDATE_API_CLIENT_CACHE, payload };
116
+ }
117
+ export {
118
+ InternalActionTypes,
119
+ apiResourceFulfilled,
120
+ changeElementTree,
121
+ createElementTree,
122
+ deleteElementTree,
123
+ registerComponentHandle,
124
+ registerComponentHandleEffect,
125
+ registerMeasurable,
126
+ registerMeasurableEffect,
127
+ registerPropControllers,
128
+ registerPropControllersHandle,
129
+ registerReactComponentEffect,
130
+ unregisterMeasurable,
131
+ unregisterPropControllers,
132
+ unregisterPropControllersHandle,
133
+ updateAPIClientCache
134
+ };
135
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +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":"AAiBO,MAAM,sBAAsB;AAAA,EACjC,wBAAwB;AAAA,EAExB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,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,yBAAyB;AAC3B;AAYO,SAAS,qBACd,cACA,YACA,UACA,QAC4B;AAC5B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,cAAc,YAAY,UAAU,OAAO;AAAA,EACxD;AACF;AAiGO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAo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C,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEA,SAAS,uBACP,MACA,WAC8B;AAC9B,SAAO,EAAE,MAAM,oBAAoB,0BAA0B,SAAS,EAAE,MAAM,UAAU,EAAE;AAC5F;AAEA,SAAS,yBAAyB,MAA8C;AAC9E,SAAO,EAAE,MAAM,oBAAoB,4BAA4B,SAAS,EAAE,KAAK,EAAE;AACnF;AAEO,SAAS,6BACd,MACA,WAC2D;AAC3D,SAAO,cAAY;AACjB,aAAS,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":[]}
@@ -0,0 +1,110 @@
1
+ import { SharedActionTypes } from "./shared-api";
2
+ const BuilderActionTypes = {
3
+ ...SharedActionTypes,
4
+ MAKESWIFT_CONNECTION_CHECK: "MAKESWIFT_CONNECTION_CHECK",
5
+ CHANGE_ELEMENT_BOX_MODELS: "CHANGE_ELEMENT_BOX_MODELS",
6
+ MOUNT_COMPONENT: "MOUNT_COMPONENT",
7
+ UNMOUNT_COMPONENT: "UNMOUNT_COMPONENT",
8
+ CHANGE_DOCUMENT_ELEMENT_SIZE: "CHANGE_DOCUMENT_ELEMENT_SIZE",
9
+ MESSAGE_BUILDER_PROP_CONTROLLER: "MESSAGE_BUILDER_PROP_CONTROLLER",
10
+ HANDLE_WHEEL: "HANDLE_WHEEL",
11
+ HANDLE_POINTER_MOVE: "HANDLE_POINTER_MOVE",
12
+ ELEMENT_FROM_POINT_CHANGE: "ELEMENT_FROM_POINT_CHANGE",
13
+ SET_IS_IN_BUILDER: "SET_IS_IN_BUILDER",
14
+ REGISTER_BUILDER_DOCUMENT: "REGISTER_BUILDER_DOCUMENT",
15
+ UNREGISTER_BUILDER_DOCUMENT: "UNREGISTER_BUILDER_DOCUMENT",
16
+ REGISTER_BUILDER_COMPONENT: "REGISTER_BUILDER_COMPONENT",
17
+ UNREGISTER_BUILDER_COMPONENT: "UNREGISTER_BUILDER_COMPONENT",
18
+ HANDLE_HOST_NAVIGATE: "HANDLE_HOST_NAVIGATE"
19
+ };
20
+ function makeswiftConnectionCheck(payload) {
21
+ return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload };
22
+ }
23
+ function changeElementBoxModels(changedElementBoxModels) {
24
+ return {
25
+ type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,
26
+ payload: { changedElementBoxModels }
27
+ };
28
+ }
29
+ function mountComponent(documentKey, elementKey) {
30
+ return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } };
31
+ }
32
+ function unmountComponent(documentKey, elementKey) {
33
+ return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } };
34
+ }
35
+ function mountComponentEffect(documentKey, elementKey) {
36
+ return (dispatch) => {
37
+ dispatch(mountComponent(documentKey, elementKey));
38
+ return () => {
39
+ dispatch(unmountComponent(documentKey, elementKey));
40
+ };
41
+ };
42
+ }
43
+ function changeDocumentElementSize(size) {
44
+ return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } };
45
+ }
46
+ function messageBuilderPropController(documentKey, elementKey, propName, message) {
47
+ return {
48
+ type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,
49
+ payload: { documentKey, elementKey, propName, message }
50
+ };
51
+ }
52
+ function handleWheel(payload) {
53
+ return { type: BuilderActionTypes.HANDLE_WHEEL, payload };
54
+ }
55
+ function handlePointerMove(payload) {
56
+ return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload };
57
+ }
58
+ function elementFromPointChange(keys) {
59
+ return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } };
60
+ }
61
+ function setIsInBuilder(isInBuilder) {
62
+ return { type: BuilderActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder };
63
+ }
64
+ function registerBuilderDocument(document) {
65
+ return {
66
+ type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,
67
+ payload: { documentKey: document.key, document }
68
+ };
69
+ }
70
+ function unregisterBuilderDocument(documentKey) {
71
+ return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } };
72
+ }
73
+ function registerBuilderDocumentsEffect(documents) {
74
+ return (dispatch) => {
75
+ documents.forEach((document) => dispatch(registerBuilderDocument(document)));
76
+ return () => {
77
+ documents.forEach((document) => dispatch(unregisterBuilderDocument(document.key)));
78
+ };
79
+ };
80
+ }
81
+ function registerBuilderComponent(payload, transferables) {
82
+ return {
83
+ type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,
84
+ payload,
85
+ transferables
86
+ };
87
+ }
88
+ function unregisterBuilderComponent(payload) {
89
+ return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload };
90
+ }
91
+ export {
92
+ BuilderActionTypes,
93
+ changeDocumentElementSize,
94
+ changeElementBoxModels,
95
+ elementFromPointChange,
96
+ handlePointerMove,
97
+ handleWheel,
98
+ makeswiftConnectionCheck,
99
+ messageBuilderPropController,
100
+ mountComponent,
101
+ mountComponentEffect,
102
+ registerBuilderComponent,
103
+ registerBuilderDocument,
104
+ registerBuilderDocumentsEffect,
105
+ setIsInBuilder,
106
+ unmountComponent,
107
+ unregisterBuilderComponent,
108
+ unregisterBuilderDocument
109
+ };
110
+ //# sourceMappingURL=builder-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/state/builder-api.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 SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\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 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 SetIsInBuilderAction = {\n type: typeof BuilderActionTypes.SET_IS_IN_BUILDER\n payload: boolean\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 transferables?: Transferable[]\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 | SetIsInBuilderAction\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 setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: BuilderActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\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): 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_BUIL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CROLL_DOCUMENT_ELEMENT",
7
+ REGISTER_PROP_CONTROLLERS: "REGISTER_PROP_CONTROLLERS",
8
+ UNREGISTER_PROP_CONTROLLERS: "UNREGISTER_PROP_CONTROLLERS",
9
+ MESSAGE_HOST_PROP_CONTROLLER: "MESSAGE_HOST_PROP_CONTROLLER",
10
+ CHANGE_API_RESOURCE: "CHANGE_API_RESOURCE",
11
+ EVICT_API_RESOURCE: "EVICT_API_RESOURCE",
12
+ SET_BUILDER_EDIT_MODE: "SET_BUILDER_EDIT_MODE",
13
+ BUILDER_POINTER_MOVE: "BUILDER_POINTER_MOVE"
14
+ };
15
+ function init() {
16
+ return { type: HostActionTypes.INIT };
17
+ }
18
+ function cleanUp() {
19
+ return { type: HostActionTypes.CLEAN_UP };
20
+ }
21
+ function changeDocument(documentKey, operation) {
22
+ return { type: HostActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } };
23
+ }
24
+ function changeDocumentElementScrollTop(scrollTop) {
25
+ return { type: HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } };
26
+ }
27
+ function scrollDocumentElement(scrollTopDelta) {
28
+ return { type: HostActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } };
29
+ }
30
+ function unregisterPropControllers(documentKey, elementKey) {
31
+ return { type: HostActionTypes.UNREGISTER_PROP_CONTROLLERS, payload: { documentKey, elementKey } };
32
+ }
33
+ function messageHostPropController(documentKey, elementKey, propName, message) {
34
+ return {
35
+ type: HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER,
36
+ payload: { documentKey, elementKey, propName, message }
37
+ };
38
+ }
39
+ function changeApiResource(resource, locale) {
40
+ return { type: HostActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } };
41
+ }
42
+ function evictApiResource(id, locale) {
43
+ return { type: HostActionTypes.EVICT_API_RESOURCE, payload: { id, locale } };
44
+ }
45
+ function setBuilderEditMode(editMode) {
46
+ return {
47
+ type: HostActionTypes.SET_BUILDER_EDIT_MODE,
48
+ payload: { editMode }
49
+ };
50
+ }
51
+ function builderPointerMove(pointer) {
52
+ return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } };
53
+ }
54
+ export {
55
+ HostActionTypes,
56
+ builderPointerMove,
57
+ changeApiResource,
58
+ changeDocument,
59
+ changeDocumentElementScrollTop,
60
+ cleanUp,
61
+ evictApiResource,
62
+ init,
63
+ messageHostPropController,
64
+ scrollDocumentElement,
65
+ setBuilderEditMode,
66
+ unregisterPropControllers
67
+ };
68
+ //# sourceMappingURL=host-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/state/host-api.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\n\nimport { ControlInstance } from '@makeswift/controls'\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\nexport const HostActionTypes = {\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 REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\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\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 RegisterPropControllersAction = {\n type: typeof HostActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof HostActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\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 BuilderPointerMoveAction = {\n type: typeof HostActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\nexport type HostAction =\n | InitAction\n | CleanUpAction\n | ChangeDocumentAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | MessageHostPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetBuilderEditModeAction\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\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return { type: HostActionTypes.UNREGISTER_PROP_CONTROLLERS, payload: { documentKey, elementKey } }\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 builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n"],"mappings":"AAUO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,iBAAiB;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B,SAAiD;AAClF,SAAO,EAAE,MAAM,gBAAgB,sBAAsB,SAAS,EAAE,QAAQ,EAAE;AAC5E;","names":[]}
@@ -4,7 +4,9 @@ import {
4
4
  } from "@reduxjs/toolkit";
5
5
  import * as APIResources from "./modules/api-resources";
6
6
  import * as LocalizedResourcesMap from "./modules/localized-resources-map";
7
- import { ActionTypes, apiResourceFulfilled, setLocalizedResourceId } from "./actions";
7
+ import { ActionTypes } from "./actions";
8
+ import { apiResourceFulfilled } from "./actions/internal";
9
+ import { setLocalizedResourceId } from "./shared-api";
8
10
  import { actionMiddleware, middlewareOptions, devToolsConfig } from "./toolkit";
9
11
  import {
10
12
  APIResourceType
@@ -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, apiResourceFulfilled, setLocalizedResourceId } from './actions'\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,EACE,kBAAkB;AAAA,EAClB;AAAA,OAKK;AAEP,YAAY,kBAAkB;AAC9B,YAAY,2BAA2B;AACvC,SAAsB,aAAa,sBAAsB,8BAA8B;AACvF,SAAS,kBAAkB,mBAAmB,sBAAsB;AAEpE;AAAA,EACE;AAAA,OAUK;AAEP,MAAM,UAAU,gBAAgB;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,gBAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AA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OAAO,MAAM;AAAA,QACnB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY,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,SAAO,oBAAoB;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,iBAAiB,EAAE,OAAO,wBAAwB,aAAa,CAAC;AAAA,IAEvF,UAAU,eAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
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,EACE,kBAAkB;AAAA,EAClB;AAAA,OAKK;AAEP,YAAY,kBAAkB;AAC9B,YAAY,2BAA2B;AACvC,SAAsB,mBAAmB;AACzC,SAAS,4BAA4B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,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -18,8 +18,8 @@ import * as ElementImperativeHandles from "./modules/element-imperative-handles"
18
18
  import * as Breakpoints from "./modules/breakpoints";
19
19
  import { withSetupTeardown } from "./mixins/setup-teardown";
20
20
  import * as ReactPage from "./react-page";
21
+ import { ActionTypes } from "./actions";
21
22
  import {
22
- ActionTypes,
23
23
  changeDocumentElementSize,
24
24
  changeElementBoxModels,
25
25
  elementFromPointChange,
@@ -27,17 +27,19 @@ import {
27
27
  handlePointerMove,
28
28
  messageBuilderPropController,
29
29
  registerBuilderComponent,
30
- registerMeasurable,
31
- registerPropControllers,
32
- registerPropControllersHandle,
33
- setBreakpoints,
34
30
  setIsInBuilder,
35
31
  unregisterBuilderComponent,
36
32
  unregisterBuilderDocument,
37
- unregisterMeasurable,
38
- unregisterPropControllers,
39
33
  registerBuilderDocument
40
- } from "./actions";
34
+ } from "./builder-api";
35
+ import { setBreakpoints } from "./shared-api";
36
+ import {
37
+ registerMeasurable,
38
+ registerPropControllers,
39
+ registerPropControllersHandle,
40
+ unregisterMeasurable,
41
+ unregisterPropControllers
42
+ } from "./actions/internal";
41
43
  import { actionMiddleware, middlewareOptions, devToolsConfig } from "./toolkit";
42
44
  import { createPropController } from "../prop-controllers/instances";
43
45
  import { serializeControls } from "../builder";