@makeswift/runtime 0.28.8-canary.13 → 0.28.8-canary.16

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 (334) hide show
  1. package/dist/cjs/api/graphql-api-client.js +1 -1
  2. package/dist/cjs/api/rest-api-client.js +1 -1
  3. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  4. package/dist/cjs/builder/host-to-builder-actions.js +5 -5
  5. package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
  6. package/dist/cjs/client/index.js +1 -1
  7. package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
  8. package/dist/cjs/next/testing/breakpoints.js +3 -15
  9. package/dist/cjs/next/testing/breakpoints.js.map +1 -1
  10. package/dist/cjs/next/testing/element-data.js +3 -82
  11. package/dist/cjs/next/testing/element-data.js.map +1 -1
  12. package/dist/cjs/next/testing/react-runtime.js.map +1 -1
  13. package/dist/cjs/runtimes/react/components/Element.js +21 -6
  14. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  15. package/dist/cjs/runtimes/react/components/ElementRegistration.js +5 -3
  16. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  17. package/dist/cjs/runtimes/react/components/resolve-props.js +5 -1
  18. package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
  19. package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  20. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +2 -2
  21. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  22. package/dist/cjs/runtimes/react/element-imperative-handle.js +2 -2
  23. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  24. package/dist/cjs/runtimes/react/hooks/use-control-instances.js +4 -3
  25. package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -1
  26. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +10 -9
  27. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  28. package/dist/cjs/runtimes/react/testing/index.js +25 -0
  29. package/dist/cjs/runtimes/react/testing/index.js.map +1 -0
  30. package/dist/cjs/runtimes/react/testing/react-provider.js +38 -0
  31. package/dist/cjs/runtimes/react/testing/react-provider.js.map +1 -0
  32. package/dist/cjs/state/actions/index.js +4 -4
  33. package/dist/cjs/state/actions/index.js.map +1 -1
  34. package/dist/cjs/state/actions/internal/action-types.js +34 -0
  35. package/dist/cjs/state/actions/internal/action-types.js.map +1 -0
  36. package/dist/cjs/state/actions/internal/index.js +0 -17
  37. package/dist/cjs/state/actions/internal/index.js.map +1 -1
  38. package/dist/cjs/state/actions/internal/read-only-action-types.js +44 -0
  39. package/dist/cjs/state/actions/internal/read-only-action-types.js.map +1 -0
  40. package/dist/cjs/state/actions/internal/read-only-actions.js +13 -92
  41. package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
  42. package/dist/cjs/state/actions/internal/read-write-action-types.js +41 -0
  43. package/dist/cjs/state/actions/internal/read-write-action-types.js.map +1 -0
  44. package/dist/cjs/state/actions/internal/read-write-actions.js +64 -14
  45. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  46. package/dist/cjs/state/builder-api/action-types.js +49 -0
  47. package/dist/cjs/state/builder-api/action-types.js.map +1 -0
  48. package/dist/cjs/state/builder-api/actions.js +14 -36
  49. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  50. package/dist/cjs/state/builder-api/proxy.js +2 -1
  51. package/dist/cjs/state/builder-api/proxy.js.map +1 -1
  52. package/dist/cjs/state/host-api/action-types.js +43 -0
  53. package/dist/cjs/state/host-api/action-types.js.map +1 -0
  54. package/dist/cjs/state/{host-api.js → host-api/actions.js} +17 -33
  55. package/dist/cjs/state/host-api/actions.js.map +1 -0
  56. package/dist/cjs/state/host-api/index.js +25 -0
  57. package/dist/cjs/state/host-api/index.js.map +1 -0
  58. package/dist/cjs/state/middleware/read-write/builder-api/index.js +15 -15
  59. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
  60. package/dist/cjs/state/middleware/read-write/measure-box-models.js +3 -3
  61. package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +1 -1
  62. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +13 -13
  63. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  64. package/dist/cjs/state/modules/api-resources.js +5 -5
  65. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  66. package/dist/cjs/state/modules/breakpoints.js +4 -4
  67. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  68. package/dist/cjs/state/modules/components-meta.js +3 -3
  69. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  70. package/dist/cjs/state/modules/element-trees.js +5 -5
  71. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  72. package/dist/cjs/state/modules/is-in-builder.js +2 -2
  73. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  74. package/dist/cjs/state/modules/is-read-only.js +2 -2
  75. package/dist/cjs/state/modules/is-read-only.js.map +1 -1
  76. package/dist/cjs/state/modules/locale.js +2 -2
  77. package/dist/cjs/state/modules/locale.js.map +1 -1
  78. package/dist/cjs/state/modules/localized-resources-map.js +3 -3
  79. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  80. package/dist/cjs/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +7 -7
  81. package/dist/cjs/state/modules/prop-controller-descriptors.js.map +1 -0
  82. package/dist/cjs/state/modules/react-components.js +3 -3
  83. package/dist/cjs/state/modules/react-components.js.map +1 -1
  84. package/dist/cjs/state/modules/read-write/box-models.js +5 -5
  85. package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
  86. package/dist/cjs/state/modules/read-write/element-imperative-handles.js +3 -3
  87. package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +1 -1
  88. package/dist/cjs/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +5 -5
  89. package/dist/cjs/state/modules/read-write/prop-controllers.js.map +1 -0
  90. package/dist/cjs/state/read-only-state.js +9 -44
  91. package/dist/cjs/state/read-only-state.js.map +1 -1
  92. package/dist/cjs/state/read-write-state.js +37 -0
  93. package/dist/cjs/state/read-write-state.js.map +1 -1
  94. package/dist/cjs/state/shared-api/action-types.js +33 -0
  95. package/dist/cjs/state/shared-api/action-types.js.map +1 -0
  96. package/dist/cjs/state/{shared-api.js → shared-api/actions.js} +8 -14
  97. package/dist/cjs/state/shared-api/actions.js.map +1 -0
  98. package/dist/cjs/state/shared-api/index.js +25 -0
  99. package/dist/cjs/state/shared-api/index.js.map +1 -0
  100. package/dist/cjs/state/store.js +3 -3
  101. package/dist/cjs/state/store.js.map +1 -1
  102. package/dist/cjs/state/translations/get.js.map +1 -1
  103. package/dist/cjs/state/translations/merge.js.map +1 -1
  104. package/dist/cjs/state/unified-state.js +12 -0
  105. package/dist/cjs/state/unified-state.js.map +1 -1
  106. package/dist/cjs/testing/breakpoints.js +35 -0
  107. package/dist/cjs/testing/breakpoints.js.map +1 -0
  108. package/dist/cjs/testing/element-data.js +102 -0
  109. package/dist/cjs/testing/element-data.js.map +1 -0
  110. package/dist/cjs/translations/index.js.map +1 -1
  111. package/dist/esm/api/graphql-api-client.js +1 -1
  112. package/dist/esm/api/rest-api-client.js +1 -1
  113. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  114. package/dist/esm/builder/host-to-builder-actions.js +2 -4
  115. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  116. package/dist/esm/client/index.js +1 -1
  117. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  118. package/dist/esm/next/testing/breakpoints.js +1 -8
  119. package/dist/esm/next/testing/breakpoints.js.map +1 -1
  120. package/dist/esm/next/testing/element-data.js +1 -75
  121. package/dist/esm/next/testing/element-data.js.map +1 -1
  122. package/dist/esm/next/testing/react-runtime.js.map +1 -1
  123. package/dist/esm/runtimes/react/components/Element.js +18 -6
  124. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  125. package/dist/esm/runtimes/react/components/ElementRegistration.js +4 -2
  126. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  127. package/dist/esm/runtimes/react/components/resolve-props.js +5 -1
  128. package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
  129. package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  130. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +1 -1
  131. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  132. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  133. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  134. package/dist/esm/runtimes/react/hooks/use-control-instances.js +3 -2
  135. package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -1
  136. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -9
  137. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  138. package/dist/esm/runtimes/react/testing/index.js +3 -0
  139. package/dist/esm/runtimes/react/testing/index.js.map +1 -0
  140. package/dist/esm/runtimes/react/testing/react-provider.js +14 -0
  141. package/dist/esm/runtimes/react/testing/react-provider.js.map +1 -0
  142. package/dist/esm/state/actions/index.js +2 -2
  143. package/dist/esm/state/actions/index.js.map +1 -1
  144. package/dist/esm/state/actions/internal/action-types.js +10 -0
  145. package/dist/esm/state/actions/internal/action-types.js.map +1 -0
  146. package/dist/esm/state/actions/internal/index.js +0 -9
  147. package/dist/esm/state/actions/internal/index.js.map +1 -1
  148. package/dist/esm/state/actions/internal/read-only-action-types.js +20 -0
  149. package/dist/esm/state/actions/internal/read-only-action-types.js.map +1 -0
  150. package/dist/esm/state/actions/internal/read-only-actions.js +1 -73
  151. package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
  152. package/dist/esm/state/actions/internal/read-write-action-types.js +17 -0
  153. package/dist/esm/state/actions/internal/read-write-action-types.js.map +1 -0
  154. package/dist/esm/state/actions/internal/read-write-actions.js +52 -8
  155. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  156. package/dist/esm/state/builder-api/action-types.js +25 -0
  157. package/dist/esm/state/builder-api/action-types.js.map +1 -0
  158. package/dist/esm/state/builder-api/actions.js +1 -24
  159. package/dist/esm/state/builder-api/actions.js.map +1 -1
  160. package/dist/esm/state/builder-api/proxy.js +2 -1
  161. package/dist/esm/state/builder-api/proxy.js.map +1 -1
  162. package/dist/esm/state/host-api/action-types.js +19 -0
  163. package/dist/esm/state/host-api/action-types.js.map +1 -0
  164. package/dist/esm/state/{host-api.js → host-api/actions.js} +2 -17
  165. package/dist/esm/state/host-api/actions.js.map +1 -0
  166. package/dist/esm/state/host-api/index.js +3 -0
  167. package/dist/esm/state/host-api/index.js.map +1 -0
  168. package/dist/esm/state/middleware/read-write/builder-api/index.js +1 -1
  169. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
  170. package/dist/esm/state/middleware/read-write/measure-box-models.js +3 -3
  171. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +1 -1
  172. package/dist/esm/state/middleware/read-write/prop-controller-handles.js +21 -13
  173. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  174. package/dist/esm/state/modules/api-resources.js +2 -2
  175. package/dist/esm/state/modules/api-resources.js.map +1 -1
  176. package/dist/esm/state/modules/breakpoints.js +2 -2
  177. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  178. package/dist/esm/state/modules/components-meta.js +1 -1
  179. package/dist/esm/state/modules/components-meta.js.map +1 -1
  180. package/dist/esm/state/modules/element-trees.js +2 -2
  181. package/dist/esm/state/modules/element-trees.js.map +1 -1
  182. package/dist/esm/state/modules/is-in-builder.js +1 -1
  183. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  184. package/dist/esm/state/modules/is-read-only.js +1 -1
  185. package/dist/esm/state/modules/is-read-only.js.map +1 -1
  186. package/dist/esm/state/modules/locale.js +1 -1
  187. package/dist/esm/state/modules/locale.js.map +1 -1
  188. package/dist/esm/state/modules/localized-resources-map.js +1 -1
  189. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  190. package/dist/esm/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +2 -2
  191. package/dist/esm/state/modules/prop-controller-descriptors.js.map +1 -0
  192. package/dist/esm/state/modules/react-components.js +1 -1
  193. package/dist/esm/state/modules/react-components.js.map +1 -1
  194. package/dist/esm/state/modules/read-write/box-models.js +2 -2
  195. package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
  196. package/dist/esm/state/modules/read-write/element-imperative-handles.js +3 -3
  197. package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +1 -1
  198. package/dist/esm/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +2 -2
  199. package/dist/esm/state/modules/read-write/prop-controllers.js.map +1 -0
  200. package/dist/esm/state/read-only-state.js +9 -41
  201. package/dist/esm/state/read-only-state.js.map +1 -1
  202. package/dist/esm/state/read-write-state.js +34 -0
  203. package/dist/esm/state/read-write-state.js.map +1 -1
  204. package/dist/esm/state/shared-api/action-types.js +9 -0
  205. package/dist/esm/state/shared-api/action-types.js.map +1 -0
  206. package/dist/esm/state/{shared-api.js → shared-api/actions.js} +2 -7
  207. package/dist/esm/state/shared-api/actions.js.map +1 -0
  208. package/dist/esm/state/shared-api/index.js +3 -0
  209. package/dist/esm/state/shared-api/index.js.map +1 -0
  210. package/dist/esm/state/store.js +1 -1
  211. package/dist/esm/state/store.js.map +1 -1
  212. package/dist/esm/state/translations/get.js.map +1 -1
  213. package/dist/esm/state/translations/merge.js +3 -1
  214. package/dist/esm/state/translations/merge.js.map +1 -1
  215. package/dist/esm/state/unified-state.js +4 -0
  216. package/dist/esm/state/unified-state.js.map +1 -1
  217. package/dist/esm/testing/breakpoints.js +9 -0
  218. package/dist/esm/testing/breakpoints.js.map +1 -0
  219. package/dist/esm/testing/element-data.js +76 -0
  220. package/dist/esm/testing/element-data.js.map +1 -0
  221. package/dist/esm/translations/index.js.map +1 -1
  222. package/dist/types/api/schema/page-pathname-slice.d.ts +2 -2
  223. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +6 -6
  224. package/dist/types/api-handler/handlers/webhook/types.d.ts +20 -20
  225. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  226. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  227. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  228. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  229. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
  230. package/dist/types/locale.d.ts +1 -1
  231. package/dist/types/next/testing/breakpoints.d.ts +1 -3
  232. package/dist/types/next/testing/breakpoints.d.ts.map +1 -1
  233. package/dist/types/next/testing/element-data.d.ts +1 -54
  234. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  235. package/dist/types/next/testing/react-runtime.d.ts.map +1 -1
  236. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  237. package/dist/types/runtimes/react/components/ElementRegistration.d.ts +1 -1
  238. package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
  239. package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
  240. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts +1 -1
  241. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
  242. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  243. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  244. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -1
  245. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +4 -3
  246. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
  247. package/dist/types/runtimes/react/hooks/use-store.d.ts +2 -4
  248. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  249. package/dist/types/runtimes/react/testing/index.d.ts +3 -0
  250. package/dist/types/runtimes/react/testing/index.d.ts.map +1 -0
  251. package/dist/types/runtimes/react/testing/react-provider.d.ts +8 -0
  252. package/dist/types/runtimes/react/testing/react-provider.d.ts.map +1 -0
  253. package/dist/types/state/__tests__/test-store.d.ts +2 -4
  254. package/dist/types/state/__tests__/test-store.d.ts.map +1 -1
  255. package/dist/types/state/actions/index.d.ts +6 -6
  256. package/dist/types/state/actions/index.d.ts.map +1 -1
  257. package/dist/types/state/actions/internal/action-types.d.ts +26 -0
  258. package/dist/types/state/actions/internal/action-types.d.ts.map +1 -0
  259. package/dist/types/state/actions/internal/index.d.ts +0 -25
  260. package/dist/types/state/actions/internal/index.d.ts.map +1 -1
  261. package/dist/types/state/actions/internal/read-only-action-types.d.ts +15 -0
  262. package/dist/types/state/actions/internal/read-only-action-types.d.ts.map +1 -0
  263. package/dist/types/state/actions/internal/read-only-actions.d.ts +3 -76
  264. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
  265. package/dist/types/state/actions/internal/read-write-action-types.d.ts +14 -0
  266. package/dist/types/state/actions/internal/read-write-action-types.d.ts.map +1 -0
  267. package/dist/types/state/actions/internal/read-write-actions.d.ts +58 -9
  268. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  269. package/dist/types/state/builder-api/action-types.d.ts +22 -0
  270. package/dist/types/state/builder-api/action-types.d.ts.map +1 -0
  271. package/dist/types/state/builder-api/actions.d.ts +1 -21
  272. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  273. package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
  274. package/dist/types/state/host-api/action-types.d.ts +17 -0
  275. package/dist/types/state/host-api/action-types.d.ts.map +1 -0
  276. package/dist/types/state/{host-api.d.ts → host-api/actions.d.ts} +7 -22
  277. package/dist/types/state/host-api/actions.d.ts.map +1 -0
  278. package/dist/types/state/host-api/index.d.ts +3 -0
  279. package/dist/types/state/host-api/index.d.ts.map +1 -0
  280. package/dist/types/state/middleware/read-write/__tests__/fixtures/operations.d.ts.map +1 -0
  281. package/dist/types/state/middleware/read-write/__tests__/fixtures/root-elements.d.ts.map +1 -0
  282. package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts +2 -0
  283. package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts.map +1 -0
  284. package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts +2 -0
  285. package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts.map +1 -0
  286. package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -1
  287. package/dist/types/state/modules/element-trees.d.ts +1 -1
  288. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  289. package/dist/types/state/modules/{prop-controllers.d.ts → prop-controller-descriptors.d.ts} +1 -1
  290. package/dist/types/state/modules/prop-controller-descriptors.d.ts.map +1 -0
  291. package/dist/types/state/modules/{prop-controller-handles.d.ts → read-write/prop-controllers.d.ts} +4 -4
  292. package/dist/types/state/modules/{prop-controller-handles.d.ts.map → read-write/prop-controllers.d.ts.map} +1 -1
  293. package/dist/types/state/read-only-state.d.ts +6 -70
  294. package/dist/types/state/read-only-state.d.ts.map +1 -1
  295. package/dist/types/state/read-write-state.d.ts +67 -4
  296. package/dist/types/state/read-write-state.d.ts.map +1 -1
  297. package/dist/types/state/shared-api/action-types.d.ts +6 -0
  298. package/dist/types/state/shared-api/action-types.d.ts.map +1 -0
  299. package/dist/types/state/{shared-api.d.ts → shared-api/actions.d.ts} +3 -7
  300. package/dist/types/state/shared-api/actions.d.ts.map +1 -0
  301. package/dist/types/state/shared-api/index.d.ts +3 -0
  302. package/dist/types/state/shared-api/index.d.ts.map +1 -0
  303. package/dist/types/state/store.d.ts +4 -8
  304. package/dist/types/state/store.d.ts.map +1 -1
  305. package/dist/types/state/translations/get.d.ts +1 -1
  306. package/dist/types/state/translations/get.d.ts.map +1 -1
  307. package/dist/types/state/translations/merge.d.ts +1 -1
  308. package/dist/types/state/translations/merge.d.ts.map +1 -1
  309. package/dist/types/state/unified-state.d.ts +1 -0
  310. package/dist/types/state/unified-state.d.ts.map +1 -1
  311. package/dist/types/testing/breakpoints.d.ts +4 -0
  312. package/dist/types/testing/breakpoints.d.ts.map +1 -0
  313. package/dist/types/testing/element-data.d.ts +55 -0
  314. package/dist/types/testing/element-data.d.ts.map +1 -0
  315. package/dist/types/translations/index.d.ts +1 -1
  316. package/dist/types/translations/index.d.ts.map +1 -1
  317. package/package.json +2 -2
  318. package/dist/cjs/state/host-api.js.map +0 -1
  319. package/dist/cjs/state/modules/prop-controller-handles.js.map +0 -1
  320. package/dist/cjs/state/modules/prop-controllers.js.map +0 -1
  321. package/dist/cjs/state/shared-api.js.map +0 -1
  322. package/dist/esm/state/host-api.js.map +0 -1
  323. package/dist/esm/state/modules/prop-controller-handles.js.map +0 -1
  324. package/dist/esm/state/modules/prop-controllers.js.map +0 -1
  325. package/dist/esm/state/shared-api.js.map +0 -1
  326. package/dist/types/state/__tests__/fixtures/operations.d.ts.map +0 -1
  327. package/dist/types/state/__tests__/fixtures/root-elements.d.ts.map +0 -1
  328. package/dist/types/state/__tests__/react-builder-preview.test.d.ts +0 -2
  329. package/dist/types/state/__tests__/react-builder-preview.test.d.ts.map +0 -1
  330. package/dist/types/state/host-api.d.ts.map +0 -1
  331. package/dist/types/state/modules/prop-controllers.d.ts.map +0 -1
  332. package/dist/types/state/shared-api.d.ts.map +0 -1
  333. /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/operations.d.ts +0 -0
  334. /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/root-elements.d.ts +0 -0
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var host_api_exports = {};
17
+ module.exports = __toCommonJS(host_api_exports);
18
+ __reExport(host_api_exports, require("./action-types"), module.exports);
19
+ __reExport(host_api_exports, require("./actions"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./action-types"),
23
+ ...require("./actions")
24
+ });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/host-api/index.ts"],"sourcesContent":["export * from './action-types'\nexport * from './actions'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,2BAAd;AACA,6BAAc,sBADd;","names":[]}
@@ -21,7 +21,7 @@ __export(builder_api_exports, {
21
21
  builderAPIMiddleware: () => builderAPIMiddleware
22
22
  });
