@fluidframework/tree 2.10.0 → 2.11.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 (465) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/api-report/tree.alpha.api.md +47 -16
  3. package/api-report/tree.beta.api.md +5 -14
  4. package/api-report/tree.legacy.alpha.api.md +5 -14
  5. package/api-report/tree.legacy.public.api.md +5 -14
  6. package/api-report/tree.public.api.md +5 -14
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/forest.d.ts +10 -2
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js.map +1 -1
  11. package/dist/core/index.d.ts +2 -2
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +3 -2
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/rebase/utils.d.ts +1 -1
  16. package/dist/core/rebase/utils.d.ts.map +1 -1
  17. package/dist/core/rebase/utils.js +11 -8
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/revertible.d.ts +30 -1
  20. package/dist/core/revertible.d.ts.map +1 -1
  21. package/dist/core/revertible.js.map +1 -1
  22. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  23. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  24. package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
  25. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  26. package/dist/core/tree/anchorSet.d.ts +2 -2
  27. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  28. package/dist/core/tree/anchorSet.js +21 -21
  29. package/dist/core/tree/anchorSet.js.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  31. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  32. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  33. package/dist/core/tree/index.d.ts +1 -1
  34. package/dist/core/tree/index.d.ts.map +1 -1
  35. package/dist/core/tree/index.js +2 -1
  36. package/dist/core/tree/index.js.map +1 -1
  37. package/dist/core/tree/visitorUtils.d.ts +25 -1
  38. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  39. package/dist/core/tree/visitorUtils.js +29 -1
  40. package/dist/core/tree/visitorUtils.js.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  42. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
  44. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  47. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  51. package/dist/feature-libraries/index.d.ts +1 -0
  52. package/dist/feature-libraries/index.d.ts.map +1 -1
  53. package/dist/feature-libraries/index.js +4 -1
  54. package/dist/feature-libraries/index.js.map +1 -1
  55. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +361 -0
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  59. package/dist/feature-libraries/indexing/index.d.ts +7 -0
  60. package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
  61. package/dist/feature-libraries/indexing/index.js +11 -0
  62. package/dist/feature-libraries/indexing/index.js.map +1 -0
  63. package/dist/feature-libraries/indexing/types.d.ts +32 -0
  64. package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
  65. package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  66. package/dist/feature-libraries/indexing/types.js.map +1 -0
  67. package/dist/feature-libraries/object-forest/objectForest.d.ts +5 -2
  68. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  69. package/dist/feature-libraries/object-forest/objectForest.js +21 -11
  70. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  71. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  72. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  73. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  74. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
  75. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  76. package/dist/index.d.ts +4 -4
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +4 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/packageVersion.d.ts +1 -1
  81. package/dist/packageVersion.js +1 -1
  82. package/dist/packageVersion.js.map +1 -1
  83. package/dist/shared-tree/index.d.ts +1 -1
  84. package/dist/shared-tree/index.d.ts.map +1 -1
  85. package/dist/shared-tree/index.js +1 -2
  86. package/dist/shared-tree/index.js.map +1 -1
  87. package/dist/shared-tree/schematizingTreeView.d.ts +7 -1
  88. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.js +31 -30
  90. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  91. package/dist/shared-tree/sharedTree.d.ts +3 -0
  92. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  93. package/dist/shared-tree/sharedTree.js +56 -20
  94. package/dist/shared-tree/sharedTree.js.map +1 -1
  95. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  96. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
  97. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  98. package/dist/shared-tree/treeCheckout.d.ts +28 -64
  99. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  100. package/dist/shared-tree/treeCheckout.js +152 -129
  101. package/dist/shared-tree/treeCheckout.js.map +1 -1
  102. package/dist/shared-tree-core/branch.d.ts +25 -81
  103. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  104. package/dist/shared-tree-core/branch.js +72 -151
  105. package/dist/shared-tree-core/branch.js.map +1 -1
  106. package/dist/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  107. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  108. package/dist/shared-tree-core/branchCommitEnricher.js +73 -54
  109. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  110. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  111. package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
  112. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  113. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  114. package/dist/shared-tree-core/editManager.js +2 -2
  115. package/dist/shared-tree-core/editManager.js.map +1 -1
  116. package/dist/shared-tree-core/index.d.ts +1 -1
  117. package/dist/shared-tree-core/index.d.ts.map +1 -1
  118. package/dist/shared-tree-core/index.js +4 -3
  119. package/dist/shared-tree-core/index.js.map +1 -1
  120. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -2
  121. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  122. package/dist/shared-tree-core/sharedTreeCore.js +11 -52
  123. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  124. package/dist/shared-tree-core/transaction.d.ts +108 -0
  125. package/dist/shared-tree-core/transaction.d.ts.map +1 -0
  126. package/dist/shared-tree-core/transaction.js +99 -0
  127. package/dist/shared-tree-core/transaction.js.map +1 -0
  128. package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
  129. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  130. package/dist/shared-tree-core/transactionEnricher.js +41 -21
  131. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  132. package/dist/simple-tree/api/identifierIndex.d.ts +21 -0
  133. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
  134. package/dist/simple-tree/api/identifierIndex.js +45 -0
  135. package/dist/simple-tree/api/identifierIndex.js.map +1 -0
  136. package/dist/simple-tree/api/index.d.ts +2 -0
  137. package/dist/simple-tree/api/index.d.ts.map +1 -1
  138. package/dist/simple-tree/api/index.js +5 -1
  139. package/dist/simple-tree/api/index.js.map +1 -1
  140. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +9 -7
  141. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  142. package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  143. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  144. package/dist/simple-tree/api/simpleTreeIndex.js +91 -0
  145. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
  146. package/dist/simple-tree/api/tree.d.ts +4 -5
  147. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  148. package/dist/simple-tree/api/tree.js.map +1 -1
  149. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  150. package/dist/simple-tree/core/index.d.ts +1 -1
  151. package/dist/simple-tree/core/index.d.ts.map +1 -1
  152. package/dist/simple-tree/core/index.js +2 -1
  153. package/dist/simple-tree/core/index.js.map +1 -1
  154. package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
  155. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  156. package/dist/simple-tree/core/treeNodeKernel.js +53 -22
  157. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  158. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  159. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  160. package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
  161. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  162. package/dist/simple-tree/index.d.ts +1 -1
  163. package/dist/simple-tree/index.d.ts.map +1 -1
  164. package/dist/simple-tree/index.js +4 -2
  165. package/dist/simple-tree/index.js.map +1 -1
  166. package/dist/simple-tree/objectNode.d.ts +7 -2
  167. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  168. package/dist/simple-tree/objectNode.js.map +1 -1
  169. package/dist/simple-tree/toMapTree.js +3 -3
  170. package/dist/simple-tree/toMapTree.js.map +1 -1
  171. package/dist/util/index.d.ts +1 -2
  172. package/dist/util/index.d.ts.map +1 -1
  173. package/dist/util/index.js +5 -4
  174. package/dist/util/index.js.map +1 -1
  175. package/dist/util/typeCheck.d.ts +6 -1
  176. package/dist/util/typeCheck.d.ts.map +1 -1
  177. package/dist/util/typeCheck.js.map +1 -1
  178. package/dist/util/typeCheckTests.d.ts +14 -2
  179. package/dist/util/typeCheckTests.d.ts.map +1 -1
  180. package/dist/util/typeCheckTests.js.map +1 -1
  181. package/dist/util/utils.d.ts +29 -0
  182. package/dist/util/utils.d.ts.map +1 -1
  183. package/dist/util/utils.js +13 -1
  184. package/dist/util/utils.js.map +1 -1
  185. package/lib/alpha.d.ts +9 -0
  186. package/lib/core/forest/forest.d.ts +10 -2
  187. package/lib/core/forest/forest.d.ts.map +1 -1
  188. package/lib/core/forest/forest.js.map +1 -1
  189. package/lib/core/index.d.ts +2 -2
  190. package/lib/core/index.d.ts.map +1 -1
  191. package/lib/core/index.js +2 -2
  192. package/lib/core/index.js.map +1 -1
  193. package/lib/core/rebase/utils.d.ts +1 -1
  194. package/lib/core/rebase/utils.d.ts.map +1 -1
  195. package/lib/core/rebase/utils.js +11 -8
  196. package/lib/core/rebase/utils.js.map +1 -1
  197. package/lib/core/revertible.d.ts +30 -1
  198. package/lib/core/revertible.d.ts.map +1 -1
  199. package/lib/core/revertible.js.map +1 -1
  200. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  201. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  202. package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
  203. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  204. package/lib/core/tree/anchorSet.d.ts +2 -2
  205. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  206. package/lib/core/tree/anchorSet.js +1 -1
  207. package/lib/core/tree/anchorSet.js.map +1 -1
  208. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  209. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  210. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  211. package/lib/core/tree/index.d.ts +1 -1
  212. package/lib/core/tree/index.d.ts.map +1 -1
  213. package/lib/core/tree/index.js +1 -1
  214. package/lib/core/tree/index.js.map +1 -1
  215. package/lib/core/tree/visitorUtils.d.ts +25 -1
  216. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  217. package/lib/core/tree/visitorUtils.js +27 -0
  218. package/lib/core/tree/visitorUtils.js.map +1 -1
  219. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  220. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  221. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
  222. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  223. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -3
  225. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  226. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  227. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  228. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  229. package/lib/feature-libraries/index.d.ts +1 -0
  230. package/lib/feature-libraries/index.d.ts.map +1 -1
  231. package/lib/feature-libraries/index.js +1 -0
  232. package/lib/feature-libraries/index.js.map +1 -1
  233. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  234. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  235. package/lib/feature-libraries/indexing/anchorTreeIndex.js +356 -0
  236. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  237. package/lib/feature-libraries/indexing/index.d.ts +7 -0
  238. package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
  239. package/lib/{events → feature-libraries/indexing}/index.js +1 -1
  240. package/lib/feature-libraries/indexing/index.js.map +1 -0
  241. package/lib/feature-libraries/indexing/types.d.ts +32 -0
  242. package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
  243. package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  244. package/lib/feature-libraries/indexing/types.js.map +1 -0
  245. package/lib/feature-libraries/object-forest/objectForest.d.ts +5 -2
  246. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  247. package/lib/feature-libraries/object-forest/objectForest.js +15 -5
  248. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  249. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  250. package/lib/feature-libraries/sequence-field/invert.js +4 -4
  251. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  252. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
  253. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  254. package/lib/index.d.ts +4 -4
  255. package/lib/index.d.ts.map +1 -1
  256. package/lib/index.js +1 -1
  257. package/lib/index.js.map +1 -1
  258. package/lib/packageVersion.d.ts +1 -1
  259. package/lib/packageVersion.js +1 -1
  260. package/lib/packageVersion.js.map +1 -1
  261. package/lib/shared-tree/index.d.ts +1 -1
  262. package/lib/shared-tree/index.d.ts.map +1 -1
  263. package/lib/shared-tree/index.js +1 -1
  264. package/lib/shared-tree/index.js.map +1 -1
  265. package/lib/shared-tree/schematizingTreeView.d.ts +7 -1
  266. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  267. package/lib/shared-tree/schematizingTreeView.js +2 -2
  268. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  269. package/lib/shared-tree/sharedTree.d.ts +3 -0
  270. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  271. package/lib/shared-tree/sharedTree.js +37 -1
  272. package/lib/shared-tree/sharedTree.js.map +1 -1
  273. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  274. package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
  275. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  276. package/lib/shared-tree/treeCheckout.d.ts +28 -64
  277. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  278. package/lib/shared-tree/treeCheckout.js +140 -116
  279. package/lib/shared-tree/treeCheckout.js.map +1 -1
  280. package/lib/shared-tree-core/branch.d.ts +25 -81
  281. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  282. package/lib/shared-tree-core/branch.js +72 -151
  283. package/lib/shared-tree-core/branch.js.map +1 -1
  284. package/lib/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  285. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  286. package/lib/shared-tree-core/branchCommitEnricher.js +74 -55
  287. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  288. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  289. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  290. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  291. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  292. package/lib/shared-tree-core/editManager.js +1 -1
  293. package/lib/shared-tree-core/editManager.js.map +1 -1
  294. package/lib/shared-tree-core/index.d.ts +1 -1
  295. package/lib/shared-tree-core/index.d.ts.map +1 -1
  296. package/lib/shared-tree-core/index.js +1 -1
  297. package/lib/shared-tree-core/index.js.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -2
  299. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  300. package/lib/shared-tree-core/sharedTreeCore.js +12 -53
  301. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  302. package/lib/shared-tree-core/transaction.d.ts +108 -0
  303. package/lib/shared-tree-core/transaction.d.ts.map +1 -0
  304. package/lib/shared-tree-core/transaction.js +95 -0
  305. package/lib/shared-tree-core/transaction.js.map +1 -0
  306. package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
  307. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  308. package/lib/shared-tree-core/transactionEnricher.js +41 -21
  309. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  310. package/lib/simple-tree/api/identifierIndex.d.ts +21 -0
  311. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
  312. package/lib/simple-tree/api/identifierIndex.js +41 -0
  313. package/lib/simple-tree/api/identifierIndex.js.map +1 -0
  314. package/lib/simple-tree/api/index.d.ts +2 -0
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -0
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +11 -9
  319. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  320. package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  321. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  322. package/lib/simple-tree/api/simpleTreeIndex.js +87 -0
  323. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
  324. package/lib/simple-tree/api/tree.d.ts +4 -5
  325. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  326. package/lib/simple-tree/api/tree.js.map +1 -1
  327. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  328. package/lib/simple-tree/core/index.d.ts +1 -1
  329. package/lib/simple-tree/core/index.d.ts.map +1 -1
  330. package/lib/simple-tree/core/index.js +1 -1
  331. package/lib/simple-tree/core/index.js.map +1 -1
  332. package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
  333. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  334. package/lib/simple-tree/core/treeNodeKernel.js +31 -1
  335. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  336. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  337. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  338. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
  339. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  340. package/lib/simple-tree/index.d.ts +1 -1
  341. package/lib/simple-tree/index.d.ts.map +1 -1
  342. package/lib/simple-tree/index.js +1 -1
  343. package/lib/simple-tree/index.js.map +1 -1
  344. package/lib/simple-tree/objectNode.d.ts +7 -2
  345. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  346. package/lib/simple-tree/objectNode.js.map +1 -1
  347. package/lib/simple-tree/toMapTree.js +5 -5
  348. package/lib/simple-tree/toMapTree.js.map +1 -1
  349. package/lib/util/index.d.ts +1 -2
  350. package/lib/util/index.d.ts.map +1 -1
  351. package/lib/util/index.js +1 -2
  352. package/lib/util/index.js.map +1 -1
  353. package/lib/util/typeCheck.d.ts +6 -1
  354. package/lib/util/typeCheck.d.ts.map +1 -1
  355. package/lib/util/typeCheck.js.map +1 -1
  356. package/lib/util/typeCheckTests.d.ts +14 -2
  357. package/lib/util/typeCheckTests.d.ts.map +1 -1
  358. package/lib/util/typeCheckTests.js.map +1 -1
  359. package/lib/util/utils.d.ts +29 -0
  360. package/lib/util/utils.d.ts.map +1 -1
  361. package/lib/util/utils.js +9 -0
  362. package/lib/util/utils.js.map +1 -1
  363. package/package.json +22 -22
  364. package/src/core/forest/forest.ts +12 -1
  365. package/src/core/index.ts +8 -1
  366. package/src/core/rebase/utils.ts +12 -10
  367. package/src/core/revertible.ts +35 -1
  368. package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
  369. package/src/core/tree/anchorSet.ts +2 -1
  370. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  371. package/src/core/tree/index.ts +1 -0
  372. package/src/core/tree/visitorUtils.ts +56 -1
  373. package/src/feature-libraries/chunked-forest/chunkedForest.ts +33 -7
  374. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -3
  375. package/src/feature-libraries/flex-tree/context.ts +1 -1
  376. package/src/feature-libraries/index.ts +9 -0
  377. package/src/feature-libraries/indexing/anchorTreeIndex.ts +453 -0
  378. package/src/feature-libraries/indexing/index.ts +11 -0
  379. package/src/feature-libraries/indexing/types.ts +37 -0
  380. package/src/feature-libraries/object-forest/objectForest.ts +22 -4
  381. package/src/feature-libraries/sequence-field/invert.ts +4 -4
  382. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
  383. package/src/index.ts +16 -6
  384. package/src/packageVersion.ts +1 -1
  385. package/src/shared-tree/index.ts +0 -2
  386. package/src/shared-tree/schematizingTreeView.ts +7 -7
  387. package/src/shared-tree/sharedTree.ts +60 -6
  388. package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
  389. package/src/shared-tree/treeCheckout.ts +186 -193
  390. package/src/shared-tree-core/branch.ts +93 -220
  391. package/src/shared-tree-core/branchCommitEnricher.ts +69 -64
  392. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  393. package/src/shared-tree-core/editManager.ts +1 -1
  394. package/src/shared-tree-core/index.ts +9 -2
  395. package/src/shared-tree-core/sharedTreeCore.ts +17 -62
  396. package/src/shared-tree-core/transaction.ts +165 -0
  397. package/src/shared-tree-core/transactionEnricher.ts +30 -24
  398. package/src/simple-tree/api/identifierIndex.ts +64 -0
  399. package/src/simple-tree/api/index.ts +5 -0
  400. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
  401. package/src/simple-tree/api/simpleTreeIndex.ts +231 -0
  402. package/src/simple-tree/api/tree.ts +8 -5
  403. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  404. package/src/simple-tree/core/index.ts +1 -0
  405. package/src/simple-tree/core/treeNodeKernel.ts +37 -2
  406. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
  407. package/src/simple-tree/index.ts +4 -0
  408. package/src/simple-tree/objectNode.ts +19 -12
  409. package/src/simple-tree/toMapTree.ts +5 -5
  410. package/src/util/index.ts +3 -1
  411. package/src/util/typeCheck.ts +6 -1
  412. package/src/util/typeCheckTests.ts +11 -1
  413. package/src/util/utils.ts +38 -0
  414. package/dist/events/emitter.d.ts +0 -139
  415. package/dist/events/emitter.d.ts.map +0 -1
  416. package/dist/events/emitter.js +0 -165
  417. package/dist/events/emitter.js.map +0 -1
  418. package/dist/events/index.d.ts +0 -7
  419. package/dist/events/index.d.ts.map +0 -1
  420. package/dist/events/index.js +0 -11
  421. package/dist/events/index.js.map +0 -1
  422. package/dist/events/interop.d.ts +0 -30
  423. package/dist/events/interop.d.ts.map +0 -1
  424. package/dist/events/interop.js.map +0 -1
  425. package/dist/events/listeners.d.ts +0 -76
  426. package/dist/events/listeners.d.ts.map +0 -1
  427. package/dist/events/listeners.js +0 -7
  428. package/dist/events/listeners.js.map +0 -1
  429. package/dist/shared-tree-core/transactionStack.d.ts +0 -29
  430. package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
  431. package/dist/shared-tree-core/transactionStack.js +0 -41
  432. package/dist/shared-tree-core/transactionStack.js.map +0 -1
  433. package/dist/util/transactionResult.d.ts +0 -19
  434. package/dist/util/transactionResult.d.ts.map +0 -1
  435. package/dist/util/transactionResult.js +0 -23
  436. package/dist/util/transactionResult.js.map +0 -1
  437. package/lib/events/emitter.d.ts +0 -139
  438. package/lib/events/emitter.d.ts.map +0 -1
  439. package/lib/events/emitter.js +0 -160
  440. package/lib/events/emitter.js.map +0 -1
  441. package/lib/events/index.d.ts +0 -7
  442. package/lib/events/index.d.ts.map +0 -1
  443. package/lib/events/index.js.map +0 -1
  444. package/lib/events/interop.d.ts +0 -30
  445. package/lib/events/interop.d.ts.map +0 -1
  446. package/lib/events/interop.js.map +0 -1
  447. package/lib/events/listeners.d.ts +0 -76
  448. package/lib/events/listeners.d.ts.map +0 -1
  449. package/lib/events/listeners.js +0 -6
  450. package/lib/events/listeners.js.map +0 -1
  451. package/lib/shared-tree-core/transactionStack.d.ts +0 -29
  452. package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
  453. package/lib/shared-tree-core/transactionStack.js +0 -37
  454. package/lib/shared-tree-core/transactionStack.js.map +0 -1
  455. package/lib/util/transactionResult.d.ts +0 -19
  456. package/lib/util/transactionResult.d.ts.map +0 -1
  457. package/lib/util/transactionResult.js +0 -20
  458. package/lib/util/transactionResult.js.map +0 -1
  459. package/src/events/README.md +0 -3
  460. package/src/events/emitter.ts +0 -256
  461. package/src/events/index.ts +0 -19
  462. package/src/events/interop.ts +0 -38
  463. package/src/events/listeners.ts +0 -80
  464. package/src/shared-tree-core/transactionStack.ts +0 -45
  465. package/src/util/transactionResult.ts +0 -19
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
+ /**
7
+ * an array of nodes that is guaranteed to have at least one element
8
+ *
9
+ * @alpha
10
+ */
11
+ export type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];
12
+ /**
13
+ * Value that may be used as keys in a {@link TreeIndex}.
14
+ *
15
+ * @privateRemarks
16
+ * no-new-null is disabled for this type so that it supports the TreeValue type.
17
+ *
18
+ * @alpha
19
+ */
20
+ export type TreeIndexKey = number | string | boolean | IFluidHandle | null;
21
+ /**
22
+ * A index where values are keyed on {@link TreeIndexKey}s.
23
+ *
24
+ * @alpha
25
+ */
26
+ export interface TreeIndex<TKey extends TreeIndexKey, TValue> extends ReadonlyMap<TKey, TValue> {
27
+ /**
28
+ * Disposes the index such that it can no longer be used and receives no updates from the forest
29
+ */
30
+ dispose(): void;
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9E;;;;;;;GAOG;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,IAAI,SAAS,YAAY,EAAE,MAAM,CAC3D,SAAQ,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB"}
@@ -3,4 +3,4 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=interop.js.map
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\n/**\n * an array of nodes that is guaranteed to have at least one element\n *\n * @alpha\n */\nexport type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];\n\n/**\n * Value that may be used as keys in a {@link TreeIndex}.\n *\n * @privateRemarks\n * no-new-null is disabled for this type so that it supports the TreeValue type.\n *\n * @alpha\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport type TreeIndexKey = number | string | boolean | IFluidHandle | null;\n\n/**\n * A index where values are keyed on {@link TreeIndexKey}s.\n *\n * @alpha\n */\nexport interface TreeIndex<TKey extends TreeIndexKey, TValue>\n\textends ReadonlyMap<TKey, TValue> {\n\t/**\n\t * Disposes the index such that it can no longer be used and receives no updates from the forest\n\t */\n\tdispose(): void;\n}\n"]}
@@ -2,8 +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 Anchor, AnchorSet, type CursorLocationType, type DeltaVisitor, type DetachedField, type FieldAnchor, type FieldKey, type FieldUpPath, type ForestEvents, type IEditableForest, type ITreeCursorSynchronous, type ITreeSubscriptionCursor, ITreeSubscriptionCursorState, type MapTree, type PathRootPrefix, TreeNavigationResult, type TreeNodeSchemaIdentifier, type TreeStoredSchemaSubscription, type UpPath, type Value } from "../../core/index.js";
6
- import { type Listenable } from "../../events/index.js";
5
+ import type { Listenable } from "@fluidframework/core-interfaces";
6
+ import { type Anchor, AnchorSet, type AnnouncedVisitor, type CursorLocationType, type DeltaVisitor, type DetachedField, type FieldAnchor, type FieldKey, type FieldUpPath, type ForestEvents, type IEditableForest, type ITreeCursorSynchronous, type ITreeSubscriptionCursor, ITreeSubscriptionCursorState, type MapTree, type PathRootPrefix, TreeNavigationResult, type TreeNodeSchemaIdentifier, type TreeStoredSchemaSubscription, type UpPath, type Value } from "../../core/index.js";
7
7
  import { type CursorWithNode, SynchronousCursor } from "../treeCursorUtils.js";
