@fluid-experimental/tree 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/api-extractor-lint.json +1 -10
  3. package/api-extractor.json +0 -9
  4. package/api-report/experimental-tree.api.md +131 -130
  5. package/dist/ChangeTypes.d.ts +15 -15
  6. package/dist/ChangeTypes.js +4 -4
  7. package/dist/ChangeTypes.js.map +1 -1
  8. package/dist/Checkout.d.ts +4 -4
  9. package/dist/Checkout.js +3 -3
  10. package/dist/Checkout.js.map +1 -1
  11. package/dist/Common.d.ts +1 -1
  12. package/dist/Common.d.ts.map +1 -1
  13. package/dist/Common.js.map +1 -1
  14. package/dist/EagerCheckout.d.ts +1 -1
  15. package/dist/EagerCheckout.js +1 -1
  16. package/dist/EagerCheckout.js.map +1 -1
  17. package/dist/EditLog.d.ts +3 -2
  18. package/dist/EditLog.d.ts.map +1 -1
  19. package/dist/EditLog.js +3 -5
  20. package/dist/EditLog.js.map +1 -1
  21. package/dist/EditUtilities.d.ts +5 -5
  22. package/dist/EditUtilities.js +2 -2
  23. package/dist/EditUtilities.js.map +1 -1
  24. package/dist/EventTypes.d.ts +1 -1
  25. package/dist/EventTypes.js +1 -1
  26. package/dist/EventTypes.js.map +1 -1
  27. package/dist/Forest.d.ts +4 -4
  28. package/dist/Forest.js +3 -6
  29. package/dist/Forest.js.map +1 -1
  30. package/dist/Identifiers.d.ts +14 -14
  31. package/dist/Identifiers.js.map +1 -1
  32. package/dist/InitialTree.d.ts +1 -1
  33. package/dist/InitialTree.js +1 -1
  34. package/dist/InitialTree.js.map +1 -1
  35. package/dist/LogViewer.d.ts +2 -2
  36. package/dist/LogViewer.js +1 -1
  37. package/dist/LogViewer.js.map +1 -1
  38. package/dist/NodeIdUtilities.d.ts +3 -3
  39. package/dist/NodeIdUtilities.js.map +1 -1
  40. package/dist/PayloadUtilities.d.ts +1 -1
  41. package/dist/PayloadUtilities.js +1 -1
  42. package/dist/PayloadUtilities.js.map +1 -1
  43. package/dist/ReconciliationPath.d.ts +3 -3
  44. package/dist/ReconciliationPath.js.map +1 -1
  45. package/dist/RevisionValueCache.d.ts +1 -1
  46. package/dist/RevisionValueCache.js +2 -2
  47. package/dist/RevisionValueCache.js.map +1 -1
  48. package/dist/RevisionView.d.ts +2 -2
  49. package/dist/RevisionView.js +2 -2
  50. package/dist/RevisionView.js.map +1 -1
  51. package/dist/SharedTree.d.ts +14 -14
  52. package/dist/SharedTree.js +2 -2
  53. package/dist/SharedTree.js.map +1 -1
  54. package/dist/Transaction.d.ts +3 -3
  55. package/dist/Transaction.js +2 -2
  56. package/dist/Transaction.js.map +1 -1
  57. package/dist/TransactionInternal.d.ts +17 -17
  58. package/dist/TransactionInternal.js +3 -3
  59. package/dist/TransactionInternal.js.map +1 -1
  60. package/dist/TreeView.d.ts +7 -7
  61. package/dist/TreeView.js +1 -1
  62. package/dist/TreeView.js.map +1 -1
  63. package/dist/id-compressor/IdCompressor.js +2 -5
  64. package/dist/id-compressor/IdCompressor.js.map +1 -1
  65. package/dist/migration-shim/migrationShim.d.ts +3 -3
  66. package/dist/migration-shim/migrationShim.d.ts.map +1 -1
  67. package/dist/migration-shim/migrationShim.js +9 -5
  68. package/dist/migration-shim/migrationShim.js.map +1 -1
  69. package/dist/migration-shim/migrationShimFactory.d.ts +2 -2
  70. package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
  71. package/dist/migration-shim/migrationShimFactory.js.map +1 -1
  72. package/dist/migration-shim/sharedTreeShim.d.ts +4 -4
  73. package/dist/migration-shim/sharedTreeShim.d.ts.map +1 -1
  74. package/dist/migration-shim/sharedTreeShim.js +1 -1
  75. package/dist/migration-shim/sharedTreeShim.js.map +1 -1
  76. package/dist/migration-shim/sharedTreeShimFactory.d.ts +1 -2
  77. package/dist/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
  78. package/dist/migration-shim/sharedTreeShimFactory.js.map +1 -1
  79. package/dist/migration-shim/shimDeltaConnection.d.ts +16 -0
  80. package/dist/migration-shim/shimDeltaConnection.d.ts.map +1 -1
  81. package/dist/migration-shim/shimDeltaConnection.js +16 -2
  82. package/dist/migration-shim/shimDeltaConnection.js.map +1 -1
  83. package/dist/migration-shim/types.d.ts +1 -1
  84. package/dist/migration-shim/types.d.ts.map +1 -1
  85. package/dist/migration-shim/types.js.map +1 -1
  86. package/dist/persisted-types/0.0.2.d.ts +24 -24
  87. package/dist/persisted-types/0.0.2.js +5 -5
  88. package/dist/persisted-types/0.0.2.js.map +1 -1
  89. package/dist/persisted-types/0.1.1.d.ts +14 -14
  90. package/dist/persisted-types/0.1.1.js +3 -3
  91. package/dist/persisted-types/0.1.1.js.map +1 -1
  92. package/dist/tree-alpha.d.ts +2674 -119
  93. package/dist/tree-beta.d.ts +1 -50
  94. package/dist/tree-public.d.ts +1 -52
  95. package/dist/tree-untrimmed.d.ts +142 -143
  96. package/lib/ChangeTypes.d.ts +15 -15
  97. package/lib/ChangeTypes.js +4 -4
  98. package/lib/ChangeTypes.js.map +1 -1
  99. package/lib/Checkout.d.ts +4 -4
  100. package/lib/Checkout.js +3 -3
  101. package/lib/Checkout.js.map +1 -1
  102. package/lib/Common.d.ts +1 -1
  103. package/lib/Common.d.ts.map +1 -1
  104. package/lib/Common.js.map +1 -1
  105. package/lib/EagerCheckout.d.ts +1 -1
  106. package/lib/EagerCheckout.js +1 -1
  107. package/lib/EagerCheckout.js.map +1 -1
  108. package/lib/EditLog.d.ts +3 -2
  109. package/lib/EditLog.d.ts.map +1 -1
  110. package/lib/EditLog.js +2 -1
  111. package/lib/EditLog.js.map +1 -1
  112. package/lib/EditUtilities.d.ts +5 -5
  113. package/lib/EditUtilities.js +2 -2
  114. package/lib/EditUtilities.js.map +1 -1
  115. package/lib/EventTypes.d.ts +1 -1
  116. package/lib/EventTypes.js +1 -1
  117. package/lib/EventTypes.js.map +1 -1
  118. package/lib/Forest.d.ts +4 -4
  119. package/lib/Forest.js +2 -2
  120. package/lib/Forest.js.map +1 -1
  121. package/lib/Identifiers.d.ts +14 -14
  122. package/lib/Identifiers.js.map +1 -1
  123. package/lib/InitialTree.d.ts +1 -1
  124. package/lib/InitialTree.js +1 -1
  125. package/lib/InitialTree.js.map +1 -1
  126. package/lib/LogViewer.d.ts +2 -2
  127. package/lib/LogViewer.js +1 -1
  128. package/lib/LogViewer.js.map +1 -1
  129. package/lib/NodeIdUtilities.d.ts +3 -3
  130. package/lib/NodeIdUtilities.js.map +1 -1
  131. package/lib/PayloadUtilities.d.ts +1 -1
  132. package/lib/PayloadUtilities.js +1 -1
  133. package/lib/PayloadUtilities.js.map +1 -1
  134. package/lib/ReconciliationPath.d.ts +3 -3
  135. package/lib/ReconciliationPath.js.map +1 -1
  136. package/lib/RevisionValueCache.d.ts +1 -1
  137. package/lib/RevisionValueCache.js +1 -1
  138. package/lib/RevisionValueCache.js.map +1 -1
  139. package/lib/RevisionView.d.ts +2 -2
  140. package/lib/RevisionView.js +2 -2
  141. package/lib/RevisionView.js.map +1 -1
  142. package/lib/SharedTree.d.ts +14 -14
  143. package/lib/SharedTree.js +2 -2
  144. package/lib/SharedTree.js.map +1 -1
  145. package/lib/Transaction.d.ts +3 -3
  146. package/lib/Transaction.js +2 -2
  147. package/lib/Transaction.js.map +1 -1
  148. package/lib/TransactionInternal.d.ts +17 -17
  149. package/lib/TransactionInternal.js +3 -3
  150. package/lib/TransactionInternal.js.map +1 -1
  151. package/lib/TreeView.d.ts +7 -7
  152. package/lib/TreeView.js +1 -1
  153. package/lib/TreeView.js.map +1 -1
  154. package/lib/id-compressor/IdCompressor.js +1 -1
  155. package/lib/id-compressor/IdCompressor.js.map +1 -1
  156. package/lib/migration-shim/migrationShim.d.ts +3 -3
  157. package/lib/migration-shim/migrationShim.d.ts.map +1 -1
  158. package/lib/migration-shim/migrationShim.js +9 -5
  159. package/lib/migration-shim/migrationShim.js.map +1 -1
  160. package/lib/migration-shim/migrationShimFactory.d.ts +2 -2
  161. package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
  162. package/lib/migration-shim/migrationShimFactory.js.map +1 -1
  163. package/lib/migration-shim/sharedTreeShim.d.ts +4 -4
  164. package/lib/migration-shim/sharedTreeShim.d.ts.map +1 -1
  165. package/lib/migration-shim/sharedTreeShim.js +1 -1
  166. package/lib/migration-shim/sharedTreeShim.js.map +1 -1
  167. package/lib/migration-shim/sharedTreeShimFactory.d.ts +1 -2
  168. package/lib/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
  169. package/lib/migration-shim/sharedTreeShimFactory.js.map +1 -1
  170. package/lib/migration-shim/shimDeltaConnection.d.ts +16 -0
  171. package/lib/migration-shim/shimDeltaConnection.d.ts.map +1 -1
  172. package/lib/migration-shim/shimDeltaConnection.js +16 -2
  173. package/lib/migration-shim/shimDeltaConnection.js.map +1 -1
  174. package/lib/migration-shim/types.d.ts +1 -1
  175. package/lib/migration-shim/types.d.ts.map +1 -1
  176. package/lib/migration-shim/types.js.map +1 -1
  177. package/lib/persisted-types/0.0.2.d.ts +24 -24
  178. package/lib/persisted-types/0.0.2.js +5 -5
  179. package/lib/persisted-types/0.0.2.js.map +1 -1
  180. package/lib/persisted-types/0.1.1.d.ts +14 -14
  181. package/lib/persisted-types/0.1.1.js +3 -3
  182. package/lib/persisted-types/0.1.1.js.map +1 -1
  183. package/lib/test/utilities/TestUtilities.d.ts +1 -2
  184. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  185. package/lib/test/utilities/TestUtilities.js.map +1 -1
  186. package/package.json +25 -25
  187. package/src/ChangeTypes.ts +15 -15
  188. package/src/Checkout.ts +4 -4
  189. package/src/Common.ts +1 -1
  190. package/src/EagerCheckout.ts +1 -1
  191. package/src/EditLog.ts +4 -3
  192. package/src/EditUtilities.ts +5 -5
  193. package/src/EventTypes.ts +1 -1
  194. package/src/Forest.ts +5 -5
  195. package/src/Identifiers.ts +14 -14
  196. package/src/InitialTree.ts +1 -1
  197. package/src/LogViewer.ts +2 -2
  198. package/src/NodeIdUtilities.ts +3 -3
  199. package/src/PayloadUtilities.ts +1 -1
  200. package/src/ReconciliationPath.ts +3 -3
  201. package/src/RevisionValueCache.ts +2 -2
  202. package/src/RevisionView.ts +2 -2
  203. package/src/SharedTree.ts +14 -14
  204. package/src/Transaction.ts +3 -3
  205. package/src/TransactionInternal.ts +17 -17
  206. package/src/TreeView.ts +7 -7
  207. package/src/id-compressor/IdCompressor.ts +1 -1
  208. package/src/migration-shim/migrationShim.ts +17 -9
  209. package/src/migration-shim/migrationShimFactory.ts +2 -2
  210. package/src/migration-shim/sharedTreeShim.ts +6 -5
  211. package/src/migration-shim/sharedTreeShimFactory.ts +1 -2
  212. package/src/migration-shim/shimDeltaConnection.ts +16 -2
  213. package/src/migration-shim/types.ts +1 -1
  214. package/src/persisted-types/0.0.2.ts +24 -24
  215. package/src/persisted-types/0.1.1.ts +14 -14
