@fluidframework/tree 2.4.0-297385 → 2.4.0-299374

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 (394) hide show
  1. package/.dependency-cruiser-known-violations.json +0 -14
  2. package/.vscode/settings.json +9 -1
  3. package/api-report/tree.alpha.api.md +178 -21
  4. package/api-report/tree.beta.api.md +46 -21
  5. package/api-report/tree.legacy.alpha.api.md +46 -21
  6. package/api-report/tree.legacy.public.api.md +46 -21
  7. package/api-report/tree.public.api.md +46 -21
  8. package/dist/alpha.d.ts +29 -1
  9. package/dist/beta.d.ts +2 -0
  10. package/dist/codec/codec.d.ts +4 -4
  11. package/dist/codec/codec.js.map +1 -1
  12. package/dist/codec/noopValidator.d.ts +1 -1
  13. package/dist/codec/noopValidator.js +1 -1
  14. package/dist/codec/noopValidator.js.map +1 -1
  15. package/dist/core/tree/anchorSet.d.ts +159 -2
  16. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  17. package/dist/core/tree/anchorSet.js +54 -12
  18. package/dist/core/tree/anchorSet.js.map +1 -1
  19. package/dist/external-utilities/typeboxValidator.d.ts +1 -1
  20. package/dist/external-utilities/typeboxValidator.js +1 -1
  21. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyField.d.ts +4 -0
  23. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyField.js +38 -6
  25. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  26. package/dist/feature-libraries/index.d.ts +0 -1
  27. package/dist/feature-libraries/index.d.ts.map +1 -1
  28. package/dist/feature-libraries/index.js +46 -49
  29. package/dist/feature-libraries/index.js.map +1 -1
  30. package/dist/feature-libraries/treeCompressionUtils.d.ts +1 -1
  31. package/dist/feature-libraries/treeCompressionUtils.js +1 -1
  32. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  33. package/dist/index.d.ts +6 -5
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/internalTypes.d.ts +2 -2
  38. package/dist/internalTypes.d.ts.map +1 -1
  39. package/dist/internalTypes.js.map +1 -1
  40. package/dist/legacy.d.ts +2 -0
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/public.d.ts +2 -0
  45. package/dist/shared-tree/index.d.ts +2 -1
  46. package/dist/shared-tree/index.d.ts.map +1 -1
  47. package/dist/shared-tree/index.js +5 -1
  48. package/dist/shared-tree/index.js.map +1 -1
  49. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  50. package/dist/shared-tree/schematizingTreeView.js +1 -14
  51. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  52. package/dist/shared-tree/sharedTree.d.ts +24 -9
  53. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  54. package/dist/shared-tree/sharedTree.js +20 -8
  55. package/dist/shared-tree/sharedTree.js.map +1 -1
  56. package/dist/shared-tree/treeApi.d.ts +6 -6
  57. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  58. package/dist/shared-tree/treeApi.js.map +1 -1
  59. package/dist/simple-tree/api/conciseTree.d.ts +29 -0
  60. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -0
  61. package/dist/simple-tree/api/conciseTree.js +25 -0
  62. package/dist/simple-tree/api/conciseTree.js.map +1 -0
  63. package/dist/simple-tree/api/customTree.d.ts +44 -0
  64. package/dist/simple-tree/api/customTree.d.ts.map +1 -0
  65. package/dist/simple-tree/api/customTree.js +63 -0
  66. package/dist/simple-tree/api/customTree.js.map +1 -0
  67. package/dist/simple-tree/api/index.d.ts +7 -2
  68. package/dist/simple-tree/api/index.d.ts.map +1 -1
  69. package/dist/simple-tree/api/index.js +5 -1
  70. package/dist/simple-tree/api/index.js.map +1 -1
  71. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
  72. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  73. package/dist/simple-tree/api/schemaCreationUtilities.js +43 -15
  74. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  75. package/dist/simple-tree/api/schemaFactory.d.ts +1 -2
  76. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  77. package/dist/simple-tree/api/schemaFactory.js +8 -8
  78. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  79. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
  80. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  81. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  82. package/dist/simple-tree/api/storedSchema.d.ts +78 -0
  83. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -0
  84. package/dist/simple-tree/api/storedSchema.js +107 -0
  85. package/dist/simple-tree/api/storedSchema.js.map +1 -0
  86. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  87. package/dist/simple-tree/api/tree.d.ts +12 -3
  88. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  89. package/dist/simple-tree/api/tree.js.map +1 -1
  90. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  91. package/dist/simple-tree/api/treeNodeApi.js +5 -5
  92. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  93. package/dist/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
  94. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -0
  95. package/dist/simple-tree/api/typesUnsafe.js.map +1 -0
  96. package/dist/simple-tree/api/verboseTree.d.ts +6 -20
  97. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  98. package/dist/simple-tree/api/verboseTree.js +10 -48
  99. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  100. package/dist/simple-tree/arrayNode.d.ts +14 -3
  101. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  102. package/dist/simple-tree/arrayNode.js +1 -2
  103. package/dist/simple-tree/arrayNode.js.map +1 -1
  104. package/dist/simple-tree/core/index.d.ts +1 -1
  105. package/dist/simple-tree/core/index.d.ts.map +1 -1
  106. package/dist/simple-tree/core/index.js +2 -1
  107. package/dist/simple-tree/core/index.js.map +1 -1
  108. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -0
  109. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  110. package/dist/simple-tree/core/treeNodeKernel.js +14 -1
  111. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  112. package/dist/simple-tree/core/treeNodeSchema.d.ts +6 -5
  113. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  114. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  115. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  116. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -1
  117. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  118. package/dist/simple-tree/core/withType.d.ts +3 -1
  119. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  120. package/dist/simple-tree/core/withType.js.map +1 -1
  121. package/dist/simple-tree/flexList.d.ts.map +1 -0
  122. package/dist/simple-tree/flexList.js.map +1 -0
  123. package/dist/simple-tree/index.d.ts +6 -7
  124. package/dist/simple-tree/index.d.ts.map +1 -1
  125. package/dist/simple-tree/index.js +5 -3
  126. package/dist/simple-tree/index.js.map +1 -1
  127. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  128. package/dist/simple-tree/mapNode.js +2 -3
  129. package/dist/simple-tree/mapNode.js.map +1 -1
  130. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  131. package/dist/simple-tree/objectNode.js +3 -4
  132. package/dist/simple-tree/objectNode.js.map +1 -1
  133. package/dist/simple-tree/schemaTypes.d.ts +60 -7
  134. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  135. package/dist/simple-tree/schemaTypes.js +11 -6
  136. package/dist/simple-tree/schemaTypes.js.map +1 -1
  137. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  138. package/dist/simple-tree/toFlexSchema.js +13 -15
  139. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  140. package/dist/simple-tree/toMapTree.d.ts +4 -2
  141. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  142. package/dist/simple-tree/toMapTree.js +3 -3
  143. package/dist/simple-tree/toMapTree.js.map +1 -1
  144. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  145. package/dist/simple-tree/treeNodeValid.js +2 -1
  146. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  147. package/dist/treeFactory.d.ts +1 -0
  148. package/dist/treeFactory.d.ts.map +1 -1
  149. package/dist/treeFactory.js +1 -0
  150. package/dist/treeFactory.js.map +1 -1
  151. package/dist/util/utils.d.ts +10 -8
  152. package/dist/util/utils.d.ts.map +1 -1
  153. package/dist/util/utils.js.map +1 -1
  154. package/docs/main/detached-trees.md +8 -8
  155. package/lib/alpha.d.ts +29 -1
  156. package/lib/beta.d.ts +2 -0
  157. package/lib/codec/codec.d.ts +4 -4
  158. package/lib/codec/codec.js.map +1 -1
  159. package/lib/codec/noopValidator.d.ts +1 -1
  160. package/lib/codec/noopValidator.js +1 -1
  161. package/lib/codec/noopValidator.js.map +1 -1
  162. package/lib/core/tree/anchorSet.d.ts +159 -2
  163. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  164. package/lib/core/tree/anchorSet.js +54 -12
  165. package/lib/core/tree/anchorSet.js.map +1 -1
  166. package/lib/external-utilities/typeboxValidator.d.ts +1 -1
  167. package/lib/external-utilities/typeboxValidator.js +1 -1
  168. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  169. package/lib/feature-libraries/flex-tree/lazyField.d.ts +4 -0
  170. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  171. package/lib/feature-libraries/flex-tree/lazyField.js +36 -5
  172. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  173. package/lib/feature-libraries/index.d.ts +0 -1
  174. package/lib/feature-libraries/index.d.ts.map +1 -1
  175. package/lib/feature-libraries/index.js +0 -1
  176. package/lib/feature-libraries/index.js.map +1 -1
  177. package/lib/feature-libraries/treeCompressionUtils.d.ts +1 -1
  178. package/lib/feature-libraries/treeCompressionUtils.js +1 -1
  179. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  180. package/lib/index.d.ts +6 -5
  181. package/lib/index.d.ts.map +1 -1
  182. package/lib/index.js +3 -3
  183. package/lib/index.js.map +1 -1
  184. package/lib/internalTypes.d.ts +2 -2
  185. package/lib/internalTypes.d.ts.map +1 -1
  186. package/lib/internalTypes.js.map +1 -1
  187. package/lib/legacy.d.ts +2 -0
  188. package/lib/packageVersion.d.ts +1 -1
  189. package/lib/packageVersion.js +1 -1
  190. package/lib/packageVersion.js.map +1 -1
  191. package/lib/public.d.ts +2 -0
  192. package/lib/shared-tree/index.d.ts +2 -1
  193. package/lib/shared-tree/index.d.ts.map +1 -1
  194. package/lib/shared-tree/index.js +2 -1
  195. package/lib/shared-tree/index.js.map +1 -1
  196. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  197. package/lib/shared-tree/schematizingTreeView.js +2 -15
  198. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  199. package/lib/shared-tree/sharedTree.d.ts +24 -9
  200. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  201. package/lib/shared-tree/sharedTree.js +19 -8
  202. package/lib/shared-tree/sharedTree.js.map +1 -1
  203. package/lib/shared-tree/treeApi.d.ts +6 -6
  204. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  205. package/lib/shared-tree/treeApi.js.map +1 -1
  206. package/lib/simple-tree/api/conciseTree.d.ts +29 -0
  207. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -0
  208. package/lib/simple-tree/api/conciseTree.js +21 -0
  209. package/lib/simple-tree/api/conciseTree.js.map +1 -0
  210. package/lib/simple-tree/api/customTree.d.ts +44 -0
  211. package/lib/simple-tree/api/customTree.d.ts.map +1 -0
  212. package/lib/simple-tree/api/customTree.js +59 -0
  213. package/lib/simple-tree/api/customTree.js.map +1 -0
  214. package/lib/simple-tree/api/index.d.ts +7 -2
  215. package/lib/simple-tree/api/index.d.ts.map +1 -1
  216. package/lib/simple-tree/api/index.js +1 -0
  217. package/lib/simple-tree/api/index.js.map +1 -1
  218. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
  219. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  220. package/lib/simple-tree/api/schemaCreationUtilities.js +43 -15
  221. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  222. package/lib/simple-tree/api/schemaFactory.d.ts +1 -2
  223. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  224. package/lib/simple-tree/api/schemaFactory.js +1 -1
  225. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  226. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
  227. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  228. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  229. package/lib/simple-tree/api/storedSchema.d.ts +78 -0
  230. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -0
  231. package/lib/simple-tree/api/storedSchema.js +101 -0
  232. package/lib/simple-tree/api/storedSchema.js.map +1 -0
  233. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  234. package/lib/simple-tree/api/tree.d.ts +12 -3
  235. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  236. package/lib/simple-tree/api/tree.js.map +1 -1
  237. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  238. package/lib/simple-tree/api/treeNodeApi.js +3 -3
  239. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  240. package/lib/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
  241. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -0
  242. package/lib/simple-tree/api/typesUnsafe.js.map +1 -0
  243. package/lib/simple-tree/api/verboseTree.d.ts +6 -20
  244. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  245. package/lib/simple-tree/api/verboseTree.js +11 -49
  246. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  247. package/lib/simple-tree/arrayNode.d.ts +14 -3
  248. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  249. package/lib/simple-tree/arrayNode.js +1 -2
  250. package/lib/simple-tree/arrayNode.js.map +1 -1
  251. package/lib/simple-tree/core/index.d.ts +1 -1
  252. package/lib/simple-tree/core/index.d.ts.map +1 -1
  253. package/lib/simple-tree/core/index.js +1 -1
  254. package/lib/simple-tree/core/index.js.map +1 -1
  255. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -0
  256. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  257. package/lib/simple-tree/core/treeNodeKernel.js +12 -0
  258. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  259. package/lib/simple-tree/core/treeNodeSchema.d.ts +6 -5
  260. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  261. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  262. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  263. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -1
  264. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  265. package/lib/simple-tree/core/withType.d.ts +3 -1
  266. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  267. package/lib/simple-tree/core/withType.js.map +1 -1
  268. package/lib/simple-tree/flexList.d.ts.map +1 -0
  269. package/lib/simple-tree/flexList.js.map +1 -0
  270. package/lib/simple-tree/index.d.ts +6 -7
  271. package/lib/simple-tree/index.d.ts.map +1 -1
  272. package/lib/simple-tree/index.js +3 -4
  273. package/lib/simple-tree/index.js.map +1 -1
  274. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  275. package/lib/simple-tree/mapNode.js +1 -2
  276. package/lib/simple-tree/mapNode.js.map +1 -1
  277. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  278. package/lib/simple-tree/objectNode.js +1 -2
  279. package/lib/simple-tree/objectNode.js.map +1 -1
  280. package/lib/simple-tree/schemaTypes.d.ts +60 -7
  281. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  282. package/lib/simple-tree/schemaTypes.js +6 -1
  283. package/lib/simple-tree/schemaTypes.js.map +1 -1
  284. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  285. package/lib/simple-tree/toFlexSchema.js +1 -3
  286. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  287. package/lib/simple-tree/toMapTree.d.ts +4 -2
  288. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  289. package/lib/simple-tree/toMapTree.js +3 -3
  290. package/lib/simple-tree/toMapTree.js.map +1 -1
  291. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  292. package/lib/simple-tree/treeNodeValid.js +2 -1
  293. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  294. package/lib/treeFactory.d.ts +1 -0
  295. package/lib/treeFactory.d.ts.map +1 -1
  296. package/lib/treeFactory.js +1 -0
  297. package/lib/treeFactory.js.map +1 -1
  298. package/lib/util/utils.d.ts +10 -8
  299. package/lib/util/utils.d.ts.map +1 -1
  300. package/lib/util/utils.js.map +1 -1
  301. package/package.json +41 -24
  302. package/src/codec/codec.ts +4 -4
  303. package/src/codec/noopValidator.ts +1 -1
  304. package/src/core/tree/anchorSet.ts +63 -13
  305. package/src/external-utilities/typeboxValidator.ts +1 -1
  306. package/src/feature-libraries/flex-tree/lazyField.ts +44 -7
  307. package/src/feature-libraries/index.ts +0 -10
  308. package/src/feature-libraries/treeCompressionUtils.ts +1 -1
  309. package/src/index.ts +26 -6
  310. package/src/internalTypes.ts +4 -1
  311. package/src/packageVersion.ts +1 -1
  312. package/src/shared-tree/index.ts +5 -0
  313. package/src/shared-tree/schematizingTreeView.ts +7 -16
  314. package/src/shared-tree/sharedTree.ts +52 -22
  315. package/src/shared-tree/treeApi.ts +19 -9
  316. package/src/simple-tree/api/conciseTree.ts +58 -0
  317. package/src/simple-tree/api/customTree.ts +119 -0
  318. package/src/simple-tree/api/index.ts +39 -1
  319. package/src/simple-tree/api/schemaCreationUtilities.ts +55 -36
  320. package/src/simple-tree/api/schemaFactory.ts +4 -6
  321. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -2
  322. package/src/simple-tree/api/storedSchema.ts +126 -0
  323. package/src/simple-tree/api/tree.ts +24 -2
  324. package/src/simple-tree/api/treeNodeApi.ts +3 -8
  325. package/src/simple-tree/{typesUnsafe.ts → api/typesUnsafe.ts} +95 -21
  326. package/src/simple-tree/api/verboseTree.ts +21 -76
  327. package/src/simple-tree/arrayNode.ts +35 -15
  328. package/src/simple-tree/core/index.ts +1 -0
  329. package/src/simple-tree/core/treeNodeKernel.ts +13 -0
  330. package/src/simple-tree/core/treeNodeSchema.ts +7 -5
  331. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -1
  332. package/src/simple-tree/core/withType.ts +10 -1
  333. package/src/simple-tree/index.ts +41 -21
  334. package/src/simple-tree/mapNode.ts +1 -1
  335. package/src/simple-tree/objectNode.ts +1 -1
  336. package/src/simple-tree/schemaTypes.ts +70 -11
  337. package/src/simple-tree/toFlexSchema.ts +1 -3
  338. package/src/simple-tree/toMapTree.ts +7 -4
  339. package/src/simple-tree/treeNodeValid.ts +2 -1
  340. package/src/treeFactory.ts +1 -0
  341. package/src/util/utils.ts +10 -8
  342. package/dist/feature-libraries/flex-tree/unboxed.d.ts +0 -12
  343. package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
  344. package/dist/feature-libraries/flex-tree/unboxed.js +0 -20
  345. package/dist/feature-libraries/flex-tree/unboxed.js.map +0 -1
  346. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
  347. package/dist/feature-libraries/typed-schema/flexList.js.map +0 -1
  348. package/dist/feature-libraries/typed-schema/index.d.ts +0 -7
  349. package/dist/feature-libraries/typed-schema/index.d.ts.map +0 -1
  350. package/dist/feature-libraries/typed-schema/index.js +0 -12
  351. package/dist/feature-libraries/typed-schema/index.js.map +0 -1
  352. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
  353. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
  354. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -7
  355. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
  356. package/dist/simple-tree/proxyBinding.d.ts +0 -15
  357. package/dist/simple-tree/proxyBinding.d.ts.map +0 -1
  358. package/dist/simple-tree/proxyBinding.js +0 -22
  359. package/dist/simple-tree/proxyBinding.js.map +0 -1
  360. package/dist/simple-tree/typesUnsafe.d.ts.map +0 -1
  361. package/dist/simple-tree/typesUnsafe.js.map +0 -1
  362. package/lib/feature-libraries/flex-tree/unboxed.d.ts +0 -12
  363. package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
  364. package/lib/feature-libraries/flex-tree/unboxed.js +0 -16
  365. package/lib/feature-libraries/flex-tree/unboxed.js.map +0 -1
  366. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
  367. package/lib/feature-libraries/typed-schema/flexList.js.map +0 -1
  368. package/lib/feature-libraries/typed-schema/index.d.ts +0 -7
  369. package/lib/feature-libraries/typed-schema/index.d.ts.map +0 -1
  370. package/lib/feature-libraries/typed-schema/index.js +0 -6
  371. package/lib/feature-libraries/typed-schema/index.js.map +0 -1
  372. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
  373. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
  374. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +0 -6
  375. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
  376. package/lib/simple-tree/proxyBinding.d.ts +0 -15
  377. package/lib/simple-tree/proxyBinding.d.ts.map +0 -1
  378. package/lib/simple-tree/proxyBinding.js +0 -18
  379. package/lib/simple-tree/proxyBinding.js.map +0 -1
  380. package/lib/simple-tree/typesUnsafe.d.ts.map +0 -1
  381. package/lib/simple-tree/typesUnsafe.js.map +0 -1
  382. package/src/feature-libraries/flex-tree/unboxed.ts +0 -24
  383. package/src/feature-libraries/typed-schema/README.md +0 -6
  384. package/src/feature-libraries/typed-schema/index.ts +0 -16
  385. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -14
  386. package/src/simple-tree/proxyBinding.ts +0 -20
  387. /package/dist/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
  388. /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
  389. /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
  390. /package/lib/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
  391. /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
  392. /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
  393. /package/src/simple-tree/{ProxyBinding.md → core/TreeNodeBinding.md} +0 -0
  394. /package/src/{feature-libraries/typed-schema → simple-tree}/flexList.ts +0 -0
