@fluid-experimental/tree 0.59.2001 → 0.59.3000

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 (258) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.vscode/SharedTree.code-workspace +15 -0
  3. package/.vscode/settings.json +6 -0
  4. package/dist/ChangeCompression.js +9 -9
  5. package/dist/ChangeCompression.js.map +1 -1
  6. package/dist/ChangeTypes.d.ts +1 -6
  7. package/dist/ChangeTypes.d.ts.map +1 -1
  8. package/dist/ChangeTypes.js +5 -5
  9. package/dist/ChangeTypes.js.map +1 -1
  10. package/dist/Checkout.js +14 -14
  11. package/dist/Checkout.js.map +1 -1
  12. package/dist/Common.d.ts +21 -3
  13. package/dist/Common.d.ts.map +1 -1
  14. package/dist/Common.js +29 -4
  15. package/dist/Common.js.map +1 -1
  16. package/dist/EditLog.js +26 -25
  17. package/dist/EditLog.js.map +1 -1
  18. package/dist/EditUtilities.js +17 -17
  19. package/dist/EditUtilities.js.map +1 -1
  20. package/dist/Forest.js +31 -31
  21. package/dist/Forest.js.map +1 -1
  22. package/dist/HistoryEditFactory.js +9 -9
  23. package/dist/HistoryEditFactory.js.map +1 -1
  24. package/dist/IdConversion.js +9 -9
  25. package/dist/IdConversion.js.map +1 -1
  26. package/dist/Identifiers.d.ts +4 -0
  27. package/dist/Identifiers.d.ts.map +1 -1
  28. package/dist/Identifiers.js.map +1 -1
  29. package/dist/LogViewer.d.ts +1 -5
  30. package/dist/LogViewer.d.ts.map +1 -1
  31. package/dist/LogViewer.js +11 -19
  32. package/dist/LogViewer.js.map +1 -1
  33. package/dist/MergeHealth.js +2 -2
  34. package/dist/MergeHealth.js.map +1 -1
  35. package/dist/NodeIdUtilities.js +2 -2
  36. package/dist/NodeIdUtilities.js.map +1 -1
  37. package/dist/PayloadUtilities.js +1 -1
  38. package/dist/PayloadUtilities.js.map +1 -1
  39. package/dist/RevisionValueCache.d.ts +13 -10
  40. package/dist/RevisionValueCache.d.ts.map +1 -1
  41. package/dist/RevisionValueCache.js +14 -11
  42. package/dist/RevisionValueCache.js.map +1 -1
  43. package/dist/RevisionView.js +4 -4
  44. package/dist/RevisionView.js.map +1 -1
  45. package/dist/SerializationUtilities.js +4 -4
  46. package/dist/SerializationUtilities.js.map +1 -1
  47. package/dist/SharedTree.d.ts +93 -31
  48. package/dist/SharedTree.d.ts.map +1 -1
  49. package/dist/SharedTree.js +160 -131
  50. package/dist/SharedTree.js.map +1 -1
  51. package/dist/SharedTreeEncoder.d.ts +3 -3
  52. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  53. package/dist/SharedTreeEncoder.js +36 -36
  54. package/dist/SharedTreeEncoder.js.map +1 -1
  55. package/dist/StringInterner.js +1 -1
  56. package/dist/StringInterner.js.map +1 -1
  57. package/dist/Summary.js +1 -1
  58. package/dist/Summary.js.map +1 -1
  59. package/dist/SummaryBackCompatibility.js +8 -8
  60. package/dist/SummaryBackCompatibility.js.map +1 -1
  61. package/dist/Transaction.js +1 -1
  62. package/dist/Transaction.js.map +1 -1
  63. package/dist/TransactionInternal.js +17 -17
  64. package/dist/TransactionInternal.js.map +1 -1
  65. package/dist/TreeCompressor.d.ts.map +1 -1
  66. package/dist/TreeCompressor.js +6 -8
  67. package/dist/TreeCompressor.js.map +1 -1
  68. package/dist/TreeNodeHandle.js +4 -4
  69. package/dist/TreeNodeHandle.js.map +1 -1
  70. package/dist/TreeView.js +7 -7
  71. package/dist/TreeView.js.map +1 -1
  72. package/dist/TreeViewUtilities.js +2 -2
  73. package/dist/TreeViewUtilities.js.map +1 -1
  74. package/dist/UndoRedoHandler.js +1 -1
  75. package/dist/UndoRedoHandler.js.map +1 -1
  76. package/dist/UuidUtilities.d.ts +30 -0
  77. package/dist/UuidUtilities.d.ts.map +1 -0
  78. package/dist/UuidUtilities.js +106 -0
  79. package/dist/UuidUtilities.js.map +1 -0
  80. package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  81. package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  82. package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
  83. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  84. package/dist/id-compressor/IdCompressor.d.ts +43 -42
  85. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  86. package/dist/id-compressor/IdCompressor.js +179 -177
  87. package/dist/id-compressor/IdCompressor.js.map +1 -1
  88. package/dist/id-compressor/IdRange.js +1 -1
  89. package/dist/id-compressor/IdRange.js.map +1 -1
  90. package/dist/id-compressor/NumericUuid.d.ts +6 -14
  91. package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
  92. package/dist/id-compressor/NumericUuid.js +15 -76
  93. package/dist/id-compressor/NumericUuid.js.map +1 -1
  94. package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
  95. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  96. package/dist/id-compressor/SessionIdNormalizer.js +418 -0
  97. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
  98. package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  99. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  100. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  101. package/dist/index.d.ts +2 -2
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/persisted-types/0.1.1.d.ts +1 -6
  105. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  106. package/dist/persisted-types/0.1.1.js +3 -3
  107. package/dist/persisted-types/0.1.1.js.map +1 -1
  108. package/lib/ChangeTypes.d.ts +1 -6
  109. package/lib/ChangeTypes.d.ts.map +1 -1
  110. package/lib/Checkout.js.map +1 -1
  111. package/lib/Common.d.ts +21 -3
  112. package/lib/Common.d.ts.map +1 -1
  113. package/lib/Common.js +25 -3
  114. package/lib/Common.js.map +1 -1
  115. package/lib/EditLog.js +2 -1
  116. package/lib/EditLog.js.map +1 -1
  117. package/lib/EditUtilities.js.map +1 -1
  118. package/lib/Forest.js.map +1 -1
  119. package/lib/HistoryEditFactory.js.map +1 -1
  120. package/lib/Identifiers.d.ts +4 -0
  121. package/lib/Identifiers.d.ts.map +1 -1
  122. package/lib/Identifiers.js.map +1 -1
  123. package/lib/LogViewer.d.ts +1 -5
  124. package/lib/LogViewer.d.ts.map +1 -1
  125. package/lib/LogViewer.js +5 -13
  126. package/lib/LogViewer.js.map +1 -1
  127. package/lib/MergeHealth.js.map +1 -1
  128. package/lib/NodeIdUtilities.js.map +1 -1
  129. package/lib/RevisionValueCache.d.ts +13 -10
  130. package/lib/RevisionValueCache.d.ts.map +1 -1
  131. package/lib/RevisionValueCache.js +10 -7
  132. package/lib/RevisionValueCache.js.map +1 -1
  133. package/lib/RevisionView.js.map +1 -1
  134. package/lib/SharedTree.d.ts +93 -31
  135. package/lib/SharedTree.d.ts.map +1 -1
  136. package/lib/SharedTree.js +107 -78
  137. package/lib/SharedTree.js.map +1 -1
  138. package/lib/SharedTreeEncoder.d.ts +3 -3
  139. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  140. package/lib/SharedTreeEncoder.js +4 -4
  141. package/lib/SharedTreeEncoder.js.map +1 -1
  142. package/lib/StringInterner.js.map +1 -1
  143. package/lib/Summary.js.map +1 -1
  144. package/lib/TreeCompressor.d.ts.map +1 -1
  145. package/lib/TreeCompressor.js +1 -3
  146. package/lib/TreeCompressor.js.map +1 -1
  147. package/lib/TreeNodeHandle.js.map +1 -1
  148. package/lib/TreeView.js.map +1 -1
  149. package/lib/TreeViewUtilities.js.map +1 -1
  150. package/lib/UuidUtilities.d.ts +30 -0
  151. package/lib/UuidUtilities.d.ts.map +1 -0
  152. package/lib/UuidUtilities.js +98 -0
  153. package/lib/UuidUtilities.js.map +1 -0
  154. package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  155. package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  156. package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
  157. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  158. package/lib/id-compressor/IdCompressor.d.ts +43 -42
  159. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  160. package/lib/id-compressor/IdCompressor.js +97 -95
  161. package/lib/id-compressor/IdCompressor.js.map +1 -1
  162. package/lib/id-compressor/NumericUuid.d.ts +6 -14
  163. package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
  164. package/lib/id-compressor/NumericUuid.js +11 -70
  165. package/lib/id-compressor/NumericUuid.js.map +1 -1
  166. package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
  167. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  168. package/lib/id-compressor/SessionIdNormalizer.js +414 -0
  169. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
  170. package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  171. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  172. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  173. package/lib/index.d.ts +2 -2
  174. package/lib/index.d.ts.map +1 -1
  175. package/lib/index.js.map +1 -1
  176. package/lib/persisted-types/0.1.1.d.ts +1 -6
  177. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  178. package/lib/persisted-types/0.1.1.js.map +1 -1
  179. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
  180. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
  181. package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
  182. package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
  183. package/lib/test/AppendOnlySortedMap.tests.js +56 -14
  184. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
  185. package/lib/test/Checkout.tests.js +2 -2
  186. package/lib/test/Checkout.tests.js.map +1 -1
  187. package/lib/test/Forest.tests.js.map +1 -1
  188. package/lib/test/IdCompressor.perf.tests.js +8 -2
  189. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  190. package/lib/test/IdCompressor.tests.js +75 -24
  191. package/lib/test/IdCompressor.tests.js.map +1 -1
  192. package/lib/test/LogViewer.tests.js +3 -5
  193. package/lib/test/LogViewer.tests.js.map +1 -1
  194. package/lib/test/NumericUuid.perf.tests.js +4 -4
  195. package/lib/test/NumericUuid.perf.tests.js.map +1 -1
  196. package/lib/test/NumericUuid.tests.js +5 -4
  197. package/lib/test/NumericUuid.tests.js.map +1 -1
  198. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  199. package/lib/test/RevisionView.tests.js.map +1 -1
  200. package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
  201. package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
  202. package/lib/test/SessionIdNormalizer.tests.js +299 -0
  203. package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
  204. package/lib/test/Summary.tests.js +1 -1
  205. package/lib/test/Summary.tests.js.map +1 -1
  206. package/lib/test/TreeCompression.tests.js +1 -1
  207. package/lib/test/TreeCompression.tests.js.map +1 -1
  208. package/lib/test/Virtualization.tests.js +1 -1
  209. package/lib/test/Virtualization.tests.js.map +1 -1
  210. package/lib/test/fuzz/Generators.d.ts +3 -14
  211. package/lib/test/fuzz/Generators.d.ts.map +1 -1
  212. package/lib/test/fuzz/Generators.js +60 -151
  213. package/lib/test/fuzz/Generators.js.map +1 -1
  214. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
  215. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  216. package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
  217. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  218. package/lib/test/fuzz/Types.d.ts +2 -9
  219. package/lib/test/fuzz/Types.d.ts.map +1 -1
  220. package/lib/test/fuzz/Types.js +1 -1
  221. package/lib/test/fuzz/Types.js.map +1 -1
  222. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
  223. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  224. package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
  225. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  226. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  227. package/lib/test/utilities/PendingLocalStateTests.js +2 -1
  228. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  229. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  230. package/lib/test/utilities/SharedTreeTests.js +30 -1
  231. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  232. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  233. package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
  234. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  235. package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
  236. package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
  237. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  238. package/lib/test/utilities/TestNode.js.map +1 -1
  239. package/lib/test/utilities/TestUtilities.d.ts +9 -1
  240. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  241. package/lib/test/utilities/TestUtilities.js +27 -13
  242. package/lib/test/utilities/TestUtilities.js.map +1 -1
  243. package/package.json +19 -17
  244. package/src/Common.ts +42 -4
  245. package/src/EditLog.ts +1 -1
  246. package/src/Identifiers.ts +5 -0
  247. package/src/LogViewer.ts +4 -20
  248. package/src/RevisionValueCache.ts +11 -8
  249. package/src/SharedTree.ts +222 -75
  250. package/src/SharedTreeEncoder.ts +17 -11
  251. package/src/TreeCompressor.ts +2 -4
  252. package/src/UuidUtilities.ts +123 -0
  253. package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
  254. package/src/id-compressor/IdCompressor.ts +144 -132
  255. package/src/id-compressor/NumericUuid.ts +11 -80
  256. package/src/id-compressor/SessionIdNormalizer.ts +497 -0
  257. package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
  258. package/src/index.ts +5 -0
