@fluid-experimental/tree 2.0.0-internal.2.0.2 → 2.0.0-internal.2.1.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 (156) hide show
  1. package/README.md +30 -12
  2. package/dist/Checkout.d.ts.map +1 -1
  3. package/dist/Checkout.js +3 -2
  4. package/dist/Checkout.js.map +1 -1
  5. package/dist/EditLog.d.ts +70 -43
  6. package/dist/EditLog.d.ts.map +1 -1
  7. package/dist/EditLog.js +152 -197
  8. package/dist/EditLog.js.map +1 -1
  9. package/dist/EventTypes.d.ts +12 -0
  10. package/dist/EventTypes.d.ts.map +1 -1
  11. package/dist/EventTypes.js +12 -0
  12. package/dist/EventTypes.js.map +1 -1
  13. package/dist/HistoryEditFactory.d.ts +10 -1
  14. package/dist/HistoryEditFactory.d.ts.map +1 -1
  15. package/dist/HistoryEditFactory.js +24 -2
  16. package/dist/HistoryEditFactory.js.map +1 -1
  17. package/dist/LogViewer.d.ts +67 -9
  18. package/dist/LogViewer.d.ts.map +1 -1
  19. package/dist/LogViewer.js +115 -68
  20. package/dist/LogViewer.js.map +1 -1
  21. package/dist/RevisionValueCache.d.ts +5 -4
  22. package/dist/RevisionValueCache.d.ts.map +1 -1
  23. package/dist/RevisionValueCache.js +12 -12
  24. package/dist/RevisionValueCache.js.map +1 -1
  25. package/dist/SharedTree.d.ts +23 -21
  26. package/dist/SharedTree.d.ts.map +1 -1
  27. package/dist/SharedTree.js +18 -158
  28. package/dist/SharedTree.js.map +1 -1
  29. package/dist/SummaryTestUtilities.d.ts +4 -1
  30. package/dist/SummaryTestUtilities.d.ts.map +1 -1
  31. package/dist/SummaryTestUtilities.js +2 -0
  32. package/dist/SummaryTestUtilities.js.map +1 -1
  33. package/dist/id-compressor/index.d.ts +3 -3
  34. package/dist/id-compressor/index.d.ts.map +1 -1
  35. package/dist/id-compressor/index.js +10 -14
  36. package/dist/id-compressor/index.js.map +1 -1
  37. package/dist/id-compressor/persisted-types/index.d.ts +1 -1
  38. package/dist/id-compressor/persisted-types/index.d.ts.map +1 -1
  39. package/dist/id-compressor/persisted-types/index.js +0 -11
  40. package/dist/id-compressor/persisted-types/index.js.map +1 -1
  41. package/dist/index.d.ts +22 -24
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +47 -48
  44. package/dist/index.js.map +1 -1
  45. package/dist/persisted-types/0.1.1.d.ts +0 -4
  46. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  47. package/dist/persisted-types/0.1.1.js +1 -5
  48. package/dist/persisted-types/0.1.1.js.map +1 -1
  49. package/dist/persisted-types/index.d.ts +2 -2
  50. package/dist/persisted-types/index.d.ts.map +1 -1
  51. package/dist/persisted-types/index.js +14 -12
  52. package/dist/persisted-types/index.js.map +1 -1
  53. package/lib/Checkout.d.ts.map +1 -1
  54. package/lib/Checkout.js +3 -2
  55. package/lib/Checkout.js.map +1 -1
  56. package/lib/EditLog.d.ts +70 -43
  57. package/lib/EditLog.d.ts.map +1 -1
  58. package/lib/EditLog.js +153 -198
  59. package/lib/EditLog.js.map +1 -1
  60. package/lib/EventTypes.d.ts +12 -0
  61. package/lib/EventTypes.d.ts.map +1 -1
  62. package/lib/EventTypes.js +12 -0
  63. package/lib/EventTypes.js.map +1 -1
  64. package/lib/HistoryEditFactory.d.ts +10 -1
  65. package/lib/HistoryEditFactory.d.ts.map +1 -1
  66. package/lib/HistoryEditFactory.js +23 -1
  67. package/lib/HistoryEditFactory.js.map +1 -1
  68. package/lib/LogViewer.d.ts +67 -9
  69. package/lib/LogViewer.d.ts.map +1 -1
  70. package/lib/LogViewer.js +114 -67
  71. package/lib/LogViewer.js.map +1 -1
  72. package/lib/RevisionValueCache.d.ts +5 -4
  73. package/lib/RevisionValueCache.d.ts.map +1 -1
  74. package/lib/RevisionValueCache.js +12 -12
  75. package/lib/RevisionValueCache.js.map +1 -1
  76. package/lib/SharedTree.d.ts +23 -21
  77. package/lib/SharedTree.d.ts.map +1 -1
  78. package/lib/SharedTree.js +23 -163
  79. package/lib/SharedTree.js.map +1 -1
  80. package/lib/SummaryTestUtilities.d.ts +4 -1
  81. package/lib/SummaryTestUtilities.d.ts.map +1 -1
  82. package/lib/SummaryTestUtilities.js +2 -0
  83. package/lib/SummaryTestUtilities.js.map +1 -1
  84. package/lib/id-compressor/index.d.ts +3 -3
  85. package/lib/id-compressor/index.d.ts.map +1 -1
  86. package/lib/id-compressor/index.js +2 -3
  87. package/lib/id-compressor/index.js.map +1 -1
  88. package/lib/id-compressor/persisted-types/index.d.ts +1 -1
  89. package/lib/id-compressor/persisted-types/index.d.ts.map +1 -1
  90. package/lib/id-compressor/persisted-types/index.js +1 -1
  91. package/lib/id-compressor/persisted-types/index.js.map +1 -1
  92. package/lib/index.d.ts +22 -24
  93. package/lib/index.d.ts.map +1 -1
  94. package/lib/index.js +16 -19
  95. package/lib/index.js.map +1 -1
  96. package/lib/persisted-types/0.1.1.d.ts +0 -4
  97. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  98. package/lib/persisted-types/0.1.1.js +0 -4
  99. package/lib/persisted-types/0.1.1.js.map +1 -1
  100. package/lib/persisted-types/index.d.ts +2 -2
  101. package/lib/persisted-types/index.d.ts.map +1 -1
  102. package/lib/persisted-types/index.js +2 -2
  103. package/lib/persisted-types/index.js.map +1 -1
  104. package/lib/test/Checkout.tests.js +1 -1
  105. package/lib/test/Checkout.tests.js.map +1 -1
  106. package/lib/test/EditLog.tests.js +173 -78
  107. package/lib/test/EditLog.tests.js.map +1 -1
  108. package/lib/test/HistoryEditFactory.tests.js +48 -7
  109. package/lib/test/HistoryEditFactory.tests.js.map +1 -1
  110. package/lib/test/LogViewer.tests.js +106 -71
  111. package/lib/test/LogViewer.tests.js.map +1 -1
  112. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +7 -7
  113. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
  114. package/lib/test/RevisionValueCache.tests.js +8 -8
  115. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  116. package/lib/test/{Virtualization.tests.d.ts → SharedTree.fuzz.tests.d.ts} +1 -1
  117. package/lib/test/SharedTree.fuzz.tests.d.ts.map +1 -0
  118. package/lib/test/SharedTree.fuzz.tests.js +9 -0
  119. package/lib/test/SharedTree.fuzz.tests.js.map +1 -0
  120. package/lib/test/SharedTree.tests.js +0 -2
  121. package/lib/test/SharedTree.tests.js.map +1 -1
  122. package/lib/test/Summary.tests.d.ts.map +1 -1
  123. package/lib/test/Summary.tests.js +10 -28
  124. package/lib/test/Summary.tests.js.map +1 -1
  125. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  126. package/lib/test/fuzz/SharedTreeFuzzTests.js +4 -3
  127. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  128. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  129. package/lib/test/utilities/PendingLocalStateTests.js +2 -40
  130. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  131. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  132. package/lib/test/utilities/SharedTreeTests.js +27 -194
  133. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  134. package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -1
  135. package/lib/test/utilities/SummarySizeTests.js +11 -9
  136. package/lib/test/utilities/SummarySizeTests.js.map +1 -1
  137. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  138. package/lib/test/utilities/TestUtilities.js +4 -2
  139. package/lib/test/utilities/TestUtilities.js.map +1 -1
  140. package/package.json +27 -21
  141. package/src/Checkout.ts +3 -2
  142. package/src/EditLog.ts +188 -252
  143. package/src/EventTypes.ts +12 -0
  144. package/src/HistoryEditFactory.ts +24 -1
  145. package/src/LogViewer.ts +149 -69
  146. package/src/RevisionValueCache.ts +15 -10
  147. package/src/SharedTree.ts +52 -220
  148. package/src/SummaryTestUtilities.ts +3 -1
  149. package/src/id-compressor/index.ts +23 -3
  150. package/src/id-compressor/persisted-types/index.ts +14 -1
  151. package/src/index.ts +53 -36
  152. package/src/persisted-types/0.1.1.ts +0 -5
  153. package/src/persisted-types/index.ts +66 -2
  154. package/lib/test/Virtualization.tests.d.ts.map +0 -1
  155. package/lib/test/Virtualization.tests.js +0 -261
  156. package/lib/test/Virtualization.tests.js.map +0 -1
