@fluid-experimental/tree 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +4 -0
- package/api-report/experimental-tree.api.md +4 -15
- package/dist/ChangeCompression.d.ts +5 -5
- package/dist/ChangeCompression.d.ts.map +1 -1
- package/dist/ChangeCompression.js +24 -24
- package/dist/ChangeCompression.js.map +1 -1
- package/dist/ChangeTypes.d.ts +3 -3
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +9 -9
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +7 -7
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +27 -27
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +2 -2
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/EagerCheckout.d.ts +3 -3
- package/dist/EagerCheckout.d.ts.map +1 -1
- package/dist/EagerCheckout.js +2 -2
- package/dist/EagerCheckout.js.map +1 -1
- package/dist/EditLog.d.ts +4 -6
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +9 -9
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +6 -6
- package/dist/EditUtilities.d.ts.map +1 -1
- package/dist/EditUtilities.js +28 -28
- package/dist/EditUtilities.js.map +1 -1
- package/dist/Forest.d.ts +2 -2
- package/dist/Forest.d.ts.map +1 -1
- package/dist/Forest.js +13 -13
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.d.ts +3 -3
- package/dist/HistoryEditFactory.d.ts.map +1 -1
- package/dist/HistoryEditFactory.js +36 -36
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/IdConversion.d.ts +3 -3
- package/dist/IdConversion.d.ts.map +1 -1
- package/dist/IdConversion.js +23 -23
- package/dist/IdConversion.js.map +1 -1
- package/dist/InitialTree.d.ts +1 -1
- package/dist/InitialTree.d.ts.map +1 -1
- package/dist/InitialTree.js +2 -2
- package/dist/InitialTree.js.map +1 -1
- package/dist/LazyCheckout.d.ts +5 -5
- package/dist/LazyCheckout.d.ts.map +1 -1
- package/dist/LazyCheckout.js +2 -2
- package/dist/LazyCheckout.js.map +1 -1
- package/dist/LogViewer.d.ts +7 -7
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +25 -25
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.d.ts +1 -1
- package/dist/MergeHealth.d.ts.map +1 -1
- package/dist/MergeHealth.js +32 -32
- package/dist/MergeHealth.js.map +1 -1
- package/dist/NodeIdUtilities.d.ts +3 -3
- package/dist/NodeIdUtilities.d.ts.map +1 -1
- package/dist/NodeIdUtilities.js +4 -4
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.d.ts +1 -1
- package/dist/PayloadUtilities.d.ts.map +1 -1
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/ReconciliationPath.d.ts +3 -3
- package/dist/ReconciliationPath.d.ts.map +1 -1
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.js +5 -5
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +5 -5
- package/dist/RevisionView.d.ts.map +1 -1
- package/dist/RevisionView.js +11 -11
- package/dist/RevisionView.js.map +1 -1
- package/dist/SerializationUtilities.d.ts +4 -4
- package/dist/SerializationUtilities.d.ts.map +1 -1
- package/dist/SerializationUtilities.js +5 -5
- package/dist/SerializationUtilities.js.map +1 -1
- package/dist/SharedTree.d.ts +15 -18
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +154 -166
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +8 -8
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +67 -67
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/StringInterner.d.ts +1 -1
- package/dist/StringInterner.d.ts.map +1 -1
- package/dist/StringInterner.js +2 -2
- package/dist/StringInterner.js.map +1 -1
- package/dist/Summary.d.ts +4 -4
- package/dist/Summary.d.ts.map +1 -1
- package/dist/Summary.js +2 -2
- package/dist/Summary.js.map +1 -1
- package/dist/SummaryBackCompatibility.d.ts +3 -3
- package/dist/SummaryBackCompatibility.d.ts.map +1 -1
- package/dist/SummaryBackCompatibility.js +13 -13
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/SummaryTestUtilities.d.ts +2 -2
- package/dist/SummaryTestUtilities.d.ts.map +1 -1
- package/dist/SummaryTestUtilities.js.map +1 -1
- package/dist/Transaction.d.ts +4 -4
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +10 -10
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.d.ts +7 -7
- package/dist/TransactionInternal.d.ts.map +1 -1
- package/dist/TransactionInternal.js +87 -87
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeCompressor.d.ts +4 -4
- package/dist/TreeCompressor.d.ts.map +1 -1
- package/dist/TreeCompressor.js +6 -6
- package/dist/TreeCompressor.js.map +1 -1
- package/dist/TreeNodeHandle.d.ts +3 -3
- package/dist/TreeNodeHandle.d.ts.map +1 -1
- package/dist/TreeNodeHandle.js +5 -5
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.d.ts +3 -3
- package/dist/TreeView.d.ts.map +1 -1
- package/dist/TreeView.js +10 -10
- package/dist/TreeView.js.map +1 -1
- package/dist/TreeViewUtilities.d.ts +2 -2
- package/dist/TreeViewUtilities.d.ts.map +1 -1
- package/dist/TreeViewUtilities.js +3 -3
- package/dist/TreeViewUtilities.js.map +1 -1
- package/dist/UndoRedoHandler.d.ts +2 -2
- package/dist/UndoRedoHandler.d.ts.map +1 -1
- package/dist/UndoRedoHandler.js +5 -5
- package/dist/UndoRedoHandler.js.map +1 -1
- package/dist/UuidUtilities.d.ts +1 -1
- package/dist/UuidUtilities.d.ts.map +1 -1
- package/dist/UuidUtilities.js +3 -3
- package/dist/UuidUtilities.js.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.js +4 -4
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +2 -2
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +78 -78
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/IdRange.d.ts +1 -1
- package/dist/id-compressor/IdRange.d.ts.map +1 -1
- package/dist/id-compressor/IdRange.js.map +1 -1
- package/dist/id-compressor/NumericUuid.d.ts +1 -1
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
- package/dist/id-compressor/NumericUuid.js +6 -6
- package/dist/id-compressor/NumericUuid.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +2 -2
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +14 -14
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/dist/id-compressor/index.d.ts +4 -4
- package/dist/id-compressor/index.d.ts.map +1 -1
- package/dist/id-compressor/index.js +11 -11
- package/dist/id-compressor/index.js.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/dist/id-compressor/persisted-types/index.d.ts +1 -1
- package/dist/id-compressor/persisted-types/index.d.ts.map +1 -1
- package/dist/id-compressor/persisted-types/index.js.map +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -73
- package/dist/index.js.map +1 -1
- package/dist/migration-shim/migrationDeltaHandler.d.ts +1 -1
- package/dist/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
- package/dist/migration-shim/migrationDeltaHandler.js +5 -8
- package/dist/migration-shim/migrationDeltaHandler.js.map +1 -1
- package/dist/migration-shim/migrationShim.d.ts +1 -1
- package/dist/migration-shim/migrationShim.d.ts.map +1 -1
- package/dist/migration-shim/migrationShim.js +1 -1
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/dist/migration-shim/migrationShimFactory.d.ts +1 -1
- package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/migrationShimFactory.js.map +1 -1
- package/dist/migration-shim/sharedTreeDeltaHandler.d.ts +1 -1
- package/dist/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeDeltaHandler.js +2 -5
- package/dist/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
- package/dist/migration-shim/types.d.ts +1 -1
- package/dist/migration-shim/types.d.ts.map +1 -1
- package/dist/migration-shim/types.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/persisted-types/0.0.2.d.ts +1 -1
- package/dist/persisted-types/0.0.2.d.ts.map +1 -1
- package/dist/persisted-types/0.0.2.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +4 -4
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js +13 -13
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/dist/persisted-types/index.d.ts +2 -2
- package/dist/persisted-types/index.d.ts.map +1 -1
- package/dist/persisted-types/index.js +13 -13
- package/dist/persisted-types/index.js.map +1 -1
- package/dist/tree-alpha.d.ts +5 -8
- package/dist/tree-beta.d.ts +5 -1
- package/dist/tree-public.d.ts +5 -1
- package/dist/tree-untrimmed.d.ts +5 -8
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/ChangeCompression.d.ts +5 -5
- package/lib/ChangeCompression.d.ts.map +1 -1
- package/lib/ChangeCompression.js +3 -3
- package/lib/ChangeCompression.js.map +1 -1
- package/lib/ChangeTypes.d.ts +3 -3
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/ChangeTypes.js +3 -3
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +7 -7
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +6 -6
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +2 -2
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js.map +1 -1
- package/lib/EagerCheckout.d.ts +3 -3
- package/lib/EagerCheckout.d.ts.map +1 -1
- package/lib/EagerCheckout.js +1 -1
- package/lib/EagerCheckout.js.map +1 -1
- package/lib/EditLog.d.ts +4 -6
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +1 -1
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +6 -6
- package/lib/EditUtilities.d.ts.map +1 -1
- package/lib/EditUtilities.js +7 -7
- package/lib/EditUtilities.js.map +1 -1
- package/lib/Forest.d.ts +2 -2
- package/lib/Forest.d.ts.map +1 -1
- package/lib/Forest.js +2 -2
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +3 -3
- package/lib/HistoryEditFactory.d.ts.map +1 -1
- package/lib/HistoryEditFactory.js +7 -7
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/IdConversion.d.ts +3 -3
- package/lib/IdConversion.d.ts.map +1 -1
- package/lib/IdConversion.js +4 -4
- package/lib/IdConversion.js.map +1 -1
- package/lib/InitialTree.d.ts +1 -1
- package/lib/InitialTree.d.ts.map +1 -1
- package/lib/InitialTree.js +1 -1
- package/lib/InitialTree.js.map +1 -1
- package/lib/LazyCheckout.d.ts +5 -5
- package/lib/LazyCheckout.d.ts.map +1 -1
- package/lib/LazyCheckout.js +1 -1
- package/lib/LazyCheckout.js.map +1 -1
- package/lib/LogViewer.d.ts +7 -7
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +4 -4
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.d.ts +1 -1
- package/lib/MergeHealth.d.ts.map +1 -1
- package/lib/MergeHealth.js +5 -5
- package/lib/MergeHealth.js.map +1 -1
- package/lib/NodeIdUtilities.d.ts +3 -3
- package/lib/NodeIdUtilities.d.ts.map +1 -1
- package/lib/NodeIdUtilities.js +2 -2
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/PayloadUtilities.d.ts +1 -1
- package/lib/PayloadUtilities.d.ts.map +1 -1
- package/lib/PayloadUtilities.js.map +1 -1
- package/lib/ReconciliationPath.d.ts +3 -3
- package/lib/ReconciliationPath.d.ts.map +1 -1
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.js +1 -1
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +5 -5
- package/lib/RevisionView.d.ts.map +1 -1
- package/lib/RevisionView.js +3 -3
- package/lib/RevisionView.js.map +1 -1
- package/lib/SerializationUtilities.d.ts +4 -4
- package/lib/SerializationUtilities.d.ts.map +1 -1
- package/lib/SerializationUtilities.js +1 -1
- package/lib/SerializationUtilities.js.map +1 -1
- package/lib/SharedTree.d.ts +15 -18
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +28 -40
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +8 -8
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +12 -12
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/StringInterner.d.ts +1 -1
- package/lib/StringInterner.d.ts.map +1 -1
- package/lib/StringInterner.js +1 -1
- package/lib/StringInterner.js.map +1 -1
- package/lib/Summary.d.ts +4 -4
- package/lib/Summary.d.ts.map +1 -1
- package/lib/Summary.js +1 -1
- package/lib/Summary.js.map +1 -1
- package/lib/SummaryBackCompatibility.d.ts +3 -3
- package/lib/SummaryBackCompatibility.d.ts.map +1 -1
- package/lib/SummaryBackCompatibility.js +3 -3
- package/lib/SummaryBackCompatibility.js.map +1 -1
- package/lib/SummaryTestUtilities.d.ts +2 -2
- package/lib/SummaryTestUtilities.d.ts.map +1 -1
- package/lib/SummaryTestUtilities.js.map +1 -1
- package/lib/Transaction.d.ts +4 -4
- package/lib/Transaction.d.ts.map +1 -1
- package/lib/Transaction.js +5 -5
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.d.ts +7 -7
- package/lib/TransactionInternal.d.ts.map +1 -1
- package/lib/TransactionInternal.js +5 -5
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/TreeCompressor.d.ts +4 -4
- package/lib/TreeCompressor.d.ts.map +1 -1
- package/lib/TreeCompressor.js +2 -2
- package/lib/TreeCompressor.js.map +1 -1
- package/lib/TreeNodeHandle.d.ts +3 -3
- package/lib/TreeNodeHandle.d.ts.map +1 -1
- package/lib/TreeNodeHandle.js +1 -1
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.d.ts +3 -3
- package/lib/TreeView.d.ts.map +1 -1
- package/lib/TreeView.js +3 -3
- package/lib/TreeView.js.map +1 -1
- package/lib/TreeViewUtilities.d.ts +2 -2
- package/lib/TreeViewUtilities.d.ts.map +1 -1
- package/lib/TreeViewUtilities.js +1 -1
- package/lib/TreeViewUtilities.js.map +1 -1
- package/lib/UndoRedoHandler.d.ts +2 -2
- package/lib/UndoRedoHandler.d.ts.map +1 -1
- package/lib/UndoRedoHandler.js +2 -2
- package/lib/UndoRedoHandler.js.map +1 -1
- package/lib/UuidUtilities.d.ts +1 -1
- package/lib/UuidUtilities.d.ts.map +1 -1
- package/lib/UuidUtilities.js +1 -1
- package/lib/UuidUtilities.js.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +2 -2
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +6 -6
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/IdRange.d.ts +1 -1
- package/lib/id-compressor/IdRange.d.ts.map +1 -1
- package/lib/id-compressor/IdRange.js.map +1 -1
- package/lib/id-compressor/NumericUuid.d.ts +1 -1
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
- package/lib/id-compressor/NumericUuid.js +2 -2
- package/lib/id-compressor/NumericUuid.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +2 -2
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +2 -2
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/index.d.ts +4 -4
- package/lib/id-compressor/index.d.ts.map +1 -1
- package/lib/id-compressor/index.js +3 -3
- package/lib/id-compressor/index.js.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/lib/id-compressor/persisted-types/index.d.ts +1 -1
- package/lib/id-compressor/persisted-types/index.d.ts.map +1 -1
- package/lib/id-compressor/persisted-types/index.js.map +1 -1
- package/lib/index.d.ts +29 -29
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +22 -22
- package/lib/index.js.map +1 -1
- package/lib/migration-shim/migrationDeltaHandler.d.ts +1 -1
- package/lib/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
- package/lib/migration-shim/migrationDeltaHandler.js +5 -8
- package/lib/migration-shim/migrationDeltaHandler.js.map +1 -1
- package/lib/migration-shim/migrationShim.d.ts +1 -1
- package/lib/migration-shim/migrationShim.d.ts.map +1 -1
- package/lib/migration-shim/migrationShim.js +1 -1
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/lib/migration-shim/migrationShimFactory.d.ts +1 -1
- package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/migrationShimFactory.js.map +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.d.ts +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.js +2 -5
- package/lib/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
- package/lib/migration-shim/types.d.ts +1 -1
- package/lib/migration-shim/types.d.ts.map +1 -1
- package/lib/migration-shim/types.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +1 -1
- package/lib/persisted-types/0.0.2.d.ts.map +1 -1
- package/lib/persisted-types/0.0.2.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +4 -4
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js +2 -2
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/persisted-types/index.d.ts +2 -2
- package/lib/persisted-types/index.d.ts.map +1 -1
- package/lib/persisted-types/index.js +2 -2
- package/lib/persisted-types/index.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.perf.tests.js +2 -2
- package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.tests.js +2 -2
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
- package/lib/test/ChangeCompression.tests.js +9 -9
- package/lib/test/ChangeCompression.tests.js.map +1 -1
- package/lib/test/Checkout.tests.d.ts +1 -1
- package/lib/test/Checkout.tests.d.ts.map +1 -1
- package/lib/test/Checkout.tests.js +2 -2
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Common.tests.js +1 -1
- package/lib/test/Common.tests.js.map +1 -1
- package/lib/test/EagerCheckout.tests.js +4 -4
- package/lib/test/EagerCheckout.tests.js.map +1 -1
- package/lib/test/Edit.tests.js +2 -2
- package/lib/test/Edit.tests.js.map +1 -1
- package/lib/test/EditLog.perf.tests.js +4 -4
- package/lib/test/EditLog.perf.tests.js.map +1 -1
- package/lib/test/EditLog.tests.js +3 -3
- package/lib/test/EditLog.tests.js.map +1 -1
- package/lib/test/EditUtilities.tests.js +6 -6
- package/lib/test/EditUtilities.tests.js.map +1 -1
- package/lib/test/Forest.perf.tests.js +4 -4
- package/lib/test/Forest.perf.tests.js.map +1 -1
- package/lib/test/Forest.tests.js +2 -2
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/GenericTransaction.tests.js +3 -3
- package/lib/test/GenericTransaction.tests.js.map +1 -1
- package/lib/test/HistoryEditFactory.tests.js +4 -4
- package/lib/test/HistoryEditFactory.tests.js.map +1 -1
- package/lib/test/IdCompressor.perf.tests.js +4 -4
- package/lib/test/IdCompressor.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +7 -7
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/IdConversion.tests.js +3 -3
- package/lib/test/IdConversion.tests.js.map +1 -1
- package/lib/test/LazyCheckout.tests.js +4 -4
- package/lib/test/LazyCheckout.tests.js.map +1 -1
- package/lib/test/LogViewer.tests.js +12 -12
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +6 -6
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
- package/lib/test/NumericUuid.perf.tests.js +3 -3
- package/lib/test/NumericUuid.perf.tests.js.map +1 -1
- package/lib/test/NumericUuid.tests.js +4 -4
- package/lib/test/NumericUuid.tests.js.map +1 -1
- package/lib/test/RevisionValueCache.tests.js +2 -2
- package/lib/test/RevisionValueCache.tests.js.map +1 -1
- package/lib/test/RevisionView.tests.js +6 -6
- package/lib/test/RevisionView.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.js +3 -3
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
- package/lib/test/SharedTree.fuzz.tests.js +1 -1
- package/lib/test/SharedTree.fuzz.tests.js.map +1 -1
- package/lib/test/SharedTree.perf.tests.js +2 -2
- package/lib/test/SharedTree.perf.tests.js.map +1 -1
- package/lib/test/SharedTree.tests.js +7 -7
- package/lib/test/SharedTree.tests.js.map +1 -1
- package/lib/test/StringInterner.tests.js +1 -1
- package/lib/test/StringInterner.tests.js.map +1 -1
- package/lib/test/Summary.tests.d.ts +2 -2
- package/lib/test/Summary.tests.d.ts.map +1 -1
- package/lib/test/Summary.tests.js +14 -14
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/Transaction.tests.js +5 -5
- package/lib/test/Transaction.tests.js.map +1 -1
- package/lib/test/TransactionInternal.tests.js +7 -7
- package/lib/test/TransactionInternal.tests.js.map +1 -1
- package/lib/test/TreeCompression.tests.js +8 -8
- package/lib/test/TreeCompression.tests.js.map +1 -1
- package/lib/test/TreeView.tests.js +3 -3
- package/lib/test/TreeView.tests.js.map +1 -1
- package/lib/test/UndoRedoHandler.tests.js +2 -2
- package/lib/test/UndoRedoHandler.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts +1 -1
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js +4 -4
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +5 -5
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/fuzz/Types.d.ts +6 -6
- package/lib/test/fuzz/Types.d.ts.map +1 -1
- package/lib/test/fuzz/Types.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +6 -6
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +6 -6
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/lib/test/utilities/MockTransaction.d.ts +4 -4
- package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
- package/lib/test/utilities/MockTransaction.js +3 -3
- package/lib/test/utilities/MockTransaction.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +5 -5
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts +2 -2
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +22 -22
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +10 -10
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js +6 -6
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
- package/lib/test/utilities/SummarySizeTests.d.ts +1 -1
- package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -1
- package/lib/test/utilities/SummarySizeTests.js +5 -5
- package/lib/test/utilities/SummarySizeTests.js.map +1 -1
- package/lib/test/utilities/TestNode.d.ts +6 -6
- package/lib/test/utilities/TestNode.d.ts.map +1 -1
- package/lib/test/utilities/TestNode.js +5 -5
- package/lib/test/utilities/TestNode.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +12 -12
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +18 -19
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/lib/test/utilities/UndoRedoTests.d.ts +2 -2
- package/lib/test/utilities/UndoRedoTests.d.ts.map +1 -1
- package/lib/test/utilities/UndoRedoTests.js +7 -7
- package/lib/test/utilities/UndoRedoTests.js.map +1 -1
- package/package.json +57 -31
- package/src/ChangeCompression.ts +7 -7
- package/src/ChangeTypes.ts +5 -5
- package/src/Checkout.ts +13 -13
- package/src/Common.ts +2 -2
- package/src/EagerCheckout.ts +3 -3
- package/src/EditLog.ts +6 -7
- package/src/EditUtilities.ts +10 -10
- package/src/Forest.ts +4 -4
- package/src/HistoryEditFactory.ts +11 -11
- package/src/IdConversion.ts +4 -4
- package/src/InitialTree.ts +3 -3
- package/src/LazyCheckout.ts +5 -5
- package/src/LogViewer.ts +8 -8
- package/src/MergeHealth.ts +6 -6
- package/src/NodeIdUtilities.ts +4 -4
- package/src/PayloadUtilities.ts +1 -1
- package/src/ReconciliationPath.ts +3 -3
- package/src/RevisionValueCache.ts +1 -1
- package/src/RevisionView.ts +7 -7
- package/src/SerializationUtilities.ts +5 -5
- package/src/SharedTree.ts +34 -54
- package/src/SharedTreeEncoder.ts +15 -15
- package/src/StringInterner.ts +2 -2
- package/src/Summary.ts +5 -5
- package/src/SummaryBackCompatibility.ts +10 -5
- package/src/SummaryTestUtilities.ts +3 -3
- package/src/Transaction.ts +8 -8
- package/src/TransactionInternal.ts +8 -8
- package/src/TreeCompressor.ts +6 -6
- package/src/TreeNodeHandle.ts +4 -4
- package/src/TreeView.ts +4 -4
- package/src/TreeViewUtilities.ts +3 -3
- package/src/UndoRedoHandler.ts +4 -4
- package/src/UuidUtilities.ts +2 -2
- package/src/id-compressor/AppendOnlySortedMap.ts +1 -1
- package/src/id-compressor/IdCompressor.ts +8 -8
- package/src/id-compressor/IdRange.ts +1 -1
- package/src/id-compressor/NumericUuid.ts +3 -3
- package/src/id-compressor/SessionIdNormalizer.ts +4 -4
- package/src/id-compressor/index.ts +4 -4
- package/src/id-compressor/persisted-types/0.0.1.ts +1 -1
- package/src/id-compressor/persisted-types/index.ts +1 -1
- package/src/index.ts +29 -29
- package/src/migration-shim/migrationDeltaHandler.ts +9 -10
- package/src/migration-shim/migrationShim.ts +7 -5
- package/src/migration-shim/migrationShimFactory.ts +4 -1
- package/src/migration-shim/sharedTreeDeltaHandler.ts +7 -6
- package/src/migration-shim/types.ts +1 -1
- package/src/persisted-types/0.0.2.ts +1 -1
- package/src/persisted-types/0.1.1.ts +4 -4
- package/src/persisted-types/index.ts +2 -2
- package/tsconfig.esnext.json +1 -2
- package/tsconfig.json +3 -0
- package/lib/test/Attach.tests.d.ts +0 -6
- package/lib/test/Attach.tests.d.ts.map +0 -1
- package/lib/test/Attach.tests.js +0 -52
- package/lib/test/Attach.tests.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdRange.d.ts","sourceRoot":"","sources":["../../src/id-compressor/IdRange.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"IdRange.d.ts","sourceRoot":"","sources":["../../src/id-compressor/IdRange.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAElF,wBAAgB,MAAM,CACrB,KAAK,EAAE,eAAe,GACpB;IAAE,KAAK,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,CAAC,EAAE,eAAe,CAAC,SAAS,CAAA;CAAE,GAAG,SAAS,CAsBpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdRange.js","sourceRoot":"","sources":["../../src/id-compressor/IdRange.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAGpD,SAAgB,MAAM,CACrB,KAAsB;IAEtB,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS,EAAE;QACtB,OAAO,SAAS,CAAC;KACjB;IAED,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACtB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpB,MAAM,SAAS,GAAG,GAA4C,CAAC;IAC/D,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS,EAAE;QACtC,KAAK,KAAL,KAAK,GAAK,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;QACpC,IAAI,KAAJ,IAAI,GAAK,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;KAChE;IAED,IAAA,mBAAM,EAAC,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEzF,OAAO;QACN,KAAK;QACL,IAAI;QACJ,SAAS,EAAE,SAAS,CAAC,SAAS;KAC9B,CAAC;AACH,CAAC;AAxBD,wBAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport type { IdCreationRange, UnackedLocalId } from './persisted-types';\n\nexport function getIds(\n\trange: IdCreationRange\n): { first: UnackedLocalId; last: UnackedLocalId; overrides?: IdCreationRange.Overrides } | undefined {\n\tconst { ids } = range;\n\tif (ids === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet first = ids.first;\n\tlet last = ids.last;\n\n\tconst overrides = ids as Partial<IdCreationRange.HasOverrides>;\n\tif (overrides.overrides !== undefined) {\n\t\tfirst ??= overrides.overrides[0][0];\n\t\tlast ??= overrides.overrides[overrides.overrides.length - 1][0];\n\t}\n\n\tassert(first !== undefined && last !== undefined, 0x656 /* malformed IdCreationRange */);\n\n\treturn {\n\t\tfirst,\n\t\tlast,\n\t\toverrides: overrides.overrides,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IdRange.js","sourceRoot":"","sources":["../../src/id-compressor/IdRange.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAGpD,SAAgB,MAAM,CACrB,KAAsB;IAEtB,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS,EAAE;QACtB,OAAO,SAAS,CAAC;KACjB;IAED,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACtB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpB,MAAM,SAAS,GAAG,GAA4C,CAAC;IAC/D,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS,EAAE;QACtC,KAAK,KAAL,KAAK,GAAK,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;QACpC,IAAI,KAAJ,IAAI,GAAK,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;KAChE;IAED,IAAA,mBAAM,EAAC,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEzF,OAAO;QACN,KAAK;QACL,IAAI;QACJ,SAAS,EAAE,SAAS,CAAC,SAAS;KAC9B,CAAC;AACH,CAAC;AAxBD,wBAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport type { IdCreationRange, UnackedLocalId } from './persisted-types/index.js';\n\nexport function getIds(\n\trange: IdCreationRange\n): { first: UnackedLocalId; last: UnackedLocalId; overrides?: IdCreationRange.Overrides } | undefined {\n\tconst { ids } = range;\n\tif (ids === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet first = ids.first;\n\tlet last = ids.last;\n\n\tconst overrides = ids as Partial<IdCreationRange.HasOverrides>;\n\tif (overrides.overrides !== undefined) {\n\t\tfirst ??= overrides.overrides[0][0];\n\t\tlast ??= overrides.overrides[overrides.overrides.length - 1][0];\n\t}\n\n\tassert(first !== undefined && last !== undefined, 0x656 /* malformed IdCreationRange */);\n\n\treturn {\n\t\tfirst,\n\t\tlast,\n\t\toverrides: overrides.overrides,\n\t};\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { SessionId, StableId } from '../Identifiers';
|
|
5
|
+
import { SessionId, StableId } from '../Identifiers.js';
|
|
6
6
|
/**
|
|
7
7
|
* A UUID (128 bit identifier) optimized for use as a 128 bit unsigned integer with fast addition and toString operations.
|
|
8
8
|
* The string entry is the upper 76 bits of the uuid and the integer entry holds the lower 52 bits:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.d.ts","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"NumericUuid.d.ts","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIxD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IACrD,QAAQ,CAAC,WAAW,EAAE,sCAAsC,CAAC;CAC7D,CAAC;AAQF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgDrG;AAaD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,SAAI,GAAG,QAAQ,CAQ/E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAKvE;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAEzE;AAQD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CA+C5E;AA2ID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAgB3D"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ensureSessionUuid = exports.incrementUuid = exports.numericUuidEquals = exports.createSessionId = exports.numericUuidFromStableId = exports.stableIdFromNumericUuid = exports.getPositiveDelta = void 0;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const UuidUtilities_js_1 = require("../UuidUtilities.js");
|
|
9
|
+
const Common_js_1 = require("../Common.js");
|
|
10
10
|
const bitsInNumericUuidInteger = 52; // Not tunable. Do not change.
|
|
11
11
|
const nibblesInNumericUuidInteger = bitsInNumericUuidInteger / 4;
|
|
12
12
|
const stringEntryLength = 22;
|
|
@@ -101,7 +101,7 @@ exports.numericUuidFromStableId = numericUuidFromStableId;
|
|
|
101
101
|
* This method (rather than standard uuid generation methods) should be used to generate session IDs.
|
|
102
102
|
*/
|
|
103
103
|
function createSessionId() {
|
|
104
|
-
return ensureSessionUuid((0,
|
|
104
|
+
return ensureSessionUuid((0, UuidUtilities_js_1.generateStableId)());
|
|
105
105
|
}
|
|
106
106
|
exports.createSessionId = createSessionId;
|
|
107
107
|
/**
|
|
@@ -143,10 +143,10 @@ function incrementUuid(uuid, amount) {
|
|
|
143
143
|
// The variant chunk itself also overflowed. We'll need to carry the overflow further, into the upper string region of the UUID.
|
|
144
144
|
const upperString = ChunkMath.Upper.parse(stringEntry);
|
|
145
145
|
const upperNumber = Number.parseInt(upperString, 16);
|
|
146
|
-
(0,
|
|
146
|
+
(0, Common_js_1.assertWithMessage)(upperNumber <= maxUpperNumber);
|
|
147
147
|
const newUpperNumber = upperNumber + 1;
|
|
148
148
|
if (newUpperNumber > maxUpperNumber) {
|
|
149
|
-
(0,
|
|
149
|
+
(0, Common_js_1.fail)('Exceeded maximum numeric UUID');
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
152
|
// The variant chunk overflowed but the upper string region did not. Splice in the incremented string region.
|
|
@@ -283,7 +283,7 @@ var ChunkMath;
|
|
|
283
283
|
// 2. The numerically important bits (i.e. not the variant identifier bits vv which are constant) are extracted into a single number
|
|
284
284
|
const variantChunk = Variant.parse(stringEntry);
|
|
285
285
|
const variantNumber = getNumericValue(variantChunk);
|
|
286
|
-
(0,
|
|
286
|
+
(0, Common_js_1.assertWithMessage)(variantNumber <= maxVariantNumber);
|
|
287
287
|
// 3. Add one to the variant number to produce our new variant number.
|
|
288
288
|
const newVariantNumber = variantNumber + 1;
|
|
289
289
|
// 4. The variant identifier bits are added back into the number, which is then turned back into a hex string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.js","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,oDAAoD;AACpD,sCAAoD;AAmBpD,MAAM,wBAAwB,GAAG,EAAE,CAAC,CAAC,8BAA8B;AACnE,MAAM,2BAA2B,GAAG,wBAAwB,GAAG,CAAC,CAAC;AACjE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,qBAAqB,GAAG,CAAC,IAAI,wBAAwB,GAAG,CAAC,CAAC;AAChE,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAE9B;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,CAAc,EAAE,CAAc,EAAE,QAAgB;IAChF,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC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C,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;AACzE,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,SAAS,gBAAgB,CAAC,KAAa;IACtC,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,IAAc;IAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAClC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC;QAChE,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,YAAY,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,WAAW,IAAI,CAAC,EAAE;YACzG,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE;gBAClC,WAAW,EAAE,CAAC;aACd;SACD;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,gCAAgC;QAC7G,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACrF,OAAO,OAAoB,CAAC;KAC5B;IAED,OAAO,IAAiB,CAAC;AAC1B,CAAC;AAhBD,8CAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { SessionId, StableId } from '../Identifiers';\nimport { generateStableId } from '../UuidUtilities';\nimport { assertWithMessage, fail } from '../Common';\n\n/**\n * A UUID (128 bit identifier) optimized for use as a 128 bit unsigned integer with fast addition and toString operations.\n * The string entry is the upper 76 bits of the uuid and the integer entry holds the lower 52 bits:\n *\n * ```\n * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n * SSSSSSSS-SSSS-SSSS-SSS - array[0]: string\n * N NNNNNNNNNNNN - array[1]: integer\n * ```\n *\n * The integer keeps the common case cost of incrementing and computing deltas very low.\n * The string optimizes toString by caching the the majority of the resulting string.\n */\nexport type NumericUuid = readonly [string, number] & {\n\treadonly NumericUuid: '9132ea20-a811-4756-85f8-aa6da5ca90f8';\n};\n\nconst bitsInNumericUuidInteger = 52; // Not tunable. Do not change.\nconst nibblesInNumericUuidInteger = bitsInNumericUuidInteger / 4;\nconst stringEntryLength = 22;\nconst maxNumericUuidInteger = 2 ** bitsInNumericUuidInteger - 1;\nconst fiftyThirdBit = 2 ** 52;\n\n/**\n * Calculates the numeric delta between a and b (i.e. a - b).\n * @param a - an uuid\n * @param b - an other uuid\n * @param maxDelta - the maximum integer delta (inclusive) to tolerate.\n * @returns undefined if the delta is negative or greater than `maxDelta`\n */\nexport function getPositiveDelta(a: NumericUuid, b: NumericUuid, maxDelta: number): number | undefined {\n\tconst [stringEntryA, lowNumberA] = a;\n\tconst [stringEntryB, lowNumberB] = b;\n\n\tif (stringEntryA === stringEntryB) {\n\t\tconst difference = lowNumberA - lowNumberB;\n\t\tif (difference >= 0 && difference <= maxDelta) {\n\t\t\treturn difference;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst highNumberA = Number.parseInt(ChunkMath.Upper.parse(stringEntryA), 16);\n\tconst highNumberB = Number.parseInt(ChunkMath.Upper.parse(stringEntryB), 16);\n\n\tlet subtractHigh = highNumberA - highNumberB;\n\tif (Math.abs(subtractHigh) > 1) {\n\t\t// If the high bits differ by more than 1, then there is no chance that any lower bits could compensate\n\t\treturn undefined;\n\t}\n\n\tlet midNumberA = ChunkMath.getNumericValue(ChunkMath.Variant.parse(stringEntryA));\n\tconst midNumberB = ChunkMath.getNumericValue(ChunkMath.Variant.parse(stringEntryB));\n\n\tlet subtractLow = lowNumberA - lowNumberB;\n\tif (subtractLow < 0) {\n\t\tmidNumberA -= 1;\n\t\tsubtractLow += fiftyThirdBit;\n\t}\n\n\tlet subtractMid = midNumberA - midNumberB;\n\tif (subtractMid < 0) {\n\t\tsubtractHigh -= 1;\n\t\tsubtractMid += ChunkMath.twentyThirdBit;\n\t}\n\n\tif (subtractHigh !== 0) {\n\t\t// a < b, no positive delta, or\n\t\t// a > b by much more than MAX_SAFE_INTEGER\n\t\treturn undefined;\n\t}\n\n\tif (subtractMid > 1) {\n\t\treturn undefined;\n\t} else {\n\t\tconst trueDelta = fiftyThirdBit * subtractMid + subtractLow;\n\t\treturn trueDelta > maxDelta ? undefined : trueDelta;\n\t}\n}\n\n// Pre-allocated array of strings of zeros.\n// Used to pad hex strings up to 52 bits\nconst zeros: string[] = [];\nfor (let i = 0; i < nibblesInNumericUuidInteger; i++) {\n\tzeros.push('0'.repeat(i));\n}\n\nfunction padToLengthWithZeros(str: string, count: number): string {\n\treturn str.length === count ? str : zeros[count - str.length] + str;\n}\n\n/**\n * @param offset - an optional offset to increment the returned StableId\n * @returns the string representation of a `NumericUuid`.\n */\nexport function stableIdFromNumericUuid(uuid: NumericUuid, offset = 0): StableId {\n\tconst lowerAdd = uuid[1] + offset;\n\t// Common fast-path\n\tif (lowerAdd <= maxNumericUuidInteger) {\n\t\tconst lowerString = padToLengthWithZeros(lowerAdd.toString(16), nibblesInNumericUuidInteger);\n\t\treturn `${uuid[0] + lowerString.slice(0, 1)}-${lowerString.slice(1)}` as StableId;\n\t}\n\treturn stableIdFromNumericUuid(incrementUuid(uuid, offset));\n}\n\n/**\n * @param stableId - a minimal uuid string\n * @returns a numeric representation of `stableId`.\n */\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuid: (string | number)[] = new Array(2);\n\tuuid[0] = stableId.slice(0, stringEntryLength);\n\tuuid[1] = Number.parseInt(ChunkMath.Lower.parse(stableId), 16);\n\treturn uuid as readonly (number | string)[] as NumericUuid;\n}\n\n/**\n * Creates a session base ID.\n * This method (rather than standard uuid generation methods) should be used to generate session IDs.\n */\nexport function createSessionId(): SessionId {\n\treturn ensureSessionUuid(generateStableId());\n}\n\n/**\n * Compares numeric uuids for equality.\n */\nexport function numericUuidEquals(a: NumericUuid, b: NumericUuid): boolean {\n\treturn a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * The maximum value that can be contained in the upper string region of a numeric UUID (i.e. the string region excluding the version\n * nibble and the variant chunk)\n */\nconst maxUpperNumber = 2 ** 48 - 1;\n\n/**\n * Increments the uuid. `amount` must be a positive integer.\n * @returns the result of incrementing the uuid by `amount`.\n */\nexport function incrementUuid(uuid: NumericUuid, amount: number): NumericUuid {\n\t/*\n\t * UUIDs incremented beyond the max UUID \"ffffffff-ffff-4fff-bfff-ffffffffffff\" will cause a failure.\n\t * Also, some reserved bits of the v4 UUID must be treated as immutable (e.g. the version and\n\t * variant bits) and thus must not be incremented.\n\t */\n\tlet newUuid: [string, number];\n\tconst result = uuid[1] + amount;\n\tif (result <= maxNumericUuidInteger) {\n\t\t// The new number still fits within the number region of a numeric UUID.\n\t\t// Incrementing is usually done with small amounts, so this is the dominantly common case.\n\t\tnewUuid = [uuid[0], result];\n\t} else {\n\t\t// The numeric UUID's number region has overflowed. We will need to carry the overflow into the variant chunk (see `VariantChunk`).\n\t\t/** The amount left over after filling up the rest of the uuid's number region with the increment amount */\n\t\tconst remainder = amount - (maxNumericUuidInteger - uuid[1]) - 1;\n\t\tconst stringEntry = uuid[0];\n\t\tconst [newVariantChunkString, carried] = ChunkMath.increment(stringEntry);\n\n\t\tif (carried) {\n\t\t\t// The variant chunk itself also overflowed. We'll need to carry the overflow further, into the upper string region of the UUID.\n\t\t\tconst upperString = ChunkMath.Upper.parse(stringEntry);\n\t\t\tconst upperNumber = Number.parseInt(upperString, 16);\n\t\t\tassertWithMessage(upperNumber <= maxUpperNumber);\n\t\t\tconst newUpperNumber = upperNumber + 1;\n\t\t\tif (newUpperNumber > maxUpperNumber) {\n\t\t\t\tfail('Exceeded maximum numeric UUID');\n\t\t\t} else {\n\t\t\t\t// The variant chunk overflowed but the upper string region did not. Splice in the incremented string region.\n\t\t\t\tconst newUpperChunk = padToLengthWithZeros(newUpperNumber.toString(16), 12);\n\t\t\t\tnewUuid = [\n\t\t\t\t\t`${ChunkMath.Upper.hyphenate(newUpperChunk)}-4${ChunkMath.Variant.hyphenate(\n\t\t\t\t\t\tnewVariantChunkString\n\t\t\t\t\t)}`,\n\t\t\t\t\tremainder,\n\t\t\t\t];\n\t\t\t}\n\t\t} else {\n\t\t\t// The variant chunk did not overflow, so just splice it back in.\n\t\t\tnewUuid = [\n\t\t\t\t`${ChunkMath.Upper.slice(stringEntry)}-4${ChunkMath.Variant.hyphenate(newVariantChunkString)}`,\n\t\t\t\tremainder,\n\t\t\t];\n\t\t}\n\t}\n\n\treturn newUuid as readonly [string, number] as NumericUuid;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace ChunkMath {\n\t/*\n\t * Recall the UUID diagram from the top of this file which describes the layout of a Numeric UUID. To implement addition, we define\n\t * another region called the \"variant chunk\" which overlaps with the \"string\" region. Note that it is just beneath the required v4 uuid\n\t * version identifier (the 13th nibble 'V' which is always '4' in a v4 UUID) and just above the \"number\" region of the layout. It\n\t * contains inside of it the v4 UUID variant identifier bits as well (see https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1).\n\t *\n\t * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n\t * SSSSSSSS SSSS SSSS SSS - array[0]: string\n\t * N NNNNNNNNNNNN - array[1]: integer\n\t * VVV-VVV - the variant chunk\n\t *\n\t * By defining the variant chunk in this way it is simple to splice in the v4 UUID version identifier ('V') just above it and any\n\t * \"bit math\" required due to the fact that the variant identifier bits ('v') do not fill up an entire nibble is handled within it.\n\t * The variant chunk is made up of 6 nibbles. Note the \"vv\" which denotes the two bits used for the v4 UUID variant identifier:\n\t *\n\t * AAAA BBBB CCCC vvDD EEEE FFFF\n\t *\n\t * Since we'll be needing to \"skip\" the variant bits (\"vv\") when doing addition, we define a a few masks which will be used below to\n\t * separate the variant chunk into pieces before recombining it:\n\t */\n\n\t// AAAA BBBB CCCC vvDD EEEE FFFF\n\tconst upperVariantChunkMask = 0xfff000; // XXXX XXXX XXXX\n\tconst variantBitMask = 0x800; // XX\n\tconst middleVariantChunkMask = 0x300; // XX\n\tconst lowerVariantChunkMask = 0xff; // XXXX XXXX\n\n\t/** The maximum numeric value that can be represented by the numerically relevant bits in the variant chunk */\n\tconst maxVariantNumber = 2 ** 22 - 1;\n\n\texport const twentyThirdBit = 2 ** 22;\n\n\t/**\n\t * The upper chunk, denoted by 'U's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Upper {\n\t\texport function parse(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(0, 8) + stringEntry.slice(9, 13);\n\t\t}\n\n\t\texport function hyphenate(upperChunk: string): string {\n\t\t\treturn `${upperChunk.slice(0, 8)}-${upperChunk.slice(8)}`;\n\t\t}\n\n\t\texport function slice(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(0, 13);\n\t\t}\n\t}\n\n\t/**\n\t * The variant chunk, denoted by 'V's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Variant {\n\t\texport function parse(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(15, 18) + stringEntry.slice(19, 22);\n\t\t}\n\n\t\texport function hyphenate(variantChunk: string): string {\n\t\t\treturn `${variantChunk.slice(0, 3)}-${variantChunk.slice(3)}`;\n\t\t}\n\t}\n\n\t/**\n\t * The lower chunk, denoted by 'L's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Lower {\n\t\texport function parse(stableId: StableId): string {\n\t\t\treturn stableId.slice(stringEntryLength, stringEntryLength + 1) + stableId.slice(stringEntryLength + 2);\n\t\t}\n\n\t\texport function hyphenate(lowerChunk: string): string {\n\t\t\treturn `${lowerChunk.slice(0, 1)}-${lowerChunk.slice(1)}`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the number representation of the given bits corresponding to the variant chunk. The value is derived by\n\t * parsing all bits except for reserved bits (i.e. the variant bits).\n\t * @param variantChunk - the variantChunk\n\t */\n\texport function getNumericValue(variantChunk: string): number {\n\t\tconst variantChunkBits = Number.parseInt(variantChunk, 16);\n\t\tconst upperVariantBits = (variantChunkBits & upperVariantChunkMask) >> 2;\n\t\tconst middleVariantBits = variantChunkBits & middleVariantChunkMask;\n\t\tconst lowerVariantBits = variantChunkBits & lowerVariantChunkMask;\n\t\treturn upperVariantBits + middleVariantBits + lowerVariantBits;\n\t}\n\n\t/**\n\t * Given the string portion of a numeric uuid, add one to it.\n\t * @returns the resulting hex string and whether or not the new value overflowed, i.e. it exceeds `maxVariantNumber`. In this case,\n\t * the resulting hex string will wrap around to its minimum value '000b00'\n\t */\n\texport function increment(stringEntry: string): [newVariantChunk: string, overflowed: boolean] {\n\t\t// To implement addition, the variant identifier bits are extracted from the variant chunk, the chunk is interpreted as a number,\n\t\t// that number is incremented by 1, and then the variant identifier bits are returned as we convert the number back into a hex\n\t\t// string.\n\n\t\t// This diagram may be helpful for seeing how the nibbles line up before and after the variant identifier bits are extracted. The\n\t\t// letters used for each nibble (\"AAAA\", \"BBBB\") etc. are arbitrary and are simply there to differentiate the nibbles as they shift.\n\t\t// --------------------------------\n\t\t// 1. AAAA BBBB CCCC vvDD EEEE FFFF\n\t\t// 2. AA AABB BBCC CCDD EEEE FFFF\n\t\t// 3. AA AABB BBCC CCDD EEEE FFFF\n\t\t// + 1\n\t\t// = GG GGHH HHII IIJJ JJKK KKLL\n\t\t// 4. GGGG HHHH IIII vvJJ JJKK KKLL\n\n\t\t// 1. The variant chunk is given as a 6 character (6 nibble) hex string, where the fourth nibble contains the variant bits\n\t\t// 2. The numerically important bits (i.e. not the variant identifier bits vv which are constant) are extracted into a single number\n\t\tconst variantChunk = Variant.parse(stringEntry);\n\t\tconst variantNumber = getNumericValue(variantChunk);\n\t\tassertWithMessage(variantNumber <= maxVariantNumber);\n\t\t// 3. Add one to the variant number to produce our new variant number.\n\t\tconst newVariantNumber = variantNumber + 1;\n\t\t// 4. The variant identifier bits are added back into the number, which is then turned back into a hex string\n\t\tconst newUpperVariantBits = (newVariantNumber & (upperVariantChunkMask >> 2)) << 2;\n\t\tconst newMiddleVariantBits = (newVariantNumber & middleVariantChunkMask) | variantBitMask; // Add the variant bits back in\n\t\tconst newLowerVariantBits = newVariantNumber & lowerVariantChunkMask;\n\t\tconst newVariantChunkBits = newUpperVariantBits + newMiddleVariantBits + newLowerVariantBits;\n\t\tconst newVariantChunk = padToLengthWithZeros(newVariantChunkBits.toString(16), variantChunk.length);\n\t\treturn [newVariantChunk, newVariantNumber > maxVariantNumber];\n\t}\n}\n\nconst maxUpperUuid = 'ffffffff-ffff-4fff-bf';\nconst maxNibbleCount = [...maxUpperUuid].filter((n) => n === 'f').length;\nconst newNibbles = ['7', 'b', 'd', 'e'];\nfunction isMaxUpperNibble(index: number): boolean {\n\treturn maxUpperUuid.charAt(index) === 'f';\n}\n\n/**\n * Any session uuid with all of its highish bits set is in danger of overflowing after fewer than 2^53 increments.\n * By zeroing one of those bits at random, potential overflow is prevented.\n */\nexport function ensureSessionUuid(uuid: StableId): SessionId {\n\tif (uuid.startsWith(maxUpperUuid)) {\n\t\tconst targetNibble = Math.floor(Math.random() * maxNibbleCount);\n\t\tlet actualIndex = 0;\n\t\tfor (let nibbleIndex = 0; nibbleIndex < targetNibble && !isMaxUpperNibble(actualIndex); actualIndex += 1) {\n\t\t\tif (isMaxUpperNibble(actualIndex)) {\n\t\t\t\tnibbleIndex++;\n\t\t\t}\n\t\t}\n\n\t\tconst newNibble = newNibbles[Math.floor(Math.random() * newNibbles.length)]; // Randomly choose a bit to zero\n\t\tconst newUuid = uuid.slice(0, actualIndex) + newNibble + uuid.slice(actualIndex + 1);\n\t\treturn newUuid as SessionId;\n\t}\n\n\treturn uuid as SessionId;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NumericUuid.js","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,0DAAuD;AACvD,4CAAuD;AAmBvD,MAAM,wBAAwB,GAAG,EAAE,CAAC,CAAC,8BAA8B;AACnE,MAAM,2BAA2B,GAAG,wBAAwB,GAAG,CAAC,CAAC;AACjE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,qBAAqB,GAAG,CAAC,IAAI,wBAAwB,GAAG,CAAC,CAAC;AAChE,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAE9B;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,CAAc,EAAE,CAAc,EAAE,QAAgB;IAChF,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAErC,IAAI,YAAY,KAAK,YAAY,EAAE;QAClC,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;QAC3C,IAAI,UAAU,IAAI,CAAC,IAAI,UAAU,IAAI,QAAQ,EAAE;YAC9C,OAAO,UAAU,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;KACjB;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7E,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAA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C,CAAC;QAChE,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,YAAY,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,WAAW,IAAI,CAAC,EAAE;YACzG,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE;gBAClC,WAAW,EAAE,CAAC;aACd;SACD;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,gCAAgC;QAC7G,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACrF,OAAO,OAAoB,CAAC;KAC5B;IAED,OAAO,IAAiB,CAAC;AAC1B,CAAC;AAhBD,8CAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { SessionId, StableId } from '../Identifiers.js';\nimport { generateStableId } from '../UuidUtilities.js';\nimport { assertWithMessage, fail } from '../Common.js';\n\n/**\n * A UUID (128 bit identifier) optimized for use as a 128 bit unsigned integer with fast addition and toString operations.\n * The string entry is the upper 76 bits of the uuid and the integer entry holds the lower 52 bits:\n *\n * ```\n * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n * SSSSSSSS-SSSS-SSSS-SSS - array[0]: string\n * N NNNNNNNNNNNN - array[1]: integer\n * ```\n *\n * The integer keeps the common case cost of incrementing and computing deltas very low.\n * The string optimizes toString by caching the the majority of the resulting string.\n */\nexport type NumericUuid = readonly [string, number] & {\n\treadonly NumericUuid: '9132ea20-a811-4756-85f8-aa6da5ca90f8';\n};\n\nconst bitsInNumericUuidInteger = 52; // Not tunable. Do not change.\nconst nibblesInNumericUuidInteger = bitsInNumericUuidInteger / 4;\nconst stringEntryLength = 22;\nconst maxNumericUuidInteger = 2 ** bitsInNumericUuidInteger - 1;\nconst fiftyThirdBit = 2 ** 52;\n\n/**\n * Calculates the numeric delta between a and b (i.e. a - b).\n * @param a - an uuid\n * @param b - an other uuid\n * @param maxDelta - the maximum integer delta (inclusive) to tolerate.\n * @returns undefined if the delta is negative or greater than `maxDelta`\n */\nexport function getPositiveDelta(a: NumericUuid, b: NumericUuid, maxDelta: number): number | undefined {\n\tconst [stringEntryA, lowNumberA] = a;\n\tconst [stringEntryB, lowNumberB] = b;\n\n\tif (stringEntryA === stringEntryB) {\n\t\tconst difference = lowNumberA - lowNumberB;\n\t\tif (difference >= 0 && difference <= maxDelta) {\n\t\t\treturn difference;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst highNumberA = Number.parseInt(ChunkMath.Upper.parse(stringEntryA), 16);\n\tconst highNumberB = Number.parseInt(ChunkMath.Upper.parse(stringEntryB), 16);\n\n\tlet subtractHigh = highNumberA - highNumberB;\n\tif (Math.abs(subtractHigh) > 1) {\n\t\t// If the high bits differ by more than 1, then there is no chance that any lower bits could compensate\n\t\treturn undefined;\n\t}\n\n\tlet midNumberA = ChunkMath.getNumericValue(ChunkMath.Variant.parse(stringEntryA));\n\tconst midNumberB = ChunkMath.getNumericValue(ChunkMath.Variant.parse(stringEntryB));\n\n\tlet subtractLow = lowNumberA - lowNumberB;\n\tif (subtractLow < 0) {\n\t\tmidNumberA -= 1;\n\t\tsubtractLow += fiftyThirdBit;\n\t}\n\n\tlet subtractMid = midNumberA - midNumberB;\n\tif (subtractMid < 0) {\n\t\tsubtractHigh -= 1;\n\t\tsubtractMid += ChunkMath.twentyThirdBit;\n\t}\n\n\tif (subtractHigh !== 0) {\n\t\t// a < b, no positive delta, or\n\t\t// a > b by much more than MAX_SAFE_INTEGER\n\t\treturn undefined;\n\t}\n\n\tif (subtractMid > 1) {\n\t\treturn undefined;\n\t} else {\n\t\tconst trueDelta = fiftyThirdBit * subtractMid + subtractLow;\n\t\treturn trueDelta > maxDelta ? undefined : trueDelta;\n\t}\n}\n\n// Pre-allocated array of strings of zeros.\n// Used to pad hex strings up to 52 bits\nconst zeros: string[] = [];\nfor (let i = 0; i < nibblesInNumericUuidInteger; i++) {\n\tzeros.push('0'.repeat(i));\n}\n\nfunction padToLengthWithZeros(str: string, count: number): string {\n\treturn str.length === count ? str : zeros[count - str.length] + str;\n}\n\n/**\n * @param offset - an optional offset to increment the returned StableId\n * @returns the string representation of a `NumericUuid`.\n */\nexport function stableIdFromNumericUuid(uuid: NumericUuid, offset = 0): StableId {\n\tconst lowerAdd = uuid[1] + offset;\n\t// Common fast-path\n\tif (lowerAdd <= maxNumericUuidInteger) {\n\t\tconst lowerString = padToLengthWithZeros(lowerAdd.toString(16), nibblesInNumericUuidInteger);\n\t\treturn `${uuid[0] + lowerString.slice(0, 1)}-${lowerString.slice(1)}` as StableId;\n\t}\n\treturn stableIdFromNumericUuid(incrementUuid(uuid, offset));\n}\n\n/**\n * @param stableId - a minimal uuid string\n * @returns a numeric representation of `stableId`.\n */\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuid: (string | number)[] = new Array(2);\n\tuuid[0] = stableId.slice(0, stringEntryLength);\n\tuuid[1] = Number.parseInt(ChunkMath.Lower.parse(stableId), 16);\n\treturn uuid as readonly (number | string)[] as NumericUuid;\n}\n\n/**\n * Creates a session base ID.\n * This method (rather than standard uuid generation methods) should be used to generate session IDs.\n */\nexport function createSessionId(): SessionId {\n\treturn ensureSessionUuid(generateStableId());\n}\n\n/**\n * Compares numeric uuids for equality.\n */\nexport function numericUuidEquals(a: NumericUuid, b: NumericUuid): boolean {\n\treturn a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * The maximum value that can be contained in the upper string region of a numeric UUID (i.e. the string region excluding the version\n * nibble and the variant chunk)\n */\nconst maxUpperNumber = 2 ** 48 - 1;\n\n/**\n * Increments the uuid. `amount` must be a positive integer.\n * @returns the result of incrementing the uuid by `amount`.\n */\nexport function incrementUuid(uuid: NumericUuid, amount: number): NumericUuid {\n\t/*\n\t * UUIDs incremented beyond the max UUID \"ffffffff-ffff-4fff-bfff-ffffffffffff\" will cause a failure.\n\t * Also, some reserved bits of the v4 UUID must be treated as immutable (e.g. the version and\n\t * variant bits) and thus must not be incremented.\n\t */\n\tlet newUuid: [string, number];\n\tconst result = uuid[1] + amount;\n\tif (result <= maxNumericUuidInteger) {\n\t\t// The new number still fits within the number region of a numeric UUID.\n\t\t// Incrementing is usually done with small amounts, so this is the dominantly common case.\n\t\tnewUuid = [uuid[0], result];\n\t} else {\n\t\t// The numeric UUID's number region has overflowed. We will need to carry the overflow into the variant chunk (see `VariantChunk`).\n\t\t/** The amount left over after filling up the rest of the uuid's number region with the increment amount */\n\t\tconst remainder = amount - (maxNumericUuidInteger - uuid[1]) - 1;\n\t\tconst stringEntry = uuid[0];\n\t\tconst [newVariantChunkString, carried] = ChunkMath.increment(stringEntry);\n\n\t\tif (carried) {\n\t\t\t// The variant chunk itself also overflowed. We'll need to carry the overflow further, into the upper string region of the UUID.\n\t\t\tconst upperString = ChunkMath.Upper.parse(stringEntry);\n\t\t\tconst upperNumber = Number.parseInt(upperString, 16);\n\t\t\tassertWithMessage(upperNumber <= maxUpperNumber);\n\t\t\tconst newUpperNumber = upperNumber + 1;\n\t\t\tif (newUpperNumber > maxUpperNumber) {\n\t\t\t\tfail('Exceeded maximum numeric UUID');\n\t\t\t} else {\n\t\t\t\t// The variant chunk overflowed but the upper string region did not. Splice in the incremented string region.\n\t\t\t\tconst newUpperChunk = padToLengthWithZeros(newUpperNumber.toString(16), 12);\n\t\t\t\tnewUuid = [\n\t\t\t\t\t`${ChunkMath.Upper.hyphenate(newUpperChunk)}-4${ChunkMath.Variant.hyphenate(\n\t\t\t\t\t\tnewVariantChunkString\n\t\t\t\t\t)}`,\n\t\t\t\t\tremainder,\n\t\t\t\t];\n\t\t\t}\n\t\t} else {\n\t\t\t// The variant chunk did not overflow, so just splice it back in.\n\t\t\tnewUuid = [\n\t\t\t\t`${ChunkMath.Upper.slice(stringEntry)}-4${ChunkMath.Variant.hyphenate(newVariantChunkString)}`,\n\t\t\t\tremainder,\n\t\t\t];\n\t\t}\n\t}\n\n\treturn newUuid as readonly [string, number] as NumericUuid;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace ChunkMath {\n\t/*\n\t * Recall the UUID diagram from the top of this file which describes the layout of a Numeric UUID. To implement addition, we define\n\t * another region called the \"variant chunk\" which overlaps with the \"string\" region. Note that it is just beneath the required v4 uuid\n\t * version identifier (the 13th nibble 'V' which is always '4' in a v4 UUID) and just above the \"number\" region of the layout. It\n\t * contains inside of it the v4 UUID variant identifier bits as well (see https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1).\n\t *\n\t * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n\t * SSSSSSSS SSSS SSSS SSS - array[0]: string\n\t * N NNNNNNNNNNNN - array[1]: integer\n\t * VVV-VVV - the variant chunk\n\t *\n\t * By defining the variant chunk in this way it is simple to splice in the v4 UUID version identifier ('V') just above it and any\n\t * \"bit math\" required due to the fact that the variant identifier bits ('v') do not fill up an entire nibble is handled within it.\n\t * The variant chunk is made up of 6 nibbles. Note the \"vv\" which denotes the two bits used for the v4 UUID variant identifier:\n\t *\n\t * AAAA BBBB CCCC vvDD EEEE FFFF\n\t *\n\t * Since we'll be needing to \"skip\" the variant bits (\"vv\") when doing addition, we define a a few masks which will be used below to\n\t * separate the variant chunk into pieces before recombining it:\n\t */\n\n\t// AAAA BBBB CCCC vvDD EEEE FFFF\n\tconst upperVariantChunkMask = 0xfff000; // XXXX XXXX XXXX\n\tconst variantBitMask = 0x800; // XX\n\tconst middleVariantChunkMask = 0x300; // XX\n\tconst lowerVariantChunkMask = 0xff; // XXXX XXXX\n\n\t/** The maximum numeric value that can be represented by the numerically relevant bits in the variant chunk */\n\tconst maxVariantNumber = 2 ** 22 - 1;\n\n\texport const twentyThirdBit = 2 ** 22;\n\n\t/**\n\t * The upper chunk, denoted by 'U's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Upper {\n\t\texport function parse(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(0, 8) + stringEntry.slice(9, 13);\n\t\t}\n\n\t\texport function hyphenate(upperChunk: string): string {\n\t\t\treturn `${upperChunk.slice(0, 8)}-${upperChunk.slice(8)}`;\n\t\t}\n\n\t\texport function slice(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(0, 13);\n\t\t}\n\t}\n\n\t/**\n\t * The variant chunk, denoted by 'V's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Variant {\n\t\texport function parse(stringEntry: string): string {\n\t\t\treturn stringEntry.slice(15, 18) + stringEntry.slice(19, 22);\n\t\t}\n\n\t\texport function hyphenate(variantChunk: string): string {\n\t\t\treturn `${variantChunk.slice(0, 3)}-${variantChunk.slice(3)}`;\n\t\t}\n\t}\n\n\t/**\n\t * The lower chunk, denoted by 'L's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\texport namespace Lower {\n\t\texport function parse(stableId: StableId): string {\n\t\t\treturn stableId.slice(stringEntryLength, stringEntryLength + 1) + stableId.slice(stringEntryLength + 2);\n\t\t}\n\n\t\texport function hyphenate(lowerChunk: string): string {\n\t\t\treturn `${lowerChunk.slice(0, 1)}-${lowerChunk.slice(1)}`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the number representation of the given bits corresponding to the variant chunk. The value is derived by\n\t * parsing all bits except for reserved bits (i.e. the variant bits).\n\t * @param variantChunk - the variantChunk\n\t */\n\texport function getNumericValue(variantChunk: string): number {\n\t\tconst variantChunkBits = Number.parseInt(variantChunk, 16);\n\t\tconst upperVariantBits = (variantChunkBits & upperVariantChunkMask) >> 2;\n\t\tconst middleVariantBits = variantChunkBits & middleVariantChunkMask;\n\t\tconst lowerVariantBits = variantChunkBits & lowerVariantChunkMask;\n\t\treturn upperVariantBits + middleVariantBits + lowerVariantBits;\n\t}\n\n\t/**\n\t * Given the string portion of a numeric uuid, add one to it.\n\t * @returns the resulting hex string and whether or not the new value overflowed, i.e. it exceeds `maxVariantNumber`. In this case,\n\t * the resulting hex string will wrap around to its minimum value '000b00'\n\t */\n\texport function increment(stringEntry: string): [newVariantChunk: string, overflowed: boolean] {\n\t\t// To implement addition, the variant identifier bits are extracted from the variant chunk, the chunk is interpreted as a number,\n\t\t// that number is incremented by 1, and then the variant identifier bits are returned as we convert the number back into a hex\n\t\t// string.\n\n\t\t// This diagram may be helpful for seeing how the nibbles line up before and after the variant identifier bits are extracted. The\n\t\t// letters used for each nibble (\"AAAA\", \"BBBB\") etc. are arbitrary and are simply there to differentiate the nibbles as they shift.\n\t\t// --------------------------------\n\t\t// 1. AAAA BBBB CCCC vvDD EEEE FFFF\n\t\t// 2. AA AABB BBCC CCDD EEEE FFFF\n\t\t// 3. AA AABB BBCC CCDD EEEE FFFF\n\t\t// + 1\n\t\t// = GG GGHH HHII IIJJ JJKK KKLL\n\t\t// 4. GGGG HHHH IIII vvJJ JJKK KKLL\n\n\t\t// 1. The variant chunk is given as a 6 character (6 nibble) hex string, where the fourth nibble contains the variant bits\n\t\t// 2. The numerically important bits (i.e. not the variant identifier bits vv which are constant) are extracted into a single number\n\t\tconst variantChunk = Variant.parse(stringEntry);\n\t\tconst variantNumber = getNumericValue(variantChunk);\n\t\tassertWithMessage(variantNumber <= maxVariantNumber);\n\t\t// 3. Add one to the variant number to produce our new variant number.\n\t\tconst newVariantNumber = variantNumber + 1;\n\t\t// 4. The variant identifier bits are added back into the number, which is then turned back into a hex string\n\t\tconst newUpperVariantBits = (newVariantNumber & (upperVariantChunkMask >> 2)) << 2;\n\t\tconst newMiddleVariantBits = (newVariantNumber & middleVariantChunkMask) | variantBitMask; // Add the variant bits back in\n\t\tconst newLowerVariantBits = newVariantNumber & lowerVariantChunkMask;\n\t\tconst newVariantChunkBits = newUpperVariantBits + newMiddleVariantBits + newLowerVariantBits;\n\t\tconst newVariantChunk = padToLengthWithZeros(newVariantChunkBits.toString(16), variantChunk.length);\n\t\treturn [newVariantChunk, newVariantNumber > maxVariantNumber];\n\t}\n}\n\nconst maxUpperUuid = 'ffffffff-ffff-4fff-bf';\nconst maxNibbleCount = [...maxUpperUuid].filter((n) => n === 'f').length;\nconst newNibbles = ['7', 'b', 'd', 'e'];\nfunction isMaxUpperNibble(index: number): boolean {\n\treturn maxUpperUuid.charAt(index) === 'f';\n}\n\n/**\n * Any session uuid with all of its highish bits set is in danger of overflowing after fewer than 2^53 increments.\n * By zeroing one of those bits at random, potential overflow is prevented.\n */\nexport function ensureSessionUuid(uuid: StableId): SessionId {\n\tif (uuid.startsWith(maxUpperUuid)) {\n\t\tconst targetNibble = Math.floor(Math.random() * maxNibbleCount);\n\t\tlet actualIndex = 0;\n\t\tfor (let nibbleIndex = 0; nibbleIndex < targetNibble && !isMaxUpperNibble(actualIndex); actualIndex += 1) {\n\t\t\tif (isMaxUpperNibble(actualIndex)) {\n\t\t\t\tnibbleIndex++;\n\t\t\t}\n\t\t}\n\n\t\tconst newNibble = newNibbles[Math.floor(Math.random() * newNibbles.length)]; // Randomly choose a bit to zero\n\t\tconst newUuid = uuid.slice(0, actualIndex) + newNibble + uuid.slice(actualIndex + 1);\n\t\treturn newUuid as SessionId;\n\t}\n\n\treturn uuid as SessionId;\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers';
|
|
6
|
-
import { SerializedSessionIdNormalizer } from './persisted-types';
|
|
5
|
+
import { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers.js';
|
|
6
|
+
import { SerializedSessionIdNormalizer } from './persisted-types/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
|
|
9
9
|
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionIdNormalizer.d.ts","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SessionIdNormalizer.d.ts","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEnG,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,mBAAmB,CAAC,YAAY;IAkBzB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAjBpD,OAAO,CAAC,WAAW,CAA8C;IACjE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAcvB;gBAEkC,gBAAgB,UAAQ;IAE5D;;;OAGG;IACI,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,wBAAwB,GAAG,SAAS;IAqB1F;;OAEG;IACI,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,CAAC,iBAAiB,EAAE,YAAY,CAAC,GAAG,SAAS;IAoB5F;;;OAGG;IACI,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS;IAgBvE;;OAEG;IACI,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAwBhF,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQjC;;OAEG;IACI,cAAc,IAAI,iBAAiB,GAAG,SAAS;IAetD;;;;;;OAMG;IACI,UAAU,IAAI,iBAAiB;IA6BtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,WAAW,CAAC,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI;IAwChH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACI,oBAAoB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI;IAmBjH,OAAO,CAAC,uBAAuB;IAwB/B;;OAEG;IACK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,wBAAwB,CAAC;IAwBhE,SAAS,IAAI,6BAA6B;WAkBnC,WAAW,CAAC,YAAY,EACrC,UAAU,EAAE,6BAA6B,EACzC,cAAc,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,YAAY,GAC1D,mBAAmB,CAAC,YAAY,CAAC;IAuB7B,MAAM,CACZ,KAAK,EAAE,mBAAmB,CAAC,YAAY,CAAC,EACxC,mBAAmB,GAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,OAA2B,GACpF,OAAO;CA+BV"}
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.SessionIdNormalizer = void 0;
|
|
8
8
|
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
|
9
9
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const Common_js_1 = require("../Common.js");
|
|
11
|
+
const AppendOnlySortedMap_js_1 = require("./AppendOnlySortedMap.js");
|
|
12
12
|
/**
|
|
13
13
|
* Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
|
|
14
14
|
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
@@ -51,13 +51,13 @@ class SessionIdNormalizer {
|
|
|
51
51
|
constructor(expensiveAsserts = false) {
|
|
52
52
|
this.expensiveAsserts = expensiveAsserts;
|
|
53
53
|
this.nextLocalId = -1;
|
|
54
|
-
this.idRanges = new
|
|
54
|
+
this.idRanges = new AppendOnlySortedMap_js_1.AppendOnlyDoublySortedMap(Common_js_1.compareFiniteNumbersReversed, ([_, finalRanges]) => {
|
|
55
55
|
if (finalRanges !== undefined) {
|
|
56
56
|
const first = getFirstRange(finalRanges);
|
|
57
57
|
return extractFirstFinalFromRange(first);
|
|
58
58
|
}
|
|
59
59
|
return Number.POSITIVE_INFINITY;
|
|
60
|
-
},
|
|
60
|
+
}, Common_js_1.compareFiniteNumbers);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Converts the final ID to its session-space representation.
|
|
@@ -87,10 +87,10 @@ class SessionIdNormalizer {
|
|
|
87
87
|
* Converts the local ID to its corresponding final ID, if one exists.
|
|
88
88
|
*/
|
|
89
89
|
getFinalId(localId) {
|
|
90
|
-
const localRange = this.idRanges.getPairOrNextLower(localId) ?? (0,
|
|
90
|
+
const localRange = this.idRanges.getPairOrNextLower(localId) ?? (0, Common_js_1.fail)('Local ID was never recorded with this normalizer.');
|
|
91
91
|
const [firstLocal, [lastLocal, finalRanges]] = localRange;
|
|
92
92
|
if (localId < lastLocal) {
|
|
93
|
-
(0,
|
|
93
|
+
(0, Common_js_1.fail)('Local ID was never recorded with this normalizer.');
|
|
94
94
|
}
|
|
95
95
|
const finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);
|
|
96
96
|
if (finalRange !== undefined) {
|
|
@@ -137,7 +137,7 @@ class SessionIdNormalizer {
|
|
|
137
137
|
return localByIndex;
|
|
138
138
|
}
|
|
139
139
|
const finalRange = getPairOrNextLower(firstLocal, finalRanges, localByIndex) ??
|
|
140
|
-
(0,
|
|
140
|
+
(0, Common_js_1.fail)('Final ranges not aligned with owning local range.');
|
|
141
141
|
const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
|
|
142
142
|
const localDelta = alignedLocal - localByIndex;
|
|
143
143
|
const finalId = firstFinal + localDelta;
|
|
@@ -148,7 +148,7 @@ class SessionIdNormalizer {
|
|
|
148
148
|
return undefined;
|
|
149
149
|
}
|
|
150
150
|
static makeFinalRangesMap() {
|
|
151
|
-
return new
|
|
151
|
+
return new AppendOnlySortedMap_js_1.AppendOnlyDoublySortedMap(Common_js_1.compareFiniteNumbersReversed, extractFirstFinalFromRange, Common_js_1.compareFiniteNumbers);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Returns the last final ID known to this normalizer.
|
|
@@ -226,7 +226,7 @@ class SessionIdNormalizer {
|
|
|
226
226
|
*/
|
|
227
227
|
addFinalIds(firstFinal, lastFinal, rangeObject) {
|
|
228
228
|
(0, core_utils_1.assert)(lastFinal >= firstFinal, 0x659 /* Malformed normalization range. */);
|
|
229
|
-
const [firstLocal, finalRangesObj] = this.idRanges.last() ?? (0,
|
|
229
|
+
const [firstLocal, finalRangesObj] = this.idRanges.last() ?? (0, Common_js_1.fail)('Final IDs must be added to an existing local range.');
|
|
230
230
|
const [lastLocal, finalRanges] = finalRangesObj;
|
|
231
231
|
let nextLocal;
|
|
232
232
|
if (finalRanges === undefined) {
|
|
@@ -286,7 +286,7 @@ class SessionIdNormalizer {
|
|
|
286
286
|
*/
|
|
287
287
|
registerFinalIdBlock(firstFinalInBlock, count, rangeObject) {
|
|
288
288
|
(0, core_utils_1.assert)(count >= 1, 0x65b /* Malformed normalization block. */);
|
|
289
|
-
const [firstLocal, [lastLocal, finalRanges]] = this.idRanges.last() ?? (0,
|
|
289
|
+
const [firstLocal, [lastLocal, finalRanges]] = this.idRanges.last() ?? (0, Common_js_1.fail)('Final ID block should not be registered before any locals.');
|
|
290
290
|
let unalignedLocalCount;
|
|
291
291
|
if (finalRanges === undefined) {
|
|
292
292
|
unalignedLocalCount = firstLocal - lastLocal + 1;
|
|
@@ -308,7 +308,7 @@ class SessionIdNormalizer {
|
|
|
308
308
|
lastFinalRange = finalRanges;
|
|
309
309
|
}
|
|
310
310
|
else {
|
|
311
|
-
[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? (0,
|
|
311
|
+
[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? (0, Common_js_1.fail)('Map should be non-empty.');
|
|
312
312
|
}
|
|
313
313
|
const [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;
|
|
314
314
|
const lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);
|
|
@@ -331,7 +331,7 @@ class SessionIdNormalizer {
|
|
|
331
331
|
lastFinalRange = finalRanges;
|
|
332
332
|
}
|
|
333
333
|
else {
|
|
334
|
-
[alignedLocal, lastFinalRange] = finalRanges.last() ?? (0,
|
|
334
|
+
[alignedLocal, lastFinalRange] = finalRanges.last() ?? (0, Common_js_1.fail)('Map should be non-empty.');
|
|
335
335
|
}
|
|
336
336
|
const [firstFinal, lastFinal] = lastFinalRange;
|
|
337
337
|
const localRangeDelta = alignedLocal - lastLocal;
|
|
@@ -415,13 +415,13 @@ function getLastRange(finalRanges) {
|
|
|
415
415
|
if (isSingleRange(finalRanges)) {
|
|
416
416
|
return finalRanges;
|
|
417
417
|
}
|
|
418
|
-
return (finalRanges.last() ?? (0,
|
|
418
|
+
return (finalRanges.last() ?? (0, Common_js_1.fail)('Map must be non-empty'))[1];
|
|
419
419
|
}
|
|
420
420
|
function getFirstRange(finalRanges) {
|
|
421
421
|
if (isSingleRange(finalRanges)) {
|
|
422
422
|
return finalRanges;
|
|
423
423
|
}
|
|
424
|
-
return (finalRanges.first() ?? (0,
|
|
424
|
+
return (finalRanges.first() ?? (0, Common_js_1.fail)('Map must be non-empty'))[1];
|
|
425
425
|
}
|
|
426
426
|
function extractFirstFinalFromRange(finalRange) {
|
|
427
427
|
return finalRange[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionIdNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8DAA8D;AAE9D,2DAAoD;AACpD,sCAA8F;AAE9F,+DAAkE;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAa,mBAAmB;IAkB/B,YAAoC,mBAAmB,KAAK;QAAxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAjBpD,gBAAW,GAAsB,CAAC,CAAsB,CAAC;QAChD,aAAQ,GAIrB,IAAI,+CAAyB,CAChC,qCAA4B,EAC5B,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,EAAE;YACpB,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;aACzC;YACD,OAAO,MAAM,CAAC,iBAAsC,CAAC;QACtD,CAAC,EACD,6BAAoB,CACpB,CAAC;IAE6D,CAAC;IAEhE;;;OAGG;IACI,iBAAiB,CAAC,OAA0B;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,UAAU,KAAK,SAAS,EAAE;YAC7B,MAAM,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,GAAG,UAAU,CAAC;YAC1D,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAC/E,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC7B,MAAM,CAAC,YAAY,EAAE,CAAC,UAAU,EAA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AE,EAAE;gBAC1C,MAAM,KAAK,CAAC;aACZ;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { compareFiniteNumbers, compareFiniteNumbersReversed, fail, Mutable } from '../Common';\nimport { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers';\nimport { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap';\nimport { SerializedSessionIdNormalizer } from './persisted-types';\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * ```\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n * ```\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * ```\n * for each index in the range of IDs created by a session:\n * \tthe local form if it exists, otherwise the final form\n * ```\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ?? fail('Local ID was never recorded with this normalizer.');\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail('Local ID was never recorded with this normalizer.');\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,\n\t * if the ID was created by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail('Final ranges not aligned with owning local range.');\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 0x657 /* Local ID space must start at -1. */);\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(localId === firstLocal - finalDelta, 0x658 /* Local ID space must be contiguous. */);\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers one or more final IDs with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)\n\t * starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.\n\t *\n\t * An example:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Subsequently calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t *\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void {\n\t\tassert(lastFinal >= firstFinal, 0x659 /* Malformed normalization range. */);\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail('Final IDs must be added to an existing local range.');\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] =\n\t\t\t\tthis.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tnextLocal = Math.min(\n\t\t\t\tthis.nextLocalId,\n\t\t\t\tlastAlignedLocal - (lastFinal - firstFinal) - 2\n\t\t\t) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(alignedLocal >= lastLocal, 0x65a /* Gaps in final space must align to a local. */);\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).\n\t *\n\t * The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with\n\t * as many finals from the registered block as possible.\n\t *\n\t * It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such\n\t * generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,\n\t * a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,\n\t * those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier\n\t * creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second\n\t * creation range is finalized.\n\t *\n\t * A usage example:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, X, X, X]\n\t * Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, 7]\n\t * Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, X]\n\t *\n\t */\n\tpublic registerFinalIdBlock(firstFinalInBlock: FinalCompressedId, count: number, rangeObject: TRangeObject): void {\n\t\tassert(count >= 1, 0x65b /* Malformed normalization block. */);\n\t\tconst [firstLocal, [lastLocal, finalRanges]] =\n\t\t\tthis.idRanges.last() ?? fail('Final ID block should not be registered before any locals.');\n\t\tlet unalignedLocalCount: number;\n\t\tif (finalRanges === undefined) {\n\t\t\tunalignedLocalCount = firstLocal - lastLocal + 1;\n\t\t} else {\n\t\t\tconst [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tunalignedLocalCount = lastAlignedLocal - lastLocal;\n\t\t}\n\t\tassert(\n\t\t\tunalignedLocalCount > 0,\n\t\t\t0x65c /* Final ID block should not be registered without an existing local range. */\n\t\t);\n\t\tconst lastFinal = (firstFinalInBlock + Math.min(unalignedLocalCount, count) - 1) as FinalCompressedId;\n\t\tthis.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);\n\t}\n\n\tprivate getAlignmentOfLastRange(\n\t\tfirstLocal: LocalCompressedId,\n\t\tfinalRanges: FinalRanges<TRangeObject>\n\t): [\n\t\tfirstAlignedLocal: LocalCompressedId,\n\t\tlastAlignedLocal: LocalCompressedId,\n\t\tlastAlignedFinal: FinalCompressedId,\n\t\tlastFinalRange: FinalRange<TRangeObject>,\n\t] {\n\t\tconst isSingle = isSingleRange(finalRanges);\n\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\tif (isSingle) {\n\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\tlastFinalRange = finalRanges;\n\t\t} else {\n\t\t\t[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t}\n\n\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\treturn [firstAlignedLocal, lastAlignedLocal as LocalCompressedId, lastAlignedFinal, lastFinalRange];\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = { localRanges: [], nextLocalId: this.nextLocalId };\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [LocalCompressedId, FinalCompressedId, FinalCompressedId][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(serializedFinalRanges.length !== 0, 0x65d /* Empty range should not be reified. */);\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\tnormalizer.nextLocalId = serialized.nextLocalId;\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b\n\t): boolean {\n\t\treturn (\n\t\t\tthis.nextLocalId === other.nextLocalId &&\n\t\t\tthis.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t\t}\n\n\t\t\t\tconst rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>) => {\n\t\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfirstFinalA === firstFinalB &&\n\t\t\t\t\t\tlastFinalA === lastFinalB &&\n\t\t\t\t\t\tcompareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t\t}\n\n\t\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t\t})\n\t\t);\n\t}\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject,\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(ranges: FinalRanges<TRangeObject>): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction getFirstRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(finalRange: FinalRange<TRangeObject>): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SessionIdNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer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UAAoC;IACrF,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,yBAAyB,CACjC,UAA6B,EAC7B,WAAkD,EAClD,OAA0B;IAE1B,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,OAAO,SAAS,CAAC;KACjB;IACD,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;QAC/B,IAAI,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE;YAC7B,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,kBAAkB,CAC1B,UAA6B,EAC7B,WAAkD,EAClD,OAA0B;IAE1B,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,OAAO,SAAS,CAAC;KACjB;IACD,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;QAC/B,IAAI,OAAO,GAAG,UAAU,EAAE;YACzB,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,QAAQ,CAAC,CAAC,OAAO,CAChB,UAA6B,EAC7B,WAAkD;IAElD,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;YAC/B,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;SAChC;aAAM;YACN,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE;gBAC1C,MAAM,KAAK,CAAC;aACZ;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { compareFiniteNumbers, compareFiniteNumbersReversed, fail, Mutable } from '../Common.js';\nimport { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers.js';\nimport { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap.js';\nimport { SerializedSessionIdNormalizer } from './persisted-types/index.js';\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * ```\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n * ```\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * ```\n * for each index in the range of IDs created by a session:\n * \tthe local form if it exists, otherwise the final form\n * ```\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ?? fail('Local ID was never recorded with this normalizer.');\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail('Local ID was never recorded with this normalizer.');\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,\n\t * if the ID was created by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail('Final ranges not aligned with owning local range.');\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 0x657 /* Local ID space must start at -1. */);\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(localId === firstLocal - finalDelta, 0x658 /* Local ID space must be contiguous. */);\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers one or more final IDs with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)\n\t * starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.\n\t *\n\t * An example:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Subsequently calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t *\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void {\n\t\tassert(lastFinal >= firstFinal, 0x659 /* Malformed normalization range. */);\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail('Final IDs must be added to an existing local range.');\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] =\n\t\t\t\tthis.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tnextLocal = Math.min(\n\t\t\t\tthis.nextLocalId,\n\t\t\t\tlastAlignedLocal - (lastFinal - firstFinal) - 2\n\t\t\t) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(alignedLocal >= lastLocal, 0x65a /* Gaps in final space must align to a local. */);\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).\n\t *\n\t * The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with\n\t * as many finals from the registered block as possible.\n\t *\n\t * It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such\n\t * generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,\n\t * a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,\n\t * those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier\n\t * creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second\n\t * creation range is finalized.\n\t *\n\t * A usage example:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, X, X, X]\n\t * Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, 7]\n\t * Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, X]\n\t *\n\t */\n\tpublic registerFinalIdBlock(firstFinalInBlock: FinalCompressedId, count: number, rangeObject: TRangeObject): void {\n\t\tassert(count >= 1, 0x65b /* Malformed normalization block. */);\n\t\tconst [firstLocal, [lastLocal, finalRanges]] =\n\t\t\tthis.idRanges.last() ?? fail('Final ID block should not be registered before any locals.');\n\t\tlet unalignedLocalCount: number;\n\t\tif (finalRanges === undefined) {\n\t\t\tunalignedLocalCount = firstLocal - lastLocal + 1;\n\t\t} else {\n\t\t\tconst [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tunalignedLocalCount = lastAlignedLocal - lastLocal;\n\t\t}\n\t\tassert(\n\t\t\tunalignedLocalCount > 0,\n\t\t\t0x65c /* Final ID block should not be registered without an existing local range. */\n\t\t);\n\t\tconst lastFinal = (firstFinalInBlock + Math.min(unalignedLocalCount, count) - 1) as FinalCompressedId;\n\t\tthis.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);\n\t}\n\n\tprivate getAlignmentOfLastRange(\n\t\tfirstLocal: LocalCompressedId,\n\t\tfinalRanges: FinalRanges<TRangeObject>\n\t): [\n\t\tfirstAlignedLocal: LocalCompressedId,\n\t\tlastAlignedLocal: LocalCompressedId,\n\t\tlastAlignedFinal: FinalCompressedId,\n\t\tlastFinalRange: FinalRange<TRangeObject>,\n\t] {\n\t\tconst isSingle = isSingleRange(finalRanges);\n\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\tif (isSingle) {\n\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\tlastFinalRange = finalRanges;\n\t\t} else {\n\t\t\t[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t}\n\n\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\treturn [firstAlignedLocal, lastAlignedLocal as LocalCompressedId, lastAlignedFinal, lastFinalRange];\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = { localRanges: [], nextLocalId: this.nextLocalId };\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [LocalCompressedId, FinalCompressedId, FinalCompressedId][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(serializedFinalRanges.length !== 0, 0x65d /* Empty range should not be reified. */);\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\tnormalizer.nextLocalId = serialized.nextLocalId;\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b\n\t): boolean {\n\t\treturn (\n\t\t\tthis.nextLocalId === other.nextLocalId &&\n\t\t\tthis.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t\t}\n\n\t\t\t\tconst rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>) => {\n\t\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfirstFinalA === firstFinalB &&\n\t\t\t\t\t\tlastFinalA === lastFinalB &&\n\t\t\t\t\t\tcompareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t\t}\n\n\t\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t\t})\n\t\t);\n\t}\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject,\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(ranges: FinalRanges<TRangeObject>): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction getFirstRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(finalRange: FinalRange<TRangeObject>): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Exports for `id-compressor`
|
|
7
7
|
*/
|
|
8
|
-
export { defaultClusterCapacity, hasOngoingSession, IdCompressor, isFinalId, isLocalId, legacySharedTreeInitialTreeId, } from './IdCompressor';
|
|
9
|
-
export { getIds } from './IdRange';
|
|
10
|
-
export { IdCreationRange, SerializedCluster, SerializedClusterOverrides, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SerializedLocalOverrides, SerializedLocalState, SerializedSessionData, SerializedSessionIdNormalizer, UnackedLocalId, VersionedSerializedIdCompressor, } from './persisted-types';
|
|
11
|
-
export { createSessionId } from './NumericUuid';
|
|
8
|
+
export { defaultClusterCapacity, hasOngoingSession, IdCompressor, isFinalId, isLocalId, legacySharedTreeInitialTreeId, } from './IdCompressor.js';
|
|
9
|
+
export { getIds } from './IdRange.js';
|
|
10
|
+
export { IdCreationRange, SerializedCluster, SerializedClusterOverrides, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SerializedLocalOverrides, SerializedLocalState, SerializedSessionData, SerializedSessionIdNormalizer, UnackedLocalId, VersionedSerializedIdCompressor, } from './persisted-types/index.js';
|
|
11
|
+
export { createSessionId } from './NumericUuid.js';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,6BAA6B,GAC7B,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,6BAA6B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,EACxC,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACd,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -8,15 +8,15 @@ exports.createSessionId = exports.getIds = exports.legacySharedTreeInitialTreeId
|
|
|
8
8
|
/**
|
|
9
9
|
* Exports for `id-compressor`
|
|
10
10
|
*/
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "defaultClusterCapacity", { enumerable: true, get: function () { return
|
|
13
|
-
Object.defineProperty(exports, "hasOngoingSession", { enumerable: true, get: function () { return
|
|
14
|
-
Object.defineProperty(exports, "IdCompressor", { enumerable: true, get: function () { return
|
|
15
|
-
Object.defineProperty(exports, "isFinalId", { enumerable: true, get: function () { return
|
|
16
|
-
Object.defineProperty(exports, "isLocalId", { enumerable: true, get: function () { return
|
|
17
|
-
Object.defineProperty(exports, "legacySharedTreeInitialTreeId", { enumerable: true, get: function () { return
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "getIds", { enumerable: true, get: function () { return
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "createSessionId", { enumerable: true, get: function () { return
|
|
11
|
+
var IdCompressor_js_1 = require("./IdCompressor.js");
|
|
12
|
+
Object.defineProperty(exports, "defaultClusterCapacity", { enumerable: true, get: function () { return IdCompressor_js_1.defaultClusterCapacity; } });
|
|
13
|
+
Object.defineProperty(exports, "hasOngoingSession", { enumerable: true, get: function () { return IdCompressor_js_1.hasOngoingSession; } });
|
|
14
|
+
Object.defineProperty(exports, "IdCompressor", { enumerable: true, get: function () { return IdCompressor_js_1.IdCompressor; } });
|
|
15
|
+
Object.defineProperty(exports, "isFinalId", { enumerable: true, get: function () { return IdCompressor_js_1.isFinalId; } });
|
|
16
|
+
Object.defineProperty(exports, "isLocalId", { enumerable: true, get: function () { return IdCompressor_js_1.isLocalId; } });
|
|
17
|
+
Object.defineProperty(exports, "legacySharedTreeInitialTreeId", { enumerable: true, get: function () { return IdCompressor_js_1.legacySharedTreeInitialTreeId; } });
|
|
18
|
+
var IdRange_js_1 = require("./IdRange.js");
|
|
19
|
+
Object.defineProperty(exports, "getIds", { enumerable: true, get: function () { return IdRange_js_1.getIds; } });
|
|
20
|
+
var NumericUuid_js_1 = require("./NumericUuid.js");
|
|
21
|
+
Object.defineProperty(exports, "createSessionId", { enumerable: true, get: function () { return NumericUuid_js_1.createSessionId; } });
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH,qDAO2B;AAN1B,yHAAA,sBAAsB,OAAA;AACtB,oHAAA,iBAAiB,OAAA;AACjB,+GAAA,YAAY,OAAA;AACZ,4GAAA,SAAS,OAAA;AACT,4GAAA,SAAS,OAAA;AACT,gIAAA,6BAA6B,OAAA;AAE9B,2CAAsC;AAA7B,oGAAA,MAAM,OAAA;AAef,mDAAmD;AAA1C,iHAAA,eAAe,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Exports for `id-compressor`\n */\n\nexport {\n\tdefaultClusterCapacity,\n\thasOngoingSession,\n\tIdCompressor,\n\tisFinalId,\n\tisLocalId,\n\tlegacySharedTreeInitialTreeId,\n} from './IdCompressor.js';\nexport { getIds } from './IdRange.js';\nexport {\n\tIdCreationRange,\n\tSerializedCluster,\n\tSerializedClusterOverrides,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedLocalOverrides,\n\tSerializedLocalState,\n\tSerializedSessionData,\n\tSerializedSessionIdNormalizer,\n\tUnackedLocalId,\n\tVersionedSerializedIdCompressor,\n} from './persisted-types/index.js';\nexport { createSessionId } from './NumericUuid.js';\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type { AttributionId, FinalCompressedId, LocalCompressedId, OpSpaceCompressedId, SessionId } from '../../Identifiers';
|
|
5
|
+
import type { AttributionId, FinalCompressedId, LocalCompressedId, OpSpaceCompressedId, SessionId } from '../../Identifiers.js';
|
|
6
6
|
/**
|
|
7
7
|
* A serialized ID allocation session for an `IdCompressor`.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,MAAM,
|
|
1
|
+
{"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,SAAS;IAC5C;;OAEG;IACH,SAAS,EAAE,SAAS;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM;CACtB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,SAAS;IACjD,mFAAmF;IACnF,oBAAoB,EAAE,MAAM;IAC5B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM;IAChB,+HAA+H;IAC/H,YAAY,CAAC,EAAE,iBAAiB;CAChC,EAAE,CAA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