@contember/react-binding 2.0.0-alpha.16 → 2.0.0-alpha.18

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 (400) hide show
  1. package/dist/development/index.cjs +2 -9
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +1 -8
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/accessorPropagation/AccessorProvider.cjs +1 -1
  6. package/dist/development/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
  7. package/dist/development/src/accessorPropagation/AccessorProvider.js +1 -1
  8. package/dist/development/src/accessorPropagation/AccessorProvider.js.map +1 -1
  9. package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
  10. package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
  11. package/dist/development/src/accessorPropagation/BindingOperationsContext.js +2 -1
  12. package/dist/development/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
  13. package/dist/development/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  14. package/dist/development/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  15. package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs +1 -1
  16. package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
  17. package/dist/development/src/accessorPropagation/EntityKeyProvider.js +1 -1
  18. package/dist/development/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
  19. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
  20. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  21. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
  22. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  23. package/dist/development/src/accessorPropagation/useEntity.cjs +4 -4
  24. package/dist/development/src/accessorPropagation/useEntity.cjs.map +1 -1
  25. package/dist/development/src/accessorPropagation/useEntity.js +4 -4
  26. package/dist/development/src/accessorPropagation/useEntity.js.map +1 -1
  27. package/dist/development/src/accessorPropagation/useEntityKey.cjs.map +1 -1
  28. package/dist/development/src/accessorPropagation/useEntityKey.js.map +1 -1
  29. package/dist/development/src/accessorPropagation/useEntityList.cjs +3 -3
  30. package/dist/development/src/accessorPropagation/useEntityList.cjs.map +1 -1
  31. package/dist/development/src/accessorPropagation/useEntityList.js +3 -3
  32. package/dist/development/src/accessorPropagation/useEntityList.js.map +1 -1
  33. package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
  34. package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
  35. package/dist/development/src/accessorPropagation/useEntityListSubTree.js +1 -1
  36. package/dist/development/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
  37. package/dist/development/src/accessorPropagation/useEntitySubTree.cjs +1 -1
  38. package/dist/development/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
  39. package/dist/development/src/accessorPropagation/useEntitySubTree.js +1 -1
  40. package/dist/development/src/accessorPropagation/useEntitySubTree.js.map +1 -1
  41. package/dist/development/src/accessorPropagation/useField.cjs +3 -3
  42. package/dist/development/src/accessorPropagation/useField.cjs.map +1 -1
  43. package/dist/development/src/accessorPropagation/useField.js +3 -3
  44. package/dist/development/src/accessorPropagation/useField.js.map +1 -1
  45. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
  46. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
  47. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
  48. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  49. package/dist/development/src/accessorSorting/addEntityAtIndex.cjs +1 -1
  50. package/dist/development/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
  51. package/dist/development/src/accessorSorting/addEntityAtIndex.js +1 -1
  52. package/dist/development/src/accessorSorting/addEntityAtIndex.js.map +1 -1
  53. package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
  54. package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
  55. package/dist/development/src/accessorSorting/repairEntitiesOrder.js +1 -1
  56. package/dist/development/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
  57. package/dist/development/src/accessorSorting/sortEntities.cjs +2 -2
  58. package/dist/development/src/accessorSorting/sortEntities.cjs.map +1 -1
  59. package/dist/development/src/accessorSorting/sortEntities.js +2 -2
  60. package/dist/development/src/accessorSorting/sortEntities.js.map +1 -1
  61. package/dist/development/src/accessorTree/AccessorTree.cjs +16 -6
  62. package/dist/development/src/accessorTree/AccessorTree.cjs.map +1 -1
  63. package/dist/development/src/accessorTree/AccessorTree.js +16 -6
  64. package/dist/development/src/accessorTree/AccessorTree.js.map +1 -1
  65. package/dist/development/src/accessorTree/useDataBinding.cjs +23 -36
  66. package/dist/development/src/accessorTree/useDataBinding.cjs.map +1 -1
  67. package/dist/development/src/accessorTree/useDataBinding.js +26 -39
  68. package/dist/development/src/accessorTree/useDataBinding.js.map +1 -1
  69. package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
  70. package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
  71. package/dist/development/src/accessorTree/useEnvironmentWithSchema.js +31 -0
  72. package/dist/development/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
  73. package/dist/development/src/coreComponents/Component.cjs.map +1 -1
  74. package/dist/development/src/coreComponents/Component.js.map +1 -1
  75. package/dist/development/src/coreComponents/DataBindingProvider.cjs +4 -14
  76. package/dist/development/src/coreComponents/DataBindingProvider.cjs.map +1 -1
  77. package/dist/development/src/coreComponents/DataBindingProvider.js +4 -14
  78. package/dist/development/src/coreComponents/DataBindingProvider.js.map +1 -1
  79. package/dist/development/src/coreComponents/EntityListSubTree.cjs +5 -14
  80. package/dist/development/src/coreComponents/EntityListSubTree.cjs.map +1 -1
  81. package/dist/development/src/coreComponents/EntityListSubTree.js +5 -14
  82. package/dist/development/src/coreComponents/EntityListSubTree.js.map +1 -1
  83. package/dist/development/src/coreComponents/EntitySubTree.cjs +7 -16
  84. package/dist/development/src/coreComponents/EntitySubTree.cjs.map +1 -1
  85. package/dist/development/src/coreComponents/EntitySubTree.js +7 -16
  86. package/dist/development/src/coreComponents/EntitySubTree.js.map +1 -1
  87. package/dist/development/src/entityEvents/useDerivedField.cjs +3 -3
  88. package/dist/development/src/entityEvents/useDerivedField.cjs.map +1 -1
  89. package/dist/development/src/entityEvents/useDerivedField.js +3 -3
  90. package/dist/development/src/entityEvents/useDerivedField.js.map +1 -1
  91. package/dist/development/src/helperComponents/DeferredSubTrees.cjs +2 -3
  92. package/dist/development/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
  93. package/dist/development/src/helperComponents/DeferredSubTrees.js +3 -4
  94. package/dist/development/src/helperComponents/DeferredSubTrees.js.map +1 -1
  95. package/dist/development/src/helperComponents/FieldView.cjs +1 -1
  96. package/dist/development/src/helperComponents/FieldView.cjs.map +1 -1
  97. package/dist/development/src/helperComponents/FieldView.js +1 -1
  98. package/dist/development/src/helperComponents/FieldView.js.map +1 -1
  99. package/dist/development/src/markers/IncrementalMarkerBuilder.cjs +56 -0
  100. package/dist/development/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
  101. package/dist/development/src/markers/IncrementalMarkerBuilder.js +56 -0
  102. package/dist/development/src/markers/IncrementalMarkerBuilder.js.map +1 -0
  103. package/dist/development/src/markers/MarkerStaticAnalyzer.cjs +110 -0
  104. package/dist/development/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
  105. package/dist/development/src/markers/MarkerStaticAnalyzer.js +110 -0
  106. package/dist/development/src/markers/MarkerStaticAnalyzer.js.map +1 -0
  107. package/dist/development/src/markers/MarkerTreeGenerator.cjs +52 -0
  108. package/dist/development/src/markers/MarkerTreeGenerator.cjs.map +1 -0
  109. package/dist/development/src/markers/MarkerTreeGenerator.js +52 -0
  110. package/dist/development/src/markers/MarkerTreeGenerator.js.map +1 -0
  111. package/dist/production/index.cjs +2 -9
  112. package/dist/production/index.cjs.map +1 -1
  113. package/dist/production/index.js +1 -8
  114. package/dist/production/index.js.map +1 -1
  115. package/dist/production/src/accessorPropagation/AccessorProvider.cjs +1 -1
  116. package/dist/production/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
  117. package/dist/production/src/accessorPropagation/AccessorProvider.js +1 -1
  118. package/dist/production/src/accessorPropagation/AccessorProvider.js.map +1 -1
  119. package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
  120. package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
  121. package/dist/production/src/accessorPropagation/BindingOperationsContext.js +2 -1
  122. package/dist/production/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
  123. package/dist/production/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  124. package/dist/production/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  125. package/dist/production/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
  126. package/dist/production/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
  127. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
  128. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  129. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
  130. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  131. package/dist/production/src/accessorPropagation/useEntity.cjs +4 -4
  132. package/dist/production/src/accessorPropagation/useEntity.cjs.map +1 -1
  133. package/dist/production/src/accessorPropagation/useEntity.js +4 -4
  134. package/dist/production/src/accessorPropagation/useEntity.js.map +1 -1
  135. package/dist/production/src/accessorPropagation/useEntityKey.cjs.map +1 -1
  136. package/dist/production/src/accessorPropagation/useEntityKey.js.map +1 -1
  137. package/dist/production/src/accessorPropagation/useEntityList.cjs +3 -3
  138. package/dist/production/src/accessorPropagation/useEntityList.cjs.map +1 -1
  139. package/dist/production/src/accessorPropagation/useEntityList.js +3 -3
  140. package/dist/production/src/accessorPropagation/useEntityList.js.map +1 -1
  141. package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
  142. package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
  143. package/dist/production/src/accessorPropagation/useEntityListSubTree.js +1 -1
  144. package/dist/production/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
  145. package/dist/production/src/accessorPropagation/useEntitySubTree.cjs +1 -1
  146. package/dist/production/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
  147. package/dist/production/src/accessorPropagation/useEntitySubTree.js +1 -1
  148. package/dist/production/src/accessorPropagation/useEntitySubTree.js.map +1 -1
  149. package/dist/production/src/accessorPropagation/useField.cjs +3 -3
  150. package/dist/production/src/accessorPropagation/useField.cjs.map +1 -1
  151. package/dist/production/src/accessorPropagation/useField.js +3 -3
  152. package/dist/production/src/accessorPropagation/useField.js.map +1 -1
  153. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
  154. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
  155. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
  156. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  157. package/dist/production/src/accessorSorting/addEntityAtIndex.cjs +1 -1
  158. package/dist/production/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
  159. package/dist/production/src/accessorSorting/addEntityAtIndex.js +1 -1
  160. package/dist/production/src/accessorSorting/addEntityAtIndex.js.map +1 -1
  161. package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
  162. package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
  163. package/dist/production/src/accessorSorting/repairEntitiesOrder.js +1 -1
  164. package/dist/production/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
  165. package/dist/production/src/accessorSorting/sortEntities.cjs +2 -2
  166. package/dist/production/src/accessorSorting/sortEntities.cjs.map +1 -1
  167. package/dist/production/src/accessorSorting/sortEntities.js +2 -2
  168. package/dist/production/src/accessorSorting/sortEntities.js.map +1 -1
  169. package/dist/production/src/accessorTree/AccessorTree.cjs +3 -1
  170. package/dist/production/src/accessorTree/AccessorTree.cjs.map +1 -1
  171. package/dist/production/src/accessorTree/AccessorTree.js +3 -1
  172. package/dist/production/src/accessorTree/AccessorTree.js.map +1 -1
  173. package/dist/production/src/accessorTree/useDataBinding.cjs +23 -36
  174. package/dist/production/src/accessorTree/useDataBinding.cjs.map +1 -1
  175. package/dist/production/src/accessorTree/useDataBinding.js +26 -39
  176. package/dist/production/src/accessorTree/useDataBinding.js.map +1 -1
  177. package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
  178. package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
  179. package/dist/production/src/accessorTree/useEnvironmentWithSchema.js +31 -0
  180. package/dist/production/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
  181. package/dist/production/src/coreComponents/Component.cjs.map +1 -1
  182. package/dist/production/src/coreComponents/Component.js.map +1 -1
  183. package/dist/production/src/coreComponents/DataBindingProvider.cjs +3 -5
  184. package/dist/production/src/coreComponents/DataBindingProvider.cjs.map +1 -1
  185. package/dist/production/src/coreComponents/DataBindingProvider.js +3 -5
  186. package/dist/production/src/coreComponents/DataBindingProvider.js.map +1 -1
  187. package/dist/production/src/coreComponents/EntityListSubTree.cjs +2 -11
  188. package/dist/production/src/coreComponents/EntityListSubTree.cjs.map +1 -1
  189. package/dist/production/src/coreComponents/EntityListSubTree.js +2 -11
  190. package/dist/production/src/coreComponents/EntityListSubTree.js.map +1 -1
  191. package/dist/production/src/coreComponents/EntitySubTree.cjs +2 -11
  192. package/dist/production/src/coreComponents/EntitySubTree.cjs.map +1 -1
  193. package/dist/production/src/coreComponents/EntitySubTree.js +2 -11
  194. package/dist/production/src/coreComponents/EntitySubTree.js.map +1 -1
  195. package/dist/production/src/entityEvents/useDerivedField.cjs +3 -3
  196. package/dist/production/src/entityEvents/useDerivedField.cjs.map +1 -1
  197. package/dist/production/src/entityEvents/useDerivedField.js +3 -3
  198. package/dist/production/src/entityEvents/useDerivedField.js.map +1 -1
  199. package/dist/production/src/helperComponents/DeferredSubTrees.cjs +2 -3
  200. package/dist/production/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
  201. package/dist/production/src/helperComponents/DeferredSubTrees.js +3 -4
  202. package/dist/production/src/helperComponents/DeferredSubTrees.js.map +1 -1
  203. package/dist/production/src/helperComponents/FieldView.cjs +1 -1
  204. package/dist/production/src/helperComponents/FieldView.cjs.map +1 -1
  205. package/dist/production/src/helperComponents/FieldView.js +1 -1
  206. package/dist/production/src/helperComponents/FieldView.js.map +1 -1
  207. package/dist/production/src/markers/IncrementalMarkerBuilder.cjs +56 -0
  208. package/dist/production/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
  209. package/dist/production/src/markers/IncrementalMarkerBuilder.js +56 -0
  210. package/dist/production/src/markers/IncrementalMarkerBuilder.js.map +1 -0
  211. package/dist/production/src/markers/MarkerStaticAnalyzer.cjs +110 -0
  212. package/dist/production/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
  213. package/dist/production/src/markers/MarkerStaticAnalyzer.js +110 -0
  214. package/dist/production/src/markers/MarkerStaticAnalyzer.js.map +1 -0
  215. package/dist/production/src/markers/MarkerTreeGenerator.cjs +52 -0
  216. package/dist/production/src/markers/MarkerTreeGenerator.cjs.map +1 -0
  217. package/dist/production/src/markers/MarkerTreeGenerator.js +52 -0
  218. package/dist/production/src/markers/MarkerTreeGenerator.js.map +1 -0
  219. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
  220. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
  221. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +2 -1
  222. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  223. package/dist/types/accessorPropagation/EntityKeyProvider.d.ts +2 -1
  224. package/dist/types/accessorPropagation/EntityKeyProvider.d.ts.map +1 -1
  225. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +2 -2
  226. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  227. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
  228. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
  229. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +7 -12
  230. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -1
  231. package/dist/types/accessorPropagation/useEntityKey.d.ts +2 -1
  232. package/dist/types/accessorPropagation/useEntityKey.d.ts.map +1 -1
  233. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +1 -2
  234. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  235. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
  236. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
  237. package/dist/types/accessorSorting/index.d.ts +0 -2
  238. package/dist/types/accessorSorting/index.d.ts.map +1 -1
  239. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  240. package/dist/types/accessorTree/AccessorTreeState.d.ts +1 -4
  241. package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
  242. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +1 -1
  243. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -1
  244. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -2
  245. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
  246. package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
  247. package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
  248. package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
  249. package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
  250. package/dist/types/accessorTree/index.d.ts +0 -1
  251. package/dist/types/accessorTree/index.d.ts.map +1 -1
  252. package/dist/types/accessorTree/useDataBinding.d.ts +6 -2
  253. package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
  254. package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts +3 -0
  255. package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts.map +1 -0
  256. package/dist/types/coreComponents/Component.d.ts +1 -1
  257. package/dist/types/coreComponents/Component.d.ts.map +1 -1
  258. package/dist/types/coreComponents/DataBindingProvider.d.ts +8 -8
  259. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  260. package/dist/types/coreComponents/Entity.d.ts +1 -1
  261. package/dist/types/coreComponents/Entity.d.ts.map +1 -1
  262. package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
  263. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  264. package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
  265. package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
  266. package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
  267. package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
  268. package/dist/types/coreComponents/index.d.ts +0 -1
  269. package/dist/types/coreComponents/index.d.ts.map +1 -1
  270. package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
  271. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  272. package/dist/types/helperComponents/If.d.ts +1 -1
  273. package/dist/types/helperComponents/If.d.ts.map +1 -1
  274. package/dist/types/helperComponents/LabelMiddleware.d.ts +1 -1
  275. package/dist/types/helperComponents/LabelMiddleware.d.ts.map +1 -1
  276. package/dist/types/helperComponents/StaticRender.d.ts +1 -1
  277. package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
  278. package/dist/types/helperComponents/Variable.d.ts +1 -1
  279. package/dist/types/helperComponents/Variable.d.ts.map +1 -1
  280. package/dist/types/index.d.ts +1 -1
  281. package/dist/types/index.d.ts.map +1 -1
  282. package/dist/types/markers/IncrementalMarkerBuilder.d.ts +5 -0
  283. package/dist/types/markers/IncrementalMarkerBuilder.d.ts.map +1 -0
  284. package/dist/types/{coreComponents → markers}/MarkerProvider.d.ts +1 -2
  285. package/dist/types/markers/MarkerProvider.d.ts.map +1 -0
  286. package/dist/types/markers/MarkerStaticAnalyzer.d.ts +14 -0
  287. package/dist/types/markers/MarkerStaticAnalyzer.d.ts.map +1 -0
  288. package/dist/types/markers/MarkerTreeGenerator.d.ts +10 -0
  289. package/dist/types/markers/MarkerTreeGenerator.d.ts.map +1 -0
  290. package/dist/types/markers/index.d.ts +3 -0
  291. package/dist/types/markers/index.d.ts.map +1 -0
  292. package/dist/types/tsconfig.tsbuildinfo +1 -1
  293. package/package.json +8 -7
  294. package/src/accessorPropagation/AccessorProvider.tsx +1 -1
  295. package/src/accessorPropagation/BindingOperationsContext.ts +1 -0
  296. package/src/accessorPropagation/EntityKeyContext.ts +2 -1
  297. package/src/accessorPropagation/EntityKeyProvider.tsx +2 -1
  298. package/src/accessorPropagation/useAccessorUpdateSubscription.ts +19 -87
  299. package/src/accessorPropagation/useEntity.ts +4 -4
  300. package/src/accessorPropagation/useEntityKey.ts +2 -2
  301. package/src/accessorPropagation/useEntityList.ts +3 -3
  302. package/src/accessorPropagation/useEntityListSubTree.ts +1 -1
  303. package/src/accessorPropagation/useEntitySubTree.ts +3 -4
  304. package/src/accessorPropagation/useField.ts +3 -3
  305. package/src/accessorSorting/SetOrderFieldOnCreate.tsx +2 -2
  306. package/src/accessorSorting/addEntityAtIndex.ts +1 -1
  307. package/src/accessorSorting/index.ts +0 -2
  308. package/src/accessorSorting/repairEntitiesOrder.ts +1 -1
  309. package/src/accessorSorting/sortEntities.ts +2 -2
  310. package/src/accessorTree/AccessorTree.tsx +17 -12
  311. package/src/accessorTree/AccessorTreeState.ts +1 -4
  312. package/src/accessorTree/AccessorTreeStateOptions.ts +0 -2
  313. package/src/accessorTree/index.ts +0 -1
  314. package/src/accessorTree/useDataBinding.ts +35 -44
  315. package/src/accessorTree/useEnvironmentWithSchema.ts +31 -0
  316. package/src/coreComponents/Component.tsx +2 -2
  317. package/src/coreComponents/DataBindingProvider.tsx +22 -35
  318. package/src/coreComponents/EntityListSubTree.tsx +4 -18
  319. package/src/coreComponents/EntitySubTree.tsx +5 -20
  320. package/src/coreComponents/index.ts +0 -1
  321. package/src/entityEvents/useDerivedField.ts +3 -3
  322. package/src/helperComponents/DeferredSubTrees.tsx +1 -5
  323. package/src/helperComponents/FieldView.tsx +1 -1
  324. package/src/index.ts +1 -1
  325. package/src/markers/IncrementalMarkerBuilder.ts +60 -0
  326. package/src/{coreComponents → markers}/MarkerProvider.ts +2 -2
  327. package/src/markers/MarkerStaticAnalyzer.ts +132 -0
  328. package/src/markers/MarkerTreeGenerator.ts +72 -0
  329. package/src/markers/index.ts +2 -0
  330. package/src/tsconfig.json +2 -1
  331. package/src/typings/react-fix.d.ts +12 -0
  332. package/tests/cases/unit/model/markerTreeGenerator.spec.tsx +44 -9
  333. package/tests/lib/bindingFactory.ts +1 -1
  334. package/dist/development/src/MarkerTreeGenerator.cjs +0 -89
  335. package/dist/development/src/MarkerTreeGenerator.cjs.map +0 -1
  336. package/dist/development/src/MarkerTreeGenerator.js +0 -89
  337. package/dist/development/src/MarkerTreeGenerator.js.map +0 -1
  338. package/dist/development/src/accessorSorting/errors.cjs +0 -10
  339. package/dist/development/src/accessorSorting/errors.cjs.map +0 -1
  340. package/dist/development/src/accessorSorting/errors.js +0 -10
  341. package/dist/development/src/accessorSorting/errors.js.map +0 -1
  342. package/dist/development/src/accessorSorting/moveEntity.cjs +0 -42
  343. package/dist/development/src/accessorSorting/moveEntity.cjs.map +0 -1
  344. package/dist/development/src/accessorSorting/moveEntity.js +0 -42
  345. package/dist/development/src/accessorSorting/moveEntity.js.map +0 -1
  346. package/dist/development/src/accessorSorting/useSortedEntities.cjs +0 -80
  347. package/dist/development/src/accessorSorting/useSortedEntities.cjs.map +0 -1
  348. package/dist/development/src/accessorSorting/useSortedEntities.js +0 -80
  349. package/dist/development/src/accessorSorting/useSortedEntities.js.map +0 -1
  350. package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
  351. package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
  352. package/dist/development/src/accessorTree/accessorTreeStateReducer.js +0 -34
  353. package/dist/development/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
  354. package/dist/development/src/core/IncrementalMarkerBuilder.cjs +0 -63
  355. package/dist/development/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
  356. package/dist/development/src/core/IncrementalMarkerBuilder.js +0 -63
  357. package/dist/development/src/core/IncrementalMarkerBuilder.js.map +0 -1
  358. package/dist/production/src/MarkerTreeGenerator.cjs +0 -89
  359. package/dist/production/src/MarkerTreeGenerator.cjs.map +0 -1
  360. package/dist/production/src/MarkerTreeGenerator.js +0 -89
  361. package/dist/production/src/MarkerTreeGenerator.js.map +0 -1
  362. package/dist/production/src/accessorSorting/errors.cjs +0 -10
  363. package/dist/production/src/accessorSorting/errors.cjs.map +0 -1
  364. package/dist/production/src/accessorSorting/errors.js +0 -10
  365. package/dist/production/src/accessorSorting/errors.js.map +0 -1
  366. package/dist/production/src/accessorSorting/moveEntity.cjs +0 -42
  367. package/dist/production/src/accessorSorting/moveEntity.cjs.map +0 -1
  368. package/dist/production/src/accessorSorting/moveEntity.js +0 -42
  369. package/dist/production/src/accessorSorting/moveEntity.js.map +0 -1
  370. package/dist/production/src/accessorSorting/useSortedEntities.cjs +0 -80
  371. package/dist/production/src/accessorSorting/useSortedEntities.cjs.map +0 -1
  372. package/dist/production/src/accessorSorting/useSortedEntities.js +0 -80
  373. package/dist/production/src/accessorSorting/useSortedEntities.js.map +0 -1
  374. package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
  375. package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
  376. package/dist/production/src/accessorTree/accessorTreeStateReducer.js +0 -34
  377. package/dist/production/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
  378. package/dist/production/src/core/IncrementalMarkerBuilder.cjs +0 -63
  379. package/dist/production/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
  380. package/dist/production/src/core/IncrementalMarkerBuilder.js +0 -63
  381. package/dist/production/src/core/IncrementalMarkerBuilder.js.map +0 -1
  382. package/dist/types/MarkerTreeGenerator.d.ts +0 -14
  383. package/dist/types/MarkerTreeGenerator.d.ts.map +0 -1
  384. package/dist/types/accessorSorting/errors.d.ts +0 -3
  385. package/dist/types/accessorSorting/errors.d.ts.map +0 -1
  386. package/dist/types/accessorSorting/moveEntity.d.ts +0 -4
  387. package/dist/types/accessorSorting/moveEntity.d.ts.map +0 -1
  388. package/dist/types/accessorSorting/useSortedEntities.d.ts +0 -5
  389. package/dist/types/accessorSorting/useSortedEntities.d.ts.map +0 -1
  390. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts +0 -4
  391. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +0 -1
  392. package/dist/types/core/IncrementalMarkerBuilder.d.ts +0 -7
  393. package/dist/types/core/IncrementalMarkerBuilder.d.ts.map +0 -1
  394. package/dist/types/coreComponents/MarkerProvider.d.ts.map +0 -1
  395. package/src/MarkerTreeGenerator.ts +0 -121
  396. package/src/accessorSorting/errors.ts +0 -9
  397. package/src/accessorSorting/moveEntity.ts +0 -65
  398. package/src/accessorSorting/useSortedEntities.ts +0 -102
  399. package/src/accessorTree/accessorTreeStateReducer.ts +0 -36
  400. package/src/core/IncrementalMarkerBuilder.ts +0 -64