@@ -37,12 +37,12 @@ function revert(changes, before) {
37
37
  case persisted_types_1.ChangeTypeInternal.Build: {
38
38
  // Save nodes added to the detached state for use in future changes
39
39
  const { destination, source } = change;
40
- Common_1.assert(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);
41
- Common_1.assert(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);
40
+ (0, Common_1.assert)(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);
41
+ (0, Common_1.assert)(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);
42
42
  builtNodes.set(destination, source.reduce((ids, curr) => {
43
43
  var _a;
44
- if (Identifiers_1.isDetachedSequenceId(curr)) {
45
- const nodesForDetachedSequence = (_a = builtNodes.get(curr)) !== null && _a !== void 0 ? _a : Common_1.fail('detached sequence must have associated built nodes');
44
+ if ((0, Identifiers_1.isDetachedSequenceId)(curr)) {
45
+ const nodesForDetachedSequence = (_a = builtNodes.get(curr)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('detached sequence must have associated built nodes');
46
46
  ids.push(...nodesForDetachedSequence);
47
47
  }
48
48
  else {
@@ -101,9 +101,9 @@ function revert(changes, before) {
101
101
  }
102
102
  case persisted_types_1.ChangeTypeInternal.Constraint:
103
103
  // TODO:#46759: Support Constraint in reverts
104
- Common_1.fail('Revert currently does not support Constraints');
104
+ (0, Common_1.fail)('Revert currently does not support Constraints');
105
105
  default:
106
- Common_1.fail('Revert does not support the change type.');
106
+ (0, Common_1.fail)('Revert does not support the change type.');
107
107
  }
108
108
  // Update the revision
109
109
  editor.applyChange(change);
@@ -159,12 +159,12 @@ function createInvertedInsert(insert, nodesInserted, saveDetached = false) {
159
159
  * anchor to the left of the originally detached nodes is chosen.
160
160
  */
161
161
  function createInvertedDetach(detach, viewBeforeChange) {
162
- const validatedSource = EditUtilities_1.validateStableRange(viewBeforeChange, detach.source);
162
+ const validatedSource = (0, EditUtilities_1.validateStableRange)(viewBeforeChange, detach.source);
163
163
  if (validatedSource.result !== EditUtilities_1.RangeValidationResultKind.Valid) {
164
164
  // TODO:#68574: having the reference view would potentially allow us to revert some detaches that currently conflict
165
165
  return undefined;
166
166
  }
167
- const { start, end } = TreeViewUtilities_1.rangeFromStableRange(viewBeforeChange, validatedSource);
167
+ const { start, end } = (0, TreeViewUtilities_1.rangeFromStableRange)(viewBeforeChange, validatedSource);
168
168
  const { trait: referenceTrait } = start;
169
169
  const nodes = viewBeforeChange.getTrait(referenceTrait);
170
170
  const startIndex = viewBeforeChange.findIndexWithinTrait(start);
@@ -201,7 +201,7 @@ function createInvertedDetach(detach, viewBeforeChange) {
201
201
  const detachedSequenceId = 0;
202
202
  return {
203
203
  invertedDetach: [
204
- persisted_types_1.ChangeInternal.build(detachedNodeIds.map((id) => SerializationUtilities_1.getChangeNodeFromViewNode(viewBeforeChange, id)), detachedSequenceId),
204
+ persisted_types_1.ChangeInternal.build(detachedNodeIds.map((id) => (0, SerializationUtilities_1.getChangeNodeFromViewNode)(viewBeforeChange, id)), detachedSequenceId),
205
205
  persisted_types_1.ChangeInternal.insert(detachedSequenceId, insertDestination),
206
206
  ],
207
207
  detachedNodeIds,
@@ -1 +1 @@
1
- {"version":3,"file":"HistoryEditFactory.js","sourceRoot":"","sources":["../src/HistoryEditFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAiF;AACjF,qCAAwC;AACxC,2DAA2D;AAC3D,uDAS2B;AAC3B,+DAA4D;AAC5D,mDAAiF;AAIjF,qEAAqE;AAErE;;;;;;;;;;;GAWG;AACH,SAAgB,MAAM,CAAC,OAAkC,EAAE,MAAoB;IAC9E,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE9D,mEAAmE;IACnE,MAAM,MAAM,GAAG,yCAAmB,CAAC,OAAO,CAAC,MAA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nB,IAAI,EAAE,sBAAI,CAAC,KAAK;YAChB,gBAAgB;YAChB,cAAc,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;SAC3E,CAAC;KACF;IAED,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE;QACrC,OAAO;YACN,cAAc,EAAE,CAAC,gCAAc,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;YAC9E,eAAe;SACf,CAAC;KACF;IAED,MAAM,kBAAkB,GAAG,CAAuB,CAAC;IACnD,OAAO;QACN,cAAc,EAAE;YACf,gCAAc,CAAC,KAAK,CACnB,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,kDAAyB,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,EAC5E,kBAAkB,CAClB;YACD,gCAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;SAC5D;QACD,eAAe;KACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,QAA0B,EAAE,gBAA0B;IACrF,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,oFAAoF;QACpF,OAAO,SAAS,CAAC;KACjB;IAED,+EAA+E;IAC/E,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;QAC1B,OAAO,CAAC,gCAAc,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,CAAC,gCAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport { assert, fail } from './Common';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tChangeInternal,\n\tChangeTypeInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tInsertInternal,\n\tBuildNodeInternal,\n\tSide,\n\tStableRangeInternal,\n} from './persisted-types';\nimport { TransactionInternal } from './TransactionInternal';\nimport { RangeValidationResultKind, validateStableRange } from './EditUtilities';\nimport { StablePlace } from './ChangeTypes';\nimport { RevisionView } from './RevisionView';\nimport { TreeView } from './TreeView';\nimport { getChangeNodeFromViewNode } from './SerializationUtilities';\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a view of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @returns if the changes could be reverted, a sequence of changes _r_ that will produce `before` if applied to a view _A_, where _A_ is the result of\n * applying `changes` to `before`. Applying _r_ to views other than _A_ is legal but may cause the changes to fail to apply or may\n * not be a true semantic inverse. If the changes could not be reverted given the state of `before`, returns undefined.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before\n * @internal\n */\nexport function revert(changes: readonly ChangeInternal[], before: RevisionView): ChangeInternal[] | undefined {\n\tconst result: ChangeInternal[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = TransactionInternal.factory(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);\n\t\t\t\tassert(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.reduce((ids: NodeId[], curr: BuildNodeInternal) => {\n\t\t\t\t\t\tif (isDetachedSequenceId(curr)) {\n\t\t\t\t\t\t\tconst nodesForDetachedSequence =\n\t\t\t\t\t\t\t\tbuiltNodes.get(curr) ?? fail('detached sequence must have associated built nodes');\n\n\t\t\t\t\t\t\tids.push(...nodesForDetachedSequence);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tids.push(curr.identifier);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}, [])\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot revert an insert whose source is no longer available for inserting (i.e. not just built, and not detached)\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst invert = createInvertedDetach(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a detach whose source does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedDetach` is addressed\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = invert;\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tif (builtNodes.has(destination) || detachedNodes.has(destination)) {\n\t\t\t\t\t\t// Malformed: destination was already used by a prior build or detach\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\t\tconst invert = createInvertedSetValue(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a set for a node that does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedSetValue` is addressed\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tresult.unshift(...invert);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Update the revision\n\t\teditor.applyChange(change);\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * The inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(\n\tinsert: InsertInternal,\n\tnodesInserted: readonly NodeId[],\n\tsaveDetached = false\n): ChangeInternal {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRangeInternal = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn ChangeInternal.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling. Otherwise, the valid\n * anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: DetachInternal,\n\tviewBeforeChange: TreeView\n): { invertedDetach: ChangeInternal[]; detachedNodeIds: NodeId[] } | undefined {\n\tconst validatedSource = validateStableRange(viewBeforeChange, detach.source);\n\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t// TODO:#68574: having the reference view would potentially allow us to revert some detaches that currently conflict\n\t\treturn undefined;\n\t}\n\n\tconst { start, end } = rangeFromStableRange(viewBeforeChange, validatedSource);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = viewBeforeChange.getTrait(referenceTrait);\n\n\tconst startIndex = viewBeforeChange.findIndexWithinTrait(start);\n\tconst endIndex = viewBeforeChange.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [ChangeInternal.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChangeInternal.build(\n\t\t\t\tdetachedNodeIds.map((id) => getChangeNodeFromViewNode(viewBeforeChange, id)),\n\t\t\t\tdetachedSequenceId\n\t\t\t),\n\t\t\tChangeInternal.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\n/**\n * The inverse of a SetValue is a SetValue that sets the value to what it was prior to the change.\n */\nfunction createInvertedSetValue(setValue: SetValueInternal, viewBeforeChange: TreeView): ChangeInternal[] | undefined {\n\tconst { nodeToModify } = setValue;\n\tconst node = viewBeforeChange.tryGetViewNode(nodeToModify);\n\tif (node === undefined) {\n\t\t// TODO:68574: With a reference view, may be able to better resolve conflicting sets\n\t\treturn undefined;\n\t}\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\tif (node.payload !== null) {\n\t\treturn [ChangeInternal.setPayload(nodeToModify, node.payload)];\n\t}\n\treturn [ChangeInternal.clearPayload(nodeToModify)];\n}\n"]}
1
+ {"version":3,"file":"Histo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;IACrF,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,oFAAoF;QACpF,OAAO,SAAS,CAAC;KACjB;IAED,+EAA+E;IAC/E,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;QAC1B,OAAO,CAAC,gCAAc,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,CAAC,gCAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport { assert, fail } from './Common';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tChangeInternal,\n\tChangeTypeInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tInsertInternal,\n\tBuildNodeInternal,\n\tSide,\n\tStableRangeInternal,\n} from './persisted-types';\nimport { TransactionInternal } from './TransactionInternal';\nimport { RangeValidationResultKind, validateStableRange } from './EditUtilities';\nimport { StablePlace } from './ChangeTypes';\nimport { RevisionView } from './RevisionView';\nimport { TreeView } from './TreeView';\nimport { getChangeNodeFromViewNode } from './SerializationUtilities';\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a view of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @returns if the changes could be reverted, a sequence of changes _r_ that will produce `before` if applied to a view _A_, where _A_ is the result of\n * applying `changes` to `before`. Applying _r_ to views other than _A_ is legal but may cause the changes to fail to apply or may\n * not be a true semantic inverse. If the changes could not be reverted given the state of `before`, returns undefined.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before\n * @internal\n */\nexport function revert(changes: readonly ChangeInternal[], before: RevisionView): ChangeInternal[] | undefined {\n\tconst result: ChangeInternal[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = TransactionInternal.factory(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);\n\t\t\t\tassert(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.reduce((ids: NodeId[], curr: BuildNodeInternal) => {\n\t\t\t\t\t\tif (isDetachedSequenceId(curr)) {\n\t\t\t\t\t\t\tconst nodesForDetachedSequence =\n\t\t\t\t\t\t\t\tbuiltNodes.get(curr) ?? fail('detached sequence must have associated built nodes');\n\n\t\t\t\t\t\t\tids.push(...nodesForDetachedSequence);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tids.push(curr.identifier);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}, [])\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot revert an insert whose source is no longer available for inserting (i.e. not just built, and not detached)\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst invert = createInvertedDetach(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a detach whose source does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedDetach` is addressed\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = invert;\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tif (builtNodes.has(destination) || detachedNodes.has(destination)) {\n\t\t\t\t\t\t// Malformed: destination was already used by a prior build or detach\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\t\tconst invert = createInvertedSetValue(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a set for a node that does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedSetValue` is addressed\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tresult.unshift(...invert);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Update the revision\n\t\teditor.applyChange(change);\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * The inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(\n\tinsert: InsertInternal,\n\tnodesInserted: readonly NodeId[],\n\tsaveDetached = false\n): ChangeInternal {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRangeInternal = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn ChangeInternal.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling. Otherwise, the valid\n * anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: DetachInternal,\n\tviewBeforeChange: TreeView\n): { invertedDetach: ChangeInternal[]; detachedNodeIds: NodeId[] } | undefined {\n\tconst validatedSource = validateStableRange(viewBeforeChange, detach.source);\n\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t// TODO:#68574: having the reference view would potentially allow us to revert some detaches that currently conflict\n\t\treturn undefined;\n\t}\n\n\tconst { start, end } = rangeFromStableRange(viewBeforeChange, validatedSource);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = viewBeforeChange.getTrait(referenceTrait);\n\n\tconst startIndex = viewBeforeChange.findIndexWithinTrait(start);\n\tconst endIndex = viewBeforeChange.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [ChangeInternal.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChangeInternal.build(\n\t\t\t\tdetachedNodeIds.map((id) => getChangeNodeFromViewNode(viewBeforeChange, id)),\n\t\t\t\tdetachedSequenceId\n\t\t\t),\n\t\t\tChangeInternal.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\n/**\n * The inverse of a SetValue is a SetValue that sets the value to what it was prior to the change.\n */\nfunction createInvertedSetValue(setValue: SetValueInternal, viewBeforeChange: TreeView): ChangeInternal[] | undefined {\n\tconst { nodeToModify } = setValue;\n\tconst node = viewBeforeChange.tryGetViewNode(nodeToModify);\n\tif (node === undefined) {\n\t\t// TODO:68574: With a reference view, may be able to better resolve conflicting sets\n\t\treturn undefined;\n\t}\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\tif (node.payload !== null) {\n\t\treturn [ChangeInternal.setPayload(nodeToModify, node.payload)];\n\t}\n\treturn [ChangeInternal.clearPayload(nodeToModify)];\n}\n"]}
@@ -17,7 +17,7 @@ function convertEditIds(edit, convert) {
17
17
  type: persisted_types_1.ChangeTypeInternal.Build,
18
18
  destination: change.destination,
19
19
  source: change.source.map((tree) => {
20
- return EditUtilities_1.convertTreeNodes(tree, (node) => convertNodeDataIds(node, convert), Identifiers_1.isDetachedSequenceId);
20
+ return (0, EditUtilities_1.convertTreeNodes)(tree, (node) => convertNodeDataIds(node, convert), Identifiers_1.isDetachedSequenceId);
21
21
  }),
22
22
  };
23
23
  case persisted_types_1.ChangeTypeInternal.Insert:
@@ -31,7 +31,7 @@ function convertEditIds(edit, convert) {
31
31
  type: persisted_types_1.ChangeTypeInternal.Detach,
32
32
  source: convertStableRangeIds(change.source, convert),
33
33
  };
34
- Common_1.copyPropertyIfDefined(change, detach, 'destination');
34
+ (0, Common_1.copyPropertyIfDefined)(change, detach, 'destination');
35
35
  return detach;
36
36
  }
37
37
  case persisted_types_1.ChangeTypeInternal.SetValue:
@@ -46,28 +46,28 @@ function convertEditIds(edit, convert) {
46
46
  effect: change.effect,
47
47
  toConstrain: convertStableRangeIds(change.toConstrain, convert),
48
48
  };
49
- Common_1.copyPropertyIfDefined(change, constraint, 'identityHash');
50
- Common_1.copyPropertyIfDefined(change, constraint, 'label');
51
- Common_1.copyPropertyIfDefined(change, constraint, 'length');
52
- Common_1.copyPropertyIfDefined(change, constraint, 'contentHash');
49
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'identityHash');
50
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'label');
51
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'length');
52
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'contentHash');
53
53
  if (change.parentNode !== undefined) {
54
54
  constraint.parentNode = convert(change.parentNode);
55
55
  }
56
56
  return constraint;
57
57
  }
58
58
  default:
59
- Common_1.fail('Unknown change type.');
59
+ (0, Common_1.fail)('Unknown change type.');
60
60
  }
61
61
  });
62
62
  const newEdit = { id: edit.id, changes };
63
- Common_1.copyPropertyIfDefined(edit, newEdit, 'pastAttemptCount');
63
+ (0, Common_1.copyPropertyIfDefined)(edit, newEdit, 'pastAttemptCount');
64
64
  return newEdit;
65
65
  }
