@fluidframework/tree 2.1.0-276326 → 2.1.0-281041

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 (442) hide show
  1. package/.eslintrc.cjs +7 -0
  2. package/.vscode/Tree.code-workspace +7 -1
  3. package/README.md +134 -29
  4. package/api-report/tree.alpha.api.md +1 -0
  5. package/api-report/tree.beta.api.md +1 -0
  6. package/api-report/tree.public.api.md +1 -0
  7. package/beta.d.ts +1 -1
  8. package/dist/beta.d.ts +1 -1
  9. package/dist/core/forest/editableForest.d.ts +6 -3
  10. package/dist/core/forest/editableForest.d.ts.map +1 -1
  11. package/dist/core/forest/editableForest.js +14 -4
  12. package/dist/core/forest/editableForest.js.map +1 -1
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +3 -1
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/rebase/index.d.ts +1 -1
  18. package/dist/core/rebase/index.d.ts.map +1 -1
  19. package/dist/core/rebase/index.js +3 -1
  20. package/dist/core/rebase/index.js.map +1 -1
  21. package/dist/core/rebase/types.d.ts +2 -0
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +9 -1
  24. package/dist/core/rebase/types.js.map +1 -1
  25. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  26. package/dist/core/tree/visitDelta.js.map +1 -1
  27. package/dist/events/events.d.ts +4 -1
  28. package/dist/events/events.d.ts.map +1 -1
  29. package/dist/events/events.js.map +1 -1
  30. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  31. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  32. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  33. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  34. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  35. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  36. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  37. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -20
  38. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -38
  40. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  42. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  43. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  44. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  45. package/dist/feature-libraries/flex-tree/lazyField.d.ts +0 -4
  46. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  47. package/dist/feature-libraries/flex-tree/lazyField.js +1 -14
  48. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  49. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +0 -1
  50. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  51. package/dist/feature-libraries/flex-tree/lazyNode.js +0 -3
  52. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +3 -3
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +2 -2
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
  58. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  59. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  60. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
  61. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
  62. package/dist/feature-libraries/modular-schema/discrepancies.js +264 -0
  63. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -0
  64. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
  65. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  66. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  67. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  68. package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -0
  69. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  70. package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
  71. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  72. package/dist/feature-libraries/modular-schema/index.js +3 -1
  73. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  74. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  75. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  77. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
  78. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +830 -245
  80. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  81. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
  83. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  84. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
  85. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  86. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  87. package/dist/feature-libraries/node-key/index.d.ts +0 -1
  88. package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
  89. package/dist/feature-libraries/node-key/index.js +1 -3
  90. package/dist/feature-libraries/node-key/index.js.map +1 -1
  91. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  92. package/dist/feature-libraries/optional-field/optionalField.js +1 -0
  93. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  94. package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
  95. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/sequence-field/index.js +1 -2
  97. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  98. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  99. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  100. package/dist/feature-libraries/sequence-field/rebase.js +6 -1
  101. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  102. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  103. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -0
  104. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  105. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -17
  106. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  107. package/dist/feature-libraries/sequence-field/utils.js +31 -39
  108. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  109. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
  110. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  111. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +2 -0
  112. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/packageVersion.d.ts +1 -1
  117. package/dist/packageVersion.js +1 -1
  118. package/dist/packageVersion.js.map +1 -1
  119. package/dist/public.d.ts +1 -1
  120. package/dist/shared-tree/schematizingTreeView.d.ts +4 -2
  121. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  122. package/dist/shared-tree/schematizingTreeView.js +240 -184
  123. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  124. package/dist/shared-tree/sharedTree.d.ts +3 -2
  125. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  126. package/dist/shared-tree/sharedTree.js +150 -90
  127. package/dist/shared-tree/sharedTree.js.map +1 -1
  128. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  129. package/dist/shared-tree/treeCheckout.js +2 -1
  130. package/dist/shared-tree/treeCheckout.js.map +1 -1
  131. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  132. package/dist/shared-tree-core/branch.js +1 -0
  133. package/dist/shared-tree-core/branch.js.map +1 -1
  134. package/dist/shared-tree-core/sharedTreeCore.d.ts +4 -6
  135. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  136. package/dist/shared-tree-core/sharedTreeCore.js +265 -209
  137. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  138. package/dist/simple-tree/arrayNode.d.ts +4 -0
  139. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  140. package/dist/simple-tree/arrayNode.js +36 -19
  141. package/dist/simple-tree/arrayNode.js.map +1 -1
  142. package/dist/simple-tree/leafNodeSchema.d.ts +22 -1
  143. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  144. package/dist/simple-tree/leafNodeSchema.js +2 -1
  145. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  146. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  147. package/dist/simple-tree/mapNode.js.map +1 -1
  148. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  149. package/dist/simple-tree/objectNode.js +2 -1
  150. package/dist/simple-tree/objectNode.js.map +1 -1
  151. package/dist/simple-tree/proxies.d.ts.map +1 -1
  152. package/dist/simple-tree/proxies.js +2 -4
  153. package/dist/simple-tree/proxies.js.map +1 -1
  154. package/dist/simple-tree/schemaFactory.d.ts +24 -1
  155. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  156. package/dist/simple-tree/schemaFactory.js +40 -4
  157. package/dist/simple-tree/schemaFactory.js.map +1 -1
  158. package/dist/simple-tree/schemaTypes.d.ts +36 -1
  159. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  160. package/dist/simple-tree/schemaTypes.js.map +1 -1
  161. package/dist/simple-tree/toFlexSchema.d.ts +2 -2
  162. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  163. package/dist/simple-tree/toFlexSchema.js +3 -2
  164. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  165. package/dist/simple-tree/tree.d.ts +4 -1
  166. package/dist/simple-tree/tree.d.ts.map +1 -1
  167. package/dist/simple-tree/tree.js +48 -1
  168. package/dist/simple-tree/tree.js.map +1 -1
  169. package/dist/simple-tree/treeNodeApi.d.ts.map +1 -1
  170. package/dist/simple-tree/treeNodeApi.js +10 -10
  171. package/dist/simple-tree/treeNodeApi.js.map +1 -1
  172. package/dist/simple-tree/types.d.ts +22 -3
  173. package/dist/simple-tree/types.d.ts.map +1 -1
  174. package/dist/simple-tree/types.js +32 -21
  175. package/dist/simple-tree/types.js.map +1 -1
  176. package/dist/util/breakable.d.ts +83 -0
  177. package/dist/util/breakable.d.ts.map +1 -0
  178. package/dist/util/breakable.js +178 -0
  179. package/dist/util/breakable.js.map +1 -0
  180. package/dist/util/index.d.ts +3 -2
  181. package/dist/util/index.d.ts.map +1 -1
  182. package/dist/util/index.js +9 -2
  183. package/dist/util/index.js.map +1 -1
  184. package/dist/util/nestedMap.d.ts +23 -3
  185. package/dist/util/nestedMap.d.ts.map +1 -1
  186. package/dist/util/nestedMap.js +38 -7
  187. package/dist/util/nestedMap.js.map +1 -1
  188. package/dist/util/utils.d.ts +7 -0
  189. package/dist/util/utils.d.ts.map +1 -1
  190. package/dist/util/utils.js +15 -1
  191. package/dist/util/utils.js.map +1 -1
  192. package/docs/README.md +1 -1
  193. package/docs/main/compatibility.md +1 -1
  194. package/docs/main/stored-and-view-schema.md +1 -1
  195. package/internal.d.ts +1 -1
  196. package/lib/beta.d.ts +1 -1
  197. package/lib/core/forest/editableForest.d.ts +6 -3
  198. package/lib/core/forest/editableForest.d.ts.map +1 -1
  199. package/lib/core/forest/editableForest.js +15 -5
  200. package/lib/core/forest/editableForest.js.map +1 -1
  201. package/lib/core/index.d.ts +1 -1
  202. package/lib/core/index.d.ts.map +1 -1
  203. package/lib/core/index.js +1 -1
  204. package/lib/core/index.js.map +1 -1
  205. package/lib/core/rebase/index.d.ts +1 -1
  206. package/lib/core/rebase/index.d.ts.map +1 -1
  207. package/lib/core/rebase/index.js +1 -1
  208. package/lib/core/rebase/index.js.map +1 -1
  209. package/lib/core/rebase/types.d.ts +2 -0
  210. package/lib/core/rebase/types.d.ts.map +1 -1
  211. package/lib/core/rebase/types.js +7 -1
  212. package/lib/core/rebase/types.js.map +1 -1
  213. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  214. package/lib/core/tree/visitDelta.js.map +1 -1
  215. package/lib/events/events.d.ts +4 -1
  216. package/lib/events/events.d.ts.map +1 -1
  217. package/lib/events/events.js.map +1 -1
  218. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  219. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  220. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  221. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  222. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  223. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  224. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  225. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +0 -20
  226. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  227. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -38
  228. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  229. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  230. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  231. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  232. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  233. package/lib/feature-libraries/flex-tree/lazyField.d.ts +0 -4
  234. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  235. package/lib/feature-libraries/flex-tree/lazyField.js +1 -14
  236. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  237. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +0 -1
  238. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  239. package/lib/feature-libraries/flex-tree/lazyNode.js +0 -3
  240. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  241. package/lib/feature-libraries/index.d.ts +3 -3
  242. package/lib/feature-libraries/index.d.ts.map +1 -1
  243. package/lib/feature-libraries/index.js +2 -2
  244. package/lib/feature-libraries/index.js.map +1 -1
  245. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
  246. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  247. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  248. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
  249. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
  250. package/lib/feature-libraries/modular-schema/discrepancies.js +260 -0
  251. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -0
  252. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
  253. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  254. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  255. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  256. package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -0
  257. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  258. package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
  259. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  260. package/lib/feature-libraries/modular-schema/index.js +1 -0
  261. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  262. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  263. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
  264. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  265. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
  266. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  267. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +829 -247
  268. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  269. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  270. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
  271. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  272. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
  273. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  274. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  275. package/lib/feature-libraries/node-key/index.d.ts +0 -1
  276. package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
  277. package/lib/feature-libraries/node-key/index.js +0 -1
  278. package/lib/feature-libraries/node-key/index.js.map +1 -1
  279. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  280. package/lib/feature-libraries/optional-field/optionalField.js +1 -0
  281. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  282. package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
  283. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  284. package/lib/feature-libraries/sequence-field/index.js +1 -1
  285. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  286. package/lib/feature-libraries/sequence-field/invert.js +1 -1
  287. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  288. package/lib/feature-libraries/sequence-field/rebase.js +6 -1
  289. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  290. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  291. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
  292. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  293. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -17
  294. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  295. package/lib/feature-libraries/sequence-field/utils.js +31 -39
  296. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  297. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
  298. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  299. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +4 -2
  300. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  301. package/lib/index.d.ts +1 -1
  302. package/lib/index.d.ts.map +1 -1
  303. package/lib/index.js.map +1 -1
  304. package/lib/packageVersion.d.ts +1 -1
  305. package/lib/packageVersion.js +1 -1
  306. package/lib/packageVersion.js.map +1 -1
  307. package/lib/public.d.ts +1 -1
  308. package/lib/shared-tree/schematizingTreeView.d.ts +4 -2
  309. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  310. package/lib/shared-tree/schematizingTreeView.js +242 -185
  311. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  312. package/lib/shared-tree/sharedTree.d.ts +3 -2
  313. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  314. package/lib/shared-tree/sharedTree.js +151 -90
  315. package/lib/shared-tree/sharedTree.js.map +1 -1
  316. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  317. package/lib/shared-tree/treeCheckout.js +2 -1
  318. package/lib/shared-tree/treeCheckout.js.map +1 -1
  319. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  320. package/lib/shared-tree-core/branch.js +1 -0
  321. package/lib/shared-tree-core/branch.js.map +1 -1
  322. package/lib/shared-tree-core/sharedTreeCore.d.ts +4 -6
  323. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  324. package/lib/shared-tree-core/sharedTreeCore.js +267 -210
  325. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  326. package/lib/simple-tree/arrayNode.d.ts +4 -0
  327. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  328. package/lib/simple-tree/arrayNode.js +38 -21
  329. package/lib/simple-tree/arrayNode.js.map +1 -1
  330. package/lib/simple-tree/leafNodeSchema.d.ts +22 -1
  331. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  332. package/lib/simple-tree/leafNodeSchema.js +1 -1
  333. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  334. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  335. package/lib/simple-tree/mapNode.js.map +1 -1
  336. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  337. package/lib/simple-tree/objectNode.js +3 -2
  338. package/lib/simple-tree/objectNode.js.map +1 -1
  339. package/lib/simple-tree/proxies.d.ts.map +1 -1
  340. package/lib/simple-tree/proxies.js +2 -4
  341. package/lib/simple-tree/proxies.js.map +1 -1
  342. package/lib/simple-tree/schemaFactory.d.ts +24 -1
  343. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  344. package/lib/simple-tree/schemaFactory.js +38 -3
  345. package/lib/simple-tree/schemaFactory.js.map +1 -1
  346. package/lib/simple-tree/schemaTypes.d.ts +36 -1
  347. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  348. package/lib/simple-tree/schemaTypes.js.map +1 -1
  349. package/lib/simple-tree/toFlexSchema.d.ts +2 -2
  350. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  351. package/lib/simple-tree/toFlexSchema.js +3 -2
  352. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  353. package/lib/simple-tree/tree.d.ts +4 -1
  354. package/lib/simple-tree/tree.d.ts.map +1 -1
  355. package/lib/simple-tree/tree.js +44 -0
  356. package/lib/simple-tree/tree.js.map +1 -1
  357. package/lib/simple-tree/treeNodeApi.d.ts.map +1 -1
  358. package/lib/simple-tree/treeNodeApi.js +11 -11
  359. package/lib/simple-tree/treeNodeApi.js.map +1 -1
  360. package/lib/simple-tree/types.d.ts +22 -3
  361. package/lib/simple-tree/types.d.ts.map +1 -1
  362. package/lib/simple-tree/types.js +32 -21
  363. package/lib/simple-tree/types.js.map +1 -1
  364. package/lib/util/breakable.d.ts +83 -0
  365. package/lib/util/breakable.d.ts.map +1 -0
  366. package/lib/util/breakable.js +171 -0
  367. package/lib/util/breakable.js.map +1 -0
  368. package/lib/util/index.d.ts +3 -2
  369. package/lib/util/index.d.ts.map +1 -1
  370. package/lib/util/index.js +3 -2
  371. package/lib/util/index.js.map +1 -1
  372. package/lib/util/nestedMap.d.ts +23 -3
  373. package/lib/util/nestedMap.d.ts.map +1 -1
  374. package/lib/util/nestedMap.js +36 -6
  375. package/lib/util/nestedMap.js.map +1 -1
  376. package/lib/util/utils.d.ts +7 -0
  377. package/lib/util/utils.d.ts.map +1 -1
  378. package/lib/util/utils.js +13 -0
  379. package/lib/util/utils.js.map +1 -1
  380. package/package.json +29 -27
  381. package/src/core/forest/editableForest.ts +17 -4
  382. package/src/core/index.ts +2 -0
  383. package/src/core/rebase/index.ts +2 -0
  384. package/src/core/rebase/types.ts +17 -0
  385. package/src/core/tree/visitDelta.ts +1 -0
  386. package/src/events/events.ts +4 -2
  387. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -1
  388. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
  389. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +0 -30
  390. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -43
  391. package/src/feature-libraries/flex-tree/index.ts +0 -1
  392. package/src/feature-libraries/flex-tree/lazyField.ts +1 -21
  393. package/src/feature-libraries/flex-tree/lazyNode.ts +0 -6
  394. package/src/feature-libraries/index.ts +1 -2
  395. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +18 -0
  396. package/src/feature-libraries/modular-schema/discrepancies.ts +395 -0
  397. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -2
  398. package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -0
  399. package/src/feature-libraries/modular-schema/index.ts +2 -0
  400. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +81 -35
  401. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1529 -454
  402. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +2 -0
  403. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +51 -0
  404. package/src/feature-libraries/node-key/index.ts +0 -1
  405. package/src/feature-libraries/optional-field/optionalField.ts +1 -0
  406. package/src/feature-libraries/sequence-field/index.ts +0 -2
  407. package/src/feature-libraries/sequence-field/invert.ts +1 -1
  408. package/src/feature-libraries/sequence-field/rebase.ts +7 -1
  409. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +2 -1
  410. package/src/feature-libraries/sequence-field/utils.ts +37 -85
  411. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +10 -0
  412. package/src/index.ts +0 -1
  413. package/src/packageVersion.ts +1 -1
  414. package/src/shared-tree/schematizingTreeView.ts +6 -2
  415. package/src/shared-tree/sharedTree.ts +5 -2
  416. package/src/shared-tree/treeCheckout.ts +6 -2
  417. package/src/shared-tree-core/branch.ts +1 -0
  418. package/src/shared-tree-core/sharedTreeCore.ts +18 -6
  419. package/src/simple-tree/arrayNode.ts +49 -22
  420. package/src/simple-tree/leafNodeSchema.ts +1 -1
  421. package/src/simple-tree/mapNode.ts +2 -2
  422. package/src/simple-tree/objectNode.ts +9 -3
  423. package/src/simple-tree/proxies.ts +2 -4
  424. package/src/simple-tree/schemaFactory.ts +45 -2
  425. package/src/simple-tree/schemaTypes.ts +36 -1
  426. package/src/simple-tree/toFlexSchema.ts +5 -4
  427. package/src/simple-tree/tree.ts +65 -4
  428. package/src/simple-tree/treeNodeApi.ts +15 -15
  429. package/src/simple-tree/types.ts +60 -30
  430. package/src/util/breakable.ts +214 -0
  431. package/src/util/index.ts +10 -0
  432. package/src/util/nestedMap.ts +49 -11
  433. package/src/util/utils.ts +17 -0
  434. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
  435. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
  436. package/dist/feature-libraries/node-key/nodeKeyIndex.js +0 -101
  437. package/dist/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
  438. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
  439. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
  440. package/lib/feature-libraries/node-key/nodeKeyIndex.js +0 -97
  441. package/lib/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
  442. package/src/feature-libraries/node-key/nodeKeyIndex.ts +0 -132
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,eAAe,MAAM,yBAAyB,CAAC;AA8BtD;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAI,QAAW;IACvC,OAAO,QAAsB,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAI,CAAyB;IAC3D,+EAA+E;IAC/E,wEAAwE;IACxE,oEAAoE;IACpE,OAAO,KAAK,CAAC,OAAO,CAAC,CA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C,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { Type } from \"@sinclair/typebox\";\nimport structuredClone from \"@ungap/structured-clone\";\n\n/**\n * Subset of Map interface.\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * Make all transitive properties in T readonly\n */\nexport type RecursiveReadonly<T> = {\n\treadonly [P in keyof T]: RecursiveReadonly<T[P]>;\n};\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Make all field required and omits fields whose ony valid value would be `undefined`.\n * This is analogous to `Required<T>` except it tolerates 'optional undefined'.\n */\nexport type Populated<T> = {\n\t[P in keyof T as Exclude<P, T[P] extends undefined ? P : never>]-?: T[P];\n};\n\n/**\n * Casts a readonly object to a mutable one.\n * Better than casting to `Mutable<Foo>` because it doesn't risk casting a non-`Foo` to a `Mutable<Foo>`.\n * @param readonly - The object with readonly fields.\n * @returns The same object but with a type that makes all fields mutable.\n */\nexport function asMutable<T>(readonly: T): Mutable<T> {\n\treturn readonly as Mutable<T>;\n}\n\nexport const clone = structuredClone;\n\n/**\n * @internal\n */\nexport function fail(message: string): never {\n\tthrow new Error(message);\n}\n\n/**\n * Checks whether or not the given object is a `readonly` array.\n *\n * Note that this does NOT indicate if a given array should be treated as readonly.\n * This instead indicates if an object is an Array, and is typed to tolerate the readonly case.\n */\nexport function isReadonlyArray<T>(x: readonly T[] | unknown): x is readonly T[] {\n\t// `Array.isArray()` does not properly narrow `readonly` array types by itself,\n\t// so we wrap it in this type guard. This may become unnecessary if/when\n\t// https://github.com/microsoft/TypeScript/issues/17002 is resolved.\n\treturn Array.isArray(x);\n}\n\n/**\n * Creates and populates a new array.\n * @param size - The size of the array to be created.\n * @param filler - Callback for populating the array with a value for a given index\n */\nexport function makeArray<T>(size: number, filler: (index: number) => T): T[] {\n\tconst array = [];\n\tfor (let i = 0; i < size; ++i) {\n\t\tarray.push(filler(i));\n\t}\n\treturn array;\n}\n\n/**\n * Compares two sets using callbacks.\n * Early returns on first false comparison.\n *\n * @param a - One Set.\n * @param b - The other Set.\n * @param aExtra - Called for items in `a` but not `b`.\n * @param bExtra - Called for items in `b` but not `a`.\n * @param same - Called for items in `a` and `b`.\n * @returns false iff any of the call backs returned false.\n */\nexport function compareSets<T>({\n\ta,\n\tb,\n\taExtra,\n\tbExtra,\n\tsame,\n}: {\n\ta: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\tb: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\taExtra?: (t: T) => boolean;\n\tbExtra?: (t: T) => boolean;\n\tsame?: (t: T) => boolean;\n}): boolean {\n\tfor (const item of a.keys()) {\n\t\tif (!b.has(item)) {\n\t\t\tif (aExtra && !aExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tif (same && !same(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tfor (const item of b.keys()) {\n\t\tif (!a.has(item)) {\n\t\t\tif (bExtra && !bExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Utility for dictionaries whose values are lists.\n * Gets the list associated with the provided key, if it exists.\n * Otherwise, creates an entry with an empty list, and returns that list.\n */\nexport function getOrAddEmptyToMap<K, V>(map: MapGetSet<K, V[]>, key: K): V[] {\n\tlet collection = map.get(key);\n\tif (collection === undefined) {\n\t\tcollection = [];\n\t\tmap.set(key, collection);\n\t}\n\treturn collection;\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Finds the first element in the given iterable that satisfies a predicate.\n * @param iterable - The iterable to search for an eligible element\n * @param predicate - The predicate to run against each element\n * @returns The first element in the iterable that satisfies the predicate, or undefined if the iterable contains no such element\n */\nexport function find<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): T | undefined {\n\tfor (const t of iterable) {\n\t\tif (predicate(t)) {\n\t\t\treturn t;\n\t\t}\n\t}\n}\n\n/**\n * Use for Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @internal\n */\nexport type JsonCompatible =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| JsonCompatible[]\n\t| JsonCompatibleObject;\n\n/**\n * Use for Json object compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @internal\n */\nexport type JsonCompatibleObject = { [P in string]?: JsonCompatible };\n\n/**\n * Use for readonly view of Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n */\nexport type JsonCompatibleReadOnly =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| readonly JsonCompatibleReadOnly[]\n\t| JsonCompatibleReadOnlyObject;\n\n/**\n * Use for readonly view of Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n */\nexport type JsonCompatibleReadOnlyObject = { readonly [P in string]?: JsonCompatibleReadOnly };\n\n/**\n * @remarks TODO: Audit usage of this type in schemas, evaluating whether it is necessary and performance\n * of alternatives.\n *\n * True \"arbitrary serializable data\" is probably fine, but some persisted types declarations might be better\n * expressed using composition of schemas for runtime validation, even if we don't think making the types\n * generic is worth the maintenance cost.\n */\nexport const JsonCompatibleReadOnlySchema = Type.Any();\n\n/**\n * Returns if a particular json compatible value is an object.\n * Does not include `null` or arrays.\n */\nexport function isJsonObject(\n\tvalue: JsonCompatibleReadOnly,\n): value is { readonly [P in string]?: JsonCompatibleReadOnly } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Verifies that the supplied indices are valid within the supplied array.\n * @param startIndex - The starting index in the range. Must be in [0, length).\n * @param endIndex - The ending index in the range. Must be within (start, length].\n * @param array - The array the indices refer to\n */\nexport function assertValidRangeIndices(\n\tstartIndex: number,\n\tendIndex: number,\n\tarray: { readonly length: number },\n): void {\n\tassert(endIndex >= startIndex, 0x79c /* Range indices are malformed. */);\n\tassertValidIndex(startIndex, array, false);\n\tassertValidIndex(endIndex, array, true);\n}\n\nexport function assertValidIndex(\n\tindex: number,\n\tarray: { readonly length: number },\n\tallowOnePastEnd: boolean = false,\n): void {\n\tassertNonNegativeSafeInteger(index);\n\tif (allowOnePastEnd) {\n\t\tassert(index <= array.length, 0x378 /* index must be less than or equal to length */);\n\t} else {\n\t\tassert(index < array.length, 0x379 /* index must be less than length */);\n\t}\n}\n\nexport function assertValidRange(\n\t{ start, end }: { start: number; end: number },\n\tarray: { readonly length: number },\n): void {\n\tassertNonNegativeSafeInteger(start);\n\tassertNonNegativeSafeInteger(end);\n\tassert(end <= array.length, 0x79d /* Range end must be less than or equal to length */);\n\tassert(start <= end, 0x79e /* Range start must be less than or equal to range start */);\n}\n\nexport function assertNonNegativeSafeInteger(index: number): void {\n\tassert(Number.isSafeInteger(index), 0x376 /* index must be an integer */);\n\tassert(index >= 0, 0x377 /* index must be non-negative */);\n}\n\n/**\n * Convert an object into a Map.\n *\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * This function helps these few cases get into using an actual map in as safe of was as is practical.\n */\nexport function objectToMap<MapKey extends string | number | symbol, MapValue>(\n\tobjectMap: Record<MapKey, MapValue>,\n): Map<MapKey, MapValue> {\n\tconst map = new Map<MapKey, MapValue>();\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tmap.set(key as MapKey, element);\n\t}\n\treturn map;\n}\n\n/**\n * Convert an object used as a map into a new object used like a map.\n *\n * @remarks\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * {@link objectToMap} helps these few cases get into using an actual map in as safe of a way as is practical.\n */\nexport function transformObjectMap<\n\tMapKey extends string | number | symbol,\n\tMapValue,\n\tNewMapValue,\n>(\n\tobjectMap: Record<MapKey, MapValue>,\n\ttransformer: (value: MapValue, key: MapKey) => NewMapValue,\n): Record<MapKey, MapValue> {\n\tconst output: Record<MapKey, MapValue> = Object.create(null);\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tObject.defineProperty(output, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: transformer(element, key as MapKey),\n\t\t});\n\t}\n\treturn output;\n}\n\n/**\n * Make an inverted copy of a map.\n *\n * @returns a map which can look up the keys from the values of the original map.\n */\nexport function invertMap<Key, Value>(input: Map<Key, Value>): Map<Value, Key> {\n\tconst result = new Map<Value, Key>(mapIterable(input, ([key, value]) => [value, key]));\n\tassert(\n\t\tresult.size === input.size,\n\t\t0x88a /* all values in a map must be unique to invert it */,\n\t);\n\treturn result;\n}\n\n/**\n * Returns the value from `set` if it contains exactly one item, otherwise `undefined`.\n * @internal\n */\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\n/**\n * Type with a name describing what it is.\n * Typically used with values (like schema) that can be stored in a map, but in some representations have their name/key as a field.\n * @internal\n */\nexport interface Named<TName> {\n\treadonly name: TName;\n}\n\n/**\n * Order {@link Named} objects by their name.\n * @internal\n */\nexport function compareNamed(a: Named<string>, b: Named<string>): -1 | 0 | 1 {\n\tif (a.name < b.name) {\n\t\treturn -1;\n\t}\n\tif (a.name > b.name) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/**\n * Placeholder for `Symbol.dispose`.\n * @privateRemarks\n * TODO: replace this with `Symbol.dispose` when it is available or make it a valid polyfill.\n * @internal\n */\nexport const disposeSymbol: unique symbol = Symbol(\"Symbol.dispose placeholder\");\n\n/**\n * An object with an explicit lifetime that can be ended.\n * @privateRemarks\n * Simpler alternative to core-utils/IDisposable for internal use in this package.\n * This avoids adding a named \"dispose\" method, and will eventually be replaced with\n * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management| TypeScript's Disposable}.\n *\n * Once this is replaced with TypeScript's Disposable, core-utils/IDisposable can extend it, bringing the APIs into a reasonable alignment.\n * @internal\n */\nexport interface IDisposable {\n\t/**\n\t * Call to end the lifetime of this object.\n\t *\n\t * It is invalid to use this object after this,\n\t * except for operations which explicitly document they are valid after disposal.\n\t *\n\t * @remarks\n\t * May cleanup resources retained by this object.\n\t * Often includes un-registering from events and thus preventing other objects from retaining a reference to this indefinably.\n\t *\n\t * Usually the only operations allowed after disposal are querying if an object is already disposed,\n\t * but this can vary between implementations.\n\t */\n\t[disposeSymbol](): void;\n}\n\n/**\n * Capitalize a string.\n */\nexport function capitalize<S extends string>(s: S): Capitalize<S> {\n\t// To avoid splitting characters which are made of multiple UTF-16 code units,\n\t// use iteration instead of indexing to separate the first character.\n\tconst iterated = s[Symbol.iterator]().next();\n\tif (iterated.done === true) {\n\t\t// Empty string case.\n\t\treturn \"\" as Capitalize<S>;\n\t}\n\n\treturn (iterated.value.toUpperCase() + s.slice(iterated.value.length)) as Capitalize<S>;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,eAAe,MAAM,yBAAyB,CAAC;AA8BtD;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAI,QAAW;IACvC,OAAO,QAAsB,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAI,CAAyB;IAC3D,+EAA+E;IAC/E,wEAAwE;IACxE,oEAAoE;IACp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B,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAkB,CAAC;AACzF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,CAAI,EAAE,CAAI;IAC1D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { Type } from \"@sinclair/typebox\";\nimport structuredClone from \"@ungap/structured-clone\";\n\n/**\n * Subset of Map interface.\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * Make all transitive properties in T readonly\n */\nexport type RecursiveReadonly<T> = {\n\treadonly [P in keyof T]: RecursiveReadonly<T[P]>;\n};\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Make all field required and omits fields whose ony valid value would be `undefined`.\n * This is analogous to `Required<T>` except it tolerates 'optional undefined'.\n */\nexport type Populated<T> = {\n\t[P in keyof T as Exclude<P, T[P] extends undefined ? P : never>]-?: T[P];\n};\n\n/**\n * Casts a readonly object to a mutable one.\n * Better than casting to `Mutable<Foo>` because it doesn't risk casting a non-`Foo` to a `Mutable<Foo>`.\n * @param readonly - The object with readonly fields.\n * @returns The same object but with a type that makes all fields mutable.\n */\nexport function asMutable<T>(readonly: T): Mutable<T> {\n\treturn readonly as Mutable<T>;\n}\n\nexport const clone = structuredClone;\n\n/**\n * @internal\n */\nexport function fail(message: string): never {\n\tthrow new Error(message);\n}\n\n/**\n * Checks whether or not the given object is a `readonly` array.\n *\n * Note that this does NOT indicate if a given array should be treated as readonly.\n * This instead indicates if an object is an Array, and is typed to tolerate the readonly case.\n */\nexport function isReadonlyArray<T>(x: readonly T[] | unknown): x is readonly T[] {\n\t// `Array.isArray()` does not properly narrow `readonly` array types by itself,\n\t// so we wrap it in this type guard. This may become unnecessary if/when\n\t// https://github.com/microsoft/TypeScript/issues/17002 is resolved.\n\treturn Array.isArray(x);\n}\n\n/**\n * Creates and populates a new array.\n * @param size - The size of the array to be created.\n * @param filler - Callback for populating the array with a value for a given index\n */\nexport function makeArray<T>(size: number, filler: (index: number) => T): T[] {\n\tconst array = [];\n\tfor (let i = 0; i < size; ++i) {\n\t\tarray.push(filler(i));\n\t}\n\treturn array;\n}\n\n/**\n * Compares two sets using callbacks.\n * Early returns on first false comparison.\n *\n * @param a - One Set.\n * @param b - The other Set.\n * @param aExtra - Called for items in `a` but not `b`.\n * @param bExtra - Called for items in `b` but not `a`.\n * @param same - Called for items in `a` and `b`.\n * @returns false iff any of the call backs returned false.\n */\nexport function compareSets<T>({\n\ta,\n\tb,\n\taExtra,\n\tbExtra,\n\tsame,\n}: {\n\ta: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\tb: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\taExtra?: (t: T) => boolean;\n\tbExtra?: (t: T) => boolean;\n\tsame?: (t: T) => boolean;\n}): boolean {\n\tfor (const item of a.keys()) {\n\t\tif (!b.has(item)) {\n\t\t\tif (aExtra && !aExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tif (same && !same(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tfor (const item of b.keys()) {\n\t\tif (!a.has(item)) {\n\t\t\tif (bExtra && !bExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Utility for dictionaries whose values are lists.\n * Gets the list associated with the provided key, if it exists.\n * Otherwise, creates an entry with an empty list, and returns that list.\n */\nexport function getOrAddEmptyToMap<K, V>(map: MapGetSet<K, V[]>, key: K): V[] {\n\tlet collection = map.get(key);\n\tif (collection === undefined) {\n\t\tcollection = [];\n\t\tmap.set(key, collection);\n\t}\n\treturn collection;\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Filter one iterable into another\n * @param iterable - the iterable to filter\n * @param filter - the predicate function to run on each element of the iterable\n * @returns a new iterable including only the elements that passed the filter predicate\n */\nexport function* filterIterable<T>(\n\titerable: Iterable<T>,\n\tfilter: (t: T) => boolean,\n): IterableIterator<T> {\n\tfor (const t of iterable) {\n\t\tif (filter(t)) {\n\t\t\tyield t;\n\t\t}\n\t}\n}\n\n/**\n * Finds the first element in the given iterable that satisfies a predicate.\n * @param iterable - The iterable to search for an eligible element\n * @param predicate - The predicate to run against each element\n * @returns The first element in the iterable that satisfies the predicate, or undefined if the iterable contains no such element\n */\nexport function find<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): T | undefined {\n\tfor (const t of iterable) {\n\t\tif (predicate(t)) {\n\t\t\treturn t;\n\t\t}\n\t}\n}\n\n/**\n * Use for Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @internal\n */\nexport type JsonCompatible =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| JsonCompatible[]\n\t| JsonCompatibleObject;\n\n/**\n * Use for Json object compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @internal\n */\nexport type JsonCompatibleObject = { [P in string]?: JsonCompatible };\n\n/**\n * Use for readonly view of Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n */\nexport type JsonCompatibleReadOnly =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| readonly JsonCompatibleReadOnly[]\n\t| JsonCompatibleReadOnlyObject;\n\n/**\n * Use for readonly view of Json compatible data.\n *\n * Note that this does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n */\nexport type JsonCompatibleReadOnlyObject = { readonly [P in string]?: JsonCompatibleReadOnly };\n\n/**\n * @remarks TODO: Audit usage of this type in schemas, evaluating whether it is necessary and performance\n * of alternatives.\n *\n * True \"arbitrary serializable data\" is probably fine, but some persisted types declarations might be better\n * expressed using composition of schemas for runtime validation, even if we don't think making the types\n * generic is worth the maintenance cost.\n */\nexport const JsonCompatibleReadOnlySchema = Type.Any();\n\n/**\n * Returns if a particular json compatible value is an object.\n * Does not include `null` or arrays.\n */\nexport function isJsonObject(\n\tvalue: JsonCompatibleReadOnly,\n): value is { readonly [P in string]?: JsonCompatibleReadOnly } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Verifies that the supplied indices are valid within the supplied array.\n * @param startIndex - The starting index in the range. Must be in [0, length).\n * @param endIndex - The ending index in the range. Must be within (start, length].\n * @param array - The array the indices refer to\n */\nexport function assertValidRangeIndices(\n\tstartIndex: number,\n\tendIndex: number,\n\tarray: { readonly length: number },\n): void {\n\tassert(endIndex >= startIndex, 0x79c /* Range indices are malformed. */);\n\tassertValidIndex(startIndex, array, false);\n\tassertValidIndex(endIndex, array, true);\n}\n\nexport function assertValidIndex(\n\tindex: number,\n\tarray: { readonly length: number },\n\tallowOnePastEnd: boolean = false,\n): void {\n\tassertNonNegativeSafeInteger(index);\n\tif (allowOnePastEnd) {\n\t\tassert(index <= array.length, 0x378 /* index must be less than or equal to length */);\n\t} else {\n\t\tassert(index < array.length, 0x379 /* index must be less than length */);\n\t}\n}\n\nexport function assertValidRange(\n\t{ start, end }: { start: number; end: number },\n\tarray: { readonly length: number },\n): void {\n\tassertNonNegativeSafeInteger(start);\n\tassertNonNegativeSafeInteger(end);\n\tassert(end <= array.length, 0x79d /* Range end must be less than or equal to length */);\n\tassert(start <= end, 0x79e /* Range start must be less than or equal to range start */);\n}\n\nexport function assertNonNegativeSafeInteger(index: number): void {\n\tassert(Number.isSafeInteger(index), 0x376 /* index must be an integer */);\n\tassert(index >= 0, 0x377 /* index must be non-negative */);\n}\n\n/**\n * Convert an object into a Map.\n *\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * This function helps these few cases get into using an actual map in as safe of was as is practical.\n */\nexport function objectToMap<MapKey extends string | number | symbol, MapValue>(\n\tobjectMap: Record<MapKey, MapValue>,\n): Map<MapKey, MapValue> {\n\tconst map = new Map<MapKey, MapValue>();\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tmap.set(key as MapKey, element);\n\t}\n\treturn map;\n}\n\n/**\n * Convert an object used as a map into a new object used like a map.\n *\n * @remarks\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * {@link objectToMap} helps these few cases get into using an actual map in as safe of a way as is practical.\n */\nexport function transformObjectMap<\n\tMapKey extends string | number | symbol,\n\tMapValue,\n\tNewMapValue,\n>(\n\tobjectMap: Record<MapKey, MapValue>,\n\ttransformer: (value: MapValue, key: MapKey) => NewMapValue,\n): Record<MapKey, MapValue> {\n\tconst output: Record<MapKey, MapValue> = Object.create(null);\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tObject.defineProperty(output, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: transformer(element, key as MapKey),\n\t\t});\n\t}\n\treturn output;\n}\n\n/**\n * Make an inverted copy of a map.\n *\n * @returns a map which can look up the keys from the values of the original map.\n */\nexport function invertMap<Key, Value>(input: Map<Key, Value>): Map<Value, Key> {\n\tconst result = new Map<Value, Key>(mapIterable(input, ([key, value]) => [value, key]));\n\tassert(\n\t\tresult.size === input.size,\n\t\t0x88a /* all values in a map must be unique to invert it */,\n\t);\n\treturn result;\n}\n\n/**\n * Returns the value from `set` if it contains exactly one item, otherwise `undefined`.\n * @internal\n */\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\n/**\n * Type with a name describing what it is.\n * Typically used with values (like schema) that can be stored in a map, but in some representations have their name/key as a field.\n * @internal\n */\nexport interface Named<TName> {\n\treadonly name: TName;\n}\n\n/**\n * Order {@link Named} objects by their name.\n * @internal\n */\nexport function compareNamed(a: Named<string>, b: Named<string>): -1 | 0 | 1 {\n\tif (a.name < b.name) {\n\t\treturn -1;\n\t}\n\tif (a.name > b.name) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/**\n * Placeholder for `Symbol.dispose`.\n * @privateRemarks\n * TODO: replace this with `Symbol.dispose` when it is available or make it a valid polyfill.\n * @internal\n */\nexport const disposeSymbol: unique symbol = Symbol(\"Symbol.dispose placeholder\");\n\n/**\n * An object with an explicit lifetime that can be ended.\n * @privateRemarks\n * Simpler alternative to core-utils/IDisposable for internal use in this package.\n * This avoids adding a named \"dispose\" method, and will eventually be replaced with\n * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management| TypeScript's Disposable}.\n *\n * Once this is replaced with TypeScript's Disposable, core-utils/IDisposable can extend it, bringing the APIs into a reasonable alignment.\n * @internal\n */\nexport interface IDisposable {\n\t/**\n\t * Call to end the lifetime of this object.\n\t *\n\t * It is invalid to use this object after this,\n\t * except for operations which explicitly document they are valid after disposal.\n\t *\n\t * @remarks\n\t * May cleanup resources retained by this object.\n\t * Often includes un-registering from events and thus preventing other objects from retaining a reference to this indefinably.\n\t *\n\t * Usually the only operations allowed after disposal are querying if an object is already disposed,\n\t * but this can vary between implementations.\n\t */\n\t[disposeSymbol](): void;\n}\n\n/**\n * Capitalize a string.\n */\nexport function capitalize<S extends string>(s: S): Capitalize<S> {\n\t// To avoid splitting characters which are made of multiple UTF-16 code units,\n\t// use iteration instead of indexing to separate the first character.\n\tconst iterated = s[Symbol.iterator]().next();\n\tif (iterated.done === true) {\n\t\t// Empty string case.\n\t\treturn \"\" as Capitalize<S>;\n\t}\n\n\treturn (iterated.value.toUpperCase() + s.slice(iterated.value.length)) as Capitalize<S>;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.1.0-276326",
3
+ "version": "2.1.0-281041",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -67,17 +67,17 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "2.1.0-276326",
71
- "@fluidframework/container-runtime": "2.1.0-276326",
72
- "@fluidframework/core-interfaces": "2.1.0-276326",
73
- "@fluidframework/core-utils": "2.1.0-276326",
74
- "@fluidframework/datastore-definitions": "2.1.0-276326",
75
- "@fluidframework/driver-definitions": "2.1.0-276326",
76
- "@fluidframework/id-compressor": "2.1.0-276326",
77
- "@fluidframework/runtime-definitions": "2.1.0-276326",
78
- "@fluidframework/runtime-utils": "2.1.0-276326",
79
- "@fluidframework/shared-object-base": "2.1.0-276326",
80
- "@fluidframework/telemetry-utils": "2.1.0-276326",
70
+ "@fluid-internal/client-utils": "2.1.0-281041",
71
+ "@fluidframework/container-runtime": "2.1.0-281041",
72
+ "@fluidframework/core-interfaces": "2.1.0-281041",
73
+ "@fluidframework/core-utils": "2.1.0-281041",
74
+ "@fluidframework/datastore-definitions": "2.1.0-281041",
75
+ "@fluidframework/driver-definitions": "2.1.0-281041",
76
+ "@fluidframework/id-compressor": "2.1.0-281041",
77
+ "@fluidframework/runtime-definitions": "2.1.0-281041",
78
+ "@fluidframework/runtime-utils": "2.1.0-281041",
79
+ "@fluidframework/shared-object-base": "2.1.0-281041",
80
+ "@fluidframework/telemetry-utils": "2.1.0-281041",
81
81
  "@sinclair/typebox": "^0.32.29",
