@fluidframework/id-compressor 2.53.0 → 2.60.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/CHANGELOG.md +4 -0
- package/api-report/{id-compressor.legacy.alpha.api.md → id-compressor.legacy.beta.api.md} +11 -11
- package/dist/finalSpace.d.ts +2 -2
- package/dist/finalSpace.d.ts.map +1 -1
- package/dist/finalSpace.js.map +1 -1
- package/dist/idCompressor.d.ts +20 -17
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js +14 -13
- package/dist/idCompressor.js.map +1 -1
- package/dist/identifiers.d.ts +1 -1
- package/dist/identifiers.d.ts.map +1 -1
- package/dist/identifiers.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/persistanceUtilities.d.ts +1 -1
- package/dist/persistanceUtilities.d.ts.map +1 -1
- package/dist/persistanceUtilities.js.map +1 -1
- package/dist/sessionSpaceNormalizer.d.ts +1 -1
- package/dist/sessionSpaceNormalizer.d.ts.map +1 -1
- package/dist/sessionSpaceNormalizer.js.map +1 -1
- package/dist/sessions.d.ts +2 -2
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js.map +1 -1
- package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.spec.js.map +1 -1
- package/dist/test/idCompressorTestUtilities.d.ts +4 -4
- package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/dist/test/idCompressorTestUtilities.js +5 -2
- package/dist/test/idCompressorTestUtilities.js.map +1 -1
- package/dist/test/numericUuid.spec.js.map +1 -1
- package/dist/test/snapshots/summary.spec.js.map +1 -1
- package/dist/test/testCommon.d.ts +2 -2
- package/dist/test/testCommon.d.ts.map +1 -1
- package/dist/test/testCommon.js.map +1 -1
- package/dist/types/idCompressor.d.ts +3 -4
- package/dist/types/idCompressor.d.ts.map +1 -1
- package/dist/types/idCompressor.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/persisted-types/0.0.1.d.ts +4 -8
- package/dist/types/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/types/persisted-types/0.0.1.js.map +1 -1
- package/dist/types/persisted-types/index.d.ts +1 -1
- package/dist/types/persisted-types/index.d.ts.map +1 -1
- package/dist/types/persisted-types/index.js.map +1 -1
- package/dist/utilities.d.ts +3 -4
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +1 -2
- package/dist/utilities.js.map +1 -1
- package/lib/finalSpace.d.ts +2 -2
- package/lib/finalSpace.d.ts.map +1 -1
- package/lib/finalSpace.js.map +1 -1
- package/lib/idCompressor.d.ts +20 -17
- package/lib/idCompressor.d.ts.map +1 -1
- package/lib/idCompressor.js +14 -13
- package/lib/idCompressor.js.map +1 -1
- package/lib/identifiers.d.ts +1 -1
- package/lib/identifiers.d.ts.map +1 -1
- package/lib/identifiers.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/persistanceUtilities.d.ts +1 -1
- package/lib/persistanceUtilities.d.ts.map +1 -1
- package/lib/persistanceUtilities.js.map +1 -1
- package/lib/sessionSpaceNormalizer.d.ts +1 -1
- package/lib/sessionSpaceNormalizer.d.ts.map +1 -1
- package/lib/sessionSpaceNormalizer.js.map +1 -1
- package/lib/sessions.d.ts +2 -2
- package/lib/sessions.d.ts.map +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.spec.js.map +1 -1
- package/lib/test/idCompressorTestUtilities.d.ts +4 -4
- package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/idCompressorTestUtilities.js +5 -2
- package/lib/test/idCompressorTestUtilities.js.map +1 -1
- package/lib/test/numericUuid.spec.js.map +1 -1
- package/lib/test/snapshots/summary.spec.js.map +1 -1
- package/lib/test/testCommon.d.ts +2 -2
- package/lib/test/testCommon.d.ts.map +1 -1
- package/lib/test/testCommon.js.map +1 -1
- package/lib/types/idCompressor.d.ts +3 -4
- package/lib/types/idCompressor.d.ts.map +1 -1
- package/lib/types/idCompressor.js.map +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/persisted-types/0.0.1.d.ts +4 -8
- package/lib/types/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/types/persisted-types/0.0.1.js.map +1 -1
- package/lib/types/persisted-types/index.d.ts +1 -1
- package/lib/types/persisted-types/index.d.ts.map +1 -1
- package/lib/types/persisted-types/index.js.map +1 -1
- package/lib/utilities.d.ts +3 -4
- package/lib/utilities.d.ts.map +1 -1
- package/lib/utilities.js +1 -2
- package/lib/utilities.js.map +1 -1
- package/package.json +9 -9
- package/src/finalSpace.ts +2 -2
- package/src/idCompressor.ts +42 -49
- package/src/identifiers.ts +1 -1
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/persistanceUtilities.ts +1 -1
- package/src/sessionSpaceNormalizer.ts +1 -1
- package/src/sessions.ts +2 -2
- package/src/test/idCompressorTestUtilities.ts +18 -15
- package/src/test/testCommon.ts +2 -2
- package/src/types/idCompressor.ts +3 -4
- package/src/types/index.ts +3 -3
- package/src/types/persisted-types/0.0.1.ts +4 -8
- package/src/types/persisted-types/index.ts +1 -1
- package/src/utilities.ts +3 -4
|
@@ -5,24 +5,21 @@
|
|
|
5
5
|
import type { SessionId } from "../identifiers.js";
|
|
6
6
|
/**
|
|
7
7
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
8
|
-
* @legacy
|
|
9
|
-
* @alpha
|
|
8
|
+
* @legacy @beta
|
|
10
9
|
*/
|
|
11
10
|
export type SerializedIdCompressor = string & {
|
|
12
11
|
readonly _serializedIdCompressor: "8c73c57c-1cf4-4278-8915-6444cb4f6af5";
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
15
14
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
16
|
-
* @legacy
|
|
17
|
-
* @alpha
|
|
15
|
+
* @legacy @beta
|
|
18
16
|
*/
|
|
19
17
|
export type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {
|
|
20
18
|
readonly _noLocalState: "3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb";
|
|
21
19
|
};
|
|
22
20
|
/**
|
|
23
21
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
24
|
-
* @legacy
|
|
25
|
-
* @alpha
|
|
22
|
+
* @legacy @beta
|
|
26
23
|
*/
|
|
27
24
|
export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {
|
|
28
25
|
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
@@ -31,8 +28,7 @@ export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor &
|
|
|
31
28
|
* Data describing a range of session-local IDs (from a remote or local session).
|
|
32
29
|
*
|
|
33
30
|
* A range is composed of local IDs that were generated.
|
|
34
|
-
* @legacy
|
|
35
|
-
* @alpha
|
|
31
|
+
* @legacy @beta
|
|
36
32
|
*/
|
|
37
33
|
export interface IdCreationRange {
|
|
38
34
|
readonly sessionId: SessionId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/types/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/types/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG;IAC7C,QAAQ,CAAC,uBAAuB,EAAE,sCAAsC,CAAC;CACzE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IAC1E,QAAQ,CAAC,aAAa,EAAE,sCAAsC,CAAC;CAC/D,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wCAAwC,GAAG,sBAAsB,GAAG;IAC/E,QAAQ,CAAC,cAAc,EAAE,sCAAsC,CAAC;CAChE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE;QACd;;WAEG;QACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAE/B;;WAEG;QACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAEvB;;;;WAIG;QACH,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;QAEtC;;WAEG;QACH,QAAQ,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;KAC5D,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/types/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"../identifiers.js\";\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n * @legacy
|
|
1
|
+
{"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/types/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"../identifiers.js\";\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n * @legacy @beta\n */\nexport type SerializedIdCompressor = string & {\n\treadonly _serializedIdCompressor: \"8c73c57c-1cf4-4278-8915-6444cb4f6af5\";\n};\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n * @legacy @beta\n */\nexport type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {\n\treadonly _noLocalState: \"3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb\";\n};\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n * @legacy @beta\n */\nexport type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {\n\treadonly _hasLocalState: \"1281acae-6d14-47e7-bc92-71c8ee0819cb\";\n};\n\n/**\n * Data describing a range of session-local IDs (from a remote or local session).\n *\n * A range is composed of local IDs that were generated.\n * @legacy @beta\n */\nexport interface IdCreationRange {\n\treadonly sessionId: SessionId;\n\treadonly ids?: {\n\t\t/**\n\t\t * The gen count of the first ID in the range created by `sessionId.`\n\t\t */\n\t\treadonly firstGenCount: number;\n\n\t\t/**\n\t\t * The number of IDs created in the range created by `sessionId.`\n\t\t */\n\t\treadonly count: number;\n\n\t\t/**\n\t\t * The size of the ID cluster to create if `count` overflows the existing cluster for\n\t\t * `sessionId`, if one exists. This request will be respected, and the size of the cluster\n\t\t * will be equal to overflow + `requestedClusterSize`.\n\t\t */\n\t\treadonly requestedClusterSize: number;\n\n\t\t/**\n\t\t * The ranges of IDs that were allocated as local IDs in the range created by `sessionId.`\n\t\t */\n\t\treadonly localIdRanges: [genCount: number, count: number][];\n\t};\n}\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, } from "./0.0.1.js";
|
|
5
|
+
export type { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, } from "./0.0.1.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/persisted-types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/persisted-types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,GACxC,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/persisted-types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./0.0.1.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/persisted-types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./0.0.1.js\";\n"]}
|
package/lib/utilities.d.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { LocalCompressedId, NumericUuid } from "./identifiers.js";
|
|
6
|
-
import { SessionId, StableId } from "./types/index.js";
|
|
5
|
+
import type { LocalCompressedId, NumericUuid } from "./identifiers.js";
|
|
6
|
+
import type { SessionId, StableId } from "./types/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Generate a random session ID
|
|
9
|
-
* @legacy
|
|
10
|
-
* @alpha
|
|
9
|
+
* @legacy @beta
|
|
11
10
|
*/
|
|
12
11
|
export declare function createSessionId(): SessionId;
|
|
13
12
|
/**
|
package/lib/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAmB5D;;;GAGG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAG3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAG7D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAE3C;AAED;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;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAwB,EAAE,MAAc;IACzE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAgB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAc,EAAE,CAAc;IAClE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAc,EAAE,CAAc;IAC7D,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { v4 } from \"uuid\";\n\nimport { LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport { SessionId, StableId } from \"./types/index.js\";\n\nconst hexadecimalCharCodes = [...\"09afAF\"].map((c) => c.codePointAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number,\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/**\n * Generate a random session ID\n * @legacy\n * @alpha\n */\nexport function createSessionId(): SessionId {\n\treturn assertIsStableId(v4()) as SessionId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n * @internal\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), 0x4a3 /* Expected a StableId */);\n\treturn stableId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsSessionId(stableId: string): SessionId {\n\tassertIsStableId(stableId);\n\treturn stableId as SessionId;\n}\n\n/**\n * Generate a random stable ID\n * @internal\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n * @internal\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 char = str.charAt(i);\n\t\t\t\tif (char !== \"8\" && char !== \"9\" && char !== \"a\" && char !== \"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 codePoint = str.codePointAt(i);\n\t\t\t\tassert(codePoint !== undefined, 0xaaf /* Unexpected undefined code point */);\n\t\t\t\tif (!isHexadecimalCharacter(codePoint)) {\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 * A numeric comparator used for sorting in ascending order.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares bigints to form a strict partial ordering.\n */\nexport function compareBigints<T extends bigint>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\nexport function genCountFromLocalId(localId: LocalCompressedId): number {\n\treturn -localId;\n}\n\nexport function localIdFromGenCount(genCount: number): LocalCompressedId {\n\treturn -genCount as LocalCompressedId;\n}\n\n// xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx\nconst versionMask = 0x4n << (19n * 4n); // Version 4\nconst variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)\nconst upperMask = 0xffffffffffffn << (20n * 4n);\n// Upper mask when version/variant bits are removed\nconst strippedUpperMask = upperMask >> 6n;\nconst middieBittiesMask = 0xfffn << (16n * 4n);\n// Middie mask when version/variant bits are removed\nconst strippedMiddieBittiesMask = middieBittiesMask >> 2n;\n// Note: leading character should be 3 to mask at 0011\n// The more-significant half of the N nibble is used to denote the variant (10xx)\nconst lowerMask = 0x3fffffffffffffffn;\n\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuidU128 = BigInt(`0x${stableId.replace(/-/g, \"\")}`);\n\tconst upperMasked = uuidU128 & upperMask;\n\tconst middieBittiesMasked = uuidU128 & middieBittiesMask;\n\tconst lowerMasked = uuidU128 & lowerMask;\n\n\tconst upperMaskedPlaced = upperMasked >> 6n;\n\tconst middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;\n\n\tconst id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;\n\treturn id as NumericUuid;\n}\n\nexport function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId {\n\t// bitwise reverse transform\n\tconst upperMasked = (numericUuid & strippedUpperMask) << 6n;\n\tconst middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;\n\tconst lowerMasked = numericUuid & lowerMask;\n\tconst uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;\n\t// Pad to 32 characters, inserting leading zeroes if needed\n\tconst uuidString = uuidU128.toString(16).padStart(32, \"0\");\n\treturn `${uuidString.slice(0, 8)}-${uuidString.slice(8, 12)}-${uuidString.slice(\n\t\t12,\n\t\t16,\n\t)}-${uuidString.slice(16, 20)}-${uuidString.slice(20, 32)}` as StableId;\n}\n\nexport function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid {\n\treturn (numericUuid + BigInt(offset)) as NumericUuid;\n}\n\nexport function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a - b) as NumericUuid;\n}\n\nexport function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a + b) as NumericUuid;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAK1B,MAAM,oBAAoB,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAOrE,CAAC;AAEF,SAAS,sBAAsB,CAAC,QAAgB;IAC/C,OAAO,CACN,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO,gBAAgB,CAAC,EAAE,EAAE,CAAc,CAAC;AAC5C,CAAC;AAED;;;GAGG;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G,WAAW,GAAG,SAAS,CAAC;IAC5C,MAAM,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,GAAG,WAAW,GAAG,WAAW,CAAC;IAC7F,2DAA2D;IAC3D,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAC9E,EAAE,EACF,EAAE,CACF,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAc,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAwB,EAAE,MAAc;IACzE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAgB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAc,EAAE,CAAc;IAClE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAc,EAAE,CAAc;IAC7D,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { v4 } from \"uuid\";\n\nimport type { LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport type { SessionId, StableId } from \"./types/index.js\";\n\nconst hexadecimalCharCodes = [...\"09afAF\"].map((c) => c.codePointAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number,\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/**\n * Generate a random session ID\n * @legacy @beta\n */\nexport function createSessionId(): SessionId {\n\treturn assertIsStableId(v4()) as SessionId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n * @internal\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), 0x4a3 /* Expected a StableId */);\n\treturn stableId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsSessionId(stableId: string): SessionId {\n\tassertIsStableId(stableId);\n\treturn stableId as SessionId;\n}\n\n/**\n * Generate a random stable ID\n * @internal\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n * @internal\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 char = str.charAt(i);\n\t\t\t\tif (char !== \"8\" && char !== \"9\" && char !== \"a\" && char !== \"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 codePoint = str.codePointAt(i);\n\t\t\t\tassert(codePoint !== undefined, 0xaaf /* Unexpected undefined code point */);\n\t\t\t\tif (!isHexadecimalCharacter(codePoint)) {\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 * A numeric comparator used for sorting in ascending order.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares bigints to form a strict partial ordering.\n */\nexport function compareBigints<T extends bigint>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\nexport function genCountFromLocalId(localId: LocalCompressedId): number {\n\treturn -localId;\n}\n\nexport function localIdFromGenCount(genCount: number): LocalCompressedId {\n\treturn -genCount as LocalCompressedId;\n}\n\n// xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx\nconst versionMask = 0x4n << (19n * 4n); // Version 4\nconst variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)\nconst upperMask = 0xffffffffffffn << (20n * 4n);\n// Upper mask when version/variant bits are removed\nconst strippedUpperMask = upperMask >> 6n;\nconst middieBittiesMask = 0xfffn << (16n * 4n);\n// Middie mask when version/variant bits are removed\nconst strippedMiddieBittiesMask = middieBittiesMask >> 2n;\n// Note: leading character should be 3 to mask at 0011\n// The more-significant half of the N nibble is used to denote the variant (10xx)\nconst lowerMask = 0x3fffffffffffffffn;\n\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuidU128 = BigInt(`0x${stableId.replace(/-/g, \"\")}`);\n\tconst upperMasked = uuidU128 & upperMask;\n\tconst middieBittiesMasked = uuidU128 & middieBittiesMask;\n\tconst lowerMasked = uuidU128 & lowerMask;\n\n\tconst upperMaskedPlaced = upperMasked >> 6n;\n\tconst middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;\n\n\tconst id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;\n\treturn id as NumericUuid;\n}\n\nexport function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId {\n\t// bitwise reverse transform\n\tconst upperMasked = (numericUuid & strippedUpperMask) << 6n;\n\tconst middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;\n\tconst lowerMasked = numericUuid & lowerMask;\n\tconst uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;\n\t// Pad to 32 characters, inserting leading zeroes if needed\n\tconst uuidString = uuidU128.toString(16).padStart(32, \"0\");\n\treturn `${uuidString.slice(0, 8)}-${uuidString.slice(8, 12)}-${uuidString.slice(\n\t\t12,\n\t\t16,\n\t)}-${uuidString.slice(16, 20)}-${uuidString.slice(20, 32)}` as StableId;\n}\n\nexport function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid {\n\treturn (numericUuid + BigInt(offset)) as NumericUuid;\n}\n\nexport function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a - b) as NumericUuid;\n}\n\nexport function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a + b) as NumericUuid;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/id-compressor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"description": "ID compressor",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,24 +81,24 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "~2.
|
|
85
|
-
"@fluidframework/core-interfaces": "~2.
|
|
86
|
-
"@fluidframework/core-utils": "~2.
|
|
87
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
84
|
+
"@fluid-internal/client-utils": "~2.60.0",
|
|
85
|
+
"@fluidframework/core-interfaces": "~2.60.0",
|
|
86
|
+
"@fluidframework/core-utils": "~2.60.0",
|
|
87
|
+
"@fluidframework/telemetry-utils": "~2.60.0",
|
|
88
88
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
89
89
|
"uuid": "^11.1.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
93
93
|
"@biomejs/biome": "~1.9.3",
|
|
94
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
95
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
94
|
+
"@fluid-internal/mocha-test-setup": "~2.60.0",
|
|
95
|
+
"@fluid-private/stochastic-test-utils": "~2.60.0",
|
|
96
96
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
97
97
|
"@fluid-tools/build-cli": "^0.57.0",
|
|
98
98
|
"@fluidframework/build-common": "^2.0.3",
|
|
99
99
|
"@fluidframework/build-tools": "^0.57.0",
|
|
100
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
101
|
-
"@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.
|
|
100
|
+
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
101
|
+
"@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.53.0",
|
|
102
102
|
"@microsoft/api-extractor": "7.52.8",
|
|
103
103
|
"@types/mocha": "^10.0.10",
|
|
104
104
|
"@types/node": "^18.19.0",
|
package/src/finalSpace.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
|
-
import { FinalCompressedId } from "./identifiers.js";
|
|
8
|
+
import type { FinalCompressedId } from "./identifiers.js";
|
|
9
9
|
import {
|
|
10
|
-
IdCluster,
|
|
10
|
+
type IdCluster,
|
|
11
11
|
clustersEqual,
|
|
12
12
|
lastAllocatedFinal,
|
|
13
13
|
lastFinalizedFinal,
|
package/src/idCompressor.ts
CHANGED
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
|
|
7
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
9
|
import {
|
|
10
|
-
ITelemetryLoggerExt,
|
|
10
|
+
type ITelemetryLoggerExt,
|
|
11
11
|
LoggingError,
|
|
12
12
|
createChildLogger,
|
|
13
13
|
} from "@fluidframework/telemetry-utils/internal";
|
|
14
14
|
|
|
15
15
|
import { FinalSpace } from "./finalSpace.js";
|
|
16
16
|
import {
|
|
17
|
-
FinalCompressedId,
|
|
18
|
-
LocalCompressedId,
|
|
19
|
-
NumericUuid,
|
|
17
|
+
type FinalCompressedId,
|
|
18
|
+
type LocalCompressedId,
|
|
19
|
+
type NumericUuid,
|
|
20
20
|
isFinalId,
|
|
21
21
|
} from "./identifiers.js";
|
|
22
22
|
import {
|
|
23
|
-
Index,
|
|
23
|
+
type Index,
|
|
24
24
|
readBoolean,
|
|
25
25
|
readNumber,
|
|
26
26
|
readNumericUuid,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "./persistanceUtilities.js";
|
|
31
31
|
import { SessionSpaceNormalizer } from "./sessionSpaceNormalizer.js";
|
|
32
32
|
import {
|
|
33
|
-
IdCluster,
|
|
33
|
+
type IdCluster,
|
|
34
34
|
Session,
|
|
35
35
|
Sessions,
|
|
36
36
|
getAlignedFinal,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
lastFinalizedFinal,
|
|
39
39
|
lastFinalizedLocal,
|
|
40
40
|
} from "./sessions.js";
|
|
41
|
-
import {
|
|
41
|
+
import type {
|
|
42
42
|
IIdCompressor,
|
|
43
43
|
IIdCompressorCore,
|
|
44
44
|
IdCreationRange,
|
|
@@ -123,7 +123,7 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
123
123
|
|
|
124
124
|
public constructor(
|
|
125
125
|
localSessionIdOrDeserialized: SessionId | Sessions,
|
|
126
|
-
private readonly logger
|
|
126
|
+
private readonly logger: ITelemetryLoggerExt | undefined,
|
|
127
127
|
) {
|
|
128
128
|
if (typeof localSessionIdOrDeserialized === "string") {
|
|
129
129
|
this.localSessionId = localSessionIdOrDeserialized;
|
|
@@ -625,26 +625,19 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
public static deserialize(
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
628
|
+
params:
|
|
629
|
+
| {
|
|
630
|
+
serialized: SerializedIdCompressorWithOngoingSession;
|
|
631
|
+
logger?: ITelemetryLoggerExt | undefined;
|
|
632
|
+
newSessionId?: never;
|
|
633
|
+
}
|
|
634
|
+
| {
|
|
635
|
+
serialized: SerializedIdCompressorWithNoSession;
|
|
636
|
+
newSessionId: SessionId;
|
|
637
|
+
logger?: ITelemetryLoggerExt | undefined;
|
|
638
|
+
},
|
|
639
639
|
): IdCompressor {
|
|
640
|
-
|
|
641
|
-
let logger: ITelemetryLoggerExt | undefined;
|
|
642
|
-
if (typeof loggerOrSessionId === "string") {
|
|
643
|
-
sessionId = loggerOrSessionId;
|
|
644
|
-
} else {
|
|
645
|
-
logger = loggerOrSessionId;
|
|
646
|
-
}
|
|
647
|
-
|
|
640
|
+
const { serialized, newSessionId, logger } = params;
|
|
648
641
|
const buffer = stringToBuffer(serialized, "base64");
|
|
649
642
|
const index: Index = {
|
|
650
643
|
index: 0,
|
|
@@ -657,7 +650,7 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
657
650
|
throw new Error("IdCompressor version 1.0 is no longer supported.");
|
|
658
651
|
}
|
|
659
652
|
case 2: {
|
|
660
|
-
return IdCompressor.deserialize2_0(index,
|
|
653
|
+
return IdCompressor.deserialize2_0(index, newSessionId, logger);
|
|
661
654
|
}
|
|
662
655
|
default: {
|
|
663
656
|
throw new Error("Unknown IdCompressor serialized version.");
|
|
@@ -667,8 +660,8 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
667
660
|
|
|
668
661
|
static deserialize2_0(
|
|
669
662
|
index: Index,
|
|
670
|
-
sessionId
|
|
671
|
-
logger
|
|
663
|
+
sessionId: SessionId | undefined,
|
|
664
|
+
logger: ITelemetryLoggerExt | undefined,
|
|
672
665
|
): IdCompressor {
|
|
673
666
|
const hasLocalState = readBoolean(index);
|
|
674
667
|
const sessionCount = readNumber(index);
|
|
@@ -751,8 +744,7 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
751
744
|
|
|
752
745
|
/**
|
|
753
746
|
* Create a new {@link IIdCompressor}.
|
|
754
|
-
* @legacy
|
|
755
|
-
* @alpha
|
|
747
|
+
* @legacy @beta
|
|
756
748
|
*/
|
|
757
749
|
export function createIdCompressor(
|
|
758
750
|
logger?: ITelemetryBaseLogger,
|
|
@@ -760,8 +752,7 @@ export function createIdCompressor(
|
|
|
760
752
|
/**
|
|
761
753
|
* Create a new {@link IIdCompressor}.
|
|
762
754
|
* @param sessionId - The seed ID for the compressor.
|
|
763
|
-
* @legacy
|
|
764
|
-
* @alpha
|
|
755
|
+
* @legacy @beta
|
|
765
756
|
*/
|
|
766
757
|
export function createIdCompressor(
|
|
767
758
|
sessionId: SessionId,
|
|
@@ -793,8 +784,7 @@ export function createIdCompressor(
|
|
|
793
784
|
|
|
794
785
|
/**
|
|
795
786
|
* Deserializes the supplied state into an ID compressor.
|
|
796
|
-
* @legacy
|
|
797
|
-
* @alpha
|
|
787
|
+
* @legacy @beta
|
|
798
788
|
*/
|
|
799
789
|
export function deserializeIdCompressor(
|
|
800
790
|
serialized: SerializedIdCompressorWithOngoingSession,
|
|
@@ -802,8 +792,7 @@ export function deserializeIdCompressor(
|
|
|
802
792
|
): IIdCompressor & IIdCompressorCore;
|
|
803
793
|
/**
|
|
804
794
|
* Deserializes the supplied state into an ID compressor.
|
|
805
|
-
* @legacy
|
|
806
|
-
* @alpha
|
|
795
|
+
* @legacy @beta
|
|
807
796
|
*/
|
|
808
797
|
export function deserializeIdCompressor(
|
|
809
798
|
serialized: SerializedIdCompressorWithNoSession,
|
|
@@ -812,19 +801,23 @@ export function deserializeIdCompressor(
|
|
|
812
801
|
): IIdCompressor & IIdCompressorCore;
|
|
813
802
|
export function deserializeIdCompressor(
|
|
814
803
|
serialized: SerializedIdCompressor | SerializedIdCompressorWithNoSession,
|
|
815
|
-
sessionIdOrLogger
|
|
816
|
-
|
|
804
|
+
sessionIdOrLogger: SessionId | ITelemetryLoggerExt | undefined,
|
|
805
|
+
loggerOrUndefined?: ITelemetryLoggerExt,
|
|
817
806
|
): IIdCompressor & IIdCompressorCore {
|
|
818
807
|
if (typeof sessionIdOrLogger === "string") {
|
|
819
|
-
return IdCompressor.deserialize(
|
|
820
|
-
serialized as SerializedIdCompressorWithNoSession,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
);
|
|
808
|
+
return IdCompressor.deserialize({
|
|
809
|
+
serialized: serialized as SerializedIdCompressorWithNoSession,
|
|
810
|
+
logger: loggerOrUndefined,
|
|
811
|
+
newSessionId: sessionIdOrLogger,
|
|
812
|
+
});
|
|
824
813
|
}
|
|
825
814
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
logger
|
|
815
|
+
assert(
|
|
816
|
+
loggerOrUndefined === undefined,
|
|
817
|
+
0xc2d /* logger would be in sessionIdOrLogger in this codepath */,
|
|
829
818
|
);
|
|
819
|
+
return IdCompressor.deserialize({
|
|
820
|
+
serialized: serialized as SerializedIdCompressorWithOngoingSession,
|
|
821
|
+
logger: sessionIdOrLogger,
|
|
822
|
+
});
|
|
830
823
|
}
|
package/src/identifiers.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { OpSpaceCompressedId, SessionSpaceCompressedId } from "./types/index.js";
|
|
6
|
+
import type { OpSpaceCompressedId, SessionSpaceCompressedId } from "./types/index.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).
|
package/src/index.ts
CHANGED
package/src/packageVersion.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/* eslint-disable no-bitwise */
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
|
|
9
|
-
import { NumericUuid } from "./identifiers.js";
|
|
9
|
+
import type { NumericUuid } from "./identifiers.js";
|
|
10
10
|
|
|
11
11
|
const halfNumeric = BigInt("0xFFFFFFFFFFFFFFFF");
|
|
12
12
|
const sixtyFour = BigInt(64);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
8
|
import { AppendOnlySortedMap } from "./appendOnlySortedMap.js";
|
|
9
|
-
import { LocalCompressedId } from "./identifiers.js";
|
|
9
|
+
import type { LocalCompressedId } from "./identifiers.js";
|
|
10
10
|
import { compareFiniteNumbers, genCountFromLocalId } from "./utilities.js";
|
|
11
11
|
|
|
12
12
|
/**
|
package/src/sessions.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { BTree } from "@tylerbu/sorted-btree-es6";
|
|
8
8
|
|
|
9
|
-
import { FinalCompressedId, LocalCompressedId, NumericUuid } from "./identifiers.js";
|
|
10
|
-
import { SessionId, StableId } from "./types/index.js";
|
|
9
|
+
import type { FinalCompressedId, LocalCompressedId, NumericUuid } from "./identifiers.js";
|
|
10
|
+
import type { SessionId, StableId } from "./types/index.js";
|
|
11
11
|
import {
|
|
12
12
|
compareBigints,
|
|
13
13
|
genCountFromLocalId,
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import { strict as assert } from "node:assert";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
BaseFuzzTestState,
|
|
10
|
-
Generator,
|
|
11
|
-
SaveInfo,
|
|
9
|
+
type BaseFuzzTestState,
|
|
10
|
+
type Generator,
|
|
11
|
+
type SaveInfo,
|
|
12
12
|
createWeightedGenerator,
|
|
13
13
|
interleave,
|
|
14
14
|
makeRandom,
|
|
@@ -16,27 +16,27 @@ import {
|
|
|
16
16
|
repeat,
|
|
17
17
|
take,
|
|
18
18
|
} from "@fluid-private/stochastic-test-utils";
|
|
19
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
19
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
20
20
|
|
|
21
21
|
import { IdCompressor } from "../idCompressor.js";
|
|
22
22
|
import {
|
|
23
23
|
type IIdCompressor,
|
|
24
24
|
type IIdCompressorCore,
|
|
25
|
-
IdCreationRange,
|
|
26
|
-
OpSpaceCompressedId,
|
|
27
|
-
SerializedIdCompressorWithNoSession,
|
|
28
|
-
SerializedIdCompressorWithOngoingSession,
|
|
29
|
-
SessionId,
|
|
30
|
-
SessionSpaceCompressedId,
|
|
31
|
-
StableId,
|
|
25
|
+
type IdCreationRange,
|
|
26
|
+
type OpSpaceCompressedId,
|
|
27
|
+
type SerializedIdCompressorWithNoSession,
|
|
28
|
+
type SerializedIdCompressorWithOngoingSession,
|
|
29
|
+
type SessionId,
|
|
30
|
+
type SessionSpaceCompressedId,
|
|
31
|
+
type StableId,
|
|
32
32
|
createIdCompressor,
|
|
33
33
|
} from "../index.js";
|
|
34
34
|
import { SessionSpaceNormalizer } from "../sessionSpaceNormalizer.js";
|
|
35
35
|
import { assertIsSessionId, createSessionId, localIdFromGenCount } from "../utilities.js";
|
|
36
36
|
|
|
37
37
|
import {
|
|
38
|
-
FinalCompressedId,
|
|
39
|
-
ReadonlyIdCompressor,
|
|
38
|
+
type FinalCompressedId,
|
|
39
|
+
type ReadonlyIdCompressor,
|
|
40
40
|
fail,
|
|
41
41
|
getOrCreate,
|
|
42
42
|
incrementStableId,
|
|
@@ -730,12 +730,15 @@ export function roundtrip(
|
|
|
730
730
|
const capacity: number = getClusterSize(compressor);
|
|
731
731
|
if (withSession) {
|
|
732
732
|
const serialized = compressor.serialize(withSession);
|
|
733
|
-
const roundtripped = IdCompressor.deserialize(serialized);
|
|
733
|
+
const roundtripped = IdCompressor.deserialize({ serialized });
|
|
734
734
|
modifyClusterSize(roundtripped, capacity);
|
|
735
735
|
return [serialized, roundtripped];
|
|
736
736
|
} else {
|
|
737
737
|
const nonLocalSerialized = compressor.serialize(withSession);
|
|
738
|
-
const roundtripped = IdCompressor.deserialize(
|
|
738
|
+
const roundtripped = IdCompressor.deserialize({
|
|
739
|
+
serialized: nonLocalSerialized,
|
|
740
|
+
newSessionId: createSessionId(),
|
|
741
|
+
});
|
|
739
742
|
modifyClusterSize(roundtripped, capacity);
|
|
740
743
|
return [nonLocalSerialized, roundtripped];
|
|
741
744
|
}
|
package/src/test/testCommon.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
|
-
import { IdCompressor } from "../idCompressor.js";
|
|
9
|
-
import { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from "../index.js";
|
|
8
|
+
import type { IdCompressor } from "../idCompressor.js";
|
|
9
|
+
import type { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from "../index.js";
|
|
10
10
|
import {
|
|
11
11
|
numericUuidFromStableId,
|
|
12
12
|
offsetNumericUuid,
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
OpSpaceCompressedId,
|
|
8
8
|
SessionId,
|
|
9
9
|
SessionSpaceCompressedId,
|
|
10
10
|
StableId,
|
|
11
11
|
} from "./identifiers.js";
|
|
12
|
-
import {
|
|
12
|
+
import type {
|
|
13
13
|
IdCreationRange,
|
|
14
14
|
SerializedIdCompressorWithNoSession,
|
|
15
15
|
SerializedIdCompressorWithOngoingSession,
|
|
@@ -75,8 +75,7 @@ import {
|
|
|
75
75
|
*
|
|
76
76
|
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
77
77
|
* should use op-space IDs.
|
|
78
|
-
* @legacy
|
|
79
|
-
* @alpha
|
|
78
|
+
* @legacy @beta
|
|
80
79
|
*/
|
|
81
80
|
export interface IIdCompressorCore {
|
|
82
81
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export type {
|
|
7
7
|
IdCreationRange,
|
|
8
8
|
SerializedIdCompressor,
|
|
9
9
|
SerializedIdCompressorWithNoSession,
|
|
10
10
|
SerializedIdCompressorWithOngoingSession,
|
|
11
11
|
} from "./persisted-types/index.js";
|
|
12
12
|
|
|
13
|
-
export { IIdCompressorCore, IIdCompressor } from "./idCompressor.js";
|
|
13
|
+
export type { IIdCompressorCore, IIdCompressor } from "./idCompressor.js";
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export type {
|
|
16
16
|
SessionSpaceCompressedId,
|
|
17
17
|
OpSpaceCompressedId,
|
|
18
18
|
SessionId,
|
|
@@ -7,8 +7,7 @@ import type { SessionId } from "../identifiers.js";
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
10
|
-
* @legacy
|
|
11
|
-
* @alpha
|
|
10
|
+
* @legacy @beta
|
|
12
11
|
*/
|
|
13
12
|
export type SerializedIdCompressor = string & {
|
|
14
13
|
readonly _serializedIdCompressor: "8c73c57c-1cf4-4278-8915-6444cb4f6af5";
|
|
@@ -16,8 +15,7 @@ export type SerializedIdCompressor = string & {
|
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
19
|
-
* @legacy
|
|
20
|
-
* @alpha
|
|
18
|
+
* @legacy @beta
|
|
21
19
|
*/
|
|
22
20
|
export type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {
|
|
23
21
|
readonly _noLocalState: "3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb";
|
|
@@ -25,8 +23,7 @@ export type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
28
|
-
* @legacy
|
|
29
|
-
* @alpha
|
|
26
|
+
* @legacy @beta
|
|
30
27
|
*/
|
|
31
28
|
export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {
|
|
32
29
|
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
@@ -36,8 +33,7 @@ export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor &
|
|
|
36
33
|
* Data describing a range of session-local IDs (from a remote or local session).
|
|
37
34
|
*
|
|
38
35
|
* A range is composed of local IDs that were generated.
|
|
39
|
-
* @legacy
|
|
40
|
-
* @alpha
|
|
36
|
+
* @legacy @beta
|
|
41
37
|
*/
|
|
42
38
|
export interface IdCreationRange {
|
|
43
39
|
readonly sessionId: SessionId;
|