@fluid-experimental/tree 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (572) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +1 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/.vscode/settings.json +1 -1
  4. package/CHANGELOG.md +4 -0
  5. package/api-report/experimental-tree.api.md +4 -15
  6. package/dist/ChangeCompression.d.ts +5 -5
  7. package/dist/ChangeCompression.d.ts.map +1 -1
  8. package/dist/ChangeCompression.js +24 -24
  9. package/dist/ChangeCompression.js.map +1 -1
  10. package/dist/ChangeTypes.d.ts +3 -3
  11. package/dist/ChangeTypes.d.ts.map +1 -1
  12. package/dist/ChangeTypes.js +9 -9
  13. package/dist/ChangeTypes.js.map +1 -1
  14. package/dist/Checkout.d.ts +7 -7
  15. package/dist/Checkout.d.ts.map +1 -1
  16. package/dist/Checkout.js +27 -27
  17. package/dist/Checkout.js.map +1 -1
  18. package/dist/Common.d.ts +2 -2
  19. package/dist/Common.d.ts.map +1 -1
  20. package/dist/Common.js.map +1 -1
  21. package/dist/EagerCheckout.d.ts +3 -3
  22. package/dist/EagerCheckout.d.ts.map +1 -1
  23. package/dist/EagerCheckout.js +2 -2
  24. package/dist/EagerCheckout.js.map +1 -1
  25. package/dist/EditLog.d.ts +4 -6
  26. package/dist/EditLog.d.ts.map +1 -1
  27. package/dist/EditLog.js +9 -9
  28. package/dist/EditLog.js.map +1 -1
  29. package/dist/EditUtilities.d.ts +6 -6
  30. package/dist/EditUtilities.d.ts.map +1 -1
  31. package/dist/EditUtilities.js +28 -28
  32. package/dist/EditUtilities.js.map +1 -1
  33. package/dist/Forest.d.ts +2 -2
  34. package/dist/Forest.d.ts.map +1 -1
  35. package/dist/Forest.js +13 -13
  36. package/dist/Forest.js.map +1 -1
  37. package/dist/HistoryEditFactory.d.ts +3 -3
  38. package/dist/HistoryEditFactory.d.ts.map +1 -1
  39. package/dist/HistoryEditFactory.js +36 -36
  40. package/dist/HistoryEditFactory.js.map +1 -1
  41. package/dist/IdConversion.d.ts +3 -3
  42. package/dist/IdConversion.d.ts.map +1 -1
  43. package/dist/IdConversion.js +23 -23
  44. package/dist/IdConversion.js.map +1 -1
  45. package/dist/InitialTree.d.ts +1 -1
  46. package/dist/InitialTree.d.ts.map +1 -1
  47. package/dist/InitialTree.js +2 -2
  48. package/dist/InitialTree.js.map +1 -1
  49. package/dist/LazyCheckout.d.ts +5 -5
  50. package/dist/LazyCheckout.d.ts.map +1 -1
  51. package/dist/LazyCheckout.js +2 -2
  52. package/dist/LazyCheckout.js.map +1 -1
  53. package/dist/LogViewer.d.ts +7 -7
  54. package/dist/LogViewer.d.ts.map +1 -1
  55. package/dist/LogViewer.js +25 -25
  56. package/dist/LogViewer.js.map +1 -1
  57. package/dist/MergeHealth.d.ts +1 -1
  58. package/dist/MergeHealth.d.ts.map +1 -1
  59. package/dist/MergeHealth.js +32 -32
  60. package/dist/MergeHealth.js.map +1 -1
  61. package/dist/NodeIdUtilities.d.ts +3 -3
  62. package/dist/NodeIdUtilities.d.ts.map +1 -1
  63. package/dist/NodeIdUtilities.js +4 -4
  64. package/dist/NodeIdUtilities.js.map +1 -1
  65. package/dist/PayloadUtilities.d.ts +1 -1
  66. package/dist/PayloadUtilities.d.ts.map +1 -1
  67. package/dist/PayloadUtilities.js.map +1 -1
  68. package/dist/ReconciliationPath.d.ts +3 -3
  69. package/dist/ReconciliationPath.d.ts.map +1 -1
  70. package/dist/ReconciliationPath.js.map +1 -1
  71. package/dist/RevisionValueCache.js +5 -5
  72. package/dist/RevisionValueCache.js.map +1 -1
  73. package/dist/RevisionView.d.ts +5 -5
  74. package/dist/RevisionView.d.ts.map +1 -1
  75. package/dist/RevisionView.js +11 -11
  76. package/dist/RevisionView.js.map +1 -1
  77. package/dist/SerializationUtilities.d.ts +4 -4
  78. package/dist/SerializationUtilities.d.ts.map +1 -1
  79. package/dist/SerializationUtilities.js +5 -5
  80. package/dist/SerializationUtilities.js.map +1 -1
  81. package/dist/SharedTree.d.ts +15 -18
  82. package/dist/SharedTree.d.ts.map +1 -1
  83. package/dist/SharedTree.js +154 -166
  84. package/dist/SharedTree.js.map +1 -1
  85. package/dist/SharedTreeEncoder.d.ts +8 -8
  86. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  87. package/dist/SharedTreeEncoder.js +67 -67
  88. package/dist/SharedTreeEncoder.js.map +1 -1
  89. package/dist/StringInterner.d.ts +1 -1
  90. package/dist/StringInterner.d.ts.map +1 -1
  91. package/dist/StringInterner.js +2 -2
  92. package/dist/StringInterner.js.map +1 -1
  93. package/dist/Summary.d.ts +4 -4
  94. package/dist/Summary.d.ts.map +1 -1
  95. package/dist/Summary.js +2 -2
  96. package/dist/Summary.js.map +1 -1
  97. package/dist/SummaryBackCompatibility.d.ts +3 -3
  98. package/dist/SummaryBackCompatibility.d.ts.map +1 -1
  99. package/dist/SummaryBackCompatibility.js +13 -13
  100. package/dist/SummaryBackCompatibility.js.map +1 -1
  101. package/dist/SummaryTestUtilities.d.ts +2 -2
  102. package/dist/SummaryTestUtilities.d.ts.map +1 -1
  103. package/dist/SummaryTestUtilities.js.map +1 -1
  104. package/dist/Transaction.d.ts +4 -4
  105. package/dist/Transaction.d.ts.map +1 -1
  106. package/dist/Transaction.js +10 -10
  107. package/dist/Transaction.js.map +1 -1
  108. package/dist/TransactionInternal.d.ts +7 -7
  109. package/dist/TransactionInternal.d.ts.map +1 -1
  110. package/dist/TransactionInternal.js +87 -87
  111. package/dist/TransactionInternal.js.map +1 -1
  112. package/dist/TreeCompressor.d.ts +4 -4
  113. package/dist/TreeCompressor.d.ts.map +1 -1
  114. package/dist/TreeCompressor.js +6 -6
  115. package/dist/TreeCompressor.js.map +1 -1
  116. package/dist/TreeNodeHandle.d.ts +3 -3
  117. package/dist/TreeNodeHandle.d.ts.map +1 -1
  118. package/dist/TreeNodeHandle.js +5 -5
  119. package/dist/TreeNodeHandle.js.map +1 -1
  120. package/dist/TreeView.d.ts +3 -3
  121. package/dist/TreeView.d.ts.map +1 -1
  122. package/dist/TreeView.js +10 -10
  123. package/dist/TreeView.js.map +1 -1
  124. package/dist/TreeViewUtilities.d.ts +2 -2
  125. package/dist/TreeViewUtilities.d.ts.map +1 -1
  126. package/dist/TreeViewUtilities.js +3 -3
  127. package/dist/TreeViewUtilities.js.map +1 -1
  128. package/dist/UndoRedoHandler.d.ts +2 -2
  129. package/dist/UndoRedoHandler.d.ts.map +1 -1
  130. package/dist/UndoRedoHandler.js +5 -5
  131. package/dist/UndoRedoHandler.js.map +1 -1
  132. package/dist/UuidUtilities.d.ts +1 -1
  133. package/dist/UuidUtilities.d.ts.map +1 -1
  134. package/dist/UuidUtilities.js +3 -3
  135. package/dist/UuidUtilities.js.map +1 -1
  136. package/dist/id-compressor/AppendOnlySortedMap.js +4 -4
  137. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  138. package/dist/id-compressor/IdCompressor.d.ts +2 -2
  139. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  140. package/dist/id-compressor/IdCompressor.js +78 -78
  141. package/dist/id-compressor/IdCompressor.js.map +1 -1
  142. package/dist/id-compressor/IdRange.d.ts +1 -1
  143. package/dist/id-compressor/IdRange.d.ts.map +1 -1
  144. package/dist/id-compressor/IdRange.js.map +1 -1
  145. package/dist/id-compressor/NumericUuid.d.ts +1 -1
  146. package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
  147. package/dist/id-compressor/NumericUuid.js +6 -6
  148. package/dist/id-compressor/NumericUuid.js.map +1 -1
  149. package/dist/id-compressor/SessionIdNormalizer.d.ts +2 -2
  150. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
  151. package/dist/id-compressor/SessionIdNormalizer.js +14 -14
  152. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
  153. package/dist/id-compressor/index.d.ts +4 -4
  154. package/dist/id-compressor/index.d.ts.map +1 -1
  155. package/dist/id-compressor/index.js +11 -11
  156. package/dist/id-compressor/index.js.map +1 -1
  157. package/dist/id-compressor/persisted-types/0.0.1.d.ts +1 -1
  158. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  159. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  160. package/dist/id-compressor/persisted-types/index.d.ts +1 -1
  161. package/dist/id-compressor/persisted-types/index.d.ts.map +1 -1
  162. package/dist/id-compressor/persisted-types/index.js.map +1 -1
  163. package/dist/index.d.ts +29 -29
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +73 -73
  166. package/dist/index.js.map +1 -1
  167. package/dist/migration-shim/migrationDeltaHandler.d.ts +1 -1
  168. package/dist/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
  169. package/dist/migration-shim/migrationDeltaHandler.js +5 -8
  170. package/dist/migration-shim/migrationDeltaHandler.js.map +1 -1
  171. package/dist/migration-shim/migrationShim.d.ts +1 -1
  172. package/dist/migration-shim/migrationShim.d.ts.map +1 -1
  173. package/dist/migration-shim/migrationShim.js +1 -1
  174. package/dist/migration-shim/migrationShim.js.map +1 -1
  175. package/dist/migration-shim/migrationShimFactory.d.ts +1 -1
  176. package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
  177. package/dist/migration-shim/migrationShimFactory.js.map +1 -1
  178. package/dist/migration-shim/sharedTreeDeltaHandler.d.ts +1 -1
  179. package/dist/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
  180. package/dist/migration-shim/sharedTreeDeltaHandler.js +2 -5
  181. package/dist/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
  182. package/dist/migration-shim/types.d.ts +1 -1
  183. package/dist/migration-shim/types.d.ts.map +1 -1
  184. package/dist/migration-shim/types.js.map +1 -1
  185. package/dist/package.json +3 -0
  186. package/dist/persisted-types/0.0.2.d.ts +1 -1
  187. package/dist/persisted-types/0.0.2.d.ts.map +1 -1
  188. package/dist/persisted-types/0.0.2.js.map +1 -1
  189. package/dist/persisted-types/0.1.1.d.ts +4 -4
  190. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  191. package/dist/persisted-types/0.1.1.js +13 -13
  192. package/dist/persisted-types/0.1.1.js.map +1 -1
  193. package/dist/persisted-types/index.d.ts +2 -2
  194. package/dist/persisted-types/index.d.ts.map +1 -1
  195. package/dist/persisted-types/index.js +13 -13
  196. package/dist/persisted-types/index.js.map +1 -1
  197. package/dist/tree-alpha.d.ts +5 -8
  198. package/dist/tree-beta.d.ts +5 -1
  199. package/dist/tree-public.d.ts +5 -1
  200. package/dist/tree-untrimmed.d.ts +5 -8
  201. package/dist/tsdoc-metadata.json +1 -1
  202. package/lib/ChangeCompression.d.ts +5 -5
  203. package/lib/ChangeCompression.d.ts.map +1 -1
  204. package/lib/ChangeCompression.js +3 -3
  205. package/lib/ChangeCompression.js.map +1 -1
  206. package/lib/ChangeTypes.d.ts +3 -3
  207. package/lib/ChangeTypes.d.ts.map +1 -1
  208. package/lib/ChangeTypes.js +3 -3
  209. package/lib/ChangeTypes.js.map +1 -1
  210. package/lib/Checkout.d.ts +7 -7
  211. package/lib/Checkout.d.ts.map +1 -1
  212. package/lib/Checkout.js +6 -6
  213. package/lib/Checkout.js.map +1 -1
  214. package/lib/Common.d.ts +2 -2
  215. package/lib/Common.d.ts.map +1 -1
  216. package/lib/Common.js.map +1 -1
  217. package/lib/EagerCheckout.d.ts +3 -3
  218. package/lib/EagerCheckout.d.ts.map +1 -1
  219. package/lib/EagerCheckout.js +1 -1
  220. package/lib/EagerCheckout.js.map +1 -1
  221. package/lib/EditLog.d.ts +4 -6
  222. package/lib/EditLog.d.ts.map +1 -1
  223. package/lib/EditLog.js +1 -1
  224. package/lib/EditLog.js.map +1 -1
  225. package/lib/EditUtilities.d.ts +6 -6
  226. package/lib/EditUtilities.d.ts.map +1 -1
  227. package/lib/EditUtilities.js +7 -7
  228. package/lib/EditUtilities.js.map +1 -1
  229. package/lib/Forest.d.ts +2 -2
  230. package/lib/Forest.d.ts.map +1 -1
  231. package/lib/Forest.js +2 -2
  232. package/lib/Forest.js.map +1 -1
  233. package/lib/HistoryEditFactory.d.ts +3 -3
  234. package/lib/HistoryEditFactory.d.ts.map +1 -1
  235. package/lib/HistoryEditFactory.js +7 -7
  236. package/lib/HistoryEditFactory.js.map +1 -1
  237. package/lib/IdConversion.d.ts +3 -3
  238. package/lib/IdConversion.d.ts.map +1 -1
  239. package/lib/IdConversion.js +4 -4
  240. package/lib/IdConversion.js.map +1 -1
  241. package/lib/InitialTree.d.ts +1 -1
  242. package/lib/InitialTree.d.ts.map +1 -1
  243. package/lib/InitialTree.js +1 -1
  244. package/lib/InitialTree.js.map +1 -1
  245. package/lib/LazyCheckout.d.ts +5 -5
  246. package/lib/LazyCheckout.d.ts.map +1 -1
  247. package/lib/LazyCheckout.js +1 -1
  248. package/lib/LazyCheckout.js.map +1 -1
  249. package/lib/LogViewer.d.ts +7 -7
  250. package/lib/LogViewer.d.ts.map +1 -1
  251. package/lib/LogViewer.js +4 -4
  252. package/lib/LogViewer.js.map +1 -1
  253. package/lib/MergeHealth.d.ts +1 -1
  254. package/lib/MergeHealth.d.ts.map +1 -1
  255. package/lib/MergeHealth.js +5 -5
  256. package/lib/MergeHealth.js.map +1 -1
  257. package/lib/NodeIdUtilities.d.ts +3 -3
  258. package/lib/NodeIdUtilities.d.ts.map +1 -1
  259. package/lib/NodeIdUtilities.js +2 -2
  260. package/lib/NodeIdUtilities.js.map +1 -1
  261. package/lib/PayloadUtilities.d.ts +1 -1
  262. package/lib/PayloadUtilities.d.ts.map +1 -1
  263. package/lib/PayloadUtilities.js.map +1 -1
  264. package/lib/ReconciliationPath.d.ts +3 -3
  265. package/lib/ReconciliationPath.d.ts.map +1 -1
  266. package/lib/ReconciliationPath.js.map +1 -1
  267. package/lib/RevisionValueCache.js +1 -1
  268. package/lib/RevisionValueCache.js.map +1 -1
  269. package/lib/RevisionView.d.ts +5 -5
  270. package/lib/RevisionView.d.ts.map +1 -1
  271. package/lib/RevisionView.js +3 -3
  272. package/lib/RevisionView.js.map +1 -1
  273. package/lib/SerializationUtilities.d.ts +4 -4
  274. package/lib/SerializationUtilities.d.ts.map +1 -1
  275. package/lib/SerializationUtilities.js +1 -1
  276. package/lib/SerializationUtilities.js.map +1 -1
  277. package/lib/SharedTree.d.ts +15 -18
  278. package/lib/SharedTree.d.ts.map +1 -1
  279. package/lib/SharedTree.js +28 -40
  280. package/lib/SharedTree.js.map +1 -1
  281. package/lib/SharedTreeEncoder.d.ts +8 -8
  282. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  283. package/lib/SharedTreeEncoder.js +12 -12
  284. package/lib/SharedTreeEncoder.js.map +1 -1
  285. package/lib/StringInterner.d.ts +1 -1
  286. package/lib/StringInterner.d.ts.map +1 -1
  287. package/lib/StringInterner.js +1 -1
  288. package/lib/StringInterner.js.map +1 -1
  289. package/lib/Summary.d.ts +4 -4
  290. package/lib/Summary.d.ts.map +1 -1
  291. package/lib/Summary.js +1 -1
  292. package/lib/Summary.js.map +1 -1
  293. package/lib/SummaryBackCompatibility.d.ts +3 -3
  294. package/lib/SummaryBackCompatibility.d.ts.map +1 -1
  295. package/lib/SummaryBackCompatibility.js +3 -3
  296. package/lib/SummaryBackCompatibility.js.map +1 -1
  297. package/lib/SummaryTestUtilities.d.ts +2 -2
  298. package/lib/SummaryTestUtilities.d.ts.map +1 -1
  299. package/lib/SummaryTestUtilities.js.map +1 -1
  300. package/lib/Transaction.d.ts +4 -4
  301. package/lib/Transaction.d.ts.map +1 -1
  302. package/lib/Transaction.js +5 -5
  303. package/lib/Transaction.js.map +1 -1
  304. package/lib/TransactionInternal.d.ts +7 -7
  305. package/lib/TransactionInternal.d.ts.map +1 -1
  306. package/lib/TransactionInternal.js +5 -5
  307. package/lib/TransactionInternal.js.map +1 -1
  308. package/lib/TreeCompressor.d.ts +4 -4
  309. package/lib/TreeCompressor.d.ts.map +1 -1
  310. package/lib/TreeCompressor.js +2 -2
  311. package/lib/TreeCompressor.js.map +1 -1
  312. package/lib/TreeNodeHandle.d.ts +3 -3
  313. package/lib/TreeNodeHandle.d.ts.map +1 -1
  314. package/lib/TreeNodeHandle.js +1 -1
  315. package/lib/TreeNodeHandle.js.map +1 -1
  316. package/lib/TreeView.d.ts +3 -3
  317. package/lib/TreeView.d.ts.map +1 -1
  318. package/lib/TreeView.js +3 -3
  319. package/lib/TreeView.js.map +1 -1
  320. package/lib/TreeViewUtilities.d.ts +2 -2
  321. package/lib/TreeViewUtilities.d.ts.map +1 -1
  322. package/lib/TreeViewUtilities.js +1 -1
  323. package/lib/TreeViewUtilities.js.map +1 -1
  324. package/lib/UndoRedoHandler.d.ts +2 -2
  325. package/lib/UndoRedoHandler.d.ts.map +1 -1
  326. package/lib/UndoRedoHandler.js +2 -2
  327. package/lib/UndoRedoHandler.js.map +1 -1
  328. package/lib/UuidUtilities.d.ts +1 -1
  329. package/lib/UuidUtilities.d.ts.map +1 -1
  330. package/lib/UuidUtilities.js +1 -1
  331. package/lib/UuidUtilities.js.map +1 -1
  332. package/lib/id-compressor/AppendOnlySortedMap.js +1 -1
  333. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  334. package/lib/id-compressor/IdCompressor.d.ts +2 -2
  335. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  336. package/lib/id-compressor/IdCompressor.js +6 -6
  337. package/lib/id-compressor/IdCompressor.js.map +1 -1
  338. package/lib/id-compressor/IdRange.d.ts +1 -1
  339. package/lib/id-compressor/IdRange.d.ts.map +1 -1
  340. package/lib/id-compressor/IdRange.js.map +1 -1
  341. package/lib/id-compressor/NumericUuid.d.ts +1 -1
  342. package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
  343. package/lib/id-compressor/NumericUuid.js +2 -2
  344. package/lib/id-compressor/NumericUuid.js.map +1 -1
  345. package/lib/id-compressor/SessionIdNormalizer.d.ts +2 -2
  346. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
  347. package/lib/id-compressor/SessionIdNormalizer.js +2 -2
  348. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
  349. package/lib/id-compressor/index.d.ts +4 -4
  350. package/lib/id-compressor/index.d.ts.map +1 -1
  351. package/lib/id-compressor/index.js +3 -3
  352. package/lib/id-compressor/index.js.map +1 -1
  353. package/lib/id-compressor/persisted-types/0.0.1.d.ts +1 -1
  354. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  355. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  356. package/lib/id-compressor/persisted-types/index.d.ts +1 -1
  357. package/lib/id-compressor/persisted-types/index.d.ts.map +1 -1
  358. package/lib/id-compressor/persisted-types/index.js.map +1 -1
  359. package/lib/index.d.ts +29 -29
  360. package/lib/index.d.ts.map +1 -1
  361. package/lib/index.js +22 -22
  362. package/lib/index.js.map +1 -1
  363. package/lib/migration-shim/migrationDeltaHandler.d.ts +1 -1
  364. package/lib/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
  365. package/lib/migration-shim/migrationDeltaHandler.js +5 -8
  366. package/lib/migration-shim/migrationDeltaHandler.js.map +1 -1
  367. package/lib/migration-shim/migrationShim.d.ts +1 -1
  368. package/lib/migration-shim/migrationShim.d.ts.map +1 -1
  369. package/lib/migration-shim/migrationShim.js +1 -1
  370. package/lib/migration-shim/migrationShim.js.map +1 -1
  371. package/lib/migration-shim/migrationShimFactory.d.ts +1 -1
  372. package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
  373. package/lib/migration-shim/migrationShimFactory.js.map +1 -1
  374. package/lib/migration-shim/sharedTreeDeltaHandler.d.ts +1 -1
  375. package/lib/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
  376. package/lib/migration-shim/sharedTreeDeltaHandler.js +2 -5
  377. package/lib/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
  378. package/lib/migration-shim/types.d.ts +1 -1
  379. package/lib/migration-shim/types.d.ts.map +1 -1
  380. package/lib/migration-shim/types.js.map +1 -1
  381. package/lib/persisted-types/0.0.2.d.ts +1 -1
  382. package/lib/persisted-types/0.0.2.d.ts.map +1 -1
  383. package/lib/persisted-types/0.0.2.js.map +1 -1
  384. package/lib/persisted-types/0.1.1.d.ts +4 -4
  385. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  386. package/lib/persisted-types/0.1.1.js +2 -2
  387. package/lib/persisted-types/0.1.1.js.map +1 -1
  388. package/lib/persisted-types/index.d.ts +2 -2
  389. package/lib/persisted-types/index.d.ts.map +1 -1
  390. package/lib/persisted-types/index.js +2 -2
  391. package/lib/persisted-types/index.js.map +1 -1
  392. package/lib/test/AppendOnlySortedMap.perf.tests.js +2 -2
  393. package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -1
  394. package/lib/test/AppendOnlySortedMap.tests.js +2 -2
  395. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
  396. package/lib/test/ChangeCompression.tests.js +9 -9
  397. package/lib/test/ChangeCompression.tests.js.map +1 -1
  398. package/lib/test/Checkout.tests.d.ts +1 -1
  399. package/lib/test/Checkout.tests.d.ts.map +1 -1
  400. package/lib/test/Checkout.tests.js +2 -2
  401. package/lib/test/Checkout.tests.js.map +1 -1
  402. package/lib/test/Common.tests.js +1 -1
  403. package/lib/test/Common.tests.js.map +1 -1
  404. package/lib/test/EagerCheckout.tests.js +4 -4
  405. package/lib/test/EagerCheckout.tests.js.map +1 -1
  406. package/lib/test/Edit.tests.js +2 -2
  407. package/lib/test/Edit.tests.js.map +1 -1
  408. package/lib/test/EditLog.perf.tests.js +4 -4
  409. package/lib/test/EditLog.perf.tests.js.map +1 -1
  410. package/lib/test/EditLog.tests.js +3 -3
  411. package/lib/test/EditLog.tests.js.map +1 -1
  412. package/lib/test/EditUtilities.tests.js +6 -6
  413. package/lib/test/EditUtilities.tests.js.map +1 -1
  414. package/lib/test/Forest.perf.tests.js +4 -4
  415. package/lib/test/Forest.perf.tests.js.map +1 -1
  416. package/lib/test/Forest.tests.js +2 -2
  417. package/lib/test/Forest.tests.js.map +1 -1
  418. package/lib/test/GenericTransaction.tests.js +3 -3
  419. package/lib/test/GenericTransaction.tests.js.map +1 -1
  420. package/lib/test/HistoryEditFactory.tests.js +4 -4
  421. package/lib/test/HistoryEditFactory.tests.js.map +1 -1
  422. package/lib/test/IdCompressor.perf.tests.js +4 -4
  423. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  424. package/lib/test/IdCompressor.tests.js +7 -7
  425. package/lib/test/IdCompressor.tests.js.map +1 -1
  426. package/lib/test/IdConversion.tests.js +3 -3
  427. package/lib/test/IdConversion.tests.js.map +1 -1
  428. package/lib/test/LazyCheckout.tests.js +4 -4
  429. package/lib/test/LazyCheckout.tests.js.map +1 -1
  430. package/lib/test/LogViewer.tests.js +12 -12
  431. package/lib/test/LogViewer.tests.js.map +1 -1
  432. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +6 -6
  433. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
  434. package/lib/test/NumericUuid.perf.tests.js +3 -3
  435. package/lib/test/NumericUuid.perf.tests.js.map +1 -1
  436. package/lib/test/NumericUuid.tests.js +4 -4
  437. package/lib/test/NumericUuid.tests.js.map +1 -1
  438. package/lib/test/RevisionValueCache.tests.js +2 -2
  439. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  440. package/lib/test/RevisionView.tests.js +6 -6
  441. package/lib/test/RevisionView.tests.js.map +1 -1
  442. package/lib/test/SessionIdNormalizer.tests.js +3 -3
  443. package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
  444. package/lib/test/SharedTree.fuzz.tests.js +1 -1
  445. package/lib/test/SharedTree.fuzz.tests.js.map +1 -1
  446. package/lib/test/SharedTree.perf.tests.js +2 -2
  447. package/lib/test/SharedTree.perf.tests.js.map +1 -1
  448. package/lib/test/SharedTree.tests.js +7 -7
  449. package/lib/test/SharedTree.tests.js.map +1 -1
  450. package/lib/test/StringInterner.tests.js +1 -1
  451. package/lib/test/StringInterner.tests.js.map +1 -1
  452. package/lib/test/Summary.tests.d.ts +2 -2
  453. package/lib/test/Summary.tests.d.ts.map +1 -1
  454. package/lib/test/Summary.tests.js +14 -14
  455. package/lib/test/Summary.tests.js.map +1 -1
  456. package/lib/test/Transaction.tests.js +5 -5
  457. package/lib/test/Transaction.tests.js.map +1 -1
  458. package/lib/test/TransactionInternal.tests.js +7 -7
  459. package/lib/test/TransactionInternal.tests.js.map +1 -1
  460. package/lib/test/TreeCompression.tests.js +8 -8
  461. package/lib/test/TreeCompression.tests.js.map +1 -1
  462. package/lib/test/TreeView.tests.js +3 -3
  463. package/lib/test/TreeView.tests.js.map +1 -1
  464. package/lib/test/UndoRedoHandler.tests.js +2 -2
  465. package/lib/test/UndoRedoHandler.tests.js.map +1 -1
  466. package/lib/test/fuzz/Generators.d.ts +1 -1
  467. package/lib/test/fuzz/Generators.d.ts.map +1 -1
  468. package/lib/test/fuzz/Generators.js +4 -4
  469. package/lib/test/fuzz/Generators.js.map +1 -1
  470. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +1 -1
  471. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  472. package/lib/test/fuzz/SharedTreeFuzzTests.js +5 -5
  473. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  474. package/lib/test/fuzz/Types.d.ts +6 -6
  475. package/lib/test/fuzz/Types.d.ts.map +1 -1
  476. package/lib/test/fuzz/Types.js.map +1 -1
  477. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +6 -6
  478. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  479. package/lib/test/utilities/IdCompressorTestUtilities.js +6 -6
  480. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  481. package/lib/test/utilities/MockTransaction.d.ts +4 -4
  482. package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
  483. package/lib/test/utilities/MockTransaction.js +3 -3
  484. package/lib/test/utilities/MockTransaction.js.map +1 -1
  485. package/lib/test/utilities/PendingLocalStateTests.d.ts +1 -1
  486. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  487. package/lib/test/utilities/PendingLocalStateTests.js +5 -5
  488. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  489. package/lib/test/utilities/SharedTreeTests.d.ts +2 -2
  490. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  491. package/lib/test/utilities/SharedTreeTests.js +22 -22
  492. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  493. package/lib/test/utilities/SharedTreeVersioningTests.d.ts +1 -1
  494. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  495. package/lib/test/utilities/SharedTreeVersioningTests.js +10 -10
  496. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  497. package/lib/test/utilities/SummaryLoadPerfTests.js +6 -6
  498. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  499. package/lib/test/utilities/SummarySizeTests.d.ts +1 -1
  500. package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -1
  501. package/lib/test/utilities/SummarySizeTests.js +5 -5
  502. package/lib/test/utilities/SummarySizeTests.js.map +1 -1
  503. package/lib/test/utilities/TestNode.d.ts +6 -6
  504. package/lib/test/utilities/TestNode.d.ts.map +1 -1
  505. package/lib/test/utilities/TestNode.js +5 -5
  506. package/lib/test/utilities/TestNode.js.map +1 -1
  507. package/lib/test/utilities/TestUtilities.d.ts +12 -12
  508. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  509. package/lib/test/utilities/TestUtilities.js +18 -19
  510. package/lib/test/utilities/TestUtilities.js.map +1 -1
  511. package/lib/test/utilities/UndoRedoTests.d.ts +2 -2
  512. package/lib/test/utilities/UndoRedoTests.d.ts.map +1 -1
  513. package/lib/test/utilities/UndoRedoTests.js +7 -7
  514. package/lib/test/utilities/UndoRedoTests.js.map +1 -1
  515. package/package.json +57 -31
  516. package/src/ChangeCompression.ts +7 -7
  517. package/src/ChangeTypes.ts +5 -5
  518. package/src/Checkout.ts +13 -13
  519. package/src/Common.ts +2 -2
  520. package/src/EagerCheckout.ts +3 -3
  521. package/src/EditLog.ts +6 -7
  522. package/src/EditUtilities.ts +10 -10
  523. package/src/Forest.ts +4 -4
  524. package/src/HistoryEditFactory.ts +11 -11
  525. package/src/IdConversion.ts +4 -4
  526. package/src/InitialTree.ts +3 -3
  527. package/src/LazyCheckout.ts +5 -5
  528. package/src/LogViewer.ts +8 -8
  529. package/src/MergeHealth.ts +6 -6
  530. package/src/NodeIdUtilities.ts +4 -4
  531. package/src/PayloadUtilities.ts +1 -1
  532. package/src/ReconciliationPath.ts +3 -3
  533. package/src/RevisionValueCache.ts +1 -1
  534. package/src/RevisionView.ts +7 -7
  535. package/src/SerializationUtilities.ts +5 -5
  536. package/src/SharedTree.ts +34 -54
  537. package/src/SharedTreeEncoder.ts +15 -15
  538. package/src/StringInterner.ts +2 -2
  539. package/src/Summary.ts +5 -5
  540. package/src/SummaryBackCompatibility.ts +10 -5
  541. package/src/SummaryTestUtilities.ts +3 -3
  542. package/src/Transaction.ts +8 -8
  543. package/src/TransactionInternal.ts +8 -8
  544. package/src/TreeCompressor.ts +6 -6
  545. package/src/TreeNodeHandle.ts +4 -4
  546. package/src/TreeView.ts +4 -4
  547. package/src/TreeViewUtilities.ts +3 -3
  548. package/src/UndoRedoHandler.ts +4 -4
  549. package/src/UuidUtilities.ts +2 -2
  550. package/src/id-compressor/AppendOnlySortedMap.ts +1 -1
  551. package/src/id-compressor/IdCompressor.ts +8 -8
  552. package/src/id-compressor/IdRange.ts +1 -1
  553. package/src/id-compressor/NumericUuid.ts +3 -3
  554. package/src/id-compressor/SessionIdNormalizer.ts +4 -4
  555. package/src/id-compressor/index.ts +4 -4
  556. package/src/id-compressor/persisted-types/0.0.1.ts +1 -1
  557. package/src/id-compressor/persisted-types/index.ts +1 -1
  558. package/src/index.ts +29 -29
  559. package/src/migration-shim/migrationDeltaHandler.ts +9 -10
  560. package/src/migration-shim/migrationShim.ts +7 -5
  561. package/src/migration-shim/migrationShimFactory.ts +4 -1
  562. package/src/migration-shim/sharedTreeDeltaHandler.ts +7 -6
  563. package/src/migration-shim/types.ts +1 -1
  564. package/src/persisted-types/0.0.2.ts +1 -1
  565. package/src/persisted-types/0.1.1.ts +4 -4
  566. package/src/persisted-types/index.ts +2 -2
  567. package/tsconfig.esnext.json +1 -2
  568. package/tsconfig.json +3 -0
  569. package/lib/test/Attach.tests.d.ts +0 -6
  570. package/lib/test/Attach.tests.d.ts.map +0 -1
  571. package/lib/test/Attach.tests.js +0 -52
  572. package/lib/test/Attach.tests.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NodeIdUtilities.js","sourceRoot":"","sources":["../src/NodeIdUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAA0D;AAG1D,qCAA6C;AA6F7C;;;GAGG;AACH,SAAgB,iBAAiB,CAChC,YAAmC,EACnC,SAAqB;IAErB,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/D,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE,CAC/B,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,IAAI,YAAY,CAAC,cAAc,CAAC;KACnF,CAAC;AACH,CAAC;AATD,8CASC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACpC,YAAmC;IAEnC,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC1B,MAAM,UAAU,GAAG,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;YACvD,IAAA,0BAAiB,EAAC,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC/B,MAAM,UAAU,GAAG,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;YACzF,IAAA,0BAAiB,EAAC,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC;AAfD,sDAeC;AAED,SAAgB,gBAAgB,CAAC,UAAwB;IACxD,OAAO;QACN,cAAc,EAAE,CAAC,QAAiB,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,QAAQ,CAAW;QAC1F,eAAe,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAW;QAC1E,kBAAkB,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAuB;QAC5F,qBAAqB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAiB;QAChF,wBAAwB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAiB;QACtF,kBAAkB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAkB;QACtF,uBAAuB,EAAE,CAAC,EAAiB,EAAE,SAAoB,EAAE,EAAE,CACpE,UAAU,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,CAAW;QAC5D,cAAc,EAAE,UAAU,CAAC,cAAc;KACzC,CAAC;AACH,CAAC;AAZD,4CAYC;AAED,+EAA+E;AAC/E,SAAgB,SAAS,CAA8B,IAAyB;IAC/E,OAAQ,IAAsB,CAAC,UAAU,IAAK,IAAY,CAAC;AAC5D,CAAC;AAFD,8BAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IdCompressor, isFinalId } from './id-compressor';\nimport { FinalNodeId, NodeId, OpSpaceNodeId, SessionId, StableNodeId } from './Identifiers';\nimport { NodeData } from './persisted-types';\nimport { assertWithMessage } from './Common';\n\n/**\n * An object which can generate node IDs and convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdContext extends NodeIdGenerator, NodeIdConverter {}\n\n/**\n * An object which can generate node IDs\n * @alpha\n */\nexport interface NodeIdGenerator {\n\t/**\n\t * Generates a node identifier.\n\t * The returned IDs may be used as the identifier of a node in the SharedTree.\n\t * `NodeId`s are *always* unique and stable within the scope of the tree and session that generated them. They are *not* unique within\n\t * a Fluid container, and *cannot* be compared across instances of a SharedTree. They are *not* stable across sessions/lifetimes of a\n\t * SharedTree, and *cannot* be persisted (e.g. stored in payloads, uploaded in blobs, etc.). If stable persistence is needed,\n\t * NodeIdConverter.convertToStableNodeId may be used to return a corresponding UUID that is globally unique and stable.\n\t * @param override - if supplied, calls to `convertToStableNodeId` using the returned node ID will return the override instead of\n\t * the UUID. Calls to `generateNodeId` with the same override always return the same ID. Performance note: passing an override string\n\t * incurs a storage cost that is significantly higher that a node ID without one, and should be avoided if possible.\n\t */\n\tgenerateNodeId(override?: string): NodeId;\n}\n\n/**\n * An object which can convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdConverter {\n\t/**\n\t * Given a NodeId, returns the corresponding stable ID or throws if the supplied node ID was not generated with this tree (`NodeId`s\n\t * may not be used across SharedTree instances, see `generateNodeId` for more).\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The result is safe to persist and re-use across `SharedTree` instances, unlike `NodeId`.\n\t */\n\tconvertToStableNodeId(id: NodeId): StableNodeId;\n\n\t/**\n\t * Given a NodeId, attempt to return the corresponding stable ID.\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The returned stable ID is undefined if `id` was never created with this SharedTree. If a stable ID is returned, this does not imply\n\t * that there is a node with `id` in the current revision of the tree, only that `id` was at some point generated by some instance of\n\t * this tree.\n\t */\n\ttryConvertToStableNodeId(id: NodeId): StableNodeId | undefined;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or throws if the supplied stable ID was never generated with this tree, either\n\t * as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\tconvertToNodeId(id: StableNodeId): NodeId;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree,\n\t * either as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\ttryConvertToNodeId(id: StableNodeId): NodeId | undefined;\n}\n\n/**\n * An object which can normalize node IDs. See docs on {@link IdCompressor} for semantics of normalization.\n */\nexport interface NodeIdNormalizer<TId extends OpSpaceNodeId> {\n\tlocalSessionId: SessionId;\n\t/**\n\t * Normalizes the given ID to op space\n\t */\n\tnormalizeToOpSpace(id: NodeId): TId;\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId, sessionId: SessionId): NodeId;\n}\n\n/**\n * An object which can normalize node IDs. It is contextualized to a known session context, and therefore\n * can normalize IDs into session space without requiring any additional information.\n */\nexport interface ContextualizedNodeIdNormalizer<TId extends OpSpaceNodeId>\n\textends Omit<NodeIdNormalizer<TId>, 'localSessionId' | 'normalizeToSessionSpace'> {\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId): NodeId;\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses either the given session ID to normalize IDs\n * to session space. If no ID is given, it will use the local session ID belonging to the normalizer.\n */\nexport function scopeIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>,\n\tsessionId?: SessionId\n): ContextualizedNodeIdNormalizer<TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => idNormalizer.normalizeToOpSpace(id),\n\t\tnormalizeToSessionSpace: (id) =>\n\t\t\tidNormalizer.normalizeToSessionSpace(id, sessionId ?? idNormalizer.localSessionId),\n\t};\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses the local session ID belonging to the normalizer\n * to normalize IDs to session space. These IDs are expected to be sequenced, and will fail to normalize if\n * they are not.\n */\nexport function sequencedIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>\n): ContextualizedNodeIdNormalizer<FinalNodeId & TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToOpSpace(id);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t\tnormalizeToSessionSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToSessionSpace(id, idNormalizer.localSessionId);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t};\n}\n\nexport function getNodeIdContext(compressor: IdCompressor): NodeIdContext & NodeIdNormalizer<OpSpaceNodeId> {\n\treturn {\n\t\tgenerateNodeId: (override?: string) => compressor.generateCompressedId(override) as NodeId,\n\t\tconvertToNodeId: (id: StableNodeId) => compressor.recompress(id) as NodeId,\n\t\ttryConvertToNodeId: (id: StableNodeId) => compressor.tryRecompress(id) as NodeId | undefined,\n\t\tconvertToStableNodeId: (id: NodeId) => compressor.decompress(id) as StableNodeId,\n\t\ttryConvertToStableNodeId: (id: NodeId) => compressor.tryDecompress(id) as StableNodeId,\n\t\tnormalizeToOpSpace: (id: NodeId) => compressor.normalizeToOpSpace(id) as OpSpaceNodeId,\n\t\tnormalizeToSessionSpace: (id: OpSpaceNodeId, sessionId: SessionId) =>\n\t\t\tcompressor.normalizeToSessionSpace(id, sessionId) as NodeId,\n\t\tlocalSessionId: compressor.localSessionId,\n\t};\n}\n\n/** Accepts either a node or a node's identifier, and returns the identifier */\nexport function getNodeId<TId extends number | string>(node: TId | NodeData<TId>): TId {\n\treturn (node as NodeData<TId>).identifier ?? (node as TId);\n}\n"]}