@@ -0,0 +1,31 @@
1
+ import { useState, useEffect, useMemo } from "react";
2
+ import { SchemaLoader } from "@contember/binding";
3
+ import { GraphQlClientError } from "@contember/graphql-client";
4
+ import { useCurrentContentGraphQlClient } from "@contember/react-client";
5
+ const useEnvironmentWithSchema = (env) => {
6
+ const [schema, setSchema] = useState(() => env.hasSchema() ? env.getSchema() : void 0);
7
+ const contentClient = useCurrentContentGraphQlClient();
8
+ useEffect(() => {
9
+ if (schema !== void 0) {
10
+ return;
11
+ }
12
+ (async () => {
13
+ try {
14
+ setSchema(await SchemaLoader.loadSchema(contentClient));
15
+ } catch (e) {
16
+ if (e instanceof GraphQlClientError) {
17
+ if (e.type === "aborted") {
18
+ return;
19
+ }
20
+ } else {
21
+ throw e;
22
+ }
23
+ }
24
+ })();
25
+ }, [contentClient, schema]);
26
+ return useMemo(() => schema ? env.withSchema(schema) : void 0, [env, schema]);
27
+ };
28
+ export {
29
+ useEnvironmentWithSchema
30
+ };
31
+ //# sourceMappingURL=useEnvironmentWithSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEnvironmentWithSchema.js","sources":["../../../../../packages/react-binding/src/accessorTree/useEnvironmentWithSchema.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { Environment, Schema, SchemaLoader } from '@contember/binding'\nimport { GraphQlClientError } from '@contember/graphql-client'\nimport { useCurrentContentGraphQlClient } from '@contember/react-client'\n\nexport const useEnvironmentWithSchema = (env: Environment): Environment | undefined => {\n\tconst [schema, setSchema] = useState<Schema | undefined>(() => env.hasSchema() ? env.getSchema() : undefined)\n\tconst contentClient = useCurrentContentGraphQlClient()\n\tuseEffect(() => {\n\t\tif (schema !== undefined) {\n\t\t\treturn\n\t\t}\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tsetSchema(await SchemaLoader.loadSchema(contentClient))\n\n\t\t\t} catch (e) {\n\t\t\t\tif (e instanceof GraphQlClientError) {\n\t\t\t\t\tif (e.type === 'aborted') {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow e\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t}, [contentClient, schema])\n\n\treturn useMemo(() => schema ? env.withSchema(schema) : undefined, [env, schema])\n}\n"],"names":[],"mappings":";;;;AAKa,MAAA,2BAA2B,CAAC,QAA8C;AACtF,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B,MAAM,IAAI,UAAA,IAAc,IAAI,cAAc,MAAS;AAC5G,QAAM,gBAAgB;AACtB,YAAU,MAAM;AACf,QAAI,WAAW,QAAW;AACzB;AAAA,IACD;AAEA,KAAC,YAAY;AACR,UAAA;AACH,kBAAU,MAAM,aAAa,WAAW,aAAa,CAAC;AAAA,eAE9C,GAAG;AACX,YAAI,aAAa,oBAAoB;AAChC,cAAA,EAAE,SAAS,WAAW;AACzB;AAAA,UACD;AAAA,QAAA,OACM;AACA,gBAAA;AAAA,QACP;AAAA,MACD;AAAA,IAAA;EACE,GACD,CAAC,eAAe,MAAM,CAAC;AAEnB,SAAA,QAAQ,MAAM,SAAS,IAAI,WAAW,MAAM,IAAI,QAAW,CAAC,KAAK,MAAM,CAAC;AAChF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Component.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactElement, ReactNode } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { Environment } from '@contember/binding'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from './MarkerProvider'\nimport { assertNever } from '@contember/utilities'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactNode\n\tdisplayName?: string | undefined\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["useEnvironment","augmentedRender","memo","assertNever"],"mappings":";;;;;AA4BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAOA,+BAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfC,UAAAA,mBAAuEC,WAAY,aAAa;AACtGD,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2FC,WAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,UAAU,IAC3B,QAAQ,UAAU;AAAA,IACpB;AAEO,WAAA;AAAA,EACR;AACAC,YAAA,YAAY,OAAO;AACpB;;"}
1
+ {"version":3,"file":"Component.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactNode } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { Environment } from '@contember/binding'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from '../markers'\nimport { assertNever } from '@contember/utilities'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactNode\n\tdisplayName?: string | undefined\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["useEnvironment","augmentedRender","memo","assertNever"],"mappings":";;;;;AA4BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAOA,+BAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfC,UAAAA,mBAAuEC,WAAY,aAAa;AACtGD,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2FC,WAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,UAAU,IAC3B,QAAQ,UAAU;AAAA,IACpB;AAEO,WAAA;AAAA,EACR;AACAC,YAAA,YAAY,OAAO;AACpB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../../../../../packages/react-binding/src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactElement, ReactNode } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { Environment } from '@contember/binding'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from './MarkerProvider'\nimport { assertNever } from '@contember/utilities'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactNode\n\tdisplayName?: string | undefined\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["augmentedRender"],"mappings":";;;AA4BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAO,gBAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfA,UAAAA,mBAAuE,KAAY,aAAa;AACtGA,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2F,KAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,UAAU,IAC3B,QAAQ,UAAU;AAAA,IACpB;AAEO,WAAA;AAAA,EACR;AACA,cAAY,OAAO;AACpB;"}
1
+ {"version":3,"file":"Component.js","sources":["../../../../../packages/react-binding/src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactNode } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { Environment } from '@contember/binding'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from '../markers'\nimport { assertNever } from '@contember/utilities'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactNode\n\tdisplayName?: string | undefined\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactNode)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["augmentedRender"],"mappings":";;;AA4BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAO,gBAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfA,UAAAA,mBAAuE,KAAY,aAAa;AACtGA,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2F,KAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,UAAU,IAC3B,QAAQ,UAAU;AAAA,IACpB;AAEO,WAAA;AAAA,EACR;AACA,cAAY,OAAO;AACpB;"}
@@ -2,21 +2,19 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const EntityKeyContext = require("../accessorPropagation/EntityKeyContext.cjs");
6
5
  const useDataBinding = require("../accessorTree/useDataBinding.cjs");
7
- const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
8
6
  const AccessorTree = require("../accessorTree/AccessorTree.cjs");
9
7
  const DataBindingProvider = React.memo(function DataBindingProvider2(props) {
10
8
  const accessorTreeState = useDataBinding.useDataBinding(props);
11
- const children = "stateComponent" in props && props.stateComponent ? React.createElement(
9
+ const children = React.createElement(
12
10
  props.stateComponent,
13
11
  {
14
12
  ...props.stateProps,
15
13
  accessorTreeState
16
14
  },
17
15
  props.children
18
- ) : props.children;
19
- return /* @__PURE__ */ jsxRuntime.jsx(TreeRootIdProvider.TreeRootIdProvider, { treeRootId: void 0, children: /* @__PURE__ */ jsxRuntime.jsx(EntityKeyContext.EntityKeyContext.Provider, { value: void 0, children: /* @__PURE__ */ jsxRuntime.jsx(AccessorTree.AccessorTree, { state: accessorTreeState, children }) }) });
16
+ );
17
+ return /* @__PURE__ */ jsxRuntime.jsx(AccessorTree.AccessorTree, { state: accessorTreeState, children });
20
18
  });
21
19
  exports.DataBindingProvider = DataBindingProvider;
22
20
  //# sourceMappingURL=DataBindingProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataBindingProvider.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\nimport { TreeRootIdProvider } from '../accessorPropagation'\nimport { EntityKeyContext } from '../accessorPropagation/EntityKeyContext'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never\n\t\tstateProps?: never\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\tprops.stateComponent,\n\t\t\t\t{\n\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t},\n\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn (\n\t\t<TreeRootIdProvider treeRootId={undefined}>\n\t\t\t<EntityKeyContext.Provider value={undefined}>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t{children}\n\t\t\t\t</AccessorTree>\n\t\t\t</EntityKeyContext.Provider>\n\t\t</TreeRootIdProvider>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["memo","DataBindingProvider","useDataBinding","createElement","TreeRootIdProvider","jsx","EntityKeyContext","AccessorTree"],"mappings":";;;;;;;;AAsCO,MAAM,sBAAsBA,MAAA,KAAK,SAASC,qBAChD,OACC;AACK,QAAA,oBAAoBC,8BAAe,KAAK;AAE9C,QAAM,WACL,oBAAoB,SAAS,MAAM,iBAChCC,MAAA;AAAA,IACD,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA,IAEL,MAAM;AACV,wCACEC,uCAAmB,EAAA,YAAY,QAC/B,UAAAC,2BAAA,IAACC,kCAAiB,UAAjB,EAA0B,OAAO,QACjC,yCAACC,aAAAA,cAAa,EAAA,OAAO,mBACnB,SACF,CAAA,GACD,EACD,CAAA;AAEF,CAAC;;"}
1
+ {"version":3,"file":"DataBindingProvider.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderStateComponent<StateProps> = {\n\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\tstateProps?: StateProps\n}\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& {\n\t\trefreshOnPersist?: boolean\n\t\tskipStateUpdateAfterPersist?: boolean\n\t\tchildren?: ReactNode\n\t}\n\t& DataBindingProviderStateComponent<StateProps>\n\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children = createElement(\n\t\tprops.stateComponent,\n\t\t{\n\t\t\t...props.stateProps!,\n\t\t\taccessorTreeState: accessorTreeState,\n\t\t},\n\t\tprops.children,\n\t)\n\treturn (\n\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t{children}\n\t\t</AccessorTree>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["memo","DataBindingProvider","useDataBinding","createElement","jsx","AccessorTree"],"mappings":";;;;;;AAgCO,MAAM,sBAAsBA,MAAA,KAAK,SAASC,qBAChD,OACC;AACK,QAAA,oBAAoBC,8BAAe,KAAK;AAE9C,QAAM,WAAWC,MAAA;AAAA,IAChB,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA;AAEP,SACEC,2BAAAA,IAAAC,aAAAA,cAAA,EAAa,OAAO,mBACnB,SACF,CAAA;AAEF,CAAC;;"}
@@ -1,20 +1,18 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { memo, createElement } from "react";
3
- import { EntityKeyContext } from "../accessorPropagation/EntityKeyContext.js";
4
3
  import { useDataBinding } from "../accessorTree/useDataBinding.js";
5
- import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
6
4
  import { AccessorTree } from "../accessorTree/AccessorTree.js";
7
5
  const DataBindingProvider = memo(function DataBindingProvider2(props) {
8
6
  const accessorTreeState = useDataBinding(props);
9
- const children = "stateComponent" in props && props.stateComponent ? createElement(
7
+ const children = createElement(
10
8
  props.stateComponent,
11
9
  {
12
10
  ...props.stateProps,
13
11
  accessorTreeState
14
12
  },
15
13
  props.children
16
- ) : props.children;
17
- return /* @__PURE__ */ jsx(TreeRootIdProvider, { treeRootId: void 0, children: /* @__PURE__ */ jsx(EntityKeyContext.Provider, { value: void 0, children: /* @__PURE__ */ jsx(AccessorTree, { state: accessorTreeState, children }) }) });
14
+ );
15
+ return /* @__PURE__ */ jsx(AccessorTree, { state: accessorTreeState, children });
18
16
  });
19
17
  export {
20
18
  DataBindingProvider
@@ -1 +1 @@
1
- {"version":3,"file":"DataBindingProvider.js","sources":["../../../../../packages/react-binding/src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\nimport { TreeRootIdProvider } from '../accessorPropagation'\nimport { EntityKeyContext } from '../accessorPropagation/EntityKeyContext'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never\n\t\tstateProps?: never\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\tprops.stateComponent,\n\t\t\t\t{\n\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t},\n\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn (\n\t\t<TreeRootIdProvider treeRootId={undefined}>\n\t\t\t<EntityKeyContext.Provider value={undefined}>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t{children}\n\t\t\t\t</AccessorTree>\n\t\t\t</EntityKeyContext.Provider>\n\t\t</TreeRootIdProvider>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["DataBindingProvider"],"mappings":";;;;;;AAsCO,MAAM,sBAAsB,KAAK,SAASA,qBAChD,OACC;AACK,QAAA,oBAAoB,eAAe,KAAK;AAE9C,QAAM,WACL,oBAAoB,SAAS,MAAM,iBAChC;AAAA,IACD,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA,IAEL,MAAM;AACV,6BACE,oBAAmB,EAAA,YAAY,QAC/B,UAAA,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,QACjC,8BAAC,cAAa,EAAA,OAAO,mBACnB,SACF,CAAA,GACD,EACD,CAAA;AAEF,CAAC;"}
1
+ {"version":3,"file":"DataBindingProvider.js","sources":["../../../../../packages/react-binding/src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderStateComponent<StateProps> = {\n\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\tstateProps?: StateProps\n}\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& {\n\t\trefreshOnPersist?: boolean\n\t\tskipStateUpdateAfterPersist?: boolean\n\t\tchildren?: ReactNode\n\t}\n\t& DataBindingProviderStateComponent<StateProps>\n\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children = createElement(\n\t\tprops.stateComponent,\n\t\t{\n\t\t\t...props.stateProps!,\n\t\t\taccessorTreeState: accessorTreeState,\n\t\t},\n\t\tprops.children,\n\t)\n\treturn (\n\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t{children}\n\t\t</AccessorTree>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["DataBindingProvider"],"mappings":";;;;AAgCO,MAAM,sBAAsB,KAAK,SAASA,qBAChD,OACC;AACK,QAAA,oBAAoB,eAAe,KAAK;AAE9C,QAAM,WAAW;AAAA,IAChB,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA;AAEP,SACE,oBAAA,cAAA,EAAa,OAAO,mBACnB,SACF,CAAA;AAEF,CAAC;"}
@@ -2,24 +2,15 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const reactUtils = require("@contember/react-utils");
5
- const React = require("react");
6
5
  const binding = require("@contember/binding");
7
6
  const Component = require("./Component.cjs");
8
7
  const EntityList = require("./EntityList.cjs");
9
8
  const Field = require("./Field.cjs");
10
- const useGetEntityListSubTree = require("../accessorPropagation/useGetEntityListSubTree.cjs");
11
- const useEntityListSubTreeParameters = require("../accessorPropagation/useEntityListSubTreeParameters.cjs");
12
- const useAccessorUpdateSubscription = require("../accessorPropagation/useAccessorUpdateSubscription.cjs");
9
+ const useEntityListSubTree = require("../accessorPropagation/useEntityListSubTree.cjs");
13
10
  const EntityListSubTree = Component.Component(
14
11
  (props) => {
15
12
  reactUtils.useConstantValueInvariant(props.isCreating, "EntityListSubTree: cannot update isCreating");
16
- const getSubTree = useGetEntityListSubTree.useGetEntityListSubTree();
17
- const parameters = useEntityListSubTreeParameters.useEntityListSubTreeParameters(props);
18
- const getAccessor = React.useCallback(
19
- () => getSubTree(parameters, props.treeRootId),
20
- [getSubTree, parameters, props.treeRootId]
21
- );
22
- const accessor = useAccessorUpdateSubscription.useAccessorUpdateSubscription(getAccessor);
13
+ const accessor = useEntityListSubTree.useEntityListSubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
23
14
  return /* @__PURE__ */ jsxRuntime.jsx(EntityList.EntityList, { ...props, accessor });
24
15
  },
25
16
  {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListSubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useGetEntityListSubTree","useEntityListSubTreeParameters","useCallback","useAccessorUpdateSubscription","jsx","EntityList","MarkerFactory","jsxs","Field","PRIMARY_KEY_NAME","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;;;;AA2CO,MAAM,oBAAoBA,UAAA;AAAA,EAChC,CAAyB,UAA0D;AACxDC,eAAAA,0BAAA,MAAM,YAAY,6CAA6C;AAEzF,UAAM,aAAaC,wBAAAA;AACb,UAAA,aAAaC,8DAA+B,KAAK;AACvD,UAAM,cAAcC,MAAA;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAWC,4DAA8B,WAAW;AAQ1D,WAAQC,2BAAAA,IAAAC,WAAAA,YAAA,EAAY,GAAG,OAAO,SAAoB,CAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAOA,QAAc,cAAA,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAAC,2BAAAA,KAACF,yBAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAACD,2BAAAA,IAAAI,MAAA,OAAA,EAAM,OAAOC,QAAkB,iBAAA,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAC,mCAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"EntityListSubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityListSubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\t\tconst accessor = useEntityListSubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useEntityListSubTree","jsx","EntityList","MarkerFactory","jsxs","Field","PRIMARY_KEY_NAME","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;AAoCO,MAAM,oBAAoBA,UAAA;AAAA,EAChC,CAAyB,UAA0D;AACxDC,eAAAA,0BAAA,MAAM,YAAY,6CAA6C;AACnF,UAAA,WAAWC,qBAAAA,qBAAqB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAQ1F,WAAQC,2BAAAA,IAAAC,WAAAA,YAAA,EAAY,GAAG,OAAO,SAAoB,CAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAOA,QAAc,cAAA,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAAC,2BAAAA,KAACF,yBAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAACD,2BAAAA,IAAAI,MAAA,OAAA,EAAM,OAAOC,QAAkB,iBAAA,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAC,mCAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -1,23 +1,14 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useConstantValueInvariant } from "@contember/react-utils";
3
- import { useCallback } from "react";
4
3
  import { MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from "@contember/binding";
5
4
  import { Component } from "./Component.js";
6
5
  import { EntityList } from "./EntityList.js";
7
6
  import { Field } from "./Field.js";
8
- import { useGetEntityListSubTree } from "../accessorPropagation/useGetEntityListSubTree.js";
9
- import { useEntityListSubTreeParameters } from "../accessorPropagation/useEntityListSubTreeParameters.js";
10
- import { useAccessorUpdateSubscription } from "../accessorPropagation/useAccessorUpdateSubscription.js";
7
+ import { useEntityListSubTree } from "../accessorPropagation/useEntityListSubTree.js";
11
8
  const EntityListSubTree = Component(
12
9
  (props) => {
13
10
  useConstantValueInvariant(props.isCreating, "EntityListSubTree: cannot update isCreating");
14
- const getSubTree = useGetEntityListSubTree();
15
- const parameters = useEntityListSubTreeParameters(props);
16
- const getAccessor = useCallback(
17
- () => getSubTree(parameters, props.treeRootId),
18
- [getSubTree, parameters, props.treeRootId]
19
- );
20
- const accessor = useAccessorUpdateSubscription(getAccessor);
11
+ const accessor = useEntityListSubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
21
12
  return /* @__PURE__ */ jsx(EntityList, { ...props, accessor });
22
13
  },
23
14
  {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListSubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;AA2CO,MAAM,oBAAoB;AAAA,EAChC,CAAyB,UAA0D;AACxD,8BAAA,MAAM,YAAY,6CAA6C;AAEzF,UAAM,aAAa;AACb,UAAA,aAAa,+BAA+B,KAAK;AACvD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,oBAAA,YAAA,EAAY,GAAG,OAAO,SAAoB,CAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,cAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"EntityListSubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityListSubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\t\tconst accessor = useEntityListSubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;AAoCO,MAAM,oBAAoB;AAAA,EAChC,CAAyB,UAA0D;AACxD,8BAAA,MAAM,YAAY,6CAA6C;AACnF,UAAA,WAAW,qBAAqB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAQ1F,WAAQ,oBAAA,YAAA,EAAY,GAAG,OAAO,SAAoB,CAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,cAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -2,25 +2,16 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const reactUtils = require("@contember/react-utils");
5
- const React = require("react");
6
5
  const binding = require("@contember/binding");
7
6
  const Component = require("./Component.cjs");
8
7
  const Entity = require("./Entity.cjs");
9
8
  const Field = require("./Field.cjs");
10
9
  const SetOrderFieldOnCreate = require("../accessorSorting/SetOrderFieldOnCreate.cjs");
11
- const useGetEntitySubTree = require("../accessorPropagation/useGetEntitySubTree.cjs");
12
- const useEntitySubTreeParameters = require("../accessorPropagation/useEntitySubTreeParameters.cjs");
13
- const useAccessorUpdateSubscription = require("../accessorPropagation/useAccessorUpdateSubscription.cjs");
10
+ const useEntitySubTree = require("../accessorPropagation/useEntitySubTree.cjs");
14
11
  const EntitySubTree = Component.Component(
15
12
  (props) => {
16
13
  reactUtils.useConstantValueInvariant(props.isCreating, "EntitySubTree: cannot update isCreating");
17
- const getSubTree = useGetEntitySubTree.useGetEntitySubTree();
18
- const parameters = useEntitySubTreeParameters.useEntitySubTreeParameters(props);
19
- const getAccessor = React.useCallback(
20
- () => getSubTree(parameters, props.treeRootId),
21
- [getSubTree, parameters, props.treeRootId]
22
- );
23
- const accessor = useAccessorUpdateSubscription.useAccessorUpdateSubscription(getAccessor);
14
+ const accessor = useEntitySubTree.useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
24
15
  return /* @__PURE__ */ jsxRuntime.jsx(Entity.Entity, { ...props, accessor });
25
16
  },
26
17
  {
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useGetEntitySubTree","useEntitySubTreeParameters","useCallback","useAccessorUpdateSubscription","jsx","Entity","MarkerFactory","jsxs","Fragment","Field","PRIMARY_KEY_NAME","SetOrderFieldOnCreate","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;;;;;AA4CO,MAAM,gBAAgBA,UAAA;AAAA,EAC5B,CAAyB,UAA2C;AACzCC,eAAAA,0BAAA,MAAM,YAAY,yCAAyC;AAErF,UAAM,aAAaC,oBAAAA;AACb,UAAA,aAAaC,sDAA2B,KAAK;AACnD,UAAM,cAAcC,MAAA;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAWC,4DAA8B,WAAW;AAQ1D,WAAQC,2BAAAA,IAAAC,OAAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAOA,QAAc,cAAA,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZC,2BAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,MAAAD,2BAAA,KAACF,OAAQ,QAAA,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAACD,2BAAAA,IAAAK,MAAA,OAAA,EAAM,OAAOC,QAAkB,iBAAA,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpCN,2BAAA;AAAA,QAACO,sBAAA;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAC,mCAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"EntitySubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode } from 'react'\nimport { useEntitySubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\t\tconst accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useEntitySubTree","jsx","Entity","MarkerFactory","jsxs","Fragment","Field","PRIMARY_KEY_NAME","SetOrderFieldOnCreate","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;;AAqCO,MAAM,gBAAgBA,UAAA;AAAA,EAC5B,CAAyB,UAA2C;AACzCC,eAAAA,0BAAA,MAAM,YAAY,yCAAyC;AAC/E,UAAA,WAAWC,iBAAAA,iBAAiB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAOtF,WAAQC,2BAAAA,IAAAC,OAAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAOA,QAAc,cAAA,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZC,2BAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,MAAAD,2BAAA,KAACF,OAAQ,QAAA,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAACD,2BAAAA,IAAAK,MAAA,OAAA,EAAM,OAAOC,QAAkB,iBAAA,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpCN,2BAAA;AAAA,QAACO,sBAAA;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAC,mCAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -1,24 +1,15 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useConstantValueInvariant } from "@contember/react-utils";
3
- import { useCallback } from "react";
4
3
  import { MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from "@contember/binding";
5
4
  import { Component } from "./Component.js";
6
5
  import { Entity } from "./Entity.js";
7
6
  import { Field } from "./Field.js";
8
7
  import { SetOrderFieldOnCreate } from "../accessorSorting/SetOrderFieldOnCreate.js";
9
- import { useGetEntitySubTree } from "../accessorPropagation/useGetEntitySubTree.js";
10
- import { useEntitySubTreeParameters } from "../accessorPropagation/useEntitySubTreeParameters.js";
11
- import { useAccessorUpdateSubscription } from "../accessorPropagation/useAccessorUpdateSubscription.js";
8
+ import { useEntitySubTree } from "../accessorPropagation/useEntitySubTree.js";
12
9
  const EntitySubTree = Component(
13
10
  (props) => {
14
11
  useConstantValueInvariant(props.isCreating, "EntitySubTree: cannot update isCreating");
15
- const getSubTree = useGetEntitySubTree();
16
- const parameters = useEntitySubTreeParameters(props);
17
- const getAccessor = useCallback(
18
- () => getSubTree(parameters, props.treeRootId),
19
- [getSubTree, parameters, props.treeRootId]
20
- );
21
- const accessor = useAccessorUpdateSubscription(getAccessor);
12
+ const accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
22
13
  return /* @__PURE__ */ jsx(Entity, { ...props, accessor });
23
14
  },
24
15
  {
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;AA4CO,MAAM,gBAAgB;AAAA,EAC5B,CAAyB,UAA2C;AACzC,8BAAA,MAAM,YAAY,yCAAyC;AAErF,UAAM,aAAa;AACb,UAAA,aAAa,2BAA2B,KAAK;AACnD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAO,cAAc,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZ,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA,qBAAC,QAAQ,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"EntitySubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode } from 'react'\nimport { useEntitySubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\t\tconst accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAqCO,MAAM,gBAAgB;AAAA,EAC5B,CAAyB,UAA2C;AACzC,8BAAA,MAAM,YAAY,yCAAyC;AAC/E,UAAA,WAAW,iBAAiB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAOtF,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAO,cAAc,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZ,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA,qBAAC,QAAQ,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -12,16 +12,16 @@ const useDerivedField = (sourceField, derivedField, transform = identityFunction
12
12
  const stableGetEntityReference = potentiallyStaleParent.getAccessor;
13
13
  const desugaredSource = useDesugaredRelativeSingleField.useDesugaredRelativeSingleField(sourceField);
14
14
  const desugaredDerived = useDesugaredRelativeSingleField.useDesugaredRelativeSingleField(derivedField);
15
- const potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField(desugaredSource);
15
+ const potentiallyStaleSourceAccessor = potentiallyStaleParent.getField(desugaredSource);
16
16
  const stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor;
17
17
  const onBeforeUpdate = React.useCallback(
18
18
  (sourceAccessor) => {
19
19
  stableGetEntityReference().batchUpdates((getAccessor) => {
20
- const derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived);
20
+ const derivedHostEntity = getAccessor().getEntity(desugaredDerived);
21
21
  if (derivedHostEntity.existsOnServer) {
22
22
  return;
23
23
  }
24
- const derivedAccessor = getAccessor().getRelativeSingleField(desugaredDerived);
24
+ const derivedAccessor = getAccessor().getField(desugaredDerived);
25
25
  if (derivedAccessor.isTouched) {
26
26
  return;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useDerivedField.cjs","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getRelativeSingleField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":["useEntityKey","useGetEntityByKey","useDesugaredRelativeSingleField","useCallback","useEffect"],"mappings":";;;;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAYA,aAAAA;AAClB,QAAM,iBAAiBC,kBAAAA;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkBC,gEAAgC,WAAW;AAC7D,QAAA,mBAAmBA,gEAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,uBAAoC,eAAe;AACjH,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiBC,MAAA;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,wBAAwB,gBAAgB;AAEhF,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,uBAAoC,gBAAgB;AAE1F,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9DC,QAAA;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;;"}
1
+ {"version":3,"file":"useDerivedField.cjs","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":["useEntityKey","useGetEntityByKey","useDesugaredRelativeSingleField","useCallback","useEffect"],"mappings":";;;;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAYA,aAAAA;AAClB,QAAM,iBAAiBC,kBAAAA;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkBC,gEAAgC,WAAW;AAC7D,QAAA,mBAAmBA,gEAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,SAAsB,eAAe;AACnG,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiBC,MAAA;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,UAAU,gBAAgB;AAElE,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,SAAsB,gBAAgB;AAE5E,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9DC,QAAA;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;;"}
@@ -10,16 +10,16 @@ const useDerivedField = (sourceField, derivedField, transform = identityFunction
10
10
  const stableGetEntityReference = potentiallyStaleParent.getAccessor;
11
11
  const desugaredSource = useDesugaredRelativeSingleField(sourceField);
12
12
  const desugaredDerived = useDesugaredRelativeSingleField(derivedField);
13
- const potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField(desugaredSource);
13
+ const potentiallyStaleSourceAccessor = potentiallyStaleParent.getField(desugaredSource);
14
14
  const stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor;
15
15
  const onBeforeUpdate = useCallback(
16
16
  (sourceAccessor) => {
17
17
  stableGetEntityReference().batchUpdates((getAccessor) => {
18
- const derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived);
18
+ const derivedHostEntity = getAccessor().getEntity(desugaredDerived);
19
19
  if (derivedHostEntity.existsOnServer) {
20
20
  return;
21
21
  }
22
- const derivedAccessor = getAccessor().getRelativeSingleField(desugaredDerived);
22
+ const derivedAccessor = getAccessor().getField(desugaredDerived);
23
23
  if (derivedAccessor.isTouched) {
24
24
  return;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useDerivedField.js","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getRelativeSingleField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkB,gCAAgC,WAAW;AAC7D,QAAA,mBAAmB,gCAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,uBAAoC,eAAe;AACjH,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiB;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,wBAAwB,gBAAgB;AAEhF,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,uBAAoC,gBAAgB;AAE1F,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9D;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;"}
1
+ {"version":3,"file":"useDerivedField.js","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkB,gCAAgC,WAAW;AAC7D,QAAA,mBAAmB,gCAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,SAAsB,eAAe;AACnG,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiB;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,UAAU,gBAAgB;AAElE,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,SAAsB,gBAAgB;AAE5E,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9D;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;"}
@@ -9,8 +9,8 @@ const useBindingOperations = require("../accessorPropagation/useBindingOperation
9
9
  const useMutationState = require("../accessorTree/useMutationState.cjs");
10
10
  const useHasEntity = require("../accessorPropagation/useHasEntity.cjs");
11
11
  const useEntityBeforePersist = require("../entityEvents/useEntityBeforePersist.cjs");
12
- const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
13
12
  const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
13
+ const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
14
14
  const DeferredSubTrees = Component.Component(
15
15
  (props) => {
16
16
  const { extendTree } = useBindingOperations.useBindingOperations();
@@ -64,8 +64,7 @@ const DeferredSubTrees = Component.Component(
64
64
  ] }),
65
65
  generateBranchMarker: (props, fields, environment) => {
66
66
  const fieldsWithHoistablesMarker = binding.MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
67
- fieldsWithHoistablesMarker.subTrees?.clear();
68
- return fieldsWithHoistablesMarker;
67
+ return new binding.EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, void 0, fieldsWithHoistablesMarker.parentReference);
69
68
  }
70
69
  },
71
70
  "DeferredSubTree"
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["Component","useBindingOperations","useMutationState","useState","useHasEntity","useConstantValueInvariant","useEntityBeforePersist","useCallback","useEffect","useEnvironment","jsx","Fragment","TreeRootIdProvider","jsxs","MarkerFactory","EntityFieldMarkersContainer","EntityFieldsWithHoistablesMarker"],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmBA,UAAA;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAeC,qBAAAA;AACvB,UAAM,aAAaC,iBAAAA;AAEb,UAAA,CAAC,WAAW,YAAY,IAAIC,eAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAIA,MAAAA,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAYC,aAAAA;AAClBC,eAAA,0BAA0B,SAAS;AACnC,QAAI,WAAW;AACdC,6BAAA;AAAA,QACCC,MAAA,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEAC,UAAAA,UAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAcC,eAAAA;AACpBD,UAAAA,UAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAcE,2BAAAA,IAAC,kBAAkB,EAAA,UAAA,MAAM,SAAS,CAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAA,CAAY,CAAC,EACnF,MAAM,CAAS,UAAA;AACf,YAAI,OAAO,SAAS;AACnB;AAAA,QACD;AACM,cAAA;AAAA,MAAA,CACN;AAAA,IAAA,GACA,CAAC,aAAa,YAAY,YAAY,UAAU,MAAM,MAAM,UAAU,MAAM,CAAC;AAEhF,YAAQ,UAAU,MAAM;AAAA,MACvB,KAAK;AAAA,MACL,KAAK;AACG,eAAAA,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAAA,MAC1B,KAAK;AAKJ,8CAAQC,uCAAmB,EAAA,YAAY,UAAU,YAAa,gBAAM,SAAS,CAAA;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AAAA,IACC,cAAc,WAEXC,2BAAA,KAAAF,WAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6BG,QAAA,cAAc,uCAAuC,QAAQ,WAAW;AAM3G,iCAA2B,UAAU;AAE9B,aAAA;AAAA,IACR;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmBd,UAAA;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAcc,QAAc,cAAA,kCAAkC,MAAS;AAE7E,UAAI,kBAAkBC,QAAAA,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAIC,QAAA,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"DeferredSubTrees.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, undefined, fieldsWithHoistablesMarker.parentReference)\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["Component","useBindingOperations","useMutationState","useState","useHasEntity","useConstantValueInvariant","useEntityBeforePersist","useCallback","useEffect","useEnvironment","jsx","Fragment","TreeRootIdProvider","jsxs","MarkerFactory","EntityFieldsWithHoistablesMarker","EntityFieldMarkersContainer"],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmBA,UAAA;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAeC,qBAAAA;AACvB,UAAM,aAAaC,iBAAAA;AAEb,UAAA,CAAC,WAAW,YAAY,IAAIC,eAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAIA,MAAAA,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAYC,aAAAA;AAClBC,eAAA,0BAA0B,SAAS;AACnC,QAAI,WAAW;AACdC,6BAAA;AAAA,QACCC,MAAA,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEAC,UAAAA,UAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAcC,eAAAA;AACpBD,UAAAA,UAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAcE,2BAAAA,IAAC,kBAAkB,EAAA,UAAA,MAAM,SAAS,CAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAA,CAAY,CAAC,EACnF,MAAM,CAAS,UAAA;AACf,YAAI,OAAO,SAAS;AACnB;AAAA,QACD;AACM,cAAA;AAAA,MAAA,CACN;AAAA,IAAA,GACA,CAAC,aAAa,YAAY,YAAY,UAAU,MAAM,MAAM,UAAU,MAAM,CAAC;AAEhF,YAAQ,UAAU,MAAM;AAAA,MACvB,KAAK;AAAA,MACL,KAAK;AACG,eAAAA,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAAA,MAC1B,KAAK;AAKJ,8CAAQC,uCAAmB,EAAA,YAAY,UAAU,YAAa,gBAAM,SAAS,CAAA;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AAAA,IACC,cAAc,WAEXC,2BAAA,KAAAF,WAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6BG,QAAA,cAAc,uCAAuC,QAAQ,WAAW;AAI3G,aAAO,IAAIC,QAAiC,iCAAA,2BAA2B,QAAQ,QAAW,2BAA2B,eAAe;AAAA,IACrI;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmBf,UAAA;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAcc,QAAc,cAAA,kCAAkC,MAAS;AAE7E,UAAI,kBAAkBE,QAAAA,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAID,QAAA,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -1,14 +1,14 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback, useEffect } from "react";
3
- import { MarkerFactory, EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from "@contember/binding";
3
+ import { MarkerFactory, EntityFieldsWithHoistablesMarker, EntityFieldMarkersContainer } from "@contember/binding";
4
4
  import { useConstantValueInvariant } from "@contember/react-utils";
5
5
  import { Component } from "../coreComponents/Component.js";
6
6
  import { useBindingOperations } from "../accessorPropagation/useBindingOperations.js";
7
7
  import { useMutationState } from "../accessorTree/useMutationState.js";
8
8
  import { useHasEntity } from "../accessorPropagation/useHasEntity.js";
9
9
  import { useEntityBeforePersist } from "../entityEvents/useEntityBeforePersist.js";
10
- import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
11
10
  import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
11
+ import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
12
12
  const DeferredSubTrees = Component(
13
13
  (props) => {
14
14
  const { extendTree } = useBindingOperations();
@@ -62,8 +62,7 @@ const DeferredSubTrees = Component(
62
62
  ] }),
63
63
  generateBranchMarker: (props, fields, environment) => {
64
64
  const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
65
- fieldsWithHoistablesMarker.subTrees?.clear();
66
- return fieldsWithHoistablesMarker;
65
+ return new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, void 0, fieldsWithHoistablesMarker.parentReference);
67
66
  }
68
67
  },
69
68
  "DeferredSubTree"
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.js","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEA,cAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAc;AACpB,cAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAc,oBAAC,kBAAkB,EAAA,UAAA,MAAM,SAAS,CAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAA,CAAY,CAAC,EACnF,MAAM,CAAS,UAAA;AACf,YAAI,OAAO,SAAS;AACnB;AAAA,QACD;AACM,cAAA;AAAA,MAAA,CACN;AAAA,IAAA,GACA,CAAC,aAAa,YAAY,YAAY,UAAU,MAAM,MAAM,UAAU,MAAM,CAAC;AAEhF,YAAQ,UAAU,MAAM;AAAA,MACvB,KAAK;AAAA,MACL,KAAK;AACG,eAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAAA,MAC1B,KAAK;AAKJ,mCAAQ,oBAAmB,EAAA,YAAY,UAAU,YAAa,gBAAM,SAAS,CAAA;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AAAA,IACC,cAAc,WAEX,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6B,cAAc,uCAAuC,QAAQ,WAAW;AAM3G,iCAA2B,UAAU;AAE9B,aAAA;AAAA,IACR;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"DeferredSubTrees.js","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, undefined, fieldsWithHoistablesMarker.parentReference)\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEA,cAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAc;AACpB,cAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAc,oBAAC,kBAAkB,EAAA,UAAA,MAAM,SAAS,CAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAA,CAAY,CAAC,EACnF,MAAM,CAAS,UAAA;AACf,YAAI,OAAO,SAAS;AACnB;AAAA,QACD;AACM,cAAA;AAAA,MAAA,CACN;AAAA,IAAA,GACA,CAAC,aAAa,YAAY,YAAY,UAAU,MAAM,MAAM,UAAU,MAAM,CAAC;AAEhF,YAAQ,UAAU,MAAM;AAAA,MACvB,KAAK;AAAA,MACL,KAAK;AACG,eAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAAA,MAC1B,KAAK;AAKJ,mCAAQ,oBAAmB,EAAA,YAAY,UAAU,YAAa,gBAAM,SAAS,CAAA;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AAAA,IACC,cAAc,WAEX,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6B,cAAc,uCAAuC,QAAQ,WAAW;AAI3G,aAAO,IAAI,iCAAiC,2BAA2B,QAAQ,QAAW,2BAA2B,eAAe;AAAA,IACrI;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}