@makeswift/runtime 0.28.8-canary.9 → 0.28.9-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (514) hide show
  1. package/dist/cjs/api/api-resources-client.js +3 -0
  2. package/dist/cjs/api/api-resources-client.js.map +1 -1
  3. package/dist/cjs/api/graphql-api-client.js +1 -1
  4. package/dist/cjs/api/ky.js +862 -0
  5. package/dist/cjs/api/ky.js.map +1 -0
  6. package/dist/cjs/api/rest-api-client.js +85 -43
  7. package/dist/cjs/api/rest-api-client.js.map +1 -1
  8. package/dist/cjs/api/types.js.map +1 -1
  9. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  10. package/dist/cjs/builder/host-to-builder-actions.js +5 -5
  11. package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
  12. package/dist/cjs/client/index.js +40 -44
  13. package/dist/cjs/client/index.js.map +1 -1
  14. package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
  15. package/dist/cjs/controls/rich-text/control.js +16 -3
  16. package/dist/cjs/controls/rich-text/control.js.map +1 -1
  17. package/dist/cjs/controls/rich-text/rich-text.js +2 -2
  18. package/dist/cjs/controls/rich-text/rich-text.js.map +1 -1
  19. package/dist/cjs/controls/rich-text-v2/control.js +15 -2
  20. package/dist/cjs/controls/rich-text-v2/control.js.map +1 -1
  21. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +2 -2
  22. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  23. package/dist/cjs/controls/slot.js.map +1 -1
  24. package/dist/cjs/next/testing/breakpoints.js +3 -15
  25. package/dist/cjs/next/testing/breakpoints.js.map +1 -1
  26. package/dist/cjs/next/testing/element-data.js +3 -82
  27. package/dist/cjs/next/testing/element-data.js.map +1 -1
  28. package/dist/cjs/next/testing/react-runtime.js.map +1 -1
  29. package/dist/cjs/prop-controllers/instances.js +20 -4
  30. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  31. package/dist/cjs/runtimes/react/components/Element.js +53 -24
  32. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  33. package/dist/cjs/runtimes/react/components/ElementRegistration.js +32 -11
  34. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  35. package/dist/cjs/runtimes/react/components/control-instances-context.js +38 -0
  36. package/dist/cjs/runtimes/react/components/control-instances-context.js.map +1 -0
  37. package/dist/cjs/runtimes/react/components/framework-context.js +1 -0
  38. package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
  39. package/dist/cjs/runtimes/react/components/resolve-props.js +5 -1
  40. package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
  41. package/dist/cjs/runtimes/react/controls/node-value/editable-node-value.js +42 -0
  42. package/dist/cjs/runtimes/react/controls/node-value/editable-node-value.js.map +1 -0
  43. package/dist/cjs/runtimes/react/controls/node-value/index.js +51 -0
  44. package/dist/cjs/runtimes/react/controls/node-value/index.js.map +1 -0
  45. package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  46. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +2 -2
  47. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  48. package/dist/cjs/runtimes/react/controls/slot/index.js +29 -0
  49. package/dist/cjs/runtimes/react/controls/slot/index.js.map +1 -0
  50. package/dist/cjs/runtimes/react/controls/slot/render-slot.js +37 -0
  51. package/dist/cjs/runtimes/react/controls/slot/render-slot.js.map +1 -0
  52. package/dist/cjs/runtimes/react/controls/{slot.js → slot/slot-value.js} +31 -26
  53. package/dist/cjs/runtimes/react/controls/slot/slot-value.js.map +1 -0
  54. package/dist/cjs/runtimes/react/element-imperative-handle.js +2 -2
  55. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  56. package/dist/cjs/runtimes/react/hooks/use-control-instance.js +88 -0
  57. package/dist/cjs/runtimes/react/hooks/use-control-instance.js.map +1 -0
  58. package/dist/cjs/runtimes/react/hooks/use-control-instances.js +2 -12
  59. package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -1
  60. package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js +3 -3
  61. package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
  62. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +10 -9
  63. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  64. package/dist/cjs/runtimes/react/hooks/use-resolved-value-override.js +58 -0
  65. package/dist/cjs/runtimes/react/hooks/use-resolved-value-override.js.map +1 -0
  66. package/dist/cjs/runtimes/react/hooks/use-selector.js +8 -2
  67. package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
  68. package/dist/cjs/runtimes/react/testing/index.js +25 -0
  69. package/dist/cjs/runtimes/react/testing/index.js.map +1 -0
  70. package/dist/cjs/runtimes/react/testing/react-provider.js +38 -0
  71. package/dist/cjs/runtimes/react/testing/react-provider.js.map +1 -0
  72. package/dist/cjs/state/actions/index.js +4 -4
  73. package/dist/cjs/state/actions/index.js.map +1 -1
  74. package/dist/cjs/state/actions/internal/action-types.js +34 -0
  75. package/dist/cjs/state/actions/internal/action-types.js.map +1 -0
  76. package/dist/cjs/state/actions/internal/index.js +0 -17
  77. package/dist/cjs/state/actions/internal/index.js.map +1 -1
  78. package/dist/cjs/state/actions/internal/read-only-action-types.js +44 -0
  79. package/dist/cjs/state/actions/internal/read-only-action-types.js.map +1 -0
  80. package/dist/cjs/state/actions/internal/read-only-actions.js +13 -92
  81. package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
  82. package/dist/cjs/state/actions/internal/read-write-action-types.js +44 -0
  83. package/dist/cjs/state/actions/internal/read-write-action-types.js.map +1 -0
  84. package/dist/cjs/state/actions/internal/read-write-actions.js +135 -14
  85. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  86. package/dist/cjs/state/api-client/state.js +8 -0
  87. package/dist/cjs/state/api-client/state.js.map +1 -1
  88. package/dist/cjs/state/builder-api/action-types.js +49 -0
  89. package/dist/cjs/state/builder-api/action-types.js.map +1 -0
  90. package/dist/cjs/state/builder-api/actions.js +14 -36
  91. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  92. package/dist/cjs/state/builder-api/proxy.js +2 -1
  93. package/dist/cjs/state/builder-api/proxy.js.map +1 -1
  94. package/dist/cjs/state/host-api/action-types.js +43 -0
  95. package/dist/cjs/state/host-api/action-types.js.map +1 -0
  96. package/dist/cjs/state/{host-api.js → host-api/actions.js} +17 -33
  97. package/dist/cjs/state/host-api/actions.js.map +1 -0
  98. package/dist/cjs/state/host-api/index.js +25 -0
  99. package/dist/cjs/state/host-api/index.js.map +1 -0
  100. package/dist/cjs/state/middleware/read-write/builder-api/index.js +2 -58
  101. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
  102. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
  103. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
  104. package/dist/cjs/state/middleware/read-write/builder-api/middleware.js +89 -0
  105. package/dist/cjs/state/middleware/read-write/builder-api/middleware.js.map +1 -0
  106. package/dist/cjs/state/middleware/read-write/builder-api/mount-change-action-buffer.js +72 -0
  107. package/dist/cjs/state/middleware/read-write/builder-api/mount-change-action-buffer.js.map +1 -0
  108. package/dist/cjs/state/middleware/read-write/measure-box-models.js +3 -3
  109. package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +1 -1
  110. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +10 -47
  111. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  112. package/dist/cjs/state/modules/api-resources.js +5 -5
  113. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  114. package/dist/cjs/state/modules/breakpoints.js +4 -4
  115. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  116. package/dist/cjs/state/modules/components-meta.js +3 -3
  117. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  118. package/dist/cjs/state/modules/element-trees.js +5 -5
  119. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  120. package/dist/cjs/state/modules/is-in-builder.js +2 -2
  121. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  122. package/dist/cjs/state/modules/is-read-only.js +2 -2
  123. package/dist/cjs/state/modules/is-read-only.js.map +1 -1
  124. package/dist/cjs/state/modules/locale.js +2 -2
  125. package/dist/cjs/state/modules/locale.js.map +1 -1
  126. package/dist/cjs/state/modules/localized-resources-map.js +3 -3
  127. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  128. package/dist/cjs/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +7 -7
  129. package/dist/cjs/state/modules/prop-controller-descriptors.js.map +1 -0
  130. package/dist/cjs/state/modules/react-components.js +3 -3
  131. package/dist/cjs/state/modules/react-components.js.map +1 -1
  132. package/dist/cjs/state/modules/read-write/box-models.js +5 -5
  133. package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
  134. package/dist/cjs/state/modules/read-write/element-imperative-handles.js +3 -3
  135. package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +1 -1
  136. package/dist/cjs/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +5 -5
  137. package/dist/cjs/state/modules/read-write/prop-controllers.js.map +1 -0
  138. package/dist/cjs/state/modules/read-write/resolved-value-overrides.js +70 -0
  139. package/dist/cjs/state/modules/read-write/resolved-value-overrides.js.map +1 -0
  140. package/dist/cjs/state/read-only-state.js +9 -44
  141. package/dist/cjs/state/read-only-state.js.map +1 -1
  142. package/dist/cjs/state/read-write-state.js +61 -1
  143. package/dist/cjs/state/read-write-state.js.map +1 -1
  144. package/dist/cjs/state/shared-api/action-types.js +33 -0
  145. package/dist/cjs/state/shared-api/action-types.js.map +1 -0
  146. package/dist/cjs/state/{shared-api.js → shared-api/actions.js} +8 -14
  147. package/dist/cjs/state/shared-api/actions.js.map +1 -0
  148. package/dist/cjs/state/shared-api/index.js +25 -0
  149. package/dist/cjs/state/shared-api/index.js.map +1 -0
  150. package/dist/cjs/state/store.js +5 -3
  151. package/dist/cjs/state/store.js.map +1 -1
  152. package/dist/cjs/state/translations/get.js.map +1 -1
  153. package/dist/cjs/state/translations/merge.js.map +1 -1
  154. package/dist/cjs/state/unified-state.js +12 -0
  155. package/dist/cjs/state/unified-state.js.map +1 -1
  156. package/dist/cjs/testing/breakpoints.js +35 -0
  157. package/dist/cjs/testing/breakpoints.js.map +1 -0
  158. package/dist/cjs/testing/element-data.js +102 -0
  159. package/dist/cjs/testing/element-data.js.map +1 -0
  160. package/dist/cjs/testing/read-write-state.js +32 -0
  161. package/dist/cjs/testing/read-write-state.js.map +1 -0
  162. package/dist/cjs/translations/index.js.map +1 -1
  163. package/dist/esm/api/api-resources-client.js +3 -0
  164. package/dist/esm/api/api-resources-client.js.map +1 -1
  165. package/dist/esm/api/graphql-api-client.js +1 -1
  166. package/dist/esm/api/ky.js +7 -0
  167. package/dist/esm/api/ky.js.map +1 -0
  168. package/dist/esm/api/rest-api-client.js +84 -43
  169. package/dist/esm/api/rest-api-client.js.map +1 -1
  170. package/dist/esm/api/types.js.map +1 -1
  171. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  172. package/dist/esm/builder/host-to-builder-actions.js +2 -4
  173. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  174. package/dist/esm/client/index.js +45 -45
  175. package/dist/esm/client/index.js.map +1 -1
  176. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  177. package/dist/esm/controls/rich-text/control.js +16 -3
  178. package/dist/esm/controls/rich-text/control.js.map +1 -1
  179. package/dist/esm/controls/rich-text/rich-text.js +2 -2
  180. package/dist/esm/controls/rich-text/rich-text.js.map +1 -1
  181. package/dist/esm/controls/rich-text-v2/control.js +15 -2
  182. package/dist/esm/controls/rich-text-v2/control.js.map +1 -1
  183. package/dist/esm/controls/rich-text-v2/rich-text-v2.js +2 -2
  184. package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  185. package/dist/esm/controls/slot.js.map +1 -1
  186. package/dist/esm/next/testing/breakpoints.js +1 -8
  187. package/dist/esm/next/testing/breakpoints.js.map +1 -1
  188. package/dist/esm/next/testing/element-data.js +1 -75
  189. package/dist/esm/next/testing/element-data.js.map +1 -1
  190. package/dist/esm/next/testing/react-runtime.js.map +1 -1
  191. package/dist/esm/prop-controllers/instances.js +20 -4
  192. package/dist/esm/prop-controllers/instances.js.map +1 -1
  193. package/dist/esm/runtimes/react/components/Element.js +51 -25
  194. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  195. package/dist/esm/runtimes/react/components/ElementRegistration.js +37 -12
  196. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  197. package/dist/esm/runtimes/react/components/control-instances-context.js +13 -0
  198. package/dist/esm/runtimes/react/components/control-instances-context.js.map +1 -0
  199. package/dist/esm/runtimes/react/components/framework-context.js +1 -0
  200. package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
  201. package/dist/esm/runtimes/react/components/resolve-props.js +5 -1
  202. package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
  203. package/dist/esm/runtimes/react/controls/node-value/editable-node-value.js +21 -0
  204. package/dist/esm/runtimes/react/controls/node-value/editable-node-value.js.map +1 -0
  205. package/dist/esm/runtimes/react/controls/node-value/index.js +17 -0
  206. package/dist/esm/runtimes/react/controls/node-value/index.js.map +1 -0
  207. package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
  208. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +1 -1
  209. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  210. package/dist/esm/runtimes/react/controls/slot/index.js +5 -0
  211. package/dist/esm/runtimes/react/controls/slot/index.js.map +1 -0
  212. package/dist/esm/runtimes/react/controls/slot/render-slot.js +13 -0
  213. package/dist/esm/runtimes/react/controls/slot/render-slot.js.map +1 -0
  214. package/dist/esm/runtimes/react/controls/{slot.js → slot/slot-value.js} +34 -23
  215. package/dist/esm/runtimes/react/controls/slot/slot-value.js.map +1 -0
  216. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  217. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  218. package/dist/esm/runtimes/react/hooks/use-control-instance.js +62 -0
  219. package/dist/esm/runtimes/react/hooks/use-control-instance.js.map +1 -0
  220. package/dist/esm/runtimes/react/hooks/use-control-instances.js +1 -11
  221. package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -1
  222. package/dist/esm/runtimes/react/hooks/use-disable-register-element.js +2 -2
  223. package/dist/esm/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
  224. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -9
  225. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  226. package/dist/esm/runtimes/react/hooks/use-resolved-value-override.js +35 -0
  227. package/dist/esm/runtimes/react/hooks/use-resolved-value-override.js.map +1 -0
  228. package/dist/esm/runtimes/react/hooks/use-selector.js +8 -2
  229. package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
  230. package/dist/esm/runtimes/react/testing/index.js +3 -0
  231. package/dist/esm/runtimes/react/testing/index.js.map +1 -0
  232. package/dist/esm/runtimes/react/testing/react-provider.js +14 -0
  233. package/dist/esm/runtimes/react/testing/react-provider.js.map +1 -0
  234. package/dist/esm/state/actions/index.js +2 -2
  235. package/dist/esm/state/actions/index.js.map +1 -1
  236. package/dist/esm/state/actions/internal/action-types.js +10 -0
  237. package/dist/esm/state/actions/internal/action-types.js.map +1 -0
  238. package/dist/esm/state/actions/internal/index.js +0 -9
  239. package/dist/esm/state/actions/internal/index.js.map +1 -1
  240. package/dist/esm/state/actions/internal/read-only-action-types.js +20 -0
  241. package/dist/esm/state/actions/internal/read-only-action-types.js.map +1 -0
  242. package/dist/esm/state/actions/internal/read-only-actions.js +1 -73
  243. package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
  244. package/dist/esm/state/actions/internal/read-write-action-types.js +20 -0
  245. package/dist/esm/state/actions/internal/read-write-action-types.js.map +1 -0
  246. package/dist/esm/state/actions/internal/read-write-actions.js +108 -8
  247. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  248. package/dist/esm/state/api-client/state.js +7 -0
  249. package/dist/esm/state/api-client/state.js.map +1 -1
  250. package/dist/esm/state/builder-api/action-types.js +25 -0
  251. package/dist/esm/state/builder-api/action-types.js.map +1 -0
  252. package/dist/esm/state/builder-api/actions.js +1 -24
  253. package/dist/esm/state/builder-api/actions.js.map +1 -1
  254. package/dist/esm/state/builder-api/proxy.js +2 -1
  255. package/dist/esm/state/builder-api/proxy.js.map +1 -1
  256. package/dist/esm/state/host-api/action-types.js +19 -0
  257. package/dist/esm/state/host-api/action-types.js.map +1 -0
  258. package/dist/esm/state/{host-api.js → host-api/actions.js} +2 -17
  259. package/dist/esm/state/host-api/actions.js.map +1 -0
  260. package/dist/esm/state/host-api/index.js +3 -0
  261. package/dist/esm/state/host-api/index.js.map +1 -0
  262. package/dist/esm/state/middleware/read-write/builder-api/index.js +1 -57
  263. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
  264. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
  265. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
  266. package/dist/esm/state/middleware/read-write/builder-api/middleware.js +65 -0
  267. package/dist/esm/state/middleware/read-write/builder-api/middleware.js.map +1 -0
  268. package/dist/esm/state/middleware/read-write/builder-api/mount-change-action-buffer.js +48 -0
  269. package/dist/esm/state/middleware/read-write/builder-api/mount-change-action-buffer.js.map +1 -0
  270. package/dist/esm/state/middleware/read-write/measure-box-models.js +3 -3
  271. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +1 -1
  272. package/dist/esm/state/middleware/read-write/prop-controller-handles.js +13 -47
  273. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  274. package/dist/esm/state/modules/api-resources.js +2 -2
  275. package/dist/esm/state/modules/api-resources.js.map +1 -1
  276. package/dist/esm/state/modules/breakpoints.js +2 -2
  277. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  278. package/dist/esm/state/modules/components-meta.js +1 -1
  279. package/dist/esm/state/modules/components-meta.js.map +1 -1
  280. package/dist/esm/state/modules/element-trees.js +2 -2
  281. package/dist/esm/state/modules/element-trees.js.map +1 -1
  282. package/dist/esm/state/modules/is-in-builder.js +1 -1
  283. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  284. package/dist/esm/state/modules/is-read-only.js +1 -1
  285. package/dist/esm/state/modules/is-read-only.js.map +1 -1
  286. package/dist/esm/state/modules/locale.js +1 -1
  287. package/dist/esm/state/modules/locale.js.map +1 -1
  288. package/dist/esm/state/modules/localized-resources-map.js +1 -1
  289. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  290. package/dist/esm/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +2 -2
  291. package/dist/esm/state/modules/prop-controller-descriptors.js.map +1 -0
  292. package/dist/esm/state/modules/react-components.js +1 -1
  293. package/dist/esm/state/modules/react-components.js.map +1 -1
  294. package/dist/esm/state/modules/read-write/box-models.js +2 -2
  295. package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
  296. package/dist/esm/state/modules/read-write/element-imperative-handles.js +3 -3
  297. package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +1 -1
  298. package/dist/esm/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +2 -2
  299. package/dist/esm/state/modules/read-write/prop-controllers.js.map +1 -0
  300. package/dist/esm/state/modules/read-write/resolved-value-overrides.js +43 -0
  301. package/dist/esm/state/modules/read-write/resolved-value-overrides.js.map +1 -0
  302. package/dist/esm/state/read-only-state.js +9 -41
  303. package/dist/esm/state/read-only-state.js.map +1 -1
  304. package/dist/esm/state/read-write-state.js +56 -1
  305. package/dist/esm/state/read-write-state.js.map +1 -1
  306. package/dist/esm/state/shared-api/action-types.js +9 -0
  307. package/dist/esm/state/shared-api/action-types.js.map +1 -0
  308. package/dist/esm/state/{shared-api.js → shared-api/actions.js} +2 -7
  309. package/dist/esm/state/shared-api/actions.js.map +1 -0
  310. package/dist/esm/state/shared-api/index.js +3 -0
  311. package/dist/esm/state/shared-api/index.js.map +1 -0
  312. package/dist/esm/state/store.js +3 -1
  313. package/dist/esm/state/store.js.map +1 -1
  314. package/dist/esm/state/translations/get.js.map +1 -1
  315. package/dist/esm/state/translations/merge.js +3 -1
  316. package/dist/esm/state/translations/merge.js.map +1 -1
  317. package/dist/esm/state/unified-state.js +4 -0
  318. package/dist/esm/state/unified-state.js.map +1 -1
  319. package/dist/esm/testing/breakpoints.js +9 -0
  320. package/dist/esm/testing/breakpoints.js.map +1 -0
  321. package/dist/esm/testing/element-data.js +76 -0
  322. package/dist/esm/testing/element-data.js.map +1 -0
  323. package/dist/esm/testing/read-write-state.js +8 -0
  324. package/dist/esm/testing/read-write-state.js.map +1 -0
  325. package/dist/esm/translations/index.js.map +1 -1
  326. package/dist/types/api/__tests__/rest-api-client.retries.test.d.ts +2 -0
  327. package/dist/types/api/__tests__/rest-api-client.retries.test.d.ts.map +1 -0
  328. package/dist/types/api/api-resources-client.d.ts +1 -0
  329. package/dist/types/api/api-resources-client.d.ts.map +1 -1
  330. package/dist/types/api/ky.d.ts +3 -0
  331. package/dist/types/api/ky.d.ts.map +1 -0
  332. package/dist/types/api/rest-api-client.d.ts +4 -0
  333. package/dist/types/api/rest-api-client.d.ts.map +1 -1
  334. package/dist/types/api/schema/page-pathname-slice.d.ts +2 -2
  335. package/dist/types/api/types.d.ts +1 -1
  336. package/dist/types/api/types.d.ts.map +1 -1
  337. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +6 -6
  338. package/dist/types/api-handler/handlers/webhook/types.d.ts +20 -20
  339. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  340. package/dist/types/client/index.d.ts.map +1 -1
  341. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  342. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  343. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  344. package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
  345. package/dist/types/controls/__tests__/slot.test.d.ts +3 -0
  346. package/dist/types/controls/__tests__/slot.test.d.ts.map +1 -0
  347. package/dist/types/controls/rich-text/control.d.ts +5 -1
  348. package/dist/types/controls/rich-text/control.d.ts.map +1 -1
  349. package/dist/types/controls/rich-text/rich-text.d.ts +2 -2
  350. package/dist/types/controls/rich-text/rich-text.d.ts.map +1 -1
  351. package/dist/types/controls/rich-text-v2/control.d.ts +6 -2
  352. package/dist/types/controls/rich-text-v2/control.d.ts.map +1 -1
  353. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +2 -2
  354. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  355. package/dist/types/controls/slot.d.ts +1 -1
  356. package/dist/types/controls/slot.d.ts.map +1 -1
  357. package/dist/types/locale.d.ts +1 -1
  358. package/dist/types/next/testing/breakpoints.d.ts +1 -3
  359. package/dist/types/next/testing/breakpoints.d.ts.map +1 -1
  360. package/dist/types/next/testing/element-data.d.ts +1 -54
  361. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  362. package/dist/types/next/testing/react-runtime.d.ts.map +1 -1
  363. package/dist/types/prop-controllers/instances.d.ts +9 -3
  364. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  365. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  366. package/dist/types/runtimes/react/components/ElementRegistration.d.ts +4 -4
  367. package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
  368. package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts +3 -0
  369. package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts.map +1 -0
  370. package/dist/types/runtimes/react/components/control-instances-context.d.ts +9 -0
  371. package/dist/types/runtimes/react/components/control-instances-context.d.ts.map +1 -0
  372. package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
  373. package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
  374. package/dist/types/runtimes/react/controls/node-value/editable-node-value.d.ts +7 -0
  375. package/dist/types/runtimes/react/controls/node-value/editable-node-value.d.ts.map +1 -0
  376. package/dist/types/runtimes/react/controls/node-value/index.d.ts +6 -0
  377. package/dist/types/runtimes/react/controls/node-value/index.d.ts.map +1 -0
  378. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts +1 -1
  379. package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
  380. package/dist/types/runtimes/react/controls/slot/index.d.ts +2 -0
  381. package/dist/types/runtimes/react/controls/slot/index.d.ts.map +1 -0
  382. package/dist/types/runtimes/react/controls/slot/render-slot.d.ts +9 -0
  383. package/dist/types/runtimes/react/controls/slot/render-slot.d.ts.map +1 -0
  384. package/dist/types/runtimes/react/controls/{slot.d.ts → slot/slot-value.d.ts} +7 -7
  385. package/dist/types/runtimes/react/controls/slot/slot-value.d.ts.map +1 -0
  386. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  387. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  388. package/dist/types/runtimes/react/hooks/__tests__/use-control-instance.test.d.ts +3 -0
  389. package/dist/types/runtimes/react/hooks/__tests__/use-control-instance.test.d.ts.map +1 -0
  390. package/dist/types/runtimes/react/hooks/use-control-instance.d.ts +7 -0
  391. package/dist/types/runtimes/react/hooks/use-control-instance.d.ts.map +1 -0
  392. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts +1 -2
  393. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -1
  394. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts +1 -1
  395. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts.map +1 -1
  396. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +4 -3
  397. package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
  398. package/dist/types/runtimes/react/hooks/use-resolved-value-override.d.ts +5 -0
  399. package/dist/types/runtimes/react/hooks/use-resolved-value-override.d.ts.map +1 -0
  400. package/dist/types/runtimes/react/hooks/use-selector.d.ts +2 -5
  401. package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
  402. package/dist/types/runtimes/react/hooks/use-store.d.ts +2 -4
  403. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  404. package/dist/types/runtimes/react/testing/index.d.ts +3 -0
  405. package/dist/types/runtimes/react/testing/index.d.ts.map +1 -0
  406. package/dist/types/runtimes/react/testing/react-provider.d.ts +8 -0
  407. package/dist/types/runtimes/react/testing/react-provider.d.ts.map +1 -0
  408. package/dist/types/slate/InlineModePlugin/index.d.ts +1 -1
  409. package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
  410. package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
  411. package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
  412. package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
  413. package/dist/types/state/__tests__/test-store.d.ts +2 -4
  414. package/dist/types/state/__tests__/test-store.d.ts.map +1 -1
  415. package/dist/types/state/actions/index.d.ts +9 -6
  416. package/dist/types/state/actions/index.d.ts.map +1 -1
  417. package/dist/types/state/actions/internal/action-types.d.ts +29 -0
  418. package/dist/types/state/actions/internal/action-types.d.ts.map +1 -0
  419. package/dist/types/state/actions/internal/index.d.ts +0 -25
  420. package/dist/types/state/actions/internal/index.d.ts.map +1 -1
  421. package/dist/types/state/actions/internal/read-only-action-types.d.ts +15 -0
  422. package/dist/types/state/actions/internal/read-only-action-types.d.ts.map +1 -0
  423. package/dist/types/state/actions/internal/read-only-actions.d.ts +3 -76
  424. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
  425. package/dist/types/state/actions/internal/read-write-action-types.d.ts +17 -0
  426. package/dist/types/state/actions/internal/read-write-action-types.d.ts.map +1 -0
  427. package/dist/types/state/actions/internal/read-write-actions.d.ts +89 -8
  428. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  429. package/dist/types/state/api-client/state.d.ts +1 -0
  430. package/dist/types/state/api-client/state.d.ts.map +1 -1
  431. package/dist/types/state/builder-api/action-types.d.ts +22 -0
  432. package/dist/types/state/builder-api/action-types.d.ts.map +1 -0
  433. package/dist/types/state/builder-api/actions.d.ts +3 -23
  434. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  435. package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
  436. package/dist/types/state/host-api/action-types.d.ts +17 -0
  437. package/dist/types/state/host-api/action-types.d.ts.map +1 -0
  438. package/dist/types/state/{host-api.d.ts → host-api/actions.d.ts} +7 -22
  439. package/dist/types/state/host-api/actions.d.ts.map +1 -0
  440. package/dist/types/state/host-api/index.d.ts +3 -0
  441. package/dist/types/state/host-api/index.d.ts.map +1 -0
  442. package/dist/types/state/middleware/read-write/__tests__/fixtures/operations.d.ts.map +1 -0
  443. package/dist/types/state/middleware/read-write/__tests__/fixtures/root-elements.d.ts.map +1 -0
  444. package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts +2 -0
  445. package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts.map +1 -0
  446. package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts +2 -0
  447. package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts.map +1 -0
  448. package/dist/types/state/middleware/read-write/builder-api/__tests__/middleware.test.d.ts +2 -0
  449. package/dist/types/state/middleware/read-write/builder-api/__tests__/middleware.test.d.ts.map +1 -0
  450. package/dist/types/state/middleware/read-write/builder-api/__tests__/mount-change-action-buffer.test.d.ts +2 -0
  451. package/dist/types/state/middleware/read-write/builder-api/__tests__/mount-change-action-buffer.test.d.ts.map +1 -0
  452. package/dist/types/state/middleware/read-write/builder-api/index.d.ts +1 -4
  453. package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -1
  454. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +1 -1
  455. package/dist/types/state/middleware/read-write/builder-api/middleware.d.ts +5 -0
  456. package/dist/types/state/middleware/read-write/builder-api/middleware.d.ts.map +1 -0
  457. package/dist/types/state/middleware/read-write/builder-api/mount-change-action-buffer.d.ts +28 -0
  458. package/dist/types/state/middleware/read-write/builder-api/mount-change-action-buffer.d.ts.map +1 -0
  459. package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -1
  460. package/dist/types/state/modules/element-trees.d.ts +1 -1
  461. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  462. package/dist/types/state/modules/{prop-controllers.d.ts → prop-controller-descriptors.d.ts} +1 -1
  463. package/dist/types/state/modules/prop-controller-descriptors.d.ts.map +1 -0
  464. package/dist/types/state/modules/{prop-controller-handles.d.ts → read-write/prop-controllers.d.ts} +4 -4
  465. package/dist/types/state/modules/{prop-controller-handles.d.ts.map → read-write/prop-controllers.d.ts.map} +1 -1
  466. package/dist/types/state/modules/read-write/resolved-value-overrides.d.ts +15 -0
  467. package/dist/types/state/modules/read-write/resolved-value-overrides.d.ts.map +1 -0
  468. package/dist/types/state/read-only-state.d.ts +6 -70
  469. package/dist/types/state/read-only-state.d.ts.map +1 -1
  470. package/dist/types/state/read-write-state.d.ts +74 -4
  471. package/dist/types/state/read-write-state.d.ts.map +1 -1
  472. package/dist/types/state/shared-api/action-types.d.ts +6 -0
  473. package/dist/types/state/shared-api/action-types.d.ts.map +1 -0
  474. package/dist/types/state/{shared-api.d.ts → shared-api/actions.d.ts} +3 -7
  475. package/dist/types/state/shared-api/actions.d.ts.map +1 -0
  476. package/dist/types/state/shared-api/index.d.ts +3 -0
  477. package/dist/types/state/shared-api/index.d.ts.map +1 -0
  478. package/dist/types/state/store.d.ts +4 -8
  479. package/dist/types/state/store.d.ts.map +1 -1
  480. package/dist/types/state/translations/get.d.ts +1 -1
  481. package/dist/types/state/translations/get.d.ts.map +1 -1
  482. package/dist/types/state/translations/merge.d.ts +1 -1
  483. package/dist/types/state/translations/merge.d.ts.map +1 -1
  484. package/dist/types/state/unified-state.d.ts +2 -0
  485. package/dist/types/state/unified-state.d.ts.map +1 -1
  486. package/dist/types/testing/breakpoints.d.ts +4 -0
  487. package/dist/types/testing/breakpoints.d.ts.map +1 -0
  488. package/dist/types/testing/element-data.d.ts +59 -0
  489. package/dist/types/testing/element-data.d.ts.map +1 -0
  490. package/dist/types/testing/read-write-state.d.ts +3 -0
  491. package/dist/types/testing/read-write-state.d.ts.map +1 -0
  492. package/dist/types/translations/index.d.ts +1 -1
  493. package/dist/types/translations/index.d.ts.map +1 -1
  494. package/package.json +7 -5
  495. package/dist/cjs/runtimes/react/controls/slot.js.map +0 -1
  496. package/dist/cjs/state/host-api.js.map +0 -1
  497. package/dist/cjs/state/modules/prop-controller-handles.js.map +0 -1
  498. package/dist/cjs/state/modules/prop-controllers.js.map +0 -1
  499. package/dist/cjs/state/shared-api.js.map +0 -1
  500. package/dist/esm/runtimes/react/controls/slot.js.map +0 -1
  501. package/dist/esm/state/host-api.js.map +0 -1
  502. package/dist/esm/state/modules/prop-controller-handles.js.map +0 -1
  503. package/dist/esm/state/modules/prop-controllers.js.map +0 -1
  504. package/dist/esm/state/shared-api.js.map +0 -1
  505. package/dist/types/runtimes/react/controls/slot.d.ts.map +0 -1
  506. package/dist/types/state/__tests__/fixtures/operations.d.ts.map +0 -1
  507. package/dist/types/state/__tests__/fixtures/root-elements.d.ts.map +0 -1
  508. package/dist/types/state/__tests__/react-builder-preview.test.d.ts +0 -2
  509. package/dist/types/state/__tests__/react-builder-preview.test.d.ts.map +0 -1
  510. package/dist/types/state/host-api.d.ts.map +0 -1
  511. package/dist/types/state/modules/prop-controllers.d.ts.map +0 -1
  512. package/dist/types/state/shared-api.d.ts.map +0 -1
  513. /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/operations.d.ts +0 -0
  514. /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/root-elements.d.ts +0 -0