82
82
  "@tylerbu/sorted-btree-es6": "^1.8.0",
83
83
  "@ungap/structured-clone": "^1.2.0",
@@ -85,20 +85,21 @@
85
85
  },
86
86
  "devDependencies": {
87
87
  "@arethetypeswrong/cli": "^0.15.2",
88
- "@biomejs/biome": "^1.7.3",
89
- "@fluid-internal/mocha-test-setup": "2.1.0-276326",
90
- "@fluid-private/stochastic-test-utils": "2.1.0-276326",
91
- "@fluid-private/test-dds-utils": "2.1.0-276326",
92
- "@fluid-private/test-drivers": "2.1.0-276326",
88
+ "@biomejs/biome": "~1.8.3",
89
+ "@fluid-internal/mocha-test-setup": "2.1.0-281041",
90
+ "@fluid-private/stochastic-test-utils": "2.1.0-281041",
91
+ "@fluid-private/test-dds-utils": "2.1.0-281041",
92
+ "@fluid-private/test-drivers": "2.1.0-281041",
93
93
  "@fluid-tools/benchmark": "^0.48.0",
94
- "@fluid-tools/build-cli": "^0.39.0",
94
+ "@fluid-tools/build-cli": "^0.40.0",
95
95
  "@fluidframework/build-common": "^2.0.3",
96
- "@fluidframework/build-tools": "^0.39.0",
97
- "@fluidframework/container-definitions": "2.1.0-276326",
98
- "@fluidframework/container-loader": "2.1.0-276326",
96
+ "@fluidframework/build-tools": "^0.40.0",
97
+ "@fluidframework/container-definitions": "2.1.0-281041",
98
+ "@fluidframework/container-loader": "2.1.0-281041",
99
99
  "@fluidframework/eslint-config-fluid": "^5.3.0",
100
- "@fluidframework/test-runtime-utils": "2.1.0-276326",
101
- "@fluidframework/test-utils": "2.1.0-276326",
100
+ "@fluidframework/test-runtime-utils": "2.1.0-281041",
101
+ "@fluidframework/test-utils": "2.1.0-281041",
102
+ "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.0.0",
102
103
  "@microsoft/api-extractor": "^7.45.1",
103
104
  "@types/diff": "^3.5.1",
104
105
  "@types/easy-table": "^0.0.32",
@@ -141,7 +142,6 @@
141
142
  }
