@fluid-experimental/tree 0.59.2000 → 0.59.3000-67119

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
package/.eslintrc.js CHANGED
@@ -9,6 +9,7 @@ module.exports = {
9
9
  rules: {
10
10
  // TODO: Recover "noUnusedLocals" behavior as part of linting. (This rule seems to be broken in the Fluid repo.)
11
11
  // '@typescript-eslint/no-unused-vars': ['error', { args: 'none', varsIgnorePattern: '^_' }],
12
+ '@typescript-eslint/brace-style': 'off',
12
13
  '@typescript-eslint/quotes': [
13
14
  'error',
14
15
  'single',
@@ -24,6 +25,7 @@ module.exports = {
24
25
  // Prettier
25
26
  'comma-dangle': 'off',
26
27
  '@typescript-eslint/comma-dangle': 'off',
28
+ '@typescript-eslint/member-delimiter-style': 'off',
27
29
  'max-len': 'off',
28
30
  'no-mixed-spaces-and-tabs': 'off',
29
31
 
@@ -0,0 +1,15 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "name": "FluidFramework",
5
+ "path": "../../../../"
6
+ },
7
+ {
8
+ "name": "@fluid-experimental/tree",
9
+ "path": ".."
10
+ }
11
+ ],
12
+ "settings": {
13
+ "terminal.integrated.cwd": "../../.."
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "mochaExplorer.files": ["dist/**/*.tests.js"],
3
+ "mochaExplorer.pruneFiles": true,
4
+ "mochaExplorer.require": "node_modules/@fluidframework/mocha-test-setup",
5
+ "mochaExplorer.timeout": 999999
6
+ }
@@ -58,17 +58,17 @@ function normalizeChange(change, normalizeId) {
58
58
  case persisted_types_1.ChangeTypeInternal.Insert: {
59
59
  const insert = {
60
60
  source: change.source,
61
- destination: IdConversion_1.convertStablePlaceIds(change.destination, normalizeId),
61
+ destination: (0, IdConversion_1.convertStablePlaceIds)(change.destination, normalizeId),
62
62
  type: persisted_types_1.ChangeTypeInternal.Insert,
63
63
  };
64
64
  return insert;
65
65
  }
66
66
  case persisted_types_1.ChangeTypeInternal.Detach: {
67
67
  const detach = {
68
- source: IdConversion_1.convertStableRangeIds(change.source, normalizeId),
68
+ source: (0, IdConversion_1.convertStableRangeIds)(change.source, normalizeId),
69
69
  type: persisted_types_1.ChangeTypeInternal.Detach,
70
70
  };
71
- Common_1.copyPropertyIfDefined(change, detach, 'destination');
71
+ (0, Common_1.copyPropertyIfDefined)(change, detach, 'destination');
72
72
  return detach;
73
73
  }
74
74
  case persisted_types_1.ChangeTypeInternal.SetValue: {
@@ -82,20 +82,20 @@ function normalizeChange(change, normalizeId) {
82
82
  case persisted_types_1.ChangeTypeInternal.Constraint: {
83
83
  const constraint = {
84
84
  effect: change.effect,
85
- toConstrain: IdConversion_1.convertStableRangeIds(change.toConstrain, normalizeId),
85
+ toConstrain: (0, IdConversion_1.convertStableRangeIds)(change.toConstrain, normalizeId),
86
86
  type: persisted_types_1.ChangeTypeInternal.Constraint,
87
87
  };
88
- Common_1.copyPropertyIfDefined(change, constraint, 'contentHash');
89
- Common_1.copyPropertyIfDefined(change, constraint, 'identityHash');
90
- Common_1.copyPropertyIfDefined(change, constraint, 'label');
91
- Common_1.copyPropertyIfDefined(change, constraint, 'length');
88
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'contentHash');
89
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'identityHash');
90
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'label');
91
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'length');
92
92
  if (change.parentNode !== undefined) {
93
93
  constraint.parentNode = normalizeId(change.parentNode);
94
94
  }
95
95
  return constraint;
96
96
  }
97
97
  default:
98
- Common_1.fail('unexpected change type');
98
+ (0, Common_1.fail)('unexpected change type');
99
99
  }
100
100
  }