@@ -1,5 +1,6 @@
1
1
  import { useControlDefs } from "../hooks/use-control-defs";
2
2
  import { useResolvedProps } from "../hooks/use-resolved-props";
3
+ import { useControlInstances } from "../hooks/use-control-instances";
3
4
  import { useStylesheetFactory } from "../hooks/use-stylesheet-factory";
4
5
  import { resolveLegacyDescriptorProp } from "../legacy-controls";
5
6
  function ResolveProps({
@@ -7,11 +8,14 @@ function ResolveProps({
7
8
  children: renderComponent
8
9
  }) {
9
10
  const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type });
11
+ const elementKey = element.key;
10
12
  const stylesheetFactory = useStylesheetFactory();
13
+ const controlInstances = useControlInstances(elementKey);
11
14
  const resolvedProps = useResolvedProps({
15
+ elementKey,
12
16
  propDefs: definitions,
13
17
  propData: element.props,
14
- elementKey: element.key,
18
+ controlInstances,
15
19
  stylesheetFactory
16
20
  });
17
21
  const renderFn = Object.entries(legacyDescriptors).reduceRight(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const stylesheetFactory = useStylesheetFactory()\n const resolvedProps = useResolvedProps({\n propDefs: definitions,\n propData: element.props,\n elementKey: element.key,\n stylesheetFactory,\n })\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":"AAIA,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAErC,SAAS,mCAAmC;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AAAA,IACrC,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB;AAAA,EACF,CAAC;AAED,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,WACE,4BAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\nimport { useControlInstances } from '../hooks/use-control-instances'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const elementKey = element.key\n const stylesheetFactory = useStylesheetFactory()\n const controlInstances = useControlInstances(elementKey)\n const resolvedProps = useResolvedProps({\n elementKey,\n propDefs: definitions,\n propData: element.props,\n controlInstances,\n stylesheetFactory,\n })\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":"AAIA,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAErC,SAAS,mCAAmC;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,aAAa,QAAQ;AAC3B,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,mBAAmB,oBAAoB,UAAU;AACvD,QAAM,gBAAgB,iBAAiB;AAAA,IACrC;AAAA,IACA,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA,IAClB;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,WACE,4BAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ useResolvedValueOverride,
4
+ DisableResolvedValueOverride
5
+ } from "../../hooks/use-resolved-value-override";
6
+ const EditableNodeValue = ({
7
+ instanceKey,
8
+ children: value
9
+ }) => {
10
+ const [valueOverride, shouldOverride] = useResolvedValueOverride(instanceKey);
11
+ if (shouldOverride) {
12
+ return /* @__PURE__ */ jsx(DisableResolvedValueOverride.Provider, { value: instanceKey, children: valueOverride });
13
+ }
14
+ return value;
15
+ };
16
+ var editable_node_value_default = EditableNodeValue;
17
+ export {
18
+ EditableNodeValue,
19
+ editable_node_value_default as default
20
+ };
21
+ //# sourceMappingURL=editable-node-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/node-value/editable-node-value.tsx"],"sourcesContent":["import { type ReactNode, type PropsWithChildren } from 'react'\n\nimport { type ControlInstanceKey } from '@makeswift/controls'\n\nimport {\n useResolvedValueOverride,\n DisableResolvedValueOverride,\n} from '../../hooks/use-resolved-value-override'\n\nexport const EditableNodeValue = ({\n instanceKey,\n children: value,\n}: PropsWithChildren<{ instanceKey: ControlInstanceKey | undefined }>): ReactNode => {\n // To make ReactNode props that have been rendered by an RSC component editable purely\n // client-side, we store the edits in the read-write store as overrides and swap them\n // in when present\n const [valueOverride, shouldOverride] = useResolvedValueOverride(instanceKey)\n if (shouldOverride) {\n // disable the override for this instance while rendering it to prevent infinite recursion\n // (the override for a `Slot` prop is a `SlotValue`, which recursively renders another\n // instance of `EditableNodeValue`, which, if we don’t disable it, will find the override\n // and render it again, ad infinitum)\n return (\n <DisableResolvedValueOverride.Provider value={instanceKey}>\n {valueOverride as ReactNode}\n </DisableResolvedValueOverride.Provider>\n )\n }\n\n return value\n}\n\nexport default EditableNodeValue\n"],"mappings":"AAuBM;AAnBN;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA,UAAU;AACZ,MAAqF;AAInF,QAAM,CAAC,eAAe,cAAc,IAAI,yBAAyB,WAAW;AAC5E,MAAI,gBAAgB;AAKlB,WACE,oBAAC,6BAA6B,UAA7B,EAAsC,OAAO,aAC3C,yBACH;AAAA,EAEJ;AAEA,SAAO;AACT;AAEA,IAAO,8BAAQ;","names":[]}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { memo, lazy } from "react";
4
+ import { useIsReadOnly } from "../../hooks/use-is-read-only";
5
+ const EditableNodeValue = lazy(() => import("./editable-node-value"));
6
+ const ReadOnlyNodeValue = ({ children }) => children;
7
+ const NodeValue = memo(function NodeValue2({
8
+ instanceKey,
9
+ children
10
+ }) {
11
+ const NodeContainer = useIsReadOnly() ? ReadOnlyNodeValue : EditableNodeValue;
12
+ return /* @__PURE__ */ jsx(NodeContainer, { instanceKey, children });
13
+ });
14
+ export {
15
+ NodeValue
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/node-value/index.tsx"],"sourcesContent":["'use client'\n\nimport { type ReactNode, type PropsWithChildren, memo, lazy } from 'react'\n\nimport { type ControlInstanceKey } from '@makeswift/controls'\n\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nconst EditableNodeValue = lazy(() => import('./editable-node-value'))\nconst ReadOnlyNodeValue = ({ children }: PropsWithChildren) => children\n\nexport const NodeValue = memo(function NodeValue({\n instanceKey,\n children,\n}: PropsWithChildren<{ instanceKey: ControlInstanceKey | undefined }>): ReactNode {\n const NodeContainer = useIsReadOnly() ? ReadOnlyNodeValue : EditableNodeValue\n return <NodeContainer instanceKey={instanceKey}>{children}</NodeContainer>\n})\n"],"mappings":";AAgBS;AAdT,SAAiD,MAAM,YAAY;AAInE,SAAS,qBAAqB;AAE9B,MAAM,oBAAoB,KAAK,MAAM,OAAO,uBAAuB,CAAC;AACpE,MAAM,oBAAoB,CAAC,EAAE,SAAS,MAAyB;AAExD,MAAM,YAAY,KAAK,SAASA,WAAU;AAAA,EAC/C;AAAA,EACA;AACF,GAAkF;AAChF,QAAM,gBAAgB,cAAc,IAAI,oBAAoB;AAC5D,SAAO,oBAAC,iBAAc,aAA2B,UAAS;AAC5D,CAAC;","names":["NodeValue"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/editable-text.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@emotion/css'\nimport { getBox } from 'css-box-model'\nimport isHotkey from 'is-hotkey'\nimport {\n FocusEvent,\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate as SlateReact, Editable, withReact, ReactEditor } from 'slate-react'\n\nimport { Slate, richTextDTOtoDAO, type RichTextValue } from '@makeswift/controls'\n\nimport { useBuilderEditMode } from '../../..'\nimport { DescriptorsPropControllers } from '../../../../../prop-controllers/instances'\nimport { withBlock, withTypography, withBuilder, onKeyDown } from '../../../../../slate'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { PropControllersHandle } from '../../../../../state/modules/prop-controller-handles'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { Element, Leaf } from '../components'\nimport { Descriptors } from '../rich-text'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: Slate.RichTextDAO = [\n { type: Slate.BlockType.Paragraph, children: [{ text: '' }] },\n]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))))\n const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false)\n useSyncDOMSelection(editor, isPreservingDOMSElection)\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n if (controller == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n setIsPreservingDOMSelection(true)\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // When clicking outside of the iframe (`relatedTarget` is null) we want to preserve the DOM selection.\n if (e.relatedTarget == null) return\n // Otherwise we want to deselect on blur and stop preserving selection.\n setIsPreservingDOMSelection(false)\n ReactEditor.deselect(editor)\n }, [])\n\n return (\n <SlateReact editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n className={cx(width, margin)}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </SlateReact>\n )\n})\n\nexport default EditableText\n"],"mappings":"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","names":["EditableText"]}
1
+ {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/editable-text.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@emotion/css'\nimport { getBox } from 'css-box-model'\nimport isHotkey from 'is-hotkey'\nimport {\n FocusEvent,\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate as SlateReact, Editable, withReact, ReactEditor } from 'slate-react'\n\nimport { Slate, richTextDTOtoDAO, type RichTextValue } from '@makeswift/controls'\n\nimport { useBuilderEditMode } from '../../..'\nimport { DescriptorsPropControllers } from '../../../../../prop-controllers/instances'\nimport { withBlock, withTypography, withBuilder, onKeyDown } from '../../../../../slate'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { PropControllersHandle } from '../../../../../state/modules/read-write/prop-controllers'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { Element, Leaf } from '../components'\nimport { Descriptors } from '../rich-text'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: Slate.RichTextDAO = [\n { type: Slate.BlockType.Paragraph, children: [{ text: '' }] },\n]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))))\n const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false)\n useSyncDOMSelection(editor, isPreservingDOMSElection)\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n if (controller == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n setIsPreservingDOMSelection(true)\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // When clicking outside of the iframe (`relatedTarget` is null) we want to preserve the DOM selection.\n if (e.relatedTarget == null) return\n // Otherwise we want to deselect on blur and stop preserving selection.\n setIsPreservingDOMSelection(false)\n ReactEditor.deselect(editor)\n }, [])\n\n return (\n <SlateReact editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n className={cx(width, margin)}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </SlateReact>\n )\n})\n\nexport default EditableText\n"],"mappings":"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","names":["EditableText"]}
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { lazy, useCallback } from "react";
3
3
  import {
4
4
  isPropControllersHandle
5
- } from "../../../../state/modules/prop-controller-handles";
5
+ } from "../../../../state/modules/read-write/prop-controllers";
6
6
  import { useIsReadOnly } from "../../hooks/use-is-read-only";
