@makeswift/runtime 0.26.4-canary.1 → 0.26.4

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 (565) hide show
  1. package/dist/cjs/api/{client.js → react.js} +7 -14
  2. package/dist/cjs/api/react.js.map +1 -0
  3. package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -1
  4. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  5. package/dist/cjs/api-handler/handlers/merge-translated-data.js.map +1 -1
  6. package/dist/cjs/api-handler/handlers/translatable-data.js.map +1 -1
  7. package/dist/cjs/builder/host-to-builder-actions.js +3 -3
  8. package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
  9. package/dist/cjs/builder/index.js +2 -2
  10. package/dist/cjs/builder/index.js.map +1 -1
  11. package/dist/cjs/client/index.js +8 -8
  12. package/dist/cjs/client/index.js.map +1 -1
  13. package/dist/cjs/components/builtin/Box/Box.js +1 -1
  14. package/dist/cjs/components/builtin/Box/Box.js.map +1 -1
  15. package/dist/cjs/components/builtin/Form/Form.js +1 -1
  16. package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
  17. package/dist/cjs/components/hooks/useTableFormFieldRefs.js +1 -1
  18. package/dist/cjs/components/hooks/useTableFormFieldRefs.js.map +1 -1
  19. package/dist/cjs/next/api-handler/config/app-router.js +10 -1
  20. package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
  21. package/dist/cjs/next/components/framework-provider/index.js +1 -1
  22. package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
  23. package/dist/cjs/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  24. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  25. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  26. package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  27. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +2 -1
  28. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  29. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  30. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  31. package/dist/cjs/next/testing/element-data.js +3 -3
  32. package/dist/cjs/next/testing/element-data.js.map +1 -1
  33. package/dist/cjs/next/testing/index.js +0 -2
  34. package/dist/cjs/next/testing/index.js.map +1 -1
  35. package/dist/cjs/next/testing/page-rendering.js +3 -3
  36. package/dist/cjs/next/testing/page-rendering.js.map +1 -1
  37. package/dist/cjs/prop-controllers/descriptors.js.map +1 -1
  38. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  39. package/dist/cjs/runtimes/react/components/Document.js +2 -2
  40. package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
  41. package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
  42. package/dist/cjs/runtimes/react/components/Element.js +2 -2
  43. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  44. package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
  45. package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
  46. package/dist/cjs/runtimes/react/components/ElementRegistration.js +2 -2
  47. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  48. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
  49. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  50. package/dist/cjs/runtimes/react/components/RuntimeProvider.js +5 -6
  51. package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
  52. package/dist/cjs/runtimes/react/components/framework-context.js +13 -3
  53. package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
  54. package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
  55. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +3 -2
  56. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  57. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  58. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  59. package/dist/cjs/runtimes/react/controls.js +2 -2
  60. package/dist/cjs/runtimes/react/controls.js.map +1 -1
  61. package/dist/cjs/runtimes/react/element-imperative-handle.js +1 -1
  62. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  63. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js +2 -2
  64. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  65. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js +2 -2
  66. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  67. package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
  68. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  69. package/dist/cjs/runtimes/react/hooks/use-component.js +3 -3
  70. package/dist/cjs/runtimes/react/hooks/use-component.js.map +1 -1
  71. package/dist/cjs/runtimes/react/hooks/use-dispatch.js.map +1 -1
  72. package/dist/cjs/runtimes/react/hooks/use-document.js +2 -2
  73. package/dist/cjs/runtimes/react/hooks/use-document.js.map +1 -1
  74. package/dist/cjs/runtimes/react/hooks/use-element-id.js +2 -2
  75. package/dist/cjs/runtimes/react/hooks/use-element-id.js.map +1 -1
  76. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js +2 -2
  77. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  78. package/dist/cjs/runtimes/react/hooks/{use-is-read-only.js → use-is-preview.js} +9 -9
  79. package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
  80. package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
  81. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +2 -2
  82. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  83. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +1 -1
  84. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  85. package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
  86. package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
  87. package/dist/cjs/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  88. package/dist/cjs/runtimes/react/host-api-client.js +3 -4
  89. package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
  90. package/dist/cjs/runtimes/react/index.js +3 -3
  91. package/dist/cjs/runtimes/react/index.js.map +1 -1
  92. package/dist/cjs/runtimes/react/poll-box-model.js +1 -1
  93. package/dist/cjs/runtimes/react/poll-box-model.js.map +1 -1
  94. package/dist/cjs/runtimes/react/react-runtime-core.js +3 -3
  95. package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
  96. package/dist/cjs/runtimes/react/runtime-core.js +2 -4
  97. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  98. package/dist/cjs/runtimes/react/utils/can-accept-ref.js.map +1 -1
  99. package/dist/cjs/state/actions/{internal/read-only-actions.js → internal.js} +62 -44
  100. package/dist/cjs/state/actions/internal.js.map +1 -0
  101. package/dist/cjs/state/builder-api/actions.js +8 -11
  102. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  103. package/dist/cjs/state/host-api.js.map +1 -1
  104. package/dist/cjs/state/makeswift-api-client.js +20 -34
  105. package/dist/cjs/state/makeswift-api-client.js.map +1 -1
  106. package/dist/cjs/state/modules/api-resources.js +4 -7
  107. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  108. package/dist/cjs/state/modules/{read-write/box-models.js → box-models.js} +4 -6
  109. package/dist/cjs/state/modules/box-models.js.map +1 -0
  110. package/dist/cjs/state/modules/breakpoints.js +1 -2
  111. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  112. package/dist/cjs/state/modules/builder-edit-mode.js +1 -2
  113. package/dist/cjs/state/modules/builder-edit-mode.js.map +1 -1
  114. package/dist/cjs/state/modules/components-meta.js +2 -3
  115. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  116. package/dist/cjs/state/modules/{read-write/element-imperative-handles.js → element-imperative-handles.js} +3 -4
  117. package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
  118. package/dist/cjs/state/modules/element-trees.js +3 -5
  119. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  120. package/dist/cjs/state/modules/is-in-builder.js +1 -2
  121. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  122. package/dist/cjs/state/modules/{is-read-only.js → is-preview.js} +9 -12
  123. package/dist/cjs/state/modules/is-preview.js.map +1 -0
  124. package/dist/cjs/state/modules/localized-resources-map.js +2 -4
  125. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  126. package/dist/cjs/state/modules/{read-write/pointer.js → pointer.js} +2 -3
  127. package/dist/cjs/state/modules/pointer.js.map +1 -0
  128. package/dist/cjs/state/modules/prop-controllers.js +2 -3
  129. package/dist/cjs/state/modules/prop-controllers.js.map +1 -1
  130. package/dist/cjs/state/modules/react-components.js +2 -3
  131. package/dist/cjs/state/modules/react-components.js.map +1 -1
  132. package/dist/cjs/state/modules/read-only-documents.js +2 -3
  133. package/dist/cjs/state/modules/read-only-documents.js.map +1 -1
  134. package/dist/cjs/state/modules/{read-write/read-write-documents.js → read-write-documents.js} +3 -3
  135. package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
  136. package/dist/cjs/state/react-builder-preview.js +508 -18
  137. package/dist/cjs/state/react-builder-preview.js.map +1 -1
  138. package/dist/cjs/state/react-page.js +250 -6
  139. package/dist/cjs/state/react-page.js.map +1 -1
  140. package/dist/cjs/state/shared-api.js.map +1 -1
  141. package/dist/cjs/state/translations/get.js +2 -2
  142. package/dist/cjs/state/translations/get.js.map +1 -1
  143. package/dist/cjs/state/translations/merge.js +2 -2
  144. package/dist/cjs/state/translations/merge.js.map +1 -1
  145. package/dist/cjs/unstable-framework-support/index.js +4 -2
  146. package/dist/cjs/unstable-framework-support/index.js.map +1 -1
  147. package/dist/esm/api/{client.js → react.js} +4 -11
  148. package/dist/esm/api/react.js.map +1 -0
  149. package/dist/esm/api-handler/handlers/element-tree.js.map +1 -1
  150. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  151. package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -1
  152. package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -1
  153. package/dist/esm/builder/host-to-builder-actions.js +4 -4
  154. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  155. package/dist/esm/builder/index.js +1 -1
  156. package/dist/esm/builder/index.js.map +1 -1
  157. package/dist/esm/client/index.js +5 -5
  158. package/dist/esm/client/index.js.map +1 -1
  159. package/dist/esm/components/builtin/Box/Box.js +1 -1
  160. package/dist/esm/components/builtin/Box/Box.js.map +1 -1
  161. package/dist/esm/components/builtin/Form/Form.js +1 -1
  162. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  163. package/dist/esm/components/hooks/useTableFormFieldRefs.js +1 -1
  164. package/dist/esm/components/hooks/useTableFormFieldRefs.js.map +1 -1
  165. package/dist/esm/next/api-handler/config/app-router.js +10 -1
  166. package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
  167. package/dist/esm/next/components/framework-provider/index.js +5 -2
  168. package/dist/esm/next/components/framework-provider/index.js.map +1 -1
  169. package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  170. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  171. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  172. package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  173. package/dist/esm/next/components/tests/makeswift-component/fixtures.js +2 -1
  174. package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  175. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  176. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  177. package/dist/esm/next/testing/element-data.js +1 -1
  178. package/dist/esm/next/testing/element-data.js.map +1 -1
  179. package/dist/esm/next/testing/index.js +0 -1
  180. package/dist/esm/next/testing/index.js.map +1 -1
  181. package/dist/esm/next/testing/page-rendering.js +3 -3
  182. package/dist/esm/next/testing/page-rendering.js.map +1 -1
  183. package/dist/esm/prop-controllers/descriptors.js.map +1 -1
  184. package/dist/esm/prop-controllers/instances.js.map +1 -1
  185. package/dist/esm/runtimes/react/components/Document.js +1 -1
  186. package/dist/esm/runtimes/react/components/Document.js.map +1 -1
  187. package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
  188. package/dist/esm/runtimes/react/components/Element.js +1 -3
  189. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  190. package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
  191. package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
  192. package/dist/esm/runtimes/react/components/ElementRegistration.js +1 -1
  193. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  194. package/dist/esm/runtimes/react/components/MakeswiftComponent.js +1 -1
  195. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  196. package/dist/esm/runtimes/react/components/RuntimeProvider.js +4 -5
  197. package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
  198. package/dist/esm/runtimes/react/components/framework-context.js +14 -2
  199. package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
  200. package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
  201. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +3 -2
  202. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  203. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  204. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  205. package/dist/esm/runtimes/react/controls.js +2 -2
  206. package/dist/esm/runtimes/react/controls.js.map +1 -1
  207. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  208. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  209. package/dist/esm/runtimes/react/hooks/use-breakpoints.js +1 -1
  210. package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  211. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js +1 -1
  212. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  213. package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
  214. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  215. package/dist/esm/runtimes/react/hooks/use-component.js +1 -1
  216. package/dist/esm/runtimes/react/hooks/use-component.js.map +1 -1
  217. package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +1 -1
  218. package/dist/esm/runtimes/react/hooks/use-document.js +1 -1
  219. package/dist/esm/runtimes/react/hooks/use-document.js.map +1 -1
  220. package/dist/esm/runtimes/react/hooks/use-element-id.js +1 -1
  221. package/dist/esm/runtimes/react/hooks/use-element-id.js.map +1 -1
  222. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js +1 -1
  223. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  224. package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
  225. package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
  226. package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
  227. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +2 -2
  228. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  229. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +1 -1
  230. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  231. package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
  232. package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
  233. package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  234. package/dist/esm/runtimes/react/host-api-client.js +2 -3
  235. package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
  236. package/dist/esm/runtimes/react/index.js +2 -2
  237. package/dist/esm/runtimes/react/index.js.map +1 -1
  238. package/dist/esm/runtimes/react/poll-box-model.js +1 -1
  239. package/dist/esm/runtimes/react/poll-box-model.js.map +1 -1
  240. package/dist/esm/runtimes/react/react-runtime-core.js +1 -4
  241. package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
  242. package/dist/esm/runtimes/react/runtime-core.js +5 -3
  243. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  244. package/dist/esm/runtimes/react/utils/can-accept-ref.js.map +1 -1
  245. package/dist/esm/state/actions/{internal/read-only-actions.js → internal.js} +52 -36
  246. package/dist/esm/state/actions/internal.js.map +1 -0
  247. package/dist/esm/state/builder-api/actions.js +7 -8
  248. package/dist/esm/state/builder-api/actions.js.map +1 -1
  249. package/dist/esm/state/host-api.js.map +1 -1
  250. package/dist/esm/state/makeswift-api-client.js +19 -33
  251. package/dist/esm/state/makeswift-api-client.js.map +1 -1
  252. package/dist/esm/state/modules/api-resources.js +5 -8
  253. package/dist/esm/state/modules/api-resources.js.map +1 -1
  254. package/dist/esm/state/modules/{read-write/box-models.js → box-models.js} +4 -6
  255. package/dist/esm/state/modules/box-models.js.map +1 -0
  256. package/dist/esm/state/modules/breakpoints.js +2 -3
  257. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  258. package/dist/esm/state/modules/builder-edit-mode.js +2 -3
  259. package/dist/esm/state/modules/builder-edit-mode.js.map +1 -1
  260. package/dist/esm/state/modules/components-meta.js +3 -4
  261. package/dist/esm/state/modules/components-meta.js.map +1 -1
  262. package/dist/esm/state/modules/{read-write/element-imperative-handles.js → element-imperative-handles.js} +3 -4
  263. package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
  264. package/dist/esm/state/modules/element-trees.js +4 -6
  265. package/dist/esm/state/modules/element-trees.js.map +1 -1
  266. package/dist/esm/state/modules/is-in-builder.js +2 -3
  267. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  268. package/dist/esm/state/modules/is-preview.js +21 -0
  269. package/dist/esm/state/modules/is-preview.js.map +1 -0
  270. package/dist/esm/state/modules/localized-resources-map.js +3 -5
  271. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  272. package/dist/esm/state/modules/{read-write/pointer.js → pointer.js} +2 -3
  273. package/dist/esm/state/modules/pointer.js.map +1 -0
  274. package/dist/esm/state/modules/prop-controllers.js +3 -4
  275. package/dist/esm/state/modules/prop-controllers.js.map +1 -1
  276. package/dist/esm/state/modules/react-components.js +3 -4
  277. package/dist/esm/state/modules/react-components.js.map +1 -1
  278. package/dist/esm/state/modules/read-only-documents.js +6 -4
  279. package/dist/esm/state/modules/read-only-documents.js.map +1 -1
  280. package/dist/esm/state/modules/{read-write/read-write-documents.js → read-write-documents.js} +3 -3
  281. package/dist/esm/state/modules/read-write-documents.js.map +1 -0
  282. package/dist/esm/state/react-builder-preview.js +500 -15
  283. package/dist/esm/state/react-builder-preview.js.map +1 -1
  284. package/dist/esm/state/react-page.js +240 -7
  285. package/dist/esm/state/react-page.js.map +1 -1
  286. package/dist/esm/state/shared-api.js.map +1 -1
  287. package/dist/esm/state/translations/get.js +1 -1
  288. package/dist/esm/state/translations/get.js.map +1 -1
  289. package/dist/esm/state/translations/merge.js +1 -1
  290. package/dist/esm/state/translations/merge.js.map +1 -1
  291. package/dist/esm/unstable-framework-support/index.js +4 -2
  292. package/dist/esm/unstable-framework-support/index.js.map +1 -1
  293. package/dist/types/api/{client.d.ts → react.d.ts} +2 -4
  294. package/dist/types/api/react.d.ts.map +1 -0
  295. package/dist/types/api-handler/handlers/element-tree.d.ts +1 -1
  296. package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -1
  297. package/dist/types/api-handler/handlers/merge-translated-data.d.ts +1 -1
  298. package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -1
  299. package/dist/types/api-handler/handlers/translatable-data.d.ts +1 -1
  300. package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -1
  301. package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
  302. package/dist/types/builder/host-to-builder-actions.d.ts +2 -2
  303. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  304. package/dist/types/builder/index.d.ts +2 -2
  305. package/dist/types/builder/index.d.ts.map +1 -1
  306. package/dist/types/client/index.d.ts +2 -2
  307. package/dist/types/client/index.d.ts.map +1 -1
  308. package/dist/types/components/builtin/Box/Box.d.ts +1 -1
  309. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  310. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  311. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  312. package/dist/types/locale.d.ts +1 -1
  313. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
  314. package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
  315. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
  316. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  317. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +3 -3
  318. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  319. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
  320. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  321. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +1 -1
  322. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -1
  323. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts +1 -1
  324. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts.map +1 -1
  325. package/dist/types/next/testing/element-data.d.ts +1 -1
  326. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  327. package/dist/types/next/testing/index.d.ts +0 -1
  328. package/dist/types/next/testing/index.d.ts.map +1 -1
  329. package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
  330. package/dist/types/prop-controllers/descriptors.d.ts +1 -1
  331. package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
  332. package/dist/types/prop-controllers/instances.d.ts +1 -1
  333. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  334. package/dist/types/runtimes/react/components/Document.d.ts +1 -1
  335. package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
  336. package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
  337. package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
  338. package/dist/types/runtimes/react/components/Element.d.ts +1 -1
  339. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  340. package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
  341. package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
  342. package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
  343. package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
  344. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +1 -1
  345. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
  346. package/dist/types/runtimes/react/components/framework-context.d.ts +4 -2
  347. package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
  348. package/dist/types/runtimes/react/components/page/Page.d.ts +1 -1
  349. package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
  350. package/dist/types/runtimes/react/controls.d.ts +2 -2
  351. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  352. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  353. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  354. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
  355. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
  356. package/dist/types/runtimes/react/hooks/use-component.d.ts +1 -1
  357. package/dist/types/runtimes/react/hooks/use-component.d.ts.map +1 -1
  358. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts +3 -3
  359. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts.map +1 -1
  360. package/dist/types/runtimes/react/hooks/use-document.d.ts +1 -1
  361. package/dist/types/runtimes/react/hooks/use-document.d.ts.map +1 -1
  362. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
  363. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
  364. package/dist/types/runtimes/react/hooks/use-register-document.d.ts +1 -1
  365. package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
  366. package/dist/types/runtimes/react/hooks/use-selector.d.ts +3 -3
  367. package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
  368. package/dist/types/runtimes/react/hooks/use-store.d.ts +4 -4
  369. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  370. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts +1 -1
  371. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts.map +1 -1
  372. package/dist/types/runtimes/react/host-api-client.d.ts +1 -1
  373. package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
  374. package/dist/types/runtimes/react/index.d.ts +1 -1
  375. package/dist/types/runtimes/react/index.d.ts.map +1 -1
  376. package/dist/types/runtimes/react/poll-box-model.d.ts +1 -1
  377. package/dist/types/runtimes/react/poll-box-model.d.ts.map +1 -1
  378. package/dist/types/runtimes/react/react-runtime-core.d.ts +1 -1
  379. package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
  380. package/dist/types/runtimes/react/runtime-core.d.ts +1 -2
  381. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  382. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts +1 -1
  383. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts.map +1 -1
  384. package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
  385. package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
  386. package/dist/types/state/actions/index.d.ts +5 -8
  387. package/dist/types/state/actions/index.d.ts.map +1 -1
  388. package/dist/types/state/actions/{internal/read-only-actions.d.ts → internal.d.ts} +67 -45
  389. package/dist/types/state/actions/internal.d.ts.map +1 -0
  390. package/dist/types/state/builder-api/actions.d.ts +14 -14
  391. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  392. package/dist/types/state/host-api.d.ts +1 -1
  393. package/dist/types/state/host-api.d.ts.map +1 -1
  394. package/dist/types/state/makeswift-api-client.d.ts +2 -11
  395. package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
  396. package/dist/types/state/modules/api-resources.d.ts.map +1 -1
  397. package/dist/types/state/modules/{read-write/box-models.d.ts → box-models.d.ts} +1 -1
  398. package/dist/types/state/modules/box-models.d.ts.map +1 -0
  399. package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
  400. package/dist/types/state/modules/builder-edit-mode.d.ts.map +1 -1
  401. package/dist/types/state/modules/components-meta.d.ts.map +1 -1
  402. package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
  403. package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
  404. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  405. package/dist/types/state/modules/is-in-builder.d.ts.map +1 -1
  406. package/dist/types/state/modules/{is-read-only.d.ts → is-preview.d.ts} +3 -3
  407. package/dist/types/state/modules/is-preview.d.ts.map +1 -0
  408. package/dist/types/state/modules/localized-resources-map.d.ts.map +1 -1
  409. package/dist/types/state/modules/{read-write/pointer.d.ts → pointer.d.ts} +3 -2
  410. package/dist/types/state/modules/pointer.d.ts.map +1 -0
  411. package/dist/types/state/modules/prop-controllers.d.ts.map +1 -1
  412. package/dist/types/state/modules/react-components.d.ts.map +1 -1
  413. package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
  414. package/dist/types/state/modules/{read-write/read-write-documents.d.ts → read-write-documents.d.ts} +4 -4
  415. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
  416. package/dist/types/state/react-builder-preview.d.ts +93 -26
  417. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  418. package/dist/types/state/react-page.d.ts +136 -20
  419. package/dist/types/state/react-page.d.ts.map +1 -1
  420. package/dist/types/state/shared-api.d.ts.map +1 -1
  421. package/dist/types/state/translations/get.d.ts +1 -1
  422. package/dist/types/state/translations/get.d.ts.map +1 -1
  423. package/dist/types/state/translations/merge.d.ts +1 -1
  424. package/dist/types/state/translations/merge.d.ts.map +1 -1
  425. package/dist/types/unstable-framework-support/index.d.ts +1 -1
  426. package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
  427. package/package.json +3 -3
  428. package/dist/cjs/api/client.js.map +0 -1
  429. package/dist/cjs/next/testing/react-runtime.js +0 -29
  430. package/dist/cjs/next/testing/react-runtime.js.map +0 -1
  431. package/dist/cjs/runtimes/react/hooks/use-is-read-only.js.map +0 -1
  432. package/dist/cjs/runtimes/react/testing/react-runtime.js +0 -32
  433. package/dist/cjs/runtimes/react/testing/react-runtime.js.map +0 -1
  434. package/dist/cjs/state/actions/internal/index.js +0 -34
  435. package/dist/cjs/state/actions/internal/index.js.map +0 -1
  436. package/dist/cjs/state/actions/internal/read-only-actions.js.map +0 -1
  437. package/dist/cjs/state/actions/internal/read-write-actions.js +0 -70
  438. package/dist/cjs/state/actions/internal/read-write-actions.js.map +0 -1
  439. package/dist/cjs/state/middleware/prop-controller-handles.js +0 -114
  440. package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
  441. package/dist/cjs/state/middleware/read-only-element-tree.js +0 -52
  442. package/dist/cjs/state/middleware/read-only-element-tree.js.map +0 -1
  443. package/dist/cjs/state/middleware/read-write/builder-api/element-size.js +0 -40
  444. package/dist/cjs/state/middleware/read-write/builder-api/element-size.js.map +0 -1
  445. package/dist/cjs/state/middleware/read-write/builder-api/index.js +0 -76
  446. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +0 -1
  447. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +0 -278
  448. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +0 -1
  449. package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js +0 -37
  450. package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  451. package/dist/cjs/state/middleware/read-write/measure-box-models.js +0 -71
  452. package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +0 -1
  453. package/dist/cjs/state/middleware/read-write/update-element-tree.js +0 -59
  454. package/dist/cjs/state/middleware/read-write/update-element-tree.js.map +0 -1
  455. package/dist/cjs/state/modules/is-read-only.js.map +0 -1
  456. package/dist/cjs/state/modules/locale.js +0 -53
  457. package/dist/cjs/state/modules/locale.js.map +0 -1
  458. package/dist/cjs/state/modules/read-write/box-models.js.map +0 -1
  459. package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +0 -1
  460. package/dist/cjs/state/modules/read-write/pointer.js.map +0 -1
  461. package/dist/cjs/state/modules/read-write/read-write-documents.js.map +0 -1
  462. package/dist/cjs/state/modules/site-version.js +0 -50
  463. package/dist/cjs/state/modules/site-version.js.map +0 -1
  464. package/dist/cjs/state/ops/copy-element-tree.js +0 -67
  465. package/dist/cjs/state/ops/copy-element-tree.js.map +0 -1
  466. package/dist/cjs/state/ops/merge-element.js +0 -73
  467. package/dist/cjs/state/ops/merge-element.js.map +0 -1
  468. package/dist/cjs/state/read-only-state.js +0 -209
  469. package/dist/cjs/state/read-only-state.js.map +0 -1
  470. package/dist/cjs/state/read-write-state.js +0 -121
  471. package/dist/cjs/state/read-write-state.js.map +0 -1
  472. package/dist/esm/api/client.js.map +0 -1
  473. package/dist/esm/next/testing/react-runtime.js +0 -5
  474. package/dist/esm/next/testing/react-runtime.js.map +0 -1
  475. package/dist/esm/runtimes/react/hooks/use-is-read-only.js +0 -9
  476. package/dist/esm/runtimes/react/hooks/use-is-read-only.js.map +0 -1
  477. package/dist/esm/runtimes/react/testing/react-runtime.js +0 -8
  478. package/dist/esm/runtimes/react/testing/react-runtime.js.map +0 -1
  479. package/dist/esm/state/actions/internal/index.js +0 -10
  480. package/dist/esm/state/actions/internal/index.js.map +0 -1
  481. package/dist/esm/state/actions/internal/read-only-actions.js.map +0 -1
  482. package/dist/esm/state/actions/internal/read-write-actions.js +0 -41
  483. package/dist/esm/state/actions/internal/read-write-actions.js.map +0 -1
  484. package/dist/esm/state/middleware/prop-controller-handles.js +0 -80
  485. package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
  486. package/dist/esm/state/middleware/read-only-element-tree.js +0 -28
  487. package/dist/esm/state/middleware/read-only-element-tree.js.map +0 -1
  488. package/dist/esm/state/middleware/read-write/builder-api/element-size.js +0 -16
  489. package/dist/esm/state/middleware/read-write/builder-api/element-size.js.map +0 -1
  490. package/dist/esm/state/middleware/read-write/builder-api/index.js +0 -52
  491. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +0 -1
  492. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +0 -251
  493. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +0 -1
  494. package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js +0 -13
  495. package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  496. package/dist/esm/state/middleware/read-write/measure-box-models.js +0 -37
  497. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +0 -1
  498. package/dist/esm/state/middleware/read-write/update-element-tree.js +0 -35
  499. package/dist/esm/state/middleware/read-write/update-element-tree.js.map +0 -1
  500. package/dist/esm/state/modules/is-read-only.js +0 -24
  501. package/dist/esm/state/modules/is-read-only.js.map +0 -1
  502. package/dist/esm/state/modules/locale.js +0 -27
  503. package/dist/esm/state/modules/locale.js.map +0 -1
  504. package/dist/esm/state/modules/read-write/box-models.js.map +0 -1
  505. package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +0 -1
  506. package/dist/esm/state/modules/read-write/pointer.js.map +0 -1
  507. package/dist/esm/state/modules/read-write/read-write-documents.js.map +0 -1
  508. package/dist/esm/state/modules/site-version.js +0 -24
  509. package/dist/esm/state/modules/site-version.js.map +0 -1
  510. package/dist/esm/state/ops/copy-element-tree.js +0 -37
  511. package/dist/esm/state/ops/copy-element-tree.js.map +0 -1
  512. package/dist/esm/state/ops/merge-element.js +0 -39
  513. package/dist/esm/state/ops/merge-element.js.map +0 -1
  514. package/dist/esm/state/read-only-state.js +0 -157
  515. package/dist/esm/state/read-only-state.js.map +0 -1
  516. package/dist/esm/state/read-write-state.js +0 -76
  517. package/dist/esm/state/read-write-state.js.map +0 -1
  518. package/dist/types/api/client.d.ts.map +0 -1
  519. package/dist/types/next/testing/react-runtime.d.ts +0 -2
  520. package/dist/types/next/testing/react-runtime.d.ts.map +0 -1
  521. package/dist/types/runtimes/react/hooks/use-is-read-only.d.ts +0 -2
  522. package/dist/types/runtimes/react/hooks/use-is-read-only.d.ts.map +0 -1
  523. package/dist/types/runtimes/react/testing/react-runtime.d.ts +0 -3
  524. package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +0 -1
  525. package/dist/types/state/__tests__/merge-element.test.d.ts +0 -2
  526. package/dist/types/state/__tests__/merge-element.test.d.ts.map +0 -1
  527. package/dist/types/state/actions/internal/index.d.ts +0 -27
  528. package/dist/types/state/actions/internal/index.d.ts.map +0 -1
  529. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +0 -1
  530. package/dist/types/state/actions/internal/read-write-actions.d.ts +0 -48
  531. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +0 -1
  532. package/dist/types/state/middleware/prop-controller-handles.d.ts +0 -4
  533. package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
  534. package/dist/types/state/middleware/read-only-element-tree.d.ts +0 -4
  535. package/dist/types/state/middleware/read-only-element-tree.d.ts.map +0 -1
  536. package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts +0 -12
  537. package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts.map +0 -1
  538. package/dist/types/state/middleware/read-write/builder-api/index.d.ts +0 -5
  539. package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +0 -1
  540. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts +0 -6
  541. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +0 -1
  542. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
  543. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts.map +0 -1
  544. package/dist/types/state/middleware/read-write/measure-box-models.d.ts +0 -4
  545. package/dist/types/state/middleware/read-write/measure-box-models.d.ts.map +0 -1
  546. package/dist/types/state/middleware/read-write/update-element-tree.d.ts +0 -4
  547. package/dist/types/state/middleware/read-write/update-element-tree.d.ts.map +0 -1
  548. package/dist/types/state/modules/is-read-only.d.ts.map +0 -1
  549. package/dist/types/state/modules/locale.d.ts +0 -6
  550. package/dist/types/state/modules/locale.d.ts.map +0 -1
  551. package/dist/types/state/modules/read-write/box-models.d.ts.map +0 -1
  552. package/dist/types/state/modules/read-write/element-imperative-handles.d.ts +0 -6
  553. package/dist/types/state/modules/read-write/element-imperative-handles.d.ts.map +0 -1
  554. package/dist/types/state/modules/read-write/pointer.d.ts.map +0 -1
  555. package/dist/types/state/modules/read-write/read-write-documents.d.ts.map +0 -1
  556. package/dist/types/state/modules/site-version.d.ts +0 -7
  557. package/dist/types/state/modules/site-version.d.ts.map +0 -1
  558. package/dist/types/state/ops/copy-element-tree.d.ts +0 -37
  559. package/dist/types/state/ops/copy-element-tree.d.ts.map +0 -1
  560. package/dist/types/state/ops/merge-element.d.ts +0 -4
  561. package/dist/types/state/ops/merge-element.d.ts.map +0 -1
  562. package/dist/types/state/read-only-state.d.ts +0 -122
  563. package/dist/types/state/read-only-state.d.ts.map +0 -1
  564. package/dist/types/state/read-write-state.d.ts +0 -56
  565. package/dist/types/state/read-write-state.d.ts.map +0 -1
