@fluidframework/tree 2.23.0 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (619) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/api-report/tree.alpha.api.md +28 -12
  3. package/dist/alpha.d.ts +6 -0
  4. package/dist/core/forest/editableForest.d.ts +1 -14
  5. package/dist/core/forest/editableForest.d.ts.map +1 -1
  6. package/dist/core/forest/editableForest.js +1 -28
  7. package/dist/core/forest/editableForest.js.map +1 -1
  8. package/dist/core/forest/forest.d.ts +16 -3
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js +4 -1
  11. package/dist/core/forest/forest.js.map +1 -1
  12. package/dist/core/forest/index.d.ts +1 -1
  13. package/dist/core/forest/index.d.ts.map +1 -1
  14. package/dist/core/forest/index.js +1 -2
  15. package/dist/core/forest/index.js.map +1 -1
  16. package/dist/core/index.d.ts +2 -2
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +3 -3
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/tree/anchorSet.d.ts +8 -3
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +12 -5
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/delta.d.ts +8 -23
  25. package/dist/core/tree/delta.d.ts.map +1 -1
  26. package/dist/core/tree/delta.js.map +1 -1
  27. package/dist/core/tree/deltaUtil.d.ts +3 -3
  28. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  29. package/dist/core/tree/deltaUtil.js +2 -2
  30. package/dist/core/tree/deltaUtil.js.map +1 -1
  31. package/dist/core/tree/index.d.ts +2 -2
  32. package/dist/core/tree/index.d.ts.map +1 -1
  33. package/dist/core/tree/index.js +2 -1
  34. package/dist/core/tree/index.js.map +1 -1
  35. package/dist/core/tree/pathTree.d.ts +54 -1
  36. package/dist/core/tree/pathTree.d.ts.map +1 -1
  37. package/dist/core/tree/pathTree.js +8 -1
  38. package/dist/core/tree/pathTree.js.map +1 -1
  39. package/dist/core/tree/visitDelta.d.ts +7 -5
  40. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  41. package/dist/core/tree/visitDelta.js +19 -9
  42. package/dist/core/tree/visitDelta.js.map +1 -1
  43. package/dist/core/tree/visitorUtils.d.ts +5 -23
  44. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  45. package/dist/core/tree/visitorUtils.js +8 -5
  46. package/dist/core/tree/visitorUtils.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  49. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  51. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/chunkTree.js +10 -7
  53. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  55. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/chunkedForest.js +5 -2
  57. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  65. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  67. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  68. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  70. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  72. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  74. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts +1 -0
  76. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.js +3 -1
  78. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  79. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  80. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  81. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
  82. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  83. package/dist/feature-libraries/deltaUtils.js +1 -1
  84. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  85. package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
  86. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  87. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  88. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  89. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  90. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  91. package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  92. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  93. package/dist/feature-libraries/flex-tree/lazyField.js +9 -6
  94. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  96. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
  97. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  98. package/dist/feature-libraries/index.d.ts +2 -1
  99. package/dist/feature-libraries/index.d.ts.map +1 -1
  100. package/dist/feature-libraries/index.js +9 -7
  101. package/dist/feature-libraries/index.js.map +1 -1
  102. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  103. package/dist/feature-libraries/initializeForest.d.ts +18 -0
  104. package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
  105. package/dist/feature-libraries/initializeForest.js +35 -0
  106. package/dist/feature-libraries/initializeForest.js.map +1 -0
  107. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  108. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +9 -15
  110. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  111. package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
  112. package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
  113. package/dist/feature-libraries/node-identifier/index.js +16 -0
  114. package/dist/feature-libraries/node-identifier/index.js.map +1 -0
  115. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  116. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  117. package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
  118. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  119. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  120. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  121. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
  122. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  123. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  124. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  125. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
  126. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  127. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
  128. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  129. package/dist/feature-libraries/object-forest/objectForest.js +6 -2
  130. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  131. package/dist/feature-libraries/treeCursorUtils.js +1 -1
  132. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  133. package/dist/index.d.ts +3 -3
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +9 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/packageVersion.d.ts +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  141. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  142. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  143. package/dist/shared-tree/independentView.d.ts.map +1 -1
  144. package/dist/shared-tree/independentView.js +3 -18
  145. package/dist/shared-tree/independentView.js.map +1 -1
  146. package/dist/shared-tree/index.d.ts +1 -1
  147. package/dist/shared-tree/index.d.ts.map +1 -1
  148. package/dist/shared-tree/index.js +2 -1
  149. package/dist/shared-tree/index.js.map +1 -1
  150. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  151. package/dist/shared-tree/schematizeTree.js +3 -2
  152. package/dist/shared-tree/schematizeTree.js.map +1 -1
  153. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  154. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  155. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  156. package/dist/shared-tree/sharedTree.d.ts +1 -0
  157. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  158. package/dist/shared-tree/sharedTree.js +11 -7
  159. package/dist/shared-tree/sharedTree.js.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  161. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  163. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  164. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  165. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  166. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  167. package/dist/shared-tree/treeApiAlpha.d.ts +6 -31
  168. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  169. package/dist/shared-tree/treeApiAlpha.js +3 -18
  170. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  171. package/dist/shared-tree/treeCheckout.js +1 -1
  172. package/dist/shared-tree/treeCheckout.js.map +1 -1
  173. package/dist/simple-tree/api/conciseTree.d.ts +8 -2
  174. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/conciseTree.js +10 -1
  176. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  177. package/dist/simple-tree/api/create.d.ts +3 -3
  178. package/dist/simple-tree/api/create.d.ts.map +1 -1
  179. package/dist/simple-tree/api/create.js.map +1 -1
  180. package/dist/simple-tree/api/customTree.d.ts +42 -12
  181. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/customTree.js +30 -2
  183. package/dist/simple-tree/api/customTree.js.map +1 -1
  184. package/dist/simple-tree/api/index.d.ts +4 -3
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +6 -1
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaFactory.d.ts +12 -9
  189. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaFactory.js +16 -26
  191. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  193. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
  195. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
  197. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  198. package/dist/simple-tree/api/schemaFromSimple.js +60 -0
  199. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
  200. package/dist/simple-tree/api/simpleSchema.d.ts +3 -0
  201. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  202. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  203. package/dist/simple-tree/api/tree.d.ts +11 -5
  204. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  205. package/dist/simple-tree/api/tree.js +11 -2
  206. package/dist/simple-tree/api/tree.js.map +1 -1
  207. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  208. package/dist/simple-tree/api/treeNodeApi.js +2 -17
  209. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  210. package/dist/simple-tree/api/typesUnsafe.d.ts +15 -15
  211. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  212. package/dist/simple-tree/api/verboseTree.d.ts +16 -25
  213. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  214. package/dist/simple-tree/api/verboseTree.js +15 -10
  215. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  216. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  217. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  218. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  219. package/dist/simple-tree/flexList.d.ts +4 -5
  220. package/dist/simple-tree/flexList.d.ts.map +1 -1
  221. package/dist/simple-tree/flexList.js +1 -14
  222. package/dist/simple-tree/flexList.js.map +1 -1
  223. package/dist/simple-tree/index.d.ts +2 -2
  224. package/dist/simple-tree/index.d.ts.map +1 -1
  225. package/dist/simple-tree/index.js +7 -2
  226. package/dist/simple-tree/index.js.map +1 -1
  227. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  228. package/dist/simple-tree/objectNode.js +2 -0
  229. package/dist/simple-tree/objectNode.js.map +1 -1
  230. package/dist/simple-tree/schemaTypes.d.ts +34 -2
  231. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  232. package/dist/simple-tree/schemaTypes.js +55 -2
  233. package/dist/simple-tree/schemaTypes.js.map +1 -1
  234. package/dist/simple-tree/toMapTree.d.ts +4 -4
  235. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  236. package/dist/simple-tree/toMapTree.js.map +1 -1
  237. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  238. package/dist/simple-tree/toStoredSchema.js +1 -5
  239. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  240. package/dist/simple-tree/treeNodeValid.d.ts +7 -1
  241. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  242. package/dist/simple-tree/treeNodeValid.js +13 -5
  243. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  244. package/dist/util/cloneWithReplacements.d.ts +21 -0
  245. package/dist/util/cloneWithReplacements.d.ts.map +1 -0
  246. package/dist/util/cloneWithReplacements.js +38 -0
  247. package/dist/util/cloneWithReplacements.js.map +1 -0
  248. package/dist/util/index.d.ts +1 -0
  249. package/dist/util/index.d.ts.map +1 -1
  250. package/dist/util/index.js +3 -1
  251. package/dist/util/index.js.map +1 -1
  252. package/dist/util/referenceCounting.d.ts +18 -0
  253. package/dist/util/referenceCounting.d.ts.map +1 -1
  254. package/dist/util/referenceCounting.js.map +1 -1
  255. package/lib/alpha.d.ts +6 -0
  256. package/lib/core/forest/editableForest.d.ts +1 -14
  257. package/lib/core/forest/editableForest.d.ts.map +1 -1
  258. package/lib/core/forest/editableForest.js +0 -26
  259. package/lib/core/forest/editableForest.js.map +1 -1
  260. package/lib/core/forest/forest.d.ts +16 -3
  261. package/lib/core/forest/forest.d.ts.map +1 -1
  262. package/lib/core/forest/forest.js +4 -1
  263. package/lib/core/forest/forest.js.map +1 -1
  264. package/lib/core/forest/index.d.ts +1 -1
  265. package/lib/core/forest/index.d.ts.map +1 -1
  266. package/lib/core/forest/index.js +1 -1
  267. package/lib/core/forest/index.js.map +1 -1
  268. package/lib/core/index.d.ts +2 -2
  269. package/lib/core/index.d.ts.map +1 -1
  270. package/lib/core/index.js +2 -2
  271. package/lib/core/index.js.map +1 -1
  272. package/lib/core/tree/anchorSet.d.ts +8 -3
  273. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  274. package/lib/core/tree/anchorSet.js +12 -5
  275. package/lib/core/tree/anchorSet.js.map +1 -1
  276. package/lib/core/tree/delta.d.ts +8 -23
  277. package/lib/core/tree/delta.d.ts.map +1 -1
  278. package/lib/core/tree/delta.js.map +1 -1
  279. package/lib/core/tree/deltaUtil.d.ts +3 -3
  280. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  281. package/lib/core/tree/deltaUtil.js +2 -2
  282. package/lib/core/tree/deltaUtil.js.map +1 -1
  283. package/lib/core/tree/index.d.ts +2 -2
  284. package/lib/core/tree/index.d.ts.map +1 -1
  285. package/lib/core/tree/index.js +1 -1
  286. package/lib/core/tree/index.js.map +1 -1
  287. package/lib/core/tree/pathTree.d.ts +54 -1
  288. package/lib/core/tree/pathTree.d.ts.map +1 -1
  289. package/lib/core/tree/pathTree.js +6 -0
  290. package/lib/core/tree/pathTree.js.map +1 -1
  291. package/lib/core/tree/visitDelta.d.ts +7 -5
  292. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  293. package/lib/core/tree/visitDelta.js +19 -9
  294. package/lib/core/tree/visitDelta.js.map +1 -1
  295. package/lib/core/tree/visitorUtils.d.ts +5 -23
  296. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  297. package/lib/core/tree/visitorUtils.js +8 -5
  298. package/lib/core/tree/visitorUtils.js.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  300. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  301. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  302. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  303. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/chunkTree.js +11 -8
  305. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  307. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -3
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  316. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  317. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  319. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  320. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  322. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  324. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  325. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  326. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  327. package/lib/feature-libraries/default-schema/index.d.ts +1 -0
  328. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  329. package/lib/feature-libraries/default-schema/index.js +1 -0
  330. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  331. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  332. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  333. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
  334. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  335. package/lib/feature-libraries/deltaUtils.js +1 -1
  336. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  337. package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
  338. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  339. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  340. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  341. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  342. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  343. package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  344. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  345. package/lib/feature-libraries/flex-tree/lazyField.js +11 -8
  346. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  347. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  348. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  349. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  350. package/lib/feature-libraries/index.d.ts +2 -1
  351. package/lib/feature-libraries/index.d.ts.map +1 -1
  352. package/lib/feature-libraries/index.js +2 -1
  353. package/lib/feature-libraries/index.js.map +1 -1
  354. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  355. package/lib/feature-libraries/initializeForest.d.ts +18 -0
  356. package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
  357. package/lib/feature-libraries/initializeForest.js +31 -0
  358. package/lib/feature-libraries/initializeForest.js.map +1 -0
  359. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  360. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  361. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -16
  362. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  363. package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
  364. package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
  365. package/lib/feature-libraries/node-identifier/index.js +8 -0
  366. package/lib/feature-libraries/node-identifier/index.js.map +1 -0
  367. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  368. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  369. package/lib/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +16 -16
  370. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  371. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  372. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  373. package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
  374. package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  375. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  376. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  377. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
  378. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  379. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
  380. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  381. package/lib/feature-libraries/object-forest/objectForest.js +6 -2
  382. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  383. package/lib/feature-libraries/treeCursorUtils.js +1 -1
  384. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  385. package/lib/index.d.ts +3 -3
  386. package/lib/index.d.ts.map +1 -1
  387. package/lib/index.js +2 -1
  388. package/lib/index.js.map +1 -1
  389. package/lib/packageVersion.d.ts +1 -1
  390. package/lib/packageVersion.js +1 -1
  391. package/lib/packageVersion.js.map +1 -1
  392. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  393. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  394. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  395. package/lib/shared-tree/independentView.d.ts.map +1 -1
  396. package/lib/shared-tree/independentView.js +5 -20
  397. package/lib/shared-tree/independentView.js.map +1 -1
  398. package/lib/shared-tree/index.d.ts +1 -1
  399. package/lib/shared-tree/index.d.ts.map +1 -1
  400. package/lib/shared-tree/index.js +1 -1
  401. package/lib/shared-tree/index.js.map +1 -1
  402. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  403. package/lib/shared-tree/schematizeTree.js +3 -2
  404. package/lib/shared-tree/schematizeTree.js.map +1 -1
  405. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  406. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  407. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  408. package/lib/shared-tree/sharedTree.d.ts +1 -0
  409. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  410. package/lib/shared-tree/sharedTree.js +9 -6
  411. package/lib/shared-tree/sharedTree.js.map +1 -1
  412. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  413. package/lib/shared-tree/sharedTreeChangeFamily.js +1 -1
  414. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  415. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  416. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  417. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  418. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  419. package/lib/shared-tree/treeApiAlpha.d.ts +6 -31
  420. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  421. package/lib/shared-tree/treeApiAlpha.js +3 -18
  422. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  423. package/lib/shared-tree/treeCheckout.js +2 -2
  424. package/lib/shared-tree/treeCheckout.js.map +1 -1
  425. package/lib/simple-tree/api/conciseTree.d.ts +8 -2
  426. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  427. package/lib/simple-tree/api/conciseTree.js +9 -1
  428. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  429. package/lib/simple-tree/api/create.d.ts +3 -3
  430. package/lib/simple-tree/api/create.d.ts.map +1 -1
  431. package/lib/simple-tree/api/create.js.map +1 -1
  432. package/lib/simple-tree/api/customTree.d.ts +42 -12
  433. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  434. package/lib/simple-tree/api/customTree.js +29 -2
  435. package/lib/simple-tree/api/customTree.js.map +1 -1
  436. package/lib/simple-tree/api/index.d.ts +4 -3
  437. package/lib/simple-tree/api/index.d.ts.map +1 -1
  438. package/lib/simple-tree/api/index.js +4 -3
  439. package/lib/simple-tree/api/index.js.map +1 -1
  440. package/lib/simple-tree/api/schemaFactory.d.ts +12 -9
  441. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  442. package/lib/simple-tree/api/schemaFactory.js +14 -23
  443. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  445. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  446. package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
  447. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  448. package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
  449. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  450. package/lib/simple-tree/api/schemaFromSimple.js +56 -0
  451. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
  452. package/lib/simple-tree/api/simpleSchema.d.ts +3 -0
  453. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  455. package/lib/simple-tree/api/tree.d.ts +11 -5
  456. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  457. package/lib/simple-tree/api/tree.js +12 -3
  458. package/lib/simple-tree/api/tree.js.map +1 -1
  459. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  460. package/lib/simple-tree/api/treeNodeApi.js +4 -19
  461. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  462. package/lib/simple-tree/api/typesUnsafe.d.ts +15 -15
  463. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  464. package/lib/simple-tree/api/verboseTree.d.ts +16 -25
  465. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  466. package/lib/simple-tree/api/verboseTree.js +14 -10
  467. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  468. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  469. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  470. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  471. package/lib/simple-tree/flexList.d.ts +4 -5
  472. package/lib/simple-tree/flexList.d.ts.map +1 -1
  473. package/lib/simple-tree/flexList.js +0 -12
  474. package/lib/simple-tree/flexList.js.map +1 -1
  475. package/lib/simple-tree/index.d.ts +2 -2
  476. package/lib/simple-tree/index.d.ts.map +1 -1
  477. package/lib/simple-tree/index.js +2 -2
  478. package/lib/simple-tree/index.js.map +1 -1
  479. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  480. package/lib/simple-tree/objectNode.js +2 -0
  481. package/lib/simple-tree/objectNode.js.map +1 -1
  482. package/lib/simple-tree/schemaTypes.d.ts +34 -2
  483. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  484. package/lib/simple-tree/schemaTypes.js +54 -3
  485. package/lib/simple-tree/schemaTypes.js.map +1 -1
  486. package/lib/simple-tree/toMapTree.d.ts +4 -4
  487. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  488. package/lib/simple-tree/toMapTree.js.map +1 -1
  489. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  490. package/lib/simple-tree/toStoredSchema.js +3 -7
  491. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  492. package/lib/simple-tree/treeNodeValid.d.ts +7 -1
  493. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  494. package/lib/simple-tree/treeNodeValid.js +13 -5
  495. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  496. package/lib/util/cloneWithReplacements.d.ts +21 -0
  497. package/lib/util/cloneWithReplacements.d.ts.map +1 -0
  498. package/lib/util/cloneWithReplacements.js +34 -0
  499. package/lib/util/cloneWithReplacements.js.map +1 -0
  500. package/lib/util/index.d.ts +1 -0
  501. package/lib/util/index.d.ts.map +1 -1
  502. package/lib/util/index.js +1 -0
  503. package/lib/util/index.js.map +1 -1
  504. package/lib/util/referenceCounting.d.ts +18 -0
  505. package/lib/util/referenceCounting.d.ts.map +1 -1
  506. package/lib/util/referenceCounting.js.map +1 -1
  507. package/package.json +22 -22
  508. package/src/core/forest/editableForest.ts +1 -52
  509. package/src/core/forest/forest.ts +17 -2
  510. package/src/core/forest/index.ts +0 -1
  511. package/src/core/index.ts +4 -2
  512. package/src/core/tree/anchorSet.ts +41 -10
  513. package/src/core/tree/delta.ts +8 -25
  514. package/src/core/tree/deltaUtil.ts +5 -5
  515. package/src/core/tree/index.ts +4 -1
  516. package/src/core/tree/pathTree.ts +72 -1
  517. package/src/core/tree/visitDelta.ts +38 -17
  518. package/src/core/tree/visitorUtils.ts +22 -36
  519. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  520. package/src/feature-libraries/chunked-forest/chunkTree.ts +19 -8
  521. package/src/feature-libraries/chunked-forest/chunkedForest.ts +9 -4
  522. package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
  523. package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
  524. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  525. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -2
  526. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
  527. package/src/feature-libraries/default-schema/index.ts +2 -0
  528. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
  529. package/src/feature-libraries/deltaUtils.ts +1 -1
  530. package/src/feature-libraries/flex-tree/context.ts +4 -4
  531. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
  532. package/src/feature-libraries/flex-tree/lazyField.ts +19 -10
  533. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
  534. package/src/feature-libraries/index.ts +10 -8
  535. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  536. package/src/feature-libraries/initializeForest.ts +55 -0
  537. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +12 -28
  538. package/src/feature-libraries/node-identifier/README.md +11 -0
  539. package/src/feature-libraries/node-identifier/index.ts +17 -0
  540. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
  541. package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
  542. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
  543. package/src/feature-libraries/object-forest/objectForest.ts +10 -3
  544. package/src/feature-libraries/treeCursorUtils.ts +1 -1
  545. package/src/index.ts +17 -10
  546. package/src/packageVersion.ts +1 -1
  547. package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
  548. package/src/shared-tree/independentView.ts +5 -29
  549. package/src/shared-tree/index.ts +1 -0
  550. package/src/shared-tree/schematizeTree.ts +3 -2
  551. package/src/shared-tree/schematizingTreeView.ts +3 -3
  552. package/src/shared-tree/sharedTree.ts +13 -9
  553. package/src/shared-tree/sharedTreeChangeFamily.ts +0 -1
  554. package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
  555. package/src/shared-tree/treeApiAlpha.ts +15 -78
  556. package/src/shared-tree/treeCheckout.ts +2 -2
  557. package/src/simple-tree/api/conciseTree.ts +25 -8
  558. package/src/simple-tree/api/create.ts +3 -3
  559. package/src/simple-tree/api/customTree.ts +59 -16
  560. package/src/simple-tree/api/index.ts +10 -1
  561. package/src/simple-tree/api/schemaFactory.ts +18 -32
  562. package/src/simple-tree/api/schemaFactoryAlpha.ts +12 -0
  563. package/src/simple-tree/api/schemaFromSimple.ts +68 -0
  564. package/src/simple-tree/api/simpleSchema.ts +10 -0
  565. package/src/simple-tree/api/tree.ts +13 -8
  566. package/src/simple-tree/api/treeNodeApi.ts +4 -17
  567. package/src/simple-tree/api/typesUnsafe.ts +15 -15
  568. package/src/simple-tree/api/verboseTree.ts +43 -55
  569. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  570. package/src/simple-tree/flexList.ts +4 -14
  571. package/src/simple-tree/index.ts +6 -0
  572. package/src/simple-tree/objectNode.ts +3 -0
  573. package/src/simple-tree/schemaTypes.ts +70 -4
  574. package/src/simple-tree/toMapTree.ts +6 -6
  575. package/src/simple-tree/toStoredSchema.ts +3 -6
  576. package/src/simple-tree/treeNodeValid.ts +16 -5
  577. package/src/util/cloneWithReplacements.ts +41 -0
  578. package/src/util/index.ts +2 -0
  579. package/src/util/referenceCounting.ts +18 -1
  580. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  581. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  582. package/dist/feature-libraries/node-key/index.d.ts +0 -8
  583. package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
  584. package/dist/feature-libraries/node-key/index.js +0 -16
  585. package/dist/feature-libraries/node-key/index.js.map +0 -1
  586. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  587. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  588. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  589. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
  590. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  591. package/dist/feature-libraries/node-key/nodeKey.js +0 -26
  592. package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
  593. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  594. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  595. package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
  596. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  597. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  598. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  599. package/lib/feature-libraries/node-key/index.d.ts +0 -8
  600. package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
  601. package/lib/feature-libraries/node-key/index.js +0 -8
  602. package/lib/feature-libraries/node-key/index.js.map +0 -1
  603. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  604. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  605. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  606. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
  607. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  608. package/lib/feature-libraries/node-key/nodeKey.js +0 -22
  609. package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
  610. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  611. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  612. package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
  613. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  614. package/src/feature-libraries/node-key/README.md +0 -11
  615. package/src/feature-libraries/node-key/index.ts +0 -17
  616. package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
  617. package/src/feature-libraries/node-key/nodeKey.ts +0 -47
  618. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
  619. /package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeValid.js","sourceRoot":"","sources":["../../src/simple-tree/treeNodeValid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,8CAYyB;AACzB,4DAAkF;AAClF,uEAAsE;AACtE,+CAAwC;AAExC,8CAAmE;AACnE,+CAA0C;AAE1C;;;;;;;GAOG;AACH,MAAsB,aAAsB,SAAQ,mBAAQ;IAC3D;;;;;;;OAOG;IACO,MAAM,CAAC,eAAe,CAE/B,QAA0B,EAC1B,KAAmB;QAEnB,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,YAAY,CAE5B,QAA0B,EAC1B,KAAQ;QAER,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5D,CAAC;IAED;;;OAGG;IACO,MAAM,CAAC,YAAY;QAC5B,IAAA,eAAI,EAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACxC,CAAC;IAsBD;;OAEG;IACI,MAAM,CAAC,eAAe;QAC5B,IAAA,iBAAM,EAAC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AC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,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\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\tisTreeNode,\n\tTreeNodeKernel,\n\tprivateToken,\n\tTreeNode,\n\ttype InternalTreeNode,\n\ttypeSchemaSymbol,\n\ttype InnerNode,\n\ttype Context,\n\ttype UnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { type FlexTreeNode, isFlexTreeNode } from \"../feature-libraries/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { fail } from \"../util/index.js\";\n\nimport { getSimpleNodeSchemaFromInnerNode } from \"./core/index.js\";\nimport { markEager } from \"./flexList.js\";\n\n/**\n * Class which all {@link TreeNode}s must extend.\n * Since this is not exported, it allows robust detection of attempts to create TreeNodes which do not go through SchemaFactory which is the only place which exposes classes that extend this.\n *\n * This has static members which schema classes can override to provide schema specific functionality.\n * These static members are only intended to be used / overridden by code within this package, and are used by the various node kinds.\n * Access to these static members has to be done via `this.constructor.staticMember` to support the overrides, and thus can only be used in the constructor, after the base constructor has been invoked.\n */\nexport abstract class TreeNodeValid<TInput> extends TreeNode {\n\t/**\n\t * Schema classes can override this to control what happens at the end of the constructor.\n\t * The return value from this is returned from the constructor, allowing substituting a proxy if desired.\n\t *\n\t * This is not simply done in the derived constructor to enable:\n\t * - this class to access the value which is being returned before it's returned from the constructor.\n\t * - the derived class to be provided the input `FlexTreeNode` without relying on a field on the node to hold it.\n\t */\n\tprotected static prepareInstance<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: FlexTreeNode,\n\t): TreeNodeValid<T> {\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Schema classes must override to provide an implementation of RawTreeNode construction.\n\t */\n\tprotected static buildRawNode<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: T,\n\t): UnhydratedFlexTreeNode {\n\t\treturn fail(0xae4 /* Schema must override buildRawNode */);\n\t}\n\n\t/**\n\t * Schema classes can override to provide a callback that is called once when the first node is constructed.\n\t * This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.\n\t */\n\tprotected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): Context {\n\t\tfail(0xae5 /* Missing oneTimeSetup */);\n\t}\n\n\t/**\n\t * The most derived constructor (the one invoked with the `new` operator, not a parent class constructor invoked with as `super`) used to construct an instance of this type.\n\t * @remarks\n\t * Captured when an instance is constructed.\n\t *\n\t * Used to ensure that some derived class (which must override this member, defaulting it to `undefined`) is only instantiated with a single \"most derived\" class (the constructor actually invoked the the user with `new`).\n\t *\n\t * Typically this is override in the class that statically implements {@link TreeNodeSchema} to enforce that all nodes using that schema use the same class and not different subclasses of it.\n\t *\n\t * Also used to detect if oneTimeSetup has run.\n\t *\n\t * @privateRemarks\n\t * This defaults to \"default\", which is used to trigger an error if not overridden in the derived class.\n\t *\n\t * The value of this on TreeNodeValid must only be overridden by base classes and never modified.\n\t * Ways to enforce this immutability prevent it from being overridden,\n\t * so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.\n\t */\n\tprotected static constructorCached: MostDerivedData | \"default\" | undefined = \"default\";\n\n\t/**\n\t * Indicate that `this` is the most derived version of a schema, and thus the only one allowed to be used (other than by being subclassed a single time).\n\t */\n\tpublic static markMostDerived(this: typeof TreeNodeValid & TreeNodeSchema): MostDerivedData {\n\t\tassert(this.constructorCached !== \"default\", 0x95f /* invalid schema class */);\n\n\t\tif (this.constructorCached === undefined) {\n\t\t\t// Set the constructorCached on the layer of the prototype chain that declared it.\n\t\t\t// This is necessary to ensure there is only one subclass of that type used:\n\t\t\t// if constructorCached was simply set on `schema`,\n\t\t\t// then a base classes between `schema` (exclusive) and where `constructorCached` is set (inclusive) and other subclasses of them\n\t\t\t// would not see the stored `constructorCached`, and the validation above against multiple derived classes would not work.\n\n\t\t\t// This is not just an alias of `this`, but a reference to the item in the prototype chain being walked, which happens to start at `this`.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias, unicorn/no-this-assignment\n\t\t\tlet schemaBase: typeof TreeNodeValid = this;\n\t\t\twhile (!Object.prototype.hasOwnProperty.call(schemaBase, \"constructorCached\")) {\n\t\t\t\tschemaBase = Reflect.getPrototypeOf(schemaBase) as typeof TreeNodeValid;\n\t\t\t}\n\t\t\tassert(schemaBase.constructorCached === undefined, 0x962 /* overwriting wrong cache */);\n\t\t\tschemaBase.constructorCached = { constructor: this, oneTimeInitialized: undefined };\n\t\t\tassert(\n\t\t\t\tthis.constructorCached === schemaBase.constructorCached,\n\t\t\t\t0x9b5 /* Inheritance should work */,\n\t\t\t);\n\t\t\treturn this.constructorCached;\n\t\t} else if (this.constructorCached.constructor === this) {\n\t\t\treturn this.constructorCached;\n\t\t}\n\n\t\t// If users trying to diagnose the cause of this error becomes a common issue, more information could be captured.\n\t\t// The call stack to when a schema is first marked most derived could be captured in debug builds and stored in the `MostDerivedData` object:\n\t\t// This could then be included in the error to aid in debugging this error.\n\t\tthrow new UsageError(\n\t\t\t`Two schema classes were used (${this.name} and ${\n\t\t\t\tthis.constructorCached.constructor.name\n\t\t\t}) which derived from the same SchemaFactory generated class (${JSON.stringify(\n\t\t\t\tthis.identifier,\n\t\t\t)}). This is invalid.`,\n\t\t);\n\t}\n\n\t/**\n\t * Node creation function for implementing the TreeNodeSchemaNonClass half of TreeNodeSchemaBoth.\n\t * @remarks\n\t * When used as TreeNodeSchemaNonClass and subclassed,\n\t * does not actually have the correct compile time type for the return value due to TypeScript limitations.\n\t * This is why this is not exposed as part of TreeNodeSchemaClass where subclassing is allowed.\n\t */\n\tpublic static create<TInput, TOut, TThis extends new (args: TInput) => TOut>(\n\t\tthis: TThis,\n\t\tinput: TInput,\n\t): TOut {\n\t\treturn new this(input);\n\t}\n\n\t/**\n\t * @see {@link TreeNodeSchemaCore.createFromInsertable}.\n\t */\n\tpublic static createFromInsertable<TInput, TOut, TThis extends new (args: TInput) => TOut>(\n\t\tthis: TThis,\n\t\tinput: TInput,\n\t): TOut {\n\t\treturn new this(input);\n\t}\n\n\tpublic constructor(input: TInput | InternalTreeNode) {\n\t\tsuper(privateToken);\n\t\tconst schema = this.constructor as typeof TreeNodeValid & TreeNodeSchema;\n\t\tconst cache = schema.markMostDerived();\n\t\tif (cache.oneTimeInitialized === undefined) {\n\t\t\tcache.oneTimeInitialized = schema.oneTimeSetup();\n\t\t}\n\n\t\tif (isTreeNode(input)) {\n\t\t\t// TODO: update this once we have better support for deep-copying and move operations.\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes). Currently no API is provided to make deep copies, but it can be done manually with object spreads - for example `new Foo({...oldFoo})` will work if all fields of `oldFoo` are leaf nodes.\",\n\t\t\t);\n\t\t}\n\n\t\tconst node: InnerNode = isFlexTreeNode(input) ? input : schema.buildRawNode(this, input);\n\t\tassert(\n\t\t\tgetSimpleNodeSchemaFromInnerNode(node) === schema,\n\t\t\t0x83b /* building node with wrong schema */,\n\t\t);\n\n\t\tconst result = schema.prepareInstance(this, node);\n\t\t// The TreeNodeKernel associates itself the TreeNode (result here, not node) so it can be looked up later via getKernel.\n\t\t// If desired this could be put in a non-enumerable symbol property for lookup instead, but that gets messy going through proxies,\n\t\t// so just relying on the WeakMap seems like the cleanest approach.\n\t\tnew TreeNodeKernel(result, schema, node, cache.oneTimeInitialized);\n\n\t\treturn result;\n\t}\n}\n// Class objects are functions (callable), so we need a strong way to distinguish between `schema` and `() => schema` when used as a `LazyItem`.\nmarkEager(TreeNodeValid);\n\n/**\n * Data cached about the most derived type in a schema's class hierarchy.\n * @remarks\n * The most derived type is the only one allowed to be referenced by other schema or constructed as a node.\n * It has to be discovered lazily (when a node is constructed or when a {@link TreeViewConfiguration} is made),\n * since JavaScript provides no way to find derived classes, or inject static class initialization time logic into base classes.\n * Additionally since schema can reference other schema through lazy references which might be forward or recursive references,\n * this can not be evaluated for one schema when referenced by another schema.\n *\n * See {@link TreeNodeValid.constructorCached} and {@link TreeNodeValid.markMostDerived}.\n */\nexport interface MostDerivedData {\n\treadonly constructor: typeof TreeNodeValid & TreeNodeSchema;\n\toneTimeInitialized?: Context;\n}\n\n// #region NodeJS custom inspect for TreeNodes.\n\n/**\n * Used to customize \"inspect\" behavior in NodeJS.\n * See https://nodejs.org/api/util.html#utilinspectcustom for details.\n *\n * VS-Code's debugger also uses this to inspect objects,\n * see https://github.com/microsoft/vscode-js-debug/blob/64df2686c92bac402909dee5c3c389bbb7a81f6d/src/adapter/templates/getStringyProps.ts#L11 for details.\n */\nconst customInspectSymbol = Symbol.for(\"nodejs.util.inspect.custom\");\n\n/**\n * Node inspecting function for use with {@link customInspectSymbol}.\n */\nfunction inspectNodeFunction(\n\tthis: TreeNodeValid<unknown>,\n\tdepth: number,\n\toptions?: unknown,\n\tinspect?: unknown,\n): unknown {\n\tconst schema = this[typeSchemaSymbol];\n\tconst title = `${schema.name}: ${NodeKind[schema.kind]} Node (${schema.identifier})`;\n\n\tif (depth < 2) {\n\t\tconst short = shortContent(this);\n\t\tif (short !== undefined) {\n\t\t\treturn `${title} ${short}`;\n\t\t}\n\t\treturn title;\n\t}\n\tconst content = `${title} ${JSON.stringify(this)}`;\n\treturn content;\n}\n\n/**\n * If the node has no items, a short JSON string for it.\n */\nfunction shortContent(node: TreeNodeValid<unknown>): string | undefined {\n\tif (Object.values(node).length === 0) {\n\t\treturn JSON.stringify(node);\n\t}\n\treturn undefined;\n}\n\n/**\n * Add inherited non-enumerable symbol for NodeJS inspection to all nodes.\n *\n * See {@link customInspectSymbol}.\n */\nObject.defineProperty(TreeNodeValid.prototype, customInspectSymbol, {\n\tvalue: inspectNodeFunction,\n\tenumerable: false,\n});\n\n// #endregion\n\n// #region Browser custom debug format for TreeNodes\n\n// This section has side-effects, so including it in this file ensures its loaded whenever TreeNodes could exist.\n// Supported in at least Chrome and FireFox, more details at https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n// For this to work the browser's dev tools generally have to \"Enable custom formatters\".\n\n// This formatter is inspired by https://github.com/andrewdavey/immutable-devtools/blob/master/src/createFormatters.js which provides a similar formatter for the immutable.js library.\n\nconst globals = typeof window === \"undefined\" ? globalThis : window;\nconst formatters = ((\n\tglobals as { devtoolsFormatters?: DevtoolsFormatter.DevtoolsFormatter[] }\n).devtoolsFormatters ??= []);\n\nconst nodeFormatter: DevtoolsFormatter.DevtoolsFormatter = {\n\theader(object, config) {\n\t\tif (isTreeNode(object)) {\n\t\t\treturn [\"span\", `${inspectNodeFunction.call(object, 1)}`];\n\t\t}\n\t\treturn null;\n\t},\n\tbody(object, config): DevtoolsFormatter.Item {\n\t\tconst children: DevtoolsFormatter.Item[] = [];\n\t\tfor (const [key, value] of Object.entries(object as TreeNode)) {\n\t\t\tchildren.push([\"li\", [\"span\", `${key}: `], formattedReference(value)]);\n\t\t}\n\n\t\t// TODO:\n\t\t// for array nodes, this isn't great since (at least in FireFox) the list items show up with a prefixed number starting from 1.\n\t\t// This looks messy when followed by the array index.\n\t\t// Find a way to hide the list index.\n\t\t// { style: 'list-style-type: none` } did not seem to work.\n\n\t\treturn [\"ol\", ...children];\n\t},\n\thasBody(object, config) {\n\t\treturn shortContent(object as TreeNodeValid<undefined>) === undefined;\n\t},\n};\n\nfunction formattedReference(\n\tobject: unknown,\n\tconfig?: DevtoolsFormatter.ObjectConfig,\n): DevtoolsFormatter.Item {\n\tif (object === undefined) {\n\t\treturn [\"span\", \"undefined\"];\n\t} else if (object === \"null\") {\n\t\treturn [\"span\", \"null\"];\n\t}\n\n\treturn [\"object\", { object, config }];\n}\n\nformatters.push(nodeFormatter);\n\n// #endregion\n\n// These types are based on https://github.com/BenjaminAster/Better-TypeScript/blob/main/types/devtools-formatters.d.ts\n// however the original package causes multiple compile errors due to some of its other types it used, so the relevant part has been extracted and adjusted to better match our conventions.\ndeclare namespace DevtoolsFormatter {\n\ttype ObjectConfig = Record<string | symbol, unknown>;\n\n\ttype ElementTagName = \"div\" | \"span\" | \"ol\" | \"li\" | \"table\" | \"tr\" | \"td\";\n\n\ttype ElementTemplate = StyledElementTemplate | UnstyledElementTemplate;\n\n\ttype StyledElementTemplate = readonly [\n\t\tElementTagName,\n\t\t{\n\t\t\tstyle?: string;\n\t\t},\n\t\t...Item[],\n\t];\n\n\ttype UnstyledElementTemplate = readonly [ElementTagName, ...Item[]];\n\n\ttype ObjectReference = readonly [\n\t\t\"object\",\n\t\t{\n\t\t\tobject: unknown;\n\t\t\tconfig?: ObjectConfig;\n\t\t},\n\t];\n\n\ttype Item = string | ElementTemplate | ObjectReference;\n\n\tinterface DevtoolsFormatter {\n\t\theader(\n\t\t\tobject?: unknown,\n\t\t\tconfig?: ObjectConfig,\n\t\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\t): Item | null;\n\t\thasBody(object?: unknown, config?: ObjectConfig): boolean;\n\t\tbody(object?: unknown, config?: ObjectConfig): Item;\n\t}\n}\n"]}