7
7
  const EditableText = lazy(() => import("./EditableText"));
8
8
  const ReadOnlyText = lazy(() => import("./ReadOnlyText"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/rich-text.tsx"],"sourcesContent":["import { ReactNode, lazy, useCallback } from 'react'\n\nimport { type DataType } from '@makeswift/controls'\nimport { RichTextV1Control, RichTextV1Definition } from '../../../../controls/rich-text'\n\nimport {\n isPropControllersHandle,\n PropControllersHandle,\n} from '../../../../state/modules/prop-controller-handles'\n\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nconst EditableText = lazy(() => import('./EditableText'))\nconst ReadOnlyText = lazy(() => import('./ReadOnlyText'))\n\nexport type RichTextControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV1Definition }\n\nexport function renderRichText(\n data: DataType<RichTextV1Definition> | undefined,\n control: RichTextV1Control | null,\n) {\n return <RichText data={data} control={control} />\n}\n\nfunction RichText({\n data,\n control,\n}: {\n data: DataType<RichTextV1Definition> | undefined\n control: RichTextV1Control | null\n}) {\n const textCallbackRef = useCallback(\n (handle: PropControllersHandle<Descriptors> | HTMLDivElement | null) => {\n if (isPropControllersHandle(handle))\n handle?.setPropControllers?.(control == null ? null : { text: control })\n },\n [control],\n )\n\n return useIsReadOnly() ? (\n <ReadOnlyText text={data} ref={textCallbackRef} />\n ) : (\n <EditableText text={data} ref={textCallbackRef} />\n )\n}\n"],"mappings":"AAuBS;AAvBT,SAAoB,MAAM,mBAAmB;AAK7C;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,qBAAqB;AAE9B,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AACxD,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AAMjD,SAAS,eACd,MACA,SACA;AACA,SAAO,oBAAC,YAAS,MAAY,SAAkB;AACjD;AAEA,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AACF,GAGG;AACD,QAAM,kBAAkB;AAAA,IACtB,CAAC,WAAuE;AACtE,UAAI,wBAAwB,MAAM;AAChC,gBAAQ,qBAAqB,WAAW,OAAO,OAAO,EAAE,MAAM,QAAQ,CAAC;AAAA,IAC3E;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,cAAc,IACnB,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB,IAEhD,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB;AAEpD;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/rich-text.tsx"],"sourcesContent":["import { ReactNode, lazy, useCallback } from 'react'\n\nimport { type DataType } from '@makeswift/controls'\nimport { RichTextV1Control, RichTextV1Definition } from '../../../../controls/rich-text'\n\nimport {\n isPropControllersHandle,\n PropControllersHandle,\n} from '../../../../state/modules/read-write/prop-controllers'\n\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nconst EditableText = lazy(() => import('./EditableText'))\nconst ReadOnlyText = lazy(() => import('./ReadOnlyText'))\n\nexport type RichTextControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV1Definition }\n\nexport function renderRichText(\n data: DataType<RichTextV1Definition> | undefined,\n control: RichTextV1Control | null,\n) {\n return <RichText data={data} control={control} />\n}\n\nfunction RichText({\n data,\n control,\n}: {\n data: DataType<RichTextV1Definition> | undefined\n control: RichTextV1Control | null\n}) {\n const textCallbackRef = useCallback(\n (handle: PropControllersHandle<Descriptors> | HTMLDivElement | null) => {\n if (isPropControllersHandle(handle))\n handle?.setPropControllers?.(control == null ? null : { text: control })\n },\n [control],\n )\n\n return useIsReadOnly() ? (\n <ReadOnlyText text={data} ref={textCallbackRef} />\n ) : (\n <EditableText text={data} ref={textCallbackRef} />\n )\n}\n"],"mappings":"AAuBS;AAvBT,SAAoB,MAAM,mBAAmB;AAK7C;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,qBAAqB;AAE9B,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AACxD,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AAMjD,SAAS,eACd,MACA,SACA;AACA,SAAO,oBAAC,YAAS,MAAY,SAAkB;AACjD;AAEA,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AACF,GAGG;AACD,QAAM,kBAAkB;AAAA,IACtB,CAAC,WAAuE;AACtE,UAAI,wBAAwB,MAAM;AAChC,gBAAQ,qBAAqB,WAAW,OAAO,OAAO,EAAE,MAAM,QAAQ,CAAC;AAAA,IAC3E;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,cAAc,IACnB,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB,IAEhD,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB;AAEpD;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { renderSlot } from "./render-slot";