8
8
  /** A `MapTree` with mutable fields */
9
9
  interface MutableMapTree extends MapTree {
@@ -21,6 +21,7 @@ export declare class ObjectForest implements IEditableForest {
21
21
  readonly additionalAsserts: boolean;
22
22
  private activeVisitor?;
23
23
  readonly currentCursors: Set<Cursor>;
24
+ private readonly deltaVisitors;
24
25
  readonly events: Listenable<ForestEvents>;
25
26
  get roots(): MapTree;
26
27
  constructor(anchors?: AnchorSet, additionalAsserts?: boolean, roots?: MapTree);
@@ -28,6 +29,8 @@ export declare class ObjectForest implements IEditableForest {
28
29
  clone(_: TreeStoredSchemaSubscription, anchors: AnchorSet): ObjectForest;
29
30
  forgetAnchor(anchor: Anchor): void;
30
31
  acquireVisitor(): DeltaVisitor;
32
+ registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;
33
+ deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;
31
34
  private nextRange;
32
35
  newDetachedField(): DetachedField;
33
36
  private add;
@@ -1 +1 @@
1
- {"version":3,"file":"objectForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,MAAM,EACX,SAAS,EACT,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,KAAK,OAAO,EACZ,KAAK,cAAc,EAInB,oBAAoB,EACpB,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,MAAM,EACX,KAAK,KAAK,EAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AASvE,OAAO,EAAE,KAAK,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,sCAAsC;AACtC,UAAU,cAAe,SAAQ,OAAO;IACvC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;CACjD;AAcD;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,eAAe;;aAelC,OAAO,EAAE,SAAS;aAClB,iBAAiB,EAAE,OAAO;IAf3C,OAAO,CAAC,aAAa,CAAC,CAAe;IAGrC,SAAgB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAGxD,SAAgB,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,CAAgB;IAGhE,IAAW,KAAK,IAAI,OAAO,CAE1B;gBAGgB,OAAO,GAAE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GAAG,OAAO;IAIlC,QAAQ,IAAI,OAAO;IAInB,QAAQ,IAAI,IAAI;IAIhB,UAAU,IAAI,OAAO;IAIrB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAItC,IAAW,IAAI,IAAI,wBAAwB,CAG1C;IACD,IAAW,KAAK,IAAI,KAAK,CAGxB;IAGM,KAAK,IAAI,IAAI;IAUpB;;;OAGG;IACI,2BAA2B,IAAI,IAAI;IAcnC,OAAO,IAAI,cAAc;IAKzB,SAAS,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC;IAUvC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,uBAAuB;IAK9C,IAAI,IAAI,IAAI;IASZ,WAAW,IAAI,MAAM;CAO5B;AAKD;;GAEG;AACH,wBAAgB,WAAW,CAC1B,OAAO,CAAC,EAAE,SAAS,EACnB,iBAAiB,GAAE,OAAe,GAChC,YAAY,CAEd"}
@@ -15,8 +15,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
15
15
  };
16
16
  var _ObjectForest_events, _ObjectForest_roots;
17
17
  import { assert } from "@fluidframework/core-utils/internal";
18
- import { AnchorSet, ITreeSubscriptionCursorState, aboveRootPlaceholder, deepCopyMapTree, } from "../../core/index.js";
19
- import { createEmitter } from "../../events/index.js";
18
+ import { createEmitter } from "@fluid-internal/client-utils";
19
+ import { AnchorSet, ITreeSubscriptionCursorState, aboveRootPlaceholder, combineVisitors, deepCopyMapTree, } from "../../core/index.js";
20
20
  import { assertNonNegativeSafeInteger, assertValidIndex, assertValidRange, brand, fail, } from "../../util/index.js";
21
21
  import { cursorForMapTreeNode, mapTreeFromCursor } from "../mapTreeCursor.js";
22
22
  import { SynchronousCursor } from "../treeCursorUtils.js";
@@ -45,6 +45,7 @@ export class ObjectForest {
45
45
  this.additionalAsserts = additionalAsserts;
46
46
  // All cursors that are in the "Current" state. Must be empty when editing.
47
47
  this.currentCursors = new Set();
48
+ this.deltaVisitors = new Set();
48
49
  _ObjectForest_events.set(this, createEmitter());
49
50
  this.events = __classPrivateFieldGet(this, _ObjectForest_events, "f");
50
51
  _ObjectForest_roots.set(this, void 0);
@@ -177,9 +178,18 @@ export class ObjectForest {
177
178
  cursor.exitField();
178
179
  }
179
180
  }
180
- const visitor = new Visitor(this);
181
- this.activeVisitor = visitor;
182
- return visitor;
181
+ const forestVisitor = new Visitor(this);
182
+ const announcedVisitors = [];
183
+ this.deltaVisitors.forEach((getVisitor) => announcedVisitors.push(getVisitor()));
184
+ const combinedVisitor = combineVisitors([forestVisitor, ...announcedVisitors], announcedVisitors);
185
+ this.activeVisitor = combinedVisitor;
186
+ return combinedVisitor;
187
+ }
188
+ registerAnnouncedVisitor(visitor) {
189
+ this.deltaVisitors.add(visitor);
190
+ }
191
+ deregisterAnnouncedVisitor(visitor) {
192
+ this.deltaVisitors.delete(visitor);
183
193
  }
184
194
  newDetachedField() {
185
195
  const range = brand(String(this.nextRange));
@@ -1 +1 @@
1
- {"version":3,"file":"objectForest.js","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAEN,SAAS,EAYT,4BAA4B,EAW5B,oBAAoB,EACpB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACN,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,IAAI,GACJ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAuB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/E,kGAAkG;AAClG,SAAS,gBAAgB,CAAC,OAAuB,EAAE,GAAa;IAC/D,MAAM,KAAK,GAAG,O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iB,CAAC,CAAC;AACrD,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 Anchor,\n\tAnchorSet,\n\ttype CursorLocationType,\n\ttype DeltaVisitor,\n\ttype DetachedField,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ForestEvents,\n\ttype IEditableForest,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\ttype MapTree,\n\ttype PathRootPrefix,\n\ttype PlaceIndex,\n\ttype ProtoNodes,\n\ttype Range,\n\tTreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\ttype Value,\n\taboveRootPlaceholder,\n\tdeepCopyMapTree,\n} from \"../../core/index.js\";\nimport { createEmitter, type Listenable } from \"../../events/index.js\";\nimport {\n\tassertNonNegativeSafeInteger,\n\tassertValidIndex,\n\tassertValidRange,\n\tbrand,\n\tfail,\n} from \"../../util/index.js\";\nimport { cursorForMapTreeNode, mapTreeFromCursor } from \"../mapTreeCursor.js\";\nimport { type CursorWithNode, SynchronousCursor } from \"../treeCursorUtils.js\";\n\n/** A `MapTree` with mutable fields */\ninterface MutableMapTree extends MapTree {\n\treadonly fields: Map<FieldKey, MutableMapTree[]>;\n}\n\n/** Get a field from a `MutableMapTree`, optionally modifying the tree to create it if missing. */\nfunction getOrCreateField(mapTree: MutableMapTree, key: FieldKey): MutableMapTree[] {\n\tconst field = mapTree.fields.get(key);\n\tif (field !== undefined) {\n\t\treturn field;\n\t}\n\n\tconst newField: MutableMapTree[] = [];\n\tmapTree.fields.set(key, newField);\n\treturn newField;\n}\n\n/**\n * Reference implementation of IEditableForest.\n *\n * This implementation focuses on correctness and simplicity, not performance.\n * It does not use compressed chunks: instead nodes are implemented using objects.\n */\nexport class ObjectForest implements IEditableForest {\n\tprivate activeVisitor?: DeltaVisitor;\n\n\t// All cursors that are in the \"Current\" state. Must be empty when editing.\n\tpublic readonly currentCursors: Set<Cursor> = new Set();\n\n\treadonly #events = createEmitter<ForestEvents>();\n\tpublic readonly events: Listenable<ForestEvents> = this.#events;\n\n\treadonly #roots: MutableMapTree;\n\tpublic get roots(): MapTree {\n\t\treturn this.#roots;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly anchors: AnchorSet = new AnchorSet(),\n\t\tpublic readonly additionalAsserts: boolean = false,\n\t\troots?: MapTree,\n\t) {\n\t\tthis.#roots =\n\t\t\troots !== undefined\n\t\t\t\t? deepCopyMapTree(roots)\n\t\t\t\t: {\n\t\t\t\t\t\ttype: aboveRootPlaceholder,\n\t\t\t\t\t\tfields: new Map(),\n\t\t\t\t\t};\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(_: TreeStoredSchemaSubscription, anchors: AnchorSet): ObjectForest {\n\t\treturn new ObjectForest(anchors, this.additionalAsserts, this.roots);\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x76c /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\t// Note: This code uses cursors, however it also modifies the tree.\n\t\t// In general this is not safe, but this code happens to only modify the tree below the current cursor location,\n\t\t// which happens to work.\n\t\t// This pattern could be generalized/formalized with a concept of an exclusive cursor,\n\t\t// which can edit, but is the only cursor allowed at the time.\n\n\t\tconst cursor: Cursor = this.allocateCursor(\"acquireVisitor\");\n\t\tcursor.setToAboveDetachedSequences();\n\n\t\t/**\n\t\t * Called before each edit to allow cursor cleanup to happen and ensure that there are no unexpected cursors.\n\t\t * This is required for each change since there may be app facing change event handlers which create cursors.\n\t\t */\n\t\tconst preEdit = (): void => {\n\t\t\tthis.#events.emit(\"beforeChange\");\n\t\t\tassert(\n\t\t\t\tthis.currentCursors.has(cursor),\n\t\t\t\t0x995 /* missing visitor cursor while editing */,\n\t\t\t);\n\t\t\tif (this.currentCursors.size > 1) {\n\t\t\t\tconst unexpectedSources = [...this.currentCursors].flatMap((c) =>\n\t\t\t\t\tc === cursor ? [] : (c.source ?? null),\n\t\t\t\t);\n\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Found unexpected cursors when editing with the following annotations: ${JSON.stringify(\n\t\t\t\t\t\tunexpectedSources,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tclass Visitor implements DeltaVisitor {\n\t\t\tpublic constructor(private readonly forest: ObjectForest) {}\n\t\t\tpublic free(): void {\n\t\t\t\tcursor.free();\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.activeVisitor !== undefined,\n\t\t\t\t\t0x76d /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tthis.forest.activeVisitor = undefined;\n\t\t\t}\n\t\t\tpublic destroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.forest.delete(detachedField);\n\t\t\t}\n\t\t\tpublic create(content: ProtoNodes, destination: FieldKey): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.forest.add(content, destination);\n\t\t\t\tthis.forest.#events.emit(\"afterRootFieldCreated\", destination);\n\t\t\t}\n\t\t\tpublic attach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t}\n\t\t\tpublic detach(source: Range, destination: FieldKey): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t}\n\t\t\t/**\n\t\t\t * Attaches the nodes from the given source field into the current field.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The the range to be attached.\n\t\t\t * @param count - The number of nodes being attached.\n\t\t\t * Expected to match the number of nodes in the source detached field.\n\t\t\t * @param destination - The index in the current field at which to attach the content.\n\t\t\t */\n\t\t\tprivate attachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassertNonNegativeSafeInteger(count);\n\t\t\t\tif (count === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst [parent, key] = cursor.getParent();\n\t\t\t\tassert(\n\t\t\t\t\tparent !== this.forest.roots || key !== source,\n\t\t\t\t\t0x7b6 /* Attach source field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst currentField = getOrCreateField(parent, key);\n\t\t\t\tassertValidIndex(destination, currentField, true);\n\t\t\t\tconst sourceField = this.forest.#roots.fields.get(source) ?? [];\n\t\t\t\tassert(sourceField !== undefined, 0x7b7 /* Attach source field must exist */);\n\t\t\t\tassert(\n\t\t\t\t\tsourceField.length === count,\n\t\t\t\t\t0x7b8 /* Attach must consume all nodes in source field */,\n\t\t\t\t);\n\t\t\t\t// TODO: this will fail for very large insertions due to argument limits.\n\t\t\t\tcurrentField.splice(destination, 0, ...sourceField);\n\t\t\t\tthis.forest.delete(source);\n\t\t\t}\n\t\t\t/**\n\t\t\t * Detaches the range from the current field and transfers it to the given destination if any.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The bounds of the range to be detached from the current field.\n\t\t\t * @param destination - If specified, the destination to transfer the detached range to.\n\t\t\t * If not specified, the detached range is destroyed.\n\t\t\t */\n\t\t\tprivate detachEdit(source: Range, destination: FieldKey | undefined): void {\n\t\t\t\tconst [parent, key] = cursor.getParent();\n\t\t\t\tassert(\n\t\t\t\t\tdestination === undefined || parent !== this.forest.roots || key !== destination,\n\t\t\t\t\t0x7b9 /* Detach destination field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst currentField = getOrCreateField(parent, key);\n\t\t\t\tassertValidRange(source, currentField);\n\t\t\t\tconst content = currentField.splice(source.start, source.end - source.start);\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tthis.forest.addFieldAsDetached(content, destination);\n\t\t\t\t}\n\t\t\t\t// This check is performed after the transfer to ensure that the field is not removed in scenarios\n\t\t\t\t// where the source and destination are the same.\n\t\t\t\tif (currentField.length === 0) {\n\t\t\t\t\tparent.fields.delete(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic replace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tpreEdit();\n\t\t\t\tassert(\n\t\t\t\t\tnewContentSource !== oldContentDestination,\n\t\t\t\t\t0x7ba /* Replace detached source field and detached destination field must be different */,\n\t\t\t\t);\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t}\n\t\t\tpublic enterNode(index: number): void {\n\t\t\t\tcursor.enterNode(index);\n\t\t\t}\n\t\t\tpublic exitNode(index: number): void {\n\t\t\t\tcursor.exitNode();\n\t\t\t}\n\t\t\tpublic enterField(key: FieldKey): void {\n\t\t\t\tcursor.enterField(key);\n\t\t\t}\n\t\t\tpublic exitField(key: FieldKey): void {\n\t\t\t\tcursor.exitField();\n\t\t\t}\n\t\t}\n\n\t\tconst visitor = new Visitor(this);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\n\t}\n\n\tprivate nextRange = 0;\n\tpublic newDetachedField(): DetachedField {\n\t\tconst range: DetachedField = brand(String(this.nextRange));\n\t\tthis.nextRange += 1;\n\t\treturn range;\n\t}\n\n\tprivate add(nodes: Iterable<ITreeCursor>, key: FieldKey): void {\n\t\tconst field = Array.from(nodes, mapTreeFromCursor) as MutableMapTree[];\n\t\tthis.addFieldAsDetached(field, key);\n\t}\n\n\tprivate addFieldAsDetached(field: MutableMapTree[], key: FieldKey): void {\n\t\tassert(!this.roots.fields.has(key), 0x370 /* new range must not already exist */);\n\t\tif (field.length > 0) {\n\t\t\tthis.#roots.fields.set(key, field);\n\t\t}\n\t}\n\n\tprivate delete(field: FieldKey): void {\n\t\tthis.#roots.fields.delete(field);\n\t}\n\n\tpublic allocateCursor(source?: string): Cursor {\n\t\treturn new Cursor(this, source);\n\t}\n\n\tpublic tryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tconst path = this.anchors.locate(destination);\n\t\tif (path === undefined) {\n\t\t\treturn TreeNavigationResult.NotFound;\n\t\t}\n\t\tthis.moveCursorToPath(path, cursorToMove);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic tryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tif (destination.parent === undefined) {\n\t\t\tthis.moveCursorToPath(undefined, cursorToMove);\n\t\t} else {\n\t\t\tconst result = this.tryMoveCursorToNode(destination.parent, cursorToMove);\n\t\t\tif (result !== TreeNavigationResult.Ok) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tcursorToMove.enterField(destination.fieldKey);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic moveCursorToPath(\n\t\tdestination: UpPath | undefined,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): void {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x337 /* ObjectForest must only be given its own Cursor type */,\n\t\t);\n\t\tassert(\n\t\t\tcursorToMove.forest === this,\n\t\t\t0x338 /* ObjectForest must only be given its own Cursor */,\n\t\t);\n\n\t\tconst indexStack: number[] = [];\n\t\tconst keyStack: FieldKey[] = [];\n\n\t\tlet path: UpPath | undefined = destination;\n\t\twhile (path !== undefined) {\n\t\t\tindexStack.push(path.parentIndex);\n\t\t\tkeyStack.push(path.parentField);\n\t\t\tpath = path.parent;\n\t\t}\n\t\tcursorToMove.setToAboveDetachedSequences();\n\t\twhile (keyStack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterField(keyStack.pop()!);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterNode(indexStack.pop()!);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tpublic getCursorAboveDetachedFields(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode(this.roots);\n\t}\n}\n\n/**\n * Cursor implementation for ObjectForest.\n */\nclass Cursor extends SynchronousCursor implements ITreeSubscriptionCursor {\n\tpublic state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @param forest - forest this cursor navigates\n\t * @param innerCursor - underlying cursor implementation this wraps. `undefined` when state is not `Current`\n\t */\n\tpublic constructor(\n\t\tpublic readonly forest: ObjectForest,\n\t\tpublic readonly source: string | undefined,\n\t\tprivate innerCursor?: CursorWithNode<MutableMapTree>,\n\t) {\n\t\tsuper();\n\t\tif (innerCursor === undefined) {\n\t\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\t} else {\n\t\t\tthis.state = ITreeSubscriptionCursorState.Current;\n\t\t\tthis.forest.currentCursors.add(this);\n\t\t}\n\t}\n\n\tpublic buildFieldAnchor(): FieldAnchor {\n\t\tconst path = this.getFieldPath();\n\t\tconst anchor =\n\t\t\tpath.parent === undefined ? undefined : this.forest.anchors.track(path.parent);\n\t\treturn { parent: anchor, fieldKey: path.field };\n\t}\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tassert(this.innerCursor !== undefined, 0x45f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldPath(prefix);\n\t}\n\tpublic get mode(): CursorLocationType {\n\t\tassert(this.innerCursor !== undefined, 0x42e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.mode;\n\t}\n\n\tpublic nextField(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x42f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.nextField();\n\t}\n\tpublic exitField(): void {\n\t\tassert(this.innerCursor !== undefined, 0x430 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.exitField();\n\t}\n\tpublic override skipPendingFields(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x431 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.skipPendingFields();\n\t}\n\tpublic getFieldKey(): FieldKey {\n\t\tassert(this.innerCursor !== undefined, 0x432 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldKey();\n\t}\n\tpublic getFieldLength(): number {\n\t\tassert(this.innerCursor !== undefined, 0x433 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldLength();\n\t}\n\tpublic firstNode(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x434 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.firstNode();\n\t}\n\tpublic enterNode(childIndex: number): void {\n\t\tassert(this.innerCursor !== undefined, 0x435 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.enterNode(childIndex);\n\t}\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tassert(this.innerCursor !== undefined, 0x436 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getPath(prefix) ?? fail(\"no path when at root\");\n\t}\n\tpublic get fieldIndex(): number {\n\t\tassert(this.innerCursor !== undefined, 0x437 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.fieldIndex;\n\t}\n\tpublic get chunkStart(): number {\n\t\tassert(this.innerCursor !== undefined, 0x438 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.chunkStart;\n\t}\n\tpublic get chunkLength(): number {\n\t\tassert(this.innerCursor !== undefined, 0x439 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.chunkLength;\n\t}\n\tpublic seekNodes(offset: number): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43a /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.seekNodes(offset);\n\t}\n\tpublic nextNode(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43b /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.nextNode();\n\t}\n\tpublic exitNode(): void {\n\t\tassert(this.innerCursor !== undefined, 0x43c /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.exitNode();\n\t}\n\tpublic firstField(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43d /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.firstField();\n\t}\n\tpublic enterField(key: FieldKey): void {\n\t\tassert(this.innerCursor !== undefined, 0x43e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.enterField(key);\n\t}\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\tassert(this.innerCursor !== undefined, 0x43f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.type;\n\t}\n\tpublic get value(): Value {\n\t\tassert(this.innerCursor !== undefined, 0x440 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.value;\n\t}\n\n\t// TODO: tests for clear when not at root.\n\tpublic clear(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33b /* Cursor must not be freed */,\n\t\t);\n\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\tthis.innerCursor = undefined;\n\t\tthis.forest.currentCursors.delete(this);\n\t}\n\n\t/**\n\t * Move this cursor to the special dummy node above the detached sequences.\n\t * Can be used when cleared (but not freed).\n\t */\n\tpublic setToAboveDetachedSequences(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33c /* Cursor must not be freed */,\n\t\t);\n\t\tthis.clear();\n\t\tthis.state = ITreeSubscriptionCursorState.Current;\n\t\t// Cast to a cursor of _mutable_ trees to allow direct manipulation of the tree data which is more efficient than doing immutable copies.\n\t\tthis.innerCursor = cursorForMapTreeNode(\n\t\t\tthis.forest.roots,\n\t\t) as CursorWithNode<MutableMapTree>;\n\t\tthis.forest.currentCursors.add(this);\n\t}\n\n\tpublic getNode(): MutableMapTree {\n\t\tassert(this.innerCursor !== undefined, 0x33e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getNode();\n\t}\n\n\tpublic getParent(): [MutableMapTree, FieldKey] {\n\t\tassert(this.innerCursor !== undefined, 0x441 /* Cursor must be current to be used */);\n\t\t// This could be optimized to skip moving it accessing internals of cursor.\n\t\tconst key = this.innerCursor.getFieldKey();\n\t\tthis.innerCursor.exitField();\n\t\tconst node = this.innerCursor.getNode();\n\t\tthis.innerCursor.enterField(key);\n\t\treturn [node, key];\n\t}\n\n\tpublic fork(source?: string): ITreeSubscriptionCursor {\n\t\tassert(this.innerCursor !== undefined, 0x460 /* Cursor must be current to be used */);\n\t\treturn new Cursor(this.forest, source ?? `fork: ${this.source}`, this.innerCursor.fork());\n\t}\n\n\tpublic free(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33f /* Cursor must not be double freed */,\n\t\t);\n\t\tthis.forest.currentCursors.delete(this);\n\t\tthis.state = ITreeSubscriptionCursorState.Freed;\n\t}\n\n\tpublic buildAnchor(): Anchor {\n\t\tassert(\n\t\t\tthis.state === ITreeSubscriptionCursorState.Current,\n\t\t\t0x37a /* Cursor must be current to be used */,\n\t\t);\n\t\treturn this.forest.anchors.track(this.getPath());\n\t}\n}\n\n// This function is the folder level export for objectForest, and hides all the implementation types.\n// When other forest implementations are created (ex: optimized ones),\n// this function should likely be moved and updated to (at least conditionally) use them.\n/**\n * @returns an implementation of {@link IEditableForest} with no data or schema.\n */\nexport function buildForest(\n\tanchors?: AnchorSet,\n\tadditionalAsserts: boolean = false,\n): ObjectForest {\n\treturn new ObjectForest(anchors, additionalAsserts);\n}\n"]}
1
+ {"version":3,"file":"objectForest.js","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM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,EAAE,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,IAAI,CAAC,MAAe;QAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACtF,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,IAAI;QACV,MAAM,CACL,IAAI,CAAC,KAAK,KAAK,4BAA4B,CAAC,KAAK,EACjD,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,4BAA4B,CAAC,KAAK,CAAC;IACjD,CAAC;IAEM,WAAW;QACjB,MAAM,CACL,IAAI,CAAC,KAAK,KAAK,4BAA4B,CAAC,OAAO,EACnD,KAAK,CAAC,uCAAuC,CAC7C,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;CACD;AAED,qGAAqG;AACrG,sEAAsE;AACtE,yFAAyF;AACzF;;GAEG;AACH,MAAM,UAAU,WAAW,CAC1B,OAAmB,EACnB,oBAA6B,KAAK;IAElC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\n\nimport {\n\ttype Anchor,\n\tAnchorSet,\n\ttype AnnouncedVisitor,\n\ttype CursorLocationType,\n\ttype DeltaVisitor,\n\ttype DetachedField,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ForestEvents,\n\ttype IEditableForest,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\ttype MapTree,\n\ttype PathRootPrefix,\n\ttype PlaceIndex,\n\ttype ProtoNodes,\n\ttype Range,\n\tTreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\ttype Value,\n\taboveRootPlaceholder,\n\tcombineVisitors,\n\tdeepCopyMapTree,\n} from \"../../core/index.js\";\nimport {\n\tassertNonNegativeSafeInteger,\n\tassertValidIndex,\n\tassertValidRange,\n\tbrand,\n\tfail,\n} from \"../../util/index.js\";\nimport { cursorForMapTreeNode, mapTreeFromCursor } from \"../mapTreeCursor.js\";\nimport { type CursorWithNode, SynchronousCursor } from \"../treeCursorUtils.js\";\n\n/** A `MapTree` with mutable fields */\ninterface MutableMapTree extends MapTree {\n\treadonly fields: Map<FieldKey, MutableMapTree[]>;\n}\n\n/** Get a field from a `MutableMapTree`, optionally modifying the tree to create it if missing. */\nfunction getOrCreateField(mapTree: MutableMapTree, key: FieldKey): MutableMapTree[] {\n\tconst field = mapTree.fields.get(key);\n\tif (field !== undefined) {\n\t\treturn field;\n\t}\n\n\tconst newField: MutableMapTree[] = [];\n\tmapTree.fields.set(key, newField);\n\treturn newField;\n}\n\n/**\n * Reference implementation of IEditableForest.\n *\n * This implementation focuses on correctness and simplicity, not performance.\n * It does not use compressed chunks: instead nodes are implemented using objects.\n */\nexport class ObjectForest implements IEditableForest {\n\tprivate activeVisitor?: DeltaVisitor;\n\n\t// All cursors that are in the \"Current\" state. Must be empty when editing.\n\tpublic readonly currentCursors: Set<Cursor> = new Set();\n\tprivate readonly deltaVisitors: Set<() => AnnouncedVisitor> = new Set();\n\n\treadonly #events = createEmitter<ForestEvents>();\n\tpublic readonly events: Listenable<ForestEvents> = this.#events;\n\n\treadonly #roots: MutableMapTree;\n\tpublic get roots(): MapTree {\n\t\treturn this.#roots;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly anchors: AnchorSet = new AnchorSet(),\n\t\tpublic readonly additionalAsserts: boolean = false,\n\t\troots?: MapTree,\n\t) {\n\t\tthis.#roots =\n\t\t\troots !== undefined\n\t\t\t\t? deepCopyMapTree(roots)\n\t\t\t\t: {\n\t\t\t\t\t\ttype: aboveRootPlaceholder,\n\t\t\t\t\t\tfields: new Map(),\n\t\t\t\t\t};\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(_: TreeStoredSchemaSubscription, anchors: AnchorSet): ObjectForest {\n\t\treturn new ObjectForest(anchors, this.additionalAsserts, this.roots);\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x76c /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\t// Note: This code uses cursors, however it also modifies the tree.\n\t\t// In general this is not safe, but this code happens to only modify the tree below the current cursor location,\n\t\t// which happens to work.\n\t\t// This pattern could be generalized/formalized with a concept of an exclusive cursor,\n\t\t// which can edit, but is the only cursor allowed at the time.\n\n\t\tconst cursor: Cursor = this.allocateCursor(\"acquireVisitor\");\n\t\tcursor.setToAboveDetachedSequences();\n\n\t\t/**\n\t\t * Called before each edit to allow cursor cleanup to happen and ensure that there are no unexpected cursors.\n\t\t * This is required for each change since there may be app facing change event handlers which create cursors.\n\t\t */\n\t\tconst preEdit = (): void => {\n\t\t\tthis.#events.emit(\"beforeChange\");\n\t\t\tassert(\n\t\t\t\tthis.currentCursors.has(cursor),\n\t\t\t\t0x995 /* missing visitor cursor while editing */,\n\t\t\t);\n\t\t\tif (this.currentCursors.size > 1) {\n\t\t\t\tconst unexpectedSources = [...this.currentCursors].flatMap((c) =>\n\t\t\t\t\tc === cursor ? [] : (c.source ?? null),\n\t\t\t\t);\n\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Found unexpected cursors when editing with the following annotations: ${JSON.stringify(\n\t\t\t\t\t\tunexpectedSources,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tclass Visitor implements DeltaVisitor {\n\t\t\tpublic constructor(private readonly forest: ObjectForest) {}\n\t\t\tpublic free(): void {\n\t\t\t\tcursor.free();\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.activeVisitor !== undefined,\n\t\t\t\t\t0x76d /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tthis.forest.activeVisitor = undefined;\n\t\t\t}\n\t\t\tpublic destroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.forest.delete(detachedField);\n\t\t\t}\n\t\t\tpublic create(content: ProtoNodes, destination: FieldKey): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.forest.add(content, destination);\n\t\t\t\tthis.forest.#events.emit(\"afterRootFieldCreated\", destination);\n\t\t\t}\n\t\t\tpublic attach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t}\n\t\t\tpublic detach(source: Range, destination: FieldKey): void {\n\t\t\t\tpreEdit();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t}\n\t\t\t/**\n\t\t\t * Attaches the nodes from the given source field into the current field.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The the range to be attached.\n\t\t\t * @param count - The number of nodes being attached.\n\t\t\t * Expected to match the number of nodes in the source detached field.\n\t\t\t * @param destination - The index in the current field at which to attach the content.\n\t\t\t */\n\t\t\tprivate attachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassertNonNegativeSafeInteger(count);\n\t\t\t\tif (count === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst [parent, key] = cursor.getParent();\n\t\t\t\tassert(\n\t\t\t\t\tparent !== this.forest.roots || key !== source,\n\t\t\t\t\t0x7b6 /* Attach source field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst currentField = getOrCreateField(parent, key);\n\t\t\t\tassertValidIndex(destination, currentField, true);\n\t\t\t\tconst sourceField = this.forest.#roots.fields.get(source) ?? [];\n\t\t\t\tassert(sourceField !== undefined, 0x7b7 /* Attach source field must exist */);\n\t\t\t\tassert(\n\t\t\t\t\tsourceField.length === count,\n\t\t\t\t\t0x7b8 /* Attach must consume all nodes in source field */,\n\t\t\t\t);\n\t\t\t\t// TODO: this will fail for very large insertions due to argument limits.\n\t\t\t\tcurrentField.splice(destination, 0, ...sourceField);\n\t\t\t\tthis.forest.delete(source);\n\t\t\t}\n\t\t\t/**\n\t\t\t * Detaches the range from the current field and transfers it to the given destination if any.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The bounds of the range to be detached from the current field.\n\t\t\t * @param destination - If specified, the destination to transfer the detached range to.\n\t\t\t * If not specified, the detached range is destroyed.\n\t\t\t */\n\t\t\tprivate detachEdit(source: Range, destination: FieldKey | undefined): void {\n\t\t\t\tconst [parent, key] = cursor.getParent();\n\t\t\t\tassert(\n\t\t\t\t\tdestination === undefined || parent !== this.forest.roots || key !== destination,\n\t\t\t\t\t0x7b9 /* Detach destination field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst currentField = getOrCreateField(parent, key);\n\t\t\t\tassertValidRange(source, currentField);\n\t\t\t\tconst content = currentField.splice(source.start, source.end - source.start);\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tthis.forest.addFieldAsDetached(content, destination);\n\t\t\t\t}\n\t\t\t\t// This check is performed after the transfer to ensure that the field is not removed in scenarios\n\t\t\t\t// where the source and destination are the same.\n\t\t\t\tif (currentField.length === 0) {\n\t\t\t\t\tparent.fields.delete(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic replace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tpreEdit();\n\t\t\t\tassert(\n\t\t\t\t\tnewContentSource !== oldContentDestination,\n\t\t\t\t\t0x7ba /* Replace detached source field and detached destination field must be different */,\n\t\t\t\t);\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t}\n\t\t\tpublic enterNode(index: number): void {\n\t\t\t\tcursor.enterNode(index);\n\t\t\t}\n\t\t\tpublic exitNode(index: number): void {\n\t\t\t\tcursor.exitNode();\n\t\t\t}\n\t\t\tpublic enterField(key: FieldKey): void {\n\t\t\t\tcursor.enterField(key);\n\t\t\t}\n\t\t\tpublic exitField(key: FieldKey): void {\n\t\t\t\tcursor.exitField();\n\t\t\t}\n\t\t}\n\n\t\tconst forestVisitor = new Visitor(this);\n\t\tconst announcedVisitors: AnnouncedVisitor[] = [];\n\t\tthis.deltaVisitors.forEach((getVisitor) => announcedVisitors.push(getVisitor()));\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[forestVisitor, ...announcedVisitors],\n\t\t\tannouncedVisitors,\n\t\t);\n\t\tthis.activeVisitor = combinedVisitor;\n\t\treturn combinedVisitor;\n\t}\n\n\tpublic registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.add(visitor);\n\t}\n\n\tpublic deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.delete(visitor);\n\t}\n\n\tprivate nextRange = 0;\n\tpublic newDetachedField(): DetachedField {\n\t\tconst range: DetachedField = brand(String(this.nextRange));\n\t\tthis.nextRange += 1;\n\t\treturn range;\n\t}\n\n\tprivate add(nodes: Iterable<ITreeCursor>, key: FieldKey): void {\n\t\tconst field = Array.from(nodes, mapTreeFromCursor) as MutableMapTree[];\n\t\tthis.addFieldAsDetached(field, key);\n\t}\n\n\tprivate addFieldAsDetached(field: MutableMapTree[], key: FieldKey): void {\n\t\tassert(!this.roots.fields.has(key), 0x370 /* new range must not already exist */);\n\t\tif (field.length > 0) {\n\t\t\tthis.#roots.fields.set(key, field);\n\t\t}\n\t}\n\n\tprivate delete(field: FieldKey): void {\n\t\tthis.#roots.fields.delete(field);\n\t}\n\n\tpublic allocateCursor(source?: string): Cursor {\n\t\treturn new Cursor(this, source);\n\t}\n\n\tpublic tryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tconst path = this.anchors.locate(destination);\n\t\tif (path === undefined) {\n\t\t\treturn TreeNavigationResult.NotFound;\n\t\t}\n\t\tthis.moveCursorToPath(path, cursorToMove);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic tryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tif (destination.parent === undefined) {\n\t\t\tthis.moveCursorToPath(undefined, cursorToMove);\n\t\t} else {\n\t\t\tconst result = this.tryMoveCursorToNode(destination.parent, cursorToMove);\n\t\t\tif (result !== TreeNavigationResult.Ok) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tcursorToMove.enterField(destination.fieldKey);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic moveCursorToPath(\n\t\tdestination: UpPath | undefined,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): void {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x337 /* ObjectForest must only be given its own Cursor type */,\n\t\t);\n\t\tassert(\n\t\t\tcursorToMove.forest === this,\n\t\t\t0x338 /* ObjectForest must only be given its own Cursor */,\n\t\t);\n\n\t\tconst indexStack: number[] = [];\n\t\tconst keyStack: FieldKey[] = [];\n\n\t\tlet path: UpPath | undefined = destination;\n\t\twhile (path !== undefined) {\n\t\t\tindexStack.push(path.parentIndex);\n\t\t\tkeyStack.push(path.parentField);\n\t\t\tpath = path.parent;\n\t\t}\n\t\tcursorToMove.setToAboveDetachedSequences();\n\t\twhile (keyStack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterField(keyStack.pop()!);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterNode(indexStack.pop()!);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tpublic getCursorAboveDetachedFields(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode(this.roots);\n\t}\n}\n\n/**\n * Cursor implementation for ObjectForest.\n */\nclass Cursor extends SynchronousCursor implements ITreeSubscriptionCursor {\n\tpublic state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @param forest - forest this cursor navigates\n\t * @param innerCursor - underlying cursor implementation this wraps. `undefined` when state is not `Current`\n\t */\n\tpublic constructor(\n\t\tpublic readonly forest: ObjectForest,\n\t\tpublic readonly source: string | undefined,\n\t\tprivate innerCursor?: CursorWithNode<MutableMapTree>,\n\t) {\n\t\tsuper();\n\t\tif (innerCursor === undefined) {\n\t\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\t} else {\n\t\t\tthis.state = ITreeSubscriptionCursorState.Current;\n\t\t\tthis.forest.currentCursors.add(this);\n\t\t}\n\t}\n\n\tpublic buildFieldAnchor(): FieldAnchor {\n\t\tconst path = this.getFieldPath();\n\t\tconst anchor =\n\t\t\tpath.parent === undefined ? undefined : this.forest.anchors.track(path.parent);\n\t\treturn { parent: anchor, fieldKey: path.field };\n\t}\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tassert(this.innerCursor !== undefined, 0x45f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldPath(prefix);\n\t}\n\tpublic get mode(): CursorLocationType {\n\t\tassert(this.innerCursor !== undefined, 0x42e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.mode;\n\t}\n\n\tpublic nextField(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x42f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.nextField();\n\t}\n\tpublic exitField(): void {\n\t\tassert(this.innerCursor !== undefined, 0x430 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.exitField();\n\t}\n\tpublic override skipPendingFields(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x431 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.skipPendingFields();\n\t}\n\tpublic getFieldKey(): FieldKey {\n\t\tassert(this.innerCursor !== undefined, 0x432 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldKey();\n\t}\n\tpublic getFieldLength(): number {\n\t\tassert(this.innerCursor !== undefined, 0x433 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getFieldLength();\n\t}\n\tpublic firstNode(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x434 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.firstNode();\n\t}\n\tpublic enterNode(childIndex: number): void {\n\t\tassert(this.innerCursor !== undefined, 0x435 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.enterNode(childIndex);\n\t}\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tassert(this.innerCursor !== undefined, 0x436 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getPath(prefix) ?? fail(\"no path when at root\");\n\t}\n\tpublic get fieldIndex(): number {\n\t\tassert(this.innerCursor !== undefined, 0x437 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.fieldIndex;\n\t}\n\tpublic get chunkStart(): number {\n\t\tassert(this.innerCursor !== undefined, 0x438 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.chunkStart;\n\t}\n\tpublic get chunkLength(): number {\n\t\tassert(this.innerCursor !== undefined, 0x439 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.chunkLength;\n\t}\n\tpublic seekNodes(offset: number): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43a /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.seekNodes(offset);\n\t}\n\tpublic nextNode(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43b /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.nextNode();\n\t}\n\tpublic exitNode(): void {\n\t\tassert(this.innerCursor !== undefined, 0x43c /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.exitNode();\n\t}\n\tpublic firstField(): boolean {\n\t\tassert(this.innerCursor !== undefined, 0x43d /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.firstField();\n\t}\n\tpublic enterField(key: FieldKey): void {\n\t\tassert(this.innerCursor !== undefined, 0x43e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.enterField(key);\n\t}\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\tassert(this.innerCursor !== undefined, 0x43f /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.type;\n\t}\n\tpublic get value(): Value {\n\t\tassert(this.innerCursor !== undefined, 0x440 /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.value;\n\t}\n\n\t// TODO: tests for clear when not at root.\n\tpublic clear(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33b /* Cursor must not be freed */,\n\t\t);\n\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\tthis.innerCursor = undefined;\n\t\tthis.forest.currentCursors.delete(this);\n\t}\n\n\t/**\n\t * Move this cursor to the special dummy node above the detached sequences.\n\t * Can be used when cleared (but not freed).\n\t */\n\tpublic setToAboveDetachedSequences(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33c /* Cursor must not be freed */,\n\t\t);\n\t\tthis.clear();\n\t\tthis.state = ITreeSubscriptionCursorState.Current;\n\t\t// Cast to a cursor of _mutable_ trees to allow direct manipulation of the tree data which is more efficient than doing immutable copies.\n\t\tthis.innerCursor = cursorForMapTreeNode(\n\t\t\tthis.forest.roots,\n\t\t) as CursorWithNode<MutableMapTree>;\n\t\tthis.forest.currentCursors.add(this);\n\t}\n\n\tpublic getNode(): MutableMapTree {\n\t\tassert(this.innerCursor !== undefined, 0x33e /* Cursor must be current to be used */);\n\t\treturn this.innerCursor.getNode();\n\t}\n\n\tpublic getParent(): [MutableMapTree, FieldKey] {\n\t\tassert(this.innerCursor !== undefined, 0x441 /* Cursor must be current to be used */);\n\t\t// This could be optimized to skip moving it accessing internals of cursor.\n\t\tconst key = this.innerCursor.getFieldKey();\n\t\tthis.innerCursor.exitField();\n\t\tconst node = this.innerCursor.getNode();\n\t\tthis.innerCursor.enterField(key);\n\t\treturn [node, key];\n\t}\n\n\tpublic fork(source?: string): ITreeSubscriptionCursor {\n\t\tassert(this.innerCursor !== undefined, 0x460 /* Cursor must be current to be used */);\n\t\treturn new Cursor(this.forest, source ?? `fork: ${this.source}`, this.innerCursor.fork());\n\t}\n\n\tpublic free(): void {\n\t\tassert(\n\t\t\tthis.state !== ITreeSubscriptionCursorState.Freed,\n\t\t\t0x33f /* Cursor must not be double freed */,\n\t\t);\n\t\tthis.forest.currentCursors.delete(this);\n\t\tthis.state = ITreeSubscriptionCursorState.Freed;\n\t}\n\n\tpublic buildAnchor(): Anchor {\n\t\tassert(\n\t\t\tthis.state === ITreeSubscriptionCursorState.Current,\n\t\t\t0x37a /* Cursor must be current to be used */,\n\t\t);\n\t\treturn this.forest.anchors.track(this.getPath());\n\t}\n}\n\n// This function is the folder level export for objectForest, and hides all the implementation types.\n// When other forest implementations are created (ex: optimized ones),\n// this function should likely be moved and updated to (at least conditionally) use them.\n/**\n * @returns an implementation of {@link IEditableForest} with no data or schema.\n */\nexport function buildForest(\n\tanchors?: AnchorSet,\n\tadditionalAsserts: boolean = false,\n): ObjectForest {\n\treturn new ObjectForest(anchors, additionalAsserts);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"invert.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAGN,KAAK,SAAS,EAWd,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACrB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,OAAO,EACnB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,iBAAiB,EAAE,iBAAiB,GAClC,SAAS,CAOX"}
1
+ {"version":3,"file":"invert.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,WAAW,EAAiC,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAGN,KAAK,SAAS,EAWd,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACrB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,OAAO,EACnB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,iBAAiB,EAAE,iBAAiB,GAClC,SAAS,CAOX"}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, unreachableCase, oob } from "@fluidframework/core-utils/internal";
6
- import { fail } from "../../util/index.js";
5
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
6
+ import { fail, hasSingle } from "../../util/index.js";
7
7
  import { CrossFieldTarget, } from "../modular-schema/index.js";
8
8
  import { MarkListFactory } from "./markListFactory.js";
9
9
  import { NoopMarkType, } from "./types.js";
@@ -179,8 +179,8 @@ function invertMark(mark, isRollback, crossFieldManager, revision) {
179
179
  if (detachInverses.length === 0) {
180
180
  return attachInverses;
181
181
  }
182
- assert(detachInverses.length === 1, 0x80d /* Only expected MoveIn marks to be split when inverting */);
183
- let detachInverse = detachInverses[0] ?? oob();
182
+ assert(hasSingle(detachInverses), 0x80d /* Only expected MoveIn marks to be split when inverting */);
183
+ let detachInverse = detachInverses[0];
184
184
  assert(isAttach(detachInverse), 0x80e /* Inverse of a detach should be an attach */);
185
185
  const inverses = [];
186
186
  for (const attachInverse of attachInverses) {
@@ -1 +1 @@
1
- {"version":3,"file":"invert.js","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAGnF,OAAO,EAAkC,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAEN,gBAAgB,GAEhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAWN,YAAY,GAGZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,cAAc,GACd,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CACrB,MAAiB,EACjB,UAAmB,EACnB,KAAkB,EAClB,QAAiC,EACjC,iBAAoC;IAEpC,OAAO,cAAc,CACpB,MAAM,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C;YAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\n\nimport type { RevisionTag } from \"../../core/index.js\";\nimport { type IdAllocator, type Mutable, fail } from \"../../util/index.js\";\nimport {\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\ttype NodeId,\n} from \"../modular-schema/index.js\";\n\nimport { MarkListFactory } from \"./markListFactory.js\";\nimport {\n\ttype CellId,\n\ttype CellMark,\n\ttype Changeset,\n\ttype Detach,\n\ttype Mark,\n\ttype MarkEffect,\n\ttype MarkList,\n\ttype MoveIn,\n\ttype MoveOut,\n\ttype NoopMark,\n\tNoopMarkType,\n\ttype Remove,\n\ttype Rename,\n} from \"./types.js\";\nimport {\n\textractMarkEffect,\n\tgetDetachOutputCellId,\n\tgetEndpoint,\n\tgetInputCellId,\n\tgetOutputCellId,\n\tisAttach,\n\tisDetach,\n\tisImpactful,\n\tnormalizeCellRename,\n\tsplitMark,\n\twithNodeChange,\n} from \"./utils.js\";\n\n/**\n * Inverts a given changeset.\n * @param change - The changeset to produce the inverse of.\n * @param isRollback - Whether the inverse is being produced for a rollback.\n * @param genId - The ID allocator to use for generating new IDs.\n * @param revision - The revision to use for the inverse changeset.\n * @param crossFieldManager - The cross-field manager to use for tracking cross-field changes.\n * @returns The inverse of the given `change` such that the inverse can be applied after `change`.\n *\n * WARNING! This implementation is incomplete:\n * - Support for slices is not implemented.\n */\nexport function invert(\n\tchange: Changeset,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\trevision: RevisionTag | undefined,\n\tcrossFieldManager: CrossFieldManager,\n): Changeset {\n\treturn invertMarkList(\n\t\tchange,\n\t\tisRollback,\n\t\tcrossFieldManager as CrossFieldManager<NodeId>,\n\t\trevision,\n\t);\n}\n\nfunction invertMarkList(\n\tmarkList: MarkList,\n\tisRollback: boolean,\n\tcrossFieldManager: CrossFieldManager<NodeId>,\n\trevision: RevisionTag | undefined,\n): MarkList {\n\tconst inverseMarkList = new MarkListFactory();\n\n\tfor (const mark of markList) {\n\t\tconst inverseMarks = invertMark(mark, isRollback, crossFieldManager, revision);\n\t\tinverseMarkList.push(...inverseMarks);\n\t}\n\n\treturn inverseMarkList.list;\n}\n\nfunction invertMark(\n\tmark: Mark,\n\tisRollback: boolean,\n\tcrossFieldManager: CrossFieldManager<NodeId>,\n\trevision: RevisionTag | undefined,\n): Mark[] {\n\tif (!isImpactful(mark)) {\n\t\tconst inputId = getInputCellId(mark);\n\t\treturn [invertNodeChangeOrSkip(mark.count, mark.changes, inputId)];\n\t}\n\tconst type = mark.type;\n\tswitch (type) {\n\t\tcase NoopMarkType: {\n\t\t\treturn [mark];\n\t\t}\n\t\tcase \"Rename\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x9f5 /* Rename mark must have cell ID */);\n\t\t\tconst inverse: Mutable<CellMark<Rename>> = {\n\t\t\t\ttype: \"Rename\",\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: mark.idOverride,\n\t\t\t\t// Unlike a remove or move-out, which follow a node, there is no way for this mark to assign the original input cell ID to another cell.\n\t\t\t\t// This means it should be safe to always restore the input cell ID (as opposed to only doing it on rollbacks).\n\t\t\t\t// Despite that, we still only do it on rollback for the sake of consistency: once a cell has been assigned an ID,\n\t\t\t\t// the only way for that cell to be assigned that ID again is if it is rolled back to that state.\n\t\t\t\tidOverride: isRollback ? inputId : { localId: inputId.localId },\n\t\t\t};\n\t\t\treturn [withNodeChange(inverse, mark.changes)];\n\t\t}\n\t\tcase \"Remove\": {\n\t\t\tassert(mark.revision !== undefined, 0x5a1 /* Unable to revert to undefined revision */);\n\t\t\tconst outputId = getOutputCellId(mark);\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tlet inverse: Mutable<Mark>;\n\t\t\tif (inputId === undefined) {\n\t\t\t\tinverse = {\n\t\t\t\t\ttype: \"Insert\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\tcellId: outputId,\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tinverse = {\n\t\t\t\t\ttype: \"Remove\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\tcellId: outputId,\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tif (isRollback) {\n\t\t\t\t\tinverse.idOverride = inputId;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn [withNodeChange(inverse, mark.changes)];\n\t\t}\n\t\tcase \"Insert\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x80c /* Active inserts should target empty cells */);\n\t\t\tconst removeMark: Mutable<CellMark<Remove>> = {\n\t\t\t\ttype: \"Remove\",\n\t\t\t\tcount: mark.count,\n\t\t\t\tid: inputId.localId,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (isRollback) {\n\t\t\t\tremoveMark.idOverride = inputId;\n\t\t\t}\n\n\t\t\tconst inverse = withNodeChange(removeMark, mark.changes);\n\t\t\treturn [inverse];\n\t\t}\n\t\tcase \"MoveOut\": {\n\t\t\tif (mark.changes !== undefined) {\n\t\t\t\tassert(mark.count === 1, 0x6ed /* Mark with changes can only target a single cell */);\n\n\t\t\t\tconst endpoint = getEndpoint(mark);\n\t\t\t\tcrossFieldManager.set(\n\t\t\t\t\tCrossFieldTarget.Destination,\n\t\t\t\t\tendpoint.revision,\n\t\t\t\t\tendpoint.localId,\n\t\t\t\t\tmark.count,\n\t\t\t\t\tmark.changes,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cellId = getDetachOutputCellId(mark) ?? {\n\t\t\t\trevision: mark.revision ?? fail(\"Revision must be defined\"),\n\t\t\t\tlocalId: mark.id,\n\t\t\t};\n\n\t\t\tconst moveIn: MoveIn = {\n\t\t\t\ttype: \"MoveIn\",\n\t\t\t\tid: mark.id,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (mark.finalEndpoint !== undefined) {\n\t\t\t\tmoveIn.finalEndpoint = {\n\t\t\t\t\tlocalId: mark.finalEndpoint.localId,\n\t\t\t\t\trevision: mark.revision,\n\t\t\t\t};\n\t\t\t}\n\t\t\tlet effect: MarkEffect = moveIn;\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tif (inputId !== undefined) {\n\t\t\t\tconst detach: Mutable<Detach> = {\n\t\t\t\t\ttype: \"Remove\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tif (isRollback) {\n\t\t\t\t\tdetach.idOverride = inputId;\n\t\t\t\t}\n\t\t\t\teffect = {\n\t\t\t\t\ttype: \"AttachAndDetach\",\n\t\t\t\t\tattach: moveIn,\n\t\t\t\t\tdetach,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn [{ ...effect, count: mark.count, cellId }];\n\t\t}\n\t\tcase \"MoveIn\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x89e /* Active move-ins should target empty cells */);\n\t\t\tconst invertedMark: Mutable<CellMark<MoveOut>> = {\n\t\t\t\ttype: \"MoveOut\",\n\t\t\t\tid: mark.id,\n\t\t\t\tcount: mark.count,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (isRollback) {\n\t\t\t\tinvertedMark.idOverride = inputId;\n\t\t\t}\n\n\t\t\tif (mark.finalEndpoint) {\n\t\t\t\tinvertedMark.finalEndpoint = {\n\t\t\t\t\tlocalId: mark.finalEndpoint.localId,\n\t\t\t\t\trevision: mark.revision,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn applyMovedChanges(invertedMark, mark.revision, crossFieldManager);\n\t\t}\n\t\tcase \"AttachAndDetach\": {\n\t\t\tconst attach: Mark = {\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: mark.cellId,\n\t\t\t\t...mark.attach,\n\t\t\t};\n\t\t\tconst idAfterAttach = getOutputCellId(attach);\n\n\t\t\t// We put `mark.changes` on the detach so that if it is a move source\n\t\t\t// the changes can be sent to the endpoint.\n\t\t\tconst detach: Mark = {\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: idAfterAttach,\n\t\t\t\tchanges: mark.changes,\n\t\t\t\t...mark.detach,\n\t\t\t};\n\t\t\tconst attachInverses = invertMark(attach, isRollback, crossFieldManager, revision);\n\t\t\tconst detachInverses = invertMark(detach, isRollback, crossFieldManager, revision);\n\n\t\t\tif (detachInverses.length === 0) {\n\t\t\t\treturn attachInverses;\n\t\t\t}\n\n\t\t\tassert(\n\t\t\t\tdetachInverses.length === 1,\n\t\t\t\t0x80d /* Only expected MoveIn marks to be split when inverting */,\n\t\t\t);\n\n\t\t\tlet detachInverse = detachInverses[0] ?? oob();\n\t\t\tassert(isAttach(detachInverse), 0x80e /* Inverse of a detach should be an attach */);\n\n\t\t\tconst inverses: Mark[] = [];\n\t\t\tfor (const attachInverse of attachInverses) {\n\t\t\t\tlet detachInverseCurr: Mark = detachInverse;\n\t\t\t\tif (attachInverse.count !== detachInverse.count) {\n\t\t\t\t\t[detachInverseCurr, detachInverse] = splitMark(detachInverse, attachInverse.count);\n\t\t\t\t}\n\n\t\t\t\tif (attachInverse.type === NoopMarkType) {\n\t\t\t\t\tif (attachInverse.changes !== undefined) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdetachInverseCurr.changes === undefined,\n\t\t\t\t\t\t\t0x80f /* Unexpected node changes */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdetachInverseCurr.changes = attachInverse.changes;\n\t\t\t\t\t}\n\t\t\t\t\tinverses.push(detachInverseCurr);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tassert(isDetach(attachInverse), 0x810 /* Inverse of an attach should be a detach */);\n\t\t\t\tassert(detachInverseCurr.cellId !== undefined, 0x9f6 /* Expected empty cell */);\n\t\t\t\tconst inverted = normalizeCellRename(\n\t\t\t\t\tdetachInverseCurr.cellId,\n\t\t\t\t\tattachInverse.count,\n\t\t\t\t\textractMarkEffect(detachInverseCurr),\n\t\t\t\t\textractMarkEffect(attachInverse),\n\t\t\t\t);\n\t\t\t\tif (detachInverse.changes !== undefined) {\n\t\t\t\t\tinverted.changes = detachInverse.changes;\n\t\t\t\t}\n\n\t\t\t\tif (attachInverse.changes !== undefined) {\n\t\t\t\t\tassert(inverted.changes === undefined, 0x811 /* Unexpected node changes */);\n\t\t\t\t\tinverted.changes = attachInverse.changes;\n\t\t\t\t}\n\t\t\t\tinverses.push(inverted);\n\t\t\t}\n\n\t\t\treturn inverses;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(type);\n\t}\n}\n\nfunction applyMovedChanges(\n\tmark: CellMark<MoveOut>,\n\trevision: RevisionTag | undefined,\n\tmanager: CrossFieldManager<NodeId>,\n): Mark[] {\n\t// Although this is a source mark, we query the destination because this was a destination mark during the original invert pass.\n\tconst entry = manager.get(CrossFieldTarget.Destination, revision, mark.id, mark.count, true);\n\n\tif (entry.length < mark.count) {\n\t\tconst [mark1, mark2] = splitMark(mark, entry.length);\n\t\tconst mark1WithChanges =\n\t\t\tentry.value !== undefined\n\t\t\t\t? withNodeChange<CellMark<MoveOut>, MoveOut>(mark1, entry.value)\n\t\t\t\t: mark1;\n\n\t\treturn [mark1WithChanges, ...applyMovedChanges(mark2, revision, manager)];\n\t}\n\n\tif (entry.value !== undefined) {\n\t\tmanager.onMoveIn(entry.value);\n\t\treturn [withNodeChange<CellMark<MoveOut>, MoveOut>(mark, entry.value)];\n\t}\n\n\treturn [mark];\n}\n\nfunction invertNodeChangeOrSkip(\n\tcount: number,\n\tchanges: NodeId | undefined,\n\tcellId?: CellId,\n): Mark {\n\tif (changes !== undefined) {\n\t\tassert(count === 1, 0x66c /* A modify mark must have length equal to one */);\n\t\tconst noop: CellMark<NoopMark> = {\n\t\t\tcount,\n\t\t\tchanges,\n\t\t};\n\t\tif (cellId !== undefined) {\n\t\t\tnoop.cellId = cellId;\n\t\t}\n\t\treturn noop;\n\t}\n\n\tif (cellId !== undefined) {\n\t\treturn { count, cellId };\n\t}\n\treturn { count };\n}\n"]}
1
+ {"version":3,"file":"invert.js","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EAAkC,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAEN,gBAAgB,GAEhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAWN,YAAY,GAGZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,cAAc,GACd,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CACrB,MAAiB,EACjB,UAAmB,EACnB,KAAkB,EAClB,QAAiC,EACjC,iBAAoC;IAEpC,OAAO,cAAc,CACpB,MAAM,EACN,UAAU,EACV,iBAA8C,EAC9C,QAAQ,CACR,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CACtB,QAAkB,EAClB,UAAmB,EACnB,iBAA4C,EAC5C,QAAiC;IAEjC,MAAM,eAAe,GAAG,IAAI,e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AC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport type { RevisionTag } from \"../../core/index.js\";\nimport { type IdAllocator, type Mutable, fail, hasSingle } from \"../../util/index.js\";\nimport {\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\ttype NodeId,\n} from \"../modular-schema/index.js\";\n\nimport { MarkListFactory } from \"./markListFactory.js\";\nimport {\n\ttype CellId,\n\ttype CellMark,\n\ttype Changeset,\n\ttype Detach,\n\ttype Mark,\n\ttype MarkEffect,\n\ttype MarkList,\n\ttype MoveIn,\n\ttype MoveOut,\n\ttype NoopMark,\n\tNoopMarkType,\n\ttype Remove,\n\ttype Rename,\n} from \"./types.js\";\nimport {\n\textractMarkEffect,\n\tgetDetachOutputCellId,\n\tgetEndpoint,\n\tgetInputCellId,\n\tgetOutputCellId,\n\tisAttach,\n\tisDetach,\n\tisImpactful,\n\tnormalizeCellRename,\n\tsplitMark,\n\twithNodeChange,\n} from \"./utils.js\";\n\n/**\n * Inverts a given changeset.\n * @param change - The changeset to produce the inverse of.\n * @param isRollback - Whether the inverse is being produced for a rollback.\n * @param genId - The ID allocator to use for generating new IDs.\n * @param revision - The revision to use for the inverse changeset.\n * @param crossFieldManager - The cross-field manager to use for tracking cross-field changes.\n * @returns The inverse of the given `change` such that the inverse can be applied after `change`.\n *\n * WARNING! This implementation is incomplete:\n * - Support for slices is not implemented.\n */\nexport function invert(\n\tchange: Changeset,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\trevision: RevisionTag | undefined,\n\tcrossFieldManager: CrossFieldManager,\n): Changeset {\n\treturn invertMarkList(\n\t\tchange,\n\t\tisRollback,\n\t\tcrossFieldManager as CrossFieldManager<NodeId>,\n\t\trevision,\n\t);\n}\n\nfunction invertMarkList(\n\tmarkList: MarkList,\n\tisRollback: boolean,\n\tcrossFieldManager: CrossFieldManager<NodeId>,\n\trevision: RevisionTag | undefined,\n): MarkList {\n\tconst inverseMarkList = new MarkListFactory();\n\n\tfor (const mark of markList) {\n\t\tconst inverseMarks = invertMark(mark, isRollback, crossFieldManager, revision);\n\t\tinverseMarkList.push(...inverseMarks);\n\t}\n\n\treturn inverseMarkList.list;\n}\n\nfunction invertMark(\n\tmark: Mark,\n\tisRollback: boolean,\n\tcrossFieldManager: CrossFieldManager<NodeId>,\n\trevision: RevisionTag | undefined,\n): Mark[] {\n\tif (!isImpactful(mark)) {\n\t\tconst inputId = getInputCellId(mark);\n\t\treturn [invertNodeChangeOrSkip(mark.count, mark.changes, inputId)];\n\t}\n\tconst type = mark.type;\n\tswitch (type) {\n\t\tcase NoopMarkType: {\n\t\t\treturn [mark];\n\t\t}\n\t\tcase \"Rename\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x9f5 /* Rename mark must have cell ID */);\n\t\t\tconst inverse: Mutable<CellMark<Rename>> = {\n\t\t\t\ttype: \"Rename\",\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: mark.idOverride,\n\t\t\t\t// Unlike a remove or move-out, which follow a node, there is no way for this mark to assign the original input cell ID to another cell.\n\t\t\t\t// This means it should be safe to always restore the input cell ID (as opposed to only doing it on rollbacks).\n\t\t\t\t// Despite that, we still only do it on rollback for the sake of consistency: once a cell has been assigned an ID,\n\t\t\t\t// the only way for that cell to be assigned that ID again is if it is rolled back to that state.\n\t\t\t\tidOverride: isRollback ? inputId : { localId: inputId.localId },\n\t\t\t};\n\t\t\treturn [withNodeChange(inverse, mark.changes)];\n\t\t}\n\t\tcase \"Remove\": {\n\t\t\tassert(mark.revision !== undefined, 0x5a1 /* Unable to revert to undefined revision */);\n\t\t\tconst outputId = getOutputCellId(mark);\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tlet inverse: Mutable<Mark>;\n\t\t\tif (inputId === undefined) {\n\t\t\t\tinverse = {\n\t\t\t\t\ttype: \"Insert\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\tcellId: outputId,\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tinverse = {\n\t\t\t\t\ttype: \"Remove\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\tcellId: outputId,\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tif (isRollback) {\n\t\t\t\t\tinverse.idOverride = inputId;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn [withNodeChange(inverse, mark.changes)];\n\t\t}\n\t\tcase \"Insert\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x80c /* Active inserts should target empty cells */);\n\t\t\tconst removeMark: Mutable<CellMark<Remove>> = {\n\t\t\t\ttype: \"Remove\",\n\t\t\t\tcount: mark.count,\n\t\t\t\tid: inputId.localId,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (isRollback) {\n\t\t\t\tremoveMark.idOverride = inputId;\n\t\t\t}\n\n\t\t\tconst inverse = withNodeChange(removeMark, mark.changes);\n\t\t\treturn [inverse];\n\t\t}\n\t\tcase \"MoveOut\": {\n\t\t\tif (mark.changes !== undefined) {\n\t\t\t\tassert(mark.count === 1, 0x6ed /* Mark with changes can only target a single cell */);\n\n\t\t\t\tconst endpoint = getEndpoint(mark);\n\t\t\t\tcrossFieldManager.set(\n\t\t\t\t\tCrossFieldTarget.Destination,\n\t\t\t\t\tendpoint.revision,\n\t\t\t\t\tendpoint.localId,\n\t\t\t\t\tmark.count,\n\t\t\t\t\tmark.changes,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cellId = getDetachOutputCellId(mark) ?? {\n\t\t\t\trevision: mark.revision ?? fail(\"Revision must be defined\"),\n\t\t\t\tlocalId: mark.id,\n\t\t\t};\n\n\t\t\tconst moveIn: MoveIn = {\n\t\t\t\ttype: \"MoveIn\",\n\t\t\t\tid: mark.id,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (mark.finalEndpoint !== undefined) {\n\t\t\t\tmoveIn.finalEndpoint = {\n\t\t\t\t\tlocalId: mark.finalEndpoint.localId,\n\t\t\t\t\trevision: mark.revision,\n\t\t\t\t};\n\t\t\t}\n\t\t\tlet effect: MarkEffect = moveIn;\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tif (inputId !== undefined) {\n\t\t\t\tconst detach: Mutable<Detach> = {\n\t\t\t\t\ttype: \"Remove\",\n\t\t\t\t\tid: mark.id,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tif (isRollback) {\n\t\t\t\t\tdetach.idOverride = inputId;\n\t\t\t\t}\n\t\t\t\teffect = {\n\t\t\t\t\ttype: \"AttachAndDetach\",\n\t\t\t\t\tattach: moveIn,\n\t\t\t\t\tdetach,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn [{ ...effect, count: mark.count, cellId }];\n\t\t}\n\t\tcase \"MoveIn\": {\n\t\t\tconst inputId = getInputCellId(mark);\n\t\t\tassert(inputId !== undefined, 0x89e /* Active move-ins should target empty cells */);\n\t\t\tconst invertedMark: Mutable<CellMark<MoveOut>> = {\n\t\t\t\ttype: \"MoveOut\",\n\t\t\t\tid: mark.id,\n\t\t\t\tcount: mark.count,\n\t\t\t\trevision,\n\t\t\t};\n\n\t\t\tif (isRollback) {\n\t\t\t\tinvertedMark.idOverride = inputId;\n\t\t\t}\n\n\t\t\tif (mark.finalEndpoint) {\n\t\t\t\tinvertedMark.finalEndpoint = {\n\t\t\t\t\tlocalId: mark.finalEndpoint.localId,\n\t\t\t\t\trevision: mark.revision,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn applyMovedChanges(invertedMark, mark.revision, crossFieldManager);\n\t\t}\n\t\tcase \"AttachAndDetach\": {\n\t\t\tconst attach: Mark = {\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: mark.cellId,\n\t\t\t\t...mark.attach,\n\t\t\t};\n\t\t\tconst idAfterAttach = getOutputCellId(attach);\n\n\t\t\t// We put `mark.changes` on the detach so that if it is a move source\n\t\t\t// the changes can be sent to the endpoint.\n\t\t\tconst detach: Mark = {\n\t\t\t\tcount: mark.count,\n\t\t\t\tcellId: idAfterAttach,\n\t\t\t\tchanges: mark.changes,\n\t\t\t\t...mark.detach,\n\t\t\t};\n\t\t\tconst attachInverses = invertMark(attach, isRollback, crossFieldManager, revision);\n\t\t\tconst detachInverses = invertMark(detach, isRollback, crossFieldManager, revision);\n\n\t\t\tif (detachInverses.length === 0) {\n\t\t\t\treturn attachInverses;\n\t\t\t}\n\n\t\t\tassert(\n\t\t\t\thasSingle(detachInverses),\n\t\t\t\t0x80d /* Only expected MoveIn marks to be split when inverting */,\n\t\t\t);\n\n\t\t\tlet detachInverse = detachInverses[0];\n\t\t\tassert(isAttach(detachInverse), 0x80e /* Inverse of a detach should be an attach */);\n\n\t\t\tconst inverses: Mark[] = [];\n\t\t\tfor (const attachInverse of attachInverses) {\n\t\t\t\tlet detachInverseCurr: Mark = detachInverse;\n\t\t\t\tif (attachInverse.count !== detachInverse.count) {\n\t\t\t\t\t[detachInverseCurr, detachInverse] = splitMark(detachInverse, attachInverse.count);\n\t\t\t\t}\n\n\t\t\t\tif (attachInverse.type === NoopMarkType) {\n\t\t\t\t\tif (attachInverse.changes !== undefined) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdetachInverseCurr.changes === undefined,\n\t\t\t\t\t\t\t0x80f /* Unexpected node changes */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdetachInverseCurr.changes = attachInverse.changes;\n\t\t\t\t\t}\n\t\t\t\t\tinverses.push(detachInverseCurr);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tassert(isDetach(attachInverse), 0x810 /* Inverse of an attach should be a detach */);\n\t\t\t\tassert(detachInverseCurr.cellId !== undefined, 0x9f6 /* Expected empty cell */);\n\t\t\t\tconst inverted = normalizeCellRename(\n\t\t\t\t\tdetachInverseCurr.cellId,\n\t\t\t\t\tattachInverse.count,\n\t\t\t\t\textractMarkEffect(detachInverseCurr),\n\t\t\t\t\textractMarkEffect(attachInverse),\n\t\t\t\t);\n\t\t\t\tif (detachInverse.changes !== undefined) {\n\t\t\t\t\tinverted.changes = detachInverse.changes;\n\t\t\t\t}\n\n\t\t\t\tif (attachInverse.changes !== undefined) {\n\t\t\t\t\tassert(inverted.changes === undefined, 0x811 /* Unexpected node changes */);\n\t\t\t\t\tinverted.changes = attachInverse.changes;\n\t\t\t\t}\n\t\t\t\tinverses.push(inverted);\n\t\t\t}\n\n\t\t\treturn inverses;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(type);\n\t}\n}\n\nfunction applyMovedChanges(\n\tmark: CellMark<MoveOut>,\n\trevision: RevisionTag | undefined,\n\tmanager: CrossFieldManager<NodeId>,\n): Mark[] {\n\t// Although this is a source mark, we query the destination because this was a destination mark during the original invert pass.\n\tconst entry = manager.get(CrossFieldTarget.Destination, revision, mark.id, mark.count, true);\n\n\tif (entry.length < mark.count) {\n\t\tconst [mark1, mark2] = splitMark(mark, entry.length);\n\t\tconst mark1WithChanges =\n\t\t\tentry.value !== undefined\n\t\t\t\t? withNodeChange<CellMark<MoveOut>, MoveOut>(mark1, entry.value)\n\t\t\t\t: mark1;\n\n\t\treturn [mark1WithChanges, ...applyMovedChanges(mark2, revision, manager)];\n\t}\n\n\tif (entry.value !== undefined) {\n\t\tmanager.onMoveIn(entry.value);\n\t\treturn [withNodeChange<CellMark<MoveOut>, MoveOut>(mark, entry.value)];\n\t}\n\n\treturn [mark];\n}\n\nfunction invertNodeChangeOrSkip(\n\tcount: number,\n\tchanges: NodeId | undefined,\n\tcellId?: CellId,\n): Mark {\n\tif (changes !== undefined) {\n\t\tassert(count === 1, 0x66c /* A modify mark must have length equal to one */);\n\t\tconst noop: CellMark<NoopMark> = {\n\t\t\tcount,\n\t\t\tchanges,\n\t\t};\n\t\tif (cellId !== undefined) {\n\t\t\tnoop.cellId = cellId;\n\t\t}\n\t\treturn noop;\n\t}\n\n\tif (cellId !== undefined) {\n\t\treturn { count, cellId };\n\t}\n\treturn { count };\n}\n"]}
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, unreachableCase, oob } from "@fluidframework/core-utils/internal";
5
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
6
6
  import { areEqualChangeAtomIds, } from "../../core/index.js";
