@fluidframework/id-compressor 2.103.0 → 2.111.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/api-report/id-compressor.beta.api.md +2 -1
  3. package/api-report/id-compressor.legacy.beta.api.md +2 -1
  4. package/api-report/id-compressor.legacy.public.api.md +2 -1
  5. package/api-report/id-compressor.public.api.md +2 -1
  6. package/dist/idCompressor.d.ts +1 -0
  7. package/dist/idCompressor.d.ts.map +1 -1
  8. package/dist/idCompressor.js +16 -1
  9. package/dist/idCompressor.js.map +1 -1
  10. package/dist/packageVersion.d.ts +1 -1
  11. package/dist/packageVersion.js +1 -1
  12. package/dist/packageVersion.js.map +1 -1
  13. package/dist/test/idCompressor.spec.js.map +1 -1
  14. package/dist/test/types/validateIdCompressorPrevious.generated.js.map +1 -1
  15. package/dist/types/idCompressor.d.ts +52 -8
  16. package/dist/types/idCompressor.d.ts.map +1 -1
  17. package/dist/types/idCompressor.js.map +1 -1
  18. package/dist/types/identifiers.d.ts +10 -2
  19. package/dist/types/identifiers.d.ts.map +1 -1
  20. package/dist/types/identifiers.js.map +1 -1
  21. package/lib/idCompressor.d.ts +1 -0
  22. package/lib/idCompressor.d.ts.map +1 -1
  23. package/lib/idCompressor.js +16 -1
  24. package/lib/idCompressor.js.map +1 -1
  25. package/lib/packageVersion.d.ts +1 -1
  26. package/lib/packageVersion.js +1 -1
  27. package/lib/packageVersion.js.map +1 -1
  28. package/lib/test/idCompressor.spec.js.map +1 -1
  29. package/lib/test/types/validateIdCompressorPrevious.generated.js.map +1 -1
  30. package/lib/types/idCompressor.d.ts +52 -8
  31. package/lib/types/idCompressor.d.ts.map +1 -1
  32. package/lib/types/idCompressor.js.map +1 -1
  33. package/lib/types/identifiers.d.ts +10 -2
  34. package/lib/types/identifiers.d.ts.map +1 -1
  35. package/lib/types/identifiers.js.map +1 -1
  36. package/package.json +15 -11
  37. package/src/idCompressor.ts +20 -3
  38. package/src/packageVersion.ts +1 -1
  39. package/src/test/types/validateIdCompressorPrevious.generated.ts +2 -1
  40. package/src/types/idCompressor.ts +55 -8
  41. package/src/types/identifiers.ts +12 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @fluidframework/id-compressor
2
2
 