23
23
  module.exports = __toCommonJS(builder_api_exports);
24
- var import_actions2 = require("../../../builder-api/actions");
24
+ var import_action_types = require("../../../builder-api/action-types");
25
25
  var import_toolkit2 = require("../../../toolkit");
26
26
  var import_host_api = require("../../../host-api");
27
27
  var import_initialize_connection = require("./initialize-connection");
@@ -33,20 +33,20 @@ function builderAPIMiddleware(builderProxy) {
33
33
  };
34
34
  return (action) => {
35
35
  switch (action.type) {
36
- case import_actions2.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:
37
- case import_actions2.BuilderActionTypes.MOUNT_COMPONENT:
38
- case import_actions2.BuilderActionTypes.UNMOUNT_COMPONENT:
39
- case import_actions2.BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:
40
- case import_actions2.BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:
41
- case import_actions2.BuilderActionTypes.HANDLE_WHEEL:
42
- case import_actions2.BuilderActionTypes.HANDLE_POINTER_MOVE:
43
- case import_actions2.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:
44
- case import_actions2.BuilderActionTypes.SET_LOCALE:
45
- case import_actions2.BuilderActionTypes.SET_BREAKPOINTS:
46
- case import_actions2.BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:
47
- case import_actions2.BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:
48
- case import_actions2.BuilderActionTypes.REGISTER_BUILDER_COMPONENT:
49
- case import_actions2.BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:
36
+ case import_action_types.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:
37
+ case import_action_types.BuilderActionTypes.MOUNT_COMPONENT:
38
+ case import_action_types.BuilderActionTypes.UNMOUNT_COMPONENT:
39
+ case import_action_types.BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:
40
+ case import_action_types.BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:
41
+ case import_action_types.BuilderActionTypes.HANDLE_WHEEL:
42
+ case import_action_types.BuilderActionTypes.HANDLE_POINTER_MOVE:
43
+ case import_action_types.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:
44
+ case import_action_types.BuilderActionTypes.SET_LOCALE:
45
+ case import_action_types.BuilderActionTypes.SET_BREAKPOINTS:
46
+ case import_action_types.BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:
47
+ case import_action_types.BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:
48
+ case import_action_types.BuilderActionTypes.REGISTER_BUILDER_COMPONENT:
49
+ case import_action_types.BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:
50
50
  builderProxy.execute(action);
51
51
  break;
52
52
  case import_host_api.HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/actions'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTo({\n top: action.payload.scrollTop,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollBy({\n top: action.payload.scrollTopDelta,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n // and in response to host's client-side navigation\n cleanUp() // cleanup existing connection setup, if any\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n cleanUp = () => {}\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,kBAAmC;AAEnC,IAAAC,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS,qBACd,cACuC;AACvC,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,QAAI,OAAO,WAAW;AAAa,aAAO,CAAC,WAAmB,KAAK,MAAM;AAEzE,QAAI,UAAU,MAAM;AAAA,IAAC;AACrB,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AACtB,uBAAa,QAAQ,MAAM;AAC3B;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,SAAS;AAAA,YACvC,KAAK,OAAO,QAAQ;AAAA,YACpB,UAAU;AAAA,UACZ,CAAC;AACD;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,SAAS;AAAA,YACvC,KAAK,OAAO,QAAQ;AAAA,YACpB,UAAU;AAAA,UACZ,CAAC;AACD;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,aAAa,GAAG,gBAAgB;AACvC;AAAA,QAEF,KAAK,gCAAgB;AAGnB,kBAAQ;AACR,oBAAU,aAAS,0DAA4B,YAAY,CAAC;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AAEnB,kBAAQ;AACR,oBAAU,MAAM;AAAA,UAAC;AACjB;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_toolkit"]}
1
+ {"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/action-types'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTo({\n top: action.payload.scrollTop,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollBy({\n top: action.payload.scrollTopDelta,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n // and in response to host's client-side navigation\n cleanUp() // cleanup existing connection setup, if any\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n cleanUp = () => {}\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAmC;AAEnC,IAAAA,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS,qBACd,cACuC;AACvC,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,QAAI,OAAO,WAAW;AAAa,aAAO,CAAC,WAAmB,KAAK,MAAM;AAEzE,QAAI,UAAU,MAAM;AAAA,IAAC;AACrB,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AAAA,QACxB,KAAK,uCAAmB;AACtB,uBAAa,QAAQ,MAAM;AAC3B;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,SAAS;AAAA,YACvC,KAAK,OAAO,QAAQ;AAAA,YACpB,UAAU;AAAA,UACZ,CAAC;AACD;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,SAAS;AAAA,YACvC,KAAK,OAAO,QAAQ;AAAA,YACpB,UAAU;AAAA,UACZ,CAAC;AACD;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,aAAa,GAAG,gBAAgB;AACvC;AAAA,QAEF,KAAK,gCAAgB;AAGnB,kBAAQ;AACR,oBAAU,aAAS,0DAA4B,YAAY,CAAC;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AAEnB,kBAAQ;AACR,oBAAU,MAAM;AAAA,UAAC;AACjB;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
@@ -32,14 +32,14 @@ __export(measure_box_models_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(measure_box_models_exports);
34
34
  var BoxModels = __toESM(require("../../modules/read-write/box-models"));
35
- var import_read_only_actions = require("../../actions/internal/read-only-actions");
35
+ var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
36
36
  var ReadWriteActions = __toESM(require("../../actions/internal/read-write-actions"));
37
37
  var import_toolkit2 = require("../../toolkit");
38
38
  function measureBoxModelsMiddleware() {
39
39
  return (0, import_toolkit2.actionMiddleware)(({ dispatch }) => (next) => {
40
40
  return (action) => {
41
41
  switch (action.type) {
42
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {
42
+ case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {
43
43
  if (BoxModels.isMeasurable(action.payload.componentHandle)) {
44
44
  dispatch(
45
45
  ReadWriteActions.registerMeasurable(
@@ -51,7 +51,7 @@ function measureBoxModelsMiddleware() {
51
51
  }
52
52
  break;
53
53
  }
54
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE:
54
+ case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE:
55
55
  dispatch(
56
56
  ReadWriteActions.unregisterMeasurable(
57
57
  action.payload.documentKey,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/middleware/read-write/measure-box-models.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport * as BoxModels from '../../modules/read-write/box-models'\nimport { type Action } from '../../actions'\n\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\nimport * as ReadWriteActions from '../../actions/internal/read-write-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { type State, type Dispatch } from '../../read-write-state'\n\nexport function measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n ReadWriteActions.registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(\n ReadWriteActions.unregisterMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n ),\n )\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAA2B;AAG3B,+BAAoC;AACpC,uBAAkC;AAElC,IAAAA,kBAAiC;AAI1B,SAAS,6BAAoE;AAClF,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,6CAAoB,2BAA2B;AAClD,cAAI,UAAU,aAAa,OAAO,QAAQ,eAAe,GAAG;AAC1D;AAAA,cACE,iBAAiB;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,cACjB;AAAA,YACF;AAAA,UACF;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,6CAAoB;AACvB;AAAA,YACE,iBAAiB;AAAA,cACf,OAAO,QAAQ;AAAA,cACf,OAAO,QAAQ;AAAA,YACjB;AAAA,UACF;AACA;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
1
+ {"version":3,"sources":["../../../../../src/state/middleware/read-write/measure-box-models.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport * as BoxModels from '../../modules/read-write/box-models'\nimport { type Action } from '../../actions'\n\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\nimport * as ReadWriteActions from '../../actions/internal/read-write-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { type State, type Dispatch } from '../../read-write-state'\n\nexport function measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n ReadWriteActions.registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(\n ReadWriteActions.unregisterMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n ),\n )\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAA2B;AAG3B,qCAAqC;AACrC,uBAAkC;AAElC,IAAAA,kBAAiC;AAI1B,SAAS,6BAAoE;AAClF,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oDAAqB,2BAA2B;AACnD,cAAI,UAAU,aAAa,OAAO,QAAQ,eAAe,GAAG;AAC1D;AAAA,cACE,iBAAiB;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,cACjB;AAAA,YACF;AAAA,UACF;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oDAAqB;AACxB;AAAA,YACE,iBAAiB;AAAA,cACf,OAAO,QAAQ;AAAA,cACf,OAAO,QAAQ;AAAA,YACjB;AAAA,UACF;AACA;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
@@ -31,14 +31,15 @@ __export(prop_controller_handles_exports, {
31
31
  propControllerHandlesMiddleware: () => propControllerHandlesMiddleware
32
32
  });
33
33
  module.exports = __toCommonJS(prop_controller_handles_exports);
34
- var PropControllerHandles = __toESM(require("../../modules/prop-controller-handles"));
34
+ var PropControllers = __toESM(require("../../modules/read-write/prop-controllers"));
35
35
  var Builder = __toESM(require("../../builder-api/actions"));
36
- var import_read_only_actions = require("../../actions/internal/read-only-actions");
37
- var ReadOnly = __toESM(require("../../actions/internal/read-only-actions"));
36
+ var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
38
37
  var import_toolkit2 = require("../../toolkit");
39
38
  var import_instances = require("../../../prop-controllers/instances");
40
39
  var import_host_api = require("../../host-api");
41
40
  var ReadOnlyState = __toESM(require("../../read-only-state"));
41
+ var import_read_write_state = require("../../read-write-state");
42
+ var import_read_write_actions = require("../../actions/internal/read-write-actions");
42
43
  function createAndRegisterPropControllers(documentKey, elementKey) {
43
44
  return (dispatch, getState) => {
44
45
  const descriptors = ReadOnlyState.getElementPropControllerDescriptors(
@@ -61,7 +62,7 @@ function createAndRegisterPropControllers(documentKey, elementKey) {
61
62
  },
62
63
  {}
63
64
  );
64
- dispatch(ReadOnly.registerPropControllers(documentKey, elementKey, propControllers));
65
+ dispatch((0, import_read_write_actions.registerPropControllers)(documentKey, elementKey, propControllers));
65
66
  return propControllers;
66
67
  };
67
68
  }
@@ -69,33 +70,32 @@ function propControllerHandlesMiddleware() {
69
70
  return (0, import_toolkit2.actionMiddleware)(({ dispatch, getState }) => (next) => {
70
71
  return (action) => {
71
72
  switch (action.type) {
72
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {
73
+ case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {
73
74
  const { documentKey, elementKey, componentHandle } = action.payload;
74
75
  const element = ReadOnlyState.getElement(getState(), documentKey, elementKey);
75
76
  const propControllers = dispatch(
76
77
  createAndRegisterPropControllers(documentKey, elementKey)
77
78
  );
78
- if (element != null && !ReadOnlyState.isElementReference(element) && PropControllerHandles.isPropControllersHandle(componentHandle)) {
79
- dispatch(
80
- ReadOnly.registerPropControllersHandle(documentKey, elementKey, componentHandle)
81
- );
79
+ if (element != null && !ReadOnlyState.isElementReference(element) && PropControllers.isPropControllersHandle(componentHandle)) {
80
+ dispatch((0, import_read_write_actions.registerPropControllersHandle)(documentKey, elementKey, componentHandle));
82
81
  componentHandle.setPropControllers(propControllers);
83
82
  }
84
83
  break;
85
84
  }
86
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {
85
+ case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
87
86
  const { documentKey, elementKey } = action.payload;
88
- const handle = ReadOnlyState.getPropControllersHandle(getState(), {
87
+ const handle = (0, import_read_write_state.getPropControllersHandle)(getState(), {
89
88
  documentKey,
90
89
  elementKey
91
90
  });
92
91
  handle?.setPropControllers(null);
93
- dispatch(ReadOnly.unregisterPropControllers(documentKey, elementKey));
92
+ dispatch((0, import_read_write_actions.unregisterPropControllers)(documentKey, elementKey));
93
+ dispatch((0, import_read_write_actions.unregisterPropControllersHandle)(documentKey, elementKey));
94
94
  break;
95
95
  }
96
96
  case import_host_api.HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {
97
97
  const { documentKey, elementKey, propName, message } = action.payload;
98
- const propController = ReadOnlyState.getPropController(getState(), {
98
+ const propController = (0, import_read_write_state.getPropController)(getState(), {
99
99
  documentKey,
100
100
  elementKey,
101
101
  propName
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware, type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport * as PropControllerHandles from '../../modules/prop-controller-handles'\n\nimport { type Action } from '../../actions'\n\nimport * as Builder from '../../builder-api/actions'\n\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\nimport * as ReadOnly from '../../actions/internal/read-only-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { createPropController } from '../../../prop-controllers/instances'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\nimport { type State, type Dispatch } from '../../read-write-state'\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReadOnlyState.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController({\n descriptor,\n instanceKey: { elementKey, propPath: propName },\n sendMessage: message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n }) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n dispatch(ReadOnly.registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(\n ReadOnly.registerPropControllersHandle(documentKey, elementKey, componentHandle),\n )\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = ReadOnlyState.getPropControllersHandle(getState(), {\n documentKey,\n elementKey,\n })\n\n handle?.setPropControllers(null)\n\n dispatch(ReadOnly.unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = ReadOnlyState.getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAAuC;AAIvC,cAAyB;AAEzB,+BA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,UACpD;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,6CAAoB,6BAA6B;AACpD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,gBAAM,SAAS,cAAc,yBAAyB,SAAS,GAAG;AAAA,YAChE;AAAA,YACA;AAAA,UACF,CAAC;AAED,kBAAQ,mBAAmB,IAAI;AAE/B,mBAAS,SAAS,0BAA0B,aAAa,UAAU,CAAC;AAEpE;AAAA,QACF;AAAA,QAEA,KAAK,gCAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,iBAAiB,cAAc,kBAAkB,SAAS,GAAG;AAAA,YACjE;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAED,cAAI;AAAgB,2BAAe,KAAK,OAAO;AAAA,QACjD;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
1
+ {"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware, type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport * as PropControllers from '../../modules/read-write/prop-controllers'\n\nimport { type Action } from '../../actions'\n\nimport * as Builder from '../../builder-api/actions'\n\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { createPropController } from '../../../prop-controllers/instances'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\nimport {\n type State,\n type Dispatch,\n getPropControllersHandle,\n getPropController,\n} from '../../read-write-state'\n\nimport {\n registerPropControllers,\n registerPropControllersHandle,\n unregisterPropControllers,\n unregisterPropControllersHandle,\n} from '../../actions/internal/read-write-actions'\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReadOnlyState.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController({\n descriptor,\n instanceKey: { elementKey, propPath: propName },\n sendMessage: message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n }) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllers.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = getPropControllersHandle(getState(), {\n documentKey,\n elementKey,\n })\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n dispatch(unregisterPropControllersHandle(documentKey, elementKey))\n\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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A8B,aAAa,YAAY,eAAe,CAAC;AAChF,4BAAgB,mBAAmB,eAAe;AAAA,UACpD;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oDAAqB,6BAA6B;AACrD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,gBAAM,aAAS,kDAAyB,SAAS,GAAG;AAAA,YAClD;AAAA,YACA;AAAA,UACF,CAAC;AAED,kBAAQ,mBAAmB,IAAI;AAE/B,uBAAS,qDAA0B,aAAa,UAAU,CAAC;AAC3D,uBAAS,2DAAgC,aAAa,UAAU,CAAC;AAEjE;AAAA,QACF;AAAA,QAEA,KAAK,gCAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,qBAAiB,2CAAkB,SAAS,GAAG;AAAA,YACnD;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAED,cAAI;AAAgB,2BAAe,KAAK,OAAO;AAAA,QACjD;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
@@ -38,8 +38,8 @@ module.exports = __toCommonJS(api_resources_exports);
38
38
  var import_api = require("../../api");
39
39
  var import_deepEqual = __toESM(require("../../utils/deepEqual"));
40
40
  var import_actions = require("../actions");
41
- var import_read_only_actions = require("../actions/internal/read-only-actions");
42
- var import_read_write_actions = require("../actions/internal/read-write-actions");
41
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
42
+ var import_read_write_action_types = require("../actions/internal/read-write-action-types");
43
43
  var import_host_api = require("../host-api");
44
44
  function isValidAPIResourceType(resourceType) {
45
45
  return resourceType in import_api.APIResourceType;
@@ -119,7 +119,7 @@ function reducer(state = getInitialState(), action) {
119
119
  if (!(0, import_actions.isKnownAction)(action))
120
120
  return state;
121
121
  switch (action.type) {
122
- case import_read_write_actions.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
122
+ case import_read_write_action_types.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
123
123
  const { apiResources } = action.payload;
124
124
  return Object.entries(apiResources).reduce((state2, [resourceType, cachedResources]) => {
125
125
  const resType = resourceType;
@@ -132,10 +132,10 @@ function reducer(state = getInitialState(), action) {
132
132
  return updated == null || updated === existing ? state2 : new Map(state2).set(resType, updated);
133
133
  }, state);
134
134
  }
135
- case import_read_write_actions.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {
135
+ case import_read_write_action_types.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {
136
136
  return getInitialState();
137
137
  }
138
- case import_read_only_actions.ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {
138
+ case import_read_only_action_types.ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {
139
139
  const { resourceType, resourceId, resource, locale } = action.payload;
140
140
  return new Map(state).set(
141
141
  resourceType,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\nimport { HostActionTypes } from '../host-api'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return deepEqual(r.get(cid), value) ? 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 ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n case ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,qBAA+D;AAC/D,+BAAoC;AACpC,gCAAqC;AACrC,sBAAgC;AAIhC,SAAS,uBAAuB,cAAuD;AACrF,SAAO,gBAAgB;AACzB;AAEA,SAAS,6BACP,cAC4C;AAC5C,SAAO,gBAAgB;AACzB;AAEA,SAAS,YACP,YACA,cACA,QACqB;AACrB,SACE,UAAU,QAAQ,6BAA6B,YAAY,IACvD,GAAG,UAAU,IAAI,MAAM,KACvB;AAER;AAEA,SAAS,iBAAiBA,cAA2D;AACnF,QAAM,CAAC,YAAY,MAAM,IAAIA,aAAY,MAAM,GAAG;AAClD,SAAO,CAAC,YAAY,UAAU,IAAI;AACpC;AAYO,SAAS,gBACd,kBAAmC;AAAA,EACjC,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,mBAAmB,CAAC;AAAA,EACpB,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,wBAAwB,CAAC;AAC3B,GACO;AACP,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,eAAe,EAAE,IAAI,CAAC,CAAC,cAAc,SAAS,MAAM;AAAA,MACjE;AAAA,MACA,IAAI;AAAA,QACF,UAAU,IAAI,CAAC,EAAE,IAAI,OAAO,OAAO,MAAM;AAAA,UACvC,YAAY,IAAI,cAAiC,MAAM;AAAA,UACvD;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,SAAS,mBAAmB,OAA+B;AAChE,QAAM,cAA+B;AAAA,IACnC,QAAQ,CAAC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UACvC,YAAY,SAAS,IAAI,SAAS,YAAY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,gCAAgB,oBAAoB;AACvC,YAAM,EAAE,IAAI,OAAO,IAAI,OAAO;AAC9B,YAAM,CAAC,cAAc,UAAU,IAAI,GAAG,MAAM,GAAG;AAE/C,UAAI,CAAC,uBAAuB,YAAY;AAAG,eAAO;AAElD,YAAM,YAAY,IAAI,IAAI,MAAM,IAAI,YAA+B,CAAE;AAErE,YAAM,UAAU,UAAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-action-types'\nimport { HostActionTypes } from '../host-api'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return deepEqual(r.get(cid), value) ? 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 ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n case ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResour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AY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,gCAAgB,oBAAoB;AACvC,YAAM,EAAE,IAAI,OAAO,IAAI,OAAO;AAC9B,YAAM,CAAC,cAAc,UAAU,IAAI,GAAG,MAAM,GAAG;AAE/C,UAAI,CAAC,uBAAuB,YAAY;AAAG,eAAO;AAElD,YAAM,YAAY,IAAI,IAAI,MAAM,IAAI,YAA+B,CAAE;AAErE,YAAM,UAAU,UAAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
@@ -30,8 +30,8 @@ __export(breakpoints_exports, {
30
30
  module.exports = __toCommonJS(breakpoints_exports);
31
31
  var import_controls = require("@makeswift/controls");
32
32
  var import_actions = require("../actions");
33
- var import_internal = require("../actions/internal");
34
- var import_actions2 = require("../builder-api/actions");
33
+ var import_action_types = require("../actions/internal/action-types");
34
+ var import_action_types2 = require("../builder-api/action-types");
35
35
  var import_is_server = require("../../utils/is-server");
36
36
  var import_controls2 = require("@makeswift/controls");
37
37
  const DefaultBreakpointID = {
@@ -84,7 +84,7 @@ function reducer(state = getInitialState(), action) {
84
84
  if (!(0, import_actions.isKnownAction)(action))
85
85
  return state;
86
86
  switch (action.type) {
87
- case import_actions2.BuilderActionTypes.SET_BREAKPOINTS: {
87
+ case import_action_types2.BuilderActionTypes.SET_BREAKPOINTS: {
88
88
  const breakpoints = action.payload.breakpoints;
89
89
  if (breakpoints.length === 0)
90
90
  throw new Error("Breakpoints cannot be empty.");
@@ -94,7 +94,7 @@ function reducer(state = getInitialState(), action) {
94
94
  clientBreakpoint: getMatchingMediaBreakpointId(breakpoints)
95
95
  };
96
96
  }
97
- case import_internal.InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {
97
+ case import_action_types.InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {
98
98
  const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints);
99
99
  if (clientBreakpoint === state.clientBreakpoint)
100
100
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal'\nimport { BuilderActionTypes } from '../builder-api/actions'\nimport { isServer } from '../../utils/is-server'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = {\n breakpoints: Breakpoints\n baseBreakpoint: BreakpointId\n clientBreakpoint: BreakpointId\n}\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 const getDeviceQueries = (breakpoints: Breakpoints) =>\n breakpoints.map(device => ({\n id: device.id,\n query: getBreakpointMediaQuery(device).replace('@media', ''),\n }))\n\nconst getBaseBreakpointId = (breakpoints: Breakpoints): BreakpointId =>\n getBaseBreakpoint(breakpoints).id\n\n// Intentional impurity in the reducer buys us several practical upsides here:\n//\n// - We can keep `SET_BREAKPOINTS` atomic by recalculating the client breakpoint\n// state when we update the set of available breakpoints; if we don't do that\n// here, we'll have to do it from the outside, and the state will temporarily\n// hold a stale client breakpoint value in between\n//\n// - We can have a valid, internally consistent *initial* state for the client\n// breakpoint; if we move the client breakpoint calculation out of the reducer,\n// we'll be forced to start with a stale initial state, which will introduce\n// implicit coupling and potential timing issues between the\n// `useCurrentBreakpoint` hook and the client breakpoint synchronization code\n// in `BreakpointWatch`\n//\n// - `UPDATE_CLIENT_BREAKPOINT` can compute the client breakpoint from browser\n// state using the current breakpoint set instead of having to validate and\n// handle external payload\n\nexport function getMatchingMediaBreakpointId(breakpoints: Breakpoints): BreakpointId {\n const baseBreakpoint = getBaseBreakpointId(breakpoints)\n if (isServer()) return baseBreakpoint\n\n // using `findLast` to preserve the legacy behavior; might not be necessary\n const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(\n ({ query }) => window.matchMedia(query).matches,\n )\n\n return matchingBreakpoint?.id ?? baseBreakpoint\n}\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n }\n\n case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {\n const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints)\n if (clientBreakpoint === state.clientBreakpoint) return state\n\n return { ...state, clientBreakpoint }\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;AAAA;AAAA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xC,UAAM,IAAI;AAAA,MACR,uCAAuC,oBAAoB,OAAO;AAAA,IACpE;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,QAAM,SAAS,OAAO,QAAQ,KAAK,EAChC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,GAAG,OAAO,GAAG,EAAE,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEnC,SAAO,QAAQ,CAAC,EAAE,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_controls"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal/action-types'\nimport { BuilderActionTypes } from '../builder-api/action-types'\nimport { isServer } from '../../utils/is-server'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = {\n breakpoints: Breakpoints\n baseBreakpoint: BreakpointId\n clientBreakpoint: BreakpointId\n}\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 const getDeviceQueries = (breakpoints: Breakpoints) =>\n breakpoints.map(device => ({\n id: device.id,\n query: getBreakpointMediaQuery(device).replace('@media', ''),\n }))\n\nconst getBaseBreakpointId = (breakpoints: Breakpoints): BreakpointId =>\n getBaseBreakpoint(breakpoints).id\n\n// Intentional impurity in the reducer buys us several practical upsides here:\n//\n// - We can keep `SET_BREAKPOINTS` atomic by recalculating the client breakpoint\n// state when we update the set of available breakpoints; if we don't do that\n// here, we'll have to do it from the outside, and the state will temporarily\n// hold a stale client breakpoint value in between\n//\n// - We can have a valid, internally consistent *initial* state for the client\n// breakpoint; if we move the client breakpoint calculation out of the reducer,\n// we'll be forced to start with a stale initial state, which will introduce\n// implicit coupling and potential timing issues between the\n// `useCurrentBreakpoint` hook and the client breakpoint synchronization code\n// in `BreakpointWatch`\n//\n// - `UPDATE_CLIENT_BREAKPOINT` can compute the client breakpoint from browser\n// state using the current breakpoint set instead of having to validate and\n// handle external payload\n\nexport function getMatchingMediaBreakpointId(breakpoints: Breakpoints): BreakpointId {\n const baseBreakpoint = getBaseBreakpointId(breakpoints)\n if (isServer()) return baseBreakpoint\n\n // using `findLast` to preserve the legacy behavior; might not be necessary\n const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(\n ({ query }) => window.matchMedia(query).matches,\n )\n\n return matchingBreakpoint?.id ?? baseBreakpoint\n}\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n }\n\n case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {\n const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints)\n if (clientBreakpoint === state.clientBreakpoint) return state\n\n return { ...state, clientBreakpoint }\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;AAAA;AAAA;AAAA,sBAMO;AAEP,qBAA+D;AAC/D,0BAAoC;AACpC,IAAAA,uBAAmC;AACnC,uBAAyB;AAEzB,IAAAC,mBAKO;AAQA,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;AA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AAI;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_action_types","import_controls"]}
@@ -26,7 +26,7 @@ __export(components_meta_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(components_meta_exports);
28
28
  var import_actions = require("../actions");
29
- var import_read_only_actions = require("../actions/internal/read-only-actions");
29
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
30
30
  const ComponentIcon = {
31
31
  Accordion: "accordion",
32
32
  Audio: "audio",
@@ -75,9 +75,9 @@ function reducer(state = getInitialState(), action) {
75
75
  if (!(0, import_actions.isKnownAction)(action))
76
76
  return state;
77
77
  switch (action.type) {
78
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT:
78
+ case import_read_only_action_types.ReadOnlyActionTypes.REGISTER_COMPONENT:
79
79
  return new Map(state).set(action.payload.type, action.payload.meta);
80
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
80
+ case import_read_only_action_types.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
81
81
  const nextState = new Map(state);
82
82
  const deleted = nextState.delete(action.payload.type);
83
83
  return deleted ? nextState : state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\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 Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/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names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\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 Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";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O,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -43,8 +43,8 @@ var import_immutable = require("immutable");
43
43
  var import_controls = require("@makeswift/controls");
44
44
  var Introspection = __toESM(require("../../prop-controllers/introspection"));
45
45
  var import_actions = require("../actions");
46
- var import_read_only_actions = require("../actions/internal/read-only-actions");
47
- var import_read_write_actions = require("../actions/internal/read-write-actions");
46
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
47
+ var import_read_write_action_types = require("../actions/internal/read-write-action-types");
48
48
  var import_read_only_documents = require("./read-only-documents");
49
49
  function getInitialState(documents, descriptors) {
50
50
  const state = /* @__PURE__ */ new Map();
@@ -74,19 +74,19 @@ function reducer(state = getInitialState(), action) {
74
74
  if (!(0, import_actions.isKnownAction)(action))
75
75
  return state;
76
76
  switch (action.type) {
77
- case import_read_only_actions.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
77
+ case import_read_only_action_types.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
78
78
  const { document, descriptors } = action.payload;
79
79
  return new Map(state).set(
80
80
  document.key,
81
81
  buildElementTree((0, import_read_only_documents.getRootElement)(document), descriptors)
82
82
  );
83
83
  }
84
- case import_read_only_actions.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
84
+ case import_read_only_action_types.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
85
85
  const nextState = new Map(state);
86
86
  const deleted = nextState.delete(action.payload.documentKey);
87
87
  return deleted ? nextState : state;
88
88
  }
89
- case import_read_write_actions.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
89
+ case import_read_write_action_types.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
90
90
  const { oldDocument, newDocument, descriptors, operation } = action.payload;
91
91
  const documentKey = oldDocument.key;
92
92
  console.assert(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn, removeIn, setIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction getPropChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): Element[] | null {\n if (isElementReference(element)) return null\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return null\n\n return Introspection.getElementChildren(propDescriptor, element.props[propName])\n}\n\nfunction isChildrenProp(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n const children = getPropChildren(element, propName, descriptors)\n return children != null\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n elementToDelete: Element,\n descriptors: DescriptorsByComponentType,\n) {\n for (const element of traverseElementTree(elementToDelete, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n}\n\nfunction deleteChildrenInProp(\n elementTree: ElementTree,\n parentElement: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n) {\n const childrenInProp = getPropChildren(parentElement, propName, descriptors)\n\n if (childrenInProp == null) {\n return\n }\n\n for (const child of childrenInProp) {\n deleteElement(elementTree, child, descriptors)\n }\n}\n\nfunction deleteElementOrProp(\n { elements, elementIds }: ElementTree,\n targetElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null) {\n deleteElement({ elements, elementIds }, targetElement, descriptors)\n return\n }\n\n if (isChildrenProp(targetElement, propName, descriptors)) {\n deleteChildrenInProp({ elements, elementIds }, targetElement, propName, descriptors)\n }\n\n // The provided targetElement might refer to an element from the before/after documents,\n // not the actual element object from the ElementTree\n const elementInTree = elements.get(targetElement.key)\n\n if (!elementInTree) {\n console.error(\n `Attempting to remove prop ${propName} from element ${targetElement.key} not found in tree`,\n )\n return\n }\n\n if (!isElementReference(elementInTree)) {\n const newProps = { ...elementInTree.props }\n delete newProps[propName]\n elements.set(targetElement.key, { ...elementInTree, props: newProps })\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [targetElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, targetElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || isChildrenProp(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyOpComponent(root: Element, component: Operation[number]): Element {\n let applied: Element = root\n\n if ('ld' in component || 'od' in component) {\n applied = removeIn(applied, component.p)\n }\n\n if ('li' in component) {\n applied = setIn(applied, component.p, component.li)\n }\n\n if ('oi' in component) {\n applied = setIn(applied, component.p, component.oi)\n }\n\n return applied\n}\n\nfunction selectTreeTransform(op: Operation[number]): typeof applyUpdate {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n\n if (hasDelete && hasInsert) return applyUpdate\n if (hasDelete) return applyDelete\n if (hasInsert) return applyInsert\n\n return elementTree => elementTree\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n // Updates the element tree \"cache\" based on the provided operation, which can\n // be composed of 1-n component ops. We apply each component op sequentially\n // to the 'old' root element to determine the changed elements and update the\n // cache accordingly at each intermediate step.\n const result = operation.reduce(\n (acc, op) => {\n const rootBefore = acc.rootBefore\n\n // If there's only one component op, we can skip the application of the op\n // and assume that the result will be the 'new' root element provided to\n // us by the builder.\n const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new\n\n const roots = { before: rootBefore, after: rootAfter }\n const applyChange = selectTreeTransform(op)\n\n return {\n elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),\n rootBefore: rootAfter,\n }\n },\n { elementTree, rootBefore: rootElements.old },\n )\n\n return result.elementTree\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAuC;AAEvC,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA+D;AAE/D,+BAAoC;AACpC,gCAAqC;AAErC,iCAA8C;AAUvC,SAAS,gBACd,WACA,aAC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,uBAAqB,UAAU,oBAAoB,aAAa,KAAK;AAErE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,iBAAiB,MAAe,WAAuC;AAC9E,MAAI,UAAmB;AAEvB,MAAI,QAAQ,aAAa,QAAQ,WAAW;AAC1C,kBAAU,2BAAS,SAAS,UAAU,CAAC;AAAA,EACzC;AAEA,MAAI,QAAQ,WAAW;AACrB,kBAAU,wBAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EACpD;AAEA,MAAI,QAAQ,WAAW;AACrB,kBAAU,wBAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EACpD;AAEA,SAAO;AACT;AAEA,SAAS,oBAAoB,IAA2C;AACtE,QAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,QAAM,YAAY,QAAQ,MAAM,QAAQ;AAExC,MAAI,aAAa;AAAW,WAAO;AACnC,MAAI;AAAW,WAAO;AACtB,MAAI;AAAW,WAAO;AAEtB,SAAO,iBAAe;AACxB;AAEA,SAAS,aACP,aACA,aACA,cACA,WACa;AAKb,QAAM,SAAS,UAAU;AAAA,IACvB,CAAC,KAAK,OAAO;AACX,YAAM,aAAa,IAAI;AAKvB,YAAM,YAAY,UAAU,SAAS,IAAI,iBAAiB,YAAY,EAAE,IAAI,aAAa;AAEzF,YAAM,QAAQ,EAAE,QAAQ,YAAY,OAAO,UAAU;AACrD,YAAM,cAAc,oBAAoB,EAAE;AAE1C,aAAO;AAAA,QACL,aAAa,YAAY,IAAI,aAAa,aAAa,OAAO,GAAG,CAAC;AAAA,QAClE,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,EAAE,aAAa,YAAY,aAAa,IAAI;AAAA,EAC9C;AAEA,SAAO,OAAO;AAChB;","names":["i"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn, removeIn, setIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-action-types'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controller-descriptors'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction getPropChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): Element[] | null {\n if (isElementReference(element)) return null\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return null\n\n return Introspection.getElementChildren(propDescriptor, element.props[propName])\n}\n\nfunction isChildrenProp(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n const children = getPropChildren(element, propName, descriptors)\n return children != null\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n elementToDelete: Element,\n descriptors: DescriptorsByComponentType,\n) {\n for (const element of traverseElementTree(elementToDelete, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n}\n\nfunction deleteChildrenInProp(\n elementTree: ElementTree,\n parentElement: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n) {\n const childrenInProp = getPropChildren(parentElement, propName, descriptors)\n\n if (childrenInProp == null) {\n return\n }\n\n for (const child of childrenInProp) {\n deleteElement(elementTree, child, descriptors)\n }\n}\n\nfunction deleteElementOrProp(\n { elements, elementIds }: ElementTree,\n targetElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null) {\n deleteElement({ elements, elementIds }, targetElement, descriptors)\n return\n }\n\n if (isChildrenProp(targetElement, propName, descriptors)) {\n deleteChildrenInProp({ elements, elementIds }, targetElement, propName, descriptors)\n }\n\n // The provided targetElement might refer to an element from the before/after documents,\n // not the actual element object from the ElementTree\n const elementInTree = elements.get(targetElement.key)\n\n if (!elementInTree) {\n console.error(\n `Attempting to remove prop ${propName} from element ${targetElement.key} not found in tree`,\n )\n return\n }\n\n if (!isElementReference(elementInTree)) {\n const newProps = { ...elementInTree.props }\n delete newProps[propName]\n elements.set(targetElement.key, { ...elementInTree, props: newProps })\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [targetElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, targetElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || isChildrenProp(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyOpComponent(root: Element, component: Operation[number]): Element {\n let applied: Element = root\n\n if ('ld' in component || 'od' in component) {\n applied = removeIn(applied, component.p)\n }\n\n if ('li' in component) {\n applied = setIn(applied, component.p, component.li)\n }\n\n if ('oi' in component) {\n applied = setIn(applied, component.p, component.oi)\n }\n\n return applied\n}\n\nfunction selectTreeTransform(op: Operation[number]): typeof applyUpdate {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n\n if (hasDelete && hasInsert) return applyUpdate\n if (hasDelete) return applyDelete\n if (hasInsert) return applyInsert\n\n return elementTree => elementTree\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n // Updates the element tree \"cache\" based on the provided operation, which can\n // be composed of 1-n component ops. We apply each component op sequentially\n // to the 'old' root element to determine the changed elements and update the\n // cache accordingly at each intermediate step.\n const result = operation.reduce(\n (acc, op) => {\n const rootBefore = acc.rootBefore\n\n // If there's only one component op, we can skip the application of the op\n // and assume that the result will be the 'new' root element provided to\n // us by the builder.\n const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new\n\n const roots = { before: rootBefore, after: rootAfter }\n const applyChange = selectTreeTransform(op)\n\n return {\n elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),\n rootBefore: rootAfter,\n }\n },\n { elementTree, rootBefore: rootElements.old },\n )\n\n return result.elementTree\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAuC;AAEvC,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA+D;AAE/D,oCAAoC;AACpC,qCAAqC;AAErC,iCAA8C;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,W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