1
+ {"version":3,"file":"treeNodeValid.js","sourceRoot":"","sources":["../../src/simple-tree/treeNodeValid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,8CAYyB;AACzB,4DAAkF;AAClF,uEAAsE;AACtE,+CAAwC;AAExC,8CAAmE;AACnE,+CAA0C;AAE1C;;;;;;;GAOG;AACH,MAAsB,aAAsB,SAAQ,mBAAQ;IAC3D;;;;;;;OAOG;IACO,MAAM,CAAC,eAAe,CAE/B,QAA0B,EAC1B,KAAmB;QAEnB,OAAO,QA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D,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,CAAC,MAAM,EAAE,MAAM;QACrB,OAAO,YAAY,CAAC,MAAkC,CAAC,KAAK,SAAS,CAAC;IACvE,CAAC;CACD,CAAC;AAEF,SAAS,kBAAkB,CAC1B,MAAe,EACf,MAAuC;IAEvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC9B,CAAC;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,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\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\tisTreeNode,\n\tTreeNodeKernel,\n\tprivateToken,\n\tTreeNode,\n\ttype InternalTreeNode,\n\ttypeSchemaSymbol,\n\ttype InnerNode,\n\ttype Context,\n\ttype UnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { type FlexTreeNode, isFlexTreeNode } from \"../feature-libraries/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { fail } from \"../util/index.js\";\n\nimport { getSimpleNodeSchemaFromInnerNode } from \"./core/index.js\";\nimport { markEager } from \"./flexList.js\";\n\n/**\n * Class which all {@link TreeNode}s must extend.\n * Since this is not exported, it allows robust detection of attempts to create TreeNodes which do not go through SchemaFactory which is the only place which exposes classes that extend this.\n *\n * This has static members which schema classes can override to provide schema specific functionality.\n * These static members are only intended to be used / overridden by code within this package, and are used by the various node kinds.\n * Access to these static members has to be done via `this.constructor.staticMember` to support the overrides, and thus can only be used in the constructor, after the base constructor has been invoked.\n */\nexport abstract class TreeNodeValid<TInput> extends TreeNode {\n\t/**\n\t * Schema classes can override this to control what happens at the end of the constructor.\n\t * The return value from this is returned from the constructor, allowing substituting a proxy if desired.\n\t *\n\t * This is not simply done in the derived constructor to enable:\n\t * - this class to access the value which is being returned before it's returned from the constructor.\n\t * - the derived class to be provided the input `FlexTreeNode` without relying on a field on the node to hold it.\n\t */\n\tprotected static prepareInstance<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: FlexTreeNode,\n\t): TreeNodeValid<T> {\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Schema classes must override to provide an implementation of RawTreeNode construction.\n\t */\n\tprotected static buildRawNode<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: T,\n\t): UnhydratedFlexTreeNode {\n\t\treturn fail(0xae4 /* Schema must override buildRawNode */);\n\t}\n\n\t/**\n\t * Schema classes can override to provide a callback that is called once when the first node is constructed.\n\t * This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.\n\t * @remarks\n\t * It is valid to dereference LazyItem schema references in this function (or anything that runs after it).\n\t */\n\tprotected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): Context {\n\t\tfail(0xae5 /* Missing oneTimeSetup */);\n\t}\n\n\t/**\n\t * The most derived constructor (the one invoked with the `new` operator, not a parent class constructor invoked with as `super`) used to construct an instance of this type.\n\t * @remarks\n\t * Captured when an instance is constructed.\n\t *\n\t * Used to ensure that some derived class (which must override this member, defaulting it to `undefined`) is only instantiated with a single \"most derived\" class (the constructor actually invoked the the user with `new`).\n\t *\n\t * Typically this is override in the class that statically implements {@link TreeNodeSchema} to enforce that all nodes using that schema use the same class and not different subclasses of it.\n\t *\n\t * Also used to detect if oneTimeSetup has run.\n\t *\n\t * @privateRemarks\n\t * This defaults to \"default\", which is used to trigger an error if not overridden in the derived class.\n\t *\n\t * The value of this on TreeNodeValid must only be overridden by base classes and never modified.\n\t * Ways to enforce this immutability prevent it from being overridden,\n\t * so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.\n\t */\n\tprotected static constructorCached: MostDerivedData | \"default\" | undefined = \"default\";\n\n\t/**\n\t * Indicate that `this` is the most derived version of a schema, and thus the only one allowed to be used (other than by being subclassed a single time).\n\t */\n\tpublic static markMostDerived(this: typeof TreeNodeValid & TreeNodeSchema): MostDerivedData {\n\t\tassert(this.constructorCached !== \"default\", 0x95f /* invalid schema class */);\n\n\t\tif (this.constructorCached === undefined) {\n\t\t\t// Set the constructorCached on the layer of the prototype chain that declared it.\n\t\t\t// This is necessary to ensure there is only one subclass of that type used:\n\t\t\t// if constructorCached was simply set on `schema`,\n\t\t\t// then a base classes between `schema` (exclusive) and where `constructorCached` is set (inclusive) and other subclasses of them\n\t\t\t// would not see the stored `constructorCached`, and the validation above against multiple derived classes would not work.\n\n\t\t\t// This is not just an alias of `this`, but a reference to the item in the prototype chain being walked, which happens to start at `this`.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias, unicorn/no-this-assignment\n\t\t\tlet schemaBase: typeof TreeNodeValid = this;\n\t\t\twhile (!Object.prototype.hasOwnProperty.call(schemaBase, \"constructorCached\")) {\n\t\t\t\tschemaBase = Reflect.getPrototypeOf(schemaBase) as typeof TreeNodeValid;\n\t\t\t}\n\t\t\tassert(schemaBase.constructorCached === undefined, 0x962 /* overwriting wrong cache */);\n\t\t\tschemaBase.constructorCached = { constructor: this, oneTimeInitialized: undefined };\n\t\t\tassert(\n\t\t\t\tthis.constructorCached === schemaBase.constructorCached,\n\t\t\t\t0x9b5 /* Inheritance should work */,\n\t\t\t);\n\t\t\treturn this.constructorCached;\n\t\t} else if (this.constructorCached.constructor === this) {\n\t\t\treturn this.constructorCached;\n\t\t}\n\n\t\t// If users trying to diagnose the cause of this error becomes a common issue, more information could be captured.\n\t\t// The call stack to when a schema is first marked most derived could be captured in debug builds and stored in the `MostDerivedData` object:\n\t\t// This could then be included in the error to aid in debugging this error.\n\t\tthrow new UsageError(\n\t\t\t`Two schema classes were used (${this.name} and ${\n\t\t\t\tthis.constructorCached.constructor.name\n\t\t\t}) which derived from the same SchemaFactory generated class (${JSON.stringify(\n\t\t\t\tthis.identifier,\n\t\t\t)}). This is invalid.`,\n\t\t);\n\t}\n\n\t/**\n\t * Node creation function for implementing the TreeNodeSchemaNonClass half of TreeNodeSchemaBoth.\n\t * @remarks\n\t * When used as TreeNodeSchemaNonClass and subclassed,\n\t * does not actually have the correct compile time type for the return value due to TypeScript limitations.\n\t * This is why this is not exposed as part of TreeNodeSchemaClass where subclassing is allowed.\n\t */\n\tpublic static create<TInput, TOut, TThis extends new (args: TInput) => TOut>(\n\t\tthis: TThis,\n\t\tinput: TInput,\n\t): TOut {\n\t\treturn new this(input);\n\t}\n\n\t/**\n\t * See {@link TreeNodeSchemaCore.createFromInsertable}.\n\t */\n\tpublic static createFromInsertable<TInput, TOut, TThis extends new (args: TInput) => TOut>(\n\t\tthis: TThis,\n\t\tinput: TInput,\n\t): TOut {\n\t\treturn new this(input);\n\t}\n\n\t/**\n\t * Idempotent initialization function that pre-caches data and can dereference lazy schema references.\n\t */\n\tpublic static oneTimeInitialize(\n\t\tthis: typeof TreeNodeValid & TreeNodeSchema,\n\t): Required<MostDerivedData> {\n\t\tconst cache = this.markMostDerived();\n\t\tcache.oneTimeInitialized ??= this.oneTimeSetup();\n\t\t// TypeScript fails to narrow the type of `oneTimeInitialized` to `Context` here, so use a cast:\n\t\treturn cache as MostDerivedData & { oneTimeInitialized: Context };\n\t}\n\n\tpublic constructor(input: TInput | InternalTreeNode) {\n\t\tsuper(privateToken);\n\t\tconst schema = this.constructor as typeof TreeNodeValid & TreeNodeSchema;\n\t\tconst cache = schema.oneTimeInitialize();\n\n\t\tif (isTreeNode(input)) {\n\t\t\t// TODO: update this once we have better support for deep-copying and move operations.\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes). Currently no API is provided to make deep copies, but it can be done manually with object spreads - for example `new Foo({...oldFoo})` will work if all fields of `oldFoo` are leaf nodes.\",\n\t\t\t);\n\t\t}\n\n\t\tconst node: InnerNode = isFlexTreeNode(input) ? input : schema.buildRawNode(this, input);\n\t\tassert(\n\t\t\tgetSimpleNodeSchemaFromInnerNode(node) === schema,\n\t\t\t0x83b /* building node with wrong schema */,\n\t\t);\n\n\t\tconst result = schema.prepareInstance(this, node);\n\t\t// The TreeNodeKernel associates itself the TreeNode (result here, not node) so it can be looked up later via getKernel.\n\t\t// If desired this could be put in a non-enumerable symbol property for lookup instead, but that gets messy going through proxies,\n\t\t// so just relying on the WeakMap seems like the cleanest approach.\n\t\tnew TreeNodeKernel(result, schema, node, cache.oneTimeInitialized);\n\n\t\treturn result;\n\t}\n}\n// Class objects are functions (callable), so we need a strong way to distinguish between `schema` and `() => schema` when used as a `LazyItem`.\nmarkEager(TreeNodeValid);\n\n/**\n * Data cached about the most derived type in a schema's class hierarchy.\n * @remarks\n * The most derived type is the only one allowed to be referenced by other schema or constructed as a node.\n * It has to be discovered lazily (when a node is constructed or when a {@link TreeViewConfiguration} is made),\n * since JavaScript provides no way to find derived classes, or inject static class initialization time logic into base classes.\n * Additionally since schema can reference other schema through lazy references which might be forward or recursive references,\n * this can not be evaluated for one schema when referenced by another schema.\n *\n * See {@link TreeNodeValid.constructorCached} and {@link TreeNodeValid.markMostDerived}.\n */\nexport interface MostDerivedData {\n\treadonly constructor: typeof TreeNodeValid & TreeNodeSchema;\n\toneTimeInitialized?: Context;\n}\n\n// #region NodeJS custom inspect for TreeNodes.\n\n/**\n * Used to customize \"inspect\" behavior in NodeJS.\n * See https://nodejs.org/api/util.html#utilinspectcustom for details.\n *\n * VS-Code's debugger also uses this to inspect objects,\n * see https://github.com/microsoft/vscode-js-debug/blob/64df2686c92bac402909dee5c3c389bbb7a81f6d/src/adapter/templates/getStringyProps.ts#L11 for details.\n */\nconst customInspectSymbol = Symbol.for(\"nodejs.util.inspect.custom\");\n\n/**\n * Node inspecting function for use with {@link customInspectSymbol}.\n */\nfunction inspectNodeFunction(\n\tthis: TreeNodeValid<unknown>,\n\tdepth: number,\n\toptions?: unknown,\n\tinspect?: unknown,\n): unknown {\n\tconst schema = this[typeSchemaSymbol];\n\tconst title = `${schema.name}: ${NodeKind[schema.kind]} Node (${schema.identifier})`;\n\n\tif (depth < 2) {\n\t\tconst short = shortContent(this);\n\t\tif (short !== undefined) {\n\t\t\treturn `${title} ${short}`;\n\t\t}\n\t\treturn title;\n\t}\n\tconst content = `${title} ${JSON.stringify(this)}`;\n\treturn content;\n}\n\n/**\n * If the node has no items, a short JSON string for it.\n */\nfunction shortContent(node: TreeNodeValid<unknown>): string | undefined {\n\tif (Object.values(node).length === 0) {\n\t\treturn JSON.stringify(node);\n\t}\n\treturn undefined;\n}\n\n/**\n * Add inherited non-enumerable symbol for NodeJS inspection to all nodes.\n *\n * See {@link customInspectSymbol}.\n */\nObject.defineProperty(TreeNodeValid.prototype, customInspectSymbol, {\n\tvalue: inspectNodeFunction,\n\tenumerable: false,\n});\n\n// #endregion\n\n// #region Browser custom debug format for TreeNodes\n\n// This section has side-effects, so including it in this file ensures its loaded whenever TreeNodes could exist.\n// Supported in at least Chrome and FireFox, more details at https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n// For this to work the browser's dev tools generally have to \"Enable custom formatters\".\n\n// This formatter is inspired by https://github.com/andrewdavey/immutable-devtools/blob/master/src/createFormatters.js which provides a similar formatter for the immutable.js library.\n\nconst globals = typeof window === \"undefined\" ? globalThis : window;\nconst formatters = ((\n\tglobals as { devtoolsFormatters?: DevtoolsFormatter.DevtoolsFormatter[] }\n).devtoolsFormatters ??= []);\n\nconst nodeFormatter: DevtoolsFormatter.DevtoolsFormatter = {\n\theader(object, config) {\n\t\tif (isTreeNode(object)) {\n\t\t\treturn [\"span\", `${inspectNodeFunction.call(object, 1)}`];\n\t\t}\n\t\treturn null;\n\t},\n\tbody(object, config): DevtoolsFormatter.Item {\n\t\tconst children: DevtoolsFormatter.Item[] = [];\n\t\tfor (const [key, value] of Object.entries(object as TreeNode)) {\n\t\t\tchildren.push([\"li\", [\"span\", `${key}: `], formattedReference(value)]);\n\t\t}\n\n\t\t// TODO:\n\t\t// for array nodes, this isn't great since (at least in FireFox) the list items show up with a prefixed number starting from 1.\n\t\t// This looks messy when followed by the array index.\n\t\t// Find a way to hide the list index.\n\t\t// { style: 'list-style-type: none` } did not seem to work.\n\n\t\treturn [\"ol\", ...children];\n\t},\n\thasBody(object, config) {\n\t\treturn shortContent(object as TreeNodeValid<undefined>) === undefined;\n\t},\n};\n\nfunction formattedReference(\n\tobject: unknown,\n\tconfig?: DevtoolsFormatter.ObjectConfig,\n): DevtoolsFormatter.Item {\n\tif (object === undefined) {\n\t\treturn [\"span\", \"undefined\"];\n\t} else if (object === \"null\") {\n\t\treturn [\"span\", \"null\"];\n\t}\n\n\treturn [\"object\", { object, config }];\n}\n\nformatters.push(nodeFormatter);\n\n// #endregion\n\n// These types are based on https://github.com/BenjaminAster/Better-TypeScript/blob/main/types/devtools-formatters.d.ts\n// however the original package causes multiple compile errors due to some of its other types it used, so the relevant part has been extracted and adjusted to better match our conventions.\ndeclare namespace DevtoolsFormatter {\n\ttype ObjectConfig = Record<string | symbol, unknown>;\n\n\ttype ElementTagName = \"div\" | \"span\" | \"ol\" | \"li\" | \"table\" | \"tr\" | \"td\";\n\n\ttype ElementTemplate = StyledElementTemplate | UnstyledElementTemplate;\n\n\ttype StyledElementTemplate = readonly [\n\t\tElementTagName,\n\t\t{\n\t\t\tstyle?: string;\n\t\t},\n\t\t...Item[],\n\t];\n\n\ttype UnstyledElementTemplate = readonly [ElementTagName, ...Item[]];\n\n\ttype ObjectReference = readonly [\n\t\t\"object\",\n\t\t{\n\t\t\tobject: unknown;\n\t\t\tconfig?: ObjectConfig;\n\t\t},\n\t];\n\n\ttype Item = string | ElementTemplate | ObjectReference;\n\n\tinterface DevtoolsFormatter {\n\t\theader(\n\t\t\tobject?: unknown,\n\t\t\tconfig?: ObjectConfig,\n\t\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\t): Item | null;\n\t\thasBody(object?: unknown, config?: ObjectConfig): boolean;\n\t\tbody(object?: unknown, config?: ObjectConfig): Item;\n\t}\n}\n"]}
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Like `JSON.stringify`, but returns a clone instead of stringifying the result.
7
+ *
8
+ * @remarks Only considers enumerable own properties with string keys.
9
+ *
10
+ * @param root - Data to clone.
11
+ * @param rootKey - The key to pass to replacer for the root.
12
+ * @param replacer - Like `JSON.stringify`'s replacer: called for every value while walking data. Unlike `JSON.stringify`'s replacer, this
13
+ * returns a wrapper around the value with a "clone" flag to indicate if the clone should recurse into that object (true) or use it as is (false).
14
+ * @returns A clone of `root`.
15
+ * @alpha
16
+ */
17
+ export declare function cloneWithReplacements(root: unknown, rootKey: string, replacer: (key: string, value: unknown) => {
18
+ clone: boolean;
19
+ value: unknown;
20
+ }): unknown;
21
+ //# sourceMappingURL=cloneWithReplacements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloneWithReplacements.d.ts","sourceRoot":"","sources":["../../src/util/cloneWithReplacements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC3E,OAAO,CAmBT"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.cloneWithReplacements = void 0;
8
+ /**
9
+ * Like `JSON.stringify`, but returns a clone instead of stringifying the result.
10
+ *
11
+ * @remarks Only considers enumerable own properties with string keys.
12
+ *
13
+ * @param root - Data to clone.
14
+ * @param rootKey - The key to pass to replacer for the root.
15
+ * @param replacer - Like `JSON.stringify`'s replacer: called for every value while walking data. Unlike `JSON.stringify`'s replacer, this
16
+ * returns a wrapper around the value with a "clone" flag to indicate if the clone should recurse into that object (true) or use it as is (false).
17
+ * @returns A clone of `root`.
18
+ * @alpha
19
+ */
20
+ function cloneWithReplacements(root, rootKey, replacer) {
21
+ const { clone, value } = replacer(rootKey, root);
22
+ if (clone === false) {
23
+ return value;
24
+ }
25
+ if (root === null || typeof root !== "object") {
26
+ return root;
27
+ }
28
+ if (Array.isArray(root)) {
29
+ return root.map((item, index) => cloneWithReplacements(item, index.toString(), replacer));
30
+ }
31
+ const result = {};
32
+ for (const [key, field] of Object.entries(root)) {
33
+ result[key] = cloneWithReplacements(field, key, replacer);
34
+ }
35
+ return result;
36
+ }
37
+ exports.cloneWithReplacements = cloneWithReplacements;
38
+ //# sourceMappingURL=cloneWithReplacements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloneWithReplacements.js","sourceRoot":"","sources":["../../src/util/cloneWithReplacements.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;GAWG;AACH,SAAgB,qBAAqB,CACpC,IAAa,EACb,OAAe,EACf,QAA6E;IAE7E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAvBD,sDAuBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Like `JSON.stringify`, but returns a clone instead of stringifying the result.\n *\n * @remarks Only considers enumerable own properties with string keys.\n *\n * @param root - Data to clone.\n * @param rootKey - The key to pass to replacer for the root.\n * @param replacer - Like `JSON.stringify`'s replacer: called for every value while walking data. Unlike `JSON.stringify`'s replacer, this\n * returns a wrapper around the value with a \"clone\" flag to indicate if the clone should recurse into that object (true) or use it as is (false).\n * @returns A clone of `root`.\n * @alpha\n */\nexport function cloneWithReplacements(\n\troot: unknown,\n\trootKey: string,\n\treplacer: (key: string, value: unknown) => { clone: boolean; value: unknown },\n): unknown {\n\tconst { clone, value } = replacer(rootKey, root);\n\tif (clone === false) {\n\t\treturn value;\n\t}\n\n\tif (root === null || typeof root !== \"object\") {\n\t\treturn root;\n\t}\n\n\tif (Array.isArray(root)) {\n\t\treturn root.map((item, index) => cloneWithReplacements(item, index.toString(), replacer));\n\t}\n\n\tconst result: Record<string, unknown> = {};\n\tfor (const [key, field] of Object.entries(root)) {\n\t\tresult[key] = cloneWithReplacements(field, key, replacer);\n\t}\n\treturn result;\n}\n"]}
@@ -19,4 +19,5 @@ export { RangeMap, type RangeQueryResult, newIntegerRangeMap, } from "./rangeMap
19
19
  export { type IdAllocator, idAllocatorFromMaxId, idAllocatorFromState, type IdAllocationState, fakeIdAllocator, } from "./idAllocator.js";