3
+ ## 2.111.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add originatorless normalization for op-space IDs in id-compressor ([#27367](https://github.com/microsoft/FluidFramework/pull/27367)) [4af409440ad](https://github.com/microsoft/FluidFramework/commit/4af409440adc8667c786b8989dbd8d8b8618bc02)
8
+
9
+ `IIdCompressor` now includes `tryNormalizeToSessionSpaceWithoutSession(id)`.
10
+ This API supports recovery scenarios where an [op-space identifier](https://fluidframework.com/docs/api/id-compressor/opspacecompressedid-typealias) must be decoded
11
+ without the originating session id.
12
+
13
+ For finalized IDs, the method returns the correct session-space form.
14
+ For non-final IDs, it returns `undefined` to indicate that originator context is
15
+ required and callers should use `normalizeToSessionSpace(id, originSessionId)` when
16
+ that context is available.
17
+
18
+ ```typescript
19
+ const maybeSessionId =
20
+ idCompressor.tryNormalizeToSessionSpaceWithoutSession(opId);
21
+ if (maybeSessionId === undefined) {
22
+ const sessionId = idCompressor.normalizeToSessionSpace(opId, originatorId);
23
+ // use sessionId
24
+ } else {
25
+ // use maybeSessionId
26
+ }
27
+ ```
28
+
29
+ `IIdCompressor` is now marked `@sealed`.
30
+ Fluid already assumed any `IIdCompressor` was its own implementation and casted them internally.
31
+ Any custom implementations will no longer build due to the above change,
32
+ but would not have worked at runtime anyway.
33
+ The updated tagging now correctly documents this requirement.
34
+
35
+ ## 2.110.0
36
+
37
+ Dependency updates only.
38
+
3
39
  ## 2.103.0
4
40
 
5
41
  Dependency updates only.
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```ts
6
6
 
7
- // @public
7
+ // @public @sealed
8
8
  export interface IIdCompressor {
9
9
  decompress(id: SessionSpaceCompressedId): StableId;
10
10
  generateCompressedId(): SessionSpaceCompressedId;
@@ -13,6 +13,7 @@ export interface IIdCompressor {
13
13
  normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
14
14
  normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
15
15
  recompress(uncompressed: StableId): SessionSpaceCompressedId;
16
+ tryNormalizeToSessionSpaceWithoutSession(id: OpSpaceCompressedId): SessionSpaceCompressedId | undefined;
16
17
  tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
17
18
  }
18
19
 
@@ -32,7 +32,7 @@ export interface IdCreationRange {
32
32
  readonly sessionId: SessionId;
33
33
  }
34
34
 
35
- // @public
35
+ // @public @sealed
36
36
  export interface IIdCompressor {
37
37
  decompress(id: SessionSpaceCompressedId): StableId;
38
38
  generateCompressedId(): SessionSpaceCompressedId;
@@ -41,6 +41,7 @@ export interface IIdCompressor {
41
41
  normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
42
42
  normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
43
43
  recompress(uncompressed: StableId): SessionSpaceCompressedId;
44
+ tryNormalizeToSessionSpaceWithoutSession(id: OpSpaceCompressedId): SessionSpaceCompressedId | undefined;
44
45
  tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
45
46
  }
46
47
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```ts
6
6
 
7
- // @public
7
+ // @public @sealed
8
8
  export interface IIdCompressor {
9
9
  decompress(id: SessionSpaceCompressedId): StableId;
10
10
  generateCompressedId(): SessionSpaceCompressedId;
@@ -13,6 +13,7 @@ export interface IIdCompressor {
13
13
  normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
14
14
  normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
15
15
  recompress(uncompressed: StableId): SessionSpaceCompressedId;
16
+ tryNormalizeToSessionSpaceWithoutSession(id: OpSpaceCompressedId): SessionSpaceCompressedId | undefined;
16
17
  tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
17
18
  }
18
19
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```ts
6
6
 
7
- // @public
7
+ // @public @sealed
8
8
  export interface IIdCompressor {
9
9
  decompress(id: SessionSpaceCompressedId): StableId;
10
10
  generateCompressedId(): SessionSpaceCompressedId;
@@ -13,6 +13,7 @@ export interface IIdCompressor {
13
13
  normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
14
14
  normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
15
15
  recompress(uncompressed: StableId): SessionSpaceCompressedId;
16
+ tryNormalizeToSessionSpaceWithoutSession(id: OpSpaceCompressedId): SessionSpaceCompressedId | undefined;
16
17
  tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
17
18
  }
18
19
 
@@ -61,6 +61,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
61
61
  finalizeCreationRange(range: IdCreationRange): void;
62
62
  private addEmptyCluster;
63
63
  normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
64
+ tryNormalizeToSessionSpaceWithoutSession(id: OpSpaceCompressedId): SessionSpaceCompressedId | undefined;
64
65
  normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
65
66
  decompress(id: SessionSpaceCompressedId): StableId;
66
67
  recompress(uncompressed: StableId): SessionSpaceCompressedId;
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAOnF,OAAO,KAAK,EAAE,mBA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AgB,uBAAuB,CACtC,UAAU,EAAE,wCAAwC,EACpD,MAAM,CAAC,EAAE,mBAAmB,GAC1B,aAAa,CAAC;AACjB;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,mCAAmC,EAC/C,YAAY,EAAE,SAAS,EACvB,MAAM,CAAC,EAAE,mBAAmB,GAC1B,aAAa,CAAC;AAwBjB;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,IAAI,GACf,wCAAwC,CAAC;AAC5C;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,KAAK,GAChB,mCAAmC,CAAC;AASvC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,aAAa,GACvB,aAAa,GAAG,iBAAiB,CAMnC"}
@@ -284,7 +284,7 @@ class IdCompressor {
284
284
  : finalForm;
285
285
  }
286
286
  }
287
- normalizeToSessionSpace(id, originSessionId) {
287
+ tryNormalizeToSessionSpaceWithoutSession(id) {
288
288
  if ((0, identifiers_js_1.isFinalId)(id)) {
289
289
  const containingCluster = this.localSession.getClusterByAllocatedFinal(id);
290
290
  if (containingCluster === undefined) {
@@ -301,6 +301,12 @@ class IdCompressor {
301
301
  }
302
302
  else {
303
303
  if ((0, utilities_js_1.genCountFromLocalId)(alignedLocal) > this.localGenCount) {
304
+ // The ID is not valid in this compressor. It is either from a future version of this compressor, or another compressor.
305
+ // Since IDs from other compressors often are valid in this one, but uncompress incorrectly,
306
+ // we cannot rely on this function (tryNormalizeToSessionSpaceWithoutSession) to validate that the IDs are from the same compressor.
307
+ // Since such validation can not be robust, this "try" function is explicitly documented not to be allowed to be used for this case.
308
+ // Therefore, as documented in the API docs for this function, calls can not rely on a specific output in this case,
309
+ // and therefore the document behavior of throwing makes the most sense (helps catch bugs).
304
310
  throw new Error("Unknown op space ID.");
305
311
  }
306
312
  return id;
@@ -308,6 +314,12 @@ class IdCompressor {
308
314
  }
309
315
  }
310
316
  else {
317
+ return undefined;
318
+ }
319
+ }
320
+ normalizeToSessionSpace(id, originSessionId) {
321
+ const normalizedWithoutSession = this.tryNormalizeToSessionSpaceWithoutSession(id);
322
+ if (normalizedWithoutSession === undefined) {
311
323
  const localToNormalize = id;
312
324
  if (originSessionId === this.localSessionId) {
313
325
  if (this.normalizer.contains(localToNormalize)) {
@@ -331,6 +343,9 @@ class IdCompressor {
331
343
  return correspondingFinal;
332
344
  }
333
345
  }
346
+ else {
347
+ return normalizedWithoutSession;
348
+ }
334
349
  }
335
350
  decompress(id) {
336
351
  if ((0, identifiers_js_1.isFinalId)(id)) {
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8E;AAE9E,kEAA6D;AAE7D,uEAIkD;AAIlD,mDAA6C;AAC7C,qDAK0B;AAC1B,uEAQmC;AACnC,2EAAqE;AACrE,+CAQuB;AAavB,iDAQwB;AAExB;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,SAAS,sBAAsB,CAAC,aAAqB,EAAE,WAAmB;IACzE,OAAO,IAAI,uBAAY,CAAC,+BAA+B,EAAE;QACxD,aAAa;QACb,WAAW;KACX,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAa,YAAY;IA+CxB,aAAa;IAEb,YACC,4BAAkD,EACjC,MAAsC;QAAtC,WAAM,GAAN,MAAM,CAAgC;QAzCvC,eAAU,GAAG,IAAI,kDAAsB,EAAE,CAAC;QAC3D,mDAAmD;QAC3C,kBAAa,GAAG,CAAC,CAAC;QAE1B,aAAa;QAEb,sBAAsB;QAEtB;;;;;WAKG;QACK,0BAAqB,GAAG,CAAC,CAAC;QACjB,aAAQ,GAAG,IAAI,sBAAQ,EAAE,CAAC;QAC1B,eAAU,GAAG,IAAI,0BAAU,EAAE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AAI,UAAU,EACzB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,OAAO,UAA+C,CAAC;AACxD,CAAC;AARD,wDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tLoggingError,\n\tcreateChildLogger,\n\textractTelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n// eslint-disable-next-line import-x/no-internal-modules -- Needed to avoid specialized /internal ITelemetryLoggerExt\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/legacy\";\n\nimport { FinalSpace } from \"./finalSpace.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\ttype NumericUuid,\n\tisFinalId,\n} from \"./identifiers.js\";\nimport {\n\ttype Index,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities.js\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer.js\";\nimport {\n\ttype IdCluster,\n\tSession,\n\tSessions,\n\tgetAlignedFinal,\n\tgetAlignedLocal,\n\tlastFinalizedFinal,\n\tlastFinalizedLocal,\n} from \"./sessions.js\";\nimport type {\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./types/index.js\";\nimport {\n\tcreateSessionId,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * The version of IdCompressor that is currently persisted.\n * This should not be changed without careful consideration to compatibility.\n */\nconst currentWrittenVersion = 2;\n\nfunction rangeFinalizationError(expectedStart: number, actualStart: number): LoggingError {\n\treturn new LoggingError(\"Ranges finalized out of order\", {\n\t\texpectedStart,\n\t\tactualStart,\n\t});\n}\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// #region Local state\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t// #endregion\n\n\t// #region Final state\n\n\t/**\n\t * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t * This is advanced to `generatedIdCount` + 1 each time it is called.\n\t * On the other hand, when `resetUnfinalizedCreationRange` is called,\n\t * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.\n\t */\n\tprivate nextRangeBaseGenCount = 1;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// #endregion\n\n\t// #region Ephemeral state\n\n\t/**\n\t * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.\n\t * Eventually, this can be adjusted dynamically to have cluster reservation policies that\n\t * optimize the number of eager finals.\n\t * It is not readonly as it is accessed by tests for clear-box testing.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly\n\tprivate nextRequestedClusterSize: number = 512;\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\t// The ongoing ghost session, if one exists.\n\tprivate ongoingGhostSession?: { cluster?: IdCluster; ghostSessionId: SessionId } | undefined;\n\n\t// #endregion\n\n\tpublic constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger: TelemetryLoggerExt | undefined,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\t// This ghost session code inside this block should not be changed without a version bump (it is performed at a consensus point)\n\t\tif (this.ongoingGhostSession) {\n\t\t\tif (this.ongoingGhostSession.cluster === undefined) {\n\t\t\t\tthis.ongoingGhostSession.cluster = this.addEmptyCluster(\n\t\t\t\t\tthis.sessions.getOrCreate(this.ongoingGhostSession.ghostSessionId),\n\t\t\t\t\t1,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.ongoingGhostSession.cluster.capacity++;\n\t\t\t}\n\t\t\tthis.ongoingGhostSession.cluster.count++;\n\t\t\treturn lastFinalizedFinal(\n\t\t\t\tthis.ongoingGhostSession.cluster,\n\t\t\t) as unknown as SessionSpaceCompressedId;\n\t\t} else {\n\t\t\tthis.localGenCount++;\n\t\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\t\tif (lastCluster === undefined) {\n\t\t\t\tthis.telemetryLocalIdCount++;\n\t\t\t\treturn this.generateNextLocalId();\n\t\t\t}\n\n\t\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t\t// collaborators *after* the one containing the creation range.\n\t\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t\t// Space in the cluster: eager final\n\t\t\t\treturn ((lastCluster.baseFinalId as number) +\n\t\t\t\t\tclusterOffset) as SessionSpaceCompressedId;\n\t\t\t}\n\t\t\t// No space in the cluster, return next local\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\t}\n\n\tpublic generateDocumentUniqueId():\n\t\t| (SessionSpaceCompressedId & OpSpaceCompressedId)\n\t\t| StableId {\n\t\tconst id = this.generateCompressedId();\n\t\treturn isFinalId(id) ? id : this.decompress(id);\n\t}\n\n\t/**\n\t * Starts a ghost session. Only exposed for test purposes (this class is not exported from the package).\n\t * @param ghostSessionId - The session ID to start the ghost session with.\n\t */\n\tpublic startGhostSession(ghostSessionId: SessionId): void {\n\t\tassert(!this.ongoingGhostSession, 0x8fe /* Ghost session already in progress. */);\n\t\tthis.ongoingGhostSession = { ghostSessionId };\n\t}\n\n\t/**\n\t * {@inheritdoc IIdCompressorCore.beginGhostSession}\n\t */\n\tpublic beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void {\n\t\tthis.startGhostSession(ghostSessionId);\n\t\ttry {\n\t\t\tghostSessionCallback();\n\t\t} finally {\n\t\t\tthis.ongoingGhostSession = undefined;\n\t\t}\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a6 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t\trequestedClusterSize: this.nextRequestedClusterSize,\n\t\t\t\tlocalIdRanges: this.normalizer.getRangesBetween(\n\t\t\t\t\tthis.nextRangeBaseGenCount,\n\t\t\t\t\tthis.localGenCount,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t\treturn this.updateToRange(range);\n\t}\n\n\tpublic takeUnfinalizedCreationRange(): IdCreationRange {\n\t\tthis.resetUnfinalizedCreationRange();\n\t\treturn this.takeNextCreationRange();\n\t}\n\n\tpublic resetUnfinalizedCreationRange(): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0xcec /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\n\t\tconst lastLocalCluster = this.localSession.getLastCluster();\n\t\tthis.nextRangeBaseGenCount =\n\t\t\tlastLocalCluster === undefined\n\t\t\t\t? 1\n\t\t\t\t: genCountFromLocalId(\n\t\t\t\t\t\t(lastLocalCluster.baseLocalId - lastLocalCluster.count) as LocalCompressedId,\n\t\t\t\t\t);\n\t}\n\n\tprivate updateToRange(range: IdCreationRange): IdCreationRange {\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn IdCompressor.assertValidRange(range);\n\t}\n\n\tprivate static assertValidRange(range: IdCreationRange): IdCreationRange {\n\t\tif (range.ids === undefined) {\n\t\t\treturn range;\n\t\t}\n\t\tconst { count, requestedClusterSize } = range.ids;\n\t\tassert(count > 0, 0x755 /* Malformed ID Range. */);\n\t\tassert(requestedClusterSize > 0, 0x876 /* Clusters must have a positive capacity. */);\n\t\tassert(\n\t\t\trequestedClusterSize <= IdCompressor.maxClusterSize,\n\t\t\t0x877 /* Clusters must not exceed max cluster size. */,\n\t\t);\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a7 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tIdCompressor.assertValidRange(range);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount, requestedClusterSize } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow rangeFinalizationError(-1, rangeBaseLocal);\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, requestedClusterSize + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow rangeFinalizationError(\n\t\t\t\tlastCluster.baseLocalId - lastCluster.count,\n\t\t\t\trangeBaseLocal,\n\t\t\t);\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + requestedClusterSize;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession?.cluster,\n\t\t\t0x8a8 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(\n\t\t\t!this.sessions.clusterCollides(newCluster),\n\t\t\t0x758 /* Cluster collision detected. */,\n\t\t);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(lastFinalizedLocal(containingCluster));\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(!this.normalizer.contains(alignedLocal), 0x759 /* Normalizer out of sync. */);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a9 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst { normalizer, finalSpace, sessions, localGenCount, logger, nextRangeBaseGenCount } =\n\t\t\tthis;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t\t1 + // next range base genCount\n\t\t\t\t1 + // count of normalizer pairs\n\t\t\t\tnormalizer.idRanges.size * 2 // pairs\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * 2 + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, currentWrittenVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfor (const cluster of finalSpace.clusters) {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t}\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tlogger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(\n\t\tparams:\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithOngoingSession;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t\t\tnewSessionId?: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithNoSession;\n\t\t\t\t\tnewSessionId: SessionId;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t },\n\t): IdCompressor {\n\t\tconst { serialized, newSessionId, logger } = params;\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst version = readNumber(index);\n\t\tswitch (version) {\n\t\t\tcase 1: {\n\t\t\t\tthrow new Error(\"IdCompressor version 1.0 is no longer supported.\");\n\t\t\t}\n\t\t\tcase 2: {\n\t\t\t\treturn IdCompressor.deserialize2_0(index, newSessionId, logger);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unknown IdCompressor serialized version.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic deserialize2_0(\n\t\tindex: Index,\n\t\tsessionId: SessionId | undefined,\n\t\tlogger: TelemetryLoggerExt | undefined,\n\t): IdCompressor {\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (hasLocalState) {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t} else {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions), logger);\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst sessionArray = sessions[sessionIndex + sessionOffset];\n\t\t\tassert(\n\t\t\t\tsessionArray !== undefined,\n\t\t\t\t0x9d8 /* sessionArray is undefined in IdCompressor.deserialize2_0 */,\n\t\t\t);\n\t\t\tconst session = sessionArray[1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n\n/**\n * Create a new {@link IIdCompressor}.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(logger?: ITelemetryBaseLogger): IIdCompressor;\n/**\n * Create a new {@link IIdCompressor}.\n * @param sessionId - The seed ID for the compressor.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor;\nexport function createIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tlet localSessionId: SessionId;\n\tlet logger: ITelemetryBaseLogger | undefined;\n\tif (sessionIdOrLogger === undefined) {\n\t\tlocalSessionId = createSessionId();\n\t} else {\n\t\tif (typeof sessionIdOrLogger === \"string\") {\n\t\t\tlocalSessionId = sessionIdOrLogger;\n\t\t\tlogger = loggerOrUndefined;\n\t\t} else {\n\t\t\tlocalSessionId = createSessionId();\n\t\t\tlogger = sessionIdOrLogger;\n\t\t}\n\t}\n\tconst compressor = new IdCompressor(\n\t\tlocalSessionId,\n\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t);\n\treturn compressor;\n}\n\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithOngoingSession,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithNoSession,\n\tnewSessionId: SessionId,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressor | SerializedIdCompressorWithNoSession,\n\tsessionIdOrLogger: SessionId | ITelemetryLoggerExt | undefined,\n\tloggerOrUndefined?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore {\n\tif (typeof sessionIdOrLogger === \"string\") {\n\t\treturn IdCompressor.deserialize({\n\t\t\tserialized: serialized as SerializedIdCompressorWithNoSession,\n\t\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(loggerOrUndefined),\n\t\t\tnewSessionId: sessionIdOrLogger,\n\t\t});\n\t}\n\n\tassert(\n\t\tloggerOrUndefined === undefined,\n\t\t0xc2d /* logger would be in sessionIdOrLogger in this codepath */,\n\t);\n\treturn IdCompressor.deserialize({\n\t\tserialized: serialized as SerializedIdCompressorWithOngoingSession,\n\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(sessionIdOrLogger),\n\t});\n}\n\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: true,\n): SerializedIdCompressorWithOngoingSession;\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: false,\n): SerializedIdCompressorWithNoSession;\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: boolean,\n): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\tconst core = toIdCompressorWithCore(compressor);\n\treturn withSession ? core.serialize(true) : core.serialize(false);\n}\n\n/**\n * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.\n *\n * @remarks\n * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`\n * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their\n * public return type is narrowed to {@link IIdCompressor}. Internal consumers that\n * need access to core compressor operations (serialization, range management, etc.)\n * use this function to recover the {@link IIdCompressorCore} surface.\n *\n * @param compressor - A compressor created by `createIdCompressor` or\n * `deserializeIdCompressor`.\n * @returns The same compressor, typed to include {@link IIdCompressorCore}.\n * @internal\n */\nexport function toIdCompressorWithCore(\n\tcompressor: IIdCompressor,\n): IIdCompressor & IIdCompressorCore {\n\tassert(\n\t\t\"serialize\" in compressor,\n\t\t0xced /* Expected compressor to implement IIdCompressorCore */,\n\t);\n\treturn compressor as IIdCompressor & IIdCompressorCore;\n}\n"]}
1
+ {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8E;AAE9E,kEAA6D;AAE7D,uEAIkD;AAIlD,mDAA6C;AAC7C,qDAK0B;AAC1B,uEAQmC;AACnC,2EAAqE;AACrE,+CAQuB;AAavB,iDAQwB;AAExB;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,SAAS,sBAAsB,CAAC,aAAqB,EAAE,WAAmB;IACzE,OAAO,IAAI,uBAAY,CAAC,+BAA+B,EAAE;QACxD,aAAa;QACb,WAAW;KACX,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAa,YAAY;IA+CxB,aAAa;IAEb,YACC,4BAAkD,EACjC,MAAsC;QAAtC,WAAM,GAAN,MAAM,CAAgC;QAzCvC,eAAU,GAAG,IAAI,kDAAsB,EAAE,CAAC;QAC3D,mDAAmD;QAC3C,kBAAa,GAAG,CAAC,CAA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Y,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,UAAsD;QAClE,MAAM,EAAE,IAAA,oCAAyB,EAA8B,iBAAiB,CAAC;KACjF,CAAC,CAAC;AACJ,CAAC;AArBD,0DAqBC;AAwBD,SAAgB,qBAAqB,CACpC,UAAyB,EACzB,WAAoB;IAEpB,MAAM,IAAI,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAND,sDAMC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB,CACrC,UAAyB;IAEzB,IAAA,iBAAM,EACL,WAAW,IAAI,UAAU,EACzB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,OAAO,UAA+C,CAAC;AACxD,CAAC;AARD,wDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tLoggingError,\n\tcreateChildLogger,\n\textractTelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n// eslint-disable-next-line import-x/no-internal-modules -- Needed to avoid specialized /internal ITelemetryLoggerExt\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/legacy\";\n\nimport { FinalSpace } from \"./finalSpace.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\ttype NumericUuid,\n\tisFinalId,\n} from \"./identifiers.js\";\nimport {\n\ttype Index,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities.js\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer.js\";\nimport {\n\ttype IdCluster,\n\tSession,\n\tSessions,\n\tgetAlignedFinal,\n\tgetAlignedLocal,\n\tlastFinalizedFinal,\n\tlastFinalizedLocal,\n} from \"./sessions.js\";\nimport type {\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./types/index.js\";\nimport {\n\tcreateSessionId,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * The version of IdCompressor that is currently persisted.\n * This should not be changed without careful consideration to compatibility.\n */\nconst currentWrittenVersion = 2;\n\nfunction rangeFinalizationError(expectedStart: number, actualStart: number): LoggingError {\n\treturn new LoggingError(\"Ranges finalized out of order\", {\n\t\texpectedStart,\n\t\tactualStart,\n\t});\n}\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// #region Local state\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t// #endregion\n\n\t// #region Final state\n\n\t/**\n\t * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t * This is advanced to `generatedIdCount` + 1 each time it is called.\n\t * On the other hand, when `resetUnfinalizedCreationRange` is called,\n\t * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.\n\t */\n\tprivate nextRangeBaseGenCount = 1;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// #endregion\n\n\t// #region Ephemeral state\n\n\t/**\n\t * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.\n\t * Eventually, this can be adjusted dynamically to have cluster reservation policies that\n\t * optimize the number of eager finals.\n\t * It is not readonly as it is accessed by tests for clear-box testing.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly\n\tprivate nextRequestedClusterSize: number = 512;\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\t// The ongoing ghost session, if one exists.\n\tprivate ongoingGhostSession?: { cluster?: IdCluster; ghostSessionId: SessionId } | undefined;\n\n\t// #endregion\n\n\tpublic constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger: TelemetryLoggerExt | undefined,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\t// This ghost session code inside this block should not be changed without a version bump (it is performed at a consensus point)\n\t\tif (this.ongoingGhostSession) {\n\t\t\tif (this.ongoingGhostSession.cluster === undefined) {\n\t\t\t\tthis.ongoingGhostSession.cluster = this.addEmptyCluster(\n\t\t\t\t\tthis.sessions.getOrCreate(this.ongoingGhostSession.ghostSessionId),\n\t\t\t\t\t1,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.ongoingGhostSession.cluster.capacity++;\n\t\t\t}\n\t\t\tthis.ongoingGhostSession.cluster.count++;\n\t\t\treturn lastFinalizedFinal(\n\t\t\t\tthis.ongoingGhostSession.cluster,\n\t\t\t) as unknown as SessionSpaceCompressedId;\n\t\t} else {\n\t\t\tthis.localGenCount++;\n\t\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\t\tif (lastCluster === undefined) {\n\t\t\t\tthis.telemetryLocalIdCount++;\n\t\t\t\treturn this.generateNextLocalId();\n\t\t\t}\n\n\t\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t\t// collaborators *after* the one containing the creation range.\n\t\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t\t// Space in the cluster: eager final\n\t\t\t\treturn ((lastCluster.baseFinalId as number) +\n\t\t\t\t\tclusterOffset) as SessionSpaceCompressedId;\n\t\t\t}\n\t\t\t// No space in the cluster, return next local\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\t}\n\n\tpublic generateDocumentUniqueId():\n\t\t| (SessionSpaceCompressedId & OpSpaceCompressedId)\n\t\t| StableId {\n\t\tconst id = this.generateCompressedId();\n\t\treturn isFinalId(id) ? id : this.decompress(id);\n\t}\n\n\t/**\n\t * Starts a ghost session. Only exposed for test purposes (this class is not exported from the package).\n\t * @param ghostSessionId - The session ID to start the ghost session with.\n\t */\n\tpublic startGhostSession(ghostSessionId: SessionId): void {\n\t\tassert(!this.ongoingGhostSession, 0x8fe /* Ghost session already in progress. */);\n\t\tthis.ongoingGhostSession = { ghostSessionId };\n\t}\n\n\t/**\n\t * {@inheritdoc IIdCompressorCore.beginGhostSession}\n\t */\n\tpublic beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void {\n\t\tthis.startGhostSession(ghostSessionId);\n\t\ttry {\n\t\t\tghostSessionCallback();\n\t\t} finally {\n\t\t\tthis.ongoingGhostSession = undefined;\n\t\t}\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a6 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t\trequestedClusterSize: this.nextRequestedClusterSize,\n\t\t\t\tlocalIdRanges: this.normalizer.getRangesBetween(\n\t\t\t\t\tthis.nextRangeBaseGenCount,\n\t\t\t\t\tthis.localGenCount,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t\treturn this.updateToRange(range);\n\t}\n\n\tpublic takeUnfinalizedCreationRange(): IdCreationRange {\n\t\tthis.resetUnfinalizedCreationRange();\n\t\treturn this.takeNextCreationRange();\n\t}\n\n\tpublic resetUnfinalizedCreationRange(): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0xcec /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\n\t\tconst lastLocalCluster = this.localSession.getLastCluster();\n\t\tthis.nextRangeBaseGenCount =\n\t\t\tlastLocalCluster === undefined\n\t\t\t\t? 1\n\t\t\t\t: genCountFromLocalId(\n\t\t\t\t\t\t(lastLocalCluster.baseLocalId - lastLocalCluster.count) as LocalCompressedId,\n\t\t\t\t\t);\n\t}\n\n\tprivate updateToRange(range: IdCreationRange): IdCreationRange {\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn IdCompressor.assertValidRange(range);\n\t}\n\n\tprivate static assertValidRange(range: IdCreationRange): IdCreationRange {\n\t\tif (range.ids === undefined) {\n\t\t\treturn range;\n\t\t}\n\t\tconst { count, requestedClusterSize } = range.ids;\n\t\tassert(count > 0, 0x755 /* Malformed ID Range. */);\n\t\tassert(requestedClusterSize > 0, 0x876 /* Clusters must have a positive capacity. */);\n\t\tassert(\n\t\t\trequestedClusterSize <= IdCompressor.maxClusterSize,\n\t\t\t0x877 /* Clusters must not exceed max cluster size. */,\n\t\t);\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a7 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tIdCompressor.assertValidRange(range);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount, requestedClusterSize } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow rangeFinalizationError(-1, rangeBaseLocal);\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, requestedClusterSize + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow rangeFinalizationError(\n\t\t\t\tlastCluster.baseLocalId - lastCluster.count,\n\t\t\t\trangeBaseLocal,\n\t\t\t);\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + requestedClusterSize;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession?.cluster,\n\t\t\t0x8a8 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(\n\t\t\t!this.sessions.clusterCollides(newCluster),\n\t\t\t0x758 /* Cluster collision detected. */,\n\t\t);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic tryNormalizeToSessionSpaceWithoutSession(\n\t\tid: OpSpaceCompressedId,\n\t): SessionSpaceCompressedId | undefined {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\t// The ID is not valid in this compressor. It is either from a future version of this compressor, or another compressor.\n\t\t\t\t\t\t// Since IDs from other compressors often are valid in this one, but uncompress incorrectly,\n\t\t\t\t\t\t// we cannot rely on this function (tryNormalizeToSessionSpaceWithoutSession) to validate that the IDs are from the same compressor.\n\t\t\t\t\t\t// Since such validation can not be robust, this \"try\" function is explicitly documented not to be allowed to be used for this case.\n\t\t\t\t\t\t// Therefore, as documented in the API docs for this function, calls can not rely on a specific output in this case,\n\t\t\t\t\t\t// and therefore the document behavior of throwing makes the most sense (helps catch bugs).\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tconst normalizedWithoutSession = this.tryNormalizeToSessionSpaceWithoutSession(id);\n\t\tif (normalizedWithoutSession === undefined) {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t} else {\n\t\t\treturn normalizedWithoutSession;\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(lastFinalizedLocal(containingCluster));\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(!this.normalizer.contains(alignedLocal), 0x759 /* Normalizer out of sync. */);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a9 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst { normalizer, finalSpace, sessions, localGenCount, logger, nextRangeBaseGenCount } =\n\t\t\tthis;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t\t1 + // next range base genCount\n\t\t\t\t1 + // count of normalizer pairs\n\t\t\t\tnormalizer.idRanges.size * 2 // pairs\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * 2 + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, currentWrittenVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfor (const cluster of finalSpace.clusters) {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t}\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tlogger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(\n\t\tparams:\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithOngoingSession;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t\t\tnewSessionId?: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithNoSession;\n\t\t\t\t\tnewSessionId: SessionId;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t },\n\t): IdCompressor {\n\t\tconst { serialized, newSessionId, logger } = params;\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst version = readNumber(index);\n\t\tswitch (version) {\n\t\t\tcase 1: {\n\t\t\t\tthrow new Error(\"IdCompressor version 1.0 is no longer supported.\");\n\t\t\t}\n\t\t\tcase 2: {\n\t\t\t\treturn IdCompressor.deserialize2_0(index, newSessionId, logger);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unknown IdCompressor serialized version.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic deserialize2_0(\n\t\tindex: Index,\n\t\tsessionId: SessionId | undefined,\n\t\tlogger: TelemetryLoggerExt | undefined,\n\t): IdCompressor {\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (hasLocalState) {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t} else {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions), logger);\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst sessionArray = sessions[sessionIndex + sessionOffset];\n\t\t\tassert(\n\t\t\t\tsessionArray !== undefined,\n\t\t\t\t0x9d8 /* sessionArray is undefined in IdCompressor.deserialize2_0 */,\n\t\t\t);\n\t\t\tconst session = sessionArray[1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n\n/**\n * Create a new {@link IIdCompressor}.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(logger?: ITelemetryBaseLogger): IIdCompressor;\n/**\n * Create a new {@link IIdCompressor}.\n * @param sessionId - The seed ID for the compressor.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor;\nexport function createIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tlet localSessionId: SessionId;\n\tlet logger: ITelemetryBaseLogger | undefined;\n\tif (sessionIdOrLogger === undefined) {\n\t\tlocalSessionId = createSessionId();\n\t} else {\n\t\tif (typeof sessionIdOrLogger === \"string\") {\n\t\t\tlocalSessionId = sessionIdOrLogger;\n\t\t\tlogger = loggerOrUndefined;\n\t\t} else {\n\t\t\tlocalSessionId = createSessionId();\n\t\t\tlogger = sessionIdOrLogger;\n\t\t}\n\t}\n\tconst compressor = new IdCompressor(\n\t\tlocalSessionId,\n\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t);\n\treturn compressor;\n}\n\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithOngoingSession,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithNoSession,\n\tnewSessionId: SessionId,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressor | SerializedIdCompressorWithNoSession,\n\tsessionIdOrLogger: SessionId | ITelemetryLoggerExt | undefined,\n\tloggerOrUndefined?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore {\n\tif (typeof sessionIdOrLogger === \"string\") {\n\t\treturn IdCompressor.deserialize({\n\t\t\tserialized: serialized as SerializedIdCompressorWithNoSession,\n\t\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(loggerOrUndefined),\n\t\t\tnewSessionId: sessionIdOrLogger,\n\t\t});\n\t}\n\n\tassert(\n\t\tloggerOrUndefined === undefined,\n\t\t0xc2d /* logger would be in sessionIdOrLogger in this codepath */,\n\t);\n\treturn IdCompressor.deserialize({\n\t\tserialized: serialized as SerializedIdCompressorWithOngoingSession,\n\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(sessionIdOrLogger),\n\t});\n}\n\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: true,\n): SerializedIdCompressorWithOngoingSession;\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: false,\n): SerializedIdCompressorWithNoSession;\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: boolean,\n): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\tconst core = toIdCompressorWithCore(compressor);\n\treturn withSession ? core.serialize(true) : core.serialize(false);\n}\n\n/**\n * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.\n *\n * @remarks\n * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`\n * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their\n * public return type is narrowed to {@link IIdCompressor}. Internal consumers that\n * need access to core compressor operations (serialization, range management, etc.)\n * use this function to recover the {@link IIdCompressorCore} surface.\n *\n * @param compressor - A compressor created by `createIdCompressor` or\n * `deserializeIdCompressor`.\n * @returns The same compressor, typed to include {@link IIdCompressorCore}.\n * @internal\n */\nexport function toIdCompressorWithCore(\n\tcompressor: IIdCompressor,\n): IIdCompressor & IIdCompressorCore {\n\tassert(\n\t\t\"serialize\" in compressor,\n\t\t0xced /* Expected compressor to implement IIdCompressorCore */,\n\t);\n\treturn compressor as IIdCompressor & IIdCompressorCore;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/id-compressor";
8
- export declare const pkgVersion = "2.103.0";
8
+ export declare const pkgVersion = "2.111.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/id-compressor";
11
- exports.pkgVersion = "2.103.0";
11
+ exports.pkgVersion = "2.111.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.103.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.111.0\";\n"]}