@@ -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;GACG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MA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;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC,4BAA4B,CAAC,CAAC;AA4BjF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAmB,CAAI;IAChD,8EAA8E;IAC9E,qEAAqE;IACrE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IAC7C,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC5B,qBAAqB;QACrB,OAAO,EAAmB,CAAC;IAC5B,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 */\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 * Counts the number of elements in the given iterable.\n * @param iterable - the iterable to enumerate\n * @returns the number of elements that were iterated after exhausting the iterable\n */\nexport function count(iterable: Iterable<unknown>): number {\n\tlet n = 0;\n\tfor (const _ of iterable) {\n\t\tn += 1;\n\t}\n\treturn n;\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 */\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 */\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 */\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 */\nexport interface Named<TName> {\n\treadonly name: TName;\n}\n\n/**\n * Order {@link Named} objects by their name.\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 */\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 */\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;GACG;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,CAAC,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAI,IAAY,EAAE,MAA4B;IACtE,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EA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AC,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 */\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 * Counts the number of elements in the given iterable.\n * @param iterable - the iterable to enumerate\n * @returns the number of elements that were iterated after exhausting the iterable\n */\nexport function count(iterable: Iterable<unknown>): number {\n\tlet n = 0;\n\tfor (const _ of iterable) {\n\t\tn += 1;\n\t}\n\treturn n;\n}\n\n/**\n * Use for Json compatible data.\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\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 * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\n */\nexport type JsonCompatibleObject = { [P in string]?: JsonCompatible };\n\n/**\n * Use for readonly view of Json compatible data.\n * @remarks\n * 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 * @remarks\n * 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 */\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 */\nexport interface Named<TName> {\n\treadonly name: TName;\n}\n\n/**\n * Order {@link Named} objects by their name.\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 */\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 */\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.4.0-297385",
3
+ "version": "2.4.0-299374",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -87,17 +87,17 @@
87
87
  "temp-directory": "nyc/.nyc_output"
88
88
  },
