@fluidframework/tree 2.116.0-416006 → 2.116.1

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 (327) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +5 -3
  3. package/api-report/tree.alpha.api.md +4 -2
  4. package/api-report/tree.beta.api.md +1 -1
  5. package/api-report/tree.legacy.beta.api.md +1 -1
  6. package/dist/codec/codec.d.ts +6 -6
  7. package/dist/codec/codec.d.ts.map +1 -1
  8. package/dist/codec/codec.js +3 -3
  9. package/dist/codec/codec.js.map +1 -1
  10. package/dist/codec/versioned/codec.d.ts +3 -3
  11. package/dist/codec/versioned/codec.d.ts.map +1 -1
  12. package/dist/codec/versioned/codec.js.map +1 -1
  13. package/dist/core/forest/editableForest.d.ts +2 -0
  14. package/dist/core/forest/editableForest.d.ts.map +1 -1
  15. package/dist/core/forest/editableForest.js.map +1 -1
  16. package/dist/core/index.d.ts +1 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +2 -2
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/tree/index.d.ts +1 -1
  21. package/dist/core/tree/index.d.ts.map +1 -1
  22. package/dist/core/tree/index.js +2 -2
  23. package/dist/core/tree/index.js.map +1 -1
  24. package/dist/core/tree/visitorUtils.d.ts +24 -3
  25. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  26. package/dist/core/tree/visitorUtils.js +24 -6
  27. package/dist/core/tree/visitorUtils.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +30 -6
  29. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/chunkedForest.js +146 -54
  31. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  32. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts +2 -1
  33. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -1
  34. package/dist/feature-libraries/comparison-forest/comparisonForest.js +87 -70
  35. package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  36. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  37. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +5 -0
  38. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  39. package/dist/feature-libraries/forest-summary/forestSummarizer.js +127 -107
  40. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  41. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts +2 -2
  42. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
  43. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  44. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  45. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  46. package/dist/feature-libraries/modular-schema/invert.js +1 -1
  47. package/dist/feature-libraries/modular-schema/invert.js.map +1 -1
  48. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  49. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +2 -11
  50. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  51. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +11 -16
  52. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  53. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +10 -3
  54. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  55. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  56. package/dist/feature-libraries/object-forest/objectForest.js +34 -13
  57. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  58. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  59. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  60. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  61. package/dist/feature-libraries/sequence-field/rebase.js +1 -1
  62. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  64. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  65. package/dist/packageVersion.d.ts +1 -1
  66. package/dist/packageVersion.d.ts.map +1 -1
  67. package/dist/packageVersion.js +1 -1
  68. package/dist/packageVersion.js.map +1 -1
  69. package/dist/shared-tree/independentView.d.ts.map +1 -1
  70. package/dist/shared-tree/independentView.js +2 -4
  71. package/dist/shared-tree/independentView.js.map +1 -1
  72. package/dist/shared-tree/sharedTree.d.ts +30 -5
  73. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  74. package/dist/shared-tree/sharedTree.js +8 -8
  75. package/dist/shared-tree/sharedTree.js.map +1 -1
  76. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  77. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  78. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  79. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +25 -1
  80. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  81. package/dist/shared-tree/sharedTreeChangeEnricher.js +24 -0
  82. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  83. package/dist/shared-tree/treeCheckout.d.ts +21 -10
  84. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  85. package/dist/shared-tree/treeCheckout.js +56 -24
  86. package/dist/shared-tree/treeCheckout.js.map +1 -1
  87. package/dist/shared-tree-core/branchCommitEnricher.d.ts +2 -1
  88. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  89. package/dist/shared-tree-core/branchCommitEnricher.js +3 -2
  90. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  91. package/dist/shared-tree-core/changeEnricher.d.ts +3 -2
  92. package/dist/shared-tree-core/changeEnricher.d.ts.map +1 -1
  93. package/dist/shared-tree-core/changeEnricher.js.map +1 -1
  94. package/dist/shared-tree-core/defaultResubmitMachine.d.ts +9 -1
  95. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  96. package/dist/shared-tree-core/defaultResubmitMachine.js +7 -2
  97. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  98. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  99. package/dist/shared-tree-core/editManager.js +2 -2
  100. package/dist/shared-tree-core/editManager.js.map +1 -1
  101. package/dist/shared-tree-core/editManagerCodecs.d.ts +2 -2
  102. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  103. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  104. package/dist/shared-tree-core/editManagerSummarizer.d.ts +2 -2
  105. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  106. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  107. package/dist/shared-tree-core/messageCodecs.d.ts +2 -2
  108. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  109. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  110. package/dist/shared-tree-core/sharedTreeCore.d.ts +11 -2
  111. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  112. package/dist/shared-tree-core/sharedTreeCore.js +11 -8
  113. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  114. package/dist/shared-tree-core/summaryTypes.d.ts +2 -2
  115. package/dist/shared-tree-core/summaryTypes.d.ts.map +1 -1
  116. package/dist/shared-tree-core/summaryTypes.js.map +1 -1
  117. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +1 -1
  118. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  119. package/dist/simple-tree/api/storedSchema.d.ts +2 -2
  120. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  121. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  122. package/dist/simple-tree/api/treeChangeEvents.d.ts +5 -1
  123. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  124. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  125. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  126. package/dist/simple-tree/node-kinds/array/arrayNode.js +10 -0
  127. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  128. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  129. package/dist/simple-tree/node-kinds/map/mapNode.js +19 -2
  130. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  131. package/dist/tableSchema.d.ts +1 -1
  132. package/dist/tableSchema.js +1 -1
  133. package/dist/tableSchema.js.map +1 -1
  134. package/dist/treeFactory.d.ts.map +1 -1
  135. package/dist/treeFactory.js +1 -1
  136. package/dist/treeFactory.js.map +1 -1
  137. package/dist/util/breakable.d.ts +14 -2
  138. package/dist/util/breakable.d.ts.map +1 -1
  139. package/dist/util/breakable.js +9 -1
  140. package/dist/util/breakable.js.map +1 -1
  141. package/dist/util/compressedIds.d.ts +2 -2
  142. package/dist/util/compressedIds.d.ts.map +1 -1
  143. package/dist/util/compressedIds.js +1 -6
  144. package/dist/util/compressedIds.js.map +1 -1
  145. package/lib/codec/codec.d.ts +6 -6
  146. package/lib/codec/codec.d.ts.map +1 -1
  147. package/lib/codec/codec.js +3 -3
  148. package/lib/codec/codec.js.map +1 -1
  149. package/lib/codec/versioned/codec.d.ts +3 -3
  150. package/lib/codec/versioned/codec.d.ts.map +1 -1
  151. package/lib/codec/versioned/codec.js.map +1 -1
  152. package/lib/core/forest/editableForest.d.ts +2 -0
  153. package/lib/core/forest/editableForest.d.ts.map +1 -1
  154. package/lib/core/forest/editableForest.js.map +1 -1
  155. package/lib/core/index.d.ts +1 -1
  156. package/lib/core/index.d.ts.map +1 -1
  157. package/lib/core/index.js +1 -1
  158. package/lib/core/index.js.map +1 -1
  159. package/lib/core/tree/index.d.ts +1 -1
  160. package/lib/core/tree/index.d.ts.map +1 -1
  161. package/lib/core/tree/index.js +1 -1
  162. package/lib/core/tree/index.js.map +1 -1
  163. package/lib/core/tree/visitorUtils.d.ts +24 -3
  164. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  165. package/lib/core/tree/visitorUtils.js +22 -4
  166. package/lib/core/tree/visitorUtils.js.map +1 -1
  167. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +30 -6
  168. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  169. package/lib/feature-libraries/chunked-forest/chunkedForest.js +146 -56
  170. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  171. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts +2 -1
  172. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -1
  173. package/lib/feature-libraries/comparison-forest/comparisonForest.js +88 -70
  174. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  175. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  176. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +5 -0
  177. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  178. package/lib/feature-libraries/forest-summary/forestSummarizer.js +129 -108
  179. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  180. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts +2 -2
  181. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
  182. package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  183. package/lib/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  184. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  185. package/lib/feature-libraries/modular-schema/invert.js +2 -2
  186. package/lib/feature-libraries/modular-schema/invert.js.map +1 -1
  187. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  188. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +2 -11
  189. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  190. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +11 -16
  191. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  192. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +10 -3
  193. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  194. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  195. package/lib/feature-libraries/object-forest/objectForest.js +35 -14
  196. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  197. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  198. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  199. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  200. package/lib/feature-libraries/sequence-field/rebase.js +2 -2
  201. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  202. package/lib/feature-libraries/sequence-field/utils.js +1 -1
  203. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  204. package/lib/packageVersion.d.ts +1 -1
  205. package/lib/packageVersion.d.ts.map +1 -1
  206. package/lib/packageVersion.js +1 -1
  207. package/lib/packageVersion.js.map +1 -1
  208. package/lib/shared-tree/independentView.d.ts.map +1 -1
  209. package/lib/shared-tree/independentView.js +3 -5
  210. package/lib/shared-tree/independentView.js.map +1 -1
  211. package/lib/shared-tree/sharedTree.d.ts +30 -5
  212. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  213. package/lib/shared-tree/sharedTree.js +8 -8
  214. package/lib/shared-tree/sharedTree.js.map +1 -1
  215. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  216. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  217. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  218. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +25 -1
  219. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  220. package/lib/shared-tree/sharedTreeChangeEnricher.js +24 -0
  221. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  222. package/lib/shared-tree/treeCheckout.d.ts +21 -10
  223. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  224. package/lib/shared-tree/treeCheckout.js +56 -24
  225. package/lib/shared-tree/treeCheckout.js.map +1 -1
  226. package/lib/shared-tree-core/branchCommitEnricher.d.ts +2 -1
  227. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  228. package/lib/shared-tree-core/branchCommitEnricher.js +3 -2
  229. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  230. package/lib/shared-tree-core/changeEnricher.d.ts +3 -2
  231. package/lib/shared-tree-core/changeEnricher.d.ts.map +1 -1
  232. package/lib/shared-tree-core/changeEnricher.js.map +1 -1
  233. package/lib/shared-tree-core/defaultResubmitMachine.d.ts +9 -1
  234. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  235. package/lib/shared-tree-core/defaultResubmitMachine.js +7 -2
  236. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  237. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  238. package/lib/shared-tree-core/editManager.js +2 -2
  239. package/lib/shared-tree-core/editManager.js.map +1 -1
  240. package/lib/shared-tree-core/editManagerCodecs.d.ts +2 -2
  241. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  242. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  243. package/lib/shared-tree-core/editManagerSummarizer.d.ts +2 -2
  244. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  245. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  246. package/lib/shared-tree-core/messageCodecs.d.ts +2 -2
  247. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  248. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  249. package/lib/shared-tree-core/sharedTreeCore.d.ts +11 -2
  250. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  251. package/lib/shared-tree-core/sharedTreeCore.js +11 -8
  252. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  253. package/lib/shared-tree-core/summaryTypes.d.ts +2 -2
  254. package/lib/shared-tree-core/summaryTypes.d.ts.map +1 -1
  255. package/lib/shared-tree-core/summaryTypes.js.map +1 -1
  256. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +1 -1
  257. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  258. package/lib/simple-tree/api/storedSchema.d.ts +2 -2
  259. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  260. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  261. package/lib/simple-tree/api/treeChangeEvents.d.ts +5 -1
  262. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  263. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  264. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  265. package/lib/simple-tree/node-kinds/array/arrayNode.js +10 -0
  266. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  267. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  268. package/lib/simple-tree/node-kinds/map/mapNode.js +19 -2
  269. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  270. package/lib/tableSchema.d.ts +1 -1
  271. package/lib/tableSchema.js +1 -1
  272. package/lib/tableSchema.js.map +1 -1
  273. package/lib/treeFactory.d.ts.map +1 -1
  274. package/lib/treeFactory.js +1 -1
  275. package/lib/treeFactory.js.map +1 -1
  276. package/lib/util/breakable.d.ts +14 -2
  277. package/lib/util/breakable.d.ts.map +1 -1
  278. package/lib/util/breakable.js +9 -1
  279. package/lib/util/breakable.js.map +1 -1
  280. package/lib/util/compressedIds.d.ts +2 -2
  281. package/lib/util/compressedIds.d.ts.map +1 -1
  282. package/lib/util/compressedIds.js +1 -6
  283. package/lib/util/compressedIds.js.map +1 -1
  284. package/package.json +27 -27
  285. package/src/codec/codec.ts +7 -7
  286. package/src/codec/versioned/codec.ts +5 -5
  287. package/src/core/forest/editableForest.ts +2 -0
  288. package/src/core/index.ts +1 -1
  289. package/src/core/tree/index.ts +1 -1
  290. package/src/core/tree/visitorUtils.ts +37 -12
  291. package/src/feature-libraries/chunked-forest/chunkedForest.ts +214 -59
  292. package/src/feature-libraries/comparison-forest/comparisonForest.ts +6 -1
  293. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +2 -2
  294. package/src/feature-libraries/forest-summary/forestSummarizer.ts +10 -0
  295. package/src/feature-libraries/forest-summary/summaryTypes.ts +2 -2
  296. package/src/feature-libraries/indexing/anchorTreeIndex.ts +1 -1
  297. package/src/feature-libraries/modular-schema/invert.ts +2 -2
  298. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2 -23
  299. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +12 -21
  300. package/src/feature-libraries/object-forest/objectForest.ts +48 -14
  301. package/src/feature-libraries/schema-index/schemaSummarizer.ts +3 -3
  302. package/src/feature-libraries/sequence-field/rebase.ts +2 -2
  303. package/src/feature-libraries/sequence-field/utils.ts +1 -1
  304. package/src/packageVersion.ts +1 -1
  305. package/src/shared-tree/independentView.ts +5 -12
  306. package/src/shared-tree/sharedTree.ts +41 -10
  307. package/src/shared-tree/sharedTreeChangeCodecs.ts +2 -2
  308. package/src/shared-tree/sharedTreeChangeEnricher.ts +25 -1
  309. package/src/shared-tree/treeCheckout.ts +53 -24
  310. package/src/shared-tree-core/branchCommitEnricher.ts +6 -2
  311. package/src/shared-tree-core/changeEnricher.ts +7 -2
  312. package/src/shared-tree-core/defaultResubmitMachine.ts +5 -0
  313. package/src/shared-tree-core/editManager.ts +2 -4
  314. package/src/shared-tree-core/editManagerCodecs.ts +2 -2
  315. package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
  316. package/src/shared-tree-core/messageCodecs.ts +2 -2
  317. package/src/shared-tree-core/sharedTreeCore.ts +29 -11
  318. package/src/shared-tree-core/summaryTypes.ts +2 -2
  319. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +1 -1
  320. package/src/simple-tree/api/storedSchema.ts +2 -2
  321. package/src/simple-tree/api/treeChangeEvents.ts +5 -1
  322. package/src/simple-tree/node-kinds/array/arrayNode.ts +15 -0
  323. package/src/simple-tree/node-kinds/map/mapNode.ts +23 -2
  324. package/src/tableSchema.ts +1 -1
  325. package/src/treeFactory.ts +0 -1
  326. package/src/util/breakable.ts +9 -1
  327. package/src/util/compressedIds.ts +7 -13