66
66
  exports.convertEditIds = convertEditIds;
67
67
  function convertNodeDataIds(nodeData, convert) {
68
68
  const identifier = convert(nodeData.identifier);
69
69
  const output = { definition: nodeData.definition, identifier };
70
- Common_1.copyPropertyIfDefined(nodeData, output, 'payload');
70
+ (0, Common_1.copyPropertyIfDefined)(nodeData, output, 'payload');
71
71
  return output;
72
72
  }
73
73
  exports.convertNodeDataIds = convertNodeDataIds;
@@ -1 +1 @@
1
- {"version":3,"file":"IdConversion.js","sourceRoot":"","sources":["../src/IdConversion.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAkF;AAClF,mDAAmD;AACnD,+CAAiF;AACjF,uDAW2B;AAE3B,SAAgB,cAAc,CAC7B,IAA4D,EAC5D,OAA6B;IAE7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAkD,EAAE;QAC3F,QAAQ,MAAM,CAAC,IAAI,EAAE;YACpB,KAAK,oCAAkB,CAAC,KAAK;g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CAAC,CAAC;IACtD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACvB,CAAC;AAPD,sDAOC;AAED,SAAgB,qBAAqB,CACpC,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAyD,EACjG,OAA6B;IAE7B,MAAM,cAAc,GAAiE;QACpF,IAAI;KACJ,CAAC;IAEF,IAAI,gBAAgB,KAAK,SAAS,EAAE;QACnC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACzC,cAAc,CAAC,gBAAgB,GAAG,MAAM,CAAC;KACzC;IAED,IAAI,cAAc,KAAK,SAAS,EAAE;QACjC,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC9C,cAAc,CAAC,cAAc,GAAG;YAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,MAAM;SACN,CAAC;KACF;IAED,OAAO,cAAc,CAAC;AACvB,CAAC;AAtBD,sDAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, ReplaceRecursive } from './Common';\nimport { convertTreeNodes } from './EditUtilities';\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport {\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintInternal,\n\tDetachInternal,\n\tEdit,\n\tNodeData,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n\tTreeNode,\n} from './persisted-types';\n\nexport function convertEditIds<IdFrom, IdTo>(\n\tedit: ReplaceRecursive<Edit<ChangeInternal>, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, IdTo>> {\n\tconst changes = edit.changes.map((change): ReplaceRecursive<ChangeInternal, NodeId, IdTo> => {\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.Build,\n\t\t\t\t\tdestination: change.destination,\n\t\t\t\t\tsource: change.source.map((tree) => {\n\t\t\t\t\t\treturn convertTreeNodes<\n\t\t\t\t\t\t\tTreeNode<ReplaceRecursive<BuildNodeInternal, NodeId, IdFrom>, IdFrom>,\n\t\t\t\t\t\t\tTreeNode<ReplaceRecursive<BuildNodeInternal, NodeId, IdTo>, IdTo>,\n\t\t\t\t\t\t\tDetachedSequenceId\n\t\t\t\t\t\t>(tree, (node) => convertNodeDataIds(node, convert), isDetachedSequenceId);\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.Insert,\n\t\t\t\t\tsource: change.source,\n\t\t\t\t\tdestination: convertStablePlaceIds(change.destination, convert),\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst detach: ReplaceRecursive<DetachInternal, NodeId, IdTo> = {\n\t\t\t\t\ttype: ChangeTypeInternal.Detach,\n\t\t\t\t\tsource: convertStableRangeIds(change.source, convert),\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(change, detach, 'destination');\n\t\t\t\treturn detach;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.SetValue,\n\t\t\t\t\tnodeToModify: convert(change.nodeToModify),\n\t\t\t\t\tpayload: change.payload,\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Constraint: {\n\t\t\t\tconst constraint: Mutable<ReplaceRecursive<ConstraintInternal, NodeId, IdTo>> = {\n\t\t\t\t\ttype: ChangeTypeInternal.Constraint,\n\t\t\t\t\teffect: change.effect,\n\t\t\t\t\ttoConstrain: convertStableRangeIds(change.toConstrain, convert),\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'identityHash');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'label');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'length');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'contentHash');\n\t\t\t\tif (change.parentNode !== undefined) {\n\t\t\t\t\tconstraint.parentNode = convert(change.parentNode);\n\t\t\t\t}\n\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tfail('Unknown change type.');\n\t\t}\n\t});\n\tconst newEdit = { id: edit.id, changes };\n\tcopyPropertyIfDefined(edit, newEdit, 'pastAttemptCount');\n\treturn newEdit;\n}\n\nexport function convertNodeDataIds<IdFrom, IdTo>(\n\tnodeData: NodeData<IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): NodeData<IdTo> {\n\tconst identifier = convert(nodeData.identifier);\n\tconst output = { definition: nodeData.definition, identifier };\n\tcopyPropertyIfDefined(nodeData, output, 'payload');\n\treturn output;\n}\n\nexport function convertStableRangeIds<IdFrom, IdTo>(\n\trange: ReplaceRecursive<StableRangeInternal, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): ReplaceRecursive<StableRangeInternal, NodeId, IdTo> {\n\tconst start = convertStablePlaceIds(range.start, convert);\n\tconst end = convertStablePlaceIds(range.end, convert);\n\treturn { start, end };\n}\n\nexport function convertStablePlaceIds<IdFrom, IdTo>(\n\t{ side, referenceSibling, referenceTrait }: ReplaceRecursive<StablePlaceInternal, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): ReplaceRecursive<StablePlaceInternal, NodeId, IdTo> {\n\tconst stablePlaceNew: Mutable<ReplaceRecursive<StablePlaceInternal, NodeId, IdTo>> = {\n\t\tside,\n\t};\n\n\tif (referenceSibling !== undefined) {\n\t\tconst nodeId = convert(referenceSibling);\n\t\tstablePlaceNew.referenceSibling = nodeId;\n\t}\n\n\tif (referenceTrait !== undefined) {\n\t\tconst parent = convert(referenceTrait.parent);\n\t\tstablePlaceNew.referenceTrait = {\n\t\t\tlabel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OAA6B;IAE7B,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;IAC/D,IAAA,8BAAqB,EAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC;AACf,CAAC;AARD,gDAQC;AAED,SAAgB,qBAAqB,CACpC,KAA4D,EAC5D,OAA6B;IAE7B,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACvB,CAAC;AAPD,sDAOC;AAED,SAAgB,qBAAqB,CACpC,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAyD,EACjG,OAA6B;IAE7B,MAAM,cAAc,GAAiE;QACpF,IAAI;KACJ,CAAC;IAEF,IAAI,gBAAgB,KAAK,SAAS,EAAE;QACnC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACzC,cAAc,CAAC,gBAAgB,GAAG,MAAM,CAAC;KACzC;IAED,IAAI,cAAc,KAAK,SAAS,EAAE;QACjC,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC9C,cAAc,CAAC,cAAc,GAAG;YAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,MAAM;SACN,CAAC;KACF;IAED,OAAO,cAAc,CAAC;AACvB,CAAC;AAtBD,sDAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, ReplaceRecursive } from './Common';\nimport { convertTreeNodes } from './EditUtilities';\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport {\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintInternal,\n\tDetachInternal,\n\tEdit,\n\tNodeData,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n\tTreeNode,\n} from './persisted-types';\n\nexport function convertEditIds<IdFrom, IdTo>(\n\tedit: ReplaceRecursive<Edit<ChangeInternal>, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, IdTo>> {\n\tconst changes = edit.changes.map((change): ReplaceRecursive<ChangeInternal, NodeId, IdTo> => {\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.Build,\n\t\t\t\t\tdestination: change.destination,\n\t\t\t\t\tsource: change.source.map((tree) => {\n\t\t\t\t\t\treturn convertTreeNodes<\n\t\t\t\t\t\t\tTreeNode<ReplaceRecursive<BuildNodeInternal, NodeId, IdFrom>, IdFrom>,\n\t\t\t\t\t\t\tTreeNode<ReplaceRecursive<BuildNodeInternal, NodeId, IdTo>, IdTo>,\n\t\t\t\t\t\t\tDetachedSequenceId\n\t\t\t\t\t\t>(tree, (node) => convertNodeDataIds(node, convert), isDetachedSequenceId);\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.Insert,\n\t\t\t\t\tsource: change.source,\n\t\t\t\t\tdestination: convertStablePlaceIds(change.destination, convert),\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst detach: ReplaceRecursive<DetachInternal, NodeId, IdTo> = {\n\t\t\t\t\ttype: ChangeTypeInternal.Detach,\n\t\t\t\t\tsource: convertStableRangeIds(change.source, convert),\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(change, detach, 'destination');\n\t\t\t\treturn detach;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\treturn {\n\t\t\t\t\ttype: ChangeTypeInternal.SetValue,\n\t\t\t\t\tnodeToModify: convert(change.nodeToModify),\n\t\t\t\t\tpayload: change.payload,\n\t\t\t\t};\n\t\t\tcase ChangeTypeInternal.Constraint: {\n\t\t\t\tconst constraint: Mutable<ReplaceRecursive<ConstraintInternal, NodeId, IdTo>> = {\n\t\t\t\t\ttype: ChangeTypeInternal.Constraint,\n\t\t\t\t\teffect: change.effect,\n\t\t\t\t\ttoConstrain: convertStableRangeIds(change.toConstrain, convert),\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'identityHash');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'label');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'length');\n\t\t\t\tcopyPropertyIfDefined(change, constraint, 'contentHash');\n\t\t\t\tif (change.parentNode !== undefined) {\n\t\t\t\t\tconstraint.parentNode = convert(change.parentNode);\n\t\t\t\t}\n\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tfail('Unknown change type.');\n\t\t}\n\t});\n\tconst newEdit = { id: edit.id, changes };\n\tcopyPropertyIfDefined(edit, newEdit, 'pastAttemptCount');\n\treturn newEdit;\n}\n\nexport function convertNodeDataIds<IdFrom, IdTo>(\n\tnodeData: NodeData<IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): NodeData<IdTo> {\n\tconst identifier = convert(nodeData.identifier);\n\tconst output = { definition: nodeData.definition, identifier };\n\tcopyPropertyIfDefined(nodeData, output, 'payload');\n\treturn output;\n}\n\nexport function convertStableRangeIds<IdFrom, IdTo>(\n\trange: ReplaceRecursive<StableRangeInternal, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): ReplaceRecursive<StableRangeInternal, NodeId, IdTo> {\n\tconst start = convertStablePlaceIds(range.start, convert);\n\tconst end = convertStablePlaceIds(range.end, convert);\n\treturn { start, end };\n}\n\nexport function convertStablePlaceIds<IdFrom, IdTo>(\n\t{ side, referenceSibling, referenceTrait }: ReplaceRecursive<StablePlaceInternal, NodeId, IdFrom>,\n\tconvert: (id: IdFrom) => IdTo\n): ReplaceRecursive<StablePlaceInternal, NodeId, IdTo> {\n\tconst stablePlaceNew: Mutable<ReplaceRecursive<StablePlaceInternal, NodeId, IdTo>> = {\n\t\tside,\n\t};\n\n\tif (referenceSibling !== undefined) {\n\t\tconst nodeId = convert(referenceSibling);\n\t\tstablePlaceNew.referenceSibling = nodeId;\n\t}\n\n\tif (referenceTrait !== undefined) {\n\t\tconst parent = convert(referenceTrait.parent);\n\t\tstablePlaceNew.referenceTrait = {\n\t\t\tlabel: referenceTrait.label,\n\t\t\tparent,\n\t\t};\n\t}\n\n\treturn stablePlaceNew;\n}\n"]}
@@ -14,6 +14,10 @@
14
14
  export declare type UuidString = string & {
15
15
  readonly UuidString: '9d40d0ae-90d9-44b1-9482-9f55d59d5465';
16
16
  };