@@ -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'\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\nexport type RegisterComponentAction = {\n type: typeof InternalActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\nexport type 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,SAAS,qBACd,cACA,YACA,UACA,QAC4B;AAC5B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,cAAc,YAAY,UAAU,OAAO;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO,EAAE,MAAM,oBAAoB,qBAAqB,QAAQ;AAClE;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC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MAAM;AACX,eAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEO,SAAS,8BACd,aACA,YACA,QACqC;AACrC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,YAAY,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,gCACd,aACA,YACuC;AACvC,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,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":[]}
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var actions_exports = {};
21
20
  __export(actions_exports, {
@@ -39,14 +38,13 @@ __export(actions_exports, {
39
38
  });
40
39
  module.exports = __toCommonJS(actions_exports);
41
40
  var import_shared_api = require("../shared-api");
42
- __reExport(actions_exports, require("../shared-api"), module.exports);
43
41
  const BuilderActionTypes = {
44
42
  ...import_shared_api.SharedActionTypes,
45
43
  MAKESWIFT_CONNECTION_CHECK: "MAKESWIFT_CONNECTION_CHECK",
44
+ CHANGE_ELEMENT_BOX_MODELS: "CHANGE_ELEMENT_BOX_MODELS",
46
45
  MOUNT_COMPONENT: "MOUNT_COMPONENT",
47
46
  UNMOUNT_COMPONENT: "UNMOUNT_COMPONENT",
48
47
  CHANGE_DOCUMENT_ELEMENT_SIZE: "CHANGE_DOCUMENT_ELEMENT_SIZE",
49
- CHANGE_ELEMENT_BOX_MODELS: "CHANGE_ELEMENT_BOX_MODELS",
50
48
  MESSAGE_BUILDER_PROP_CONTROLLER: "MESSAGE_BUILDER_PROP_CONTROLLER",
51
49
  HANDLE_WHEEL: "HANDLE_WHEEL",
52
50
  HANDLE_POINTER_MOVE: "HANDLE_POINTER_MOVE",
@@ -60,6 +58,12 @@ const BuilderActionTypes = {
60
58
  function makeswiftConnectionCheck(payload) {
61
59
  return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload };
62
60
  }
61
+ function changeElementBoxModels(changedElementBoxModels) {
62
+ return {
63
+ type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,
64
+ payload: { changedElementBoxModels }
65
+ };
66
+ }
63
67
  function mountComponent(documentKey, elementKey) {
64
68
  return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } };
65
69
  }
@@ -77,12 +81,6 @@ function mountComponentEffect(documentKey, elementKey) {
77
81
  function changeDocumentElementSize(size) {
78
82
  return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } };
79
83
  }
