@fluid-experimental/tree 0.58.2002 → 0.59.1000

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 (817) hide show
  1. package/README.md +159 -46
  2. package/dist/ChangeCompression.d.ts +39 -0
  3. package/dist/ChangeCompression.d.ts.map +1 -0
  4. package/dist/ChangeCompression.js +117 -0
  5. package/dist/ChangeCompression.js.map +1 -0
  6. package/{lib/default-edits/PersistedTypes.d.ts → dist/ChangeTypes.d.ts} +58 -105
  7. package/dist/ChangeTypes.d.ts.map +1 -0
  8. package/dist/{default-edits/PersistedTypes.js → ChangeTypes.js} +21 -76
  9. package/dist/ChangeTypes.js.map +1 -0
  10. package/dist/Checkout.d.ts +39 -27
  11. package/dist/Checkout.d.ts.map +1 -1
  12. package/dist/Checkout.js +61 -32
  13. package/dist/Checkout.js.map +1 -1
  14. package/dist/Common.d.ts +175 -38
  15. package/dist/Common.d.ts.map +1 -1
  16. package/dist/Common.js +240 -103
  17. package/dist/Common.js.map +1 -1
  18. package/dist/EagerCheckout.d.ts +24 -0
  19. package/dist/EagerCheckout.d.ts.map +1 -0
  20. package/dist/{BasicCheckout.js → EagerCheckout.js} +9 -6
  21. package/dist/EagerCheckout.js.map +1 -0
  22. package/dist/EditLog.d.ts +77 -63
  23. package/dist/EditLog.d.ts.map +1 -1
  24. package/dist/EditLog.js +85 -48
  25. package/dist/EditLog.js.map +1 -1
  26. package/dist/EditUtilities.d.ts +168 -0
  27. package/dist/EditUtilities.d.ts.map +1 -0
  28. package/dist/EditUtilities.js +373 -0
  29. package/dist/EditUtilities.js.map +1 -0
  30. package/dist/EventTypes.d.ts +73 -0
  31. package/dist/EventTypes.d.ts.map +1 -0
  32. package/dist/EventTypes.js +78 -0
  33. package/dist/EventTypes.js.map +1 -0
  34. package/dist/Forest.d.ts +29 -7
  35. package/dist/Forest.d.ts.map +1 -1
  36. package/dist/Forest.js +60 -36
  37. package/dist/Forest.js.map +1 -1
  38. package/dist/HistoryEditFactory.d.ts +20 -0
  39. package/dist/HistoryEditFactory.d.ts.map +1 -0
  40. package/dist/HistoryEditFactory.js +226 -0
  41. package/dist/HistoryEditFactory.js.map +1 -0
  42. package/dist/IdConversion.d.ts +12 -0
  43. package/dist/IdConversion.d.ts.map +1 -0
  44. package/dist/IdConversion.js +98 -0
  45. package/dist/IdConversion.js.map +1 -0
  46. package/dist/Identifiers.d.ts +89 -2
  47. package/dist/Identifiers.d.ts.map +1 -1
  48. package/dist/Identifiers.js +10 -0
  49. package/dist/Identifiers.js.map +1 -1
  50. package/dist/InitialTree.d.ts +2 -2
  51. package/dist/InitialTree.d.ts.map +1 -1
  52. package/dist/InitialTree.js +2 -1
  53. package/dist/InitialTree.js.map +1 -1
  54. package/dist/LazyCheckout.d.ts +28 -0
  55. package/dist/LazyCheckout.d.ts.map +1 -0
  56. package/dist/LazyCheckout.js +44 -0
  57. package/dist/LazyCheckout.js.map +1 -0
  58. package/dist/LogViewer.d.ts +129 -85
  59. package/dist/LogViewer.d.ts.map +1 -1
  60. package/dist/LogViewer.js +111 -85
  61. package/dist/LogViewer.js.map +1 -1
  62. package/dist/MergeHealth.d.ts +221 -0
  63. package/dist/MergeHealth.d.ts.map +1 -0
  64. package/dist/MergeHealth.js +263 -0
  65. package/dist/MergeHealth.js.map +1 -0
  66. package/dist/NodeIdUtilities.d.ts +105 -0
  67. package/dist/NodeIdUtilities.d.ts.map +1 -0
  68. package/dist/NodeIdUtilities.js +60 -0
  69. package/dist/NodeIdUtilities.js.map +1 -0
  70. package/dist/PayloadUtilities.d.ts +42 -0
  71. package/dist/PayloadUtilities.d.ts.map +1 -0
  72. package/dist/PayloadUtilities.js +114 -0
  73. package/dist/PayloadUtilities.js.map +1 -0
  74. package/dist/ReconciliationPath.d.ts +18 -13
  75. package/dist/ReconciliationPath.d.ts.map +1 -1
  76. package/dist/ReconciliationPath.js.map +1 -1
  77. package/dist/RevisionValueCache.d.ts +11 -2
  78. package/dist/RevisionValueCache.d.ts.map +1 -1
  79. package/dist/RevisionValueCache.js +2 -3
  80. package/dist/RevisionValueCache.js.map +1 -1
  81. package/dist/RevisionView.d.ts +83 -0
  82. package/dist/RevisionView.d.ts.map +1 -0
  83. package/dist/RevisionView.js +182 -0
  84. package/dist/RevisionView.js.map +1 -0
  85. package/dist/SerializationUtilities.d.ts +36 -0
  86. package/dist/SerializationUtilities.d.ts.map +1 -0
  87. package/dist/SerializationUtilities.js +102 -0
  88. package/dist/SerializationUtilities.js.map +1 -0
  89. package/dist/SharedTree.d.ts +439 -0
  90. package/dist/SharedTree.d.ts.map +1 -0
  91. package/dist/SharedTree.js +1109 -0
  92. package/dist/SharedTree.js.map +1 -0
  93. package/dist/SharedTreeEncoder.d.ts +102 -0
  94. package/dist/SharedTreeEncoder.d.ts.map +1 -0
  95. package/dist/SharedTreeEncoder.js +313 -0
  96. package/dist/SharedTreeEncoder.js.map +1 -0
  97. package/dist/StringInterner.d.ts +46 -0
  98. package/dist/StringInterner.d.ts.map +1 -0
  99. package/dist/StringInterner.js +61 -0
  100. package/dist/StringInterner.js.map +1 -0
  101. package/dist/Summary.d.ts +40 -0
  102. package/dist/Summary.d.ts.map +1 -0
  103. package/dist/Summary.js +23 -0
  104. package/dist/Summary.js.map +1 -0
  105. package/dist/SummaryBackCompatibility.d.ts +22 -22
  106. package/dist/SummaryBackCompatibility.d.ts.map +1 -1
  107. package/dist/SummaryBackCompatibility.js +30 -33
  108. package/dist/SummaryBackCompatibility.js.map +1 -1
  109. package/dist/SummaryTestUtilities.d.ts +31 -0
  110. package/dist/SummaryTestUtilities.d.ts.map +1 -0
  111. package/dist/SummaryTestUtilities.js +37 -0
  112. package/dist/SummaryTestUtilities.js.map +1 -0
  113. package/dist/Transaction.d.ts +52 -0
  114. package/dist/Transaction.d.ts.map +1 -0
  115. package/dist/Transaction.js +72 -0
  116. package/dist/Transaction.js.map +1 -0
  117. package/dist/TransactionInternal.d.ts +540 -0
  118. package/dist/TransactionInternal.d.ts.map +1 -0
  119. package/dist/TransactionInternal.js +626 -0
  120. package/dist/TransactionInternal.js.map +1 -0
  121. package/dist/TreeCompressor.d.ts +36 -0
  122. package/dist/TreeCompressor.d.ts.map +1 -0
  123. package/dist/TreeCompressor.js +137 -0
  124. package/dist/TreeCompressor.js.map +1 -0
  125. package/dist/TreeNodeHandle.d.ts +12 -18
  126. package/dist/TreeNodeHandle.d.ts.map +1 -1
  127. package/dist/TreeNodeHandle.js +13 -23
  128. package/dist/TreeNodeHandle.js.map +1 -1
  129. package/dist/TreeView.d.ts +166 -0
  130. package/dist/TreeView.d.ts.map +1 -0
  131. package/dist/TreeView.js +218 -0
  132. package/dist/TreeView.js.map +1 -0
  133. package/dist/TreeViewUtilities.d.ts +21 -0
  134. package/dist/TreeViewUtilities.d.ts.map +1 -0
  135. package/dist/TreeViewUtilities.js +77 -0
  136. package/dist/TreeViewUtilities.js.map +1 -0
  137. package/dist/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
  138. package/dist/UndoRedoHandler.d.ts.map +1 -0
  139. package/dist/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +5 -9
  140. package/dist/UndoRedoHandler.js.map +1 -0
  141. package/dist/id-compressor/AppendOnlySortedMap.d.ts +127 -0
  142. package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
  143. package/dist/id-compressor/AppendOnlySortedMap.js +283 -0
  144. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -0
  145. package/dist/id-compressor/IdCompressor.d.ts +389 -0
  146. package/dist/id-compressor/IdCompressor.d.ts.map +1 -0
  147. package/dist/id-compressor/IdCompressor.js +1353 -0
  148. package/dist/id-compressor/IdCompressor.js.map +1 -0
  149. package/dist/id-compressor/IdRange.d.ts +11 -0
  150. package/dist/id-compressor/IdRange.d.ts.map +1 -0
  151. package/dist/id-compressor/IdRange.js +29 -0
  152. package/dist/id-compressor/IdRange.js.map +1 -0
  153. package/dist/id-compressor/NumericUuid.d.ts +63 -0
  154. package/dist/id-compressor/NumericUuid.d.ts.map +1 -0
  155. package/dist/id-compressor/NumericUuid.js +377 -0
  156. package/dist/id-compressor/NumericUuid.js.map +1 -0
  157. package/dist/id-compressor/index.d.ts +12 -0
  158. package/dist/id-compressor/index.d.ts.map +1 -0
  159. package/dist/id-compressor/index.js +26 -0
  160. package/dist/id-compressor/index.js.map +1 -0
  161. package/dist/id-compressor/persisted-types/0.0.1.d.ts +156 -0
  162. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
  163. package/dist/id-compressor/persisted-types/0.0.1.js +7 -0
  164. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -0
  165. package/dist/id-compressor/persisted-types/index.d.ts +6 -0
  166. package/dist/id-compressor/persisted-types/index.d.ts.map +1 -0
  167. package/dist/id-compressor/persisted-types/index.js +18 -0
  168. package/dist/id-compressor/persisted-types/index.js.map +1 -0
  169. package/dist/index.d.ts +29 -9
  170. package/dist/index.d.ts.map +1 -1
  171. package/dist/index.js +50 -35
  172. package/dist/index.js.map +1 -1
  173. package/dist/persisted-types/0.0.2.d.ts +385 -0
  174. package/dist/persisted-types/0.0.2.d.ts.map +1 -0
  175. package/dist/persisted-types/0.0.2.js +113 -0
  176. package/dist/persisted-types/0.0.2.js.map +1 -0
  177. package/dist/persisted-types/0.1.1.d.ts +314 -0
  178. package/dist/persisted-types/0.1.1.d.ts.map +1 -0
  179. package/dist/persisted-types/0.1.1.js +153 -0
  180. package/dist/persisted-types/0.1.1.js.map +1 -0
  181. package/dist/persisted-types/index.d.ts +7 -0
  182. package/dist/persisted-types/index.d.ts.map +1 -0
  183. package/dist/persisted-types/index.js +20 -0
  184. package/dist/persisted-types/index.js.map +1 -0
  185. package/docs/0-1-1-Compression.md +228 -0
  186. package/docs/Breaking-Change-Migration.md +52 -0
  187. package/docs/Compression.md +2 -2
  188. package/docs/Telemetry.md +43 -0
  189. package/docs/Write-Format.md +19 -0
  190. package/lib/ChangeCompression.d.ts +39 -0
  191. package/lib/ChangeCompression.d.ts.map +1 -0
  192. package/lib/ChangeCompression.js +111 -0
  193. package/lib/ChangeCompression.js.map +1 -0
  194. package/{dist/default-edits/PersistedTypes.d.ts → lib/ChangeTypes.d.ts} +58 -105
  195. package/lib/ChangeTypes.d.ts.map +1 -0
  196. package/lib/{default-edits/PersistedTypes.js → ChangeTypes.js} +15 -68
  197. package/lib/ChangeTypes.js.map +1 -0
  198. package/lib/Checkout.d.ts +39 -27
  199. package/lib/Checkout.d.ts.map +1 -1
  200. package/lib/Checkout.js +53 -24
  201. package/lib/Checkout.js.map +1 -1
  202. package/lib/Common.d.ts +175 -38
  203. package/lib/Common.d.ts.map +1 -1
  204. package/lib/Common.js +226 -101
  205. package/lib/Common.js.map +1 -1
  206. package/lib/EagerCheckout.d.ts +24 -0
  207. package/lib/EagerCheckout.d.ts.map +1 -0
  208. package/lib/{BasicCheckout.js → EagerCheckout.js} +7 -4
  209. package/lib/EagerCheckout.js.map +1 -0
  210. package/lib/EditLog.d.ts +77 -63
  211. package/lib/EditLog.d.ts.map +1 -1
  212. package/lib/EditLog.js +83 -47
  213. package/lib/EditLog.js.map +1 -1
  214. package/lib/EditUtilities.d.ts +168 -0
  215. package/lib/EditUtilities.d.ts.map +1 -0
  216. package/lib/EditUtilities.js +353 -0
  217. package/lib/EditUtilities.js.map +1 -0
  218. package/lib/EventTypes.d.ts +73 -0
  219. package/lib/EventTypes.d.ts.map +1 -0
  220. package/lib/EventTypes.js +75 -0
  221. package/lib/EventTypes.js.map +1 -0
  222. package/lib/Forest.d.ts +29 -7
  223. package/lib/Forest.d.ts.map +1 -1
  224. package/lib/Forest.js +58 -35
  225. package/lib/Forest.js.map +1 -1
  226. package/lib/HistoryEditFactory.d.ts +20 -0
  227. package/lib/HistoryEditFactory.d.ts.map +1 -0
  228. package/lib/{default-edits/HistoryEditFactory.js → HistoryEditFactory.js} +78 -39
  229. package/lib/HistoryEditFactory.js.map +1 -0
  230. package/lib/IdConversion.d.ts +12 -0
  231. package/lib/IdConversion.d.ts.map +1 -0
  232. package/lib/IdConversion.js +91 -0
  233. package/lib/IdConversion.js.map +1 -0
  234. package/lib/Identifiers.d.ts +89 -2
  235. package/lib/Identifiers.d.ts.map +1 -1
  236. package/lib/Identifiers.js +8 -1
  237. package/lib/Identifiers.js.map +1 -1
  238. package/lib/InitialTree.d.ts +2 -2
  239. package/lib/InitialTree.d.ts.map +1 -1
  240. package/lib/InitialTree.js +2 -1
  241. package/lib/InitialTree.js.map +1 -1
  242. package/lib/LazyCheckout.d.ts +28 -0
  243. package/lib/LazyCheckout.d.ts.map +1 -0
  244. package/lib/LazyCheckout.js +40 -0
  245. package/lib/LazyCheckout.js.map +1 -0
  246. package/lib/LogViewer.d.ts +129 -85
  247. package/lib/LogViewer.d.ts.map +1 -1
  248. package/lib/LogViewer.js +103 -77
  249. package/lib/LogViewer.js.map +1 -1
  250. package/lib/MergeHealth.d.ts +221 -0
  251. package/lib/MergeHealth.d.ts.map +1 -0
  252. package/lib/MergeHealth.js +258 -0
  253. package/lib/MergeHealth.js.map +1 -0
  254. package/lib/NodeIdUtilities.d.ts +105 -0
  255. package/lib/NodeIdUtilities.d.ts.map +1 -0
  256. package/lib/NodeIdUtilities.js +53 -0
  257. package/lib/NodeIdUtilities.js.map +1 -0
  258. package/lib/PayloadUtilities.d.ts +42 -0
  259. package/lib/PayloadUtilities.d.ts.map +1 -0
  260. package/lib/PayloadUtilities.js +110 -0
  261. package/lib/PayloadUtilities.js.map +1 -0
  262. package/lib/ReconciliationPath.d.ts +18 -13
  263. package/lib/ReconciliationPath.d.ts.map +1 -1
  264. package/lib/ReconciliationPath.js.map +1 -1
  265. package/lib/RevisionValueCache.d.ts +11 -2
  266. package/lib/RevisionValueCache.d.ts.map +1 -1
  267. package/lib/RevisionValueCache.js +2 -3
  268. package/lib/RevisionValueCache.js.map +1 -1
  269. package/lib/RevisionView.d.ts +83 -0
  270. package/lib/RevisionView.d.ts.map +1 -0
  271. package/lib/RevisionView.js +175 -0
  272. package/lib/RevisionView.js.map +1 -0
  273. package/lib/SerializationUtilities.d.ts +36 -0
  274. package/lib/SerializationUtilities.d.ts.map +1 -0
  275. package/lib/SerializationUtilities.js +95 -0
  276. package/lib/SerializationUtilities.js.map +1 -0
  277. package/lib/SharedTree.d.ts +439 -0
  278. package/lib/SharedTree.d.ts.map +1 -0
  279. package/lib/SharedTree.js +1104 -0
  280. package/lib/SharedTree.js.map +1 -0
  281. package/lib/SharedTreeEncoder.d.ts +102 -0
  282. package/lib/SharedTreeEncoder.d.ts.map +1 -0
  283. package/lib/SharedTreeEncoder.js +308 -0
  284. package/lib/SharedTreeEncoder.js.map +1 -0
  285. package/lib/StringInterner.d.ts +46 -0
  286. package/lib/StringInterner.d.ts.map +1 -0
  287. package/lib/StringInterner.js +57 -0
  288. package/lib/StringInterner.js.map +1 -0
  289. package/lib/Summary.d.ts +40 -0
  290. package/lib/Summary.d.ts.map +1 -0
  291. package/lib/Summary.js +19 -0
  292. package/lib/Summary.js.map +1 -0
  293. package/lib/SummaryBackCompatibility.d.ts +22 -22
  294. package/lib/SummaryBackCompatibility.d.ts.map +1 -1
  295. package/lib/SummaryBackCompatibility.js +29 -32
  296. package/lib/SummaryBackCompatibility.js.map +1 -1
  297. package/lib/SummaryTestUtilities.d.ts +31 -0
  298. package/lib/SummaryTestUtilities.d.ts.map +1 -0
  299. package/lib/SummaryTestUtilities.js +32 -0
  300. package/lib/SummaryTestUtilities.js.map +1 -0
  301. package/lib/Transaction.d.ts +52 -0
  302. package/lib/Transaction.d.ts.map +1 -0
  303. package/lib/Transaction.js +68 -0
  304. package/lib/Transaction.js.map +1 -0
  305. package/lib/TransactionInternal.d.ts +540 -0
  306. package/lib/TransactionInternal.d.ts.map +1 -0
  307. package/lib/TransactionInternal.js +622 -0
  308. package/lib/TransactionInternal.js.map +1 -0
  309. package/lib/TreeCompressor.d.ts +36 -0
  310. package/lib/TreeCompressor.d.ts.map +1 -0
  311. package/lib/TreeCompressor.js +133 -0
  312. package/lib/TreeCompressor.js.map +1 -0
  313. package/lib/TreeNodeHandle.d.ts +12 -18
  314. package/lib/TreeNodeHandle.d.ts.map +1 -1
  315. package/lib/TreeNodeHandle.js +14 -24
  316. package/lib/TreeNodeHandle.js.map +1 -1
  317. package/lib/TreeView.d.ts +166 -0
  318. package/lib/TreeView.d.ts.map +1 -0
  319. package/lib/TreeView.js +214 -0
  320. package/lib/TreeView.js.map +1 -0
  321. package/lib/TreeViewUtilities.d.ts +21 -0
  322. package/lib/TreeViewUtilities.d.ts.map +1 -0
  323. package/lib/TreeViewUtilities.js +71 -0
  324. package/lib/TreeViewUtilities.js.map +1 -0
  325. package/lib/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
  326. package/lib/UndoRedoHandler.d.ts.map +1 -0
  327. package/lib/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +3 -7
  328. package/lib/UndoRedoHandler.js.map +1 -0
  329. package/lib/id-compressor/AppendOnlySortedMap.d.ts +127 -0
  330. package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
  331. package/lib/id-compressor/AppendOnlySortedMap.js +278 -0
  332. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -0
  333. package/lib/id-compressor/IdCompressor.d.ts +389 -0
  334. package/lib/id-compressor/IdCompressor.d.ts.map +1 -0
  335. package/lib/id-compressor/IdCompressor.js +1343 -0
  336. package/lib/id-compressor/IdCompressor.js.map +1 -0
  337. package/lib/id-compressor/IdRange.d.ts +11 -0
  338. package/lib/id-compressor/IdRange.d.ts.map +1 -0
  339. package/lib/id-compressor/IdRange.js +25 -0
  340. package/lib/id-compressor/IdRange.js.map +1 -0
  341. package/lib/id-compressor/NumericUuid.d.ts +63 -0
  342. package/lib/id-compressor/NumericUuid.d.ts.map +1 -0
  343. package/lib/id-compressor/NumericUuid.js +365 -0
  344. package/lib/id-compressor/NumericUuid.js.map +1 -0
  345. package/lib/id-compressor/index.d.ts +12 -0
  346. package/lib/id-compressor/index.d.ts.map +1 -0
  347. package/lib/id-compressor/index.js +12 -0
  348. package/lib/id-compressor/index.js.map +1 -0
  349. package/lib/id-compressor/persisted-types/0.0.1.d.ts +156 -0
  350. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
  351. package/lib/{test/Snapshot.tests.d.ts → id-compressor/persisted-types/0.0.1.js} +1 -1
  352. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -0
  353. package/lib/id-compressor/persisted-types/index.d.ts +6 -0
  354. package/lib/id-compressor/persisted-types/index.d.ts.map +1 -0
  355. package/lib/id-compressor/persisted-types/index.js +6 -0
  356. package/lib/id-compressor/persisted-types/index.js.map +1 -0
  357. package/lib/index.d.ts +29 -9
  358. package/lib/index.d.ts.map +1 -1
  359. package/lib/index.js +23 -6
  360. package/lib/index.js.map +1 -1
  361. package/lib/persisted-types/0.0.2.d.ts +385 -0
  362. package/lib/persisted-types/0.0.2.d.ts.map +1 -0
  363. package/lib/persisted-types/0.0.2.js +110 -0
  364. package/lib/persisted-types/0.0.2.js.map +1 -0
  365. package/lib/persisted-types/0.1.1.d.ts +314 -0
  366. package/lib/persisted-types/0.1.1.d.ts.map +1 -0
  367. package/lib/persisted-types/0.1.1.js +150 -0
  368. package/lib/persisted-types/0.1.1.js.map +1 -0
  369. package/lib/persisted-types/index.d.ts +7 -0
  370. package/lib/persisted-types/index.d.ts.map +1 -0
  371. package/lib/persisted-types/index.js +8 -0
  372. package/lib/persisted-types/index.js.map +1 -0
  373. package/lib/test/AppendOnlySortedMap.tests.d.ts +6 -0
  374. package/lib/test/AppendOnlySortedMap.tests.d.ts.map +1 -0
  375. package/lib/test/AppendOnlySortedMap.tests.js +169 -0
  376. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -0
  377. package/lib/test/{SnapshotUtilities.tests.d.ts → ChangeCompression.tests.d.ts} +1 -1
  378. package/lib/test/ChangeCompression.tests.d.ts.map +1 -0
  379. package/lib/test/ChangeCompression.tests.js +145 -0
  380. package/lib/test/ChangeCompression.tests.js.map +1 -0
  381. package/lib/test/Checkout.tests.d.ts +2 -3
  382. package/lib/test/Checkout.tests.d.ts.map +1 -1
  383. package/lib/test/Checkout.tests.js +126 -69
  384. package/lib/test/Checkout.tests.js.map +1 -1
  385. package/lib/test/Common.tests.js +60 -2
  386. package/lib/test/Common.tests.js.map +1 -1
  387. package/lib/test/{BasicCheckout.tests.d.ts → EagerCheckout.tests.d.ts} +1 -1
  388. package/lib/test/EagerCheckout.tests.d.ts.map +1 -0
  389. package/lib/test/EagerCheckout.tests.js +20 -0
  390. package/lib/test/EagerCheckout.tests.js.map +1 -0
  391. package/lib/test/Edit.tests.js +22 -14
  392. package/lib/test/Edit.tests.js.map +1 -1
  393. package/lib/test/{Anchors.glassBox.tests.d.ts → EditLog.perf.tests.d.ts} +1 -1
  394. package/lib/test/EditLog.perf.tests.d.ts.map +1 -0
  395. package/lib/test/EditLog.perf.tests.js +30 -0
  396. package/lib/test/EditLog.perf.tests.js.map +1 -0
  397. package/lib/test/EditLog.tests.js +10 -6
  398. package/lib/test/EditLog.tests.js.map +1 -1
  399. package/lib/test/EditUtilities.tests.d.ts +6 -0
  400. package/lib/test/EditUtilities.tests.d.ts.map +1 -0
  401. package/lib/test/EditUtilities.tests.js +503 -0
  402. package/lib/test/EditUtilities.tests.js.map +1 -0
  403. package/lib/test/Forest.perf.tests.d.ts +6 -0
  404. package/lib/test/Forest.perf.tests.d.ts.map +1 -0
  405. package/lib/test/Forest.perf.tests.js +133 -0
  406. package/lib/test/Forest.perf.tests.js.map +1 -0
  407. package/lib/test/Forest.tests.js +54 -27
  408. package/lib/test/Forest.tests.js.map +1 -1
  409. package/lib/test/GenericTransaction.tests.js +12 -3
  410. package/lib/test/GenericTransaction.tests.js.map +1 -1
  411. package/lib/test/HistoryEditFactory.tests.d.ts +6 -0
  412. package/lib/test/HistoryEditFactory.tests.d.ts.map +1 -0
  413. package/lib/test/HistoryEditFactory.tests.js +90 -0
  414. package/lib/test/HistoryEditFactory.tests.js.map +1 -0
  415. package/lib/test/IdCompressor.perf.tests.d.ts +6 -0
  416. package/lib/test/IdCompressor.perf.tests.d.ts.map +1 -0
  417. package/lib/test/IdCompressor.perf.tests.js +304 -0
  418. package/lib/test/IdCompressor.perf.tests.js.map +1 -0
  419. package/lib/test/IdCompressor.tests.d.ts +6 -0
  420. package/lib/test/IdCompressor.tests.d.ts.map +1 -0
  421. package/lib/test/IdCompressor.tests.js +1075 -0
  422. package/lib/test/IdCompressor.tests.js.map +1 -0
  423. package/lib/test/IdConversion.tests.d.ts +6 -0
  424. package/lib/test/IdConversion.tests.d.ts.map +1 -0
  425. package/lib/test/IdConversion.tests.js +36 -0
  426. package/lib/test/IdConversion.tests.js.map +1 -0
  427. package/lib/test/LazyCheckout.tests.d.ts +6 -0
  428. package/lib/test/LazyCheckout.tests.d.ts.map +1 -0
  429. package/lib/test/LazyCheckout.tests.js +22 -0
  430. package/lib/test/LazyCheckout.tests.js.map +1 -0
  431. package/lib/test/LogViewer.tests.js +276 -191
  432. package/lib/test/LogViewer.tests.js.map +1 -1
  433. package/lib/test/{SharedTreeWithAnchors.tests.d.ts → MergeHealthTelemetryHeartbeat.tests.d.ts} +1 -1
  434. package/lib/test/MergeHealthTelemetryHeartbeat.tests.d.ts.map +1 -0
  435. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +342 -0
  436. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -0
  437. package/lib/test/NumericUuid.perf.tests.d.ts +6 -0
  438. package/lib/test/NumericUuid.perf.tests.d.ts.map +1 -0
  439. package/lib/test/NumericUuid.perf.tests.js +68 -0
  440. package/lib/test/NumericUuid.perf.tests.js.map +1 -0
  441. package/lib/test/NumericUuid.tests.d.ts +6 -0
  442. package/lib/test/NumericUuid.tests.d.ts.map +1 -0
  443. package/lib/test/NumericUuid.tests.js +191 -0
  444. package/lib/test/NumericUuid.tests.js.map +1 -0
  445. package/lib/test/RevisionView.tests.d.ts +6 -0
  446. package/lib/test/RevisionView.tests.d.ts.map +1 -0
  447. package/lib/test/RevisionView.tests.js +133 -0
  448. package/lib/test/RevisionView.tests.js.map +1 -0
  449. package/lib/test/SharedTree.perf.tests.d.ts +6 -0
  450. package/lib/test/SharedTree.perf.tests.d.ts.map +1 -0
  451. package/lib/test/SharedTree.perf.tests.js +39 -0
  452. package/lib/test/SharedTree.perf.tests.js.map +1 -0
  453. package/lib/test/SharedTree.tests.js +15 -3
  454. package/lib/test/SharedTree.tests.js.map +1 -1
  455. package/lib/test/StringInterner.tests.d.ts +6 -0
  456. package/lib/test/StringInterner.tests.d.ts.map +1 -0
  457. package/lib/test/StringInterner.tests.js +71 -0
  458. package/lib/test/StringInterner.tests.js.map +1 -0
  459. package/lib/test/Summary.tests.d.ts +8 -0
  460. package/lib/test/Summary.tests.d.ts.map +1 -0
  461. package/lib/test/Summary.tests.js +407 -0
  462. package/lib/test/Summary.tests.js.map +1 -0
  463. package/lib/test/Transaction.tests.js +76 -330
  464. package/lib/test/Transaction.tests.js.map +1 -1
  465. package/lib/test/TransactionInternal.tests.d.ts +6 -0
  466. package/lib/test/TransactionInternal.tests.d.ts.map +1 -0
  467. package/lib/test/TransactionInternal.tests.js +568 -0
  468. package/lib/test/TransactionInternal.tests.js.map +1 -0
  469. package/lib/test/TreeCompression.tests.d.ts +6 -0
  470. package/lib/test/TreeCompression.tests.d.ts.map +1 -0
  471. package/lib/test/TreeCompression.tests.js +292 -0
  472. package/lib/test/TreeCompression.tests.js.map +1 -0
  473. package/lib/test/TreeView.tests.d.ts +6 -0
  474. package/lib/test/TreeView.tests.d.ts.map +1 -0
  475. package/lib/test/TreeView.tests.js +176 -0
  476. package/lib/test/TreeView.tests.js.map +1 -0
  477. package/lib/test/UndoRedoHandler.tests.js +2 -2
  478. package/lib/test/UndoRedoHandler.tests.js.map +1 -1
  479. package/lib/test/Virtualization.tests.js +146 -62
  480. package/lib/test/Virtualization.tests.js.map +1 -1
  481. package/lib/test/fuzz/Generators.d.ts +19 -0
  482. package/lib/test/fuzz/Generators.d.ts.map +1 -0
  483. package/lib/test/fuzz/Generators.js +420 -0
  484. package/lib/test/fuzz/Generators.js.map +1 -0
  485. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +20 -0
  486. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -0
  487. package/lib/test/fuzz/SharedTreeFuzzTests.js +217 -0
  488. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -0
  489. package/lib/test/fuzz/Types.d.ts +133 -0
  490. package/lib/test/fuzz/Types.d.ts.map +1 -0
  491. package/lib/test/{GenericTransactionWithAnchors.tests.d.ts → fuzz/Types.js} +2 -2
  492. package/lib/test/fuzz/Types.js.map +1 -0
  493. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +180 -0
  494. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -0
  495. package/lib/test/utilities/IdCompressorTestUtilities.js +528 -0
  496. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -0
  497. package/lib/test/utilities/MockTransaction.d.ts +26 -7
  498. package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
  499. package/lib/test/utilities/MockTransaction.js +40 -11
  500. package/lib/test/utilities/MockTransaction.js.map +1 -1
  501. package/lib/test/utilities/PendingLocalStateTests.d.ts +12 -0
  502. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -0
  503. package/lib/test/utilities/PendingLocalStateTests.js +105 -0
  504. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -0
  505. package/lib/test/utilities/SharedTreeTests.d.ts +3 -4
  506. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  507. package/lib/test/utilities/SharedTreeTests.js +696 -439
  508. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  509. package/lib/test/utilities/SharedTreeVersioningTests.d.ts +11 -0
  510. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -0
  511. package/lib/test/utilities/SharedTreeVersioningTests.js +370 -0
  512. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -0
  513. package/lib/test/utilities/SummaryLoadPerfTests.d.ts +10 -0
  514. package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -0
  515. package/lib/test/utilities/SummaryLoadPerfTests.js +102 -0
  516. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -0
  517. package/lib/test/utilities/SummarySizeTests.d.ts +11 -0
  518. package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -0
  519. package/lib/test/utilities/SummarySizeTests.js +158 -0
  520. package/lib/test/utilities/SummarySizeTests.js.map +1 -0
  521. package/lib/test/utilities/TestCommon.d.ts +9 -0
  522. package/lib/test/utilities/TestCommon.d.ts.map +1 -0
  523. package/lib/test/utilities/TestCommon.js +13 -0
  524. package/lib/test/utilities/TestCommon.js.map +1 -0
  525. package/lib/test/utilities/TestNode.d.ts +140 -0
  526. package/lib/test/utilities/TestNode.d.ts.map +1 -0
  527. package/lib/test/utilities/TestNode.js +292 -0
  528. package/lib/test/utilities/TestNode.js.map +1 -0
  529. package/lib/test/utilities/TestUtilities.d.ts +84 -70
  530. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  531. package/lib/test/utilities/TestUtilities.js +218 -143
  532. package/lib/test/utilities/TestUtilities.js.map +1 -1
  533. package/lib/test/utilities/UndoRedoTests.d.ts +4 -5
  534. package/lib/test/utilities/UndoRedoTests.d.ts.map +1 -1
  535. package/lib/test/utilities/UndoRedoTests.js +138 -149
  536. package/lib/test/utilities/UndoRedoTests.js.map +1 -1
  537. package/package.json +22 -17
  538. package/src/ChangeCompression.ts +159 -0
  539. package/src/{default-edits/PersistedTypes.ts → ChangeTypes.ts} +62 -125
  540. package/src/Checkout.ts +82 -53
  541. package/src/Common.ts +317 -117
  542. package/src/EagerCheckout.ts +38 -0
  543. package/src/EditLog.ts +153 -100
  544. package/src/EditUtilities.ts +559 -0
  545. package/src/EventTypes.ts +74 -0
  546. package/src/Forest.ts +81 -73
  547. package/src/{default-edits/HistoryEditFactory.ts → HistoryEditFactory.ts} +103 -53
  548. package/src/IdConversion.ts +125 -0
  549. package/src/Identifiers.ts +101 -1
  550. package/src/InitialTree.ts +5 -4
  551. package/src/LazyCheckout.ts +51 -0
  552. package/src/LogViewer.ts +242 -166
  553. package/src/MergeHealth.ts +447 -0
  554. package/src/NodeIdUtilities.ts +156 -0
  555. package/src/PayloadUtilities.ts +124 -0
  556. package/src/ReconciliationPath.ts +18 -13
  557. package/src/RevisionValueCache.ts +14 -5
  558. package/src/RevisionView.ts +252 -0
  559. package/src/SerializationUtilities.ts +130 -0
  560. package/src/SharedTree.ts +1501 -0
  561. package/src/SharedTreeEncoder.ts +493 -0
  562. package/src/StringInterner.ts +72 -0
  563. package/src/Summary.ts +48 -0
  564. package/src/SummaryBackCompatibility.ts +47 -57
  565. package/src/SummaryTestUtilities.ts +54 -0
  566. package/src/Transaction.ts +89 -0
  567. package/src/TransactionInternal.ts +1087 -0
  568. package/src/TreeCompressor.ts +213 -0
  569. package/src/TreeNodeHandle.ts +19 -32
  570. package/src/TreeView.ts +322 -0
  571. package/src/TreeViewUtilities.ts +77 -0
  572. package/src/{default-edits/UndoRedoHandler.ts → UndoRedoHandler.ts} +8 -13
  573. package/src/id-compressor/AppendOnlySortedMap.ts +325 -0
  574. package/src/id-compressor/IdCompressor.md +3 -0
  575. package/src/id-compressor/IdCompressor.ts +1848 -0
  576. package/src/id-compressor/IdRange.ts +33 -0
  577. package/src/id-compressor/NumericUuid.ts +414 -0
  578. package/src/id-compressor/index.ts +13 -0
  579. package/src/id-compressor/persisted-types/0.0.1.ts +179 -0
  580. package/src/id-compressor/persisted-types/README.md +3 -0
  581. package/src/id-compressor/persisted-types/index.ts +6 -0
  582. package/src/index.ts +118 -59
  583. package/src/persisted-types/0.0.2.ts +442 -0
  584. package/src/persisted-types/0.1.1.ts +476 -0
  585. package/src/persisted-types/README.md +22 -0
  586. package/src/persisted-types/index.ts +9 -0
  587. package/.mocharc.js +0 -41
  588. package/api/tree.api.md +0 -729
  589. package/dist/BasicCheckout.d.ts +0 -23
  590. package/dist/BasicCheckout.d.ts.map +0 -1
  591. package/dist/BasicCheckout.js.map +0 -1
  592. package/dist/Snapshot.d.ts +0 -198
  593. package/dist/Snapshot.d.ts.map +0 -1
  594. package/dist/Snapshot.js +0 -267
  595. package/dist/Snapshot.js.map +0 -1
  596. package/dist/SnapshotUtilities.d.ts +0 -29
  597. package/dist/SnapshotUtilities.d.ts.map +0 -1
  598. package/dist/SnapshotUtilities.js +0 -73
  599. package/dist/SnapshotUtilities.js.map +0 -1
  600. package/dist/anchored-edits/AnchorResolution.d.ts +0 -144
  601. package/dist/anchored-edits/AnchorResolution.d.ts.map +0 -1
  602. package/dist/anchored-edits/AnchorResolution.js +0 -162
  603. package/dist/anchored-edits/AnchorResolution.js.map +0 -1
  604. package/dist/anchored-edits/Factory.d.ts +0 -56
  605. package/dist/anchored-edits/Factory.d.ts.map +0 -1
  606. package/dist/anchored-edits/Factory.js +0 -79
  607. package/dist/anchored-edits/Factory.js.map +0 -1
  608. package/dist/anchored-edits/PersistedTypes.d.ts +0 -245
  609. package/dist/anchored-edits/PersistedTypes.d.ts.map +0 -1
  610. package/dist/anchored-edits/PersistedTypes.js +0 -131
  611. package/dist/anchored-edits/PersistedTypes.js.map +0 -1
  612. package/dist/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
  613. package/dist/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
  614. package/dist/anchored-edits/SharedTreeWithAnchors.js +0 -115
  615. package/dist/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
  616. package/dist/anchored-edits/TransactionWithAnchors.d.ts +0 -28
  617. package/dist/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
  618. package/dist/anchored-edits/TransactionWithAnchors.js +0 -36
  619. package/dist/anchored-edits/TransactionWithAnchors.js.map +0 -1
  620. package/dist/anchored-edits/index.d.ts +0 -10
  621. package/dist/anchored-edits/index.d.ts.map +0 -1
  622. package/dist/anchored-edits/index.js +0 -34
  623. package/dist/anchored-edits/index.js.map +0 -1
  624. package/dist/default-edits/EditUtilities.d.ts +0 -57
  625. package/dist/default-edits/EditUtilities.d.ts.map +0 -1
  626. package/dist/default-edits/EditUtilities.js +0 -192
  627. package/dist/default-edits/EditUtilities.js.map +0 -1
  628. package/dist/default-edits/Factory.d.ts +0 -56
  629. package/dist/default-edits/Factory.d.ts.map +0 -1
  630. package/dist/default-edits/Factory.js +0 -79
  631. package/dist/default-edits/Factory.js.map +0 -1
  632. package/dist/default-edits/HistoryEditFactory.d.ts +0 -19
  633. package/dist/default-edits/HistoryEditFactory.d.ts.map +0 -1
  634. package/dist/default-edits/HistoryEditFactory.js +0 -187
  635. package/dist/default-edits/HistoryEditFactory.js.map +0 -1
  636. package/dist/default-edits/PersistedTypes.d.ts.map +0 -1
  637. package/dist/default-edits/PersistedTypes.js.map +0 -1
  638. package/dist/default-edits/SharedTree.d.ts +0 -111
  639. package/dist/default-edits/SharedTree.d.ts.map +0 -1
  640. package/dist/default-edits/SharedTree.js +0 -124
  641. package/dist/default-edits/SharedTree.js.map +0 -1
  642. package/dist/default-edits/Summary.d.ts +0 -15
  643. package/dist/default-edits/Summary.d.ts.map +0 -1
  644. package/dist/default-edits/Summary.js +0 -35
  645. package/dist/default-edits/Summary.js.map +0 -1
  646. package/dist/default-edits/Transaction.d.ts +0 -41
  647. package/dist/default-edits/Transaction.d.ts.map +0 -1
  648. package/dist/default-edits/Transaction.js +0 -225
  649. package/dist/default-edits/Transaction.js.map +0 -1
  650. package/dist/default-edits/UndoRedoHandler.d.ts.map +0 -1
  651. package/dist/default-edits/UndoRedoHandler.js.map +0 -1
  652. package/dist/default-edits/index.d.ts +0 -13
  653. package/dist/default-edits/index.d.ts.map +0 -1
  654. package/dist/default-edits/index.js +0 -41
  655. package/dist/default-edits/index.js.map +0 -1
  656. package/dist/generic/GenericEditUtilities.d.ts +0 -26
  657. package/dist/generic/GenericEditUtilities.d.ts.map +0 -1
  658. package/dist/generic/GenericEditUtilities.js +0 -45
  659. package/dist/generic/GenericEditUtilities.js.map +0 -1
  660. package/dist/generic/GenericSharedTree.d.ts +0 -221
  661. package/dist/generic/GenericSharedTree.d.ts.map +0 -1
  662. package/dist/generic/GenericSharedTree.js +0 -447
  663. package/dist/generic/GenericSharedTree.js.map +0 -1
  664. package/dist/generic/GenericTransaction.d.ts +0 -87
  665. package/dist/generic/GenericTransaction.d.ts.map +0 -1
  666. package/dist/generic/GenericTransaction.js +0 -144
  667. package/dist/generic/GenericTransaction.js.map +0 -1
  668. package/dist/generic/PersistedTypes.d.ts +0 -194
  669. package/dist/generic/PersistedTypes.d.ts.map +0 -1
  670. package/dist/generic/PersistedTypes.js +0 -42
  671. package/dist/generic/PersistedTypes.js.map +0 -1
  672. package/dist/generic/Summary.d.ts +0 -63
  673. package/dist/generic/Summary.d.ts.map +0 -1
  674. package/dist/generic/Summary.js +0 -64
  675. package/dist/generic/Summary.js.map +0 -1
  676. package/dist/generic/index.d.ts +0 -10
  677. package/dist/generic/index.d.ts.map +0 -1
  678. package/dist/generic/index.js +0 -26
  679. package/dist/generic/index.js.map +0 -1
  680. package/docs/Future.md +0 -155
  681. package/lib/BasicCheckout.d.ts +0 -23
  682. package/lib/BasicCheckout.d.ts.map +0 -1
  683. package/lib/BasicCheckout.js.map +0 -1
  684. package/lib/Snapshot.d.ts +0 -198
  685. package/lib/Snapshot.d.ts.map +0 -1
  686. package/lib/Snapshot.js +0 -263
  687. package/lib/Snapshot.js.map +0 -1
  688. package/lib/SnapshotUtilities.d.ts +0 -29
  689. package/lib/SnapshotUtilities.d.ts.map +0 -1
  690. package/lib/SnapshotUtilities.js +0 -67
  691. package/lib/SnapshotUtilities.js.map +0 -1
  692. package/lib/anchored-edits/AnchorResolution.d.ts +0 -144
  693. package/lib/anchored-edits/AnchorResolution.d.ts.map +0 -1
  694. package/lib/anchored-edits/AnchorResolution.js +0 -152
  695. package/lib/anchored-edits/AnchorResolution.js.map +0 -1
  696. package/lib/anchored-edits/Factory.d.ts +0 -56
  697. package/lib/anchored-edits/Factory.d.ts.map +0 -1
  698. package/lib/anchored-edits/Factory.js +0 -74
  699. package/lib/anchored-edits/Factory.js.map +0 -1
  700. package/lib/anchored-edits/PersistedTypes.d.ts +0 -245
  701. package/lib/anchored-edits/PersistedTypes.d.ts.map +0 -1
  702. package/lib/anchored-edits/PersistedTypes.js +0 -128
  703. package/lib/anchored-edits/PersistedTypes.js.map +0 -1
  704. package/lib/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
  705. package/lib/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
  706. package/lib/anchored-edits/SharedTreeWithAnchors.js +0 -110
  707. package/lib/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
  708. package/lib/anchored-edits/TransactionWithAnchors.d.ts +0 -28
  709. package/lib/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
  710. package/lib/anchored-edits/TransactionWithAnchors.js +0 -32
  711. package/lib/anchored-edits/TransactionWithAnchors.js.map +0 -1
  712. package/lib/anchored-edits/index.d.ts +0 -10
  713. package/lib/anchored-edits/index.d.ts.map +0 -1
  714. package/lib/anchored-edits/index.js +0 -11
  715. package/lib/anchored-edits/index.js.map +0 -1
  716. package/lib/default-edits/EditUtilities.d.ts +0 -57
  717. package/lib/default-edits/EditUtilities.d.ts.map +0 -1
  718. package/lib/default-edits/EditUtilities.js +0 -181
  719. package/lib/default-edits/EditUtilities.js.map +0 -1
  720. package/lib/default-edits/Factory.d.ts +0 -56
  721. package/lib/default-edits/Factory.d.ts.map +0 -1
  722. package/lib/default-edits/Factory.js +0 -74
  723. package/lib/default-edits/Factory.js.map +0 -1
  724. package/lib/default-edits/HistoryEditFactory.d.ts +0 -19
  725. package/lib/default-edits/HistoryEditFactory.d.ts.map +0 -1
  726. package/lib/default-edits/HistoryEditFactory.js.map +0 -1
  727. package/lib/default-edits/PersistedTypes.d.ts.map +0 -1
  728. package/lib/default-edits/PersistedTypes.js.map +0 -1
  729. package/lib/default-edits/SharedTree.d.ts +0 -111
  730. package/lib/default-edits/SharedTree.d.ts.map +0 -1
  731. package/lib/default-edits/SharedTree.js +0 -100
  732. package/lib/default-edits/SharedTree.js.map +0 -1
  733. package/lib/default-edits/Summary.d.ts +0 -15
  734. package/lib/default-edits/Summary.d.ts.map +0 -1
  735. package/lib/default-edits/Summary.js +0 -31
  736. package/lib/default-edits/Summary.js.map +0 -1
  737. package/lib/default-edits/Transaction.d.ts +0 -41
  738. package/lib/default-edits/Transaction.d.ts.map +0 -1
  739. package/lib/default-edits/Transaction.js +0 -221
  740. package/lib/default-edits/Transaction.js.map +0 -1
  741. package/lib/default-edits/UndoRedoHandler.d.ts.map +0 -1
  742. package/lib/default-edits/UndoRedoHandler.js.map +0 -1
  743. package/lib/default-edits/index.d.ts +0 -13
  744. package/lib/default-edits/index.d.ts.map +0 -1
  745. package/lib/default-edits/index.js +0 -14
  746. package/lib/default-edits/index.js.map +0 -1
  747. package/lib/generic/GenericEditUtilities.d.ts +0 -26
  748. package/lib/generic/GenericEditUtilities.d.ts.map +0 -1
  749. package/lib/generic/GenericEditUtilities.js +0 -38
  750. package/lib/generic/GenericEditUtilities.js.map +0 -1
  751. package/lib/generic/GenericSharedTree.d.ts +0 -221
  752. package/lib/generic/GenericSharedTree.d.ts.map +0 -1
  753. package/lib/generic/GenericSharedTree.js +0 -443
  754. package/lib/generic/GenericSharedTree.js.map +0 -1
  755. package/lib/generic/GenericTransaction.d.ts +0 -87
  756. package/lib/generic/GenericTransaction.d.ts.map +0 -1
  757. package/lib/generic/GenericTransaction.js +0 -140
  758. package/lib/generic/GenericTransaction.js.map +0 -1
  759. package/lib/generic/PersistedTypes.d.ts +0 -194
  760. package/lib/generic/PersistedTypes.d.ts.map +0 -1
  761. package/lib/generic/PersistedTypes.js +0 -39
  762. package/lib/generic/PersistedTypes.js.map +0 -1
  763. package/lib/generic/Summary.d.ts +0 -63
  764. package/lib/generic/Summary.d.ts.map +0 -1
  765. package/lib/generic/Summary.js +0 -58
  766. package/lib/generic/Summary.js.map +0 -1
  767. package/lib/generic/index.d.ts +0 -10
  768. package/lib/generic/index.d.ts.map +0 -1
  769. package/lib/generic/index.js +0 -11
  770. package/lib/generic/index.js.map +0 -1
  771. package/lib/test/Anchors.glassBox.tests.d.ts.map +0 -1
  772. package/lib/test/Anchors.glassBox.tests.js +0 -410
  773. package/lib/test/Anchors.glassBox.tests.js.map +0 -1
  774. package/lib/test/BasicCheckout.tests.d.ts.map +0 -1
  775. package/lib/test/BasicCheckout.tests.js +0 -8
  776. package/lib/test/BasicCheckout.tests.js.map +0 -1
  777. package/lib/test/GenericTransactionWithAnchors.tests.d.ts.map +0 -1
  778. package/lib/test/GenericTransactionWithAnchors.tests.js +0 -25
  779. package/lib/test/GenericTransactionWithAnchors.tests.js.map +0 -1
  780. package/lib/test/SharedTreeWithAnchors.tests.d.ts.map +0 -1
  781. package/lib/test/SharedTreeWithAnchors.tests.js +0 -420
  782. package/lib/test/SharedTreeWithAnchors.tests.js.map +0 -1
  783. package/lib/test/Snapshot.tests.d.ts.map +0 -1
  784. package/lib/test/Snapshot.tests.js +0 -96
  785. package/lib/test/Snapshot.tests.js.map +0 -1
  786. package/lib/test/SnapshotUtilities.tests.d.ts.map +0 -1
  787. package/lib/test/SnapshotUtilities.tests.js +0 -168
  788. package/lib/test/SnapshotUtilities.tests.js.map +0 -1
  789. package/lib/test/undoRedoStackManager.d.ts +0 -26
  790. package/lib/test/undoRedoStackManager.d.ts.map +0 -1
  791. package/lib/test/undoRedoStackManager.js +0 -176
  792. package/lib/test/undoRedoStackManager.js.map +0 -1
  793. package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts +0 -13
  794. package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts.map +0 -1
  795. package/lib/test/utilities/SummaryFormatCompatibilityTests.js +0 -154
  796. package/lib/test/utilities/SummaryFormatCompatibilityTests.js.map +0 -1
  797. package/src/BasicCheckout.ts +0 -34
  798. package/src/Snapshot.ts +0 -363
  799. package/src/SnapshotUtilities.ts +0 -88
  800. package/src/anchored-edits/AnchorResolution.ts +0 -442
  801. package/src/anchored-edits/Factory.ts +0 -94
  802. package/src/anchored-edits/PersistedTypes.ts +0 -310
  803. package/src/anchored-edits/SharedTreeWithAnchors.ts +0 -200
  804. package/src/anchored-edits/TransactionWithAnchors.ts +0 -39
  805. package/src/anchored-edits/index.ts +0 -21
  806. package/src/default-edits/EditUtilities.ts +0 -220
  807. package/src/default-edits/Factory.ts +0 -94
  808. package/src/default-edits/SharedTree.ts +0 -174
  809. package/src/default-edits/Summary.ts +0 -44
  810. package/src/default-edits/Transaction.ts +0 -262
  811. package/src/default-edits/index.ts +0 -29
  812. package/src/generic/GenericEditUtilities.ts +0 -46
  813. package/src/generic/GenericSharedTree.ts +0 -593
  814. package/src/generic/GenericTransaction.ts +0 -194
  815. package/src/generic/PersistedTypes.ts +0 -221
  816. package/src/generic/Summary.ts +0 -113
  817. package/src/generic/index.ts +0 -41
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAuE;AACvE,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA4IzB;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAM9B;;;OAGG;IACH,YAAmB,IAAkB,EAAE,MAAgC;QAN/D,SAAI,GAAG,IAAI,CAAC;QAOnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC/B,MAAM,EAAE,4BAAU,CAAC,OAAO;YAC1B,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;SACT,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAA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C;;WAEG;QACH,gDAAqB,CAAA;QACrB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,gDAAqB,CAAA;IACtB,CAAC,EAjBW,uBAAuB,GAAvB,2CAAuB,KAAvB,2CAAuB,QAiBlC;AACF,CAAC,EAvpBgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAupBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail, Result } from './Common';\nimport { NodeId, DetachedSequenceId, TraitLabel, isDetachedSequenceId } from './Identifiers';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintEffect,\n\tConstraintInternal,\n\tDetachInternal,\n\tEditStatus,\n\tInsertInternal,\n\tSetValueInternal,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n} from './persisted-types';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tBadPlaceValidationResult,\n\tBadRangeValidationResult,\n\tPlaceValidationResult,\n\tRangeValidationResultKind,\n} from './EditUtilities';\nimport { RevisionView, TransactionView } from './RevisionView';\nimport { ReconciliationChange, ReconciliationPath } from './ReconciliationPath';\nimport { TreeViewNode } from './TreeView';\n\n/**\n * Result of applying a transaction.\n * @public\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @public\n */\nexport interface EditingResultBase {\n\t/**\n\t * The final status of the transaction.\n\t */\n\treadonly status: EditStatus;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n\t/**\n\t * The revision preceding the transaction.\n\t */\n\treadonly before: RevisionView;\n}\n\n/**\n * Result of applying an invalid or malformed transaction.\n * @public\n */\nexport interface FailedEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * Result of applying a valid transaction.\n * @public\n */\nexport interface ValidEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The new revision produced by the transaction.\n\t */\n\treadonly after: RevisionView;\n}\n\n/**\n * The result of applying a change within a transaction.\n * @public\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @public\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n */\nexport interface SucceedingTransactionState {\n\t/**\n\t * The current status of the transaction.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The state of a transaction that has encountered an error.\n */\nexport interface FailingTransactionState extends TransactionFailure {\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The failure state of a transaction.\n */\nexport interface TransactionFailure {\n\t/**\n\t * The status indicating the kind of failure encountered.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class GenericTransaction {\n\tprivate readonly policy: GenericTransactionPolicy;\n\tprotected readonly before: RevisionView;\n\tprivate state: TransactionState;\n\tprivate open = true;\n\n\t/**\n\t * Create and open an edit of the provided `TreeView`. After applying 0 or more changes, this editor should be closed via `close()`.\n\t * @param view - the `TreeView` at which this edit begins. The first change will be applied against this view.\n\t */\n\tpublic constructor(view: RevisionView, policy: GenericTransactionPolicy) {\n\t\tthis.before = view;\n\t\tthis.policy = policy;\n\t\tthis.state = {\n\t\t\tview: view.openForTransaction(),\n\t\t\tstatus: EditStatus.Applied,\n\t\t\tchanges: [],\n\t\t\tsteps: [],\n\t\t};\n\t}\n\n\t/** Whether or not this transaction has been closed via `close()` */\n\tpublic get isOpen(): boolean {\n\t\treturn this.open;\n\t}\n\n\t/**\n\t * The most up-to-date `TreeView` for this edit. This is the state of the tree after all changes applied so far.\n\t */\n\tpublic get view(): TransactionView {\n\t\treturn this.state.view;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get status(): EditStatus {\n\t\treturn this.state.status;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get changes(): readonly ChangeInternal[] {\n\t\treturn this.state.changes;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get steps(): readonly ReconciliationChange[] {\n\t\treturn this.state.steps;\n\t}\n\n\t/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */\n\tpublic close(): EditingResult {\n\t\tassert(this.open, 'transaction has already been closed');\n\t\tthis.open = false;\n\t\tif (this.state.status === EditStatus.Applied) {\n\t\t\tconst validation = this.policy.validateOnClose(this.state);\n\t\t\tif (Result.isOk(validation)) {\n\t\t\t\tif (validation.result !== this.view) {\n\t\t\t\t\tthis.state = { ...this.state, view: validation.result };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tsteps: this.steps,\n\t\t\t\t\tchanges: this.changes,\n\t\t\t\t\tbefore: this.before,\n\t\t\t\t\tafter: this.view.close(),\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.state = { ...this.state, ...validation.error };\n\t\t\treturn {\n\t\t\t\t...validation.error,\n\t\t\t\tsteps: this.steps,\n\t\t\t\tchanges: this.changes,\n\t\t\t\tbefore: this.before,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: this.state.status,\n\t\t\tfailure: this.state.failure,\n\t\t\tsteps: this.steps,\n\t\t\tchanges: this.changes,\n\t\t\tbefore: this.before,\n\t\t};\n\t}\n\n\t/**\n\t * A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply,\n\t * the remaining changes in `changes` will be ignored.\n\t * @param changes - the sequence of changes to apply.\n\t * @param path - the reconciliation path for the first change.\n\t * @returns this\n\t */\n\tpublic applyChanges(changes: Iterable<ChangeInternal>, path: ReconciliationPath = []): this {\n\t\tconst iter = changes[Symbol.iterator]();\n\t\tconst firsChangeInternal = iter.next().value;\n\t\tlet iterResult = iter.next();\n\t\tif (iterResult.done === true) {\n\t\t\tfor (const change of changes) {\n\t\t\t\tif (this.applyChange(change, path).status !== EditStatus.Applied) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tif (this.applyChange(firsChangeInternal, path).status !== EditStatus.Applied) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst ongoingEdit = {\n\t\t\t0: this.steps[this.steps.length - 1],\n\t\t\tbefore: this.view,\n\t\t\tafter: this.view,\n\t\t\tlength: 1,\n\t\t};\n\n\t\t/**\n\t\t * We use a Proxy instead of `{ ...path, ...objectWithOngoingEdit }` to avoid eagerly demanding all parts of the path, which may\n\t\t * require extensive computation.\n\t\t */\n\t\tconst pathWithOngoingEdit = new Proxy(path, {\n\t\t\tget: (target: ReconciliationPath, prop: string): ReconciliationPath[number | 'length'] => {\n\t\t\t\tif (prop === 'length') {\n\t\t\t\t\treturn target.length + 1;\n\t\t\t\t}\n\t\t\t\treturn prop === String(target.length) ? ongoingEdit : target[prop];\n\t\t\t},\n\t\t});\n\n\t\twhile (iterResult.done !== true) {\n\t\t\tif (this.applyChange(iterResult.value, pathWithOngoingEdit).status !== EditStatus.Applied) {\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tongoingEdit[ongoingEdit.length] = this.steps[this.steps.length - 1];\n\t\t\tongoingEdit.length += 1;\n\t\t\tongoingEdit.after = this.view;\n\t\t\titerResult = iter.next();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to\n\t * apply.\n\t * @param change - the change to apply\n\t * @param path - the reconciliation path for the change.\n\t * @returns this\n\t */\n\tpublic applyChange(change: ChangeInternal, path: ReconciliationPath = []): this {\n\t\tassert(this.open, 'Editor must be open to apply changes.');\n\t\tif (this.state.status !== EditStatus.Applied) {\n\t\t\tfail('Cannot apply change to an edit unless all previous changes have applied');\n\t\t}\n\t\tconst resolutionResult = this.policy.tryResolveChange(this.state, change, path);\n\t\tif (Result.isError(resolutionResult)) {\n\t\t\tthis.state = { ...this.state, ...resolutionResult.error };\n\t\t\treturn this;\n\t\t}\n\t\tconst resolvedChange = resolutionResult.result;\n\t\tconst changeResult = this.policy.dispatchChange(this.state, resolvedChange);\n\t\tif (Result.isOk(changeResult)) {\n\t\t\tthis.state = {\n\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\tview: changeResult.result,\n\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t};\n\t\t} else {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\t...changeResult.error,\n\t\t\t};\n\t\t}\n\t\treturn this;\n\t}\n}\n\n/**\n * An object that encapsulates the rules and state pertaining to a specific subclass of {@link GenericTransaction}.\n * The characteristics that define such a subclass (and an implementation of this interface) are:\n * - The type of change that can be applied\n * - How those changes impact the state of the tree\n * - How those changes are resolved in the face of concurrent changes\n * - What makes a transaction valid\n * - The kind of situations that might lead to a transaction failure\n *\n * Instances of this type are passed to the {@link GenericTransaction} constructor.\n */\nexport interface GenericTransactionPolicy {\n\t/**\n\t * Given a change, attempts to derive an equivalent change which can be applied to the current state even if the given change was issued\n\t * over a different state. This can be used to apply a sequence of changes that were issued concurrently, i.e., without knowledge of\n\t * each other.\n\t * @param state - The current state on which the returned change will be applied.\n\t * @param change - The original change issued.\n\t * @param path - The reconciliation path for the change.\n\t * @returns The change to be applied to the current state, or a failure if the change cannot be resolved.\n\t */\n\ttryResolveChange(\n\t\tstate: SucceedingTransactionState,\n\t\tchange: ChangeInternal,\n\t\tpath: ReconciliationPath\n\t): Result<ChangeInternal, TransactionFailure>;\n\n\t/**\n\t * Provides a new state given the current state and a change to apply.\n\t * @param state - The current state on which the change is applied.\n\t * @param change - The change to apply to the current state.\n\t * @returns The new state reflecting the applied change, or a failure.\n\t */\n\tdispatchChange(state: SucceedingTransactionState, change: ChangeInternal): ChangeResult;\n\n\t/**\n\t * Additional transaction validation when the transaction is closed.\n\t * @param state - The current state of the transaction.\n\t * @returns The new state reflecting the closed transaction, or a failure if the transaction cannot be closed.\n\t */\n\tvalidateOnClose(state: SucceedingTransactionState): ChangeResult;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n * @public\n */\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t */\n\texport function factory(view: RevisionView): GenericTransaction {\n\t\treturn new GenericTransaction(view, new Policy());\n\t}\n\n\ttype ValidState = SucceedingTransactionState;\n\n\t/**\n\t * The policy followed by a {@link TransactionInternal}.\n\t */\n\texport class Policy implements GenericTransactionPolicy {\n\t\t/**\n\t\t * Maps detached sequences of nodes to their NodeIds\n\t\t */\n\t\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\t\t/**\n\t\t * Resolves change with Result.Ok\n\t\t *\n\t\t * @param state - Unused\n\t\t * @param change - Change to resolve\n\t\t * @returns Result.Ok which contains change\n\t\t */\n\t\tpublic tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal> {\n\t\t\treturn Result.ok(change);\n\t\t}\n\n\t\t/**\n\t\t * Validates the transaction when it is closed\n\t\t *\n\t\t * @param state - Current state\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic validateOnClose(state: ValidState): ChangeResult {\n\t\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\t\treturn this.detached.size !== 0\n\t\t\t\t? Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.UnusedDetachedSequence,\n\t\t\t\t\t\t\tsequenceId: this.detached.keys().next().value,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: Result.ok(state.view);\n\t\t}\n\n\t\t/**\n\t\t * Applies a given change\n\t\t *\n\t\t * @param state - Current state\n\t\t * @param change - Change to apply\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult {\n\t\t\tswitch (change.type) {\n\t\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\t\treturn this.applyBuild(state, change);\n\t\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\t\treturn this.applyInsert(state, change);\n\t\t\t\tcase ChangeTypeInternal.Detach:\n\t\t\t\t\treturn this.applyDetach(state, change);\n\t\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t\treturn this.applyConstraint(state, change);\n\t\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\t\treturn this.applySetValue(state, change);\n\t\t\t\tdefault:\n\t\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t\t}\n\t\t}\n\n\t\tprivate applyBuild(state: ValidState, change: BuildInternal): ChangeResult {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet idAlreadyPresent: NodeId | undefined;\n\t\t\tlet duplicateIdInBuild: NodeId | undefined;\n\t\t\tlet invalidId: NodeId | undefined;\n\t\t\tlet detachedSequenceNotFound: DetachedSequenceId | undefined;\n\t\t\tconst map = new Map<NodeId, TreeViewNode>();\n\t\t\tconst newIds = this.createViewNodesForTree(\n\t\t\t\tchange.source,\n\t\t\t\t(id, viewNode) => {\n\t\t\t\t\tif (map.has(id)) {\n\t\t\t\t\t\tduplicateIdInBuild = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.view.hasNode(viewNode.identifier)) {\n\t\t\t\t\t\tidAlreadyPresent = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tmap.set(id, viewNode);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\t(detachedId) => {\n\t\t\t\t\tdetachedSequenceNotFound = detachedId;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (idAlreadyPresent !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.IdAlreadyInUse, change, id: idAlreadyPresent },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (duplicateIdInBuild !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: { kind: FailureKind.DuplicateIdInBuild, change, id: duplicateIdInBuild },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (invalidId !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: invalidId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (detachedSequenceNotFound !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: detachedSequenceNotFound,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst view = state.view.addNodes(map.values());\n\t\t\tthis.detached.set(\n\t\t\t\tchange.destination,\n\t\t\t\tnewIds ?? fail('Unhandled failure case in Transaction.createViewNodesForTree')\n\t\t\t);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyInsert(state: ValidState, change: InsertInternal): ChangeResult {\n\t\t\tconst source = this.detached.get(change.source);\n\t\t\tif (source === undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.source,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst validatedDestination = validateStablePlace(state.view, change.destination);\n\t\t\tif (validatedDestination.result !== PlaceValidationResult.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedDestination.result === PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Malformed\n\t\t\t\t\t\t\t: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadPlace,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tplace: change.destination,\n\t\t\t\t\t\tplaceFailure: validatedDestination.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.detached.delete(change.source);\n\t\t\tconst view = insertIntoTrait(state.view, source, validatedDestination);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyDetach(state: ValidState, change: DetachInternal): ChangeResult {\n\t\t\tconst validatedSource = validateStableRange(state.view, change.source);\n\t\t\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.PlacesInDifferentTraits ||\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.Inverted ||\n\t\t\t\t\t\tvalidatedSource.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Invalid\n\t\t\t\t\t\t\t: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadRange,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\trange: change.source,\n\t\t\t\t\t\trangeFailure: validatedSource.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = detachRange(state.view, validatedSource);\n\t\t\tlet modifiedView = result.view;\n\t\t\tconst { detached } = result;\n\n\t\t\t// Store or dispose detached\n\t\t\tif (change.destination !== undefined) {\n\t\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\t\treturn Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\t\tchange,\n\t\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.detached.set(change.destination, detached);\n\t\t\t} else {\n\t\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t\t}\n\t\t\treturn Result.ok(modifiedView);\n\t\t}\n\n\t\tprivate applyConstraint(state: ValidState, change: ConstraintInternal): ChangeResult {\n\t\t\t// TODO: Implement identityHash and contentHash\n\t\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\t\tconst validatedChange = validateStableRange(state.view, change.toConstrain);\n\t\t\tif (validatedChange.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn validatedChange.result !== RangeValidationResultKind.PlacesInDifferentTraits &&\n\t\t\t\t\tvalidatedChange.result !== RangeValidationResultKind.Inverted &&\n\t\t\t\t\tvalidatedChange.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t? change.effect === ConstraintEffect.ValidRetry\n\t\t\t\t\t\t? Result.ok(state.view)\n\t\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t })\n\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t });\n\t\t\t}\n\n\t\t\tconst { start, end } = rangeFromStableRange(state.view, validatedChange);\n\t\t\tconst startIndex = state.view.findIndexWithinTrait(start);\n\t\t\tconst endIndex = state.view.findIndexWithinTrait(end);\n\n\t\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLength,\n\t\t\t\t\t\t\tactual: endIndex - startIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadParent,\n\t\t\t\t\t\t\tactual: change.parentNode,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLabel,\n\t\t\t\t\t\t\tactual: end.trait.label,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn Result.ok(state.view);\n\t\t}\n\n\t\tprivate applySetValue(state: ValidState, change: SetValueInternal): ChangeResult {\n\t\t\tif (!state.view.hasNode(change.nodeToModify)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: change.nodeToModify },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newView = state.view.setNodeValue(change.nodeToModify, change.payload);\n\t\t\treturn Result.ok(newView);\n\t\t}\n\n\t\t/**\n\t\t * Generates tree view nodes from the supplied edit nodes.\n\t\t * Invokes onCreateNode for each new node, and halts creation early if it returns true.\n\t\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t\t */\n\t\tprotected createViewNodesForTree(\n\t\t\tsequence: Iterable<BuildNodeInternal>,\n\t\t\tonCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): NodeId[] | undefined {\n\t\t\tconst topLevelIds: NodeId[] = [];\n\t\t\tconst unprocessed: BuildNodeInternal[] = [];\n\t\t\tfor (const buildNode of sequence) {\n\t\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t\t} else {\n\t\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (unprocessed.length > 0) {\n\t\t\t\tconst node = unprocessed.pop();\n\t\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tfor (const key in node.traits) {\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst newNode: TreeViewNode = {\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\ttraits,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\t\tif (onCreateNode(node.identifier, newNode)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn topLevelIds;\n\t\t}\n\n\t\tprivate getDetachedNodeIds(\n\t\t\tdetachedId: DetachedSequenceId,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): readonly NodeId[] | undefined {\n\t\t\t// Retrieve the detached sequence from the void.\n\t\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\t\tif (detachedNodeIds === undefined) {\n\t\t\t\tonInvalidDetachedId(detachedId);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\t\tthis.detached.delete(detachedId);\n\t\t\treturn detachedNodeIds;\n\t\t}\n\t}\n\n\t/**\n\t * The kinds of failures that a transaction might encounter.\n\t */\n\texport enum FailureKind {\n\t\t/**\n\t\t * Transaction has an unused DetachedSequenceId\n\t\t */\n\t\tUnusedDetachedSequence = 'UnusedDetachedSequence',\n\t\t/**\n\t\t * Transaction has a build operation using an already in use DetachedSequenceID.\n\t\t */\n\t\tDetachedSequenceIdAlreadyInUse = 'DetachedSequenceIdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to operate on an unknown DetachedSequenceID\n\t\t */\n\t\tDetachedSequenceNotFound = 'DetachedSequenceNotFound',\n\t\t/**\n\t\t * Transaction has a build which uses a duplicated NodeId\n\t\t */\n\t\tDuplicateIdInBuild = 'DuplicateIdInBuild',\n\t\t/**\n\t\t * Transaction tries to build a node using an ID which is already used in the current state\n\t\t */\n\t\tIdAlreadyInUse = 'IdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to set value of an unknown node\n\t\t */\n\t\tUnknownId = 'UnknownId',\n\t\t/**\n\t\t * Transaction tries to insert in an invalid Place\n\t\t */\n\t\tBadPlace = 'BadPlace',\n\t\t/**\n\t\t * Transaction tries to detach an invalid Range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * Transaction has an invalid constraint\n\t\t */\n\t\tConstraintViolation = 'ConstraintViolation',\n\t}\n\n\t/**\n\t * A failure encountered by a transaction.\n\t */\n\texport type Failure =\n\t\t| UnusedDetachedSequenceFailure\n\t\t| DetachedSequenceIdAlreadyInUseFailure\n\t\t| DetachedSequenceNotFoundFailure\n\t\t| DuplicateIdInBuildFailure\n\t\t| IdAlreadyInUseFailure\n\t\t| UnknownIdFailure\n\t\t| BadPlaceFailure\n\t\t| BadRangeFailure\n\t\t| ConstraintViolationFailure;\n\n\t/**\n\t * Error returned when a transaction is closed while there is an unused detached sequence.\n\t */\n\texport interface UnusedDetachedSequenceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnusedDetachedSequence)\n\t\t */\n\t\treadonly kind: FailureKind.UnusedDetachedSequence;\n\t\t/**\n\t\t * The unused DetachedSequenceId\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.\n\t */\n\texport interface DetachedSequenceIdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceIdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceIdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that is already in use\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID\n\t */\n\texport interface DetachedSequenceNotFoundFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceNotFound)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceNotFound;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that wasn't found\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a build uses a duplicated NodeId\n\t */\n\texport interface DuplicateIdInBuildFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DuplicateIdInBuild)\n\t\t */\n\t\treadonly kind: FailureKind.DuplicateIdInBuild;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of duplicated node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a build node ID is already used in the current state\n\t */\n\texport interface IdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.IdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.IdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of already in use node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a change is attempted on an unknown NodeId\n\t */\n\texport interface UnknownIdFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnknownId)\n\t\t */\n\t\treadonly kind: FailureKind.UnknownId;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The unknown ID\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when an insert change uses an invalid Place\n\t */\n\texport interface BadPlaceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadPlace)\n\t\t */\n\t\treadonly kind: FailureKind.BadPlace;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The faulting place\n\t\t */\n\t\treadonly place: StablePlaceInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly placeFailure: BadPlaceValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a detach operation is given an invalid or malformed Range\n\t */\n\texport interface BadRangeFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadRange)\n\t\t */\n\t\treadonly kind: FailureKind.BadRange;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * Faulting range\n\t\t */\n\t\treadonly range: StableRangeInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly rangeFailure: BadRangeValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a constraint fails to apply\n\t */\n\texport interface ConstraintViolationFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.ConstraintViolation)\n\t\t */\n\t\treadonly kind: FailureKind.ConstraintViolation;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly constraint: ConstraintInternal;\n\t\t/**\n\t\t * The first violation the constraint encounters (there may be others).\n\t\t */\n\t\treadonly violation: ConstraintViolationResult;\n\t}\n\n\t/**\n\t * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur\n\t */\n\texport type ConstraintViolationResult =\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadRange;\n\t\t\t\treadonly rangeFailure: BadRangeValidationResult;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLength;\n\t\t\t\treadonly actual: number;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadParent;\n\t\t\t\treadonly actual: NodeId;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLabel;\n\t\t\t\treadonly actual: TraitLabel;\n\t\t };\n\n\t/**\n\t * Enum of possible kinds of constraint violations that can be encountered\n\t */\n\texport enum ConstraintViolationKind {\n\t\t/**\n\t\t * The constraint failed because it applies to an invalid range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * The constraint failed because the length prescribed by the constraint does not match the length of range being constrained\n\t\t */\n\t\tBadLength = 'BadLength',\n\t\t/**\n\t\t * The constraint failed because the parent prescribed by the constraint does not match the actual parent of the range being constrained\n\t\t */\n\t\tBadParent = 'BadParent',\n\t\t/**\n\t\t * The constraint failed because the trait label prescribed by the constraint does not match the actual trait label of the range being constrained\n\t\t */\n\t\tBadLabel = 'BadLabel',\n\t}\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import type { DetachedSequenceId, OpSpaceNodeId } from './Identifiers';
2
+ import type { StringInterner } from './StringInterner';
3
+ import type { CompressedPlaceholderTree, PlaceholderTree } from './persisted-types';
4
+ import type { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';
5
+ /**
6
+ * Compresses a given {@link PlaceholderTree} into a more compact serializable format.
7
+ */
8
+ export interface TreeCompressor<TPlaceholder extends DetachedSequenceId | never> {
9
+ /**
10
+ * @param node - The {@link PlaceholderTree} to compress.
11
+ * @param interner - The StringInterner to use to intern strings.
12
+ * @param idNormalizer - A normalizer to transform node IDs into op-space
13
+ */
14
+ compress<TId extends OpSpaceNodeId>(node: PlaceholderTree<TPlaceholder>, interner: StringInterner, idNormalizer: ContextualizedNodeIdNormalizer<TId>): CompressedPlaceholderTree<TId, TPlaceholder>;
15
+ /**
16
+ * @param node - The {@link PlaceholderTree} to compress.
17
+ * @param interner - The StringInterner to use to intern strings.
18
+ * @param idNormalizer - A normalizer to transform node IDs into op-space
19
+ */
20
+ decompress<TId extends OpSpaceNodeId>(node: CompressedPlaceholderTree<TId, TPlaceholder>, interner: StringInterner, idNormalizer: ContextualizedNodeIdNormalizer<TId>): PlaceholderTree<TPlaceholder>;
21
+ }
22
+ /**
23
+ * Compresses a given {@link PlaceholderTree}
24
+ * (Such as a {@link ChangeNode} or {@link BuildNode}) into an array,
25
+ * while also string interning all node {@link Definition}s and {@link TraitLabel}s.
26
+ * See {@link CompressedPlaceholderTree} for format.
27
+ */
28
+ export declare class InterningTreeCompressor<TPlaceholder extends DetachedSequenceId | never> implements TreeCompressor<TPlaceholder> {
29
+ compress<TId extends OpSpaceNodeId>(node: PlaceholderTree<TPlaceholder>, interner: StringInterner, idNormalizer: ContextualizedNodeIdNormalizer<TId>): CompressedPlaceholderTree<TId, TPlaceholder>;
30
+ private compressI;
31
+ /** The ID that was compressed or decompressed most recently */
32
+ private previousId?;
33
+ decompress<TId extends OpSpaceNodeId>(node: CompressedPlaceholderTree<TId, TPlaceholder>, interner: StringInterner, idNormalizer: ContextualizedNodeIdNormalizer<TId>): PlaceholderTree<TPlaceholder>;
34
+ private decompressI;
35
+ }
36
+ //# sourceMappingURL=TreeCompressor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeCompressor.d.ts","sourceRoot":"","sources":["../src/TreeCompressor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,kBAAkB,EAAoB,aAAa,EAAc,MAAM,eAAe,CAAC;AACjH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAoB,yBAAyB,EAAE,eAAe,EAAW,MAAM,mBAAmB,CAAC;AAC/G,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAGxE;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,YAAY,SAAS,kBAAkB,GAAG,KAAK;IAC9E;;;;OAIG;IACH,QAAQ,CAAC,GAAG,SAAS,aAAa,EACjC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,EACnC,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,8BAA8B,CAAC,GAAG,CAAC,GAC/C,yBAAyB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEhD;;;;OAIG;IACH,UAAU,CAAC,GAAG,SAAS,aAAa,EACnC,IAAI,EAAE,yBAAyB,CAAC,GAAG,EAAE,YAAY,CAAC,EAClD,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,8BAA8B,CAAC,GAAG,CAAC,GAC/C,eAAe,CAAC,YAAY,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,qBAAa,uBAAuB,CAAC,YAAY,SAAS,kBAAkB,GAAG,KAAK,CACnF,YAAW,cAAc,CAAC,YAAY,CAAC;IAEhC,QAAQ,CAAC,GAAG,SAAS,aAAa,EACxC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,EACnC,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,8BAA8B,CAAC,GAAG,CAAC,GAC/C,yBAAyB,CAAC,GAAG,EAAE,YAAY,CAAC;IAK/C,OAAO,CAAC,SAAS;IAyCjB,+DAA+D;IAC/D,OAAO,CAAC,UAAU,CAAC,CAAgB;IAE5B,UAAU,CAAC,GAAG,SAAS,aAAa,EAC1C,IAAI,EAAE,yBAAyB,CAAC,GAAG,EAAE,YAAY,CAAC,EAClD,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,8BAA8B,CAAC,GAAG,CAAC,GAC/C,eAAe,CAAC,YAAY,CAAC;IAUhC,OAAO,CAAC,WAAW;CAqFnB"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InterningTreeCompressor = void 0;
4
+ /*!
5
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
+ * Licensed under the MIT License.
7
+ */
8
+ const Identifiers_1 = require("./Identifiers");
9
+ const Common_1 = require("./Common");
10
+ /**
11
+ * Compresses a given {@link PlaceholderTree}
12
+ * (Such as a {@link ChangeNode} or {@link BuildNode}) into an array,
13
+ * while also string interning all node {@link Definition}s and {@link TraitLabel}s.
14
+ * See {@link CompressedPlaceholderTree} for format.
15
+ */
16
+ class InterningTreeCompressor {
17
+ compress(node, interner, idNormalizer) {
18
+ this.previousId = undefined;
19
+ return this.compressI(node, interner, idNormalizer);
20
+ }
21
+ compressI(node, interner, idNormalizer) {
22
+ var _a, _b;
23
+ if (Identifiers_1.isDetachedSequenceId(node)) {
24
+ return node;
25
+ }
26
+ const internedDefinition = (_a = interner.getInternedId(node.definition)) !== null && _a !== void 0 ? _a : node.definition;
27
+ const normalizedId = idNormalizer.normalizeToOpSpace(node.identifier);
28
+ const compressedId = canElideId(this.previousId, normalizedId) ? undefined : normalizedId;
29
+ this.previousId = normalizedId;
30
+ const compressedTraits = [];
31
+ // Omit traits if empty and payload is undefined.
32
+ const traits = Object.entries(node.traits).sort();
33
+ if (traits.length > 0 || node.payload !== undefined) {
34
+ for (const [label, trait] of traits) {
35
+ compressedTraits.push((_b = interner.getInternedId(label)) !== null && _b !== void 0 ? _b : label, trait.map((child) => this.compressI(child, interner, idNormalizer)));
36
+ }
37
+ }
38
+ const payloadTraits = node.payload !== undefined ? [node.payload, ...compressedTraits] : compressedTraits;
39
+ if (payloadTraits.length > 0) {
40
+ if (compressedId !== undefined) {
41
+ return [internedDefinition, compressedId, payloadTraits];
42
+ }
43
+ return [internedDefinition, payloadTraits];
44
+ }
45
+ if (compressedId !== undefined) {
46
+ return [internedDefinition, compressedId];
47
+ }
48
+ return [internedDefinition];
49
+ }
50
+ decompress(node, interner, idNormalizer) {
51
+ if (Identifiers_1.isDetachedSequenceId(node)) {
52
+ return node;
53
+ }
54
+ const rootId = node[1];
55
+ Common_1.assert(typeof rootId === 'number', 'Root node was compressed with no ID');
56
+ this.previousId = rootId;
57
+ return this.decompressI(node, interner, idNormalizer);
58
+ }
59
+ decompressI(node, interner, idNormalizer) {
60
+ var _a;
61
+ if (Identifiers_1.isDetachedSequenceId(node)) {
62
+ return node;
63
+ }
64
+ let compressedId;
65
+ let compressedTraits;
66
+ let payload;
67
+ const [maybeInternedDefinition, idOrPayloadTraits, payloadTraits] = node;
68
+ if (idOrPayloadTraits !== undefined) {
69
+ if (typeof idOrPayloadTraits === 'number') {
70
+ compressedId = idOrPayloadTraits;
71
+ if (payloadTraits !== undefined) {
72
+ compressedTraits = payloadTraits;
73
+ }
74
+ }
75
+ else {
76
+ // TODO: This cast can be removed on typescript 4.6
77
+ compressedTraits = idOrPayloadTraits;
78
+ }
79
+ }
80
+ const definition = typeof maybeInternedDefinition === 'string'
81
+ ? maybeInternedDefinition
82
+ : // TODO: This cast can be removed on typescript 4.6
83
+ interner.getString(maybeInternedDefinition);
84
+ let identifier;
85
+ if (compressedId !== undefined) {
86
+ identifier = compressedId;
87
+ }
88
+ else {
89
+ const prevId = (_a = this.previousId) !== null && _a !== void 0 ? _a : Common_1.fail();
90
+ identifier = prevId < 0 ? (prevId - 1) : (prevId + 1);
91
+ }
92
+ this.previousId = identifier;
93
+ const traits = {};
94
+ if (compressedTraits !== undefined) {
95
+ let offset;
96
+ if (compressedTraits.length % 2 === 1) {
97
+ offset = 1;
98
+ payload = compressedTraits[0];
99
+ }
100
+ else {
101
+ offset = 0;
102
+ }
103
+ const traitsLength = compressedTraits.length - offset;
104
+ for (let i = 0; i < traitsLength; i += 2) {
105
+ const offsetIndex = i + offset;
106
+ const maybeCompressedLabel = compressedTraits[offsetIndex];
107
+ const compressedChildren = compressedTraits[offsetIndex + 1];
108
+ const decompressedTraits = compressedChildren.map((child) => this.decompressI(child, interner, idNormalizer));
109
+ const label = typeof maybeCompressedLabel === 'string'
110
+ ? maybeCompressedLabel
111
+ : interner.getString(maybeCompressedLabel);
112
+ traits[label] = decompressedTraits;
113
+ }
114
+ }
115
+ const decompressedNode = {
116
+ identifier: idNormalizer.normalizeToSessionSpace(identifier),
117
+ definition,
118
+ traits,
119
+ };
120
+ if (payload !== undefined) {
121
+ decompressedNode.payload = payload;
122
+ }
123
+ return decompressedNode;
124
+ }
125
+ }
126
+ exports.InterningTreeCompressor = InterningTreeCompressor;
127
+ function canElideId(previousId, id) {
128
+ if (previousId === undefined) {
129
+ return false;
130
+ }
131
+ const numericId = previousId;
132
+ if (numericId < 0) {
133
+ return id === numericId - 1;
134
+ }
135
+ return id === numericId +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AS,GAAG,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { isDetachedSequenceId } from './Identifiers';\nimport type { Definition, DetachedSequenceId, InternedStringId, OpSpaceNodeId, TraitLabel } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport type { CompressedTraits, CompressedPlaceholderTree, PlaceholderTree, Payload } from './persisted-types';\nimport type { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { assert, fail, Mutable } from './Common';\n\n/**\n * Compresses a given {@link PlaceholderTree} into a more compact serializable format.\n */\nexport interface TreeCompressor<TPlaceholder extends DetachedSequenceId | never> {\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tcompress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder>;\n\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tdecompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder>;\n}\n\n/**\n * Compresses a given {@link PlaceholderTree}\n * (Such as a {@link ChangeNode} or {@link BuildNode}) into an array,\n * while also string interning all node {@link Definition}s and {@link TraitLabel}s.\n * See {@link CompressedPlaceholderTree} for format.\n */\nexport class InterningTreeCompressor<TPlaceholder extends DetachedSequenceId | never>\n\timplements TreeCompressor<TPlaceholder>\n{\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tthis.previousId = undefined;\n\t\treturn this.compressI(node, interner, idNormalizer);\n\t}\n\n\tprivate compressI<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst internedDefinition = interner.getInternedId(node.definition) ?? node.definition;\n\t\tconst normalizedId = idNormalizer.normalizeToOpSpace(node.identifier);\n\t\tconst compressedId = canElideId(this.previousId, normalizedId) ? undefined : normalizedId;\n\t\tthis.previousId = normalizedId;\n\t\tconst compressedTraits: CompressedTraits<TId, TPlaceholder> = [];\n\n\t\t// Omit traits if empty and payload is undefined.\n\t\tconst traits = Object.entries(node.traits).sort();\n\t\tif (traits.length > 0 || node.payload !== undefined) {\n\t\t\tfor (const [label, trait] of traits) {\n\t\t\t\tcompressedTraits.push(\n\t\t\t\t\tinterner.getInternedId(label) ?? (label as TraitLabel),\n\t\t\t\t\ttrait.map((child) => this.compressI(child, interner, idNormalizer))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst payloadTraits = node.payload !== undefined ? [node.payload, ...compressedTraits] : compressedTraits;\n\t\tif (payloadTraits.length > 0) {\n\t\t\tif (compressedId !== undefined) {\n\t\t\t\treturn [internedDefinition, compressedId, payloadTraits];\n\t\t\t}\n\t\t\treturn [internedDefinition, payloadTraits];\n\t\t}\n\n\t\tif (compressedId !== undefined) {\n\t\t\treturn [internedDefinition, compressedId];\n\t\t}\n\n\t\treturn [internedDefinition];\n\t}\n\n\t/** The ID that was compressed or decompressed most recently */\n\tprivate previousId?: OpSpaceNodeId;\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\t\tconst rootId = node[1];\n\t\tassert(typeof rootId === 'number', 'Root node was compressed with no ID');\n\t\tthis.previousId = rootId;\n\t\treturn this.decompressI(node, interner, idNormalizer);\n\t}\n\n\tprivate decompressI<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tlet compressedId: TId | undefined;\n\t\tlet compressedTraits:\n\t\t\t| [Payload, ...CompressedTraits<TId, TPlaceholder>]\n\t\t\t| CompressedTraits<TId, TPlaceholder>\n\t\t\t| undefined;\n\t\tlet payload: Payload | undefined;\n\t\tconst [maybeInternedDefinition, idOrPayloadTraits, payloadTraits] = node;\n\t\tif (idOrPayloadTraits !== undefined) {\n\t\t\tif (typeof idOrPayloadTraits === 'number') {\n\t\t\t\tcompressedId = idOrPayloadTraits;\n\t\t\t\tif (payloadTraits !== undefined) {\n\t\t\t\t\tcompressedTraits = payloadTraits;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// TODO: This cast can be removed on typescript 4.6\n\t\t\t\tcompressedTraits = idOrPayloadTraits as typeof compressedTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst definition =\n\t\t\ttypeof maybeInternedDefinition === 'string'\n\t\t\t\t? maybeInternedDefinition\n\t\t\t\t: // TODO: This cast can be removed on typescript 4.6\n\t\t\t\t (interner.getString(maybeInternedDefinition as number) as Definition);\n\n\t\tlet identifier: TId;\n\t\tif (compressedId !== undefined) {\n\t\t\tidentifier = compressedId;\n\t\t} else {\n\t\t\tconst prevId = this.previousId ?? fail();\n\t\t\tidentifier = prevId < 0 ? ((prevId - 1) as TId) : (((prevId as number) + 1) as TId);\n\t\t}\n\t\tthis.previousId = identifier;\n\n\t\tconst traits = {};\n\t\tif (compressedTraits !== undefined) {\n\t\t\tlet offset: number;\n\t\t\tif (compressedTraits.length % 2 === 1) {\n\t\t\t\toffset = 1;\n\t\t\t\tpayload = compressedTraits[0];\n\t\t\t} else {\n\t\t\t\toffset = 0;\n\t\t\t}\n\t\t\tconst traitsLength = compressedTraits.length - offset;\n\t\t\tfor (let i = 0; i < traitsLength; i += 2) {\n\t\t\t\tconst offsetIndex = i + offset;\n\t\t\t\tconst maybeCompressedLabel = compressedTraits[offsetIndex] as InternedStringId;\n\t\t\t\tconst compressedChildren = compressedTraits[offsetIndex + 1] as (\n\t\t\t\t\t| TPlaceholder\n\t\t\t\t\t| CompressedPlaceholderTree<TId, TPlaceholder>\n\t\t\t\t)[];\n\n\t\t\t\tconst decompressedTraits = compressedChildren.map((child) =>\n\t\t\t\t\tthis.decompressI(child, interner, idNormalizer)\n\t\t\t\t);\n\n\t\t\t\tconst label =\n\t\t\t\t\ttypeof maybeCompressedLabel === 'string'\n\t\t\t\t\t\t? maybeCompressedLabel\n\t\t\t\t\t\t: (interner.getString(maybeCompressedLabel) as TraitLabel);\n\t\t\t\ttraits[label] = decompressedTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst decompressedNode: Mutable<PlaceholderTree<TPlaceholder>> = {\n\t\t\tidentifier: idNormalizer.normalizeToSessionSpace(identifier),\n\t\t\tdefinition,\n\t\t\ttraits,\n\t\t};\n\n\t\tif (payload !== undefined) {\n\t\t\tdecompressedNode.payload = payload;\n\t\t}\n\n\t\treturn decompressedNode;\n\t}\n}\n\nfunction canElideId<TId extends OpSpaceNodeId>(previousId: TId | undefined, id: TId): boolean {\n\tif (previousId === undefined) {\n\t\treturn false;\n\t}\n\n\tconst numericId: number = previousId;\n\tif (numericId < 0) {\n\t\treturn id === numericId - 1;\n\t}\n\n\treturn id === numericId + 1;\n}\n"]}
@@ -3,32 +3,26 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { Definition, NodeId } from './Identifiers';
6
- import { ChangeNode, Payload, TraitMap, TreeNode } from './generic';
7
- import { Snapshot } from './Snapshot';
6
+ import { Payload, TraitMap, TreeNode } from './persisted-types';
7
+ import { TreeView, TreeViewNode } from './TreeView';
8
8
  /**
9
- * A handle to a `TreeNode` that exists within a specific `Snapshot`. This type provides a convenient
10
- * API for traversing trees of nodes in a Snapshot and is not designed to provide maximum runtime
11
- * performance; if performance is a concern, consider using the Snapshot and SnapshotNode APIs directly.
9
+ * A handle to a `TreeNode` that exists within a specific `TreeView`. This type provides a convenient
10
+ * API for traversing trees of nodes in a TreeView and is not designed to provide maximum runtime
11
+ * performance; if performance is a concern, consider using the TreeView and TreeViewNode APIs directly.
12
12
  * @public
13
13
  */
14
- export declare class TreeNodeHandle implements TreeNode<TreeNodeHandle> {
15
- private readonly snapshot;
16
- private readonly nodeId;
17
- /** Construct a handle which references the node with the given id in the given `Snapshot` */
18
- constructor(snapshot: Snapshot, nodeId: NodeId);
14
+ export declare class TreeNodeHandle implements TreeNode<TreeNodeHandle, NodeId> {
15
+ private readonly view;
16
+ private readonly viewNode;
17
+ /** Construct a handle which references the node with the given id in the given `TreeView` */
18
+ constructor(view: TreeView, nodeId: NodeId);
19
19
  get payload(): Payload | undefined;
20
20
  get definition(): Definition;
21
21
  get identifier(): NodeId;
22
22
  get traits(): TraitMap<TreeNodeHandle>;
23
23
  /**
24
- * Get a `ChangeNode` for the snapshot node that this handle references
24
+ * Get a `TreeViewNode` for the tree view node that this handle references
25
25
  */
26
- get node(): ChangeNode;
27
- /**
28
- * Generate a new `ChangeNode` for the snapshot node that this handle references. The returned node will be fully
29
- * demanded, i.e. will contain no lazy/virtualized subtrees.
30
- */
31
- demandTree(): ChangeNode;
32
- toString(): string;
26
+ get node(): TreeViewNode;
33
27
  }
34
28
  //# sourceMappingURL=TreeNodeHandle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeHandle.d.ts","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,QAAQ,CAAC,cAAc,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,6FAA6F;gBAC1E,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKrD,IAAW,OAAO,IAAI,OAAO,GAAG,SAAS,CAExC;IAED,IAAW,UAAU,IAAI,UAAU,CAElC;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,MAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,CAgB5C;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED;;;OAGG;IACI,UAAU,IAAI,UAAU;IAIxB,QAAQ,IAAI,MAAM;CAGzB"}
1
+ {"version":3,"file":"TreeNodeHandle.d.ts","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IACtE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAExC,6FAA6F;gBAC1E,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKjD,IAAW,OAAO,IAAI,OAAO,GAAG,SAAS,CAExC;IAED,IAAW,UAAU,IAAI,UAAU,CAElC;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,MAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,CAgB5C;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,YAAY,CAE9B;CACD"}
@@ -6,18 +6,18 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TreeNodeHandle = void 0;
8
8
  const Common_1 = require("./Common");
9
- const SnapshotUtilities_1 = require("./SnapshotUtilities");
10
9
  /**
11
- * A handle to a `TreeNode` that exists within a specific `Snapshot`. This type provides a convenient
12
- * API for traversing trees of nodes in a Snapshot and is not designed to provide maximum runtime
13
- * performance; if performance is a concern, consider using the Snapshot and SnapshotNode APIs directly.
10
+ * A handle to a `TreeNode` that exists within a specific `TreeView`. This type provides a convenient
11
+ * API for traversing trees of nodes in a TreeView and is not designed to provide maximum runtime
12
+ * performance; if performance is a concern, consider using the TreeView and TreeViewNode APIs directly.
14
13
  * @public
15
14
  */
16
15
  class TreeNodeHandle {
17
- /** Construct a handle which references the node with the given id in the given `Snapshot` */
18
- constructor(snapshot, nodeId) {
19
- this.snapshot = snapshot;
20
- this.nodeId = nodeId;
16
+ /** Construct a handle which references the node with the given id in the given `TreeView` */
17
+ constructor(view, nodeId) {
18
+ var _a;
19
+ this.view = view;
20
+ this.viewNode = (_a = view.tryGetViewNode(nodeId)) !== null && _a !== void 0 ? _a : Common_1.fail('Failed to create handle: node is not present in view');
21
21
  }
22
22
  get payload() {
23
23
  return this.node.payload;
@@ -31,11 +31,11 @@ class TreeNodeHandle {
31
31
  get traits() {
32
32
  // Construct a new trait map that wraps each node in each trait in a handle
33
33
  const traitMap = {};
34
- const { snapshot } = this;
35
- for (const [label, trait] of Object.entries(this.node.traits)) {
34
+ const { view } = this;
35
+ for (const [label, trait] of this.node.traits.entries()) {
36
36
  Object.defineProperty(traitMap, label, {
37
37
  get() {
38
- const handleTrait = trait.map((node) => new TreeNodeHandle(snapshot, node.identifier));
38
+ const handleTrait = trait.map((node) => new TreeNodeHandle(view, node));
39
39
  return Common_1.memoizeGetter(this, label, handleTrait);
40
40
  },
41
41
  configurable: true,
@@ -45,20 +45,10 @@ class TreeNodeHandle {
45
45
  return Common_1.memoizeGetter(this, 'traits', traitMap);
46
46
  }
47
47
  /**
48
- * Get a `ChangeNode` for the snapshot node that this handle references
48
+ * Get a `TreeViewNode` for the tree view node that this handle references
49
49
  */
50
50
  get node() {
51
- return Common_1.memoizeGetter(this, 'node', SnapshotUtilities_1.getChangeNodeFromSnapshot(this.snapshot, this.nodeId, true));
52
- }
53
- /**
54
- * Generate a new `ChangeNode` for the snapshot node that this handle references. The returned node will be fully
55
- * demanded, i.e. will contain no lazy/virtualized subtrees.
56
- */
57
- demandTree() {
58
- return SnapshotUtilities_1.getChangeNodeFromSnapshot(this.snapshot, this.nodeId, false);
59
- }
60
- toString() {
61
- return JSON.stringify(this.demandTree());
51
+ return Common_1.memoizeGetter(this, 'node', this.viewNode);
62
52
  }
63
53
  }
64
54
  exports.TreeNodeHandle = TreeNodeHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,qCAAyC;AACzC,2DAAgE;AAEhE;;;;;GAKG;AACH,MAAa,cAAc;IAI1B,6FAA6F;IAC7F,YAAmB,QAAkB,EAAE,MAAc;QACpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC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CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD;AA1DD,wCA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { ChangeNode, Payload, TraitMap, TreeNode } from './generic';\nimport { Snapshot } from './Snapshot';\nimport { memoizeGetter } from './Common';\nimport { getChangeNodeFromSnapshot } from './SnapshotUtilities';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `Snapshot`. This type provides a convenient\n * API for traversing trees of nodes in a Snapshot and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the Snapshot and SnapshotNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle> {\n\tprivate readonly snapshot: Snapshot;\n\tprivate readonly nodeId: NodeId;\n\n\t/** Construct a handle which references the node with the given id in the given `Snapshot` */\n\tpublic constructor(snapshot: Snapshot, nodeId: NodeId) {\n\t\tthis.snapshot = snapshot;\n\t\tthis.nodeId = nodeId;\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { snapshot } = this;\n\t\tfor (const [label, trait] of Object.entries(this.node.traits)) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(snapshot, node.identifier));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `ChangeNode` for the snapshot node that this handle references\n\t */\n\tpublic get node(): ChangeNode {\n\t\treturn memoizeGetter(this, 'node', getChangeNodeFromSnapshot(this.snapshot, this.nodeId, true));\n\t}\n\n\t/**\n\t * Generate a new `ChangeNode` for the snapshot node that this handle references. The returned node will be fully\n\t * demanded, i.e. will contain no lazy/virtualized subtrees.\n\t */\n\tpublic demandTree(): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this.snapshot, this.nodeId, false);\n\t}\n\n\tpublic toString(): string {\n\t\treturn JSON.stringify(this.demandTree());\n\t}\n}\n"]}
1
+ {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA+C;AAI/C;;;;;GAKG;AACH,MAAa,cAAc;IAI1B,6FAA6F;IAC7F,YAAmB,IAAc,EAAE,MAAc;;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,SAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,mCAAI,aAAI,CAAC,sDAAsD,CAAC,CAAC;IAC7G,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,MAAM;QAChB,2EAA2E;QAC3E,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;YACxD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;gBACtC,GAAG;oBACF,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBACxE,OAAO,sBAAa,CAAC,IAAgC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;gBAC5E,CAAC;gBACD,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,IAAI;aAChB,CAAC,CAAC;SACH;QAED,OAAO,sBAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,sBAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACD;AA9CD,wCA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { fail, memoizeGetter } from './Common';\nimport { Payload, TraitMap, TreeNode } from './persisted-types';\nimport { TreeView, TreeViewNode } from './TreeView';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `TreeView`. This type provides a convenient\n * API for traversing trees of nodes in a TreeView and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the TreeView and TreeViewNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle, NodeId> {\n\tprivate readonly view: TreeView;\n\tprivate readonly viewNode: TreeViewNode;\n\n\t/** Construct a handle which references the node with the given id in the given `TreeView` */\n\tpublic constructor(view: TreeView, nodeId: NodeId) {\n\t\tthis.view = view;\n\t\tthis.viewNode = view.tryGetViewNode(nodeId) ?? fail('Failed to create handle: node is not present in view');\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { view } = this;\n\t\tfor (const [label, trait] of this.node.traits.entries()) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(view, node));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `TreeViewNode` for the tree view node that this handle references\n\t */\n\tpublic get node(): TreeViewNode {\n\t\treturn memoizeGetter(this, 'node', this.viewNode);\n\t}\n}\n"]}
@@ -0,0 +1,166 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { NodeId, TraitLabel } from './Identifiers';
6
+ import { Delta, Forest } from './Forest';
7
+ import { NodeData, Side } from './persisted-types';
8
+ /**
9
+ * Specifies the location of a trait (a labeled sequence of nodes) within the tree.
10
+ * @public
11
+ */
12
+ export interface TraitLocation {
13
+ readonly parent: NodeId;
14
+ readonly label: TraitLabel;
15
+ }
16
+ /**
17
+ * An immutable view of a distributed tree node.
18
+ * @public
19
+ */
20
+ export interface TreeViewNode extends NodeData<NodeId> {
21
+ /** The IDs of the children under this node */
22
+ readonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;
23
+ /** The parent and trait under which this node resides. Undefined iff this is the root node of the tree (i.e. {@link initialTree}). */
24
+ readonly parentage?: TraitLocation;
25
+ }
26
+ /**
27
+ * Index of a place within a trait.
28
+ * 0 = before all nodes,
29
+ * 1 = after first node,
30
+ * etc.
31
+ * @public
32
+ */
33
+ export declare type PlaceIndex = number & {
34
+ readonly PlaceIndex: unique symbol;
35
+ };
36
+ /**
37
+ * Index of a node within a trait.
38
+ * 0 = first node,
39
+ * 1 = second node,
40
+ * etc.
41
+ * @public
42
+ */
43
+ export declare type TraitNodeIndex = number & {
44
+ readonly TraitNodeIndex: unique symbol;
45
+ };
46
+ /**
47
+ * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.
48
+ * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.
49
+ * @public
50
+ */
51
+ export interface TreeViewPlace {
52
+ readonly sibling?: NodeId;
53
+ readonly side: Side;
54
+ readonly trait: TraitLocation;
55
+ }
56
+ /**
57
+ * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.
58
+ * Valid iff start and end are valid and are within the same trait.
59
+ * @public
60
+ */
61
+ export interface TreeViewRange {
62
+ readonly start: TreeViewPlace;
63
+ readonly end: TreeViewPlace;
64
+ }
65
+ /**
66
+ * Contains some redundant information. Use only in computations between edits. Do not store.
67
+ * @public
68
+ */
69
+ export interface NodeInTrait {
70
+ readonly trait: TraitLocation;
71
+ readonly index: TraitNodeIndex;
72
+ }
73
+ /**
74
+ * A view of a distributed tree.
75
+ * @public
76
+ */
77
+ export declare abstract class TreeView {
78
+ readonly root: NodeId;
79
+ protected readonly forest: Forest;
80
+ private readonly rootNode;
81
+ /**
82
+ * A cache of node's index within their parent trait.
83
+ * Used to avoid redundant linear scans of traits.
84
+ * Not shared across views; initialized to empty each time a TreeView is created.
85
+ */
86
+ private traitIndicesCache?;
87
+ protected constructor(root: NodeId, forest: Forest);
88
+ /** @returns the number of nodes in this view */
89
+ get size(): number;
90
+ /** @returns true iff a node with the given id exists in this view */
91
+ hasNode(id: NodeId): boolean;
92
+ /**
93
+ * @returns the index just after place (which specifies a location between items).
94
+ * Performance note: this is O(siblings in trait).
95
+ */
96
+ findIndexWithinTrait(place: TreeViewPlace): PlaceIndex;
97
+ /** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */
98
+ getViewNode(id: NodeId): TreeViewNode;
99
+ /** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */
100
+ tryGetViewNode(id: NodeId): TreeViewNode | undefined;
101
+ /**
102
+ * @returns the label of the trait under which a node with the given id resides. Fails if the node does not exist in this view or if
103
+ * it is the root node.
104
+ */
105
+ getTraitLabel(id: NodeId): TraitLabel;
106
+ /**
107
+ * @returns the label of the trait under which a node with the given id resides, or undefined if the node is not present in this
108
+ * view or if it is the root node
109
+ */
110
+ tryGetTraitLabel(id: NodeId): TraitLabel | undefined;
111
+ /**
112
+ * @returns the parent of the node with the given id. Fails if the node does not exist in this view or if it is the root node.
113
+ */
114
+ getParentViewNode(id: NodeId): TreeViewNode;
115
+ /**
116
+ * @returns the parent of the node with the given id. Returns undefined if the node does not exist in this view or if it is the root
117
+ * node.
118
+ */
119
+ tryGetParentViewNode(id: NodeId): TreeViewNode | undefined;
120
+ /**
121
+ * @returns the trait location of the node with the given id. Fails if the node does not exist in this view or of it is the root
122
+ * node
123
+ */
124
+ getTraitLocation(id: NodeId): TraitLocation;
125
+ /**
126
+ * @returns the trait location of the node with the given id, or undefined if the node does not exist in this view or if it is the root
127
+ * node
128
+ */
129
+ tryGetTraitLocation(id: NodeId): TraitLocation | undefined;
130
+ /**
131
+ * @returns the index within the trait under which the node with the given id resides. The node must exist in this view and must have a
132
+ * parent.
133
+ * Performance note: this is O(siblings in trait).
134
+ */
135
+ getIndexInTrait(id: NodeId): TraitNodeIndex;
136
+ /**
137
+ * @returns the index within the trait under which the node with the given id resides, or undefined if the node does not exist in this
138
+ * view or does not have a parent.
139
+ * Performance note: this is O(siblings in trait).
140
+ */
141
+ tryGetIndexInTrait(id: NodeId): TraitNodeIndex | undefined;
142
+ /**
143
+ * @returns the trait at the given location. If no such trait exists, returns an empty trait.
144
+ */
145
+ getTrait(traitLocation: TraitLocation): readonly NodeId[];
146
+ /** Asserts that the view's internal state is consistent. Useful for testing/validation. */
147
+ assertConsistent(): void;
148
+ [Symbol.iterator](): IterableIterator<TreeViewNode>;
149
+ /** @returns true iff the given view is equal to this view */
150
+ abstract equals(view: TreeView): boolean;
151
+ /**
152
+ * @returns true iff the given view's forest of nodes is equivalent to this view's forest of nodes
153
+ * @param strict - if true, the views' forests must be the same object, otherwise they must merely be equivalent
154
+ */
155
+ hasEqualForest(view: TreeView, strict?: boolean): boolean;
156
+ private iterateNodeDescendants;
157
+ private getIndexOfSide;
158
+ /**
159
+ * Calculate the difference between two `TreeView`s
160
+ * @param view - the other view to compare to this one
161
+ * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `view`.
162
+ * The views must share a root.
163
+ */
164
+ delta(view: TreeView): Delta<NodeId>;
165
+ }
166
+ //# sourceMappingURL=TreeView.d.ts.map