@makeswift/runtime 0.28.8-canary.12 → 0.28.8-canary.15

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 (340) 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/controls/rich-text/control.js +9 -3
  9. package/dist/cjs/controls/rich-text/control.js.map +1 -1
  10. package/dist/cjs/controls/rich-text-v2/control.js +6 -0
  11. package/dist/cjs/controls/rich-text-v2/control.js.map +1 -1
  12. package/dist/cjs/next/testing/breakpoints.js +3 -15
  13. package/dist/cjs/next/testing/breakpoints.js.map +1 -1
  14. package/dist/cjs/next/testing/element-data.js +3 -82
  15. package/dist/cjs/next/testing/element-data.js.map +1 -1
  16. package/dist/cjs/next/testing/react-runtime.js.map +1 -1
  17. package/dist/cjs/prop-controllers/instances.js +6 -0
  18. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  19. package/dist/cjs/runtimes/react/components/Element.js +21 -6
  20. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  21. package/dist/cjs/runtimes/react/components/ElementRegistration.js +5 -3
  22. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  23. package/dist/cjs/runtimes/react/components/resolve-props.js +5 -1
  24. package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
  25. package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  26. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +2 -2
  27. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  28. package/dist/cjs/runtimes/react/element-imperative-handle.js +2 -2
  29. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  30. package/dist/cjs/runtimes/react/hooks/use-control-instances.js +4 -3
  31. package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -1
  32. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +10 -9
  33. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  34. package/dist/cjs/runtimes/react/testing/index.js +25 -0
  35. package/dist/cjs/runtimes/react/testing/index.js.map +1 -0
  36. package/dist/cjs/runtimes/react/testing/react-provider.js +38 -0
  37. package/dist/cjs/runtimes/react/testing/react-provider.js.map +1 -0
  38. package/dist/cjs/state/actions/index.js +4 -4
  39. package/dist/cjs/state/actions/index.js.map +1 -1
  40. package/dist/cjs/state/actions/internal/action-types.js +34 -0
  41. package/dist/cjs/state/actions/internal/action-types.js.map +1 -0
  42. package/dist/cjs/state/actions/internal/index.js +0 -17
  43. package/dist/cjs/state/actions/internal/index.js.map +1 -1
  44. package/dist/cjs/state/actions/internal/read-only-action-types.js +44 -0
  45. package/dist/cjs/state/actions/internal/read-only-action-types.js.map +1 -0
  46. package/dist/cjs/state/actions/internal/read-only-actions.js +13 -92
  47. package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
  48. package/dist/cjs/state/actions/internal/read-write-action-types.js +41 -0
  49. package/dist/cjs/state/actions/internal/read-write-action-types.js.map +1 -0
  50. package/dist/cjs/state/actions/internal/read-write-actions.js +62 -14
  51. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  52. package/dist/cjs/state/builder-api/action-types.js +49 -0
  53. package/dist/cjs/state/builder-api/action-types.js.map +1 -0
  54. package/dist/cjs/state/builder-api/actions.js +14 -36
  55. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  56. package/dist/cjs/state/builder-api/proxy.js +2 -1
  57. package/dist/cjs/state/builder-api/proxy.js.map +1 -1
  58. package/dist/cjs/state/host-api/action-types.js +43 -0
  59. package/dist/cjs/state/host-api/action-types.js.map +1 -0
  60. package/dist/cjs/state/{host-api.js → host-api/actions.js} +17 -33
  61. package/dist/cjs/state/host-api/actions.js.map +1 -0
  62. package/dist/cjs/state/host-api/index.js +25 -0
  63. package/dist/cjs/state/host-api/index.js.map +1 -0
  64. package/dist/cjs/state/middleware/read-write/builder-api/index.js +15 -15
  65. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
  66. package/dist/cjs/state/middleware/read-write/measure-box-models.js +3 -3
  67. package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +1 -1
  68. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +12 -13
  69. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  70. package/dist/cjs/state/modules/api-resources.js +5 -5
  71. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  72. package/dist/cjs/state/modules/breakpoints.js +4 -4
  73. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  74. package/dist/cjs/state/modules/components-meta.js +3 -3
  75. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  76. package/dist/cjs/state/modules/element-trees.js +5 -5
  77. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  78. package/dist/cjs/state/modules/is-in-builder.js +2 -2
  79. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  80. package/dist/cjs/state/modules/is-read-only.js +2 -2
  81. package/dist/cjs/state/modules/is-read-only.js.map +1 -1
  82. package/dist/cjs/state/modules/locale.js +2 -2
  83. package/dist/cjs/state/modules/locale.js.map +1 -1
  84. package/dist/cjs/state/modules/localized-resources-map.js +3 -3
  85. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  86. package/dist/cjs/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +7 -7
  87. package/dist/cjs/state/modules/prop-controller-descriptors.js.map +1 -0
  88. package/dist/cjs/state/modules/react-components.js +3 -3
  89. package/dist/cjs/state/modules/react-components.js.map +1 -1
  90. package/dist/cjs/state/modules/read-write/box-models.js +5 -5
  91. package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
  92. package/dist/cjs/state/modules/read-write/element-imperative-handles.js +3 -3
  93. package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +1 -1
  94. package/dist/cjs/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +5 -5
  95. package/dist/cjs/state/modules/read-write/prop-controllers.js.map +1 -0
  96. package/dist/cjs/state/read-only-state.js +9 -44
  97. package/dist/cjs/state/read-only-state.js.map +1 -1
  98. package/dist/cjs/state/read-write-state.js +37 -0
  99. package/dist/cjs/state/read-write-state.js.map +1 -1
  100. package/dist/cjs/state/shared-api/action-types.js +33 -0
  101. package/dist/cjs/state/shared-api/action-types.js.map +1 -0
  102. package/dist/cjs/state/{shared-api.js → shared-api/actions.js} +8 -14
  103. package/dist/cjs/state/shared-api/actions.js.map +1 -0
  104. package/dist/cjs/state/shared-api/index.js +25 -0
  105. package/dist/cjs/state/shared-api/index.js.map +1 -0
  106. package/dist/cjs/state/store.js +3 -3
  107. package/dist/cjs/state/store.js.map +1 -1
  108. package/dist/cjs/state/translations/get.js.map +1 -1
  109. package/dist/cjs/state/translations/merge.js.map +1 -1
  110. package/dist/cjs/state/unified-state.js +12 -0
  111. package/dist/cjs/state/unified-state.js.map +1 -1
  112. package/dist/cjs/testing/breakpoints.js +35 -0
  113. package/dist/cjs/testing/breakpoints.js.map +1 -0
  114. package/dist/cjs/testing/element-data.js +102 -0
  115. package/dist/cjs/testing/element-data.js.map +1 -0
  116. package/dist/cjs/translations/index.js.map +1 -1
  117. package/dist/esm/api/graphql-api-client.js +1 -1
  118. package/dist/esm/api/rest-api-client.js +1 -1
  119. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  120. package/dist/esm/builder/host-to-builder-actions.js +2 -4
  121. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  122. package/dist/esm/client/index.js +1 -1
  123. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  124. package/dist/esm/controls/rich-text/control.js +9 -3
  125. package/dist/esm/controls/rich-text/control.js.map +1 -1
  126. package/dist/esm/controls/rich-text-v2/control.js +6 -0
  127. package/dist/esm/controls/rich-text-v2/control.js.map +1 -1
  128. package/dist/esm/next/testing/breakpoints.js +1 -8
  129. package/dist/esm/next/testing/breakpoints.js.map +1 -1
  130. package/dist/esm/next/testing/element-data.js +1 -75
  131. package/dist/esm/next/testing/element-data.js.map +1 -1
  132. package/dist/esm/next/testing/react-runtime.js.map +1 -1
  133. package/dist/esm/prop-controllers/instances.js +6 -0
  134. package/dist/esm/prop-controllers/instances.js.map +1 -1
  135. package/dist/esm/runtimes/react/components/Element.js +18 -6
  136. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  137. package/dist/esm/runtimes/react/components/ElementRegistration.js +4 -2
  138. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  139. package/dist/esm/runtimes/react/components/resolve-props.js +5 -1
  140. package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
  141. package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  142. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +1 -1
  143. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  144. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  145. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  146. package/dist/esm/runtimes/react/hooks/use-control-instances.js +3 -2
  147. package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -1
  148. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -9
  149. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  150. package/dist/esm/runtimes/react/testing/index.js +3 -0
  151. package/dist/esm/runtimes/react/testing/index.js.map +1 -0
  152. package/dist/esm/runtimes/react/testing/react-provider.js +14 -0
  153. package/dist/esm/runtimes/react/testing/react-provider.js.map +1 -0
  154. package/dist/esm/state/actions/index.js +2 -2
  155. package/dist/esm/state/actions/index.js.map +1 -1
  156. package/dist/esm/state/actions/internal/action-types.js +10 -0
  157. package/dist/esm/state/actions/internal/action-types.js.map +1 -0
  158. package/dist/esm/state/actions/internal/index.js +0 -9
  159. package/dist/esm/state/actions/internal/index.js.map +1 -1
  160. package/dist/esm/state/actions/internal/read-only-action-types.js +20 -0
  161. package/dist/esm/state/actions/internal/read-only-action-types.js.map +1 -0
  162. package/dist/esm/state/actions/internal/read-only-actions.js +1 -73
  163. package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
  164. package/dist/esm/state/actions/internal/read-write-action-types.js +17 -0
  165. package/dist/esm/state/actions/internal/read-write-action-types.js.map +1 -0
  166. package/dist/esm/state/actions/internal/read-write-actions.js +51 -8
  167. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  168. package/dist/esm/state/builder-api/action-types.js +25 -0
  169. package/dist/esm/state/builder-api/action-types.js.map +1 -0
  170. package/dist/esm/state/builder-api/actions.js +1 -24
  171. package/dist/esm/state/builder-api/actions.js.map +1 -1
  172. package/dist/esm/state/builder-api/proxy.js +2 -1
  173. package/dist/esm/state/builder-api/proxy.js.map +1 -1
  174. package/dist/esm/state/host-api/action-types.js +19 -0
  175. package/dist/esm/state/host-api/action-types.js.map +1 -0
  176. package/dist/esm/state/{host-api.js → host-api/actions.js} +2 -17
  177. package/dist/esm/state/host-api/actions.js.map +1 -0
  178. package/dist/esm/state/host-api/index.js +3 -0
  179. package/dist/esm/state/host-api/index.js.map +1 -0
  180. package/dist/esm/state/middleware/read-write/builder-api/index.js +1 -1
  181. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
  182. package/dist/esm/state/middleware/read-write/measure-box-models.js +3 -3
  183. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +1 -1
  184. package/dist/esm/state/middleware/read-write/prop-controller-handles.js +19 -13
  185. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  186. package/dist/esm/state/modules/api-resources.js +2 -2
  187. package/dist/esm/state/modules/api-resources.js.map +1 -1
  188. package/dist/esm/state/modules/breakpoints.js +2 -2
  189. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  190. package/dist/esm/state/modules/components-meta.js +1 -1
  191. package/dist/esm/state/modules/components-meta.js.map +1 -1
  192. package/dist/esm/state/modules/element-trees.js +2 -2
  193. package/dist/esm/state/modules/element-trees.js.map +1 -1
  194. package/dist/esm/state/modules/is-in-builder.js +1 -1
  195. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  196. package/dist/esm/state/modules/is-read-only.js +1 -1
  197. package/dist/esm/state/modules/is-read-only.js.map +1 -1
  198. package/dist/esm/state/modules/locale.js +1 -1
  199. package/dist/esm/state/modules/locale.js.map +1 -1
  200. package/dist/esm/state/modules/localized-resources-map.js +1 -1
  201. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  202. package/dist/esm/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +2 -2
  203. package/dist/esm/state/modules/prop-controller-descriptors.js.map +1 -0
  204. package/dist/esm/state/modules/react-components.js +1 -1
  205. package/dist/esm/state/modules/react-components.js.map +1 -1
  206. package/dist/esm/state/modules/read-write/box-models.js +2 -2
  207. package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
  208. package/dist/esm/state/modules/read-write/element-imperative-handles.js +3 -3
  209. package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +1 -1
  210. package/dist/esm/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +2 -2
  211. package/dist/esm/state/modules/read-write/prop-controllers.js.map +1 -0
  212. package/dist/esm/state/read-only-state.js +9 -41
  213. package/dist/esm/state/read-only-state.js.map +1 -1
  214. package/dist/esm/state/read-write-state.js +34 -0
  215. package/dist/esm/state/read-write-state.js.map +1 -1
  216. package/dist/esm/state/shared-api/action-types.js +9 -0
  217. package/dist/esm/state/shared-api/action-types.js.map +1 -0
  218. package/dist/esm/state/{shared-api.js → shared-api/actions.js} +2 -7
  219. package/dist/esm/state/shared-api/actions.js.map +1 -0
  220. package/dist/esm/state/shared-api/index.js +3 -0
  221. package/dist/esm/state/shared-api/index.js.map +1 -0
  222. package/dist/esm/state/store.js +1 -1
  223. package/dist/esm/state/store.js.map +1 -1
  224. package/dist/esm/state/translations/get.js.map +1 -1
  225. package/dist/esm/state/translations/merge.js +3 -1
  226. package/dist/esm/state/translations/merge.js.map +1 -1
  227. package/dist/esm/state/unified-state.js +4 -0
  228. package/dist/esm/state/unified-state.js.map +1 -1
  229. package/dist/esm/testing/breakpoints.js +9 -0
  230. package/dist/esm/testing/breakpoints.js.map +1 -0
  231. package/dist/esm/testing/element-data.js +76 -0
  232. package/dist/esm/testing/element-data.js.map +1 -0
  233. package/dist/esm/translations/index.js.map +1 -1
  234. package/dist/types/api/schema/page-pathname-slice.d.ts +2 -2
  235. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +6 -6
  236. package/dist/types/api-handler/handlers/webhook/types.d.ts +20 -20
  237. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  238. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  239. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  240. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  241. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
  242. package/dist/types/controls/rich-text/control.d.ts +3 -1
  243. package/dist/types/controls/rich-text/control.d.ts.map +1 -1
  244. package/dist/types/controls/rich-text-v2/control.d.ts +2 -0
  245. package/dist/types/controls/rich-text-v2/control.d.ts.map +1 -1
  246. package/dist/types/locale.d.ts +1 -1
  247. package/dist/types/next/testing/breakpoints.d.ts +1 -3
  248. package/dist/types/next/testing/breakpoints.d.ts.map +1 -1
  249. package/dist/types/next/testing/element-data.d.ts +1 -54
  250. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  251. package/dist/types/next/testing/react-runtime.d.ts.map +1 -1
  252. package/dist/types/prop-controllers/instances.d.ts +2 -0
  253. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  254. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  255. package/dist/types/runtimes/react/components/ElementRegistration.d.ts +1 -1
  256. package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
  257. package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
  258. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts +1 -1
  259. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
  260. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  261. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  262. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -1
  263. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +4 -3
  264. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
  265. package/dist/types/runtimes/react/hooks/use-store.d.ts +2 -4
  266. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  267. package/dist/types/runtimes/react/testing/index.d.ts +3 -0
  268. package/dist/types/runtimes/react/testing/index.d.ts.map +1 -0
  269. package/dist/types/runtimes/react/testing/react-provider.d.ts +8 -0
  270. package/dist/types/runtimes/react/testing/react-provider.d.ts.map +1 -0
  271. package/dist/types/state/__tests__/test-store.d.ts +2 -4
  272. package/dist/types/state/__tests__/test-store.d.ts.map +1 -1
  273. package/dist/types/state/actions/index.d.ts +6 -6
  274. package/dist/types/state/actions/index.d.ts.map +1 -1
  275. package/dist/types/state/actions/internal/action-types.d.ts +26 -0
  276. package/dist/types/state/actions/internal/action-types.d.ts.map +1 -0
  277. package/dist/types/state/actions/internal/index.d.ts +0 -25
  278. package/dist/types/state/actions/internal/index.d.ts.map +1 -1
  279. package/dist/types/state/actions/internal/read-only-action-types.d.ts +15 -0
  280. package/dist/types/state/actions/internal/read-only-action-types.d.ts.map +1 -0
  281. package/dist/types/state/actions/internal/read-only-actions.d.ts +3 -76
  282. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
  283. package/dist/types/state/actions/internal/read-write-action-types.d.ts +14 -0
  284. package/dist/types/state/actions/internal/read-write-action-types.d.ts.map +1 -0
  285. package/dist/types/state/actions/internal/read-write-actions.d.ts +57 -9
  286. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  287. package/dist/types/state/builder-api/action-types.d.ts +22 -0
  288. package/dist/types/state/builder-api/action-types.d.ts.map +1 -0
  289. package/dist/types/state/builder-api/actions.d.ts +1 -21
  290. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  291. package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
  292. package/dist/types/state/host-api/action-types.d.ts +17 -0
  293. package/dist/types/state/host-api/action-types.d.ts.map +1 -0
  294. package/dist/types/state/{host-api.d.ts → host-api/actions.d.ts} +7 -22
  295. package/dist/types/state/host-api/actions.d.ts.map +1 -0
  296. package/dist/types/state/host-api/index.d.ts +3 -0
  297. package/dist/types/state/host-api/index.d.ts.map +1 -0
  298. package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -1
  299. package/dist/types/state/modules/element-trees.d.ts +1 -1
  300. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  301. package/dist/types/state/modules/{prop-controllers.d.ts → prop-controller-descriptors.d.ts} +1 -1
  302. package/dist/types/state/modules/prop-controller-descriptors.d.ts.map +1 -0
  303. package/dist/types/state/modules/{prop-controller-handles.d.ts → read-write/prop-controllers.d.ts} +4 -4
  304. package/dist/types/state/modules/{prop-controller-handles.d.ts.map → read-write/prop-controllers.d.ts.map} +1 -1
  305. package/dist/types/state/read-only-state.d.ts +6 -70
  306. package/dist/types/state/read-only-state.d.ts.map +1 -1
  307. package/dist/types/state/read-write-state.d.ts +67 -4
  308. package/dist/types/state/read-write-state.d.ts.map +1 -1
  309. package/dist/types/state/shared-api/action-types.d.ts +6 -0
  310. package/dist/types/state/shared-api/action-types.d.ts.map +1 -0
  311. package/dist/types/state/{shared-api.d.ts → shared-api/actions.d.ts} +3 -7
  312. package/dist/types/state/shared-api/actions.d.ts.map +1 -0
  313. package/dist/types/state/shared-api/index.d.ts +3 -0
  314. package/dist/types/state/shared-api/index.d.ts.map +1 -0
  315. package/dist/types/state/store.d.ts +4 -8
  316. package/dist/types/state/store.d.ts.map +1 -1
  317. package/dist/types/state/translations/get.d.ts +1 -1
  318. package/dist/types/state/translations/get.d.ts.map +1 -1
  319. package/dist/types/state/translations/merge.d.ts +1 -1
  320. package/dist/types/state/translations/merge.d.ts.map +1 -1
  321. package/dist/types/state/unified-state.d.ts +1 -0
  322. package/dist/types/state/unified-state.d.ts.map +1 -1
  323. package/dist/types/testing/breakpoints.d.ts +4 -0
  324. package/dist/types/testing/breakpoints.d.ts.map +1 -0
  325. package/dist/types/testing/element-data.d.ts +55 -0
  326. package/dist/types/testing/element-data.d.ts.map +1 -0
  327. package/dist/types/translations/index.d.ts +1 -1
  328. package/dist/types/translations/index.d.ts.map +1 -1
  329. package/package.json +4 -4
  330. package/dist/cjs/state/host-api.js.map +0 -1
  331. package/dist/cjs/state/modules/prop-controller-handles.js.map +0 -1
  332. package/dist/cjs/state/modules/prop-controllers.js.map +0 -1
  333. package/dist/cjs/state/shared-api.js.map +0 -1
  334. package/dist/esm/state/host-api.js.map +0 -1
  335. package/dist/esm/state/modules/prop-controller-handles.js.map +0 -1
  336. package/dist/esm/state/modules/prop-controllers.js.map +0 -1
  337. package/dist/esm/state/shared-api.js.map +0 -1
  338. package/dist/types/state/host-api.d.ts.map +0 -1
  339. package/dist/types/state/modules/prop-controllers.d.ts.map +0 -1
  340. package/dist/types/state/shared-api.d.ts.map +0 -1