80
- function changeElementBoxModels(changedElementBoxModels) {
81
- return {
82
- type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,
83
- payload: { changedElementBoxModels }
84
- };
85
- }
86
84
  function messageBuilderPropController(documentKey, elementKey, propName, message) {
87
85
  return {
88
86
  type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,
@@ -146,7 +144,6 @@ function hasTransferables(action) {
146
144
  registerBuilderDocumentsEffect,
147
145
  unmountComponent,
148
146
  unregisterBuilderComponent,
149
- unregisterBuilderDocument,
150
- ...require("../shared-api")
147
+ unregisterBuilderDocument
151
148
  });
152
149
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type ComponentMeta } from '../modules/components-meta'\nimport { type BoxModel } from '../modules/read-write/box-models'\n\nimport { type ElementSize } from '../middleware/read-write/builder-api/element-size'\nimport { type DocumentPayload, type SharedAction, SharedActionTypes } from '../shared-api'\n\nexport * from '../shared-api'\n\n// actions dispatched by the host to the builder (\"Builder API\")\n// note that some of these actions, in addition to being dispatched to the builder,\n// might also be internally intercepted by the host as a part of maintaining the\n// runtime's \"read-write\" state\nexport const BuilderActionTypes = {\n ...SharedActionTypes,\n\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n HANDLE_HOST_NAVIGATE: 'HANDLE_HOST_NAVIGATE',\n} as const\n\ntype ActionWithTransferables<A> = A & {\n transferables?: Transferable[]\n}\n\ntype MakeswiftConnectionCheckAction = {\n type: typeof BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK\n payload: { currentUrl: string }\n}\n\ntype MountComponentAction = {\n type: typeof BuilderActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof BuilderActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: ElementSize }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype HandleWheelAction = {\n type: typeof BuilderActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof BuilderActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype HandleHostNavigateAction = {\n type: typeof BuilderActionTypes.HANDLE_HOST_NAVIGATE\n payload: { url: string | null }\n}\n\nexport type BuilderAction =\n | SharedAction\n | MakeswiftConnectionCheckAction\n | MountComponentAction\n | UnmountComponentAction\n | ChangeDocumentElementSizeAction\n | ChangeElementBoxModelsAction\n | MessageBuilderPropControllerAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | ElementFromPointChangeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | HandleHostNavigateAction\n\nexport function makeswiftConnectionCheck(\n payload: MakeswiftConnectionCheckAction['payload'],\n): MakeswiftConnectionCheckAction {\n return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function changeDocumentElementSize(size: ElementSize): ChangeDocumentElementSizeAction {\n return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return {\n type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,\n payload: { changedElementBoxModels },\n }\n}\n\nexport function messageBuilderPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageBuilderPropControllerAction<T> {\n return {\n type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: BuilderActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerBuilderDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterBuilderDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): ActionWithTransferables<RegisterBuilderComponentAction> {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nexport function hasTransferables<A extends BuilderAction>(\n action: A,\n): action is ActionWithTransferables<A> {\n return 'transferables' in action && Array.isArray(action.transferables)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,wBAA2E;AAE3E,4BAAc,0BAZd;AAkBO,MAAM,qBAAqB;AAAA,EAChC,GAAG;AAAA,EAEH,4BAA4B;AAAA,EAE5B,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EAEnB,8BAA8B;AAAA,EAC9B,2BAA2B;AAAA,EAE3B,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,eAAe,aAAqB,YAA0C;AAC5F,SAAO,EAAE,MAAM,mBAAmB,iBAAiB,SAAS,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AS,wBAAwB,QAAQ,CAAC,CAAC;AAEzE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,0BAA0B,SAAS,GAAG,CAAC,CAAC;AAAA,IACjF;AAAA,EACF;AACF;AAEO,SAAS,yBACd,SACA,eACyD;AACzD,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type 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,mBAAmB;AAAA,IACzB,SAAS,EAAE,wBAAwB;AAAA,EACrC;AACF;AAEO,SAAS,eAAe,aAAqB,YAA0C;AAC5F,SAAO,EAAE,MAAM,mBAAmB,iBAAiB,SAAS,EAAE,aAAa,WAAW,EAAE;AAC1F;AAEO,SAAS,iBAAiB,aAAqB,YAA4C;AAChG,SAAO,EAAE,MAAM,mBAAmB,mBAAmB,SAAS,EAAE,aAAa,WAAW,E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AEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
@@ -1 +1 @@
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/read-write/pointer'\n\nimport { type SharedAction, SharedActionTypes } from './shared-api'\n\n// actions dispatched by the builder to the host (\"Host API\")\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;AAG9C,MAAM,kBAAkB;AAA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AO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,YAAY,qBAAqB,OAAO;AAAA,EACrD;AACF;AAEO,SAAS,mBAAmB,SAAiD;AAClF,SAAO,EAAE,MAAM,gBAAgB,sBAAsB,SAAS,EAAE,QAAQ,EAAE;AAC5E;AAEO,SAAS,aAAa,QAAuC;AAClE,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,iBAAiB,OAAO,IAAI;AACvE;","names":[]}
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;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ACF;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAIiC;AAC/B,SAAO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,YAAY,qBAAqB,OAAO;AAAA,EACrD;AACF;AAEO,SAAS,mBAAmB,SAAiD;AAClF,SAAO,EAAE,MAAM,gBAAgB,sBAAsB,SAAS,EAAE,QAAQ,EAAE;AAC5E;AAEO,SAAS,aAAa,QAAuC;AAClE,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,iBAAiB,OAAO,IAAI;AACvE;","names":[]}
@@ -35,19 +35,14 @@ __export(makeswift_api_client_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(makeswift_api_client_exports);
37
37
  var import_toolkit = require("@reduxjs/toolkit");
38
- var import_site_version = require("../api/site-version");
39
- var SiteVersionState = __toESM(require("./modules/site-version"));
40
- var LocaleState = __toESM(require("./modules/locale"));
41
38
  var APIResources = __toESM(require("./modules/api-resources"));
42
39
  var LocalizedResourcesMap = __toESM(require("./modules/localized-resources-map"));
43
40
  var import_actions = require("./actions");
44
- var import_read_only_actions = require("./actions/internal/read-only-actions");
41
+ var import_internal = require("./actions/internal");
45
42
  var import_host_api = require("./host-api");
46
43
  var import_toolkit2 = require("./toolkit");
47
44
  var import_api = require("../api");
48
45
  const reducer = (0, import_toolkit.combineReducers)({
49
- siteVersion: SiteVersionState.reducer,
50
- locale: LocaleState.reducer,
51
46
  apiResources: APIResources.reducer,
52
47
  localizedResourcesMap: LocalizedResourcesMap.reducer
53
48
  });
@@ -85,11 +80,10 @@ function getAPIResource(state, resourceType, resourceId, locale) {
85
80
  }
86
81
  }