142
143
  },
143
144
  "typeValidation": {
144
- "disabled": true,
145
145
  "broken": {}
146
146
  },
147
147
  "scripts": {
@@ -160,7 +160,7 @@
160
160
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
161
161
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
162
162
  "check:are-the-types-wrong": "attw --pack .",
163
- "check:biome": "biome check . --formatter-enabled=true",
163
+ "check:biome": "biome check .",
164
164
  "check:exports": "concurrently \"npm:check:exports:*\"",
165
165
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
166
166
  "check:exports:cjs:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.cjs.json",
@@ -176,13 +176,15 @@
176
176
  "eslint": "eslint --format stylish src",
177
177
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
178
178
  "format": "npm run format:biome",
179
- "format:biome": "biome check . --formatter-enabled=true --apply",
179
+ "format:biome": "biome check . --write",
180
180
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
181
181
  "lint": "fluid-build . --task lint",
182
182
  "lint:fix": "fluid-build . --task eslint:fix --task format",
183
183
  "test": "npm run test:mocha",
184
184
  "test:benchmark:report": "mocha --exit --perfMode --parentProcess --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 60000",
185
185
  "test:coverage": "c8 npm test",
186
+ "test:memory": "mocha --config ./src/test/memory/.mocharc.cjs",
187
+ "test:memory-profiling:report": "mocha --config ./src/test/memory/.mocharc.cjs",
186
188
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
187
189
  "test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
188
190
  "test:mocha:esm": "mocha",
@@ -190,7 +192,7 @@
190
192
  "test:snapshots:regen": "pnpm test:mocha:esm --snapshot",
191
193
  "test:stress": "cross-env FUZZ_TEST_COUNT=20 FUZZ_STRESS_RUN=true mocha --ignore \"lib/test/memory/**/*\" --recursive \"lib/test/**/*.spec.js\"",
192
194
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
193
- "typetests:gen": "flub generate typetests --dir . -v",
195
+ "typetests:gen": "flub generate typetests --dir . -v --level public",
194
196
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
195
197
  }