2
+ export {
3
+ renderSlot
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/index.ts"],"sourcesContent":["export { renderSlot } from './render-slot'\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]}
@@ -0,0 +1,13 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { SlotValue } from "./slot-value";
3
+ function renderSlot({
4
+ data,
5
+ control,
6
+ config
7
+ }) {
8
+ return /* @__PURE__ */ jsx(SlotValue, { data, instanceKey: control?.instanceKey, config });
9
+ }
10
+ export {
11
+ renderSlot
12
+ };
13
+ //# sourceMappingURL=render-slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/render-slot.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig } from '../../../../controls/slot'\n\nimport { SlotValue } from './slot-value'\n\nexport function renderSlot({\n data,\n control,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n // To make `SlotValue` interactive in the builder after it has been rendered as part of an\n // RSC component's server output and hydrated on the client, we need some way to connect\n // it to the corresponding control instance. Handling this purely client-side isn't an\n // option, as by itself the rendered slot has no identity we could use to look up its control\n // instance. Instantiating the instance on the server and simply passing it as a prop is\n // also not an option, as class instances like `SlotControl` can't cross the RSC server-client\n // serialization boundary. We can, however, pass the control's `instanceKey` instead, and use\n // it to look up the corresponding client-side control instance in `SlotValue` via\n // `useControlInstance`, and it works equally well for purely client-side rendering.\n return <SlotValue data={data} instanceKey={control?.instanceKey} config={config} />\n}\n"],"mappings":"AAyBS;AApBT,SAAS,iBAAiB;AAEnB,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIc;AAUZ,SAAO,oBAAC,aAAU,MAAY,aAAa,SAAS,aAAa,QAAgB;AACnF;","names":[]}
@@ -1,28 +1,39 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useState, memo } from "react";
3
+ import {
4
+ useEffect,
5
+ useState,
6
+ memo
7
+ } from "react";
4
8
  import { cx } from "@emotion/css";
