@fluid-experimental/tree 0.58.2001 → 0.59.2000-61729
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 +159 -46
- 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 -105
- 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 +61 -32
- 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 +129 -85
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +111 -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 +105 -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 +439 -0
- package/dist/SharedTree.d.ts.map +1 -0
- package/dist/SharedTree.js +1109 -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 +71 -0
- package/dist/Transaction.d.ts.map +1 -0
- package/dist/Transaction.js +92 -0
- package/dist/Transaction.js.map +1 -0
- package/dist/TransactionInternal.d.ts +540 -0
- package/dist/TransactionInternal.d.ts.map +1 -0
- package/dist/TransactionInternal.js +626 -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/docs/Write-Format.md +19 -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 -105
- 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 +53 -24
- 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 +129 -85
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +103 -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 +105 -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 +439 -0
- package/lib/SharedTree.d.ts.map +1 -0
- package/lib/SharedTree.js +1104 -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 +71 -0
- package/lib/Transaction.d.ts.map +1 -0
- package/lib/Transaction.js +88 -0
- package/lib/Transaction.js.map +1 -0
- package/lib/TransactionInternal.d.ts +540 -0
- package/lib/TransactionInternal.d.ts.map +1 -0
- package/lib/TransactionInternal.js +622 -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 +276 -191
- 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 +109 -329
- 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 +146 -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 -125
- package/src/Checkout.ts +82 -53
- 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 +156 -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 +1501 -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 +120 -0
- package/src/TransactionInternal.ts +1087 -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 +118 -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/docs/Future.md +0 -155
- 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/Common.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.copyPropertyIfDefined = exports.noop = exports.compareArrays = exports.compareIterables = exports.memoizeGetter = exports.assertArrayOfOne = exports.assertNotUndefined = exports.fail = exports.assert = exports.
|
|
7
|
+
exports.Result = exports.backmap = exports.compareBtrees = exports.setPropertyIfDefined = exports.copyPropertyIfDefined = exports.identity = exports.noop = exports.getOrCreate = exports.compareMaps = exports.compareArrays = exports.compareIterables = exports.find = exports.reduce = exports.filter = exports.map = exports.memoizeGetter = exports.assign = exports.assertArrayOfOne = exports.assertNotUndefined = exports.fail = exports.assert = exports.compareStrings = exports.compareFiniteNumbers = exports.isSharedTreeEvent = exports.sharedTreeAssertionErrorType = void 0;
|
|
8
8
|
const defaultFailMessage = 'Assertion failed';
|
|
9
9
|
/**
|
|
10
10
|
* Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field
|
|
@@ -32,114 +32,26 @@ class SharedTreeAssertionError extends Error {
|
|
|
32
32
|
super(message);
|
|
33
33
|
this.errorType = exports.sharedTreeAssertionErrorType;
|
|
34
34
|
this.name = 'Assertion error';
|
|
35
|
+
// Note: conditional as `captureStackTrace` isn't defined in all browsers (e.g. Safari).
|
|
35
36
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
|
-
*
|
|
40
|
-
* May return false for equivalent payloads encoded differently.
|
|
40
|
+
* Compares finite numbers to form a strict partial ordering.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
* (This is because they may not be preserved through roundtrip).
|
|
44
|
-
*
|
|
45
|
-
* For other information which Fluid would lose on serialization round trip,
|
|
46
|
-
* behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)
|
|
47
|
-
* and commutative (argument order does not matter).
|
|
48
|
-
*
|
|
49
|
-
* This means that any Payload is equal to itself and a deep clone of itself.
|
|
50
|
-
*
|
|
51
|
-
* Payloads might not be equal to a version of themselves that has been serialized then deserialized.
|
|
52
|
-
* If they are serialized then deserialized again, the two deserialized objects will compare equal,
|
|
53
|
-
* however the serialized strings may be unequal (due to field order for objects being unspecified).
|
|
54
|
-
*
|
|
55
|
-
* Fluid will cause lossy operations due to use of JSON.stringify().
|
|
56
|
-
* This includes:
|
|
57
|
-
* - Loss of object identity
|
|
58
|
-
* - Loss of field order (may be ordered arbitrarily)
|
|
59
|
-
* - -0 becomes +0
|
|
60
|
-
* - NaN, Infinity, -Infinity all become null
|
|
61
|
-
* - custom toJSON functions may cause arbitrary behavior
|
|
62
|
-
* - functions become undefined or null
|
|
63
|
-
* - non enumerable properties (including prototype) are lost
|
|
64
|
-
* - more (this is not a complete list)
|
|
65
|
-
*
|
|
66
|
-
* Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).
|
|
67
|
-
*
|
|
68
|
-
* IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.
|
|
69
|
-
*
|
|
70
|
-
* TODO:#54095: Is there a better way to do this comparison?
|
|
71
|
-
* @public
|
|
42
|
+
* Handles +/-0 like Map: -0 is equal to +0.
|
|
72
43
|
*/
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
// This treats -0 and +0 as different.
|
|
76
|
-
// Since -0 is not preserved in serialization round trips,
|
|
77
|
-
// it can be handed in any way that is reflective and commutative, so this is fine.
|
|
78
|
-
if (Object.is(a, b)) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.
|
|
82
|
-
if (typeof a !== 'object' || typeof b !== 'object') {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
// null is of type object, and needs to be treated as distinct from the empty object.
|
|
86
|
-
// Handling it early also avoids type errors trying to access its keys.
|
|
87
|
-
// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).
|
|
88
|
-
if (a === null || b === null) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
// Special case IFluidHandles, comparing them only by their absolutePath
|
|
92
|
-
// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.
|
|
93
|
-
{
|
|
94
|
-
const aHandle = a;
|
|
95
|
-
const bHandle = b;
|
|
96
|
-
if (aHandle.IFluidHandle === a) {
|
|
97
|
-
if (bHandle.IFluidHandle !== b) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return a.absolutePath === b.absolutePath;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.
|
|
104
|
-
const aKeys = Object.keys(a);
|
|
105
|
-
const bKeys = Object.keys(b);
|
|
106
|
-
if (aKeys.length !== bKeys.length) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
// make sure objects with numeric keys (or no keys) compare unequal to arrays.
|
|
110
|
-
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.
|
|
114
|
-
// Therefor the keys arrays must be sorted here.
|
|
115
|
-
if (!Array.isArray(a)) {
|
|
116
|
-
aKeys.sort();
|
|
117
|
-
bKeys.sort();
|
|
118
|
-
}
|
|
119
|
-
// First check keys are equal.
|
|
120
|
-
// This will often early exit, and thus is worth doing as a separate pass than recursive check.
|
|
121
|
-
if (!compareArrays(aKeys, bKeys)) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
125
|
-
const aItem = a[aKeys[i]];
|
|
126
|
-
const bItem = b[bKeys[i]];
|
|
127
|
-
// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.
|
|
128
|
-
// Detect this pattern and special case it to avoid infinite recursion.
|
|
129
|
-
const aSelf = Object.is(aItem, a);
|
|
130
|
-
const bSelf = Object.is(bItem, b);
|
|
131
|
-
if (aSelf !== bSelf) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (!aSelf) {
|
|
135
|
-
if (!comparePayloads(aItem, bItem)) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return true;
|
|
44
|
+
function compareFiniteNumbers(a, b) {
|
|
45
|
+
return a - b;
|
|
141
46
|
}
|
|
142
|
-
exports.
|
|
47
|
+
exports.compareFiniteNumbers = compareFiniteNumbers;
|
|
48
|
+
/**
|
|
49
|
+
* Compares strings lexically to form a strict partial ordering.
|
|
50
|
+
*/
|
|
51
|
+
function compareStrings(a, b) {
|
|
52
|
+
return a > b ? 1 : a === b ? 0 : -1;
|
|
53
|
+
}
|
|
54
|
+
exports.compareStrings = compareStrings;
|
|
143
55
|
/**
|
|
144
56
|
* Asserts against a boolean condition. Throws an Error if the assertion failed. Will run and throw in release builds.
|
|
145
57
|
* Use when violations are logic errors in the program.
|
|
@@ -162,7 +74,6 @@ exports.assert = assert;
|
|
|
162
74
|
*/
|
|
163
75
|
function fail(message = defaultFailMessage, containsPII = false) {
|
|
164
76
|
if (process.env.NODE_ENV !== 'production') {
|
|
165
|
-
// eslint-disable-next-line no-debugger
|
|
166
77
|
debugger;
|
|
167
78
|
console.error(message);
|
|
168
79
|
}
|
|
@@ -172,6 +83,18 @@ exports.fail = fail;
|
|
|
172
83
|
/**
|
|
173
84
|
* Asserts a value is not undefined, and returns the value.
|
|
174
85
|
* Use when violations are logic errors in the program.
|
|
86
|
+
*
|
|
87
|
+
* When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.
|
|
88
|
+
* Using `?? fail` allows for message formatting without incurring the cost of formatting the message in the non failing case
|
|
89
|
+
* (ex:
|
|
90
|
+
* ```
|
|
91
|
+
* x ?? fail(`x should exist for ${y}`)
|
|
92
|
+
* ```
|
|
93
|
+
* ). Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.
|
|
94
|
+
*
|
|
95
|
+
* Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.
|
|
96
|
+
* This pattern is preferred because it is more general (same approach works with typeof, instance of, comparison to other values etc.).
|
|
97
|
+
*
|
|
175
98
|
* @param value - Value to assert against is non undefined.
|
|
176
99
|
* @param message - Message to be printed if assertion fails.
|
|
177
100
|
*/
|
|
@@ -190,6 +113,17 @@ function assertArrayOfOne(array, message = 'array value must contain exactly one
|
|
|
190
113
|
return array[0];
|
|
191
114
|
}
|
|
192
115
|
exports.assertArrayOfOne = assertArrayOfOne;
|
|
116
|
+
/**
|
|
117
|
+
* Assign a property and value to a given object.
|
|
118
|
+
* @param object - the object to add the property to
|
|
119
|
+
* @param property - the property key
|
|
120
|
+
* @param value - the value of the property
|
|
121
|
+
* @returns `object` after assigning `value` to the property `property`.
|
|
122
|
+
*/
|
|
123
|
+
function assign(object, property, value) {
|
|
124
|
+
return Object.assign(object, { [property]: value });
|
|
125
|
+
}
|
|
126
|
+
exports.assign = assign;
|
|
193
127
|
/**
|
|
194
128
|
* Redefine a property to have the given value. This is simply a type-safe wrapper around
|
|
195
129
|
* `Object.defineProperty`, but it is useful for caching public getters on first read.
|
|
@@ -215,6 +149,59 @@ function memoizeGetter(object, propName, value) {
|
|
|
215
149
|
return value;
|
|
216
150
|
}
|
|
217
151
|
exports.memoizeGetter = memoizeGetter;
|
|
152
|
+
/**
|
|
153
|
+
* Map an iterable to another iterable
|
|
154
|
+
*/
|
|
155
|
+
function* map(sequence, mapper) {
|
|
156
|
+
for (const t of sequence) {
|
|
157
|
+
yield mapper(t);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.map = map;
|
|
161
|
+
/**
|
|
162
|
+
* Filter an iterable into another iterable
|
|
163
|
+
*/
|
|
164
|
+
function* filter(sequence, filter) {
|
|
165
|
+
for (const t of sequence) {
|
|
166
|
+
if (filter(t)) {
|
|
167
|
+
yield t;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.filter = filter;
|
|
172
|
+
/**
|
|
173
|
+
* Reduce an iterable into a single value, or undefined if the iterable has too few elements to reduce
|
|
174
|
+
*/
|
|
175
|
+
function reduce(sequence, reduce, initialValue) {
|
|
176
|
+
let previous;
|
|
177
|
+
let current;
|
|
178
|
+
for (const t of sequence) {
|
|
179
|
+
current = t;
|
|
180
|
+
if (previous === undefined) {
|
|
181
|
+
if (initialValue !== undefined) {
|
|
182
|
+
current = reduce(initialValue, current);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
current = reduce(previous, current);
|
|
187
|
+
}
|
|
188
|
+
previous = current;
|
|
189
|
+
}
|
|
190
|
+
return current;
|
|
191
|
+
}
|
|
192
|
+
exports.reduce = reduce;
|
|
193
|
+
/**
|
|
194
|
+
* Returns the first element of the given sequence that satisfies the given predicate, or undefined if no such element exists
|
|
195
|
+
*/
|
|
196
|
+
function find(sequence, find) {
|
|
197
|
+
for (const t of sequence) {
|
|
198
|
+
if (find(t)) {
|
|
199
|
+
return t;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
exports.find = find;
|
|
218
205
|
/**
|
|
219
206
|
* Iterate through two iterables and return true if they yield equivalent elements in the same order.
|
|
220
207
|
* @param iterableA - the first iterable to compare
|
|
@@ -267,6 +254,42 @@ function compareArrays(arrayA, arrayB, elementComparator = Object.is) {
|
|
|
267
254
|
return true;
|
|
268
255
|
}
|
|
269
256
|
exports.compareArrays = compareArrays;
|
|
257
|
+
/**
|
|
258
|
+
* Compare two maps and return true if their contents are equivalent.
|
|
259
|
+
* @param mapA - the first array to compare
|
|
260
|
+
* @param mapB - the second array to compare
|
|
261
|
+
* @param elementComparator - the function used to check if two `T`s are equivalent.
|
|
262
|
+
* Defaults to `Object.is()` equality (a shallow compare)
|
|
263
|
+
*/
|
|
264
|
+
function compareMaps(mapA, mapB, elementComparator = Object.is) {
|
|
265
|
+
if (mapA.size !== mapB.size) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
for (const [keyA, valueA] of mapA) {
|
|
269
|
+
const valueB = mapB.get(keyA);
|
|
270
|
+
if (valueB === undefined || !elementComparator(valueA, valueB)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
exports.compareMaps = compareMaps;
|
|
277
|
+
/**
|
|
278
|
+
* Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
|
|
279
|
+
* @param map - the map to query/update
|
|
280
|
+
* @param key - the key to lookup in the map
|
|
281
|
+
* @param defaultValue - a function which returns a default value. This is called and used to set an initial value in the map if none exists
|
|
282
|
+
* @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)
|
|
283
|
+
*/
|
|
284
|
+
function getOrCreate(map, key, defaultValue) {
|
|
285
|
+
let value = map.get(key);
|
|
286
|
+
if (value === undefined) {
|
|
287
|
+
value = defaultValue();
|
|
288
|
+
map.set(key, value);
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
exports.getOrCreate = getOrCreate;
|
|
270
293
|
/**
|
|
271
294
|
* Function which does nothing (no-ops).
|
|
272
295
|
*/
|
|
@@ -274,6 +297,13 @@ function noop() {
|
|
|
274
297
|
// noop
|
|
275
298
|
}
|
|
276
299
|
exports.noop = noop;
|
|
300
|
+
/**
|
|
301
|
+
* Function which returns its input
|
|
302
|
+
*/
|
|
303
|
+
function identity(t) {
|
|
304
|
+
return t;
|
|
305
|
+
}
|
|
306
|
+
exports.identity = identity;
|
|
277
307
|
/**
|
|
278
308
|
* Copies a property in such a way that it is only set on `destination` if it is present on `source`.
|
|
279
309
|
* This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.
|
|
@@ -285,4 +315,111 @@ function copyPropertyIfDefined(source, destination, property) {
|
|
|
285
315
|
}
|
|
286
316
|
}
|
|
287
317
|
exports.copyPropertyIfDefined = copyPropertyIfDefined;
|
|
318
|
+
/**
|
|
319
|
+
* Sets a property in such a way that it is only set on `destination` if the provided value is not undefined.
|
|
320
|
+
* This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.
|
|
321
|
+
*/
|
|
322
|
+
function setPropertyIfDefined(value, destination, property) {
|
|
323
|
+
if (value !== undefined) {
|
|
324
|
+
destination[property] = value;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.setPropertyIfDefined = setPropertyIfDefined;
|
|
328
|
+
/**
|
|
329
|
+
* function (thing: ObjectWithMaybeFoo) {
|
|
330
|
+
* const x: MyActualType = {
|
|
331
|
+
* bar: 3
|
|
332
|
+
* };
|
|
333
|
+
* x.foo = 3;
|
|
334
|
+
*
|
|
335
|
+
* copyPropertyIfDefined(thing, x, 'foo');
|
|
336
|
+
* }
|
|
337
|
+
* @returns
|
|
338
|
+
*/
|
|
339
|
+
function breakOnDifference() {
|
|
340
|
+
return { break: true };
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Helper that returns whether two b-trees are equal.
|
|
344
|
+
* Accelerated when large portions of the tree are shared between the two.
|
|
345
|
+
*/
|
|
346
|
+
function compareBtrees(treeA, treeB, compare) {
|
|
347
|
+
const diff = treeA.diffAgainst(treeB, breakOnDifference, breakOnDifference, (_, valA, valB) => {
|
|
348
|
+
if (!compare(valA, valB)) {
|
|
349
|
+
return { break: true };
|
|
350
|
+
}
|
|
351
|
+
return undefined;
|
|
352
|
+
});
|
|
353
|
+
return diff === undefined;
|
|
354
|
+
}
|
|
355
|
+
exports.compareBtrees = compareBtrees;
|
|
356
|
+
function backmap(forwardmap) {
|
|
357
|
+
return new Map(map(forwardmap, ([key, value]) => [value, key]));
|
|
358
|
+
}
|
|
359
|
+
exports.backmap = backmap;
|
|
360
|
+
var Result;
|
|
361
|
+
(function (Result) {
|
|
362
|
+
/**
|
|
363
|
+
* Factory function for making a successful Result.
|
|
364
|
+
* @param result - The result to wrap in the Result.
|
|
365
|
+
*/
|
|
366
|
+
function ok(result) {
|
|
367
|
+
return { type: ResultType.Ok, result };
|
|
368
|
+
}
|
|
369
|
+
Result.ok = ok;
|
|
370
|
+
/**
|
|
371
|
+
* Factory function for making a unsuccessful Result.
|
|
372
|
+
* @param error - The error to wrap in the Result.
|
|
373
|
+
*/
|
|
374
|
+
function error(error) {
|
|
375
|
+
return { type: ResultType.Error, error };
|
|
376
|
+
}
|
|
377
|
+
Result.error = error;
|
|
378
|
+
/**
|
|
379
|
+
* Type guard for successful Result.
|
|
380
|
+
* @returns True if `result` is successful.
|
|
381
|
+
*/
|
|
382
|
+
function isOk(result) {
|
|
383
|
+
return result.type === ResultType.Ok;
|
|
384
|
+
}
|
|
385
|
+
Result.isOk = isOk;
|
|
386
|
+
/**
|
|
387
|
+
* Type guard for unsuccessful Result.
|
|
388
|
+
* @returns True if `result` is unsuccessful.
|
|
389
|
+
*/
|
|
390
|
+
function isError(result) {
|
|
391
|
+
return result.type === ResultType.Error;
|
|
392
|
+
}
|
|
393
|
+
Result.isError = isError;
|
|
394
|
+
/**
|
|
395
|
+
* Maps the given result with the given function when the result is ok.
|
|
396
|
+
* @param result - The result to map.
|
|
397
|
+
* @param map - The function to apply to derive the new result.
|
|
398
|
+
* @returns The given result if it is not ok, the mapped result otherwise.
|
|
399
|
+
*/
|
|
400
|
+
function mapOk(result, map) {
|
|
401
|
+
return isOk(result) ? ok(map(result.result)) : result;
|
|
402
|
+
}
|
|
403
|
+
Result.mapOk = mapOk;
|
|
404
|
+
/**
|
|
405
|
+
* Maps the given result with the given function when the result is an error.
|
|
406
|
+
* @param result - The result to map.
|
|
407
|
+
* @param map - The function to apply to derive the new error.
|
|
408
|
+
* @returns The given result if it is ok, the mapped result otherwise.
|
|
409
|
+
*/
|
|
410
|
+
function mapError(result, map) {
|
|
411
|
+
return isError(result) ? error(map(result.error)) : result;
|
|
412
|
+
}
|
|
413
|
+
Result.mapError = mapError;
|
|
414
|
+
/**
|
|
415
|
+
* Tag value use to differentiate the members of the `Result` discriminated union.
|
|
416
|
+
*/
|
|
417
|
+
let ResultType;
|
|
418
|
+
(function (ResultType) {
|
|
419
|
+
/** Signals a successful result. */
|
|
420
|
+
ResultType[ResultType["Ok"] = 0] = "Ok";
|
|
421
|
+
/** Signals an unsuccessful result. */
|
|
422
|
+
ResultType[ResultType["Error"] = 1] = "Error";
|
|
423
|
+
})(ResultType = Result.ResultType || (Result.ResultType = {}));
|
|
424
|
+
})(Result = exports.Result || (exports.Result = {}));
|
|
288
425
|
//# sourceMappingURL=Common.js.map
|
package/dist/Common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C;;;;;;;;GAQG;AACU,QAAA,4BAA4B,GAAG,qBAAqB,CAAC;AASlE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA0B;IAC3D,OAAQ,KAAkD,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACvF,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,MAAM,wBAAyB,SAAQ,KAAK;IAG3C,YAAmB,OAAe;;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHA,cAAS,GAAG,oCAA4B,CAAC;QAIxD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,MAAA,KAAK,CAAC,iBAAiB,+CAAvB,KAAK,EAAqB,IAAI,EAAE;IACjC,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2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AAE,2CAA2C;KAC/E,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,6CAA6C;MACvF;QACD,mDAAmD;QACnD,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;KACD;IAED,2EAA2E;IAC3E,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,MAAoB,EACpB,MAAoB,EACpB,oBAA6C,MAAM,CAAC,EAAE;IAEtD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE;QACpC,OAAO,KAAK,CAAC;KACb;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACb;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAhBD,sCAgBC;AAED;;GAEG;AACH,SAAgB,IAAI;IACnB,OAAO;AACR,CAAC;AAFD,oBAEC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAa,MAAY,EAAE,WAAiB,EAAE,QAAoB;IACtG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,WAAmB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;KACvC;AACF,CAAC;AALD,sDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerPropertyBag } from '@fluidframework/telemetry-utils';\nimport { ITelemetryBaseEvent } from '@fluidframework/common-definitions';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { Payload } from './generic';\n\nconst defaultFailMessage = 'Assertion failed';\n\n/**\n * Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field\n * in its handlings of errors thrown by containers. See\n * https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-utils/src/error.ts\n *\n * Exporting this enables users to safely filter telemetry handling of errors based on their type.\n *\n * @public\n */\nexport const sharedTreeAssertionErrorType = 'SharedTreeAssertion';\n\n/**\n * Telemetry properties decorated on all SharedTree events.\n */\nexport interface SharedTreeTelemetryProperties extends ITelemetryLoggerPropertyBag {\n\tisSharedTreeEvent: true;\n}\n\n/**\n * Returns if the supplied event is a SharedTree telemetry event.\n */\nexport function isSharedTreeEvent(event: ITelemetryBaseEvent): boolean {\n\treturn (event as unknown as SharedTreeTelemetryProperties).isSharedTreeEvent === true;\n}\n\n/**\n * Error object thrown by assertion failures in `SharedTree`.\n */\nclass SharedTreeAssertionError extends Error {\n\tpublic readonly errorType = sharedTreeAssertionErrorType;\n\n\tpublic constructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'Assertion error';\n\t\tError.captureStackTrace?.(this);\n\t}\n}\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @public\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (Array.isArray(a) !== Array.isArray(b)) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!Array.isArray(a)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Asserts against a boolean condition. Throws an Error if the assertion failed. Will run and throw in release builds.\n * Use when violations are logic errors in the program.\n * @param condition - A condition to assert is truthy\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function assert(condition: unknown, message?: string, containsPII = false): asserts condition {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (!condition) {\n\t\tfail(message, containsPII);\n\t}\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function fail(message: string = defaultFailMessage, containsPII = false): never {\n\tif (process.env.NODE_ENV !== 'production') {\n\t\t// eslint-disable-next-line no-debugger\n\t\tdebugger;\n\t\tconsole.error(message);\n\t}\n\n\tthrow new SharedTreeAssertionError(containsPII ? 'Assertion failed' : message);\n}\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(value: T | undefined, message = 'value must not be undefined'): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Asserts an array contains a single value and returns the value.\n * @param array - array to assert contains a single value.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertArrayOfOne<T>(array: readonly T[], message = 'array value must contain exactly one item'): T {\n\tassert(array.length === 1, message);\n\treturn array[0];\n}\n\n/**\n * Redefine a property to have the given value. This is simply a type-safe wrapper around\n * `Object.defineProperty`, but it is useful for caching public getters on first read.\n * @example\n * ```\n * // `randomOnce()` will return a random number, but always the same random number.\n * {\n * get randomOnce(): number {\n * return memoizeGetter(this, 'randomOnce', random(100))\n * }\n * }\n * ```\n * @param object - the object containing the property\n * @param propName - the name of the property on the object\n * @param value - the value of the property\n */\nexport function memoizeGetter<T, K extends keyof T>(object: T, propName: K, value: T[K]): T[K] {\n\tObject.defineProperty(object, propName, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\treturn value;\n}\n\n/**\n * Iterate through two iterables and return true if they yield equivalent elements in the same order.\n * @param iterableA - the first iterable to compare\n * @param iterableB - the second iterable to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareIterables<T>(\n\titerableA: Iterable<T>,\n\titerableB: Iterable<T>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\treturn compareIterators<T>(iterableA[Symbol.iterator](), iterableB[Symbol.iterator](), elementComparator);\n}\n\n/**\n * Iterate through two iterators and return true if they yield equivalent elements in the same order.\n * @param iteratorA - the first iterator to compare\n * @param iteratorB - the second iterator to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nfunction compareIterators<T, TReturn extends T = T>(\n\titeratorA: Iterator<T, TReturn>,\n\titeratorB: Iterator<T, TReturn>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tlet a: IteratorResult<T, TReturn>;\n\tlet b: IteratorResult<T, TReturn>;\n\tfor (\n\t\ta = iteratorA.next(), b = iteratorB.next(); // Given two iterators...\n\t\ta.done !== true && b.done !== true; // ...while both have elements remaining...\n\t\ta = iteratorA.next(), b = iteratorB.next() // ...take one element at a time from each...\n\t) {\n\t\t// ...and ensure that their elements are equivalent\n\t\tif (!elementComparator(a.value, b.value)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// If one iterator is done, but not the other, then they are not equivalent\n\treturn a.done === b.done;\n}\n\n/**\n * Compare two arrays and return true if their elements are equivalent and in the same order.\n * @param arrayA - the first array to compare\n * @param arrayB - the second array to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareArrays<T>(\n\tarrayA: readonly T[],\n\tarrayB: readonly T[],\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tif (arrayA.length !== arrayB.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\tif (!elementComparator(arrayA[i], arrayB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Function which does nothing (no-ops).\n */\nexport function noop(): void {\n\t// noop\n}\n\n/**\n * Copies a property in such a way that it is only set on `destination` if it is present on `source`.\n * This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.\n */\nexport function copyPropertyIfDefined<TSrc, TDst>(source: TSrc, destination: TDst, property: keyof TSrc): void {\n\tconst value = source[property];\n\tif (value !== undefined) {\n\t\t(destination as any)[property] = value;\n\t}\n}\n\n/**\n * A developer facing (non-localized) error message.\n * TODO: better error system.\n */\nexport type ErrorString = string;\n"]}
|
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AEpB,CAAA;IACD;;;OAGG;IACH,SAAgB,IAAI,CAAc,MAA2B;QAC5D,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,EAAE,CAAC;IACtC,CAAC;IAFe,WAAI,OAEnB,CAAA;IACD;;;OAGG;IACH,SAAgB,OAAO,CAAc,MAA2B;QAC/D,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,KAAK,CAAC;IACzC,CAAC;IAFe,cAAO,UAEtB,CAAA;IACD;;;;;OAKG;IACH,SAAgB,KAAK,CACpB,MAA6B,EAC7B,GAA0B;QAE1B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACvD,CAAC;IALe,YAAK,QAKpB,CAAA;IACD;;;;;OAKG;IACH,SAAgB,QAAQ,CACvB,MAA6B,EAC7B,GAAmC;QAEnC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5D,CAAC;IALe,eAAQ,WAKvB,CAAA;IACD;;OAEG;IACH,IAAY,UAKX;IALD,WAAY,UAAU;QACrB,mCAAmC;QACnC,uCAAE,CAAA;QACF,sCAAsC;QACtC,6CAAK,CAAA;IACN,CAAC,EALW,UAAU,GAAV,iBAAU,KAAV,iBAAU,QAKrB;AAeF,CAAC,EA5EgB,MAAM,GAAN,cAAM,KAAN,cAAM,QA4EtB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseEvent, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport BTree from 'sorted-btree';\n\nconst defaultFailMessage = 'Assertion failed';\n\n/**\n * Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field\n * in its handlings of errors thrown by containers. See\n * https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-utils/src/error.ts\n *\n * Exporting this enables users to safely filter telemetry handling of errors based on their type.\n *\n * @public\n */\nexport const sharedTreeAssertionErrorType = 'SharedTreeAssertion';\n\n/**\n * Telemetry properties decorated on all SharedTree events.\n */\nexport interface SharedTreeTelemetryProperties extends ITelemetryProperties {\n\treadonly isSharedTreeEvent: true;\n}\n\n/**\n * Returns if the supplied event is a SharedTree telemetry event.\n */\nexport function isSharedTreeEvent(event: ITelemetryBaseEvent): boolean {\n\treturn (event as unknown as SharedTreeTelemetryProperties).isSharedTreeEvent === true;\n}\n\n/**\n * Error object thrown by assertion failures in `SharedTree`.\n */\nclass SharedTreeAssertionError extends Error {\n\tpublic readonly errorType = sharedTreeAssertionErrorType;\n\n\tpublic constructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'Assertion error';\n\t\t// Note: conditional as `captureStackTrace` isn't defined in all browsers (e.g. Safari).\n\t\tError.captureStackTrace?.(this);\n\t}\n}\n\n/**\n * Compares finite numbers to form a strict partial ordering.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Asserts against a boolean condition. Throws an Error if the assertion failed. Will run and throw in release builds.\n * Use when violations are logic errors in the program.\n * @param condition - A condition to assert is truthy\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function assert(condition: unknown, message?: string, containsPII = false): asserts condition {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (!condition) {\n\t\tfail(message, containsPII);\n\t}\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function fail(message: string = defaultFailMessage, containsPII = false): never {\n\tif (process.env.NODE_ENV !== 'production') {\n\t\tdebugger;\n\t\tconsole.error(message);\n\t}\n\n\tthrow new SharedTreeAssertionError(containsPII ? 'Assertion failed' : message);\n}\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n *\n * When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.\n * Using `?? fail` allows for message formatting without incurring the cost of formatting the message in the non failing case\n * (ex:\n * ```\n * x ?? fail(`x should exist for ${y}`)\n * ```\n * ). Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.\n *\n * Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.\n * This pattern is preferred because it is more general (same approach works with typeof, instance of, comparison to other values etc.).\n *\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(value: T | undefined, message = 'value must not be undefined'): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Asserts an array contains a single value and returns the value.\n * @param array - array to assert contains a single value.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertArrayOfOne<T>(array: readonly T[], message = 'array value must contain exactly one item'): T {\n\tassert(array.length === 1, message);\n\treturn array[0];\n}\n\n/**\n * Assign a property and value to a given object.\n * @param object - the object to add the property to\n * @param property - the property key\n * @param value - the value of the property\n * @returns `object` after assigning `value` to the property `property`.\n */\nexport function assign<T, K extends keyof never, V>(object: T, property: K, value: V): With<T, K, V> {\n\treturn Object.assign(object, { [property]: value }) as With<T, K, V>;\n}\n\n/**\n * Redefine a property to have the given value. This is simply a type-safe wrapper around\n * `Object.defineProperty`, but it is useful for caching public getters on first read.\n * @example\n * ```\n * // `randomOnce()` will return a random number, but always the same random number.\n * {\n * get randomOnce(): number {\n * return memoizeGetter(this, 'randomOnce', random(100))\n * }\n * }\n * ```\n * @param object - the object containing the property\n * @param propName - the name of the property on the object\n * @param value - the value of the property\n */\nexport function memoizeGetter<T, K extends keyof T>(object: T, propName: K, value: T[K]): T[K] {\n\tObject.defineProperty(object, propName, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\treturn value;\n}\n\n/**\n * Map an iterable to another iterable\n */\nexport function* map<T, R>(sequence: Iterable<T>, mapper: (t: T) => R): Iterable<R> {\n\tfor (const t of sequence) {\n\t\tyield mapper(t);\n\t}\n}\n\n/**\n * Filter an iterable into another iterable\n */\nexport function* filter<T>(sequence: Iterable<T>, filter: (t: T) => boolean): Iterable<T> {\n\tfor (const t of sequence) {\n\t\tif (filter(t)) {\n\t\t\tyield t;\n\t\t}\n\t}\n}\n\n/**\n * Reduce an iterable into a single value, or undefined if the iterable has too few elements to reduce\n */\nexport function reduce<T>(\n\tsequence: Iterable<T>,\n\treduce: (previous: T, current: T) => T,\n\tinitialValue?: T\n): T | undefined {\n\tlet previous: T | undefined;\n\tlet current: T | undefined;\n\tfor (const t of sequence) {\n\t\tcurrent = t;\n\t\tif (previous === undefined) {\n\t\t\tif (initialValue !== undefined) {\n\t\t\t\tcurrent = reduce(initialValue, current);\n\t\t\t}\n\t\t} else {\n\t\t\tcurrent = reduce(previous, current);\n\t\t}\n\t\tprevious = current;\n\t}\n\treturn current;\n}\n\n/**\n * Returns the first element of the given sequence that satisfies the given predicate, or undefined if no such element exists\n */\nexport function find<T>(sequence: Iterable<T>, find: (t: T) => boolean): T | undefined {\n\tfor (const t of sequence) {\n\t\tif (find(t)) {\n\t\t\treturn t;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Iterate through two iterables and return true if they yield equivalent elements in the same order.\n * @param iterableA - the first iterable to compare\n * @param iterableB - the second iterable to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareIterables<T>(\n\titerableA: Iterable<T>,\n\titerableB: Iterable<T>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\treturn compareIterators<T>(iterableA[Symbol.iterator](), iterableB[Symbol.iterator](), elementComparator);\n}\n\n/**\n * Iterate through two iterators and return true if they yield equivalent elements in the same order.\n * @param iteratorA - the first iterator to compare\n * @param iteratorB - the second iterator to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nfunction compareIterators<T, TReturn extends T = T>(\n\titeratorA: Iterator<T, TReturn>,\n\titeratorB: Iterator<T, TReturn>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tlet a: IteratorResult<T, TReturn>;\n\tlet b: IteratorResult<T, TReturn>;\n\tfor (\n\t\ta = iteratorA.next(), b = iteratorB.next(); // Given two iterators...\n\t\ta.done !== true && b.done !== true; // ...while both have elements remaining...\n\t\ta = iteratorA.next(), b = iteratorB.next() // ...take one element at a time from each...\n\t) {\n\t\t// ...and ensure that their elements are equivalent\n\t\tif (!elementComparator(a.value, b.value)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// If one iterator is done, but not the other, then they are not equivalent\n\treturn a.done === b.done;\n}\n\n/**\n * Compare two arrays and return true if their elements are equivalent and in the same order.\n * @param arrayA - the first array to compare\n * @param arrayB - the second array to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareArrays<T>(\n\tarrayA: readonly T[],\n\tarrayB: readonly T[],\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tif (arrayA.length !== arrayB.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\tif (!elementComparator(arrayA[i], arrayB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Compare two maps and return true if their contents are equivalent.\n * @param mapA - the first array to compare\n * @param mapB - the second array to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareMaps<K, V>(\n\tmapA: ReadonlyMap<K, V>,\n\tmapB: ReadonlyMap<K, V>,\n\telementComparator: (a: V, b: V) => boolean = Object.is\n): boolean {\n\tif (mapA.size !== mapB.size) {\n\t\treturn false;\n\t}\n\n\tfor (const [keyA, valueA] of mapA) {\n\t\tconst valueB = mapB.get(keyA);\n\t\tif (valueB === undefined || !elementComparator(valueA, valueB)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - the map to query/update\n * @param key - the key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: () => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue();\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Function which does nothing (no-ops).\n */\nexport function noop(): void {\n\t// noop\n}\n\n/**\n * Function which returns its input\n */\nexport function identity<T>(t: T): T {\n\treturn t;\n}\n\n/**\n * Copies a property in such a way that it is only set on `destination` if it is present on `source`.\n * This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.\n */\nexport function copyPropertyIfDefined<TSrc, TDst>(source: TSrc, destination: TDst, property: keyof TSrc): void {\n\tconst value = source[property];\n\tif (value !== undefined) {\n\t\t(destination as any)[property] = value;\n\t}\n}\n\n/**\n * Sets a property in such a way that it is only set on `destination` if the provided value is not undefined.\n * This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.\n */\nexport function setPropertyIfDefined<TDst, P extends keyof TDst>(\n\tvalue: TDst[P] | undefined,\n\tdestination: TDst,\n\tproperty: P\n): void {\n\tif (value !== undefined) {\n\t\tdestination[property] = value;\n\t}\n}\n\n/**\n * function (thing: ObjectWithMaybeFoo) {\n * \t const x: MyActualType = {\n * \t bar: 3\n * };\n * \t\tx.foo = 3;\n *\n * \t copyPropertyIfDefined(thing, x, 'foo');\n * }\n * @returns\n */\n\nfunction breakOnDifference(): { break: boolean } {\n\treturn { break: true };\n}\n\n/**\n * Helper that returns whether two b-trees are equal.\n * Accelerated when large portions of the tree are shared between the two.\n */\nexport function compareBtrees<K, V>(treeA: BTree<K, V>, treeB: BTree<K, V>, compare: (valA: V, valB: V) => boolean) {\n\tconst diff = treeA.diffAgainst(treeB, breakOnDifference, breakOnDifference, (_, valA, valB) => {\n\t\tif (!compare(valA, valB)) {\n\t\t\treturn { break: true };\n\t\t}\n\t\treturn undefined;\n\t});\n\n\treturn diff === undefined;\n}\n\nexport function backmap<K, V>(forwardmap: Map<V, K>): Map<K, V> {\n\treturn new Map(map(forwardmap, ([key, value]) => [value, key]));\n}\n\n/**\n * A developer facing (non-localized) error message.\n * TODO: better error system.\n */\nexport type ErrorString = string;\n\n/**\n * Discriminated union instance that wraps either a result of type `TOk` or an error of type `TError`.\n */\nexport type Result<TOk, TError> = Result.Ok<TOk> | Result.Error<TError>;\n\nexport namespace Result {\n\t/**\n\t * Factory function for making a successful Result.\n\t * @param result - The result to wrap in the Result.\n\t */\n\texport function ok<TOk>(result: TOk): Ok<TOk> {\n\t\treturn { type: ResultType.Ok, result };\n\t}\n\t/**\n\t * Factory function for making a unsuccessful Result.\n\t * @param error - The error to wrap in the Result.\n\t */\n\texport function error<TError>(error: TError): Error<TError> {\n\t\treturn { type: ResultType.Error, error };\n\t}\n\t/**\n\t * Type guard for successful Result.\n\t * @returns True if `result` is successful.\n\t */\n\texport function isOk<TOk, TError>(result: Result<TOk, TError>): result is Ok<TOk> {\n\t\treturn result.type === ResultType.Ok;\n\t}\n\t/**\n\t * Type guard for unsuccessful Result.\n\t * @returns True if `result` is unsuccessful.\n\t */\n\texport function isError<TOk, TError>(result: Result<TOk, TError>): result is Error<TError> {\n\t\treturn result.type === ResultType.Error;\n\t}\n\t/**\n\t * Maps the given result with the given function when the result is ok.\n\t * @param result - The result to map.\n\t * @param map - The function to apply to derive the new result.\n\t * @returns The given result if it is not ok, the mapped result otherwise.\n\t */\n\texport function mapOk<TOkIn, TOkOut, TError>(\n\t\tresult: Result<TOkIn, TError>,\n\t\tmap: (ok: TOkIn) => TOkOut\n\t): Result<TOkOut, TError> {\n\t\treturn isOk(result) ? ok(map(result.result)) : result;\n\t}\n\t/**\n\t * Maps the given result with the given function when the result is an error.\n\t * @param result - The result to map.\n\t * @param map - The function to apply to derive the new error.\n\t * @returns The given result if it is ok, the mapped result otherwise.\n\t */\n\texport function mapError<TOk, TErrorIn, TErrorOut>(\n\t\tresult: Result<TOk, TErrorIn>,\n\t\tmap: (error: TErrorIn) => TErrorOut\n\t): Result<TOk, TErrorOut> {\n\t\treturn isError(result) ? error(map(result.error)) : result;\n\t}\n\t/**\n\t * Tag value use to differentiate the members of the `Result` discriminated union.\n\t */\n\texport enum ResultType {\n\t\t/** Signals a successful result. */\n\t\tOk,\n\t\t/** Signals an unsuccessful result. */\n\t\tError,\n\t}\n\t/**\n\t * Wraps a result of type `TOk`.\n\t */\n\texport interface Ok<TOk> {\n\t\treadonly type: ResultType.Ok;\n\t\treadonly result: TOk;\n\t}\n\t/**\n\t * Wraps an error of type `TError`.\n\t */\n\texport interface Error<TError> {\n\t\treadonly type: ResultType.Error;\n\t\treadonly error: TError;\n\t}\n}\n\n/** Type that removes `readonly` from fields. */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/** Type that recursively removes `readonly` from fields. */\nexport type RecursiveMutable<T> = {\n\t-readonly [K in keyof T]: RecursiveMutable<T[K]>;\n};\n\n/** Type that produces a writeable map from a readonly map. */\nexport type MutableMap<T extends ReadonlyMap<unknown, unknown>> = T extends ReadonlyMap<infer K, infer V>\n\t? Map<K, V>\n\t: never;\n\n/** Type that includes the property K: V on T */\nexport type With<T, K extends keyof never, V> = T & { [key in K]: V };\n\n/**\n * A readonly `Map` which is known to contain a value for every possible key\n */\nexport interface ClosedMap<K, V> extends Omit<Map<K, V>, 'delete' | 'clear'> {\n\tget(key: K): V;\n}\n\n/**\n * Change the given property Prop of type T to have a type of TPropNew\n */\nexport type ChangePropType<T, Prop extends keyof T, TPropNew> = Omit<T, Prop> & { [_ in Prop]: TPropNew };\n\n// eslint-disable-next-line @rushstack/no-new-null\ntype Primitive = string | number | bigint | boolean | null | symbol | undefined;\n\n/**\n * Recursively replace all properties with type assignable to type TReplace in T with properties of type TWith.\n */\nexport type ReplaceRecursive<T, TReplace, TWith> = T extends TReplace\n\t? TWith\n\t: T extends Primitive\n\t? T\n\t: {\n\t\t\t[P in keyof T]: ReplaceRecursive<T[P], TReplace, TWith>;\n\t };\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Checkout } from './Checkout';
|
|
6
|
+
import { RevisionView } from './RevisionView';
|
|
7
|
+
import { SharedTree } from './SharedTree';
|
|
8
|
+
/**
|
|
9
|
+
* Checkout that always stays up to date with the SharedTree.
|
|
10
|
+
* This means that {@link EagerCheckout.waitForPendingUpdates} is always a no-op since EagerCheckout is always up to date.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @sealed
|
|
14
|
+
*/
|
|
15
|
+
export declare class EagerCheckout extends Checkout {
|
|
16
|
+
/**
|
|
17
|
+
* @param tree - the tree
|
|
18
|
+
*/
|
|
19
|
+
constructor(tree: SharedTree);
|
|
20
|
+
protected get latestCommittedView(): RevisionView;
|
|
21
|
+
waitForPendingUpdates(): Promise<void>;
|
|
22
|
+
waitForEditsToSubmit(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=EagerCheckout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EagerCheckout.d.ts","sourceRoot":"","sources":["../src/EagerCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,QAAQ;IAC1C;;OAEG;gBACgB,IAAI,EAAE,UAAU;IAMnC,SAAS,KAAK,mBAAmB,IAAI,YAAY,CAEhD;IAEY,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.EagerCheckout = void 0;
|
|
8
8
|
const Checkout_1 = require("./Checkout");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Checkout that always stays up to date with the SharedTree.
|
|
11
|
+
* This means that {@link EagerCheckout.waitForPendingUpdates} is always a no-op since EagerCheckout is always up to date.
|
|
11
12
|
*
|
|
12
|
-
* waitForPendingUpdates is always a no-op since BasicCheckout is always up to date.
|
|
13
13
|
* @public
|
|
14
14
|
* @sealed
|
|
15
15
|
*/
|
|
16
|
-
class
|
|
16
|
+
class EagerCheckout extends Checkout_1.Checkout {
|
|
17
17
|
/**
|
|
18
18
|
* @param tree - the tree
|
|
19
19
|
*/
|
|
@@ -28,6 +28,9 @@ class BasicCheckout extends Checkout_1.Checkout {
|
|
|
28
28
|
async waitForPendingUpdates() {
|
|
29
29
|
return Promise.resolve();
|
|
30
30
|
}
|
|
31
|
+
async waitForEditsToSubmit() {
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
|
-
exports.
|
|
33
|
-
//# sourceMappingURL=
|
|
35
|
+
exports.EagerCheckout = EagerCheckout;
|
|
36
|
+
//# sourceMappingURL=EagerCheckout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EagerCheckout.js","sourceRoot":"","sources":["../src/EagerCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAsC;AAItC;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,mBAAQ;IAC1C;;OAEG;IACH,YAAmB,IAAgB;QAClC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,IAAiC,EAAE,EAAE;YACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAc,mBAAmB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QACjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,oBAAoB;QAChC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD;AArBD,sCAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Checkout } from './Checkout';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedEventArguments, SharedTree } from './SharedTree';\n\n/**\n * Checkout that always stays up to date with the SharedTree.\n * This means that {@link EagerCheckout.waitForPendingUpdates} is always a no-op since EagerCheckout is always up to date.\n *\n * @public\n * @sealed\n */\nexport class EagerCheckout extends Checkout {\n\t/**\n\t * @param tree - the tree\n\t */\n\tpublic constructor(tree: SharedTree) {\n\t\tsuper(tree, tree.currentView, (args: EditCommittedEventArguments) => {\n\t\t\tthis.emitChange();\n\t\t});\n\t}\n\n\tprotected get latestCommittedView(): RevisionView {\n\t\treturn this.tree.currentView;\n\t}\n\n\tpublic async waitForPendingUpdates(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n\n\tpublic async waitForEditsToSubmit(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n}\n"]}
|