17
+ /**
18
+ * An identifier associated with a session for the purpose of attributing its created content to some user/entity.
19
+ */
20
+ export declare type AttributionId = UuidString;
17
21
  /**
18
22
  * A version 4, variant 2 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
19
23
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Identifiers.d.ts","sourceRoot":"","sources":["../src/Identifiers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH;;;;;GAKG;AACH,oBAAY,UAAU,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,sCAAsC,CAAA;CAAE,CAAC;AAElG;;;GAGG;AACH,oBAAY,QAAQ,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,sCAAsC,CAAA;CAAE,CAAC;AAElG;;;GAGG;AACH,oBAAY,SAAS,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,sCAA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GAIG;AACH,oBAAY,UAAU,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,sCAAsC,CAAA;CAAE,CAAC;AAEtG;;;GAGG;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAElG"}
@@ -1 +1 @@
1
- {"version":3,"file":"Identifiers.js","sourceRoot":"","sources":["../src/Identifiers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8IH;;;GAGG;AACH,wDAAwD;AACxD,SAAgB,oBAAoB,CAAC,IAAiC;IACrE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AACjC,CAAC;AAFD,oDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type-safe identifiers for specific use cases.\n */\n\n/**\n * A 128-bit Universally Unique IDentifier. Represented here\n * with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,\n * where x is a lowercase hex digit.\n * @public\n */\nexport type UuidString = string & { readonly UuidString: '9d40d0ae-90d9-44b1-9482-9f55d59d5465' };\n\n/**\n * A version 4, variant 2 uuid (https://datatracker.ietf.org/doc/html/rfc4122).\n * @internal\n */\nexport type StableId = UuidString & { readonly StableId: '53172b0d-a3d5-41ea-bd75-b43839c97f5a' };\n\n/**\n * A StableId which is suitable for use as a session identifier\n * @internal\n */\nexport type SessionId = StableId & { readonly SessionId: '4498f850-e14e-4be9-8db0-89ec00997e58' };\n\n/**\n * Edit identifier\n * @public\n */\nexport type EditId = UuidString & { readonly EditId: '56897beb-53e4-4e66-85da-4bf5cd5d0d49' };\n\n/**\n * Scoped to a single edit: identifies a sequences of nodes that can be moved into a trait.\n *\n * Within a given Edit, any DetachedSequenceId must be a source at most once, and a destination at most once.\n * If used as a source, it must be after it is used as a destination.\n * If this is violated, the Edit is considered malformed.\n * @public\n */\nexport type DetachedSequenceId = number & { readonly DetachedSequenceId: 'f7d7903a-194e-45e7-8e82-c9ef4333577d' };\n\n/**\n * An identifier (UUID) that has been shortened by a distributed compression algorithm.\n * @public\n */\nexport type CompressedId = FinalCompressedId | LocalCompressedId;\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the original string.\n * @public\n */\nexport type InternedStringId = number & { readonly InternedStringId: 'e221abc9-9d17-4493-8db0-70c871a1c27c' };\n\n/**\n * A brand for identity types that are unique within a particular session (SharedTree instance).\n */\nexport interface SessionUnique {\n\treadonly SessionUnique: 'cea55054-6b82-4cbf-ad19-1fa645ea3b3e';\n}\n\n/**\n * A compressed ID that has been normalized into \"session space\" (see `IdCompressor` for more).\n * Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to the\n * compressor that produced them.\n * @public\n */\nexport type SessionSpaceCompressedId = CompressedId & SessionUnique;\n\n/**\n * A compressed ID that has been normalized into \"op space\" (see `IdCompressor` for more).\n * Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require no normalizing when\n * received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.\n * @internal\n */\nexport type OpSpaceCompressedId = CompressedId & {\n\treadonly OpNormalized: '9209432d-a959-4df7-b2ad-767ead4dbcae';\n};\n\n/**\n * A compressed ID that is local to a document. Stable across all revisions of a document starting from the one in which it was created.\n * It should not be persisted outside of the history as it can only be decompressed in the context of the originating document.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n * @public\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: '5d83d1e2-98b7-4e4e-a889-54c855cfa73d';\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: '9209432d-a959-4df7-b2ad-767ead4dbcae';\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * It should not be persisted outside of the history as it can only be decompressed in the context of the originating session.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n * @public\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: '6fccb42f-e2a4-4243-bd29-f13d12b9c6d1';\n} & SessionUnique; // Same brand as CompressedId, as local IDs are always locally normalized\n\nexport interface NodeIdBrand {\n\treadonly NodeId: 'e53e7d6b-c8b9-431a-8805-4843fc639342';\n}\n\n/**\n * Node identifier.\n * Identifies a node within a document.\n * @public\n */\nexport type NodeId = number & SessionSpaceCompressedId & NodeIdBrand;\n\nexport type FinalNodeId = FinalCompressedId & NodeIdBrand;\n\n/**\n * A Node identifier which is persisted by SharedTree internals. Not usable as a {@link NodeId}.\n * @internal\n */\nexport type OpSpaceNodeId = number & OpSpaceCompressedId & NodeIdBrand;\n\n/**\n * Globally unique node identifier.\n * Uniquely identifies a node within and across documents. Can be used across SharedTree instances.\n * @public\n */\nexport type StableNodeId = string & { readonly StableNodeId: 'a0843b38-699d-4bb2-aa7a-16c502a71151' };\n\n/**\n * Definition.\n * A full (Uuid) persistable definition.\n * @public\n */\nexport type Definition = UuidString & { readonly Definition: 'c0ef9488-2a78-482d-aeed-37fba996354c' };\n\n/**\n * Definition.\n * A full (Uuid) persistable label for a trait.\n * @public\n */\nexport type TraitLabel = UuidString & { readonly TraitLabel: '613826ed-49cc-4df3-b2b8-bfc6866af8e3' };\n\n/**\n * Determine if a node is a DetachedSequenceId.\n * @internal\n */\n// Nodes can be an `object` type which is a banned type.\nexport function isDetachedSequenceId(node: DetachedSequenceId | object): node is DetachedSequenceId {\n\treturn typeof node !== 'object';\n}\n"]}
1
+ {"version":3,"file":"Identifiers.js","sourceRoot":"","sources":["../src/Identifiers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmJH;;;GAGG;AACH,wDAAwD;AACxD,SAAgB,oBAAoB,CAAC,IAAiC;IACrE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AACjC,CAAC;AAFD,oDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type-safe identifiers for specific use cases.\n */\n\n/**\n * A 128-bit Universally Unique IDentifier. Represented here\n * with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,\n * where x is a lowercase hex digit.\n * @public\n */\nexport type UuidString = string & { readonly UuidString: '9d40d0ae-90d9-44b1-9482-9f55d59d5465' };\n\n/**\n * An identifier associated with a session for the purpose of attributing its created content to some user/entity.\n */\nexport type AttributionId = UuidString;\n\n/**\n * A version 4, variant 2 uuid (https://datatracker.ietf.org/doc/html/rfc4122).\n * @internal\n */\nexport type StableId = UuidString & { readonly StableId: '53172b0d-a3d5-41ea-bd75-b43839c97f5a' };\n\n/**\n * A StableId which is suitable for use as a session identifier\n * @internal\n */\nexport type SessionId = StableId & { readonly SessionId: '4498f850-e14e-4be9-8db0-89ec00997e58' };\n\n/**\n * Edit identifier\n * @public\n */\nexport type EditId = UuidString & { readonly EditId: '56897beb-53e4-4e66-85da-4bf5cd5d0d49' };\n\n/**\n * Scoped to a single edit: identifies a sequences of nodes that can be moved into a trait.\n *\n * Within a given Edit, any DetachedSequenceId must be a source at most once, and a destination at most once.\n * If used as a source, it must be after it is used as a destination.\n * If this is violated, the Edit is considered malformed.\n * @public\n */\nexport type DetachedSequenceId = number & { readonly DetachedSequenceId: 'f7d7903a-194e-45e7-8e82-c9ef4333577d' };\n\n/**\n * An identifier (UUID) that has been shortened by a distributed compression algorithm.\n * @public\n */\nexport type CompressedId = FinalCompressedId | LocalCompressedId;\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the original string.\n * @public\n */\nexport type InternedStringId = number & { readonly InternedStringId: 'e221abc9-9d17-4493-8db0-70c871a1c27c' };\n\n/**\n * A brand for identity types that are unique within a particular session (SharedTree instance).\n */\nexport interface SessionUnique {\n\treadonly SessionUnique: 'cea55054-6b82-4cbf-ad19-1fa645ea3b3e';\n}\n\n/**\n * A compressed ID that has been normalized into \"session space\" (see `IdCompressor` for more).\n * Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to the\n * compressor that produced them.\n * @public\n */\nexport type SessionSpaceCompressedId = CompressedId & SessionUnique;\n\n/**\n * A compressed ID that has been normalized into \"op space\" (see `IdCompressor` for more).\n * Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require no normalizing when\n * received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.\n * @internal\n */\nexport type OpSpaceCompressedId = CompressedId & {\n\treadonly OpNormalized: '9209432d-a959-4df7-b2ad-767ead4dbcae';\n};\n\n/**\n * A compressed ID that is local to a document. Stable across all revisions of a document starting from the one in which it was created.\n * It should not be persisted outside of the history as it can only be decompressed in the context of the originating document.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n * @public\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: '5d83d1e2-98b7-4e4e-a889-54c855cfa73d';\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: '9209432d-a959-4df7-b2ad-767ead4dbcae';\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * It should not be persisted outside of the history as it can only be decompressed in the context of the originating session.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n * @public\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: '6fccb42f-e2a4-4243-bd29-f13d12b9c6d1';\n} & SessionUnique; // Same brand as CompressedId, as local IDs are always locally normalized\n\nexport interface NodeIdBrand {\n\treadonly NodeId: 'e53e7d6b-c8b9-431a-8805-4843fc639342';\n}\n\n/**\n * Node identifier.\n * Identifies a node within a document.\n * @public\n */\nexport type NodeId = number & SessionSpaceCompressedId & NodeIdBrand;\n\nexport type FinalNodeId = FinalCompressedId & NodeIdBrand;\n\n/**\n * A Node identifier which is persisted by SharedTree internals. Not usable as a {@link NodeId}.\n * @internal\n */\nexport type OpSpaceNodeId = number & OpSpaceCompressedId & NodeIdBrand;\n\n/**\n * Globally unique node identifier.\n * Uniquely identifies a node within and across documents. Can be used across SharedTree instances.\n * @public\n */\nexport type StableNodeId = string & { readonly StableNodeId: 'a0843b38-699d-4bb2-aa7a-16c502a71151' };\n\n/**\n * Definition.\n * A full (Uuid) persistable definition.\n * @public\n */\nexport type Definition = UuidString & { readonly Definition: 'c0ef9488-2a78-482d-aeed-37fba996354c' };\n\n/**\n * Definition.\n * A full (Uuid) persistable label for a trait.\n * @public\n */\nexport type TraitLabel = UuidString & { readonly TraitLabel: '613826ed-49cc-4df3-b2b8-bfc6866af8e3' };\n\n/**\n * Determine if a node is a DetachedSequenceId.\n * @internal\n */\n// Nodes can be an `object` type which is a banned type.\nexport function isDetachedSequenceId(node: DetachedSequenceId | object): node is DetachedSequenceId {\n\treturn typeof node !== 'object';\n}\n"]}
@@ -184,10 +184,6 @@ export declare class CachingLogViewer implements LogViewer {
184
184
  * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.
185
185
  */
186
186
  private readonly processEditStatus;
187
- /**
188
- * Iff true, additional correctness assertions will be run during LogViewer operations.
189
- */
190
- private readonly expensiveValidation;
191
187
  /**
192
188
  * The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.
193
189
  * This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.
@@ -225,7 +221,7 @@ export declare class CachingLogViewer implements LogViewer {
225
221
  * @param processEditStatus - called after applying an edit.
226
222
  * @param processSequencedEditResult - called after applying a sequenced edit.
227
223
  */
228
- constructor(log: EditLog<ChangeInternal>, baseView: RevisionView, knownRevisions?: [Revision, EditCacheEntry][], expensiveValidation?: boolean, processEditStatus?: EditStatusCallback, processSequencedEditResult?: SequencedEditResultCallback, minimumSequenceNumber?: number);
224
+ constructor(log: EditLog<ChangeInternal>, baseView: RevisionView, knownRevisions?: [Revision, EditCacheEntry][], processEditStatus?: EditStatusCallback, processSequencedEditResult?: SequencedEditResultCallback, minimumSequenceNumber?: number);
229
225
  /**
230
226
  * As a performance optimization, this method caches views generated by local edits if they are sequenced without
231
227
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,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAIhE,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc;IAW1D,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY;IAIjE;;;;;OAKG;IACI,wBAAwB,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI;IAOpE;;;OAGG;IACI,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAIrF;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAwCxB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IA2DjB;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAiBjC;;;;;OAKG;IACI,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB;IA2DrE;;OAEG;IACI,8BAA8B,IAAI;QAAE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAa3G;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0B9B;;;;OAIG;IACI,+BAA+B,CAAC,cAAc,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;CA0C/F"}
package/dist/LogViewer.js CHANGED
@@ -31,7 +31,7 @@ class CachingLogViewer {
31
31
  * @param processEditStatus - called after applying an edit.
32
32
  * @param processSequencedEditResult - called after applying a sequenced edit.
33
33
  */
34
- constructor(log, baseView, knownRevisions = [], expensiveValidation = false, processEditStatus = Common_1.noop, processSequencedEditResult = Common_1.noop, minimumSequenceNumber = 0) {
34
+ constructor(log, baseView, knownRevisions = [], processEditStatus = Common_1.noop, processSequencedEditResult = Common_1.noop, minimumSequenceNumber = 0) {
35
35
  /**
36
36
  * A cache for local revisions.
37
37
  * It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.
@@ -45,16 +45,13 @@ class CachingLogViewer {
45
45
  */
46
46
  this.unappliedSelfEdits = new denque_1.default();
47
47
  this.log = log;
48
- if (expensiveValidation) {
49
- knownRevisions.forEach(([revision]) => {
50
- Common_1.assert(Number.isInteger(revision), 'revision must be an integer');
51
- Common_1.assert(this.log.isSequencedRevision(revision), 'revision must correspond to the result of a SequencedEdit');
52
- });
53
- }
48
+ knownRevisions.forEach(([revision]) => {
49
+ (0, Common_1.assert)(Number.isInteger(revision), 'revision must be an integer');
50
+ (0, Common_1.assert)(this.log.isSequencedRevision(revision), 'revision must correspond to the result of a SequencedEdit');
51
+ });
54
52
  this.sequencedRevisionCache = new RevisionValueCache_1.RevisionValueCache(CachingLogViewer.sequencedCacheSizeMax, minimumSequenceNumber, [...knownRevisions, [0, { view: baseView }]]);
55
53
  this.processEditStatus = processEditStatus !== null && processEditStatus !== void 0 ? processEditStatus : Common_1.noop;
56
54
  this.processSequencedEditResult = processSequencedEditResult !== null && processSequencedEditResult !== void 0 ? processSequencedEditResult : Common_1.noop;
57
- this.expensiveValidation = expensiveValidation;
58
55
  this.detachFromEditLog = this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));
59
56
  }