7
+ import { getLast, hasSome } from "../../util/index.js";
7
8
  import { nodeIdFromChangeAtom } from "../deltaUtils.js";
8
9
  import { isMoveIn, isMoveOut } from "./moveEffectTable.js";
9
10
  import { NoopMarkType } from "./types.js";
@@ -140,8 +141,8 @@ export function sequenceFieldToDelta(change, deltaFromChild) {
140
141
  }
141
142
  }
142
143
  // Remove trailing no-op marks
143
- while (local.length > 0) {
144
- const lastMark = local[local.length - 1] ?? oob();
144
+ while (hasSome(local)) {
145
+ const lastMark = getLast(local);
145
146
  if (lastMark.attach !== undefined ||
146
147
  lastMark.detach !== undefined ||
147
148
  lastMark.fields !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceFieldToDelta.js","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/sequenceFieldToDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EAKN,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACN,kB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AAC;YACF,MAAM;QACP,CAAC;QACD,KAAK,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;IACD,MAAM,KAAK,GAA+B,EAAE,CAAC;IAC7C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype DeltaDetachedNodeChanges,\n\ttype DeltaDetachedNodeRename,\n\ttype DeltaFieldChanges,\n\ttype DeltaMark,\n\tareEqualChangeAtomIds,\n} from \"../../core/index.js\";\nimport type { Mutable } from \"../../util/index.js\";\nimport { nodeIdFromChangeAtom } from \"../deltaUtils.js\";\n\nimport { isMoveIn, isMoveOut } from \"./moveEffectTable.js\";\nimport { type MarkList, NoopMarkType } from \"./types.js\";\nimport {\n\tareInputCellsEmpty,\n\tareOutputCellsEmpty,\n\tgetDetachedNodeId,\n\tgetEndpoint,\n\tgetInputCellId,\n\tisAttachAndDetachEffect,\n} from \"./utils.js\";\nimport type { ToDelta } from \"../modular-schema/index.js\";\n\nexport function sequenceFieldToDelta(\n\tchange: MarkList,\n\tdeltaFromChild: ToDelta,\n): DeltaFieldChanges {\n\tconst local: DeltaMark[] = [];\n\tconst global: DeltaDetachedNodeChanges[] = [];\n\tconst rename: DeltaDetachedNodeRename[] = [];\n\n\tfor (const mark of change) {\n\t\tconst deltaMark: Mutable<DeltaMark> = { count: mark.count };\n\t\tconst inputCellId = getInputCellId(mark);\n\t\tconst changes = mark.changes;\n\t\tif (changes !== undefined) {\n\t\t\tconst nestedDelta = deltaFromChild(changes);\n\t\t\tif (nestedDelta.size > 0) {\n\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\tdeltaMark.fields = nestedDelta;\n\t\t\t\t} else {\n\t\t\t\t\tglobal.push({\n\t\t\t\t\t\tid: nodeIdFromChangeAtom(inputCellId),\n\t\t\t\t\t\tfields: nestedDelta,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!areInputCellsEmpty(mark) && !areOutputCellsEmpty(mark)) {\n\t\t\t// Since each cell is associated with exactly one node,\n\t\t\t// the cell starting end ending populated means the cell content has not changed.\n\t\t\tlocal.push(deltaMark);\n\t\t} else if (isAttachAndDetachEffect(mark)) {\n\t\t\tassert(\n\t\t\t\tinputCellId !== undefined,\n\t\t\t\t0x81e /* AttachAndDetach mark should have defined input cell ID */,\n\t\t\t);\n\t\t\t// The cell starting and ending empty means the cell content has not changed,\n\t\t\t// unless transient content was inserted/attached.\n\t\t\tif (isMoveIn(mark.attach) && isMoveOut(mark.detach)) {\n\t\t\t\tassert(\n\t\t\t\t\tmark.changes === undefined,\n\t\t\t\t\t0x81f /* AttachAndDetach moves should not have changes */,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst outputId = getDetachedNodeId(mark.detach);\n\t\t\tassert(\n\t\t\t\toutputId !== undefined,\n\t\t\t\t0x820 /* AttachAndDetach mark should have defined output cell ID */,\n\t\t\t);\n\t\t\tconst oldId = nodeIdFromChangeAtom(\n\t\t\t\tisMoveIn(mark.attach) ? getEndpoint(mark.attach) : inputCellId,\n\t\t\t);\n\t\t\tif (!areEqualChangeAtomIds(inputCellId, outputId)) {\n\t\t\t\trename.push({\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\toldId,\n\t\t\t\t\tnewId: nodeIdFromChangeAtom(outputId),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (deltaMark.fields) {\n\t\t\t\tglobal.push({\n\t\t\t\t\tid: oldId,\n\t\t\t\t\tfields: deltaMark.fields,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst type = mark.type;\n\t\t\t// Inline into `switch(mark.type)` once we upgrade to TS 4.7\n\t\t\tswitch (type) {\n\t\t\t\tcase \"MoveIn\": {\n\t\t\t\t\tlocal.push({\n\t\t\t\t\t\tattach: nodeIdFromChangeAtom(getEndpoint(mark)),\n\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Remove\": {\n\t\t\t\t\tconst newDetachId = getDetachedNodeId(mark);\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tdeltaMark.detach = nodeIdFromChangeAtom(newDetachId);\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst oldId = nodeIdFromChangeAtom(inputCellId);\n\t\t\t\t\t\t// Removal of already removed content is only a no-op if the detach IDs are different.\n\t\t\t\t\t\tif (!areEqualChangeAtomIds(inputCellId, newDetachId)) {\n\t\t\t\t\t\t\trename.push({\n\t\t\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t\t\t\toldId,\n\t\t\t\t\t\t\t\tnewId: nodeIdFromChangeAtom(newDetachId),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// In all cases, the nested changes apply\n\t\t\t\t\t\tif (deltaMark.fields) {\n\t\t\t\t\t\t\tglobal.push({\n\t\t\t\t\t\t\t\tid: oldId,\n\t\t\t\t\t\t\t\tfields: deltaMark.fields,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"MoveOut\": {\n\t\t\t\t\t// The move destination will look for the detach ID of the source, so we can ignore `finalEndpoint`.\n\t\t\t\t\tconst detachId = nodeIdFromChangeAtom(getDetachedNodeId(mark));\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tdeltaMark.detach = detachId;\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move sources implicitly restore their content\n\t\t\t\t\t\trename.push({\n\t\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t\t\toldId: nodeIdFromChangeAtom(inputCellId),\n\t\t\t\t\t\t\tnewId: detachId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Insert\": {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tinputCellId !== undefined,\n\t\t\t\t\t\t0x821 /* Active Insert marks must have a CellId */,\n\t\t\t\t\t);\n\t\t\t\t\tconst buildId = nodeIdFromChangeAtom(inputCellId);\n\t\t\t\t\tdeltaMark.attach = buildId;\n\t\t\t\t\tif (deltaMark.fields) {\n\t\t\t\t\t\t// Nested changes are represented on the node in its starting location\n\t\t\t\t\t\tglobal.push({ id: buildId, fields: deltaMark.fields });\n\t\t\t\t\t\tdelete deltaMark.fields;\n\t\t\t\t\t}\n\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase NoopMarkType:\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Rename\":\n\t\t\t\t\tassert(\n\t\t\t\t\t\tmark.cellId !== undefined,\n\t\t\t\t\t\t0x9f9 /* Renames should only target empty cells */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(type);\n\t\t\t}\n\t\t}\n\t}\n\t// Remove trailing no-op marks\n\twhile (local.length > 0) {\n\t\tconst lastMark = local[local.length - 1] ?? oob();\n\t\tif (\n\t\t\tlastMark.attach !== undefined ||\n\t\t\tlastMark.detach !== undefined ||\n\t\t\tlastMark.fields !== undefined\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tlocal.pop();\n\t}\n\tconst delta: Mutable<DeltaFieldChanges> = {};\n\tif (local.length > 0) {\n\t\tdelta.local = local;\n\t}\n\tif (global.length > 0) {\n\t\tdelta.global = global;\n\t}\n\tif (rename.length > 0) {\n\t\tdelta.rename = rename;\n\t}\n\treturn delta;\n}\n"]}