package/README.md CHANGED
@@ -134,6 +134,12 @@ function getViewAfterEdit(sharedTree: SharedTree, editId: EditId): TreeView {
134
134
  }
135
135
  ```
136
136
 
137
+ ### Listening to changes to the tree
138
+
139
+ SharedTree exposes an `EditCommitted` event which fires whenever local or remote edits are applied to the tree. Beware! This API has a severe pitfall. It is not guaranteed that the edit provided by `EditCommitted` is the most recent edit in the tree's edit log. This is because local edits are always considered to be most recent in the log, but there might be remote edits from other clients which are _sequenced before_ but _discovered after_ the local edits. Therefore, code which is using the `EditId` of the edit provided by `EditCommitted` to query the `LogViewer` requires very careful attention and is prone to bugs.
140
+
141
+ You are _strongly_ encouraged to use a `Checkout` instead which provides a cleaner and safer API for listening to changes to the tree. See "Use a Checkout" below for more information.
142
+
137
143
  ## Editing
138
144
 
139
145
  For simple edits (ones in which transactionality isn't important), `SharedTree` provides convenient, imperative APIs along the following lines:
@@ -216,17 +222,6 @@ A [Checkout](./src/Checkout.ts) is similar to a `Transaction` in that it applies
216
222
 
217
223
  > If a change failed to apply, `closeEdit` will throw an error. Detect this case by checking `getEditStatus` and calling `abortEdit` instead.
218
224
 
219
- - Change notifications are emitted when any changes are applied to the `Checkout`. This allows updating of application state even in response to changes within an ongoing edit. Notifications are also emitted when the underlying SharedTree's view changes, _unless there is an ongoing edit (i.e., `openEdit` has been called)_.
220
-
221
- ```typescript
222
- const checkout = new EagerCheckout(sharedTree);
223
- checkout.on('viewChange', (before: TreeView, after: TreeView) => {
224
- // Use the delta object as a convenient way to see which nodes were added, deleted, or changed between views
225
- const delta = after.delta(before);
226
- }));
227
-
228
- ```
229
-
230
225
  - Checkouts can rebase an edit in progress.
231
226
 
232
227
  ```typescript