@@ -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,EAIE;AAAA,EACA;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,OAIK;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,EACj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,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":[]}
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,EAIE;AAAA,EACA;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,OAIK;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;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,MAAM,mBAAmB,CAAC,gBAC/B,YAAY,IAAI,aAAW;AAAA,EACzB,IAAI,OAAO;AAAA,EACX,OAAO,wBAAwB,MAAM,EAAE,QAAQ,UAAU,EAAE;AAC7D,EAAE;AAEJ,MAAM,sBAAsB,CAAC,gBAC3B,kBAAkB,WAAW,EAAE;AAoB1B,SAAS,6BAA6B,aAAwC;AACnF,QAAM,iBAAiB,oBAAoB,WAAW;AACtD,MAAI,SAAS;AAAG,WAAO;AAGvB,QAAM,qBAAqB,iBAAiB,WAAW,EAAE;AAAA,IACvD,CAAC,EAAE,MAAM,MAAM,OAAO,WAAW,K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CAAC;AACH;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { isKnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  const ComponentIcon = {
4
4
  Accordion: "accordion",
5
5
  Audio: "audio",
@@ -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,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAE7B,MAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAiBO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,iBAAiB,OAAc,MAAoC;AACjF,SAAO,kBAAkB,KAAK,EAAE,IAAI,IAAI,KAAK;AAC/C;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,oBAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, 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":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAE7B,MAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAiBO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,iBAAiB,OAAc,MAAoC;AACjF,SAAO,kBAAkB,KAAK,EAAE,IAAI,IAAI,KAAK;AAC/C;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,oBAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -2,8 +2,8 @@ import { getIn, removeIn, setIn } from "immutable";
2
2
  import { isElementReference } from "@makeswift/controls";
3
3
  import * as Introspection from "../../prop-controllers/introspection";
4
4
  import { isKnownAction } from "../actions";
5
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
6
- import { ReadWriteActionTypes } from "../actions/internal/read-write-actions";
5
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
6
+ import { ReadWriteActionTypes } from "../actions/internal/read-write-action-types";
7
7
  import { getRootElement } from "./read-only-documents";
8
8
  function getInitialState(documents, descriptors) {
9
9
  const state = /* @__PURE__ */ new Map();
@@ -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":"AACA,SAAS,OAAO,UAAU,aAAa;AAEvC,SAAyC,0BAA0B;AAEnE,YAAY,mBAAmB;AAE/B,SAA0C,qBAAqB;AAE/D,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAErC,SAAS,sBAAqC;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,iBAAiB,eAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YAAY,oBAAI,IAAI;AACjE;AAEO,SAAS,cAAc,OAAc,aAA0C;AACpF,SAAO,eAAe,OAAO,WAAW,GAAG,cAAc,oBAAI,IAAI;AACnE;AAEO,SAAS,WAAW,OAAc,aAAqB,YAAoC;AAChG,SAAO,YAAY,OAAO,WAAW,EAAE,IAAI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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":"AACA,SAAS,OAAO,UAAU,aAAa;AAEvC,SAAyC,0BAA0B;AAEnE,YAAY,mBAAmB;AAE/B,SAA0C,qBAAqB;AAE/D,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAErC,SAAS,sBAAqC;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,iBAAiB,eAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YAAY,oBAAI,IAAI;AACjE;AAEO,SAAS,cAAc,OAAc,aAA0C;AACpF,SAAO,eAAe,OAAO,WAAW,GAAG,cAAc,oBAAI,IAAI;AACnE;AAEO,SAAS,WAAW,OAAc,aAAqB,YAAoC;AAChG,SAAO,YAAY,OAAO,WAAW,EAAE,IAAI,UAAU,KAAK;AAC5D;AAEO,SAAS,aAAa,OAAc,aAAqB,YAAmC;AACjG,SAAO,cAAc,OAAO,WAAW,EAAE,IAAI,UAAU,KAAK;AAC9D;AAEO,SAAS,QAAQ,QAAe,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,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,5 +1,5 @@
1
1
  import { isKnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  function getInitialState() {
4
4
  return false;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/is-in-builder.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/is-in-builder.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport type State = boolean\n\nexport function getInitialState(): State {\n return false\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_IS_IN_BUILDER:\n return action.payload\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { isKnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  function getInitialState(isReadOnly = true) {
4
4
  return isReadOnly;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/is-read-only.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport type State = boolean\n\nexport function getInitialState(isReadOnly = true): State {\n return isReadOnly\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_IS_READ_ONLY:\n return action.payload\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,gBAAgB,aAAa,MAAa;AACxD,SAAO;AACT;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/is-read-only.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport type State = boolean\n\nexport function getInitialState(isReadOnly = true): State {\n return isReadOnly\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_IS_READ_ONLY:\n return action.payload\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,gBAAgB,aAAa,MAAa;AACxD,SAAO;AACT;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { isKnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  function getInitialState(locale = null) {
4
4
  return locale;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/locale.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport type State = string | null\n\nexport function getInitialState(locale: string | null = null): State {\n return locale\n}\n\nexport function getLocale(state: State): string | null {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_LOCALE:\n return action.payload.locale\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,gBAAgB,SAAwB,MAAa;AACnE,SAAO;AACT;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO,QAAQ;AAAA,IAExB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/locale.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport type State = string | null\n\nexport function getInitialState(locale: string | null = null): State {\n return locale\n}\n\nexport function getLocale(state: State): string | null {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.SET_LOCALE:\n return action.payload.locale\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,gBAAgB,SAAwB,MAAa;AACnE,SAAO;AACT;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,OAAO,QAAQ;AAAA,IAExB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import { mapValues } from "@makeswift/controls";
2
2
  import { isKnownAction } from "../actions";
3
- import { ReadWriteActionTypes } from "../actions/internal/read-write-actions";
3
+ import { ReadWriteActionTypes } from "../actions/internal/read-write-action-types";
4
4
  import { HostActionTypes } from "../host-api";
5
5
  function getInitialState(serializedState = {}) {
6
6
  return new Map(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/localized-resources-map.ts"],"sourcesContent":["import { mapValues } from '@makeswift/controls'\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\nimport { HostActionTypes } from '../host-api'\n\ntype State = Map<string, Map<string, string | null>>\n\nexport type SerializedState = {\n [locale: string]: {\n [resourceId: string]: string | null\n }\n}\n\nexport function getInitialState(serializedState: SerializedState = {}): State {\n return new Map(\n Object.entries(mapValues(serializedState, resources => new Map(Object.entries(resources)))),\n )\n}\n\nexport function getSerializedState(state: State): SerializedState {\n return mapValues(Object.fromEntries(state.entries()), resources =>\n Object.fromEntries(resources.entries()),\n )\n}\n\nexport function getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return state.get(locale)?.get(resourceId)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case HostActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { resourceId, localizedResourceId, locale } = action.payload\n\n if (locale == null) {\n console.error('Attempt to set a localized resource ID for a non-localized page', {\n resourceId,\n localizedResourceId,\n })\n\n return state\n }\n\n return new Map(state).set(\n locale,\n (state.get(locale) ?? new Map()).set(resourceId, localizedResourceId),\n )\n }\n\n case ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { localizedResourcesMap } = action.payload\n\n return Object.entries(localizedResourcesMap).reduce((state, [locale, resources]) => {\n const existing = state.get(locale) ?? new Map<string, string | null>()\n const updated = Object.entries(resources).reduce((r, [id, localizedId]) => {\n return r.get(id) != null ? r : new Map(r).set(id, localizedId)\n }, existing)\n\n return updated === existing ? state : new Map(state).set(locale, updated)\n }, state)\n }\n\n case ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAUzB,SAAS,gBAAgB,kBAAmC,CAAC,GAAU;AAC5E,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,UAAU,iBAAiB,eAAa,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,CAAC,CAAC;AAAA,EAC5F;AACF;AAEO,SAAS,mBAAmB,OAA+B;AAChE,SAAO;AAAA,IAAU,OAAO,YAAY,MAAM,QAAQ,CAAC;AAAA,IAAG,eACpD,OAAO,YAAY,UAAU,QAAQ,CAAC;AAAA,EACxC;AACF;AAEO,SAAS,uBACd,OACA,QACA,YAC2B;AAC3B,SAAO,MAAM,IAAI,MAAM,GAAG,IAAI,UAAU;AAC1C;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,gBAAgB,2BAA2B;AAC9C,YAAM,EAAE,YAAY,qBAAqB,OAAO,IAAI,OAAO;AAE3D,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,mEAAmE;AAAA,UAC/E;AAAA,UACA;AAAA,QACF,CAAC;AAED,eAAO;AAAA,MACT;AAEA,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB;AAAA,SACC,MAAM,IAAI,MAAM,KAAK,oBAAI,IAAI,GAAG,IAAI,YAAY,mBAAmB;AAAA,MACtE;AAAA,IACF;AAAA,IAEA,KAAK,qBAAqB,yBAAyB;AACjD,YAAM,EAAE,sBAAsB,IAAI,OAAO;AAEzC,aAAO,OAAO,QAAQ,qBAAqB,EAAE,OAAO,CAACA,QAAO,CAAC,QAAQ,SAAS,MAAM;AAClF,cAAM,WAAWA,OAAM,IAAI,MAAM,KAAK,oBAAI,IAA2B;AACrE,cAAM,UAAU,OAAO,QAAQ,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,WAAW,MAAM;AACzE,iBAAO,EAAE,IAAI,EAAE,KAAK,OAAO,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,WAAW;AAAA,QAC/D,GAAG,QAAQ;AAEX,eAAO,YAAY,WAAWA,SAAQ,IAAI,IAAIA,MAAK,EAAE,IAAI,QAAQ,OAAO;AAAA,MAC1E,GAAG,KAAK;AAAA,IACV;AAAA,IAEA,KAAK,qBAAqB,wBAAwB;AAChD,aAAO,gBAAgB;AAAA,IACzB;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["state"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/localized-resources-map.ts"],"sourcesContent":["import { mapValues } from '@makeswift/controls'\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-action-types'\nimport { HostActionTypes } from '../host-api'\n\ntype State = Map<string, Map<string, string | null>>\n\nexport type SerializedState = {\n [locale: string]: {\n [resourceId: string]: string | null\n }\n}\n\nexport function getInitialState(serializedState: SerializedState = {}): State {\n return new Map(\n Object.entries(mapValues(serializedState, resources => new Map(Object.entries(resources)))),\n )\n}\n\nexport function getSerializedState(state: State): SerializedState {\n return mapValues(Object.fromEntries(state.entries()), resources =>\n Object.fromEntries(resources.entries()),\n )\n}\n\nexport function getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return state.get(locale)?.get(resourceId)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case HostActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { resourceId, localizedResourceId, locale } = action.payload\n\n if (locale == null) {\n console.error('Attempt to set a localized resource ID for a non-localized page', {\n resourceId,\n localizedResourceId,\n })\n\n return state\n }\n\n return new Map(state).set(\n locale,\n (state.get(locale) ?? new Map()).set(resourceId, localizedResourceId),\n )\n }\n\n case ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { localizedResourcesMap } = action.payload\n\n return Object.entries(localizedResourcesMap).reduce((state, [locale, resources]) => {\n const existing = state.get(locale) ?? new Map<string, string | null>()\n const updated = Object.entries(resources).reduce((r, [id, localizedId]) => {\n return r.get(id) != null ? r : new Map(r).set(id, localizedId)\n }, existing)\n\n return updated === existing ? state : new Map(state).set(locale, updated)\n }, state)\n }\n\n case ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAUzB,SAAS,gBAAgB,kBAAmC,CAAC,GAAU;AAC5E,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,UAAU,iBAAiB,eAAa,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,CAAC,CAAC;AAAA,EAC5F;AACF;AAEO,SAAS,mBAAmB,OAA+B;AAChE,SAAO;AAAA,IAAU,OAAO,YAAY,MAAM,QAAQ,CAAC;AAAA,IAAG,eACpD,OAAO,YAAY,UAAU,QAAQ,CAAC;AAAA,EACxC;AACF;AA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KnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  function getInitialState({
4
4
  propControllerDescriptors = /* @__PURE__ */ new Map()
5
5
  } = {}) {
@@ -32,4 +32,4 @@ export {
32
32
  getPropControllerDescriptors,
33
33
  reducer
34
34
  };
35
- //# sourceMappingURL=prop-controllers.js.map
35
+ //# sourceMappingURL=prop-controller-descriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/prop-controller-descriptors.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nimport { Descriptor as PropControllerDescriptor } from '../../prop-controllers/descriptors'\n\nexport type { PropControllerDescriptor }\n\nexport type DescriptorsByProp = Record<string, PropControllerDescriptor>\nexport type DescriptorsByComponentType = Map<string, DescriptorsByProp>\nexport type State = DescriptorsByComponentType\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: State\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(state: State): State {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): DescriptorsByProp | null {\n return getPropControllerDescriptors(state).get(componentType) ?? 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.propControllerDescriptors)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.type)\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAU7B,SAAS,gBAAgB;AAAA,EAC9B,4BAA4B,oBAAI,IAAI;AACtC,IAEI,CAAC,GAAU;AACb,SAAO;AACT;AAEO,SAAS,6BAA6B,OAAqB;AAChE,SAAO;AACT;AAEO,SAAS,sCACd,OACA,eAC0B;AAC1B,SAAO,6BAA6B,KAAK,EAAE,IAAI,aAAa,KAAK;AACnE;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,yBAAyB;AAAA,IAEzF,KAAK,oBAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAC/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AACpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { isKnownAction } from "../actions";
2
- import { ReadOnlyActionTypes } from "../actions/internal/read-only-actions";
2
+ import { ReadOnlyActionTypes } from "../actions/internal/read-only-action-types";
3
3
  function getInitialState({
4
4
  reactComponents = /* @__PURE__ */ new Map()
5
5
  } = {}) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/react-components.tsx"],"sourcesContent":["import type { Component, PropsWithoutRef, ReactNode, RefAttributes } from 'react'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactNode)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ReadOnlyActionTypes.UNREGISTER_REACT_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":"AAEA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAQ7B,SAAS,gBAAgB;AAAA,EAC9B,kBAAkB,oBAAI,IAAI;AAC5B,IAAsD,CAAC,GAAU;AAC/D,SAAO;AACT;AAEA,SAAS,mBAAmB,OAA0C;AACpE,SAAO;AACT;AAEO,SAAS,kBAAkB,OAAc,MAAoC;AAClF,SAAO,mBAAmB,KAAK,EAAE,IAAI,IAAI,KAAK;AAChD;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAgC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS;AAAA,IAEzE,KAAK,oBAAoB,4BAA4B;AACnD,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/react-components.tsx"],"sourcesContent":["import type { Component, PropsWithoutRef, ReactNode, RefAttributes } from 'react'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactNode)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ReadOnlyActionTypes.UNREGISTER_REACT_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":"AAEA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAQ7B,SAAS,gBAAgB;AAAA,EAC9B,kBAAkB,oBAAI,IAAI;AAC5B,IAAsD,CAAC,GAAU;AAC/D,SAAO;AACT;AAEA,SAAS,mBAAmB,OAA0C;AACpE,SAAO;AACT;AAEO,SAAS,kBAAkB,OAAc,MAAoC;AAClF,SAAO,mBAAmB,KAAK,EAAE,IAAI,IAAI,KAAK;AAChD;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAgC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS;AAAA,IAEzE,KAAK,oBAAoB,4BAA4B;AACnD,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -4,8 +4,8 @@ import {
4
4
  withScroll
5
5
  } from "css-box-model";
6
6
  import { isKnownAction } from "../../actions";
7
- import { ReadWriteActionTypes } from "../../actions/internal/read-write-actions";
8
- import { BuilderActionTypes } from "../../builder-api/actions";
7
+ import { ReadWriteActionTypes } from "../../actions/internal/read-write-action-types";
8
+ import { BuilderActionTypes } from "../../builder-api/action-types";
9
9
  function parse(rawString) {
10
10
  const value = Number(rawString.replace(/px$/, ""));
11
11
  return Number.isFinite(value) ? value : 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/modules/read-write/box-models.ts"],"sourcesContent":["import { type BoxDisplayModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-actions'\nimport { BuilderActionTypes } from '../../builder-api/actions'\n\nexport type { BoxDisplayModel }\n\nexport function parse(rawString: string): number {\n const value = Number(rawString.replace(/px$/, ''))\n\n return Number.isFinite(value) ? value : 0\n}\n\nexport function createBox(boxArgs: CreateBoxArgs & { visible?: boolean }): BoxDisplayModel {\n const box = withScroll(createBoxWithoutScroll(boxArgs))\n return { ...box, visible: boxArgs.visible }\n}\n\nexport function isElementVisible(element: Element): boolean {\n // checkVisibility is widely supported as of March 2024, but we're adding this\n // check as a precaution for browsers where it may not be available.\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility\n if (element.checkVisibility == null) {\n return true\n }\n\n return element.checkVisibility({\n visibilityProperty: true,\n contentVisibilityAuto: true,\n opacityProperty: true,\n })\n}\n\nexport function getBox(element: Element): BoxDisplayModel {\n const visible = isElementVisible(element)\n const boxModel = withScroll(getBoxWithoutScroll(element))\n\n return { ...boxModel, visible }\n}\n\nexport interface BoxModelHandle {\n getBoxModel(): BoxDisplayModel | null\n}\n\nexport type Measurable = Element | BoxModelHandle\n\nexport function isMeasurable(value: unknown): value is Measurable {\n if (value instanceof Element) return true\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getBoxModel' in value &&\n typeof (value as { getBoxModel: unknown }).getBoxModel === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport function measure(measurable: Measurable): BoxDisplayModel | null {\n if (measurable instanceof Element) return getBox(measurable)\n\n return measurable.getBoxModel()\n}\n\nexport type State = {\n measurables: Map<string, Map<string, Measurable>>\n boxModels: Map<string, Map<string, BoxDisplayModel>>\n}\n\nexport function getInitialState(): State {\n return { measurables: new Map(), boxModels: new Map() }\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, Measurable>> {\n return state.measurables\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxDisplayModel>> {\n return state.boxModels\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxDisplayModel | null {\n return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_MEASURABLE: {\n const { documentKey, elementKey, measurable } = action.payload\n\n return {\n ...state,\n measurables: new Map(state.measurables).set(\n documentKey,\n new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable),\n ),\n }\n }\n\n case ReadWriteActionTypes.UNREGISTER_MEASURABLE: {\n const { documentKey, elementKey } = action.payload\n const nextMeasurables = new Map(state.measurables.get(documentKey) ?? [])\n\n const deleted = nextMeasurables.delete(elementKey)\n\n return deleted\n ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) }\n : state\n }\n\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {\n const { changedElementBoxModels } = action.payload\n\n if (changedElementBoxModels.size === 0) return state\n\n const nextBoxModels = new Map(state.boxModels)\n\n changedElementBoxModels.forEach((changedBoxModels, documentKey) => {\n const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? [])\n\n changedBoxModels.forEach((changedBoxModel, elementKey) => {\n if (changedBoxModel == null) nextDocumentBoxModels.delete(elementKey)\n else nextDocumentBoxModels.set(elementKey, changedBoxModel)\n })\n\n if (nextDocumentBoxModels.size > 0) nextBoxModels.set(documentKey, nextDocumentBoxModels)\n else nextBoxModels.delete(documentKey)\n })\n\n return { ...state, boxModels: nextBoxModels }\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA;AAAA,EACE,aAAa;AAAA,EAEb,UAAU;AAAA,EACV;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAI5B,SAAS,MAAM,WAA2B;AAC/C,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,EAAE,CAAC;AAEjD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAEO,SAAS,UAAU,SAAiE;AACzF,QAAM,MAAM,WAAW,uBAAuB,OAAO,CAAC;AACtD,SAAO,EAAE,GAAG,KAAK,SAAS,QAAQ,QAAQ;AAC5C;AAEO,SAAS,iBAAiB,SAA2B;AAI1D,MAAI,QAAQ,mBAAmB,MAAM;AACnC,WAAO;AAAA,EACT;AAEA,SAAO,QAAQ,gBAAgB;AAAA,IAC7B,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,EACnB,CAAC;AACH;AAEO,SAAS,OAAO,SAAmC;AACxD,QAAM,UAAU,iBAAiB,OAAO;AACxC,QAAM,WAAW,WAAW,oBAAoB,OAAO,CAAC;AAExD,SAAO,EAAE,GAAG,UAAU,QAAQ;AAChC;AAQO,SAAS,aAAa,OAAqC;AAChE,MAAI,iBAAiB;A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,IACtF;AAAA,IACN;AAAA,IAEA,KAAK,mBAAmB,2BAA2B;AACjD,YAAM,EAAE,wBAAwB,IAAI,OAAO;AAE3C,UAAI,wBAAwB,SAAS;AAAG,eAAO;AAE/C,YAAM,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAE7C,8BAAwB,QAAQ,CAAC,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/state/modules/read-write/box-models.ts"],"sourcesContent":["import { type BoxDisplayModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\nimport { BuilderActionTypes } from '../../builder-api/action-types'\n\nexport type { BoxDisplayModel }\n\nexport function parse(rawString: string): number {\n const value = Number(rawString.replace(/px$/, ''))\n\n return Number.isFinite(value) ? value : 0\n}\n\nexport function createBox(boxArgs: CreateBoxArgs & { visible?: boolean }): BoxDisplayModel {\n const box = withScroll(createBoxWithoutScroll(boxArgs))\n return { ...box, visible: boxArgs.visible }\n}\n\nexport function isElementVisible(element: Element): boolean {\n // checkVisibility is widely supported as of March 2024, but we're adding this\n // check as a precaution for browsers where it may not be available.\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility\n if (element.checkVisibility == null) {\n return true\n }\n\n return element.checkVisibility({\n visibilityProperty: true,\n contentVisibilityAuto: true,\n opacityProperty: true,\n })\n}\n\nexport function getBox(element: Element): BoxDisplayModel {\n const visible = isElementVisible(element)\n const boxModel = withScroll(getBoxWithoutScroll(element))\n\n return { ...boxModel, visible }\n}\n\nexport interface BoxModelHandle {\n getBoxModel(): BoxDisplayModel | null\n}\n\nexport type Measurable = Element | BoxModelHandle\n\nexport function isMeasurable(value: unknown): value is Measurable {\n if (value instanceof Element) return true\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getBoxModel' in value &&\n typeof (value as { getBoxModel: unknown }).getBoxModel === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport function measure(measurable: Measurable): BoxDisplayModel | null {\n if (measurable instanceof Element) return getBox(measurable)\n\n return measurable.getBoxModel()\n}\n\nexport type State = {\n measurables: Map<string, Map<string, Measurable>>\n boxModels: Map<string, Map<string, BoxDisplayModel>>\n}\n\nexport function getInitialState(): State {\n return { measurables: new Map(), boxModels: new Map() }\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, Measurable>> {\n return state.measurables\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxDisplayModel>> {\n return state.boxModels\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxDisplayModel | null {\n return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_MEASURABLE: {\n const { documentKey, elementKey, measurable } = action.payload\n\n return {\n ...state,\n measurables: new Map(state.measurables).set(\n documentKey,\n new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable),\n ),\n }\n }\n\n case ReadWriteActionTypes.UNREGISTER_MEASURABLE: {\n const { documentKey, elementKey } = action.payload\n const nextMeasurables = new Map(state.measurables.get(documentKey) ?? [])\n\n const deleted = nextMeasurables.delete(elementKey)\n\n return deleted\n ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) }\n : state\n }\n\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {\n const { changedElementBoxModels } = action.payload\n\n if (changedElementBoxModels.size === 0) return state\n\n const nextBoxModels = new Map(state.boxModels)\n\n changedElementBoxModels.forEach((changedBoxModels, documentKey) => {\n const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? [])\n\n changedBoxModels.forEach((changedBoxModel, elementKey) => {\n if (changedBoxModel == null) nextDocumentBoxModels.delete(elementKey)\n else nextDocumentBoxModels.set(elementKey, changedBoxModel)\n })\n\n if (nextDocumentBoxModels.size > 0) nextBoxModels.set(documentKey, nextDocumentBoxModels)\n else nextBoxModels.delete(documentKey)\n })\n\n return { ...state, boxModels: nextBoxModels }\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA;AAAA,EACE,aAAa;AAAA,EAEb,UAAU;AAAA,EACV;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAI5B,SAAS,MAAM,WAA2B;AAC/C,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,EAAE,CAAC;AAEjD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAEO,SAAS,UAAU,SAAiE;AACzF,QAAM,MAAM,WAAW,uBAAuB,OAAO,CAAC;AACtD,SAAO,EAAE,GAAG,KAAK,SAAS,QAAQ,QAAQ;AAC5C;AAEO,SAAS,iBAAiB,SAA2B;AAI1D,MAAI,QAAQ,mBAAmB,MAAM;AACnC,WAAO;AAAA,EACT;AAEA,SAAO,QAAQ,gBAAgB;AAAA,IAC7B,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,EACnB,CAAC;AACH;AAEO,SAAS,OAAO,SAAmC;AAC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,IAAI,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,gBAAgB,OAAO,UAAU;AAEjD,aAAO,UACH,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,MAAM,WAAW,EAAE,IAAI,aAAa,eAAe,EAAE,IACtF;AAAA,IACN;AAAA,IAEA,KAAK,mBAAmB,2BAA2B;AACjD,YAAM,EAAE,wBAAwB,IAAI,OAAO;AAE3C,UAAI,wBAAwB,SAAS;AAAG,eAAO;AAE/C,YAAM,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAE7C,8BAAwB,QAAQ,CAAC,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { isKnownAction } from "../../actions";
2
- import { ReadOnlyActionTypes } from "../../actions/internal/read-only-actions";
2
+ import { ReadWriteActionTypes } from "../../actions/internal/read-write-action-types";
3
3
  function getElementImperativeHandles(state) {
4
4
  return state;
5
5
  }
@@ -10,7 +10,7 @@ function reducer(state = getInitialState(), action) {
10
10
  if (!isKnownAction(action))
11
11
  return state;
12
12
  switch (action.type) {
13
- case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE:
13
+ case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE:
14
14
  return new Map(state).set(
15
15
  action.payload.documentKey,
16
16
  new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
@@ -18,7 +18,7 @@ function reducer(state = getInitialState(), action) {
18
18
  action.payload.componentHandle
19
19
  )
20
20
  );
21
- case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {
21
+ case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
22
22
  const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
23
23
  const deleted = byElementKey.delete(action.payload.elementKey);
24
24
  if (!deleted)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/modules/read-write/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\n\nexport type State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAI7B,SAAS,4BACd,OACmD;AACnD,SAAO;AACT;AAEA,SAAS,kBAAyB;AAChC,SAAO,oBAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAAA,UAC5D,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,oBAAoB,6BAA6B;AACpD,YAAM,eAAe,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,aAAa,OAAO,OAAO,QAAQ,UAAU;AAE7D,UAAI,CAAC;AAAS,eAAO;AAErB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY;AAAA,IACpE;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/state/modules/read-write/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nexport type State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AAI9B,SAAS,4BACd,OACmD;AACnD,SAAO;AACT;AAEA,SAAS,kBAAyB;AAChC,SAAO,oBAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,qBAAqB;AACxB,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAAA,UAC5D,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,qBAAqB,6BAA6B;AACrD,YAAM,eAAe,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,aAAa,OAAO,OAAO,QAAQ,UAAU;AAE7D,UAAI,CAAC;AAAS,eAAO;AAErB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY;AAAA,IACpE;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { ActionTypes, isKnownAction } from "../actions";
1
+ import { ActionTypes, isKnownAction } from "../../actions";
2
2
  function isPropControllersHandle(value) {
3
3
  if (typeof value === "object" && value !== null && "setPropControllers" in value && typeof value.setPropControllers === "function") {
4
4
  return true;
@@ -65,4 +65,4 @@ export {
65
65
  isPropControllersHandle,
66
66
  reducer
67
67
  };
68
- //# sourceMappingURL=prop-controller-handles.js.map
68
+ //# sourceMappingURL=prop-controllers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/state/modules/read-write/prop-controllers.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../../actions'\nimport type { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport type { Descriptor } from '../../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, ControlInstance>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, ControlInstance> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): ControlInstance | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,aAAa,qBAAqB;AAUrE,SAAS,wBAAwB,OAAgD;AACtF,MACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACxB,OAAQ,MAA0C,uBAAuB,YACzE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOO,SAAS,kBAAyB;AACvC,SAAO,EAAE,SAAS,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACpD;AAEO,SAAS,yBACd,OACA,aACA,YAC8B;AAC9B,SAAO,MAAM,QAAQ,IAAI,WAAW,GAAG,IAAI,UAAU,KAAK;AAC5D;AAEO,SAAS,mBACd,OACA,aACA,YACwC;AACxC,SAAO,MAAM,UAAU,IAAI,WAAW,GAAG,IAAI,UAAU,KAAK;AAC9D;AAEO,SAAS,kBACd,OACA,aACA,YACA,UACwB;AACxB,SAAO,mBAAmB,OAAO,aAAa,UAAU,IAAI,QAAQ,KAAK;AAC3E;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cA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AAA,IACN;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -5,8 +5,7 @@ import * as Documents from "./modules/read-only-documents";
5
5
  import * as ElementTrees from "./modules/element-trees";
6
6
  import * as ReactComponents from "./modules/react-components";
7
7
  import * as ComponentsMeta from "./modules/components-meta";
8
- import * as PropControllers from "./modules/prop-controllers";
9
- import * as PropControllerHandles from "./modules/prop-controller-handles";
8
+ import * as PropControllerDescriptors from "./modules/prop-controller-descriptors";
10
9
  import * as IsInBuilder from "./modules/is-in-builder";
11
10
  import * as IsReadOnly from "./modules/is-read-only";
12
11
  import * as BuilderEditMode from "./modules/builder-edit-mode";
@@ -25,8 +24,7 @@ const reducers = {
25
24
  elementTrees: ElementTrees.reducer,
26
25
  reactComponents: ReactComponents.reducer,
27
26
  componentsMeta: ComponentsMeta.reducer,
28
- propControllers: PropControllers.reducer,
29
- propControllerHandles: PropControllerHandles.reducer,
27
+ propControllerDescriptors: PropControllerDescriptors.reducer,
30
28
  isInBuilder: IsInBuilder.reducer,
31
29
  builderEditMode: BuilderEditMode.reducer,
32
30
  breakpoints: Breakpoints.reducer
@@ -61,47 +59,20 @@ function getComponentsMeta(state) {
61
59
  function getComponentMeta(state, type) {
62
60
  return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type);
63
61
  }
64
- function getPropControllersStateSlice(state) {
65
- return state.propControllers;
62
+ function getPropControllerDescriptorsStateSlice(state) {
63
+ return state.propControllerDescriptors;
66
64
  }
67
65
  function getPropControllerDescriptors(state) {
68
- return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state));
66
+ return PropControllerDescriptors.getPropControllerDescriptors(
67
+ getPropControllerDescriptorsStateSlice(state)
68
+ );
69
69
  }
70
70
  function getComponentPropControllerDescriptors(state, componentType) {
71
- return PropControllers.getComponentPropControllerDescriptors(
72
- getPropControllersStateSlice(state),
71
+ return PropControllerDescriptors.getComponentPropControllerDescriptors(
72
+ getPropControllerDescriptorsStateSlice(state),
73
73
  componentType
74
74
  );
75
75
  }
76
- function getPropControllerHandlesStateSlice(state) {
77
- return state.propControllerHandles;
78
- }
79
- function getPropControllers(state, { documentKey, elementKey }) {
80
- return PropControllerHandles.getPropControllers(
81
- getPropControllerHandlesStateSlice(state),
82
- documentKey,
83
- elementKey
84
- );
85
- }
86
- function getPropControllersHandle(state, { documentKey, elementKey }) {
87
- return PropControllerHandles.getPropControllersHandle(
88
- getPropControllerHandlesStateSlice(state),
89
- documentKey,
90
- elementKey
91
- );
92
- }
93
- function getPropController(state, {
94
- documentKey,
95
- elementKey,
96
- propName
97
- }) {
98
- return PropControllerHandles.getPropController(
99
- getPropControllerHandlesStateSlice(state),
100
- documentKey,
101
- elementKey,
102
- propName
103
- );
104
- }
105
76
  const getDocumentKeysSortedByDepth = createSelector(
106
77
  [getDocumentsStateSlice, getElementTreesSlice],
107
78
  (documents, elementTrees) => {
@@ -164,10 +135,7 @@ export {
164
135
  getIsInBuilder,
165
136
  getIsReadOnly,
166
137
  getLocale,
167
- getPropController,
168
138
  getPropControllerDescriptors,
169
- getPropControllers,
170
- getPropControllersHandle,
171
139
  getReactComponent,
172
140
  getRootElement,
173
141
  isElementReference,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nfunction getBreakpointsStateSlice(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getBreakpoints(state: State): Breakpoints.Breakpoints {\n return getBreakpointsStateSlice(state).breakpoints\n}\n\nexport function getBaseBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).baseBreakpoint\n}\n\nexport function getClientBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).clientBreakpoint\n}\n\nexport function getLocale(state: State): string | null {\n return state.locale\n}\n"],"mappings":"AAEA,SAAS,sBAAsB;AAE/B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,YAAY,qBAAqB;AACjC,YAAY,2BAA2B;AACvC,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,qBAAqB;AACjC,YAAY,iBAAiB;AAa7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM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AuB;AACnD,SAAO,MAAM;AACf;AAEO,SAAS,mBAAmB,OAAqC;AACtE,SAAO,MAAM;AACf;AAEA,SAAS,yBAAyB,OAAiC;AACjE,SAAO,MAAM;AACf;AAEO,SAAS,eAAe,OAAuC;AACpE,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,kBAAkB,OAAwC;AACxE,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,oBAAoB,OAAwC;AAC1E,SAAO,yBAAyB,KAAK,EAAE;AACzC;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO,MAAM;AACf;","names":[]}
1
+ {"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllerDescriptors from './modules/prop-controller-descriptors'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllerDescriptors: PropControllerDescriptors.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllerDescriptors: PropControllerDescriptors.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllerDescriptorsStateSlice(state: State): PropControllerDescriptors.State {\n return state.propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllerDescriptors.State {\n return PropControllerDescriptors.getPropControllerDescriptors(\n getPropControllerDescriptorsStateSlice(state),\n )\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllerDescriptors.DescriptorsByProp | null {\n return PropControllerDescriptors.getComponentPropControllerDescriptors(\n getPropControllerDescriptorsStateSlice(state),\n componentType,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllerDescriptors.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nfunction getBreakpointsStateSlice(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getBreakpoints(state: State): Breakpoints.Breakpoints {\n return getBreakpointsStateSlice(state).breakpoints\n}\n\nexport function getBaseBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).baseBreakpoint\n}\n\nexport function getClientBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).clientBreakpoint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