87
82
  function fetchAPIResource(resourceType, resourceId, fetch, locale) {
88
- const fetchVersioned = async (url, version) => {
83
+ const fetchJson = async (url) => {
89
84
  const response = await fetch(url, {
90
85
  headers: {
91
- "Content-Type": "application/json",
92
- ...version != null ? { [import_site_version.ApiHandlerHeaders.SiteVersion]: (0, import_site_version.serializeSiteVersion)(version) } : {}
86
+ "Content-Type": "application/json"
93
87
  }
94
88
  });
95
89
  if (response.status === 404)
@@ -105,29 +99,22 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
105
99
  };
106
100
  return async (dispatch, getState) => {
107
101
  const state = getState();
108
- const version = SiteVersionState.getSiteVersion(state.siteVersion);
109
102
  if (getHasAPIResource(state, resourceType, resourceId, locale)) {
110
103
  return getAPIResource(state, resourceType, resourceId, locale);
111
104
  }
112
105
  let resource;
113
106
  switch (resourceType) {
114
107
  case import_api.APIResourceType.Swatch:
115
- resource = await fetchVersioned(`/api/makeswift/swatches/${resourceId}`, version);
108
+ resource = await fetchJson(`/api/makeswift/swatches/${resourceId}`);
116
109
  break;
117
110
  case import_api.APIResourceType.File:
118
- resource = await fetchVersioned(`/api/makeswift/files/${resourceId}`, version);
111
+ resource = await fetchJson(`/api/makeswift/files/${resourceId}`);
119
112
  break;
120
113
  case import_api.APIResourceType.Typography:
121
- resource = await fetchVersioned(
122
- `/api/makeswift/typographies/${resourceId}`,
123
- version
124
- );
114
+ resource = await fetchJson(`/api/makeswift/typographies/${resourceId}`);
125
115
  break;
126
116
  case import_api.APIResourceType.GlobalElement:
127
- resource = await fetchVersioned(
128
- `/api/makeswift/global-elements/${resourceId}`,
129
- version
130
- );
117
+ resource = await fetchJson(`/api/makeswift/global-elements/${resourceId}`);
131
118
  break;
132
119
  case import_api.APIResourceType.LocalizedGlobalElement: {
133
120
  if (locale == null)
@@ -135,9 +122,8 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
135
122
  if (getLocalizedResourceId(state, locale, resourceId) === null) {
136
123
  return null;
137
124
  }
138
- resource = await fetchVersioned(
139
- `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,
140
- version
125
+ resource = await fetchJson(
126
+ `/api/makeswift/localized-global-elements/${resourceId}/${locale}`
141
127
  );
142
128
  dispatch(
143
129
  (0, import_host_api.setLocalizedResourceId)({
@@ -152,21 +138,21 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
152
138
  const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, "http://n");
153
139
  if (locale != null)
154
140
  url.searchParams.set("locale", locale);
155
- resource = await fetchVersioned(url.pathname + url.search, version);
141
+ resource = await fetchJson(url.pathname + url.search);
156
142
  break;
157
143
  }
158
144
  case import_api.APIResourceType.Table:
159
- resource = await fetchVersioned(`/api/makeswift/tables/${resourceId}`, version);
145
+ resource = await fetchJson(`/api/makeswift/tables/${resourceId}`);
160
146
  break;
161
147
  default:
162
148
  resource = null;
163
149
  }
164
- dispatch((0, import_read_only_actions.apiResourceFulfilled)(resourceType, resourceId, resource, locale));
150
+ dispatch((0, import_internal.apiResourceFulfilled)(resourceType, resourceId, resource, locale));
165
151
  return resource;
166
152
  };
167
153
  }
168
- function defaultLocaleMiddleware() {
169
- return (0, import_toolkit2.actionMiddleware)(({ getState }) => (next) => {
154
+ function defaultLocaleMiddleware(defaultLocale) {
155
+ return (0, import_toolkit2.actionMiddleware)(() => (next) => {
170
156
  return (action) => {
171
157
  switch (action.type) {
172
158
  case import_actions.ActionTypes.CHANGE_API_RESOURCE:
@@ -175,10 +161,7 @@ function defaultLocaleMiddleware() {
175
161
  const { locale } = action.payload;
176
162
  return next({
177
163
  ...action,
178
- payload: {
179
- ...action.payload,
180
- locale: locale ?? LocaleState.getLocale(getState().locale)
181
- }
164
+ payload: { ...action.payload, locale: locale ?? defaultLocale }
182
165
  });
183
166
  }
184
167
  }
@@ -186,7 +169,10 @@ function defaultLocaleMiddleware() {
186
169
  };
187
170
  });
188
171
  }
189
- function configureStore({ serializedState }) {
172
+ function configureStore({
173
+ defaultLocale,
174
+ serializedState
175
+ }) {
190
176
  return (0, import_toolkit.configureStore)({
191
177
  reducer,
192
178
  preloadedState: {
@@ -195,7 +181,7 @@ function configureStore({ serializedState }) {
195
181
  serializedState?.localizedResourcesMap
196
182
  )
197
183
  },
198
- middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware()),
184
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),
199
185
  devTools: (0, import_toolkit2.devToolsConfig)({
200
186
  name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
201
187
  actionsDenylist: [
@@ -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 { type SiteVersion, ApiHandlerHeaders, serializeSiteVersion } from '../api/site-version'\n\nimport * as SiteVersionState from './modules/site-version'\nimport * as LocaleState from './modules/locale'\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\n\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal/read-only-actions'\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 siteVersion: SiteVersionState.reducer,\n locale: LocaleState.reducer,\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 fetchVersioned = async <T>(url: string, version: SiteVersion | null): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n ...(version != null\n ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) }\n : {}),\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 const version = SiteVersionState.getSiteVersion(state.siteVersion)\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 fetchVersioned<Swatch>(`/api/makeswift/swatches/${resourceId}`, version)\n break\n\n case APIResourceType.File:\n resource = await fetchVersioned<File>(`/api/makeswift/files/${resourceId}`, version)\n break\n\n case APIResourceType.Typography:\n resource = await fetchVersioned<Typography>(\n `/api/makeswift/typographies/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchVersioned<GlobalElement>(\n `/api/makeswift/global-elements/${resourceId}`,\n version,\n )\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 fetchVersioned<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n version,\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 fetchVersioned<PagePathnameSlice>(url.pathname + url.search, version)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchVersioned<Table>(`/api/makeswift/tables/${resourceId}`, version)\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(): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(({ getState }) => 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: {\n ...action.payload,\n locale: locale ?? LocaleState.getLocale(getState().locale),\n },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({ serializedState }: { serializedState?: SerializedState }) {\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()),\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,0BAA0E;AAE1E,uBAAkC;AAClC,kBAA6B;AAC7B,mBAA8B;AAC9B,4BAAuC;AAEvC,qBAAyC;AACzC,+BAAqC;AACrC,sBAAuC;AACvC,IAAAA,kBAAoE;AAEpE,iBAWO;AAEP,MAAM,cAAU,gCAAgB;AAAA,EAC9B,aAAa,iBAAiB;AAAA,EAC9B,QAAQ,YAAY;AAAA,EACpB,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAWD,SAAS,uBACP,OACA,QACA,YAC2B;AAC3B,SAAO,s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A,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,UAA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A,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"]}
@@ -38,9 +38,6 @@ module.exports = __toCommonJS(api_resources_exports);
38
38
  var import_api = require("../../api");
39
39
  var import_deepEqual = __toESM(require("../../utils/deepEqual"));
40
40
  var import_actions = require("../actions");
41
- var import_read_only_actions = require("../actions/internal/read-only-actions");
42
- var import_read_write_actions = require("../actions/internal/read-write-actions");
43
- var import_host_api = require("../host-api");
44
41
  function isValidAPIResourceType(resourceType) {
45
42
  return resourceType in import_api.APIResourceType;
46
43
  }
@@ -119,7 +116,7 @@ function reducer(state = getInitialState(), action) {
119
116
  if (!(0, import_actions.isKnownAction)(action))
120
117
  return state;
121
118
  switch (action.type) {
122
- case import_read_write_actions.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
119
+ case import_actions.ActionTypes.UPDATE_API_CLIENT_CACHE: {
123
120
  const { apiResources } = action.payload;
124
121
  return Object.entries(apiResources).reduce((state2, [resourceType, cachedResources]) => {
125
122
  const resType = resourceType;
@@ -132,7 +129,7 @@ function reducer(state = getInitialState(), action) {
132
129
  return updated == null || updated === existing ? state2 : new Map(state2).set(resType, updated);
133
130
  }, state);
134
131
  }
135
- case import_read_only_actions.ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {
132
+ case import_actions.ActionTypes.API_RESOURCE_FULFILLED: {
136
133
  const { resourceType, resourceId, resource, locale } = action.payload;
137
134
  return new Map(state).set(
138
135
  resourceType,
@@ -142,7 +139,7 @@ function reducer(state = getInitialState(), action) {
142
139
  )
143
140
  );
144
141
  }
145
- case import_host_api.HostActionTypes.CHANGE_API_RESOURCE: {
142
+ case import_actions.ActionTypes.CHANGE_API_RESOURCE: {
146
143
  const { resource, locale } = action.payload;
147
144
  const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale);
148
145
  if ((0, import_deepEqual.default)(existingApiResource, resource))
@@ -155,7 +152,7 @@ function reducer(state = getInitialState(), action) {
155
152
  )
156
153
  );
157
154
  }
158
- case import_host_api.HostActionTypes.EVICT_API_RESOURCE: {
155
+ case import_actions.ActionTypes.EVICT_API_RESOURCE: {
159
156
  const { id, locale } = action.payload;
160
157
  const [resourceType, resourceId] = id.split(":");
161
158
  if (!isValidAPIResourceType(resourceType))
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\nimport { HostActionTypes } from '../host-api'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\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 const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return r.get(cid) != null ? r : new Map(r).set(cid, value)\n }, existing)\n\n return updated == null || updated === existing\n ? state\n : new Map(state).set(resType, updated)\n }, state)\n }\n\n case ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,qBAA+D;AAC/D,+BAAoC;AACpC,gCAAqC;AACrC,sBAAgC;AAIhC,SAAS,uBAAuB,cAAuD;AACrF,SAAO,gBAAgB;AACzB;AAEA,SAAS,6BACP,cAC4C;AAC5C,SAAO,gBAAgB;AACzB;AAEA,SAAS,YACP,YACA,cACA,QACqB;AACrB,SACE,UAAU,QAAQ,6BAA6B,YAAY,IACvD,GAAG,UAAU,IAAI,MAAM,KACvB;AAER;AAEA,SAAS,iBAAiBA,cAA2D;AACnF,QAAM,CAAC,YAAY,MAAM,IAAIA,aAAY,MAAM,GAAG;AAClD,SAAO,CAAC,YAAY,UAAU,IAAI;AACpC;AAYO,SAAS,gBACd,kBAAmC;AAAA,EACjC,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,mBAAmB,CAAC;AAAA,EACpB,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,wBAAwB,CAAC;AAC3B,GACO;AACP,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,eAAe,EAAE,IAAI,CAAC,CAAC,cAAc,SAAS,MAAM;AAAA,MACjE;AAAA,MACA,IAAI;AAAA,QACF,UAAU,IAAI,CAAC,EAAE,IAAI,OAAO,OAAO,MAAM;AAAA,UACvC,YAAY,IAAI,cAAiC,MAAM;AAAA,UACvD;AAAA,QACF,CAAC;AAAA,MACH;AAAA,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AAE;AAAA,UACvC,YAAY,SAAS,IAAI,SAAS,YAAY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,gCAAgB,oBAAoB;AACvC,YAAM,EAAE,IAAI,OAAO,IAAI,OAAO;AAC9B,YAAM,CAAC,cAAc,UAAU,IAAI,GAAG,MAAM,GAAG;AAE/C,UAAI,CAAC,uBAAuB,YAAY;AAAG,eAAO;AAElD,YAAM,YAAY,IAAI,IAAI,MAAM,IAAI,YAA+B,CAAE;AAErE,YAAM,UAAU,UAAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\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 const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return r.get(cid) != null ? r : new Map(r).set(cid, value)\n }, existing)\n\n return updated == null || updated === existing\n ? state\n : new Map(state).set(resType, updated)\n }, state)\n }\n\n case ActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case ActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,qBA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AAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
@@ -31,9 +31,7 @@ __export(box_models_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(box_models_exports);
33
33
  var import_css_box_model = require("css-box-model");
34
- var import_actions = require("../../actions");
35
- var import_read_write_actions = require("../../actions/internal/read-write-actions");
36
- var import_actions2 = require("../../builder-api/actions");
34
+ var import_actions = require("../actions");
37
35
  function parse(rawString) {
38
36
  const value = Number(rawString.replace(/px$/, ""));
39
37
  return Number.isFinite(value) ? value : 0;
@@ -73,7 +71,7 @@ function reducer(state = getInitialState(), action) {
73
71
  if (!(0, import_actions.isKnownAction)(action))
74
72
  return state;
75
73
  switch (action.type) {
76
- case import_read_write_actions.ReadWriteActionTypes.REGISTER_MEASURABLE: {
74
+ case import_actions.ActionTypes.REGISTER_MEASURABLE: {
77
75
  const { documentKey, elementKey, measurable } = action.payload;
78
76
  return {
79
77
  ...state,
@@ -83,13 +81,13 @@ function reducer(state = getInitialState(), action) {
83
81
  )
84
82
  };
85
83
  }
86
- case import_read_write_actions.ReadWriteActionTypes.UNREGISTER_MEASURABLE: {
84
+ case import_actions.ActionTypes.UNREGISTER_MEASURABLE: {
87
85
  const { documentKey, elementKey } = action.payload;
88
86
  const nextMeasurables = new Map(state.measurables.get(documentKey) ?? []);
89
87
  const deleted = nextMeasurables.delete(elementKey);
90
88
  return deleted ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) } : state;
91
89
  }
92
- case import_actions2.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {
90
+ case import_actions.ActionTypes.CHANGE_ELEMENT_BOX_MODELS: {
93
91
  const { changedElementBoxModels } = action.payload;
94
92
  if (changedElementBoxModels.size === 0)
95
93
  return state;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/box-models.ts"],"sourcesContent":["import { type BoxModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport type { BoxModel }\n\nexport function parse(rawString: string): number {\n const value = Number(rawString.replace(/px$/, ''))\n\n return Number.isFinite(value) ? value : 0\n}\n\nexport function createBox(boxArgs: CreateBoxArgs): BoxModel {\n return withScroll(createBoxWithoutScroll(boxArgs))\n}\n\nexport function getBox(element: Element): BoxModel {\n return withScroll(getBoxWithoutScroll(element))\n}\n\nexport interface BoxModelHandle {\n getBoxModel(): BoxModel | null\n}\n\nexport type Measurable = Element | BoxModelHandle\n\nexport function isMeasurable(value: unknown): value is Measurable {\n if (value instanceof Element) return true\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getBoxModel' in value &&\n typeof (value as { getBoxModel: unknown }).getBoxModel === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport function measure(measurable: Measurable): BoxModel | null {\n if (measurable instanceof Element) return getBox(measurable)\n\n return measurable.getBoxModel()\n}\n\nexport type State = {\n measurables: Map<string, Map<string, Measurable>>\n boxModels: Map<string, Map<string, BoxModel>>\n}\n\nexport function getInitialState(): State {\n return { measurables: new Map(), boxModels: new Map() }\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, Measurable>> {\n return state.measurables\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModel>> {\n return state.boxModels\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModel | null {\n return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.REGISTER_MEASURABLE: {\n const { documentKey, elementKey, measurable } = action.payload\n\n return {\n ...state,\n measurables: new Map(state.measurables).set(\n documentKey,\n new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_MEASURABLE: {\n const { documentKey, elementKey } = action.payload\n const nextMeasurables = new Map(state.measurables.get(documentKey) ?? [])\n\n const deleted = nextMeasurables.delete(elementKey)\n\n return deleted\n ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) }\n : state\n }\n\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS: {\n const { changedElementBoxModels } = action.payload\n\n if (changedElementBoxModels.size === 0) return state\n\n const nextBoxModels = new Map(state.boxModels)\n\n changedElementBoxModels.forEach((changedBoxModels, documentKey) => {\n const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? [])\n\n changedBoxModels.forEach((changedBoxModel, elementKey) => {\n if (changedBoxModel == null) nextDocumentBoxModels.delete(elementKey)\n else nextDocumentBoxModels.set(elementKey, changedBoxModel)\n })\n\n if (nextDocumentBoxModels.size > 0) nextBoxModels.set(documentKey, nextDocumentBoxModels)\n else nextBoxModels.delete(documentKey)\n })\n\n return { ...state, boxModels: nextBoxModels }\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAKO;AAEP,qBAA4E;AAIrE,SAAS,MAAM,WAA2B;AAC/C,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,EAAE,CAAC;AAEjD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAEO,SAAS,UAAU,SAAkC;AAC1D,aAAO,qCAAW,qBAAAA,WAAuB,OAAO,CAAC;AACnD;AAEO,SAAS,OAAO,SAA4B;AACjD,aAAO,qCAAW,qBAAAC,QAAoB,OAAO,CAAC;AAChD;AAQO,SAAS,aAAa,OAAqC;AAChE,MAAI,iBAA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AAE,IACtF;AAAA,IACN;AAAA,IAEA,KAAK,2BAAY,2BAA2B;AAC1C,YAAM,EAAE,wBAAwB,IAAI,OAAO;AAE3C,UAAI,wBAAwB,SAAS;AAAG,eAAO;AAE/C,YAAM,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAE7C,8BAAwB,QAAQ,CAAC,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["createBoxWithoutScroll","getBoxWithoutScroll"]}
@@ -27,7 +27,6 @@ __export(breakpoints_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(breakpoints_exports);
29
29
  var import_actions = require("../actions");
30
- var import_actions2 = require("../builder-api/actions");
31
30
  var import_controls2 = require("@makeswift/controls");
32
31
  const DefaultBreakpointID = {
33
32
  Desktop: "desktop",
@@ -61,7 +60,7 @@ function reducer(state = getInitialState(), action) {
61
60
  if (!(0, import_actions.isKnownAction)(action))
62
61
  return state;
63
62
  switch (action.type) {
64
- case import_actions2.BuilderActionTypes.SET_BREAKPOINTS: {
63
+ case import_actions.ActionTypes.SET_BREAKPOINTS: {
65
64
  const breakpoints = action.payload.breakpoints;
66
65
  if (breakpoints.length === 0)
67
66
  throw new Error("Breakpoints cannot be empty.");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import { type Breakpoint, type Breakpoints } from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { BuilderActionTypes } from '../builder-api/actions'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = Breakpoints\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return breakpoints\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return breakpoints\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA+D;AAC/D,IAAAA,kBAAmC;AAEnC,IAAAC,mBAKO;AAIA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,I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F;AAEA,SAAO;AACT;AAEA,SAAS,yBAAyB,OAAyB;AACzD,MAAI,oBAAoB,WAAW,OAAO;AACxC,UAAM,IAAI;AAAA,MACR,uCAAuC,oBAAoB,OAAO;AAAA,IACpE;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_controls"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import { type Breakpoint, type Breakpoints } from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = Breakpoints\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return breakpoints\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return breakpoints\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA4E;AAE5E,IAAAA,mBAKO;AAIA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,SAAS,gBAAgB,cAAc,qBAA4B;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GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_controls"]}
@@ -24,7 +24,6 @@ __export(builder_edit_mode_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(builder_edit_mode_exports);
26
26
  var import_actions = require("../actions");
27
- var import_host_api = require("../host-api");
28
27
  const BuilderEditMode = {
29
28
  BUILD: "build",
30
29
  CONTENT: "content",
@@ -37,7 +36,7 @@ function reducer(state = getInitialState(), action) {
37
36
  if (!(0, import_actions.isKnownAction)(action))
38
37
  return state;
39
38
  switch (action.type) {
40
- case import_host_api.HostActionTypes.SET_BUILDER_EDIT_MODE:
39
+ case import_actions.ActionTypes.SET_BUILDER_EDIT_MODE:
41
40
  return action.payload.editMode;
42
41
  default:
43
42
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/builder-edit-mode.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { HostActionTypes } from '../host-api'\n\nexport const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n INTERACT: 'interact',\n} as const\n\nexport type BuilderEditMode = (typeof BuilderEditMode)[keyof typeof BuilderEditMode]\n\nexport type State = BuilderEditMode | null\n\nexport function getInitialState(): State {\n return null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n return action.payload.editMode\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,sBAAgC;AAEzB,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AACZ;AAMO,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,gCAAgB;AACnB,aAAO,OAAO,QAAQ;AAAA,IAExB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/builder-edit-mode.ts"],"sourcesContent":["import { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n INTERACT: 'interact',\n} as const\n\nexport type BuilderEditMode = (typeof BuilderEditMode)[keyof typeof BuilderEditMode]\n\nexport type State = BuilderEditMode | null\n\nexport function getInitialState(): State {\n return null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.SET_BUILDER_EDIT_MODE:\n return action.payload.editMode\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA4E;AAErE,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AACZ;AAMO,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,2BAAY;AACf,aAAO,OAAO,QAAQ;AAAA,IAExB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}