101
101
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeCompression.js","sourceRoot":"","sources":["../src/ChangeCompression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uDAY2B;AAE3B,qCAAkF;AAGlF,iDAA8E;AAE9E;;;;GAIG;AACH,MAAa,gBAAgB;IAC5B,YAAoC,cAAkD;QAAlD,mBAAc,GAAd,cAAc,CAAoC;IAAG,C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,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;YAC1D,8BAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YACnD,8BAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACpD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;gBACpC,UAAU,CAAC,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aACvD;YACD,OAAO,UAAU,CAAC;SAClB;QACD;YACC,aAAI,CAAC,wBAAwB,CAAC,CAAC;KAChC;AACF,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAC3B,UAA4B,EAC5B,QAAwB,EACxB,YAAiD,EACjD,IAAW;IAEX,uCACI,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,IACzF;AACH,CAAC;AAVD,oCAUC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAI7B,UAA4B,EAC5B,QAAwB,EACxB,YAAiD,EACjD,IAAW;IAEX,uCACI,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,IAC3F;AACH,CAAC;AAbD,wCAaC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, NodeId, OpSpaceNodeId } from './Identifiers';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tCompressedChangeInternal,\n\tChangeTypeInternal,\n\tCompressedBuildInternal,\n\tCompressedPlaceholderTree,\n\tInsertInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tConstraintInternal,\n} from './persisted-types';\nimport { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { copyPropertyIfDefined, fail, Mutable, ReplaceRecursive } from './Common';\nimport { TreeCompressor } from './TreeCompressor';\nimport { StringInterner } from './StringInterner';\nimport { convertStablePlaceIds, convertStableRangeIds } from './IdConversion';\n\n/**\n * Encapsulates knowledge of how to compress/decompress a change into a compressed change\n * Compression and decompression each take in a {@link StringInterner} for deduplicating shared strings.\n * @internal\n */\nexport class ChangeCompressor {\n\tpublic constructor(private readonly treeCompressor: TreeCompressor<DetachedSequenceId>) {}\n\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tchange: ChangeInternal,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedChangeInternal<TId> {\n\t\tif (change.type === ChangeTypeInternal.Build) {\n\t\t\tconst source: CompressedPlaceholderTree<TId, DetachedSequenceId>[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.compress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: CompressedBuildInternal<TId> = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.CompressedBuild,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToOpSpace(id));\n\t\t}\n\t}\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tchange: CompressedChangeInternal<TId>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): ChangeInternal {\n\t\tif (change.type === ChangeTypeInternal.CompressedBuild) {\n\t\t\tconst source: BuildNodeInternal[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.decompress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: BuildInternal = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.Build,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToSessionSpace(id));\n\t\t}\n\t}\n}\n\nfunction normalizeChange<From extends NodeId | OpSpaceNodeId, To extends NodeId | OpSpaceNodeId>(\n\tchange: ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, From>,\n\tnormalizeId: (id: From) => To\n): ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, To> {\n\tswitch (change.type) {\n\t\tcase ChangeTypeInternal.Insert: {\n\t\t\tconst insert: ReplaceRecursive<InsertInternal, NodeId, To> = {\n\t\t\t\tsource: change.source,\n\t\t\t\tdestination: convertStablePlaceIds(change.destination, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Insert,\n\t\t\t};\n\t\t\treturn insert;\n\t\t}\n\t\tcase ChangeTypeInternal.Detach: {\n\t\t\tconst detach: ReplaceRecursive<DetachInternal, NodeId, To> = {\n\t\t\t\tsource: convertStableRangeIds(change.source, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Detach,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, detach, 'destination');\n\t\t\treturn detach;\n\t\t}\n\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\tconst setValue: ReplaceRecursive<SetValueInternal, NodeId, To> = {\n\t\t\t\tnodeToModify: normalizeId(change.nodeToModify),\n\t\t\t\tpayload: change.payload,\n\t\t\t\ttype: ChangeTypeInternal.SetValue,\n\t\t\t};\n\t\t\treturn setValue;\n\t\t}\n\t\tcase ChangeTypeInternal.Constraint: {\n\t\t\tconst constraint: Mutable<ReplaceRecursive<ConstraintInternal, NodeId, To>> = {\n\t\t\t\teffect: change.effect,\n\t\t\t\ttoConstrain: convertStableRangeIds(change.toConstrain, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Constraint,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, constraint, 'contentHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'identityHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'label');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'length');\n\t\t\tif (change.parentNode !== undefined) {\n\t\t\t\tconstraint.parentNode = normalizeId(change.parentNode);\n\t\t\t}\n\t\t\treturn constraint;\n\t\t}\n\t\tdefault:\n\t\t\tfail('unexpected change type');\n\t}\n}\n\n/**\n * Compresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function compressEdit<TId extends OpSpaceNodeId, TEdit extends { changes: readonly ChangeInternal[] }>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly CompressedChangeInternal<TId>[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.compress(change, interner, idNormalizer)),\n\t};\n}\n\n/**\n * Decompresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function decompressEdit<\n\tTId extends OpSpaceNodeId,\n\tTEdit extends { changes: readonly CompressedChangeInternal<TId>[] }\n>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly ChangeInternal[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.decompress(change, interner, idNormalizer)),\n\t};\n}\n"]}
1
+ {"version":3,"file":"ChangeCompression.js","sourceRoot":"","sources":["../src/ChangeCompression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uDAY2B;AAE3B,qCAAkF;AAGlF,iDAA8E;AAE9E;;;;GAIG;AACH,MAAa,gBAAgB;IAC5B,YAAoC,cAAkD;QAAlD,mBAAc,GAAd,cAAc,CAAoC;IAAG,CAAC;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CAAC;YACzD,IAAA,8BAAqB,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;YAC1D,IAAA,8BAAqB,EAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YACnD,IAAA,8BAAqB,EAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACpD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;gBACpC,UAAU,CAAC,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aACvD;YACD,OAAO,UAAU,CAAC;SAClB;QACD;YACC,IAAA,aAAI,EAAC,wBAAwB,CAAC,CAAC;KAChC;AACF,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAC3B,UAA4B,EAC5B,QAAwB,EACxB,YAAiD,EACjD,IAAW;IAEX,uCACI,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,IACzF;AACH,CAAC;AAVD,oCAUC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAI7B,UAA4B,EAC5B,QAAwB,EACxB,YAAiD,EACjD,IAAW;IAEX,uCACI,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,IAC3F;AACH,CAAC;AAbD,wCAaC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, NodeId, OpSpaceNodeId } from './Identifiers';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tCompressedChangeInternal,\n\tChangeTypeInternal,\n\tCompressedBuildInternal,\n\tCompressedPlaceholderTree,\n\tInsertInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tConstraintInternal,\n} from './persisted-types';\nimport { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { copyPropertyIfDefined, fail, Mutable, ReplaceRecursive } from './Common';\nimport { TreeCompressor } from './TreeCompressor';\nimport { StringInterner } from './StringInterner';\nimport { convertStablePlaceIds, convertStableRangeIds } from './IdConversion';\n\n/**\n * Encapsulates knowledge of how to compress/decompress a change into a compressed change\n * Compression and decompression each take in a {@link StringInterner} for deduplicating shared strings.\n * @internal\n */\nexport class ChangeCompressor {\n\tpublic constructor(private readonly treeCompressor: TreeCompressor<DetachedSequenceId>) {}\n\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tchange: ChangeInternal,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedChangeInternal<TId> {\n\t\tif (change.type === ChangeTypeInternal.Build) {\n\t\t\tconst source: CompressedPlaceholderTree<TId, DetachedSequenceId>[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.compress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: CompressedBuildInternal<TId> = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.CompressedBuild,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToOpSpace(id));\n\t\t}\n\t}\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tchange: CompressedChangeInternal<TId>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): ChangeInternal {\n\t\tif (change.type === ChangeTypeInternal.CompressedBuild) {\n\t\t\tconst source: BuildNodeInternal[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.decompress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: BuildInternal = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.Build,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToSessionSpace(id));\n\t\t}\n\t}\n}\n\nfunction normalizeChange<From extends NodeId | OpSpaceNodeId, To extends NodeId | OpSpaceNodeId>(\n\tchange: ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, From>,\n\tnormalizeId: (id: From) => To\n): ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, To> {\n\tswitch (change.type) {\n\t\tcase ChangeTypeInternal.Insert: {\n\t\t\tconst insert: ReplaceRecursive<InsertInternal, NodeId, To> = {\n\t\t\t\tsource: change.source,\n\t\t\t\tdestination: convertStablePlaceIds(change.destination, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Insert,\n\t\t\t};\n\t\t\treturn insert;\n\t\t}\n\t\tcase ChangeTypeInternal.Detach: {\n\t\t\tconst detach: ReplaceRecursive<DetachInternal, NodeId, To> = {\n\t\t\t\tsource: convertStableRangeIds(change.source, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Detach,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, detach, 'destination');\n\t\t\treturn detach;\n\t\t}\n\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\tconst setValue: ReplaceRecursive<SetValueInternal, NodeId, To> = {\n\t\t\t\tnodeToModify: normalizeId(change.nodeToModify),\n\t\t\t\tpayload: change.payload,\n\t\t\t\ttype: ChangeTypeInternal.SetValue,\n\t\t\t};\n\t\t\treturn setValue;\n\t\t}\n\t\tcase ChangeTypeInternal.Constraint: {\n\t\t\tconst constraint: Mutable<ReplaceRecursive<ConstraintInternal, NodeId, To>> = {\n\t\t\t\teffect: change.effect,\n\t\t\t\ttoConstrain: convertStableRangeIds(change.toConstrain, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Constraint,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, constraint, 'contentHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'identityHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'label');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'length');\n\t\t\tif (change.parentNode !== undefined) {\n\t\t\t\tconstraint.parentNode = normalizeId(change.parentNode);\n\t\t\t}\n\t\t\treturn constraint;\n\t\t}\n\t\tdefault:\n\t\t\tfail('unexpected change type');\n\t}\n}\n\n/**\n * Compresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function compressEdit<TId extends OpSpaceNodeId, TEdit extends { changes: readonly ChangeInternal[] }>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly CompressedChangeInternal<TId>[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.compress(change, interner, idNormalizer)),\n\t};\n}\n\n/**\n * Decompresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function decompressEdit<\n\tTId extends OpSpaceNodeId,\n\tTEdit extends { changes: readonly CompressedChangeInternal<TId>[] }\n>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly ChangeInternal[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.decompress(change, interner, idNormalizer)),\n\t};\n}\n"]}
@@ -167,12 +167,7 @@ export declare const Change: {
167
167
  detach: (source: StableRange, destination?: number | undefined) => Detach;
168
168
  setPayload: (nodeToModify: NodeId, payload: Payload) => SetValue;
169
169
  clearPayload: (nodeToModify: NodeId) => SetValue;
170
- constraint: (toConstrain: StableRange, effect: ConstraintEffect, identityHash?: UuidString | undefined, length?: number | undefined, contentHash?: UuidString | undefined, parentNode?: (number & {
171
- readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
172
- } & import("./Identifiers").SessionUnique & import("./Identifiers").NodeIdBrand) | (number & {
173
- readonly FinalCompressedId: "5d83d1e2-98b7-4e4e-a889-54c855cfa73d";
174
- readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
175
- } & import("./Identifiers").SessionUnique & import("./Identifiers").NodeIdBrand) | undefined, label?: TraitLabel | undefined) => Constraint;
170
+ constraint: (toConstrain: StableRange, effect: ConstraintEffect, identityHash?: UuidString | undefined, length?: number | undefined, contentHash?: UuidString | undefined, parentNode?: NodeId | undefined, label?: TraitLabel | undefined) => Constraint;
176
171
  /** Helpers for making high-level composite operations */
177
172
  /**
178
173
  * @returns a change that deletes the supplied part of the tree.
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeTypes.d.ts","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;KACtE,CAAC;CACF;AAED;;;GAGG;AACH,oBAAY,UAAU;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,UAAU,IAAA;CACV;AAED;;;;;;;GAOG;AACH,o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AE,MAAM,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;GAMG;AAGH;;GAEG;AACH,eAAO,MAAM,WAAW;IACvB;;OAEG;mBACY,SAAS,MAAM,CAAC,GAAG,MAAM,KAAG,WAAW;IAItD;;OAEG;kBACW,SAAS,MAAM,CAAC,GAAG,MAAM,KAAG,WAAW;IACrD;;OAEG;uBACgB,aAAa,KAAG,WAAW;IAC9C;;OAEG;qBACc,aAAa,KAAG,WAAW;CAC5C,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,WAAW;IACvB;;;;OAIG;kBACW,WAAW;kBAAe,WAAW,KAAK,WAAW;;IAUnE;;;OAGG;iBACU,SAAS,MAAM,CAAC,GAAG,MAAM,KAAG,WAAW;IAIpD;;;;OAIG;iBACU,aAAa,KAAG,WAAW;CAIxC,CAAC"}
@@ -78,7 +78,7 @@ exports.Change = {
78
78
  */
79
79
  move: (source, destination) => {
80
80
  const detach = exports.Change.detach(source, 0);
81
- return [detach, exports.Change.insert(Common_1.assertNotUndefined(detach.destination), destination)];
81
+ return [detach, exports.Change.insert((0, Common_1.assertNotUndefined)(detach.destination), destination)];
82
82
  },
83
83
  };
