@makeswift/runtime 0.26.4-canary.0 → 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 (534) hide show
  1. package/dist/cjs/api/{client.js → react.js} +4 -4
  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/tests/controls/color-control/fixtures.js.map +1 -1
  22. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  23. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  24. package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  25. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +2 -1
  26. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  27. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  28. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  29. package/dist/cjs/next/testing/element-data.js +3 -3
  30. package/dist/cjs/next/testing/element-data.js.map +1 -1
  31. package/dist/cjs/next/testing/index.js +0 -2
  32. package/dist/cjs/next/testing/index.js.map +1 -1
  33. package/dist/cjs/next/testing/page-rendering.js +3 -3
  34. package/dist/cjs/next/testing/page-rendering.js.map +1 -1
  35. package/dist/cjs/prop-controllers/descriptors.js.map +1 -1
  36. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  37. package/dist/cjs/runtimes/react/components/Document.js +2 -2
  38. package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
  39. package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
  40. package/dist/cjs/runtimes/react/components/Element.js +2 -2
  41. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  42. package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
  43. package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
  44. package/dist/cjs/runtimes/react/components/ElementRegistration.js +2 -2
  45. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  46. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
  47. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  48. package/dist/cjs/runtimes/react/components/RuntimeProvider.js +3 -3
  49. package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
  50. package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
  51. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +3 -2
  52. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  53. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  54. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  55. package/dist/cjs/runtimes/react/controls.js +2 -2
  56. package/dist/cjs/runtimes/react/controls.js.map +1 -1
  57. package/dist/cjs/runtimes/react/element-imperative-handle.js +1 -1
  58. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  59. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js +2 -2
  60. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  61. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js +2 -2
  62. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  63. package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
  64. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  65. package/dist/cjs/runtimes/react/hooks/use-component.js +3 -3
  66. package/dist/cjs/runtimes/react/hooks/use-component.js.map +1 -1
  67. package/dist/cjs/runtimes/react/hooks/use-dispatch.js.map +1 -1
  68. package/dist/cjs/runtimes/react/hooks/use-document.js +2 -2
  69. package/dist/cjs/runtimes/react/hooks/use-document.js.map +1 -1
  70. package/dist/cjs/runtimes/react/hooks/use-element-id.js +2 -2
  71. package/dist/cjs/runtimes/react/hooks/use-element-id.js.map +1 -1
  72. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js +2 -2
  73. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  74. package/dist/cjs/runtimes/react/hooks/{use-is-read-only.js → use-is-preview.js} +9 -9
  75. package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
  76. package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
  77. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +2 -2
  78. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  79. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +1 -1
  80. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  81. package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
  82. package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
  83. package/dist/cjs/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  84. package/dist/cjs/runtimes/react/host-api-client.js +2 -2
  85. package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
  86. package/dist/cjs/runtimes/react/index.js +3 -3
  87. package/dist/cjs/runtimes/react/index.js.map +1 -1
  88. package/dist/cjs/runtimes/react/poll-box-model.js +1 -1
  89. package/dist/cjs/runtimes/react/poll-box-model.js.map +1 -1
  90. package/dist/cjs/runtimes/react/react-runtime-core.js +3 -3
  91. package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
  92. package/dist/cjs/runtimes/react/runtime-core.js +2 -4
  93. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  94. package/dist/cjs/runtimes/react/utils/can-accept-ref.js.map +1 -1
  95. package/dist/cjs/state/actions/{internal/read-only-actions.js → internal.js} +62 -30
  96. package/dist/cjs/state/actions/internal.js.map +1 -0
  97. package/dist/cjs/state/builder-api/actions.js +8 -11
  98. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  99. package/dist/cjs/state/host-api.js.map +1 -1
  100. package/dist/cjs/state/makeswift-api-client.js +2 -2
  101. package/dist/cjs/state/makeswift-api-client.js.map +1 -1
  102. package/dist/cjs/state/modules/api-resources.js +4 -7
  103. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  104. package/dist/cjs/state/modules/{read-write/box-models.js → box-models.js} +4 -6
  105. package/dist/cjs/state/modules/box-models.js.map +1 -0
  106. package/dist/cjs/state/modules/breakpoints.js +1 -2
  107. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  108. package/dist/cjs/state/modules/builder-edit-mode.js +1 -2
  109. package/dist/cjs/state/modules/builder-edit-mode.js.map +1 -1
  110. package/dist/cjs/state/modules/components-meta.js +2 -3
  111. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  112. package/dist/cjs/state/modules/{read-write/element-imperative-handles.js → element-imperative-handles.js} +3 -4
  113. package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
  114. package/dist/cjs/state/modules/element-trees.js +3 -5
  115. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  116. package/dist/cjs/state/modules/is-in-builder.js +1 -2
  117. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  118. package/dist/cjs/state/modules/{is-read-only.js → is-preview.js} +9 -12
  119. package/dist/cjs/state/modules/is-preview.js.map +1 -0
  120. package/dist/cjs/state/modules/localized-resources-map.js +2 -4
  121. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  122. package/dist/cjs/state/modules/{read-write/pointer.js → pointer.js} +2 -3
  123. package/dist/cjs/state/modules/pointer.js.map +1 -0
  124. package/dist/cjs/state/modules/prop-controllers.js +2 -3
  125. package/dist/cjs/state/modules/prop-controllers.js.map +1 -1
  126. package/dist/cjs/state/modules/react-components.js +2 -3
  127. package/dist/cjs/state/modules/react-components.js.map +1 -1
  128. package/dist/cjs/state/modules/read-only-documents.js +2 -3
  129. package/dist/cjs/state/modules/read-only-documents.js.map +1 -1
  130. package/dist/cjs/state/modules/{read-write/read-write-documents.js → read-write-documents.js} +3 -3
  131. package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
  132. package/dist/cjs/state/react-builder-preview.js +508 -18
  133. package/dist/cjs/state/react-builder-preview.js.map +1 -1
  134. package/dist/cjs/state/react-page.js +250 -6
  135. package/dist/cjs/state/react-page.js.map +1 -1
  136. package/dist/cjs/state/shared-api.js.map +1 -1
  137. package/dist/cjs/state/translations/get.js +2 -2
  138. package/dist/cjs/state/translations/get.js.map +1 -1
  139. package/dist/cjs/state/translations/merge.js +2 -2
  140. package/dist/cjs/state/translations/merge.js.map +1 -1
  141. package/dist/esm/api/{client.js → react.js} +1 -1
  142. package/dist/esm/api/react.js.map +1 -0
  143. package/dist/esm/api-handler/handlers/element-tree.js.map +1 -1
  144. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  145. package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -1
  146. package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -1
  147. package/dist/esm/builder/host-to-builder-actions.js +4 -4
  148. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  149. package/dist/esm/builder/index.js +1 -1
  150. package/dist/esm/builder/index.js.map +1 -1
  151. package/dist/esm/client/index.js +5 -5
  152. package/dist/esm/client/index.js.map +1 -1
  153. package/dist/esm/components/builtin/Box/Box.js +1 -1
  154. package/dist/esm/components/builtin/Box/Box.js.map +1 -1
  155. package/dist/esm/components/builtin/Form/Form.js +1 -1
  156. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  157. package/dist/esm/components/hooks/useTableFormFieldRefs.js +1 -1
  158. package/dist/esm/components/hooks/useTableFormFieldRefs.js.map +1 -1
  159. package/dist/esm/next/api-handler/config/app-router.js +10 -1
  160. package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
  161. package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  162. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  163. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  164. package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  165. package/dist/esm/next/components/tests/makeswift-component/fixtures.js +2 -1
  166. package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  167. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  168. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  169. package/dist/esm/next/testing/element-data.js +1 -1
  170. package/dist/esm/next/testing/element-data.js.map +1 -1
  171. package/dist/esm/next/testing/index.js +0 -1
  172. package/dist/esm/next/testing/index.js.map +1 -1
  173. package/dist/esm/next/testing/page-rendering.js +3 -3
  174. package/dist/esm/next/testing/page-rendering.js.map +1 -1
  175. package/dist/esm/prop-controllers/descriptors.js.map +1 -1
  176. package/dist/esm/prop-controllers/instances.js.map +1 -1
  177. package/dist/esm/runtimes/react/components/Document.js +1 -1
  178. package/dist/esm/runtimes/react/components/Document.js.map +1 -1
  179. package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
  180. package/dist/esm/runtimes/react/components/Element.js +1 -3
  181. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  182. package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
  183. package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
  184. package/dist/esm/runtimes/react/components/ElementRegistration.js +1 -1
  185. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  186. package/dist/esm/runtimes/react/components/MakeswiftComponent.js +1 -1
  187. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  188. package/dist/esm/runtimes/react/components/RuntimeProvider.js +2 -2
  189. package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
  190. package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
  191. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +3 -2
  192. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  193. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  194. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  195. package/dist/esm/runtimes/react/controls.js +2 -2
  196. package/dist/esm/runtimes/react/controls.js.map +1 -1
  197. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  198. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  199. package/dist/esm/runtimes/react/hooks/use-breakpoints.js +1 -1
  200. package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  201. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js +1 -1
  202. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  203. package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
  204. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  205. package/dist/esm/runtimes/react/hooks/use-component.js +1 -1
  206. package/dist/esm/runtimes/react/hooks/use-component.js.map +1 -1
  207. package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +1 -1
  208. package/dist/esm/runtimes/react/hooks/use-document.js +1 -1
  209. package/dist/esm/runtimes/react/hooks/use-document.js.map +1 -1
  210. package/dist/esm/runtimes/react/hooks/use-element-id.js +1 -1
  211. package/dist/esm/runtimes/react/hooks/use-element-id.js.map +1 -1
  212. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js +1 -1
  213. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  214. package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
  215. package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
  216. package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
  217. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +2 -2
  218. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  219. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +1 -1
  220. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  221. package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
  222. package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
  223. package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  224. package/dist/esm/runtimes/react/host-api-client.js +1 -1
  225. package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
  226. package/dist/esm/runtimes/react/index.js +2 -2
  227. package/dist/esm/runtimes/react/index.js.map +1 -1
  228. package/dist/esm/runtimes/react/poll-box-model.js +1 -1
  229. package/dist/esm/runtimes/react/poll-box-model.js.map +1 -1
  230. package/dist/esm/runtimes/react/react-runtime-core.js +1 -4
  231. package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
  232. package/dist/esm/runtimes/react/runtime-core.js +5 -3
  233. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  234. package/dist/esm/runtimes/react/utils/can-accept-ref.js.map +1 -1
  235. package/dist/esm/state/actions/{internal/read-only-actions.js → internal.js} +52 -24
  236. package/dist/esm/state/actions/internal.js.map +1 -0
  237. package/dist/esm/state/builder-api/actions.js +7 -8
  238. package/dist/esm/state/builder-api/actions.js.map +1 -1
  239. package/dist/esm/state/host-api.js.map +1 -1
  240. package/dist/esm/state/makeswift-api-client.js +1 -1
  241. package/dist/esm/state/makeswift-api-client.js.map +1 -1
  242. package/dist/esm/state/modules/api-resources.js +5 -8
  243. package/dist/esm/state/modules/api-resources.js.map +1 -1
  244. package/dist/esm/state/modules/{read-write/box-models.js → box-models.js} +4 -6
  245. package/dist/esm/state/modules/box-models.js.map +1 -0
  246. package/dist/esm/state/modules/breakpoints.js +2 -3
  247. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  248. package/dist/esm/state/modules/builder-edit-mode.js +2 -3
  249. package/dist/esm/state/modules/builder-edit-mode.js.map +1 -1
  250. package/dist/esm/state/modules/components-meta.js +3 -4
  251. package/dist/esm/state/modules/components-meta.js.map +1 -1
  252. package/dist/esm/state/modules/{read-write/element-imperative-handles.js → element-imperative-handles.js} +3 -4
  253. package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
  254. package/dist/esm/state/modules/element-trees.js +4 -6
  255. package/dist/esm/state/modules/element-trees.js.map +1 -1
  256. package/dist/esm/state/modules/is-in-builder.js +2 -3
  257. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  258. package/dist/esm/state/modules/is-preview.js +21 -0
  259. package/dist/esm/state/modules/is-preview.js.map +1 -0
  260. package/dist/esm/state/modules/localized-resources-map.js +3 -5
  261. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  262. package/dist/esm/state/modules/{read-write/pointer.js → pointer.js} +2 -3
  263. package/dist/esm/state/modules/pointer.js.map +1 -0
  264. package/dist/esm/state/modules/prop-controllers.js +3 -4
  265. package/dist/esm/state/modules/prop-controllers.js.map +1 -1
  266. package/dist/esm/state/modules/react-components.js +3 -4
  267. package/dist/esm/state/modules/react-components.js.map +1 -1
  268. package/dist/esm/state/modules/read-only-documents.js +6 -4
  269. package/dist/esm/state/modules/read-only-documents.js.map +1 -1
  270. package/dist/esm/state/modules/{read-write/read-write-documents.js → read-write-documents.js} +3 -3
  271. package/dist/esm/state/modules/read-write-documents.js.map +1 -0
  272. package/dist/esm/state/react-builder-preview.js +500 -15
  273. package/dist/esm/state/react-builder-preview.js.map +1 -1
  274. package/dist/esm/state/react-page.js +240 -7
  275. package/dist/esm/state/react-page.js.map +1 -1
  276. package/dist/esm/state/shared-api.js.map +1 -1
  277. package/dist/esm/state/translations/get.js +1 -1
  278. package/dist/esm/state/translations/get.js.map +1 -1
  279. package/dist/esm/state/translations/merge.js +1 -1
  280. package/dist/esm/state/translations/merge.js.map +1 -1
  281. package/dist/types/api/{client.d.ts → react.d.ts} +1 -1
  282. package/dist/types/api/react.d.ts.map +1 -0
  283. package/dist/types/api-handler/handlers/element-tree.d.ts +1 -1
  284. package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -1
  285. package/dist/types/api-handler/handlers/merge-translated-data.d.ts +1 -1
  286. package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -1
  287. package/dist/types/api-handler/handlers/translatable-data.d.ts +1 -1
  288. package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -1
  289. package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
  290. package/dist/types/builder/host-to-builder-actions.d.ts +2 -2
  291. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  292. package/dist/types/builder/index.d.ts +2 -2
  293. package/dist/types/builder/index.d.ts.map +1 -1
  294. package/dist/types/client/index.d.ts +2 -2
  295. package/dist/types/client/index.d.ts.map +1 -1
  296. package/dist/types/components/builtin/Box/Box.d.ts +1 -1
  297. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  298. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  299. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  300. package/dist/types/locale.d.ts +1 -1
  301. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
  302. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
  303. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  304. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +3 -3
  305. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  306. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
  307. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  308. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +1 -1
  309. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -1
  310. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts +1 -1
  311. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts.map +1 -1
  312. package/dist/types/next/testing/element-data.d.ts +1 -1
  313. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  314. package/dist/types/next/testing/index.d.ts +0 -1
  315. package/dist/types/next/testing/index.d.ts.map +1 -1
  316. package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
  317. package/dist/types/prop-controllers/descriptors.d.ts +1 -1
  318. package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
  319. package/dist/types/prop-controllers/instances.d.ts +1 -1
  320. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  321. package/dist/types/runtimes/react/components/Document.d.ts +1 -1
  322. package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
  323. package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
  324. package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
  325. package/dist/types/runtimes/react/components/Element.d.ts +1 -1
  326. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  327. package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
  328. package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
  329. package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
  330. package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
  331. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +1 -1
  332. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
  333. package/dist/types/runtimes/react/components/page/Page.d.ts +1 -1
  334. package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
  335. package/dist/types/runtimes/react/controls.d.ts +2 -2
  336. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  337. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  338. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  339. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
  340. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
  341. package/dist/types/runtimes/react/hooks/use-component.d.ts +1 -1
  342. package/dist/types/runtimes/react/hooks/use-component.d.ts.map +1 -1
  343. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts +3 -3
  344. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts.map +1 -1
  345. package/dist/types/runtimes/react/hooks/use-document.d.ts +1 -1
  346. package/dist/types/runtimes/react/hooks/use-document.d.ts.map +1 -1
  347. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
  348. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
  349. package/dist/types/runtimes/react/hooks/use-register-document.d.ts +1 -1
  350. package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
  351. package/dist/types/runtimes/react/hooks/use-selector.d.ts +3 -3
  352. package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
  353. package/dist/types/runtimes/react/hooks/use-store.d.ts +4 -4
  354. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  355. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts +1 -1
  356. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts.map +1 -1
  357. package/dist/types/runtimes/react/host-api-client.d.ts +1 -1
  358. package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
  359. package/dist/types/runtimes/react/index.d.ts +1 -1
  360. package/dist/types/runtimes/react/index.d.ts.map +1 -1
  361. package/dist/types/runtimes/react/poll-box-model.d.ts +1 -1
  362. package/dist/types/runtimes/react/poll-box-model.d.ts.map +1 -1
  363. package/dist/types/runtimes/react/react-runtime-core.d.ts +1 -1
  364. package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
  365. package/dist/types/runtimes/react/runtime-core.d.ts +1 -2
  366. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  367. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts +1 -1
  368. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts.map +1 -1
  369. package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
  370. package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
  371. package/dist/types/state/actions/index.d.ts +5 -6
  372. package/dist/types/state/actions/index.d.ts.map +1 -1
  373. package/dist/types/state/actions/{internal/read-only-actions.d.ts → internal.d.ts} +67 -33
  374. package/dist/types/state/actions/internal.d.ts.map +1 -0
  375. package/dist/types/state/builder-api/actions.d.ts +14 -14
  376. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  377. package/dist/types/state/host-api.d.ts +1 -1
  378. package/dist/types/state/host-api.d.ts.map +1 -1
  379. package/dist/types/state/modules/api-resources.d.ts.map +1 -1
  380. package/dist/types/state/modules/{read-write/box-models.d.ts → box-models.d.ts} +1 -1
  381. package/dist/types/state/modules/box-models.d.ts.map +1 -0
  382. package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
  383. package/dist/types/state/modules/builder-edit-mode.d.ts.map +1 -1
  384. package/dist/types/state/modules/components-meta.d.ts.map +1 -1
  385. package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
  386. package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
  387. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  388. package/dist/types/state/modules/is-in-builder.d.ts.map +1 -1
  389. package/dist/types/state/modules/{is-read-only.d.ts → is-preview.d.ts} +3 -3
  390. package/dist/types/state/modules/is-preview.d.ts.map +1 -0
  391. package/dist/types/state/modules/localized-resources-map.d.ts.map +1 -1
  392. package/dist/types/state/modules/{read-write/pointer.d.ts → pointer.d.ts} +3 -2
  393. package/dist/types/state/modules/pointer.d.ts.map +1 -0
  394. package/dist/types/state/modules/prop-controllers.d.ts.map +1 -1
  395. package/dist/types/state/modules/react-components.d.ts.map +1 -1
  396. package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
  397. package/dist/types/state/modules/{read-write/read-write-documents.d.ts → read-write-documents.d.ts} +4 -4
  398. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
  399. package/dist/types/state/react-builder-preview.d.ts +93 -26
  400. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  401. package/dist/types/state/react-page.d.ts +136 -20
  402. package/dist/types/state/react-page.d.ts.map +1 -1
  403. package/dist/types/state/shared-api.d.ts.map +1 -1
  404. package/dist/types/state/translations/get.d.ts +1 -1
  405. package/dist/types/state/translations/get.d.ts.map +1 -1
  406. package/dist/types/state/translations/merge.d.ts +1 -1
  407. package/dist/types/state/translations/merge.d.ts.map +1 -1
  408. package/package.json +3 -3
  409. package/dist/cjs/api/client.js.map +0 -1
  410. package/dist/cjs/next/testing/react-runtime.js +0 -29
  411. package/dist/cjs/next/testing/react-runtime.js.map +0 -1
  412. package/dist/cjs/runtimes/react/hooks/use-is-read-only.js.map +0 -1
  413. package/dist/cjs/runtimes/react/testing/react-runtime.js +0 -32
  414. package/dist/cjs/runtimes/react/testing/react-runtime.js.map +0 -1
  415. package/dist/cjs/state/actions/internal/index.js +0 -34
  416. package/dist/cjs/state/actions/internal/index.js.map +0 -1
  417. package/dist/cjs/state/actions/internal/read-only-actions.js.map +0 -1
  418. package/dist/cjs/state/actions/internal/read-write-actions.js +0 -70
  419. package/dist/cjs/state/actions/internal/read-write-actions.js.map +0 -1
  420. package/dist/cjs/state/middleware/prop-controller-handles.js +0 -114
  421. package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
  422. package/dist/cjs/state/middleware/read-only-element-tree.js +0 -52
  423. package/dist/cjs/state/middleware/read-only-element-tree.js.map +0 -1
  424. package/dist/cjs/state/middleware/read-write/builder-api/element-size.js +0 -40
  425. package/dist/cjs/state/middleware/read-write/builder-api/element-size.js.map +0 -1
  426. package/dist/cjs/state/middleware/read-write/builder-api/index.js +0 -76
  427. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +0 -1
  428. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +0 -278
  429. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +0 -1
  430. package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js +0 -37
  431. package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  432. package/dist/cjs/state/middleware/read-write/measure-box-models.js +0 -71
  433. package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +0 -1
  434. package/dist/cjs/state/middleware/read-write/update-element-tree.js +0 -59
  435. package/dist/cjs/state/middleware/read-write/update-element-tree.js.map +0 -1
  436. package/dist/cjs/state/modules/is-read-only.js.map +0 -1
  437. package/dist/cjs/state/modules/read-write/box-models.js.map +0 -1
  438. package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +0 -1
  439. package/dist/cjs/state/modules/read-write/pointer.js.map +0 -1
  440. package/dist/cjs/state/modules/read-write/read-write-documents.js.map +0 -1
  441. package/dist/cjs/state/ops/copy-element-tree.js +0 -67
  442. package/dist/cjs/state/ops/copy-element-tree.js.map +0 -1
  443. package/dist/cjs/state/ops/merge-element.js +0 -73
  444. package/dist/cjs/state/ops/merge-element.js.map +0 -1
  445. package/dist/cjs/state/read-only-state.js +0 -209
  446. package/dist/cjs/state/read-only-state.js.map +0 -1
  447. package/dist/cjs/state/read-write-state.js +0 -121
  448. package/dist/cjs/state/read-write-state.js.map +0 -1
  449. package/dist/esm/api/client.js.map +0 -1
  450. package/dist/esm/next/testing/react-runtime.js +0 -5
  451. package/dist/esm/next/testing/react-runtime.js.map +0 -1
  452. package/dist/esm/runtimes/react/hooks/use-is-read-only.js +0 -9
  453. package/dist/esm/runtimes/react/hooks/use-is-read-only.js.map +0 -1
  454. package/dist/esm/runtimes/react/testing/react-runtime.js +0 -8
  455. package/dist/esm/runtimes/react/testing/react-runtime.js.map +0 -1
  456. package/dist/esm/state/actions/internal/index.js +0 -10
  457. package/dist/esm/state/actions/internal/index.js.map +0 -1
  458. package/dist/esm/state/actions/internal/read-only-actions.js.map +0 -1
  459. package/dist/esm/state/actions/internal/read-write-actions.js +0 -41
  460. package/dist/esm/state/actions/internal/read-write-actions.js.map +0 -1
  461. package/dist/esm/state/middleware/prop-controller-handles.js +0 -80
  462. package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
  463. package/dist/esm/state/middleware/read-only-element-tree.js +0 -28
  464. package/dist/esm/state/middleware/read-only-element-tree.js.map +0 -1
  465. package/dist/esm/state/middleware/read-write/builder-api/element-size.js +0 -16
  466. package/dist/esm/state/middleware/read-write/builder-api/element-size.js.map +0 -1
  467. package/dist/esm/state/middleware/read-write/builder-api/index.js +0 -52
  468. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +0 -1
  469. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +0 -251
  470. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +0 -1
  471. package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js +0 -13
  472. package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  473. package/dist/esm/state/middleware/read-write/measure-box-models.js +0 -37
  474. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +0 -1
  475. package/dist/esm/state/middleware/read-write/update-element-tree.js +0 -35
  476. package/dist/esm/state/middleware/read-write/update-element-tree.js.map +0 -1
  477. package/dist/esm/state/modules/is-read-only.js +0 -24
  478. package/dist/esm/state/modules/is-read-only.js.map +0 -1
  479. package/dist/esm/state/modules/read-write/box-models.js.map +0 -1
  480. package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +0 -1
  481. package/dist/esm/state/modules/read-write/pointer.js.map +0 -1
  482. package/dist/esm/state/modules/read-write/read-write-documents.js.map +0 -1
  483. package/dist/esm/state/ops/copy-element-tree.js +0 -37
  484. package/dist/esm/state/ops/copy-element-tree.js.map +0 -1
  485. package/dist/esm/state/ops/merge-element.js +0 -39
  486. package/dist/esm/state/ops/merge-element.js.map +0 -1
  487. package/dist/esm/state/read-only-state.js +0 -157
  488. package/dist/esm/state/read-only-state.js.map +0 -1
  489. package/dist/esm/state/read-write-state.js +0 -76
  490. package/dist/esm/state/read-write-state.js.map +0 -1
  491. package/dist/types/api/client.d.ts.map +0 -1
  492. package/dist/types/next/testing/react-runtime.d.ts +0 -2
  493. package/dist/types/next/testing/react-runtime.d.ts.map +0 -1
  494. package/dist/types/runtimes/react/hooks/use-is-read-only.d.ts +0 -2
  495. package/dist/types/runtimes/react/hooks/use-is-read-only.d.ts.map +0 -1
  496. package/dist/types/runtimes/react/testing/react-runtime.d.ts +0 -3
  497. package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +0 -1
  498. package/dist/types/state/__tests__/merge-element.test.d.ts +0 -2
  499. package/dist/types/state/__tests__/merge-element.test.d.ts.map +0 -1
  500. package/dist/types/state/actions/internal/index.d.ts +0 -25
  501. package/dist/types/state/actions/internal/index.d.ts.map +0 -1
  502. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +0 -1
  503. package/dist/types/state/actions/internal/read-write-actions.d.ts +0 -48
  504. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +0 -1
  505. package/dist/types/state/middleware/prop-controller-handles.d.ts +0 -4
  506. package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
  507. package/dist/types/state/middleware/read-only-element-tree.d.ts +0 -4
  508. package/dist/types/state/middleware/read-only-element-tree.d.ts.map +0 -1
  509. package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts +0 -12
  510. package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts.map +0 -1
  511. package/dist/types/state/middleware/read-write/builder-api/index.d.ts +0 -5
  512. package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +0 -1
  513. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts +0 -6
  514. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +0 -1
  515. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
  516. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts.map +0 -1
  517. package/dist/types/state/middleware/read-write/measure-box-models.d.ts +0 -4
  518. package/dist/types/state/middleware/read-write/measure-box-models.d.ts.map +0 -1
  519. package/dist/types/state/middleware/read-write/update-element-tree.d.ts +0 -4
  520. package/dist/types/state/middleware/read-write/update-element-tree.d.ts.map +0 -1
  521. package/dist/types/state/modules/is-read-only.d.ts.map +0 -1
  522. package/dist/types/state/modules/read-write/box-models.d.ts.map +0 -1
  523. package/dist/types/state/modules/read-write/element-imperative-handles.d.ts +0 -6
  524. package/dist/types/state/modules/read-write/element-imperative-handles.d.ts.map +0 -1
  525. package/dist/types/state/modules/read-write/pointer.d.ts.map +0 -1
  526. package/dist/types/state/modules/read-write/read-write-documents.d.ts.map +0 -1
  527. package/dist/types/state/ops/copy-element-tree.d.ts +0 -37
  528. package/dist/types/state/ops/copy-element-tree.d.ts.map +0 -1
  529. package/dist/types/state/ops/merge-element.d.ts +0 -4
  530. package/dist/types/state/ops/merge-element.d.ts.map +0 -1
  531. package/dist/types/state/read-only-state.d.ts +0 -122
  532. package/dist/types/state/read-only-state.d.ts.map +0 -1
  533. package/dist/types/state/read-write-state.d.ts +0 -56
  534. package/dist/types/state/read-write-state.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type ComponentMeta } from '../modules/components-meta'\nimport { type BoxModel } from '../modules/read-write/box-models'\n\nimport { type ElementSize } from '../middleware/read-write/builder-api/element-size'\nimport { type DocumentPayload, type SharedAction, SharedActionTypes } from '../shared-api'\n\nexport * from '../shared-api'\n\n// actions dispatched by the host to the builder (\"Builder API\")\n// note that some of these actions, in addition to being dispatched to the builder,\n// might also be internally intercepted by the host as a part of maintaining the\n// runtime's \"read-write\" state\nexport const BuilderActionTypes = {\n ...SharedActionTypes,\n\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n HANDLE_HOST_NAVIGATE: 'HANDLE_HOST_NAVIGATE',\n} as const\n\ntype ActionWithTransferables<A> = A & {\n transferables?: Transferable[]\n}\n\ntype MakeswiftConnectionCheckAction = {\n type: typeof BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK\n payload: { currentUrl: string }\n}\n\ntype MountComponentAction = {\n type: typeof BuilderActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof BuilderActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: ElementSize }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype HandleWheelAction = {\n type: typeof BuilderActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof BuilderActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype HandleHostNavigateAction = {\n type: typeof BuilderActionTypes.HANDLE_HOST_NAVIGATE\n payload: { url: string | null }\n}\n\nexport type BuilderAction =\n | SharedAction\n | MakeswiftConnectionCheckAction\n | MountComponentAction\n | UnmountComponentAction\n | ChangeDocumentElementSizeAction\n | ChangeElementBoxModelsAction\n | MessageBuilderPropControllerAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | ElementFromPointChangeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | HandleHostNavigateAction\n\nexport function makeswiftConnectionCheck(\n payload: MakeswiftConnectionCheckAction['payload'],\n): MakeswiftConnectionCheckAction {\n return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function changeDocumentElementSize(size: ElementSize): ChangeDocumentElementSizeAction {\n return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return {\n type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,\n payload: { changedElementBoxModels },\n }\n}\n\nexport function messageBuilderPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageBuilderPropControllerAction<T> {\n return {\n type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: BuilderActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, BuilderAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerBuilderDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterBuilderDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): ActionWithTransferables<RegisterBuilderComponentAction> {\n return {\n type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nexport function hasTransferables<A extends BuilderAction>(\n action: A,\n): action is ActionWithTransferables<A> {\n return 'transferables' in action && Array.isArray(action.transferables)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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ACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,YAAY,UAAU,QAAQ;AAAA,EACxD;AACF;AAEO,SAAS,YAAY,SAAgE;AAC1F,SAAO,EAAE,MAAM,mBAAmB,cAAc,QAAQ;AAC1D;AAEO,SAAS,kBAAkB,SAGN;AAC1B,SAAO,EAAE,MAAM,mBAAmB,qBAAqB,QAAQ;AACjE;AAEO,SAAS,uBACd,MAI8B;AAC9B,SAAO,EAAE,MAAM,mBAAmB,2BAA2B,SAAS,EAAE,KAAK,EAAE;AACjF;AAEO,SAAS,wBAAwB,UAAmD;AACzF,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,0BAA0B,aAAsD;AAC9F,SAAO,EAAE,MAAM,mBAAmB,6BAA6B,SAAS,EAAE,YAAY,EAAE;AAC1F;AAEO,SAAS,+BACd,WAC0D;AAC1D,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,wBAAwB,QAAQ,CAAC,CAAC;AAEzE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,0BAA0B,SAAS,GAAG,CAAC,CAAC;AAAA,IACjF;AAAA,EACF;AACF;AAEO,SAAS,yBACd,SACA,eACyD;AACzD,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/builder-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SerializedControl } from '../../builder'\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\n\nimport { type Document } from '../modules/read-only-documents'\nimport { type 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,iBAAi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EO,SAAS,uBACd,MAI8B;AAC9B,SAAO,EAAE,MAAM,mBAAmB,2BAA2B,SAAS,EAAE,KAAK,EAAE;AACjF;AAEO,SAAS,wBAAwB,UAAmD;AACzF,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,0BAA0B,aAAsD;AAC9F,SAAO,EAAE,MAAM,mBAAmB,6BAA6B,SAAS,EAAE,YAAY,EAAE;AAC1F;AAEO,SAAS,+BACd,WAC0D;AAC1D,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,wBAAwB,QAAQ,CAAC,CAAC;AAEzE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,0BAA0B,SAAS,GAAG,CAAC,CAAC;AAAA,IACjF;AAAA,EACF;AACF;AAEO,SAAS,yBACd,SACA,eACyD;AACzD,SAAO;AAAA,IACL,MAAM,mBAAmB;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BACd,SACkC;AAClC,SAAO,EAAE,MAAM,mBAAmB,8BAA8B,QAAQ;AAC1E;AAEO,SAAS,iBACd,QACsC;AACtC,SAAO,mBAAmB,UAAU,MAAM,QAAQ,OAAO,aAAa;AACxE;","names":[]}
