@fluid-experimental/tree 0.59.2001 → 0.59.3000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.vscode/SharedTree.code-workspace +15 -0
  3. package/.vscode/settings.json +6 -0
  4. package/dist/ChangeCompression.js +9 -9
  5. package/dist/ChangeCompression.js.map +1 -1
  6. package/dist/ChangeTypes.d.ts +1 -6
  7. package/dist/ChangeTypes.d.ts.map +1 -1
  8. package/dist/ChangeTypes.js +5 -5
  9. package/dist/ChangeTypes.js.map +1 -1
  10. package/dist/Checkout.js +14 -14
  11. package/dist/Checkout.js.map +1 -1
  12. package/dist/Common.d.ts +21 -3
  13. package/dist/Common.d.ts.map +1 -1
  14. package/dist/Common.js +29 -4
  15. package/dist/Common.js.map +1 -1
  16. package/dist/EditLog.js +26 -25
  17. package/dist/EditLog.js.map +1 -1
  18. package/dist/EditUtilities.js +17 -17
  19. package/dist/EditUtilities.js.map +1 -1
  20. package/dist/Forest.js +31 -31
  21. package/dist/Forest.js.map +1 -1
  22. package/dist/HistoryEditFactory.js +9 -9
  23. package/dist/HistoryEditFactory.js.map +1 -1
  24. package/dist/IdConversion.js +9 -9
  25. package/dist/IdConversion.js.map +1 -1
  26. package/dist/Identifiers.d.ts +4 -0
  27. package/dist/Identifiers.d.ts.map +1 -1
  28. package/dist/Identifiers.js.map +1 -1
  29. package/dist/LogViewer.d.ts +1 -5
  30. package/dist/LogViewer.d.ts.map +1 -1
  31. package/dist/LogViewer.js +11 -19
  32. package/dist/LogViewer.js.map +1 -1
  33. package/dist/MergeHealth.js +2 -2
  34. package/dist/MergeHealth.js.map +1 -1
  35. package/dist/NodeIdUtilities.js +2 -2
  36. package/dist/NodeIdUtilities.js.map +1 -1
  37. package/dist/PayloadUtilities.js +1 -1
  38. package/dist/PayloadUtilities.js.map +1 -1
  39. package/dist/RevisionValueCache.d.ts +13 -10
  40. package/dist/RevisionValueCache.d.ts.map +1 -1
  41. package/dist/RevisionValueCache.js +14 -11
  42. package/dist/RevisionValueCache.js.map +1 -1
  43. package/dist/RevisionView.js +4 -4
  44. package/dist/RevisionView.js.map +1 -1
  45. package/dist/SerializationUtilities.js +4 -4
  46. package/dist/SerializationUtilities.js.map +1 -1
  47. package/dist/SharedTree.d.ts +93 -31
  48. package/dist/SharedTree.d.ts.map +1 -1
  49. package/dist/SharedTree.js +160 -131
  50. package/dist/SharedTree.js.map +1 -1
  51. package/dist/SharedTreeEncoder.d.ts +3 -3
  52. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  53. package/dist/SharedTreeEncoder.js +36 -36
  54. package/dist/SharedTreeEncoder.js.map +1 -1
  55. package/dist/StringInterner.js +1 -1
  56. package/dist/StringInterner.js.map +1 -1
  57. package/dist/Summary.js +1 -1
  58. package/dist/Summary.js.map +1 -1
  59. package/dist/SummaryBackCompatibility.js +8 -8
  60. package/dist/SummaryBackCompatibility.js.map +1 -1
  61. package/dist/Transaction.js +1 -1
  62. package/dist/Transaction.js.map +1 -1
  63. package/dist/TransactionInternal.js +17 -17
  64. package/dist/TransactionInternal.js.map +1 -1
  65. package/dist/TreeCompressor.d.ts.map +1 -1
  66. package/dist/TreeCompressor.js +6 -8
  67. package/dist/TreeCompressor.js.map +1 -1
  68. package/dist/TreeNodeHandle.js +4 -4
  69. package/dist/TreeNodeHandle.js.map +1 -1
  70. package/dist/TreeView.js +7 -7
  71. package/dist/TreeView.js.map +1 -1
  72. package/dist/TreeViewUtilities.js +2 -2
  73. package/dist/TreeViewUtilities.js.map +1 -1
  74. package/dist/UndoRedoHandler.js +1 -1
  75. package/dist/UndoRedoHandler.js.map +1 -1
  76. package/dist/UuidUtilities.d.ts +30 -0
  77. package/dist/UuidUtilities.d.ts.map +1 -0
  78. package/dist/UuidUtilities.js +106 -0
  79. package/dist/UuidUtilities.js.map +1 -0
  80. package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  81. package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  82. package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
  83. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  84. package/dist/id-compressor/IdCompressor.d.ts +43 -42
  85. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  86. package/dist/id-compressor/IdCompressor.js +179 -177
  87. package/dist/id-compressor/IdCompressor.js.map +1 -1
  88. package/dist/id-compressor/IdRange.js +1 -1
  89. package/dist/id-compressor/IdRange.js.map +1 -1
  90. package/dist/id-compressor/NumericUuid.d.ts +6 -14
  91. package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
  92. package/dist/id-compressor/NumericUuid.js +15 -76
  93. package/dist/id-compressor/NumericUuid.js.map +1 -1
  94. package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
  95. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  96. package/dist/id-compressor/SessionIdNormalizer.js +418 -0
  97. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
  98. package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  99. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  100. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  101. package/dist/index.d.ts +2 -2
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/persisted-types/0.1.1.d.ts +1 -6
  105. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  106. package/dist/persisted-types/0.1.1.js +3 -3
  107. package/dist/persisted-types/0.1.1.js.map +1 -1
  108. package/lib/ChangeTypes.d.ts +1 -6
  109. package/lib/ChangeTypes.d.ts.map +1 -1
  110. package/lib/Checkout.js.map +1 -1
  111. package/lib/Common.d.ts +21 -3
  112. package/lib/Common.d.ts.map +1 -1
  113. package/lib/Common.js +25 -3
  114. package/lib/Common.js.map +1 -1
  115. package/lib/EditLog.js +2 -1
  116. package/lib/EditLog.js.map +1 -1
  117. package/lib/EditUtilities.js.map +1 -1
  118. package/lib/Forest.js.map +1 -1
  119. package/lib/HistoryEditFactory.js.map +1 -1
  120. package/lib/Identifiers.d.ts +4 -0
  121. package/lib/Identifiers.d.ts.map +1 -1
  122. package/lib/Identifiers.js.map +1 -1
  123. package/lib/LogViewer.d.ts +1 -5
  124. package/lib/LogViewer.d.ts.map +1 -1
  125. package/lib/LogViewer.js +5 -13
  126. package/lib/LogViewer.js.map +1 -1
  127. package/lib/MergeHealth.js.map +1 -1
  128. package/lib/NodeIdUtilities.js.map +1 -1
  129. package/lib/RevisionValueCache.d.ts +13 -10
  130. package/lib/RevisionValueCache.d.ts.map +1 -1
  131. package/lib/RevisionValueCache.js +10 -7
  132. package/lib/RevisionValueCache.js.map +1 -1
  133. package/lib/RevisionView.js.map +1 -1
  134. package/lib/SharedTree.d.ts +93 -31
  135. package/lib/SharedTree.d.ts.map +1 -1
  136. package/lib/SharedTree.js +107 -78
  137. package/lib/SharedTree.js.map +1 -1
  138. package/lib/SharedTreeEncoder.d.ts +3 -3
  139. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  140. package/lib/SharedTreeEncoder.js +4 -4
  141. package/lib/SharedTreeEncoder.js.map +1 -1
  142. package/lib/StringInterner.js.map +1 -1
  143. package/lib/Summary.js.map +1 -1
  144. package/lib/TreeCompressor.d.ts.map +1 -1
  145. package/lib/TreeCompressor.js +1 -3
  146. package/lib/TreeCompressor.js.map +1 -1
  147. package/lib/TreeNodeHandle.js.map +1 -1
  148. package/lib/TreeView.js.map +1 -1
  149. package/lib/TreeViewUtilities.js.map +1 -1
  150. package/lib/UuidUtilities.d.ts +30 -0
  151. package/lib/UuidUtilities.d.ts.map +1 -0
  152. package/lib/UuidUtilities.js +98 -0
  153. package/lib/UuidUtilities.js.map +1 -0
  154. package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  155. package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  156. package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
  157. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  158. package/lib/id-compressor/IdCompressor.d.ts +43 -42
  159. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  160. package/lib/id-compressor/IdCompressor.js +97 -95
  161. package/lib/id-compressor/IdCompressor.js.map +1 -1
  162. package/lib/id-compressor/NumericUuid.d.ts +6 -14
  163. package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
  164. package/lib/id-compressor/NumericUuid.js +11 -70
  165. package/lib/id-compressor/NumericUuid.js.map +1 -1
  166. package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
  167. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  168. package/lib/id-compressor/SessionIdNormalizer.js +414 -0
  169. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
  170. package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  171. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  172. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  173. package/lib/index.d.ts +2 -2
  174. package/lib/index.d.ts.map +1 -1
  175. package/lib/index.js.map +1 -1
  176. package/lib/persisted-types/0.1.1.d.ts +1 -6
  177. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  178. package/lib/persisted-types/0.1.1.js.map +1 -1
  179. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
  180. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
  181. package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
  182. package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
  183. package/lib/test/AppendOnlySortedMap.tests.js +56 -14
  184. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
  185. package/lib/test/Checkout.tests.js +2 -2
  186. package/lib/test/Checkout.tests.js.map +1 -1
  187. package/lib/test/Forest.tests.js.map +1 -1
  188. package/lib/test/IdCompressor.perf.tests.js +8 -2
  189. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  190. package/lib/test/IdCompressor.tests.js +75 -24
  191. package/lib/test/IdCompressor.tests.js.map +1 -1
  192. package/lib/test/LogViewer.tests.js +3 -5
  193. package/lib/test/LogViewer.tests.js.map +1 -1
  194. package/lib/test/NumericUuid.perf.tests.js +4 -4
  195. package/lib/test/NumericUuid.perf.tests.js.map +1 -1
  196. package/lib/test/NumericUuid.tests.js +5 -4
  197. package/lib/test/NumericUuid.tests.js.map +1 -1
  198. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  199. package/lib/test/RevisionView.tests.js.map +1 -1
  200. package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
  201. package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
  202. package/lib/test/SessionIdNormalizer.tests.js +299 -0
  203. package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
  204. package/lib/test/Summary.tests.js +1 -1
  205. package/lib/test/Summary.tests.js.map +1 -1
  206. package/lib/test/TreeCompression.tests.js +1 -1
  207. package/lib/test/TreeCompression.tests.js.map +1 -1
  208. package/lib/test/Virtualization.tests.js +1 -1
  209. package/lib/test/Virtualization.tests.js.map +1 -1
  210. package/lib/test/fuzz/Generators.d.ts +3 -14
  211. package/lib/test/fuzz/Generators.d.ts.map +1 -1
  212. package/lib/test/fuzz/Generators.js +60 -151
  213. package/lib/test/fuzz/Generators.js.map +1 -1
  214. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
  215. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  216. package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
  217. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  218. package/lib/test/fuzz/Types.d.ts +2 -9
  219. package/lib/test/fuzz/Types.d.ts.map +1 -1
  220. package/lib/test/fuzz/Types.js +1 -1
  221. package/lib/test/fuzz/Types.js.map +1 -1
  222. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
  223. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  224. package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
  225. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  226. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  227. package/lib/test/utilities/PendingLocalStateTests.js +2 -1
  228. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  229. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  230. package/lib/test/utilities/SharedTreeTests.js +30 -1
  231. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  232. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  233. package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
  234. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  235. package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
  236. package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
  237. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  238. package/lib/test/utilities/TestNode.js.map +1 -1
  239. package/lib/test/utilities/TestUtilities.d.ts +9 -1
  240. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  241. package/lib/test/utilities/TestUtilities.js +27 -13
  242. package/lib/test/utilities/TestUtilities.js.map +1 -1
  243. package/package.json +19 -17
  244. package/src/Common.ts +42 -4
  245. package/src/EditLog.ts +1 -1
  246. package/src/Identifiers.ts +5 -0
  247. package/src/LogViewer.ts +4 -20
  248. package/src/RevisionValueCache.ts +11 -8
  249. package/src/SharedTree.ts +222 -75
  250. package/src/SharedTreeEncoder.ts +17 -11
  251. package/src/TreeCompressor.ts +2 -4
  252. package/src/UuidUtilities.ts +123 -0
  253. package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
  254. package/src/id-compressor/IdCompressor.ts +144 -132
  255. package/src/id-compressor/NumericUuid.ts +11 -80
  256. package/src/id-compressor/SessionIdNormalizer.ts +497 -0
  257. package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
  258. package/src/index.ts +5 -0