84
84
  /**
@@ -98,12 +98,12 @@ exports.StablePlace = {
98
98
  */
99
99
  before: (node) => ({
100
100
  side: persisted_types_1.Side.Before,
101
- referenceSibling: NodeIdUtilities_1.getNodeId(node),
101
+ referenceSibling: (0, NodeIdUtilities_1.getNodeId)(node),
102
102
  }),
103
103
  /**
104
104
  * @returns The location directly after `node`.
105
105
  */
106
- after: (node) => ({ side: persisted_types_1.Side.After, referenceSibling: NodeIdUtilities_1.getNodeId(node) }),
106
+ after: (node) => ({ side: persisted_types_1.Side.After, referenceSibling: (0, NodeIdUtilities_1.getNodeId)(node) }),
107
107
  /**
108
108
  * @returns The location at the start of `trait`.
109
109
  */
@@ -127,8 +127,8 @@ exports.StableRange = {
127
127
  to: (end) => {
128
128
  if (start.referenceTrait && end.referenceTrait) {
129
129
  const message = 'StableRange must be constructed with endpoints from the same trait';
130
- Common_1.assert(start.referenceTrait.parent === end.referenceTrait.parent, message);
131
- Common_1.assert(start.referenceTrait.label === end.referenceTrait.label, message);
130
+ (0, Common_1.assert)(start.referenceTrait.parent === end.referenceTrait.parent, message);
131
+ (0, Common_1.assert)(start.referenceTrait.label === end.referenceTrait.label, message);
132
132
  }
133
133
  return { start, end };
134
134
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeTypes.js","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAAsD;AACtD,uDAAgG;AAEhG,uDAA8C;AAY9C;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,6CAAK,CAAA;IACL,mDAAQ,CAAA;IACR,uDAAU,CAAA;AACX,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AAuJD,+FAA+F;AAC/F;;GAEG;AACU,QAAA,MAAM,GAAG;IACrB,KAAK,EAAE,CAAC,MAA+C,EAAE,WAAmB,EAAS,EAAE,CAAC,CAAC;QACxF,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,KAAK;KACtB,CAAC;IAEF,MAAM,EAAE,CAAC,MAAc,EAAE,WAAwB,EAAU,EAAE,CAAC,CAAC;QAC9D,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,MAAM;KACvB,CAAC;IAEF,MAAM,EAAE,CAAC,MAAmB,EAAE,WAAoB,EAAU,EAAE,CAAC,CAAC;QAC/D,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,MAAM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ACvB,CAAC;KACD,CAAC;IACF;;;OAGG;IACH,IAAI,EAAE,CAAC,IAA+B,EAAe,EAAE,CAAC,CAAC;QACxD,KAAK,EAAE,mBAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/B,GAAG,EAAE,mBAAW,CAAC,KAAK,CAAC,IAAI,CAAC;KAC5B,CAAC;IACF;;;;OAIG;IACH,GAAG,EAAE,CAAC,KAAoB,EAAe,EAAE,CAAC,CAAC;QAC5C,KAAK,EAAE,mBAAW,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,GAAG,EAAE,mBAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KAC/B,CAAC;CACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NodeId, TraitLabel, UuidString } from './Identifiers';\nimport { assert, assertNotUndefined } from './Common';\nimport { ConstraintEffect, NodeData, Payload, Side, TreeNodeSequence } from './persisted-types';\nimport { TraitLocation } from './TreeView';\nimport { getNodeId } from './NodeIdUtilities';\n\n/**\n * An object which may have traits with children of the given type underneath it\n * @public\n */\nexport interface HasVariadicTraits<TChild> {\n\treadonly traits?: {\n\t\treadonly [key: string]: TChild | TreeNodeSequence<TChild> | undefined;\n\t};\n}\n\n/**\n * The type of a Change\n * @public\n */\nexport enum ChangeType {\n\tInsert,\n\tDetach,\n\tBuild,\n\tSetValue,\n\tConstraint,\n}\n\n/**\n * A change that composes an Edit.\n *\n * `Change` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * Change.insert(sourceId, destination)\n * @public\n */\nexport type Change = Insert | Detach | Build | SetValue | Constraint;\n\n/**\n * Node or a detached sequence of nodes (referred to by a detached sequence ID) for use in a Build change.\n * See `BuildTreeNode` for more.\n * @public\n */\nexport type BuildNode = BuildTreeNode | number;\n\n/**\n * Node for use in a Build change, which is composed of a definition describing what this nodes type, an identifier identifying this node\n * within the tree, and a payload containing an opaque serializable piece of data.\n * An identifier can be provided explicitly if the node must be referred to before the results of the `Change` containing this\n * BuildTreeNode can be observed. If `identifier` is not supplied, one will be generated for it in an especially efficient manner\n * that allows for compact storage and transmission and thus this property should be omitted if convenient.\n * See the SharedTree readme for more on the tree format.\n */\nexport interface BuildTreeNode extends HasVariadicTraits<BuildNode> {\n\tdefinition: string;\n\tidentifier?: NodeId;\n\tpayload?: Payload;\n}\n\n/**\n * Constructs a sequence of nodes, associates it with the supplied ID, and stores it for use in later changes.\n * Does not modify the document.\n *\n * Valid if (transitively) all DetachedSequenceId are used according to their rules (use here counts as a destination),\n * and all Nodes' identifiers are previously unused.\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: number;\n\treadonly source: BuildNode | TreeNodeSequence<BuildNode>;\n\treadonly type: typeof ChangeType.Build;\n}\n\n/**\n * Inserts a sequence of nodes at the specified destination.\n * The source can be constructed either by a Build (used to insert new nodes) or a Detach (amounts to a \"move\" operation).\n * @public\n */\nexport interface Insert {\n\treadonly destination: StablePlace;\n\treadonly source: number;\n\treadonly type: typeof ChangeType.Insert;\n}\n\n/**\n * Removes a sequence of nodes from the tree.\n * If a destination is specified, the detached sequence is associated with that ID and held for possible reuse\n * by later changes in this same Edit (such as by an Insert).\n * A Detach without a destination is a deletion of the specified sequence, as is a Detach with a destination that is not used later.\n * @public\n */\nexport interface Detach {\n\treadonly destination?: number;\n\treadonly source: StableRange;\n\treadonly type: typeof ChangeType.Detach;\n}\n\n/**\n * Modifies the payload of a node.\n * @public\n */\nexport interface SetValue {\n\treadonly nodeToModify: NodeId;\n\t/**\n\t * Sets or clears the payload.\n\t * To improve ease of forwards compatibility, an explicit `null` value is used to represent the clearing of a payload.\n\t * SetValue may use `undefined` in future API versions to mean \"don't change the payload\" (which is useful if e.g. other\n\t * fields are added to SetValue that can be changed without altering the payload)\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly payload: Payload | null;\n\treadonly type: typeof ChangeType.SetValue;\n}\n\n/**\n * A set of constraints on the validity of an Edit.\n * A Constraint is used to detect when an Edit, due to other concurrent edits, may have unintended effects or merge in\n * non-semantic ways. It is processed in order like any other Change in an Edit. It can cause an edit to fail if the\n * various constraints are not met at the time of evaluation (ex: the parentNode has changed due to concurrent editing).\n * Does not modify the document.\n * @public\n */\nexport interface Constraint {\n\t/**\n\t * Selects a sequence of nodes which will be checked against the constraints specified by the optional fields.\n\t * If `toConstrain` is invalid, it will be treated like a constraint being unmet.\n\t * Depending on `effect` this may or may not make the Edit invalid.\n\t *\n\t * When a constraint is not met, the effects is specified by `effect`.\n\t */\n\treadonly toConstrain: StableRange;\n\n\t/**\n\t * Require that the identities of all the nodes in toConstrain hash to this value.\n\t * Hash is order dependent.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.\n\t */\n\treadonly identityHash?: UuidString;\n\n\t/**\n\t * Require that the number of nodes in toConstrain is this value.\n\t */\n\treadonly length?: number;\n\n\t/**\n\t * Require that the contents of all of the nodes in toConstrain hash to this value.\n\t * Hash is an order dependant deep hash, which includes all subtree content recursively.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).\n\t */\n\treadonly contentHash?: UuidString;\n\n\t/**\n\t * Require that parent under which toConstrain is located has this identifier.\n\t */\n\treadonly parentNode?: NodeId;\n\n\t/**\n\t * Require that the trait under which toConstrain is located has this label.\n\t */\n\treadonly label?: TraitLabel;\n\n\t/**\n\t * What to do if a constraint is not met.\n\t */\n\treadonly effect: ConstraintEffect;\n\n\t/**\n\t * Marker for which kind of Change this is.\n\t */\n\treadonly type: typeof ChangeType.Constraint;\n}\n\n// Note: Documentation of this constant is merged with documentation of the `Change` interface.\n/**\n * @public\n */\nexport const Change = {\n\tbuild: (source: BuildNode | TreeNodeSequence<BuildNode>, destination: number): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: number, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: number): Detach => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Detach,\n\t}),\n\n\tsetPayload: (nodeToModify: NodeId, payload: Payload): SetValue => ({\n\t\tnodeToModify,\n\t\tpayload,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tclearPayload: (nodeToModify: NodeId): SetValue => ({\n\t\tnodeToModify,\n\t\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface above.)\n\t\tpayload: null,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tconstraint: (\n\t\ttoConstrain: StableRange,\n\t\teffect: ConstraintEffect,\n\t\tidentityHash?: UuidString,\n\t\tlength?: number,\n\t\tcontentHash?: UuidString,\n\t\tparentNode?: NodeId,\n\t\tlabel?: TraitLabel\n\t): Constraint => ({\n\t\ttoConstrain,\n\t\teffect,\n\t\tidentityHash,\n\t\tlength,\n\t\tcontentHash,\n\t\tparentNode,\n\t\tlabel,\n\t\ttype: ChangeType.Constraint,\n\t}),\n\n\t/** Helpers for making high-level composite operations */\n\n\t/**\n\t * @returns a change that deletes the supplied part of the tree.\n\t */\n\tdelete: (stableRange: StableRange): Change => Change.detach(stableRange),\n\n\t/**\n\t * @returns changes that insert 'nodes' into the specified location in the tree.\n\t */\n\tinsertTree: (nodes: BuildNode | TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n\n\t/**\n\t * @returns changes that moves the specified content to a new location in the tree.\n\t */\n\tmove: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0);\n\t\treturn [detach, Change.insert(assertNotUndefined(detach.destination), destination)];\n\t},\n};\n\n/**\n * A location in a trait.\n * This is NOT the location of a node, but a location where a node could be inserted:\n * it is next to a sibling or at one end of the trait.\n *\n * To be well formed, either `sibling` or `trait` must be defined, but not both.\n *\n * Any given insertion location can be described by two `StablePlace` objects, one with `Side.After` and one with `Side.Before`.\n * For example, in a trait containing two strings \"foo\" and \"bar\", there are 6 different `StablePlace`s corresponding to 3 locations in the\n * trait a new node could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\n * Neither of the two ways to specify the same location are considered to be after each other.\n *\n * The anchor (`referenceSibling` or `referenceTrait`) used for a particular `StablePlace` can have an impact in collaborative scenarios.\n *\n * `StablePlace` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StablePlace.before(node)\n * StablePlace.atStartOf(trait)\n * @public\n */\nexport interface StablePlace {\n\t/**\n\t * Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified).\n\t * If 'After' and there is no sibling, this StablePlace is after the front of the trait.\n\t * If 'Before' and there is no sibling, this StablePlace is before the back of the trait.\n\t */\n\treadonly side: Side;\n\n\t/**\n\t * The sibling to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceTrait must be unspecified.\n\t */\n\treadonly referenceSibling?: NodeId;\n\n\t/**\n\t * The trait to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceSibling must be unspecified.\n\t */\n\treadonly referenceTrait?: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait.\n * Valid iff start and end are valid and are within the same trait and the start does not occur after the end in the trait.\n *\n * See {@link (StablePlace:interface)} for what it means for a place to be \"after\" another place.\n *\n * `StableRange` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n * @public\n */\nexport interface StableRange {\n\treadonly start: StablePlace;\n\treadonly end: StablePlace;\n}\n\n/**\n * The remainder of this file consists of ergonomic factory methods for persisted types, or common combinations thereof (e.g. \"Move\" as a\n * combination of a \"Detach\" change and an \"Insert\" change).\n *\n * None of these helpers are persisted in documents, and therefore changes to their semantics need only follow standard semantic versioning\n * practices.\n */\n\n// Note: Documentation of this constant is merged with documentation of the `StablePlace` interface.\n/**\n * @public\n */\nexport const StablePlace = {\n\t/**\n\t * @returns The location directly before `node`.\n\t */\n\tbefore: (node: NodeData<NodeId> | NodeId): StablePlace => ({\n\t\tside: Side.Before,\n\t\treferenceSibling: getNodeId(node),\n\t}),\n\t/**\n\t * @returns The location directly after `node`.\n\t */\n\tafter: (node: NodeData<NodeId> | NodeId): StablePlace => ({ side: Side.After, referenceSibling: getNodeId(node) }),\n\t/**\n\t * @returns The location at the start of `trait`.\n\t */\n\tatStartOf: (trait: TraitLocation): StablePlace => ({ side: Side.After, referenceTrait: trait }),\n\t/**\n\t * @returns The location at the end of `trait`.\n\t */\n\tatEndOf: (trait: TraitLocation): StablePlace => ({ side: Side.Before, referenceTrait: trait }),\n};\n\n// Note: Documentation of this constant is merged with documentation of the `StableRange` interface.\n/**\n * @public\n */\nexport const StableRange = {\n\t/**\n\t * Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.\n\t * @example\n\t * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n\t */\n\tfrom: (start: StablePlace): { to: (end: StablePlace) => StableRange } => ({\n\t\tto: (end: StablePlace): StableRange => {\n\t\t\tif (start.referenceTrait && end.referenceTrait) {\n\t\t\t\tconst message = 'StableRange must be constructed with endpoints from the same trait';\n\t\t\t\tassert(start.referenceTrait.parent === end.referenceTrait.parent, message);\n\t\t\t\tassert(start.referenceTrait.label === end.referenceTrait.label, message);\n\t\t\t}\n\t\t\treturn { start, end };\n\t\t},\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains only the provided `node`.\n\t * Both the start and end `StablePlace` objects used to anchor this `StableRange` are in terms of the passed in node.\n\t */\n\tonly: (node: NodeData<NodeId> | NodeId): StableRange => ({\n\t\tstart: StablePlace.before(node),\n\t\tend: StablePlace.after(node),\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains everything in the trait.\n\t * This is anchored using the provided `trait`, and is independent of the actual contents of the trait:\n\t * it does not use sibling anchoring.\n\t */\n\tall: (trait: TraitLocation): StableRange => ({\n\t\tstart: StablePlace.atStartOf(trait),\n\t\tend: StablePlace.atEndOf(trait),\n\t}),\n};\n"]}
1
+ {"version":3,"file":"ChangeTypes.js","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAAsD;AACtD,uDAAgG;AAEhG,uDAA8C;AAY9C;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,6CAAK,CAAA;IACL,mDAAQ,CAAA;IACR,uDAAU,CAAA;AACX,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AAuJD,+FAA+F;AAC/F;;GAEG;AACU,QAAA,MAAM,GAAG;IACrB,KAAK,EAAE,CAAC,MAA+C,EAAE,WAAmB,EAAS,EAAE,CAAC,CAAC;QACxF,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,KAAK;KACtB,CAAC;IAEF,MAAM,EAAE,CAAC,MAAc,EAAE,WAAwB,EAAU,EAAE,CAAC,CAAC;QAC9D,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,MAAM;KACvB,CAAC;IAEF,MAAM,EAAE,CAAC,MAAmB,EAAE,WAAoB,EAAU,EAAE,CAAC,CAAC;QAC/D,WAAW;QACX,MAAM;QACN,IAAI,EAAE,UAAU,CAAC,MAAM;KACvB,CAAC;IAEF,UAAU,EAAE,CAAC,YAAoB,EAAE,OAAgB,EAAY,EAAE,CAAC,CAAC;QAClE,YAAY;QACZ,OAAO;QACP,IAAI,EAAE,UAAU,CAAC,QAAQ;KACzB,CAAC;IAEF,YAAY,EAAE,CAAC,YAAoB,EAAY,EAAE,CAAC,CAAC;QAClD,YAAY;QACZ,sFAAsF;QACtF,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,UAAU,CAAC,QAAQ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EAAE,CAAC,CAAC;QAC5C,KAAK,EAAE,mBAAW,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,GAAG,EAAE,mBAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KAC/B,CAAC;CACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NodeId, TraitLabel, UuidString } from './Identifiers';\nimport { assert, assertNotUndefined } from './Common';\nimport { ConstraintEffect, NodeData, Payload, Side, TreeNodeSequence } from './persisted-types';\nimport { TraitLocation } from './TreeView';\nimport { getNodeId } from './NodeIdUtilities';\n\n/**\n * An object which may have traits with children of the given type underneath it\n * @public\n */\nexport interface HasVariadicTraits<TChild> {\n\treadonly traits?: {\n\t\treadonly [key: string]: TChild | TreeNodeSequence<TChild> | undefined;\n\t};\n}\n\n/**\n * The type of a Change\n * @public\n */\nexport enum ChangeType {\n\tInsert,\n\tDetach,\n\tBuild,\n\tSetValue,\n\tConstraint,\n}\n\n/**\n * A change that composes an Edit.\n *\n * `Change` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * Change.insert(sourceId, destination)\n * @public\n */\nexport type Change = Insert | Detach | Build | SetValue | Constraint;\n\n/**\n * Node or a detached sequence of nodes (referred to by a detached sequence ID) for use in a Build change.\n * See `BuildTreeNode` for more.\n * @public\n */\nexport type BuildNode = BuildTreeNode | number;\n\n/**\n * Node for use in a Build change, which is composed of a definition describing what this nodes type, an identifier identifying this node\n * within the tree, and a payload containing an opaque serializable piece of data.\n * An identifier can be provided explicitly if the node must be referred to before the results of the `Change` containing this\n * BuildTreeNode can be observed. If `identifier` is not supplied, one will be generated for it in an especially efficient manner\n * that allows for compact storage and transmission and thus this property should be omitted if convenient.\n * See the SharedTree readme for more on the tree format.\n */\nexport interface BuildTreeNode extends HasVariadicTraits<BuildNode> {\n\tdefinition: string;\n\tidentifier?: NodeId;\n\tpayload?: Payload;\n}\n\n/**\n * Constructs a sequence of nodes, associates it with the supplied ID, and stores it for use in later changes.\n * Does not modify the document.\n *\n * Valid if (transitively) all DetachedSequenceId are used according to their rules (use here counts as a destination),\n * and all Nodes' identifiers are previously unused.\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: number;\n\treadonly source: BuildNode | TreeNodeSequence<BuildNode>;\n\treadonly type: typeof ChangeType.Build;\n}\n\n/**\n * Inserts a sequence of nodes at the specified destination.\n * The source can be constructed either by a Build (used to insert new nodes) or a Detach (amounts to a \"move\" operation).\n * @public\n */\nexport interface Insert {\n\treadonly destination: StablePlace;\n\treadonly source: number;\n\treadonly type: typeof ChangeType.Insert;\n}\n\n/**\n * Removes a sequence of nodes from the tree.\n * If a destination is specified, the detached sequence is associated with that ID and held for possible reuse\n * by later changes in this same Edit (such as by an Insert).\n * A Detach without a destination is a deletion of the specified sequence, as is a Detach with a destination that is not used later.\n * @public\n */\nexport interface Detach {\n\treadonly destination?: number;\n\treadonly source: StableRange;\n\treadonly type: typeof ChangeType.Detach;\n}\n\n/**\n * Modifies the payload of a node.\n * @public\n */\nexport interface SetValue {\n\treadonly nodeToModify: NodeId;\n\t/**\n\t * Sets or clears the payload.\n\t * To improve ease of forwards compatibility, an explicit `null` value is used to represent the clearing of a payload.\n\t * SetValue may use `undefined` in future API versions to mean \"don't change the payload\" (which is useful if e.g. other\n\t * fields are added to SetValue that can be changed without altering the payload)\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly payload: Payload | null;\n\treadonly type: typeof ChangeType.SetValue;\n}\n\n/**\n * A set of constraints on the validity of an Edit.\n * A Constraint is used to detect when an Edit, due to other concurrent edits, may have unintended effects or merge in\n * non-semantic ways. It is processed in order like any other Change in an Edit. It can cause an edit to fail if the\n * various constraints are not met at the time of evaluation (ex: the parentNode has changed due to concurrent editing).\n * Does not modify the document.\n * @public\n */\nexport interface Constraint {\n\t/**\n\t * Selects a sequence of nodes which will be checked against the constraints specified by the optional fields.\n\t * If `toConstrain` is invalid, it will be treated like a constraint being unmet.\n\t * Depending on `effect` this may or may not make the Edit invalid.\n\t *\n\t * When a constraint is not met, the effects is specified by `effect`.\n\t */\n\treadonly toConstrain: StableRange;\n\n\t/**\n\t * Require that the identities of all the nodes in toConstrain hash to this value.\n\t * Hash is order dependent.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.\n\t */\n\treadonly identityHash?: UuidString;\n\n\t/**\n\t * Require that the number of nodes in toConstrain is this value.\n\t */\n\treadonly length?: number;\n\n\t/**\n\t * Require that the contents of all of the nodes in toConstrain hash to this value.\n\t * Hash is an order dependant deep hash, which includes all subtree content recursively.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).\n\t */\n\treadonly contentHash?: UuidString;\n\n\t/**\n\t * Require that parent under which toConstrain is located has this identifier.\n\t */\n\treadonly parentNode?: NodeId;\n\n\t/**\n\t * Require that the trait under which toConstrain is located has this label.\n\t */\n\treadonly label?: TraitLabel;\n\n\t/**\n\t * What to do if a constraint is not met.\n\t */\n\treadonly effect: ConstraintEffect;\n\n\t/**\n\t * Marker for which kind of Change this is.\n\t */\n\treadonly type: typeof ChangeType.Constraint;\n}\n\n// Note: Documentation of this constant is merged with documentation of the `Change` interface.\n/**\n * @public\n */\nexport const Change = {\n\tbuild: (source: BuildNode | TreeNodeSequence<BuildNode>, destination: number): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: number, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: number): Detach => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Detach,\n\t}),\n\n\tsetPayload: (nodeToModify: NodeId, payload: Payload): SetValue => ({\n\t\tnodeToModify,\n\t\tpayload,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tclearPayload: (nodeToModify: NodeId): SetValue => ({\n\t\tnodeToModify,\n\t\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface above.)\n\t\tpayload: null,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tconstraint: (\n\t\ttoConstrain: StableRange,\n\t\teffect: ConstraintEffect,\n\t\tidentityHash?: UuidString,\n\t\tlength?: number,\n\t\tcontentHash?: UuidString,\n\t\tparentNode?: NodeId,\n\t\tlabel?: TraitLabel\n\t): Constraint => ({\n\t\ttoConstrain,\n\t\teffect,\n\t\tidentityHash,\n\t\tlength,\n\t\tcontentHash,\n\t\tparentNode,\n\t\tlabel,\n\t\ttype: ChangeType.Constraint,\n\t}),\n\n\t/** Helpers for making high-level composite operations */\n\n\t/**\n\t * @returns a change that deletes the supplied part of the tree.\n\t */\n\tdelete: (stableRange: StableRange): Change => Change.detach(stableRange),\n\n\t/**\n\t * @returns changes that insert 'nodes' into the specified location in the tree.\n\t */\n\tinsertTree: (nodes: BuildNode | TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n\n\t/**\n\t * @returns changes that moves the specified content to a new location in the tree.\n\t */\n\tmove: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0);\n\t\treturn [detach, Change.insert(assertNotUndefined(detach.destination), destination)];\n\t},\n};\n\n/**\n * A location in a trait.\n * This is NOT the location of a node, but a location where a node could be inserted:\n * it is next to a sibling or at one end of the trait.\n *\n * To be well formed, either `sibling` or `trait` must be defined, but not both.\n *\n * Any given insertion location can be described by two `StablePlace` objects, one with `Side.After` and one with `Side.Before`.\n * For example, in a trait containing two strings \"foo\" and \"bar\", there are 6 different `StablePlace`s corresponding to 3 locations in the\n * trait a new node could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\n * Neither of the two ways to specify the same location are considered to be after each other.\n *\n * The anchor (`referenceSibling` or `referenceTrait`) used for a particular `StablePlace` can have an impact in collaborative scenarios.\n *\n * `StablePlace` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StablePlace.before(node)\n * StablePlace.atStartOf(trait)\n * @public\n */\nexport interface StablePlace {\n\t/**\n\t * Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified).\n\t * If 'After' and there is no sibling, this StablePlace is after the front of the trait.\n\t * If 'Before' and there is no sibling, this StablePlace is before the back of the trait.\n\t */\n\treadonly side: Side;\n\n\t/**\n\t * The sibling to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceTrait must be unspecified.\n\t */\n\treadonly referenceSibling?: NodeId;\n\n\t/**\n\t * The trait to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceSibling must be unspecified.\n\t */\n\treadonly referenceTrait?: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait.\n * Valid iff start and end are valid and are within the same trait and the start does not occur after the end in the trait.\n *\n * See {@link (StablePlace:interface)} for what it means for a place to be \"after\" another place.\n *\n * `StableRange` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n * @public\n */\nexport interface StableRange {\n\treadonly start: StablePlace;\n\treadonly end: StablePlace;\n}\n\n/**\n * The remainder of this file consists of ergonomic factory methods for persisted types, or common combinations thereof (e.g. \"Move\" as a\n * combination of a \"Detach\" change and an \"Insert\" change).\n *\n * None of these helpers are persisted in documents, and therefore changes to their semantics need only follow standard semantic versioning\n * practices.\n */\n\n// Note: Documentation of this constant is merged with documentation of the `StablePlace` interface.\n/**\n * @public\n */\nexport const StablePlace = {\n\t/**\n\t * @returns The location directly before `node`.\n\t */\n\tbefore: (node: NodeData<NodeId> | NodeId): StablePlace => ({\n\t\tside: Side.Before,\n\t\treferenceSibling: getNodeId(node),\n\t}),\n\t/**\n\t * @returns The location directly after `node`.\n\t */\n\tafter: (node: NodeData<NodeId> | NodeId): StablePlace => ({ side: Side.After, referenceSibling: getNodeId(node) }),\n\t/**\n\t * @returns The location at the start of `trait`.\n\t */\n\tatStartOf: (trait: TraitLocation): StablePlace => ({ side: Side.After, referenceTrait: trait }),\n\t/**\n\t * @returns The location at the end of `trait`.\n\t */\n\tatEndOf: (trait: TraitLocation): StablePlace => ({ side: Side.Before, referenceTrait: trait }),\n};\n\n// Note: Documentation of this constant is merged with documentation of the `StableRange` interface.\n/**\n * @public\n */\nexport const StableRange = {\n\t/**\n\t * Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.\n\t * @example\n\t * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n\t */\n\tfrom: (start: StablePlace): { to: (end: StablePlace) => StableRange } => ({\n\t\tto: (end: StablePlace): StableRange => {\n\t\t\tif (start.referenceTrait && end.referenceTrait) {\n\t\t\t\tconst message = 'StableRange must be constructed with endpoints from the same trait';\n\t\t\t\tassert(start.referenceTrait.parent === end.referenceTrait.parent, message);\n\t\t\t\tassert(start.referenceTrait.label === end.referenceTrait.label, message);\n\t\t\t}\n\t\t\treturn { start, end };\n\t\t},\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains only the provided `node`.\n\t * Both the start and end `StablePlace` objects used to anchor this `StableRange` are in terms of the passed in node.\n\t */\n\tonly: (node: NodeData<NodeId> | NodeId): StableRange => ({\n\t\tstart: StablePlace.before(node),\n\t\tend: StablePlace.after(node),\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains everything in the trait.\n\t * This is anchored using the provided `trait`, and is independent of the actual contents of the trait:\n\t * it does not use sibling anchoring.\n\t */\n\tall: (trait: TraitLocation): StableRange => ({\n\t\tstart: StablePlace.atStartOf(trait),\n\t\tend: StablePlace.atEndOf(trait),\n\t}),\n};\n"]}
package/dist/Checkout.js CHANGED
@@ -97,7 +97,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
97
97
  * Changes accumulate in the edit via calls to `applyChanges()`.
98
98
  */
99
99
  openEdit() {
100
- Common_1.assert(this.currentEdit === undefined, 'An edit is already open.');
100
+ (0, Common_1.assert)(this.currentEdit === undefined, 'An edit is already open.');
101
101
  this.currentEdit = TransactionInternal_1.TransactionInternal.factory(this.latestCommittedView);
102
102
  }
103
103
  /**
@@ -110,11 +110,11 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
110
110
  */
111
111
  closeEdit() {
112
112
  const { currentEdit } = this;
113
- Common_1.assert(currentEdit !== undefined, 'An edit is not open.');
113
+ (0, Common_1.assert)(currentEdit !== undefined, 'An edit is not open.');
114
114
  this.currentEdit = undefined;
115
115
  const editingResult = currentEdit.close();
116
- Common_1.assert(editingResult.status === persisted_types_1.EditStatus.Applied, 'Locally constructed edits must be well-formed and valid');
117
- const id = EditUtilities_1.newEditId();
116
+ (0, Common_1.assert)(editingResult.status === persisted_types_1.EditStatus.Applied, 'Locally constructed edits must be well-formed and valid');
117
+ const id = (0, EditUtilities_1.newEditId)();
118
118
  this.handleNewEdit(id, editingResult);
119
119
  return id;
120
120
  }
@@ -147,9 +147,9 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
147
147
  * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
148
148
  */
149
149
  applyChanges(...changes) {
150
- Common_1.assert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
150
+ (0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
151
151
  const { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));
152
- Common_1.assert(status === persisted_types_1.EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');
152
+ (0, Common_1.assert)(status === persisted_types_1.EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');
153
153
  this.emitChange();
154
154
  }
155
155
  /**
@@ -158,7 +158,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
158
158
  * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
159
159
  */
160
160
  tryApplyChangesInternal(...changes) {
161
- Common_1.assert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
161
+ (0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
162
162
  const { status } = this.currentEdit.applyChanges(changes);
163
163
  if (status === persisted_types_1.EditStatus.Applied) {
164
164
  this.emitChange();
@@ -181,7 +181,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
181
181
  */
182
182
  tryApplyEdit(...changes) {
183
183
  this.openEdit();
184
- Common_1.assert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
184
+ (0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
185
185
  const { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));
186
186
  if (status === persisted_types_1.EditStatus.Applied) {
187
187
  this.emitChange();
@@ -202,13 +202,13 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
202
202
  * @returns - the result of the rebase.
203
203
  */
204
204
  rebaseCurrentEdit() {
205
- Common_1.assert(this.currentEdit !== undefined, 'An edit is not open.');
206
- Common_1.assert(this.currentEdit.status === persisted_types_1.EditStatus.Applied, 'Local edits should always be valid.');
205
+ (0, Common_1.assert)(this.currentEdit !== undefined, 'An edit is not open.');
206
+ (0, Common_1.assert)(this.currentEdit.status === persisted_types_1.EditStatus.Applied, 'Local edits should always be valid.');
207
207
  // When closed, the result might indicate Malformed due to unused detached entities.
208
208
  // This is not an error, as the edit was still open and can still use those entities.
209
209
  const priorResults = this.currentEdit.close();
210
210
  const rebasedEdit = TransactionInternal_1.TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);
211
- Common_1.assert(rebasedEdit.status !== persisted_types_1.EditStatus.Malformed, 'Malformed changes should have been caught on original application.');
211
+ (0, Common_1.assert)(rebasedEdit.status !== persisted_types_1.EditStatus.Malformed, 'Malformed changes should have been caught on original application.');
212
212
  let status;
213
213
  if (rebasedEdit.status === persisted_types_1.EditStatus.Invalid) {
214
214
  status = EditValidationResult.Invalid;
@@ -227,7 +227,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
227
227
  */
228
228
  abortEdit() {
229
229
  const { currentEdit } = this;
230
- Common_1.assert(currentEdit !== undefined, 'An edit is not open.');
230
+ (0, Common_1.assert)(currentEdit !== undefined, 'An edit is not open.');
231
231
  this.currentEdit = undefined;
232
232
  this.emitChange();
233
233
  }
@@ -238,7 +238,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
238
238
  */
239
239
  getEditStatus() {
240
240
  const { currentEdit } = this;
241
- Common_1.assert(currentEdit !== undefined, 'An edit is not open.');
241
+ (0, Common_1.assert)(currentEdit !== undefined, 'An edit is not open.');
242
242
  // TODO: could this ever be anything other than 'Applied'
243
243
  // TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?
244
244
  return currentEdit.status;
@@ -248,7 +248,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
248
248
  * @param editIds - the edits to revert
249
249
  */
250
250
  revert(editId) {
251
- Common_1.assert(this.currentEdit !== undefined);
251
+ (0, Common_1.assert)(this.currentEdit !== undefined);
252
252
  const index = this.tree.edits.getIndexOfId(editId);
253
253
  const edit = this.tree.edits.getEditInSessionAtIndex(index);
254
254
  const before = this.tree.logViewer.getRevisionViewInSession(index);
@@ -1 +1 @@
1
- {"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAgF;AAEhF,qCAAkC;AAElC,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAMxB;AASD;;;GAGG;AACH,IAAY,oBAiB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AC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AAzSD,4BAySC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent } from '@fluidframework/common-definitions';\nimport { assert } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tassert(editingResult.status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid');\n\n\t\tconst id: EditId = newEditId();\n\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(...changes: Change[]): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(...changes: ChangeInternal[]): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(...changes: Change[]): EditId {\n\t\tthis.openEdit();\n\t\tthis.applyChanges(...changes);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(...changes: Change[]): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(index);\n\t\tconst before = this.tree.logViewer.getRevisionViewInSession(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(...changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
1
+ {"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAgF;AAEhF,qCAAkC;AAElC,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAMxB;AASD;;;GAGG;AACH,IAAY,oBAiBX;AAjBD,WAAY,oBAAoB;IAC/B;;;;OAIG;IACH,yEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAO,CAAA;IACP;;OAEG;IACH,iEAAK,CAAA;AACN,CAAC,EAjBW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAiB/B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAsB,QAAS,SAAQ,+CAA8C;IA0CpF,YAAsB,IAAgB,EAAE,WAAyB,EAAE,eAAqC;QACvG,KAAK,CAAC,CAAC,MAAM,EAAE,KAAc,EAAE,EAAE;YAChC,IAAI,CAAC,IAA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;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,OAAO,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,CAAC;SACzC;IACF,CAAC;IAED;;;;OAIG;IACO,UAAU;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;YAC5C,6GAA6G;YAC7G,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;IACF,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AAzSD,4BAySC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent } from '@fluidframework/common-definitions';\nimport { assert } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tassert(editingResult.status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid');\n\n\t\tconst id: EditId = newEditId();\n\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(...changes: Change[]): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(...changes: ChangeInternal[]): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(...changes: Change[]): EditId {\n\t\tthis.openEdit();\n\t\tthis.applyChanges(...changes);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(...changes: Change[]): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(index);\n\t\tconst before = this.tree.logViewer.getRevisionViewInSession(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(...changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
package/dist/Common.d.ts CHANGED
@@ -25,11 +25,17 @@ export interface SharedTreeTelemetryProperties extends ITelemetryProperties {
25
25
  */
26
26
  export declare function isSharedTreeEvent(event: ITelemetryBaseEvent): boolean;
27
27
  /**
28
- * Compares finite numbers to form a strict partial ordering.
28
+ * A numeric comparator used for sorting in ascending order.
29
29
  *
30
30
  * Handles +/-0 like Map: -0 is equal to +0.
31
31
  */
32
32
  export declare function compareFiniteNumbers<T extends number>(a: T, b: T): number;
33
+ /**
34
+ * A numeric comparator used for sorting in descending order.
35
+ *
36
+ * Handles +/-0 like Map: -0 is equal to +0.
37
+ */
38
+ export declare function compareFiniteNumbersReversed<T extends number>(a: T, b: T): number;
33
39
  /**
34
40
  * Compares strings lexically to form a strict partial ordering.
35
41
  */
@@ -143,10 +149,10 @@ export declare function compareMaps<K, V>(mapA: ReadonlyMap<K, V>, mapB: Readonl
143
149
  * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
144
150
  * @param map - the map to query/update
145
151
  * @param key - the key to lookup in the map
146
- * @param defaultValue - a function which returns a default value. This is called and used to set an initial value in the map if none exists
152
+ * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists
147
153
  * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)
148
154
  */
149
- export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: () => V): V;
155
+ export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V;
150
156
  /**
151
157
  * Function which does nothing (no-ops).
152
158
  */
@@ -272,5 +278,17 @@ declare type Primitive = string | number | bigint | boolean | null | symbol | un
272
278
  export declare type ReplaceRecursive<T, TReplace, TWith> = T extends TReplace ? TWith : T extends Primitive ? T : {
273
279
  [P in keyof T]: ReplaceRecursive<T[P], TReplace, TWith>;
274
280
  };
281
+ /** A union type of the first `N` positive integers */
282
+ export declare type TakeWholeNumbers<N extends number, A extends never[] = []> = N extends A['length'] ? never : A['length'] | TakeWholeNumbers<N, [never, ...A]>;
283
+ /** Returns a tuple type with exactly `Length` elements of type `T` */
284
+ export declare type ArrayOfLength<T, Length extends number, A extends T[] = []> = Length extends A['length'] ? A : ArrayOfLength<T, Length, [T, ...A]>;
285
+ /**
286
+ * Fails if `array` does not have exactly `length` elements
287
+ */
288
+ export declare function hasExactlyLength<T, Len extends TakeWholeNumbers<16>>(array: readonly T[], length: Len): array is ArrayOfLength<T, Len>;
289
+ /**
290
+ * Fails if `array` does not have at least `length` elements
291
+ */
292
+ export declare function hasLength<T, Len extends TakeWholeNumbers<16>>(array: readonly T[], length: Len): array is [...ArrayOfLength<T, Len>, ...T[]];
275
293
  export {};
276
294
  //# sourceMappingURL=Common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,KAAK,MAAM,cAAc,CAAC;AAIjC;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,wBAAwB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAErE;AAgBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,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