@fluidframework/id-compressor 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.1.0.0.232845
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/api-report/id-compressor.api.md +3 -40
- package/dist/id-compressor-alpha.d.ts +3 -65
- package/dist/id-compressor-beta.d.ts +1 -2
- package/dist/id-compressor-public.d.ts +1 -2
- package/dist/id-compressor-untrimmed.d.ts +3 -65
- package/dist/idCompressor.d.ts +9 -19
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js +34 -33
- package/dist/idCompressor.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- 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/tsdoc-metadata.json +1 -1
- package/lib/id-compressor-alpha.d.mts +3 -65
- package/lib/id-compressor-beta.d.mts +1 -2
- package/lib/id-compressor-public.d.mts +1 -2
- package/lib/id-compressor-untrimmed.d.mts +3 -65
- package/lib/idCompressor.d.mts +9 -19
- package/lib/idCompressor.d.mts.map +1 -1
- package/lib/idCompressor.mjs +34 -33
- package/lib/idCompressor.mjs.map +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/packageVersion.d.mts +1 -1
- package/lib/packageVersion.mjs +1 -1
- package/lib/packageVersion.mjs.map +1 -1
- package/package.json +10 -9
- package/src/idCompressor.ts +53 -51
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
7
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
8
|
+
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
8
9
|
|
|
9
10
|
// @internal
|
|
10
11
|
export function assertIsStableId(stableId: string): StableId;
|
|
@@ -19,52 +20,14 @@ export function createIdCompressor(sessionId: SessionId, logger?: ITelemetryBase
|
|
|
19
20
|
export function createSessionId(): SessionId;
|
|
20
21
|
|
|
21
22
|
// @alpha
|
|
22
|
-
export function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession): IIdCompressor & IIdCompressorCore;
|
|
23
|
+
export function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
23
24
|
|
|
24
25
|
// @alpha
|
|
25
|
-
export function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IIdCompressor & IIdCompressorCore;
|
|
26
|
+
export function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
26
27
|
|
|
27
28
|
// @internal
|
|
28
29
|
export function generateStableId(): StableId;
|
|
29
30
|
|
|
30
|
-
// @alpha @deprecated
|
|
31
|
-
export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
32
|
-
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
33
|
-
// @deprecated (undocumented)
|
|
34
|
-
static create(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
35
|
-
// @deprecated (undocumented)
|
|
36
|
-
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
37
|
-
// (undocumented)
|
|
38
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
39
|
-
// (undocumented)
|
|
40
|
-
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
41
|
-
// (undocumented)
|
|
42
|
-
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
43
|
-
// (undocumented)
|
|
44
|
-
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
45
|
-
// (undocumented)
|
|
46
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
47
|
-
// (undocumented)
|
|
48
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
49
|
-
// (undocumented)
|
|
50
|
-
readonly localSessionId: SessionId;
|
|
51
|
-
static readonly maxClusterSize: number;
|
|
52
|
-
// (undocumented)
|
|
53
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
54
|
-
// (undocumented)
|
|
55
|
-
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
56
|
-
// (undocumented)
|
|
57
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
58
|
-
// (undocumented)
|
|
59
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
60
|
-
// (undocumented)
|
|
61
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
62
|
-
// (undocumented)
|
|
63
|
-
takeNextCreationRange(): IdCreationRange;
|
|
64
|
-
// (undocumented)
|
|
65
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
31
|
// @alpha
|
|
69
32
|
export interface IdCreationRange {
|
|
70
33
|
// (undocumented)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
2
3
|
|
|
3
4
|
/* Excluded from this release type: assertIsStableId */
|
|
4
5
|
|
|
@@ -25,79 +26,16 @@ export declare function createSessionId(): SessionId;
|
|
|
25
26
|
* Deserializes the supplied state into an ID compressor.
|
|
26
27
|
* @alpha
|
|
27
28
|
*/
|
|
28
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession): IIdCompressor & IIdCompressorCore;
|
|
29
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Deserializes the supplied state into an ID compressor.
|
|
32
33
|
* @alpha
|
|
33
34
|
*/
|
|
34
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IIdCompressor & IIdCompressorCore;
|
|
35
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
35
36
|
|
|
36
37
|
/* Excluded from this release type: generateStableId */
|
|
37
38
|
|
|
38
|
-
/**
|
|
39
|
-
* See {@link IIdCompressor} and {@link IIdCompressorCore}
|
|
40
|
-
*
|
|
41
|
-
* @alpha
|
|
42
|
-
*
|
|
43
|
-
* @deprecated Not intended for public use and will be removed from the public API in the future.
|
|
44
|
-
* Use `createIdCompressor` instead.
|
|
45
|
-
*/
|
|
46
|
-
export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
47
|
-
private readonly logger?;
|
|
48
|
-
/**
|
|
49
|
-
* Max allowed initial cluster size.
|
|
50
|
-
*/
|
|
51
|
-
static readonly maxClusterSize: number;
|
|
52
|
-
readonly localSessionId: SessionId;
|
|
53
|
-
private readonly localSession;
|
|
54
|
-
private readonly normalizer;
|
|
55
|
-
private localGenCount;
|
|
56
|
-
private nextRangeBaseGenCount;
|
|
57
|
-
private readonly sessions;
|
|
58
|
-
private readonly finalSpace;
|
|
59
|
-
/**
|
|
60
|
-
* Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
|
|
61
|
-
* Eventually, this can be adjusted dynamically to have cluster reservation policies that
|
|
62
|
-
* optimize the number of eager finals.
|
|
63
|
-
* It is not readonly as it is accessed by tests for clear-box testing.
|
|
64
|
-
*/
|
|
65
|
-
private nextRequestedClusterSize;
|
|
66
|
-
private telemetryLocalIdCount;
|
|
67
|
-
private telemetryEagerFinalIdCount;
|
|
68
|
-
private ongoingGhostSession?;
|
|
69
|
-
private constructor();
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
72
|
-
*/
|
|
73
|
-
static create(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
76
|
-
*/
|
|
77
|
-
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
78
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
79
|
-
/**
|
|
80
|
-
* {@inheritdoc IIdCompressorCore.beginGhostSession}
|
|
81
|
-
*/
|
|
82
|
-
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
83
|
-
private generateNextLocalId;
|
|
84
|
-
takeNextCreationRange(): IdCreationRange;
|
|
85
|
-
private static assertValidRange;
|
|
86
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
87
|
-
private addEmptyCluster;
|
|
88
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
89
|
-
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
90
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
91
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
92
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
93
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
94
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
95
|
-
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
96
|
-
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
97
|
-
private static deserialize2_0;
|
|
98
|
-
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
39
|
/**
|
|
102
40
|
* Data describing a range of session-local IDs (from a remote or local session).
|
|
103
41
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
2
3
|
|
|
3
4
|
/* Excluded from this release type: assertIsStableId */
|
|
4
5
|
|
|
@@ -10,8 +11,6 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
10
11
|
|
|
11
12
|
/* Excluded from this release type: generateStableId */
|
|
12
13
|
|
|
13
|
-
/* Excluded from this release type: IdCompressor */
|
|
14
|
-
|
|
15
14
|
/* Excluded from this release type: IdCreationRange */
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
2
3
|
|
|
3
4
|
/* Excluded from this release type: assertIsStableId */
|
|
4
5
|
|
|
@@ -10,8 +11,6 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
10
11
|
|
|
11
12
|
/* Excluded from this release type: generateStableId */
|
|
12
13
|
|
|
13
|
-
/* Excluded from this release type: IdCompressor */
|
|
14
|
-
|
|
15
14
|
/* Excluded from this release type: IdCreationRange */
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Asserts that the given string is a stable ID.
|
|
@@ -29,13 +30,13 @@ export declare function createSessionId(): SessionId;
|
|
|
29
30
|
* Deserializes the supplied state into an ID compressor.
|
|
30
31
|
* @alpha
|
|
31
32
|
*/
|
|
32
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession): IIdCompressor & IIdCompressorCore;
|
|
33
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Deserializes the supplied state into an ID compressor.
|
|
36
37
|
* @alpha
|
|
37
38
|
*/
|
|
38
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IIdCompressor & IIdCompressorCore;
|
|
39
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Generate a random stable ID
|
|
@@ -43,69 +44,6 @@ export declare function deserializeIdCompressor(serialized: SerializedIdCompress
|
|
|
43
44
|
*/
|
|
44
45
|
export declare function generateStableId(): StableId;
|
|
45
46
|
|
|
46
|
-
/**
|
|
47
|
-
* See {@link IIdCompressor} and {@link IIdCompressorCore}
|
|
48
|
-
*
|
|
49
|
-
* @alpha
|
|
50
|
-
*
|
|
51
|
-
* @deprecated Not intended for public use and will be removed from the public API in the future.
|
|
52
|
-
* Use `createIdCompressor` instead.
|
|
53
|
-
*/
|
|
54
|
-
export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
55
|
-
private readonly logger?;
|
|
56
|
-
/**
|
|
57
|
-
* Max allowed initial cluster size.
|
|
58
|
-
*/
|
|
59
|
-
static readonly maxClusterSize: number;
|
|
60
|
-
readonly localSessionId: SessionId;
|
|
61
|
-
private readonly localSession;
|
|
62
|
-
private readonly normalizer;
|
|
63
|
-
private localGenCount;
|
|
64
|
-
private nextRangeBaseGenCount;
|
|
65
|
-
private readonly sessions;
|
|
66
|
-
private readonly finalSpace;
|
|
67
|
-
/**
|
|
68
|
-
* Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
|
|
69
|
-
* Eventually, this can be adjusted dynamically to have cluster reservation policies that
|
|
70
|
-
* optimize the number of eager finals.
|
|
71
|
-
* It is not readonly as it is accessed by tests for clear-box testing.
|
|
72
|
-
*/
|
|
73
|
-
private nextRequestedClusterSize;
|
|
74
|
-
private telemetryLocalIdCount;
|
|
75
|
-
private telemetryEagerFinalIdCount;
|
|
76
|
-
private ongoingGhostSession?;
|
|
77
|
-
private constructor();
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
80
|
-
*/
|
|
81
|
-
static create(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
84
|
-
*/
|
|
85
|
-
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
86
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
87
|
-
/**
|
|
88
|
-
* {@inheritdoc IIdCompressorCore.beginGhostSession}
|
|
89
|
-
*/
|
|
90
|
-
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
91
|
-
private generateNextLocalId;
|
|
92
|
-
takeNextCreationRange(): IdCreationRange;
|
|
93
|
-
private static assertValidRange;
|
|
94
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
95
|
-
private addEmptyCluster;
|
|
96
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
97
|
-
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
98
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
99
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
100
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
101
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
102
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
103
|
-
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
104
|
-
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
105
|
-
private static deserialize2_0;
|
|
106
|
-
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
47
|
/**
|
|
110
48
|
* Data describing a range of session-local IDs (from a remote or local session).
|
|
111
49
|
*
|
package/dist/idCompressor.d.ts
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
6
7
|
import { IdCreationRange, IIdCompressor, IIdCompressorCore, OpSpaceCompressedId, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SessionId, SessionSpaceCompressedId, StableId } from "./types";
|
|
8
|
+
import { Index } from "./persistanceUtilities";
|
|
9
|
+
import { Sessions } from "./sessions";
|
|
7
10
|
/**
|
|
8
11
|
* See {@link IIdCompressor} and {@link IIdCompressorCore}
|
|
9
|
-
*
|
|
10
|
-
* @alpha
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Not intended for public use and will be removed from the public API in the future.
|
|
13
|
-
* Use `createIdCompressor` instead.
|
|
14
12
|
*/
|
|
15
13
|
export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
16
14
|
private readonly logger?;
|
|
@@ -35,15 +33,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
35
33
|
private telemetryLocalIdCount;
|
|
36
34
|
private telemetryEagerFinalIdCount;
|
|
37
35
|
private ongoingGhostSession?;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
41
|
-
*/
|
|
42
|
-
static create(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated Use `createIdCompressor` instead.
|
|
45
|
-
*/
|
|
46
|
-
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
36
|
+
constructor(localSessionIdOrDeserialized: SessionId | Sessions, logger?: ITelemetryLoggerExt | undefined);
|
|
47
37
|
generateCompressedId(): SessionSpaceCompressedId;
|
|
48
38
|
/**
|
|
49
39
|
* {@inheritdoc IIdCompressorCore.beginGhostSession}
|
|
@@ -61,9 +51,9 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
61
51
|
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
62
52
|
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
63
53
|
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
64
|
-
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
65
|
-
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
66
|
-
|
|
54
|
+
static deserialize(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IdCompressor;
|
|
55
|
+
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IdCompressor;
|
|
56
|
+
static deserialize2_0(index: Index, sessionId?: SessionId, logger?: ITelemetryLoggerExt): IdCompressor;
|
|
67
57
|
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
68
58
|
}
|
|
69
59
|
/**
|
|
@@ -81,10 +71,10 @@ export declare function createIdCompressor(sessionId: SessionId, logger?: ITelem
|
|
|
81
71
|
* Deserializes the supplied state into an ID compressor.
|
|
82
72
|
* @alpha
|
|
83
73
|
*/
|
|
84
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession): IIdCompressor & IIdCompressorCore;
|
|
74
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
85
75
|
/**
|
|
86
76
|
* Deserializes the supplied state into an ID compressor.
|
|
87
77
|
* @alpha
|
|
88
78
|
*/
|
|
89
|
-
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IIdCompressor & IIdCompressorCore;
|
|
79
|
+
export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
|
|
90
80
|
//# sourceMappingURL=idCompressor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"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"}
|
package/dist/idCompressor.js
CHANGED
|
@@ -21,11 +21,6 @@ const finalSpace_1 = require("./finalSpace");
|
|
|
21
21
|
const currentWrittenVersion = 2.0;
|
|
22
22
|
/**
|
|
23
23
|
* See {@link IIdCompressor} and {@link IIdCompressorCore}
|
|
24
|
-
*
|
|
25
|
-
* @alpha
|
|
26
|
-
*
|
|
27
|
-
* @deprecated Not intended for public use and will be removed from the public API in the future.
|
|
28
|
-
* Use `createIdCompressor` instead.
|
|
29
24
|
*/
|
|
30
25
|
class IdCompressor {
|
|
31
26
|
// #endregion
|
|
@@ -70,25 +65,6 @@ class IdCompressor {
|
|
|
70
65
|
this.localSessionId = (0, utilities_1.stableIdFromNumericUuid)(this.localSession.sessionUuid);
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
|
-
static create(sessionIdOrLogger, loggerOrUndefined) {
|
|
74
|
-
let localSessionId;
|
|
75
|
-
let logger;
|
|
76
|
-
if (sessionIdOrLogger === undefined) {
|
|
77
|
-
localSessionId = (0, utilities_1.createSessionId)();
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if (typeof sessionIdOrLogger === "string") {
|
|
81
|
-
localSessionId = sessionIdOrLogger;
|
|
82
|
-
logger = loggerOrUndefined;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
localSessionId = (0, utilities_1.createSessionId)();
|
|
86
|
-
logger = loggerOrUndefined;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const compressor = new IdCompressor(localSessionId, logger === undefined ? undefined : (0, telemetry_utils_1.createChildLogger)({ logger }));
|
|
90
|
-
return compressor;
|
|
91
|
-
}
|
|
92
68
|
generateCompressedId() {
|
|
93
69
|
// This ghost session code inside this block should not be changed without a version bump (it is performed at a consensus point)
|
|
94
70
|
if (this.ongoingGhostSession) {
|
|
@@ -447,7 +423,15 @@ class IdCompressor {
|
|
|
447
423
|
});
|
|
448
424
|
return (0, client_utils_1.bufferToString)(serializedFloat.buffer, "base64");
|
|
449
425
|
}
|
|
450
|
-
static deserialize(serialized,
|
|
426
|
+
static deserialize(serialized, loggerOrSessionId) {
|
|
427
|
+
let sessionId;
|
|
428
|
+
let logger;
|
|
429
|
+
if (typeof loggerOrSessionId === "string") {
|
|
430
|
+
sessionId = loggerOrSessionId;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
logger = loggerOrSessionId;
|
|
434
|
+
}
|
|
451
435
|
const buffer = (0, client_utils_1.stringToBuffer)(serialized, "base64");
|
|
452
436
|
const index = {
|
|
453
437
|
index: 0,
|
|
@@ -459,12 +443,12 @@ class IdCompressor {
|
|
|
459
443
|
case 1.0:
|
|
460
444
|
throw new Error("IdCompressor version 1.0 is no longer supported.");
|
|
461
445
|
case 2.0:
|
|
462
|
-
return IdCompressor.deserialize2_0(index, sessionId);
|
|
446
|
+
return IdCompressor.deserialize2_0(index, sessionId, logger);
|
|
463
447
|
default:
|
|
464
448
|
throw new Error("Unknown IdCompressor serialized version.");
|
|
465
449
|
}
|
|
466
450
|
}
|
|
467
|
-
static deserialize2_0(index, sessionId) {
|
|
451
|
+
static deserialize2_0(index, sessionId, logger) {
|
|
468
452
|
const hasLocalState = (0, persistanceUtilities_1.readBoolean)(index);
|
|
469
453
|
const sessionCount = (0, persistanceUtilities_1.readNumber)(index);
|
|
470
454
|
const clusterCount = (0, persistanceUtilities_1.readNumber)(index);
|
|
@@ -485,7 +469,7 @@ class IdCompressor {
|
|
|
485
469
|
const numeric = (0, persistanceUtilities_1.readNumericUuid)(index);
|
|
486
470
|
sessions.push([numeric, new sessions_1.Session(numeric)]);
|
|
487
471
|
}
|
|
488
|
-
const compressor = new IdCompressor(new sessions_1.Sessions(sessions));
|
|
472
|
+
const compressor = new IdCompressor(new sessions_1.Sessions(sessions), logger);
|
|
489
473
|
// Clusters
|
|
490
474
|
let baseFinalId = 0;
|
|
491
475
|
for (let i = 0; i < clusterCount; i++) {
|
|
@@ -528,13 +512,30 @@ exports.IdCompressor = IdCompressor;
|
|
|
528
512
|
*/
|
|
529
513
|
IdCompressor.maxClusterSize = 2 ** 20;
|
|
530
514
|
function createIdCompressor(sessionIdOrLogger, loggerOrUndefined) {
|
|
531
|
-
|
|
515
|
+
let localSessionId;
|
|
516
|
+
let logger;
|
|
517
|
+
if (sessionIdOrLogger === undefined) {
|
|
518
|
+
localSessionId = (0, utilities_1.createSessionId)();
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
if (typeof sessionIdOrLogger === "string") {
|
|
522
|
+
localSessionId = sessionIdOrLogger;
|
|
523
|
+
logger = loggerOrUndefined;
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
localSessionId = (0, utilities_1.createSessionId)();
|
|
527
|
+
logger = sessionIdOrLogger;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const compressor = new IdCompressor(localSessionId, logger === undefined ? undefined : (0, telemetry_utils_1.createChildLogger)({ logger }));
|
|
531
|
+
return compressor;
|
|
532
532
|
}
|
|
533
533
|
exports.createIdCompressor = createIdCompressor;
|
|
534
|
-
function deserializeIdCompressor(serialized,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
534
|
+
function deserializeIdCompressor(serialized, sessionIdOrLogger, logger) {
|
|
535
|
+
if (typeof sessionIdOrLogger === "string") {
|
|
536
|
+
return IdCompressor.deserialize(serialized, sessionIdOrLogger, logger);
|
|
537
|
+
}
|
|
538
|
+
return IdCompressor.deserialize(serialized, logger);
|
|
538
539
|
}
|
|
539
540
|
exports.deserializeIdCompressor = deserializeIdCompressor;
|
|
540
541
|
//# sourceMappingURL=idCompressor.js.map
|