@fluid-experimental/tree 0.59.2001 → 0.59.3000
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 +2 -0
- package/.vscode/SharedTree.code-workspace +15 -0
- package/.vscode/settings.json +6 -0
- package/dist/ChangeCompression.js +9 -9
- package/dist/ChangeCompression.js.map +1 -1
- package/dist/ChangeTypes.d.ts +1 -6
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +5 -5
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.js +14 -14
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +21 -3
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +29 -4
- package/dist/Common.js.map +1 -1
- package/dist/EditLog.js +26 -25
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.js +17 -17
- package/dist/EditUtilities.js.map +1 -1
- package/dist/Forest.js +31 -31
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.js +9 -9
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/IdConversion.js +9 -9
- package/dist/IdConversion.js.map +1 -1
- package/dist/Identifiers.d.ts +4 -0
- package/dist/Identifiers.d.ts.map +1 -1
- package/dist/Identifiers.js.map +1 -1
- package/dist/LogViewer.d.ts +1 -5
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +11 -19
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.js +2 -2
- package/dist/MergeHealth.js.map +1 -1
- package/dist/NodeIdUtilities.js +2 -2
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.js +1 -1
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +13 -10
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +14 -11
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.js +4 -4
- package/dist/RevisionView.js.map +1 -1
- package/dist/SerializationUtilities.js +4 -4
- package/dist/SerializationUtilities.js.map +1 -1
- package/dist/SharedTree.d.ts +93 -31
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +160 -131
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +3 -3
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +36 -36
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/StringInterner.js +1 -1
- package/dist/StringInterner.js.map +1 -1
- package/dist/Summary.js +1 -1
- package/dist/Summary.js.map +1 -1
- package/dist/SummaryBackCompatibility.js +8 -8
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/Transaction.js +1 -1
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.js +17 -17
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeCompressor.d.ts.map +1 -1
- package/dist/TreeCompressor.js +6 -8
- package/dist/TreeCompressor.js.map +1 -1
- package/dist/TreeNodeHandle.js +4 -4
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.js +7 -7
- package/dist/TreeView.js.map +1 -1
- package/dist/TreeViewUtilities.js +2 -2
- package/dist/TreeViewUtilities.js.map +1 -1
- package/dist/UndoRedoHandler.js +1 -1
- package/dist/UndoRedoHandler.js.map +1 -1
- package/dist/UuidUtilities.d.ts +30 -0
- package/dist/UuidUtilities.d.ts.map +1 -0
- package/dist/UuidUtilities.js +106 -0
- package/dist/UuidUtilities.js.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
- package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +43 -42
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +179 -177
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/IdRange.js +1 -1
- package/dist/id-compressor/IdRange.js.map +1 -1
- package/dist/id-compressor/NumericUuid.d.ts +6 -14
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
- package/dist/id-compressor/NumericUuid.js +15 -76
- package/dist/id-compressor/NumericUuid.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
- package/dist/id-compressor/SessionIdNormalizer.js +418 -0
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
- 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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +1 -6
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js +3 -3
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/lib/ChangeTypes.d.ts +1 -6
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +21 -3
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +25 -3
- package/lib/Common.js.map +1 -1
- package/lib/EditLog.js +2 -1
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.js.map +1 -1
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/Identifiers.d.ts +4 -0
- package/lib/Identifiers.d.ts.map +1 -1
- package/lib/Identifiers.js.map +1 -1
- package/lib/LogViewer.d.ts +1 -5
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +5 -13
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.js.map +1 -1
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +13 -10
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +10 -7
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.js.map +1 -1
- package/lib/SharedTree.d.ts +93 -31
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +107 -78
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +3 -3
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +4 -4
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/StringInterner.js.map +1 -1
- package/lib/Summary.js.map +1 -1
- package/lib/TreeCompressor.d.ts.map +1 -1
- package/lib/TreeCompressor.js +1 -3
- package/lib/TreeCompressor.js.map +1 -1
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.js.map +1 -1
- package/lib/TreeViewUtilities.js.map +1 -1
- package/lib/UuidUtilities.d.ts +30 -0
- package/lib/UuidUtilities.d.ts.map +1 -0
- package/lib/UuidUtilities.js +98 -0
- package/lib/UuidUtilities.js.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
- package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +43 -42
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +97 -95
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/NumericUuid.d.ts +6 -14
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
- package/lib/id-compressor/NumericUuid.js +11 -70
- package/lib/id-compressor/NumericUuid.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
- package/lib/id-compressor/SessionIdNormalizer.js +414 -0
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
- 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/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +1 -6
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.js +56 -14
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
- package/lib/test/Checkout.tests.js +2 -2
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/IdCompressor.perf.tests.js +8 -2
- package/lib/test/IdCompressor.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +75 -24
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/LogViewer.tests.js +3 -5
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/NumericUuid.perf.tests.js +4 -4
- package/lib/test/NumericUuid.perf.tests.js.map +1 -1
- package/lib/test/NumericUuid.tests.js +5 -4
- package/lib/test/NumericUuid.tests.js.map +1 -1
- package/lib/test/RevisionValueCache.tests.js.map +1 -1
- package/lib/test/RevisionView.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
- package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
- package/lib/test/SessionIdNormalizer.tests.js +299 -0
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
- package/lib/test/Summary.tests.js +1 -1
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/TreeCompression.tests.js +1 -1
- package/lib/test/TreeCompression.tests.js.map +1 -1
- package/lib/test/Virtualization.tests.js +1 -1
- package/lib/test/Virtualization.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts +3 -14
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js +60 -151
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/fuzz/Types.d.ts +2 -9
- package/lib/test/fuzz/Types.d.ts.map +1 -1
- package/lib/test/fuzz/Types.js +1 -1
- package/lib/test/fuzz/Types.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +2 -1
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +30 -1
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
- package/lib/test/utilities/TestNode.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +9 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +27 -13
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +19 -17
- package/src/Common.ts +42 -4
- package/src/EditLog.ts +1 -1
- package/src/Identifiers.ts +5 -0
- package/src/LogViewer.ts +4 -20
- package/src/RevisionValueCache.ts +11 -8
- package/src/SharedTree.ts +222 -75
- package/src/SharedTreeEncoder.ts +17 -11
- package/src/TreeCompressor.ts +2 -4
- package/src/UuidUtilities.ts +123 -0
- package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
- package/src/id-compressor/IdCompressor.ts +144 -132
- package/src/id-compressor/NumericUuid.ts +11 -80
- package/src/id-compressor/SessionIdNormalizer.ts +497 -0
- package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
- package/src/index.ts +5 -0
|
@@ -17,30 +17,22 @@ export declare type NumericUuid = readonly [string, number] & {
|
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Calculates the numeric delta between a and b (i.e. a - b).
|
|
20
|
-
* @param a an uuid
|
|
21
|
-
* @param b an other uuid
|
|
22
|
-
* @param maxDelta the maximum integer delta (inclusive) to tolerate.
|
|
20
|
+
* @param a - an uuid
|
|
21
|
+
* @param b - an other uuid
|
|
22
|
+
* @param maxDelta - the maximum integer delta (inclusive) to tolerate.
|
|
23
23
|
* @returns undefined if the delta is negative or greater than `maxDelta`
|
|
24
24
|
*/
|
|
25
25
|
export declare function getPositiveDelta(a: NumericUuid, b: NumericUuid, maxDelta: number): number | undefined;
|
|
26
26
|
/**
|
|
27
|
-
* @param offset an optional offset to increment the returned StableId
|
|
27
|
+
* @param offset - an optional offset to increment the returned StableId
|
|
28
28
|
* @returns the string representation of a `NumericUuid`.
|
|
29
29
|
*/
|
|
30
30
|
export declare function stableIdFromNumericUuid(uuid: NumericUuid, offset?: number): StableId;
|
|
31
31
|
/**
|
|
32
|
-
* @param stableId a minimal uuid string
|
|
32
|
+
* @param stableId - a minimal uuid string
|
|
33
33
|
* @returns a numeric representation of `stableId`.
|
|
34
34
|
*/
|
|
35
35
|
export declare function numericUuidFromStableId(stableId: StableId): NumericUuid;
|
|
36
|
-
/**
|
|
37
|
-
* Asserts that the supplied uuid is a stable ID.
|
|
38
|
-
*/
|
|
39
|
-
export declare function assertIsStableId(uuid: string): StableId;
|
|
40
|
-
/**
|
|
41
|
-
* Returns whether the supplied string is a v4 variant 2 uuid.
|
|
42
|
-
*/
|
|
43
|
-
export declare function isStableId(str: string): str is StableId;
|
|
44
36
|
/**
|
|
45
37
|
* Creates a session base ID.
|
|
46
38
|
* This method (rather than standard uuid generation methods) should be used to generate session IDs.
|
|
@@ -52,7 +44,7 @@ export declare function createSessionId(): SessionId;
|
|
|
52
44
|
export declare function numericUuidEquals(a: NumericUuid, b: NumericUuid): boolean;
|
|
53
45
|
/**
|
|
54
46
|
* Increments the uuid. `amount` must be a positive integer.
|
|
55
|
-
* @returns the result of incrementing the uuid by `amount
|
|
47
|
+
* @returns the result of incrementing the uuid by `amount`.
|
|
56
48
|
*/
|
|
57
49
|
export declare function incrementUuid(uuid: NumericUuid, amount: number): NumericUuid;
|
|
58
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.d.ts","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"NumericUuid.d.ts","sourceRoot":"","sources":["../../src/id-compressor/NumericUuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGrD;;;;;;;;GAQG;AACH,oBAAY,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;AAiID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAgB3D"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ensureSessionUuid = exports.incrementUuid = exports.numericUuidEquals = exports.createSessionId = exports.
|
|
7
|
+
exports.ensureSessionUuid = exports.incrementUuid = exports.numericUuidEquals = exports.createSessionId = exports.numericUuidFromStableId = exports.stableIdFromNumericUuid = exports.getPositiveDelta = void 0;
|
|
8
8
|
/* eslint-disable no-bitwise */
|
|
9
|
-
const uuid_1 = require("uuid");
|
|
10
9
|
const Common_1 = require("../Common");
|
|
10
|
+
const UuidUtilities_1 = require("../UuidUtilities");
|
|
11
11
|
const bitsInNumericUuidInteger = 52; // Not tunable. Do not change.
|
|
12
12
|
const nibblesInNumericUuidInteger = bitsInNumericUuidInteger / 4;
|
|
13
13
|
const stringEntryLength = 22;
|
|
@@ -15,9 +15,9 @@ const maxNumericUuidInteger = 2 ** bitsInNumericUuidInteger - 1;
|
|
|
15
15
|
const fiftyThirdBit = 2 ** 52;
|
|
16
16
|
/**
|
|
17
17
|
* Calculates the numeric delta between a and b (i.e. a - b).
|
|
18
|
-
* @param a an uuid
|
|
19
|
-
* @param b an other uuid
|
|
20
|
-
* @param maxDelta the maximum integer delta (inclusive) to tolerate.
|
|
18
|
+
* @param a - an uuid
|
|
19
|
+
* @param b - an other uuid
|
|
20
|
+
* @param maxDelta - the maximum integer delta (inclusive) to tolerate.
|
|
21
21
|
* @returns undefined if the delta is negative or greater than `maxDelta`
|
|
22
22
|
*/
|
|
23
23
|
function getPositiveDelta(a, b, maxDelta) {
|
|
@@ -73,7 +73,7 @@ function padToLengthWithZeros(str, count) {
|
|
|
73
73
|
return str.length === count ? str : zeros[count - str.length] + str;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* @param offset an optional offset to increment the returned StableId
|
|
76
|
+
* @param offset - an optional offset to increment the returned StableId
|
|
77
77
|
* @returns the string representation of a `NumericUuid`.
|
|
78
78
|
*/
|
|
79
79
|
function stableIdFromNumericUuid(uuid, offset = 0) {
|
|
@@ -87,7 +87,7 @@ function stableIdFromNumericUuid(uuid, offset = 0) {
|
|
|
87
87
|
}
|
|
88
88
|
exports.stableIdFromNumericUuid = stableIdFromNumericUuid;
|
|
89
89
|
/**
|
|
90
|
-
* @param stableId a minimal uuid string
|
|
90
|
+
* @param stableId - a minimal uuid string
|
|
91
91
|
* @returns a numeric representation of `stableId`.
|
|
92
92
|
*/
|
|
93
93
|
function numericUuidFromStableId(stableId) {
|
|
@@ -97,73 +97,12 @@ function numericUuidFromStableId(stableId) {
|
|
|
97
97
|
return uuid;
|
|
98
98
|
}
|
|
99
99
|
exports.numericUuidFromStableId = numericUuidFromStableId;
|
|
100
|
-
/**
|
|
101
|
-
* Asserts that the supplied uuid is a stable ID.
|
|
102
|
-
*/
|
|
103
|
-
function assertIsStableId(uuid) {
|
|
104
|
-
Common_1.assert(isStableId(uuid), `${uuid} is not a StableId.`);
|
|
105
|
-
return uuid;
|
|
106
|
-
}
|
|
107
|
-
exports.assertIsStableId = assertIsStableId;
|
|
108
|
-
const charCode0 = '0'.charCodeAt(0);
|
|
109
|
-
const charCode9 = '9'.charCodeAt(0);
|
|
110
|
-
const charCodea = 'a'.charCodeAt(0);
|
|
111
|
-
const charCodef = 'f'.charCodeAt(0);
|
|
112
|
-
const charCodeA = 'A'.charCodeAt(0);
|
|
113
|
-
const charCodeF = 'F'.charCodeAt(0);
|
|
114
|
-
/**
|
|
115
|
-
* Returns whether the supplied string is a v4 variant 2 uuid.
|
|
116
|
-
*/
|
|
117
|
-
function isStableId(str) {
|
|
118
|
-
if (str.length !== 36) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
for (let i = 0; i < str.length; i++) {
|
|
122
|
-
switch (i) {
|
|
123
|
-
case 8:
|
|
124
|
-
case 13:
|
|
125
|
-
case 18:
|
|
126
|
-
case 23: {
|
|
127
|
-
if (str.charAt(i) !== '-') {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case 14: {
|
|
133
|
-
if (str.charAt(i) !== '4') {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
case 19: {
|
|
139
|
-
const c = str.charAt(i);
|
|
140
|
-
if (c !== '8' && c !== '9' && c !== 'a' && c !== 'b') {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
default: {
|
|
146
|
-
const code = str.charCodeAt(i);
|
|
147
|
-
const isUuidChar = (code >= charCode0 && code <= charCode9) ||
|
|
148
|
-
(code >= charCodea && code <= charCodef) ||
|
|
149
|
-
(code >= charCodeA && code <= charCodeF);
|
|
150
|
-
if (!isUuidChar) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
exports.isStableId = isStableId;
|
|
160
100
|
/**
|
|
161
101
|
* Creates a session base ID.
|
|
162
102
|
* This method (rather than standard uuid generation methods) should be used to generate session IDs.
|
|
163
103
|
*/
|
|
164
104
|
function createSessionId() {
|
|
165
|
-
|
|
166
|
-
return ensureSessionUuid(uuid);
|
|
105
|
+
return ensureSessionUuid((0, UuidUtilities_1.generateStableId)());
|
|
167
106
|
}
|
|
168
107
|
exports.createSessionId = createSessionId;
|
|
169
108
|
/**
|
|
@@ -180,7 +119,7 @@ exports.numericUuidEquals = numericUuidEquals;
|
|
|
180
119
|
const maxUpperNumber = 2 ** 48 - 1;
|
|
181
120
|
/**
|
|
182
121
|
* Increments the uuid. `amount` must be a positive integer.
|
|
183
|
-
* @returns the result of incrementing the uuid by `amount
|
|
122
|
+
* @returns the result of incrementing the uuid by `amount`.
|
|
184
123
|
*/
|
|
185
124
|
function incrementUuid(uuid, amount) {
|
|
186
125
|
/*
|
|
@@ -205,10 +144,10 @@ function incrementUuid(uuid, amount) {
|
|
|
205
144
|
// The variant chunk itself also overflowed. We'll need to carry the overflow further, into the upper string region of the UUID.
|
|
206
145
|
const upperString = ChunkMath.Upper.parse(stringEntry);
|
|
207
146
|
const upperNumber = Number.parseInt(upperString, 16);
|
|
208
|
-
Common_1.assert(upperNumber <= maxUpperNumber);
|
|
147
|
+
(0, Common_1.assert)(upperNumber <= maxUpperNumber);
|
|
209
148
|
const newUpperNumber = upperNumber + 1;
|
|
210
149
|
if (newUpperNumber > maxUpperNumber) {
|
|
211
|
-
Common_1.fail('Exceeded maximum numeric UUID');
|
|
150
|
+
(0, Common_1.fail)('Exceeded maximum numeric UUID');
|
|
212
151
|
}
|
|
213
152
|
else {
|
|
214
153
|
// The variant chunk overflowed but the upper string region did not. Splice in the incremented string region.
|
|
@@ -301,9 +240,9 @@ var ChunkMath;
|
|
|
301
240
|
Lower.hyphenate = hyphenate;
|
|
302
241
|
})(Lower = ChunkMath.Lower || (ChunkMath.Lower = {}));
|
|
303
242
|
/**
|
|
304
|
-
* Returns the number representation of the given bits corresponding to the variant chunk. The value is derived by
|
|
305
|
-
* except for reserved bits (i.e. the variant bits).
|
|
306
|
-
* @param
|
|
243
|
+
* Returns the number representation of the given bits corresponding to the variant chunk. The value is derived by
|
|
244
|
+
* parsing all bits except for reserved bits (i.e. the variant bits).
|
|
245
|
+
* @param variantChunk - the variantChunk
|
|
307
246
|
*/
|
|
308
247
|
function getNumericValue(variantChunk) {
|
|
309
248
|
const variantChunkBits = Number.parseInt(variantChunk, 16);
|
|
@@ -335,7 +274,7 @@ var ChunkMath;
|
|
|
335
274
|
// 2. The numerically important bits (i.e. not the variant identifier bits vv which are constant) are extracted into a single number
|
|
336
275
|
const variantChunk = Variant.parse(stringEntry);
|
|
337
276
|
const variantNumber = getNumericValue(variantChunk);
|
|
338
|
-
Common_1.assert(variantNumber <= maxVariantNumber);
|
|
277
|
+
(0, Common_1.assert)(variantNumber <= maxVariantNumber);
|
|
339
278
|
// 3. Add one to the variant number to produce our new variant number.
|
|
340
279
|
const newVariantNumber = variantNumber + 1;
|
|
341
280
|
// 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;;;AAEH,+BAA+B;AAE/B,+BAA0B;AAC1B,sCAAyC;AAgBzC,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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M,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 { v4 } from 'uuid';\nimport { assert, fail } from '../Common';\nimport { SessionId, StableId } from '../Identifiers';\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 * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n * SSSSSSSS-SSSS-SSSS-SSS - array[0]: string\n * N NNNNNNNNNNNN - array[1]: integer\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 * Asserts that the supplied uuid is a stable ID.\n */\nexport function assertIsStableId(uuid: string): StableId {\n\tassert(isStableId(uuid), `${uuid} is not a StableId.`);\n\treturn uuid;\n}\n\nconst charCode0 = '0'.charCodeAt(0);\nconst charCode9 = '9'.charCodeAt(0);\nconst charCodea = 'a'.charCodeAt(0);\nconst charCodef = 'f'.charCodeAt(0);\nconst charCodeA = 'A'.charCodeAt(0);\nconst charCodeF = 'F'.charCodeAt(0);\n\n/**\n * Returns whether the supplied string is a v4 variant 2 uuid.\n */\nexport function isStableId(str: string): str is StableId {\n\tif (str.length !== 36) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23: {\n\t\t\t\tif (str.charAt(i) !== '-') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 14: {\n\t\t\t\tif (str.charAt(i) !== '4') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 19: {\n\t\t\t\tconst c = str.charAt(i);\n\t\t\t\tif (c !== '8' && c !== '9' && c !== 'a' && c !== 'b') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tconst code = str.charCodeAt(i);\n\t\t\t\tconst isUuidChar =\n\t\t\t\t\t(code >= charCode0 && code <= charCode9) ||\n\t\t\t\t\t(code >= charCodea && code <= charCodef) ||\n\t\t\t\t\t(code >= charCodeA && code <= charCodeF);\n\n\t\t\t\tif (!isUuidChar) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\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\tconst uuid = assertIsStableId(v4());\n\treturn ensureSessionUuid(uuid);\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\tassert(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\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/** the upper chunk, denoted by 'U's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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/** the variant chunk, denoted by 'V's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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/** the lower chunk, denoted by 'L's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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 parsing all bits\n\t * except for reserved bits (i.e. the variant bits).\n\t * @param variantChunkBits\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\tassert(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;;;AAEH,+BAA+B;AAE/B,sCAAyC;AAEzC,oDAAoD;AAepD,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,SAA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MAAM,cAAc,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,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 { assert, fail } from '../Common';\nimport { SessionId, StableId } from '../Identifiers';\nimport { generateStableId } from '../UuidUtilities';\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 * UUUUUUUU-UUUU-VUUU-vUUU-UUUUUUUUUUUU - the uuid\n * SSSSSSSS-SSSS-SSSS-SSS - array[0]: string\n * N NNNNNNNNNNNN - array[1]: integer\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\tassert(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\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/** the upper chunk, denoted by 'U's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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/** the variant chunk, denoted by 'V's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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/** the lower chunk, denoted by 'L's in UUUUUUUU-UUUU-VVVV-vVVL-LLLLLLLLLLLL */\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\tassert(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"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers';
|
|
6
|
+
/**
|
|
7
|
+
* Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
|
|
8
|
+
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
9
|
+
* that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
|
|
10
|
+
* Below is an example to illustrate how various mappings can arise:
|
|
11
|
+
*
|
|
12
|
+
* +- Creation Index
|
|
13
|
+
* / +- Locals
|
|
14
|
+
* / / +- Finals
|
|
15
|
+
* / / /
|
|
16
|
+
* ---+-----+----
|
|
17
|
+
* 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
|
|
18
|
+
* 1 | -2 | 1 -|
|
|
19
|
+
* 2 | | 2 -|
|
|
20
|
+
* 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
|
|
21
|
+
* 4 | | 4 -|
|
|
22
|
+
* 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
|
|
23
|
+
* 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.
|
|
24
|
+
* 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.
|
|
25
|
+
* 8 | | 13
|
|
26
|
+
* 9 | | 14
|
|
27
|
+
* 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.
|
|
28
|
+
*
|
|
29
|
+
* 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.
|
|
30
|
+
* These kinds of "gaps" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,
|
|
31
|
+
* which depends on receiving an ack/sequence number from the server. Given this context, "session space" can be thought of as:
|
|
32
|
+
*
|
|
33
|
+
* for each index in the range of IDs created by a session:
|
|
34
|
+
* the local form if it exists, otherwise the final form
|
|
35
|
+
*
|
|
36
|
+
* This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and
|
|
37
|
+
* final space) is uninterrupted by "gaps" and can be compactly represented by a (first, last) pair and is easily binary searched for
|
|
38
|
+
* normalization between local and final space.
|
|
39
|
+
*/
|
|
40
|
+
export declare class SessionIdNormalizer<TRangeObject> {
|
|
41
|
+
private readonly expensiveAsserts;
|
|
42
|
+
private nextLocalId;
|
|
43
|
+
private readonly idRanges;
|
|
44
|
+
constructor(expensiveAsserts?: boolean);
|
|
45
|
+
/**
|
|
46
|
+
* Converts the final ID to its session-space representation.
|
|
47
|
+
* This will be the corresponding local if a local form exists, and `finalId` otherwise.
|
|
48
|
+
*/
|
|
49
|
+
getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Converts the local ID to its corresponding final ID, if one exists.
|
|
52
|
+
*/
|
|
53
|
+
getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the index of the supplied session-space ID in the total range of IDs created by the session, if the ID was created
|
|
56
|
+
* by the session for this `SessionIdNormalizer`.
|
|
57
|
+
*/
|
|
58
|
+
getCreationIndex(finalId: FinalCompressedId): number | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the session-space ID at the supplied creation index, if one exists.
|
|
61
|
+
*/
|
|
62
|
+
getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined;
|
|
63
|
+
private static makeFinalRangesMap;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the last final ID known to this normalizer.
|
|
66
|
+
*/
|
|
67
|
+
getLastFinalId(): FinalCompressedId | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Registers and returns the next ID in local space with this normalizer. An example:
|
|
70
|
+
*
|
|
71
|
+
* Locals: [-1, -2, X, X]
|
|
72
|
+
* Finals: [ 0, 1, 2, 3]
|
|
73
|
+
* In this scenario, a call to this method would generate and return -5.
|
|
74
|
+
*/
|
|
75
|
+
addLocalId(): LocalCompressedId;
|
|
76
|
+
/**
|
|
77
|
+
* Registers a final ID with this normalizer.
|
|
78
|
+
* If there are any local IDs at the tip of session-space that do not have a corresponding final, it will be registered (aligned) with
|
|
79
|
+
* the first of those. Otherwise, will be registered as the next ID in session space in creation order. An example:
|
|
80
|
+
*
|
|
81
|
+
* Locals: [-1, -2, X, -4]
|
|
82
|
+
* Finals: [ 0, 1, 2, X]
|
|
83
|
+
* Calling `addFinalIds` with first === last === 5 results in the following:
|
|
84
|
+
* Locals: [-1, -2, X, -4]
|
|
85
|
+
* Finals: [ 0, 1, 2, 5]
|
|
86
|
+
* Calling `addFinalIds` with first === last === 6 results in the following:
|
|
87
|
+
* Locals: [-1, -2, X, -4, X]
|
|
88
|
+
* Finals: [ 0, 1, 2, 5, 6]
|
|
89
|
+
*
|
|
90
|
+
* Non-contiguous final IDs (i.e. the first final after a "gap" in final space) must always correspond to a local ID. For example,
|
|
91
|
+
* in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a
|
|
92
|
+
* non-contiguous final ID without a local form:
|
|
93
|
+
* Locals: [-1, -2, X, -4, X]
|
|
94
|
+
* Finals: [ 0, 1, 2, 5, 9]
|
|
95
|
+
* ^final ID 9 is not contiguous and does not have a corresponding local ID
|
|
96
|
+
*/
|
|
97
|
+
addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void;
|
|
98
|
+
/**
|
|
99
|
+
* Returns an enumerable of all session-space IDs known to this normalizer, in creation order.
|
|
100
|
+
*/
|
|
101
|
+
[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId>;
|
|
102
|
+
serialize(): SerializedSessionIdNormalizer;
|
|
103
|
+
static deserialize<TRangeObject>(serialized: SerializedSessionIdNormalizer, getRangeObject: (finalId: FinalCompressedId) => TRangeObject): SessionIdNormalizer<TRangeObject>;
|
|
104
|
+
equals(other: SessionIdNormalizer<TRangeObject>, compareRangeObjects?: (a: TRangeObject, b: TRangeObject) => boolean): boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Serialized table for normalizing IDs made by the local session.
|
|
108
|
+
*
|
|
109
|
+
* TODO: Move this into ID compressor persisted types when integrated.
|
|
110
|
+
*/
|
|
111
|
+
export interface SerializedSessionIdNormalizer {
|
|
112
|
+
readonly localRanges: readonly (readonly [
|
|
113
|
+
firstLocal: LocalCompressedId,
|
|
114
|
+
lastLocal: LocalCompressedId,
|
|
115
|
+
finalRanges?: readonly (readonly [
|
|
116
|
+
alignedLocal: LocalCompressedId,
|
|
117
|
+
firstFinal: FinalCompressedId,
|
|
118
|
+
lastFinal: FinalCompressedId
|
|
119
|
+
])[]
|
|
120
|
+
])[];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=SessionIdNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionIdNormalizer.d.ts","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAGhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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;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