1
+ {"version":3,"file":"NodeIdUtilities.js","sourceRoot":"","sources":["../src/NodeIdUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAmE;AAGnE,2CAAgD;AA6FhD;;;GAGG;AACH,SAAgB,iBAAiB,CAChC,YAAmC,EACnC,SAAqB;IAErB,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/D,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE,CAC/B,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,IAAI,YAAY,CAAC,cAAc,CAAC;KACnF,CAAC;AACH,CAAC;AATD,8CASC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACpC,YAAmC;IAEnC,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC1B,MAAM,UAAU,GAAG,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;YACvD,IAAA,6BAAiB,EAAC,IAAA,oBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC/B,MAAM,UAAU,GAAG,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;YACzF,IAAA,6BAAiB,EAAC,IAAA,oBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC;AAfD,sDAeC;AAED,SAAgB,gBAAgB,CAAC,UAAwB;IACxD,OAAO;QACN,cAAc,EAAE,CAAC,QAAiB,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,QAAQ,CAAW;QAC1F,eAAe,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAW;QAC1E,kBAAkB,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAuB;QAC5F,qBAAqB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAiB;QAChF,wBAAwB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAiB;QACtF,kBAAkB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAkB;QACtF,uBAAuB,EAAE,CAAC,EAAiB,EAAE,SAAoB,EAAE,EAAE,CACpE,UAAU,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,CAAW;QAC5D,cAAc,EAAE,UAAU,CAAC,cAAc;KACzC,CAAC;AACH,CAAC;AAZD,4CAYC;AAED,+EAA+E;AAC/E,SAAgB,SAAS,CAA8B,IAAyB;IAC/E,OAAQ,IAAsB,CAAC,UAAU,IAAK,IAAY,CAAC;AAC5D,CAAC;AAFD,8BAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IdCompressor, isFinalId } from './id-compressor/index.js';\nimport { FinalNodeId, NodeId, OpSpaceNodeId, SessionId, StableNodeId } from './Identifiers.js';\nimport { NodeData } from './persisted-types/index.js';\nimport { assertWithMessage } from './Common.js';\n\n/**\n * An object which can generate node IDs and convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdContext extends NodeIdGenerator, NodeIdConverter {}\n\n/**\n * An object which can generate node IDs\n * @alpha\n */\nexport interface NodeIdGenerator {\n\t/**\n\t * Generates a node identifier.\n\t * The returned IDs may be used as the identifier of a node in the SharedTree.\n\t * `NodeId`s are *always* unique and stable within the scope of the tree and session that generated them. They are *not* unique within\n\t * a Fluid container, and *cannot* be compared across instances of a SharedTree. They are *not* stable across sessions/lifetimes of a\n\t * SharedTree, and *cannot* be persisted (e.g. stored in payloads, uploaded in blobs, etc.). If stable persistence is needed,\n\t * NodeIdConverter.convertToStableNodeId may be used to return a corresponding UUID that is globally unique and stable.\n\t * @param override - if supplied, calls to `convertToStableNodeId` using the returned node ID will return the override instead of\n\t * the UUID. Calls to `generateNodeId` with the same override always return the same ID. Performance note: passing an override string\n\t * incurs a storage cost that is significantly higher that a node ID without one, and should be avoided if possible.\n\t */\n\tgenerateNodeId(override?: string): NodeId;\n}\n\n/**\n * An object which can convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdConverter {\n\t/**\n\t * Given a NodeId, returns the corresponding stable ID or throws if the supplied node ID was not generated with this tree (`NodeId`s\n\t * may not be used across SharedTree instances, see `generateNodeId` for more).\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The result is safe to persist and re-use across `SharedTree` instances, unlike `NodeId`.\n\t */\n\tconvertToStableNodeId(id: NodeId): StableNodeId;\n\n\t/**\n\t * Given a NodeId, attempt to return the corresponding stable ID.\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The returned stable ID is undefined if `id` was never created with this SharedTree. If a stable ID is returned, this does not imply\n\t * that there is a node with `id` in the current revision of the tree, only that `id` was at some point generated by some instance of\n\t * this tree.\n\t */\n\ttryConvertToStableNodeId(id: NodeId): StableNodeId | undefined;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or throws if the supplied stable ID was never generated with this tree, either\n\t * as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\tconvertToNodeId(id: StableNodeId): NodeId;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree,\n\t * either as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\ttryConvertToNodeId(id: StableNodeId): NodeId | undefined;\n}\n\n/**\n * An object which can normalize node IDs. See docs on {@link IdCompressor} for semantics of normalization.\n */\nexport interface NodeIdNormalizer<TId extends OpSpaceNodeId> {\n\tlocalSessionId: SessionId;\n\t/**\n\t * Normalizes the given ID to op space\n\t */\n\tnormalizeToOpSpace(id: NodeId): TId;\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId, sessionId: SessionId): NodeId;\n}\n\n/**\n * An object which can normalize node IDs. It is contextualized to a known session context, and therefore\n * can normalize IDs into session space without requiring any additional information.\n */\nexport interface ContextualizedNodeIdNormalizer<TId extends OpSpaceNodeId>\n\textends Omit<NodeIdNormalizer<TId>, 'localSessionId' | 'normalizeToSessionSpace'> {\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId): NodeId;\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses either the given session ID to normalize IDs\n * to session space. If no ID is given, it will use the local session ID belonging to the normalizer.\n */\nexport function scopeIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>,\n\tsessionId?: SessionId\n): ContextualizedNodeIdNormalizer<TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => idNormalizer.normalizeToOpSpace(id),\n\t\tnormalizeToSessionSpace: (id) =>\n\t\t\tidNormalizer.normalizeToSessionSpace(id, sessionId ?? idNormalizer.localSessionId),\n\t};\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses the local session ID belonging to the normalizer\n * to normalize IDs to session space. These IDs are expected to be sequenced, and will fail to normalize if\n * they are not.\n */\nexport function sequencedIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>\n): ContextualizedNodeIdNormalizer<FinalNodeId & TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToOpSpace(id);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t\tnormalizeToSessionSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToSessionSpace(id, idNormalizer.localSessionId);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t};\n}\n\nexport function getNodeIdContext(compressor: IdCompressor): NodeIdContext & NodeIdNormalizer<OpSpaceNodeId> {\n\treturn {\n\t\tgenerateNodeId: (override?: string) => compressor.generateCompressedId(override) as NodeId,\n\t\tconvertToNodeId: (id: StableNodeId) => compressor.recompress(id) as NodeId,\n\t\ttryConvertToNodeId: (id: StableNodeId) => compressor.tryRecompress(id) as NodeId | undefined,\n\t\tconvertToStableNodeId: (id: NodeId) => compressor.decompress(id) as StableNodeId,\n\t\ttryConvertToStableNodeId: (id: NodeId) => compressor.tryDecompress(id) as StableNodeId,\n\t\tnormalizeToOpSpace: (id: NodeId) => compressor.normalizeToOpSpace(id) as OpSpaceNodeId,\n\t\tnormalizeToSessionSpace: (id: OpSpaceNodeId, sessionId: SessionId) =>\n\t\t\tcompressor.normalizeToSessionSpace(id, sessionId) as NodeId,\n\t\tlocalSessionId: compressor.localSessionId,\n\t};\n}\n\n/** Accepts either a node or a node's identifier, and returns the identifier */\nexport function getNodeId<TId extends number | string>(node: TId | NodeData<TId>): TId {\n\treturn (node as NodeData<TId>).identifier ?? (node as TId);\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { Payload } from './persisted-types';
5
+ import { Payload } from './persisted-types/index.js';
6
6
  /**
7
7
  * @returns true if two `Payloads` are identical.
8
8
  * May return false for equivalent payloads encoded differently.
@@ -1 +1 @@
1
- {"version":3,"file":"PayloadUtilities.d.ts","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA+E/D"}
1
+ {"version":3,"file":"PayloadUtilities.d.ts","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA+E/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"PayloadUtilities.js","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2H;IAC3H,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED,qFAAqF;IACrF,uEAAuE;IACvE,0FAA0F;IAC1F,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,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AC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACb;QACD,IAAI,CAAC,KAAK,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AA/ED,0CA+EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { Payload } from './persisted-types';\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @alpha\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (a instanceof Array !== b instanceof Array) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!(a instanceof Array)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"file":"PayloadUtilities.js","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2H;IAC3H,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED,qFAAqF;IACrF,uEAAuE;IACvE,0FAA0F;IAC1F,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,wEAAwE;IACxE,6HAA6H;IAC7H;QACC,MAAM,OAAO,GAAG,CAAiB,CAAC;QAClC,MAAM,OAAO,GAAG,CAAiB,CAAC;QAClC,IAAI,OAAO,CAAC,YAAY,KAAK,CAAC,EAAE;YAC/B,IAAI,OAAO,CAAC,YAAY,KAAK,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAA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AI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AA/ED,0CA+EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { Payload } from './persisted-types/index.js';\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @alpha\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (a instanceof Array !== b instanceof Array) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!(a instanceof Array)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ChangeInternal } from './persisted-types';
6
- import { TransactionView } from './RevisionView';
7
- import { TreeView } from './TreeView';
5
+ import { ChangeInternal } from './persisted-types/index.js';
6
+ import { TransactionView } from './RevisionView.js';
7
+ import { TreeView } from './TreeView.js';
8
8
  /**
9
9
  * The path of edits from the revision view where a change was meant to have been applied to the view where the edit that contains the
10
10
  * change is actually applied.
@@ -1 +1 @@
1
- {"version":3,"file":"ReconciliationPath.d.ts","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CAChC"}
1
+ {"version":3,"file":"ReconciliationPath.d.ts","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReconciliationPath.js","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChangeInternal } from './persisted-types';\nimport { TransactionView } from './RevisionView';\nimport { TreeView } from './TreeView';\n\n/**\n * The path of edits from the revision view where a change was meant to have been applied to the view where the edit that contains the\n * change is actually applied.\n * The path only contains edits that were successfully applied.\n * This path is always empty for a change that has no concurrent edits.\n * @alpha\n */\nexport interface ReconciliationPath {\n\t/**\n\t * The number of edits in the path.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to edit information.\n\t * @returns Reconciliation information for the edit at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationEdit;\n}\n\n/**\n * An edit in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationEdit {\n\t/**\n\t * The state before the edit was applied.\n\t */\n\treadonly before: TreeView;\n\t/**\n\t * The state after the edit was applied.\n\t */\n\treadonly after: TreeView;\n\t/**\n\t * The number of changes in the edit.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to change information.\n\t * @returns Reconciliation information for the change at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationChange;\n}\n\n/**\n * A change in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationChange {\n\t/**\n\t * The resolved change that was applied during the edit.\n\t * Resolved changes are guaranteed to be expressed with valid tree locations instead of anchors that need resolution.\n\t */\n\treadonly resolvedChange: ChangeInternal;\n\t/**\n\t * The resulting view from applying the resolved change.\n\t */\n\treadonly after: TransactionView;\n}\n"]}
1
+ {"version":3,"file":"ReconciliationPath.js","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChangeInternal } from './persisted-types/index.js';\nimport { TransactionView } from './RevisionView.js';\nimport { TreeView } from './TreeView.js';\n\n/**\n * The path of edits from the revision view where a change was meant to have been applied to the view where the edit that contains the\n * change is actually applied.\n * The path only contains edits that were successfully applied.\n * This path is always empty for a change that has no concurrent edits.\n * @alpha\n */\nexport interface ReconciliationPath {\n\t/**\n\t * The number of edits in the path.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to edit information.\n\t * @returns Reconciliation information for the edit at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationEdit;\n}\n\n/**\n * An edit in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationEdit {\n\t/**\n\t * The state before the edit was applied.\n\t */\n\treadonly before: TreeView;\n\t/**\n\t * The state after the edit was applied.\n\t */\n\treadonly after: TreeView;\n\t/**\n\t * The number of changes in the edit.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to change information.\n\t * @returns Reconciliation information for the change at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationChange;\n}\n\n/**\n * A change in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationChange {\n\t/**\n\t * The resolved change that was applied during the edit.\n\t * Resolved changes are guaranteed to be expressed with valid tree locations instead of anchors that need resolution.\n\t */\n\treadonly resolvedChange: ChangeInternal;\n\t/**\n\t * The resulting view from applying the resolved change.\n\t */\n\treadonly after: TransactionView;\n}\n"]}
@@ -11,7 +11,7 @@ exports.RevisionValueCache = void 0;
11
11
  const core_utils_1 = require("@fluidframework/core-utils");
12
12
  const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
13
13
  const lru_cache_1 = __importDefault(require("lru-cache"));
14
- const Common_1 = require("./Common");
14
+ const Common_js_1 = require("./Common.js");
15
15
  /**
16
16
  * A cache of `TValue`s corresponding to `Revision`s.
17
17
  *
@@ -46,17 +46,17 @@ class RevisionValueCache {
46
46
  * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).
47
47
  * Contains all cached values, regardless of why they are cached (retained, LRU or window).
48
48
  */
49
- this.sortedEntries = new sorted_btree_es6_1.BTree(undefined, Common_1.compareFiniteNumbers);
49
+ this.sortedEntries = new sorted_btree_es6_1.BTree(undefined, Common_js_1.compareFiniteNumbers);
50
50
  (0, core_utils_1.assert)(retentionWindowStart >= 0, 0x62c /* retentionWindowStart must be initialized >= 0 */);
51
51
  this.evictableRevisions = new lru_cache_1.default({
52
52
  max: evictableSize,
53
53
  noDisposeOnSet: true,
54
54
  dispose: (revision) => {
55
55
  if (revision >= this.retentionWindowStart) {
56
- (0, Common_1.fail)('Entries in retention window should never be evicted.');
56
+ (0, Common_js_1.fail)('Entries in retention window should never be evicted.');
57
57
  }
58
58
  if (this.retainedRevision === revision) {
59
- (0, Common_1.fail)('Retained entries should not be evicted');
59
+ (0, Common_js_1.fail)('Retained entries should not be evicted');
60
60
  }
61
61
  this.sortedEntries.delete(revision);
62
62
  },
@@ -77,7 +77,7 @@ class RevisionValueCache {
77
77
  */
78
78
  updateRetentionWindow(newRetentionWindowStart) {
79
79
  if (newRetentionWindowStart < this.retentionWindowStart) {
80
- (0, Common_1.fail)('retention window boundary must not move backwards');
80
+ (0, Common_js_1.fail)('retention window boundary must not move backwards');
81
81
  }
82
82
  const prevRetentionWindowStart = this.retentionWindowStart;
83
83
  this.retentionWindowStart = newRetentionWindowStart;
@@ -1 +1 @@
1
- {"version":3,"file":"RevisionValueCache.js","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AACpD,gEAAkD;AAClD,0DAA4B;AAC5B,qCAAsD;AAetD;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAqB9B;IACC;;OAEG;IACH,aAAqB;IACrB;;;OAGG;IACK,oBAA8B;IACtC;;OAEG;IACH,gBAAqC;QAJ7B,yBAAoB,GAApB,oBAAoB,CAAU;QA7BvC;;;;WAIG;QACc,kBAAa,GAAG,IAAI,wBAAK,CAAmB,SAAS,EAAE,6BAAoB,CAAC,CAAC;QA8B7F,IAAA,mBAAM,EAAC,oBAAoB,IAAI,CAAC,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAC7F,IAAI,CAAC,kBAAkB,GAAG,IAAI,mBAAG,CAAC;YACjC,GAAG,EAAE,aAAa;YAClB,cAAc,EAAE,IAAI;YACpB,OAA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CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,iBAA2B;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/D,IAAI,OAAO,KAAK,SAAS,EAAE;YAC1B,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,SAAS,CAAC;IAC9E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,QAAkB,EAAE,KAAa;QAC1D,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,EAAE;YACxC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACjD;QACD,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;QACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAkB,EAAE,KAAa;QAClD,IAAI,IAAI,CAAC,gBAAgB,KAAK,QAAQ,EAAE;YACvC,OAAO;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CACD;AAnID,gDAmIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { BTree } from '@tylerbu/sorted-btree-es6';\nimport LRU from 'lru-cache';\nimport { fail, compareFiniteNumbers } from './Common';\n\n/**\n * A revision corresponds to an index in an `EditLog`.\n *\n * It is associated with the output `RevisionView` of applying the edit at the index to the previous revision.\n * For example:\n *\n * - revision 0 corresponds to the initialRevision.\n *\n * - revision 1 corresponds to the output of editLog[0] applied to the initialRevision.\n * @alpha\n */\nexport type Revision = number;\n\n/**\n * A cache of `TValue`s corresponding to `Revision`s.\n *\n * A value is kept in cache if it meets any of the following criteria:\n *\n * - The revision is \\>= `retentionWindowStart`\n *\n * - The value has been used recently, meaning getClosestEntry or cacheValue was called with its revision. Note that\n * being returned when a large revision was passed to getClosestEntry does not count.\n *\n * - The value is `retained` meaning it was provided to to constructor in retainedEntries or passed to\n * `cacheRetainedValue`\n */\nexport class RevisionValueCache<TValue> {\n\t/**\n\t * A cache of entries for revisions.\n\t * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).\n\t * Contains all cached values, regardless of why they are cached (retained, LRU or window).\n\t */\n\tprivate readonly sortedEntries = new BTree<Revision, TValue>(undefined, compareFiniteNumbers);\n\n\t/**\n\t * Cache of most recently used evictable entries.\n\t * Subset of `sortedValues` eligible for eviction:\n\t * All entries are also in `sortedValues`, and are removed from `sortedValues` when evicted from this cache.\n\t * Evicts least recently used entries.\n\t */\n\tprivate readonly evictableRevisions: LRU<Revision, TValue>;\n\n\t/**\n\t * The oldest revision that must be retained in memory.\n\t */\n\tprivate retainedRevision?: Revision;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Maximum capacity for evictable cache entries (those neither marked as retained nor within the retention window).\n\t\t */\n\t\tevictableSize: number,\n\t\t/**\n\t\t * The first revision within the retention window. All entries with revisions \\>= retentionWindowStart will be retained.\n\t\t * Must be \\>= 0.\n\t\t */\n\t\tprivate retentionWindowStart: Revision,\n\t\t/**\n\t\t * The oldest revision that must be retained in memory.\n\t\t */\n\t\tretainedRevision?: [Revision, TValue]\n\t) {\n\t\tassert(retentionWindowStart >= 0, 0x62c /* retentionWindowStart must be initialized >= 0 */);\n\t\tthis.evictableRevisions = new LRU({\n\t\t\tmax: evictableSize,\n\t\t\tnoDisposeOnSet: true,\n\t\t\tdispose: (revision) => {\n\t\t\t\tif (revision >= this.retentionWindowStart) {\n\t\t\t\t\tfail('Entries in retention window should never be evicted.');\n\t\t\t\t}\n\t\t\t\tif (this.retainedRevision === revision) {\n\t\t\t\t\tfail('Retained entries should not be evicted');\n\t\t\t\t}\n\t\t\t\tthis.sortedEntries.delete(revision);\n\t\t\t},\n\t\t});\n\n\t\tif (retainedRevision !== undefined) {\n\t\t\tthis.cacheRetainedValue(retainedRevision[0], retainedRevision[1]);\n\t\t}\n\t}\n\n\t/**\n\t * @returns if the supplied revision is within the retention window.\n\t */\n\tpublic isWithinRetentionWindow(revision: Revision): boolean {\n\t\treturn revision >= this.retentionWindowStart;\n\t}\n\n\t/**\n\t * Sets the new retention window.\n\t * @param newRetentionWindowStart - defines the trailing edge (inclusive) of the new retention window.\n\t */\n\tpublic updateRetentionWindow(newRetentionWindowStart: Revision): void {\n\t\tif (newRetentionWindowStart < this.retentionWindowStart) {\n\t\t\tfail('retention window boundary must not move backwards');\n\t\t}\n\t\tconst prevRetentionWindowStart = this.retentionWindowStart;\n\t\tthis.retentionWindowStart = newRetentionWindowStart;\n\t\tconst oldWindowEntries: [Revision, TValue][] = [];\n\t\tthis.sortedEntries.forRange(\n\t\t\tprevRetentionWindowStart,\n\t\t\tthis.retentionWindowStart,\n\t\t\tfalse,\n\t\t\t(windowRevision, windowEntry) => {\n\t\t\t\tif (this.retainedRevision !== windowRevision) {\n\t\t\t\t\t// Adding to the LRU can cause eviction which in turn mutates the b-tree we are enumerating. Thus, store list of\n\t\t\t\t\t// old window entries separately.\n\t\t\t\t\toldWindowEntries.push([windowRevision, windowEntry]);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\toldWindowEntries.forEach(([revision, value]) => {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t});\n\t}\n\n\t/**\n\t * @returns a [cachedRevision, value] where cachedRevision \\<= requestedRevision, or undefined if no such revision\n\t * is cached.\n\t */\n\tpublic getClosestEntry(requestedRevision: Revision): [revision: Revision, value: TValue] | undefined {\n\t\tconst fromLRU = this.evictableRevisions.get(requestedRevision);\n\t\tif (fromLRU !== undefined) {\n\t\t\treturn [requestedRevision, fromLRU];\n\t\t}\n\t\treturn this.sortedEntries.getPairOrNextLower(requestedRevision) ?? undefined;\n\t}\n\n\t/**\n\t * Caches the supplied value and guarantees it will never be evicted.\n\t * This will make the previously retained value evictable.\n\t */\n\tpublic cacheRetainedValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision !== undefined) {\n\t\t\tthis.sortedEntries.delete(this.retainedRevision);\n\t\t}\n\t\tthis.retainedRevision = revision;\n\t\tthis.sortedEntries.set(revision, value);\n\t}\n\n\t/**\n\t * Caches the supplied value.\n\t * The cached value is subject to eviction unless it is within the retention window or was previously added\n\t * via `cacheRetainedValue`.\n\t * Note that if a non-retained entry starts out within the retention window and passes outside of it due to a call to\n\t * updateRetentionWindow it is then subject to eviction.\n\t */\n\tpublic cacheValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision === revision) {\n\t\t\treturn;\n\t\t}\n\t\tthis.sortedEntries.set(revision, value);\n\t\tif (revision < this.retentionWindowStart) {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"RevisionValueCache.js","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AACpD,gEAAkD;AAClD,0DAA4B;AAC5B,2CAAyD;AAezD;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAqB9B;IACC;;OAEG;IACH,aAAqB;IACrB;;;OAGG;IACK,oBAA8B;IACtC;;OAEG;IACH,gBAAqC;QAJ7B,yBAAoB,G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AAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CACD;AAnID,gDAmIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { BTree } from '@tylerbu/sorted-btree-es6';\nimport LRU from 'lru-cache';\nimport { fail, compareFiniteNumbers } from './Common.js';\n\n/**\n * A revision corresponds to an index in an `EditLog`.\n *\n * It is associated with the output `RevisionView` of applying the edit at the index to the previous revision.\n * For example:\n *\n * - revision 0 corresponds to the initialRevision.\n *\n * - revision 1 corresponds to the output of editLog[0] applied to the initialRevision.\n * @alpha\n */\nexport type Revision = number;\n\n/**\n * A cache of `TValue`s corresponding to `Revision`s.\n *\n * A value is kept in cache if it meets any of the following criteria:\n *\n * - The revision is \\>= `retentionWindowStart`\n *\n * - The value has been used recently, meaning getClosestEntry or cacheValue was called with its revision. Note that\n * being returned when a large revision was passed to getClosestEntry does not count.\n *\n * - The value is `retained` meaning it was provided to to constructor in retainedEntries or passed to\n * `cacheRetainedValue`\n */\nexport class RevisionValueCache<TValue> {\n\t/**\n\t * A cache of entries for revisions.\n\t * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).\n\t * Contains all cached values, regardless of why they are cached (retained, LRU or window).\n\t */\n\tprivate readonly sortedEntries = new BTree<Revision, TValue>(undefined, compareFiniteNumbers);\n\n\t/**\n\t * Cache of most recently used evictable entries.\n\t * Subset of `sortedValues` eligible for eviction:\n\t * All entries are also in `sortedValues`, and are removed from `sortedValues` when evicted from this cache.\n\t * Evicts least recently used entries.\n\t */\n\tprivate readonly evictableRevisions: LRU<Revision, TValue>;\n\n\t/**\n\t * The oldest revision that must be retained in memory.\n\t */\n\tprivate retainedRevision?: Revision;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Maximum capacity for evictable cache entries (those neither marked as retained nor within the retention window).\n\t\t */\n\t\tevictableSize: number,\n\t\t/**\n\t\t * The first revision within the retention window. All entries with revisions \\>= retentionWindowStart will be retained.\n\t\t * Must be \\>= 0.\n\t\t */\n\t\tprivate retentionWindowStart: Revision,\n\t\t/**\n\t\t * The oldest revision that must be retained in memory.\n\t\t */\n\t\tretainedRevision?: [Revision, TValue]\n\t) {\n\t\tassert(retentionWindowStart >= 0, 0x62c /* retentionWindowStart must be initialized >= 0 */);\n\t\tthis.evictableRevisions = new LRU({\n\t\t\tmax: evictableSize,\n\t\t\tnoDisposeOnSet: true,\n\t\t\tdispose: (revision) => {\n\t\t\t\tif (revision >= this.retentionWindowStart) {\n\t\t\t\t\tfail('Entries in retention window should never be evicted.');\n\t\t\t\t}\n\t\t\t\tif (this.retainedRevision === revision) {\n\t\t\t\t\tfail('Retained entries should not be evicted');\n\t\t\t\t}\n\t\t\t\tthis.sortedEntries.delete(revision);\n\t\t\t},\n\t\t});\n\n\t\tif (retainedRevision !== undefined) {\n\t\t\tthis.cacheRetainedValue(retainedRevision[0], retainedRevision[1]);\n\t\t}\n\t}\n\n\t/**\n\t * @returns if the supplied revision is within the retention window.\n\t */\n\tpublic isWithinRetentionWindow(revision: Revision): boolean {\n\t\treturn revision >= this.retentionWindowStart;\n\t}\n\n\t/**\n\t * Sets the new retention window.\n\t * @param newRetentionWindowStart - defines the trailing edge (inclusive) of the new retention window.\n\t */\n\tpublic updateRetentionWindow(newRetentionWindowStart: Revision): void {\n\t\tif (newRetentionWindowStart < this.retentionWindowStart) {\n\t\t\tfail('retention window boundary must not move backwards');\n\t\t}\n\t\tconst prevRetentionWindowStart = this.retentionWindowStart;\n\t\tthis.retentionWindowStart = newRetentionWindowStart;\n\t\tconst oldWindowEntries: [Revision, TValue][] = [];\n\t\tthis.sortedEntries.forRange(\n\t\t\tprevRetentionWindowStart,\n\t\t\tthis.retentionWindowStart,\n\t\t\tfalse,\n\t\t\t(windowRevision, windowEntry) => {\n\t\t\t\tif (this.retainedRevision !== windowRevision) {\n\t\t\t\t\t// Adding to the LRU can cause eviction which in turn mutates the b-tree we are enumerating. Thus, store list of\n\t\t\t\t\t// old window entries separately.\n\t\t\t\t\toldWindowEntries.push([windowRevision, windowEntry]);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\toldWindowEntries.forEach(([revision, value]) => {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t});\n\t}\n\n\t/**\n\t * @returns a [cachedRevision, value] where cachedRevision \\<= requestedRevision, or undefined if no such revision\n\t * is cached.\n\t */\n\tpublic getClosestEntry(requestedRevision: Revision): [revision: Revision, value: TValue] | undefined {\n\t\tconst fromLRU = this.evictableRevisions.get(requestedRevision);\n\t\tif (fromLRU !== undefined) {\n\t\t\treturn [requestedRevision, fromLRU];\n\t\t}\n\t\treturn this.sortedEntries.getPairOrNextLower(requestedRevision) ?? undefined;\n\t}\n\n\t/**\n\t * Caches the supplied value and guarantees it will never be evicted.\n\t * This will make the previously retained value evictable.\n\t */\n\tpublic cacheRetainedValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision !== undefined) {\n\t\t\tthis.sortedEntries.delete(this.retainedRevision);\n\t\t}\n\t\tthis.retainedRevision = revision;\n\t\tthis.sortedEntries.set(revision, value);\n\t}\n\n\t/**\n\t * Caches the supplied value.\n\t * The cached value is subject to eviction unless it is within the retention window or was previously added\n\t * via `cacheRetainedValue`.\n\t * Note that if a non-retained entry starts out within the retention window and passes outside of it due to a call to\n\t * updateRetentionWindow it is then subject to eviction.\n\t */\n\tpublic cacheValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision === revision) {\n\t\t\treturn;\n\t\t}\n\t\tthis.sortedEntries.set(revision, value);\n\t\tif (revision < this.retentionWindowStart) {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t}\n\t}\n}\n"]}
@@ -2,11 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { NodeId, StableNodeId, TraitLabel } from './Identifiers';
6
- import { NodeIdConverter } from './NodeIdUtilities';
7
- import { Payload, TreeNode } from './persisted-types';
8
- import { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView';
9
- import { HasVariadicTraits } from './ChangeTypes';
5
+ import { NodeId, StableNodeId, TraitLabel } from './Identifiers.js';
6
+ import { NodeIdConverter } from './NodeIdUtilities.js';
7
+ import { Payload, TreeNode } from './persisted-types/index.js';
8
+ import { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView.js';
9
+ import { HasVariadicTraits } from './ChangeTypes.js';
10
10
  /**
11
11
  * An immutable view of a distributed tree.
12
12
  * @alpha
@@ -1 +1 @@
1
- {"version":3,"file":"RevisionView.d.ts","sourceRoot":"","sources":["../src/RevisionView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACzC;;;;OAIG;WACW,QAAQ,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,mBAAmB,CAAC,EAAE,OAAO,GAAG,YAAY;IAC3G;;;;;OAKG;WACW,QAAQ,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,EAAE,YA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AQ,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAc9F"}
@@ -5,14 +5,14 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.iterateChildren = exports.convertTreeNodesToViewNodes = exports.TransactionView = exports.RevisionView = void 0;
8
- const Common_1 = require("./Common");
9
- const Forest_1 = require("./Forest");
10
- const TreeView_1 = require("./TreeView");
8
+ const Common_js_1 = require("./Common.js");
9
+ const Forest_js_1 = require("./Forest.js");
10
+ const TreeView_js_1 = require("./TreeView.js");
11
11
  /**
12
12
  * An immutable view of a distributed tree.
13
13
  * @alpha
14
14
  */
15
- class RevisionView extends TreeView_1.TreeView {
15
+ class RevisionView extends TreeView_js_1.TreeView {
16
16
  static fromTree(root, idConverterOrExpensiveValidation, expensiveValidation = false) {
17
17
  if (typeof idConverterOrExpensiveValidation === 'object') {
18
18
  const rootId = idConverterOrExpensiveValidation.convertToNodeId(root.identifier);
@@ -22,18 +22,18 @@ class RevisionView extends TreeView_1.TreeView {
22
22
  definition: node.definition,
23
23
  identifier,
24
24
  };
25
- (0, Common_1.copyPropertyIfDefined)(node, viewNode, 'payload');
25
+ (0, Common_js_1.copyPropertyIfDefined)(node, viewNode, 'payload');
26
26
  return viewNode;
27
27
  });
28
- return new RevisionView(rootId, Forest_1.Forest.create(expensiveValidation).add(treeViewNodes));
28
+ return new RevisionView(rootId, Forest_js_1.Forest.create(expensiveValidation).add(treeViewNodes));
29
29
  }
30
30
  else {
31
- return new RevisionView(root.identifier, Forest_1.Forest.create(expensiveValidation).add(convertTreeNodesToViewNodes(root, (node) => {
31
+ return new RevisionView(root.identifier, Forest_js_1.Forest.create(expensiveValidation).add(convertTreeNodesToViewNodes(root, (node) => {
32
32
  const viewNode = {
33
33
  definition: node.definition,
34
34
  identifier: node.identifier,
35
35
  };
36
- (0, Common_1.copyPropertyIfDefined)(node, viewNode, 'payload');
36
+ (0, Common_js_1.copyPropertyIfDefined)(node, viewNode, 'payload');
37
37
  return viewNode;
38
38
  })));
39
39
  }
@@ -54,7 +54,7 @@ exports.RevisionView = RevisionView;
54
54
  * An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.
55
55
  * @alpha
56
56
  */
57
- class TransactionView extends TreeView_1.TreeView {
57
+ class TransactionView extends TreeView_js_1.TreeView {
58
58
  /** Conclude a transaction by generating an immutable `RevisionView` from this view */
59
59
  close() {
60
60
  return new RevisionView(this.root, this.forest);
@@ -124,10 +124,10 @@ function convertTreeNodesToViewNodes(root, convert) {
124
124
  const pendingNodes = [{ childIterator: iterateChildren(rootTraits)[Symbol.iterator](), newNode: convertedRoot }];
125
125
  const resultNodes = [];
126
126
  while (pendingNodes.length > 0) {
127
- const { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? (0, Common_1.fail)('Undefined node');
127
+ const { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? (0, Common_js_1.fail)('Undefined node');
128
128
  const { value, done } = childIterator.next();
129
129
  if (done === true) {
130
- resultNodes.push(pendingNodes.pop()?.newNode ?? (0, Common_1.fail)('covertTreeNodesToViewNodes incorrectly coordinated parentage'));
130
+ resultNodes.push(pendingNodes.pop()?.newNode ?? (0, Common_js_1.fail)('covertTreeNodesToViewNodes incorrectly coordinated parentage'));
131
131
  }
132
132
  else {
133
133
  const [traitLabel, child] = value;
@@ -1 +1 @@
1
- {"version":3,"file":"RevisionView.js","sourceRoot":"","sources":["../src/RevisionView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA4E;AAC5E,qCAAkC;AAIlC,yCAAkF;AAGlF;;;GAGG;AACH,MAAa,YAAa,SAAQ,mBAAQ;IAmBlC,MAAM,CAAC,QAAQ,CACrB,IAAO,EACP,gCAA4D,EAC5D,mBAAmB,GAAG,KAAK;QAE3B,IAAI,OAAO,gCAAgC,KAAK,QAAQ,EAAE;YACzD,MAAM,MAAM,GAAG,gCAAgC,CAAC,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC,CAAC;YA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GAAG,EAAE,CAAC;gBACd,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;aACpC;YACA,QAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;SACvD;KACD;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAlDD,kEAkDC;AAED;;GAEG;AACH,QAAe,CAAC,CAAC,eAAe,CAAI,SAA+B;IAClE,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE;QACnC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACrE,IAAI,KAAK,KAAK,SAAS,EAAE;gBACxB,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;oBAC9B,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;wBAC1B,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;qBACnC;iBACD;qBAAM;oBACN,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;iBACnC;aACD;SACD;KACD;AACF,CAAC;AAdD,0CAcC;AAED,SAAS,kBAAkB,CAAS,QAA2C;IAC9E,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, MutableMap } from './Common';\nimport { Forest } from './Forest';\nimport { NodeId, StableNodeId, TraitLabel } from './Identifiers';\nimport { NodeIdConverter } from './NodeIdUtilities';\nimport { Payload, TreeNode, TreeNodeSequence } from './persisted-types';\nimport { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView';\nimport { HasVariadicTraits } from './ChangeTypes';\n\n/**\n * An immutable view of a distributed tree.\n * @alpha\n */\nexport class RevisionView extends TreeView {\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the {@link RevisionView}\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, NodeId>>(root: T, expensiveValidation?: boolean): RevisionView;\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `RevisionView`\n\t * @param idConverter - the {@link NodeIdConverter} that will recompress the IDs the in the tree\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverter: NodeIdConverter,\n\t\texpensiveValidation?: boolean\n\t): RevisionView;\n\n\tpublic static fromTree<T extends TreeNode<T, NodeId> | TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverterOrExpensiveValidation?: NodeIdConverter | boolean,\n\t\texpensiveValidation = false\n\t): RevisionView {\n\t\tif (typeof idConverterOrExpensiveValidation === 'object') {\n\t\t\tconst rootId = idConverterOrExpensiveValidation.convertToNodeId(root.identifier as StableNodeId);\n\n\t\t\tconst treeViewNodes = convertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\tconst identifier = idConverterOrExpensiveValidation.convertToNodeId(node.identifier as StableNodeId);\n\t\t\t\tconst viewNode = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\treturn viewNode;\n\t\t\t});\n\n\t\t\treturn new RevisionView(rootId, Forest.create(expensiveValidation).add(treeViewNodes));\n\t\t} else {\n\t\t\treturn new RevisionView(\n\t\t\t\troot.identifier as NodeId,\n\t\t\t\tForest.create(expensiveValidation).add(\n\t\t\t\t\tconvertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\t\t\tconst viewNode = {\n\t\t\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\t\t\tidentifier: node.identifier as NodeId,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\t\t\treturn viewNode;\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Begin a transaction by generating a mutable `TransactionView` from this view */\n\tpublic openForTransaction(): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest);\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof RevisionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.\n * @alpha\n */\nexport class TransactionView extends TreeView {\n\t/** Conclude a transaction by generating an immutable `RevisionView` from this view */\n\tpublic close(): RevisionView {\n\t\treturn new RevisionView(this.root, this.forest);\n\t}\n\n\t/** Inserts all nodes in a NodeSequence into the view */\n\tpublic addNodes(sequence: Iterable<TreeViewNode>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.add(sequence));\n\t}\n\n\t/** Remove all nodes with the given ids from the view */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the view.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: TreeViewPlace): TransactionView {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new TransactionView(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the view.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: TreeViewRange): { view: TransactionView; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { view: new TransactionView(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets or overwrites a node's value. The node must exist in this view.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.setValue(nodeId, value));\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof TransactionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'>): TOut[];\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined;\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined {\n\tconst convertedRoot = convert(root) as Mutable<TOut>;\n\tif (convertedRoot === undefined || root.traits === undefined) {\n\t\treturn undefined;\n\t}\n\t// `convertedRoot` might be the same as `root`, in which case stash the children of `root` before wiping them from `convertedRoot`\n\tconst rootTraits = (root as unknown as TOut) === convertedRoot ? { traits: root.traits } : root;\n\tconvertedRoot.traits = new Map();\n\tconst pendingNodes: {\n\t\tchildIterator: Iterator<[TraitLabel, TIn]>;\n\t\tnewNode: Mutable<TOut>;\n\t}[] = [{ childIterator: iterateChildren(rootTraits)[Symbol.iterator](), newNode: convertedRoot }];\n\tconst resultNodes: TOut[] = [];\n\n\twhile (pendingNodes.length > 0) {\n\t\tconst { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? fail('Undefined node');\n\t\tconst { value, done } = childIterator.next();\n\t\tif (done === true) {\n\t\t\tresultNodes.push(\n\t\t\t\tpendingNodes.pop()?.newNode ?? fail('covertTreeNodesToViewNodes incorrectly coordinated parentage')\n\t\t\t);\n\t\t} else {\n\t\t\tconst [traitLabel, child] = value as [TraitLabel, TIn];\n\t\t\tconst convertedChild = convert(child) as TOut;\n\t\t\tif (convertedChild === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (child.traits !== undefined) {\n\t\t\t\tconst childTraits = (child as unknown as TOut) === convertedChild ? { traits: child.traits } : child;\n\t\t\t\t(convertedChild as Mutable<TOut>).traits = new Map();\n\t\t\t\tpendingNodes.push({\n\t\t\t\t\tchildIterator: iterateChildren(childTraits)[Symbol.iterator](),\n\t\t\t\t\tnewNode: convertedChild,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newTraits = newNode.traits as MutableMap<TOut['traits']>;\n\t\t\tlet newTrait = newTraits.get(traitLabel);\n\t\t\tif (newTrait === undefined) {\n\t\t\t\tnewTrait = [];\n\t\t\t\tnewTraits.set(traitLabel, newTrait);\n\t\t\t}\n\t\t\t(newTrait as NodeId[]).push(convertedChild.identifier);\n\t\t}\n\t}\n\n\treturn resultNodes;\n}\n\n/**\n * Returns an iterable of the supplied node's traits in a stable order.\n */\nexport function* iterateChildren<T>(hasTraits: HasVariadicTraits<T>): Iterable<[TraitLabel, T]> {\n\tif (hasTraits.traits !== undefined) {\n\t\tfor (const [label, trait] of Object.entries(hasTraits.traits).sort()) {\n\t\t\tif (trait !== undefined) {\n\t\t\t\tif (isTreeNodeSequence(trait)) {\n\t\t\t\t\tfor (const child of trait) {\n\t\t\t\t\t\tyield [label as TraitLabel, child];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tyield [label as TraitLabel, trait];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isTreeNodeSequence<TChild>(sequence: TreeNodeSequence<TChild> | TChild): sequence is TreeNodeSequence<TChild> {\n\treturn Array.isArray(sequence);\n}\n"]}
1
+ {"version":3,"file":"RevisionView.js","sourceRoot":"","sources":["../src/RevisionView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAA+E;AAC/E,2CAAqC;AAIrC,+CAAqF;AAGrF;;;GAGG;AACH,MAAa,YAAa,SAAQ,sBAAQ;IAmBlC,MAAM,CAAC,QAAQ,CACrB,IAAO,EACP,gCAA4D,EAC5D,mBAAmB,GAAG,KAAK;QAE3B,IAAI,OAAO,gCAAgC,KAAK,QAAQ,EAAE;YACzD,MAAM,MAAM,GAAG,gCAAgC,CAAC,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC,CAAC;YAEjG,MAAM,aAAa,GAAG,2BAA2B,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChE,MAAM,UAAU,GAAG,gCAAgC,CAAC,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC,CAAC;gBACrG,MAAM,QAAQ,GAAG;oBAChB,UAAU,EAAE,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,kEAkDC;AAED;;GAEG;AACH,QAAe,CAAC,CAAC,eAAe,CAAI,SAA+B;IAClE,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE;QACnC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACrE,IAAI,KAAK,KAAK,SAAS,EAAE;gBACxB,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;oBAC9B,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;wBAC1B,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;qBACnC;iBACD;qBAAM;oBACN,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;iBACnC;aACD;SACD;KACD;AACF,CAAC;AAdD,0CAcC;AAED,SAAS,kBAAkB,CAAS,QAA2C;IAC9E,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, MutableMap } from './Common.js';\nimport { Forest } from './Forest.js';\nimport { NodeId, StableNodeId, TraitLabel } from './Identifiers.js';\nimport { NodeIdConverter } from './NodeIdUtilities.js';\nimport { Payload, TreeNode, TreeNodeSequence } from './persisted-types/index.js';\nimport { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView.js';\nimport { HasVariadicTraits } from './ChangeTypes.js';\n\n/**\n * An immutable view of a distributed tree.\n * @alpha\n */\nexport class RevisionView extends TreeView {\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the {@link RevisionView}\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, NodeId>>(root: T, expensiveValidation?: boolean): RevisionView;\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `RevisionView`\n\t * @param idConverter - the {@link NodeIdConverter} that will recompress the IDs the in the tree\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverter: NodeIdConverter,\n\t\texpensiveValidation?: boolean\n\t): RevisionView;\n\n\tpublic static fromTree<T extends TreeNode<T, NodeId> | TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverterOrExpensiveValidation?: NodeIdConverter | boolean,\n\t\texpensiveValidation = false\n\t): RevisionView {\n\t\tif (typeof idConverterOrExpensiveValidation === 'object') {\n\t\t\tconst rootId = idConverterOrExpensiveValidation.convertToNodeId(root.identifier as StableNodeId);\n\n\t\t\tconst treeViewNodes = convertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\tconst identifier = idConverterOrExpensiveValidation.convertToNodeId(node.identifier as StableNodeId);\n\t\t\t\tconst viewNode = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\treturn viewNode;\n\t\t\t});\n\n\t\t\treturn new RevisionView(rootId, Forest.create(expensiveValidation).add(treeViewNodes));\n\t\t} else {\n\t\t\treturn new RevisionView(\n\t\t\t\troot.identifier as NodeId,\n\t\t\t\tForest.create(expensiveValidation).add(\n\t\t\t\t\tconvertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\t\t\tconst viewNode = {\n\t\t\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\t\t\tidentifier: node.identifier as NodeId,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\t\t\treturn viewNode;\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Begin a transaction by generating a mutable `TransactionView` from this view */\n\tpublic openForTransaction(): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest);\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof RevisionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.\n * @alpha\n */\nexport class TransactionView extends TreeView {\n\t/** Conclude a transaction by generating an immutable `RevisionView` from this view */\n\tpublic close(): RevisionView {\n\t\treturn new RevisionView(this.root, this.forest);\n\t}\n\n\t/** Inserts all nodes in a NodeSequence into the view */\n\tpublic addNodes(sequence: Iterable<TreeViewNode>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.add(sequence));\n\t}\n\n\t/** Remove all nodes with the given ids from the view */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the view.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: TreeViewPlace): TransactionView {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new TransactionView(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the view.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: TreeViewRange): { view: TransactionView; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { view: new TransactionView(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets or overwrites a node's value. The node must exist in this view.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.setValue(nodeId, value));\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof TransactionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'>): TOut[];\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined;\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined {\n\tconst convertedRoot = convert(root) as Mutable<TOut>;\n\tif (convertedRoot === undefined || root.traits === undefined) {\n\t\treturn undefined;\n\t}\n\t// `convertedRoot` might be the same as `root`, in which case stash the children of `root` before wiping them from `convertedRoot`\n\tconst rootTraits = (root as unknown as TOut) === convertedRoot ? { traits: root.traits } : root;\n\tconvertedRoot.traits = new Map();\n\tconst pendingNodes: {\n\t\tchildIterator: Iterator<[TraitLabel, TIn]>;\n\t\tnewNode: Mutable<TOut>;\n\t}[] = [{ childIterator: iterateChildren(rootTraits)[Symbol.iterator](), newNode: convertedRoot }];\n\tconst resultNodes: TOut[] = [];\n\n\twhile (pendingNodes.length > 0) {\n\t\tconst { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? fail('Undefined node');\n\t\tconst { value, done } = childIterator.next();\n\t\tif (done === true) {\n\t\t\tresultNodes.push(\n\t\t\t\tpendingNodes.pop()?.newNode ?? fail('covertTreeNodesToViewNodes incorrectly coordinated parentage')\n\t\t\t);\n\t\t} else {\n\t\t\tconst [traitLabel, child] = value as [TraitLabel, TIn];\n\t\t\tconst convertedChild = convert(child) as TOut;\n\t\t\tif (convertedChild === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (child.traits !== undefined) {\n\t\t\t\tconst childTraits = (child as unknown as TOut) === convertedChild ? { traits: child.traits } : child;\n\t\t\t\t(convertedChild as Mutable<TOut>).traits = new Map();\n\t\t\t\tpendingNodes.push({\n\t\t\t\t\tchildIterator: iterateChildren(childTraits)[Symbol.iterator](),\n\t\t\t\t\tnewNode: convertedChild,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newTraits = newNode.traits as MutableMap<TOut['traits']>;\n\t\t\tlet newTrait = newTraits.get(traitLabel);\n\t\t\tif (newTrait === undefined) {\n\t\t\t\tnewTrait = [];\n\t\t\t\tnewTraits.set(traitLabel, newTrait);\n\t\t\t}\n\t\t\t(newTrait as NodeId[]).push(convertedChild.identifier);\n\t\t}\n\t}\n\n\treturn resultNodes;\n}\n\n/**\n * Returns an iterable of the supplied node's traits in a stable order.\n */\nexport function* iterateChildren<T>(hasTraits: HasVariadicTraits<T>): Iterable<[TraitLabel, T]> {\n\tif (hasTraits.traits !== undefined) {\n\t\tfor (const [label, trait] of Object.entries(hasTraits.traits).sort()) {\n\t\t\tif (trait !== undefined) {\n\t\t\t\tif (isTreeNodeSequence(trait)) {\n\t\t\t\t\tfor (const child of trait) {\n\t\t\t\t\t\tyield [label as TraitLabel, child];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tyield [label as TraitLabel, trait];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isTreeNodeSequence<TChild>(sequence: TreeNodeSequence<TChild> | TChild): sequence is TreeNodeSequence<TChild> {\n\treturn Array.isArray(sequence);\n}\n"]}
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { NodeId } from './Identifiers';
6
- import { NodeIdConverter } from './NodeIdUtilities';
7
- import { ChangeNode, ChangeNode_0_0_2 } from './persisted-types';
8
- import { TreeView } from './TreeView';
5
+ import { NodeId } from './Identifiers.js';
6
+ import { NodeIdConverter } from './NodeIdUtilities.js';
7
+ import { ChangeNode, ChangeNode_0_0_2 } from './persisted-types/index.js';
8
+ import { TreeView } from './TreeView.js';
9
9
  /**
10
10
  * Converts this tree view to an equivalent `ChangeNode`.
11
11
  * @param view - the view to convert
@@ -1 +1 @@
1
- {"version":3,"file":"SerializationUtilities.d.ts","sourceRoot":"","sources":["../src/SerializationUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAc,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAY,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,qBAAqB,CA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esModule", { value: true });
7
7
  exports.getChangeNode_0_0_2FromViewNode = exports.getChangeNode_0_0_2FromView = exports.getChangeNodeFromViewNode = exports.getChangeNodeFromView = void 0;
8
- const Common_1 = require("./Common");
8
+ const Common_js_1 = require("./Common.js");
9
9
  /**
10
10
  * Converts this tree view to an equivalent `ChangeNode`.
11
11
  * @param view - the view to convert
@@ -27,12 +27,12 @@ function getChangeNodeFromViewNode(view, id, lazyTraits = false) {
27
27
  definition: node.definition,
28
28
  identifier: node.identifier,
29
29
  };
30
- (0, Common_1.copyPropertyIfDefined)(node, nodeData, 'payload');
30
+ (0, Common_js_1.copyPropertyIfDefined)(node, nodeData, 'payload');
31
31
  if (lazyTraits) {
32
32
  return {
33
33
  ...nodeData,
34
34
  get traits() {
35
- return (0, Common_1.memoizeGetter)(this, 'traits', makeTraits(view, node.traits, lazyTraits));
35
+ return (0, Common_js_1.memoizeGetter)(this, 'traits', makeTraits(view, node.traits, lazyTraits));
36
36
  },
37
37
  };
38
38
  }
@@ -50,7 +50,7 @@ function makeTraits(view, traits, lazyTraits = false) {
50
50
  Object.defineProperty(traitMap, label, {
51
51
  get() {
52
52
  const treeNodeTrait = trait.map((id) => getChangeNodeFromViewNode(view, id, lazyTraits));
53
- return (0, Common_1.memoizeGetter)(this, label, treeNodeTrait);
53
+ return (0, Common_js_1.memoizeGetter)(this, label, treeNodeTrait);
54
54
  },
55
55
  configurable: true,
56
56
  enumerable: true,
@@ -87,7 +87,7 @@ function getChangeNode_0_0_2FromViewNode(view, id, idConverter) {
87
87
  definition: node.definition,
88
88
  identifier: idConverter.convertToStableNodeId(node.identifier),
89
89
  };
90
- (0, Common_1.copyPropertyIfDefined)(node, nodeData, 'payload');
90
+ (0, Common_js_1.copyPropertyIfDefined)(node, nodeData, 'payload');
91
91
  return {
92
92
  ...nodeData,
93
93
  traits: makeTraits_0_0_2(view, node.traits, idConverter),
@@ -1 +1 @@
1
- {"version":3,"file":"SerializationUtilities.js","sourceRoot":"","sources":["../src/Serializ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SAAS,gBAAgB,CACxB,IAAc,EACd,MAAkD,EAClD,WAA4B;IAE5B,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;QAC9C,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;YACtC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,+BAA+B,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;YAChF,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;KACH;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, memoizeGetter } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { NodeIdConverter } from './NodeIdUtilities';\nimport { ChangeNode, ChangeNode_0_0_2, TraitMap } from './persisted-types';\nimport { TreeView } from './TreeView';\n\n/**\n * Converts this tree view to an equivalent `ChangeNode`.\n * @param view - the view to convert\n */\nexport function getChangeNodeFromView(view: TreeView): ChangeNode {\n\treturn getChangeNodeFromViewNode(view, view.root);\n}\n\n/**\n * Converts a node in this tree view to an equivalent `ChangeNode`.\n * @param view - the view of the tree that contains the node to convert\n * @param id - the id of the node to convert\n * @param lazyTraits - whether or not traits should be populated lazily. If true, the subtrees under each trait will not be read until\n * the trait is first accessed.\n */\nexport function getChangeNodeFromViewNode(view: TreeView, id: NodeId, lazyTraits = false): ChangeNode {\n\tconst node = view.getViewNode(id);\n\tconst nodeData = {\n\t\tdefinition: node.definition,\n\t\tidentifier: node.identifier,\n\t};\n\tcopyPropertyIfDefined(node, nodeData, 'payload');\n\n\tif (lazyTraits) {\n\t\treturn {\n\t\t\t...nodeData,\n\t\t\tget traits() {\n\t\t\t\treturn memoizeGetter(this, 'traits', makeTraits(view, node.traits, lazyTraits));\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\t...nodeData,\n\t\ttraits: makeTraits(view, node.traits, lazyTraits),\n\t};\n}\n\n/** Given the traits of a TreeViewNode, return the corresponding traits on a Node */\nfunction makeTraits(\n\tview: TreeView,\n\ttraits: ReadonlyMap<TraitLabel, readonly NodeId[]>,\n\tlazyTraits = false\n): TraitMap<ChangeNode> {\n\tconst traitMap = {};\n\tfor (const [label, trait] of traits.entries()) {\n\t\tif (lazyTraits) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst treeNodeTrait = trait.map((id) => getChangeNodeFromViewNode(view, id, lazyTraits));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<ChangeNode>, label, treeNodeTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t} else {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tvalue: trait.map((id) => getChangeNodeFromViewNode(view, id, lazyTraits)),\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn traitMap;\n}\n\n/**\n * Converts this tree view to an equivalent `ChangeNode`.\n * @param view - the view to convert\n */\nexport function getChangeNode_0_0_2FromView(view: TreeView, idConverter: NodeIdConverter): ChangeNode_0_0_2 {\n\treturn getChangeNode_0_0_2FromViewNode(view, view.root, idConverter);\n}\n\n/**\n * Converts a node in this tree view to an equivalent `ChangeNode`.\n * @param view - the view of the tree that contains the node to convert\n * @param id - the id of the node to convert\n * @param lazyTraits - whether or not traits should be populated lazily. If true, the subtrees under each trait will not be read until\n * the trait is first accessed.\n * @deprecated Remove by March 2022\n */\nexport function getChangeNode_0_0_2FromViewNode(\n\tview: TreeView,\n\tid: NodeId,\n\tidConverter: NodeIdConverter\n): ChangeNode_0_0_2 {\n\tconst node = view.getViewNode(id);\n\tconst nodeData = {\n\t\tdefinition: node.definition,\n\t\tidentifier: idConverter.convertToStableNodeId(node.identifier),\n\t};\n\tcopyPropertyIfDefined(node, nodeData, 'payload');\n\n\treturn {\n\t\t...nodeData,\n\t\ttraits: makeTraits_0_0_2(view, node.traits, idConverter),\n\t};\n}\n\n/**\n * Given the traits of a TreeViewNode, return the corresponding traits on a Node\n * @deprecated Remove by march 2022\n */\nfunction makeTraits_0_0_2(\n\tview: TreeView,\n\ttraits: ReadonlyMap<TraitLabel, readonly NodeId[]>,\n\tidConverter: NodeIdConverter\n): TraitMap<ChangeNode_0_0_2> {\n\tconst traitMap = {};\n\tfor (const [label, trait] of traits.entries()) {\n\t\tObject.defineProperty(traitMap, label, {\n\t\t\tvalue: trait.map((id) => getChangeNode_0_0_2FromViewNode(view, id, idConverter)),\n\t\t\tenumerable: true,\n\t\t});\n\t}\n\n\treturn traitMap;\n}\n"]}
1
+ {"version":3,"file":"SerializationUtilities.js","sourceRoot":"","sources":["../src/SerializationUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAmE;AAMnE;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,IAAc;IACnD,OAAO,yBAAyB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAFD,sDAEC;AAED;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,IAAc,EAAE,EAAU,EAAE,UAAU,GAAG,KAAK;IACvF,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG;QAChB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC3B,CAAC;IACF,IAAA,iCAAqB,EAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEjD,IAAI,UAAU,EAAE;QACf,OAAO;YACN,GAAG,QAAQ;YACX,IAAI,MAAM;gBACT,OAAO,IAAA,yBAAa,EAAC,IAAI,EAAE,QAAQ,E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,IAAI,EAAE,WAAW,CAAC,CAAC;AACtE,CAAC;AAFD,kEAEC;AAED;;;;;;;GAOG;AACH,SAAgB,+BAA+B,CAC9C,IAAc,EACd,EAAU,EACV,WAA4B;IAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG;QAChB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC;KAC9D,CAAC;IACF,IAAA,iCAAqB,EAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEjD,OAAO;QACN,GAAG,QAAQ;QACX,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC;KACxD,CAAC;AACH,CAAC;AAhBD,0EAgBC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CACxB,IAAc,EACd,MAAkD,EAClD,WAA4B;IAE5B,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;QAC9C,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;YACtC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,+BAA+B,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;YAChF,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;KACH;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, memoizeGetter } from './Common.js';\nimport { NodeId, TraitLabel } from './Identifiers.js';\nimport { NodeIdConverter } from './NodeIdUtilities.js';\nimport { ChangeNode, ChangeNode_0_0_2, TraitMap } from './persisted-types/index.js';\nimport { TreeView } from './TreeView.js';\n\n/**\n * Converts this tree view to an equivalent `ChangeNode`.\n * @param view - the view to convert\n */\nexport function getChangeNodeFromView(view: TreeView): ChangeNode {\n\treturn getChangeNodeFromViewNode(view, view.root);\n}\n\n/**\n * Converts a node in this tree view to an equivalent `ChangeNode`.\n * @param view - the view of the tree that contains the node to convert\n * @param id - the id of the node to convert\n * @param lazyTraits - whether or not traits should be populated lazily. If true, the subtrees under each trait will not be read until\n * the trait is first accessed.\n */\nexport function getChangeNodeFromViewNode(view: TreeView, id: NodeId, lazyTraits = false): ChangeNode {\n\tconst node = view.getViewNode(id);\n\tconst nodeData = {\n\t\tdefinition: node.definition,\n\t\tidentifier: node.identifier,\n\t};\n\tcopyPropertyIfDefined(node, nodeData, 'payload');\n\n\tif (lazyTraits) {\n\t\treturn {\n\t\t\t...nodeData,\n\t\t\tget traits() {\n\t\t\t\treturn memoizeGetter(this, 'traits', makeTraits(view, node.traits, lazyTraits));\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\t...nodeData,\n\t\ttraits: makeTraits(view, node.traits, lazyTraits),\n\t};\n}\n\n/** Given the traits of a TreeViewNode, return the corresponding traits on a Node */\nfunction makeTraits(\n\tview: TreeView,\n\ttraits: ReadonlyMap<TraitLabel, readonly NodeId[]>,\n\tlazyTraits = false\n): TraitMap<ChangeNode> {\n\tconst traitMap = {};\n\tfor (const [label, trait] of traits.entries()) {\n\t\tif (lazyTraits) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst treeNodeTrait = trait.map((id) => getChangeNodeFromViewNode(view, id, lazyTraits));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<ChangeNode>, label, treeNodeTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t} else {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tvalue: trait.map((id) => getChangeNodeFromViewNode(view, id, lazyTraits)),\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn traitMap;\n}\n\n/**\n * Converts this tree view to an equivalent `ChangeNode`.\n * @param view - the view to convert\n */\nexport function getChangeNode_0_0_2FromView(view: TreeView, idConverter: NodeIdConverter): ChangeNode_0_0_2 {\n\treturn getChangeNode_0_0_2FromViewNode(view, view.root, idConverter);\n}\n\n/**\n * Converts a node in this tree view to an equivalent `ChangeNode`.\n * @param view - the view of the tree that contains the node to convert\n * @param id - the id of the node to convert\n * @param lazyTraits - whether or not traits should be populated lazily. If true, the subtrees under each trait will not be read until\n * the trait is first accessed.\n * @deprecated Remove by March 2022\n */\nexport function getChangeNode_0_0_2FromViewNode(\n\tview: TreeView,\n\tid: NodeId,\n\tidConverter: NodeIdConverter\n): ChangeNode_0_0_2 {\n\tconst node = view.getViewNode(id);\n\tconst nodeData = {\n\t\tdefinition: node.definition,\n\t\tidentifier: idConverter.convertToStableNodeId(node.identifier),\n\t};\n\tcopyPropertyIfDefined(node, nodeData, 'payload');\n\n\treturn {\n\t\t...nodeData,\n\t\ttraits: makeTraits_0_0_2(view, node.traits, idConverter),\n\t};\n}\n\n/**\n * Given the traits of a TreeViewNode, return the corresponding traits on a Node\n * @deprecated Remove by march 2022\n */\nfunction makeTraits_0_0_2(\n\tview: TreeView,\n\ttraits: ReadonlyMap<TraitLabel, readonly NodeId[]>,\n\tidConverter: NodeIdConverter\n): TraitMap<ChangeNode_0_0_2> {\n\tconst traitMap = {};\n\tfor (const [label, trait] of traits.entries()) {\n\t\tObject.defineProperty(traitMap, label, {\n\t\t\tvalue: trait.map((id) => getChangeNode_0_0_2FromViewNode(view, id, idConverter)),\n\t\t\tenumerable: true,\n\t\t});\n\t}\n\n\treturn traitMap;\n}\n"]}
@@ -2,20 +2,20 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, IChannelAttributes, IChannelServices, IChannel } from '@fluidframework/datastore-definitions';
5
+ import { IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, IChannelAttributes, IChannelServices } from '@fluidframework/datastore-definitions';
6
6
  import { IFluidSerializer, ISharedObjectEvents, SharedObject } from '@fluidframework/shared-object-base';
7
- import { ITelemetryProperties } from '@fluidframework/core-interfaces';
7
+ import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
8
8
  import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
9
9
  import { ISummaryTreeWithStats, ITelemetryContext } from '@fluidframework/runtime-definitions';
10
- import { OrderedEditSet } from './EditLog';
11
- import { EditId, NodeId, StableNodeId, AttributionId } from './Identifiers';
12
- import { LogViewer } from './LogViewer';
13
- import { ReconciliationPath } from './ReconciliationPath';
14
- import { ChangeInternal, Edit, EditStatus, SharedTreeSummaryBase, WriteFormat, InternalizedChange } from './persisted-types';
15
- import { NodeIdContext } from './NodeIdUtilities';
16
- import { RevisionView } from './RevisionView';
17
- import { Change } from './ChangeTypes';
18
- import { TransactionInternal } from './TransactionInternal';
10
+ import { OrderedEditSet } from './EditLog.js';
11
+ import { EditId, NodeId, StableNodeId, AttributionId } from './Identifiers.js';
12
+ import { LogViewer } from './LogViewer.js';
13
+ import { ReconciliationPath } from './ReconciliationPath.js';
14
+ import { ChangeInternal, Edit, EditStatus, SharedTreeSummaryBase, WriteFormat, InternalizedChange } from './persisted-types/index.js';
15
+ import { NodeIdContext } from './NodeIdUtilities.js';
16
+ import { RevisionView } from './RevisionView.js';
17
+ import { Change } from './ChangeTypes.js';
18
+ import { TransactionInternal } from './TransactionInternal.js';
19
19
  /**
20
20
  * The write format and associated options used to construct a `SharedTree`
21
21
  * @alpha
@@ -126,7 +126,7 @@ export declare class SharedTreeFactory implements IChannelFactory {
126
126
  /**
127
127
  * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.load}
128
128
  */
129
- load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<IChannel>;
129
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<SharedTree>;
130
130
  /**
131
131
  * Create a new SharedTree.
132
132
  * @param runtime - data store runtime that owns the new SharedTree
@@ -379,7 +379,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
379
379
  * Initialize shared tree with a serialized summary. This is used for testing.
380
380
  * @returns Statistics about the loaded summary.
381
381
  */
382
- loadSerializedSummary(blobData: string): ITelemetryProperties;
382
+ loadSerializedSummary(blobData: string): ITelemetryBaseProperties;
383
383
  /**
384
384
  * Saves this SharedTree into a deserialized summary.
385
385
  */
@@ -437,7 +437,6 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
437
437
  * Parses a sequenced edit. This is only invoked for ops with version matching the current `writeFormat`.
438
438
  */
439
439
  private parseSequencedEdit;
440
- private encodeSemiSerializedEdit;
441
440
  private processSequencedEdit;
442
441
  /**
443
442
  * Updates SharedTree to the provided version if the version is a valid write version newer than the current version.
@@ -494,7 +493,6 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
494
493
  * Submits an edit by the local client to the runtime.
495
494
  */
496
495
  private submitEditOp;
497
- private serializeEdit;
498
496
  /** A type-safe `submitLocalMessage` wrapper to enforce op format */
499
497
  private submitOp;
500
498
  getRuntime(): IFluidDataStoreRuntime;
@@ -503,12 +501,11 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
503
501
  * When closing a container, hosts have the option to stash this pending local state somewhere to be reapplied
504
502
  * later (to avoid data loss).
505
503
  * If a host then loads a container using that stashed state, this function is called for each stashed op, and is expected to:
506
- * 1. Update this DDS to reflect that state locally.
507
- * 2. Return any `localOpMetadata` that would have been associated with this op.
504
+ * Update this DDS to reflect that state locally, and submit the op to do that.
508
505
  *
509
506
  * @param content - op to apply locally.
510
507
  */
511
- protected applyStashedOp(op: unknown): StashedLocalOpMetadata;
508
+ protected applyStashedOp(op: unknown): void;
512
509
  protected reSubmitCore(op: unknown, localOpMetadata?: StashedLocalOpMetadata): void;
513
510
  private changeWriteFormat;
514
511
  /**