@@ -16,7 +16,7 @@ import { TreeViewNode } from './TreeView';
16
16
  export type EditingResult = FailedEditingResult | ValidEditingResult;
17
17
  /**
18
18
  * Basic result of applying a transaction.
19
- * @internal
19
+ * @alpha
20
20
  */
21
21
  export interface EditingResultBase {
22
22
  /**
@@ -62,7 +62,7 @@ export interface FailedEditingResult extends EditingResultBase {
62
62
  }
63
63
  /**
64
64
  * Result of applying a valid transaction.
65
- * @internal
65
+ * @alpha
66
66
  */
67
67
  export interface ValidEditingResult extends EditingResultBase {
68
68
  /**
@@ -86,7 +86,7 @@ export type ChangeResult = Result<TransactionView, TransactionFailure>;
86
86
  export type TransactionState = SucceedingTransactionState | FailingTransactionState;
87
87
  /**
88
88
  * The state of a transaction that has not encountered an error.
89
- * @internal
89
+ * @alpha
90
90
  */
91
91
  export interface SucceedingTransactionState {
92
92
  /**
@@ -252,7 +252,7 @@ export interface GenericTransactionPolicy {
252
252
  *
253
253
  * No data outside the Transaction is modified by Transaction:
254
254
  * the results from `close` must be used to actually submit an `Edit`.
255
- * @internal
255
+ * @alpha
256
256
  */
257
257
  export declare namespace TransactionInternal {
258
258
  /**
@@ -309,7 +309,7 @@ export declare namespace TransactionInternal {
309
309
  }
310
310
  /**
311
311
  * The kinds of failures that a transaction might encounter.
312
- * @internal
312
+ * @alpha
313
313
  */
314
314
  export enum FailureKind {
315
315
  /**
@@ -351,12 +351,12 @@ export declare namespace TransactionInternal {
351
351
  }
352
352
  /**
353
353
  * A failure encountered by a transaction.
354
- * @internal
354
+ * @alpha
355
355
  */
356
356
  export type Failure = UnusedDetachedSequenceFailure | DetachedSequenceIdAlreadyInUseFailure | DetachedSequenceNotFoundFailure | DuplicateIdInBuildFailure | IdAlreadyInUseFailure | UnknownIdFailure | BadPlaceFailure | BadRangeFailure | ConstraintViolationFailure;
357
357
  /**
358
358
  * Error returned when a transaction is closed while there is an unused detached sequence.
359
- * @internal
359
+ * @alpha
360
360
  */
361
361
  export interface UnusedDetachedSequenceFailure {
362
362
  /**
@@ -370,7 +370,7 @@ export declare namespace TransactionInternal {
370
370
  }
371
371
  /**
372
372
  * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.
373
- * @internal
373
+ * @alpha
374
374
  */
375
375
  export interface DetachedSequenceIdAlreadyInUseFailure {
376
376
  /**
@@ -388,7 +388,7 @@ export declare namespace TransactionInternal {
388
388
  }
389
389
  /**
390
390
  * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID
391
- * @internal
391
+ * @alpha
392
392
  */
393
393
  export interface DetachedSequenceNotFoundFailure {
394
394
  /**
@@ -406,7 +406,7 @@ export declare namespace TransactionInternal {
406
406
  }
407
407
  /**
408
408
  * Error thrown when a build uses a duplicated NodeId
409
- * @internal
409
+ * @alpha
410
410
  */
411
411
  export interface DuplicateIdInBuildFailure {
412
412
  /**
@@ -424,7 +424,7 @@ export declare namespace TransactionInternal {
424
424
  }
425
425
  /**
426
426
  * Error thrown when a build node ID is already used in the current state
427
- * @internal
427
+ * @alpha
428
428
  */
429
429
  export interface IdAlreadyInUseFailure {
430
430
  /**
@@ -442,7 +442,7 @@ export declare namespace TransactionInternal {
442
442
  }
443
443
  /**
444
444
  * Error thrown when a change is attempted on an unknown NodeId
445
- * @internal
445
+ * @alpha
446
446
  */
447
447
  export interface UnknownIdFailure {
448
448
  /**
@@ -460,7 +460,7 @@ export declare namespace TransactionInternal {
460
460
  }
461
461
  /**
462
462
  * Error thrown when an insert change uses an invalid Place
463
- * @internal
463
+ * @alpha
464
464
  */
465
465
  export interface BadPlaceFailure {
466
466
  /**
@@ -482,7 +482,7 @@ export declare namespace TransactionInternal {
482
482
  }
483
483
  /**
484
484
  * Error thrown when a detach operation is given an invalid or malformed Range
485
- * @internal
485
+ * @alpha
486
486
  */
487
487
  export interface BadRangeFailure {
488
488
  /**
@@ -504,7 +504,7 @@ export declare namespace TransactionInternal {
504
504
  }
505
505
  /**
506
506
  * Error thrown when a constraint fails to apply
507
- * @internal
507
+ * @alpha
508
508
  */
509
509
  export interface ConstraintViolationFailure {
510
510
  /**
@@ -522,7 +522,7 @@ export declare namespace TransactionInternal {
522
522
  }
523
523
  /**
524
524
  * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur
525
- * @internal
525
+ * @alpha
526
526
  */
527
527
  export type ConstraintViolationResult = {
528
528
  readonly kind: ConstraintViolationKind.BadRange;
@@ -539,7 +539,7 @@ export declare namespace TransactionInternal {
539
539
  };
540
540
  /**
541
541
  * Enum of possible kinds of constraint violations that can be encountered
542
- * @internal
542
+ * @alpha
543
543
  */
544
544
  export enum ConstraintViolationKind {
545
545
  /**
@@ -206,7 +206,7 @@ exports.GenericTransaction = GenericTransaction;
206
206
  *
207
207
  * No data outside the Transaction is modified by Transaction:
208
208
  * the results from `close` must be used to actually submit an `Edit`.
209
- * @internal
209
+ * @alpha
210
210
  */
211
211
  // eslint-disable-next-line @typescript-eslint/no-namespace
212
212
  var TransactionInternal;
@@ -576,7 +576,7 @@ var TransactionInternal;
576
576
  TransactionInternal.Policy = Policy;
577
577
  /**
578
578
  * The kinds of failures that a transaction might encounter.
579
- * @internal
579
+ * @alpha
580
580
  */
581
581
  let FailureKind;
582
582
  (function (FailureKind) {
@@ -619,7 +619,7 @@ var TransactionInternal;
619
619
  })(FailureKind = TransactionInternal.FailureKind || (TransactionInternal.FailureKind = {}));
620
620
  /**
621
621
  * Enum of possible kinds of constraint violations that can be encountered
622
- * @internal
622
+ * @alpha
623
623
  */
624
624
  let ConstraintViolationKind;
625
625
  (function (ConstraintViolationKind) {
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,qCAAkF;AAClF,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA+IzB;;;;;;;;;;;;;GAaG;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;I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B;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,EAtqBgB,mBAAmB,mCAAnB,mBAAmB,QAsqBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { assertWithMessage, 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 * @internal\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @internal\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 * @internal\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 * @internal\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 * @internal\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @internal\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n * @internal\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 * @internal\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 * @internal\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 * @internal\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/**\n\t * Information about why the transaction failed. Defined if and only if `status` is invalid or malformed.\n\t */\n\tpublic get failure(): TransactionInternal.Failure | undefined {\n\t\treturn (this.state as FailingTransactionState).failure;\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, 0x638 /* 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, 0x639 /* 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\tthis.state = Result.isOk(changeResult)\n\t\t\t? {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tview: changeResult.result,\n\t\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\t...this.state,\n\t\t\t\t\t...changeResult.error,\n\t\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 * @internal\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 * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t * @internal\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 * @internal\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, 0x63a /* identityHash constraint is not implemented */);\n\t\t\tassert(change.contentHash === undefined, 0x63b /* 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\tassertWithMessage(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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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 * @internal\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;;;GAGG;;;AAEH,2DAAoD;AACpD,qCAAkF;AAClF,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA+IzB;;;;;;;;;;;;;GAaG;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,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;;OAGG;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;IAsND;;;OAGG;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,EAtqBgB,mBAAmB,mCAAnB,mBAAmB,QAsqBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { assertWithMessage, 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 * @internal\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @alpha\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 * @internal\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 * @alpha\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 * @internal\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @internal\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n * @alpha\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 * @internal\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 * @internal\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 * @internal\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/**\n\t * Information about why the transaction failed. Defined if and only if `status` is invalid or malformed.\n\t */\n\tpublic get failure(): TransactionInternal.Failure | undefined {\n\t\treturn (this.state as FailingTransactionState).failure;\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, 0x638 /* 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, 0x639 /* 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\tthis.state = Result.isOk(changeResult)\n\t\t\t? {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tview: changeResult.result,\n\t\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\t...this.state,\n\t\t\t\t\t...changeResult.error,\n\t\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 * @internal\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 * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t * @internal\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 * @internal\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, 0x63a /* identityHash constraint is not implemented */);\n\t\t\tassert(change.contentHash === undefined, 0x63b /* 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\tassertWithMessage(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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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"]}
@@ -7,7 +7,7 @@ import { Delta, Forest } from './Forest';
7
7
  import { NodeData, Side } from './persisted-types';
8
8
  /**
9
9
  * Specifies the location of a trait (a labeled sequence of nodes) within the tree.
10
- * @internal
10
+ * @alpha
11
11
  */
12
12
  export interface TraitLocation {
13
13
  readonly parent: NodeId;
@@ -15,7 +15,7 @@ export interface TraitLocation {
15
15
  }
16
16
  /**
17
17
  * An immutable view of a distributed tree node.
18
- * @internal
18
+ * @alpha
19
19
  */
20
20
  export interface TreeViewNode extends NodeData<NodeId> {
21
21
  /** The IDs of the children under this node */
@@ -28,7 +28,7 @@ export interface TreeViewNode extends NodeData<NodeId> {
28
28
  * 0 = before all nodes,
29
29
  * 1 = after first node,
30
30
  * etc.
31
- * @internal
31
+ * @alpha
32
32
  */
33
33
  export type PlaceIndex = number & {
34
34
  readonly PlaceIndex: unique symbol;
@@ -38,7 +38,7 @@ export type PlaceIndex = number & {
38
38
  * 0 = first node,
39
39
  * 1 = second node,
40
40
  * etc.
41
- * @internal
41
+ * @alpha
42
42
  */
43
43
  export type TraitNodeIndex = number & {
44
44
  readonly TraitNodeIndex: unique symbol;
@@ -46,7 +46,7 @@ export type TraitNodeIndex = number & {
46
46
  /**
47
47
  * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.
48
48
  * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.
49
- * @internal
49
+ * @alpha
50
50
  */
51
51
  export interface TreeViewPlace {
52
52
  readonly sibling?: NodeId;
@@ -56,7 +56,7 @@ export interface TreeViewPlace {
56
56
  /**
57
57
  * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.
58
58
  * Valid iff start and end are valid and are within the same trait.
59
- * @internal
59
+ * @alpha
60
60
  */
61
61
  export interface TreeViewRange {
62
62
  readonly start: TreeViewPlace;
@@ -72,7 +72,7 @@ export interface NodeInTrait {
72
72
  }
73
73
  /**
74
74
  * A view of a distributed tree.
75
- * @internal
75
+ * @alpha
76
76
  */
77
77
  export declare abstract class TreeView {
78
78
  readonly root: NodeId;
package/dist/TreeView.js CHANGED
@@ -11,7 +11,7 @@ const Forest_1 = require("./Forest");
11
11
  const persisted_types_1 = require("./persisted-types");
12
12
  /**
13
13
  * A view of a distributed tree.
14
- * @internal
14
+ * @alpha
15
15
  */
16
16
  class TreeView {
17
17
  constructor(root, forest) {
@@ -1 +1 @@
1
- {"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../src/TreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,qCAAuD;AAEvD,qCAA+D;AAC/D,uDAAmD;AAsEnD;;;GAGG;AACH,MAAsB,QAAQ;IAY7B,YAAsB,IAAY,EAAE,MAAc;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,gDAAgD;IAChD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qEAAqE;IAC9D,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,KAAoB;QAC/C,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,kHAAkH;IAC3G,WAAW,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,IAAA,aA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AAE,KAAqB;IAClD,qEAAqE;IACrE,OAAO,CAAC,IAAI,GAAG,KAAK,CAAe,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { copyPropertyIfDefined, fail } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { Delta, Forest, isParentedForestNode } from './Forest';\nimport { NodeData, Side } from './persisted-types';\n\n/**\n * Specifies the location of a trait (a labeled sequence of nodes) within the tree.\n * @internal\n */\nexport interface TraitLocation {\n\treadonly parent: NodeId;\n\treadonly label: TraitLabel;\n}\n\n/**\n * An immutable view of a distributed tree node.\n * @internal\n */\nexport interface TreeViewNode extends NodeData<NodeId> {\n\t/** The IDs of the children under this node */\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n\t/** The parent and trait under which this node resides. Undefined iff this is the root node of the tree (i.e. {@link initialTree}). */\n\treadonly parentage?: TraitLocation;\n}\n\n/**\n * Index of a place within a trait.\n * 0 = before all nodes,\n * 1 = after first node,\n * etc.\n * @internal\n */\nexport type PlaceIndex = number & { readonly PlaceIndex: unique symbol };\n\n/**\n * Index of a node within a trait.\n * 0 = first node,\n * 1 = second node,\n * etc.\n * @internal\n */\nexport type TraitNodeIndex = number & { readonly TraitNodeIndex: unique symbol };\n\n/**\n * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.\n * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.\n * @internal\n */\nexport interface TreeViewPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.\n * Valid iff start and end are valid and are within the same trait.\n * @internal\n */\nexport interface TreeViewRange {\n\treadonly start: TreeViewPlace;\n\treadonly end: TreeViewPlace;\n}\n\n/**\n * Contains some redundant information. Use only in computations between edits. Do not store.\n * @internal\n */\nexport interface NodeInTrait {\n\treadonly trait: TraitLocation;\n\treadonly index: TraitNodeIndex;\n}\n\n/**\n * A view of a distributed tree.\n * @internal\n */\nexport abstract class TreeView {\n\tpublic readonly root: NodeId;\n\tprotected readonly forest: Forest;\n\tprivate readonly rootNode: TreeViewNode;\n\n\t/**\n\t * A cache of node's index within their parent trait.\n\t * Used to avoid redundant linear scans of traits.\n\t * Not shared across views; initialized to empty each time a TreeView is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\tprotected constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t\tthis.rootNode = this.getViewNode(root);\n\t}\n\n\t/** @returns the number of nodes in this view */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/** @returns true iff a node with the given id exists in this view */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.has(id);\n\t}\n\n\t/**\n\t * @returns the index just after place (which specifies a location between items).\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic findIndexWithinTrait(place: TreeViewPlace): PlaceIndex {\n\t\tif (place.sibling === undefined) {\n\t\t\treturn this.getIndexOfSide(place.side, place.trait);\n\t\t}\n\t\treturn getIndex(place.side, this.getIndexInTrait(place.sibling));\n\t}\n\n\t/** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */\n\tpublic getViewNode(id: NodeId): TreeViewNode {\n\t\treturn this.tryGetViewNode(id) ?? fail('NodeId not found');\n\t}\n\n\t/** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */\n\tpublic tryGetViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst forestNode = this.forest.tryGet(id);\n\t\tif (forestNode !== undefined && isParentedForestNode(forestNode)) {\n\t\t\tconst viewNode: TreeViewNode = {\n\t\t\t\tdefinition: forestNode.definition,\n\t\t\t\tidentifier: forestNode.identifier,\n\t\t\t\ttraits: forestNode.traits,\n\t\t\t\tparentage: {\n\t\t\t\t\tlabel: forestNode.traitParent,\n\t\t\t\t\tparent: forestNode.parentId,\n\t\t\t\t},\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(forestNode, viewNode, 'payload');\n\t\t\treturn viewNode;\n\t\t}\n\n\t\treturn forestNode;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides. Fails if the node does not exist in this view or if\n\t * it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel {\n\t\treturn this.forest.getParent(id).traitParent;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides, or undefined if the node is not present in this\n\t * view or if it is the root node\n\t */\n\tpublic tryGetTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Fails if the node does not exist in this view or if it is the root node.\n\t */\n\tpublic getParentViewNode(id: NodeId): TreeViewNode {\n\t\tconst parentInfo = this.forest.getParent(id);\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Returns undefined if the node does not exist in this view or if it is the root\n\t * node.\n\t */\n\tpublic tryGetParentViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst parentInfo = this.forest.tryGetParent(id);\n\t\tif (parentInfo === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id. Fails if the node does not exist in this view or of it is the root\n\t * node\n\t */\n\tpublic getTraitLocation(id: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(id);\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id, or undefined if the node does not exist in this view or if it is the root\n\t * node\n\t */\n\tpublic tryGetTraitLocation(id: NodeId): TraitLocation | undefined {\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides. The node must exist in this view and must have a\n\t * parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(id: NodeId): TraitNodeIndex {\n\t\tconst index = this.tryGetIndexInTrait(id);\n\t\treturn index ?? fail('ID does not exist in the forest.');\n\t}\n\n\t/**\n\t * @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\n\t * view or does not have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic tryGetIndexInTrait(id: NodeId): TraitNodeIndex | undefined {\n\t\tconst cachedIndex = this.traitIndicesCache?.get(id);\n\t\tif (cachedIndex !== undefined) {\n\t\t\treturn cachedIndex;\n\t\t}\n\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parent = this.forest.tryGet(parentData.parentId);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst trait = parent.traits.get(parentData.traitParent) ?? fail('inconsistent forest: trait parent not found');\n\t\tlet foundIndex: TraitNodeIndex | undefined;\n\t\tif (trait.length === 0) {\n\t\t\treturn foundIndex;\n\t\t}\n\n\t\tthis.traitIndicesCache ??= new Map();\n\t\tfor (let i = 0; i < trait.length; i++) {\n\t\t\tconst nodeInTrait = trait[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === id) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\n\t\treturn foundIndex;\n\t}\n\n\t/**\n\t * @returns the trait at the given location. If no such trait exists, returns an empty trait.\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getViewNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\n\t}\n\n\t/** Asserts that the view's internal state is consistent. Useful for testing/validation. */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<TreeViewNode> {\n\t\treturn this.iterateNodeDescendants(this.rootNode);\n\t}\n\n\t/** @returns true iff the given view is equal to this view */\n\tpublic abstract equals(view: TreeView): boolean;\n\n\t/**\n\t * @returns true iff the given view's forest of nodes is equivalent to this view's forest of nodes\n\t * @param strict - if true, the views' forests must be the same object, otherwise they must merely be equivalent\n\t */\n\tpublic hasEqualForest(view: TreeView, strict = false): boolean {\n\t\tif (this.root === view.root) {\n\t\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\t\treturn strict ? this.forest === view.forest : this.forest.equals(view.forest);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate *iterateNodeDescendants(node: TreeViewNode): IterableIterator<TreeViewNode> {\n\t\tyield node;\n\t\tfor (const label of [...node.traits.keys()].sort()) {\n\t\t\tconst trait = node.traits.get(label);\n\t\t\tfor (const childId of trait ?? fail('Expected trait with label')) {\n\t\t\t\tconst child = this.getViewNode(childId);\n\t\t\t\tyield* this.iterateNodeDescendants(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getIndexOfSide(side: Side, traitLocation: TraitLocation): PlaceIndex {\n\t\treturn side === Side.After ? (0 as PlaceIndex) : (this.getTrait(traitLocation).length as PlaceIndex);\n\t}\n\n\t/**\n\t * Calculate the difference between two `TreeView`s\n\t * @param view - the other view to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `view`.\n\t * The views must share a root.\n\t */\n\tpublic delta(view: TreeView): Delta<NodeId> {\n\t\tassert(this.root === view.root, 0x63d /* Delta can only be calculated between views that share a root */);\n\t\treturn this.forest.delta(view.forest);\n\t}\n}\n\nfunction getIndex(side: Side, index: TraitNodeIndex): PlaceIndex {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (side + index) as PlaceIndex;\n}\n"]}
1
+ {"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../src/TreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,qCAAuD;AAEvD,qCAA+D;AAC/D,uDAAmD;AAsEnD;;;GAGG;AACH,MAAsB,QAAQ;IAY7B,YAAsB,IAAY,EAAE,MAAc;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,gDAAgD;IAChD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qEAAqE;IAC9D,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,KAAoB;QAC/C,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,kHAAkH;IAC3G,WAAW,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,IAAA,aAAI,EAAC,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,wHAAwH;IACjH,cAAc,CAAC,EAAU;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,E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ensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { copyPropertyIfDefined, fail } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { Delta, Forest, isParentedForestNode } from './Forest';\nimport { NodeData, Side } from './persisted-types';\n\n/**\n * Specifies the location of a trait (a labeled sequence of nodes) within the tree.\n * @alpha\n */\nexport interface TraitLocation {\n\treadonly parent: NodeId;\n\treadonly label: TraitLabel;\n}\n\n/**\n * An immutable view of a distributed tree node.\n * @alpha\n */\nexport interface TreeViewNode extends NodeData<NodeId> {\n\t/** The IDs of the children under this node */\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n\t/** The parent and trait under which this node resides. Undefined iff this is the root node of the tree (i.e. {@link initialTree}). */\n\treadonly parentage?: TraitLocation;\n}\n\n/**\n * Index of a place within a trait.\n * 0 = before all nodes,\n * 1 = after first node,\n * etc.\n * @alpha\n */\nexport type PlaceIndex = number & { readonly PlaceIndex: unique symbol };\n\n/**\n * Index of a node within a trait.\n * 0 = first node,\n * 1 = second node,\n * etc.\n * @alpha\n */\nexport type TraitNodeIndex = number & { readonly TraitNodeIndex: unique symbol };\n\n/**\n * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.\n * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.\n * @alpha\n */\nexport interface TreeViewPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.\n * Valid iff start and end are valid and are within the same trait.\n * @alpha\n */\nexport interface TreeViewRange {\n\treadonly start: TreeViewPlace;\n\treadonly end: TreeViewPlace;\n}\n\n/**\n * Contains some redundant information. Use only in computations between edits. Do not store.\n * @internal\n */\nexport interface NodeInTrait {\n\treadonly trait: TraitLocation;\n\treadonly index: TraitNodeIndex;\n}\n\n/**\n * A view of a distributed tree.\n * @alpha\n */\nexport abstract class TreeView {\n\tpublic readonly root: NodeId;\n\tprotected readonly forest: Forest;\n\tprivate readonly rootNode: TreeViewNode;\n\n\t/**\n\t * A cache of node's index within their parent trait.\n\t * Used to avoid redundant linear scans of traits.\n\t * Not shared across views; initialized to empty each time a TreeView is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\tprotected constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t\tthis.rootNode = this.getViewNode(root);\n\t}\n\n\t/** @returns the number of nodes in this view */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/** @returns true iff a node with the given id exists in this view */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.has(id);\n\t}\n\n\t/**\n\t * @returns the index just after place (which specifies a location between items).\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic findIndexWithinTrait(place: TreeViewPlace): PlaceIndex {\n\t\tif (place.sibling === undefined) {\n\t\t\treturn this.getIndexOfSide(place.side, place.trait);\n\t\t}\n\t\treturn getIndex(place.side, this.getIndexInTrait(place.sibling));\n\t}\n\n\t/** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */\n\tpublic getViewNode(id: NodeId): TreeViewNode {\n\t\treturn this.tryGetViewNode(id) ?? fail('NodeId not found');\n\t}\n\n\t/** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */\n\tpublic tryGetViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst forestNode = this.forest.tryGet(id);\n\t\tif (forestNode !== undefined && isParentedForestNode(forestNode)) {\n\t\t\tconst viewNode: TreeViewNode = {\n\t\t\t\tdefinition: forestNode.definition,\n\t\t\t\tidentifier: forestNode.identifier,\n\t\t\t\ttraits: forestNode.traits,\n\t\t\t\tparentage: {\n\t\t\t\t\tlabel: forestNode.traitParent,\n\t\t\t\t\tparent: forestNode.parentId,\n\t\t\t\t},\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(forestNode, viewNode, 'payload');\n\t\t\treturn viewNode;\n\t\t}\n\n\t\treturn forestNode;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides. Fails if the node does not exist in this view or if\n\t * it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel {\n\t\treturn this.forest.getParent(id).traitParent;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides, or undefined if the node is not present in this\n\t * view or if it is the root node\n\t */\n\tpublic tryGetTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Fails if the node does not exist in this view or if it is the root node.\n\t */\n\tpublic getParentViewNode(id: NodeId): TreeViewNode {\n\t\tconst parentInfo = this.forest.getParent(id);\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Returns undefined if the node does not exist in this view or if it is the root\n\t * node.\n\t */\n\tpublic tryGetParentViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst parentInfo = this.forest.tryGetParent(id);\n\t\tif (parentInfo === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id. Fails if the node does not exist in this view or of it is the root\n\t * node\n\t */\n\tpublic getTraitLocation(id: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(id);\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id, or undefined if the node does not exist in this view or if it is the root\n\t * node\n\t */\n\tpublic tryGetTraitLocation(id: NodeId): TraitLocation | undefined {\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides. The node must exist in this view and must have a\n\t * parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(id: NodeId): TraitNodeIndex {\n\t\tconst index = this.tryGetIndexInTrait(id);\n\t\treturn index ?? fail('ID does not exist in the forest.');\n\t}\n\n\t/**\n\t * @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\n\t * view or does not have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic tryGetIndexInTrait(id: NodeId): TraitNodeIndex | undefined {\n\t\tconst cachedIndex = this.traitIndicesCache?.get(id);\n\t\tif (cachedIndex !== undefined) {\n\t\t\treturn cachedIndex;\n\t\t}\n\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parent = this.forest.tryGet(parentData.parentId);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst trait = parent.traits.get(parentData.traitParent) ?? fail('inconsistent forest: trait parent not found');\n\t\tlet foundIndex: TraitNodeIndex | undefined;\n\t\tif (trait.length === 0) {\n\t\t\treturn foundIndex;\n\t\t}\n\n\t\tthis.traitIndicesCache ??= new Map();\n\t\tfor (let i = 0; i < trait.length; i++) {\n\t\t\tconst nodeInTrait = trait[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === id) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\n\t\treturn foundIndex;\n\t}\n\n\t/**\n\t * @returns the trait at the given location. If no such trait exists, returns an empty trait.\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getViewNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\n\t}\n\n\t/** Asserts that the view's internal state is consistent. Useful for testing/validation. */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<TreeViewNode> {\n\t\treturn this.iterateNodeDescendants(this.rootNode);\n\t}\n\n\t/** @returns true iff the given view is equal to this view */\n\tpublic abstract equals(view: TreeView): boolean;\n\n\t/**\n\t * @returns true iff the given view's forest of nodes is equivalent to this view's forest of nodes\n\t * @param strict - if true, the views' forests must be the same object, otherwise they must merely be equivalent\n\t */\n\tpublic hasEqualForest(view: TreeView, strict = false): boolean {\n\t\tif (this.root === view.root) {\n\t\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\t\treturn strict ? this.forest === view.forest : this.forest.equals(view.forest);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate *iterateNodeDescendants(node: TreeViewNode): IterableIterator<TreeViewNode> {\n\t\tyield node;\n\t\tfor (const label of [...node.traits.keys()].sort()) {\n\t\t\tconst trait = node.traits.get(label);\n\t\t\tfor (const childId of trait ?? fail('Expected trait with label')) {\n\t\t\t\tconst child = this.getViewNode(childId);\n\t\t\t\tyield* this.iterateNodeDescendants(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getIndexOfSide(side: Side, traitLocation: TraitLocation): PlaceIndex {\n\t\treturn side === Side.After ? (0 as PlaceIndex) : (this.getTrait(traitLocation).length as PlaceIndex);\n\t}\n\n\t/**\n\t * Calculate the difference between two `TreeView`s\n\t * @param view - the other view to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `view`.\n\t * The views must share a root.\n\t */\n\tpublic delta(view: TreeView): Delta<NodeId> {\n\t\tassert(this.root === view.root, 0x63d /* Delta can only be calculated between views that share a root */);\n\t\treturn this.forest.delta(view.forest);\n\t}\n}\n\nfunction getIndex(side: Side, index: TraitNodeIndex): PlaceIndex {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (side + index) as PlaceIndex;\n}\n"]}
@@ -3,15 +3,12 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
7
  exports.hasOngoingSession = exports.IdCompressor = exports.isLocalId = exports.isFinalId = exports.legacySharedTreeInitialTreeId = exports.defaultClusterCapacity = void 0;
11
8
  /* eslint-disable @typescript-eslint/restrict-plus-operands */
12
9
  const core_utils_1 = require("@fluidframework/core-utils");
13
10
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
14
- const sorted_btree_1 = __importDefault(require("sorted-btree"));
11
+ const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
15
12
  const Common_1 = require("../Common");
16
13
  const UuidUtilities_1 = require("../UuidUtilities");
17
14
  const AppendOnlySortedMap_1 = require("./AppendOnlySortedMap");
@@ -197,7 +194,7 @@ class IdCompressor {
197
194
  * This is unified as a performance optimization, as the common case does not have overridden IDs. It is a btree due to the need
198
195
  * to make range queries.
199
196
  */
200
- this.clustersAndOverridesInversion = new sorted_btree_1.default(undefined, Common_1.compareStrings);
197
+ this.clustersAndOverridesInversion = new sorted_btree_es6_1.BTree(undefined, Common_1.compareStrings);
201
198
  /**
202
199
  * Maps the first final ID in a cluster to its owning cluster.
203
200
  * Can be searched in O(log n) to determine clusters for any final ID.