5
- import { Element } from "../components/Element";
6
- import { useIsInBuilder } from "../hooks/use-is-in-builder";
7
- import { getIndexes } from "../../../components/utils/columns";
8
- import { useResponsiveStyle } from "../../../components/utils/responsive-style";
9
- import { useStyle } from "../use-style";
10
- import { pollBoxModel } from "../poll-box-model";
11
- function renderSlot(props) {
12
- return /* @__PURE__ */ jsx(SlotValue, { ...props });
13
- }
14
- const SlotValue = memo(
15
- ({
16
- data,
17
- control,
18
- config
19
- }) => {
20
- if (data == null || data.elements.length === 0) {
21
- return /* @__PURE__ */ jsx(Slot.Placeholder, { control, placeholder: config.unstable_placeholder });
22
- }
23
- return /* @__PURE__ */ jsx(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ jsx(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ jsx(Element, { element }) }, element.key)) });
9
+ import {
10
+ SlotControl
11
+ } from "@makeswift/controls";
12
+ import { Element } from "../../components/Element";
13
+ import { getIndexes } from "../../../../components/utils/columns";
14
+ import { useResponsiveStyle } from "../../../../components/utils/responsive-style";
15
+ import { useIsInBuilder } from "../../hooks/use-is-in-builder";
16
+ import { useControlInstance } from "../../hooks/use-control-instance";
17
+ import { useStyle } from "../../use-style";
18
+ import { pollBoxModel } from "../../poll-box-model";
19
+ import { NodeValue } from "../node-value";
20
+ const SlotValue = memo(function SlotValue2({
21
+ instanceKey,
22
+ ...props
23
+ }) {
24
+ return /* @__PURE__ */ jsx(NodeValue, { instanceKey, children: /* @__PURE__ */ jsx(SlotOrPlaceholder, { instanceKey, ...props }) });
25
+ });
26
+ const SlotOrPlaceholder = ({
27
+ data,
28
+ instanceKey,
29
+ config
30
+ }) => {
31
+ const control = useControlInstance(instanceKey, SlotControl);
32
+ if (data == null || data.elements.length === 0) {
33
+ return /* @__PURE__ */ jsx(Slot.Placeholder, { control, placeholder: config.unstable_placeholder });
24
34
  }
25
- );
35
+ return /* @__PURE__ */ jsx(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ jsx(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ jsx(Element, { element }) }, element.key)) });
36
+ };
26
37
  function Slot({
27
38
  as,
28
39
  control,
@@ -153,6 +164,6 @@ function SlotPlaceholder({ control, placeholder }) {
153
164
  }
154
165
  export {
155
166
  Slot,
156
- renderSlot
167
+ SlotValue
157
168
  };
158
- //# sourceMappingURL=slot.js.map
169
+ //# sourceMappingURL=slot-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/slot-value.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type ReactNode,\n useEffect,\n useState,\n memo,\n} from 'react'\n\nimport { cx } from '@emotion/css'\n\nimport {\n SlotDefinition,\n SlotControl,\n type DataType,\n type ControlInstanceKey,\n} from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../../controls/slot'\n\nimport { Element } from '../../components/Element'\nimport { getIndexes } from '../../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\n\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { useControlInstance } from '../../hooks/use-control-instance'\n\nimport { useStyle } from '../../use-style'\nimport { pollBoxModel } from '../../poll-box-model'\n\nimport { NodeValue } from '../node-value'\n\nexport const SlotValue = memo(function SlotValue({\n instanceKey,\n ...props\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n instanceKey: ControlInstanceKey | undefined\n config: SlotConfig\n}): ReactNode {\n return (\n <NodeValue instanceKey={instanceKey}>\n <SlotOrPlaceholder instanceKey={instanceKey} {...props} />\n </NodeValue>\n )\n})\n\nconst SlotOrPlaceholder = ({\n data,\n instanceKey,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n instanceKey: ControlInstanceKey | undefined\n config: SlotConfig\n}): ReactNode => {\n const control = useControlInstance(instanceKey, SlotControl)\n\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n}\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)\"\n fontSize=\"14px\"\n fontFamily=\"sans-serif\"\n style={{ userSelect: 'none' }}\n >\n {text}\n </text>\n )}\n </svg>\n </div>\n )\n}\n"],"mappings":"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","names":["SlotValue"]}
@@ -1,7 +1,7 @@
1
1
  import { isMeasurable, measure } from "../../state/modules/read-write/box-models";
2
2
  import {
3
3
  isPropControllersHandle
4
- } from "../../state/modules/prop-controller-handles";
4
+ } from "../../state/modules/read-write/prop-controllers";
5
5
  class ElementImperativeHandle {
6
6
  getCurrent = () => null;
7
7
  lastPropControllers = null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/element-imperative-handle.ts"],"sourcesContent":["import { BoxModelHandle, type BoxDisplayModel } from '../../state/modules/read-write/box-models'\nimport { Descriptor } from '../../prop-controllers/descriptors'\nimport { DescriptorsPropControllers } from '../../prop-controllers/instances'\nimport { isMeasurable, measure } from '../../state/modules/read-write/box-models'\nimport {\n isPropControllersHandle,\n PropControllersHandle,\n} from '../../state/modules/prop-controller-handles'\n\nexport class ElementImperativeHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n >\n implements BoxModelHandle, PropControllersHandle<T>\n{\n private getCurrent: () => unknown = () => null\n private lastPropControllers: DescriptorsPropControllers<T> | null = null\n\n callback(getCurrent: () => unknown) {\n const current = this.getCurrent()\n\n if (current === null) this.setPropControllers(null)\n\n this.getCurrent = getCurrent\n\n if (this.lastPropControllers !== null) this.setPropControllers(this.lastPropControllers)\n }\n\n getBoxModel(): BoxDisplayModel | null {\n const current = this.getCurrent()\n\n return isMeasurable(current) ? measure(current) : null\n }\n\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void {\n const current = this.getCurrent()\n\n if (isPropControllersHandle(current)) current.setPropControllers(propControllers)\n\n this.lastPropControllers = propControllers\n }\n\n getDomNode(): Element | null {\n const current = this.getCurrent()\n\n if (isDomNodeHandle(current)) return current.getDomNode()\n\n return current instanceof Element ? current : null\n }\n}\n\ntype DomNodeHandle = {\n getDomNode(): Element | null\n}\n\nexport function isDomNodeHandle(value: unknown): value is DomNodeHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getDomNode' in value &&\n typeof (value as { getDomNode: unknown }).getDomNode === 'function'\n ) {\n return true\n }\n\n return false\n}\n"],"mappings":"AAGA,SAAS,cAAc,eAAe;AACtC;AAAA,EACE;AAAA,OAEK;AAEA,MAAM,wBAIb;AAAA,EACU,aAA4B,MAAM;AAAA,EAClC,sBAA4D;AAAA,EAEpE,SAAS,YAA2B;AAClC,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,YAAY;AAAM,WAAK,mBAAmB,IAAI;AAElD,SAAK,aAAa;AAElB,QAAI,KAAK,wBAAwB;AAAM,WAAK,mBAAmB,KAAK,mBAAmB;AAAA,EACzF;AAAA,EAEA,cAAsC;AACpC,UAAM,UAAU,KAAK,WAAW;AAEhC,WAAO,aAAa,OAAO,IAAI,QAAQ,OAAO,IAAI;AAAA,EACpD;AAAA,EAEA,mBAAmB,iBAA6D;AAC9E,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,wBAAwB,OAAO;AAAG,cAAQ,mBAAmB,eAAe;AAEhF,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,aAA6B;AAC3B,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,gBAAgB,OAAO;AAAG,aAAO,QAAQ,WAAW;AAExD,WAAO,mBAAmB,UAAU,UAAU;AAAA,EAChD;AACF;AAMO,SAAS,gBAAgB,OAAwC;AACtE,MACE,OAAO,UAAU,YACjB,UAAU,QACV,gBAAgB,SAChB,OAAQ,MAAkC,eAAe,YACzD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/react/element-imperative-handle.ts"],"sourcesContent":["import { BoxModelHandle, type BoxDisplayModel } from '../../state/modules/read-write/box-models'\nimport { Descriptor } from '../../prop-controllers/descriptors'\nimport { DescriptorsPropControllers } from '../../prop-controllers/instances'\nimport { isMeasurable, measure } from '../../state/modules/read-write/box-models'\nimport {\n isPropControllersHandle,\n PropControllersHandle,\n} from '../../state/modules/read-write/prop-controllers'\n\nexport class ElementImperativeHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n >\n implements BoxModelHandle, PropControllersHandle<T>\n{\n private getCurrent: () => unknown = () => null\n private lastPropControllers: DescriptorsPropControllers<T> | null = null\n\n callback(getCurrent: () => unknown) {\n const current = this.getCurrent()\n\n if (current === null) this.setPropControllers(null)\n\n this.getCurrent = getCurrent\n\n if (this.lastPropControllers !== null) this.setPropControllers(this.lastPropControllers)\n }\n\n getBoxModel(): BoxDisplayModel | null {\n const current = this.getCurrent()\n\n return isMeasurable(current) ? measure(current) : null\n }\n\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void {\n const current = this.getCurrent()\n\n if (isPropControllersHandle(current)) current.setPropControllers(propControllers)\n\n this.lastPropControllers = propControllers\n }\n\n getDomNode(): Element | null {\n const current = this.getCurrent()\n\n if (isDomNodeHandle(current)) return current.getDomNode()\n\n return current instanceof Element ? current : null\n }\n}\n\ntype DomNodeHandle = {\n getDomNode(): Element | null\n}\n\nexport function isDomNodeHandle(value: unknown): value is DomNodeHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getDomNode' in value &&\n typeof (value as { getDomNode: unknown }).getDomNode === 'function'\n ) {\n return true\n }\n\n return false\n}\n"],"mappings":"AAGA,SAAS,cAAc,eAAe;AACtC;AAAA,EACE;AAAA,OAEK;AAEA,MAAM,wBAIb;AAAA,EACU,aAA4B,MAAM;AAAA,EAClC,sBAA4D;AAAA,EAEpE,SAAS,YAA2B;AAClC,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,YAAY;AAAM,WAAK,mBAAmB,IAAI;AAElD,SAAK,aAAa;AAElB,QAAI,KAAK,wBAAwB;AAAM,WAAK,mBAAmB,KAAK,mBAAmB;AAAA,EACzF;AAAA,EAEA,cAAsC;AACpC,UAAM,UAAU,KAAK,WAAW;AAEhC,WAAO,aAAa,OAAO,IAAI,QAAQ,OAAO,IAAI;AAAA,EACpD;AAAA,EAEA,mBAAmB,iBAA6D;AAC9E,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,wBAAwB,OAAO;AAAG,cAAQ,mBAAmB,eAAe;AAEhF,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,aAA6B;AAC3B,UAAM,UAAU,KAAK,WAAW;AAEhC,QAAI,gBAAgB,OAAO;AAAG,aAAO,QAAQ,WAAW;AAExD,WAAO,mBAAmB,UAAU,UAAU;AAAA,EAChD;AACF;AAMO,SAAS,gBAAgB,OAAwC;AACtE,MACE,OAAO,UAAU,YACjB,UAAU,QACV,gBAAgB,SAChB,OAAQ,MAAkC,eAAe,YACzD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,62 @@