20
20
  export { Breakable, type WithBreakable, breakingMethod, throwIfBroken, breakingClass, } from "./breakable.js";
21
21
  export { type TupleBTree, newTupleBTree, mergeTupleBTrees } from "./bTreeUtils.js";
22
+ export { cloneWithReplacements } from "./cloneWithReplacements.js";
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO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EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBA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AsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.count = exports.find = exports.compareStrings = exports.transformObjectMap = exports.assertValidRangeIndices = exports.capitalize = exports.disposeSymbol = exports.compareNamed = exports.oneFromSet = exports.invertMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.filterIterable = exports.mapIterable = exports.makeArray = exports.JsonCompatibleReadOnlySchema = exports.isReadonlyArray = exports.isJsonObject = exports.getOrCreate = exports.getOrAddEmptyToMap = exports.fail = exports.compareSets = exports.clone = exports.balancedReduce = exports.asMutable = exports.StackyIterator = exports.OffsetListFactory = exports.nestedSetContains = exports.addToNestedSet = exports.getOrCreateInNestedMap = exports.nestedMapFromFlatList = exports.nestedMapToFlatList = exports.mapNestedMap = exports.tryGetFromNestedMap = exports.tryAddToNestedMap = exports.setInNestedMap = exports.populateNestedMap = exports.SizedNestedMap = exports.forEachInNestedMap = exports.getOrDefaultInNestedMap = exports.getOrAddInNestedMap = exports.deleteFromNestedMap = exports.extractFromOpaque = exports.brandOpaque = exports.brandedStringType = exports.brandedNumberType = exports.BrandedType = exports.brand = void 0;
8
- exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.getOrAddInMap = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = void 0;
8
+ exports.cloneWithReplacements = exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.getOrAddInMap = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = void 0;
9
9
  var brand_js_1 = require("./brand.js");