60
57
  /**
@@ -167,16 +164,16 @@ class CachingLogViewer {
167
164
  // This is because the local cache does not contain an entry for the implicit initial tree edit.
168
165
  const localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;
169
166
  if (localCacheIndex < length) {
170
- const cached = (_a = this.localRevisionCache.peekAt(localCacheIndex)) !== null && _a !== void 0 ? _a : Common_1.fail('missing tail of localRevisionViewCache');
167
+ const cached = (_a = this.localRevisionCache.peekAt(localCacheIndex)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('missing tail of localRevisionViewCache');
171
168
  return Object.assign(Object.assign({}, cached), { startRevision: revisionClamped });
172
169
  }
173
170
  else {
174
- current = (_b = this.localRevisionCache.peekAt(length - 1)) !== null && _b !== void 0 ? _b : Common_1.fail('missing tail of localRevisionViewCache');
171
+ current = (_b = this.localRevisionCache.peekAt(length - 1)) !== null && _b !== void 0 ? _b : (0, Common_1.fail)('missing tail of localRevisionViewCache');
175
172
  startRevision = numberOfSequencedEdits + length;
176
173
  }
177
174
  }
178
175
  else {
179
- const [cachedRevision, cachedView] = (_c = this.sequencedRevisionCache.getClosestEntry(revisionClamped)) !== null && _c !== void 0 ? _c : Common_1.fail('No preceding revision view cached.');
176
+ const [cachedRevision, cachedView] = (_c = this.sequencedRevisionCache.getClosestEntry(revisionClamped)) !== null && _c !== void 0 ? _c : (0, Common_1.fail)('No preceding revision view cached.');
180
177
  startRevision = cachedRevision;
181
178
  current = cachedView;
182
179
  }
@@ -225,7 +222,7 @@ class CachingLogViewer {
225
222
  // This relies on local edits being append only, and that generating the view for a local revision requires generating
226
223
  // the views for all local revisions before it in the log. Thus, generating such a view will necessarily require
227
224
  // calls to this method for all local revisions prior, guaranteeing the correct push order.
228
- Common_1.assert(revision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1, 'Local revision view cached out of order.');
225
+ (0, Common_1.assert)(revision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1, 'Local revision view cached out of order.');
229
226
  this.localRevisionCache.push(computedCacheEntry);
230
227
  }
231
228
  // Only update highestRevisionCacheEntry if this snapshot is the highest revision.
@@ -249,11 +246,6 @@ class CachingLogViewer {
249
246
  wasLocal = true;
250
247
  this.unappliedSelfEdits.shift();
251
248
  }
252
- else if (this.expensiveValidation) {
253
- for (let i = 0; i < this.unappliedSelfEdits.length; i++) {
254
- Common_1.assert(this.unappliedSelfEdits.peekAt(i) !== edit.id, 'Local edits processed out of order.');
255
- }
256
- }
257
249
  }
258
250
  this.processSequencedEditResult({ edit, wasLocal, result, reconciliationPath });
259
251
  }
@@ -327,7 +319,7 @@ class CachingLogViewer {
327
319
  const before = this.getRevisionViewInSession(index);
328
320
  const resultAfter = this.getEditResultInSession(index + 1);
329
321
  if (resultAfter.status === undefined) {
330
- Common_1.fail('The status of every edit in session should be known');
322
+ (0, Common_1.fail)('The status of every edit in session should be known');
331
323
  }
332
324
  return resultAfter.status === persisted_types_1.EditStatus.Applied
333
325
  ? {
@@ -370,7 +362,7 @@ class CachingLogViewer {
370
362
  const before = this.getRevisionViewInSession(index);
371
363
  const resultAfter = this.getEditResultInSession(index + 1);
372
364
  if (resultAfter.status === undefined) {
373
- Common_1.fail('The status of every edit in session should be known');
365
+ (0, Common_1.fail)('The status of every edit in session should be known');
374
366
  }
375
367
  return resultAfter.status === persisted_types_1.EditStatus.Applied
376
368
  ? {