@@ -239,7 +234,30 @@ A [Checkout](./src/Checkout.ts) is similar to a `Transaction` in that it applies
239
234
  checkout.closeEdit(); // This submits the changes to the tree in an edit
240
235
  ```
241
236
 
242
- - Checkout implementations can choose how often they synchronize their view with the underlying `SharedTree` when not in an edit (i.e. snapshot isolated). If you want to synchronize as frequently as possible (this is likely), use `EagerCheckout`. If you prefer to control the cadence for synchronization, `LazyCheckout` can manage this through `Checkout.waitForPendingUpdates`.
237
+ - Checkout implementations can choose how often they synchronize their view with the underlying `SharedTree` when not in an edit (i.e. snapshot isolated). If you want to synchronize as frequently as possible (this is likely), use `EagerCheckout`. If you prefer to control the cadence for synchronization, `LazyCheckout` can manage this through `Checkout.waitForPendingUpdates`. Clients may implement their own checkout if a more complicated policy is desirable.
238
+
239
+ - Checkouts provide the `viewChange` event: a convenient API for observing changes to the Checkout's `currentView`. Clients are expected to subscribe to the `viewChange` event and update their application accordingly whenever a `viewChange` happens. This is almost always desirable over the lower-level `SharedTree.EditCommitted` event because it lets app authors respond directly to changes to the content of the tree, rather than needing to be aware of the underlying edits that caused the changes. For most applications, the `viewChange` event "just works", because it follows special rules regarding when to fire. `viewChange` is fired under the following circumstances:
240
+
241
+ - If there is **not** an ongoing edit for this checkout (i.e. not between `openEdit()` and `closeEdit()`), `viewChange` is fired...
242
+ - when an edit is applied directly to the _Checkout_ by the local client
243
+ - by `EagerCheckout` when an edit is applied to the _SharedTree_ by the local or a remote client
244
+ - by `LazyCheckout` when `waitForPendingUpdates()` is called and there are outstanding edits to the tree from the local or a remote client
245
+ - If there **is** an ongoing edit for this checkout, `viewChange` is fired...
246
+ - when a change is applied to the ongoing edit in the checkout
247
+ - when the ongoing edit is rebased via `rebaseCurrentEdit()`
248
+
249
+ This policy may seem complicated at first glance, but in practice it provides a natural flow. Checkouts always notify listeners of changes that are applied directly to the checkout itself, but changes from outside the checkout (e.g. from a remote client) are buffered according to the checkout's policy. `EagerCheckout` doesn't buffer them at all and fires a change event right away, whereas `LazyCheckout` avoids firing a change event until asked (via `waitForPendingUpdates()`). Note that every kind of checkout provides [snapshot isolation](https://en.wikipedia.org/wiki/Snapshot_isolation), meaning that while the checkout is in the middle of an edit (i.e. between `openEdit()` and `closeEdit()`) it will not fire an event for changes coming from outside of the Checkout. This is desirable because it prevents the view from changing "out from under" the current edit that is being built.
250
+
251
+ The `viewChange` event also provides the previous view as well as the new view, which allows clients to generate a delta of the two views if they desire:
252
+
253
+ ```typescript
254
+ const checkout = new EagerCheckout(sharedTree);
255
+ checkout.on('viewChange', (before: TreeView, after: TreeView) => {
256
+ // Use the delta object as a convenient way to see which nodes were added, deleted, or changed between views
257
+ const delta = before.delta(after);
258
+ }));
259
+
260
+ ```
243
261
 
244
262
  ## Conflicts
245
263
 
@@ -1 +1 @@
1
- {"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,WAAW,EAA0C,MAAM,oCAAoC,CAAC;AAEtH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAA2C,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;GAGG;AACH,oBAAY,aAAa;IACxB;;;OAGG;IACH,UAAU,eAAe;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,WAAW;IACnD,CAAC,KAAK,EAAE,YAAY,EAAE,Q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SAAS;IAgBtE;;;;;;;;;;OAUG;IACI,iBAAiB,IAAI,oBAAoB,CAAC,KAAK,GAAG,oBAAoB,CAAC,OAAO;IAuBrF;;;OAGG;IACI,SAAS,IAAI,IAAI;IAOxB;;;;OAIG;IACI,aAAa,IAAI,UAAU;IAQlC;;;OAGG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYnC;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI;IAU5B;;OAEG;aACa,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtD;;;OAGG;aACa,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAErD;;;OAGG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAUnC"}
package/dist/Checkout.js CHANGED
@@ -257,10 +257,11 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
257
257
  * @param editIds - the edits to revert
258
258
  */
259
259
  revert(editId) {
260
+ var _a;
260
261
  (0, Common_1.assert)(this.currentEdit !== undefined);
261
262
  const index = this.tree.edits.getIndexOfId(editId);
262
- const edit = this.tree.edits.getEditInSessionAtIndex(index);
263
- const before = this.tree.logViewer.getRevisionViewInSession(index);
263
+ const edit = (_a = this.tree.edits.tryGetEditAtIndex(index)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('Edit with the specified ID does not exist in memory');
264
+ const before = this.tree.logViewer.getRevisionViewInMemory(index);
264
265
  const changes = this.tree.revertChanges(edit.changes, before);
265
266
  if (changes !== undefined) {
266
267
  this.tryApplyChangesInternal(changes);
@@ -1 +1 @@
1
- {"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA6F;AAE7F,qCAAwE;AAExE,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY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AI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AAnVD,4BAmVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assert, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tif (editingResult.status !== EditStatus.Applied) {\n\t\t\tconst { failure } = editingResult;\n\t\t\tconst additionalProps: ITelemetryProperties = {};\n\t\t\tswitch (failure.kind) {\n\t\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: 'FailedLocalEdit',\n\t\t\t\tstatus: editingResult.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\t\tfailureKind: editingResult.failure.kind,\n\t\t\t\t...additionalProps,\n\t\t\t});\n\t\t\tfail('Locally constructed edits must be well-formed and valid');\n\t\t}\n\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(index);\n\t\tconst before = this.tree.logViewer.getRevisionViewInSession(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
1
+ {"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA6F;AAE7F,qCAAwE;AAExE,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAMxB;AASD;;;GAGG;AACH,IAAY,oBAiBX;AAjBD,WAAY,oBAAoB;IAC/B;;;;OAIG;IACH,yEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAO,CAAA;IACP;;OAE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AAoB,CAAC,CAAC;IACzE,CAAC;CACD;AApVD,4BAoVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assert, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tif (editingResult.status !== EditStatus.Applied) {\n\t\t\tconst { failure } = editingResult;\n\t\t\tconst additionalProps: ITelemetryProperties = {};\n\t\t\tswitch (failure.kind) {\n\t\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: 'FailedLocalEdit',\n\t\t\t\tstatus: editingResult.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\t\tfailureKind: editingResult.failure.kind,\n\t\t\t\t...additionalProps,\n\t\t\t});\n\t\t\tfail('Locally constructed edits must be well-formed and valid');\n\t\t}\n\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit =\n\t\t\tthis.tree.edits.tryGetEditAtIndex(index) ?? fail('Edit with the specified ID does not exist in memory');\n\t\tconst before = this.tree.logViewer.getRevisionViewInMemory(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
package/dist/EditLog.d.ts CHANGED
@@ -11,8 +11,6 @@ import type { ChangeCompressor } from './ChangeCompression';
11
11
  /**
12
12
  * An ordered set of Edits associated with a SharedTree.
13
13
  * Supports fast lookup of edits by ID and enforces idempotence.
14
- * Edits are virtualized, however, edits added during the current session are guaranteed to be available
15
- * synchronously.
16
14
  * @public
17
15
  * @sealed
18
16
  */
@@ -40,15 +38,26 @@ export interface OrderedEditSet<TChange = unknown> {
40
38
  /**
41
39
  * @returns the edit at the given index within this `OrderedEditSet`.
42
40
  */
43
- getEditAtIndex(index: number): Promise<Edit<TChange>>;
41
+ tryGetEditAtIndex(index: number): Edit<TChange> | undefined;
44
42
  /**
45
- * @returns the edit at the given index. Must have been added to the log during the current session.
43
+ * @returns the edit with the given identifier within this `OrderedEditSet`.
46
44
  */
47
- getEditInSessionAtIndex(index: number): Edit<TChange>;
45
+ tryGetEditFromId(editId: EditId): Edit<TChange> | undefined;
48
46
  /**
49
47
  * @returns the Edit associated with the EditId or undefined if there is no such edit in the set.
48
+ * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.
50
49
  */
51
50
  tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;
51
+ /**
52
+ * @returns the edit at the given index within this `OrderedEditSet`.
53
+ * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs.
54
+ */
55
+ getEditAtIndex(index: number): Promise<Edit<TChange>>;
56
+ /**
57
+ * @returns the edit at the given index. Must have been added to the log during the current session.
58
+ * @deprecated this will be removed in favor of {@link OrderedEditSet.tryGetEditAtIndex}
59
+ */
60
+ getEditInSessionAtIndex(index: number): Edit<TChange>;
52
61
  }
53
62
  /**
54
63
  * Server-provided metadata for edits that have been sequenced.
@@ -106,6 +115,7 @@ export interface EditLogEncoder {
106
115
  }
107
116
  /**
108
117
  * A sequence of edits that may or may not need to be downloaded into the EditLog from an external service
118
+ * @deprecated Edit virtualization is no longer supported.
109
119
  */
110
120
  export interface EditChunk<TChange> {
111
121
  handle?: EditHandle<TChange>;
@@ -114,6 +124,7 @@ export interface EditChunk<TChange> {
114
124
  /**
115
125
  * EditHandles are used to load edit chunks stored outside of the EditLog.
116
126
  * This is typically implemented by a wrapper around an IFluidHandle<ArrayBufferLike>.
127
+ * @deprecated Edit virtualization is no longer supported.
117
128
  * @public
118
129
  */
119
130
  export interface EditHandle<TChange> {
@@ -130,6 +141,7 @@ export declare function separateEditAndId<TChange>(edit: Edit<TChange>): {
130
141
  /**
131
142
  * @param summary - The edit log summary to parse.
132
143
  * @returns the number of handles saved to the provided edit log summary.
144
+ * @deprecated Edit virtualization is no longer supported.
133
145
  */
134
146
  export declare function getNumberOfHandlesFromEditLogSummary(summary: EditLogSummary<unknown, unknown>): number;
135
147
  /**
@@ -139,7 +151,13 @@ export declare function getNumberOfHandlesFromEditLogSummary(summary: EditLogSum
139
151
  */
140
152
  export declare type EditAddedHandler<TChange> = (edit: Edit<TChange>, isLocal: boolean, wasLocal: boolean) => void;
141
153
  /**
142
- * Events which may be emitted by `EditLog`.
154
+ * Event fired before edits are evicted from the edit log. It takes in a count of the number of edits to evict
155
+ * starting from the oldest in memory edit. To get the edit itself, call {@link EditLog.getEditAtIndex}.
156
+ * The edit index corresponds to the count + {@link EditLog.earliestAvailableEditIndex}.
157
+ */
158
+ export declare type EditEvictionHandler = (editsToEvict: number) => void;
159
+ /**
160
+ * Events which may be emitted by {@link EditLog}
143
161
  * @public
144
162
  */
145
163
  export interface IEditLogEvents extends IEvent {
@@ -153,23 +171,21 @@ export interface IEditLogEvents extends IEvent {
153
171
  * @sealed
154
172
  */
155
173
  export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditLogEvents> implements OrderedEditSet<TChange> {
174
+ private readonly logger?;
175
+ private readonly targetLength;
176
+ private readonly evictionFrequency;
156
177
  private localEditSequence;
178
+ private readonly sequenceNumberToIndex;
157
179
  private _minSequenceNumber;
158
- private readonly sequencedEditIds;
159
- private readonly editChunks;
180
+ private readonly sequencedEdits;
160
181
  private readonly localEdits;
161
- private readonly loadedChunkCache;
162
- private readonly indexOfFirstEditInSession;
163
- private readonly maximumEvictableIndex;
164
182
  private readonly allEditIds;
183
+ private _earliestAvailableEditIndex;
165
184
  private readonly _editAddedHandlers;
166
- private readonly logger?;
167
- /**
168
- * The number of edits associated with each blob.
169
- */
170
- readonly editsPerChunk: number;
185
+ private readonly _editEvictionHandlers;
171
186
  /**
172
- * @returns The index of the earliest edit available through `getEditInSessionAtIndex`.
187
+ * @returns The index of the earliest edit stored in this log.
188
+ * Edit indices are unique and strictly increasing within the session.
173
189
  */
174
190
  get earliestAvailableEditIndex(): number;
175
191
  /**
@@ -180,8 +196,17 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
180
196
  * Construct an `EditLog` using the given options.
181
197
  * @param summary - An edit log summary used to populate the edit log.
182
198
  * @param logger - An optional logger to record telemetry/errors
183
- */
184
- constructor(summary?: EditLogSummary<TChange, EditHandle<TChange>>, logger?: ITelemetryLogger, editAddedHandlers?: readonly EditAddedHandler<TChange>[], indexOfFirstEditInSession?: number);
199
+ * @param editAddedHandlers - Optional handlers that are called when edits are added.
200
+ * @param targetLength - The target number of sequenced edits that the log will try to store in memory.
201
+ * Depending on eviction frequency and the collaboration window, there can be more edits in memory at a given time.
202
+ * Edits greater than or equal to the `minSequenceNumber` (aka in the collaboration window) are not evicted.
203
+ * @param evictionFrequency - The rate at which edits are evicted from memory. This is a factor of the editLogSize.
204
+ * For example, with the default frequency of inMemoryHistorySize * 2 and a size of 10, the log will evict once it reaches 20 sequenced edits
205
+ * down to 10 edits, also keeping any that are still in the collaboration window.
206
+ * @param editEvictionHandlers - Handlers that are called before edits are evicted from memory. This provides a chance for
207
+ * callers to work with the edits before they are lost.
208
+ */
209
+ constructor(summary?: EditLogSummary<TChange, EditHandle<TChange>>, logger?: ITelemetryLogger | undefined, editAddedHandlers?: readonly EditAddedHandler<TChange>[], targetLength?: number, evictionFrequency?: number, editEvictionHandlers?: readonly EditEvictionHandler[]);
185
210
  /**
186
211
  * Registers a handler for when an edit is added to this `EditLog`.
187
212
  * @returns A callback which can be invoked to unregister this handler.
@@ -191,6 +216,15 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
191
216
  * @returns the `EditAddedHandler`s registered on this `EditLog`.
192
217
  */
193
218
  get editAddedHandlers(): readonly EditAddedHandler<TChange>[];
219
+ /**
220
+ * Registers a handler that is called before an edit is evicted from this `EditLog`.
221
+ * @returns A callback which can be invoked to unregister this handler.
222
+ */
223
+ registerEditEvictionHandler(handler: EditEvictionHandler): () => void;
224
+ /**
225
+ * @returns the `EditEvictedHandler`s registered on this `EditLog`.
226
+ */
227
+ get editEvictedHandlers(): readonly EditEvictionHandler[];
194
228
  /**
195
229
  * {@inheritDoc OrderedEditSet.length}
196
230
  */
@@ -232,25 +266,13 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
232
266
  */
233
267
  getIdAtIndex(index: number): EditId;
234
268
  /**
235
- * {@inheritDoc OrderedEditSet.getEditAtIndex}
236
- */
237
- getEditAtIndex(index: number): Promise<Edit<TChange>>;
238
- /**
239
- * {@inheritDoc OrderedEditSet.getEditInSessionAtIndex}
269
+ * {@inheritDoc OrderedEditSet.tryGetEditAtIndex}
240
270
  */
241
- getEditInSessionAtIndex(index: number): Edit<TChange>;
271
+ tryGetEditAtIndex(index: number): Edit<TChange> | undefined;
242
272
  /**
243
- * {@inheritDoc OrderedEditSet.tryGetEdit}
273
+ * {@inheritDoc OrderedEditSet.tryGetEditFromId}
244
274
  */
245
- tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;
246
- /**
247
- * @returns The edits of edit chunks that do not have associated edit handles, does not include the last edit chunk if it is not full.
248
- */
249
- getEditChunksReadyForUpload(): Iterable<[number, readonly EditWithoutId<TChange>[]]>;
250
- /**
251
- * Assigns provided handles to edit chunks based on chunk index specified.
252
- */
253
- processEditChunkHandle(chunkHandle: EditHandle<TChange>, startRevision: number): void;
275
+ tryGetEditFromId(editId: EditId): Edit<TChange> | undefined;
254
276
  /**
255
277
  * Sequences all local edits.
256
278
  */
@@ -272,19 +294,13 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
272
294
  * If the id of the supplied edit matches a local edit already present in the log, the local edit will be replaced.
273
295
  */
274
296
  private addSequencedEditInternal;
275
- /**
276
- * @returns The last edit chunk i.e. the chunk which the most recent sequenced edits have been placed into, as well as its starting revision.
277
- * Returns undefined iff there are no sequenced edits.
278
- * When defined, this chunk is guaranteed to contain at least one edit
279
- * (though it may be necessary to load the chunk via its handle to use it)
280
- */
281
- getLastEditChunk(): [startRevision: number, edits: EditChunk<TChange>] | undefined;
282
297
  /**
283
298
  * Adds a non-sequenced (local) edit to the edit log.
284
299
  * Duplicate edits are ignored.
285
300
  */
286
301
  addLocalEdit(edit: Edit<TChange>): void;
287
302
  private emitAdd;
303
+ private evictEdits;
288
304
  /**
289
305
  * @returns true iff this `EditLog` and `other` are equivalent, regardless of locality.
290
306
  */
@@ -300,6 +316,17 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
300
316
  * @internal
301
317
  */
302
318
  getEditLogSummary<TCompressedChange>(compressEdit: (edit: Pick<Edit<TChange>, 'changes'>) => Pick<Edit<TCompressedChange>, 'changes'>): EditLogSummary<TCompressedChange, FluidEditHandle>;
303
- private addKeyToCache;
319
+ /**
320
+ * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.
321
+ */
322
+ tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;
323
+ /**
324
+ * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.
325
+ */
326
+ getEditAtIndex(index: number): Promise<Edit<TChange>>;
327
+ /**
328
+ * @deprecated Edit virtualization is no longer supported. Instead, use {@link OrderedEditSet.tryGetEditFromId}.
329
+ */
330
+ getEditInSessionAtIndex(index: number): Edit<TChange>;
304
331
  }
305
332
  //# sourceMappingURL=EditLog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditLog.d.ts","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAiB,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO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