196
198
  }
@@ -13,9 +13,10 @@ import {
13
13
  type DeltaVisitor,
14
14
  type DetachedField,
15
15
  type ITreeCursorSynchronous,
16
- applyDelta,
16
+ combineVisitors,
17
17
  deltaForRootInitialization,
18
18
  makeDetachedFieldIndex,
19
+ visitDelta,
19
20
  } from "../tree/index.js";
20
21
 
21
22
  import type { IForestSubscription, ITreeSubscriptionCursor } from "./forest.js";
@@ -40,8 +41,11 @@ export interface IEditableForest extends IForestSubscription {
40
41
  }
41
42
 
42
43
  /**
43
- * Sets the contents of the forest via delta.
44
- * Requires the fores starts empty.
44
+ * Initializes the given forest with the given content.
45
+ * @remarks The forest must be empty when this function is called.
46
+ * This does not perform an edit in the typical sense.
47
+ * Instead, it creates a delta expressing a creation and insertion of the `content` under the {@link rootFieldKey}, and then applies the delta to the forest.
48
+ * If `visitAnchors` is enabled, then the delta will also be applied to the forest's {@link AnchorSet} (in which case there must be no existing anchors when this function is called).
45
49
  *
46
50
  * @remarks
47
51
  * This does not perform an edit: it updates the forest content as if there was an edit that did that.
@@ -51,10 +55,19 @@ export function initializeForest(
51
55
  content: readonly ITreeCursorSynchronous[],
52
56
  revisionTagCodec: RevisionTagCodec,
53
57
  idCompressor: IIdCompressor,
58
+ visitAnchors = false,
54
59
  ): void {
55
60
  assert(forest.isEmpty, 0x747 /* forest must be empty */);
