@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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMO;AAEP,qBAA+D;AAC/D,sBAAoC;AACpC,IAAAA,kBAAmC;AACnC,uBAAyB;AAEzB,IAAAC,mBAKO;AAQA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAA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,IAAI,OAAO,SAAS,GAAG,OAAO,UAAU;AAExD,QAAI,YAAY,WAAW,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,qBAAqB,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_controls"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal/action-types'\nimport { BuilderActionTypes } from '../builder-api/action-types'\nimport { isServer } from '../../utils/is-server'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = {\n breakpoints: Breakpoints\n baseBreakpoint: BreakpointId\n clientBreakpoint: BreakpointId\n}\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport const getDeviceQueries = (breakpoints: Breakpoints) =>\n breakpoints.map(device => ({\n id: device.id,\n query: getBreakpointMediaQuery(device).replace('@media', ''),\n }))\n\nconst getBaseBreakpointId = (breakpoints: Breakpoints): BreakpointId =>\n getBaseBreakpoint(breakpoints).id\n\n// Intentional impurity in the reducer buys us several practical upsides here:\n//\n// - We can keep `SET_BREAKPOINTS` atomic by recalculating the client breakpoint\n// state when we update the set of available breakpoints; if we don't do that\n// here, we'll have to do it from the outside, and the state will temporarily\n// hold a stale client breakpoint value in between\n//\n// - We can have a valid, internally consistent *initial* state for the client\n// breakpoint; if we move the client breakpoint calculation out of the reducer,\n// we'll be forced to start with a stale initial state, which will introduce\n// implicit coupling and potential timing issues between the\n// `useCurrentBreakpoint` hook and the client breakpoint synchronization code\n// in `BreakpointWatch`\n//\n// - `UPDATE_CLIENT_BREAKPOINT` can compute the client breakpoint from browser\n// state using the current breakpoint set instead of having to validate and\n// handle external payload\n\nexport function getMatchingMediaBreakpointId(breakpoints: Breakpoints): BreakpointId {\n const baseBreakpoint = getBaseBreakpointId(breakpoints)\n if (isServer()) return baseBreakpoint\n\n // using `findLast` to preserve the legacy behavior; might not be necessary\n const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(\n ({ query }) => window.matchMedia(query).matches,\n )\n\n return matchingBreakpoint?.id ?? baseBreakpoint\n}\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n }\n\n case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {\n const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints)\n if (clientBreakpoint === state.clientBreakpoint) return state\n\n return { ...state, clientBreakpoint }\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMO;AAEP,qBAA+D;AAC/D,0BAAoC;AACpC,IAAAA,uBAAmC;AACnC,uBAAyB;AAEzB,IAAAC,mBAKO;AAQA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;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,WAAO,yCAAwB,MAAM,EAAE,QAAQ,UAAU,EAAE;AAC7D,EAAE;AAEJ,MAAM,sBAAsB,CAAC,oBAC3B,mCAAkB,WAAW,EAAE;AAoB1B,SAAS,6BAA6B,aAAwC;AACnF,QAAM,iBAAiB,oBAAoB,WAAW;AACtD,UAAI,2BAAS;AAAG,WA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;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_action_types","import_controls"]}
@@ -26,7 +26,7 @@ __export(components_meta_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(components_meta_exports);
28
28
  var import_actions = require("../actions");
29
- var import_read_only_actions = require("../actions/internal/read-only-actions");
29
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
30
30
  const ComponentIcon = {
31
31
  Accordion: "accordion",
32
32
  Audio: "audio",
@@ -75,9 +75,9 @@ function reducer(state = getInitialState(), action) {
75
75
  if (!(0, import_actions.isKnownAction)(action))
76
76
  return state;
77
77
  switch (action.type) {
78
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT:
78
+ case import_read_only_action_types.ReadOnlyActionTypes.REGISTER_COMPONENT:
79
79
  return new Map(state).set(action.payload.type, action.payload.meta);
80
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
80
+ case import_read_only_action_types.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
81
81
  const nextState = new Map(state);
82
82
  const deleted = nextState.delete(action.payload.type);
83
83
  return deleted ? nextState : state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,+BAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,6CAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,oCAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,kDAAoB,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":[]}
@@ -43,8 +43,8 @@ var import_immutable = require("immutable");
43
43
  var import_controls = require("@makeswift/controls");
44
44
  var Introspection = __toESM(require("../../prop-controllers/introspection"));
45
45
  var import_actions = require("../actions");
46
- var import_read_only_actions = require("../actions/internal/read-only-actions");
47
- var import_read_write_actions = require("../actions/internal/read-write-actions");
46
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
47
+ var import_read_write_action_types = require("../actions/internal/read-write-action-types");
48
48
  var import_read_only_documents = require("./read-only-documents");
49
49
  function getInitialState(documents, descriptors) {
50
50
  const state = /* @__PURE__ */ new Map();
@@ -74,19 +74,19 @@ function reducer(state = getInitialState(), action) {
74
74
  if (!(0, import_actions.isKnownAction)(action))
75
75
  return state;
76
76
  switch (action.type) {
77
- case import_read_only_actions.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
77
+ case import_read_only_action_types.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
78
78
  const { document, descriptors } = action.payload;
79
79
  return new Map(state).set(
80
80
  document.key,
81
81
  buildElementTree((0, import_read_only_documents.getRootElement)(document), descriptors)
82
82
  );
83
83
  }
84
- case import_read_only_actions.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
84
+ case import_read_only_action_types.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
85
85
  const nextState = new Map(state);
86
86
  const deleted = nextState.delete(action.payload.documentKey);
87
87
  return deleted ? nextState : state;
88
88
  }
89
- case import_read_write_actions.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
89
+ case import_read_write_action_types.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
90
90
  const { oldDocument, newDocument, descriptors, operation } = action.payload;
91
91
  const documentKey = oldDocument.key;
92
92
  console.assert(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn, removeIn, setIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction getPropChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): Element[] | null {\n if (isElementReference(element)) return null\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return null\n\n return Introspection.getElementChildren(propDescriptor, element.props[propName])\n}\n\nfunction isChildrenProp(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n const children = getPropChildren(element, propName, descriptors)\n return children != null\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n elementToDelete: Element,\n descriptors: DescriptorsByComponentType,\n) {\n for (const element of traverseElementTree(elementToDelete, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n}\n\nfunction deleteChildrenInProp(\n elementTree: ElementTree,\n parentElement: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n) {\n const childrenInProp = getPropChildren(parentElement, propName, descriptors)\n\n if (childrenInProp == null) {\n return\n }\n\n for (const child of childrenInProp) {\n deleteElement(elementTree, child, descriptors)\n }\n}\n\nfunction deleteElementOrProp(\n { elements, elementIds }: ElementTree,\n targetElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null) {\n deleteElement({ elements, elementIds }, targetElement, descriptors)\n return\n }\n\n if (isChildrenProp(targetElement, propName, descriptors)) {\n deleteChildrenInProp({ elements, elementIds }, targetElement, propName, descriptors)\n }\n\n // The provided targetElement might refer to an element from the before/after documents,\n // not the actual element object from the ElementTree\n const elementInTree = elements.get(targetElement.key)\n\n if (!elementInTree) {\n console.error(\n `Attempting to remove prop ${propName} from element ${targetElement.key} not found in tree`,\n )\n return\n }\n\n if (!isElementReference(elementInTree)) {\n const newProps = { ...elementInTree.props }\n delete newProps[propName]\n elements.set(targetElement.key, { ...elementInTree, props: newProps })\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [targetElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, targetElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || isChildrenProp(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyOpComponent(root: Element, component: Operation[number]): Element {\n let applied: Element = root\n\n if ('ld' in component || 'od' in component) {\n applied = removeIn(applied, component.p)\n }\n\n if ('li' in component) {\n applied = setIn(applied, component.p, component.li)\n }\n\n if ('oi' in component) {\n applied = setIn(applied, component.p, component.oi)\n }\n\n return applied\n}\n\nfunction selectTreeTransform(op: Operation[number]): typeof applyUpdate {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n\n if (hasDelete && hasInsert) return applyUpdate\n if (hasDelete) return applyDelete\n if (hasInsert) return applyInsert\n\n return elementTree => elementTree\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n // Updates the element tree \"cache\" based on the provided operation, which can\n // be composed of 1-n component ops. We apply each component op sequentially\n // to the 'old' root element to determine the changed elements and update the\n // cache accordingly at each intermediate step.\n const result = operation.reduce(\n (acc, op) => {\n const rootBefore = acc.rootBefore\n\n // If there's only one component op, we can skip the application of the op\n // and assume that the result will be the 'new' root element provided to\n // us by the builder.\n const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new\n\n const roots = { before: rootBefore, after: rootAfter }\n const applyChange = selectTreeTransform(op)\n\n return {\n elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),\n rootBefore: rootAfter,\n }\n },\n { elementTree, rootBefore: rootElements.old },\n )\n\n return result.elementTree\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAuC;AAEvC,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA+D;AAE/D,+BAAoC;AACpC,gCAAqC;AAErC,iCAA8C;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,qBAAiB,2CAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YA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M,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EACpD;AAEA,SAAO;AACT;AAEA,SAAS,oBAAoB,IAA2C;AACtE,QAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,QAAM,YAAY,QAAQ,MAAM,QAAQ;AAExC,MAAI,aAAa;AAAW,WAAO;AACnC,MAAI;AAAW,WAAO;AACtB,MAAI;AAAW,WAAO;AAEtB,SAAO,iBAAe;AACxB;AAEA,SAAS,aACP,aACA,aACA,cACA,WACa;AAKb,QAAM,SAAS,UAAU;AAAA,IACvB,CAAC,KAAK,OAAO;AACX,YAAM,aAAa,IAAI;AAKvB,YAAM,YAAY,UAAU,SAAS,IAAI,iBAAiB,YAAY,EAAE,IAAI,aAAa;AAEzF,YAAM,QAAQ,EAAE,QAAQ,YAAY,OAAO,UAAU;AACrD,YAAM,cAAc,oBAAoB,EAAE;AAE1C,aAAO;AAAA,QACL,aAAa,YAAY,IAAI,aAAa,aAAa,OAAO,GAAG,CAAC;AAAA,QAClE,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,EAAE,aAAa,YAAY,aAAa,IAAI;AAAA,EAC9C;AAEA,SAAO,OAAO;AAChB;","names":["i"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn, removeIn, setIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-action-types'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controller-descriptors'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction getPropChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): Element[] | null {\n if (isElementReference(element)) return null\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return null\n\n return Introspection.getElementChildren(propDescriptor, element.props[propName])\n}\n\nfunction isChildrenProp(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n const children = getPropChildren(element, propName, descriptors)\n return children != null\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n elementToDelete: Element,\n descriptors: DescriptorsByComponentType,\n) {\n for (const element of traverseElementTree(elementToDelete, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n}\n\nfunction deleteChildrenInProp(\n elementTree: ElementTree,\n parentElement: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n) {\n const childrenInProp = getPropChildren(parentElement, propName, descriptors)\n\n if (childrenInProp == null) {\n return\n }\n\n for (const child of childrenInProp) {\n deleteElement(elementTree, child, descriptors)\n }\n}\n\nfunction deleteElementOrProp(\n { elements, elementIds }: ElementTree,\n targetElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null) {\n deleteElement({ elements, elementIds }, targetElement, descriptors)\n return\n }\n\n if (isChildrenProp(targetElement, propName, descriptors)) {\n deleteChildrenInProp({ elements, elementIds }, targetElement, propName, descriptors)\n }\n\n // The provided targetElement might refer to an element from the before/after documents,\n // not the actual element object from the ElementTree\n const elementInTree = elements.get(targetElement.key)\n\n if (!elementInTree) {\n console.error(\n `Attempting to remove prop ${propName} from element ${targetElement.key} not found in tree`,\n )\n return\n }\n\n if (!isElementReference(elementInTree)) {\n const newProps = { ...elementInTree.props }\n delete newProps[propName]\n elements.set(targetElement.key, { ...elementInTree, props: newProps })\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [targetElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, targetElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || isChildrenProp(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [targetElement, propName] = getElementAndPropName(rootElements.before, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyOpComponent(root: Element, component: Operation[number]): Element {\n let applied: Element = root\n\n if ('ld' in component || 'od' in component) {\n applied = removeIn(applied, component.p)\n }\n\n if ('li' in component) {\n applied = setIn(applied, component.p, component.li)\n }\n\n if ('oi' in component) {\n applied = setIn(applied, component.p, component.oi)\n }\n\n return applied\n}\n\nfunction selectTreeTransform(op: Operation[number]): typeof applyUpdate {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n\n if (hasDelete && hasInsert) return applyUpdate\n if (hasDelete) return applyDelete\n if (hasInsert) return applyInsert\n\n return elementTree => elementTree\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n // Updates the element tree \"cache\" based on the provided operation, which can\n // be composed of 1-n component ops. We apply each component op sequentially\n // to the 'old' root element to determine the changed elements and update the\n // cache accordingly at each intermediate step.\n const result = operation.reduce(\n (acc, op) => {\n const rootBefore = acc.rootBefore\n\n // If there's only one component op, we can skip the application of the op\n // and assume that the result will be the 'new' root element provided to\n // us by the builder.\n const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new\n\n const roots = { before: rootBefore, after: rootAfter }\n const applyChange = selectTreeTransform(op)\n\n return {\n elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),\n rootBefore: rootAfter,\n }\n },\n { elementTree, rootBefore: rootElements.old },\n )\n\n return result.elementTree\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAuC;AAEvC,sBAAmE;AAEnE,oBAA+B;AAE/B,qBAA+D;AAE/D,oCAAoC;AACpC,qCAAqC;AAErC,iCAA8C;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,qBAAiB,2CAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAc,aAAyC;AAC7E,SAAO,MAAM,IAAI,WAAW,KAAK;AACnC;AAEO,SAAS,YAAY,OAAc,aAA2C;AACnF,SAAO,eAAe,OAAO,WAAW,GAAG,YAAY,oBAAI,IAAI;AACjE;AAEO,SAAS,cAAc,OAAc,aAA0C;AACpF,SAAO,eAAe,OA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BAAoB,IAA2C;AACtE,QAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,QAAM,YAAY,QAAQ,MAAM,QAAQ;AAExC,MAAI,aAAa;AAAW,WAAO;AACnC,MAAI;AAAW,WAAO;AACtB,MAAI;AAAW,WAAO;AAEtB,SAAO,iBAAe;AACxB;AAEA,SAAS,aACP,aACA,aACA,cACA,WACa;AAKb,QAAM,SAAS,UAAU;AAAA,IACvB,CAAC,KAAK,OAAO;AACX,YAAM,aAAa,IAAI;AAKvB,YAAM,YAAY,UAAU,SAAS,IAAI,iBAAiB,YAAY,EAAE,IAAI,aAAa;AAEzF,YAAM,QAAQ,EAAE,QAAQ,YAAY,OAAO,UAAU;AACrD,YAAM,cAAc,oBAAoB,EAAE;AAE1C,aAAO;AAAA,QACL,aAAa,YAAY,IAAI,aAAa,aAAa,OAAO,GAAG,CAAC;AAAA,QAClE,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,EAAE,aAAa,YAAY,aAAa,IAAI;AAAA,EAC9C;AAEA,SAAO,OAAO;AAChB;","names":["i"]}
@@ -24,7 +24,7 @@ __export(is_in_builder_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(is_in_builder_exports);
26
26
  var import_actions = require("../actions");
27
- var import_read_only_actions = require("../actions/internal/read-only-actions");
27
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
28
28
  function getInitialState() {
29
29
  return false;
30
30
  }
@@ -35,7 +35,7 @@ function reducer(state = getInitialState(), action) {
35
35
  if (!(0, import_actions.isKnownAction)(action))
36
36
  return state;
37
37
  switch (action.type) {
38
- case import_read_only_actions.ReadOnlyActionTypes.SET_IS_IN_BUILDER:
38
+ case import_read_only_action_types.ReadOnlyActionTypes.SET_IS_IN_BUILDER:
39
39
  return action.payload;
40
40
  default:
41
41
  return state;
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,+BAAoC;AAI7B,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;AACvB,aAAO,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,oCAAoC;AAI7B,SAAS,kBAAyB;AACvC,SAAO;AACT;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -24,7 +24,7 @@ __export(is_read_only_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(is_read_only_exports);
26
26
  var import_actions = require("../actions");
27
- var import_read_only_actions = require("../actions/internal/read-only-actions");
27
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
28
28
  function getInitialState(isReadOnly = true) {
29
29
  return isReadOnly;
30
30
  }
@@ -35,7 +35,7 @@ function reducer(state = getInitialState(), action) {
35
35
  if (!(0, import_actions.isKnownAction)(action))
36
36
  return state;
37
37
  switch (action.type) {
38
- case import_read_only_actions.ReadOnlyActionTypes.SET_IS_READ_ONLY:
38
+ case import_read_only_action_types.ReadOnlyActionTypes.SET_IS_READ_ONLY:
39
39
  return action.payload;
40
40
  default:
41
41
  return state;
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,+BAAoC;AAI7B,SAAS,gBAAgB,aAAa,MAAa;AACxD,SAAO;AACT;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,oCAAoC;AAI7B,SAAS,gBAAgB,aAAa,MAAa;AACxD,SAAO;AACT;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,OAAO;AAAA,IAEhB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -24,7 +24,7 @@ __export(locale_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(locale_exports);
26
26
  var import_actions = require("../actions");
27
- var import_read_only_actions = require("../actions/internal/read-only-actions");
27
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
28
28
  function getInitialState(locale = null) {
29
29
  return locale;
30
30
  }
@@ -35,7 +35,7 @@ function reducer(state = getInitialState(), action) {
35
35
  if (!(0, import_actions.isKnownAction)(action))
36
36
  return state;
37
37
  switch (action.type) {
38
- case import_read_only_actions.ReadOnlyActionTypes.SET_LOCALE:
38
+ case import_read_only_action_types.ReadOnlyActionTypes.SET_LOCALE:
39
39
  return action.payload.locale;
40
40
  default:
41
41
  return state;
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,+BAAoC;AAI7B,SAAS,gBAAgB,SAAwB,MAAa;AACnE,SAAO;AACT;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,oCAAoC;AAI7B,SAAS,gBAAgB,SAAwB,MAAa;AACnE,SAAO;AACT;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,OAAO,QAAQ;AAAA,IAExB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -26,7 +26,7 @@ __export(localized_resources_map_exports, {
26
26
  module.exports = __toCommonJS(localized_resources_map_exports);
27
27
  var import_controls = require("@makeswift/controls");
28
28
  var import_actions = require("../actions");
29
- var import_read_write_actions = require("../actions/internal/read-write-actions");
29
+ var import_read_write_action_types = require("../actions/internal/read-write-action-types");
30
30
  var import_host_api = require("../host-api");
31
31
  function getInitialState(serializedState = {}) {
32
32
  return new Map(
@@ -60,7 +60,7 @@ function reducer(state = getInitialState(), action) {
60
60
  (state.get(locale) ?? /* @__PURE__ */ new Map()).set(resourceId, localizedResourceId)
61
61
  );
62
62
  }
63
- case import_read_write_actions.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
63
+ case import_read_write_action_types.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
64
64
  const { localizedResourcesMap } = action.payload;
65
65
  return Object.entries(localizedResourcesMap).reduce((state2, [locale, resources]) => {
66
66
  const existing = state2.get(locale) ?? /* @__PURE__ */ new Map();
@@ -70,7 +70,7 @@ function reducer(state = getInitialState(), action) {
70
70
  return updated === existing ? state2 : new Map(state2).set(locale, updated);
71
71
  }, state);
72
72
  }
73
- case import_read_write_actions.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {
73
+ case import_read_write_action_types.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {
74
74
  return getInitialState();
75
75
  }
76
76
  default:
@@ -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.CLE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M;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,+CAAqB,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,qBAA+D;AAC/D,qCAAqC;AACrC,sBAAgC;AAUzB,SAAS,gBAAgB,kBAAmC,CAAC,GAAU;AAC5E,SAAO,IAAI;AAAA,IACT,OAAO,YAAQ,2BAAU,iBAAiB,eAAa,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,CAAC,CAAC;AAAA,EAC5F;AACF;AAEO,SAAS,mBAAmB,OAA+B;AAChE,aAAO;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,gCAAgB,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,oDAAqB,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,oDAAqB,wBAAwB;AAChD,aAAO,gBAAgB;AAAA,IACzB;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["state"]}
@@ -16,16 +16,16 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var prop_controllers_exports = {};
20
- __export(prop_controllers_exports, {
19
+ var prop_controller_descriptors_exports = {};
20
+ __export(prop_controller_descriptors_exports, {
21
21
  getComponentPropControllerDescriptors: () => getComponentPropControllerDescriptors,
22
22
  getInitialState: () => getInitialState,
23
23
  getPropControllerDescriptors: () => getPropControllerDescriptors,
24
24
  reducer: () => reducer
25
25
  });
26
- module.exports = __toCommonJS(prop_controllers_exports);
26
+ module.exports = __toCommonJS(prop_controller_descriptors_exports);
27
27
  var import_actions = require("../actions");
28
- var import_read_only_actions = require("../actions/internal/read-only-actions");
28
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
29
29
  function getInitialState({
30
30
  propControllerDescriptors = /* @__PURE__ */ new Map()
31
31
  } = {}) {
@@ -41,9 +41,9 @@ function reducer(state = getInitialState(), action) {
41
41
  if (!(0, import_actions.isKnownAction)(action))
42
42
  return state;
43
43
  switch (action.type) {
44
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT:
44
+ case import_read_only_action_types.ReadOnlyActionTypes.REGISTER_COMPONENT:
45
45
  return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors);
46
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
46
+ case import_read_only_action_types.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
47
47
  const nextState = new Map(state);
48
48
  const deleted = nextState.delete(action.payload.type);
49
49
  return deleted ? nextState : state;
@@ -59,4 +59,4 @@ function reducer(state = getInitialState(), action) {
59
59
  getPropControllerDescriptors,
60
60
  reducer
61
61
  });
62
- //# sourceMappingURL=prop-controllers.js.map
62
+ //# 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,oCAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,yBAAyB;AAAA,IAEzF,KAAK,kDAAoB,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":[]}
@@ -24,7 +24,7 @@ __export(react_components_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(react_components_exports);
26
26
  var import_actions = require("../actions");
27
- var import_read_only_actions = require("../actions/internal/read-only-actions");
27
+ var import_read_only_action_types = require("../actions/internal/read-only-action-types");
28
28
  function getInitialState({
29
29
  reactComponents = /* @__PURE__ */ new Map()
30
30
  } = {}) {
@@ -40,9 +40,9 @@ function reducer(state = getInitialState(), action) {
40
40
  if (!(0, import_actions.isKnownAction)(action))
41
41
  return state;
42
42
  switch (action.type) {
43
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_REACT_COMPONENT:
43
+ case import_read_only_action_types.ReadOnlyActionTypes.REGISTER_REACT_COMPONENT:
44
44
  return new Map(state).set(action.payload.type, action.payload.component);
45
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT: {
45
+ case import_read_only_action_types.ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT: {
46
46
  const nextState = new Map(state);
47
47
  const deleted = nextState.delete(action.payload.type);
48
48
  return deleted ? nextState : state;
@@ -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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA+D;AAC/D,+BAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS;AAAA,IAEzE,KAAK,6CAAoB,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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA+D;AAC/D,oCAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kDAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS;AAAA,IAEzE,KAAK,kDAAoB,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":[]}
@@ -33,8 +33,8 @@ __export(box_models_exports, {
33
33
  module.exports = __toCommonJS(box_models_exports);
34
34
  var import_css_box_model = require("css-box-model");
35
35
  var import_actions = require("../../actions");
36
- var import_read_write_actions = require("../../actions/internal/read-write-actions");
37
- var import_actions2 = require("../../builder-api/actions");
36
+ var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
37
+ var import_action_types = require("../../builder-api/action-types");
38
38
  function parse(rawString) {
39
39
  const value = Number(rawString.replace(/px$/, ""));
40
40
  return Number.isFinite(value) ? value : 0;
@@ -87,7 +87,7 @@ function reducer(state = getInitialState(), action) {
87
87
  if (!(0, import_actions.isKnownAction)(action))
88
88
  return state;
89
89
  switch (action.type) {
90
- case import_read_write_actions.ReadWriteActionTypes.REGISTER_MEASURABLE: {
90
+ case import_read_write_action_types.ReadWriteActionTypes.REGISTER_MEASURABLE: {
91
91
  const { documentKey, elementKey, measurable } = action.payload;
92
92
  return {
93
93
  ...state,
@@ -97,13 +97,13 @@ function reducer(state = getInitialState(), action) {
97
97
  )
98
98
  };
99
99
  }
100
- case import_read_write_actions.ReadWriteActionTypes.UNREGISTER_MEASURABLE: {
100
+ case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_MEASURABLE: {
101
101
  const { documentKey, elementKey } = action.payload;
102
102
  const nextMeasurables = new Map(state.measurables.get(documentKey) ?? []);
103
103
  const deleted = nextMeasurables.delete(elementKey);
104
104
  return deleted ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) } : state;
105
105
  }
106
- case import_actions2.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {
106
+ case import_action_types.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {
107
107
  const { changedElementBoxModels } = action.payload;
108
108
  if (changedElementBoxModels.size === 0)
109
109
  return state;
@@ -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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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;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":["import_actions","createBoxWithoutScroll","getBoxWithoutScroll"]}
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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAKO;AAEP,qBAA+D;AAC/D,qCAAqC;AACrC,0BAAmC;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,UAAM,qCAAW,qBAAAA,WAAuB,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,eAAW,qCAAW,qBAAAC,QAAoB,OAAO,CAAC;AAExD,SAAO,EAAE,GAAG,UAAU,QAAQ;AAChC;AAQO,SAAS,aAAa,OAAqC;AAChE,MAAI,iBAAiB;AAAS,WAAO;AAErC,MACE,OAAO,UAAU,YACjB,UAAU,QACV,iBAAiB,SACjB,OAAQ,MAAmC,gBAAgB,YAC3D;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,QAAQ,YAAgD;AACtE,MAAI,sBAAsB;AAAS,WAAO,OAAO,UAAU;A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,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["createBoxWithoutScroll","getBoxWithoutScroll"]}
@@ -23,7 +23,7 @@ __export(element_imperative_handles_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(element_imperative_handles_exports);
25
25
  var import_actions = require("../../actions");
26
- var import_read_only_actions = require("../../actions/internal/read-only-actions");
26
+ var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
27
27
  function getElementImperativeHandles(state) {
28
28
  return state;
29
29
  }
@@ -34,7 +34,7 @@ function reducer(state = getInitialState(), action) {
34
34
  if (!(0, import_actions.isKnownAction)(action))
35
35
  return state;
36
36
  switch (action.type) {
37
- case import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE:
37
+ case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE:
38
38
  return new Map(state).set(
39
39
  action.payload.documentKey,
40
40
  new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
@@ -42,7 +42,7 @@ function reducer(state = getInitialState(), action) {
42
42
  action.payload.componentHandle
43
43
  )
44
44
  );
45
- case import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {
45
+ case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
46
46
  const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
47
47
  const deleted = byElementKey.delete(action.payload.elementKey);
48
48
  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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA+D;AAC/D,+BAAoC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,6CAAoB;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,6CAAoB,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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA+D;AAC/D,qCAAqC;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,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oDAAqB;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,oDAAqB,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":[]}
@@ -16,8 +16,8 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var prop_controller_handles_exports = {};
20
- __export(prop_controller_handles_exports, {
19
+ var prop_controllers_exports = {};
20
+ __export(prop_controllers_exports, {
21
21
  getInitialState: () => getInitialState,
22
22
  getPropController: () => getPropController,
23
23
  getPropControllers: () => getPropControllers,
@@ -25,8 +25,8 @@ __export(prop_controller_handles_exports, {
25
25
  isPropControllersHandle: () => isPropControllersHandle,
26
26
  reducer: () => reducer
27
27
  });
28
- module.exports = __toCommonJS(prop_controller_handles_exports);
29
- var import_actions = require("../actions");
28
+ module.exports = __toCommonJS(prop_controllers_exports);
29
+ var import_actions = require("../../actions");
30
30
  function isPropControllersHandle(value) {
31
31
  if (typeof value === "object" && value !== null && "setPropControllers" in value && typeof value.setPropControllers === "function") {
32
32
  return true;
@@ -94,4 +94,4 @@ function reducer(state = getInitialState(), action) {
94
94
  isPropControllersHandle,
95
95
  reducer
96
96
  });
97
- //# sourceMappingURL=prop-controller-handles.js.map
97
+ //# sourceMappingURL=prop-controllers.js.map