@@ -69,7 +69,7 @@ class GenericTransaction {
69
69
  }
70
70
  /** @returns the final `EditStatus` and `TreeView` after all changes are applied. */
71
71
  close() {
72
- Common_1.assert(this.open, 'transaction has already been closed');
72
+ (0, Common_1.assert)(this.open, 'transaction has already been closed');
73
73
  this.open = false;
74
74
  if (this.state.status === persisted_types_1.EditStatus.Applied) {
75
75
  const validation = this.policy.validateOnClose(this.state);
@@ -155,9 +155,9 @@ class GenericTransaction {
155
155
  * @returns this
156
156
  */
157
157
  applyChange(change, path = []) {
158
- Common_1.assert(this.open, 'Editor must be open to apply changes.');
158
+ (0, Common_1.assert)(this.open, 'Editor must be open to apply changes.');
159
159
  if (this.state.status !== persisted_types_1.EditStatus.Applied) {
160
- Common_1.fail('Cannot apply change to an edit unless all previous changes have applied');
160
+ (0, Common_1.fail)('Cannot apply change to an edit unless all previous changes have applied');
161
161
  }
162
162
  const resolutionResult = this.policy.tryResolveChange(this.state, change, path);
163
163
  if (Common_1.Result.isError(resolutionResult)) {
@@ -262,7 +262,7 @@ var TransactionInternal;
262
262
  case persisted_types_1.ChangeTypeInternal.SetValue:
263
263
  return this.applySetValue(state, change);
264
264
  default:
265
- return Common_1.fail('Attempted to apply unsupported change');
265
+ return (0, Common_1.fail)('Attempted to apply unsupported change');
266
266
  }
267
267
  }
268
268
  applyBuild(state, change) {
@@ -324,7 +324,7 @@ var TransactionInternal;
324
324
  });
325
325
  }
326
326
  const view = state.view.addNodes(map.values());
327
- this.detached.set(change.destination, newIds !== null && newIds !== void 0 ? newIds : Common_1.fail('Unhandled failure case in Transaction.createViewNodesForTree'));
327
+ this.detached.set(change.destination, newIds !== null && newIds !== void 0 ? newIds : (0, Common_1.fail)('Unhandled failure case in Transaction.createViewNodesForTree'));
328
328
  return Common_1.Result.ok(view);
329
329
  }
330
330
  applyInsert(state, change) {
@@ -339,7 +339,7 @@ var TransactionInternal;
339
339
  },
340
340
  });
341
341
  }
342
- const validatedDestination = EditUtilities_1.validateStablePlace(state.view, change.destination);
342
+ const validatedDestination = (0, EditUtilities_1.validateStablePlace)(state.view, change.destination);
343
343
  if (validatedDestination.result !== EditUtilities_1.PlaceValidationResult.Valid) {
344
344
  return Common_1.Result.error({
345
345
  status: validatedDestination.result === EditUtilities_1.PlaceValidationResult.Malformed
@@ -354,11 +354,11 @@ var TransactionInternal;
354
354
  });
355
355
  }
356
356
  this.detached.delete(change.source);
357
- const view = EditUtilities_1.insertIntoTrait(state.view, source, validatedDestination);
357
+ const view = (0, EditUtilities_1.insertIntoTrait)(state.view, source, validatedDestination);
358
358
  return Common_1.Result.ok(view);
359
359
  }
360
360
  applyDetach(state, change) {
361
- const validatedSource = EditUtilities_1.validateStableRange(state.view, change.source);
361
+ const validatedSource = (0, EditUtilities_1.validateStableRange)(state.view, change.source);
362
362
  if (validatedSource.result !== EditUtilities_1.RangeValidationResultKind.Valid) {
363
363
  return Common_1.Result.error({
364
364
  status: validatedSource.result === EditUtilities_1.RangeValidationResultKind.PlacesInDifferentTraits ||
@@ -374,7 +374,7 @@ var TransactionInternal;
374
374
  },
375
375
  });
376
376
  }
377
- const result = EditUtilities_1.detachRange(state.view, validatedSource);
377
+ const result = (0, EditUtilities_1.detachRange)(state.view, validatedSource);
378
378
  let modifiedView = result.view;
379
379
  const { detached } = result;
380
380
  // Store or dispose detached
@@ -398,9 +398,9 @@ var TransactionInternal;
398
398
  }
399
399
  applyConstraint(state, change) {
400
400
  // TODO: Implement identityHash and contentHash
401
- Common_1.assert(change.identityHash === undefined, 'identityHash constraint is not implemented');
402
- Common_1.assert(change.contentHash === undefined, 'contentHash constraint is not implemented');
403
- const validatedChange = EditUtilities_1.validateStableRange(state.view, change.toConstrain);
401
+ (0, Common_1.assert)(change.identityHash === undefined, 'identityHash constraint is not implemented');
402
+ (0, Common_1.assert)(change.contentHash === undefined, 'contentHash constraint is not implemented');
403
+ const validatedChange = (0, EditUtilities_1.validateStableRange)(state.view, change.toConstrain);
404
404
  if (validatedChange.result !== EditUtilities_1.RangeValidationResultKind.Valid) {
405
405
  return validatedChange.result !== EditUtilities_1.RangeValidationResultKind.PlacesInDifferentTraits &&
406
406
  validatedChange.result !== EditUtilities_1.RangeValidationResultKind.Inverted &&
@@ -430,7 +430,7 @@ var TransactionInternal;
430
430
  },
431
431
  });
432
432
  }
433
- const { start, end } = TreeViewUtilities_1.rangeFromStableRange(state.view, validatedChange);
433
+ const { start, end } = (0, TreeViewUtilities_1.rangeFromStableRange)(state.view, validatedChange);
434
434
  const startIndex = state.view.findIndexWithinTrait(start);
435
435
  const endIndex = state.view.findIndexWithinTrait(end);