@@ -1 +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;AAAA,EAC7B,GAAG;AAAA,EAEH,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,iBAAiB;AAAA,EAEjB,oCAAoC;AAAA,EACpC,yBAAyB;AAAA,EAEzB,8BAA8B;AAAA,EAE9B,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EAEpB,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAE3B,sBAAsB;AACxB;AAkEO,SAAS,OAAmB;AACjC,SAAO,EAAE,MAAM,gBAAgB,KAAK;AACtC;AAEO,SAAS,UAAyB;AACvC,SAAO,EAAE,MAAM,gBAAgB,SAAS;AAC1C;AAEO,SAAS,eAAe,aAAqB,WAA4C;AAC9F,SAAO,EAAE,MAAM,gBAAgB,iBAAiB,SAAS,EAAE,aAAa,UAAU,EAAE;AACtF;AAEO,SAAS,+BACd,WACsC;AACtC,SAAO,EAAE,MAAM,gBAAgB,oCAAoC,SAAS,EAAE,UAAU,EAAE;AAC5F;AAEO,SAAS,sBAAsB,gBAAqD;AACzF,SAAO,EAAE,MAAM,gBAAgB,yBAAyB,SAAS,EAAE,eAAe,EAAE;AACtF;AAEO,SAAS,0BACd,aACA,YACA,UACA,SACoC;AACpC,SAAO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,aAAa,YAAY,UAAU,QAAQ;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,UACA,QACyB;AACzB,SAAO,EAAE,MAAM,gBAAgB,qBAAqB,SAAS,EAAE,UAAU,OAAO,EAAE;AACpF;AAEO,SAAS,iBAAiB,IAAY,QAAgD;AAC3F,SAAO,EAAE,MAAM,gBAAgB,oBAAoB,SAAS,EAAE,IAAI,OAAO,EAAE;AAC7E;AAEO,SAAS,mBAAmB,UAAqD;AACtF,SAAO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,SAAS;AAAA,EACtB;AACF;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":[]}
1
+ {"version":3,"sources":["../../../src/state/host-api.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\nimport { type Operation } from 'ot-json0'\n\nimport { type PropControllerMessage } from '../prop-controllers/instances'\nimport { type APIResource, APIResourceLocale } from '../api/types'\n\nimport { BuilderEditMode } from './modules/builder-edit-mode'\nimport { type Point } from './modules/pointer'\n\nimport { type SharedAction, SharedActionTypes } from './shared-api'\n\nexport const HostActionTypes = {\n ...SharedActionTypes,\n\n INIT: 'INIT',\n CLEAN_UP: 'CLEAN_UP',\n\n CHANGE_DOCUMENT: 'CHANGE_DOCUMENT',\n\n CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP: 'CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP',\n SCROLL_DOCUMENT_ELEMENT: 'SCROLL_DOCUMENT_ELEMENT',\n\n MESSAGE_HOST_PROP_CONTROLLER: 'MESSAGE_HOST_PROP_CONTROLLER',\n\n CHANGE_API_RESOURCE: 'CHANGE_API_RESOURCE',\n EVICT_API_RESOURCE: 'EVICT_API_RESOURCE',\n\n SET_BUILDER_EDIT_MODE: 'SET_BUILDER_EDIT_MODE',\n SET_LOCALIZED_RESOURCE_ID: 'SET_LOCALIZED_RESOURCE_ID',\n\n BUILDER_POINTER_MOVE: 'BUILDER_POINTER_MOVE',\n} as const\n\ntype InitAction = { type: typeof HostActionTypes.INIT }\n\ntype CleanUpAction = { type: typeof HostActionTypes.CLEAN_UP }\n\ntype ChangeDocumentAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT\n payload: { documentKey: string; operation: Operation }\n}\n\ntype ChangeDocumentElementScrollTopAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP\n payload: { scrollTop: number }\n}\n\ntype ScrollDocumentElementAction = {\n type: typeof HostActionTypes.SCROLL_DOCUMENT_ELEMENT\n payload: { scrollTopDelta: number }\n}\n\ntype MessageHostPropControllerAction<T = PropControllerMessage> = {\n type: typeof HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype ChangeAPIResourceAction = {\n type: typeof HostActionTypes.CHANGE_API_RESOURCE\n payload: { resource: APIResource; locale?: string | null }\n}\n\ntype EvictAPIResourceAction = {\n type: typeof HostActionTypes.EVICT_API_RESOURCE\n payload: { id: string; locale?: string | null }\n}\n\ntype SetBuilderEditModeAction = {\n type: typeof HostActionTypes.SET_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype SetLocalizedResourceIdAction = {\n type: typeof HostActionTypes.SET_LOCALIZED_RESOURCE_ID\n // TODO: make `locale` required once we've upgraded the builder to always provide it\n payload: { locale?: string; resourceId: string; localizedResourceId: string | null }\n}\n\ntype BuilderPointerMoveAction = {\n type: typeof HostActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\nexport type HostAction =\n | SharedAction\n | InitAction\n | CleanUpAction\n | ChangeDocumentAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | MessageHostPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetBuilderEditModeAction\n | SetLocalizedResourceIdAction\n | BuilderPointerMoveAction\n\nexport function init(): InitAction {\n return { type: HostActionTypes.INIT }\n}\n\nexport function cleanUp(): CleanUpAction {\n return { type: HostActionTypes.CLEAN_UP }\n}\n\nexport function changeDocument(documentKey: string, operation: Operation): ChangeDocumentAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } }\n}\n\nexport function changeDocumentElementScrollTop(\n scrollTop: number,\n): ChangeDocumentElementScrollTopAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } }\n}\n\nexport function scrollDocumentElement(scrollTopDelta: number): ScrollDocumentElementAction {\n return { type: HostActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } }\n}\n\nexport function messageHostPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageHostPropControllerAction<T> {\n return {\n type: HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function changeApiResource<R extends APIResource>(\n resource: R,\n locale?: APIResourceLocale<R>,\n): ChangeAPIResourceAction {\n return { type: HostActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } }\n}\n\nexport function evictApiResource(id: string, locale?: string | null): EvictAPIResourceAction {\n return { type: HostActionTypes.EVICT_API_RESOURCE, payload: { id, locale } }\n}\n\nexport function setBuilderEditMode(editMode: BuilderEditMode): SetBuilderEditModeAction {\n return {\n type: HostActionTypes.SET_BUILDER_EDIT_MODE,\n payload: { editMode },\n }\n}\n\nexport function setLocalizedResourceId({\n resourceId,\n localizedResourceId,\n locale,\n}: {\n resourceId: string\n localizedResourceId: string | null\n locale?: string\n}): SetLocalizedResourceIdAction {\n return {\n type: HostActionTypes.SET_LOCALIZED_RESOURCE_ID,\n payload: { resourceId, localizedResourceId, locale },\n }\n}\n\nexport function builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n\nexport function isHostAction(action: unknown): action is HostAction {\n return isAction(action) && Object.hasOwn(HostActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAUzB,wBAAqD;AAE9C,MAAM,kBAAkB;AAAA,EAC7B,GAAG;AAAA,EAEH,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,iBAAiB;AAAA,EAEjB,oCAAoC;AAAA,EACpC,yBAAyB;AAAA,EAEzB,8BAA8B;AAAA,EAE9B,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EAEpB,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAE3B,sBAAsB;AACxB;AAkEO,SAAS,OAAmB;AACjC,SAAO,EAAE,MAAM,gBAAgB,KAAK;AACtC;AAEO,SAAS,UAAyB;AACvC,SAAO,EAAE,MAAM,gBAAgB,SAAS;AAC1C;AAEO,SAAS,eAAe,aAAqB,WAA4C;AAC9F,SAAO,EAAE,MAAM,gBAAgB,iBAAiB,SAAS,EAAE,aAAa,UAAU,EAAE;AACtF;AAEO,SAAS,+BACd,WACsC;AACtC,SAAO,EAAE,MAAM,gBAAgB,oCAAoC,SAAS,EAAE,UAAU,EAAE;AAC5F;AAEO,SAAS,sBAAsB,gBAAqD;AACzF,SAAO,EAAE,MAAM,gBAAgB,yBAAyB,SAAS,EAAE,eAAe,EAAE;AACtF;AAEO,SAAS,0BACd,aACA,YACA,UACA,SACoC;AACpC,SAAO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,aAAa,YAAY,UAAU,QAAQ;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,UACA,QACyB;AACzB,SAAO,EAAE,MAAM,gBAAgB,qBAAqB,SAAS,EAAE,UAAU,OAAO,EAAE;AACpF;AAEO,SAAS,iBAAiB,IAAY,QAAgD;AAC3F,SAAO,EAAE,MAAM,gBAAgB,oBAAoB,SAAS,EAAE,IAAI,OAAO,EAAE;AAC7E;AAEO,SAAS,mBAAmB,UAAqD;AACtF,SAAO;AAAA,IACL,MAAM,gBAAgB;AAAA,IACtB,SAAS,EAAE,SAAS;AAAA,EACtB;AACF;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":[]}
@@ -38,7 +38,7 @@ var import_toolkit = require("@reduxjs/toolkit");
38
38
  var APIResources = __toESM(require("./modules/api-resources"));
39
39
  var LocalizedResourcesMap = __toESM(require("./modules/localized-resources-map"));
40
40
  var import_actions = require("./actions");
41
- var import_read_only_actions = require("./actions/internal/read-only-actions");
41
+ var import_internal = require("./actions/internal");
42
42
  var import_host_api = require("./host-api");
43
43
  var import_toolkit2 = require("./toolkit");
44
44
  var import_api = require("../api");
@@ -147,7 +147,7 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
147
147
  default:
148
148
  resource = null;
149
149
  }