56
61
  const delta: DeltaRoot = deltaForRootInitialization(content);
57
- applyDelta(delta, forest, makeDetachedFieldIndex("init", revisionTagCodec, idCompressor));
62
+ let visitor = forest.acquireVisitor();
63
+ if (visitAnchors) {
64
+ assert(forest.anchors.isEmpty(), "anchor set must be empty");
65
+ const anchorVisitor = forest.anchors.acquireVisitor();
66
+ visitor = combineVisitors([visitor, anchorVisitor], [anchorVisitor]);
67
+ }
68
+
69
+ visitDelta(delta, visitor, makeDetachedFieldIndex("init", revisionTagCodec, idCompressor));
70
+ visitor.free();
58
71
  }
59
72
 
60
73
  // TODO: Types below here may be useful for input into edit building APIs, but are no longer used here directly.
package/src/core/index.ts CHANGED
@@ -190,6 +190,8 @@ export {
190
190
  taggedOptAtomId,
191
191
  offsetChangeAtomId,
192
192
  replaceAtomRevisions,
193
+ getFromChangeAtomIdMap,
194
+ setInChangeAtomIdMap,
193
195
  replaceChange,
194
196
  type RebaseStats,
195
197
  type RebaseStatsWithDuration,
@@ -23,6 +23,8 @@ export {
23
23
  taggedOptAtomId,
24
24
  offsetChangeAtomId,
25
25
  replaceAtomRevisions,
26
+ getFromChangeAtomIdMap,
27
+ setInChangeAtomIdMap,
26
28
  replaceChange,
27
29
  } from "./types.js";
28
30
  export { RevisionTagCodec } from "./revisionTagCodec.js";
@@ -17,6 +17,8 @@ import {
17
17
  brand,
18
18
  brandedNumberType,
19
19
  brandedStringType,
20
+ setInNestedMap,
21
+ tryGetFromNestedMap,
20
22
  } from "../../util/index.js";
21
23
  import type { TaggedChange } from "./changeRebaser.js";
22
24
 
@@ -74,6 +76,21 @@ export type EncodedChangeAtomId = [ChangesetLocalId, EncodedRevisionTag] | Chang
74
76
  */
75
77
  export type ChangeAtomIdMap<T> = NestedMap<RevisionTag | undefined, ChangesetLocalId, T>;
76
78
 
79
+ export function getFromChangeAtomIdMap<T>(
80
+ map: ChangeAtomIdMap<T>,
81
+ id: ChangeAtomId,
82
+ ): T | undefined {
83
+ return tryGetFromNestedMap(map, id.revision, id.localId);
84
+ }
85
+
86
+ export function setInChangeAtomIdMap<T>(
87
+ map: ChangeAtomIdMap<T>,
88
+ id: ChangeAtomId,
89
+ value: T,
90
+ ): void {
91
+ setInNestedMap(map, id.revision, id.localId, value);
92
+ }
93
+
77
94
  /**
78
95
  * @internal
79
96
  */
@@ -9,6 +9,7 @@ import { type NestedMap, setInNestedMap, tryGetFromNestedMap } from "../../util/
9
9
  import type { FieldKey } from "../schema-stored/index.js";
10
10
 
11
11
  import type { ITreeCursorSynchronous } from "./cursor.js";
12
+ // eslint-disable-next-line import/no-duplicates
12
13
  import type * as Delta from "./delta.js";
13
14
  // Since ProtoNodes is reexported, import it directly to avoid forcing Delta to be reexported.
14
15
  // eslint-disable-next-line import/no-duplicates
@@ -8,9 +8,11 @@ import { getOrCreate } from "../util/index.js";
8
8
 
9
9
  /**
10
10
  * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.
11
+ * @privateRemarks
12
+ * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.
13
+ * Then the constraint on the type parameter in this new context is inferred, giving the intersection.
11
14
  */
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- export type UnionToIntersection<T> = (T extends any ? (k: T) => unknown : never) extends (
15
+ export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (
14
16
  k: infer U,
15
17
  ) => unknown
16
18
  ? U
@@ -170,7 +170,7 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
170
170
  family: ChangeFamily<ChangeFamilyEditor, DefaultChangeset>,
171
171
  changeReceiver: (change: DefaultChangeset) => void,
172
172
  ) {
173
- this.modularBuilder = new ModularEditBuilder(family, changeReceiver);
173
+ this.modularBuilder = new ModularEditBuilder(family, fieldKinds, changeReceiver);
174
174
  }
175
175
 
176
176
  public enterTransaction(): void {
@@ -48,6 +48,7 @@ export const noChangeHandler: FieldChangeHandler<0> = {
48
48
  isEmpty: (change: 0) => true,
49
49
  getNestedChanges: (change: 0) => [],
50
50
  createEmpty: () => 0,
51
+ getCrossFieldKeys: () => [],
51
52
  };
52
53
 
53
54
  export interface ValueFieldEditor extends FieldEditor<OptionalChangeset> {
@@ -282,16 +282,6 @@ export class EagerMapTreeFieldNode<TSchema extends FlexFieldNodeSchema>
282
282
  return unboxedField(field, EmptyKey, this.mapTree, this);
283
283
  }
284
284
 
285
- public get boxedContent(): FlexTreeTypedField<TSchema["info"]> {
286
- const field = this.mapTree.fields.get(EmptyKey) ?? [];
287
- return getOrCreateField(
288
- this,
289
- EmptyKey,
290
- field,
291
- this.schema.info,
292
- ) as unknown as FlexTreeTypedField<TSchema["info"]>;
293
- }
294
-
295
285
  public override getBoxed(key: string): FlexTreeTypedField<TSchema["info"]> {
296
286
  return super.getBoxed(key) as FlexTreeTypedField<TSchema["info"]>;
297
287
  }
@@ -418,9 +408,6 @@ export const rootMapTreeField: MapTreeField<FlexAllowedTypes> = {
418
408
  is<TSchema extends FlexFieldSchema>(schema: TSchema) {
419
409
  return schema === (FlexFieldSchema.empty as FlexFieldSchema);
420
410
  },
421
- isSameAs(other: FlexTreeField): boolean {
422
- return other === this;
423
- },
424
411
  boxedIterator(): IterableIterator<FlexTreeNode> {
425
412
  return [].values();
426
413
  },
@@ -476,15 +463,6 @@ class MapTreeField<T extends FlexAllowedTypes> implements FlexTreeField {
476
463
  return this.schema.equals(schema);
477
464
  }
478
465
 
479
- public isSameAs(other: FlexTreeField): boolean {
480
- if (other.parent === this.parent && other.key === this.key) {
481
- assert(other === this, 0x992 /* Expected field to be cached */);
482
- return true;
483
- }
484
-
485
- return false;
486
- }
487
-
488
466
  public boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<T>> {
489
467
  return this.mapTrees
490
468
  .map(
@@ -530,10 +508,6 @@ class MapTreeRequiredField<T extends FlexAllowedTypes>
530
508
  public set content(_: FlexTreeUnboxNodeUnion<T>) {
531
509
  throw unsupportedUsageError("Setting an optional field");
532
510
  }
533
-
534
- public get boxedContent(): FlexTreeTypedNodeUnion<T> {
535
- return this.boxedAt(0) ?? fail("Required field must have exactly one node");
536
- }
537
511
  }
538
512
 
539
513
  class MapTreeOptionalField<T extends FlexAllowedTypes>
@@ -548,10 +522,6 @@ class MapTreeOptionalField<T extends FlexAllowedTypes>
548
522
  public set content(_: FlexTreeUnboxNodeUnion<T> | undefined) {
549
523
  throw unsupportedUsageError("Setting an optional field");
550
524
  }
551
-
552
- public get boxedContent(): FlexTreeTypedNodeUnion<T> | undefined {
553
- return this.boxedAt(0);
554
- }
555
525
  }
556
526
 
557
527
  class MapTreeSequenceField<T extends FlexAllowedTypes>
@@ -14,7 +14,6 @@ import {
14
14
  import type { Assume, FlattenKeys } from "../../util/index.js";
15
15
  import type { FieldKinds, SequenceFieldEditBuilder } from "../default-schema/index.js";
16
16
  import type { FlexFieldKind } from "../modular-schema/index.js";
17
- import type { LocalNodeKey, StableNodeKey } from "../node-key/index.js";
18
17
  import type {
19
18
  AllowedTypesToFlexInsertableTree,
20
19
  InsertableFlexField,
@@ -262,18 +261,6 @@ export interface FlexTreeField extends FlexTreeEntity<FlexFieldSchema> {
262
261
 
263
262
  boxedIterator(): IterableIterator<FlexTreeNode>;
264
263
 
265
- /**
266
- * Check if this field is the same as a different field.
267
- * This is defined to mean that both are in the same flex tree, and are the same field on the same node.
268
- * This is more than just a reference comparison because unlike FlexTree nodes, fields are not cached on anchors and can be duplicated.
269
- *
270
- * @privateRemarks
271
- * TODO:
272
- * If practical, cache TreeField instances so use of this method can be replaced with `===` to compare object identity.
273
- * Implementing this will require some care to preserve lazy-ness and work efficiently (without leaks) for empty fields, particularly on MapNodes.
274
- */
275
- isSameAs(other: FlexTreeField): boolean;
276
-
277
264
  /**
278
265
  * Gets a node of this field by its index without unboxing.
279
266
  * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.
@@ -468,20 +455,8 @@ export interface FlexTreeFieldNode<in out TSchema extends FlexFieldNodeSchema>
468
455
 
469
456
  /**
470
457
  * The content this field node wraps.
471
- * @remarks
472
- * This is a version of {@link FlexTreeFieldNode.boxedContent} but does unboxing.
473
- * Since field node are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField})
474
458
  */
475
459
  readonly content: FlexTreeUnboxField<TSchema["info"]>;
476
- /**
477
- * The field this field node wraps.
478
- *
479
- * @remarks
480
- * Since field nodes are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField}),
481
- * this is usually the same as {@link FlexTreeFieldNode.content}.
482
- * This is also the same as `[...this][0]`.
483
- */
484
- readonly boxedContent: FlexTreeTypedField<TSchema["info"]>;
485
460
  }
486
461
 
487
462
  /**
@@ -507,11 +482,6 @@ export interface FlexTreeFieldNode<in out TSchema extends FlexFieldNodeSchema>
507
482
  */
508
483
  export interface FlexTreeObjectNode extends FlexTreeNode {
509
484
  readonly schema: FlexObjectNodeSchema;
510
-
511
- /**
512
- * {@link LocalNodeKey} that identifies this node.
513
- */
514
- readonly localNodeKey?: LocalNodeKey;
515
485
  }
516
486
 
517
487
  /**
@@ -987,8 +957,6 @@ export interface FlexTreeRequiredField<in out TTypes extends FlexAllowedTypes>
987
957
  extends FlexTreeField {
988
958
  get content(): FlexTreeUnboxNodeUnion<TTypes>;
989
959
  set content(content: FlexibleNodeContent<TTypes>);
990
-
991
- readonly boxedContent: FlexTreeTypedNodeUnion<TTypes>;
992
960
  }
993
961
 
994
962
  /**
@@ -1009,17 +977,6 @@ export interface FlexTreeOptionalField<in out TTypes extends FlexAllowedTypes>
1009
977
  extends FlexTreeField {
1010
978
  get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined;
1011
979
  set content(newContent: FlexibleNodeContent<TTypes> | undefined);
1012
-
1013
- readonly boxedContent?: FlexTreeTypedNodeUnion<TTypes>;
1014
- }
1015
-
1016
- /**
1017
- * Field that contains an immutable {@link StableNodeKey} identifying this node.
1018
- * @internal
1019
- */
1020
- export interface FlexTreeNodeKeyField extends FlexTreeField {
1021
- readonly localNodeKey: LocalNodeKey;
1022
- readonly stableNodeKey: StableNodeKey;
1023
980
  }
1024
981
 
1025
982
  // #endregion
@@ -56,7 +56,6 @@ export type {
56
56
  FlexTreeObjectNodeFields,
57
57
  FlexTreeUnboxNode,
58
58
  FlexTreeUnboxNodeUnion,
59
- FlexTreeNodeKeyField,
60
59
  IsArrayOfOne,
61
60
  FlexibleNodeSubSequence,
62
61
  } from "./flexTreeTypes.js";
@@ -190,14 +190,6 @@ export abstract class LazyField<
190
190
  return this.schema.equals(schema);
191
191
  }
192
192
 
193
- public isSameAs(other: FlexTreeField): boolean {
194
- assert(
195
- other.context === this.context,
196
- 0x77d /* Content from different flex trees should not be used together */,
197
- );
198
- return this.key === other.key && this.parent === other.parent;
199
- }
200
-
201
193
  public get parent(): FlexTreeNode | undefined {
202
194
  if (this[anchorSymbol].parent === undefined) {
203
195
  return undefined;
@@ -444,7 +436,7 @@ export class LazySequence<TTypes extends FlexAllowedTypes>
444
436
  sourceEnd: number,
445
437
  source?: FlexTreeSequenceField<FlexAllowedTypes>,
446
438
  ): void {
447
- const sourceField = source !== undefined ? (this.isSameAs(source) ? this : source) : this;
439
+ const sourceField = source ?? this;
448
440
 
449
441
  // TODO: determine support for move across different sequence types
450
442
  assert(
@@ -495,10 +487,6 @@ export class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>
495
487
  public set content(newContent: FlexibleNodeContent<TTypes>) {
496
488
  fail("cannot set content in readonly field");
497
489
  }
498
-
499
- public get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {
500
- return this.boxedAt(0) ?? fail("value node must have 1 item");
501
- }
502
490
  }
503
491
 
504
492
  export class LazyValueField<TTypes extends FlexAllowedTypes>
@@ -532,10 +520,6 @@ export class LazyValueField<TTypes extends FlexAllowedTypes>
532
520
  assert(content.length === 1, 0x780 /* value field content should normalize to one item */);
533
521
  fieldEditor.set(content[0]);
534
522
  }
535
-
536
- public override get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {
537
- return this.boxedAt(0) ?? fail("value node must have 1 item");
538
- }
539
523
  }
540
524
 
541
525
  export class LazyIdentifierField<TTypes extends FlexAllowedTypes>
@@ -589,10 +573,6 @@ export class LazyOptionalField<TTypes extends FlexAllowedTypes>
589
573
  );
590
574
  fieldEditor.set(content.length === 0 ? undefined : content[0], this.length === 0);
591
575
  }
592
-
593
- public get boxedContent(): FlexTreeTypedNodeUnion<TTypes> | undefined {
594
- return this.length === 0 ? undefined : this.boxedAt(0);
595
- }
596
576
  }
597
577
 
598
578
  export class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<
@@ -434,12 +434,6 @@ export class LazyFieldNode<TSchema extends FlexFieldNodeSchema>
434
434
  unboxedField(this.context, this.schema.info, cursor),
435
435
  ) as FlexTreeUnboxField<TSchema["info"]>;