@@ -2,29 +2,24 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type ChangesetLocalId, type FieldKindIdentifier, type RevisionInfo, type RevisionTag, type TaggedChange, type TreeChunk } from "../../core/index.js";
5
+ import { type ChangesetLocalId, type FieldKindIdentifier, type RevisionInfo, type RevisionTag, type TaggedChange } from "../../core/index.js";
6
6
  import { type RangeQueryResult } from "../../util/index.js";
7
7
  import { type ChangeAtomIdBTree } from "../changeAtomIdBTree.js";
8
8
  import { CrossFieldTarget, type CrossFieldManager, type CrossFieldMap } from "./crossFieldQueries.js";
9
9
  import type { FieldChangeHandler } from "./fieldChangeHandler.js";
10
10
  import { NodeAttachState } from "./fieldChangeHandler.js";
11
11
  import type { FlexFieldKind } from "./fieldKind.js";
12
- import { type CrossFieldKeyTable, type FieldChangeMap, type FieldId, type ModularChangeset, type NoChangeConstraint, type NodeChangeset, type NodeId } from "./modularChangeTypes.js";
12
+ import { type FieldChangeMap, type ModularChangeset, type NodeChangeset, type NodeId } from "./modularChangeTypes.js";
13
13
  export declare function hasConflicts(change: ModularChangeset): boolean;