436
436
  if (change.length !== undefined && change.length !== endIndex - startIndex) {
@@ -494,7 +494,7 @@ var TransactionInternal;
494
494
  const topLevelIds = [];
495
495
  const unprocessed = [];
496
496
  for (const buildNode of sequence) {
497
- if (Identifiers_1.isDetachedSequenceId(buildNode)) {
497
+ if ((0, Identifiers_1.isDetachedSequenceId)(buildNode)) {
498
498
  const detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);
499
499
  if (detachedIds === undefined) {
500
500
  return undefined;
@@ -508,7 +508,7 @@ var TransactionInternal;
508
508
  }
509
509
  while (unprocessed.length > 0) {
510
510
  const node = unprocessed.pop();
511
- Common_1.assert(node !== undefined && !Identifiers_1.isDetachedSequenceId(node));
511
+ (0, Common_1.assert)(node !== undefined && !(0, Identifiers_1.isDetachedSequenceId)(node));
512
512
  const traits = new Map();
513
513
  // eslint-disable-next-line no-restricted-syntax
514
514
  for (const key in node.traits) {
@@ -517,7 +517,7 @@ var TransactionInternal;
517
517
  if (children.length > 0) {
518
518
  const childIds = [];
519
519
  for (const child of children) {
520
- if (Identifiers_1.isDetachedSequenceId(child)) {
520
+ if ((0, Identifiers_1.isDetachedSequenceId)(child)) {
521
521
  const detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);
522
522
  if (detachedIds === undefined) {
523
523
  return undefined;
@@ -538,7 +538,7 @@ var TransactionInternal;
538
538
  definition: node.definition,
539
539
  traits,
540
540
  };
541
- Common_1.copyPropertyIfDefined(node, newNode, 'payload');
541
+ (0, Common_1.copyPropertyIfDefined)(node, newNode, 'payload');
542
542
  if (onCreateNode(node.identifier, newNode)) {
543
543
  return undefined;
544
544
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAuE;AACvE,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA4IzB;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAM9B;;;OAGG;IACH,YAAmB,IAAkB,EAAE,MAAgC;QAN/D,SAAI,GAAG,IAAI,CAAC;QAOnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC/B,MAAM,EAAE,4BAAU,CAAC,OAAO;YAC1B,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;SACT,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,oFAAoF;IAC7E,KAAK;QACX,eAAM,CAAC,IAAI,CAAC,IAAI,EAAE,qCA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MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,eAAe,KAAK,SAAS,EAAE;gBAClC,mBAAmB,CAAC,UAAU,CAAC,CAAC;gBAChC,OAAO,SAAS,CAAC;aACjB;YACD,uHAAuH;YACvH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACjC,OAAO,eAAe,CAAC;QACxB,CAAC;KACD;IAhYY,0BAAM,SAgYlB,CAAA;IAED;;OAEG;IACH,IAAY,WAqCX;IArCD,WAAY,WAAW;QACtB;;WAEG;QACH,gEAAiD,CAAA;QACjD;;WAEG;QACH,gFAAiE,CAAA;QACjE;;WAEG;QACH,oEAAqD,CAAA;QACrD;;WAEG;QACH,wDAAyC,CAAA;QACzC;;WAEG;QACH,gDAAiC,CAAA;QACjC;;WAEG;QACH,sCAAuB,CAAA;QACvB;;WAEG;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,0DAA2C,CAAA;IAC5C,CAAC,EArCW,WAAW,GAAX,+BAAW,KAAX,+BAAW,QAqCtB;IA2MD;;OAEG;IACH,IAAY,uBAiBX;IAjBD,WAAY,uBAAuB;QAClC;;WAEG;QACH,gDAAqB,CAAA;QACrB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,gDAAqB,CAAA;IACtB,CAAC,EAjBW,uBAAuB,GAAvB,2CAAuB,KAAvB,2CAAuB,QAiBlC;AACF,CAAC,EAvpBgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAupBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail, Result } from './Common';\nimport { NodeId, DetachedSequenceId, TraitLabel, isDetachedSequenceId } from './Identifiers';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintEffect,\n\tConstraintInternal,\n\tDetachInternal,\n\tEditStatus,\n\tInsertInternal,\n\tSetValueInternal,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n} from './persisted-types';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tBadPlaceValidationResult,\n\tBadRangeValidationResult,\n\tPlaceValidationResult,\n\tRangeValidationResultKind,\n} from './EditUtilities';\nimport { RevisionView, TransactionView } from './RevisionView';\nimport { ReconciliationChange, ReconciliationPath } from './ReconciliationPath';\nimport { TreeViewNode } from './TreeView';\n\n/**\n * Result of applying a transaction.\n * @public\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @public\n */\nexport interface EditingResultBase {\n\t/**\n\t * The final status of the transaction.\n\t */\n\treadonly status: EditStatus;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n\t/**\n\t * The revision preceding the transaction.\n\t */\n\treadonly before: RevisionView;\n}\n\n/**\n * Result of applying an invalid or malformed transaction.\n * @public\n */\nexport interface FailedEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * Result of applying a valid transaction.\n * @public\n */\nexport interface ValidEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The new revision produced by the transaction.\n\t */\n\treadonly after: RevisionView;\n}\n\n/**\n * The result of applying a change within a transaction.\n * @public\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @public\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n */\nexport interface SucceedingTransactionState {\n\t/**\n\t * The current status of the transaction.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The state of a transaction that has encountered an error.\n */\nexport interface FailingTransactionState extends TransactionFailure {\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The failure state of a transaction.\n */\nexport interface TransactionFailure {\n\t/**\n\t * The status indicating the kind of failure encountered.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class GenericTransaction {\n\tprivate readonly policy: GenericTransactionPolicy;\n\tprotected readonly before: RevisionView;\n\tprivate state: TransactionState;\n\tprivate open = true;\n\n\t/**\n\t * Create and open an edit of the provided `TreeView`. After applying 0 or more changes, this editor should be closed via `close()`.\n\t * @param view - the `TreeView` at which this edit begins. The first change will be applied against this view.\n\t */\n\tpublic constructor(view: RevisionView, policy: GenericTransactionPolicy) {\n\t\tthis.before = view;\n\t\tthis.policy = policy;\n\t\tthis.state = {\n\t\t\tview: view.openForTransaction(),\n\t\t\tstatus: EditStatus.Applied,\n\t\t\tchanges: [],\n\t\t\tsteps: [],\n\t\t};\n\t}\n\n\t/** Whether or not this transaction has been closed via `close()` */\n\tpublic get isOpen(): boolean {\n\t\treturn this.open;\n\t}\n\n\t/**\n\t * The most up-to-date `TreeView` for this edit. This is the state of the tree after all changes applied so far.\n\t */\n\tpublic get view(): TransactionView {\n\t\treturn this.state.view;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get status(): EditStatus {\n\t\treturn this.state.status;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get changes(): readonly ChangeInternal[] {\n\t\treturn this.state.changes;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get steps(): readonly ReconciliationChange[] {\n\t\treturn this.state.steps;\n\t}\n\n\t/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */\n\tpublic close(): EditingResult {\n\t\tassert(this.open, 'transaction has already been closed');\n\t\tthis.open = false;\n\t\tif (this.state.status === EditStatus.Applied) {\n\t\t\tconst validation = this.policy.validateOnClose(this.state);\n\t\t\tif (Result.isOk(validation)) {\n\t\t\t\tif (validation.result !== this.view) {\n\t\t\t\t\tthis.state = { ...this.state, view: validation.result };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tsteps: this.steps,\n\t\t\t\t\tchanges: this.changes,\n\t\t\t\t\tbefore: this.before,\n\t\t\t\t\tafter: this.view.close(),\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.state = { ...this.state, ...validation.error };\n\t\t\treturn {\n\t\t\t\t...validation.error,\n\t\t\t\tsteps: this.steps,\n\t\t\t\tchanges: this.changes,\n\t\t\t\tbefore: this.before,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: this.state.status,\n\t\t\tfailure: this.state.failure,\n\t\t\tsteps: this.steps,\n\t\t\tchanges: this.changes,\n\t\t\tbefore: this.before,\n\t\t};\n\t}\n\n\t/**\n\t * A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply,\n\t * the remaining changes in `changes` will be ignored.\n\t * @param changes - the sequence of changes to apply.\n\t * @param path - the reconciliation path for the first change.\n\t * @returns this\n\t */\n\tpublic applyChanges(changes: Iterable<ChangeInternal>, path: ReconciliationPath = []): this {\n\t\tconst iter = changes[Symbol.iterator]();\n\t\tconst firsChangeInternal = iter.next().value;\n\t\tlet iterResult = iter.next();\n\t\tif (iterResult.done === true) {\n\t\t\tfor (const change of changes) {\n\t\t\t\tif (this.applyChange(change, path).status !== EditStatus.Applied) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tif (this.applyChange(firsChangeInternal, path).status !== EditStatus.Applied) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst ongoingEdit = {\n\t\t\t0: this.steps[this.steps.length - 1],\n\t\t\tbefore: this.view,\n\t\t\tafter: this.view,\n\t\t\tlength: 1,\n\t\t};\n\n\t\t/**\n\t\t * We use a Proxy instead of `{ ...path, ...objectWithOngoingEdit }` to avoid eagerly demanding all parts of the path, which may\n\t\t * require extensive computation.\n\t\t */\n\t\tconst pathWithOngoingEdit = new Proxy(path, {\n\t\t\tget: (target: ReconciliationPath, prop: string): ReconciliationPath[number | 'length'] => {\n\t\t\t\tif (prop === 'length') {\n\t\t\t\t\treturn target.length + 1;\n\t\t\t\t}\n\t\t\t\treturn prop === String(target.length) ? ongoingEdit : target[prop];\n\t\t\t},\n\t\t});\n\n\t\twhile (iterResult.done !== true) {\n\t\t\tif (this.applyChange(iterResult.value, pathWithOngoingEdit).status !== EditStatus.Applied) {\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tongoingEdit[ongoingEdit.length] = this.steps[this.steps.length - 1];\n\t\t\tongoingEdit.length += 1;\n\t\t\tongoingEdit.after = this.view;\n\t\t\titerResult = iter.next();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to\n\t * apply.\n\t * @param change - the change to apply\n\t * @param path - the reconciliation path for the change.\n\t * @returns this\n\t */\n\tpublic applyChange(change: ChangeInternal, path: ReconciliationPath = []): this {\n\t\tassert(this.open, 'Editor must be open to apply changes.');\n\t\tif (this.state.status !== EditStatus.Applied) {\n\t\t\tfail('Cannot apply change to an edit unless all previous changes have applied');\n\t\t}\n\t\tconst resolutionResult = this.policy.tryResolveChange(this.state, change, path);\n\t\tif (Result.isError(resolutionResult)) {\n\t\t\tthis.state = { ...this.state, ...resolutionResult.error };\n\t\t\treturn this;\n\t\t}\n\t\tconst resolvedChange = resolutionResult.result;\n\t\tconst changeResult = this.policy.dispatchChange(this.state, resolvedChange);\n\t\tif (Result.isOk(changeResult)) {\n\t\t\tthis.state = {\n\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\tview: changeResult.result,\n\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t};\n\t\t} else {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\t...changeResult.error,\n\t\t\t};\n\t\t}\n\t\treturn this;\n\t}\n}\n\n/**\n * An object that encapsulates the rules and state pertaining to a specific subclass of {@link GenericTransaction}.\n * The characteristics that define such a subclass (and an implementation of this interface) are:\n * - The type of change that can be applied\n * - How those changes impact the state of the tree\n * - How those changes are resolved in the face of concurrent changes\n * - What makes a transaction valid\n * - The kind of situations that might lead to a transaction failure\n *\n * Instances of this type are passed to the {@link GenericTransaction} constructor.\n */\nexport interface GenericTransactionPolicy {\n\t/**\n\t * Given a change, attempts to derive an equivalent change which can be applied to the current state even if the given change was issued\n\t * over a different state. This can be used to apply a sequence of changes that were issued concurrently, i.e., without knowledge of\n\t * each other.\n\t * @param state - The current state on which the returned change will be applied.\n\t * @param change - The original change issued.\n\t * @param path - The reconciliation path for the change.\n\t * @returns The change to be applied to the current state, or a failure if the change cannot be resolved.\n\t */\n\ttryResolveChange(\n\t\tstate: SucceedingTransactionState,\n\t\tchange: ChangeInternal,\n\t\tpath: ReconciliationPath\n\t): Result<ChangeInternal, TransactionFailure>;\n\n\t/**\n\t * Provides a new state given the current state and a change to apply.\n\t * @param state - The current state on which the change is applied.\n\t * @param change - The change to apply to the current state.\n\t * @returns The new state reflecting the applied change, or a failure.\n\t */\n\tdispatchChange(state: SucceedingTransactionState, change: ChangeInternal): ChangeResult;\n\n\t/**\n\t * Additional transaction validation when the transaction is closed.\n\t * @param state - The current state of the transaction.\n\t * @returns The new state reflecting the closed transaction, or a failure if the transaction cannot be closed.\n\t */\n\tvalidateOnClose(state: SucceedingTransactionState): ChangeResult;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n * @public\n */\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t */\n\texport function factory(view: RevisionView): GenericTransaction {\n\t\treturn new GenericTransaction(view, new Policy());\n\t}\n\n\ttype ValidState = SucceedingTransactionState;\n\n\t/**\n\t * The policy followed by a {@link TransactionInternal}.\n\t */\n\texport class Policy implements GenericTransactionPolicy {\n\t\t/**\n\t\t * Maps detached sequences of nodes to their NodeIds\n\t\t */\n\t\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\t\t/**\n\t\t * Resolves change with Result.Ok\n\t\t *\n\t\t * @param state - Unused\n\t\t * @param change - Change to resolve\n\t\t * @returns Result.Ok which contains change\n\t\t */\n\t\tpublic tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal> {\n\t\t\treturn Result.ok(change);\n\t\t}\n\n\t\t/**\n\t\t * Validates the transaction when it is closed\n\t\t *\n\t\t * @param state - Current state\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic validateOnClose(state: ValidState): ChangeResult {\n\t\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\t\treturn this.detached.size !== 0\n\t\t\t\t? Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.UnusedDetachedSequence,\n\t\t\t\t\t\t\tsequenceId: this.detached.keys().next().value,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: Result.ok(state.view);\n\t\t}\n\n\t\t/**\n\t\t * Applies a given change\n\t\t *\n\t\t * @param state - Current state\n\t\t * @param change - Change to apply\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult {\n\t\t\tswitch (change.type) {\n\t\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\t\treturn this.applyBuild(state, change);\n\t\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\t\treturn this.applyInsert(state, change);\n\t\t\t\tcase ChangeTypeInternal.Detach:\n\t\t\t\t\treturn this.applyDetach(state, change);\n\t\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t\treturn this.applyConstraint(state, change);\n\t\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\t\treturn this.applySetValue(state, change);\n\t\t\t\tdefault:\n\t\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t\t}\n\t\t}\n\n\t\tprivate applyBuild(state: ValidState, change: BuildInternal): ChangeResult {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet idAlreadyPresent: NodeId | undefined;\n\t\t\tlet duplicateIdInBuild: NodeId | undefined;\n\t\t\tlet invalidId: NodeId | undefined;\n\t\t\tlet detachedSequenceNotFound: DetachedSequenceId | undefined;\n\t\t\tconst map = new Map<NodeId, TreeViewNode>();\n\t\t\tconst newIds = this.createViewNodesForTree(\n\t\t\t\tchange.source,\n\t\t\t\t(id, viewNode) => {\n\t\t\t\t\tif (map.has(id)) {\n\t\t\t\t\t\tduplicateIdInBuild = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.view.hasNode(viewNode.identifier)) {\n\t\t\t\t\t\tidAlreadyPresent = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tmap.set(id, viewNode);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\t(detachedId) => {\n\t\t\t\t\tdetachedSequenceNotFound = detachedId;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (idAlreadyPresent !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.IdAlreadyInUse, change, id: idAlreadyPresent },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (duplicateIdInBuild !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: { kind: FailureKind.DuplicateIdInBuild, change, id: duplicateIdInBuild },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (invalidId !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: invalidId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (detachedSequenceNotFound !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: detachedSequenceNotFound,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst view = state.view.addNodes(map.values());\n\t\t\tthis.detached.set(\n\t\t\t\tchange.destination,\n\t\t\t\tnewIds ?? fail('Unhandled failure case in Transaction.createViewNodesForTree')\n\t\t\t);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyInsert(state: ValidState, change: InsertInternal): ChangeResult {\n\t\t\tconst source = this.detached.get(change.source);\n\t\t\tif (source === undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.source,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst validatedDestination = validateStablePlace(state.view, change.destination);\n\t\t\tif (validatedDestination.result !== PlaceValidationResult.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedDestination.result === PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Malformed\n\t\t\t\t\t\t\t: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadPlace,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tplace: change.destination,\n\t\t\t\t\t\tplaceFailure: validatedDestination.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.detached.delete(change.source);\n\t\t\tconst view = insertIntoTrait(state.view, source, validatedDestination);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyDetach(state: ValidState, change: DetachInternal): ChangeResult {\n\t\t\tconst validatedSource = validateStableRange(state.view, change.source);\n\t\t\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.PlacesInDifferentTraits ||\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.Inverted ||\n\t\t\t\t\t\tvalidatedSource.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Invalid\n\t\t\t\t\t\t\t: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadRange,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\trange: change.source,\n\t\t\t\t\t\trangeFailure: validatedSource.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = detachRange(state.view, validatedSource);\n\t\t\tlet modifiedView = result.view;\n\t\t\tconst { detached } = result;\n\n\t\t\t// Store or dispose detached\n\t\t\tif (change.destination !== undefined) {\n\t\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\t\treturn Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\t\tchange,\n\t\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.detached.set(change.destination, detached);\n\t\t\t} else {\n\t\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t\t}\n\t\t\treturn Result.ok(modifiedView);\n\t\t}\n\n\t\tprivate applyConstraint(state: ValidState, change: ConstraintInternal): ChangeResult {\n\t\t\t// TODO: Implement identityHash and contentHash\n\t\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\t\tconst validatedChange = validateStableRange(state.view, change.toConstrain);\n\t\t\tif (validatedChange.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn validatedChange.result !== RangeValidationResultKind.PlacesInDifferentTraits &&\n\t\t\t\t\tvalidatedChange.result !== RangeValidationResultKind.Inverted &&\n\t\t\t\t\tvalidatedChange.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t? change.effect === ConstraintEffect.ValidRetry\n\t\t\t\t\t\t? Result.ok(state.view)\n\t\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t })\n\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t });\n\t\t\t}\n\n\t\t\tconst { start, end } = rangeFromStableRange(state.view, validatedChange);\n\t\t\tconst startIndex = state.view.findIndexWithinTrait(start);\n\t\t\tconst endIndex = state.view.findIndexWithinTrait(end);\n\n\t\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLength,\n\t\t\t\t\t\t\tactual: endIndex - startIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadParent,\n\t\t\t\t\t\t\tactual: change.parentNode,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLabel,\n\t\t\t\t\t\t\tactual: end.trait.label,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn Result.ok(state.view);\n\t\t}\n\n\t\tprivate applySetValue(state: ValidState, change: SetValueInternal): ChangeResult {\n\t\t\tif (!state.view.hasNode(change.nodeToModify)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: change.nodeToModify },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newView = state.view.setNodeValue(change.nodeToModify, change.payload);\n\t\t\treturn Result.ok(newView);\n\t\t}\n\n\t\t/**\n\t\t * Generates tree view nodes from the supplied edit nodes.\n\t\t * Invokes onCreateNode for each new node, and halts creation early if it returns true.\n\t\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t\t */\n\t\tprotected createViewNodesForTree(\n\t\t\tsequence: Iterable<BuildNodeInternal>,\n\t\t\tonCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): NodeId[] | undefined {\n\t\t\tconst topLevelIds: NodeId[] = [];\n\t\t\tconst unprocessed: BuildNodeInternal[] = [];\n\t\t\tfor (const buildNode of sequence) {\n\t\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t\t} else {\n\t\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (unprocessed.length > 0) {\n\t\t\t\tconst node = unprocessed.pop();\n\t\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tfor (const key in node.traits) {\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst newNode: TreeViewNode = {\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\ttraits,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\t\tif (onCreateNode(node.identifier, newNode)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn topLevelIds;\n\t\t}\n\n\t\tprivate getDetachedNodeIds(\n\t\t\tdetachedId: DetachedSequenceId,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): readonly NodeId[] | undefined {\n\t\t\t// Retrieve the detached sequence from the void.\n\t\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\t\tif (detachedNodeIds === undefined) {\n\t\t\t\tonInvalidDetachedId(detachedId);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\t\tthis.detached.delete(detachedId);\n\t\t\treturn detachedNodeIds;\n\t\t}\n\t}\n\n\t/**\n\t * The kinds of failures that a transaction might encounter.\n\t */\n\texport enum FailureKind {\n\t\t/**\n\t\t * Transaction has an unused DetachedSequenceId\n\t\t */\n\t\tUnusedDetachedSequence = 'UnusedDetachedSequence',\n\t\t/**\n\t\t * Transaction has a build operation using an already in use DetachedSequenceID.\n\t\t */\n\t\tDetachedSequenceIdAlreadyInUse = 'DetachedSequenceIdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to operate on an unknown DetachedSequenceID\n\t\t */\n\t\tDetachedSequenceNotFound = 'DetachedSequenceNotFound',\n\t\t/**\n\t\t * Transaction has a build which uses a duplicated NodeId\n\t\t */\n\t\tDuplicateIdInBuild = 'DuplicateIdInBuild',\n\t\t/**\n\t\t * Transaction tries to build a node using an ID which is already used in the current state\n\t\t */\n\t\tIdAlreadyInUse = 'IdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to set value of an unknown node\n\t\t */\n\t\tUnknownId = 'UnknownId',\n\t\t/**\n\t\t * Transaction tries to insert in an invalid Place\n\t\t */\n\t\tBadPlace = 'BadPlace',\n\t\t/**\n\t\t * Transaction tries to detach an invalid Range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * Transaction has an invalid constraint\n\t\t */\n\t\tConstraintViolation = 'ConstraintViolation',\n\t}\n\n\t/**\n\t * A failure encountered by a transaction.\n\t */\n\texport type Failure =\n\t\t| UnusedDetachedSequenceFailure\n\t\t| DetachedSequenceIdAlreadyInUseFailure\n\t\t| DetachedSequenceNotFoundFailure\n\t\t| DuplicateIdInBuildFailure\n\t\t| IdAlreadyInUseFailure\n\t\t| UnknownIdFailure\n\t\t| BadPlaceFailure\n\t\t| BadRangeFailure\n\t\t| ConstraintViolationFailure;\n\n\t/**\n\t * Error returned when a transaction is closed while there is an unused detached sequence.\n\t */\n\texport interface UnusedDetachedSequenceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnusedDetachedSequence)\n\t\t */\n\t\treadonly kind: FailureKind.UnusedDetachedSequence;\n\t\t/**\n\t\t * The unused DetachedSequenceId\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.\n\t */\n\texport interface DetachedSequenceIdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceIdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceIdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that is already in use\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID\n\t */\n\texport interface DetachedSequenceNotFoundFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceNotFound)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceNotFound;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that wasn't found\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a build uses a duplicated NodeId\n\t */\n\texport interface DuplicateIdInBuildFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DuplicateIdInBuild)\n\t\t */\n\t\treadonly kind: FailureKind.DuplicateIdInBuild;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of duplicated node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a build node ID is already used in the current state\n\t */\n\texport interface IdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.IdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.IdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of already in use node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a change is attempted on an unknown NodeId\n\t */\n\texport interface UnknownIdFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnknownId)\n\t\t */\n\t\treadonly kind: FailureKind.UnknownId;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The unknown ID\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when an insert change uses an invalid Place\n\t */\n\texport interface BadPlaceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadPlace)\n\t\t */\n\t\treadonly kind: FailureKind.BadPlace;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The faulting place\n\t\t */\n\t\treadonly place: StablePlaceInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly placeFailure: BadPlaceValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a detach operation is given an invalid or malformed Range\n\t */\n\texport interface BadRangeFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadRange)\n\t\t */\n\t\treadonly kind: FailureKind.BadRange;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * Faulting range\n\t\t */\n\t\treadonly range: StableRangeInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly rangeFailure: BadRangeValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a constraint fails to apply\n\t */\n\texport interface ConstraintViolationFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.ConstraintViolation)\n\t\t */\n\t\treadonly kind: FailureKind.ConstraintViolation;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly constraint: ConstraintInternal;\n\t\t/**\n\t\t * The first violation the constraint encounters (there may be others).\n\t\t */\n\t\treadonly violation: ConstraintViolationResult;\n\t}\n\n\t/**\n\t * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur\n\t */\n\texport type ConstraintViolationResult =\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadRange;\n\t\t\t\treadonly rangeFailure: BadRangeValidationResult;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLength;\n\t\t\t\treadonly actual: number;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadParent;\n\t\t\t\treadonly actual: NodeId;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLabel;\n\t\t\t\treadonly actual: TraitLabel;\n\t\t };\n\n\t/**\n\t * Enum of possible kinds of constraint violations that can be encountered\n\t */\n\texport enum ConstraintViolationKind {\n\t\t/**\n\t\t * The constraint failed because it applies to an invalid range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * The constraint failed because the length prescribed by the constraint does not match the length of range being constrained\n\t\t */\n\t\tBadLength = 'BadLength',\n\t\t/**\n\t\t * The constraint failed because the parent prescribed by the constraint does not match the actual parent of the range being constrained\n\t\t */\n\t\tBadParent = 'BadParent',\n\t\t/**\n\t\t * The constraint failed because the trait label prescribed by the constraint does not match the actual trait label of the range being constrained\n\t\t */\n\t\tBadLabel = 'BadLabel',\n\t}\n}\n"]}
1
+ {"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAG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CAAC;gBAChC,OAAO,SAAS,CAAC;aACjB;YACD,uHAAuH;YACvH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACjC,OAAO,eAAe,CAAC;QACxB,CAAC;KACD;IAhYY,0BAAM,SAgYlB,CAAA;IAED;;OAEG;IACH,IAAY,WAqCX;IArCD,WAAY,WAAW;QACtB;;WAEG;QACH,gEAAiD,CAAA;QACjD;;WAEG;QACH,gFAAiE,CAAA;QACjE;;WAEG;QACH,oEAAqD,CAAA;QACrD;;WAEG;QACH,wDAAyC,CAAA;QACzC;;WAEG;QACH,gDAAiC,CAAA;QACjC;;WAEG;QACH,sCAAuB,CAAA;QACvB;;WAEG;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,0DAA2C,CAAA;IAC5C,CAAC,EArCW,WAAW,GAAX,+BAAW,KAAX,+BAAW,QAqCtB;IA2MD;;OAEG;IACH,IAAY,uBAiBX;IAjBD,WAAY,uBAAuB;QAClC;;WAEG;QACH,gDAAqB,CAAA;QACrB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,gDAAqB,CAAA;IACtB,CAAC,EAjBW,uBAAuB,GAAvB,2CAAuB,KAAvB,2CAAuB,QAiBlC;AACF,CAAC,EAvpBgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAupBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail, Result } from './Common';\nimport { NodeId, DetachedSequenceId, TraitLabel, isDetachedSequenceId } from './Identifiers';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintEffect,\n\tConstraintInternal,\n\tDetachInternal,\n\tEditStatus,\n\tInsertInternal,\n\tSetValueInternal,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n} from './persisted-types';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tBadPlaceValidationResult,\n\tBadRangeValidationResult,\n\tPlaceValidationResult,\n\tRangeValidationResultKind,\n} from './EditUtilities';\nimport { RevisionView, TransactionView } from './RevisionView';\nimport { ReconciliationChange, ReconciliationPath } from './ReconciliationPath';\nimport { TreeViewNode } from './TreeView';\n\n/**\n * Result of applying a transaction.\n * @public\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @public\n */\nexport interface EditingResultBase {\n\t/**\n\t * The final status of the transaction.\n\t */\n\treadonly status: EditStatus;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n\t/**\n\t * The revision preceding the transaction.\n\t */\n\treadonly before: RevisionView;\n}\n\n/**\n * Result of applying an invalid or malformed transaction.\n * @public\n */\nexport interface FailedEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * Result of applying a valid transaction.\n * @public\n */\nexport interface ValidEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The new revision produced by the transaction.\n\t */\n\treadonly after: RevisionView;\n}\n\n/**\n * The result of applying a change within a transaction.\n * @public\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @public\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n */\nexport interface SucceedingTransactionState {\n\t/**\n\t * The current status of the transaction.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The state of a transaction that has encountered an error.\n */\nexport interface FailingTransactionState extends TransactionFailure {\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The failure state of a transaction.\n */\nexport interface TransactionFailure {\n\t/**\n\t * The status indicating the kind of failure encountered.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class GenericTransaction {\n\tprivate readonly policy: GenericTransactionPolicy;\n\tprotected readonly before: RevisionView;\n\tprivate state: TransactionState;\n\tprivate open = true;\n\n\t/**\n\t * Create and open an edit of the provided `TreeView`. After applying 0 or more changes, this editor should be closed via `close()`.\n\t * @param view - the `TreeView` at which this edit begins. The first change will be applied against this view.\n\t */\n\tpublic constructor(view: RevisionView, policy: GenericTransactionPolicy) {\n\t\tthis.before = view;\n\t\tthis.policy = policy;\n\t\tthis.state = {\n\t\t\tview: view.openForTransaction(),\n\t\t\tstatus: EditStatus.Applied,\n\t\t\tchanges: [],\n\t\t\tsteps: [],\n\t\t};\n\t}\n\n\t/** Whether or not this transaction has been closed via `close()` */\n\tpublic get isOpen(): boolean {\n\t\treturn this.open;\n\t}\n\n\t/**\n\t * The most up-to-date `TreeView` for this edit. This is the state of the tree after all changes applied so far.\n\t */\n\tpublic get view(): TransactionView {\n\t\treturn this.state.view;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get status(): EditStatus {\n\t\treturn this.state.status;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get changes(): readonly ChangeInternal[] {\n\t\treturn this.state.changes;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get steps(): readonly ReconciliationChange[] {\n\t\treturn this.state.steps;\n\t}\n\n\t/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */\n\tpublic close(): EditingResult {\n\t\tassert(this.open, 'transaction has already been closed');\n\t\tthis.open = false;\n\t\tif (this.state.status === EditStatus.Applied) {\n\t\t\tconst validation = this.policy.validateOnClose(this.state);\n\t\t\tif (Result.isOk(validation)) {\n\t\t\t\tif (validation.result !== this.view) {\n\t\t\t\t\tthis.state = { ...this.state, view: validation.result };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tsteps: this.steps,\n\t\t\t\t\tchanges: this.changes,\n\t\t\t\t\tbefore: this.before,\n\t\t\t\t\tafter: this.view.close(),\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.state = { ...this.state, ...validation.error };\n\t\t\treturn {\n\t\t\t\t...validation.error,\n\t\t\t\tsteps: this.steps,\n\t\t\t\tchanges: this.changes,\n\t\t\t\tbefore: this.before,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: this.state.status,\n\t\t\tfailure: this.state.failure,\n\t\t\tsteps: this.steps,\n\t\t\tchanges: this.changes,\n\t\t\tbefore: this.before,\n\t\t};\n\t}\n\n\t/**\n\t * A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply,\n\t * the remaining changes in `changes` will be ignored.\n\t * @param changes - the sequence of changes to apply.\n\t * @param path - the reconciliation path for the first change.\n\t * @returns this\n\t */\n\tpublic applyChanges(changes: Iterable<ChangeInternal>, path: ReconciliationPath = []): this {\n\t\tconst iter = changes[Symbol.iterator]();\n\t\tconst firsChangeInternal = iter.next().value;\n\t\tlet iterResult = iter.next();\n\t\tif (iterResult.done === true) {\n\t\t\tfor (const change of changes) {\n\t\t\t\tif (this.applyChange(change, path).status !== EditStatus.Applied) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tif (this.applyChange(firsChangeInternal, path).status !== EditStatus.Applied) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst ongoingEdit = {\n\t\t\t0: this.steps[this.steps.length - 1],\n\t\t\tbefore: this.view,\n\t\t\tafter: this.view,\n\t\t\tlength: 1,\n\t\t};\n\n\t\t/**\n\t\t * We use a Proxy instead of `{ ...path, ...objectWithOngoingEdit }` to avoid eagerly demanding all parts of the path, which may\n\t\t * require extensive computation.\n\t\t */\n\t\tconst pathWithOngoingEdit = new Proxy(path, {\n\t\t\tget: (target: ReconciliationPath, prop: string): ReconciliationPath[number | 'length'] => {\n\t\t\t\tif (prop === 'length') {\n\t\t\t\t\treturn target.length + 1;\n\t\t\t\t}\n\t\t\t\treturn prop === String(target.length) ? ongoingEdit : target[prop];\n\t\t\t},\n\t\t});\n\n\t\twhile (iterResult.done !== true) {\n\t\t\tif (this.applyChange(iterResult.value, pathWithOngoingEdit).status !== EditStatus.Applied) {\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tongoingEdit[ongoingEdit.length] = this.steps[this.steps.length - 1];\n\t\t\tongoingEdit.length += 1;\n\t\t\tongoingEdit.after = this.view;\n\t\t\titerResult = iter.next();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to\n\t * apply.\n\t * @param change - the change to apply\n\t * @param path - the reconciliation path for the change.\n\t * @returns this\n\t */\n\tpublic applyChange(change: ChangeInternal, path: ReconciliationPath = []): this {\n\t\tassert(this.open, 'Editor must be open to apply changes.');\n\t\tif (this.state.status !== EditStatus.Applied) {\n\t\t\tfail('Cannot apply change to an edit unless all previous changes have applied');\n\t\t}\n\t\tconst resolutionResult = this.policy.tryResolveChange(this.state, change, path);\n\t\tif (Result.isError(resolutionResult)) {\n\t\t\tthis.state = { ...this.state, ...resolutionResult.error };\n\t\t\treturn this;\n\t\t}\n\t\tconst resolvedChange = resolutionResult.result;\n\t\tconst changeResult = this.policy.dispatchChange(this.state, resolvedChange);\n\t\tif (Result.isOk(changeResult)) {\n\t\t\tthis.state = {\n\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\tview: changeResult.result,\n\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t};\n\t\t} else {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\t...changeResult.error,\n\t\t\t};\n\t\t}\n\t\treturn this;\n\t}\n}\n\n/**\n * An object that encapsulates the rules and state pertaining to a specific subclass of {@link GenericTransaction}.\n * The characteristics that define such a subclass (and an implementation of this interface) are:\n * - The type of change that can be applied\n * - How those changes impact the state of the tree\n * - How those changes are resolved in the face of concurrent changes\n * - What makes a transaction valid\n * - The kind of situations that might lead to a transaction failure\n *\n * Instances of this type are passed to the {@link GenericTransaction} constructor.\n */\nexport interface GenericTransactionPolicy {\n\t/**\n\t * Given a change, attempts to derive an equivalent change which can be applied to the current state even if the given change was issued\n\t * over a different state. This can be used to apply a sequence of changes that were issued concurrently, i.e., without knowledge of\n\t * each other.\n\t * @param state - The current state on which the returned change will be applied.\n\t * @param change - The original change issued.\n\t * @param path - The reconciliation path for the change.\n\t * @returns The change to be applied to the current state, or a failure if the change cannot be resolved.\n\t */\n\ttryResolveChange(\n\t\tstate: SucceedingTransactionState,\n\t\tchange: ChangeInternal,\n\t\tpath: ReconciliationPath\n\t): Result<ChangeInternal, TransactionFailure>;\n\n\t/**\n\t * Provides a new state given the current state and a change to apply.\n\t * @param state - The current state on which the change is applied.\n\t * @param change - The change to apply to the current state.\n\t * @returns The new state reflecting the applied change, or a failure.\n\t */\n\tdispatchChange(state: SucceedingTransactionState, change: ChangeInternal): ChangeResult;\n\n\t/**\n\t * Additional transaction validation when the transaction is closed.\n\t * @param state - The current state of the transaction.\n\t * @returns The new state reflecting the closed transaction, or a failure if the transaction cannot be closed.\n\t */\n\tvalidateOnClose(state: SucceedingTransactionState): ChangeResult;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n * @public\n */\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t */\n\texport function factory(view: RevisionView): GenericTransaction {\n\t\treturn new GenericTransaction(view, new Policy());\n\t}\n\n\ttype ValidState = SucceedingTransactionState;\n\n\t/**\n\t * The policy followed by a {@link TransactionInternal}.\n\t */\n\texport class Policy implements GenericTransactionPolicy {\n\t\t/**\n\t\t * Maps detached sequences of nodes to their NodeIds\n\t\t */\n\t\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\t\t/**\n\t\t * Resolves change with Result.Ok\n\t\t *\n\t\t * @param state - Unused\n\t\t * @param change - Change to resolve\n\t\t * @returns Result.Ok which contains change\n\t\t */\n\t\tpublic tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal> {\n\t\t\treturn Result.ok(change);\n\t\t}\n\n\t\t/**\n\t\t * Validates the transaction when it is closed\n\t\t *\n\t\t * @param state - Current state\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic validateOnClose(state: ValidState): ChangeResult {\n\t\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\t\treturn this.detached.size !== 0\n\t\t\t\t? Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.UnusedDetachedSequence,\n\t\t\t\t\t\t\tsequenceId: this.detached.keys().next().value,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: Result.ok(state.view);\n\t\t}\n\n\t\t/**\n\t\t * Applies a given change\n\t\t *\n\t\t * @param state - Current state\n\t\t * @param change - Change to apply\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult {\n\t\t\tswitch (change.type) {\n\t\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\t\treturn this.applyBuild(state, change);\n\t\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\t\treturn this.applyInsert(state, change);\n\t\t\t\tcase ChangeTypeInternal.Detach:\n\t\t\t\t\treturn this.applyDetach(state, change);\n\t\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t\treturn this.applyConstraint(state, change);\n\t\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\t\treturn this.applySetValue(state, change);\n\t\t\t\tdefault:\n\t\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t\t}\n\t\t}\n\n\t\tprivate applyBuild(state: ValidState, change: BuildInternal): ChangeResult {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet idAlreadyPresent: NodeId | undefined;\n\t\t\tlet duplicateIdInBuild: NodeId | undefined;\n\t\t\tlet invalidId: NodeId | undefined;\n\t\t\tlet detachedSequenceNotFound: DetachedSequenceId | undefined;\n\t\t\tconst map = new Map<NodeId, TreeViewNode>();\n\t\t\tconst newIds = this.createViewNodesForTree(\n\t\t\t\tchange.source,\n\t\t\t\t(id, viewNode) => {\n\t\t\t\t\tif (map.has(id)) {\n\t\t\t\t\t\tduplicateIdInBuild = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.view.hasNode(viewNode.identifier)) {\n\t\t\t\t\t\tidAlreadyPresent = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tmap.set(id, viewNode);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\t(detachedId) => {\n\t\t\t\t\tdetachedSequenceNotFound = detachedId;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (idAlreadyPresent !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.IdAlreadyInUse, change, id: idAlreadyPresent },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (duplicateIdInBuild !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: { kind: FailureKind.DuplicateIdInBuild, change, id: duplicateIdInBuild },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (invalidId !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: invalidId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (detachedSequenceNotFound !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: detachedSequenceNotFound,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst view = state.view.addNodes(map.values());\n\t\t\tthis.detached.set(\n\t\t\t\tchange.destination,\n\t\t\t\tnewIds ?? fail('Unhandled failure case in Transaction.createViewNodesForTree')\n\t\t\t);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyInsert(state: ValidState, change: InsertInternal): ChangeResult {\n\t\t\tconst source = this.detached.get(change.source);\n\t\t\tif (source === undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.source,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst validatedDestination = validateStablePlace(state.view, change.destination);\n\t\t\tif (validatedDestination.result !== PlaceValidationResult.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedDestination.result === PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Malformed\n\t\t\t\t\t\t\t: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadPlace,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tplace: change.destination,\n\t\t\t\t\t\tplaceFailure: validatedDestination.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.detached.delete(change.source);\n\t\t\tconst view = insertIntoTrait(state.view, source, validatedDestination);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyDetach(state: ValidState, change: DetachInternal): ChangeResult {\n\t\t\tconst validatedSource = validateStableRange(state.view, change.source);\n\t\t\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.PlacesInDifferentTraits ||\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.Inverted ||\n\t\t\t\t\t\tvalidatedSource.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Invalid\n\t\t\t\t\t\t\t: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadRange,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\trange: change.source,\n\t\t\t\t\t\trangeFailure: validatedSource.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = detachRange(state.view, validatedSource);\n\t\t\tlet modifiedView = result.view;\n\t\t\tconst { detached } = result;\n\n\t\t\t// Store or dispose detached\n\t\t\tif (change.destination !== undefined) {\n\t\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\t\treturn Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\t\tchange,\n\t\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.detached.set(change.destination, detached);\n\t\t\t} else {\n\t\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t\t}\n\t\t\treturn Result.ok(modifiedView);\n\t\t}\n\n\t\tprivate applyConstraint(state: ValidState, change: ConstraintInternal): ChangeResult {\n\t\t\t// TODO: Implement identityHash and contentHash\n\t\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\t\tconst validatedChange = validateStableRange(state.view, change.toConstrain);\n\t\t\tif (validatedChange.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn validatedChange.result !== RangeValidationResultKind.PlacesInDifferentTraits &&\n\t\t\t\t\tvalidatedChange.result !== RangeValidationResultKind.Inverted &&\n\t\t\t\t\tvalidatedChange.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t? change.effect === ConstraintEffect.ValidRetry\n\t\t\t\t\t\t? Result.ok(state.view)\n\t\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t })\n\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t });\n\t\t\t}\n\n\t\t\tconst { start, end } = rangeFromStableRange(state.view, validatedChange);\n\t\t\tconst startIndex = state.view.findIndexWithinTrait(start);\n\t\t\tconst endIndex = state.view.findIndexWithinTrait(end);\n\n\t\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLength,\n\t\t\t\t\t\t\tactual: endIndex - startIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadParent,\n\t\t\t\t\t\t\tactual: change.parentNode,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLabel,\n\t\t\t\t\t\t\tactual: end.trait.label,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn Result.ok(state.view);\n\t\t}\n\n\t\tprivate applySetValue(state: ValidState, change: SetValueInternal): ChangeResult {\n\t\t\tif (!state.view.hasNode(change.nodeToModify)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: change.nodeToModify },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newView = state.view.setNodeValue(change.nodeToModify, change.payload);\n\t\t\treturn Result.ok(newView);\n\t\t}\n\n\t\t/**\n\t\t * Generates tree view nodes from the supplied edit nodes.\n\t\t * Invokes onCreateNode for each new node, and halts creation early if it returns true.\n\t\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t\t */\n\t\tprotected createViewNodesForTree(\n\t\t\tsequence: Iterable<BuildNodeInternal>,\n\t\t\tonCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): NodeId[] | undefined {\n\t\t\tconst topLevelIds: NodeId[] = [];\n\t\t\tconst unprocessed: BuildNodeInternal[] = [];\n\t\t\tfor (const buildNode of sequence) {\n\t\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t\t} else {\n\t\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (unprocessed.length > 0) {\n\t\t\t\tconst node = unprocessed.pop();\n\t\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tfor (const key in node.traits) {\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst newNode: TreeViewNode = {\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\ttraits,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\t\tif (onCreateNode(node.identifier, newNode)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn topLevelIds;\n\t\t}\n\n\t\tprivate getDetachedNodeIds(\n\t\t\tdetachedId: DetachedSequenceId,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): readonly NodeId[] | undefined {\n\t\t\t// Retrieve the detached sequence from the void.\n\t\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\t\tif (detachedNodeIds === undefined) {\n\t\t\t\tonInvalidDetachedId(detachedId);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\t\tthis.detached.delete(detachedId);\n\t\t\treturn detachedNodeIds;\n\t\t}\n\t}\n\n\t/**\n\t * The kinds of failures that a transaction might encounter.\n\t */\n\texport enum FailureKind {\n\t\t/**\n\t\t * Transaction has an unused DetachedSequenceId\n\t\t */\n\t\tUnusedDetachedSequence = 'UnusedDetachedSequence',\n\t\t/**\n\t\t * Transaction has a build operation using an already in use DetachedSequenceID.\n\t\t */\n\t\tDetachedSequenceIdAlreadyInUse = 'DetachedSequenceIdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to operate on an unknown DetachedSequenceID\n\t\t */\n\t\tDetachedSequenceNotFound = 'DetachedSequenceNotFound',\n\t\t/**\n\t\t * Transaction has a build which uses a duplicated NodeId\n\t\t */\n\t\tDuplicateIdInBuild = 'DuplicateIdInBuild',\n\t\t/**\n\t\t * Transaction tries to build a node using an ID which is already used in the current state\n\t\t */\n\t\tIdAlreadyInUse = 'IdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to set value of an unknown node\n\t\t */\n\t\tUnknownId = 'UnknownId',\n\t\t/**\n\t\t * Transaction tries to insert in an invalid Place\n\t\t */\n\t\tBadPlace = 'BadPlace',\n\t\t/**\n\t\t * Transaction tries to detach an invalid Range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * Transaction has an invalid constraint\n\t\t */\n\t\tConstraintViolation = 'ConstraintViolation',\n\t}\n\n\t/**\n\t * A failure encountered by a transaction.\n\t */\n\texport type Failure =\n\t\t| UnusedDetachedSequenceFailure\n\t\t| DetachedSequenceIdAlreadyInUseFailure\n\t\t| DetachedSequenceNotFoundFailure\n\t\t| DuplicateIdInBuildFailure\n\t\t| IdAlreadyInUseFailure\n\t\t| UnknownIdFailure\n\t\t| BadPlaceFailure\n\t\t| BadRangeFailure\n\t\t| ConstraintViolationFailure;\n\n\t/**\n\t * Error returned when a transaction is closed while there is an unused detached sequence.\n\t */\n\texport interface UnusedDetachedSequenceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnusedDetachedSequence)\n\t\t */\n\t\treadonly kind: FailureKind.UnusedDetachedSequence;\n\t\t/**\n\t\t * The unused DetachedSequenceId\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.\n\t */\n\texport interface DetachedSequenceIdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceIdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceIdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that is already in use\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID\n\t */\n\texport interface DetachedSequenceNotFoundFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceNotFound)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceNotFound;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that wasn't found\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a build uses a duplicated NodeId\n\t */\n\texport interface DuplicateIdInBuildFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DuplicateIdInBuild)\n\t\t */\n\t\treadonly kind: FailureKind.DuplicateIdInBuild;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of duplicated node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a build node ID is already used in the current state\n\t */\n\texport interface IdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.IdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.IdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of already in use node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a change is attempted on an unknown NodeId\n\t */\n\texport interface UnknownIdFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnknownId)\n\t\t */\n\t\treadonly kind: FailureKind.UnknownId;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The unknown ID\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when an insert change uses an invalid Place\n\t */\n\texport interface BadPlaceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadPlace)\n\t\t */\n\t\treadonly kind: FailureKind.BadPlace;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The faulting place\n\t\t */\n\t\treadonly place: StablePlaceInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly placeFailure: BadPlaceValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a detach operation is given an invalid or malformed Range\n\t */\n\texport interface BadRangeFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadRange)\n\t\t */\n\t\treadonly kind: FailureKind.BadRange;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * Faulting range\n\t\t */\n\t\treadonly range: StableRangeInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly rangeFailure: BadRangeValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a constraint fails to apply\n\t */\n\texport interface ConstraintViolationFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.ConstraintViolation)\n\t\t */\n\t\treadonly kind: FailureKind.ConstraintViolation;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly constraint: ConstraintInternal;\n\t\t/**\n\t\t * The first violation the constraint encounters (there may be others).\n\t\t */\n\t\treadonly violation: ConstraintViolationResult;\n\t}\n\n\t/**\n\t * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur\n\t */\n\texport type ConstraintViolationResult =\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadRange;\n\t\t\t\treadonly rangeFailure: BadRangeValidationResult;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLength;\n\t\t\t\treadonly actual: number;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadParent;\n\t\t\t\treadonly actual: NodeId;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLabel;\n\t\t\t\treadonly actual: TraitLabel;\n\t\t };\n\n\t/**\n\t * Enum of possible kinds of constraint violations that can be encountered\n\t */\n\texport enum ConstraintViolationKind {\n\t\t/**\n\t\t * The constraint failed because it applies to an invalid range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * The constraint failed because the length prescribed by the constraint does not match the length of range being constrained\n\t\t */\n\t\tBadLength = 'BadLength',\n\t\t/**\n\t\t * The constraint failed because the parent prescribed by the constraint does not match the actual parent of the range being constrained\n\t\t */\n\t\tBadParent = 'BadParent',\n\t\t/**\n\t\t * The constraint failed because the trait label prescribed by the constraint does not match the actual trait label of the range being constrained\n\t\t */\n\t\tBadLabel = 'BadLabel',\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeCompressor.d.ts","sourceRoot":"","sources":["../src/TreeCompressor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,kBAAkB,EAAoB,aAAa,EAAc,MAAM,eAAe,CAAC;AACjH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,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AO,CAAC,UAAU,CAAC,CAAgB;IAE5B,UAAU,CAAC,GAAG,SAAS,aAAa,EAC1C,IAAI,EAAE,yBAAyB,CAAC,GAAG,EAAE,YAAY,CAAC,EAClD,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,8BAA8B,CAAC,GAAG,CAAC,GAC/C,eAAe,CAAC,YAAY,CAAC;IAUhC,OAAO,CAAC,WAAW;CAmFnB"}
@@ -20,7 +20,7 @@ class InterningTreeCompressor {
20
20
  }
21
21
  compressI(node, interner, idNormalizer) {
22
22
  var _a, _b;
23
- if (Identifiers_1.isDetachedSequenceId(node)) {
23
+ if ((0, Identifiers_1.isDetachedSequenceId)(node)) {
24
24
  return node;
25
25
  }
26
26
  const internedDefinition = (_a = interner.getInternedId(node.definition)) !== null && _a !== void 0 ? _a : node.definition;
@@ -48,17 +48,17 @@ class InterningTreeCompressor {
48
48
  return [internedDefinition];
49
49
  }
50
50
  decompress(node, interner, idNormalizer) {
51
- if (Identifiers_1.isDetachedSequenceId(node)) {
51
+ if ((0, Identifiers_1.isDetachedSequenceId)(node)) {
52
52
  return node;
53
53
  }
54
54
  const rootId = node[1];
55
- Common_1.assert(typeof rootId === 'number', 'Root node was compressed with no ID');
55
+ (0, Common_1.assert)(typeof rootId === 'number', 'Root node was compressed with no ID');
56
56
  this.previousId = rootId;
57
57
  return this.decompressI(node, interner, idNormalizer);
58
58
  }
59
59
  decompressI(node, interner, idNormalizer) {
60
60
  var _a;
61
- if (Identifiers_1.isDetachedSequenceId(node)) {
61
+ if ((0, Identifiers_1.isDetachedSequenceId)(node)) {
62
62
  return node;
63
63
  }
64
64
  let compressedId;
@@ -73,20 +73,18 @@ class InterningTreeCompressor {
73
73
  }
74
74
  }
75
75
  else {
76
- // TODO: This cast can be removed on typescript 4.6
77
76
  compressedTraits = idOrPayloadTraits;
78
77
  }
79
78
  }
80
79
  const definition = typeof maybeInternedDefinition === 'string'
81
80
  ? maybeInternedDefinition
82
- : // TODO: This cast can be removed on typescript 4.6
83
- interner.getString(maybeInternedDefinition);
81
+ : interner.getString(maybeInternedDefinition);
84
82
  let identifier;
85
83
  if (compressedId !== undefined) {
86
84
  identifier = compressedId;
87
85
  }
88
86
  else {
89
- const prevId = (_a = this.previousId) !== null && _a !== void 0 ? _a : Common_1.fail();
87
+ const prevId = (_a = this.previousId) !== null && _a !== void 0 ? _a : (0, Common_1.fail)();
90
88
  identifier = prevId < 0 ? (prevId - 1) : (prevId + 1);
91
89
  }
92
90
  this.previousId = identifier;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeCompressor.js","sourceRoot":"","sources":["../src/TreeCompressor.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+CAAqD;AAKrD,qCAAiD;AA6BjD;;;;;GAKG;AACH,MAAa,uBAAuB;IAG5B,QAAQ,CACd,IAAmC,EACnC,QAAwB,EACxB,YAAiD;QAEjD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAEO,SAAS,CAChB,IAAmC,EACnC,QAAwB,EACxB,YAAiD;;QAEjD,IAAI,kCAAoB,CAAC,IAAI,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACZ;QAED,MAAM,kBAAkB,SAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,IAAI,CAAC,UAAU,CAAC;QACtF,MAAM,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;QAC1F,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,MAAM,gBAAgB,GAAwC,EAAE,CAAC;QAEjE,iDAAiD;QACjD,MAAM,MA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JC;AAED,SAAS,UAAU,CAA4B,UAA2B,EAAE,EAAO;IAClF,IAAI,UAAU,KAAK,SAAS,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,MAAM,SAAS,GAAW,UAAU,CAAC;IACrC,IAAI,SAAS,GAAG,CAAC,EAAE;QAClB,OAAO,EAAE,KAAK,SAAS,GAAG,CAAC,CAAC;KAC5B;IAED,OAAO,EAAE,KAAK,SAAS,GAAG,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { isDetachedSequenceId } from './Identifiers';\nimport type { Definition, DetachedSequenceId, InternedStringId, OpSpaceNodeId, TraitLabel } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport type { CompressedTraits, CompressedPlaceholderTree, PlaceholderTree, Payload } from './persisted-types';\nimport type { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { assert, fail, Mutable } from './Common';\n\n/**\n * Compresses a given {@link PlaceholderTree} into a more compact serializable format.\n */\nexport interface TreeCompressor<TPlaceholder extends DetachedSequenceId | never> {\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tcompress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder>;\n\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tdecompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder>;\n}\n\n/**\n * Compresses a given {@link PlaceholderTree}\n * (Such as a {@link ChangeNode} or {@link BuildNode}) into an array,\n * while also string interning all node {@link Definition}s and {@link TraitLabel}s.\n * See {@link CompressedPlaceholderTree} for format.\n */\nexport class InterningTreeCompressor<TPlaceholder extends DetachedSequenceId | never>\n\timplements TreeCompressor<TPlaceholder>\n{\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tthis.previousId = undefined;\n\t\treturn this.compressI(node, interner, idNormalizer);\n\t}\n\n\tprivate compressI<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst internedDefinition = interner.getInternedId(node.definition) ?? node.definition;\n\t\tconst normalizedId = idNormalizer.normalizeToOpSpace(node.identifier);\n\t\tconst compressedId = canElideId(this.previousId, normalizedId) ? undefined : normalizedId;\n\t\tthis.previousId = normalizedId;\n\t\tconst compressedTraits: CompressedTraits<TId, TPlaceholder> = [];\n\n\t\t// Omit traits if empty and payload is undefined.\n\t\tconst traits = Object.entries(node.traits).sort();\n\t\tif (traits.length > 0 || node.payload !== undefined) {\n\t\t\tfor (const [label, trait] of traits) {\n\t\t\t\tcompressedTraits.push(\n\t\t\t\t\tinterner.getInternedId(label) ?? (label as TraitLabel),\n\t\t\t\t\ttrait.map((child) => this.compressI(child, interner, idNormalizer))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst payloadTraits = node.payload !== undefined ? [node.payload, ...compressedTraits] : compressedTraits;\n\t\tif (payloadTraits.length > 0) {\n\t\t\tif (compressedId !== undefined) {\n\t\t\t\treturn [internedDefinition, compressedId, payloadTraits];\n\t\t\t}\n\t\t\treturn [internedDefinition, payloadTraits];\n\t\t}\n\n\t\tif (compressedId !== undefined) {\n\t\t\treturn [internedDefinition, compressedId];\n\t\t}\n\n\t\treturn [internedDefinition];\n\t}\n\n\t/** The ID that was compressed or decompressed most recently */\n\tprivate previousId?: OpSpaceNodeId;\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\t\tconst rootId = node[1];\n\t\tassert(typeof rootId === 'number', 'Root node was compressed with no ID');\n\t\tthis.previousId = rootId;\n\t\treturn this.decompressI(node, interner, idNormalizer);\n\t}\n\n\tprivate decompressI<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tlet compressedId: TId | undefined;\n\t\tlet compressedTraits:\n\t\t\t| [Payload, ...CompressedTraits<TId, TPlaceholder>]\n\t\t\t| CompressedTraits<TId, TPlaceholder>\n\t\t\t| undefined;\n\t\tlet payload: Payload | undefined;\n\t\tconst [maybeInternedDefinition, idOrPayloadTraits, payloadTraits] = node;\n\t\tif (idOrPayloadTraits !== undefined) {\n\t\t\tif (typeof idOrPayloadTraits === 'number') {\n\t\t\t\tcompressedId = idOrPayloadTraits;\n\t\t\t\tif (payloadTraits !== undefined) {\n\t\t\t\t\tcompressedTraits = payloadTraits;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// TODO: This cast can be removed on typescript 4.6\n\t\t\t\tcompressedTraits = idOrPayloadTraits as typeof compressedTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst definition =\n\t\t\ttypeof maybeInternedDefinition === 'string'\n\t\t\t\t? maybeInternedDefinition\n\t\t\t\t: // TODO: This cast can be removed on typescript 4.6\n\t\t\t\t (interner.getString(maybeInternedDefinition as number) as Definition);\n\n\t\tlet identifier: TId;\n\t\tif (compressedId !== undefined) {\n\t\t\tidentifier = compressedId;\n\t\t} else {\n\t\t\tconst prevId = this.previousId ?? fail();\n\t\t\tidentifier = prevId < 0 ? ((prevId - 1) as TId) : (((prevId as number) + 1) as TId);\n\t\t}\n\t\tthis.previousId = identifier;\n\n\t\tconst traits = {};\n\t\tif (compressedTraits !== undefined) {\n\t\t\tlet offset: number;\n\t\t\tif (compressedTraits.length % 2 === 1) {\n\t\t\t\toffset = 1;\n\t\t\t\tpayload = compressedTraits[0];\n\t\t\t} else {\n\t\t\t\toffset = 0;\n\t\t\t}\n\t\t\tconst traitsLength = compressedTraits.length - offset;\n\t\t\tfor (let i = 0; i < traitsLength; i += 2) {\n\t\t\t\tconst offsetIndex = i + offset;\n\t\t\t\tconst maybeCompressedLabel = compressedTraits[offsetIndex] as InternedStringId;\n\t\t\t\tconst compressedChildren = compressedTraits[offsetIndex + 1] as (\n\t\t\t\t\t| TPlaceholder\n\t\t\t\t\t| CompressedPlaceholderTree<TId, TPlaceholder>\n\t\t\t\t)[];\n\n\t\t\t\tconst decompressedTraits = compressedChildren.map((child) =>\n\t\t\t\t\tthis.decompressI(child, interner, idNormalizer)\n\t\t\t\t);\n\n\t\t\t\tconst label =\n\t\t\t\t\ttypeof maybeCompressedLabel === 'string'\n\t\t\t\t\t\t? maybeCompressedLabel\n\t\t\t\t\t\t: (interner.getString(maybeCompressedLabel) as TraitLabel);\n\t\t\t\ttraits[label] = decompressedTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst decompressedNode: Mutable<PlaceholderTree<TPlaceholder>> = {\n\t\t\tidentifier: idNormalizer.normalizeToSessionSpace(identifier),\n\t\t\tdefinition,\n\t\t\ttraits,\n\t\t};\n\n\t\tif (payload !== undefined) {\n\t\t\tdecompressedNode.payload = payload;\n\t\t}\n\n\t\treturn decompressedNode;\n\t}\n}\n\nfunction canElideId<TId extends OpSpaceNodeId>(previousId: TId | undefined, id: TId): boolean {\n\tif (previousId === undefined) {\n\t\treturn false;\n\t}\n\n\tconst numericId: number = previousId;\n\tif (numericId < 0) {\n\t\treturn id === numericId - 1;\n\t}\n\n\treturn id === numericId + 1;\n}\n"]}
1
+ {"version":3,"file":"TreeCompressor.js","sourceRoot":"","sources":["../src/TreeCompressor.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+CAAqD;AAKrD,qCAAiD;AA6BjD;;;;;GAKG;AACH,MAAa,uBAAuB;IAG5B,QAAQ,CACd,IAAmC,EACnC,QAAwB,EACxB,YAAiD;QAEjD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAEO,SAAS,CAChB,IAAmC,EACnC,QAAwB,EACxB,YAAiD;;QAEjD,IAAI,IAAA,kCAAoB,EAAC,IAAI,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACZ;QAED,MAAM,kBAAkB,GAAG,MAAA,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,IAAI,CAAC,UAAU,CAAC;QACtF,MAAM,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;QAC1F,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,MAAM,gBAAgB,GAAwC,EAAE,CAAC;QAEjE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IACzB,CAAC;CACD;AAzJD,0DAyJC;AAED,SAAS,UAAU,CAA4B,UAA2B,EAAE,EAAO;IAClF,IAAI,UAAU,KAAK,SAAS,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,MAAM,SAAS,GAAW,UAAU,CAAC;IACrC,IAAI,SAAS,GAAG,CAAC,EAAE;QAClB,OAAO,EAAE,KAAK,SAAS,GAAG,CAAC,CAAC;KAC5B;IAED,OAAO,EAAE,KAAK,SAAS,GAAG,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { isDetachedSequenceId } from './Identifiers';\nimport type { Definition, DetachedSequenceId, InternedStringId, OpSpaceNodeId, TraitLabel } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport type { CompressedTraits, CompressedPlaceholderTree, PlaceholderTree, Payload } from './persisted-types';\nimport type { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { assert, fail, Mutable } from './Common';\n\n/**\n * Compresses a given {@link PlaceholderTree} into a more compact serializable format.\n */\nexport interface TreeCompressor<TPlaceholder extends DetachedSequenceId | never> {\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tcompress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder>;\n\n\t/**\n\t * @param node - The {@link PlaceholderTree} to compress.\n\t * @param interner - The StringInterner to use to intern strings.\n\t * @param idNormalizer - A normalizer to transform node IDs into op-space\n\t */\n\tdecompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder>;\n}\n\n/**\n * Compresses a given {@link PlaceholderTree}\n * (Such as a {@link ChangeNode} or {@link BuildNode}) into an array,\n * while also string interning all node {@link Definition}s and {@link TraitLabel}s.\n * See {@link CompressedPlaceholderTree} for format.\n */\nexport class InterningTreeCompressor<TPlaceholder extends DetachedSequenceId | never>\n\timplements TreeCompressor<TPlaceholder>\n{\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tthis.previousId = undefined;\n\t\treturn this.compressI(node, interner, idNormalizer);\n\t}\n\n\tprivate compressI<TId extends OpSpaceNodeId>(\n\t\tnode: PlaceholderTree<TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedPlaceholderTree<TId, TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst internedDefinition = interner.getInternedId(node.definition) ?? node.definition;\n\t\tconst normalizedId = idNormalizer.normalizeToOpSpace(node.identifier);\n\t\tconst compressedId = canElideId(this.previousId, normalizedId) ? undefined : normalizedId;\n\t\tthis.previousId = normalizedId;\n\t\tconst compressedTraits: CompressedTraits<TId, TPlaceholder> = [];\n\n\t\t// Omit traits if empty and payload is undefined.\n\t\tconst traits = Object.entries(node.traits).sort();\n\t\tif (traits.length > 0 || node.payload !== undefined) {\n\t\t\tfor (const [label, trait] of traits) {\n\t\t\t\tcompressedTraits.push(\n\t\t\t\t\tinterner.getInternedId(label) ?? (label as TraitLabel),\n\t\t\t\t\ttrait.map((child) => this.compressI(child, interner, idNormalizer))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst payloadTraits = node.payload !== undefined ? [node.payload, ...compressedTraits] : compressedTraits;\n\t\tif (payloadTraits.length > 0) {\n\t\t\tif (compressedId !== undefined) {\n\t\t\t\treturn [internedDefinition, compressedId, payloadTraits];\n\t\t\t}\n\t\t\treturn [internedDefinition, payloadTraits];\n\t\t}\n\n\t\tif (compressedId !== undefined) {\n\t\t\treturn [internedDefinition, compressedId];\n\t\t}\n\n\t\treturn [internedDefinition];\n\t}\n\n\t/** The ID that was compressed or decompressed most recently */\n\tprivate previousId?: OpSpaceNodeId;\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\t\tconst rootId = node[1];\n\t\tassert(typeof rootId === 'number', 'Root node was compressed with no ID');\n\t\tthis.previousId = rootId;\n\t\treturn this.decompressI(node, interner, idNormalizer);\n\t}\n\n\tprivate decompressI<TId extends OpSpaceNodeId>(\n\t\tnode: CompressedPlaceholderTree<TId, TPlaceholder>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): PlaceholderTree<TPlaceholder> {\n\t\tif (isDetachedSequenceId(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tlet compressedId: TId | undefined;\n\t\tlet compressedTraits:\n\t\t\t| [Payload, ...CompressedTraits<TId, TPlaceholder>]\n\t\t\t| CompressedTraits<TId, TPlaceholder>\n\t\t\t| undefined;\n\t\tlet payload: Payload | undefined;\n\t\tconst [maybeInternedDefinition, idOrPayloadTraits, payloadTraits] = node;\n\t\tif (idOrPayloadTraits !== undefined) {\n\t\t\tif (typeof idOrPayloadTraits === 'number') {\n\t\t\t\tcompressedId = idOrPayloadTraits;\n\t\t\t\tif (payloadTraits !== undefined) {\n\t\t\t\t\tcompressedTraits = payloadTraits;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcompressedTraits = idOrPayloadTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst definition =\n\t\t\ttypeof maybeInternedDefinition === 'string'\n\t\t\t\t? maybeInternedDefinition\n\t\t\t\t: (interner.getString(maybeInternedDefinition) as Definition);\n\n\t\tlet identifier: TId;\n\t\tif (compressedId !== undefined) {\n\t\t\tidentifier = compressedId;\n\t\t} else {\n\t\t\tconst prevId = this.previousId ?? fail();\n\t\t\tidentifier = prevId < 0 ? ((prevId - 1) as TId) : (((prevId as number) + 1) as TId);\n\t\t}\n\t\tthis.previousId = identifier;\n\n\t\tconst traits = {};\n\t\tif (compressedTraits !== undefined) {\n\t\t\tlet offset: number;\n\t\t\tif (compressedTraits.length % 2 === 1) {\n\t\t\t\toffset = 1;\n\t\t\t\tpayload = compressedTraits[0];\n\t\t\t} else {\n\t\t\t\toffset = 0;\n\t\t\t}\n\t\t\tconst traitsLength = compressedTraits.length - offset;\n\t\t\tfor (let i = 0; i < traitsLength; i += 2) {\n\t\t\t\tconst offsetIndex = i + offset;\n\t\t\t\tconst maybeCompressedLabel = compressedTraits[offsetIndex] as InternedStringId;\n\t\t\t\tconst compressedChildren = compressedTraits[offsetIndex + 1] as (\n\t\t\t\t\t| TPlaceholder\n\t\t\t\t\t| CompressedPlaceholderTree<TId, TPlaceholder>\n\t\t\t\t)[];\n\n\t\t\t\tconst decompressedTraits = compressedChildren.map((child) =>\n\t\t\t\t\tthis.decompressI(child, interner, idNormalizer)\n\t\t\t\t);\n\n\t\t\t\tconst label =\n\t\t\t\t\ttypeof maybeCompressedLabel === 'string'\n\t\t\t\t\t\t? maybeCompressedLabel\n\t\t\t\t\t\t: (interner.getString(maybeCompressedLabel) as TraitLabel);\n\t\t\t\ttraits[label] = decompressedTraits;\n\t\t\t}\n\t\t}\n\n\t\tconst decompressedNode: Mutable<PlaceholderTree<TPlaceholder>> = {\n\t\t\tidentifier: idNormalizer.normalizeToSessionSpace(identifier),\n\t\t\tdefinition,\n\t\t\ttraits,\n\t\t};\n\n\t\tif (payload !== undefined) {\n\t\t\tdecompressedNode.payload = payload;\n\t\t}\n\n\t\treturn decompressedNode;\n\t}\n}\n\nfunction canElideId<TId extends OpSpaceNodeId>(previousId: TId | undefined, id: TId): boolean {\n\tif (previousId === undefined) {\n\t\treturn false;\n\t}\n\n\tconst numericId: number = previousId;\n\tif (numericId < 0) {\n\t\treturn id === numericId - 1;\n\t}\n\n\treturn id === numericId + 1;\n}\n"]}
@@ -17,7 +17,7 @@ class TreeNodeHandle {
17
17
  constructor(view, nodeId) {
18
18
  var _a;
19
19
  this.view = view;
20
- this.viewNode = (_a = view.tryGetViewNode(nodeId)) !== null && _a !== void 0 ? _a : Common_1.fail('Failed to create handle: node is not present in view');
20
+ this.viewNode = (_a = view.tryGetViewNode(nodeId)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('Failed to create handle: node is not present in view');
21
21
  }
22
22
  get payload() {
23
23
  return this.node.payload;
@@ -36,19 +36,19 @@ class TreeNodeHandle {
36
36
  Object.defineProperty(traitMap, label, {
37
37
  get() {
38
38
  const handleTrait = trait.map((node) => new TreeNodeHandle(view, node));
39
- return Common_1.memoizeGetter(this, label, handleTrait);
39
+ return (0, Common_1.memoizeGetter)(this, label, handleTrait);
40
40
  },
41
41
  configurable: true,
42
42
  enumerable: true,
43
43
  });
44
44
  }
45
- return Common_1.memoizeGetter(this, 'traits', traitMap);
45
+ return (0, Common_1.memoizeGetter)(this, 'traits', traitMap);
46
46
  }
47
47
  /**
48
48
  * Get a `TreeViewNode` for the tree view node that this handle references
49
49
  */
50
50
  get node() {
51
- return Common_1.memoizeGetter(this, 'node', this.viewNode);
51
+ return (0, Common_1.memoizeGetter)(this, 'node', this.viewNode);
52
52
  }
53
53
  }
54
54
  exports.TreeNodeHandle = TreeNodeHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA+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,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACD;AA9CD,wCA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { fail, memoizeGetter } from './Common';\nimport { Payload, TraitMap, TreeNode } from './persisted-types';\nimport { TreeView, TreeViewNode } from './TreeView';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `TreeView`. This type provides a convenient\n * API for traversing trees of nodes in a TreeView and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the TreeView and TreeViewNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle, NodeId> {\n\tprivate readonly view: TreeView;\n\tprivate readonly viewNode: TreeViewNode;\n\n\t/** Construct a handle which references the node with the given id in the given `TreeView` */\n\tpublic constructor(view: TreeView, nodeId: NodeId) {\n\t\tthis.view = view;\n\t\tthis.viewNode = view.tryGetViewNode(nodeId) ?? fail('Failed to create handle: node is not present in view');\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { view } = this;\n\t\tfor (const [label, trait] of this.node.traits.entries()) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(view, node));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `TreeViewNode` for the tree view node that this handle references\n\t */\n\tpublic get node(): TreeViewNode {\n\t\treturn memoizeGetter(this, 'node', this.viewNode);\n\t}\n}\n"]}
1
+ {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA+C;AAI/C;;;;;GAKG;AACH,MAAa,cAAc;IAI1B,6FAA6F;IAC7F,YAAmB,IAAc,EAAE,MAAc;;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,MAAA,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,mCAAI,IAAA,aAAI,EAAC,sDAAsD,CAAC,CAAC;IAC7G,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,MAAM;QAChB,2EAA2E;QAC3E,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;YACxD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;gBACtC,GAAG;oBACF,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBACxE,OAAO,IAAA,sBAAa,EAAC,IAAgC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;gBAC5E,CAAC;gBACD,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,IAAI;aAChB,CAAC,CAAC;SACH;QAED,OAAO,IAAA,sBAAa,EAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAA,sBAAa,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACD;AA9CD,wCA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { fail, memoizeGetter } from './Common';\nimport { Payload, TraitMap, TreeNode } from './persisted-types';\nimport { TreeView, TreeViewNode } from './TreeView';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `TreeView`. This type provides a convenient\n * API for traversing trees of nodes in a TreeView and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the TreeView and TreeViewNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle, NodeId> {\n\tprivate readonly view: TreeView;\n\tprivate readonly viewNode: TreeViewNode;\n\n\t/** Construct a handle which references the node with the given id in the given `TreeView` */\n\tpublic constructor(view: TreeView, nodeId: NodeId) {\n\t\tthis.view = view;\n\t\tthis.viewNode = view.tryGetViewNode(nodeId) ?? fail('Failed to create handle: node is not present in view');\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { view } = this;\n\t\tfor (const [label, trait] of this.node.traits.entries()) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(view, node));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `TreeViewNode` for the tree view node that this handle references\n\t */\n\tpublic get node(): TreeViewNode {\n\t\treturn memoizeGetter(this, 'node', this.viewNode);\n\t}\n}\n"]}
package/dist/TreeView.js CHANGED
@@ -39,12 +39,12 @@ class TreeView {
39
39
  /** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */
40
40
  getViewNode(id) {
41
41
  var _a;
42
- return (_a = this.tryGetViewNode(id)) !== null && _a !== void 0 ? _a : Common_1.fail('NodeId not found');
42
+ return (_a = this.tryGetViewNode(id)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('NodeId not found');
43
43
  }
44
44
  /** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */
45
45
  tryGetViewNode(id) {
46
46
  const forestNode = this.forest.tryGet(id);
47
- if (forestNode !== undefined && Forest_1.isParentedForestNode(forestNode)) {
47
+ if (forestNode !== undefined && (0, Forest_1.isParentedForestNode)(forestNode)) {
48
48
  const viewNode = {
49
49
  definition: forestNode.definition,
50
50
  identifier: forestNode.identifier,
@@ -54,7 +54,7 @@ class TreeView {
54
54
  parent: forestNode.parentId,
55
55
  },
56
56
  };
57
- Common_1.copyPropertyIfDefined(forestNode, viewNode, 'payload');
57
+ (0, Common_1.copyPropertyIfDefined)(forestNode, viewNode, 'payload');
58
58
  return viewNode;
59
59
  }
60
60
  return forestNode;
@@ -124,7 +124,7 @@ class TreeView {
124
124
  */
125
125
  getIndexInTrait(id) {
126
126
  const index = this.tryGetIndexInTrait(id);
127
- return index !== null && index !== void 0 ? index : Common_1.fail('ID does not exist in the forest.');
127
+ return index !== null && index !== void 0 ? index : (0, Common_1.fail)('ID does not exist in the forest.');
128
128
  }
129
129
  /**
130
130
  * @returns the index within the trait under which the node with the given id resides, or undefined if the node does not exist in this
@@ -145,7 +145,7 @@ class TreeView {
145
145
  if (parent === undefined) {
146
146
  return undefined;
147
147
  }
148
- const trait = (_b = parent.traits.get(parentData.traitParent)) !== null && _b !== void 0 ? _b : Common_1.fail('inconsistent forest: trait parent not found');
148
+ const trait = (_b = parent.traits.get(parentData.traitParent)) !== null && _b !== void 0 ? _b : (0, Common_1.fail)('inconsistent forest: trait parent not found');
149
149
  let foundIndex;
150
150
  if (trait.length === 0) {
151
151
  return foundIndex;
@@ -190,7 +190,7 @@ class TreeView {
190
190
  yield node;
191
191
  for (const label of [...node.traits.keys()].sort()) {
192
192
  const trait = node.traits.get(label);
193
- for (const childId of trait !== null && trait !== void 0 ? trait : Common_1.fail('Expected trait with label')) {
193
+ for (const childId of trait !== null && trait !== void 0 ? trait : (0, Common_1.fail)('Expected trait with label')) {
194
194
  const child = this.getViewNode(childId);
195
195
  yield* this.iterateNodeDescendants(child);
196
196
  }
@@ -206,7 +206,7 @@ class TreeView {
206
206
  * The views must share a root.
207
207
  */
208
208
  delta(view) {
209
- Common_1.assert(this.root === view.root, 'Delta can only be calculated between views that share a root');
209
+ (0, Common_1.assert)(this.root === view.root, 'Delta can only be calculated between views that share a root');
210
210
  return this.forest.delta(view.forest);
211
211
  }
212
212
  }