150
- dispatch((0, import_read_only_actions.apiResourceFulfilled)(resourceType, resourceId, resource, locale));
150
+ dispatch((0, import_internal.apiResourceFulfilled)(resourceType, resourceId, resource, locale));
151
151
  return resource;
152
152
  };
153
153
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal/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 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,+BAAqC;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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KAAK,2BAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS,EAAE,GAAG,OAAO,SAAS,QAAQ,UAAU,cAAc;AAAA,UAChE,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AACF,GAGG;AACD,aAAO,eAAAC,gBAAoB;AAAA,IACzB;AAAA,IACA,gBAAgB;AAAA,MACd,cAAc,aAAa,gBAAgB,iBAAiB,YAAY;AAAA,MACxE,uBAAuB,sBAAsB;AAAA,QAC3C,iBAAiB;AAAA,MACnB;AAAA,IACF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO,wBAAwB,aAAa,CAAC;AAAA,IAEvF,cAAU,gCAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,2BAAY;AAAA,QACZ,2BAAY;AAAA,QACZ,2BAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","configureReduxStore"]}
1
+ {"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal'\nimport { setLocalizedResourceId } from './host-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchJson = async <T>(url: string): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchJson<Swatch>(`/api/makeswift/swatches/${resourceId}`)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(`/api/makeswift/typographies/${resourceId}`)\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(`/api/makeswift/global-elements/${resourceId}`)\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchJson<PagePathnameSlice>(url.pathname + url.search)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(\n defaultLocale: string | undefined,\n): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: { ...action.payload, locale: locale ?? defaultLocale },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n defaultLocale,\n serializedState,\n}: {\n defaultLocale: string | undefined\n serializedState?: SerializedState\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAEP,mBAA8B;AAC9B,4BAAuC;AACvC,qBAAyC;AACzC,sBAAqC;AACrC,sBAAuC;AACvC,I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H,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;A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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,qBAA4E;AAI5E,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,CAA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MACF;AAAA,IACF;AAAA,IAEA,KAAK,2BAAY,qBAAqB;AACpC,YAAM,EAAE,UAAU,OAAO,IAAI,OAAO;AACpC,YAAM,sBAAsB,eAAe,OAAO,SAAS,YAAY,SAAS,IAAI,MAAM;AAE1F,cAAI,iBAAAC,SAAU,qBAAqB,QAAQ;AAAG,eAAO;AAErD,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,SAAS;AAAA,QACT,IAAI,IAAI,MAAM,IAAI,SAAS,UAAU,CAAE,EAAE;AAAA,UACvC,YAAY,SAAS,IAAI,SAAS,YAAY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,2BAAY,oBAAoB;AACnC,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"]}
@@ -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,iBAAiB;AAAS,WAAO;AAErC,MACE,OAAO,UAAU,YACjB,UAAU,QACV,iBAAiB,SACjB,OAAQ,MAAmC,gBAAgB,YAC3D;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,QAAQ,YAAyC;AAC/D,MAAI,sBAAsB;AAAS,WAAO,OAAO,UAAU;AAE3D,SAAO,WAAW,YAAY;AAChC;AAOO,SAAS,kBAAyB;AACvC,SAAO,EAAE,aAAa,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACxD;AAEO,SAAS,eAAe,OAAoD;AACjF,SAAO,MAAM;AACf;AAEO,SAAS,aAAa,OAAkD;AAC7E,SAAO,MAAM;AACf;AAEO,SAAS,YACd,OACA,aACA,YACiB;AACjB,SAAO,aAAa,KAAK,EAAE,IAAI,WAAW,GAAG,IAAI,UAAU,KAAK;AAClE;AAEO,SAAS,QAAQ,QAAe,g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AE,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,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;AACxE,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,mCAAmB,iBAAiB;AACvC,YAAM,cAAc,OAAO,QAAQ;AAEnC,UAAI,YAAY,WAAW;AAAG,cAAM,IAAI,MAAM,8BAA8B;AAE5E,aAAO;AAAA,IACT;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;AAIO,SAAS,sBAAsB,OAAsC;AAC1E,2BAAyB,KAAK;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,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;AACxE,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,iBAAiB;AAChC,YAAM,cAAc,OAAO,QAAQ;AAEnC,UAAI,YAAY,WAAW;AAAG,cAAM,IAAI,MAAM,8BAA8B;AAE5E,aAAO;AAAA,IACT;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;AAIO,SAAS,sBAAsB,OAAsC;AAC1E,2BAAyB,KAAK;AAE9B,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,QAAM,cAAc,OAAO;AAAA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B,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":[]}
@@ -26,7 +26,6 @@ __export(components_meta_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(components_meta_exports);
28
28
  var import_actions = require("../actions");
29
- var import_read_only_actions = require("../actions/internal/read-only-actions");
30
29
  const ComponentIcon = {
31
30
  Billing: "billing",
32
31
  Bolt: "bolt",
@@ -66,9 +65,9 @@ function reducer(state = getInitialState(), action) {
66
65
  if (!(0, import_actions.isKnownAction)(action))
67
66
  return state;
68
67
  switch (action.type) {
69
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT:
68
+ case import_actions.ActionTypes.REGISTER_COMPONENT:
70
69
  return new Map(state).set(action.payload.type, action.payload.meta);
71
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
70
+ case import_actions.ActionTypes.UNREGISTER_COMPONENT: {
72
71
  const nextState = new Map(state);
73
72
  const deleted = nextState.delete(action.payload.type);
74
73
  return deleted ? nextState : state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport const ComponentIcon = {\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Navigation: 'navigation',\n SocialLinks: 'social-links',\n Star: 'star',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? 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 ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,+BAAoC;AAE7B,MAAM,gBAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAcO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,iBAAiB,OAAc,MAAoC;AACjF,SAAO,kBAAkB,KAAK,EAAE,IAAI,IAAI,KAAK;AAC/C;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,6CAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport const ComponentIcon = {\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Navigation: 'navigation',\n SocialLinks: 'social-links',\n Star: 'star',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? 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.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA4E;AAErE,MAAM,gBAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAcO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,iBAAiB,OAAc,MAAoC;AACjF,SAAO,kBAAkB,KAAK,EAAE,IAAI,IAAI,KAAK;AAC/C;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,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,2BAAY,sBAAsB;AACrC,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -22,8 +22,7 @@ __export(element_imperative_handles_exports, {
22
22
  reducer: () => reducer
23
23
  });
24
24
  module.exports = __toCommonJS(element_imperative_handles_exports);
25
- var import_actions = require("../../actions");
26
- var import_read_only_actions = require("../../actions/internal/read-only-actions");
25
+ var import_actions = require("../actions");
27
26
  function getElementImperativeHandles(state) {
28
27
  return state;
29
28
  }
@@ -34,7 +33,7 @@ function reducer(state = getInitialState(), action) {
34
33
  if (!(0, import_actions.isKnownAction)(action))
35
34
  return state;
36
35
  switch (action.type) {
37
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE:
36
+ case import_actions.ActionTypes.REGISTER_COMPONENT_HANDLE:
38
37
  return new Map(state).set(
39
38
  action.payload.documentKey,
40
39
  new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
@@ -42,7 +41,7 @@ function reducer(state = getInitialState(), action) {
42
41
  action.payload.componentHandle
43
42
  )
44
43
  );
45
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {
44
+ case import_actions.ActionTypes.UNREGISTER_COMPONENT_HANDLE: {
46
45
  const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
47
46
  const deleted = byElementKey.delete(action.payload.elementKey);
48
47
  if (!deleted)
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\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.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4E;AAIrE,SAAS,4BACd,OACmD;AACnD,SAAO;AACT;AAEA,SAAS,kBAAyB;AAChC,SAAO,oBAAI,IAAI;AACjB;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,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAAA,UAC5D,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,2BAAY,6BAA6B;AAC5C,YAAM,eAAe,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,aAAa,OAAO,OAAO,QAAQ,UAAU;AAE7D,UAAI,CAAC;AAAS,eAAO;AAErB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY;AAAA,IACpE;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -43,8 +43,6 @@ var import_immutable = require("immutable");
43
43
  var import_controls = require("@makeswift/controls");
44
44
  var Introspection = __toESM(require("../../prop-controllers/introspection"));
45
45
  var import_actions = require("../actions");
46
- var import_read_only_actions = require("../actions/internal/read-only-actions");
47
- var import_read_write_actions = require("../actions/internal/read-write-actions");
48
46
  var import_read_only_documents = require("./read-only-documents");
49
47
  function getInitialState(documents, descriptors) {
50
48
  const state = /* @__PURE__ */ new Map();
@@ -74,19 +72,19 @@ function reducer(state = getInitialState(), action) {
74
72
  if (!(0, import_actions.isKnownAction)(action))
75
73
  return state;
76
74
  switch (action.type) {
77
- case import_read_only_actions.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
75
+ case import_actions.ActionTypes.CREATE_ELEMENT_TREE: {
78
76
  const { document, descriptors } = action.payload;
79
77
  return new Map(state).set(
80
78
  document.key,
81
79
  buildElementTree((0, import_read_only_documents.getRootElement)(document), descriptors)
82
80
  );
83
81
  }
84
- case import_read_only_actions.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
82
+ case import_actions.ActionTypes.DELETE_ELEMENT_TREE: {
85
83
  const nextState = new Map(state);
86
84
  const deleted = nextState.delete(action.payload.documentKey);
87
85
  return deleted ? nextState : state;
88
86
  }
89
- case import_read_write_actions.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
87
+ case import_actions.ActionTypes.CHANGE_ELEMENT_TREE: {
90
88
  const { oldDocument, newDocument, descriptors, operation } = action.payload;
91
89
  const documentKey = oldDocument.key;
92
90
  console.assert(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? 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 ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction hasChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n if (isElementReference(element)) return false\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return false\n\n const children = Introspection.getElementChildren(propDescriptor, element.props[propName])\n return children.length > 0\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n deletedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(deletedElement, propName, descriptors)) {\n for (const element of traverseElementTree(deletedElement, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n } else {\n elements.delete(deletedElement.key)\n elementIds.delete(deletedElement.key)\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [deleteElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, deleteElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.new, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.new, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n return operation.reduce((tree, op) => {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n if (hasDelete && hasInsert) {\n return applyUpdate(tree, descriptors, rootElements, op.p)\n }\n\n if (hasDelete) return applyDelete(tree, descriptors, rootElements, op.p)\n if (hasInsert) return applyInsert(tree, descriptors, rootElements, op.p)\n return tree\n }, elementTree)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAsB;AAEtB,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA+D;AAE/D,+BAAoC;AACpC,gCAAqC;AAErC,iCAA8C;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,qBAAiB,2CAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YAAY,oBAAI,IAAI;AACjE;AAEO,SAAS,cAAc,OAAc,aAA0C;AACpF,SAAO,eAAe,OAAO,WAAW,GAAG,cAAc,oBAAI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AAE,UAAU,WAAW,GAAG,iBAAiB,UAAU,WAAW;AAE9E,uBAAqB,UAAU,oBAAoB,aAAa,GAAG;AAEnE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,aACP,aACA,aACA,cACA,WACa;AACb,SAAO,UAAU,OAAO,CAAC,MAAM,OAAO;AACpC,UAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,UAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,QAAI,aAAa,WAAW;AAC1B,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AAAA,IAC1D;AAEA,QAAI;AAAW,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AACvE,QAAI;AAAW,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AACvE,WAAO;AAAA,EACT,GAAG,WAAW;AAChB;","names":["i"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? 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.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction hasChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n if (isElementReference(element)) return false\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return false\n\n const children = Introspection.getElementChildren(propDescriptor, element.props[propName])\n return children.length > 0\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n deletedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(deletedElement, propName, descriptors)) {\n for (const element of traverseElementTree(deletedElement, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n } else {\n elements.delete(deletedElement.key)\n elementIds.delete(deletedElement.key)\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [deleteElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, deleteElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.new, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.new, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n return operation.reduce((tree, op) => {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n if (hasDelete && hasInsert) {\n return applyUpdate(tree, descriptors, rootElements, op.p)\n }\n\n if (hasDelete) return applyDelete(tree, descriptors, rootElements, op.p)\n if (hasInsert) return applyInsert(tree, descriptors, rootElements, op.p)\n return tree\n }, elementTree)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAsB;AAEtB,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA4E;AAE5E,iCAA8C;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,qBAAiB,2CAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YAAY,oBAAI,IAAI;AACjE;AAEO,SAAS,cAAc,OAAc,aAA0C;AACpF,SAAO,eAAe,OAAO,WAAW,GAAG,cAAc,oBAAI,IAAI;AACnE;AAEO,SAAS,WAAW,OAAc,aAAqB,YAAoC;AAChG,SAAO,YAAY,OAAO,WAAW,EAAE,IAAI,UAAU,KAAK;AAC5D;AAEO,SAAS,aAAa,OAAc,aAAqB,YAAmC;AACjG,SAAO,cAAc,OAAO,WAAW,EAAE,IAAI,UAAU,KAAK;AAC9D;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,2BAAY,qBAAqB;AACpC,YAAM,EAAE,UAAU,YAAY,IAAI,OAAO;AACzC,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,SA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