14
- export declare function makeModularChangeset(props?: {
15
- fieldChanges?: FieldChangeMap;
16
- nodeChanges?: ChangeAtomIdBTree<NodeChangeset>;
17
- nodeToParent?: ChangeAtomIdBTree<FieldId>;
18
- nodeAliases?: ChangeAtomIdBTree<NodeId>;
19
- crossFieldKeys?: CrossFieldKeyTable;
20
- maxId: number;
21
- revisions?: readonly RevisionInfo[];
22
- constraintViolationCount?: number;
23
- noChangeConstraint?: NoChangeConstraint;
24
- noChangeConstraintOnRevert?: NoChangeConstraint;
25
- builds?: ChangeAtomIdBTree<TreeChunk>;
26
- destroys?: ChangeAtomIdBTree<number>;
27
- refreshers?: ChangeAtomIdBTree<TreeChunk>;
14
+ /**
15
+ * Creates a normalized changeset from the provided properties.
16
+ *
17
+ * Required changeset maps are initialized when omitted, and empty optional properties are not
18
+ * included in the returned changeset. `maxId` accepts an unbranded allocator ID; `undefined`
19
+ * indicates that the changeset contains no IDs.
20
+ */
21
+ export declare function makeModularChangeset(props?: Partial<Omit<ModularChangeset, "maxId">> & {
22
+ maxId?: number;
28
23
  }): ModularChangeset;
29
24
  export interface CrossFieldTable<TFieldData> {
30
25
  srcTable: CrossFieldMap<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"modularChangeUtils.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,KAAK,gBAAgB,EAErB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAGhB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAEN,KAAK,kBAAk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CAAC,mBAAmB,EAAE,aAAa,CAAC,EAC3D,IAAI,EAAE,mBAAmB,GACvB,kBAAkB,CAAC,OAAO,CAAC,CAE7B;AAcD,MAAM,WAAW,eAAe;IAC/B,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,eAAe,CAI1E;AAED,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,cAAc,EACtB,sBAAsB,EAAE,eAAe,EACvC,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,iBAAiB,CAAC,aAAa,CAAC,EACvC,UAAU,EAAE,WAAW,CAAC,mBAAmB,EAAE,aAAa,CAAC,GACzD,IAAI,CAaN;AAiCD,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,iBAAiB,CAAC,aAAa,CAAC,EACvC,EAAE,EAAE,MAAM,GACR,aAAa,CAIf"}
1
+ {"version":3,"file":"modularChangeUtils.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,KAAK,gBAAgB,EAErB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAGhB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,gBAAgB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
17
  return (change.constraintViolationCount ?? 0) > 0;
18
18
  }
19
19
  exports.hasConflicts = hasConflicts;
20
- function makeModularChangeset(props) {
21
- const p = props ?? { maxId: -1 };
20
+ /**
21
+ * Creates a normalized changeset from the provided properties.
22
+ *
23
+ * Required changeset maps are initialized when omitted, and empty optional properties are not
24
+ * included in the returned changeset. `maxId` accepts an unbranded allocator ID; `undefined`
25
+ * indicates that the changeset contains no IDs.
26
+ */
27
+ function makeModularChangeset(props = {}) {
28
+ const p = props;
22
29
  const changeset = {
23
30
  fieldChanges: p.fieldChanges ?? new Map(),
24
31
  nodeChanges: p.nodeChanges ?? (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
@@ -29,7 +36,7 @@ function makeModularChangeset(props) {
29
36
  if (p.revisions !== undefined && p.revisions.length > 0) {
30
37
  changeset.revisions = p.revisions;
31
38
  }
32
- if (p.maxId >= 0) {
39
+ if (p.maxId !== undefined && p.maxId >= 0) {
33
40
  changeset.maxId = (0, index_js_2.brand)(p.maxId);
34
41
  }
35
42
  if (p.constraintViolationCount !== undefined && p.constraintViolationCount > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"modularChangeUtils.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,kDAS6B;AAC7B,kDAAiF;AACjF,kEAIiC;AACjC,iEAMgC;AAEhC,mEAA0D;AAE1D,+DAAyD;AACzD,mEAUiC;AAEjC,SAAgB,YAAY,CAAC,MAAwB;IACpD,OAAO,CAAC,MAAM,CAAC,wBAAwB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AAFD,oCAEC;AAED,SAAgB,oBAAoB,CAAC,KAcpC;IACA,MAAM,CAAC,GAAG,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;IACjC,MAAM,SAAS,GAA8B;QAC5C,YAAY,EAAE,CAAC,CAAC,Y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Ae,CAAC,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACrC,0BAA0B,CACzB,IAAI,CAAC,YAAY,EACjB,gBAAgB,EAChB,eAAe,EACf,KAAK,EACL,UAAU,CACV,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAgB,gBAAgB,CAC/B,KAAuC,EACvC,EAAU;IAEV,MAAM,IAAI,GAAG,IAAA,6CAAsB,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,IAAA,iBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACb,CAAC;AAPD,4CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport {\n\tnewChangeAtomIdRangeMap,\n\ttype ChangesetLocalId,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype RevisionInfo,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\ttype TreeChunk,\n} from \"../../core/index.js\";\nimport { brand, type Mutable, type RangeQueryResult } from \"../../util/index.js\";\nimport {\n\tgetFromChangeAtomIdMap,\n\tnewChangeAtomIdBTree,\n\ttype ChangeAtomIdBTree,\n} from \"../changeAtomIdBTree.js\";\nimport {\n\tCrossFieldTarget,\n\tgetFirstFromCrossFieldMap,\n\tsetInCrossFieldMap,\n\ttype CrossFieldManager,\n\ttype CrossFieldMap,\n} from \"./crossFieldQueries.js\";\nimport type { FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport { NodeAttachState } from \"./fieldChangeHandler.js\";\nimport type { FlexFieldKind } from \"./fieldKind.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\tnewCrossFieldKeyTable,\n\ttype CrossFieldKeyTable,\n\ttype FieldChange,\n\ttype FieldChangeMap,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NoChangeConstraint,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\nexport function hasConflicts(change: ModularChangeset): boolean {\n\treturn (change.constraintViolationCount ?? 0) > 0;\n}\n\nexport function makeModularChangeset(props?: {\n\tfieldChanges?: FieldChangeMap;\n\tnodeChanges?: ChangeAtomIdBTree<NodeChangeset>;\n\tnodeToParent?: ChangeAtomIdBTree<FieldId>;\n\tnodeAliases?: ChangeAtomIdBTree<NodeId>;\n\tcrossFieldKeys?: CrossFieldKeyTable;\n\tmaxId: number;\n\trevisions?: readonly RevisionInfo[];\n\tconstraintViolationCount?: number;\n\tnoChangeConstraint?: NoChangeConstraint;\n\tnoChangeConstraintOnRevert?: NoChangeConstraint;\n\tbuilds?: ChangeAtomIdBTree<TreeChunk>;\n\tdestroys?: ChangeAtomIdBTree<number>;\n\trefreshers?: ChangeAtomIdBTree<TreeChunk>;\n}): ModularChangeset {\n\tconst p = props ?? { maxId: -1 };\n\tconst changeset: Mutable<ModularChangeset> = {\n\t\tfieldChanges: p.fieldChanges ?? new Map<FieldKey, FieldChange>(),\n\t\tnodeChanges: p.nodeChanges ?? newChangeAtomIdBTree(),\n\t\tnodeToParent: p.nodeToParent ?? newChangeAtomIdBTree(),\n\t\tnodeAliases: p.nodeAliases ?? newChangeAtomIdBTree(),\n\t\tcrossFieldKeys: p.crossFieldKeys ?? newCrossFieldKeyTable(),\n\t};\n\n\tif (p.revisions !== undefined && p.revisions.length > 0) {\n\t\tchangeset.revisions = p.revisions;\n\t}\n\tif (p.maxId >= 0) {\n\t\tchangeset.maxId = brand(p.maxId);\n\t}\n\tif (p.constraintViolationCount !== undefined && p.constraintViolationCount > 0) {\n\t\tchangeset.constraintViolationCount = p.constraintViolationCount;\n\t}\n\tif (p.noChangeConstraint !== undefined) {\n\t\tchangeset.noChangeConstraint = p.noChangeConstraint;\n\t}\n\tif (p.noChangeConstraintOnRevert !== undefined) {\n\t\tchangeset.noChangeConstraintOnRevert = p.noChangeConstraintOnRevert;\n\t}\n\tif (p.builds !== undefined && p.builds.size > 0) {\n\t\tchangeset.builds = p.builds;\n\t}\n\tif (p.destroys !== undefined && p.destroys.size > 0) {\n\t\tchangeset.destroys = p.destroys;\n\t}\n\tif (p.refreshers !== undefined && p.refreshers.size > 0) {\n\t\tchangeset.refreshers = p.refreshers;\n\t}\n\treturn changeset;\n}\n\n// TODO: TFieldData could instead just be a numeric ID generated by the CrossFieldTable\n// The CrossFieldTable could have a generic field ID to context table\nexport interface CrossFieldTable<TFieldData> {\n\tsrcTable: CrossFieldMap<unknown>;\n\tdstTable: CrossFieldMap<unknown>;\n\tsrcDependents: CrossFieldMap<TFieldData>;\n\tdstDependents: CrossFieldMap<TFieldData>;\n\tinvalidatedFields: Set<TFieldData>;\n}\n\nexport abstract class CrossFieldManagerI<T> implements CrossFieldManager {\n\tpublic constructor(\n\t\tprotected readonly crossFieldTable: CrossFieldTable<T>,\n\t\tprivate readonly currentFieldKey: T,\n\t\tprotected readonly allowInval = true,\n\t) {}\n\n\tpublic set(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t\tnewValue: unknown,\n\t\tinvalidateDependents: boolean,\n\t): void {\n\t\tif (invalidateDependents && this.allowInval) {\n\t\t\tconst lastChangedId = (id as number) + count - 1;\n\t\t\tlet firstId = id;\n\t\t\twhile (firstId <= lastChangedId) {\n\t\t\t\tconst dependentEntry = getFirstFromCrossFieldMap(\n\t\t\t\t\tthis.getDependents(target),\n\t\t\t\t\trevision,\n\t\t\t\t\tfirstId,\n\t\t\t\t\tlastChangedId - firstId + 1,\n\t\t\t\t);\n\t\t\t\tif (dependentEntry.value !== undefined) {\n\t\t\t\t\tthis.crossFieldTable.invalidatedFields.add(dependentEntry.value);\n\t\t\t\t}\n\n\t\t\t\tfirstId = brand(firstId + dependentEntry.length);\n\t\t\t}\n\t\t}\n\t\tsetInCrossFieldMap(this.getMap(target), revision, id, count, newValue);\n\t}\n\n\tpublic get(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t\taddDependency: boolean,\n\t): RangeQueryResult<unknown> {\n\t\tif (addDependency) {\n\t\t\t// We assume that if there is already an entry for this ID it is because\n\t\t\t// a field handler has called compose on the same node multiple times.\n\t\t\t// In this case we only want to update the latest version, so we overwrite the dependency.\n\t\t\tsetInCrossFieldMap(\n\t\t\t\tthis.getDependents(target),\n\t\t\t\trevision,\n\t\t\t\tid,\n\t\t\t\tcount,\n\t\t\t\tthis.currentFieldKey,\n\t\t\t);\n\t\t}\n\t\treturn getFirstFromCrossFieldMap(this.getMap(target), revision, id, count);\n\t}\n\n\tpublic abstract onMoveIn(id: NodeId): void;\n\n\tpublic abstract moveKey(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t): void;\n\n\tprivate getMap(target: CrossFieldTarget): CrossFieldMap<unknown> {\n\t\treturn target === CrossFieldTarget.Source\n\t\t\t? this.crossFieldTable.srcTable\n\t\t\t: this.crossFieldTable.dstTable;\n\t}\n\n\tprivate getDependents(target: CrossFieldTarget): CrossFieldMap<T> {\n\t\treturn target === CrossFieldTarget.Source\n\t\t\t? this.crossFieldTable.srcDependents\n\t\t\t: this.crossFieldTable.dstDependents;\n\t}\n}\n\nexport function newCrossFieldTable<T>(): CrossFieldTable<T> {\n\treturn {\n\t\tsrcTable: newChangeAtomIdRangeMap(),\n\t\tdstTable: newChangeAtomIdRangeMap(),\n\t\tsrcDependents: newChangeAtomIdRangeMap(),\n\t\tdstDependents: newChangeAtomIdRangeMap(),\n\t\tinvalidatedFields: new Set(),\n\t};\n}\n\nexport function getRevInfoFromTaggedChanges(changes: TaggedChange<ModularChangeset>[]): {\n\trevInfos: RevisionInfo[];\n\tmaxId: ChangesetLocalId;\n} {\n\tlet maxId = -1;\n\tconst revInfos: RevisionInfo[] = [];\n\tconst revisions = new Set<RevisionTag>();\n\tfor (const taggedChange of changes) {\n\t\tconst change = taggedChange.change;\n\t\tmaxId = Math.max(change.maxId ?? -1, maxId);\n\t\tconst infosToAdd = revisionInfoFromTaggedChange(taggedChange);\n\t\tfor (const info of infosToAdd) {\n\t\t\tif (!revisions.has(info.revision)) {\n\t\t\t\trevisions.add(info.revision);\n\t\t\t\trevInfos.push(info);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst rolledBackRevisions: RevisionTag[] = [];\n\tfor (const info of revInfos) {\n\t\tif (info.rollbackOf !== undefined) {\n\t\t\trolledBackRevisions.push(info.rollbackOf);\n\t\t}\n\t}\n\n\trolledBackRevisions.reverse();\n\tfor (const revision of rolledBackRevisions) {\n\t\tif (!revisions.has(revision)) {\n\t\t\trevInfos.push({ revision });\n\t\t}\n\t}\n\n\treturn { maxId: brand(maxId), revInfos };\n}\n\nexport function revisionInfoFromTaggedChange(\n\ttaggedChange: TaggedChange<ModularChangeset>,\n): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.change.revisions !== undefined) {\n\t\trevInfos.push(...taggedChange.change.revisions);\n\t} else if (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nexport function getChangeHandler(\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\tkind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\treturn getFieldKind(fieldKinds, kind).changeHandler;\n}\n\nfunction getFieldKind(\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\tkind: FieldKindIdentifier,\n): FlexFieldKind {\n\tif (kind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind;\n\t}\n\tconst fieldKind = fieldKinds.get(kind);\n\tassert(fieldKind !== undefined, 0x3ad /* Unknown field kind */);\n\treturn fieldKind;\n}\n\nexport interface ConstraintState {\n\tviolationCount: number;\n}\n\nexport function newConstraintState(violationCount: number): ConstraintState {\n\treturn {\n\t\tviolationCount,\n\t};\n}\n\nexport function updateConstraintsForFields(\n\tfields: FieldChangeMap,\n\tparentInputAttachState: NodeAttachState,\n\tconstraintState: ConstraintState,\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): void {\n\tfor (const field of fields.values()) {\n\t\tconst handler = getChangeHandler(fieldKinds, field.fieldKind);\n\t\tfor (const [nodeId, inputIndex, _outputIndex] of handler.getNestedChanges(field.change)) {\n\t\t\tconst isInputDetached = inputIndex === undefined;\n\t\t\tconst inputAttachState =\n\t\t\t\tparentInputAttachState === NodeAttachState.Detached || isInputDetached\n\t\t\t\t\t? NodeAttachState.Detached\n\t\t\t\t\t: NodeAttachState.Attached;\n\n\t\t\tupdateConstraintsForNode(nodeId, inputAttachState, nodes, constraintState, fieldKinds);\n\t\t}\n\t}\n}\n\nfunction updateConstraintsForNode(\n\tnodeId: NodeId,\n\tinputAttachState: NodeAttachState,\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tconstraintState: ConstraintState,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): void {\n\tconst node =\n\t\tnodes.get([nodeId.revision, nodeId.localId]) ?? fail(0xb24 /* Unknown node ID */);\n\tif (node.nodeExistsConstraint !== undefined) {\n\t\tconst isNowViolated = inputAttachState === NodeAttachState.Detached;\n\t\tif (node.nodeExistsConstraint.violated !== isNowViolated) {\n\t\t\tnode.nodeExistsConstraint = {\n\t\t\t\t...node.nodeExistsConstraint,\n\t\t\t\tviolated: isNowViolated,\n\t\t\t};\n\t\t\tconstraintState.violationCount += isNowViolated ? 1 : -1;\n\t\t}\n\t}\n\n\tif (node.fieldChanges !== undefined) {\n\t\tupdateConstraintsForFields(\n\t\t\tnode.fieldChanges,\n\t\t\tinputAttachState,\n\t\t\tconstraintState,\n\t\t\tnodes,\n\t\t\tfieldKinds,\n\t\t);\n\t}\n}\n\nexport function nodeChangeFromId(\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tid: NodeId,\n): NodeChangeset {\n\tconst node = getFromChangeAtomIdMap(nodes, id);\n\tassert(node !== undefined, 0x9ca /* Unknown node ID */);\n\treturn node;\n}\n"]}
1
+ {"version":3,"file":"modularChangeUtils.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,kDAQ6B;AAC7B,kDAAiF;AACjF,kEAIiC;AACjC,iEAMgC;AAEhC,mEAA0D;AAE1D,+DAAyD;AACzD,mEAOiC;AAEjC,SAAgB,YAAY,CAAC,MAAwB;IACpD,OAAO,CAAC,MAAM,CAAC,wBAAwB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AAFD,oCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CACnC,QAAuE,EAAE;IAEzE,MAAM,CAAC,GAAG,KAAK,CAAC;IAChB,MAAM,SAAS,GAA8B;QAC5C,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,IAAI,GAAG,EAAyB;QAChE,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,IAAA,2CAAoB,GAAE;QACpD,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,IAAA,2CAAoB,GAAE;QACtD,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,IAAA,2CAAoB,GAAE;QACpD,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAA,6CAAqB,GAAE;KAC3D,C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ACV,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAgB,gBAAgB,CAC/B,KAAuC,EACvC,EAAU;IAEV,MAAM,IAAI,GAAG,IAAA,6CAAsB,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,IAAA,iBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACb,CAAC;AAPD,4CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport {\n\tnewChangeAtomIdRangeMap,\n\ttype ChangesetLocalId,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype RevisionInfo,\n\ttype RevisionTag,\n\ttype TaggedChange,\n} from \"../../core/index.js\";\nimport { brand, type Mutable, type RangeQueryResult } from \"../../util/index.js\";\nimport {\n\tgetFromChangeAtomIdMap,\n\tnewChangeAtomIdBTree,\n\ttype ChangeAtomIdBTree,\n} from \"../changeAtomIdBTree.js\";\nimport {\n\tCrossFieldTarget,\n\tgetFirstFromCrossFieldMap,\n\tsetInCrossFieldMap,\n\ttype CrossFieldManager,\n\ttype CrossFieldMap,\n} from \"./crossFieldQueries.js\";\nimport type { FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport { NodeAttachState } from \"./fieldChangeHandler.js\";\nimport type { FlexFieldKind } from \"./fieldKind.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\tnewCrossFieldKeyTable,\n\ttype FieldChange,\n\ttype FieldChangeMap,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\nexport function hasConflicts(change: ModularChangeset): boolean {\n\treturn (change.constraintViolationCount ?? 0) > 0;\n}\n\n/**\n * Creates a normalized changeset from the provided properties.\n *\n * Required changeset maps are initialized when omitted, and empty optional properties are not\n * included in the returned changeset. `maxId` accepts an unbranded allocator ID; `undefined`\n * indicates that the changeset contains no IDs.\n */\nexport function makeModularChangeset(\n\tprops: Partial<Omit<ModularChangeset, \"maxId\">> & { maxId?: number } = {},\n): ModularChangeset {\n\tconst p = props;\n\tconst changeset: Mutable<ModularChangeset> = {\n\t\tfieldChanges: p.fieldChanges ?? new Map<FieldKey, FieldChange>(),\n\t\tnodeChanges: p.nodeChanges ?? newChangeAtomIdBTree(),\n\t\tnodeToParent: p.nodeToParent ?? newChangeAtomIdBTree(),\n\t\tnodeAliases: p.nodeAliases ?? newChangeAtomIdBTree(),\n\t\tcrossFieldKeys: p.crossFieldKeys ?? newCrossFieldKeyTable(),\n\t};\n\n\tif (p.revisions !== undefined && p.revisions.length > 0) {\n\t\tchangeset.revisions = p.revisions;\n\t}\n\tif (p.maxId !== undefined && p.maxId >= 0) {\n\t\tchangeset.maxId = brand(p.maxId);\n\t}\n\tif (p.constraintViolationCount !== undefined && p.constraintViolationCount > 0) {\n\t\tchangeset.constraintViolationCount = p.constraintViolationCount;\n\t}\n\tif (p.noChangeConstraint !== undefined) {\n\t\tchangeset.noChangeConstraint = p.noChangeConstraint;\n\t}\n\tif (p.noChangeConstraintOnRevert !== undefined) {\n\t\tchangeset.noChangeConstraintOnRevert = p.noChangeConstraintOnRevert;\n\t}\n\tif (p.builds !== undefined && p.builds.size > 0) {\n\t\tchangeset.builds = p.builds;\n\t}\n\tif (p.destroys !== undefined && p.destroys.size > 0) {\n\t\tchangeset.destroys = p.destroys;\n\t}\n\tif (p.refreshers !== undefined && p.refreshers.size > 0) {\n\t\tchangeset.refreshers = p.refreshers;\n\t}\n\treturn changeset;\n}\n\n// TODO: TFieldData could instead just be a numeric ID generated by the CrossFieldTable\n// The CrossFieldTable could have a generic field ID to context table\nexport interface CrossFieldTable<TFieldData> {\n\tsrcTable: CrossFieldMap<unknown>;\n\tdstTable: CrossFieldMap<unknown>;\n\tsrcDependents: CrossFieldMap<TFieldData>;\n\tdstDependents: CrossFieldMap<TFieldData>;\n\tinvalidatedFields: Set<TFieldData>;\n}\n\nexport abstract class CrossFieldManagerI<T> implements CrossFieldManager {\n\tpublic constructor(\n\t\tprotected readonly crossFieldTable: CrossFieldTable<T>,\n\t\tprivate readonly currentFieldKey: T,\n\t\tprotected readonly allowInval = true,\n\t) {}\n\n\tpublic set(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t\tnewValue: unknown,\n\t\tinvalidateDependents: boolean,\n\t): void {\n\t\tif (invalidateDependents && this.allowInval) {\n\t\t\tconst lastChangedId = (id as number) + count - 1;\n\t\t\tlet firstId = id;\n\t\t\twhile (firstId <= lastChangedId) {\n\t\t\t\tconst dependentEntry = getFirstFromCrossFieldMap(\n\t\t\t\t\tthis.getDependents(target),\n\t\t\t\t\trevision,\n\t\t\t\t\tfirstId,\n\t\t\t\t\tlastChangedId - firstId + 1,\n\t\t\t\t);\n\t\t\t\tif (dependentEntry.value !== undefined) {\n\t\t\t\t\tthis.crossFieldTable.invalidatedFields.add(dependentEntry.value);\n\t\t\t\t}\n\n\t\t\t\tfirstId = brand(firstId + dependentEntry.length);\n\t\t\t}\n\t\t}\n\t\tsetInCrossFieldMap(this.getMap(target), revision, id, count, newValue);\n\t}\n\n\tpublic get(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t\taddDependency: boolean,\n\t): RangeQueryResult<unknown> {\n\t\tif (addDependency) {\n\t\t\t// We assume that if there is already an entry for this ID it is because\n\t\t\t// a field handler has called compose on the same node multiple times.\n\t\t\t// In this case we only want to update the latest version, so we overwrite the dependency.\n\t\t\tsetInCrossFieldMap(\n\t\t\t\tthis.getDependents(target),\n\t\t\t\trevision,\n\t\t\t\tid,\n\t\t\t\tcount,\n\t\t\t\tthis.currentFieldKey,\n\t\t\t);\n\t\t}\n\t\treturn getFirstFromCrossFieldMap(this.getMap(target), revision, id, count);\n\t}\n\n\tpublic abstract onMoveIn(id: NodeId): void;\n\n\tpublic abstract moveKey(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t): void;\n\n\tprivate getMap(target: CrossFieldTarget): CrossFieldMap<unknown> {\n\t\treturn target === CrossFieldTarget.Source\n\t\t\t? this.crossFieldTable.srcTable\n\t\t\t: this.crossFieldTable.dstTable;\n\t}\n\n\tprivate getDependents(target: CrossFieldTarget): CrossFieldMap<T> {\n\t\treturn target === CrossFieldTarget.Source\n\t\t\t? this.crossFieldTable.srcDependents\n\t\t\t: this.crossFieldTable.dstDependents;\n\t}\n}\n\nexport function newCrossFieldTable<T>(): CrossFieldTable<T> {\n\treturn {\n\t\tsrcTable: newChangeAtomIdRangeMap(),\n\t\tdstTable: newChangeAtomIdRangeMap(),\n\t\tsrcDependents: newChangeAtomIdRangeMap(),\n\t\tdstDependents: newChangeAtomIdRangeMap(),\n\t\tinvalidatedFields: new Set(),\n\t};\n}\n\nexport function getRevInfoFromTaggedChanges(changes: TaggedChange<ModularChangeset>[]): {\n\trevInfos: RevisionInfo[];\n\tmaxId: ChangesetLocalId;\n} {\n\tlet maxId = -1;\n\tconst revInfos: RevisionInfo[] = [];\n\tconst revisions = new Set<RevisionTag>();\n\tfor (const taggedChange of changes) {\n\t\tconst change = taggedChange.change;\n\t\tmaxId = Math.max(change.maxId ?? -1, maxId);\n\t\tconst infosToAdd = revisionInfoFromTaggedChange(taggedChange);\n\t\tfor (const info of infosToAdd) {\n\t\t\tif (!revisions.has(info.revision)) {\n\t\t\t\trevisions.add(info.revision);\n\t\t\t\trevInfos.push(info);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst rolledBackRevisions: RevisionTag[] = [];\n\tfor (const info of revInfos) {\n\t\tif (info.rollbackOf !== undefined) {\n\t\t\trolledBackRevisions.push(info.rollbackOf);\n\t\t}\n\t}\n\n\trolledBackRevisions.reverse();\n\tfor (const revision of rolledBackRevisions) {\n\t\tif (!revisions.has(revision)) {\n\t\t\trevInfos.push({ revision });\n\t\t}\n\t}\n\n\treturn { maxId: brand(maxId), revInfos };\n}\n\nexport function revisionInfoFromTaggedChange(\n\ttaggedChange: TaggedChange<ModularChangeset>,\n): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.change.revisions !== undefined) {\n\t\trevInfos.push(...taggedChange.change.revisions);\n\t} else if (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nexport function getChangeHandler(\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\tkind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\treturn getFieldKind(fieldKinds, kind).changeHandler;\n}\n\nfunction getFieldKind(\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\tkind: FieldKindIdentifier,\n): FlexFieldKind {\n\tif (kind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind;\n\t}\n\tconst fieldKind = fieldKinds.get(kind);\n\tassert(fieldKind !== undefined, 0x3ad /* Unknown field kind */);\n\treturn fieldKind;\n}\n\nexport interface ConstraintState {\n\tviolationCount: number;\n}\n\nexport function newConstraintState(violationCount: number): ConstraintState {\n\treturn {\n\t\tviolationCount,\n\t};\n}\n\nexport function updateConstraintsForFields(\n\tfields: FieldChangeMap,\n\tparentInputAttachState: NodeAttachState,\n\tconstraintState: ConstraintState,\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): void {\n\tfor (const field of fields.values()) {\n\t\tconst handler = getChangeHandler(fieldKinds, field.fieldKind);\n\t\tfor (const [nodeId, inputIndex, _outputIndex] of handler.getNestedChanges(field.change)) {\n\t\t\tconst isInputDetached = inputIndex === undefined;\n\t\t\tconst inputAttachState =\n\t\t\t\tparentInputAttachState === NodeAttachState.Detached || isInputDetached\n\t\t\t\t\t? NodeAttachState.Detached\n\t\t\t\t\t: NodeAttachState.Attached;\n\n\t\t\tupdateConstraintsForNode(nodeId, inputAttachState, nodes, constraintState, fieldKinds);\n\t\t}\n\t}\n}\n\nfunction updateConstraintsForNode(\n\tnodeId: NodeId,\n\tinputAttachState: NodeAttachState,\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tconstraintState: ConstraintState,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): void {\n\tconst node =\n\t\tnodes.get([nodeId.revision, nodeId.localId]) ?? fail(0xb24 /* Unknown node ID */);\n\tif (node.nodeExistsConstraint !== undefined) {\n\t\tconst isNowViolated = inputAttachState === NodeAttachState.Detached;\n\t\tif (node.nodeExistsConstraint.violated !== isNowViolated) {\n\t\t\tnode.nodeExistsConstraint = {\n\t\t\t\t...node.nodeExistsConstraint,\n\t\t\t\tviolated: isNowViolated,\n\t\t\t};\n\t\t\tconstraintState.violationCount += isNowViolated ? 1 : -1;\n\t\t}\n\t}\n\n\tif (node.fieldChanges !== undefined) {\n\t\tupdateConstraintsForFields(\n\t\t\tnode.fieldChanges,\n\t\t\tinputAttachState,\n\t\t\tconstraintState,\n\t\t\tnodes,\n\t\t\tfieldKinds,\n\t\t);\n\t}\n}\n\nexport function nodeChangeFromId(\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tid: NodeId,\n): NodeChangeset {\n\tconst node = getFromChangeAtomIdMap(nodes, id);\n\tassert(node !== undefined, 0x9ca /* Unknown node ID */);\n\treturn node;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"objectForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH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
1
+ {"version":3,"file":"objectForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACN,KAAK,MAAM,EACX,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,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,EAGnB,KAAK,SAAS,EAEd,oBAAoB,EACpB,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,MAAM,EACX,KAAK,KAAK,EAMV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAMN,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,MAAM,qBAAqB,CAAC;AAK7B,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,EAAE,aAAa;;aAiBjD,OAAO,EAAE,SAAS;IAClC;;OAEG;aACa,MAAM,EAAE,4BAA4B,GAAG,SAAS;aAChD,OAAO,EAAE,SAAS;aAClB,iBAAiB,EAAE,OAAO;IAtB3C,OAAO,CAAC,aAAa,CAAC,CAAe;IAGrC,SAAgB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IACxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAGxE,SAAgB,MAAM,E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S,EAClB,MAAM,CAAC,EAAE,4BAA4B,EACrC,OAAO,CAAC,EAAE,SAAS,EACnB,iBAAiB,GAAE,OAAe,GAChC,YAAY,CAEd"}
@@ -37,6 +37,7 @@ let ObjectForest = (() => {
37
37
  let _checkSchema_decorators;
38
38
  return _a = class ObjectForest {
39
39
  get roots() {
40
+ this.breaker.use();
40
41
  return tslib_1.__classPrivateFieldGet(this, _ObjectForest_roots, "f");
41
42
  }
42
43
  constructor(breaker,
@@ -66,12 +67,15 @@ let ObjectForest = (() => {
66
67
  }
67
68
  }
68
69
  get isEmpty() {
70
+ this.breaker.use();
69
71
  return this.roots.fields.size === 0;
70
72
  }
71
73
  clone(schema, breaker) {
74
+ this.breaker.use();
72
75
  return new _a(breaker ?? this.breaker, schema, undefined, this.additionalAsserts, this.roots);
73
76
  }
74
77
  chunkField(cursor) {
78
+ this.breaker.use();
75
79
  return (0, index_js_3.chunkField)(cursor, { idCompressor: undefined, policy: index_js_3.defaultChunkPolicy });
76
80
  }
77
81
  forgetAnchor(anchor) {
@@ -104,6 +108,7 @@ let ObjectForest = (() => {
104
108
  }
105
109
  }
106
110
  acquireVisitor() {
111
+ this.breaker.use();
107
112
  (0, internal_1.assert)(this.activeVisitor === undefined, 0x76c /* Must release existing visitor before acquiring another */);
108
113
  // Note: This code uses cursors, however it also modifies the tree.
109
114
  // In general this is not safe, but this code happens to only modify the tree below the current cursor location,
@@ -140,10 +145,14 @@ let ObjectForest = (() => {
140
145
  }
141
146
  destroy(detachedField, count) {
142
147
  preEdit();
148
+ const field = tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_roots, "f").fields.get(detachedField);
149
+ (0, internal_1.assert)(field !== undefined, 0xd28 /* Destroyed field must exist */);
150
+ (0, internal_1.assert)(field.length === count, 0xd29 /* Destroy count must match field length */);
143
151
  this.forest.delete(detachedField);
144
152
  }
145
153
  create(content, destination) {
146
154
  preEdit();
155
+ (0, internal_1.assert)(!tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_roots, "f").fields.has(destination), 0xd2a /* Create destination must be a new empty field */);
147
156
  this.forest.add(content, destination);
148
157
  tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_events, "f").emit("afterRootFieldCreated", destination);
149
158
  }
@@ -165,16 +174,15 @@ let ObjectForest = (() => {
165
174
  */
166
175
  attachEdit(source, count, destination) {
167
176
  (0, index_js_2.assertNonNegativeSafeInteger)(count);
168
- if (count === 0) {
169
- return;
170
- }
171
177
  const [parent, key] = cursor.getParent();
172
- (0, internal_1.assert)(parent !== this.forest.roots || key !== source, 0x7b6 /* Attach source field must be different from current field */);
178
+ (0, internal_1.assert)(parent !== this.forest.roots || key !== source, 0xd2b /* Attach source field must be different from current field */);
179
+ const sourceField = tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_roots, "f").fields.get(source);
180
+ (0, internal_1.assert)(sourceField !== undefined, 0xd2c /* Attach source field must exist */);
181
+ (0, internal_1.assert)(sourceField.length === count, 0xd2d /* Attach must consume all nodes in source field */);
182
+ const existingDestinationField = parent.fields.get(key) ?? [];
183
+ (0, internal_1.assert)(destination <= existingDestinationField.length, 0xd2e /* Attach destination must not exceed field length */);
184
+ (0, index_js_2.assertValidIndex)(destination, existingDestinationField, true);
173
185
  const currentField = getOrCreateField(parent, key);
174
- (0, index_js_2.assertValidIndex)(destination, currentField, true);
175
- const sourceField = tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_roots, "f").fields.get(source) ?? [];
176
- (0, internal_1.assert)(sourceField !== undefined, 0x7b7 /* Attach source field must exist */);
177
- (0, internal_1.assert)(sourceField.length === count, 0x7b8 /* Attach must consume all nodes in source field */);
178
186
  // TODO: this will fail for very large insertions due to argument limits.
179
187
  currentField.splice(destination, 0, ...sourceField);
180
188
  this.forest.delete(source);
@@ -188,9 +196,14 @@ let ObjectForest = (() => {
188
196
  */
189
197
  detachEdit(source, destination) {
190
198
  const [parent, key] = cursor.getParent();
191
- (0, internal_1.assert)(destination === undefined || parent !== this.forest.roots || key !== destination, 0x7b9 /* Detach destination field must be different from current field */);
192
- const currentField = getOrCreateField(parent, key);
199
+ (0, internal_1.assert)(destination === undefined || parent !== this.forest.roots || key !== destination, 0xd2f /* Detach destination field must be different from current field */);
200
+ const currentField = parent.fields.get(key) ?? [];
201
+ (0, internal_1.assert)(source.start <= source.end, 0xd30 /* Detach range start must not exceed end */);
202
+ (0, internal_1.assert)(source.end <= currentField.length, 0xd31 /* Detach range must not exceed field length */);
193
203
  (0, index_js_2.assertValidRange)(source, currentField);
204
+ if (destination !== undefined) {
205
+ (0, internal_1.assert)(!tslib_1.__classPrivateFieldGet(this.forest, _ObjectForest_roots, "f").fields.has(destination), 0xd32 /* Detach destination must be a new empty field */);
206
+ }
194
207
  const content = currentField.splice(source.start, source.end - source.start);
195
208
  if (destination !== undefined) {
196
209
  this.forest.addFieldAsDetached(content, destination);
@@ -219,9 +232,12 @@ let ObjectForest = (() => {
219
232
  for (const getVisitor of this.deltaVisitors) {
220
233
  announcedVisitors.push(getVisitor());
221
234
  }
222
- const combinedVisitor = (0, index_js_1.combineVisitors)([forestVisitor, ...announcedVisitors]);
223
- this.activeVisitor = combinedVisitor;
224
- return combinedVisitor;
235
+ const visitor = (0, index_js_1.combineVisitors)([
236
+ (0, index_js_1.makeBreakingVisitor)(forestVisitor, this.breaker),
237
+ ...announcedVisitors,
238
+ ]);
239
+ this.activeVisitor = visitor;
240
+ return visitor;
225
241
  }
226
242
  registerAnnouncedVisitor(visitor) {
227
243
  this.deltaVisitors.add(visitor);
@@ -248,9 +264,11 @@ let ObjectForest = (() => {
248
264
  tslib_1.__classPrivateFieldGet(this, _ObjectForest_roots, "f").fields.delete(field);
249
265
  }
250
266
  allocateCursor(source) {
267
+ this.breaker.use();
251
268
  return new Cursor(this, source);
252
269
  }
253
270
  tryMoveCursorToNode(destination, cursorToMove) {
271
+ this.breaker.use();
254
272
  const path = this.anchors.locate(destination);
255
273
  if (path === undefined) {
256
274
  return -1 /* TreeNavigationResult.NotFound */;
@@ -259,6 +277,7 @@ let ObjectForest = (() => {
259
277
  return 1 /* TreeNavigationResult.Ok */;
260
278
  }
261
279
  tryMoveCursorToField(destination, cursorToMove) {
280
+ this.breaker.use();
262
281
  if (destination.parent === undefined) {
263
282
  this.moveCursorToPath(undefined, cursorToMove);
264
283
  }
@@ -272,6 +291,7 @@ let ObjectForest = (() => {
272
291
  return 1 /* TreeNavigationResult.Ok */;
273
292
  }
274
293
  moveCursorToPath(destination, cursorToMove) {
294
+ this.breaker.use();
275
295
  (0, internal_1.assert)(cursorToMove instanceof Cursor, 0x337 /* ObjectForest must only be given its own Cursor type */);
276
296
  (0, internal_1.assert)(cursorToMove.forest === this, 0x338 /* ObjectForest must only be given its own Cursor */);
277
297
  const indexStack = [];
@@ -292,6 +312,7 @@ let ObjectForest = (() => {
292
312
  return;
293
313
  }
294
314
  getCursorAboveDetachedFields() {
315
+ this.breaker.use();
295
316
  return (0, mapTreeCursor_js_1.cursorForMapTreeNode)(this.roots);
296
317
  }
297
318
  },
@@ -1 +1 @@
1
- {"version":3,"file":"objectForest.js","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA6D;AAE7D,kEAAmE;AAEnE,kDAgC6B;AAC7B,kDAQ6B;AAC7B,yDAA4E;AAC5E,yDAA6E;AAC7E,0DAA8E;AAC9E,0DAAwE;AACxE,8DAA+E;AAO/E,kGAAkG;AAClG,SAAS,gBAAgB,CAAC,OAAuB,EAAE,GAAa;IAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClC,OAAO,QAAQ,CAA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W,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,IAAI;QACV,IAAA,iBAAM,EACL,IAAI,CAAC,KAAK,KAAK,uCAA4B,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,uCAA4B,CAAC,KAAK,CAAC;IACjD,CAAC;IAEM,WAAW;QACjB,IAAA,iBAAM,EACL,IAAI,CAAC,KAAK,KAAK,uCAA4B,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;;;;;GAKG;AACH,SAAgB,WAAW,CAC1B,OAAkB,EAClB,MAAqC,EACrC,OAAmB,EACnB,oBAA6B,KAAK;IAElC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACtE,CAAC;AAPD,kCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Anchor,\n\tAnchorSet,\n\ttype AnnouncedVisitor,\n\ttype CursorLocationType,\n\ttype DeltaDetachedNodeId,\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 Range,\n\ttype TreeChunk,\n\ttype TreeFieldStoredSchema,\n\tTreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\ttype Value,\n\taboveRootPlaceholder,\n\tcombineVisitors,\n\tdeepCopyMapTree,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport {\n\tassertNonNegativeSafeInteger,\n\tassertValidIndex,\n\tassertValidRange,\n\tbrand,\n\tbreakingMethod,\n\ttype Breakable,\n\ttype WithBreakable,\n} from \"../../util/index.js\";\nimport { chunkField, defaultChunkPolicy } from \"../chunked-forest/index.js\";\nimport { defaultSchemaPolicy, FieldKinds } from \"../default-schema/index.js\";\nimport { cursorForMapTreeNode, mapTreeFromCursor } from \"../mapTreeCursor.js\";\nimport { isFieldInSchema, throwOutOfSchema } from \"../schemaChecker.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, WithBreakable {\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 breaker: Breakable,\n\t\t/**\n\t\t * If provided, may be used for validation, but otherwise unused.\n\t\t */\n\t\tpublic readonly schema: TreeStoredSchemaSubscription | undefined,\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? {\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\t\t\t: deepCopyMapTree(roots);\n\n\t\tif (additionalAsserts) {\n\t\t\tthis.checkSchema();\n\t\t}\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription, breaker?: Breakable): ObjectForest {\n\t\treturn new ObjectForest(\n\t\t\tbreaker ?? this.breaker,\n\t\t\tschema,\n\t\t\tundefined,\n\t\t\tthis.additionalAsserts,\n\t\t\tthis.roots,\n\t\t);\n\t}\n\n\tpublic chunkField(cursor: ITreeCursorSynchronous): TreeChunk[] {\n\t\treturn chunkField(cursor, { idCompressor: undefined, policy: defaultChunkPolicy });\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\t/**\n\t * Throw (and break) if content does not match schema.\n\t */\n\t@breakingMethod\n\tpublic checkSchema(): void {\n\t\tconst schema = this.schema;\n\t\tif (schema !== undefined) {\n\t\t\tconst roots = new Set([...this.roots.fields.keys(), rootFieldKey]);\n\t\t\tfor (const key of roots) {\n\t\t\t\tconst documentRoot = this.roots.fields.get(key) ?? [];\n\t\t\t\tconst fieldSchema: TreeFieldStoredSchema =\n\t\t\t\t\tkey === rootFieldKey\n\t\t\t\t\t\t? schema.rootFieldSchema\n\t\t\t\t\t\t: // TODO: someday we should have schema for detached fields, and use that instead of generating one here.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some detached fields may have multiple nodes, so we must treat them as sequences:\n\t\t\t\t\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\t\t\t\t\ttypes: new Set(documentRoot.map((node) => node.type)),\n\n\t\t\t\t\t\t\t\t// Metadata is not used for schema checks\n\t\t\t\t\t\t\t\tpersistedMetadata: undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\tisFieldInSchema(\n\t\t\t\t\tdocumentRoot,\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\t{\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOutOfSchema,\n\t\t\t\t);\n\t\t\t}\n\t\t}\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\tif (this.forest.additionalAsserts) {\n\t\t\t\t\t// Schema validation:\n\t\t\t\t\t// When doing \"additionalAsserts\", validate the content against the schema after every batch of edits.\n\t\t\t\t\tthis.forest.checkSchema();\n\t\t\t\t}\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: readonly ITreeCursorSynchronous[], 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, id: DeltaDetachedNodeId): 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 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\tfor (const getVisitor of this.deltaVisitors) {\n\t\t\tannouncedVisitors.push(getVisitor());\n\t\t}\n\t\tconst combinedVisitor = combineVisitors([forestVisitor, ...announcedVisitors]);\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(0xb27 /* 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 content.\n * @privateRemarks\n * TODO:\n * refactor to remove this function, and instead place `ForestTypeReference` and `ForestTypeExpensiveDebug` here as a better way to encapsulate ObjectForest.\n */\nexport function buildForest(\n\tbreaker: Breakable,\n\tschema?: TreeStoredSchemaSubscription,\n\tanchors?: AnchorSet,\n\tadditionalAsserts: boolean = false,\n): ObjectForest {\n\treturn new ObjectForest(breaker, schema, anchors, additionalAsserts);\n}\n"]}
1
+ {"version":3,"file":"objectForest.js","sourceRoot":"","sources":["../../../src/feature-libraries/object-forest/objectForest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA6D;AAE7D,kEAAmE;AAEnE,kDAiC6B;AAC7B,kDAQ6B;AAC7B,yDAA4E;AAC5E,yDAA6E;AAC7E,0DAA8E;AAC9E,0DAAwE;AACxE,8DAA+E;AAO/E,kGAAkG;AAClG,SAAS,gBAAgB,CAAC,OAAuB,EAAE,GAAa;IAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;GAKG;IACU,YAAY;;;;sBAAZ,YAAY;YAWxB,IAAW,KAAK;gBACf,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;gBACnB,OAAO,+BAAA,IAAI,2BAAO,CAAC;YACpB,CAAC;YAED,YACiB,OAAkB;YAClC;;eAEG;YACa,MAAgD,EAChD,UAAqB,IAAI,oBAAS,EAAE,EACpC,oBAA6B,KAAK,EAClD,KAAe;gBAPC,YAAO,IAjBZ,2DAAY,EAiBP,OAAO,EAAW;gBAIlB,WAAM,GAAN,MAAM,CAA0C;gBAChD,YAAO,GAAP,OAAO,CAA6B;gBACpC,sBAAiB,GAAjB,iBAAiB,CAAiB;gBApBnD,2EAA2E;gBAC3D,mBAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;gBACvC,kBAAa,GAAgC,IAAI,GAAG,EAAE,CAAC;gBAE/D,+BAAU,IAAA,4BAAa,GAAgB,EAAC;gBACjC,WAAM,GAA6B,+BAAA,IAAI,4BA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M,EACL,IAAI,CAAC,KAAK,KAAK,uCAA4B,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;;;;;GAKG;AACH,SAAgB,WAAW,CAC1B,OAAkB,EAClB,MAAqC,EACrC,OAAmB,EACnB,oBAA6B,KAAK;IAElC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACtE,CAAC;AAPD,kCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Anchor,\n\tAnchorSet,\n\ttype AnnouncedVisitor,\n\ttype CursorLocationType,\n\ttype DeltaDetachedNodeId,\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 Range,\n\ttype TreeChunk,\n\ttype TreeFieldStoredSchema,\n\tTreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\ttype Value,\n\taboveRootPlaceholder,\n\tcombineVisitors,\n\tdeepCopyMapTree,\n\tmakeBreakingVisitor,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport {\n\tassertNonNegativeSafeInteger,\n\tassertValidIndex,\n\tassertValidRange,\n\tbrand,\n\tbreakingMethod,\n\ttype Breakable,\n\ttype WithBreakable,\n} from \"../../util/index.js\";\nimport { chunkField, defaultChunkPolicy } from \"../chunked-forest/index.js\";\nimport { defaultSchemaPolicy, FieldKinds } from \"../default-schema/index.js\";\nimport { cursorForMapTreeNode, mapTreeFromCursor } from \"../mapTreeCursor.js\";\nimport { isFieldInSchema, throwOutOfSchema } from \"../schemaChecker.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, WithBreakable {\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\tthis.breaker.use();\n\t\treturn this.#roots;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly breaker: Breakable,\n\t\t/**\n\t\t * If provided, may be used for validation, but otherwise unused.\n\t\t */\n\t\tpublic readonly schema: TreeStoredSchemaSubscription | undefined,\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? {\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\t\t\t: deepCopyMapTree(roots);\n\n\t\tif (additionalAsserts) {\n\t\t\tthis.checkSchema();\n\t\t}\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\tthis.breaker.use();\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription, breaker?: Breakable): ObjectForest {\n\t\tthis.breaker.use();\n\t\treturn new ObjectForest(\n\t\t\tbreaker ?? this.breaker,\n\t\t\tschema,\n\t\t\tundefined,\n\t\t\tthis.additionalAsserts,\n\t\t\tthis.roots,\n\t\t);\n\t}\n\n\tpublic chunkField(cursor: ITreeCursorSynchronous): TreeChunk[] {\n\t\tthis.breaker.use();\n\t\treturn chunkField(cursor, { idCompressor: undefined, policy: defaultChunkPolicy });\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\t/**\n\t * Throw (and break) if content does not match schema.\n\t */\n\t@breakingMethod\n\tpublic checkSchema(): void {\n\t\tconst schema = this.schema;\n\t\tif (schema !== undefined) {\n\t\t\tconst roots = new Set([...this.roots.fields.keys(), rootFieldKey]);\n\t\t\tfor (const key of roots) {\n\t\t\t\tconst documentRoot = this.roots.fields.get(key) ?? [];\n\t\t\t\tconst fieldSchema: TreeFieldStoredSchema =\n\t\t\t\t\tkey === rootFieldKey\n\t\t\t\t\t\t? schema.rootFieldSchema\n\t\t\t\t\t\t: // TODO: someday we should have schema for detached fields, and use that instead of generating one here.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some detached fields may have multiple nodes, so we must treat them as sequences:\n\t\t\t\t\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\t\t\t\t\ttypes: new Set(documentRoot.map((node) => node.type)),\n\n\t\t\t\t\t\t\t\t// Metadata is not used for schema checks\n\t\t\t\t\t\t\t\tpersistedMetadata: undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\tisFieldInSchema(\n\t\t\t\t\tdocumentRoot,\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\t{\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOutOfSchema,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tthis.breaker.use();\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\tif (this.forest.additionalAsserts) {\n\t\t\t\t\t// Schema validation:\n\t\t\t\t\t// When doing \"additionalAsserts\", validate the content against the schema after every batch of edits.\n\t\t\t\t\tthis.forest.checkSchema();\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic destroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tpreEdit();\n\t\t\t\tconst field = this.forest.#roots.fields.get(detachedField);\n\t\t\t\tassert(field !== undefined, 0xd28 /* Destroyed field must exist */);\n\t\t\t\tassert(field.length === count, 0xd29 /* Destroy count must match field length */);\n\t\t\t\tthis.forest.delete(detachedField);\n\t\t\t}\n\t\t\tpublic create(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void {\n\t\t\t\tpreEdit();\n\t\t\t\tassert(\n\t\t\t\t\t!this.forest.#roots.fields.has(destination),\n\t\t\t\t\t0xd2a /* Create destination must be a new empty field */,\n\t\t\t\t);\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, id: DeltaDetachedNodeId): 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\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\t0xd2b /* Attach source field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst sourceField = this.forest.#roots.fields.get(source);\n\t\t\t\tassert(sourceField !== undefined, 0xd2c /* Attach source field must exist */);\n\t\t\t\tassert(\n\t\t\t\t\tsourceField.length === count,\n\t\t\t\t\t0xd2d /* Attach must consume all nodes in source field */,\n\t\t\t\t);\n\t\t\t\tconst existingDestinationField = parent.fields.get(key) ?? [];\n\t\t\t\tassert(\n\t\t\t\t\tdestination <= existingDestinationField.length,\n\t\t\t\t\t0xd2e /* Attach destination must not exceed field length */,\n\t\t\t\t);\n\t\t\t\tassertValidIndex(destination, existingDestinationField, true);\n\t\t\t\tconst currentField = getOrCreateField(parent, key);\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\t0xd2f /* Detach destination field must be different from current field */,\n\t\t\t\t);\n\t\t\t\tconst currentField = parent.fields.get(key) ?? [];\n\t\t\t\tassert(source.start <= source.end, 0xd30 /* Detach range start must not exceed end */);\n\t\t\t\tassert(\n\t\t\t\t\tsource.end <= currentField.length,\n\t\t\t\t\t0xd31 /* Detach range must not exceed field length */,\n\t\t\t\t);\n\t\t\t\tassertValidRange(source, currentField);\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.forest.#roots.fields.has(destination),\n\t\t\t\t\t\t0xd32 /* Detach destination must be a new empty field */,\n\t\t\t\t\t);\n\t\t\t\t}\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 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\tfor (const getVisitor of this.deltaVisitors) {\n\t\t\tannouncedVisitors.push(getVisitor());\n\t\t}\n\t\tconst visitor = combineVisitors([\n\t\t\tmakeBreakingVisitor(forestVisitor, this.breaker),\n\t\t\t...announcedVisitors,\n\t\t]);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\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\tthis.breaker.use();\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\tthis.breaker.use();\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\tthis.breaker.use();\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\tthis.breaker.use();\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\tthis.breaker.use();\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(0xb27 /* 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 content.\n * @privateRemarks\n * TODO:\n * refactor to remove this function, and instead place `ForestTypeReference` and `ForestTypeExpensiveDebug` here as a better way to encapsulate ObjectForest.\n */\nexport function buildForest(\n\tbreaker: Breakable,\n\tschema?: TreeStoredSchemaSubscription,\n\tanchors?: AnchorSet,\n\tadditionalAsserts: boolean = false,\n): ObjectForest {\n\treturn new ObjectForest(breaker, schema, anchors, additionalAsserts);\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
6
- import type { IExperimentalIncrementalSummaryContext, ITelemetryContext, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
6
+ import type { IExperimentalIncrementalSummaryContext, ITelemetryContext, OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
7
7
  import type { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
8
8
  import type { IJsonCodec } from "../../codec/index.js";
9
9
  import { type MutableTreeStoredSchema, type TreeStoredSchema } from "../../core/index.js";
@@ -34,7 +34,7 @@ export declare class SchemaSummarizer extends VersionedSummarizer<SchemaSummaryF
34
34
  private readonly schema;
35
35
  private readonly codec;
36
36
  private schemaIndexLastChangedSeq;
37
- constructor(schema: MutableTreeStoredSchema, collabWindow: CollabWindow, codec: IJsonCodec<TreeStoredSchema>, minVersionForCollab: MinimumVersionForCollab);
37
+ constructor(schema: MutableTreeStoredSchema, collabWindow: CollabWindow, codec: IJsonCodec<TreeStoredSchema>, minVersionForCollab: OldestSupportedClientVersion);
38
38
  protected summarizeInternal(props: {
39
39
  stringify: SummaryElementStringifier;
40
40
  fullTree?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"schemaSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EACX,sCAAsC,EACtC,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C;;GAEG;AACH,0BAAkB,0BAA0B;IAC3C;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,OAAO,IAAK;CACZ;AAiBD;;GAEG;AACH,qBAAa,gBACZ,SAAQ,mBAAmB,CAAC,0BAA0B,CACtD,YAAW,YAAY;IAKtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALvB,OAAO,CAAC,yBAAyB,CAAqB;gBAGpC,MAAM,EAAE,uBAAuB,EAChD,YAAY,EAAE,YAAY,EACT,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,EACpD,mBAAmB,EAAE,uBAAuB;IAe7C,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;QAClC,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;QACnE,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;cAmBQ,YAAY,CAC3B,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAgBhB"}
1
+ {"version":3,"file":"schemaSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EACX,sCAAsC,EACtC,iBAAiB,EACjB,4BAA4B,EAC5B,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C;;GAEG;AACH,0BAAkB,0BAA0B;IAC3C;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,OAAO,IAAK;CACZ;AAiBD;;GAEG;AACH,qBAAa,gBACZ,SAAQ,mBAAmB,CAAC,0BAA0B,CACtD,YAAW,YAAY;IAKtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALvB,OAAO,CAAC,yBAAyB,CAAqB;gBAGpC,MAAM,EAAE,uBAAuB,EAChD,YAAY,EAAE,YAAY,EACT,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,EACpD,mBAAmB,EAAE,4BAA4B;IAelD,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;QAClC,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;QACnE,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;cAmBQ,YAAY,CAC3B,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAgBhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAE7D,2EAAiE;AASjE,kDAI6B;AAC7B,8DAKyC;AAG5B,QAAA,eAAe,GAAG,cAAc,CAAC;AAE9C;;GAEG;AACH,IAAkB,0BAajB;AAbD,WAAkB,0BAA0B;IAC3C;;OAEG;IACH,uEAAM,CAAA;IACN;;OAEG;IACH,uEAAM,CAAA;IACN;;OAEG;IACH,iFAAY,CAAA;AACb,CAAC,EAbiB,0BAA0B,0CAA1B,0BAA0B,QAa3C;AAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAA6B;;;CAG7D,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,sCAAsC,CAC9C,OAAgC;IAEhC,2EAA2E;IAC3E,6CAAqC;AACtC,CAAC;A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,CAAC,CAAC;QAC/E,kEAAkE;QAClE,0EAA0E;QAC1E,iDAAiD;QACjD,IAAA,iBAAM,EACL,IAAA,4BAAiB,EAAC,IAAI,CAAC,MAAM,CAAC,EAC9B,KAAK,CAAC,0EAA0E,CAChF,CAAC;QAEF,MAAM,YAAY,GAAG,IAAA,6BAAc,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAC1D,+DAA+D;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC;IACpC,CAAC;CACD;AAtED,4CAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../../codec/index.js\";\nimport {\n\ttype MutableTreeStoredSchema,\n\ttype TreeStoredSchema,\n\tschemaDataIsEmpty,\n} from \"../../core/index.js\";\nimport {\n\tVersionedSummarizer,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport type { CollabWindow } from \"../incrementalSummarizationUtils.js\";\n\nexport const schemaStringKey = \"SchemaString\";\n\n/**\n * The versions for the schema summary format.\n */\nexport const enum SchemaSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<SchemaSummaryFormatVersion>([\n\tSchemaSummaryFormatVersion.v1,\n\tSchemaSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToSchemaSummaryFormatVersion(\n\tversion: MinimumVersionForCollab,\n): SchemaSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn SchemaSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading a schema repository.\n */\nexport class SchemaSummarizer\n\textends VersionedSummarizer<SchemaSummaryFormatVersion>\n\timplements Summarizable\n{\n\tprivate schemaIndexLastChangedSeq: number | undefined;\n\n\tpublic constructor(\n\t\tprivate readonly schema: MutableTreeStoredSchema,\n\t\tcollabWindow: CollabWindow,\n\t\tprivate readonly codec: IJsonCodec<TreeStoredSchema>,\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t) {\n\t\tsuper(\n\t\t\t\"Schema\",\n\t\t\tminVersionToSchemaSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t\tthis.schema.events.on(\"afterSchemaChange\", () => {\n\t\t\t// Invalidate the cache, as we need to regenerate the blob if the schema changes\n\t\t\t// We are assuming that schema changes from remote ops are valid, as we are in a summarization context.\n\t\t\tthis.schemaIndexLastChangedSeq = collabWindow.getCurrentSeq();\n\t\t});\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { builder, incrementalSummaryContext, stringify, fullTree = false } = props;\n\t\tif (\n\t\t\t!fullTree &&\n\t\t\tincrementalSummaryContext !== undefined &&\n\t\t\tthis.schemaIndexLastChangedSeq !== undefined &&\n\t\t\tincrementalSummaryContext.latestSummarySequenceNumber >= this.schemaIndexLastChangedSeq\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tschemaStringKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`${incrementalSummaryContext.summaryPath}/${schemaStringKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tconst dataString = stringify(this.codec.encode(this.schema));\n\t\t\tbuilder.addBlob(schemaStringKey, dataString);\n\t\t}\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(schemaStringKey);\n\t\t// After the awaits, validate that the schema is in a clean state.\n\t\t// This detects any schema that could have been accidentally added through\n\t\t// invalid means and are about to be overwritten.\n\t\tassert(\n\t\t\tschemaDataIsEmpty(this.schema),\n\t\t\t0x3da /* there should not already be stored schema when loading stored schema */,\n\t\t);\n\n\t\tconst schemaString = bufferToString(schemaBuffer, \"utf8\");\n\t\t// Currently no Fluid handles are used, so just use JSON.parse.\n\t\tconst decoded = this.codec.decode(JSON.parse(schemaString));\n\t\tthis.schema.apply(decoded);\n\t\tthis.schemaIndexLastChangedSeq = 0;\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAE7D,2EAAiE;AASjE,kDAI6B;AAC7B,8DAKyC;AAG5B,QAAA,eAAe,GAAG,cAAc,CAAC;AAE9C;;GAEG;AACH,IAAkB,0BAajB;AAbD,WAAkB,0BAA0B;IAC3C;;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AAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,OAAO,CAAC,uBAAe,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAES,KAAK,CAAC,YAAY,CAC3B,QAAgC,EAChC,KAA2B;QAE3B,MAAM,YAAY,GAAoB,MAAM,QAAQ,CAAC,QAAQ,CAAC,uBAAe,CAAC,CAAC;QAC/E,kEAAkE;QAClE,0EAA0E;QAC1E,iDAAiD;QACjD,IAAA,iBAAM,EACL,IAAA,4BAAiB,EAAC,IAAI,CAAC,MAAM,CAAC,EAC9B,KAAK,CAAC,0EAA0E,CAChF,CAAC;QAEF,MAAM,YAAY,GAAG,IAAA,6BAAc,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAC1D,+DAA+D;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC;IACpC,CAAC;CACD;AAtED,4CAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tOldestSupportedClientVersion,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../../codec/index.js\";\nimport {\n\ttype MutableTreeStoredSchema,\n\ttype TreeStoredSchema,\n\tschemaDataIsEmpty,\n} from \"../../core/index.js\";\nimport {\n\tVersionedSummarizer,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport type { CollabWindow } from \"../incrementalSummarizationUtils.js\";\n\nexport const schemaStringKey = \"SchemaString\";\n\n/**\n * The versions for the schema summary format.\n */\nexport const enum SchemaSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<SchemaSummaryFormatVersion>([\n\tSchemaSummaryFormatVersion.v1,\n\tSchemaSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToSchemaSummaryFormatVersion(\n\tversion: OldestSupportedClientVersion,\n): SchemaSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn SchemaSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading a schema repository.\n */\nexport class SchemaSummarizer\n\textends VersionedSummarizer<SchemaSummaryFormatVersion>\n\timplements Summarizable\n{\n\tprivate schemaIndexLastChangedSeq: number | undefined;\n\n\tpublic constructor(\n\t\tprivate readonly schema: MutableTreeStoredSchema,\n\t\tcollabWindow: CollabWindow,\n\t\tprivate readonly codec: IJsonCodec<TreeStoredSchema>,\n\t\tminVersionForCollab: OldestSupportedClientVersion,\n\t) {\n\t\tsuper(\n\t\t\t\"Schema\",\n\t\t\tminVersionToSchemaSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t\tthis.schema.events.on(\"afterSchemaChange\", () => {\n\t\t\t// Invalidate the cache, as we need to regenerate the blob if the schema changes\n\t\t\t// We are assuming that schema changes from remote ops are valid, as we are in a summarization context.\n\t\t\tthis.schemaIndexLastChangedSeq = collabWindow.getCurrentSeq();\n\t\t});\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { builder, incrementalSummaryContext, stringify, fullTree = false } = props;\n\t\tif (\n\t\t\t!fullTree &&\n\t\t\tincrementalSummaryContext !== undefined &&\n\t\t\tthis.schemaIndexLastChangedSeq !== undefined &&\n\t\t\tincrementalSummaryContext.latestSummarySequenceNumber >= this.schemaIndexLastChangedSeq\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tschemaStringKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`${incrementalSummaryContext.summaryPath}/${schemaStringKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tconst dataString = stringify(this.codec.encode(this.schema));\n\t\t\tbuilder.addBlob(schemaStringKey, dataString);\n\t\t}\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(schemaStringKey);\n\t\t// After the awaits, validate that the schema is in a clean state.\n\t\t// This detects any schema that could have been accidentally added through\n\t\t// invalid means and are about to be overwritten.\n\t\tassert(\n\t\t\tschemaDataIsEmpty(this.schema),\n\t\t\t0x3da /* there should not already be stored schema when loading stored schema */,\n\t\t);\n\n\t\tconst schemaString = bufferToString(schemaBuffer, \"utf8\");\n\t\t// Currently no Fluid handles are used, so just use JSON.parse.\n\t\tconst decoded = this.codec.decode(JSON.parse(schemaString));\n\t\tthis.schema.apply(decoded);\n\t\tthis.schemaIndexLastChangedSeq = 0;\n\t}\n}\n"]}
@@ -149,7 +149,7 @@ function addMovedMarkEffect(mark, effect) {
149
149
  else if ((0, utils_js_1.isTombstone)(mark)) {
150
150
  return { ...mark, ...effect };
151
151
  }
152
- (0, internal_1.assert)(false, 0x818 /* Unexpected combination of mark effects at source and destination */);
152
+ (0, internal_1.fail)(0x818 /* Unexpected combination of mark effects at source and destination */);
153
153
  }
154
154
  function rebaseMark(currMark, baseMark, rebaseChild, moveEffects) {
155
155
  const rebasedMark = rebaseNodeChange((0, utils_js_1.cloneMark)(currMark), baseMark, rebaseChild);