1
+ {"version":3,"file":"sequenceFieldToDelta.js","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/sequenceFieldToDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAKN,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,uBAAuB,GACvB,MAAM,YAAY,CAAC;AAGpB,MAAM,UAAU,oBAAoB,CACnC,MAAgB,EAChB,cAAuB;IAEvB,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,MAAM,MAAM,GAA8B,EAAE,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5D,MAAM,WAAW,GAAG,c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C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype DeltaDetachedNodeChanges,\n\ttype DeltaDetachedNodeRename,\n\ttype DeltaFieldChanges,\n\ttype DeltaMark,\n\tareEqualChangeAtomIds,\n} from \"../../core/index.js\";\nimport { getLast, hasSome, type Mutable } from \"../../util/index.js\";\nimport { nodeIdFromChangeAtom } from \"../deltaUtils.js\";\n\nimport { isMoveIn, isMoveOut } from \"./moveEffectTable.js\";\nimport { type MarkList, NoopMarkType } from \"./types.js\";\nimport {\n\tareInputCellsEmpty,\n\tareOutputCellsEmpty,\n\tgetDetachedNodeId,\n\tgetEndpoint,\n\tgetInputCellId,\n\tisAttachAndDetachEffect,\n} from \"./utils.js\";\nimport type { ToDelta } from \"../modular-schema/index.js\";\n\nexport function sequenceFieldToDelta(\n\tchange: MarkList,\n\tdeltaFromChild: ToDelta,\n): DeltaFieldChanges {\n\tconst local: DeltaMark[] = [];\n\tconst global: DeltaDetachedNodeChanges[] = [];\n\tconst rename: DeltaDetachedNodeRename[] = [];\n\n\tfor (const mark of change) {\n\t\tconst deltaMark: Mutable<DeltaMark> = { count: mark.count };\n\t\tconst inputCellId = getInputCellId(mark);\n\t\tconst changes = mark.changes;\n\t\tif (changes !== undefined) {\n\t\t\tconst nestedDelta = deltaFromChild(changes);\n\t\t\tif (nestedDelta.size > 0) {\n\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\tdeltaMark.fields = nestedDelta;\n\t\t\t\t} else {\n\t\t\t\t\tglobal.push({\n\t\t\t\t\t\tid: nodeIdFromChangeAtom(inputCellId),\n\t\t\t\t\t\tfields: nestedDelta,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!areInputCellsEmpty(mark) && !areOutputCellsEmpty(mark)) {\n\t\t\t// Since each cell is associated with exactly one node,\n\t\t\t// the cell starting end ending populated means the cell content has not changed.\n\t\t\tlocal.push(deltaMark);\n\t\t} else if (isAttachAndDetachEffect(mark)) {\n\t\t\tassert(\n\t\t\t\tinputCellId !== undefined,\n\t\t\t\t0x81e /* AttachAndDetach mark should have defined input cell ID */,\n\t\t\t);\n\t\t\t// The cell starting and ending empty means the cell content has not changed,\n\t\t\t// unless transient content was inserted/attached.\n\t\t\tif (isMoveIn(mark.attach) && isMoveOut(mark.detach)) {\n\t\t\t\tassert(\n\t\t\t\t\tmark.changes === undefined,\n\t\t\t\t\t0x81f /* AttachAndDetach moves should not have changes */,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst outputId = getDetachedNodeId(mark.detach);\n\t\t\tassert(\n\t\t\t\toutputId !== undefined,\n\t\t\t\t0x820 /* AttachAndDetach mark should have defined output cell ID */,\n\t\t\t);\n\t\t\tconst oldId = nodeIdFromChangeAtom(\n\t\t\t\tisMoveIn(mark.attach) ? getEndpoint(mark.attach) : inputCellId,\n\t\t\t);\n\t\t\tif (!areEqualChangeAtomIds(inputCellId, outputId)) {\n\t\t\t\trename.push({\n\t\t\t\t\tcount: mark.count,\n\t\t\t\t\toldId,\n\t\t\t\t\tnewId: nodeIdFromChangeAtom(outputId),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (deltaMark.fields) {\n\t\t\t\tglobal.push({\n\t\t\t\t\tid: oldId,\n\t\t\t\t\tfields: deltaMark.fields,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst type = mark.type;\n\t\t\t// Inline into `switch(mark.type)` once we upgrade to TS 4.7\n\t\t\tswitch (type) {\n\t\t\t\tcase \"MoveIn\": {\n\t\t\t\t\tlocal.push({\n\t\t\t\t\t\tattach: nodeIdFromChangeAtom(getEndpoint(mark)),\n\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Remove\": {\n\t\t\t\t\tconst newDetachId = getDetachedNodeId(mark);\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tdeltaMark.detach = nodeIdFromChangeAtom(newDetachId);\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst oldId = nodeIdFromChangeAtom(inputCellId);\n\t\t\t\t\t\t// Removal of already removed content is only a no-op if the detach IDs are different.\n\t\t\t\t\t\tif (!areEqualChangeAtomIds(inputCellId, newDetachId)) {\n\t\t\t\t\t\t\trename.push({\n\t\t\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t\t\t\toldId,\n\t\t\t\t\t\t\t\tnewId: nodeIdFromChangeAtom(newDetachId),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// In all cases, the nested changes apply\n\t\t\t\t\t\tif (deltaMark.fields) {\n\t\t\t\t\t\t\tglobal.push({\n\t\t\t\t\t\t\t\tid: oldId,\n\t\t\t\t\t\t\t\tfields: deltaMark.fields,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"MoveOut\": {\n\t\t\t\t\t// The move destination will look for the detach ID of the source, so we can ignore `finalEndpoint`.\n\t\t\t\t\tconst detachId = nodeIdFromChangeAtom(getDetachedNodeId(mark));\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tdeltaMark.detach = detachId;\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move sources implicitly restore their content\n\t\t\t\t\t\trename.push({\n\t\t\t\t\t\t\tcount: mark.count,\n\t\t\t\t\t\t\toldId: nodeIdFromChangeAtom(inputCellId),\n\t\t\t\t\t\t\tnewId: detachId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Insert\": {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tinputCellId !== undefined,\n\t\t\t\t\t\t0x821 /* Active Insert marks must have a CellId */,\n\t\t\t\t\t);\n\t\t\t\t\tconst buildId = nodeIdFromChangeAtom(inputCellId);\n\t\t\t\t\tdeltaMark.attach = buildId;\n\t\t\t\t\tif (deltaMark.fields) {\n\t\t\t\t\t\t// Nested changes are represented on the node in its starting location\n\t\t\t\t\t\tglobal.push({ id: buildId, fields: deltaMark.fields });\n\t\t\t\t\t\tdelete deltaMark.fields;\n\t\t\t\t\t}\n\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase NoopMarkType:\n\t\t\t\t\tif (inputCellId === undefined) {\n\t\t\t\t\t\tlocal.push(deltaMark);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Rename\":\n\t\t\t\t\tassert(\n\t\t\t\t\t\tmark.cellId !== undefined,\n\t\t\t\t\t\t0x9f9 /* Renames should only target empty cells */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(type);\n\t\t\t}\n\t\t}\n\t}\n\t// Remove trailing no-op marks\n\twhile (hasSome(local)) {\n\t\tconst lastMark = getLast(local);\n\t\tif (\n\t\t\tlastMark.attach !== undefined ||\n\t\t\tlastMark.detach !== undefined ||\n\t\t\tlastMark.fields !== undefined\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tlocal.pop();\n\t}\n\tconst delta: Mutable<DeltaFieldChanges> = {};\n\tif (local.length > 0) {\n\t\tdelta.local = local;\n\t}\n\tif (global.length > 0) {\n\t\tdelta.global = global;\n\t}\n\tif (rename.length > 0) {\n\t\tdelta.rename = rename;\n\t}\n\treturn delta;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -2,12 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { EmptyKey, type FieldKey, type TreeValue, type FieldMapObject, type NodeData, type GenericTreeNode, type JsonableTree, type GenericFieldsNode, type TreeNodeSchemaIdentifier, type TreeFieldStoredSchema, ValueSchema, TreeNodeStoredSchema, type FieldKindIdentifier, type TreeTypeSet, type TreeStoredSchema, type Revertible, CommitKind, RevertibleStatus, type CommitMetadata, type StoredSchemaCollection, type ErasedTreeNodeSchemaDataFormat, ObjectNodeStoredSchema, MapNodeStoredSchema, LeafNodeStoredSchema, type RevertibleFactory, } from "./core/index.js";
5
+ export { EmptyKey, type FieldKey, type TreeValue, type FieldMapObject, type NodeData, type GenericTreeNode, type JsonableTree, type GenericFieldsNode, type TreeNodeSchemaIdentifier, type TreeFieldStoredSchema, ValueSchema, TreeNodeStoredSchema, type FieldKindIdentifier, type TreeTypeSet, type TreeStoredSchema, type Revertible, CommitKind, RevertibleStatus, type CommitMetadata, type StoredSchemaCollection, type ErasedTreeNodeSchemaDataFormat, ObjectNodeStoredSchema, MapNodeStoredSchema, LeafNodeStoredSchema, type RevertibleFactory, type RevertibleAlphaFactory, type RevertibleAlpha, } from "./core/index.js";
6
6
  export { type Brand } from "./util/index.js";
7
- export { type Listeners, type IsListener, type Listenable, type Off, } from "./events/index.js";
8
- export { TreeStatus, TreeCompressionStrategy, } from "./feature-libraries/index.js";
7
+ export type { Listeners, IsListener, Listenable, Off, } from "@fluidframework/core-interfaces";
8
+ export { TreeStatus, TreeCompressionStrategy, type TreeIndex, type TreeIndexKey, type TreeIndexNodes, } from "./feature-libraries/index.js";
9
9
  export { type ISharedTree, type SharedTreeOptions, ForestType, type SharedTreeContentSnapshot, type SharedTreeFormatOptions, SharedTreeFormatVersion, Tree, type TransactionConstraint, type NodeInDocumentConstraint, type RunTransaction, rollback, type ForestOptions, getBranch, type BranchableTree, type TreeBranchFork, independentInitializedView, type ViewContent, TreeAlpha, independentView, } from "./shared-tree/index.js";
10
- export { TreeArrayNode, type Unhydrated, IterableTreeArrayContent, TreeNode, type ViewableTree, type ITree, type TreeNodeSchema, TreeViewConfiguration, type ITreeViewConfiguration, type ITreeConfigurationOptions, type TreeView, type TreeViewEvents, SchemaFactory, type ImplicitFieldSchema, type TreeFieldFromImplicitField, type TreeChangeEvents, type NodeFromSchema, type TreeMapNode, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeLeafValue, FieldKind, FieldSchema, type FieldSchemaMetadata, type ImplicitAllowedTypes, type InsertableTreeFieldFromImplicitField, type InsertableTypedNode, NodeKind, type TreeObjectNode, type TreeNodeFromImplicitAllowedTypes, type TreeNodeSchemaClass, type SchemaCompatibilityStatus, type FieldProps, type InternalTreeNode, type WithType, type NodeChangedData, type TreeNodeApi, type TreeNodeSchemaCore, type AllowedTypes, type TreeObjectNodeUnsafe, type InsertableTreeNodeFromImplicitAllowedTypesUnsafe, type TreeArrayNodeUnsafe, type TreeMapNodeUnsafe, type InsertableObjectFromSchemaRecordUnsafe, type InsertableTreeFieldFromImplicitFieldUnsafe, type FieldSchemaUnsafe, type TreeNodeSchemaClassUnsafe, type InsertableTreeNodeFromAllowedTypesUnsafe, type typeSchemaSymbol, type TreeNodeSchemaNonClass, type ValidateRecursiveSchema, type FixRecursiveArraySchema, adaptEnum, enumFromStrings, singletonSchema, type UnsafeUnknownSchema, type TreeViewAlpha, type InsertableField, type Insertable, type InsertableContent, type FactoryContent, type FactoryContentObject, type ReadableField, type ReadSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, TreeBeta, type TreeChangeEventsBeta, type VerboseTreeNode, type EncodeOptions, type ParseOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, type JsonTreeSchema, type JsonSchemaId, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonLeafNodeSchema, type JsonMapNodeSchema, type JsonArrayNodeSchema, type JsonObjectNodeSchema, type JsonFieldSchema, type JsonSchemaRef, type JsonRefPath, type JsonSchemaType, type JsonLeafSchemaType, getJsonSchema, type LazyItem, type Unenforced, type SimpleNodeSchemaBase, type SimpleTreeSchema, type SimpleNodeSchema, type SimpleFieldSchema, type SimpleLeafNodeSchema, type SimpleMapNodeSchema, type SimpleArrayNodeSchema, type SimpleObjectNodeSchema, normalizeAllowedTypes, getSimpleSchema, numberSchema, stringSchema, booleanSchema, handleSchema, nullSchema, type ReadonlyArrayNode, type InsertableTreeNodeFromAllowedTypes, type Input, type TreeBranch, type TreeBranchEvents, asTreeViewAlpha, } from "./simple-tree/index.js";
10
+ export { TreeArrayNode, type Unhydrated, IterableTreeArrayContent, TreeNode, type ViewableTree, type ITree, type TreeNodeSchema, TreeViewConfiguration, type ITreeViewConfiguration, type ITreeConfigurationOptions, type TreeView, type TreeViewEvents, SchemaFactory, type ImplicitFieldSchema, type TreeFieldFromImplicitField, type TreeChangeEvents, type NodeFromSchema, type TreeMapNode, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeLeafValue, FieldKind, FieldSchema, type FieldSchemaMetadata, type ImplicitAllowedTypes, type InsertableTreeFieldFromImplicitField, type InsertableTypedNode, NodeKind, type TreeObjectNode, type TreeNodeFromImplicitAllowedTypes, type TreeNodeSchemaClass, type SchemaCompatibilityStatus, type FieldProps, type InternalTreeNode, type WithType, type NodeChangedData, type TreeNodeApi, type TreeNodeSchemaCore, type AllowedTypes, type TreeObjectNodeUnsafe, type InsertableTreeNodeFromImplicitAllowedTypesUnsafe, type TreeArrayNodeUnsafe, type TreeMapNodeUnsafe, type InsertableObjectFromSchemaRecordUnsafe, type InsertableTreeFieldFromImplicitFieldUnsafe, type FieldSchemaUnsafe, type TreeNodeSchemaClassUnsafe, type InsertableTreeNodeFromAllowedTypesUnsafe, type typeSchemaSymbol, type TreeNodeSchemaNonClass, type ValidateRecursiveSchema, type FixRecursiveArraySchema, type SimpleTreeIndex, type IdentifierIndex, createSimpleTreeIndex, createIdentifierIndex, adaptEnum, enumFromStrings, singletonSchema, type UnsafeUnknownSchema, type TreeViewAlpha, type InsertableField, type Insertable, type InsertableContent, type FactoryContent, type FactoryContentObject, type ReadableField, type ReadSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, TreeBeta, type TreeChangeEventsBeta, type VerboseTreeNode, type EncodeOptions, type ParseOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, type JsonTreeSchema, type JsonSchemaId, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonLeafNodeSchema, type JsonMapNodeSchema, type JsonArrayNodeSchema, type JsonObjectNodeSchema, type JsonFieldSchema, type JsonSchemaRef, type JsonRefPath, type JsonSchemaType, type JsonLeafSchemaType, getJsonSchema, type LazyItem, type Unenforced, type SimpleNodeSchemaBase, type SimpleTreeSchema, type SimpleNodeSchema, type SimpleFieldSchema, type SimpleLeafNodeSchema, type SimpleMapNodeSchema, type SimpleArrayNodeSchema, type SimpleObjectNodeSchema, normalizeAllowedTypes, getSimpleSchema, numberSchema, stringSchema, booleanSchema, handleSchema, nullSchema, type ReadonlyArrayNode, type InsertableTreeNodeFromAllowedTypes, type Input, type TreeBranch, type TreeBranchEvents, asTreeViewAlpha, } from "./simple-tree/index.js";
11
11
  export { SharedTree, configuredSharedTree, } from "./treeFactory.js";
12
12
  export { type ICodecOptions, type JsonValidator, type SchemaValidationFunction, FluidClientVersion, } from "./codec/index.js";
13
13
  export { noopValidator } from "./codec/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,WAAW,EACX,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EACnB,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E,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  export { EmptyKey, ValueSchema, TreeNodeStoredSchema, CommitKind, RevertibleStatus, ObjectNodeStoredSchema, MapNodeStoredSchema, LeafNodeStoredSchema, } from "./core/index.js";
6
6
  export { TreeStatus, TreeCompressionStrategy, } from "./feature-libraries/index.js";
7
7
  export { ForestType, SharedTreeFormatVersion, Tree, rollback, getBranch, independentInitializedView, TreeAlpha, independentView, } from "./shared-tree/index.js";
8
- export { TreeArrayNode, IterableTreeArrayContent, TreeViewConfiguration, SchemaFactory, FieldKind, FieldSchema, NodeKind,
8
+ export { TreeArrayNode, IterableTreeArrayContent, TreeViewConfiguration, SchemaFactory, FieldKind, FieldSchema, NodeKind, createSimpleTreeIndex, createIdentifierIndex,
9
9
  // experimental @alpha APIs:
10
10
  adaptEnum, enumFromStrings, singletonSchema,
11
11
  // test recursive schema for checking that d.ts files handles schema correctly