@fluid-experimental/tree 0.58.2001 → 0.59.1000-61898
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.
- package/README.md +9 -9
- package/dist/ChangeCompression.d.ts +39 -0
- package/dist/ChangeCompression.d.ts.map +1 -0
- package/dist/ChangeCompression.js +117 -0
- package/dist/ChangeCompression.js.map +1 -0
- package/{lib/default-edits/PersistedTypes.d.ts → dist/ChangeTypes.d.ts} +58 -100
- package/dist/ChangeTypes.d.ts.map +1 -0
- package/dist/{default-edits/PersistedTypes.js → ChangeTypes.js} +21 -76
- package/dist/ChangeTypes.js.map +1 -0
- package/dist/Checkout.d.ts +39 -27
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +59 -31
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +175 -38
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +240 -103
- package/dist/Common.js.map +1 -1
- package/dist/EagerCheckout.d.ts +24 -0
- package/dist/EagerCheckout.d.ts.map +1 -0
- package/dist/{BasicCheckout.js → EagerCheckout.js} +9 -6
- package/dist/EagerCheckout.js.map +1 -0
- package/dist/EditLog.d.ts +77 -63
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +85 -48
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +168 -0
- package/dist/EditUtilities.d.ts.map +1 -0
- package/dist/EditUtilities.js +373 -0
- package/dist/EditUtilities.js.map +1 -0
- package/dist/EventTypes.d.ts +73 -0
- package/dist/EventTypes.d.ts.map +1 -0
- package/dist/EventTypes.js +78 -0
- package/dist/EventTypes.js.map +1 -0
- package/dist/Forest.d.ts +29 -7
- package/dist/Forest.d.ts.map +1 -1
- package/dist/Forest.js +60 -36
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.d.ts +20 -0
- package/dist/HistoryEditFactory.d.ts.map +1 -0
- package/dist/HistoryEditFactory.js +226 -0
- package/dist/HistoryEditFactory.js.map +1 -0
- package/dist/IdConversion.d.ts +12 -0
- package/dist/IdConversion.d.ts.map +1 -0
- package/dist/IdConversion.js +98 -0
- package/dist/IdConversion.js.map +1 -0
- package/dist/Identifiers.d.ts +89 -2
- package/dist/Identifiers.d.ts.map +1 -1
- package/dist/Identifiers.js +10 -0
- package/dist/Identifiers.js.map +1 -1
- package/dist/InitialTree.d.ts +2 -2
- package/dist/InitialTree.d.ts.map +1 -1
- package/dist/InitialTree.js +2 -1
- package/dist/InitialTree.js.map +1 -1
- package/dist/LazyCheckout.d.ts +28 -0
- package/dist/LazyCheckout.d.ts.map +1 -0
- package/dist/LazyCheckout.js +44 -0
- package/dist/LazyCheckout.js.map +1 -0
- package/dist/LogViewer.d.ts +130 -85
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +110 -85
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.d.ts +221 -0
- package/dist/MergeHealth.d.ts.map +1 -0
- package/dist/MergeHealth.js +263 -0
- package/dist/MergeHealth.js.map +1 -0
- package/dist/NodeIdUtilities.d.ts +90 -0
- package/dist/NodeIdUtilities.d.ts.map +1 -0
- package/dist/NodeIdUtilities.js +60 -0
- package/dist/NodeIdUtilities.js.map +1 -0
- package/dist/PayloadUtilities.d.ts +42 -0
- package/dist/PayloadUtilities.d.ts.map +1 -0
- package/dist/PayloadUtilities.js +114 -0
- package/dist/PayloadUtilities.js.map +1 -0
- package/dist/ReconciliationPath.d.ts +18 -13
- package/dist/ReconciliationPath.d.ts.map +1 -1
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +11 -2
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +2 -3
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +83 -0
- package/dist/RevisionView.d.ts.map +1 -0
- package/dist/RevisionView.js +182 -0
- package/dist/RevisionView.js.map +1 -0
- package/dist/SerializationUtilities.d.ts +36 -0
- package/dist/SerializationUtilities.d.ts.map +1 -0
- package/dist/SerializationUtilities.js +102 -0
- package/dist/SerializationUtilities.js.map +1 -0
- package/dist/SharedTree.d.ts +400 -0
- package/dist/SharedTree.d.ts.map +1 -0
- package/dist/SharedTree.js +1074 -0
- package/dist/SharedTree.js.map +1 -0
- package/dist/SharedTreeEncoder.d.ts +102 -0
- package/dist/SharedTreeEncoder.d.ts.map +1 -0
- package/dist/SharedTreeEncoder.js +313 -0
- package/dist/SharedTreeEncoder.js.map +1 -0
- package/dist/StringInterner.d.ts +46 -0
- package/dist/StringInterner.d.ts.map +1 -0
- package/dist/StringInterner.js +61 -0
- package/dist/StringInterner.js.map +1 -0
- package/dist/Summary.d.ts +40 -0
- package/dist/Summary.d.ts.map +1 -0
- package/dist/Summary.js +23 -0
- package/dist/Summary.js.map +1 -0
- package/dist/SummaryBackCompatibility.d.ts +22 -22
- package/dist/SummaryBackCompatibility.d.ts.map +1 -1
- package/dist/SummaryBackCompatibility.js +30 -33
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/SummaryTestUtilities.d.ts +31 -0
- package/dist/SummaryTestUtilities.d.ts.map +1 -0
- package/dist/SummaryTestUtilities.js +37 -0
- package/dist/SummaryTestUtilities.js.map +1 -0
- package/dist/Transaction.d.ts +53 -0
- package/dist/Transaction.d.ts.map +1 -0
- package/dist/Transaction.js +76 -0
- package/dist/Transaction.js.map +1 -0
- package/dist/TransactionInternal.d.ts +543 -0
- package/dist/TransactionInternal.d.ts.map +1 -0
- package/dist/TransactionInternal.js +622 -0
- package/dist/TransactionInternal.js.map +1 -0
- package/dist/TreeCompressor.d.ts +36 -0
- package/dist/TreeCompressor.d.ts.map +1 -0
- package/dist/TreeCompressor.js +137 -0
- package/dist/TreeCompressor.js.map +1 -0
- package/dist/TreeNodeHandle.d.ts +12 -18
- package/dist/TreeNodeHandle.d.ts.map +1 -1
- package/dist/TreeNodeHandle.js +13 -23
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.d.ts +166 -0
- package/dist/TreeView.d.ts.map +1 -0
- package/dist/TreeView.js +218 -0
- package/dist/TreeView.js.map +1 -0
- package/dist/TreeViewUtilities.d.ts +21 -0
- package/dist/TreeViewUtilities.d.ts.map +1 -0
- package/dist/TreeViewUtilities.js +77 -0
- package/dist/TreeViewUtilities.js.map +1 -0
- package/dist/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
- package/dist/UndoRedoHandler.d.ts.map +1 -0
- package/dist/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +5 -9
- package/dist/UndoRedoHandler.js.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts +127 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.js +283 -0
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -0
- package/dist/id-compressor/IdCompressor.d.ts +389 -0
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -0
- package/dist/id-compressor/IdCompressor.js +1353 -0
- package/dist/id-compressor/IdCompressor.js.map +1 -0
- package/dist/id-compressor/IdRange.d.ts +11 -0
- package/dist/id-compressor/IdRange.d.ts.map +1 -0
- package/dist/id-compressor/IdRange.js +29 -0
- package/dist/id-compressor/IdRange.js.map +1 -0
- package/dist/id-compressor/NumericUuid.d.ts +63 -0
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -0
- package/dist/id-compressor/NumericUuid.js +377 -0
- package/dist/id-compressor/NumericUuid.js.map +1 -0
- package/dist/id-compressor/index.d.ts +12 -0
- package/dist/id-compressor/index.d.ts.map +1 -0
- package/dist/id-compressor/index.js +26 -0
- package/dist/id-compressor/index.js.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +156 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.js +7 -0
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -0
- package/dist/id-compressor/persisted-types/index.d.ts +6 -0
- package/dist/id-compressor/persisted-types/index.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/index.js +18 -0
- package/dist/id-compressor/persisted-types/index.js.map +1 -0
- package/dist/index.d.ts +29 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -35
- package/dist/index.js.map +1 -1
- package/dist/persisted-types/0.0.2.d.ts +385 -0
- package/dist/persisted-types/0.0.2.d.ts.map +1 -0
- package/dist/persisted-types/0.0.2.js +113 -0
- package/dist/persisted-types/0.0.2.js.map +1 -0
- package/dist/persisted-types/0.1.1.d.ts +314 -0
- package/dist/persisted-types/0.1.1.d.ts.map +1 -0
- package/dist/persisted-types/0.1.1.js +153 -0
- package/dist/persisted-types/0.1.1.js.map +1 -0
- package/dist/persisted-types/index.d.ts +7 -0
- package/dist/persisted-types/index.d.ts.map +1 -0
- package/dist/persisted-types/index.js +20 -0
- package/dist/persisted-types/index.js.map +1 -0
- package/docs/0-1-1-Compression.md +228 -0
- package/docs/Breaking-Change-Migration.md +52 -0
- package/docs/Compression.md +2 -2
- package/docs/Telemetry.md +43 -0
- package/lib/ChangeCompression.d.ts +39 -0
- package/lib/ChangeCompression.d.ts.map +1 -0
- package/lib/ChangeCompression.js +111 -0
- package/lib/ChangeCompression.js.map +1 -0
- package/{dist/default-edits/PersistedTypes.d.ts → lib/ChangeTypes.d.ts} +58 -100
- package/lib/ChangeTypes.d.ts.map +1 -0
- package/lib/{default-edits/PersistedTypes.js → ChangeTypes.js} +15 -68
- package/lib/ChangeTypes.js.map +1 -0
- package/lib/Checkout.d.ts +39 -27
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +51 -23
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +175 -38
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +226 -101
- package/lib/Common.js.map +1 -1
- package/lib/EagerCheckout.d.ts +24 -0
- package/lib/EagerCheckout.d.ts.map +1 -0
- package/lib/{BasicCheckout.js → EagerCheckout.js} +7 -4
- package/lib/EagerCheckout.js.map +1 -0
- package/lib/EditLog.d.ts +77 -63
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +83 -47
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +168 -0
- package/lib/EditUtilities.d.ts.map +1 -0
- package/lib/EditUtilities.js +353 -0
- package/lib/EditUtilities.js.map +1 -0
- package/lib/EventTypes.d.ts +73 -0
- package/lib/EventTypes.d.ts.map +1 -0
- package/lib/EventTypes.js +75 -0
- package/lib/EventTypes.js.map +1 -0
- package/lib/Forest.d.ts +29 -7
- package/lib/Forest.d.ts.map +1 -1
- package/lib/Forest.js +58 -35
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +20 -0
- package/lib/HistoryEditFactory.d.ts.map +1 -0
- package/lib/{default-edits/HistoryEditFactory.js → HistoryEditFactory.js} +78 -39
- package/lib/HistoryEditFactory.js.map +1 -0
- package/lib/IdConversion.d.ts +12 -0
- package/lib/IdConversion.d.ts.map +1 -0
- package/lib/IdConversion.js +91 -0
- package/lib/IdConversion.js.map +1 -0
- package/lib/Identifiers.d.ts +89 -2
- package/lib/Identifiers.d.ts.map +1 -1
- package/lib/Identifiers.js +8 -1
- package/lib/Identifiers.js.map +1 -1
- package/lib/InitialTree.d.ts +2 -2
- package/lib/InitialTree.d.ts.map +1 -1
- package/lib/InitialTree.js +2 -1
- package/lib/InitialTree.js.map +1 -1
- package/lib/LazyCheckout.d.ts +28 -0
- package/lib/LazyCheckout.d.ts.map +1 -0
- package/lib/LazyCheckout.js +40 -0
- package/lib/LazyCheckout.js.map +1 -0
- package/lib/LogViewer.d.ts +130 -85
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +102 -77
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.d.ts +221 -0
- package/lib/MergeHealth.d.ts.map +1 -0
- package/lib/MergeHealth.js +258 -0
- package/lib/MergeHealth.js.map +1 -0
- package/lib/NodeIdUtilities.d.ts +90 -0
- package/lib/NodeIdUtilities.d.ts.map +1 -0
- package/lib/NodeIdUtilities.js +53 -0
- package/lib/NodeIdUtilities.js.map +1 -0
- package/lib/PayloadUtilities.d.ts +42 -0
- package/lib/PayloadUtilities.d.ts.map +1 -0
- package/lib/PayloadUtilities.js +110 -0
- package/lib/PayloadUtilities.js.map +1 -0
- package/lib/ReconciliationPath.d.ts +18 -13
- package/lib/ReconciliationPath.d.ts.map +1 -1
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +11 -2
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +2 -3
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +83 -0
- package/lib/RevisionView.d.ts.map +1 -0
- package/lib/RevisionView.js +175 -0
- package/lib/RevisionView.js.map +1 -0
- package/lib/SerializationUtilities.d.ts +36 -0
- package/lib/SerializationUtilities.d.ts.map +1 -0
- package/lib/SerializationUtilities.js +95 -0
- package/lib/SerializationUtilities.js.map +1 -0
- package/lib/SharedTree.d.ts +400 -0
- package/lib/SharedTree.d.ts.map +1 -0
- package/lib/SharedTree.js +1069 -0
- package/lib/SharedTree.js.map +1 -0
- package/lib/SharedTreeEncoder.d.ts +102 -0
- package/lib/SharedTreeEncoder.d.ts.map +1 -0
- package/lib/SharedTreeEncoder.js +308 -0
- package/lib/SharedTreeEncoder.js.map +1 -0
- package/lib/StringInterner.d.ts +46 -0
- package/lib/StringInterner.d.ts.map +1 -0
- package/lib/StringInterner.js +57 -0
- package/lib/StringInterner.js.map +1 -0
- package/lib/Summary.d.ts +40 -0
- package/lib/Summary.d.ts.map +1 -0
- package/lib/Summary.js +19 -0
- package/lib/Summary.js.map +1 -0
- package/lib/SummaryBackCompatibility.d.ts +22 -22
- package/lib/SummaryBackCompatibility.d.ts.map +1 -1
- package/lib/SummaryBackCompatibility.js +29 -32
- package/lib/SummaryBackCompatibility.js.map +1 -1
- package/lib/SummaryTestUtilities.d.ts +31 -0
- package/lib/SummaryTestUtilities.d.ts.map +1 -0
- package/lib/SummaryTestUtilities.js +32 -0
- package/lib/SummaryTestUtilities.js.map +1 -0
- package/lib/Transaction.d.ts +53 -0
- package/lib/Transaction.d.ts.map +1 -0
- package/lib/Transaction.js +72 -0
- package/lib/Transaction.js.map +1 -0
- package/lib/TransactionInternal.d.ts +543 -0
- package/lib/TransactionInternal.d.ts.map +1 -0
- package/lib/TransactionInternal.js +618 -0
- package/lib/TransactionInternal.js.map +1 -0
- package/lib/TreeCompressor.d.ts +36 -0
- package/lib/TreeCompressor.d.ts.map +1 -0
- package/lib/TreeCompressor.js +133 -0
- package/lib/TreeCompressor.js.map +1 -0
- package/lib/TreeNodeHandle.d.ts +12 -18
- package/lib/TreeNodeHandle.d.ts.map +1 -1
- package/lib/TreeNodeHandle.js +14 -24
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.d.ts +166 -0
- package/lib/TreeView.d.ts.map +1 -0
- package/lib/TreeView.js +214 -0
- package/lib/TreeView.js.map +1 -0
- package/lib/TreeViewUtilities.d.ts +21 -0
- package/lib/TreeViewUtilities.d.ts.map +1 -0
- package/lib/TreeViewUtilities.js +71 -0
- package/lib/TreeViewUtilities.js.map +1 -0
- package/lib/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
- package/lib/UndoRedoHandler.d.ts.map +1 -0
- package/lib/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +3 -7
- package/lib/UndoRedoHandler.js.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts +127 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.js +278 -0
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -0
- package/lib/id-compressor/IdCompressor.d.ts +389 -0
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -0
- package/lib/id-compressor/IdCompressor.js +1343 -0
- package/lib/id-compressor/IdCompressor.js.map +1 -0
- package/lib/id-compressor/IdRange.d.ts +11 -0
- package/lib/id-compressor/IdRange.d.ts.map +1 -0
- package/lib/id-compressor/IdRange.js +25 -0
- package/lib/id-compressor/IdRange.js.map +1 -0
- package/lib/id-compressor/NumericUuid.d.ts +63 -0
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -0
- package/lib/id-compressor/NumericUuid.js +365 -0
- package/lib/id-compressor/NumericUuid.js.map +1 -0
- package/lib/id-compressor/index.d.ts +12 -0
- package/lib/id-compressor/index.d.ts.map +1 -0
- package/lib/id-compressor/index.js +12 -0
- package/lib/id-compressor/index.js.map +1 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +156 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
- package/lib/{test/Snapshot.tests.d.ts → id-compressor/persisted-types/0.0.1.js} +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -0
- package/lib/id-compressor/persisted-types/index.d.ts +6 -0
- package/lib/id-compressor/persisted-types/index.d.ts.map +1 -0
- package/lib/id-compressor/persisted-types/index.js +6 -0
- package/lib/id-compressor/persisted-types/index.js.map +1 -0
- package/lib/index.d.ts +29 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +23 -6
- package/lib/index.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +385 -0
- package/lib/persisted-types/0.0.2.d.ts.map +1 -0
- package/lib/persisted-types/0.0.2.js +110 -0
- package/lib/persisted-types/0.0.2.js.map +1 -0
- package/lib/persisted-types/0.1.1.d.ts +314 -0
- package/lib/persisted-types/0.1.1.d.ts.map +1 -0
- package/lib/persisted-types/0.1.1.js +150 -0
- package/lib/persisted-types/0.1.1.js.map +1 -0
- package/lib/persisted-types/index.d.ts +7 -0
- package/lib/persisted-types/index.d.ts.map +1 -0
- package/lib/persisted-types/index.js +8 -0
- package/lib/persisted-types/index.js.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.d.ts +6 -0
- package/lib/test/AppendOnlySortedMap.tests.d.ts.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.js +169 -0
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -0
- package/lib/test/{SnapshotUtilities.tests.d.ts → ChangeCompression.tests.d.ts} +1 -1
- package/lib/test/ChangeCompression.tests.d.ts.map +1 -0
- package/lib/test/ChangeCompression.tests.js +145 -0
- package/lib/test/ChangeCompression.tests.js.map +1 -0
- package/lib/test/Checkout.tests.d.ts +2 -3
- package/lib/test/Checkout.tests.d.ts.map +1 -1
- package/lib/test/Checkout.tests.js +126 -69
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Common.tests.js +60 -2
- package/lib/test/Common.tests.js.map +1 -1
- package/lib/test/{BasicCheckout.tests.d.ts → EagerCheckout.tests.d.ts} +1 -1
- package/lib/test/EagerCheckout.tests.d.ts.map +1 -0
- package/lib/test/EagerCheckout.tests.js +20 -0
- package/lib/test/EagerCheckout.tests.js.map +1 -0
- package/lib/test/Edit.tests.js +22 -14
- package/lib/test/Edit.tests.js.map +1 -1
- package/lib/test/{Anchors.glassBox.tests.d.ts → EditLog.perf.tests.d.ts} +1 -1
- package/lib/test/EditLog.perf.tests.d.ts.map +1 -0
- package/lib/test/EditLog.perf.tests.js +30 -0
- package/lib/test/EditLog.perf.tests.js.map +1 -0
- package/lib/test/EditLog.tests.js +10 -6
- package/lib/test/EditLog.tests.js.map +1 -1
- package/lib/test/EditUtilities.tests.d.ts +6 -0
- package/lib/test/EditUtilities.tests.d.ts.map +1 -0
- package/lib/test/EditUtilities.tests.js +503 -0
- package/lib/test/EditUtilities.tests.js.map +1 -0
- package/lib/test/Forest.perf.tests.d.ts +6 -0
- package/lib/test/Forest.perf.tests.d.ts.map +1 -0
- package/lib/test/Forest.perf.tests.js +133 -0
- package/lib/test/Forest.perf.tests.js.map +1 -0
- package/lib/test/Forest.tests.js +54 -27
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/GenericTransaction.tests.js +12 -3
- package/lib/test/GenericTransaction.tests.js.map +1 -1
- package/lib/test/HistoryEditFactory.tests.d.ts +6 -0
- package/lib/test/HistoryEditFactory.tests.d.ts.map +1 -0
- package/lib/test/HistoryEditFactory.tests.js +90 -0
- package/lib/test/HistoryEditFactory.tests.js.map +1 -0
- package/lib/test/IdCompressor.perf.tests.d.ts +6 -0
- package/lib/test/IdCompressor.perf.tests.d.ts.map +1 -0
- package/lib/test/IdCompressor.perf.tests.js +304 -0
- package/lib/test/IdCompressor.perf.tests.js.map +1 -0
- package/lib/test/IdCompressor.tests.d.ts +6 -0
- package/lib/test/IdCompressor.tests.d.ts.map +1 -0
- package/lib/test/IdCompressor.tests.js +1075 -0
- package/lib/test/IdCompressor.tests.js.map +1 -0
- package/lib/test/IdConversion.tests.d.ts +6 -0
- package/lib/test/IdConversion.tests.d.ts.map +1 -0
- package/lib/test/IdConversion.tests.js +36 -0
- package/lib/test/IdConversion.tests.js.map +1 -0
- package/lib/test/LazyCheckout.tests.d.ts +6 -0
- package/lib/test/LazyCheckout.tests.d.ts.map +1 -0
- package/lib/test/LazyCheckout.tests.js +22 -0
- package/lib/test/LazyCheckout.tests.js.map +1 -0
- package/lib/test/LogViewer.tests.js +269 -187
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/{SharedTreeWithAnchors.tests.d.ts → MergeHealthTelemetryHeartbeat.tests.d.ts} +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.d.ts.map +1 -0
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +342 -0
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -0
- package/lib/test/NumericUuid.perf.tests.d.ts +6 -0
- package/lib/test/NumericUuid.perf.tests.d.ts.map +1 -0
- package/lib/test/NumericUuid.perf.tests.js +68 -0
- package/lib/test/NumericUuid.perf.tests.js.map +1 -0
- package/lib/test/NumericUuid.tests.d.ts +6 -0
- package/lib/test/NumericUuid.tests.d.ts.map +1 -0
- package/lib/test/NumericUuid.tests.js +191 -0
- package/lib/test/NumericUuid.tests.js.map +1 -0
- package/lib/test/RevisionView.tests.d.ts +6 -0
- package/lib/test/RevisionView.tests.d.ts.map +1 -0
- package/lib/test/RevisionView.tests.js +133 -0
- package/lib/test/RevisionView.tests.js.map +1 -0
- package/lib/test/SharedTree.perf.tests.d.ts +6 -0
- package/lib/test/SharedTree.perf.tests.d.ts.map +1 -0
- package/lib/test/SharedTree.perf.tests.js +39 -0
- package/lib/test/SharedTree.perf.tests.js.map +1 -0
- package/lib/test/SharedTree.tests.js +15 -3
- package/lib/test/SharedTree.tests.js.map +1 -1
- package/lib/test/StringInterner.tests.d.ts +6 -0
- package/lib/test/StringInterner.tests.d.ts.map +1 -0
- package/lib/test/StringInterner.tests.js +71 -0
- package/lib/test/StringInterner.tests.js.map +1 -0
- package/lib/test/Summary.tests.d.ts +8 -0
- package/lib/test/Summary.tests.d.ts.map +1 -0
- package/lib/test/Summary.tests.js +407 -0
- package/lib/test/Summary.tests.js.map +1 -0
- package/lib/test/Transaction.tests.js +76 -330
- package/lib/test/Transaction.tests.js.map +1 -1
- package/lib/test/TransactionInternal.tests.d.ts +6 -0
- package/lib/test/TransactionInternal.tests.d.ts.map +1 -0
- package/lib/test/TransactionInternal.tests.js +568 -0
- package/lib/test/TransactionInternal.tests.js.map +1 -0
- package/lib/test/TreeCompression.tests.d.ts +6 -0
- package/lib/test/TreeCompression.tests.d.ts.map +1 -0
- package/lib/test/TreeCompression.tests.js +292 -0
- package/lib/test/TreeCompression.tests.js.map +1 -0
- package/lib/test/TreeView.tests.d.ts +6 -0
- package/lib/test/TreeView.tests.d.ts.map +1 -0
- package/lib/test/TreeView.tests.js +176 -0
- package/lib/test/TreeView.tests.js.map +1 -0
- package/lib/test/UndoRedoHandler.tests.js +2 -2
- package/lib/test/UndoRedoHandler.tests.js.map +1 -1
- package/lib/test/Virtualization.tests.js +147 -62
- package/lib/test/Virtualization.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts +19 -0
- package/lib/test/fuzz/Generators.d.ts.map +1 -0
- package/lib/test/fuzz/Generators.js +420 -0
- package/lib/test/fuzz/Generators.js.map +1 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +20 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.js +217 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -0
- package/lib/test/fuzz/Types.d.ts +133 -0
- package/lib/test/fuzz/Types.d.ts.map +1 -0
- package/lib/test/{GenericTransactionWithAnchors.tests.d.ts → fuzz/Types.js} +2 -2
- package/lib/test/fuzz/Types.js.map +1 -0
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +180 -0
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -0
- package/lib/test/utilities/IdCompressorTestUtilities.js +528 -0
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -0
- package/lib/test/utilities/MockTransaction.d.ts +26 -7
- package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
- package/lib/test/utilities/MockTransaction.js +40 -11
- package/lib/test/utilities/MockTransaction.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts +12 -0
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -0
- package/lib/test/utilities/PendingLocalStateTests.js +105 -0
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -0
- package/lib/test/utilities/SharedTreeTests.d.ts +3 -4
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +696 -439
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts +11 -0
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js +370 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -0
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts +10 -0
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -0
- package/lib/test/utilities/SummaryLoadPerfTests.js +102 -0
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -0
- package/lib/test/utilities/SummarySizeTests.d.ts +11 -0
- package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -0
- package/lib/test/utilities/SummarySizeTests.js +158 -0
- package/lib/test/utilities/SummarySizeTests.js.map +1 -0
- package/lib/test/utilities/TestCommon.d.ts +9 -0
- package/lib/test/utilities/TestCommon.d.ts.map +1 -0
- package/lib/test/utilities/TestCommon.js +13 -0
- package/lib/test/utilities/TestCommon.js.map +1 -0
- package/lib/test/utilities/TestNode.d.ts +140 -0
- package/lib/test/utilities/TestNode.d.ts.map +1 -0
- package/lib/test/utilities/TestNode.js +292 -0
- package/lib/test/utilities/TestNode.js.map +1 -0
- package/lib/test/utilities/TestUtilities.d.ts +84 -70
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +218 -143
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/lib/test/utilities/UndoRedoTests.d.ts +4 -5
- package/lib/test/utilities/UndoRedoTests.d.ts.map +1 -1
- package/lib/test/utilities/UndoRedoTests.js +138 -149
- package/lib/test/utilities/UndoRedoTests.js.map +1 -1
- package/package.json +22 -17
- package/src/ChangeCompression.ts +159 -0
- package/src/{default-edits/PersistedTypes.ts → ChangeTypes.ts} +62 -120
- package/src/Checkout.ts +81 -52
- package/src/Common.ts +317 -117
- package/src/EagerCheckout.ts +38 -0
- package/src/EditLog.ts +153 -100
- package/src/EditUtilities.ts +559 -0
- package/src/EventTypes.ts +74 -0
- package/src/Forest.ts +81 -73
- package/src/{default-edits/HistoryEditFactory.ts → HistoryEditFactory.ts} +103 -53
- package/src/IdConversion.ts +125 -0
- package/src/Identifiers.ts +101 -1
- package/src/InitialTree.ts +5 -4
- package/src/LazyCheckout.ts +51 -0
- package/src/LogViewer.ts +242 -166
- package/src/MergeHealth.ts +447 -0
- package/src/NodeIdUtilities.ts +141 -0
- package/src/PayloadUtilities.ts +124 -0
- package/src/ReconciliationPath.ts +18 -13
- package/src/RevisionValueCache.ts +14 -5
- package/src/RevisionView.ts +252 -0
- package/src/SerializationUtilities.ts +130 -0
- package/src/SharedTree.ts +1458 -0
- package/src/SharedTreeEncoder.ts +493 -0
- package/src/StringInterner.ts +72 -0
- package/src/Summary.ts +48 -0
- package/src/SummaryBackCompatibility.ts +47 -57
- package/src/SummaryTestUtilities.ts +54 -0
- package/src/Transaction.ts +94 -0
- package/src/TransactionInternal.ts +1088 -0
- package/src/TreeCompressor.ts +213 -0
- package/src/TreeNodeHandle.ts +19 -32
- package/src/TreeView.ts +322 -0
- package/src/TreeViewUtilities.ts +77 -0
- package/src/{default-edits/UndoRedoHandler.ts → UndoRedoHandler.ts} +8 -13
- package/src/id-compressor/AppendOnlySortedMap.ts +325 -0
- package/src/id-compressor/IdCompressor.md +3 -0
- package/src/id-compressor/IdCompressor.ts +1848 -0
- package/src/id-compressor/IdRange.ts +33 -0
- package/src/id-compressor/NumericUuid.ts +414 -0
- package/src/id-compressor/index.ts +13 -0
- package/src/id-compressor/persisted-types/0.0.1.ts +179 -0
- package/src/id-compressor/persisted-types/README.md +3 -0
- package/src/id-compressor/persisted-types/index.ts +6 -0
- package/src/index.ts +119 -59
- package/src/persisted-types/0.0.2.ts +442 -0
- package/src/persisted-types/0.1.1.ts +476 -0
- package/src/persisted-types/README.md +22 -0
- package/src/persisted-types/index.ts +9 -0
- package/.mocharc.js +0 -41
- package/api/tree.api.md +0 -729
- package/dist/BasicCheckout.d.ts +0 -23
- package/dist/BasicCheckout.d.ts.map +0 -1
- package/dist/BasicCheckout.js.map +0 -1
- package/dist/Snapshot.d.ts +0 -198
- package/dist/Snapshot.d.ts.map +0 -1
- package/dist/Snapshot.js +0 -267
- package/dist/Snapshot.js.map +0 -1
- package/dist/SnapshotUtilities.d.ts +0 -29
- package/dist/SnapshotUtilities.d.ts.map +0 -1
- package/dist/SnapshotUtilities.js +0 -73
- package/dist/SnapshotUtilities.js.map +0 -1
- package/dist/anchored-edits/AnchorResolution.d.ts +0 -144
- package/dist/anchored-edits/AnchorResolution.d.ts.map +0 -1
- package/dist/anchored-edits/AnchorResolution.js +0 -162
- package/dist/anchored-edits/AnchorResolution.js.map +0 -1
- package/dist/anchored-edits/Factory.d.ts +0 -56
- package/dist/anchored-edits/Factory.d.ts.map +0 -1
- package/dist/anchored-edits/Factory.js +0 -79
- package/dist/anchored-edits/Factory.js.map +0 -1
- package/dist/anchored-edits/PersistedTypes.d.ts +0 -245
- package/dist/anchored-edits/PersistedTypes.d.ts.map +0 -1
- package/dist/anchored-edits/PersistedTypes.js +0 -131
- package/dist/anchored-edits/PersistedTypes.js.map +0 -1
- package/dist/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
- package/dist/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
- package/dist/anchored-edits/SharedTreeWithAnchors.js +0 -115
- package/dist/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
- package/dist/anchored-edits/TransactionWithAnchors.d.ts +0 -28
- package/dist/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
- package/dist/anchored-edits/TransactionWithAnchors.js +0 -36
- package/dist/anchored-edits/TransactionWithAnchors.js.map +0 -1
- package/dist/anchored-edits/index.d.ts +0 -10
- package/dist/anchored-edits/index.d.ts.map +0 -1
- package/dist/anchored-edits/index.js +0 -34
- package/dist/anchored-edits/index.js.map +0 -1
- package/dist/default-edits/EditUtilities.d.ts +0 -57
- package/dist/default-edits/EditUtilities.d.ts.map +0 -1
- package/dist/default-edits/EditUtilities.js +0 -192
- package/dist/default-edits/EditUtilities.js.map +0 -1
- package/dist/default-edits/Factory.d.ts +0 -56
- package/dist/default-edits/Factory.d.ts.map +0 -1
- package/dist/default-edits/Factory.js +0 -79
- package/dist/default-edits/Factory.js.map +0 -1
- package/dist/default-edits/HistoryEditFactory.d.ts +0 -19
- package/dist/default-edits/HistoryEditFactory.d.ts.map +0 -1
- package/dist/default-edits/HistoryEditFactory.js +0 -187
- package/dist/default-edits/HistoryEditFactory.js.map +0 -1
- package/dist/default-edits/PersistedTypes.d.ts.map +0 -1
- package/dist/default-edits/PersistedTypes.js.map +0 -1
- package/dist/default-edits/SharedTree.d.ts +0 -111
- package/dist/default-edits/SharedTree.d.ts.map +0 -1
- package/dist/default-edits/SharedTree.js +0 -124
- package/dist/default-edits/SharedTree.js.map +0 -1
- package/dist/default-edits/Summary.d.ts +0 -15
- package/dist/default-edits/Summary.d.ts.map +0 -1
- package/dist/default-edits/Summary.js +0 -35
- package/dist/default-edits/Summary.js.map +0 -1
- package/dist/default-edits/Transaction.d.ts +0 -41
- package/dist/default-edits/Transaction.d.ts.map +0 -1
- package/dist/default-edits/Transaction.js +0 -225
- package/dist/default-edits/Transaction.js.map +0 -1
- package/dist/default-edits/UndoRedoHandler.d.ts.map +0 -1
- package/dist/default-edits/UndoRedoHandler.js.map +0 -1
- package/dist/default-edits/index.d.ts +0 -13
- package/dist/default-edits/index.d.ts.map +0 -1
- package/dist/default-edits/index.js +0 -41
- package/dist/default-edits/index.js.map +0 -1
- package/dist/generic/GenericEditUtilities.d.ts +0 -26
- package/dist/generic/GenericEditUtilities.d.ts.map +0 -1
- package/dist/generic/GenericEditUtilities.js +0 -45
- package/dist/generic/GenericEditUtilities.js.map +0 -1
- package/dist/generic/GenericSharedTree.d.ts +0 -221
- package/dist/generic/GenericSharedTree.d.ts.map +0 -1
- package/dist/generic/GenericSharedTree.js +0 -447
- package/dist/generic/GenericSharedTree.js.map +0 -1
- package/dist/generic/GenericTransaction.d.ts +0 -87
- package/dist/generic/GenericTransaction.d.ts.map +0 -1
- package/dist/generic/GenericTransaction.js +0 -144
- package/dist/generic/GenericTransaction.js.map +0 -1
- package/dist/generic/PersistedTypes.d.ts +0 -194
- package/dist/generic/PersistedTypes.d.ts.map +0 -1
- package/dist/generic/PersistedTypes.js +0 -42
- package/dist/generic/PersistedTypes.js.map +0 -1
- package/dist/generic/Summary.d.ts +0 -63
- package/dist/generic/Summary.d.ts.map +0 -1
- package/dist/generic/Summary.js +0 -64
- package/dist/generic/Summary.js.map +0 -1
- package/dist/generic/index.d.ts +0 -10
- package/dist/generic/index.d.ts.map +0 -1
- package/dist/generic/index.js +0 -26
- package/dist/generic/index.js.map +0 -1
- package/lib/BasicCheckout.d.ts +0 -23
- package/lib/BasicCheckout.d.ts.map +0 -1
- package/lib/BasicCheckout.js.map +0 -1
- package/lib/Snapshot.d.ts +0 -198
- package/lib/Snapshot.d.ts.map +0 -1
- package/lib/Snapshot.js +0 -263
- package/lib/Snapshot.js.map +0 -1
- package/lib/SnapshotUtilities.d.ts +0 -29
- package/lib/SnapshotUtilities.d.ts.map +0 -1
- package/lib/SnapshotUtilities.js +0 -67
- package/lib/SnapshotUtilities.js.map +0 -1
- package/lib/anchored-edits/AnchorResolution.d.ts +0 -144
- package/lib/anchored-edits/AnchorResolution.d.ts.map +0 -1
- package/lib/anchored-edits/AnchorResolution.js +0 -152
- package/lib/anchored-edits/AnchorResolution.js.map +0 -1
- package/lib/anchored-edits/Factory.d.ts +0 -56
- package/lib/anchored-edits/Factory.d.ts.map +0 -1
- package/lib/anchored-edits/Factory.js +0 -74
- package/lib/anchored-edits/Factory.js.map +0 -1
- package/lib/anchored-edits/PersistedTypes.d.ts +0 -245
- package/lib/anchored-edits/PersistedTypes.d.ts.map +0 -1
- package/lib/anchored-edits/PersistedTypes.js +0 -128
- package/lib/anchored-edits/PersistedTypes.js.map +0 -1
- package/lib/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
- package/lib/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
- package/lib/anchored-edits/SharedTreeWithAnchors.js +0 -110
- package/lib/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
- package/lib/anchored-edits/TransactionWithAnchors.d.ts +0 -28
- package/lib/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
- package/lib/anchored-edits/TransactionWithAnchors.js +0 -32
- package/lib/anchored-edits/TransactionWithAnchors.js.map +0 -1
- package/lib/anchored-edits/index.d.ts +0 -10
- package/lib/anchored-edits/index.d.ts.map +0 -1
- package/lib/anchored-edits/index.js +0 -11
- package/lib/anchored-edits/index.js.map +0 -1
- package/lib/default-edits/EditUtilities.d.ts +0 -57
- package/lib/default-edits/EditUtilities.d.ts.map +0 -1
- package/lib/default-edits/EditUtilities.js +0 -181
- package/lib/default-edits/EditUtilities.js.map +0 -1
- package/lib/default-edits/Factory.d.ts +0 -56
- package/lib/default-edits/Factory.d.ts.map +0 -1
- package/lib/default-edits/Factory.js +0 -74
- package/lib/default-edits/Factory.js.map +0 -1
- package/lib/default-edits/HistoryEditFactory.d.ts +0 -19
- package/lib/default-edits/HistoryEditFactory.d.ts.map +0 -1
- package/lib/default-edits/HistoryEditFactory.js.map +0 -1
- package/lib/default-edits/PersistedTypes.d.ts.map +0 -1
- package/lib/default-edits/PersistedTypes.js.map +0 -1
- package/lib/default-edits/SharedTree.d.ts +0 -111
- package/lib/default-edits/SharedTree.d.ts.map +0 -1
- package/lib/default-edits/SharedTree.js +0 -100
- package/lib/default-edits/SharedTree.js.map +0 -1
- package/lib/default-edits/Summary.d.ts +0 -15
- package/lib/default-edits/Summary.d.ts.map +0 -1
- package/lib/default-edits/Summary.js +0 -31
- package/lib/default-edits/Summary.js.map +0 -1
- package/lib/default-edits/Transaction.d.ts +0 -41
- package/lib/default-edits/Transaction.d.ts.map +0 -1
- package/lib/default-edits/Transaction.js +0 -221
- package/lib/default-edits/Transaction.js.map +0 -1
- package/lib/default-edits/UndoRedoHandler.d.ts.map +0 -1
- package/lib/default-edits/UndoRedoHandler.js.map +0 -1
- package/lib/default-edits/index.d.ts +0 -13
- package/lib/default-edits/index.d.ts.map +0 -1
- package/lib/default-edits/index.js +0 -14
- package/lib/default-edits/index.js.map +0 -1
- package/lib/generic/GenericEditUtilities.d.ts +0 -26
- package/lib/generic/GenericEditUtilities.d.ts.map +0 -1
- package/lib/generic/GenericEditUtilities.js +0 -38
- package/lib/generic/GenericEditUtilities.js.map +0 -1
- package/lib/generic/GenericSharedTree.d.ts +0 -221
- package/lib/generic/GenericSharedTree.d.ts.map +0 -1
- package/lib/generic/GenericSharedTree.js +0 -443
- package/lib/generic/GenericSharedTree.js.map +0 -1
- package/lib/generic/GenericTransaction.d.ts +0 -87
- package/lib/generic/GenericTransaction.d.ts.map +0 -1
- package/lib/generic/GenericTransaction.js +0 -140
- package/lib/generic/GenericTransaction.js.map +0 -1
- package/lib/generic/PersistedTypes.d.ts +0 -194
- package/lib/generic/PersistedTypes.d.ts.map +0 -1
- package/lib/generic/PersistedTypes.js +0 -39
- package/lib/generic/PersistedTypes.js.map +0 -1
- package/lib/generic/Summary.d.ts +0 -63
- package/lib/generic/Summary.d.ts.map +0 -1
- package/lib/generic/Summary.js +0 -58
- package/lib/generic/Summary.js.map +0 -1
- package/lib/generic/index.d.ts +0 -10
- package/lib/generic/index.d.ts.map +0 -1
- package/lib/generic/index.js +0 -11
- package/lib/generic/index.js.map +0 -1
- package/lib/test/Anchors.glassBox.tests.d.ts.map +0 -1
- package/lib/test/Anchors.glassBox.tests.js +0 -410
- package/lib/test/Anchors.glassBox.tests.js.map +0 -1
- package/lib/test/BasicCheckout.tests.d.ts.map +0 -1
- package/lib/test/BasicCheckout.tests.js +0 -8
- package/lib/test/BasicCheckout.tests.js.map +0 -1
- package/lib/test/GenericTransactionWithAnchors.tests.d.ts.map +0 -1
- package/lib/test/GenericTransactionWithAnchors.tests.js +0 -25
- package/lib/test/GenericTransactionWithAnchors.tests.js.map +0 -1
- package/lib/test/SharedTreeWithAnchors.tests.d.ts.map +0 -1
- package/lib/test/SharedTreeWithAnchors.tests.js +0 -420
- package/lib/test/SharedTreeWithAnchors.tests.js.map +0 -1
- package/lib/test/Snapshot.tests.d.ts.map +0 -1
- package/lib/test/Snapshot.tests.js +0 -96
- package/lib/test/Snapshot.tests.js.map +0 -1
- package/lib/test/SnapshotUtilities.tests.d.ts.map +0 -1
- package/lib/test/SnapshotUtilities.tests.js +0 -168
- package/lib/test/SnapshotUtilities.tests.js.map +0 -1
- package/lib/test/undoRedoStackManager.d.ts +0 -26
- package/lib/test/undoRedoStackManager.d.ts.map +0 -1
- package/lib/test/undoRedoStackManager.js +0 -176
- package/lib/test/undoRedoStackManager.js.map +0 -1
- package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts +0 -13
- package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts.map +0 -1
- package/lib/test/utilities/SummaryFormatCompatibilityTests.js +0 -154
- package/lib/test/utilities/SummaryFormatCompatibilityTests.js.map +0 -1
- package/src/BasicCheckout.ts +0 -34
- package/src/Snapshot.ts +0 -363
- package/src/SnapshotUtilities.ts +0 -88
- package/src/anchored-edits/AnchorResolution.ts +0 -442
- package/src/anchored-edits/Factory.ts +0 -94
- package/src/anchored-edits/PersistedTypes.ts +0 -310
- package/src/anchored-edits/SharedTreeWithAnchors.ts +0 -200
- package/src/anchored-edits/TransactionWithAnchors.ts +0 -39
- package/src/anchored-edits/index.ts +0 -21
- package/src/default-edits/EditUtilities.ts +0 -220
- package/src/default-edits/Factory.ts +0 -94
- package/src/default-edits/SharedTree.ts +0 -174
- package/src/default-edits/Summary.ts +0 -44
- package/src/default-edits/Transaction.ts +0 -262
- package/src/default-edits/index.ts +0 -29
- package/src/generic/GenericEditUtilities.ts +0 -46
- package/src/generic/GenericSharedTree.ts +0 -593
- package/src/generic/GenericTransaction.ts +0 -194
- package/src/generic/PersistedTypes.ts +0 -221
- package/src/generic/Summary.ts +0 -113
- package/src/generic/index.ts +0 -41
package/dist/LogViewer.js
CHANGED
|
@@ -10,32 +10,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.CachingLogViewer = void 0;
|
|
11
11
|
const denque_1 = __importDefault(require("denque"));
|
|
12
12
|
const Common_1 = require("./Common");
|
|
13
|
-
const Snapshot_1 = require("./Snapshot");
|
|
14
|
-
const generic_1 = require("./generic");
|
|
15
13
|
const RevisionValueCache_1 = require("./RevisionValueCache");
|
|
16
|
-
const
|
|
14
|
+
const persisted_types_1 = require("./persisted-types");
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
16
|
+
* Creates views for revisions associated with an EditLog and caches the results.
|
|
17
|
+
*
|
|
18
|
+
* Does so by listening for edits added to the log. If the underlying EditLog or its listeners need to be reused beyond the lifetime of
|
|
19
|
+
* a CachingLogViewer instance, that instance should be disposed with `detachFromEditLog` to ensure it is garbage-collectable.
|
|
19
20
|
* @internal
|
|
20
21
|
*/
|
|
21
22
|
class CachingLogViewer {
|
|
22
23
|
/**
|
|
23
24
|
* Create a new LogViewer
|
|
24
|
-
* @param log - the edit log which
|
|
25
|
-
* @param baseTree - the tree used in the
|
|
26
|
-
* @param knownRevisions - a set of [sequencedRevision,
|
|
25
|
+
* @param log - the edit log which revisions will be based on.
|
|
26
|
+
* @param baseTree - the tree used in the view corresponding to the 0th revision.
|
|
27
|
+
* @param knownRevisions - a set of [sequencedRevision, view] pairs that are known (have been precomputed) at construction time.
|
|
27
28
|
* These revisions are guaranteed to never be evicted from the cache.
|
|
28
29
|
* @param expensiveValidation - Iff true, additional correctness assertions will be run during LogViewer operations.
|
|
29
30
|
* @param processEditStatus - called after applying an edit.
|
|
30
|
-
* @param
|
|
31
|
+
* @param processSequencedEditResult - called after applying a sequenced edit.
|
|
31
32
|
*/
|
|
32
|
-
constructor(log,
|
|
33
|
+
constructor(log, baseView, knownRevisions = [], expensiveValidation = false, processEditStatus = Common_1.noop, processSequencedEditResult = Common_1.noop, transactionFactory, minimumSequenceNumber = 0) {
|
|
34
|
+
this.transactionFactory = transactionFactory;
|
|
33
35
|
/**
|
|
34
|
-
* A cache for local
|
|
36
|
+
* A cache for local revisions.
|
|
35
37
|
* It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.
|
|
36
38
|
* When a previously local edit is sequenced, this cache is adjusted to account for it, not invalidated.
|
|
37
39
|
*/
|
|
38
|
-
this.
|
|
40
|
+
this.localRevisionCache = new denque_1.default();
|
|
39
41
|
/**
|
|
40
42
|
* The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.
|
|
41
43
|
* This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.
|
|
@@ -49,19 +51,27 @@ class CachingLogViewer {
|
|
|
49
51
|
Common_1.assert(this.log.isSequencedRevision(revision), 'revision must correspond to the result of a SequencedEdit');
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
|
-
this.
|
|
54
|
+
this.sequencedRevisionCache = new RevisionValueCache_1.RevisionValueCache(CachingLogViewer.sequencedCacheSizeMax, minimumSequenceNumber, [...knownRevisions, [0, { view: baseView }]]);
|
|
53
55
|
this.processEditStatus = processEditStatus !== null && processEditStatus !== void 0 ? processEditStatus : Common_1.noop;
|
|
56
|
+
this.processSequencedEditResult = processSequencedEditResult !== null && processSequencedEditResult !== void 0 ? processSequencedEditResult : Common_1.noop;
|
|
54
57
|
this.expensiveValidation = expensiveValidation;
|
|
55
|
-
this.logger = logger;
|
|
56
58
|
this.transactionFactory = transactionFactory;
|
|
57
|
-
this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));
|
|
59
|
+
this.detachFromEditLog = this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
+
* @returns true if the highest revision is cached.
|
|
63
|
+
*/
|
|
64
|
+
highestRevisionCached() {
|
|
65
|
+
return this.highestRevisionCacheEntry !== undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* As a performance optimization, this method caches views generated by local edits if they are sequenced without
|
|
62
69
|
* being interleaved with remote edits.
|
|
63
70
|
*/
|
|
64
71
|
handleEditAdded(edit, isLocal, wasLocal) {
|
|
72
|
+
// Clear highestRevisionCacheEntry, since what revision is highest might change.
|
|
73
|
+
// Note that as an optimization we could skip clearing this when a local edit is sequenced.
|
|
74
|
+
this.highestRevisionCacheEntry = undefined;
|
|
65
75
|
if (isLocal) {
|
|
66
76
|
this.unappliedSelfEdits.push(edit.id);
|
|
67
77
|
}
|
|
@@ -69,26 +79,27 @@ class CachingLogViewer {
|
|
|
69
79
|
// If the new sequenced edit was generated by this client, the corresponding cache entry (if there is one)
|
|
70
80
|
// will be at the front of the queue. If the queue is empty, then a concurrent sequenced edit from remote client
|
|
71
81
|
// must have invalidated the queue cache.
|
|
72
|
-
const entry = this.
|
|
82
|
+
const entry = this.localRevisionCache.shift();
|
|
73
83
|
if (entry !== undefined) {
|
|
74
84
|
const revision = this.log.numberOfSequencedEdits;
|
|
75
|
-
const
|
|
76
|
-
this.
|
|
85
|
+
const { view } = entry;
|
|
86
|
+
this.sequencedRevisionCache.cacheValue(revision, entry.status === persisted_types_1.EditStatus.Applied
|
|
77
87
|
? {
|
|
78
|
-
|
|
88
|
+
view,
|
|
79
89
|
status: entry.status,
|
|
80
90
|
steps: entry.steps,
|
|
81
91
|
}
|
|
82
92
|
: {
|
|
83
|
-
|
|
93
|
+
view,
|
|
84
94
|
status: entry.status,
|
|
95
|
+
failure: entry.failure,
|
|
85
96
|
});
|
|
86
|
-
this.handleSequencedEditResult(edit, entry);
|
|
97
|
+
this.handleSequencedEditResult(edit, entry, []);
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
else {
|
|
90
101
|
// Invalidate any cached results of applying edits which are ordered after `edit` (which are all remaining local edits)
|
|
91
|
-
this.
|
|
102
|
+
this.localRevisionCache.clear();
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
async getEditResult(revision) {
|
|
@@ -97,12 +108,12 @@ class CachingLogViewer {
|
|
|
97
108
|
let current = startingPoint;
|
|
98
109
|
for (let i = startRevision; i < revision && i < this.log.length; i++) {
|
|
99
110
|
const edit = await this.log.getEditAtIndex(i);
|
|
100
|
-
current = this.applyEdit(current.
|
|
111
|
+
current = this.applyEdit(current.view, edit, i);
|
|
101
112
|
}
|
|
102
113
|
return current;
|
|
103
114
|
}
|
|
104
|
-
async
|
|
105
|
-
return (await this.getEditResult(revision)).
|
|
115
|
+
async getRevisionView(revision) {
|
|
116
|
+
return (await this.getEditResult(revision)).view;
|
|
106
117
|
}
|
|
107
118
|
getEditResultInSession(revision) {
|
|
108
119
|
const startingPoint = this.getStartingPoint(revision);
|
|
@@ -110,12 +121,12 @@ class CachingLogViewer {
|
|
|
110
121
|
let current = startingPoint;
|
|
111
122
|
for (let i = startRevision; i < revision && i < this.log.length; i++) {
|
|
112
123
|
const edit = this.log.getEditInSessionAtIndex(i);
|
|
113
|
-
current = this.applyEdit(current.
|
|
124
|
+
current = this.applyEdit(current.view, edit, i);
|
|
114
125
|
}
|
|
115
126
|
return current;
|
|
116
127
|
}
|
|
117
|
-
|
|
118
|
-
return this.getEditResultInSession(revision).
|
|
128
|
+
getRevisionViewInSession(revision) {
|
|
129
|
+
return this.getEditResultInSession(revision).view;
|
|
119
130
|
}
|
|
120
131
|
/**
|
|
121
132
|
* Informs the CachingLogViewer of the latest known minimumSequenceNumber for all connected clients.
|
|
@@ -127,111 +138,114 @@ class CachingLogViewer {
|
|
|
127
138
|
// Sequence numbers in Fluid are 1-indexed, meaning they correspond to revisions, and can be used as revisions.
|
|
128
139
|
// This ensures that all revisions >= minimumSequenceNumber are kept in the cache, meaning that even if all clients are caught up
|
|
129
140
|
// the most recent sequenced revision will be cached.
|
|
130
|
-
this.
|
|
141
|
+
this.sequencedRevisionCache.updateRetentionWindow(minimumSequenceNumber);
|
|
131
142
|
}
|
|
132
143
|
/**
|
|
133
|
-
* Inform the CachingLogViewer that a particular edit is
|
|
134
|
-
*
|
|
144
|
+
* Inform the CachingLogViewer that a particular edit is known to have a specific result when applied to a particular TreeView.
|
|
145
|
+
* CachingLogViewer may use this information as an optimization to avoid re-running the edit if re-applied to the same TreeView.
|
|
135
146
|
*/
|
|
136
147
|
setKnownEditingResult(edit, result) {
|
|
137
148
|
this.cachedEditResult = { editId: edit.id, result };
|
|
138
149
|
}
|
|
139
150
|
/**
|
|
140
|
-
* @returns the cached
|
|
151
|
+
* @returns the cached revision view closest to the requested `revision`.
|
|
141
152
|
*/
|
|
142
153
|
getStartingPoint(revision) {
|
|
143
154
|
var _a, _b, _c;
|
|
144
|
-
// Per the documentation for revision, the returned
|
|
155
|
+
// Per the documentation for revision, the returned view should be the output of the edit at the largest index <= `revision`.
|
|
145
156
|
const revisionClamped = Math.min(revision, this.log.length);
|
|
157
|
+
// If the highest revision is requested, and it's cached, use highestRevisionCacheEntry.
|
|
158
|
+
if (revisionClamped === this.log.length && this.highestRevisionCacheEntry !== undefined) {
|
|
159
|
+
return Object.assign(Object.assign({}, this.highestRevisionCacheEntry), { startRevision: revisionClamped });
|
|
160
|
+
}
|
|
146
161
|
let current;
|
|
147
162
|
let startRevision;
|
|
148
163
|
const { numberOfSequencedEdits } = this.log;
|
|
149
164
|
const isLocalRevision = revisionClamped > numberOfSequencedEdits;
|
|
150
|
-
if (isLocalRevision && !this.
|
|
151
|
-
const { length } = this.
|
|
152
|
-
// Local
|
|
165
|
+
if (isLocalRevision && !this.localRevisionCache.isEmpty()) {
|
|
166
|
+
const { length } = this.localRevisionCache;
|
|
167
|
+
// Local revision view cache is indexed such that the view for revision 0 (a local edit) is stored at index 0 in the cache.
|
|
153
168
|
// This is because the local cache does not contain an entry for the implicit initial tree edit.
|
|
154
169
|
const localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;
|
|
155
170
|
if (localCacheIndex < length) {
|
|
156
|
-
const cached = (_a = this.
|
|
171
|
+
const cached = (_a = this.localRevisionCache.peekAt(localCacheIndex)) !== null && _a !== void 0 ? _a : Common_1.fail('missing tail of localRevisionViewCache');
|
|
157
172
|
return Object.assign(Object.assign({}, cached), { startRevision: revisionClamped });
|
|
158
173
|
}
|
|
159
174
|
else {
|
|
160
|
-
current = (_b = this.
|
|
175
|
+
current = (_b = this.localRevisionCache.peekAt(length - 1)) !== null && _b !== void 0 ? _b : Common_1.fail('missing tail of localRevisionViewCache');
|
|
161
176
|
startRevision = numberOfSequencedEdits + length;
|
|
162
177
|
}
|
|
163
178
|
}
|
|
164
179
|
else {
|
|
165
|
-
const [cachedRevision,
|
|
180
|
+
const [cachedRevision, cachedView] = (_c = this.sequencedRevisionCache.getClosestEntry(revisionClamped)) !== null && _c !== void 0 ? _c : Common_1.fail('No preceding revision view cached.');
|
|
166
181
|
startRevision = cachedRevision;
|
|
167
|
-
current =
|
|
182
|
+
current = cachedView;
|
|
168
183
|
}
|
|
169
184
|
return Object.assign({ startRevision }, current);
|
|
170
185
|
}
|
|
171
186
|
/**
|
|
172
|
-
* Helper for applying an edit at the supplied
|
|
187
|
+
* Helper for applying an edit at the supplied revision view.
|
|
173
188
|
* Must only be called in the order that edits appear in the log.
|
|
174
189
|
* Must only be called once for a given local edit as long as the local cache has not been invalidated.
|
|
175
190
|
* Must only be called once for a given sequenced edit.
|
|
176
|
-
* @returns the resulting
|
|
191
|
+
* @returns the resulting revision view and the outcome of edit that produced it.
|
|
177
192
|
*/
|
|
178
|
-
applyEdit(
|
|
193
|
+
applyEdit(prevView, edit, editIndex) {
|
|
179
194
|
let editingResult;
|
|
180
195
|
let cached;
|
|
196
|
+
let reconciliationPath = [];
|
|
181
197
|
if (this.cachedEditResult !== undefined &&
|
|
182
198
|
this.cachedEditResult.editId === edit.id &&
|
|
183
|
-
this.cachedEditResult.result.before ===
|
|
199
|
+
this.cachedEditResult.result.before === prevView) {
|
|
184
200
|
editingResult = this.cachedEditResult.result;
|
|
185
201
|
cached = true;
|
|
186
202
|
}
|
|
187
203
|
else {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
.close();
|
|
204
|
+
reconciliationPath = this.reconciliationPathFromEdit(edit.id);
|
|
205
|
+
editingResult = this.transactionFactory(prevView).applyChanges(edit.changes, reconciliationPath).close();
|
|
191
206
|
cached = false;
|
|
192
207
|
}
|
|
193
208
|
const revision = editIndex + 1;
|
|
194
|
-
let
|
|
195
|
-
if (editingResult.status ===
|
|
196
|
-
|
|
209
|
+
let nextView;
|
|
210
|
+
if (editingResult.status === persisted_types_1.EditStatus.Applied) {
|
|
211
|
+
nextView = editingResult.after;
|
|
197
212
|
}
|
|
198
213
|
else {
|
|
199
|
-
|
|
214
|
+
nextView = prevView;
|
|
200
215
|
}
|
|
201
|
-
const computedCacheEntry = editingResult.status ===
|
|
202
|
-
? {
|
|
203
|
-
: {
|
|
216
|
+
const computedCacheEntry = editingResult.status === persisted_types_1.EditStatus.Applied
|
|
217
|
+
? { view: nextView, status: editingResult.status, steps: editingResult.steps }
|
|
218
|
+
: { view: nextView, status: editingResult.status, failure: editingResult.failure };
|
|
204
219
|
if (this.log.isSequencedRevision(revision)) {
|
|
205
|
-
this.
|
|
206
|
-
this.handleSequencedEditResult(edit, computedCacheEntry);
|
|
220
|
+
this.sequencedRevisionCache.cacheValue(revision, computedCacheEntry);
|
|
221
|
+
this.handleSequencedEditResult(edit, computedCacheEntry, reconciliationPath);
|
|
207
222
|
}
|
|
208
223
|
else {
|
|
209
|
-
// This relies on local edits being append only, and that generating the
|
|
210
|
-
// the
|
|
224
|
+
// This relies on local edits being append only, and that generating the view for a local revision requires generating
|
|
225
|
+
// the views for all local revisions before it in the log. Thus, generating such a view will necessarily require
|
|
211
226
|
// calls to this method for all local revisions prior, guaranteeing the correct push order.
|
|
212
|
-
Common_1.assert(revision === this.log.numberOfSequencedEdits + this.
|
|
213
|
-
this.
|
|
227
|
+
Common_1.assert(revision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1, 'Local revision view cached out of order.');
|
|
228
|
+
this.localRevisionCache.push(computedCacheEntry);
|
|
229
|
+
}
|
|
230
|
+
// Only update highestRevisionCacheEntry if this snapshot is the highest revision.
|
|
231
|
+
if (revision >= this.log.length) {
|
|
232
|
+
this.highestRevisionCacheEntry = computedCacheEntry;
|
|
214
233
|
}
|
|
215
234
|
this.processEditStatus(editingResult.status, this.log.getIdAtIndex(editIndex), cached);
|
|
216
235
|
return computedCacheEntry;
|
|
217
236
|
}
|
|
218
237
|
/**
|
|
219
|
-
* Helper for performing caching
|
|
238
|
+
* Helper for performing caching when a sequenced local edit is first applied.
|
|
239
|
+
* Invokes the `processSequencedEditResult` handler that was passed to the constructor (if any).
|
|
220
240
|
* Must only be called for non-cached sequenced edits.
|
|
221
241
|
*/
|
|
222
|
-
handleSequencedEditResult(edit, result) {
|
|
242
|
+
handleSequencedEditResult(edit, result, reconciliationPath) {
|
|
243
|
+
let wasLocal = false;
|
|
223
244
|
// This is the first time this sequenced edit has been processed by this LogViewer. If it was a local edit, log telemetry
|
|
224
245
|
// in the event that it was invalid or malformed.
|
|
225
246
|
if (this.unappliedSelfEdits.length > 0) {
|
|
226
247
|
if (edit.id === this.unappliedSelfEdits.peekFront()) {
|
|
227
|
-
|
|
228
|
-
this.logger.send({
|
|
229
|
-
category: 'generic',
|
|
230
|
-
eventName: result.status === generic_1.EditStatus.Malformed
|
|
231
|
-
? 'MalformedSharedTreeEdit'
|
|
232
|
-
: 'InvalidSharedTreeEdit',
|
|
233
|
-
});
|
|
234
|
-
}
|
|
248
|
+
wasLocal = true;
|
|
235
249
|
this.unappliedSelfEdits.shift();
|
|
236
250
|
}
|
|
237
251
|
else if (this.expensiveValidation) {
|
|
@@ -240,6 +254,7 @@ class CachingLogViewer {
|
|
|
240
254
|
}
|
|
241
255
|
}
|
|
242
256
|
}
|
|
257
|
+
this.processSequencedEditResult({ edit, wasLocal, result, reconciliationPath });
|
|
243
258
|
}
|
|
244
259
|
/**
|
|
245
260
|
* We currently compute only the "main branch" part of the reconciliation path (meaning we don't include inverts of the edits
|
|
@@ -263,15 +278,20 @@ class CachingLogViewer {
|
|
|
263
278
|
if (targetSequenceNumber < orderedId.sequenceInfo.sequenceNumber) {
|
|
264
279
|
const firstEdit = this.getEditResultFromSequenceNumber(targetSequenceNumber);
|
|
265
280
|
if (firstEdit !== undefined) {
|
|
266
|
-
if (firstEdit.status ===
|
|
267
|
-
|
|
281
|
+
if (firstEdit.status === persisted_types_1.EditStatus.Applied) {
|
|
282
|
+
const firstEditInfo = this.log.getOrderedEditId(firstEdit.id);
|
|
283
|
+
if (firstEditInfo.sequenceInfo !== undefined &&
|
|
284
|
+
firstEditInfo.sequenceInfo.sequenceNumber >
|
|
285
|
+
orderedId.sequenceInfo.referenceSequenceNumber) {
|
|
286
|
+
reconciliationPath.push(Object.assign(Object.assign({}, firstEdit.steps), { before: firstEdit.before, after: firstEdit.view, length: firstEdit.steps.length }));
|
|
287
|
+
}
|
|
268
288
|
}
|
|
269
289
|
const lowestIndex = this.log.getIndexOfId(firstEdit.id) + 1;
|
|
270
290
|
const highestIndex = this.log.getIndexOfId(editId) - 1;
|
|
271
291
|
for (let index = lowestIndex; index <= highestIndex; ++index) {
|
|
272
292
|
const edit = this.getEditResultFromIndex(index);
|
|
273
|
-
if (edit.status ===
|
|
274
|
-
reconciliationPath.push(Object.assign(Object.assign({}, edit.steps), { before: edit.before, after: edit.
|
|
293
|
+
if (edit.status === persisted_types_1.EditStatus.Applied) {
|
|
294
|
+
reconciliationPath.push(Object.assign(Object.assign({}, edit.steps), { before: edit.before, after: edit.view, length: edit.steps.length }));
|
|
275
295
|
}
|
|
276
296
|
}
|
|
277
297
|
}
|
|
@@ -303,30 +323,33 @@ class CachingLogViewer {
|
|
|
303
323
|
*/
|
|
304
324
|
getEditResultFromIndex(index) {
|
|
305
325
|
const edit = this.log.getEditInSessionAtIndex(index);
|
|
306
|
-
const before = this.
|
|
326
|
+
const before = this.getRevisionViewInSession(index);
|
|
307
327
|
const resultAfter = this.getEditResultInSession(index + 1);
|
|
308
328
|
if (resultAfter.status === undefined) {
|
|
309
329
|
Common_1.fail('The status of every edit in session should be known');
|
|
310
330
|
}
|
|
311
|
-
return resultAfter.status ===
|
|
331
|
+
return resultAfter.status === persisted_types_1.EditStatus.Applied
|
|
312
332
|
? {
|
|
313
333
|
id: edit.id,
|
|
314
|
-
status:
|
|
334
|
+
status: persisted_types_1.EditStatus.Applied,
|
|
315
335
|
before,
|
|
316
336
|
changes: edit.changes,
|
|
317
|
-
|
|
337
|
+
view: resultAfter.view,
|
|
318
338
|
steps: resultAfter.steps,
|
|
319
339
|
}
|
|
320
340
|
: {
|
|
321
341
|
id: edit.id,
|
|
322
342
|
status: resultAfter.status,
|
|
343
|
+
failure: resultAfter.failure,
|
|
323
344
|
before,
|
|
345
|
+
view: resultAfter.view,
|
|
324
346
|
changes: edit.changes,
|
|
325
347
|
};
|
|
326
348
|
}
|
|
327
349
|
/**
|
|
328
350
|
* @param sequenceNumber - The server-assigned sequenced number assigned to the edit of interest.
|
|
329
|
-
* @returns Edit result information for the edit with the given sequence number
|
|
351
|
+
* @returns Edit result information for the edit with the given sequence number or the nearest sequenced edit before that.
|
|
352
|
+
* Undefined if no sequenced edit occurred at or prior to the given sequenceNumber.
|
|
330
353
|
*/
|
|
331
354
|
getEditResultFromSequenceNumber(sequenceNumber) {
|
|
332
355
|
const earliestSequenced = this.earliestSequencedEditInSession();
|
|
@@ -343,24 +366,26 @@ class CachingLogViewer {
|
|
|
343
366
|
// has been processed by a different DDS (several DDSes can share the same stream of operations and will only see those
|
|
344
367
|
// relevant to them). In such cases, we return the edit info for the last known edit before that.
|
|
345
368
|
if (orderedId.sequenceInfo && orderedId.sequenceInfo.sequenceNumber <= sequenceNumber) {
|
|
346
|
-
const before = this.
|
|
369
|
+
const before = this.getRevisionViewInSession(index);
|
|
347
370
|
const resultAfter = this.getEditResultInSession(index + 1);
|
|
348
371
|
if (resultAfter.status === undefined) {
|
|
349
372
|
Common_1.fail('The status of every edit in session should be known');
|
|
350
373
|
}
|
|
351
|
-
return resultAfter.status ===
|
|
374
|
+
return resultAfter.status === persisted_types_1.EditStatus.Applied
|
|
352
375
|
? {
|
|
353
376
|
id: edit.id,
|
|
354
|
-
status:
|
|
377
|
+
status: persisted_types_1.EditStatus.Applied,
|
|
355
378
|
before,
|
|
356
379
|
changes: edit.changes,
|
|
357
|
-
|
|
380
|
+
view: resultAfter.view,
|
|
358
381
|
steps: resultAfter.steps,
|
|
359
382
|
}
|
|
360
383
|
: {
|
|
361
384
|
id: edit.id,
|
|
362
385
|
status: resultAfter.status,
|
|
386
|
+
failure: resultAfter.failure,
|
|
363
387
|
before,
|
|
388
|
+
view: resultAfter.view,
|
|
364
389
|
changes: edit.changes,
|
|
365
390
|
};
|
|
366
391
|
}
|
|
@@ -371,7 +396,7 @@ class CachingLogViewer {
|
|
|
371
396
|
}
|
|
372
397
|
exports.CachingLogViewer = CachingLogViewer;
|
|
373
398
|
/**
|
|
374
|
-
* Maximum size of the sequenced
|
|
399
|
+
* Maximum size of the sequenced revision cache.
|
|
375
400
|
*/
|
|
376
401
|
CachingLogViewer.sequencedCacheSizeMax = 50;
|
|
377
402
|
//# sourceMappingURL=LogViewer.js.map
|
package/dist/LogViewer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogViewer.js","sourceRoot":"","sources":["../src/LogViewer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,oDAA4B;AAC5B,qCAA8C;AAE9C,yCAAsC;AACtC,uCAAgF;AAEhF,6DAA0D;AAC1D,+CAA4C;AAiI5C;;;GAGG;AACH,MAAa,gBAAgB;IAsD5B;;;;;;;;;OASG;IACH,YACC,GAAqB,EACrB,eAAyB,mBAAQ,CAAC,QAAQ,CAAC,yBAAW,CAAC,EACvD,iBAAwD,EAAE,EAC1D,mBAAmB,GAAG,KAAK,EAC3B,oBAAwC,aAAI,EAC5C,MAA4B,EAC5B,kBAAuE,EACvE,qBAAqB,GAAG,CAAC;QAhE1B;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAA0C,CAAC;QAwB3F;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAU,CAAC;QAgC1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,mBAAmB,EAAE;YACxB,cAAc,CAAC,OAAO,CAAC,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AAC,IAAI,CAAC,EAAE,CAA2B,CAAC;gBAC/E,uHAAuH;gBACvH,yDAAyD;gBACzD,0HAA0H;gBAC1H,yHAAyH;gBACzH,uHAAuH;gBACvH,iGAAiG;gBACjG,IAAI,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC,cAAc,IAAI,cAAc,EAAE;oBACtF,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;oBAChD,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;oBAC3D,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,EAAE;wBACrC,aAAI,CAAC,qDAAqD,CAAC,CAAC;qBAC5D;oBACD,OAAO,WAAW,CAAC,MAAM,KAAK,oBAAU,CAAC,OAAO;wBAC/C,CAAC,CAAC;4BACA,EAAE,EAAE,IAAI,CAAC,EAAE;4BACX,MAAM,EAAE,oBAAU,CAAC,OAAO;4BAC1B,MAAM;4BACN,OAAO,EAAE,IAAI,CAAC,OAAO;4BACrB,KAAK,EAAE,WAAW,CAAC,QAAQ;4BAC3B,KAAK,EAAE,WAAW,CAAC,KAAK;yBACvB;wBACH,CAAC,CAAC;4BACA,EAAE,EAAE,IAAI,CAAC,EAAE;4BACX,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,MAAM;4BACN,OAAO,EAAE,IAAI,CAAC,OAAO;yBACpB,CAAC;iBACL;aACD;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;;AAhcF,4CAicC;AA9bA;;GAEG;AACoB,sCAAqB,GAAG,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from '@fluidframework/common-definitions';\nimport Denque from 'denque';\nimport { assert, fail, noop } from './Common';\nimport { EditLog, SequencedOrderedEditId } from './EditLog';\nimport { Snapshot } from './Snapshot';\nimport { Edit, EditStatus, EditingResult, GenericTransaction } from './generic';\nimport { EditId } from './Identifiers';\nimport { RevisionValueCache } from './RevisionValueCache';\nimport { initialTree } from './InitialTree';\nimport { ReconciliationEdit, ReconciliationPath } from './ReconciliationPath';\n\n/**\n * Callback for when an edit is applied (meaning the result of applying it to a particular snapshot is computed).\n *\n * Edits may be applied any time a Snapshot is computed that includes them.\n * Depending on the caching policy of the LogViewer, a given edit may or may not be applied in order to compute a Snapshot containing it.\n *\n * If the same edit occurs in different contexts (ex: a local edit is adjusted for a new remote edit),\n * that it will be reapplied, and this may result in different results.\n *\n * Edits may additionally be reapplied at other times since their previous output might not be cached.\n *\n * If an application requests the current view, this will force all edits to be applied.\n * Such an application can use this callback can be log each edit as it comes it to see its status,\n * however this may include duplicates, as well as entries for reapplications in modified contexts.\n *\n * In the context of this callback,\n * skipping the first evaluation of an edit in a particular context due to setKnownEditingResult is still considered applying.\n * To use this call back to track when the actual computational work of applying edits is done, only count cases when `wasCached` is false.\n */\nexport type EditStatusCallback = (editResult: EditStatus, editId: EditId, wasCached: boolean) => void;\n\n/**\n * Result of applying an identified transaction.\n * @public\n */\nexport type EditingResultWithId<TChange> = EditingResult<TChange> & {\n\t/**\n\t * Unique identifier for this edit. Must never be reused.\n\t * Used for referencing and de-duplicating edits.\n\t */\n\treadonly id: EditId;\n};\n\n/**\n * The data cached by `CachingLogViewer` for an edit.\n */\nexport type EditCacheEntry<TChange> =\n\t| SuccessfulEditCacheEntry<TChange>\n\t| UnsuccessfulEditCacheEntry\n\t| SummarizedEditResultCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has attempted to apply locally.\n */\nexport type AttemptedEditResultCacheEntry<TChange> = SuccessfulEditCacheEntry<TChange> | UnsuccessfulEditCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has successfully applied locally.\n */\nexport interface SuccessfulEditCacheEntry<TChange> {\n\t/**\n\t * The snapshot resulting from the edit.\n\t */\n\tsnapshot: Snapshot;\n\t/**\n\t * The status code for the edit that produced the snapshot.\n\t */\n\tstatus: EditStatus.Applied;\n\t/**\n\t * The resolved changes that were applied during the edit and their associated outcome.\n\t */\n\tsteps: readonly { resolvedChange: TChange; after: Snapshot }[];\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has unsuccessfully attempted to apply locally.\n */\nexport interface UnsuccessfulEditCacheEntry {\n\t/**\n\t * The snapshot resulting from the edit.\n\t */\n\treadonly snapshot: Snapshot;\n\t/**\n\t * The status code for the edit that produced the snapshot.\n\t */\n\tstatus: EditStatus.Invalid | EditStatus.Malformed;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has retrieved from a summary.\n * TODO:#57176: once summarized edits carry enough information remove this interface and use `AttemptedEditResultCacheEntry` instead.\n */\nexport interface SummarizedEditResultCacheEntry {\n\t/**\n\t * The snapshot resulting from the edit.\n\t */\n\tsnapshot: Snapshot;\n\tstatus?: undefined;\n}\n\n/**\n * A revision corresponds to an index in an `EditLog`.\n *\n * It is associated with the output `Snapshot` of applying the edit at the index to the previous revision.\n * For example:\n * - revision 0 corresponds to the initialSnapshot.\n * - revision 1 corresponds to the output of editLog[0] applied to the initialSnapshot.\n */\nexport type Revision = number;\n\n/**\n * Creates `Snapshot`s for the revisions in an `EditLog`\n */\nexport interface LogViewer {\n\t/**\n\t * Returns the `Snapshot` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialSnapshot.\n\t * - revision 1 returns the output of editLog[0] (or initialSnapshot if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetSnapshot(revision: Revision): Promise<Snapshot>;\n\n\t/**\n\t * Returns the `Snapshot` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t * Can only be used to retrieve revisions added during the current sessions.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialSnapshot.\n\t * - revision 1 returns the output of editLog[0] (or initialSnapshot if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetSnapshotInSession(revision: Revision): Snapshot;\n}\n\n/**\n * Creates Snapshots for revisions associated with an EditLog and caches the results.\n * @internal\n */\nexport class CachingLogViewer<TChange> implements LogViewer {\n\tpublic readonly log: EditLog<TChange>;\n\n\t/**\n\t * Maximum size of the sequenced snapshot cache.\n\t */\n\tpublic static readonly sequencedCacheSizeMax = 50;\n\n\t/**\n\t * A cache for local snapshots.\n\t * It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.\n\t * When a previously local edit is sequenced, this cache is adjusted to account for it, not invalidated.\n\t */\n\tprivate readonly localSnapshotCache = new Denque<AttemptedEditResultCacheEntry<TChange>>();\n\n\t/**\n\t * Cache of sequenced snapshots.\n\t */\n\tprivate readonly sequencedSnapshotCache: RevisionValueCache<EditCacheEntry<TChange>>;\n\n\t/**\n\t * Called whenever an edit is processed.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processEditStatus: EditStatusCallback;\n\n\t/**\n\t * Iff true, additional correctness assertions will be run during LogViewer operations.\n\t */\n\tprivate readonly expensiveValidation: boolean;\n\n\t/**\n\t * Telemetry logger, used to log events such as edit application rejection.\n\t */\n\tprivate readonly logger: ITelemetryBaseLogger;\n\n\t/**\n\t * The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.\n\t * This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.\n\t * Used to log telemetry about the result of edit application. Edits are removed when first applied after being sequenced.\n\t */\n\tprivate readonly unappliedSelfEdits = new Denque<EditId>();\n\n\t/**\n\t * Cache of applying a edit.\n\t * Due to use of Transactions in checkouts, a common pattern involves applying an edit\n\t * as part of the transaction, then submitting it.\n\t * This cache helps optimize that case by avoiding recomputing the edit if no other edits were added during the transaction.\n\t */\n\tprivate cachedEditResult?: { editId: EditId; result: EditingResult<TChange> };\n\n\tprivate readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/**\n\t * Create a new LogViewer\n\t * @param log - the edit log which snapshots will be based on.\n\t * @param baseTree - the tree used in the snapshot corresponding to the 0th revision. Defaults to `initialTree`.\n\t * @param knownRevisions - a set of [sequencedRevision, snapshot] pairs that are known (have been precomputed) at construction time.\n\t * These revisions are guaranteed to never be evicted from the cache.\n\t * @param expensiveValidation - Iff true, additional correctness assertions will be run during LogViewer operations.\n\t * @param processEditStatus - called after applying an edit.\n\t * @param logger - used to log telemetry\n\t */\n\tpublic constructor(\n\t\tlog: EditLog<TChange>,\n\t\tbaseSnapshot: Snapshot = Snapshot.fromTree(initialTree),\n\t\tknownRevisions: [Revision, EditCacheEntry<TChange>][] = [],\n\t\texpensiveValidation = false,\n\t\tprocessEditStatus: EditStatusCallback = noop,\n\t\tlogger: ITelemetryBaseLogger,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tminimumSequenceNumber = 0\n\t) {\n\t\tthis.log = log;\n\t\tif (expensiveValidation) {\n\t\t\tknownRevisions.forEach(([revision]) => {\n\t\t\t\tassert(Number.isInteger(revision), 'revision must be an integer');\n\t\t\t\tassert(\n\t\t\t\t\tthis.log.isSequencedRevision(revision),\n\t\t\t\t\t'revision must correspond to the result of a SequencedEdit'\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\tthis.sequencedSnapshotCache = new RevisionValueCache(\n\t\t\tCachingLogViewer.sequencedCacheSizeMax,\n\t\t\tminimumSequenceNumber,\n\t\t\t[...knownRevisions, [0, { snapshot: baseSnapshot }]]\n\t\t);\n\t\tthis.processEditStatus = processEditStatus ?? noop;\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.logger = logger;\n\t\tthis.transactionFactory = transactionFactory;\n\t\tthis.log.registerEditAddedHandler(this.handleEditAdded.bind(this));\n\t}\n\n\t/**\n\t * Performs the tracking needed to log telemetry about failed (invalid/malformed) local edits when they are sequenced.\n\t * As a performance optimization, this method also caches snapshots generated by local edits if they are sequenced without\n\t * being interleaved with remote edits.\n\t */\n\tprivate handleEditAdded(edit: Edit<TChange>, isLocal: boolean, wasLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\tthis.unappliedSelfEdits.push(edit.id);\n\t\t} else if (wasLocal) {\n\t\t\t// If the new sequenced edit was generated by this client, the corresponding cache entry (if there is one)\n\t\t\t// will be at the front of the queue. If the queue is empty, then a concurrent sequenced edit from remote client\n\t\t\t// must have invalidated the queue cache.\n\t\t\tconst entry = this.localSnapshotCache.shift();\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst revision = this.log.numberOfSequencedEdits;\n\t\t\t\tconst snapshot = entry.snapshot;\n\t\t\t\tthis.sequencedSnapshotCache.cacheValue(\n\t\t\t\t\trevision,\n\t\t\t\t\tentry.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsnapshot,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tsteps: entry.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsnapshot,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t }\n\t\t\t\t);\n\t\t\t\tthis.handleSequencedEditResult(edit, entry);\n\t\t\t}\n\t\t} else {\n\t\t\t// Invalidate any cached results of applying edits which are ordered after `edit` (which are all remaining local edits)\n\t\t\tthis.localSnapshotCache.clear();\n\t\t}\n\t}\n\n\tpublic async getEditResult(revision: Revision): Promise<EditCacheEntry<TChange>> {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry<TChange> = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = await this.log.getEditAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.snapshot, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic async getSnapshot(revision: Revision): Promise<Snapshot> {\n\t\treturn (await this.getEditResult(revision)).snapshot;\n\t}\n\n\tpublic getEditResultInSession(revision: Revision): EditCacheEntry<TChange> {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry<TChange> = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.snapshot, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic getSnapshotInSession(revision: Revision): Snapshot {\n\t\treturn this.getEditResultInSession(revision).snapshot;\n\t}\n\n\t/**\n\t * Informs the CachingLogViewer of the latest known minimumSequenceNumber for all connected clients.\n\t * This can be used to provide more aggressive caching of revisions within the collaboration window, as those revisions\n\t * are more likely to be demanded to resolve conflicts.\n\t * @param minSequenceNumber - the minimum known sequence number of all connected clients.\n\t */\n\tpublic setMinimumSequenceNumber(minimumSequenceNumber: number): void {\n\t\t// Sequence numbers in Fluid are 1-indexed, meaning they correspond to revisions, and can be used as revisions.\n\t\t// This ensures that all revisions >= minimumSequenceNumber are kept in the cache, meaning that even if all clients are caught up\n\t\t// the most recent sequenced revision will be cached.\n\t\tthis.sequencedSnapshotCache.updateRetentionWindow(minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Inform the CachingLogViewer that a particular edit is know to have a specific result when applied to a particular Snapshot.\n\t * LogViewer may use this information to as a optimization to avoid re-running the edit if re-applied to the same Snapshot.\n\t */\n\tpublic setKnownEditingResult(edit: Edit<TChange>, result: EditingResult<TChange>): void {\n\t\tthis.cachedEditResult = { editId: edit.id, result };\n\t}\n\n\t/**\n\t * @returns the cached snapshot closest to the requested `revision`.\n\t */\n\tprivate getStartingPoint(revision: Revision): { startRevision: Revision } & EditCacheEntry<TChange> {\n\t\t// Per the documentation for revision, the returned snapshot should be the output of the edit at the largest index <= `revision`.\n\t\tconst revisionClamped = Math.min(revision, this.log.length);\n\t\tlet current: EditCacheEntry<TChange>;\n\t\tlet startRevision: Revision;\n\t\tconst { numberOfSequencedEdits } = this.log;\n\t\tconst isLocalRevision = revisionClamped > numberOfSequencedEdits;\n\t\tif (isLocalRevision && !this.localSnapshotCache.isEmpty()) {\n\t\t\tconst { length } = this.localSnapshotCache;\n\t\t\t// Local snapshot cache is indexed such that the snapshot for revision 0 (a local edit) is stored at index 0 in the cache.\n\t\t\t// This is because the local cache does not contain an entry for the implicit initial tree edit.\n\t\t\tconst localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;\n\t\t\tif (localCacheIndex < length) {\n\t\t\t\tconst cached =\n\t\t\t\t\tthis.localSnapshotCache.peekAt(localCacheIndex) ?? fail('missing tail of localSnapshotCache');\n\t\t\t\treturn {\n\t\t\t\t\t...cached,\n\t\t\t\t\tstartRevision: revisionClamped,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tcurrent = this.localSnapshotCache.peekAt(length - 1) ?? fail('missing tail of localSnapshotCache');\n\t\t\t\tstartRevision = numberOfSequencedEdits + length;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [cachedRevision, cachedSnapshot] =\n\t\t\t\tthis.sequencedSnapshotCache.getClosestEntry(revisionClamped) ?? fail('No preceding snapshot cached.');\n\t\t\tstartRevision = cachedRevision;\n\t\t\tcurrent = cachedSnapshot;\n\t\t}\n\t\treturn { startRevision, ...current };\n\t}\n\n\t/**\n\t * Helper for applying an edit at the supplied snapshot.\n\t * Must only be called in the order that edits appear in the log.\n\t * Must only be called once for a given local edit as long as the local cache has not been invalidated.\n\t * Must only be called once for a given sequenced edit.\n\t * @returns the resulting snapshot and the outcome of edit that produced it.\n\t */\n\tprivate applyEdit(\n\t\tprevSnapshot: Snapshot,\n\t\tedit: Edit<TChange>,\n\t\teditIndex: number\n\t): AttemptedEditResultCacheEntry<TChange> {\n\t\tlet editingResult: EditingResult<TChange>;\n\t\tlet cached;\n\t\tif (\n\t\t\tthis.cachedEditResult !== undefined &&\n\t\t\tthis.cachedEditResult.editId === edit.id &&\n\t\t\tthis.cachedEditResult.result.before === prevSnapshot\n\t\t) {\n\t\t\teditingResult = this.cachedEditResult.result;\n\t\t\tcached = true;\n\t\t} else {\n\t\t\teditingResult = this.transactionFactory(prevSnapshot)\n\t\t\t\t.applyChanges(edit.changes, this.reconciliationPathFromEdit(edit.id))\n\t\t\t\t.close();\n\t\t\tcached = false;\n\t\t}\n\n\t\tconst revision = editIndex + 1;\n\t\tlet nextSnapshot: Snapshot;\n\t\tif (editingResult.status === EditStatus.Applied) {\n\t\t\tnextSnapshot = editingResult.after;\n\t\t} else {\n\t\t\tnextSnapshot = prevSnapshot;\n\t\t}\n\n\t\tconst computedCacheEntry =\n\t\t\teditingResult.status === EditStatus.Applied\n\t\t\t\t? { snapshot: nextSnapshot, status: editingResult.status, steps: editingResult.steps }\n\t\t\t\t: { snapshot: nextSnapshot, status: editingResult.status };\n\n\t\tif (this.log.isSequencedRevision(revision)) {\n\t\t\tthis.sequencedSnapshotCache.cacheValue(revision, computedCacheEntry);\n\t\t\tthis.handleSequencedEditResult(edit, computedCacheEntry);\n\t\t} else {\n\t\t\t// This relies on local edits being append only, and that generating the snapshot for a local revision requires generating\n\t\t\t// the snapshot for all local revisions before it in the log. Thus, generating such a snapshot will necessarily require\n\t\t\t// calls to this method for all local revisions prior, guaranteeing the correct push order.\n\t\t\tassert(\n\t\t\t\trevision === this.log.numberOfSequencedEdits + this.localSnapshotCache.length + 1,\n\t\t\t\t'Local snapshot cached out of order.'\n\t\t\t);\n\t\t\tthis.localSnapshotCache.push(computedCacheEntry);\n\t\t}\n\n\t\tthis.processEditStatus(editingResult.status, this.log.getIdAtIndex(editIndex), cached);\n\t\treturn computedCacheEntry;\n\t}\n\n\t/**\n\t * Helper for performing caching and telemetry logging when a sequenced local edit is first applied.\n\t * Must only be called for non-cached sequenced edits.\n\t */\n\tprivate handleSequencedEditResult(edit: Edit<TChange>, result: AttemptedEditResultCacheEntry<TChange>): void {\n\t\t// This is the first time this sequenced edit has been processed by this LogViewer. If it was a local edit, log telemetry\n\t\t// in the event that it was invalid or malformed.\n\t\tif (this.unappliedSelfEdits.length > 0) {\n\t\t\tif (edit.id === this.unappliedSelfEdits.peekFront()) {\n\t\t\t\tif (result.status !== EditStatus.Applied) {\n\t\t\t\t\tthis.logger.send({\n\t\t\t\t\t\tcategory: 'generic',\n\t\t\t\t\t\teventName:\n\t\t\t\t\t\t\tresult.status === EditStatus.Malformed\n\t\t\t\t\t\t\t\t? 'MalformedSharedTreeEdit'\n\t\t\t\t\t\t\t\t: 'InvalidSharedTreeEdit',\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.unappliedSelfEdits.shift();\n\t\t\t} else if (this.expensiveValidation) {\n\t\t\t\tfor (let i = 0; i < this.unappliedSelfEdits.length; i++) {\n\t\t\t\t\tassert(this.unappliedSelfEdits.peekAt(i) !== edit.id, 'Local edits processed out of order.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * We currently compute only the \"main branch\" part of the reconciliation path (meaning we don't include inverts of the edits\n\t * that occurred on the rebased branch). Doing so is only needed for the sequential anchor resolution approach which is not\n\t * yet supported.\n\t * @param editId - The ID for the edit to get the reconciliation path for.\n\t */\n\tpublic reconciliationPathFromEdit(editId: EditId): ReconciliationPath<TChange> {\n\t\tconst reconciliationPath: ReconciliationEdit<TChange>[] = [];\n\t\tlet cached = false;\n\t\treturn new Proxy(reconciliationPath, {\n\t\t\tget: (target, prop): unknown => {\n\t\t\t\tif (!cached) {\n\t\t\t\t\tcached = true;\n\t\t\t\t\tconst orderedId = this.log.getOrderedEditId(editId);\n\t\t\t\t\tif (orderedId.isLocal === false && orderedId.sequenceInfo !== undefined) {\n\t\t\t\t\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\t\t\t\t\tif (earliestSequenced !== undefined) {\n\t\t\t\t\t\t\tconst earliestEditSequenceNumber = earliestSequenced.sequenceNumber;\n\t\t\t\t\t\t\tconst targetSequenceNumber = Math.max(\n\t\t\t\t\t\t\t\tearliestEditSequenceNumber,\n\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (targetSequenceNumber < orderedId.sequenceInfo.sequenceNumber) {\n\t\t\t\t\t\t\t\tconst firstEdit = this.getEditResultFromSequenceNumber(targetSequenceNumber);\n\t\t\t\t\t\t\t\tif (firstEdit !== undefined) {\n\t\t\t\t\t\t\t\t\tif (firstEdit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t...firstEdit.steps,\n\t\t\t\t\t\t\t\t\t\t\tbefore: firstEdit.before,\n\t\t\t\t\t\t\t\t\t\t\tafter: firstEdit.after,\n\t\t\t\t\t\t\t\t\t\t\tlength: firstEdit.steps.length,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst lowestIndex = this.log.getIndexOfId(firstEdit.id) + 1;\n\t\t\t\t\t\t\t\t\tconst highestIndex = this.log.getIndexOfId(editId) - 1;\n\t\t\t\t\t\t\t\t\tfor (let index = lowestIndex; index <= highestIndex; ++index) {\n\t\t\t\t\t\t\t\t\t\tconst edit = this.getEditResultFromIndex(index);\n\t\t\t\t\t\t\t\t\t\tif (edit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...edit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: edit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: edit.after,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: edit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\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\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop];\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @returns Edit information for the earliest known sequenced edit.\n\t */\n\tpublic earliestSequencedEditInSession(): { edit: Edit<TChange>; sequenceNumber: number } | undefined {\n\t\tconst earliestEditIndex = this.log.earliestAvailableEditIndex;\n\t\tconst lastSequencedEdit = this.log.numberOfSequencedEdits + earliestEditIndex - 1;\n\t\tfor (let index = earliestEditIndex; index <= lastSequencedEdit; ++index) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\tconst editOrderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\tif (editOrderedId.sequenceInfo !== undefined) {\n\t\t\t\treturn { edit, sequenceNumber: editOrderedId.sequenceInfo.sequenceNumber };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @returns Edit result information for the edit at the given `index`.\n\t */\n\tprivate getEditResultFromIndex(index: number): EditingResultWithId<TChange> {\n\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\tconst before = this.getSnapshotInSession(index);\n\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\tif (resultAfter.status === undefined) {\n\t\t\tfail('The status of every edit in session should be known');\n\t\t}\n\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t? {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tbefore,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\tafter: resultAfter.snapshot,\n\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\tbefore,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t };\n\t}\n\n\t/**\n\t * @param sequenceNumber - The server-assigned sequenced number assigned to the edit of interest.\n\t * @returns Edit result information for the edit with the given sequence number. Undefined if no such edit is known.\n\t */\n\tpublic getEditResultFromSequenceNumber(sequenceNumber: number): EditingResultWithId<TChange> | undefined {\n\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\tif (earliestSequenced !== undefined && sequenceNumber >= earliestSequenced.sequenceNumber) {\n\t\t\tconst lowestIndex = this.log.getIndexOfId(earliestSequenced.edit.id);\n\t\t\tconst highestIndex = this.log.numberOfSequencedEdits - 1;\n\t\t\tfor (let index = highestIndex; index >= lowestIndex; --index) {\n\t\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\t\tconst orderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\t\t// If `orderedId.sequenceInfo.sequenceNumber` is equal to the requested `sequenceNumber` then we have found the edit of\n\t\t\t\t// interest and simply return its associated information.\n\t\t\t\t// Note that the check bellow also is also satisfied if `orderedId.sequenceInfo.sequenceNumber`is lower than the requested\n\t\t\t\t// `sequenceNumber`. This can happen when the edit for the requested `sequenceNumber` has either not yet been received or\n\t\t\t\t// has been processed by a different DDS (several DDSes can share the same stream of operations and will only see those\n\t\t\t\t// relevant to them). In such cases, we return the edit info for the last known edit before that.\n\t\t\t\tif (orderedId.sequenceInfo && orderedId.sequenceInfo.sequenceNumber <= sequenceNumber) {\n\t\t\t\t\tconst before = this.getSnapshotInSession(index);\n\t\t\t\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\t\t\t\tif (resultAfter.status === undefined) {\n\t\t\t\t\t\tfail('The status of every edit in session should be known');\n\t\t\t\t\t}\n\t\t\t\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t\t\tafter: resultAfter.snapshot,\n\t\t\t\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LogViewer.js","sourceRoot":"","sources":["../src/LogViewer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,qCAA8C;AAG9C,6DAAoE;AAEpE,uDAAqE;AA2JrE;;;;;;GAMG;AACH,MAAa,gBAAgB;IAyE5B;;;;;;;;;OASG;IACH,YACC,GAA4B,EAC5B,QAAsB,EACtB,iBAA+C,EAAE,EACjD,mBAAmB,GAAG,KAAK,EAC3B,oBAAwC,aAAI,EAC5C,6BAA0D,aAAI,EAC7C,kBAAsC,EACvD,qBAAqB,GAAG,CAAC;QADR,uBAAkB,GAAlB,kBAAkB,CAAoB;QAlFxD;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAiC,CAAC;QA0BlF;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAU,CAAC;QAiD1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,mBAAmB,EAAE;YACxB,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE;gBACrC,eAAM,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,6BAA6B,CAAC,CAAC;gBAClE,eAAM,CACL,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EACtC,2DAA2D,CAC3D,CAAC;YACH,CAAC,CAAC,CAAC;SACH;QAED,IAAI,CAAC,sBAAsB,GAAG,IAAI,uCAAkB,CACnD,gBAAgB,CAAC,qBAAqB,EACtC,qBAAqB,EACrB,CAA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AM;4BACN,OAAO,EAAE,IAAI,CAAC,OAAO;4BACrB,IAAI,EAAE,WAAW,CAAC,IAAI;4BACtB,KAAK,EAAE,WAAW,CAAC,KAAK;yBACvB;wBACH,CAAC,CAAC;4BACA,EAAE,EAAE,IAAI,CAAC,EAAE;4BACX,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,OAAO,EAAE,WAAW,CAAC,OAAO;4BAC5B,MAAM;4BACN,IAAI,EAAE,WAAW,CAAC,IAAI;4BACtB,OAAO,EAAE,IAAI,CAAC,OAAO;yBACpB,CAAC;iBACL;aACD;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;;AAjfF,4CAkfC;AA/eA;;GAEG;AACoB,sCAAqB,GAAG,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Denque from 'denque';\nimport { assert, fail, noop } from './Common';\nimport { EditLog, SequencedOrderedEditId } from './EditLog';\nimport { EditId } from './Identifiers';\nimport { Revision, RevisionValueCache } from './RevisionValueCache';\nimport { ReconciliationChange, ReconciliationEdit, ReconciliationPath } from './ReconciliationPath';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { RevisionView } from './RevisionView';\nimport { EditingResult, TransactionInternal, TransactionFactory } from './TransactionInternal';\n\n/**\n * Callback for when an edit is applied (meaning the result of applying it to a particular revision is computed).\n *\n * Edits may be applied any time a TreeView is computed that includes them.\n * Depending on the caching policy of the LogViewer, a given edit may or may not be applied in order to compute a TreeView containing it.\n *\n * If the same edit occurs in different contexts (ex: a local edit is adjusted for a new remote edit),\n * that it will be reapplied, and this may result in different results.\n *\n * Edits may additionally be reapplied at other times since their previous output might not be cached.\n *\n * If an application requests the current view, this will force all edits to be applied.\n * Such an application can use this callback can be log each edit as it comes it to see its status,\n * however this may include duplicates, as well as entries for reapplications in modified contexts.\n *\n * In the context of this callback,\n * skipping the first evaluation of an edit in a particular context due to setKnownEditingResult is still considered applying.\n * To use this call back to track when the actual computational work of applying edits is done, only count cases when `wasCached` is false.\n */\nexport type EditStatusCallback = (editResult: EditStatus, editId: EditId, wasCached: boolean) => void;\n\n/**\n * Callback for when a sequenced edit is applied.\n * This includes local edits though the callback is only invoked once the sequenced version is received.\n *\n * For edits that were local (see {@link SequencedEditResult.wasLocal}, this callback will only be called once.\n * For non-local edits, it may be called multiple times: the number of calls and when they occur depends on caching and is an implementation\n * detail.\n */\nexport type SequencedEditResultCallback = (args: SequencedEditResult) => void;\n\n/**\n * The relevant information pertaining to the application of a sequenced edit.\n */\nexport interface SequencedEditResult {\n\t/**\n\t * The edit that was applied.\n\t */\n\tedit: Edit<ChangeInternal>;\n\t/**\n\t * true iff the edit was local.\n\t */\n\twasLocal: boolean;\n\t/**\n\t * The result of applying the edit.\n\t */\n\tresult: AttemptedEditResultCacheEntry;\n\t/**\n\t * The reconciliation path for the edit.\n\t */\n\treconciliationPath: ReconciliationPath;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit.\n */\nexport type EditCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry | SummarizedEditResultCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has attempted to apply locally.\n */\nexport type AttemptedEditResultCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has successfully applied locally.\n */\nexport interface SuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The resolved changes that were applied during the edit and their associated outcome.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has unsuccessfully attempted to apply locally.\n */\nexport interface UnsuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about the failure encountered by the edit\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has retrieved from a summary.\n * TODO:#57176: once summarized edits carry enough information remove this interface and use `AttemptedEditResultCacheEntry` instead.\n */\nexport interface SummarizedEditResultCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * Not specified on `SummarizedEditResultCacheEntry`.\n\t * Declared to allow checking `entry.status` against undefined.\n\t */\n\treadonly status?: never;\n}\n\nexport type CachedEditingResult = AttemptedEditResultCacheEntry & {\n\t/**\n\t * Unique identifier for this edit. Must never be reused.\n\t * Used for referencing and de-duplicating edits.\n\t */\n\treadonly id: EditId;\n\treadonly before: RevisionView;\n\treadonly changes: readonly ChangeInternal[];\n};\n\n/**\n * Creates `RevisionView`s for the revisions in an `EditLog`\n */\nexport interface LogViewer {\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionView(revision: Revision): Promise<RevisionView>;\n\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t * Can only be used to retrieve revisions added during the current sessions.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionViewInSession(revision: Revision): RevisionView;\n}\n\n/**\n * Creates views for revisions associated with an EditLog and caches the results.\n *\n * Does so by listening for edits added to the log. If the underlying EditLog or its listeners need to be reused beyond the lifetime of\n * a CachingLogViewer instance, that instance should be disposed with `detachFromEditLog` to ensure it is garbage-collectable.\n * @internal\n */\nexport class CachingLogViewer implements LogViewer {\n\tpublic readonly log: EditLog<ChangeInternal>;\n\n\t/**\n\t * Maximum size of the sequenced revision cache.\n\t */\n\tpublic static readonly sequencedCacheSizeMax = 50;\n\n\t/**\n\t * A cache for local revisions.\n\t * It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.\n\t * When a previously local edit is sequenced, this cache is adjusted to account for it, not invalidated.\n\t */\n\tprivate readonly localRevisionCache = new Denque<AttemptedEditResultCacheEntry>();\n\n\t/**\n\t * Cache of sequenced revisions.\n\t */\n\tprivate readonly sequencedRevisionCache: RevisionValueCache<EditCacheEntry>;\n\n\t/**\n\t * Called whenever a sequenced edit is applied.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processSequencedEditResult: SequencedEditResultCallback;\n\n\t/**\n\t * Called whenever an edit is processed.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processEditStatus: EditStatusCallback;\n\n\t/**\n\t * Iff true, additional correctness assertions will be run during LogViewer operations.\n\t */\n\tprivate readonly expensiveValidation: boolean;\n\n\t/**\n\t * The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.\n\t * This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.\n\t * Used to log telemetry about the result of edit application. Edits are removed when first applied after being sequenced.\n\t */\n\tprivate readonly unappliedSelfEdits = new Denque<EditId>();\n\n\t/**\n\t * Cache of applying a edit.\n\t * Due to use of Transactions in checkouts, a common pattern involves applying an edit\n\t * as part of the transaction, then submitting it.\n\t * This cache helps optimize that case by avoiding recomputing the edit if no other edits were added during the transaction.\n\t */\n\tprivate cachedEditResult?: { editId: EditId; result: EditingResult };\n\n\t/**\n\t * Cache entry for the highest revision.\n\t * `undefined` when not cached.\n\t */\n\tprivate highestRevisionCacheEntry?: EditCacheEntry;\n\n\t/**\n\t * Removes this log viewer from the set of handleEditAdded listeners on its underlying log.\n\t * This should be called if the underlying log or its listeners are re-used past the lifetime of this log viewer.\n\t */\n\tpublic readonly detachFromEditLog: () => void;\n\n\t/**\n\t * @returns true if the highest revision is cached.\n\t */\n\tpublic highestRevisionCached(): boolean {\n\t\treturn this.highestRevisionCacheEntry !== undefined;\n\t}\n\n\t/**\n\t * Create a new LogViewer\n\t * @param log - the edit log which revisions will be based on.\n\t * @param baseTree - the tree used in the view corresponding to the 0th revision.\n\t * @param knownRevisions - a set of [sequencedRevision, view] pairs that are known (have been precomputed) at construction time.\n\t * These revisions are guaranteed to never be evicted from the cache.\n\t * @param expensiveValidation - Iff true, additional correctness assertions will be run during LogViewer operations.\n\t * @param processEditStatus - called after applying an edit.\n\t * @param processSequencedEditResult - called after applying a sequenced edit.\n\t */\n\tpublic constructor(\n\t\tlog: EditLog<ChangeInternal>,\n\t\tbaseView: RevisionView,\n\t\tknownRevisions: [Revision, EditCacheEntry][] = [],\n\t\texpensiveValidation = false,\n\t\tprocessEditStatus: EditStatusCallback = noop,\n\t\tprocessSequencedEditResult: SequencedEditResultCallback = noop,\n\t\tprivate readonly transactionFactory: TransactionFactory,\n\t\tminimumSequenceNumber = 0\n\t) {\n\t\tthis.log = log;\n\t\tif (expensiveValidation) {\n\t\t\tknownRevisions.forEach(([revision]) => {\n\t\t\t\tassert(Number.isInteger(revision), 'revision must be an integer');\n\t\t\t\tassert(\n\t\t\t\t\tthis.log.isSequencedRevision(revision),\n\t\t\t\t\t'revision must correspond to the result of a SequencedEdit'\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\tthis.sequencedRevisionCache = new RevisionValueCache(\n\t\t\tCachingLogViewer.sequencedCacheSizeMax,\n\t\t\tminimumSequenceNumber,\n\t\t\t[...knownRevisions, [0, { view: baseView }]]\n\t\t);\n\t\tthis.processEditStatus = processEditStatus ?? noop;\n\t\tthis.processSequencedEditResult = processSequencedEditResult ?? noop;\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\t\tthis.detachFromEditLog = this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));\n\t}\n\n\t/**\n\t * As a performance optimization, this method caches views generated by local edits if they are sequenced without\n\t * being interleaved with remote edits.\n\t */\n\tprivate handleEditAdded(edit: Edit<ChangeInternal>, isLocal: boolean, wasLocal: boolean): void {\n\t\t// Clear highestRevisionCacheEntry, since what revision is highest might change.\n\t\t// Note that as an optimization we could skip clearing this when a local edit is sequenced.\n\t\tthis.highestRevisionCacheEntry = undefined;\n\n\t\tif (isLocal) {\n\t\t\tthis.unappliedSelfEdits.push(edit.id);\n\t\t} else if (wasLocal) {\n\t\t\t// If the new sequenced edit was generated by this client, the corresponding cache entry (if there is one)\n\t\t\t// will be at the front of the queue. If the queue is empty, then a concurrent sequenced edit from remote client\n\t\t\t// must have invalidated the queue cache.\n\t\t\tconst entry = this.localRevisionCache.shift();\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst revision = this.log.numberOfSequencedEdits;\n\t\t\t\tconst { view } = entry;\n\t\t\t\tthis.sequencedRevisionCache.cacheValue(\n\t\t\t\t\trevision,\n\t\t\t\t\tentry.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tsteps: entry.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tfailure: entry.failure,\n\t\t\t\t\t\t }\n\t\t\t\t);\n\t\t\t\tthis.handleSequencedEditResult(edit, entry, []);\n\t\t\t}\n\t\t} else {\n\t\t\t// Invalidate any cached results of applying edits which are ordered after `edit` (which are all remaining local edits)\n\t\t\tthis.localRevisionCache.clear();\n\t\t}\n\t}\n\n\tpublic async getEditResult(revision: Revision): Promise<EditCacheEntry> {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = await this.log.getEditAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic async getRevisionView(revision: Revision): Promise<RevisionView> {\n\t\treturn (await this.getEditResult(revision)).view;\n\t}\n\n\tpublic getEditResultInSession(revision: Revision): EditCacheEntry {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic getRevisionViewInSession(revision: Revision): RevisionView {\n\t\treturn this.getEditResultInSession(revision).view;\n\t}\n\n\t/**\n\t * Informs the CachingLogViewer of the latest known minimumSequenceNumber for all connected clients.\n\t * This can be used to provide more aggressive caching of revisions within the collaboration window, as those revisions\n\t * are more likely to be demanded to resolve conflicts.\n\t * @param minSequenceNumber - the minimum known sequence number of all connected clients.\n\t */\n\tpublic setMinimumSequenceNumber(minimumSequenceNumber: number): void {\n\t\t// Sequence numbers in Fluid are 1-indexed, meaning they correspond to revisions, and can be used as revisions.\n\t\t// This ensures that all revisions >= minimumSequenceNumber are kept in the cache, meaning that even if all clients are caught up\n\t\t// the most recent sequenced revision will be cached.\n\t\tthis.sequencedRevisionCache.updateRetentionWindow(minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Inform the CachingLogViewer that a particular edit is known to have a specific result when applied to a particular TreeView.\n\t * CachingLogViewer may use this information as an optimization to avoid re-running the edit if re-applied to the same TreeView.\n\t */\n\tpublic setKnownEditingResult(edit: Edit<ChangeInternal>, result: EditingResult): void {\n\t\tthis.cachedEditResult = { editId: edit.id, result };\n\t}\n\n\t/**\n\t * @returns the cached revision view closest to the requested `revision`.\n\t */\n\tprivate getStartingPoint(revision: Revision): { startRevision: Revision } & EditCacheEntry {\n\t\t// Per the documentation for revision, the returned view should be the output of the edit at the largest index <= `revision`.\n\t\tconst revisionClamped = Math.min(revision, this.log.length);\n\n\t\t// If the highest revision is requested, and it's cached, use highestRevisionCacheEntry.\n\t\tif (revisionClamped === this.log.length && this.highestRevisionCacheEntry !== undefined) {\n\t\t\treturn { ...this.highestRevisionCacheEntry, startRevision: revisionClamped };\n\t\t}\n\n\t\tlet current: EditCacheEntry;\n\t\tlet startRevision: Revision;\n\t\tconst { numberOfSequencedEdits } = this.log;\n\t\tconst isLocalRevision = revisionClamped > numberOfSequencedEdits;\n\t\tif (isLocalRevision && !this.localRevisionCache.isEmpty()) {\n\t\t\tconst { length } = this.localRevisionCache;\n\t\t\t// Local revision view cache is indexed such that the view for revision 0 (a local edit) is stored at index 0 in the cache.\n\t\t\t// This is because the local cache does not contain an entry for the implicit initial tree edit.\n\t\t\tconst localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;\n\t\t\tif (localCacheIndex < length) {\n\t\t\t\tconst cached =\n\t\t\t\t\tthis.localRevisionCache.peekAt(localCacheIndex) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\treturn {\n\t\t\t\t\t...cached,\n\t\t\t\t\tstartRevision: revisionClamped,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tcurrent = this.localRevisionCache.peekAt(length - 1) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\tstartRevision = numberOfSequencedEdits + length;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [cachedRevision, cachedView] =\n\t\t\t\tthis.sequencedRevisionCache.getClosestEntry(revisionClamped) ??\n\t\t\t\tfail('No preceding revision view cached.');\n\n\t\t\tstartRevision = cachedRevision;\n\t\t\tcurrent = cachedView;\n\t\t}\n\t\treturn { startRevision, ...current };\n\t}\n\n\t/**\n\t * Helper for applying an edit at the supplied revision view.\n\t * Must only be called in the order that edits appear in the log.\n\t * Must only be called once for a given local edit as long as the local cache has not been invalidated.\n\t * Must only be called once for a given sequenced edit.\n\t * @returns the resulting revision view and the outcome of edit that produced it.\n\t */\n\tprivate applyEdit(\n\t\tprevView: RevisionView,\n\t\tedit: Edit<ChangeInternal>,\n\t\teditIndex: number\n\t): AttemptedEditResultCacheEntry {\n\t\tlet editingResult: EditingResult;\n\t\tlet cached;\n\t\tlet reconciliationPath: ReconciliationPath = [];\n\t\tif (\n\t\t\tthis.cachedEditResult !== undefined &&\n\t\t\tthis.cachedEditResult.editId === edit.id &&\n\t\t\tthis.cachedEditResult.result.before === prevView\n\t\t) {\n\t\t\teditingResult = this.cachedEditResult.result;\n\t\t\tcached = true;\n\t\t} else {\n\t\t\treconciliationPath = this.reconciliationPathFromEdit(edit.id);\n\t\t\teditingResult = this.transactionFactory(prevView).applyChanges(edit.changes, reconciliationPath).close();\n\t\t\tcached = false;\n\t\t}\n\n\t\tconst revision = editIndex + 1;\n\t\tlet nextView: RevisionView;\n\t\tif (editingResult.status === EditStatus.Applied) {\n\t\t\tnextView = editingResult.after;\n\t\t} else {\n\t\t\tnextView = prevView;\n\t\t}\n\n\t\tconst computedCacheEntry =\n\t\t\teditingResult.status === EditStatus.Applied\n\t\t\t\t? { view: nextView, status: editingResult.status, steps: editingResult.steps }\n\t\t\t\t: { view: nextView, status: editingResult.status, failure: editingResult.failure };\n\n\t\tif (this.log.isSequencedRevision(revision)) {\n\t\t\tthis.sequencedRevisionCache.cacheValue(revision, computedCacheEntry);\n\t\t\tthis.handleSequencedEditResult(edit, computedCacheEntry, reconciliationPath);\n\t\t} else {\n\t\t\t// This relies on local edits being append only, and that generating the view for a local revision requires generating\n\t\t\t// the views for all local revisions before it in the log. Thus, generating such a view will necessarily require\n\t\t\t// calls to this method for all local revisions prior, guaranteeing the correct push order.\n\t\t\tassert(\n\t\t\t\trevision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1,\n\t\t\t\t'Local revision view cached out of order.'\n\t\t\t);\n\t\t\tthis.localRevisionCache.push(computedCacheEntry);\n\t\t}\n\n\t\t// Only update highestRevisionCacheEntry if this snapshot is the highest revision.\n\t\tif (revision >= this.log.length) {\n\t\t\tthis.highestRevisionCacheEntry = computedCacheEntry;\n\t\t}\n\n\t\tthis.processEditStatus(editingResult.status, this.log.getIdAtIndex(editIndex), cached);\n\t\treturn computedCacheEntry;\n\t}\n\n\t/**\n\t * Helper for performing caching when a sequenced local edit is first applied.\n\t * Invokes the `processSequencedEditResult` handler that was passed to the constructor (if any).\n\t * Must only be called for non-cached sequenced edits.\n\t */\n\tprivate handleSequencedEditResult(\n\t\tedit: Edit<ChangeInternal>,\n\t\tresult: AttemptedEditResultCacheEntry,\n\t\treconciliationPath: ReconciliationPath\n\t): void {\n\t\tlet wasLocal = false;\n\t\t// This is the first time this sequenced edit has been processed by this LogViewer. If it was a local edit, log telemetry\n\t\t// in the event that it was invalid or malformed.\n\t\tif (this.unappliedSelfEdits.length > 0) {\n\t\t\tif (edit.id === this.unappliedSelfEdits.peekFront()) {\n\t\t\t\twasLocal = true;\n\t\t\t\tthis.unappliedSelfEdits.shift();\n\t\t\t} else if (this.expensiveValidation) {\n\t\t\t\tfor (let i = 0; i < this.unappliedSelfEdits.length; i++) {\n\t\t\t\t\tassert(this.unappliedSelfEdits.peekAt(i) !== edit.id, 'Local edits processed out of order.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.processSequencedEditResult({ edit, wasLocal, result, reconciliationPath });\n\t}\n\n\t/**\n\t * We currently compute only the \"main branch\" part of the reconciliation path (meaning we don't include inverts of the edits\n\t * that occurred on the rebased branch). Doing so is only needed for the sequential anchor resolution approach which is not\n\t * yet supported.\n\t * @param editId - The ID for the edit to get the reconciliation path for.\n\t */\n\tpublic reconciliationPathFromEdit(editId: EditId): ReconciliationPath {\n\t\tconst reconciliationPath: ReconciliationEdit[] = [];\n\t\tlet cached = false;\n\t\treturn new Proxy(reconciliationPath, {\n\t\t\tget: (target, prop): unknown => {\n\t\t\t\tif (!cached) {\n\t\t\t\t\tcached = true;\n\t\t\t\t\tconst orderedId = this.log.getOrderedEditId(editId);\n\t\t\t\t\tif (orderedId.isLocal === false && orderedId.sequenceInfo !== undefined) {\n\t\t\t\t\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\t\t\t\t\tif (earliestSequenced !== undefined) {\n\t\t\t\t\t\t\tconst earliestEditSequenceNumber = earliestSequenced.sequenceNumber;\n\t\t\t\t\t\t\tconst targetSequenceNumber = Math.max(\n\t\t\t\t\t\t\t\tearliestEditSequenceNumber,\n\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (targetSequenceNumber < orderedId.sequenceInfo.sequenceNumber) {\n\t\t\t\t\t\t\t\tconst firstEdit = this.getEditResultFromSequenceNumber(targetSequenceNumber);\n\t\t\t\t\t\t\t\tif (firstEdit !== undefined) {\n\t\t\t\t\t\t\t\t\tif (firstEdit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\tconst firstEditInfo = this.log.getOrderedEditId(\n\t\t\t\t\t\t\t\t\t\t\tfirstEdit.id\n\t\t\t\t\t\t\t\t\t\t) as SequencedOrderedEditId;\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo.sequenceNumber >\n\t\t\t\t\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...firstEdit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: firstEdit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: firstEdit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: firstEdit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst lowestIndex = this.log.getIndexOfId(firstEdit.id) + 1;\n\t\t\t\t\t\t\t\t\tconst highestIndex = this.log.getIndexOfId(editId) - 1;\n\t\t\t\t\t\t\t\t\tfor (let index = lowestIndex; index <= highestIndex; ++index) {\n\t\t\t\t\t\t\t\t\t\tconst edit = this.getEditResultFromIndex(index);\n\t\t\t\t\t\t\t\t\t\tif (edit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...edit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: edit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: edit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: edit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\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\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop];\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @returns Edit information for the earliest known sequenced edit.\n\t */\n\tpublic earliestSequencedEditInSession(): { edit: Edit<ChangeInternal>; sequenceNumber: number } | undefined {\n\t\tconst earliestEditIndex = this.log.earliestAvailableEditIndex;\n\t\tconst lastSequencedEdit = this.log.numberOfSequencedEdits + earliestEditIndex - 1;\n\t\tfor (let index = earliestEditIndex; index <= lastSequencedEdit; ++index) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\tconst editOrderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\tif (editOrderedId.sequenceInfo !== undefined) {\n\t\t\t\treturn { edit, sequenceNumber: editOrderedId.sequenceInfo.sequenceNumber };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @returns Edit result information for the edit at the given `index`.\n\t */\n\tprivate getEditResultFromIndex(index: number): CachedEditingResult {\n\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\tconst before = this.getRevisionViewInSession(index);\n\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\tif (resultAfter.status === undefined) {\n\t\t\tfail('The status of every edit in session should be known');\n\t\t}\n\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t? {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tbefore,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\tbefore,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t };\n\t}\n\n\t/**\n\t * @param sequenceNumber - The server-assigned sequenced number assigned to the edit of interest.\n\t * @returns Edit result information for the edit with the given sequence number or the nearest sequenced edit before that.\n\t * Undefined if no sequenced edit occurred at or prior to the given sequenceNumber.\n\t */\n\tpublic getEditResultFromSequenceNumber(sequenceNumber: number): CachedEditingResult | undefined {\n\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\tif (earliestSequenced !== undefined && sequenceNumber >= earliestSequenced.sequenceNumber) {\n\t\t\tconst lowestIndex = this.log.getIndexOfId(earliestSequenced.edit.id);\n\t\t\tconst highestIndex = this.log.numberOfSequencedEdits - 1;\n\t\t\tfor (let index = highestIndex; index >= lowestIndex; --index) {\n\t\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\t\tconst orderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\t\t// If `orderedId.sequenceInfo.sequenceNumber` is equal to the requested `sequenceNumber` then we have found the edit of\n\t\t\t\t// interest and simply return its associated information.\n\t\t\t\t// Note that the check bellow also is also satisfied if `orderedId.sequenceInfo.sequenceNumber`is lower than the requested\n\t\t\t\t// `sequenceNumber`. This can happen when the edit for the requested `sequenceNumber` has either not yet been received or\n\t\t\t\t// has been processed by a different DDS (several DDSes can share the same stream of operations and will only see those\n\t\t\t\t// relevant to them). In such cases, we return the edit info for the last known edit before that.\n\t\t\t\tif (orderedId.sequenceInfo && orderedId.sequenceInfo.sequenceNumber <= sequenceNumber) {\n\t\t\t\t\tconst before = this.getRevisionViewInSession(index);\n\t\t\t\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\t\t\t\tif (resultAfter.status === undefined) {\n\t\t\t\t\t\tfail('The status of every edit in session should be known');\n\t\t\t\t\t}\n\t\t\t\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|