436
436
  }
437
-
438
- public get boxedContent(): FlexTreeTypedField<TSchema["info"]> {
439
- return inCursorField(this[cursorSymbol], EmptyKey, (cursor) =>
440
- makeField(this.context, this.schema.info, cursor),
441
- ) as FlexTreeTypedField<TSchema["info"]>;
442
- }
443
437
  }
444
438
 
445
439
  /**
@@ -130,6 +130,7 @@ export {
130
130
  type FieldChangeEncodingContext,
131
131
  type FieldKindConfiguration,
132
132
  type FieldKindConfigurationEntry,
133
+ getAllowedContentIncompatibilities,
133
134
  } from "./modular-schema/index.js";
134
135
 
135
136
  export {
@@ -203,7 +204,6 @@ export {
203
204
  isStableNodeKey,
204
205
  type LocalNodeKey,
205
206
  MockNodeKeyManager,
206
- NodeKeyIndex,
207
207
  type NodeKeyManager,
208
208
  nodeKeyTreeIdentifier,
209
209
  type StableNodeKey,
@@ -267,7 +267,6 @@ export {
267
267
  type FlexTreeUnboxField,
268
268
  type FlexTreeUnboxNode,
269
269
  type FlexTreeUnboxNodeUnion,
270
- type FlexTreeNodeKeyField,
271
270
  type IsArrayOfOne,
272
271
  type FlexibleNodeSubSequence,
273
272
  flexTreeMarker,
@@ -11,6 +11,7 @@ import {
11
11
  getOrAddInMap,
12
12
  setInRangeMap,
13
13
  } from "../../util/index.js";
14
+ import type { NodeId } from "./modularChangeTypes.js";
14
15
 
15
16
  export type CrossFieldMap<T> = Map<RevisionTag | undefined, RangeMap<T>>;
16
17
  export type CrossFieldQuerySet = CrossFieldMap<boolean>;
@@ -82,4 +83,21 @@ export interface CrossFieldManager<T = unknown> {
82
83
  newValue: T,
83
84
  invalidateDependents: boolean,
84
85
  ): void;
86
+
87
+ /**
88
+ * This must be called whenever a new node is moved into this field as part of the current rebase, compose, or invert.
89
+ * Calling this for a node which was already in the field is tolerated.
90
+ */
91
+ onMoveIn(id: NodeId): void;
92
+
93
+ /**
94
+ * This must be called whenever a new cross field key is moved into this field as part of the current rebase or compose.
95
+ * Calling this for a key which was already in the field is tolerated.
96
+ */
97
+ moveKey(
98
+ target: CrossFieldTarget,
99
+ revision: RevisionTag | undefined,
100
+ id: ChangesetLocalId,
101
+ count: number,
102
+ ): void;
85
103
  }