1
+ import { useCallback, useSyncExternalStore } from "react";
2
+ import { isNotNil } from "@makeswift/controls";
3
+ import { useControlInstances } from "./use-control-instances";
4
+ function useControlInstance(instanceKey, instanceClass) {
5
+ const { elementKey, propPath } = instanceKey ?? {};
6
+ const instances = useControlInstances(elementKey);
7
+ const getInstance = useCallback(
8
+ () => instances != null && propPath != null ? getInstanceByPropPath(instances, propPath) : null,
9
+ [instances, propPath]
10
+ );
11
+ const subscribe = useCallback(
12
+ (onStateChange) => {
13
+ if (instances == null || propPath == null)
14
+ return () => {
15
+ };
16
+ let unsubscribes = [];
17
+ const handleStateChange = () => {
18
+ resubscribe();
19
+ onStateChange();
20
+ };
21
+ const resubscribe = () => {
22
+ unsubscribes.forEach((unsubscribe) => unsubscribe());
23
+ const chain = getInstanceChainByPropPath(instances, propPath).filter(isNotNil);
24
+ unsubscribes = chain.map((instance) => instance.subscribe(handleStateChange));
25
+ };
26
+ resubscribe();
27
+ return () => unsubscribes.forEach((unsubscribe) => unsubscribe());
28
+ },
29
+ [instances, propPath]
30
+ );
31
+ const result = useSyncExternalStore(subscribe, getInstance, getInstance);
32
+ if (result) {
33
+ const foundKey = result.instanceKey;
34
+ if (foundKey.elementKey !== elementKey || foundKey.propPath != propPath) {
35
+ console.error("Mismatching control instance key: expected", instanceKey, " got", foundKey);
36
+ return null;
37
+ }
38
+ if (!(result instanceof instanceClass)) {
39
+ console.error(
40
+ `Unexpected control instance class: requested '${instanceClass.name}', found '${result.constructor.name}'`,
41
+ { instanceKey }
42
+ );
43
+ return null;
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+ function getInstanceChainByPropPath(instances, propPath) {
49
+ const [parentProp, ...childPath] = propPath.split(".");
50
+ const parentInstance = instances[parentProp];
51
+ const getInstanceChain = (parent, childPath2) => parent == null || childPath2.length === 0 ? [parent ?? null] : [parent, ...getInstanceChain(parent.child(childPath2[0]), childPath2.slice(1))];
52
+ return getInstanceChain(parentInstance, childPath);
53
+ }
54
+ function getInstanceByPropPath(instances, propPath) {
55
+ return getInstanceChainByPropPath(instances, propPath).at(-1) ?? null;
56
+ }
57
+ export {
58
+ getInstanceByPropPath,
59
+ getInstanceChainByPropPath,
60
+ useControlInstance
61
+ };
62
+ //# sourceMappingURL=use-control-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instance.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from 'react'\nimport { type AnyControlInstance, type ControlInstanceKey, isNotNil } from '@makeswift/controls'\n\nimport { useControlInstances } from './use-control-instances'\n\ntype InstanceConstructor<T extends AnyControlInstance> = abstract new (...args: never[]) => T\n\nexport function useControlInstance<T extends AnyControlInstance>(\n instanceKey: ControlInstanceKey | undefined,\n instanceClass: InstanceConstructor<T>,\n): T | null {\n const { elementKey, propPath } = instanceKey ?? {}\n\n const instances = useControlInstances(elementKey)\n const getInstance = useCallback(\n () =>\n instances != null && propPath != null ? getInstanceByPropPath(instances, propPath) : null,\n [instances, propPath],\n )\n\n const subscribe = useCallback(\n (onStateChange: () => void) => {\n if (instances == null || propPath == null) return () => {}\n\n let unsubscribes: (() => void)[] = []\n\n // recompute the instance chain and resubscribe to its updates on every notification,\n // since a control's own update (e.g. a `ListControl` replacing its children) can replace\n // the instances further down the chain\n const handleStateChange = () => {\n resubscribe()\n onStateChange()\n }\n\n const resubscribe = () => {\n unsubscribes.forEach(unsubscribe => unsubscribe())\n\n const chain = getInstanceChainByPropPath(instances, propPath).filter(isNotNil)\n unsubscribes = chain.map(instance => instance.subscribe(handleStateChange))\n }\n\n resubscribe()\n\n return () => unsubscribes.forEach(unsubscribe => unsubscribe())\n },\n [instances, propPath],\n )\n\n const result = useSyncExternalStore(subscribe, getInstance, getInstance)\n\n if (result) {\n const foundKey = result.instanceKey\n if (foundKey.elementKey !== elementKey || foundKey.propPath != propPath) {\n console.error('Mismatching control instance key: expected', instanceKey, ' got', foundKey)\n return null\n }\n\n if (!(result instanceof instanceClass)) {\n console.error(\n `Unexpected control instance class: requested '${instanceClass.name}', found '${result.constructor.name}'`,\n { instanceKey },\n )\n\n return null\n }\n }\n\n return result\n}\n\nexport function getInstanceChainByPropPath(\n instances: Record<string, AnyControlInstance>,\n propPath: string,\n): (AnyControlInstance | null)[] {\n const [parentProp, ...childPath] = propPath.split('.')\n const parentInstance = instances[parentProp]\n\n const getInstanceChain = (\n parent: AnyControlInstance | undefined,\n childPath: string[],\n ): (AnyControlInstance | null)[] =>\n parent == null || childPath.length === 0\n ? [parent ?? null]\n : [parent, ...getInstanceChain(parent.child(childPath[0]), childPath.slice(1))]\n\n return getInstanceChain(parentInstance, childPath)\n}\n\nexport function getInstanceByPropPath(\n instances: Record<string, AnyControlInstance>,\n propPath: string,\n): AnyControlInstance | null {\n return getInstanceChainByPropPath(instances, propPath).at(-1) ?? null\n}\n"],"mappings":"AAAA,SAAS,aAAa,4BAA4B;AAClD,SAA2D,gBAAgB;AAE3E,SAAS,2BAA2B;AAI7B,SAAS,mBACd,aACA,eACU;AACV,QAAM,EAAE,YAAY,SAAS,IAAI,eAAe,CAAC;AAEjD,QAAM,YAAY,oBAAoB,UAAU;AAChD,QAAM,cAAc;AAAA,IAClB,MACE,aAAa,QAAQ,YAAY,OAAO,sBAAsB,WAAW,QAAQ,IAAI;AAAA,IACvF,CAAC,WAAW,QAAQ;AAAA,EACtB;AAEA,QAAM,YAAY;AAAA,IAChB,CAAC,kBAA8B;AAC7B,UAAI,aAAa,QAAQ,YAAY;AAAM,eAAO,MAAM;AAAA,QAAC;AAEzD,UAAI,eAA+B,CAAC;AAKpC,YAAM,oBAAoB,MAAM;AAC9B,oBAAY;AACZ,sBAAc;AAAA,MAChB;AAEA,YAAM,cAAc,MAAM;AACxB,qBAAa,QAAQ,iBAAe,YAAY,CAAC;AAEjD,cAAM,QAAQ,2BAA2B,WAAW,QAAQ,EAAE,OAAO,QAAQ;AAC7E,uBAAe,MAAM,IAAI,cAAY,SAAS,UAAU,iBAAiB,CAAC;AAAA,MAC5E;AAEA,kBAAY;AAEZ,aAAO,MAAM,aAAa,QAAQ,iBAAe,YAAY,CAAC;AAAA,IAChE;AAAA,IACA,CAAC,WAAW,QAAQ;AAAA,EACtB;AAEA,QAAM,SAAS,qBAAqB,WAAW,aAAa,WAAW;AAEvE,MAAI,QAAQ;AACV,UAAM,WAAW,OAAO;AACxB,QAAI,SAAS,eAAe,cAAc,SAAS,YAAY,UAAU;AACvE,cAAQ,MAAM,8CAA8C,aAAa,QAAQ,QAAQ;AACzF,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,kBAAkB,gBAAgB;AACtC,cAAQ;AAAA,QACN,iDAAiD,cAAc,IAAI,aAAa,OAAO,YAAY,IAAI;AAAA,QACvG,EAAE,YAAY;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,2BACd,WACA,UAC+B;AAC/B,QAAM,CAAC,YAAY,GAAG,SAAS,IAAI,SAAS,MAAM,GAAG;AACrD,QAAM,iBAAiB,UAAU,UAAU;AAE3C,QAAM,mBAAmB,CACvB,QACAA,eAEA,UAAU,QAAQA,WAAU,WAAW,IACnC,CAAC,UAAU,IAAI,IACf,CAAC,QAAQ,GAAG,iBAAiB,OAAO,MAAMA,WAAU,CAAC,CAAC,GAAGA,WAAU,MAAM,CAAC,CAAC,CAAC;AAElF,SAAO,iBAAiB,gBAAgB,SAAS;AACnD;AAEO,SAAS,sBACd,WACA,UAC2B;AAC3B,SAAO,2BAA2B,WAAW,QAAQ,EAAE,GAAG,EAAE,KAAK;AACnE;","names":["childPath"]}
@@ -1,14 +1,4 @@
1
- import { getPropControllers } from "../../../state/read-only-state";
2
- import { useDocumentKey } from "./use-document-context";
3
- import { useSelector } from "./use-selector";
4
- function useControlInstances(elementKey) {
5
- const documentKey = useDocumentKey();
6
- return useSelector((state) => {
7
- if (documentKey == null)
8
- return null;
9
- return getPropControllers(state, { documentKey, elementKey });
10
- });
11
- }
1
+ import { useControlInstances } from "../components/control-instances-context";
12
2
  export {
13
3
  useControlInstances
14
4
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\n\nimport { getPropControllers } from '../../../state/read-only-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return getPropControllers(state, { documentKey, elementKey })\n })\n}\n"],"mappings":"AAEA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAErB,SAAS,oBAAoB,YAA4D;AAC9F,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,WAAO,mBAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EAC9D,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["export { useControlInstances } from '../components/control-instances-context'\n"],"mappings":"AAAA,SAAS,2BAA2B;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import { createContext, useContext } from "react";
2
2
  const DisableRegisterElement = createContext(false);
3
- function useDisableRegisterElement() {
3
+ function useIsRegisterElementDisabled() {
4
4
  return useContext(DisableRegisterElement);
5
5
  }
6
6
  export {
7
7
  DisableRegisterElement,
8
- useDisableRegisterElement
8
+ useIsRegisterElementDisabled
9
9
  };
10
10
  //# sourceMappingURL=use-disable-register-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-disable-register-element.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DisableRegisterElement = createContext(false)\n\nexport function useDisableRegisterElement() {\n return useContext(DisableRegisterElement)\n}\n"],"mappings":"AAAA,SAAS,eAAe,kBAAkB;AAEnC,MAAM,yBAAyB,cAAc,KAAK;AAElD,SAAS,4BAA4B;AAC1C,SAAO,WAAW,sBAAsB;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-disable-register-element.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DisableRegisterElement = createContext(false)\n\nexport function useIsRegisterElementDisabled() {\n return useContext(DisableRegisterElement)\n}\n"],"mappings":"AAAA,SAAS,eAAe,kBAAkB;AAEnC,MAAM,yBAAyB,cAAc,KAAK;AAElD,SAAS,+BAA+B;AAC7C,SAAO,WAAW,sBAAsB;AAC1C;","names":[]}
@@ -4,21 +4,20 @@ import {
4
4
  } from "@makeswift/controls";
5
5
  import { useResourceResolver } from "./use-resource-resolver";
6
6
  import { propErrorHandlingProxy } from "../utils/prop-error-handling-proxy";
7
- import { useControlInstances } from "./use-control-instances";
8
7
  import { useResolvableRecord } from "./use-resolvable-record";
9
8
  function useResolvedProps({
9
+ elementKey,
10
10
  propDefs,
11
11
  propData,
12
- elementKey,
12
+ controlInstances,
13
13
  stylesheetFactory
14
14
  }) {
15
15
  const resourceResolver = useResourceResolver();
16
- const controls = useControlInstances(elementKey);
17
16
  const cache = useRef({}).current;
18
17
  const resolveProp = useCallback(
19
18
  (def, propName) => {
20
19
  const data = propData[propName];
21
- const control = controls?.[propName];
20
+ const control = controlInstances?.[propName];
22
21
  if (cache[propName] != null && data === cache[propName].data && control === cache[propName].control) {
23
22
  return cache[propName].resolvedValue;
24
23
  }
@@ -31,24 +30,26 @@ function useResolvedProps({
31
30
  cache[propName] = { data, control, resolvedValue };
32
31
  return resolvedValue;
33
32
  },
34
- [controls, propData, resourceResolver, stylesheetFactory]
33
+ [propData, cache, resourceResolver, controlInstances, stylesheetFactory]
35
34
  );
36
35
  const resolvables = useMemo(
37
36
  () => mapValues(propDefs, (def, propName) => {
38
37
  const defaultValue = def.config?.defaultValue;
39
38
  return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, (error) => {
40
39
  console.warn(
41
- `Error reading value for prop "${propName}", falling back to \`${defaultValue}\`.`,
40
+ `Error reading value for prop "${propName}" of element ${elementKey}, falling back to \`${defaultValue}\`.`,
42
41
  { control: def, error }
43
42
  );
44
43
  });
45
44
  }),
46
- [propDefs, resolveProp]
45
+ [propDefs, resolveProp, elementKey]
47
46
  );
48
47
  const props = useResolvableRecord(resolvables);
49
48
  useEffect(() => {
50
- props.triggerResolve();
51
- }, [props]);
49
+ props.triggerResolve().catch((err) => {
50
+ console.log(`Error while resolving props for element ${elementKey}`, err);
51
+ });
52
+ }, [props, elementKey]);
52
53
  const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable);
53
54
  stylesheetFactory.useDefinedStyles();
54
55
  return resolvedProps;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\n\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nimport { useControlInstances } from './use-control-instances'\nimport { useResolvableRecord } from './use-resolvable-record'\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps({\n propDefs,\n propData,\n elementKey,\n stylesheetFactory,\n}: {\n propDefs: Record<string, ControlDefinition>\n propData: Record<string, Data>\n elementKey: string\n stylesheetFactory: StylesheetFactory\n}): Record<string, unknown> {\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = propData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, propData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,SAAS,2BAA2B;AAGpC,SAAS,8BAA8B;AAEvC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAQ7B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAK4B;AAC1B,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,WAAW,oBAAoB,UAAU;AAE/C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,SAAS,QAAQ;AAC9B,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,UAAU,kBAAkB,iBAAiB;AAAA,EAC1D;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\n\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nimport { useResolvableRecord } from './use-resolvable-record'\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps({\n elementKey,\n propDefs,\n propData,\n controlInstances,\n stylesheetFactory,\n}: {\n elementKey: string\n propDefs: Record<string, ControlDefinition>\n propData: Record<string, Data>\n controlInstances: Record<string, ControlInstance> | null\n stylesheetFactory: StylesheetFactory\n}): Record<string, unknown> {\n const resourceResolver = useResourceResolver()\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = propData[propName]\n const control = controlInstances?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [propData, cache, resourceResolver, controlInstances, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\" of element ${elementKey}, falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp, elementKey],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve().catch(err => {\n console.log(`Error while resolving props for element ${elementKey}`, err)\n })\n }, [props, elementKey])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,SAAS,2BAA2B;AAGpC,SAAS,8BAA8B;AAEvC,SAAS,2BAA2B;AAQ7B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAM4B;AAC1B,QAAM,mBAAmB,oBAAoB;AAE7C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,SAAS,QAAQ;AAC9B,YAAM,UAAU,mBAAmB,QAAQ;AAE3C,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,OAAO,kBAAkB,kBAAkB,iBAAiB;AAAA,EACzE;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,gBAAgB,UAAU,uBAAuB,YAAY;AAAA,UACtG,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,aAAa,UAAU;AAAA,EACpC;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe,EAAE,MAAM,SAAO;AAClC,cAAQ,IAAI,2CAA2C,UAAU,IAAI,GAAG;AAAA,IAC1E,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,UAAU,CAAC;AAItB,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ import {
4
+ hasResolvedValueOverride,
5
+ getResolvedValueOverride
6
+ } from "../../../state/read-write-state";
7
+ import { isReadWriteState } from "../../../state/unified-state";
8
+ import { useSelector } from "./use-selector";
9
+ import { useDocumentKey } from "./use-document-context";
10
+ const DisableResolvedValueOverride = createContext(void 0);
11
+ function useIsResolvedValueOverrideDisabled(instanceKey) {
12
+ const disabledKey = useContext(DisableResolvedValueOverride);
13
+ return disabledKey?.elementKey === instanceKey?.elementKey && disabledKey?.propPath === instanceKey?.propPath;
14
+ }
15
+ const useResolvedValueOverride = (instanceKey) => {
16
+ const documentKey = useDocumentKey();
17
+ const isDisabled = useIsResolvedValueOverrideDisabled(instanceKey);
18
+ return useSelector(
19
+ (state) => {
20
+ if (documentKey == null || instanceKey == null || !isReadWriteState(state))
21
+ return [void 0, false];
22
+ return [
23
+ getResolvedValueOverride(state, documentKey, instanceKey),
24
+ !isDisabled && hasResolvedValueOverride(state, documentKey, instanceKey)
25
+ ];
26
+ },
27
+ (a, b) => a[0] === b[0] && a[1] === b[1]
28
+ );
29
+ };
30
+ export {
31
+ DisableResolvedValueOverride,
32
+ useIsResolvedValueOverrideDisabled,
33
+ useResolvedValueOverride
34
+ };
35
+ //# sourceMappingURL=use-resolved-value-override.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-value-override.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\n\nimport {\n type ResolvedValueKey,\n type ResolvedValue,\n hasResolvedValueOverride,\n getResolvedValueOverride,\n} from '../../../state/read-write-state'\n\nimport { isReadWriteState } from '../../../state/unified-state'\nimport { useSelector } from './use-selector'\nimport { useDocumentKey } from './use-document-context'\n\nexport const DisableResolvedValueOverride = createContext<ResolvedValueKey | undefined>(undefined)\n\nexport function useIsResolvedValueOverrideDisabled(\n instanceKey: ResolvedValueKey | undefined,\n): boolean {\n const disabledKey = useContext(DisableResolvedValueOverride)\n return (\n disabledKey?.elementKey === instanceKey?.elementKey &&\n disabledKey?.propPath === instanceKey?.propPath\n )\n}\n\nexport const useResolvedValueOverride = (\n instanceKey: ResolvedValueKey | undefined,\n): [ResolvedValue, boolean] => {\n const documentKey = useDocumentKey()\n const isDisabled = useIsResolvedValueOverrideDisabled(instanceKey)\n\n return useSelector(\n state => {\n if (documentKey == null || instanceKey == null || !isReadWriteState(state))\n return [undefined, false]\n\n return [\n getResolvedValueOverride(state, documentKey, instanceKey),\n !isDisabled && hasResolvedValueOverride(state, documentKey, instanceKey),\n ]\n },\n (a, b) => a[0] === b[0] && a[1] === b[1],\n )\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAE1C;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAExB,MAAM,+BAA+B,cAA4C,MAAS;AAE1F,SAAS,mCACd,aACS;AACT,QAAM,cAAc,WAAW,4BAA4B;AAC3D,SACE,aAAa,eAAe,aAAa,cACzC,aAAa,aAAa,aAAa;AAE3C;AAEO,MAAM,2BAA2B,CACtC,gBAC6B;AAC7B,QAAM,cAAc,eAAe;AACnC,QAAM,aAAa,mCAAmC,WAAW;AAEjE,SAAO;AAAA,IACL,WAAS;AACP,UAAI,eAAe,QAAQ,eAAe,QAAQ,CAAC,iBAAiB,KAAK;AACvE,eAAO,CAAC,QAAW,KAAK;AAE1B,aAAO;AAAA,QACL,yBAAyB,OAAO,aAAa,WAAW;AAAA,QACxD,CAAC,cAAc,yBAAyB,OAAO,aAAa,WAAW;AAAA,MACzE;AAAA,IACF;AAAA,IACA,CAAC,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC;AAAA,EACzC;AACF;","names":[]}
@@ -1,8 +1,14 @@
1
1
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector";
2
2
  import { useStore } from "./use-store";
3
- function useSelector(selector) {
3
+ function useSelector(selector, isEqual) {
4
4
  const store = useStore();
5
- return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector);
5
+ return useSyncExternalStoreWithSelector(
6
+ store.subscribe,
7
+ store.getState,
8
+ store.getState,
9
+ selector,
10
+ isEqual
11
+ );
6
12
  }
7
13
  export {
8
14
  useSelector
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'\n\nimport { useStore } from './use-store'\nimport { type State as ReadOnlyState } from '../../../state/read-only-state'\nimport { type State as ReadWriteState } from '../../../state/read-write-state'\n\ntype State = ReadOnlyState | ReadWriteState\n\nexport function useSelector<R>(selector: (state: State) => R): R {\n const store = useStore()\n\n return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector)\n}\n"],"mappings":"AAAA,SAAS,wCAAwC;AAEjD,SAAS,gBAAgB;AAMlB,SAAS,YAAe,UAAkC;AAC/D,QAAM,QAAQ,SAAS;AAEvB,SAAO,iCAAiC,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,QAAQ;AACnG;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'\n\nimport { type State } from '../../../state/unified-state'\n\nimport { useStore } from './use-store'\n\nexport function useSelector<R>(\n selector: (state: State) => R,\n isEqual?: (a: R, b: R) => boolean,\n): R {\n const store = useStore()\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n store.getState,\n store.getState,\n selector,\n isEqual,\n )\n}\n"],"mappings":"AAAA,SAAS,wCAAwC;AAIjD,SAAS,gBAAgB;AAElB,SAAS,YACd,UACA,SACG;AACH,QAAM,QAAQ,SAAS;AAEvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./react-provider";
2
+ export * from "./react-runtime";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/testing/index.ts"],"sourcesContent":["export * from './react-provider'\nexport * from './react-runtime'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { RuntimeProvider } from "../components/RuntimeProvider";
3
+ import { DefaultRootStyleRegistry } from "../root-style-registry";
4
+ function ReactProvider({
5
+ children,
6
+ runtime,
7
+ siteVersion = null
8
+ }) {
9
+ return /* @__PURE__ */ jsx(RuntimeProvider, { siteVersion, runtime, children: /* @__PURE__ */ jsx(DefaultRootStyleRegistry, { children }) });
10
+ }
11
+ export {
12
+ ReactProvider
13
+ };
14
+ //# sourceMappingURL=react-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/testing/react-provider.tsx"],"sourcesContent":["import { type ReactRuntimeCore } from '../react-runtime-core'\nimport { RuntimeProvider } from '../components/RuntimeProvider'\n\nimport { DefaultRootStyleRegistry } from '../root-style-registry'\nimport { SiteVersion } from '../../../api/site-version'\n\nexport function ReactProvider({\n children,\n runtime,\n siteVersion = null,\n}: {\n children: React.ReactNode\n runtime: ReactRuntimeCore\n siteVersion?: SiteVersion | null\n}) {\n return (\n <RuntimeProvider siteVersion={siteVersion} runtime={runtime}>\n <DefaultRootStyleRegistry>{children}</DefaultRootStyleRegistry>\n </RuntimeProvider>\n )\n}\n"],"mappings":"AAiBM;AAhBN,SAAS,uBAAuB;AAEhC,SAAS,gCAAgC;AAGlC,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAIG;AACD,SACE,oBAAC,mBAAgB,aAA0B,SACzC,8BAAC,4BAA0B,UAAS,GACtC;AAEJ;","names":[]}