@makeswift/runtime 0.25.0-canary.8 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (777) hide show
  1. package/dist/cjs/api/react.js +10 -14
  2. package/dist/cjs/api/react.js.map +1 -1
  3. package/dist/cjs/api/site-version/index.js +103 -0
  4. package/dist/cjs/api/site-version/index.js.map +1 -0
  5. package/dist/cjs/api-handler/handlers/manifest.js +3 -4
  6. package/dist/cjs/api-handler/handlers/manifest.js.map +1 -1
  7. package/dist/cjs/api-handler/handlers/redirect-live.js +52 -0
  8. package/dist/cjs/api-handler/handlers/redirect-live.js.map +1 -0
  9. package/dist/cjs/api-handler/index.js +6 -5
  10. package/dist/cjs/api-handler/index.js.map +1 -1
  11. package/dist/cjs/api-handler/node-request-response.js +99 -0
  12. package/dist/cjs/api-handler/node-request-response.js.map +1 -0
  13. package/dist/cjs/{next/preview-mode.js → api-handler/preview.js} +12 -18
  14. package/dist/cjs/api-handler/preview.js.map +1 -0
  15. package/dist/cjs/api-handler/request-response.js +9 -0
  16. package/dist/cjs/api-handler/request-response.js.map +1 -1
  17. package/dist/cjs/client/index.js +67 -59
  18. package/dist/cjs/client/index.js.map +1 -1
  19. package/dist/cjs/components/builtin/Box/animations.js.map +1 -1
  20. package/dist/cjs/components/builtin/Form/components/Field/services/responsiveField.js.map +1 -1
  21. package/dist/cjs/components/builtin/Image/Image.js +4 -26
  22. package/dist/cjs/components/builtin/Image/Image.js.map +1 -1
  23. package/dist/cjs/components/builtin/Root/Root.js +4 -4
  24. package/dist/cjs/components/builtin/Root/Root.js.map +1 -1
  25. package/dist/cjs/components/builtin/Slot/Slot.js +1 -1
  26. package/dist/cjs/components/builtin/Slot/Slot.js.map +1 -1
  27. package/dist/cjs/components/builtin/Video/Video.js +3 -13
  28. package/dist/cjs/components/builtin/Video/Video.js.map +1 -1
  29. package/dist/cjs/components/hooks/useMediaQuery.js +1 -2
  30. package/dist/cjs/components/hooks/useMediaQuery.js.map +1 -1
  31. package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +3 -13
  32. package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
  33. package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js +4 -14
  34. package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
  35. package/dist/cjs/components/shared/Link/index.js +15 -40
  36. package/dist/cjs/components/shared/Link/index.js.map +1 -1
  37. package/dist/cjs/{next/components/Slot.js → components/shared/react-player.js} +9 -18
  38. package/dist/cjs/components/shared/react-player.js.map +1 -0
  39. package/dist/cjs/components/utils/responsive-style.js.map +1 -1
  40. package/dist/cjs/css/border-radius.js.map +1 -1
  41. package/dist/cjs/css/border.js.map +1 -1
  42. package/dist/cjs/css/margin.js.map +1 -1
  43. package/dist/cjs/css/padding.js.map +1 -1
  44. package/dist/cjs/next/api-handler/config/app-router.js +12 -10
  45. package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
  46. package/dist/cjs/next/api-handler/config/pages-router.js +9 -69
  47. package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -1
  48. package/dist/cjs/next/api-handler/handlers/{redirect-draft.js → app-router-redirect-preview.js} +30 -26
  49. package/dist/cjs/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
  50. package/dist/cjs/next/api-handler/handlers/{redirect-preview.js → pages-router-redirect-preview.js} +29 -22
  51. package/dist/cjs/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
  52. package/dist/cjs/next/api-handler/index.js +4 -3
  53. package/dist/cjs/next/api-handler/index.js.map +1 -1
  54. package/dist/cjs/next/api-handler/{draft.js → preview.js} +13 -11
  55. package/dist/cjs/next/api-handler/preview.js.map +1 -0
  56. package/dist/cjs/next/app-router-site-version.js +40 -0
  57. package/dist/cjs/next/app-router-site-version.js.map +1 -0
  58. package/dist/cjs/next/client.js +9 -3
  59. package/dist/cjs/next/client.js.map +1 -1
  60. package/dist/cjs/next/components/framework-provider/app-router/index.js.map +1 -1
  61. package/dist/cjs/next/components/framework-provider/index.js +20 -2
  62. package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
  63. package/dist/cjs/next/components/framework-provider/link.js +69 -0
  64. package/dist/cjs/next/components/framework-provider/link.js.map +1 -0
  65. package/dist/cjs/next/components/framework-provider/pages-router/index.js.map +1 -1
  66. package/dist/cjs/next/components/page.js +1 -1
  67. package/dist/cjs/next/components/page.js.map +1 -1
  68. package/dist/cjs/next/components/tests/__fixtures__/element-data/box-component.js +124 -0
  69. package/dist/cjs/next/components/tests/__fixtures__/element-data/box-component.js.map +1 -0
  70. package/dist/cjs/next/components/tests/__fixtures__/element-data/button-component.js +109 -0
  71. package/dist/cjs/next/components/tests/__fixtures__/element-data/button-component.js.map +1 -0
  72. package/dist/cjs/next/components/tests/__fixtures__/element-data/image-component.js +193 -0
  73. package/dist/cjs/next/components/tests/__fixtures__/element-data/image-component.js.map +1 -0
  74. package/dist/cjs/{api-handler/handlers/clear-draft.js → next/components/tests/__fixtures__/resources/files.js} +17 -19
  75. package/dist/cjs/next/components/tests/__fixtures__/resources/files.js.map +1 -0
  76. package/dist/cjs/next/components/tests/__fixtures__/resources/index.js +27 -0
  77. package/dist/cjs/next/components/tests/__fixtures__/resources/index.js.map +1 -0
  78. package/dist/cjs/next/components/tests/__fixtures__/resources/page-pathname-slices.js +33 -0
  79. package/dist/cjs/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +1 -0
  80. package/dist/cjs/next/components/tests/__fixtures__/resources/swatches.js +35 -0
  81. package/dist/cjs/next/components/tests/__fixtures__/resources/swatches.js.map +1 -0
  82. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +1 -1
  83. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  84. package/dist/cjs/next/document.js +2 -1
  85. package/dist/cjs/next/document.js.map +1 -1
  86. package/dist/cjs/next/index.js +2 -2
  87. package/dist/cjs/next/index.js.map +1 -1
  88. package/dist/cjs/next/middleware/request-utils.js +11 -17
  89. package/dist/cjs/next/middleware/request-utils.js.map +1 -1
  90. package/dist/cjs/next/root-style-registry.js +10 -25
  91. package/dist/cjs/next/root-style-registry.js.map +1 -1
  92. package/dist/cjs/next/server.js +2 -2
  93. package/dist/cjs/next/server.js.map +1 -1
  94. package/dist/cjs/next/testing/page-rendering.js +16 -3
  95. package/dist/cjs/next/testing/page-rendering.js.map +1 -1
  96. package/dist/cjs/next/testing/react-provider.js +2 -2
  97. package/dist/cjs/next/testing/react-provider.js.map +1 -1
  98. package/dist/cjs/next/tests/test-utils.js +7 -5
  99. package/dist/cjs/next/tests/test-utils.js.map +1 -1
  100. package/dist/cjs/{next → runtimes/react}/components/MakeswiftComponent.js +4 -4
  101. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -0
  102. package/dist/cjs/runtimes/react/components/RuntimeProvider.js +9 -7
  103. package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
  104. package/dist/cjs/runtimes/react/components/Slot.js +38 -0
  105. package/dist/cjs/runtimes/react/components/Slot.js.map +1 -0
  106. package/dist/cjs/{next → runtimes/react}/components/SlotProvider.js +3 -3
  107. package/dist/cjs/runtimes/react/components/SlotProvider.js.map +1 -0
  108. package/dist/cjs/runtimes/react/components/framework-context.js +38 -3
  109. package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
  110. package/dist/cjs/runtimes/react/components/page/index.js +18 -16
  111. package/dist/cjs/runtimes/react/components/page/index.js.map +1 -1
  112. package/dist/cjs/runtimes/react/components/{draft-switcher/draft-switcher.js → preview-switcher/preview-switcher.js} +12 -22
  113. package/dist/cjs/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
  114. package/dist/cjs/runtimes/react/components/{draft-switcher/draft-toolbar.js → preview-switcher/preview-toolbar.js} +17 -9
  115. package/dist/cjs/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
  116. package/dist/cjs/runtimes/react/controls/style.js.map +1 -1
  117. package/dist/cjs/runtimes/react/hooks/makeswift-api.js +9 -10
  118. package/dist/cjs/runtimes/react/hooks/makeswift-api.js.map +1 -1
  119. package/dist/cjs/runtimes/react/hooks/use-selector.js +1 -1
  120. package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
  121. package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +1 -1
  122. package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
  123. package/dist/cjs/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  124. package/dist/cjs/runtimes/react/host-api-client.js +7 -2
  125. package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
  126. package/dist/cjs/runtimes/react/root-style-registry.js +39 -13
  127. package/dist/cjs/runtimes/react/root-style-registry.js.map +1 -1
  128. package/dist/cjs/runtimes/react/use-global-style.js +1 -1
  129. package/dist/cjs/runtimes/react/use-global-style.js.map +1 -1
  130. package/dist/cjs/runtimes/react/use-style.js +3 -3
  131. package/dist/cjs/runtimes/react/use-style.js.map +1 -1
  132. package/dist/cjs/state/actions.js +6 -0
  133. package/dist/cjs/state/actions.js.map +1 -1
  134. package/dist/cjs/state/makeswift-api-client.js +42 -57
  135. package/dist/cjs/state/makeswift-api-client.js.map +1 -1
  136. package/dist/cjs/state/mixins/setup-teardown.js.map +1 -1
  137. package/dist/cjs/state/modules/api-resources.js +2 -0
  138. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  139. package/dist/cjs/state/modules/box-models.js +2 -0
  140. package/dist/cjs/state/modules/box-models.js.map +1 -1
  141. package/dist/cjs/state/modules/breakpoints.js +3 -1
  142. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  143. package/dist/cjs/state/modules/builder-edit-mode.js +2 -0
  144. package/dist/cjs/state/modules/builder-edit-mode.js.map +1 -1
  145. package/dist/cjs/state/modules/components-meta.js +2 -0
  146. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  147. package/dist/cjs/state/modules/element-imperative-handles.js +2 -0
  148. package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -1
  149. package/dist/cjs/state/modules/element-trees.js +2 -0
  150. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  151. package/dist/cjs/state/modules/is-in-builder.js +2 -0
  152. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  153. package/dist/cjs/state/modules/is-preview.js +3 -0
  154. package/dist/cjs/state/modules/is-preview.js.map +1 -1
  155. package/dist/cjs/state/modules/localized-resources-map.js +2 -0
  156. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  157. package/dist/cjs/state/modules/pointer.js +2 -0
  158. package/dist/cjs/state/modules/pointer.js.map +1 -1
  159. package/dist/cjs/state/modules/prop-controller-handles.js +2 -0
  160. package/dist/cjs/state/modules/prop-controller-handles.js.map +1 -1
  161. package/dist/cjs/state/modules/prop-controllers.js +2 -0
  162. package/dist/cjs/state/modules/prop-controllers.js.map +1 -1
  163. package/dist/cjs/state/modules/react-components.js +2 -0
  164. package/dist/cjs/state/modules/react-components.js.map +1 -1
  165. package/dist/cjs/state/modules/read-only-documents.js +2 -0
  166. package/dist/cjs/state/modules/read-only-documents.js.map +1 -1
  167. package/dist/cjs/state/modules/read-write-documents.js +2 -0
  168. package/dist/cjs/state/modules/read-write-documents.js.map +1 -1
  169. package/dist/cjs/state/react-builder-preview.js +32 -38
  170. package/dist/cjs/state/react-builder-preview.js.map +1 -1
  171. package/dist/cjs/state/react-page.js +15 -19
  172. package/dist/cjs/state/react-page.js.map +1 -1
  173. package/dist/cjs/state/toolkit.js +54 -0
  174. package/dist/cjs/state/toolkit.js.map +1 -0
  175. package/dist/cjs/testing/fixtures.js +38 -0
  176. package/dist/cjs/testing/fixtures.js.map +1 -0
  177. package/dist/cjs/utils/esm-compat.js +29 -0
  178. package/dist/cjs/utils/esm-compat.js.map +1 -0
  179. package/dist/esm/api/react.js +10 -14
  180. package/dist/esm/api/react.js.map +1 -1
  181. package/dist/esm/api/site-version/index.js +75 -0
  182. package/dist/esm/api/site-version/index.js.map +1 -0
  183. package/dist/esm/api-handler/handlers/manifest.js +3 -4
  184. package/dist/esm/api-handler/handlers/manifest.js.map +1 -1
  185. package/dist/esm/api-handler/handlers/redirect-live.js +27 -0
  186. package/dist/esm/api-handler/handlers/redirect-live.js.map +1 -0
  187. package/dist/esm/api-handler/index.js +7 -6
  188. package/dist/esm/api-handler/index.js.map +1 -1
  189. package/dist/esm/api-handler/node-request-response.js +73 -0
  190. package/dist/esm/api-handler/node-request-response.js.map +1 -0
  191. package/dist/esm/api-handler/preview.js +9 -0
  192. package/dist/esm/api-handler/preview.js.map +1 -0
  193. package/dist/esm/api-handler/request-response.js +9 -0
  194. package/dist/esm/api-handler/request-response.js.map +1 -1
  195. package/dist/esm/client/index.js +65 -58
  196. package/dist/esm/client/index.js.map +1 -1
  197. package/dist/esm/components/builtin/Box/animations.js.map +1 -1
  198. package/dist/esm/components/builtin/Form/components/Field/services/responsiveField.js.map +1 -1
  199. package/dist/esm/components/builtin/Image/Image.js +4 -16
  200. package/dist/esm/components/builtin/Image/Image.js.map +1 -1
  201. package/dist/esm/components/builtin/Root/Root.js +4 -4
  202. package/dist/esm/components/builtin/Root/Root.js.map +1 -1
  203. package/dist/esm/components/builtin/Slot/Slot.js +1 -1
  204. package/dist/esm/components/builtin/Slot/Slot.js.map +1 -1
  205. package/dist/esm/components/builtin/Video/Video.js +1 -1
  206. package/dist/esm/components/builtin/Video/Video.js.map +1 -1
  207. package/dist/esm/components/hooks/useMediaQuery.js +1 -2
  208. package/dist/esm/components/hooks/useMediaQuery.js.map +1 -1
  209. package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +1 -1
  210. package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
  211. package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js +4 -14
  212. package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
  213. package/dist/esm/components/shared/Link/index.js +13 -28
  214. package/dist/esm/components/shared/Link/index.js.map +1 -1
  215. package/dist/esm/components/shared/react-player.js +7 -0
  216. package/dist/esm/components/shared/react-player.js.map +1 -0
  217. package/dist/esm/components/utils/responsive-style.js.map +1 -1
  218. package/dist/esm/css/border-radius.js.map +1 -1
  219. package/dist/esm/css/border.js.map +1 -1
  220. package/dist/esm/css/margin.js.map +1 -1
  221. package/dist/esm/css/padding.js.map +1 -1
  222. package/dist/esm/next/api-handler/config/app-router.js +12 -10
  223. package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
  224. package/dist/esm/next/api-handler/config/pages-router.js +9 -69
  225. package/dist/esm/next/api-handler/config/pages-router.js.map +1 -1
  226. package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js +64 -0
  227. package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
  228. package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js +52 -0
  229. package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
  230. package/dist/esm/next/api-handler/index.js +4 -3
  231. package/dist/esm/next/api-handler/index.js.map +1 -1
  232. package/dist/esm/next/api-handler/preview.js +15 -0
  233. package/dist/esm/next/api-handler/preview.js.map +1 -0
  234. package/dist/esm/next/app-router-site-version.js +16 -0
  235. package/dist/esm/next/app-router-site-version.js.map +1 -0
  236. package/dist/esm/next/client.js +10 -4
  237. package/dist/esm/next/client.js.map +1 -1
  238. package/dist/esm/next/components/framework-provider/app-router/index.js.map +1 -1
  239. package/dist/esm/next/components/framework-provider/index.js +13 -2
  240. package/dist/esm/next/components/framework-provider/index.js.map +1 -1
  241. package/dist/esm/next/components/framework-provider/link.js +35 -0
  242. package/dist/esm/next/components/framework-provider/link.js.map +1 -0
  243. package/dist/esm/next/components/framework-provider/pages-router/index.js.map +1 -1
  244. package/dist/esm/next/components/page.js +2 -4
  245. package/dist/esm/next/components/page.js.map +1 -1
  246. package/dist/esm/next/components/tests/__fixtures__/element-data/box-component.js +99 -0
  247. package/dist/esm/next/components/tests/__fixtures__/element-data/box-component.js.map +1 -0
  248. package/dist/esm/next/components/tests/__fixtures__/element-data/button-component.js +83 -0
  249. package/dist/esm/next/components/tests/__fixtures__/element-data/button-component.js.map +1 -0
  250. package/dist/esm/next/components/tests/__fixtures__/element-data/image-component.js +169 -0
  251. package/dist/esm/next/components/tests/__fixtures__/element-data/image-component.js.map +1 -0
  252. package/dist/esm/next/components/tests/__fixtures__/resources/files.js +15 -0
  253. package/dist/esm/next/components/tests/__fixtures__/resources/files.js.map +1 -0
  254. package/dist/esm/next/components/tests/__fixtures__/resources/index.js +4 -0
  255. package/dist/esm/next/components/tests/__fixtures__/resources/index.js.map +1 -0
  256. package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js +9 -0
  257. package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +1 -0
  258. package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js +11 -0
  259. package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js.map +1 -0
  260. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +1 -1
  261. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  262. package/dist/esm/next/document.js +2 -1
  263. package/dist/esm/next/document.js.map +1 -1
  264. package/dist/esm/next/index.js +2 -2
  265. package/dist/esm/next/index.js.map +1 -1
  266. package/dist/esm/next/middleware/request-utils.js +14 -17
  267. package/dist/esm/next/middleware/request-utils.js.map +1 -1
  268. package/dist/esm/next/root-style-registry.js +11 -23
  269. package/dist/esm/next/root-style-registry.js.map +1 -1
  270. package/dist/esm/next/server.js +1 -1
  271. package/dist/esm/next/server.js.map +1 -1
  272. package/dist/esm/next/testing/page-rendering.js +14 -2
  273. package/dist/esm/next/testing/page-rendering.js.map +1 -1
  274. package/dist/esm/next/testing/react-provider.js +2 -2
  275. package/dist/esm/next/testing/react-provider.js.map +1 -1
  276. package/dist/esm/next/tests/test-utils.js +7 -5
  277. package/dist/esm/next/tests/test-utils.js.map +1 -1
  278. package/dist/esm/{next → runtimes/react}/components/MakeswiftComponent.js +6 -4
  279. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -0
  280. package/dist/esm/runtimes/react/components/RuntimeProvider.js +9 -7
  281. package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
  282. package/dist/esm/{next → runtimes/react}/components/Slot.js +3 -5
  283. package/dist/esm/runtimes/react/components/Slot.js.map +1 -0
  284. package/dist/esm/{next → runtimes/react}/components/SlotProvider.js +1 -2
  285. package/dist/esm/runtimes/react/components/SlotProvider.js.map +1 -0
  286. package/dist/esm/runtimes/react/components/framework-context.js +41 -3
  287. package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
  288. package/dist/esm/runtimes/react/components/page/index.js +19 -17
  289. package/dist/esm/runtimes/react/components/page/index.js.map +1 -1
  290. package/dist/esm/runtimes/react/components/{draft-switcher/draft-switcher.js → preview-switcher/preview-switcher.js} +8 -18
  291. package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
  292. package/dist/esm/runtimes/react/components/{draft-switcher/draft-toolbar.js → preview-switcher/preview-toolbar.js} +13 -5
  293. package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
  294. package/dist/esm/runtimes/react/controls/style.js.map +1 -1
  295. package/dist/esm/runtimes/react/hooks/makeswift-api.js +1 -2
  296. package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +1 -1
  297. package/dist/esm/runtimes/react/hooks/use-selector.js +1 -1
  298. package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
  299. package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +1 -1
  300. package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
  301. package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  302. package/dist/esm/runtimes/react/host-api-client.js +7 -2
  303. package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
  304. package/dist/esm/runtimes/react/root-style-registry.js +37 -13
  305. package/dist/esm/runtimes/react/root-style-registry.js.map +1 -1
  306. package/dist/esm/runtimes/react/use-global-style.js +1 -1
  307. package/dist/esm/runtimes/react/use-global-style.js.map +1 -1
  308. package/dist/esm/runtimes/react/use-style.js +1 -1
  309. package/dist/esm/runtimes/react/use-style.js.map +1 -1
  310. package/dist/esm/state/actions.js +5 -0
  311. package/dist/esm/state/actions.js.map +1 -1
  312. package/dist/esm/state/makeswift-api-client.js +42 -58
  313. package/dist/esm/state/makeswift-api-client.js.map +1 -1
  314. package/dist/esm/state/mixins/setup-teardown.js.map +1 -1
  315. package/dist/esm/state/modules/api-resources.js +3 -1
  316. package/dist/esm/state/modules/api-resources.js.map +1 -1
  317. package/dist/esm/state/modules/box-models.js +3 -1
  318. package/dist/esm/state/modules/box-models.js.map +1 -1
  319. package/dist/esm/state/modules/breakpoints.js +4 -2
  320. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  321. package/dist/esm/state/modules/builder-edit-mode.js +3 -1
  322. package/dist/esm/state/modules/builder-edit-mode.js.map +1 -1
  323. package/dist/esm/state/modules/components-meta.js +3 -1
  324. package/dist/esm/state/modules/components-meta.js.map +1 -1
  325. package/dist/esm/state/modules/element-imperative-handles.js +3 -1
  326. package/dist/esm/state/modules/element-imperative-handles.js.map +1 -1
  327. package/dist/esm/state/modules/element-trees.js +3 -1
  328. package/dist/esm/state/modules/element-trees.js.map +1 -1
  329. package/dist/esm/state/modules/is-in-builder.js +3 -1
  330. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  331. package/dist/esm/state/modules/is-preview.js +3 -0
  332. package/dist/esm/state/modules/is-preview.js.map +1 -1
  333. package/dist/esm/state/modules/localized-resources-map.js +3 -1
  334. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  335. package/dist/esm/state/modules/pointer.js +3 -1
  336. package/dist/esm/state/modules/pointer.js.map +1 -1
  337. package/dist/esm/state/modules/prop-controller-handles.js +3 -1
  338. package/dist/esm/state/modules/prop-controller-handles.js.map +1 -1
  339. package/dist/esm/state/modules/prop-controllers.js +3 -1
  340. package/dist/esm/state/modules/prop-controllers.js.map +1 -1
  341. package/dist/esm/state/modules/react-components.js +3 -1
  342. package/dist/esm/state/modules/react-components.js.map +1 -1
  343. package/dist/esm/state/modules/read-only-documents.js +6 -1
  344. package/dist/esm/state/modules/read-only-documents.js.map +1 -1
  345. package/dist/esm/state/modules/read-write-documents.js +3 -1
  346. package/dist/esm/state/modules/read-write-documents.js.map +1 -1
  347. package/dist/esm/state/react-builder-preview.js +33 -40
  348. package/dist/esm/state/react-builder-preview.js.map +1 -1
  349. package/dist/esm/state/react-page.js +16 -21
  350. package/dist/esm/state/react-page.js.map +1 -1
  351. package/dist/esm/state/toolkit.js +28 -0
  352. package/dist/esm/state/toolkit.js.map +1 -0
  353. package/dist/esm/testing/fixtures.js +13 -0
  354. package/dist/esm/testing/fixtures.js.map +1 -0
  355. package/dist/esm/utils/esm-compat.js +5 -0
  356. package/dist/esm/utils/esm-compat.js.map +1 -0
  357. package/dist/types/api/graphql/documents/queries.d.ts +7 -7
  358. package/dist/types/api/graphql/documents/queries.d.ts.map +1 -1
  359. package/dist/types/api/graphql/generated/fragment-document-nodes.d.ts.map +1 -1
  360. package/dist/types/api/react.d.ts +3 -4
  361. package/dist/types/api/react.d.ts.map +1 -1
  362. package/dist/types/api/site-version/index.d.ts +19 -0
  363. package/dist/types/api/site-version/index.d.ts.map +1 -0
  364. package/dist/types/api/site-version/site-version.test.d.ts +2 -0
  365. package/dist/types/api/site-version/site-version.test.d.ts.map +1 -0
  366. package/dist/types/api-handler/handlers/manifest.d.ts +1 -3
  367. package/dist/types/api-handler/handlers/manifest.d.ts.map +1 -1
  368. package/dist/types/api-handler/handlers/redirect-live.d.ts +6 -0
  369. package/dist/types/api-handler/handlers/redirect-live.d.ts.map +1 -0
  370. package/dist/types/api-handler/index.d.ts +5 -5
  371. package/dist/types/api-handler/index.d.ts.map +1 -1
  372. package/dist/types/api-handler/node-request-response.d.ts +8 -0
  373. package/dist/types/api-handler/node-request-response.d.ts.map +1 -0
  374. package/dist/types/api-handler/node-request-response.test.d.ts +2 -0
  375. package/dist/types/api-handler/node-request-response.test.d.ts.map +1 -0
  376. package/dist/types/api-handler/preview.d.ts +5 -0
  377. package/dist/types/api-handler/preview.d.ts.map +1 -0
  378. package/dist/types/api-handler/request-response.d.ts +1 -0
  379. package/dist/types/api-handler/request-response.d.ts.map +1 -1
  380. package/dist/types/client/index.d.ts +174 -165
  381. package/dist/types/client/index.d.ts.map +1 -1
  382. package/dist/types/components/builtin/Box/Box.d.ts +15 -147
  383. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  384. package/dist/types/components/builtin/Box/components/Placeholder/index.d.ts +0 -1
  385. package/dist/types/components/builtin/Box/components/Placeholder/index.d.ts.map +1 -1
  386. package/dist/types/components/builtin/Button/Button.d.ts +4 -70
  387. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  388. package/dist/types/components/builtin/Carousel/Carousel.d.ts +0 -1
  389. package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
  390. package/dist/types/components/builtin/Countdown/Countdown.d.ts +0 -1
  391. package/dist/types/components/builtin/Countdown/Countdown.d.ts.map +1 -1
  392. package/dist/types/components/builtin/Divider/Divider.d.ts +0 -1
  393. package/dist/types/components/builtin/Divider/Divider.d.ts.map +1 -1
  394. package/dist/types/components/builtin/Embed/Embed.d.ts +0 -1
  395. package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
  396. package/dist/types/components/builtin/Form/Form.d.ts +0 -1
  397. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  398. package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  399. package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts.map +1 -1
  400. package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts +0 -1
  401. package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts.map +1 -1
  402. package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts +0 -1
  403. package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts.map +1 -1
  404. package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts +0 -1
  405. package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts.map +1 -1
  406. package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts +0 -1
  407. package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts.map +1 -1
  408. package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts +0 -1
  409. package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts.map +1 -1
  410. package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts +0 -1
  411. package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts.map +1 -1
  412. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +0 -1
  413. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
  414. package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts +1 -1
  415. package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts.map +1 -1
  416. package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts +0 -1
  417. package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts.map +1 -1
  418. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts +0 -1
  419. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts.map +1 -1
  420. package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts +0 -1
  421. package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts.map +1 -1
  422. package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts +0 -1
  423. package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts.map +1 -1
  424. package/dist/types/components/builtin/Form/components/Field/index.d.ts +0 -1
  425. package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -1
  426. package/dist/types/components/builtin/Form/components/Field/services/responsiveField.d.ts +1 -1
  427. package/dist/types/components/builtin/Form/components/Field/services/responsiveField.d.ts.map +1 -1
  428. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts +0 -1
  429. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts.map +1 -1
  430. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts +0 -1
  431. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
  432. package/dist/types/components/builtin/Form/context/FormContext.d.ts +0 -1
  433. package/dist/types/components/builtin/Form/context/FormContext.d.ts.map +1 -1
  434. package/dist/types/components/builtin/Image/Image.d.ts +0 -1
  435. package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
  436. package/dist/types/components/builtin/Navigation/Navigation.d.ts +0 -1
  437. package/dist/types/components/builtin/Navigation/Navigation.d.ts.map +1 -1
  438. package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts +0 -1
  439. package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
  440. package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts +0 -1
  441. package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
  442. package/dist/types/components/builtin/Root/Root.d.ts +1 -2
  443. package/dist/types/components/builtin/Root/Root.d.ts.map +1 -1
  444. package/dist/types/components/builtin/Root/components/Placeholder/index.d.ts +0 -1
  445. package/dist/types/components/builtin/Root/components/Placeholder/index.d.ts.map +1 -1
  446. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts +0 -1
  447. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts.map +1 -1
  448. package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts +0 -1
  449. package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts.map +1 -1
  450. package/dist/types/components/builtin/Text/Text.d.ts +0 -1
  451. package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
  452. package/dist/types/components/builtin/Video/Video.d.ts +0 -1
  453. package/dist/types/components/builtin/Video/Video.d.ts.map +1 -1
  454. package/dist/types/components/hooks/useMediaQuery.d.ts.map +1 -1
  455. package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts +0 -1
  456. package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
  457. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts +0 -1
  458. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  459. package/dist/types/components/shared/ErrorBoundary.d.ts +0 -1
  460. package/dist/types/components/shared/ErrorBoundary.d.ts.map +1 -1
  461. package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts +0 -1
  462. package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts.map +1 -1
  463. package/dist/types/components/shared/Link/index.d.ts.map +1 -1
  464. package/dist/types/components/shared/react-player.d.ts +3 -0
  465. package/dist/types/components/shared/react-player.d.ts.map +1 -0
  466. package/dist/types/components/utils/columns.d.ts.map +1 -1
  467. package/dist/types/components/utils/responsive-style.d.ts +1 -1
  468. package/dist/types/components/utils/responsive-style.d.ts.map +1 -1
  469. package/dist/types/controls/control.d.ts +1 -25
  470. package/dist/types/controls/control.d.ts.map +1 -1
  471. package/dist/types/controls/link.d.ts +3 -3
  472. package/dist/types/controls/link.d.ts.map +1 -1
  473. package/dist/types/controls/rich-text/control.d.ts.map +1 -1
  474. package/dist/types/controls/rich-text-v2/control.d.ts +13 -13
  475. package/dist/types/controls/rich-text-v2/control.d.ts.map +1 -1
  476. package/dist/types/controls/rich-text-v2/plugin.d.ts +2 -2
  477. package/dist/types/controls/rich-text-v2/plugin.d.ts.map +1 -1
  478. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +556 -12
  479. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  480. package/dist/types/css/border-radius.d.ts +1 -1
  481. package/dist/types/css/border-radius.d.ts.map +1 -1
  482. package/dist/types/css/border.d.ts +1 -1
  483. package/dist/types/css/border.d.ts.map +1 -1
  484. package/dist/types/css/margin.d.ts +1 -1
  485. package/dist/types/css/margin.d.ts.map +1 -1
  486. package/dist/types/css/padding.d.ts +1 -1
  487. package/dist/types/css/padding.d.ts.map +1 -1
  488. package/dist/types/next/api-handler/config/app-router.d.ts +10 -8
  489. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
  490. package/dist/types/next/api-handler/config/pages-router.d.ts +3 -2
  491. package/dist/types/next/api-handler/config/pages-router.d.ts.map +1 -1
  492. package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts +5 -0
  493. package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts.map +1 -0
  494. package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts +2 -0
  495. package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts.map +1 -0
  496. package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts +4 -0
  497. package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts.map +1 -0
  498. package/dist/types/next/api-handler/index.d.ts +1 -1
  499. package/dist/types/next/api-handler/index.d.ts.map +1 -1
  500. package/dist/types/next/api-handler/preview.d.ts +8 -0
  501. package/dist/types/next/api-handler/preview.d.ts.map +1 -0
  502. package/dist/types/next/app-router-site-version.d.ts +3 -0
  503. package/dist/types/next/app-router-site-version.d.ts.map +1 -0
  504. package/dist/types/next/client.d.ts +3 -3
  505. package/dist/types/next/client.d.ts.map +1 -1
  506. package/dist/types/next/components/framework-provider/app-router/index.d.ts +1 -1
  507. package/dist/types/next/components/framework-provider/app-router/index.d.ts.map +1 -1
  508. package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
  509. package/dist/types/next/components/framework-provider/link.d.ts +2 -0
  510. package/dist/types/next/components/framework-provider/link.d.ts.map +1 -0
  511. package/dist/types/next/components/framework-provider/pages-router/index.d.ts +1 -1
  512. package/dist/types/next/components/framework-provider/pages-router/index.d.ts.map +1 -1
  513. package/dist/types/next/components/page.d.ts +2 -7
  514. package/dist/types/next/components/page.d.ts.map +1 -1
  515. package/dist/types/next/components/tests/__fixtures__/element-data/box-component.d.ts +8 -0
  516. package/dist/types/next/components/tests/__fixtures__/element-data/box-component.d.ts.map +1 -0
  517. package/dist/types/next/components/tests/__fixtures__/element-data/button-component.d.ts +9 -0
  518. package/dist/types/next/components/tests/__fixtures__/element-data/button-component.d.ts.map +1 -0
  519. package/dist/types/next/components/tests/__fixtures__/element-data/image-component.d.ts +7 -0
  520. package/dist/types/next/components/tests/__fixtures__/element-data/image-component.d.ts.map +1 -0
  521. package/dist/types/next/components/tests/__fixtures__/resources/files.d.ts +3 -0
  522. package/dist/types/next/components/tests/__fixtures__/resources/files.d.ts.map +1 -0
  523. package/dist/types/next/components/tests/__fixtures__/resources/index.d.ts +4 -0
  524. package/dist/types/next/components/tests/__fixtures__/resources/index.d.ts.map +1 -0
  525. package/dist/types/next/components/tests/__fixtures__/resources/page-pathname-slices.d.ts +3 -0
  526. package/dist/types/next/components/tests/__fixtures__/resources/page-pathname-slices.d.ts.map +1 -0
  527. package/dist/types/next/components/tests/__fixtures__/resources/swatches.d.ts +3 -0
  528. package/dist/types/next/components/tests/__fixtures__/resources/swatches.d.ts.map +1 -0
  529. package/dist/types/next/components/tests/components/box-component-rendering.test.d.ts +3 -0
  530. package/dist/types/next/components/tests/components/box-component-rendering.test.d.ts.map +1 -0
  531. package/dist/types/next/components/tests/components/button-component-rendering.test.d.ts +3 -0
  532. package/dist/types/next/components/tests/components/button-component-rendering.test.d.ts.map +1 -0
  533. package/dist/types/next/components/tests/components/image-component-rendering.test.d.ts +3 -0
  534. package/dist/types/next/components/tests/components/image-component-rendering.test.d.ts.map +1 -0
  535. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  536. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  537. package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts.map +1 -1
  538. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts +3 -16
  539. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts.map +1 -1
  540. package/dist/types/next/document.d.ts.map +1 -1
  541. package/dist/types/next/index.d.ts +3 -3
  542. package/dist/types/next/index.d.ts.map +1 -1
  543. package/dist/types/next/middleware/request-utils.d.ts +1 -0
  544. package/dist/types/next/middleware/request-utils.d.ts.map +1 -1
  545. package/dist/types/next/root-style-registry.d.ts +3 -12
  546. package/dist/types/next/root-style-registry.d.ts.map +1 -1
  547. package/dist/types/next/server.d.ts +1 -1
  548. package/dist/types/next/server.d.ts.map +1 -1
  549. package/dist/types/next/testing/element-data.d.ts +13 -13
  550. package/dist/types/next/testing/page-rendering.d.ts +3 -0
  551. package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
  552. package/dist/types/next/testing/react-provider.d.ts +3 -3
  553. package/dist/types/next/testing/react-provider.d.ts.map +1 -1
  554. package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts +2 -0
  555. package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts.map +1 -0
  556. package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts +2 -0
  557. package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts.map +1 -0
  558. package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts +2 -0
  559. package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts.map +1 -0
  560. package/dist/types/next/tests/test-utils.d.ts.map +1 -1
  561. package/dist/types/runtimes/react/components/Document.d.ts +0 -1
  562. package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
  563. package/dist/types/runtimes/react/components/DocumentRoot.d.ts +0 -1
  564. package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
  565. package/dist/types/runtimes/react/components/Element.d.ts +0 -1
  566. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  567. package/dist/types/runtimes/react/components/ElementData.d.ts +0 -1
  568. package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
  569. package/dist/types/runtimes/react/components/ElementReference.d.ts +0 -1
  570. package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
  571. package/dist/types/{next → runtimes/react}/components/MakeswiftComponent.d.ts +1 -2
  572. package/dist/types/runtimes/react/components/MakeswiftComponent.d.ts.map +1 -0
  573. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +3 -2
  574. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
  575. package/dist/types/{next → runtimes/react}/components/Slot.d.ts +2 -2
  576. package/dist/types/runtimes/react/components/Slot.d.ts.map +1 -0
  577. package/dist/types/{next → runtimes/react}/components/SlotProvider.d.ts +1 -2
  578. package/dist/types/runtimes/react/components/SlotProvider.d.ts.map +1 -0
  579. package/dist/types/runtimes/react/components/framework-context.d.ts +25 -1
  580. package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
  581. package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts +0 -1
  582. package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts.map +1 -1
  583. package/dist/types/runtimes/react/components/page/Page.d.ts +0 -1
  584. package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
  585. package/dist/types/runtimes/react/components/page/PageHead.d.ts +0 -1
  586. package/dist/types/runtimes/react/components/page/PageHead.d.ts.map +1 -1
  587. package/dist/types/runtimes/react/components/page/index.d.ts +23 -3
  588. package/dist/types/runtimes/react/components/page/index.d.ts.map +1 -1
  589. package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts +4 -0
  590. package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts.map +1 -0
  591. package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts +2 -0
  592. package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts.map +1 -0
  593. package/dist/types/runtimes/react/components/render-hook.d.ts +0 -1
  594. package/dist/types/runtimes/react/components/render-hook.d.ts.map +1 -1
  595. package/dist/types/runtimes/react/controls/control.d.ts +0 -1
  596. package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
  597. package/dist/types/runtimes/react/controls/group.d.ts +0 -1
  598. package/dist/types/runtimes/react/controls/group.d.ts.map +1 -1
  599. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts +0 -1
  600. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
  601. package/dist/types/runtimes/react/controls/rich-text/ReadOnlyText.d.ts +0 -1
  602. package/dist/types/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -1
  603. package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +0 -1
  604. package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  605. package/dist/types/runtimes/react/controls/style.d.ts +1 -1
  606. package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
  607. package/dist/types/runtimes/react/controls.d.ts +0 -1
  608. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  609. package/dist/types/runtimes/react/hooks/makeswift-api.d.ts.map +1 -1
  610. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts +0 -1
  611. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts.map +1 -1
  612. package/dist/types/runtimes/react/hooks/use-document-context.d.ts +0 -1
  613. package/dist/types/runtimes/react/hooks/use-document-context.d.ts.map +1 -1
  614. package/dist/types/runtimes/react/hooks/use-document-cycles.d.ts +0 -1
  615. package/dist/types/runtimes/react/hooks/use-document-cycles.d.ts.map +1 -1
  616. package/dist/types/runtimes/react/hooks/use-react-runtime.d.ts +0 -1
  617. package/dist/types/runtimes/react/hooks/use-react-runtime.d.ts.map +1 -1
  618. package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
  619. package/dist/types/runtimes/react/hooks/use-store.d.ts +25 -2
  620. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  621. package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts.map +1 -1
  622. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts +1 -1
  623. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts.map +1 -1
  624. package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
  625. package/dist/types/runtimes/react/legacy-controls.d.ts +0 -1
  626. package/dist/types/runtimes/react/legacy-controls.d.ts.map +1 -1
  627. package/dist/types/runtimes/react/root-style-registry.d.ts +30 -10
  628. package/dist/types/runtimes/react/root-style-registry.d.ts.map +1 -1
  629. package/dist/types/runtimes/react/use-global-style.d.ts.map +1 -1
  630. package/dist/types/runtimes/react/use-style.d.ts +1 -1
  631. package/dist/types/runtimes/react/use-style.d.ts.map +1 -1
  632. package/dist/types/slate/BlockPlugin/index.d.ts +5 -5
  633. package/dist/types/slate/BlockPlugin/utils/location.d.ts.map +1 -1
  634. package/dist/types/slate/InlineModePlugin/index.d.ts +41 -41
  635. package/dist/types/slate/InlinePlugin/getValue.d.ts.map +1 -1
  636. package/dist/types/slate/InlinePlugin/index.d.ts +5 -6
  637. package/dist/types/slate/InlinePlugin/index.d.ts.map +1 -1
  638. package/dist/types/slate/InlinePlugin/onChange.d.ts.map +1 -1
  639. package/dist/types/slate/LinkPlugin/getValue.d.ts +1 -1
  640. package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
  641. package/dist/types/slate/LinkPlugin/index.d.ts +3 -4
  642. package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
  643. package/dist/types/slate/LinkPlugin/onChange.d.ts.map +1 -1
  644. package/dist/types/slate/TextAlignPlugin/index.d.ts +5 -6
  645. package/dist/types/slate/TextAlignPlugin/index.d.ts.map +1 -1
  646. package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
  647. package/dist/types/slate/TypographyPlugin/index.d.ts +2 -3
  648. package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
  649. package/dist/types/slate/test-helpers/editor-v1.d.ts +0 -1
  650. package/dist/types/slate/test-helpers/editor-v1.d.ts.map +1 -1
  651. package/dist/types/slate/test-helpers/editor-v2-inline.d.ts +0 -1
  652. package/dist/types/slate/test-helpers/editor-v2-inline.d.ts.map +1 -1
  653. package/dist/types/slate/test-helpers/editor-v2.d.ts +0 -1
  654. package/dist/types/slate/test-helpers/editor-v2.d.ts.map +1 -1
  655. package/dist/types/slate/test-helpers/slate-test-helper.d.ts +4 -4
  656. package/dist/types/slate/test-helpers/slate-test-helper.d.ts.map +1 -1
  657. package/dist/types/slate/test-helpers/test-elements.d.ts +8 -64
  658. package/dist/types/slate/test-helpers/test-elements.d.ts.map +1 -1
  659. package/dist/types/slate/utils/editor.d.ts.map +1 -1
  660. package/dist/types/slate/utils/element.d.ts.map +1 -1
  661. package/dist/types/slate/utils/location.d.ts.map +1 -1
  662. package/dist/types/slate/utils/responsive.d.ts.map +1 -1
  663. package/dist/types/state/__tests__/actions.test.d.ts +2 -0
  664. package/dist/types/state/__tests__/actions.test.d.ts.map +1 -0
  665. package/dist/types/state/actions.d.ts +3 -2
  666. package/dist/types/state/actions.d.ts.map +1 -1
  667. package/dist/types/state/makeswift-api-client.d.ts +19 -11
  668. package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
  669. package/dist/types/state/mixins/setup-teardown.d.ts +1 -1
  670. package/dist/types/state/mixins/setup-teardown.d.ts.map +1 -1
  671. package/dist/types/state/modules/api-resources.d.ts +2 -2
  672. package/dist/types/state/modules/api-resources.d.ts.map +1 -1
  673. package/dist/types/state/modules/box-models.d.ts +2 -2
  674. package/dist/types/state/modules/box-models.d.ts.map +1 -1
  675. package/dist/types/state/modules/breakpoints.d.ts +2 -2
  676. package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
  677. package/dist/types/state/modules/builder-edit-mode.d.ts +2 -2
  678. package/dist/types/state/modules/builder-edit-mode.d.ts.map +1 -1
  679. package/dist/types/state/modules/components-meta.d.ts +2 -2
  680. package/dist/types/state/modules/components-meta.d.ts.map +1 -1
  681. package/dist/types/state/modules/element-imperative-handles.d.ts +2 -2
  682. package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -1
  683. package/dist/types/state/modules/element-trees.d.ts +2 -2
  684. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  685. package/dist/types/state/modules/is-in-builder.d.ts +2 -2
  686. package/dist/types/state/modules/is-in-builder.d.ts.map +1 -1
  687. package/dist/types/state/modules/is-preview.d.ts +2 -2
  688. package/dist/types/state/modules/is-preview.d.ts.map +1 -1
  689. package/dist/types/state/modules/localized-resources-map.d.ts +2 -2
  690. package/dist/types/state/modules/localized-resources-map.d.ts.map +1 -1
  691. package/dist/types/state/modules/pointer.d.ts +2 -2
  692. package/dist/types/state/modules/pointer.d.ts.map +1 -1
  693. package/dist/types/state/modules/prop-controller-handles.d.ts +2 -2
  694. package/dist/types/state/modules/prop-controller-handles.d.ts.map +1 -1
  695. package/dist/types/state/modules/prop-controllers.d.ts +2 -2
  696. package/dist/types/state/modules/prop-controllers.d.ts.map +1 -1
  697. package/dist/types/state/modules/react-components.d.ts +2 -2
  698. package/dist/types/state/modules/react-components.d.ts.map +1 -1
  699. package/dist/types/state/modules/read-only-documents.d.ts +2 -2
  700. package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
  701. package/dist/types/state/modules/read-write-documents.d.ts +2 -2
  702. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -1
  703. package/dist/types/state/react-builder-preview.d.ts +57 -10
  704. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  705. package/dist/types/state/react-page.d.ts +67 -36
  706. package/dist/types/state/react-page.d.ts.map +1 -1
  707. package/dist/types/state/toolkit.d.ts +11 -0
  708. package/dist/types/state/toolkit.d.ts.map +1 -0
  709. package/dist/types/testing/fixtures.d.ts +7 -0
  710. package/dist/types/testing/fixtures.d.ts.map +1 -0
  711. package/dist/types/utils/clamp.d.ts.map +1 -1
  712. package/dist/types/utils/esm-compat.d.ts +2 -0
  713. package/dist/types/utils/esm-compat.d.ts.map +1 -0
  714. package/dist/types/utils/keys.d.ts.map +1 -1
  715. package/package.json +14 -15
  716. package/dist/cjs/api/site-version.js +0 -42
  717. package/dist/cjs/api/site-version.js.map +0 -1
  718. package/dist/cjs/api-handler/handlers/clear-draft.js.map +0 -1
  719. package/dist/cjs/next/api-handler/draft.js.map +0 -1
  720. package/dist/cjs/next/api-handler/handlers/redirect-draft.js.map +0 -1
  721. package/dist/cjs/next/api-handler/handlers/redirect-preview.js.map +0 -1
  722. package/dist/cjs/next/components/MakeswiftComponent.js.map +0 -1
  723. package/dist/cjs/next/components/Slot.js.map +0 -1
  724. package/dist/cjs/next/components/SlotProvider.js.map +0 -1
  725. package/dist/cjs/next/draft-mode/index.js +0 -56
  726. package/dist/cjs/next/draft-mode/index.js.map +0 -1
  727. package/dist/cjs/next/preview-mode.js.map +0 -1
  728. package/dist/cjs/runtimes/react/components/draft-switcher/draft-switcher.js.map +0 -1
  729. package/dist/cjs/runtimes/react/components/draft-switcher/draft-toolbar.js.map +0 -1
  730. package/dist/esm/api/site-version.js +0 -15
  731. package/dist/esm/api/site-version.js.map +0 -1
  732. package/dist/esm/api-handler/handlers/clear-draft.js +0 -17
  733. package/dist/esm/api-handler/handlers/clear-draft.js.map +0 -1
  734. package/dist/esm/next/api-handler/draft.js +0 -14
  735. package/dist/esm/next/api-handler/draft.js.map +0 -1
  736. package/dist/esm/next/api-handler/handlers/redirect-draft.js +0 -52
  737. package/dist/esm/next/api-handler/handlers/redirect-draft.js.map +0 -1
  738. package/dist/esm/next/api-handler/handlers/redirect-preview.js +0 -37
  739. package/dist/esm/next/api-handler/handlers/redirect-preview.js.map +0 -1
  740. package/dist/esm/next/components/MakeswiftComponent.js.map +0 -1
  741. package/dist/esm/next/components/Slot.js.map +0 -1
  742. package/dist/esm/next/components/SlotProvider.js.map +0 -1
  743. package/dist/esm/next/draft-mode/index.js +0 -30
  744. package/dist/esm/next/draft-mode/index.js.map +0 -1
  745. package/dist/esm/next/preview-mode.js +0 -16
  746. package/dist/esm/next/preview-mode.js.map +0 -1
  747. package/dist/esm/runtimes/react/components/draft-switcher/draft-switcher.js.map +0 -1
  748. package/dist/esm/runtimes/react/components/draft-switcher/draft-toolbar.js.map +0 -1
  749. package/dist/types/api/site-version.d.ts +0 -7
  750. package/dist/types/api/site-version.d.ts.map +0 -1
  751. package/dist/types/api-handler/handlers/clear-draft.d.ts +0 -7
  752. package/dist/types/api-handler/handlers/clear-draft.d.ts.map +0 -1
  753. package/dist/types/next/api-handler/draft.d.ts +0 -8
  754. package/dist/types/next/api-handler/draft.d.ts.map +0 -1
  755. package/dist/types/next/api-handler/handlers/redirect-draft.d.ts +0 -6
  756. package/dist/types/next/api-handler/handlers/redirect-draft.d.ts.map +0 -1
  757. package/dist/types/next/api-handler/handlers/redirect-draft.test.d.ts +0 -2
  758. package/dist/types/next/api-handler/handlers/redirect-draft.test.d.ts.map +0 -1
  759. package/dist/types/next/api-handler/handlers/redirect-preview.d.ts +0 -5
  760. package/dist/types/next/api-handler/handlers/redirect-preview.d.ts.map +0 -1
  761. package/dist/types/next/components/MakeswiftComponent.d.ts.map +0 -1
  762. package/dist/types/next/components/Slot.d.ts.map +0 -1
  763. package/dist/types/next/components/SlotProvider.d.ts.map +0 -1
  764. package/dist/types/next/draft-mode/index.d.ts +0 -15
  765. package/dist/types/next/draft-mode/index.d.ts.map +0 -1
  766. package/dist/types/next/preview-mode.d.ts +0 -17
  767. package/dist/types/next/preview-mode.d.ts.map +0 -1
  768. package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts +0 -2
  769. package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts.map +0 -1
  770. package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts +0 -2
  771. package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts.map +0 -1
  772. package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts +0 -2
  773. package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts.map +0 -1
  774. package/dist/types/runtimes/react/components/draft-switcher/draft-switcher.d.ts +0 -4
  775. package/dist/types/runtimes/react/components/draft-switcher/draft-switcher.d.ts.map +0 -1
  776. package/dist/types/runtimes/react/components/draft-switcher/draft-toolbar.d.ts +0 -6
  777. package/dist/types/runtimes/react/components/draft-switcher/draft-toolbar.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/actions.ts"],"sourcesContent":["import type { Operation } from 'ot-json0'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { type Element, type Document, EMBEDDED_DOCUMENT_TYPE } from './modules/read-only-documents'\nimport type { DescriptorsByComponentType } from './modules/prop-controllers'\nimport type { ComponentType } from './modules/react-components'\nimport type { Measurable, BoxModel } from './modules/box-models'\nimport type { ThunkAction } from 'redux-thunk'\nimport { ComponentMeta } from './modules/components-meta'\nimport { PropControllerDescriptor } from '../prop-controllers'\nimport type { Size } from './react-builder-preview'\nimport type { PropControllersHandle } from './modules/prop-controller-handles'\nimport type { PropControllerMessage } from '../prop-controllers/instances'\nimport type { APIResource, APIResourceType, APIResourceLocale } from '../api/types'\nimport type { SerializedControl } from '../builder'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\nimport { BuilderEditMode } from './modules/builder-edit-mode'\nimport type { Point } from './modules/pointer'\nimport { Breakpoints } from './modules/breakpoints'\nimport { type SerializedState as APIClientCache } from './makeswift-api-client'\nimport { LocaleString, localeStringSchema } from '../locale'\n\nexport const ActionTypes = {\n INIT: 'INIT',\n CLEAN_UP: 'CLEAN_UP',\n\n REGISTER_DOCUMENT: 'REGISTER_DOCUMENT',\n UNREGISTER_DOCUMENT: 'UNREGISTER_DOCUMENT',\n CHANGE_DOCUMENT: 'CHANGE_DOCUMENT',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP: 'CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP',\n SCROLL_DOCUMENT_ELEMENT: 'SCROLL_DOCUMENT_ELEMENT',\n\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n MESSAGE_HOST_PROP_CONTROLLER: 'MESSAGE_HOST_PROP_CONTROLLER',\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n CHANGE_API_RESOURCE: 'CHANGE_API_RESOURCE',\n EVICT_API_RESOURCE: 'EVICT_API_RESOURCE',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n SET_BUILDER_EDIT_MODE: 'SET_BUILDER_EDIT_MODE',\n MAKESWIFT_CONNECTION_INIT: 'MAKESWIFT_CONNECTION_INIT',\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n BUILDER_POINTER_MOVE: 'BUILDER_POINTER_MOVE',\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n SET_BREAKPOINTS: 'SET_BREAKPOINTS',\n\n SET_LOCALE: 'SET_LOCALE',\n\n SET_LOCALIZED_RESOURCE_ID: 'SET_LOCALIZED_RESOURCE_ID',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n} as const\n\ntype InitAction = { type: typeof ActionTypes.INIT }\n\ntype CleanUpAction = { type: typeof ActionTypes.CLEAN_UP }\n\ntype DocumentPayloadBaseDocument = {\n key: string\n rootElement: Element\n locale?: string | null // older versions of the runtime may not provide this field\n}\n\ntype DocumentPayloadEmbeddedDocument = {\n key: string\n locale: string | null\n id: string\n type: string\n name: string\n rootElement: Element\n meta: { allowLocaleFallback: boolean; requestedLocale: string | null; description?: string }\n __type: typeof EMBEDDED_DOCUMENT_TYPE\n}\n\nexport type DocumentPayload = DocumentPayloadBaseDocument | DocumentPayloadEmbeddedDocument\n\ntype RegisterDocumentAction = {\n type: typeof ActionTypes.REGISTER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterDocumentAction = {\n type: typeof ActionTypes.UNREGISTER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype ChangeDocumentAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT\n payload: { documentKey: string; operation: Operation }\n}\n\ntype CreateElementTreeAction = {\n type: typeof ActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof ActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\ntype ChangeElementTreeAction = {\n type: typeof ActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof ActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof ActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterComponentAction = {\n type: typeof ActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\ntype UnregisterComponentAction = {\n type: typeof ActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof ActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n transferables?: Transferable[]\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof ActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof ActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof ActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\ntype MountComponentAction = {\n type: typeof ActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof ActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof ActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: Size }\n}\n\ntype ChangeDocumentElementScrollTopAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP\n payload: { scrollTop: number }\n}\n\ntype ScrollDocumentElementAction = {\n type: typeof ActionTypes.SCROLL_DOCUMENT_ELEMENT\n payload: { scrollTopDelta: number }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype MessageHostPropControllerAction<T = PropControllerMessage> = {\n type: typeof ActionTypes.MESSAGE_HOST_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype ChangeAPIResourceAction = {\n type: typeof ActionTypes.CHANGE_API_RESOURCE\n payload: { resource: APIResource; locale?: string | null }\n}\n\ntype EvictAPIResourceAction = {\n type: typeof ActionTypes.EVICT_API_RESOURCE\n payload: { id: string; locale?: string | null }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof ActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype HandleWheelAction = {\n type: typeof ActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof ActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype APIResourceFulfilledAction = {\n type: typeof ActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype SetBuilderEditModeAction = {\n type: typeof ActionTypes.SET_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype BuilderPointerMoveAction = {\n type: typeof ActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof ActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\nexport type SetBreakpointsAction = {\n type: typeof ActionTypes.SET_BREAKPOINTS\n payload: { breakpoints: Breakpoints }\n}\n\ntype SetLocaleAction = {\n type: typeof ActionTypes.SET_LOCALE\n payload: { locale: LocaleString; pathname?: string }\n}\n\ntype SetLocalizedResourceIdAction = {\n type: typeof ActionTypes.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 UpdateAPIClientCache = {\n type: typeof ActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\nexport type Action =\n | InitAction\n | CleanUpAction\n | RegisterDocumentAction\n | UnregisterDocumentAction\n | ChangeDocumentAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | ChangeElementTreeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | MountComponentAction\n | UnmountComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | ChangeElementBoxModelsAction\n | ChangeDocumentElementSizeAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | MessageHostPropControllerAction\n | MessageBuilderPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetIsInBuilderAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | APIResourceFulfilledAction\n | SetBuilderEditModeAction\n | BuilderPointerMoveAction\n | ElementFromPointChangeAction\n | SetBreakpointsAction\n | SetLocaleAction\n | SetLocalizedResourceIdAction\n | UpdateAPIClientCache\n\nexport function init(): InitAction {\n return { type: ActionTypes.INIT }\n}\n\nexport function cleanUp(): CleanUpAction {\n return { type: ActionTypes.CLEAN_UP }\n}\n\nexport function registerDocument(document: Document): RegisterDocumentAction {\n return { type: ActionTypes.REGISTER_DOCUMENT, payload: { documentKey: document.key, document } }\n}\n\nexport function unregisterDocument(documentKey: string): UnregisterDocumentAction {\n return { type: ActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: ActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: ActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: ActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: ActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n documents.forEach(document => dispatch(registerDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, Action> {\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 changeDocument(documentKey: string, operation: Operation): ChangeDocumentAction {\n return { type: ActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: ActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: ActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): RegisterBuilderComponentAction {\n return {\n type: ActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: ActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: ActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: ActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: ActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: ActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return { type: ActionTypes.UNREGISTER_COMPONENT_HANDLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return { type: ActionTypes.REGISTER_MEASURABLE, payload: { documentKey, elementKey, measurable } }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return { type: ActionTypes.CHANGE_ELEMENT_BOX_MODELS, payload: { changedElementBoxModels } }\n}\n\nexport function changeDocumentElementSize(size: Size): ChangeDocumentElementSizeAction {\n return { type: ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeDocumentElementScrollTop(\n scrollTop: number,\n): ChangeDocumentElementScrollTopAction {\n return { type: ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } }\n}\n\nexport function scrollDocumentElement(scrollTopDelta: number): ScrollDocumentElementAction {\n return { type: ActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return { type: ActionTypes.UNREGISTER_PROP_CONTROLLERS, payload: { documentKey, elementKey } }\n}\n\nexport function messageHostPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageHostPropControllerAction<T> {\n return {\n type: ActionTypes.MESSAGE_HOST_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\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: ActionTypes.MESSAGE_BUILDER_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: ActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } }\n}\n\nexport function evictApiResource(id: string, locale?: string | null): EvictAPIResourceAction {\n return { type: ActionTypes.EVICT_API_RESOURCE, payload: { id, locale } }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: ActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: ActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: ActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: ActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function setBuilderEditMode(editMode: BuilderEditMode): SetBuilderEditModeAction {\n return {\n type: ActionTypes.SET_BUILDER_EDIT_MODE,\n payload: { editMode },\n }\n}\n\nexport function builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: ActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: ActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function setBreakpoints(breakpoints: Breakpoints): SetBreakpointsAction {\n return { type: ActionTypes.SET_BREAKPOINTS, payload: { breakpoints } }\n}\n\nexport function setLocale(locale: Intl.Locale, pathname?: string): SetLocaleAction {\n return {\n type: ActionTypes.SET_LOCALE,\n payload: { locale: localeStringSchema.parse(locale.toString()), pathname },\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: ActionTypes.SET_LOCALIZED_RESOURCE_ID,\n payload: { resourceId, localizedResourceId, locale },\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,oBAAiD;AAE1C,MAAM,cAAc;AAAA,EACzB,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EAEjB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EAEtB,4BAA4B;AAAA,EAC5B,8BAA8B;AAAA,EAE9B,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EAEnB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,E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E,MAAM,YAAY,iBAAiB,SAAS,EAAE,YAAY,EAAE;AACvE;AAEO,SAAS,UAAU,QAAqB,UAAoC;AACjF,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,SAAS,EAAE,QAAQ,iCAAmB,MAAM,OAAO,SAAS,CAAC,GAAG,SAAS;AAAA,EAC3E;AACF;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAIiC;AAC/B,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,SAAS,EAAE,YAAY,qBAAqB,OAAO;AAAA,EACrD;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,YAAY,yBAAyB,QAAQ;AAC9D;","names":[]}
1
+ {"version":3,"sources":["../../../src/state/actions.ts"],"sourcesContent":["import { type ThunkAction, isAction } from '@reduxjs/toolkit'\nimport type { Operation } from 'ot-json0'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { type Element, type Document, EMBEDDED_DOCUMENT_TYPE } from './modules/read-only-documents'\nimport type { DescriptorsByComponentType } from './modules/prop-controllers'\nimport type { ComponentType } from './modules/react-components'\nimport type { Measurable, BoxModel } from './modules/box-models'\nimport { ComponentMeta } from './modules/components-meta'\nimport { PropControllerDescriptor } from '../prop-controllers'\nimport type { Size } from './react-builder-preview'\nimport type { PropControllersHandle } from './modules/prop-controller-handles'\nimport type { PropControllerMessage } from '../prop-controllers/instances'\nimport type { APIResource, APIResourceType, APIResourceLocale } from '../api/types'\nimport type { SerializedControl } from '../builder'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\nimport { BuilderEditMode } from './modules/builder-edit-mode'\nimport type { Point } from './modules/pointer'\nimport { Breakpoints } from './modules/breakpoints'\nimport { type SerializedState as APIClientCache } from './makeswift-api-client'\nimport { LocaleString, localeStringSchema } from '../locale'\n\nexport { type UnknownAction } from '@reduxjs/toolkit'\n\nexport const ActionTypes = {\n INIT: 'INIT',\n CLEAN_UP: 'CLEAN_UP',\n\n REGISTER_DOCUMENT: 'REGISTER_DOCUMENT',\n UNREGISTER_DOCUMENT: 'UNREGISTER_DOCUMENT',\n CHANGE_DOCUMENT: 'CHANGE_DOCUMENT',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_BUILDER_DOCUMENT: 'REGISTER_BUILDER_DOCUMENT',\n UNREGISTER_BUILDER_DOCUMENT: 'UNREGISTER_BUILDER_DOCUMENT',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n\n REGISTER_BUILDER_COMPONENT: 'REGISTER_BUILDER_COMPONENT',\n UNREGISTER_BUILDER_COMPONENT: 'UNREGISTER_BUILDER_COMPONENT',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n MOUNT_COMPONENT: 'MOUNT_COMPONENT',\n UNMOUNT_COMPONENT: 'UNMOUNT_COMPONENT',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n CHANGE_ELEMENT_BOX_MODELS: 'CHANGE_ELEMENT_BOX_MODELS',\n\n CHANGE_DOCUMENT_ELEMENT_SIZE: 'CHANGE_DOCUMENT_ELEMENT_SIZE',\n CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP: 'CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP',\n SCROLL_DOCUMENT_ELEMENT: 'SCROLL_DOCUMENT_ELEMENT',\n\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n MESSAGE_HOST_PROP_CONTROLLER: 'MESSAGE_HOST_PROP_CONTROLLER',\n MESSAGE_BUILDER_PROP_CONTROLLER: 'MESSAGE_BUILDER_PROP_CONTROLLER',\n\n CHANGE_API_RESOURCE: 'CHANGE_API_RESOURCE',\n EVICT_API_RESOURCE: 'EVICT_API_RESOURCE',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n\n HANDLE_WHEEL: 'HANDLE_WHEEL',\n HANDLE_POINTER_MOVE: 'HANDLE_POINTER_MOVE',\n\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n SET_BUILDER_EDIT_MODE: 'SET_BUILDER_EDIT_MODE',\n MAKESWIFT_CONNECTION_INIT: 'MAKESWIFT_CONNECTION_INIT',\n MAKESWIFT_CONNECTION_CHECK: 'MAKESWIFT_CONNECTION_CHECK',\n\n BUILDER_POINTER_MOVE: 'BUILDER_POINTER_MOVE',\n ELEMENT_FROM_POINT_CHANGE: 'ELEMENT_FROM_POINT_CHANGE',\n\n SET_BREAKPOINTS: 'SET_BREAKPOINTS',\n\n SET_LOCALE: 'SET_LOCALE',\n\n SET_LOCALIZED_RESOURCE_ID: 'SET_LOCALIZED_RESOURCE_ID',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n} as const\n\ntype InitAction = { type: typeof ActionTypes.INIT }\n\ntype CleanUpAction = { type: typeof ActionTypes.CLEAN_UP }\n\ntype DocumentPayloadBaseDocument = {\n key: string\n rootElement: Element\n locale?: string | null // older versions of the runtime may not provide this field\n}\n\ntype DocumentPayloadEmbeddedDocument = {\n key: string\n locale: string | null\n id: string\n type: string\n name: string\n rootElement: Element\n meta: { allowLocaleFallback: boolean; requestedLocale: string | null; description?: string }\n __type: typeof EMBEDDED_DOCUMENT_TYPE\n}\n\nexport type DocumentPayload = DocumentPayloadBaseDocument | DocumentPayloadEmbeddedDocument\n\ntype RegisterDocumentAction = {\n type: typeof ActionTypes.REGISTER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterDocumentAction = {\n type: typeof ActionTypes.UNREGISTER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype ChangeDocumentAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT\n payload: { documentKey: string; operation: Operation }\n}\n\ntype CreateElementTreeAction = {\n type: typeof ActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof ActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\ntype ChangeElementTreeAction = {\n type: typeof ActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterBuilderDocumentAction = {\n type: typeof ActionTypes.REGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterBuilderDocumentAction = {\n type: typeof ActionTypes.UNREGISTER_BUILDER_DOCUMENT\n payload: { documentKey: string }\n}\n\ntype RegisterComponentAction = {\n type: typeof ActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\ntype UnregisterComponentAction = {\n type: typeof ActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterBuilderComponentAction = {\n type: typeof ActionTypes.REGISTER_BUILDER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n serializedControls: Record<string, SerializedControl>\n }\n transferables?: Transferable[]\n}\n\ntype UnregisterBuilderComponentAction = {\n type: typeof ActionTypes.UNREGISTER_BUILDER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof ActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof ActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\ntype MountComponentAction = {\n type: typeof ActionTypes.MOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UnmountComponentAction = {\n type: typeof ActionTypes.UNMOUNT_COMPONENT\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype ChangeElementBoxModelsAction = {\n type: typeof ActionTypes.CHANGE_ELEMENT_BOX_MODELS\n payload: { changedElementBoxModels: Map<string, Map<string, BoxModel | null>> }\n}\n\ntype ChangeDocumentElementSizeAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE\n payload: { size: Size }\n}\n\ntype ChangeDocumentElementScrollTopAction = {\n type: typeof ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP\n payload: { scrollTop: number }\n}\n\ntype ScrollDocumentElementAction = {\n type: typeof ActionTypes.SCROLL_DOCUMENT_ELEMENT\n payload: { scrollTopDelta: number }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype MessageHostPropControllerAction<T = PropControllerMessage> = {\n type: typeof ActionTypes.MESSAGE_HOST_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype MessageBuilderPropControllerAction<T = PropControllerMessage> = {\n type: typeof ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype ChangeAPIResourceAction = {\n type: typeof ActionTypes.CHANGE_API_RESOURCE\n payload: { resource: APIResource; locale?: string | null }\n}\n\ntype EvictAPIResourceAction = {\n type: typeof ActionTypes.EVICT_API_RESOURCE\n payload: { id: string; locale?: string | null }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof ActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype HandleWheelAction = {\n type: typeof ActionTypes.HANDLE_WHEEL\n payload: { deltaX: number; deltaY: number }\n}\n\ntype HandlePointerMoveAction = {\n type: typeof ActionTypes.HANDLE_POINTER_MOVE\n payload: { clientX: number; clientY: number }\n}\n\ntype APIResourceFulfilledAction = {\n type: typeof ActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype SetBuilderEditModeAction = {\n type: typeof ActionTypes.SET_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype BuilderPointerMoveAction = {\n type: typeof ActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\ntype ElementFromPointChangeAction = {\n type: typeof ActionTypes.ELEMENT_FROM_POINT_CHANGE\n payload: { keys: { documentKey: string; elementKey: string } | null }\n}\n\nexport type SetBreakpointsAction = {\n type: typeof ActionTypes.SET_BREAKPOINTS\n payload: { breakpoints: Breakpoints }\n}\n\ntype SetLocaleAction = {\n type: typeof ActionTypes.SET_LOCALE\n payload: { locale: LocaleString; pathname?: string }\n}\n\ntype SetLocalizedResourceIdAction = {\n type: typeof ActionTypes.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 UpdateAPIClientCache = {\n type: typeof ActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\nexport type Action =\n | InitAction\n | CleanUpAction\n | RegisterDocumentAction\n | UnregisterDocumentAction\n | ChangeDocumentAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | ChangeElementTreeAction\n | RegisterBuilderDocumentAction\n | UnregisterBuilderDocumentAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterBuilderComponentAction\n | UnregisterBuilderComponentAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | MountComponentAction\n | UnmountComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | ChangeElementBoxModelsAction\n | ChangeDocumentElementSizeAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | MessageHostPropControllerAction\n | MessageBuilderPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetIsInBuilderAction\n | HandleWheelAction\n | HandlePointerMoveAction\n | APIResourceFulfilledAction\n | SetBuilderEditModeAction\n | BuilderPointerMoveAction\n | ElementFromPointChangeAction\n | SetBreakpointsAction\n | SetLocaleAction\n | SetLocalizedResourceIdAction\n | UpdateAPIClientCache\n\nexport function init(): InitAction {\n return { type: ActionTypes.INIT }\n}\n\nexport function cleanUp(): CleanUpAction {\n return { type: ActionTypes.CLEAN_UP }\n}\n\nexport function registerDocument(document: Document): RegisterDocumentAction {\n return { type: ActionTypes.REGISTER_DOCUMENT, payload: { documentKey: document.key, document } }\n}\n\nexport function unregisterDocument(documentKey: string): UnregisterDocumentAction {\n return { type: ActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: ActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: ActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerBuilderDocument(document: Document): RegisterBuilderDocumentAction {\n return {\n type: ActionTypes.REGISTER_BUILDER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterBuilderDocument(documentKey: string): UnregisterBuilderDocumentAction {\n return { type: ActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n documents.forEach(document => dispatch(registerDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterDocument(document.key)))\n }\n }\n}\n\nexport function registerBuilderDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, Action> {\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 changeDocument(documentKey: string, operation: Operation): ChangeDocumentAction {\n return { type: ActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: ActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: ActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerBuilderComponent(\n payload: RegisterBuilderComponentAction['payload'],\n transferables?: Transferable[],\n): RegisterBuilderComponentAction {\n return {\n type: ActionTypes.REGISTER_BUILDER_COMPONENT,\n payload,\n transferables,\n }\n}\n\nexport function unregisterBuilderComponent(\n payload: UnregisterBuilderComponentAction['payload'],\n): UnregisterBuilderComponentAction {\n return { type: ActionTypes.UNREGISTER_BUILDER_COMPONENT, payload }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: ActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: ActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function mountComponent(documentKey: string, elementKey: string): MountComponentAction {\n return { type: ActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function unmountComponent(documentKey: string, elementKey: string): UnmountComponentAction {\n return { type: ActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } }\n}\n\nexport function mountComponentEffect(\n documentKey: string,\n elementKey: string,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(mountComponent(documentKey, elementKey))\n\n return () => {\n dispatch(unmountComponent(documentKey, elementKey))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return { type: ActionTypes.UNREGISTER_COMPONENT_HANDLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return { type: ActionTypes.REGISTER_MEASURABLE, payload: { documentKey, elementKey, measurable } }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function changeElementBoxModels(\n changedElementBoxModels: Map<string, Map<string, BoxModel | null>>,\n): ChangeElementBoxModelsAction {\n return { type: ActionTypes.CHANGE_ELEMENT_BOX_MODELS, payload: { changedElementBoxModels } }\n}\n\nexport function changeDocumentElementSize(size: Size): ChangeDocumentElementSizeAction {\n return { type: ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } }\n}\n\nexport function changeDocumentElementScrollTop(\n scrollTop: number,\n): ChangeDocumentElementScrollTopAction {\n return { type: ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } }\n}\n\nexport function scrollDocumentElement(scrollTopDelta: number): ScrollDocumentElementAction {\n return { type: ActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return { type: ActionTypes.UNREGISTER_PROP_CONTROLLERS, payload: { documentKey, elementKey } }\n}\n\nexport function messageHostPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageHostPropControllerAction<T> {\n return {\n type: ActionTypes.MESSAGE_HOST_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\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: ActionTypes.MESSAGE_BUILDER_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: ActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } }\n}\n\nexport function evictApiResource(id: string, locale?: string | null): EvictAPIResourceAction {\n return { type: ActionTypes.EVICT_API_RESOURCE, payload: { id, locale } }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: ActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function handleWheel(payload: { deltaX: number; deltaY: number }): HandleWheelAction {\n return { type: ActionTypes.HANDLE_WHEEL, payload }\n}\n\nexport function handlePointerMove(payload: {\n clientX: number\n clientY: number\n}): HandlePointerMoveAction {\n return { type: ActionTypes.HANDLE_POINTER_MOVE, payload }\n}\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: ActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function setBuilderEditMode(editMode: BuilderEditMode): SetBuilderEditModeAction {\n return {\n type: ActionTypes.SET_BUILDER_EDIT_MODE,\n payload: { editMode },\n }\n}\n\nexport function builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: ActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n\nexport function elementFromPointChange(\n keys: {\n documentKey: string\n elementKey: string\n } | null,\n): ElementFromPointChangeAction {\n return { type: ActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } }\n}\n\nexport function setBreakpoints(breakpoints: Breakpoints): SetBreakpointsAction {\n return { type: ActionTypes.SET_BREAKPOINTS, payload: { breakpoints } }\n}\n\nexport function setLocale(locale: Intl.Locale, pathname?: string): SetLocaleAction {\n return {\n type: ActionTypes.SET_LOCALE,\n payload: { locale: localeStringSchema.parse(locale.toString()), pathname },\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: ActionTypes.SET_LOCALIZED_RESOURCE_ID,\n payload: { resourceId, localizedResourceId, locale },\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n\nexport function isKnownAction(action: unknown): action is Action {\n return isAction(action) && Object.hasOwn(ActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2C;AAqB3C,oBAAiD;AAI1C,MAAM,cAAc;AAAA,EACzB,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EAEjB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EAEtB,4BAA4B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,QAAQ,EAAE;AACxE;AAEO,SAAS,uBACd,MAI8B;AAC9B,SAAO,EAAE,MAAM,YAAY,2BAA2B,SAAS,EAAE,KAAK,EAAE;AAC1E;AAEO,SAAS,eAAe,aAAgD;AAC7E,SAAO,EAAE,MAAM,YAAY,iBAAiB,SAAS,EAAE,YAAY,EAAE;AACvE;AAEO,SAAS,UAAU,QAAqB,UAAoC;AACjF,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,SAAS,EAAE,QAAQ,iCAAmB,MAAM,OAAO,SAAS,CAAC,GAAG,SAAS;AAAA,EAC3E;AACF;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAIiC;AAC/B,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,SAAS,EAAE,YAAY,qBAAqB,OAAO;AAAA,EACrD;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,YAAY,yBAAyB,QAAQ;AAC9D;AAEO,SAAS,cAAc,QAAmC;AAC/D,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,aAAa,OAAO,IAAI;AACnE;","names":[]}
@@ -34,17 +34,13 @@ __export(makeswift_api_client_exports, {
34
34
  getHasAPIResource: () => getHasAPIResource
35
35
  });
36
36
  module.exports = __toCommonJS(makeswift_api_client_exports);
37
- var import_redux = require("redux");
38
- var import_redux_thunk = __toESM(require("redux-thunk"));
39
- var import_extension = require("@redux-devtools/extension");
40
- var import_serializeState = require("../utils/serializeState");
37
+ var import_toolkit = require("@reduxjs/toolkit");
41
38
  var APIResources = __toESM(require("./modules/api-resources"));
42
39
  var LocalizedResourcesMap = __toESM(require("./modules/localized-resources-map"));
43
40
  var import_actions = require("./actions");
41
+ var import_toolkit2 = require("./toolkit");
44
42
  var import_api = require("../api");
45
- var import_cache = require("../next/cache");
46
- var import_site_version = require("../api/site-version");
47
- const reducer = (0, import_redux.combineReducers)({
43
+ const reducer = (0, import_toolkit.combineReducers)({
48
44
  apiResources: APIResources.reducer,
49
45
  localizedResourcesMap: LocalizedResourcesMap.reducer
50
46
  });
@@ -81,26 +77,24 @@ function getAPIResource(state, resourceType, resourceId, locale) {
81
77
  return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale);
82
78
  }
83
79
  }
84
- async function fetchJson(url, siteVersion) {
85
- const response = await fetch(url, {
86
- headers: {
87
- "Content-Type": "application/json",
88
- [import_site_version.API_HANDLER_SITE_VERSION_HEADER]: siteVersion
89
- },
90
- next: { tags: [import_cache.MAKESWIFT_CACHE_TAG] }
91
- });
92
- if (response.status === 404)
93
- return null;
94
- if (!response.ok)
95
- throw new Error(response.statusText);
96
- if (response.headers.get("content-type")?.includes("application/json") !== true) {
97
- throw new Error(
98
- `Expected JSON response from "${url}" but got "${response.headers.get("content-type")}"`
99
- );
100
- }
101
- return response.json();
102
- }
103
- function fetchAPIResource(resourceType, resourceId, siteVersion, locale) {
80
+ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
81
+ const fetchJson = async (url) => {
82
+ const response = await fetch(url, {
83
+ headers: {
84
+ "Content-Type": "application/json"
85
+ }
86
+ });
87
+ if (response.status === 404)
88
+ return null;
89
+ if (!response.ok)
90
+ throw new Error(response.statusText);
91
+ if (response.headers.get("content-type")?.includes("application/json") !== true) {
92
+ throw new Error(
93
+ `Expected JSON response from "${url}" but got "${response.headers.get("content-type")}"`
94
+ );
95
+ }
96
+ return response.json();
97
+ };
104
98
  return async (dispatch, getState) => {
105
99
  const state = getState();
106
100
  if (getHasAPIResource(state, resourceType, resourceId, locale)) {
@@ -109,22 +103,16 @@ function fetchAPIResource(resourceType, resourceId, siteVersion, locale) {
109
103
  let resource;
110
104
  switch (resourceType) {
111
105
  case import_api.APIResourceType.Swatch:
112
- resource = await fetchJson(`/api/makeswift/swatches/${resourceId}`, siteVersion);
106
+ resource = await fetchJson(`/api/makeswift/swatches/${resourceId}`);
113
107
  break;
114
108
  case import_api.APIResourceType.File:
115
- resource = await fetchJson(`/api/makeswift/files/${resourceId}`, siteVersion);
109
+ resource = await fetchJson(`/api/makeswift/files/${resourceId}`);
116
110
  break;
117
111
  case import_api.APIResourceType.Typography:
118
- resource = await fetchJson(
119
- `/api/makeswift/typographies/${resourceId}`,
120
- siteVersion
121
- );
112
+ resource = await fetchJson(`/api/makeswift/typographies/${resourceId}`);
122
113
  break;
123
114
  case import_api.APIResourceType.GlobalElement:
124
- resource = await fetchJson(
125
- `/api/makeswift/global-elements/${resourceId}`,
126
- siteVersion
127
- );
115
+ resource = await fetchJson(`/api/makeswift/global-elements/${resourceId}`);
128
116
  break;
129
117
  case import_api.APIResourceType.LocalizedGlobalElement: {
130
118
  if (locale == null)
@@ -133,8 +121,7 @@ function fetchAPIResource(resourceType, resourceId, siteVersion, locale) {
133
121
  return null;
134
122
  }
135
123
  resource = await fetchJson(
136
- `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,
137
- siteVersion
124
+ `/api/makeswift/localized-global-elements/${resourceId}/${locale}`
138
125
  );
139
126
  dispatch(
140
127
  (0, import_actions.setLocalizedResourceId)({
@@ -149,11 +136,11 @@ function fetchAPIResource(resourceType, resourceId, siteVersion, locale) {
149
136
  const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, "http://n");
150
137
  if (locale != null)
151
138
  url.searchParams.set("locale", locale);
152
- resource = await fetchJson(url.pathname + url.search, siteVersion);
139
+ resource = await fetchJson(url.pathname + url.search);
153
140
  break;
154
141
  }
155
142
  case import_api.APIResourceType.Table:
156
- resource = await fetchJson(`/api/makeswift/tables/${resourceId}`, siteVersion);
143
+ resource = await fetchJson(`/api/makeswift/tables/${resourceId}`);
157
144
  break;
158
145
  default:
159
146
  resource = null;
@@ -163,7 +150,7 @@ function fetchAPIResource(resourceType, resourceId, siteVersion, locale) {
163
150
  };
164
151
  }
165
152
  function defaultLocaleMiddleware(defaultLocale) {
166
- return () => (next) => {
153
+ return (0, import_toolkit2.actionMiddleware)(() => (next) => {
167
154
  return (action) => {
168
155
  switch (action.type) {
169
156
  case import_actions.ActionTypes.CHANGE_API_RESOURCE:
@@ -178,32 +165,30 @@ function defaultLocaleMiddleware(defaultLocale) {
178
165
  }
179
166
  return next(action);
180
167
  };
181
- };
168
+ });
182
169
  }
183
170
  function configureStore({
184
171
  defaultLocale,
185
172
  serializedState
186
173
  }) {
187
- const composeEnhancers = (0, import_extension.composeWithDevToolsDevelopmentOnly)({
188
- name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
189
- serialize: true,
190
- stateSanitizer: (state) => (0, import_serializeState.serializeState)(state),
191
- actionsDenylist: [
192
- import_actions.ActionTypes.BUILDER_POINTER_MOVE,
193
- import_actions.ActionTypes.HANDLE_POINTER_MOVE,
194
- import_actions.ActionTypes.ELEMENT_FROM_POINT_CHANGE
195
- ]
196
- });
197
- return (0, import_redux.createStore)(
174
+ return (0, import_toolkit.configureStore)({
198
175
  reducer,
199
- {
176
+ preloadedState: {
200
177
  apiResources: APIResources.getInitialState(serializedState?.apiResources),
201
178
  localizedResourcesMap: LocalizedResourcesMap.getInitialState(
202
179
  serializedState?.localizedResourcesMap
203
180
  )
204
181
  },
205
- composeEnhancers((0, import_redux.applyMiddleware)(import_redux_thunk.default, defaultLocaleMiddleware(defaultLocale)))
206
- );
182
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),
183
+ devTools: (0, import_toolkit2.devToolsConfig)({
184
+ name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
185
+ actionsDenylist: [
186
+ import_actions.ActionTypes.BUILDER_POINTER_MOVE,
187
+ import_actions.ActionTypes.HANDLE_POINTER_MOVE,
188
+ import_actions.ActionTypes.ELEMENT_FROM_POINT_CHANGE
189
+ ]
190
+ })
191
+ });
207
192
  }
208
193
  // Annotate the CommonJS export names for ESM import in node:
209
194
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n applyMiddleware,\n createStore,\n combineReducers,\n type Dispatch as ReduxDispatch,\n type Store as ReduxStore,\n type Middleware,\n} from 'redux'\nimport thunk, { type ThunkAction, type ThunkDispatch } from 'redux-thunk'\n\nimport { composeWithDevToolsDevelopmentOnly } from '@redux-devtools/extension'\n\nimport { serializeState } from '../utils/serializeState'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes, apiResourceFulfilled, setLocalizedResourceId } from './actions'\nimport {\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'\nimport { MAKESWIFT_CACHE_TAG } from '../next/cache'\nimport { API_HANDLER_SITE_VERSION_HEADER, MakeswiftSiteVersion } from '../api/site-version'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\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\nasync function fetchJson<T>(url: string, siteVersion: MakeswiftSiteVersion): Promise<T | null> {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n [API_HANDLER_SITE_VERSION_HEADER]: siteVersion,\n },\n next: { tags: [MAKESWIFT_CACHE_TAG] },\n })\n\n if (response.status === 404) return null\n\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\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n siteVersion: MakeswiftSiteVersion,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\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}`, siteVersion)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`, siteVersion)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(\n `/api/makeswift/typographies/${resourceId}`,\n siteVersion,\n )\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(\n `/api/makeswift/global-elements/${resourceId}`,\n siteVersion,\n )\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n siteVersion,\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, siteVersion)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`, siteVersion)\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\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\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): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: 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}): Store {\n const composeEnhancers = composeWithDevToolsDevelopmentOnly({\n name: `API client store (${new Date().toISOString()})`,\n serialize: true,\n stateSanitizer: (state: any) => serializeState(state),\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n })\n\n return createStore(\n reducer,\n {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n composeEnhancers(applyMiddleware(thunk, defaultLocaleMiddleware(defaultLocale))),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAOO;AACP,yBAA4D;AAE5D,uBAAmD;AAEnD,4BAA+B;AAE/B,mBAA8B;AAC9B,4BAAuC;AACvC,qBAAuF;AACvF,iBAWO;AACP,mBAAoC;AACpC,0BAAsE;AAEtE,MAAM,cAAU,8BAAgB;AAAA,EAC9B,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AASD,SAAS,uBACP,OACA,QACA,YAC2B;AAC3B,SAAO,sBAAsB;AAAA,IAC3B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,OACA,cACA,YACA,QACS;AACT,UAAQ,cAAc;AAAA,IACpB,KAAK,2BAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aACE,eAAe,QACf,aAAa,kBAAkB,MAAM,cAAc,cA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5C,WAAO,CAAC,WAA2B;AACjC,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS,EAAE,GAAG,OAAO,SAAS,QAAQ,UAAU,cAAc;AAAA,UAChE,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF;AACF;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AACF,GAGU;AACR,QAAM,uBAAmB,qDAAmC;AAAA,IAC1D,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,IACnD,WAAW;AAAA,IACX,gBAAgB,CAAC,cAAe,sCAAe,KAAK;AAAA,IACpD,iBAAiB;AAAA,MACf,2BAAY;AAAA,MACZ,2BAAY;AAAA,MACZ,2BAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,aAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,cAAc,aAAa,gBAAgB,iBAAiB,YAAY;AAAA,MACxE,uBAAuB,sBAAsB;AAAA,QAC3C,iBAAiB;AAAA,MACnB;AAAA,IACF;AAAA,IACA,qBAAiB,8BAAgB,mBAAAA,SAAO,wBAAwB,aAAa,CAAC,CAAC;AAAA,EACjF;AACF;","names":["thunk"]}
1
+ {"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes, apiResourceFulfilled, setLocalizedResourceId } from './actions'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchJson = async <T>(url: string): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchJson<Swatch>(`/api/makeswift/swatches/${resourceId}`)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(`/api/makeswift/typographies/${resourceId}`)\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(`/api/makeswift/global-elements/${resourceId}`)\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchJson<PagePathnameSlice>(url.pathname + url.search)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(\n defaultLocale: string | undefined,\n): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: { ...action.payload, locale: locale ?? defaultLocale },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n defaultLocale,\n serializedState,\n}: {\n defaultLocale: string | undefined\n serializedState?: SerializedState\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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,2BAAY;AAAA,QACZ,2BAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","configureReduxStore"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/mixins/setup-teardown.ts"],"sourcesContent":["import { StoreEnhancer } from 'redux'\n\nexport interface SetupTeardownMixin {\n setup: () => void\n teardown: () => void\n}\n\nexport function withSetupTeardown(\n setup: () => void,\n teardown: () => void,\n): StoreEnhancer<SetupTeardownMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n setup,\n teardown,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,kBACd,OACA,UACmC;AACnC,SAAO,UAAQ,CAAC,SAAS,oBAAqB;AAAA,IAC5C,GAAG,KAAK,SAAS,cAAc;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/mixins/setup-teardown.ts"],"sourcesContent":["import { type StoreEnhancer } from '@reduxjs/toolkit'\n\nexport interface SetupTeardownMixin {\n setup: () => void\n teardown: () => void\n}\n\nexport function withSetupTeardown(\n setup: () => void,\n teardown: () => void,\n): StoreEnhancer<SetupTeardownMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n setup,\n teardown,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,kBACd,OACA,UACmC;AACnC,SAAO,UAAQ,CAAC,SAAS,oBAAqB;AAAA,IAC5C,GAAG,KAAK,SAAS,cAAc;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -113,6 +113,8 @@ function getAPIResource(state, resourceType, resourceId, locale) {
113
113
  return resource?.__typename === resourceType ? resource : null;
114
114
  }
115
115
  function reducer(state = getInitialState(), action) {
116
+ if (!(0, import_actions.isKnownAction)(action))
117
+ return state;
116
118
  switch (action.type) {
117
119
  case import_actions.ActionTypes.UPDATE_API_CLIENT_CACHE: {
118
120
  const { apiResources } = action.payload;
@@ -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, ActionTypes } 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): State {\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,qBAAyC;AAIzC,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,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AAc,MAAM;AAAA,UAC5C;AAAA,QACF;AAAA,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"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return r.get(cid) != null ? r : new Map(r).set(cid, value)\n }, existing)\n\n return updated == null || updated === existing\n ? state\n : new Map(state).set(resType, updated)\n }, state)\n }\n\n case ActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case ActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case ActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,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,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,wBAAwB,CAAC;AAC3B,GACO;AACP,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,eAAe,EAAE,IAAI,CAAC,CAAC,cAAc,SAAS,MAAM;AAAA,MACjE;AAAA,MACA,IAAI;AAAA,QACF,UAAU,IAAI,CAAC,EAAE,IAAI,OAAO,OAAO,MAAM;AAAA,UACvC,YAAY,IAAI,cAAiC,MAAM;AAAA,UACvD;AAAA,QACF,CAAC;AAA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,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"]}
@@ -68,6 +68,8 @@ function getBoxModel(state, documentKey, elementKey) {
68
68
  return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null;
69
69
  }
70
70
  function reducer(state = getInitialState(), action) {
71
+ if (!(0, import_actions.isKnownAction)(action))
72
+ return state;
71
73
  switch (action.type) {
72
74
  case import_actions.ActionTypes.REGISTER_MEASURABLE: {
73
75
  const { documentKey, elementKey, measurable } = action.payload;
@@ -1 +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 { Action, ActionTypes } 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) {\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,qBAAoC;AAI7B,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,SA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c,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["createBoxWithoutScroll","getBoxWithoutScroll"]}
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,qCAA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I,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,gBAAgB,OAAO,UAAU;AAEjD,aAAO,UACH,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,MAAM,WAAW,EAAE,IAAI,aAAa,eAAe,EAAE,IACtF;AAAA,IACN;AAAA,IAEA,KAAK,2BAAY,2BAA2B;AAC1C,YAAM,EAAE,wBAAwB,IAAI,OAAO;AAE3C,UAAI,wBAAwB,SAAS;AAAG,eAAO;AAE/C,YAAM,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAE7C,8BAAwB,QAAQ,CAAC,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["createBoxWithoutScroll","getBoxWithoutScroll"]}
@@ -57,6 +57,8 @@ function getInitialState(breakpoints = DEFAULT_BREAKPOINTS) {
57
57
  return breakpoints;
58
58
  }
59
59
  function reducer(state = getInitialState(), action) {
60
+ if (!(0, import_actions.isKnownAction)(action))
61
+ return state;
60
62
  switch (action.type) {
61
63
  case import_actions.ActionTypes.SET_BREAKPOINTS: {
62
64
  const breakpoints = action.payload.breakpoints;
@@ -110,7 +112,7 @@ function validateBreakpointsInput(input) {
110
112
  const next = array[index + 1];
111
113
  if (viewport && next && viewport < next.width) {
112
114
  throw new Error(
113
- `Error on breakpoint "${id}". Viewport cannot be smaller than the next breakpoint's width.
115
+ `Error on breakpoint "${id}". Viewport cannot be smaller than the next breakpoint's width.
114
116
  "${id}" has a viewport of ${viewport}px and the next breakpoint "${next.id}" has a width of ${next.width}px.`
115
117
  );
116
118
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import { type Breakpoint, type Breakpoints } from '@makeswift/controls'\n\nimport { Action, ActionTypes } 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): State {\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,qBAAoC;AAEpC,IAAAA,mBAKO;AAIA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAA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,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE;AAAA,IACrF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,yBAAyB,OAAyB;AACzD,MAAI,oBAAoB,WAAW,OAAO;AACxC,UAAM,IAAI;AAAA,MACR,uCAAuC,oBAAoB,OAAO;AAAA,IACpE;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_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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AAAA,EACF;AAEA,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_controls"]}
@@ -33,6 +33,8 @@ function getInitialState() {
33
33
  return null;
34
34
  }
35
35
  function reducer(state = getInitialState(), action) {
36
+ if (!(0, import_actions.isKnownAction)(action))
37
+ return state;
36
38
  switch (action.type) {
37
39
  case import_actions.ActionTypes.SET_BUILDER_EDIT_MODE:
38
40
  return action.payload.editMode;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/builder-edit-mode.ts"],"sourcesContent":["import { Action, ActionTypes } 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): State {\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,qBAAoC;AAE7B,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AACZ;AAMO,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,2BAAY;AACf,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":[]}
@@ -58,6 +58,8 @@ function getComponentsMeta(state) {
58
58
  return state;
59
59
  }
60
60
  function reducer(state = getInitialState(), action) {
61
+ if (!(0, import_actions.isKnownAction)(action))
62
+ return state;
61
63
  switch (action.type) {
62
64
  case import_actions.ActionTypes.REGISTER_COMPONENT:
63
65
  return new Map(state).set(action.payload.type, action.payload.meta);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { Action, ActionTypes } 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 = { label: string; icon: ComponentIcon; hidden: boolean, description?: string }\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 reducer(state: State = getInitialState(), action: Action): State {\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,qBAAoC;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;AAQO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuB;AAC/E,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":[]}
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}\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 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,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;AAaO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,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,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":[]}
@@ -30,6 +30,8 @@ function getInitialState() {
30
30
  return /* @__PURE__ */ new Map();
31
31
  }
32
32
  function reducer(state = getInitialState(), action) {
33
+ if (!(0, import_actions.isKnownAction)(action))
34
+ return state;
33
35
  switch (action.type) {
34
36
  case import_actions.ActionTypes.REGISTER_COMPONENT_HANDLE:
35
37
  return new Map(state).set(