10
10
  Object.defineProperty(exports, "brand", { enumerable: true, get: function () { return brand_js_1.brand; } });
11
11
  Object.defineProperty(exports, "BrandedType", { enumerable: true, get: function () { return brand_js_1.BrandedType; } });
@@ -92,4 +92,6 @@ Object.defineProperty(exports, "breakingClass", { enumerable: true, get: functio
92
92
  var bTreeUtils_js_1 = require("./bTreeUtils.js");
93
93
  Object.defineProperty(exports, "newTupleBTree", { enumerable: true, get: function () { return bTreeUtils_js_1.newTupleBTree; } });
94
94
  Object.defineProperty(exports, "mergeTupleBTrees", { enumerable: true, get: function () { return bTreeUtils_js_1.mergeTupleBTrees; } });
95
+ var cloneWithReplacements_js_1 = require("./cloneWithReplacements.js");
96
+ Object.defineProperty(exports, "cloneWithReplacements", { enumerable: true, get: function () { return cloneWithReplacements_js_1.cloneWithReplacements; } });
95
97
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[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AAA;AACT,sGAAA,UAAU,OAAA;AAEV,wGAAA,YAAY,OAAA;AACZ,yGAAA,aAAa,OAAA;AAEb,sGAAA,UAAU,OAAA;AACV,mHAAA,uBAAuB,OAAA;AACvB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,gGAAA,IAAI,OAAA;AACJ,iGAAA,KAAK,OAAA;AACL,mGAAA,OAAO,OAAA;AACP,mGAAA,OAAO,OAAA;AACP,qGAAA,SAAS,OAAA;AACT,oHAAA,wBAAwB,OAAA;AACxB,wGAAA,qBAAqB,OAAgB;AACrC,yGAAA,aAAa,OAAA;AAEd,+DAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAc7B,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,iDAMyB;AAFxB,uHAAA,sBAAsB,OAAA;AACtB,4GAAA,WAAW,OAAA;AAGZ,6CAIuB;AAHtB,uGAAA,QAAQ,OAAA;AAER,iHAAA,kBAAkB,OAAA;AAGnB,mDAM0B;AAJzB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AAEpB,iHAAA,eAAe,OAAA;AAGhB,+CAMwB;AALvB,yGAAA,SAAS,OAAA;AAET,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AAGd,iDAAmF;AAAzD,8GAAA,aAAa,OAAA;AAAE,iHAAA,gBAAgB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tclone,\n\tcompareSets,\n\tfail,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromSet,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\tgetOrAddInMap,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\tnewIntegerRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport { type TupleBTree, newTupleBTree, mergeTupleBTrees } from \"./bTreeUtils.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,uCAMoB;AALnB,iGAAA,KAAK,OAAA;AAEL,uGAAA,WAAW,OAAA;AAIZ,qDAAyE;AAAhE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAC7C,yCAKqB;AAJpB,wGAAA,WAAW,OAAA;AACX,8GAAA,iBAAiB,OAAA;AAIlB,+CAgBwB;AAfvB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AACvB,kHAAA,kBAAkB,OAAA;AAGlB,8GAAA,cAAc,OAAA;AACd,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;A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AoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,iDAMyB;AAFxB,uHAAA,sBAAsB,OAAA;AACtB,4GAAA,WAAW,OAAA;AAGZ,6CAIuB;AAHtB,uGAAA,QAAQ,OAAA;AAER,iHAAA,kBAAkB,OAAA;AAGnB,mDAM0B;AAJzB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AAEpB,iHAAA,eAAe,OAAA;AAGhB,+CAMwB;AALvB,yGAAA,SAAS,OAAA;AAET,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AAGd,iDAAmF;AAAzD,8GAAA,aAAa,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAEzD,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tclone,\n\tcompareSets,\n\tfail,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromSet,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\tgetOrAddInMap,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\tnewIntegerRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport { type TupleBTree, newTupleBTree, mergeTupleBTrees } from \"./bTreeUtils.js\";\n\nexport { cloneWithReplacements } from \"./cloneWithReplacements.js\";\n"]}
@@ -2,8 +2,26 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * An object which counts the number of users / references to it.
7
+ * @remarks
8
+ * This implements the [Reference counting](https://en.wikipedia.org/wiki/Reference_counting) pattern.
9
+ * Getting the reference count correct is difficult in TypeScript and great care must be used.
10
+ * Because of this, this interface should not be used in the public API.
11
+ */
5
12
  export interface ReferenceCounted {
13
+ /**
14
+ * Called to increase the reference count tracked by this object.
15
+ * @remarks
16
+ * When a user of this object allows something else to use it,
17
+ * this should be called.
18
+ */
6
19
  referenceAdded(): void;
20
+ /**
21
+ * Called to decrease the reference count tracked by this object.
22
+ * @remarks
23
+ * When a user of this object will no longer use it, this should be called.
24
+ */
7
25
  referenceRemoved(): void;
8
26
  /**
9
27
  * @returns true if mutating this object may impact other users of it.
@@ -1 +1 @@
1
- {"version":3,"file":"referenceCounting.d.ts","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,gBAAgB;IAChC,cAAc,IAAI,IAAI,CAAC;IAEvB,gBAAgB,IAAI,IAAI,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IAC/C,OAAO,CAAC,QAAQ;IAAtC,SAAS,aAAqB,QAAQ,GAAE,MAAU;IAE3C,cAAc,CAAC,KAAK,SAAI,GAAG,IAAI;IAI/B,gBAAgB,CAAC,KAAK,SAAI,GAAG,IAAI;IAQjC,QAAQ,IAAI,OAAO;IAInB,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;CACzC"}
1
+ {"version":3,"file":"referenceCounting.d.ts","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,cAAc,IAAI,IAAI,CAAC;IACvB;;;;OAIG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IAC/C,OAAO,CAAC,QAAQ;IAAtC,SAAS,aAAqB,QAAQ,GAAE,MAAU;IAE3C,cAAc,CAAC,KAAK,SAAI,GAAG,IAAI;IAI/B,gBAAgB,CAAC,KAAK,SAAI,GAAG,IAAI;IAQjC,QAAQ,IAAI,OAAO;IAInB,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;CACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"referenceCounting.js","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAe7D;;GAEG;AACH,MAAsB,oBAAoB;IACzC,YAA8B,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAG,CAAC;IAE/C,cAAc,CAAC,KAAK,GAAG,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;IACxB,CAAC;IAEM,gBAAgB,CAAC,KAAK,GAAG,CAAC;QAChC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvB,IAAA,iBAAM,EAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,EAAE,CAAC;QACvB,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc;QACpB,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC5B,CAAC;CAMD;AA3BD,oDA2BC","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\";\n\nexport interface ReferenceCounted {\n\treferenceAdded(): void;\n\n\treferenceRemoved(): void;\n\n\t/**\n\t * @returns true if mutating this object may impact other users of it.\n\t *\n\t * Implementations can return true if the refcount is 1 OR the content is logically immutable.\n\t */\n\tisShared(): boolean;\n}\n\n/**\n * Base class to assist with implementing ReferenceCounted.\n */\nexport abstract class ReferenceCountedBase implements ReferenceCounted {\n\tprotected constructor(private refCount: number = 1) {}\n\n\tpublic referenceAdded(count = 1): void {\n\t\tthis.refCount += count;\n\t}\n\n\tpublic referenceRemoved(count = 1): void {\n\t\tthis.refCount -= count;\n\t\tassert(this.refCount >= 0, 0x4c4 /* Negative ref count */);\n\t\tif (this.refCount === 0) {\n\t\t\tthis.onUnreferenced();\n\t\t}\n\t}\n\n\tpublic isShared(): boolean {\n\t\treturn this.refCount > 1;\n\t}\n\n\tpublic isUnreferenced(): boolean {\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Called when refcount reaches 0.\n\t */\n\tprotected abstract onUnreferenced(): void;\n}\n"]}
1
+ {"version":3,"file":"referenceCounting.js","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAgC7D;;GAEG;AACH,MAAsB,oBAAoB;IACzC,YAA8B,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAG,CAAC;IAE/C,cAAc,CAAC,KAAK,GAAG,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;IACxB,CAAC;IAEM,gBAAgB,CAAC,KAAK,GAAG,CAAC;QAChC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvB,IAAA,iBAAM,EAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,EAAE,CAAC;QACvB,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc;QACpB,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC5B,CAAC;CAMD;AA3BD,oDA2BC","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\";\n\n/**\n * An object which counts the number of users / references to it.\n * @remarks\n * This implements the [Reference counting](https://en.wikipedia.org/wiki/Reference_counting) pattern.\n * Getting the reference count correct is difficult in TypeScript and great care must be used.\n * Because of this, this interface should not be used in the public API.\n */\nexport interface ReferenceCounted {\n\t/**\n\t * Called to increase the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object allows something else to use it,\n\t * this should be called.\n\t */\n\treferenceAdded(): void;\n\t/**\n\t * Called to decrease the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object will no longer use it, this should be called.\n\t */\n\treferenceRemoved(): void;\n\n\t/**\n\t * @returns true if mutating this object may impact other users of it.\n\t *\n\t * Implementations can return true if the refcount is 1 OR the content is logically immutable.\n\t */\n\tisShared(): boolean;\n}\n\n/**\n * Base class to assist with implementing ReferenceCounted.\n */\nexport abstract class ReferenceCountedBase implements ReferenceCounted {\n\tprotected constructor(private refCount: number = 1) {}\n\n\tpublic referenceAdded(count = 1): void {\n\t\tthis.refCount += count;\n\t}\n\n\tpublic referenceRemoved(count = 1): void {\n\t\tthis.refCount -= count;\n\t\tassert(this.refCount >= 0, 0x4c4 /* Negative ref count */);\n\t\tif (this.refCount === 0) {\n\t\t\tthis.onUnreferenced();\n\t\t}\n\t}\n\n\tpublic isShared(): boolean {\n\t\treturn this.refCount > 1;\n\t}\n\n\tpublic isUnreferenced(): boolean {\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Called when refcount reaches 0.\n\t */\n\tprotected abstract onUnreferenced(): void;\n}\n"]}
package/lib/alpha.d.ts CHANGED
@@ -109,6 +109,7 @@ export {
109
109
  ForestTypeExpensiveDebug,
110
110
  ForestTypeOptimized,
111
111
  ForestTypeReference,
112
+ HandleConverter,
112
113
  ICodecOptions,
113
114
  IdentifierIndex,
114
115
  Insertable,
@@ -168,16 +169,21 @@ export {
168
169
  VoidTransactionCallbackStatus,
169
170
  adaptEnum,
170
171
  asTreeViewAlpha,
172
+ cloneWithReplacements,
171
173
  comparePersistedSchema,
172
174
  createIdentifierIndex,
173
175
  createSimpleTreeIndex,
174
176
  enumFromStrings,
177
+ evaluateLazySchema,
175
178
  extractPersistedSchema,
176
179
  getBranch,
177
180
  getJsonSchema,
178
181
  independentInitializedView,
179
182
  independentView,
180
183
  noopValidator,
184
+ replaceConciseTreeHandles,
185
+ replaceHandles,
186
+ replaceVerboseTreeHandles,
181
187
  singletonSchema,
182
188
  typeboxValidator
183
189
  } from "./index.js";
@@ -2,10 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { IIdCompressor } from "@fluidframework/id-compressor";
6
- import type { RevisionTagCodec } from "../rebase/index.js";
7
5
  import type { FieldKey } from "../schema-stored/index.js";
8
- import { type Anchor, type DeltaVisitor, type DetachedField, type ITreeCursorSynchronous } from "../tree/index.js";
6
+ import type { Anchor, DeltaVisitor, DetachedField } from "../tree/index.js";
9
7
  import type { IForestSubscription, ITreeSubscriptionCursor } from "./forest.js";
10
8
  /**
11
9
  * Editing APIs.
@@ -23,17 +21,6 @@ export interface IEditableForest extends IForestSubscription {
23
21
  */
24
22
  acquireVisitor(): DeltaVisitor;
25
23
  }
26
- /**
27
- * Initializes the given forest with the given content.
28
- * @remarks The forest must be empty when this function is called.
29
- * This does not perform an edit in the typical sense.
30
- * 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.
31
- * 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).
32
- *
33
- * @remarks
34
- * This does not perform an edit: it updates the forest content as if there was an edit that did that.
35
- */
36
- export declare function initializeForest(forest: IEditableForest, content: readonly ITreeCursorSynchronous[], revisionTagCodec: RevisionTagCodec, idCompressor: IIdCompressor, visitAnchors?: boolean): void;
37
24
  /**
38
25
  * Ways to refer to a node in an IEditableForest.
39
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"editableForest.d.ts","sourceRoot":"","sources":["../../../src/core/forest/editableForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,KAAK,MAAM,EAEX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAK3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM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CAAC;AAE9D;GACG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,KAAK,IAAI,aAAa,CAE5F;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CAChC"}
@@ -2,32 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/core-utils/internal";
6
- import { combineVisitors, deltaForRootInitialization, makeDetachedFieldIndex, visitDelta, } from "../tree/index.js";
7
- /**
8
- * Initializes the given forest with the given content.
9
- * @remarks The forest must be empty when this function is called.
10
- * This does not perform an edit in the typical sense.
11
- * 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.
12
- * 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).
13
- *
14
- * @remarks
15
- * This does not perform an edit: it updates the forest content as if there was an edit that did that.
16
- */
17
- export function initializeForest(forest, content, revisionTagCodec, idCompressor, visitAnchors = false) {
18
- assert(forest.isEmpty, 0x747 /* forest must be empty */);
19
- const delta = deltaForRootInitialization(content);
20
- let visitor = forest.acquireVisitor();
21
- if (visitAnchors) {
22
- assert(forest.anchors.isEmpty(), 0x9b7 /* anchor set must be empty */);
23
- const anchorVisitor = forest.anchors.acquireVisitor();
24
- visitor = combineVisitors([visitor, anchorVisitor]);
25
- }
26
- // any detached trees built here are immediately attached so the revision used here doesn't matter
27
- // we use a dummy revision to make correctness checks in the detached field index easier
28
- visitDelta(delta, visitor, makeDetachedFieldIndex("init", revisionTagCodec, idCompressor), 0);
29
- visitor.free();
30
- }
31
5
  export function isFieldLocation(range) {
32
6
  return typeof range === "object";
33
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"editableForest.js","sourceRoot":"","sources":["../../../src/core/forest/editableForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAMN,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,UAAU,GACV,MAAM,kBAAkB,CAAC;AAqB1B;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAuB,EACvB,OAA0C,EAC1C,gBAAkC,EAClC,YAA2B,EAC3B,YAAY,GAAG,KAAK;IAEpB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACzD,MAAM,KAAK,GAAc,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC7D,IAAI,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACtC,IAAI,YAAY,EAAE,CAAC;QAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACvE,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QACtD,OAAO,GAAG,eAAe,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,kGAAkG;IAClG,wFAAwF;IACxF,UAAU,CACT,KAAK,EACL,OAAO,EACP,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAC9D,CAA6B,CAC7B,CAAC;IACF,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAgBD,MAAM,UAAU,eAAe,CAAC,KAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionSpaceCompressedId, IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\nimport {\n\ttype Anchor,\n\ttype DeltaRoot,\n\ttype DeltaVisitor,\n\ttype DetachedField,\n\ttype ITreeCursorSynchronous,\n\tcombineVisitors,\n\tdeltaForRootInitialization,\n\tmakeDetachedFieldIndex,\n\tvisitDelta,\n} from \"../tree/index.js\";\n\nimport type { IForestSubscription, ITreeSubscriptionCursor } from \"./forest.js\";\n\n/**\n * Editing APIs.\n */\nexport interface IEditableForest extends IForestSubscription {\n\t/**\n\t * Provides a visitor that can be used to mutate the forest.\n\t *\n\t * @returns a visitor that can be used to mutate the forest.\n\t *\n\t * @remarks\n\t * Mutating the forest does NOT update anchors.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one.\n\t */\n\tacquireVisitor(): DeltaVisitor;\n}\n\n/**\n * Initializes the given forest with the given content.\n * @remarks The forest must be empty when this function is called.\n * This does not perform an edit in the typical sense.\n * 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.\n * 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).\n *\n * @remarks\n * This does not perform an edit: it updates the forest content as if there was an edit that did that.\n */\nexport function initializeForest(\n\tforest: IEditableForest,\n\tcontent: readonly ITreeCursorSynchronous[],\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\tvisitAnchors = false,\n): void {\n\tassert(forest.isEmpty, 0x747 /* forest must be empty */);\n\tconst delta: DeltaRoot = deltaForRootInitialization(content);\n\tlet visitor = forest.acquireVisitor();\n\tif (visitAnchors) {\n\t\tassert(forest.anchors.isEmpty(), 0x9b7 /* anchor set must be empty */);\n\t\tconst anchorVisitor = forest.anchors.acquireVisitor();\n\t\tvisitor = combineVisitors([visitor, anchorVisitor]);\n\t}\n\n\t// any detached trees built here are immediately attached so the revision used here doesn't matter\n\t// we use a dummy revision to make correctness checks in the detached field index easier\n\tvisitDelta(\n\t\tdelta,\n\t\tvisitor,\n\t\tmakeDetachedFieldIndex(\"init\", revisionTagCodec, idCompressor),\n\t\t0 as SessionSpaceCompressedId,\n\t);\n\tvisitor.free();\n}\n\n// TODO: Types below here may be useful for input into edit building APIs, but are no longer used here directly.\n\n/**\n * Ways to refer to a node in an IEditableForest.\n */\nexport type ForestLocation = ITreeSubscriptionCursor | Anchor;\n\n/**\n */\nexport interface TreeLocation {\n\treadonly range: FieldLocation | DetachedField;\n\treadonly index: number;\n}\n\nexport function isFieldLocation(range: FieldLocation | DetachedField): range is FieldLocation {\n\treturn typeof range === \"object\";\n}\n\n/**\n * Location of a field within a tree that is not a detached/root field.\n */\nexport interface FieldLocation {\n\treadonly key: FieldKey;\n\treadonly parent: ForestLocation;\n}\n"]}
1
+ {"version":3,"file":"editableForest.js","sourceRoot":"","sources":["../../../src/core/forest/editableForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsCH,MAAM,UAAU,eAAe,CAAC,KAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FieldKey } from \"../schema-stored/index.js\";\nimport type { Anchor, DeltaVisitor, DetachedField } from \"../tree/index.js\";\n\nimport type { IForestSubscription, ITreeSubscriptionCursor } from \"./forest.js\";\n\n/**\n * Editing APIs.\n */\nexport interface IEditableForest extends IForestSubscription {\n\t/**\n\t * Provides a visitor that can be used to mutate the forest.\n\t *\n\t * @returns a visitor that can be used to mutate the forest.\n\t *\n\t * @remarks\n\t * Mutating the forest does NOT update anchors.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one.\n\t */\n\tacquireVisitor(): DeltaVisitor;\n}\n\n// TODO: Types below here may be useful for input into edit building APIs, but are no longer used here directly.\n\n/**\n * Ways to refer to a node in an IEditableForest.\n */\nexport type ForestLocation = ITreeSubscriptionCursor | Anchor;\n\n/**\n */\nexport interface TreeLocation {\n\treadonly range: FieldLocation | DetachedField;\n\treadonly index: number;\n}\n\nexport function isFieldLocation(range: FieldLocation | DetachedField): range is FieldLocation {\n\treturn typeof range === \"object\";\n}\n\n/**\n * Location of a field within a tree that is not a detached/root field.\n */\nexport interface FieldLocation {\n\treadonly key: FieldKey;\n\treadonly parent: ForestLocation;\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { Listenable } from "@fluidframework/core-interfaces/internal";
6
6
  import type { FieldKey, TreeStoredSchemaSubscription } from "../schema-stored/index.js";
7
- import { type Anchor, type AnchorSet, type AnnouncedVisitor, type DetachedField, type ITreeCursor, type ITreeCursorSynchronous, type UpPath } from "../tree/index.js";
7
+ import { type Anchor, type AnchorSet, type AnnouncedVisitor, type DetachedField, type ITreeCursor, type ITreeCursorSynchronous, type TreeChunk, type UpPath } from "../tree/index.js";
8
8
  import type { IEditableForest } from "./editableForest.js";
9
9
  /**
10
10
  * APIs for forest designed so the implementation can be copy on write,
@@ -61,6 +61,16 @@ export interface IForestSubscription {
61
61
  * The new copy will not invalidate observers (dependents) of the old one.
62
62
  */
63
63
  clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;
64
+ /**
65
+ * Generate a TreeChunk for the content in the given field cursor.
66
+ * This can be used to chunk data that is then inserted into the forest.
67
+ *
68
+ * @remarks
69
+ * Like {@link chunkField}, but forces the results into a single TreeChunk.
70
+ * While any TreeChunk is compatible with any forest, this method creates one optimized for this specific forest.
71
+ * The provided data must be compatible with the forest's current schema.
72
+ */
73
+ chunkField(cursor: ITreeCursorSynchronous): TreeChunk;
64
74
  /**
65
75
  * Allocates a cursor in the "cleared" state.
66
76
  * @param source - optional string identifying the source of the cursor for debugging purposes when cursors are not properly cleaned up.
@@ -81,7 +91,7 @@ export interface IForestSubscription {
81
91
  */
82
92
  tryMoveCursorToField(destination: FieldAnchor, cursorToMove: ITreeSubscriptionCursor): TreeNavigationResult;
83
93
  /**
84
- * Set `cursorToMove` to location described by path.
94
+ * Set `cursorToMove` to the {@link CursorLocationType.node} described by path.
85
95
  * This is NOT a relative move: current position is discarded.
86
96
  * Path must point to existing node.
87
97
  */
@@ -111,13 +121,16 @@ export interface IForestSubscription {
111
121
  deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;
112
122
  }
113
123
  /**
124
+ * Returns an anchor to the given field.
114
125
  * @param field - defaults to {@link rootField}.
115
126
  * @returns anchor to `field`.
116
127
  */
117
128
  export declare function rootAnchor(field?: DetachedField): FieldAnchor;
118
129
  /**
130
+ * Moves the given cursor to the given detached fields in the given forest.
131
+ * @param forest - forest to move cursor in.
132
+ * @param cursorToMove - cursor to move, must be allocated by the given forest
119
133
  * @param field - defaults to {@link rootField}.
120
- * @returns anchor to `field`.
121
134
  */
122
135
  export declare function moveToDetachedField(forest: IForestSubscription, cursorToMove: ITreeSubscriptionCursor, field?: DetachedField): void;
123
136
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"forest.d.ts","sourceRoot":"","sources":["../../../src/core/forest/forest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACN,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EAGX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eA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AI;IAEX;;OAEG;IACH,EAAE,IAAI;CACN;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GACpC,oBAAoB,CAAC,EAAE,GACvB,oBAAoB,CAAC,QAAQ,CAAC"}
@@ -5,6 +5,7 @@
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
6
  import { detachedFieldAsKey, rootField, } from "../tree/index.js";
7
7
  /**
8
+ * Returns an anchor to the given field.
8
9
  * @param field - defaults to {@link rootField}.
9
10
  * @returns anchor to `field`.
10
11
  */
@@ -15,8 +16,10 @@ export function rootAnchor(field = rootField) {
15
16
  };
16
17
  }
17
18
  /**
19
+ * Moves the given cursor to the given detached fields in the given forest.
20
+ * @param forest - forest to move cursor in.
21
+ * @param cursorToMove - cursor to move, must be allocated by the given forest
18
22
  * @param field - defaults to {@link rootField}.
19
- * @returns anchor to `field`.
20
23
  */
21
24
  export function moveToDetachedField(forest, cursorToMove, field = rootField) {
22
25
  const result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);
@@ -1 +1 @@
1
- {"version":3,"file":"forest.js","sourceRoot":"","sources":["../../../src/core/forest/forest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAQN,kBAAkB,EAClB,SAAS,GACT,MAAM,kBAAkB,CAAC;AAiI1B;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,QAAuB,SAAS;IAC1D,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC;KACnC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAAqC,EACrC,QAAuB,SAAS;IAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,CACL,MAAM,oCAA4B,EAClC,KAAK,CAAC,qDAAqD,CAC3D,CAAC;AACH,CAAC;AAkED;GACG;AACH,MAAM,CAAN,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACvC;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,iFAAK,CAAA;AACN,CAAC,EAbW,4BAA4B,KAA5B,4BAA4B,QAavC;AAED;GACG;AACH,MAAM,CAAN,IAAkB,oBAejB;AAfD,WAAkB,oBAAoB;IACrC;;OAEG;IACH,wEAAa,CAAA;IAEb;;OAEG;IACH,qEAAW,CAAA;IAEX;;OAEG;IACH,2DAAM,CAAA;AACP,CAAC,EAfiB,oBAAoB,KAApB,oBAAoB,QAerC","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\";\n\nimport type { Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport type { FieldKey, TreeStoredSchemaSubscription } from \"../schema-stored/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorSet,\n\ttype AnnouncedVisitor,\n\ttype DetachedField,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype UpPath,\n\tdetachedFieldAsKey,\n\trootField,\n} from \"../tree/index.js\";\n\nimport type { IEditableForest } from \"./editableForest.js\";\n\n/**\n * APIs for forest designed so the implementation can be copy on write,\n * or mutate in place, and we can ensure no references are dangling into the forest to allow this.\n *\n * This results in rather manual memory management,\n * but makes it practical to provide highly optimized implementations,\n * for example WASM powered binary formats that can track reference counts and only copy when needed.\n */\n\n/**\n * Events for {@link IForestSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n */\nexport interface ForestEvents {\n\t/**\n\t * A new root field was just created in this forest.\n\t */\n\tafterRootFieldCreated(key: FieldKey): void;\n\n\t/**\n\t * The forest is about to be changed.\n\t * Emitted before each change in a batch of changes.\n\t * @remarks\n\t * This is the last chance for users of the forest to remove cursors from the forest before the edit.\n\t * Removing these cursors is important since they are not allowed to live across edits and\n\t * not clearing them can lead to corruption of in memory structures.\n\t */\n\tbeforeChange(): void;\n}\n\n/**\n * Invalidates whenever the tree content changes.\n * For now (might change later) downloading new parts of the forest counts as a change.\n * Not invalidated when schema changes.\n *\n * When invalidating, all outstanding cursors must be freed or cleared.\n */\nexport interface IForestSubscription {\n\t/**\n\t * Events for this forest.\n\t */\n\treadonly events: Listenable<ForestEvents>;\n\n\t/**\n\t * Set of anchors this forest is tracking.\n\t *\n\t * To keep these anchors usable, this AnchorSet must be updated / rebased for any changes made to the forest.\n\t * It is the responsibility of the caller of the forest-editing methods to do this, not the forest itself.\n\t * The caller performs these updates because it has more semantic knowledge about the edits, which can be needed to\n\t * update the anchors in a semantically optimal way.\n\t */\n\treadonly anchors: AnchorSet;\n\n\t/**\n\t * Create an independent copy of this forest, that uses the provided schema and anchors.\n\t *\n\t * The new copy will not invalidate observers (dependents) of the old one.\n\t */\n\tclone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;\n\n\t/**\n\t * Allocates a cursor in the \"cleared\" state.\n\t * @param source - optional string identifying the source of the cursor for debugging purposes when cursors are not properly cleaned up.\n\t */\n\tallocateCursor(source?: string): ITreeSubscriptionCursor;\n\n\t/**\n\t * Frees an Anchor, stopping tracking its position across edits.\n\t */\n\tforgetAnchor(anchor: Anchor): void;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * Set `cursorToMove` to location described by path.\n\t * This is NOT a relative move: current position is discarded.\n\t * Path must point to existing node.\n\t */\n\tmoveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void;\n\n\t/**\n\t * The cursor is moved to a special dummy node above the detached fields.\n\t * This dummy node can be used to read the detached fields,\n\t * but other operations (such as inspecting the dummy node's type or path) should not be relied upon.\n\t * While this method does not return an {@link ITreeSubscriptionCursor}, similar restrictions apply to its use:\n\t * the returned cursor must not used after any edits are made to the forest.\n\t */\n\tgetCursorAboveDetachedFields(): ITreeCursorSynchronous;\n\n\t/**\n\t * True if there are no nodes in the forest at all.\n\t *\n\t * @remarks\n\t * This means no nodes under any detached field, not just the special document root one.\n\t */\n\treadonly isEmpty: boolean;\n\n\t/**\n\t * Obtains and registers an {@link AnnouncedVisitor} that responds to changes on the forest.\n\t */\n\tregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;\n\n\t/**\n\t * Deregister the given visitor so that it stops responding to updates\n\t */\n\tderegisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function rootAnchor(field: DetachedField = rootField): FieldAnchor {\n\treturn {\n\t\tparent: undefined,\n\t\tfieldKey: detachedFieldAsKey(field),\n\t};\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function moveToDetachedField(\n\tforest: IForestSubscription,\n\tcursorToMove: ITreeSubscriptionCursor,\n\tfield: DetachedField = rootField,\n): void {\n\tconst result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);\n\tassert(\n\t\tresult === TreeNavigationResult.Ok,\n\t\t0x42d /* Navigation to detached fields should never fail */,\n\t);\n}\n\n/**\n * Anchor to a field.\n * This is structurally based on the parent, so it will move only as the parent moves.\n */\nexport interface FieldAnchor {\n\t/**\n\t * Node above this field.\n\t * If `undefined`, field is a detached field.\n\t */\n\tparent: Anchor | undefined;\n\tfieldKey: FieldKey;\n}\n\n/**\n * ITreeCursor supporting IForestSubscription and its changes over time.\n */\nexport interface ITreeSubscriptionCursor extends ITreeCursor {\n\t/**\n\t * @param source - optional string identifying the source of the cursor for debugging purposes when cursors are not properly cleaned up.\n\t * @returns an independent copy of this cursor at the same location in the tree.\n\t */\n\tfork(source?: string): ITreeSubscriptionCursor;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` is forbidden (undefined behavior).\n\t */\n\tfree(): void;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` or passing to `tryGet`\n\t * or calling `free` is forbidden (undefined behavior).\n\t */\n\tclear(): void;\n\n\t/**\n\t * Construct an `Anchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\tbuildAnchor(): Anchor;\n\n\t/**\n\t * Construct a `FieldAnchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t */\n\tbuildFieldAnchor(): FieldAnchor;\n\n\t/**\n\t * Current state.\n\t */\n\treadonly state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @returns location within parent field or range.\n\t */\n\t// TODO: maybe support this.\n\t// getParentInfo(id: NodeId): TreeLocation;\n}\n\n/**\n */\nexport enum ITreeSubscriptionCursorState {\n\t/**\n\t * On the current revision of the forest.\n\t */\n\tCurrent,\n\t/**\n\t * Empty, but can be reused.\n\t */\n\tCleared,\n\t/**\n\t * Freed and must not be used.\n\t */\n\tFreed,\n}\n\n/**\n */\nexport const enum TreeNavigationResult {\n\t/**\n\t * Attempt to navigate cursor to a key or index that is outside the client's view.\n\t */\n\tNotFound = -1,\n\n\t/**\n\t * Attempt to navigate cursor to a portion of the tree that has not yet been loaded.\n\t */\n\tPending = 0,\n\n\t/**\n\t * ITreeReader successfully navigated to the desired node.\n\t */\n\tOk = 1,\n}\n\n/**\n * TreeNavigationResult, but never \"Pending\".\n * Can be used when data is never pending.\n */\nexport type SynchronousNavigationResult =\n\t| TreeNavigationResult.Ok\n\t| TreeNavigationResult.NotFound;\n"]}
1
+ {"version":3,"file":"forest.js","sourceRoot":"","sources":["../../../src/core/forest/forest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EASN,kBAAkB,EAClB,SAAS,GACT,MAAM,kBAAkB,CAAC;AA4I1B;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,QAAuB,SAAS;IAC1D,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC;KACnC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAAqC,EACrC,QAAuB,SAAS;IAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,CACL,MAAM,oCAA4B,EAClC,KAAK,CAAC,qDAAqD,CAC3D,CAAC;AACH,CAAC;AAkED;GACG;AACH,MAAM,CAAN,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACvC;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,iFAAK,CAAA;AACN,CAAC,EAbW,4BAA4B,KAA5B,4BAA4B,QAavC;AAED;GACG;AACH,MAAM,CAAN,IAAkB,oBAejB;AAfD,WAAkB,oBAAoB;IACrC;;OAEG;IACH,wEAAa,CAAA;IAEb;;OAEG;IACH,qEAAW,CAAA;IAEX;;OAEG;IACH,2DAAM,CAAA;AACP,CAAC,EAfiB,oBAAoB,KAApB,oBAAoB,QAerC","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\";\n\nimport type { Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport type { FieldKey, TreeStoredSchemaSubscription } from \"../schema-stored/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorSet,\n\ttype AnnouncedVisitor,\n\ttype DetachedField,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype TreeChunk,\n\ttype UpPath,\n\tdetachedFieldAsKey,\n\trootField,\n} from \"../tree/index.js\";\n\nimport type { IEditableForest } from \"./editableForest.js\";\n\n/**\n * APIs for forest designed so the implementation can be copy on write,\n * or mutate in place, and we can ensure no references are dangling into the forest to allow this.\n *\n * This results in rather manual memory management,\n * but makes it practical to provide highly optimized implementations,\n * for example WASM powered binary formats that can track reference counts and only copy when needed.\n */\n\n/**\n * Events for {@link IForestSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n */\nexport interface ForestEvents {\n\t/**\n\t * A new root field was just created in this forest.\n\t */\n\tafterRootFieldCreated(key: FieldKey): void;\n\n\t/**\n\t * The forest is about to be changed.\n\t * Emitted before each change in a batch of changes.\n\t * @remarks\n\t * This is the last chance for users of the forest to remove cursors from the forest before the edit.\n\t * Removing these cursors is important since they are not allowed to live across edits and\n\t * not clearing them can lead to corruption of in memory structures.\n\t */\n\tbeforeChange(): void;\n}\n\n/**\n * Invalidates whenever the tree content changes.\n * For now (might change later) downloading new parts of the forest counts as a change.\n * Not invalidated when schema changes.\n *\n * When invalidating, all outstanding cursors must be freed or cleared.\n */\nexport interface IForestSubscription {\n\t/**\n\t * Events for this forest.\n\t */\n\treadonly events: Listenable<ForestEvents>;\n\n\t/**\n\t * Set of anchors this forest is tracking.\n\t *\n\t * To keep these anchors usable, this AnchorSet must be updated / rebased for any changes made to the forest.\n\t * It is the responsibility of the caller of the forest-editing methods to do this, not the forest itself.\n\t * The caller performs these updates because it has more semantic knowledge about the edits, which can be needed to\n\t * update the anchors in a semantically optimal way.\n\t */\n\treadonly anchors: AnchorSet;\n\n\t/**\n\t * Create an independent copy of this forest, that uses the provided schema and anchors.\n\t *\n\t * The new copy will not invalidate observers (dependents) of the old one.\n\t */\n\tclone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;\n\n\t/**\n\t * Generate a TreeChunk for the content in the given field cursor.\n\t * This can be used to chunk data that is then inserted into the forest.\n\t *\n\t * @remarks\n\t * Like {@link chunkField}, but forces the results into a single TreeChunk.\n\t * While any TreeChunk is compatible with any forest, this method creates one optimized for this specific forest.\n\t * The provided data must be compatible with the forest's current schema.\n\t */\n\tchunkField(cursor: ITreeCursorSynchronous): TreeChunk;\n\n\t/**\n\t * Allocates a cursor in the \"cleared\" state.\n\t * @param source - optional string identifying the source of the cursor for debugging purposes when cursors are not properly cleaned up.\n\t */\n\tallocateCursor(source?: string): ITreeSubscriptionCursor;\n\n\t/**\n\t * Frees an Anchor, stopping tracking its position across edits.\n\t */\n\tforgetAnchor(anchor: Anchor): void;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * Set `cursorToMove` to the {@link CursorLocationType.node} described by path.\n\t * This is NOT a relative move: current position is discarded.\n\t * Path must point to existing node.\n\t */\n\tmoveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void;\n\n\t/**\n\t * The cursor is moved to a special dummy node above the detached fields.\n\t * This dummy node can be used to read the detached fields,\n\t * but other operations (such as inspecting the dummy node's type or path) should not be relied upon.\n\t * While this method does not return an {@link ITreeSubscriptionCursor}, similar restrictions apply to its use:\n\t * the returned cursor must not used after any edits are made to the forest.\n\t */\n\tgetCursorAboveDetachedFields(): ITreeCursorSynchronous;\n\n\t/**\n\t * True if there are no nodes in the forest at all.\n\t *\n\t * @remarks\n\t * This means no nodes under any detached field, not just the special document root one.\n\t */\n\treadonly isEmpty: boolean;\n\n\t/**\n\t * Obtains and registers an {@link AnnouncedVisitor} that responds to changes on the forest.\n\t */\n\tregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;\n\n\t/**\n\t * Deregister the given visitor so that it stops responding to updates\n\t */\n\tderegisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;\n}\n\n/**\n * Returns an anchor to the given field.\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function rootAnchor(field: DetachedField = rootField): FieldAnchor {\n\treturn {\n\t\tparent: undefined,\n\t\tfieldKey: detachedFieldAsKey(field),\n\t};\n}\n\n/**\n * Moves the given cursor to the given detached fields in the given forest.\n * @param forest - forest to move cursor in.\n * @param cursorToMove - cursor to move, must be allocated by the given forest\n * @param field - defaults to {@link rootField}.\n */\nexport function moveToDetachedField(\n\tforest: IForestSubscription,\n\tcursorToMove: ITreeSubscriptionCursor,\n\tfield: DetachedField = rootField,\n): void {\n\tconst result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);\n\tassert(\n\t\tresult === TreeNavigationResult.Ok,\n\t\t0x42d /* Navigation to detached fields should never fail */,\n\t);\n}\n\n/**\n * Anchor to a field.\n * This is structurally based on the parent, so it will move only as the parent moves.\n */\nexport interface FieldAnchor {\n\t/**\n\t * Node above this field.\n\t * If `undefined`, field is a detached field.\n\t */\n\tparent: Anchor | undefined;\n\tfieldKey: FieldKey;\n}\n\n/**\n * ITreeCursor supporting IForestSubscription and its changes over time.\n */\nexport interface ITreeSubscriptionCursor extends ITreeCursor {\n\t/**\n\t * @param source - optional string identifying the source of the cursor for debugging purposes when cursors are not properly cleaned up.\n\t * @returns an independent copy of this cursor at the same location in the tree.\n\t */\n\tfork(source?: string): ITreeSubscriptionCursor;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` is forbidden (undefined behavior).\n\t */\n\tfree(): void;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` or passing to `tryGet`\n\t * or calling `free` is forbidden (undefined behavior).\n\t */\n\tclear(): void;\n\n\t/**\n\t * Construct an `Anchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\tbuildAnchor(): Anchor;\n\n\t/**\n\t * Construct a `FieldAnchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t */\n\tbuildFieldAnchor(): FieldAnchor;\n\n\t/**\n\t * Current state.\n\t */\n\treadonly state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @returns location within parent field or range.\n\t */\n\t// TODO: maybe support this.\n\t// getParentInfo(id: NodeId): TreeLocation;\n}\n\n/**\n */\nexport enum ITreeSubscriptionCursorState {\n\t/**\n\t * On the current revision of the forest.\n\t */\n\tCurrent,\n\t/**\n\t * Empty, but can be reused.\n\t */\n\tCleared,\n\t/**\n\t * Freed and must not be used.\n\t */\n\tFreed,\n}\n\n/**\n */\nexport const enum TreeNavigationResult {\n\t/**\n\t * Attempt to navigate cursor to a key or index that is outside the client's view.\n\t */\n\tNotFound = -1,\n\n\t/**\n\t * Attempt to navigate cursor to a portion of the tree that has not yet been loaded.\n\t */\n\tPending = 0,\n\n\t/**\n\t * ITreeReader successfully navigated to the desired node.\n\t */\n\tOk = 1,\n}\n\n/**\n * TreeNavigationResult, but never \"Pending\".\n * Can be used when data is never pending.\n */\nexport type SynchronousNavigationResult =\n\t| TreeNavigationResult.Ok\n\t| TreeNavigationResult.NotFound;\n"]}
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { type IEditableForest, type FieldLocation, type TreeLocation, isFieldLocation, type ForestLocation, initializeForest, } from "./editableForest.js";
5
+ export { type IEditableForest, type FieldLocation, type TreeLocation, isFieldLocation, type ForestLocation, } from "./editableForest.js";
6
6
  export { type IForestSubscription, type ITreeSubscriptionCursor, ITreeSubscriptionCursorState, TreeNavigationResult, type FieldAnchor, moveToDetachedField, type ForestEvents, } from "./forest.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,cAAc,EACnB,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,WAAW,EAChB,mBAAmB,EACnB,KAAK,YAAY,GACjB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,WAAW,EAChB,mBAAmB,EACnB,KAAK,YAAY,GACjB,MAAM,aAAa,CAAC"}
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { isFieldLocation, initializeForest, } from "./editableForest.js";
5
+ export { isFieldLocation, } from "./editableForest.js";
6
6
  export { ITreeSubscriptionCursorState, TreeNavigationResult, moveToDetachedField, } from "./forest.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,eAAe,EAEf,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGN,4BAA4B,EAC5B,oBAAoB,EAEpB,mBAAmB,GAEnB,MAAM,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype IEditableForest,\n\ttype FieldLocation,\n\ttype TreeLocation,\n\tisFieldLocation,\n\ttype ForestLocation,\n\tinitializeForest,\n} from \"./editableForest.js\";\nexport {\n\ttype IForestSubscription,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\tTreeNavigationResult,\n\ttype FieldAnchor,\n\tmoveToDetachedField,\n\ttype ForestEvents,\n} from \"./forest.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,eAAe,GAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGN,4BAA4B,EAC5B,oBAAoB,EAEpB,mBAAmB,GAEnB,MAAM,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype IEditableForest,\n\ttype FieldLocation,\n\ttype TreeLocation,\n\tisFieldLocation,\n\ttype ForestLocation,\n} from \"./editableForest.js\";\nexport {\n\ttype IForestSubscription,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\tTreeNavigationResult,\n\ttype FieldAnchor,\n\tmoveToDetachedField,\n\ttype ForestEvents,\n} from \"./forest.js\";\n"]}