89
89
  "dependencies": {
90
- "@fluid-internal/client-utils": "2.4.0-297385",
91
- "@fluidframework/container-runtime": "2.4.0-297385",
92
- "@fluidframework/core-interfaces": "2.4.0-297385",
93
- "@fluidframework/core-utils": "2.4.0-297385",
94
- "@fluidframework/datastore-definitions": "2.4.0-297385",
95
- "@fluidframework/driver-definitions": "2.4.0-297385",
96
- "@fluidframework/id-compressor": "2.4.0-297385",
97
- "@fluidframework/runtime-definitions": "2.4.0-297385",
98
- "@fluidframework/runtime-utils": "2.4.0-297385",
99
- "@fluidframework/shared-object-base": "2.4.0-297385",
100
- "@fluidframework/telemetry-utils": "2.4.0-297385",
90
+ "@fluid-internal/client-utils": "2.4.0-299374",
91
+ "@fluidframework/container-runtime": "2.4.0-299374",
92
+ "@fluidframework/core-interfaces": "2.4.0-299374",
93
+ "@fluidframework/core-utils": "2.4.0-299374",
94
+ "@fluidframework/datastore-definitions": "2.4.0-299374",
95
+ "@fluidframework/driver-definitions": "2.4.0-299374",
96
+ "@fluidframework/id-compressor": "2.4.0-299374",
97
+ "@fluidframework/runtime-definitions": "2.4.0-299374",
98
+ "@fluidframework/runtime-utils": "2.4.0-299374",
99
+ "@fluidframework/shared-object-base": "2.4.0-299374",
100
+ "@fluidframework/telemetry-utils": "2.4.0-299374",
101
101
  "@sinclair/typebox": "^0.32.29",
102
102
  "@tylerbu/sorted-btree-es6": "^1.8.0",
103
103
  "@ungap/structured-clone": "^1.2.0",
@@ -106,19 +106,19 @@
106
106
  "devDependencies": {
107
107
  "@arethetypeswrong/cli": "^0.15.2",
108
108
  "@biomejs/biome": "~1.8.3",
109
- "@fluid-internal/mocha-test-setup": "2.4.0-297385",
110
- "@fluid-private/stochastic-test-utils": "2.4.0-297385",
111
- "@fluid-private/test-dds-utils": "2.4.0-297385",
112
- "@fluid-private/test-drivers": "2.4.0-297385",
109
+ "@fluid-internal/mocha-test-setup": "2.4.0-299374",
110
+ "@fluid-private/stochastic-test-utils": "2.4.0-299374",
111
+ "@fluid-private/test-dds-utils": "2.4.0-299374",
112
+ "@fluid-private/test-drivers": "2.4.0-299374",
113
113
  "@fluid-tools/benchmark": "^0.50.0",
114
- "@fluid-tools/build-cli": "^0.46.0",
114
+ "@fluid-tools/build-cli": "^0.48.0",
115
115
  "@fluidframework/build-common": "^2.0.3",
116
- "@fluidframework/build-tools": "^0.46.0",
117
- "@fluidframework/container-definitions": "2.4.0-297385",
118
- "@fluidframework/container-loader": "2.4.0-297385",
116
+ "@fluidframework/build-tools": "^0.48.0",
117
+ "@fluidframework/container-definitions": "2.4.0-299374",
118
+ "@fluidframework/container-loader": "2.4.0-299374",
119
119
  "@fluidframework/eslint-config-fluid": "^5.4.0",
120
- "@fluidframework/test-runtime-utils": "2.4.0-297385",
121
- "@fluidframework/test-utils": "2.4.0-297385",
120
+ "@fluidframework/test-runtime-utils": "2.4.0-299374",
121
+ "@fluidframework/test-utils": "2.4.0-299374",
122
122
  "@fluidframework/tree-previous": "npm:@fluidframework/tree@~2.3.0",
123
123
  "@microsoft/api-extractor": "7.47.8",
124
124
  "@types/diff": "^3.5.1",
@@ -139,7 +139,6 @@
139
139
  "eslint": "~8.55.0",
140
140
  "eslint-config-prettier": "~9.0.0",
141
141
  "mocha": "^10.2.0",
142
- "mocha-json-output-reporter": "^2.0.1",
143
142
  "mocha-multi-reporters": "^1.5.1",
144
143
  "moment": "^2.21.0",
145
144
  "prettier": "~3.0.3",
@@ -180,6 +179,24 @@
180
179
  },
181
180
  "TypeAlias_ImplicitAllowedTypes": {
182
181
  "forwardCompat": false
182
+ },
183
+ "TypeAlias_InsertableTreeFieldFromImplicitField": {
184
+ "backCompat": false
185
+ },
186
+ "Interface_TreeArrayNode": {
187
+ "backCompat": false
188
+ },
189
+ "TypeAlias_InsertableTreeNodeFromImplicitAllowedTypes": {
190
+ "backCompat": false
191
+ },
192
+ "TypeAlias_NodeFromSchema": {
193
+ "backCompat": false
194
+ },
195
+ "TypeAlias_TreeFieldFromImplicitField": {
196
+ "backCompat": false
197
+ },
198
+ "TypeAlias_TreeNodeFromImplicitAllowedTypes": {
199
+ "backCompat": false
183
200
  }
184
201
  },
185
202
  "entrypoint": "public"
@@ -242,7 +259,7 @@
242
259
  "test:mocha:esm": "mocha",
243
260
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
244
261
  "test:snapshots:regen": "pnpm test:mocha:esm --snapshot",
245
- "test:stress": "cross-env FUZZ_TEST_COUNT=20 FUZZ_STRESS_RUN=true mocha --ignore \"lib/test/memory/**/*\" --recursive \"lib/test/**/*.spec.js\"",
262
+ "test:stress": "cross-env FUZZ_TEST_COUNT=20 FUZZ_STRESS_RUN=normal mocha --ignore \"lib/test/memory/**/*\" --recursive \"lib/test/**/*.spec.js\"",
246
263
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
247
264
  "typetests:gen": "flub generate typetests --dir . -v",
248
265
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
@@ -35,18 +35,18 @@ export interface IDecoder<TDecoded, TEncoded, TContext> {
35
35
  /**
36
36
  * Validates data complies with some particular schema.
37
37
  * Implementations are typically created by a {@link JsonValidator}.
38
- * @internal
38
+ * @alpha
39
39
  */
40
40
  export interface SchemaValidationFunction<Schema extends TSchema> {
41
41
  /**
42
- * @returns Whether the data matches a schema.
42
+ * Returns whether the data matches a schema.
43
43
  */
44
44
  check(data: unknown): data is Static<Schema>;
45
45
  }
46
46
 
47
47
  /**
48
48
  * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.
49
- * @internal
49
+ * @alpha
50
50
  */
51
51
  export interface JsonValidator {
52
52
  /**
@@ -63,7 +63,7 @@ export interface JsonValidator {
63
63
 
64
64
  /**
65
65
  * Options relating to handling of persisted data.
66
- * @internal
66
+ * @alpha
67
67
  */
68
68
  export interface ICodecOptions {
69
69
  /**
@@ -11,7 +11,7 @@ import type { JsonValidator } from "./codec.js";
11
11
  * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.
12
12
  * @privateRemarks Having this as an option unifies opting out of validation with selection of
13
13
  * validators, simplifying code performing validation.
14
- * @internal
14
+ * @alpha
15
15
  */
16
16
  export const noopValidator: JsonValidator = {
17
17
  compile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),
@@ -233,6 +233,13 @@ export interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents>
233
233
  */
234
234
  child(key: FieldKey, index: number): UpPath<AnchorNode>;
235
235
 
236
+ /**
237
+ * Gets the child AnchorNode if already exists.
238
+ *
239
+ * Does NOT add a ref, so the returned AnchorNode must be used with care.
240
+ */
241
+ childIfAnchored(key: FieldKey, index: number): AnchorNode | undefined;
242
+
236
243
  /**
237
244
  * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.
238
245
  * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.
@@ -413,8 +420,10 @@ export class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator
413
420
 
414
421
  /**
415
422
  * Finds a path node if it already exists.
423
+ *
424
+ * Does not add a ref!
416
425
  */
417
- private find(path: UpPath): PathNode | undefined {
426
+ public find(path: UpPath): PathNode | undefined {
418
427
  if (path instanceof PathNode) {
419
428
  if (path.anchorSet === this) {
420
429
  return path;
@@ -422,7 +431,7 @@ export class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator
422
431
  }
423
432
  const parent = path.parent ?? this.root;
424
433
  const parentPath = this.find(parent);
425
- return parentPath?.tryGetChild(path.parentField, path.parentIndex);
434
+ return parentPath?.childIfAnchored(path.parentField, path.parentIndex);
426
435
  }
427
436
 
428
437
  /**
@@ -452,7 +461,7 @@ export class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator
452
461
  while ((wrapWith = stack.pop()) !== undefined) {
453
462
  if (path === undefined || path instanceof PathNode) {
454
463
  // If path already has an anchor, get an anchor for it's child if there is one:
455
- const child = (path ?? this.root).tryGetChild(
464
+ const child = (path ?? this.root).childIfAnchored(
456
465
  wrapWith.parentField,
457
466
  wrapWith.parentIndex,
458
467
  );
@@ -1210,7 +1219,11 @@ class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorN
1210
1219
  public child(key: FieldKey, index: number): UpPath<AnchorNode> {
1211
1220
  // Fast path: if child exists, return it.
1212
1221
  return (
1213
- this.tryGetChild(key, index) ?? { parent: this, parentField: key, parentIndex: index }
1222
+ this.childIfAnchored(key, index) ?? {
1223
+ parent: this,
1224
+ parentField: key,
1225
+ parentIndex: index,
1226
+ }
1214
1227
  );
1215
1228
  }
1216
1229
 
@@ -1271,8 +1284,7 @@ class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorN
1271
1284
  field = [];
1272
1285
  this.children.set(key, field);
1273
1286
  }
1274
- // TODO: should do more optimized search (ex: binary search).
1275
- let child = field.find((c) => c.parentIndex === index);
1287
+ let child = binaryFind(field, index);
1276
1288
  if (child === undefined) {
1277
1289
  child = new PathNode(this.anchorSet, key, index, this);
1278
1290
  field.push(child);
@@ -1284,16 +1296,11 @@ class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorN
1284
1296
  return child;
1285
1297
  }
1286
1298
 
1287
- /**
1288
- * Gets a child if it exists.
1289
- * Does NOT add a ref.
1290
- */
1291
- public tryGetChild(key: FieldKey, index: number): PathNode | undefined {
1299
+ public childIfAnchored(key: FieldKey, index: number): PathNode | undefined {
1292
1300
  assert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);
1293
1301
  const field = this.children.get(key);
1294
1302
 
1295
- // TODO: should do more optimized search (ex: binary search or better) using index.
1296
- return field?.find((c) => c.parentIndex === index);
1303
+ return field === undefined ? undefined : binaryFind(field, index);
1297
1304
  }
1298
1305
 
1299
1306
  /**
@@ -1343,3 +1350,46 @@ class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorN
1343
1350
  }
1344
1351
  }
1345
1352
  }
1353
+
1354
+ /**
1355
+ * Find a child PathNode by index using a binary search.
1356
+ * @param sorted - array of PathNode's sorted by parentIndex.
1357
+ * @param index - index being looked for.
1358
+ * @returns child with the requested parentIndex, or undefined.
1359
+ * @privateRemarks
1360
+ * This function is very commonly used with small arrays (length 0 or one for all non sequence fields),
1361
+ * and is currently a hot path due to how flex tree leaves to excessive cursor to anchor and anchor to cursor translations,
1362
+ * both of which walk paths down the AnchorSet.
1363
+ * Additionally current usages tends to fully populate the anchor tree leading the correct array index to be the requested parent index.
1364
+ * This makes the performance of this performance both important in small cases and easy to overly tune to the current usage patterns.
1365
+ * This lead to not implementing a general purpose reusable binary search.
1366
+ * Once this function is not so heavily overused due to inefficient patterns in flex-tree,
1367
+ * replacing it with a standard binary search is likely fine.
1368
+ * Until then, care and benchmarking should be used when messing with this function.
1369
+ */
1370
+ function binaryFind(sorted: readonly PathNode[], index: number): PathNode | undefined {
1371
+ // Try guessing the list is not sparse as a starter:
1372
+ const guess = sorted[index];
1373
+ if (guess !== undefined && guess.parentIndex === index) {
1374
+ return guess;
1375
+ }
1376
+
1377
+ // inclusive
1378
+ let min = 0;
1379
+ // exclusive
1380
+ let max = sorted.length;
1381
+
1382
+ while (min !== max) {
1383
+ const mid = Math.floor((min + max) / 2);
1384
+ const item = sorted[mid]!;
1385
+ const found = item.parentIndex;
1386
+ if (found === index) {
1387
+ return item; // Found the target, return it.
1388
+ } else if (found > index) {
1389
+ max = mid; // Continue search on lower half.
1390
+ } else {
1391
+ min = mid + 1; // Continue search on left half.
1392
+ }
1393
+ }
1394
+ return undefined; // If we reach here, target is not in array (or array was not sorted)
1395
+ }
@@ -19,7 +19,7 @@ import type { JsonValidator } from "../codec/index.js";
19
19
  *
20
20
  * Defining this validator in its own file also helps to ensure it is tree-shakeable.
21
21
  *
22
- * @internal
22
+ * @alpha
23
23
  */
24
24
  export const typeboxValidator: JsonValidator = {
25
25
  compile: <Schema extends TSchema>(schema: Schema) => {
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
8
 
8
9
  import {
10
+ type AnchorNode,
9
11
  CursorLocationType,
10
12
  type ExclusiveMapTree,
11
13
  type FieldAnchor,
@@ -51,9 +53,7 @@ import {
51
53
  tryMoveCursorToAnchorSymbol,
52
54
  } from "./lazyEntity.js";
53
55
  import { type LazyTreeNode, makeTree } from "./lazyNode.js";
54
- import { unboxedFlexNode } from "./unboxed.js";
55
56
  import { indexForAt, treeStatusFromAnchorCache } from "./utilities.js";
56
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
57
57
  import { cursorForMapTreeField, cursorForMapTreeNode } from "../mapTreeCursor.js";
58
58
 
59
59
  /**
@@ -196,7 +196,7 @@ export abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexT
196
196
 
197
197
  public atIndex(index: number): FlexTreeUnknownUnboxed {
198
198
  return inCursorNode(this[cursorSymbol], index, (cursor) =>
199
- unboxedFlexNode(this.context, cursor),
199
+ unboxedFlexNode(this.context, cursor, this[anchorSymbol]),
200
200
  );
201
201
  }
202
202
 
@@ -222,7 +222,7 @@ export abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexT
222
222
 
223
223
  public [Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {
224
224
  return iterateCursorField(this[cursorSymbol], (cursor) =>
225
- unboxedFlexNode(this.context, cursor),
225
+ unboxedFlexNode(this.context, cursor, this[anchorSymbol]),
226
226
  );
227
227
  }
228
228
 
@@ -259,9 +259,7 @@ export class LazySequence extends LazyField implements FlexTreeSequenceField {
259
259
  return undefined;
260
260
  }
261
261
 
262
- return inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>
263
- unboxedFlexNode(this.context, cursor),
264
- );
262
+ return this.atIndex(finalIndex);
265
263
  }
266
264
  public get asArray(): readonly FlexTreeUnknownUnboxed[] {
267
265
  return this.map((x) => x);
@@ -352,3 +350,42 @@ const builderList: [FieldKindIdentifier, Builder][] = [
352
350
  ];
353
351
 
354
352
  const kindToClass: ReadonlyMap<FieldKindIdentifier, Builder> = new Map(builderList);
353
+
354
+ /**
355
+ * Returns the flex tree node, or the value if it has one.
356
+ */
357
+ export function unboxedFlexNode(
358
+ context: Context,
359
+ cursor: ITreeSubscriptionCursor,
360
+ fieldAnchor: FieldAnchor,
361
+ ): FlexTreeUnknownUnboxed {
362
+ const value = cursor.value;
363
+ if (value !== undefined) {
364
+ return value;
365
+ }
366
+
367
+ // Try accessing cached child node via anchors.
368
+ // This avoids O(depth) related costs from makeTree in the cached case.
369
+ const anchor = fieldAnchor.parent;
370
+ let child: AnchorNode | undefined;
371
+ if (anchor !== undefined) {
372
+ const anchorNode = context.checkout.forest.anchors.locate(anchor);
373
+ assert(anchorNode !== undefined, "missing anchor");
374
+ child = anchorNode.childIfAnchored(fieldAnchor.fieldKey, cursor.fieldIndex);
375
+ } else {
376
+ child = context.checkout.forest.anchors.find({
377
+ parent: undefined,
378
+ parentField: fieldAnchor.fieldKey,
379
+ parentIndex: cursor.fieldIndex,
380
+ });
381
+ }
382
+
383
+ if (child !== undefined) {
384
+ const cached = child.slots.get(flexTreeSlot);
385
+ if (cached !== undefined) {
386
+ return cached;
387
+ }
388
+ }
389
+
390
+ return makeTree(context, cursor);
391
+ }
@@ -79,16 +79,6 @@ export {
79
79
  isNeverTree,
80
80
  } from "./modular-schema/index.js";
81
81
 
82
- export {
83
- type Unenforced,
84
- markEager,
85
- type LazyItem,
86
- type FlexListToUnion,
87
- type ExtractItemType,
88
- isLazy,
89
- type FlexList,
90
- } from "./typed-schema/index.js";
91
-
92
82
  export { mapRootChanges } from "./deltaUtils.js";
93
83
 
94
84
  export {
@@ -7,7 +7,7 @@
7
7
  * Selects which heuristics to use when encoding tree content.
8
8
  * All encoding options here are compatible with the same decoder:
9
9
  * the selection here does not impact compatibility.
10
- * @internal
10
+ * @alpha
11
11
  */
12
12
  export enum TreeCompressionStrategy {
13
13
  /**
package/src/index.ts CHANGED
@@ -40,9 +40,7 @@ export {
40
40
  } from "./events/index.js";
41
41
 
42
42
  export {
43
- type LazyItem,
44
43
  TreeStatus,
45
- type Unenforced,
46
44
  TreeCompressionStrategy,
47
45
  } from "./feature-libraries/index.js";
48
46
 
@@ -58,6 +56,7 @@ export {
58
56
  type NodeInDocumentConstraint,
59
57
  type RunTransaction,
60
58
  rollback,
59
+ type ForestOptions,
61
60
  getBranch,
62
61
  type TreeBranch,
63
62
  type TreeBranchFork,
@@ -115,18 +114,25 @@ export {
115
114
  type InsertableObjectFromSchemaRecordUnsafe,
116
115
  type InsertableTreeFieldFromImplicitFieldUnsafe,
117
116
  type FieldSchemaUnsafe,
117
+ type TreeNodeSchemaClassUnsafe,
118
118
  // System types (not in Internal types for various reasons, like doc links or cannot be named errors).
119
119
  type typeSchemaSymbol,
120
120
  type TreeNodeSchemaNonClass,
121
121
  // Recursive Schema APIs
122
122
  type ValidateRecursiveSchema,
123
123
  type FixRecursiveArraySchema,
124
- // experimental @internal APIs:
124
+ // experimental @alpha APIs:
125
125
  adaptEnum,
126
126
  enumFromStrings,
127
127
  singletonSchema,
128
128
  typedObjectValues,
129
- type EmptyObject,
129
+ type UnsafeUnknownSchema,
130
+ type TreeViewAlpha,
131
+ type InsertableField,
132
+ type Insertable,
133
+ type InsertableContent,
134
+ type FactoryContent,
135
+ type FactoryContentObject,
130
136
  // test recursive schema for checking that d.ts files handles schema correctly
131
137
  test_RecursiveObject,
132
138
  test_RecursiveObject_base,
@@ -134,6 +140,8 @@ export {
134
140
  // Beta APIs
135
141
  TreeBeta,
136
142
  type TreeChangeEventsBeta,
143
+ extractPersistedSchema,
144
+ comparePersistedSchema,
137
145
  // Back to normal types
138
146
  type JsonTreeSchema,
139
147
  type JsonSchemaId,
@@ -149,10 +157,20 @@ export {
149
157
  type JsonSchemaType,
150
158
  type JsonLeafSchemaType,
151
159
  getJsonSchema,
160
+ type LazyItem,
161
+ type Unenforced,
162
+ type ReadonlyArrayNode,
152
163
  } from "./simple-tree/index.js";
153
- export { SharedTree, configuredSharedTree } from "./treeFactory.js";
164
+ export {
165
+ SharedTree,
166
+ configuredSharedTree,
167
+ } from "./treeFactory.js";
154
168
 
155
- export type { ICodecOptions, JsonValidator, SchemaValidationFunction } from "./codec/index.js";
169
+ export type {
170
+ ICodecOptions,
171
+ JsonValidator,
172
+ SchemaValidationFunction,
173
+ } from "./codec/index.js";
156
174
  export { noopValidator } from "./codec/index.js";
157
175
  export { typeboxValidator } from "./external-utilities/index.js";
158
176
 
@@ -177,3 +195,5 @@ export {
177
195
  // These would be put in `internalTypes` except doing so tents to cause errors like:
178
196
  // The inferred type of 'NodeMap' cannot be named without a reference to '../../node_modules/@fluidframework/tree/lib/internalTypes.js'. This is likely not portable. A type annotation is necessary.
179
197
  export type { MapNodeInsertableData } from "./simple-tree/index.js";
198
+
199
+ export type { JsonCompatible, JsonCompatibleObject } from "./util/index.js";
@@ -33,7 +33,10 @@ export type {
33
33
  NodeBuilderDataUnsafe,
34
34
  NodeFromSchemaUnsafe,
35
35
  ReadonlyMapInlined,
36
+ TreeNodeSchemaUnsafe,
37
+ AllowedTypesUnsafe,
38
+ TreeNodeSchemaNonClassUnsafe,
36
39
  } from "./simple-tree/index.js";
37
- export type { FlexList, FlexListToUnion, ExtractItemType } from "./feature-libraries/index.js";
40
+ export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js";
38
41
 
39
42
  export type { TreeApi } from "./shared-tree/index.js";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.4.0-297385";
9
+ export const pkgVersion = "2.4.0-299374";
@@ -13,6 +13,9 @@ export {
13
13
  type SharedTreeContentSnapshot,
14
14
  type SharedTreeFormatOptions,
15
15
  SharedTreeFormatVersion,
16
+ buildConfiguredForest,
17
+ defaultSharedTreeOptions,
18
+ type ForestOptions,
16
19
  } from "./sharedTree.js";
17
20
 
18
21
  export {
@@ -29,6 +32,8 @@ export {
29
32
 
30
33
  export { type TreeStoredContent } from "./schematizeTree.js";
31
34
 
35
+ export { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
36
+
32
37
  export { CheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
33
38
 
34
39
  export type { ISharedTreeEditor, ISchemaEditor } from "./sharedTreeEditBuilder.js";