@fluidframework/id-compressor 2.1.0-276985 → 2.1.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 (63) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +61 -31
  3. package/api-extractor/api-extractor.current.json +5 -0
  4. package/api-extractor/api-extractor.legacy.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/id-compressor.legacy.public.api.md +41 -0
  7. package/dist/finalSpace.d.ts.map +1 -1
  8. package/dist/finalSpace.js +2 -2
  9. package/dist/finalSpace.js.map +1 -1
  10. package/dist/idCompressor.d.ts.map +1 -1
  11. package/dist/idCompressor.js +3 -1
  12. package/dist/idCompressor.js.map +1 -1
  13. package/dist/legacy.d.ts +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.d.ts.map +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/dist/persistanceUtilities.d.ts.map +1 -1
  19. package/dist/persistanceUtilities.js +5 -0
  20. package/dist/persistanceUtilities.js.map +1 -1
  21. package/dist/public.d.ts +1 -1
  22. package/dist/sessionSpaceNormalizer.d.ts.map +1 -1
  23. package/dist/sessionSpaceNormalizer.js +6 -3
  24. package/dist/sessionSpaceNormalizer.js.map +1 -1
  25. package/dist/sessions.d.ts.map +1 -1
  26. package/dist/sessions.js +6 -4
  27. package/dist/sessions.js.map +1 -1
  28. package/dist/types/identifiers.d.ts +1 -1
  29. package/dist/types/identifiers.js.map +1 -1
  30. package/internal.d.ts +1 -1
  31. package/legacy.d.ts +1 -1
  32. package/lib/finalSpace.d.ts.map +1 -1
  33. package/lib/finalSpace.js +2 -2
  34. package/lib/finalSpace.js.map +1 -1
  35. package/lib/idCompressor.d.ts.map +1 -1
  36. package/lib/idCompressor.js +3 -1
  37. package/lib/idCompressor.js.map +1 -1
  38. package/lib/legacy.d.ts +1 -1
  39. package/lib/packageVersion.d.ts +1 -1
  40. package/lib/packageVersion.d.ts.map +1 -1
  41. package/lib/packageVersion.js +1 -1
  42. package/lib/packageVersion.js.map +1 -1
  43. package/lib/persistanceUtilities.d.ts.map +1 -1
  44. package/lib/persistanceUtilities.js +5 -0
  45. package/lib/persistanceUtilities.js.map +1 -1
  46. package/lib/public.d.ts +1 -1
  47. package/lib/sessionSpaceNormalizer.d.ts.map +1 -1
  48. package/lib/sessionSpaceNormalizer.js +6 -3
  49. package/lib/sessionSpaceNormalizer.js.map +1 -1
  50. package/lib/sessions.d.ts.map +1 -1
  51. package/lib/sessions.js +6 -4
  52. package/lib/sessions.js.map +1 -1
  53. package/lib/types/identifiers.d.ts +1 -1
  54. package/lib/types/identifiers.js.map +1 -1
  55. package/package.json +21 -19
  56. package/src/finalSpace.ts +3 -2
  57. package/src/idCompressor.ts +6 -1
  58. package/src/packageVersion.ts +1 -1
  59. package/src/persistanceUtilities.ts +5 -0
  60. package/src/sessionSpaceNormalizer.ts +12 -3
  61. package/src/sessions.ts +7 -4
  62. package/src/types/identifiers.ts +1 -1
  63. package/tsconfig.json +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/id-compressor",
3
- "version": "2.1.0-276985",
3
+ "version": "2.1.0",
4
4
  "description": "ID compressor",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -79,24 +79,24 @@
79
79
  "temp-directory": "nyc/.nyc_output"
80
80
  },
81
81
  "dependencies": {
82
- "@fluid-internal/client-utils": "2.1.0-276985",
83
- "@fluidframework/core-interfaces": "2.1.0-276985",
84
- "@fluidframework/core-utils": "2.1.0-276985",
85
- "@fluidframework/telemetry-utils": "2.1.0-276985",
82
+ "@fluid-internal/client-utils": "~2.1.0",
83
+ "@fluidframework/core-interfaces": "~2.1.0",
84
+ "@fluidframework/core-utils": "~2.1.0",
85
+ "@fluidframework/telemetry-utils": "~2.1.0",
86
86
  "@tylerbu/sorted-btree-es6": "^1.8.0",
87
87
  "uuid": "^9.0.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@arethetypeswrong/cli": "^0.15.2",
91
- "@biomejs/biome": "^1.7.3",
92
- "@fluid-internal/mocha-test-setup": "2.1.0-276985",
93
- "@fluid-private/stochastic-test-utils": "2.1.0-276985",
91
+ "@biomejs/biome": "~1.8.3",
92
+ "@fluid-internal/mocha-test-setup": "~2.1.0",
93
+ "@fluid-private/stochastic-test-utils": "~2.1.0",
94
94
  "@fluid-tools/benchmark": "^0.48.0",
95
- "@fluid-tools/build-cli": "^0.39.0",
95
+ "@fluid-tools/build-cli": "^0.41.0",
96
96
  "@fluidframework/build-common": "^2.0.3",
97
- "@fluidframework/build-tools": "^0.39.0",
97
+ "@fluidframework/build-tools": "^0.41.0",
98
98
  "@fluidframework/eslint-config-fluid": "^5.3.0",
99
- "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.0.0-rc.5.0.0",
99
+ "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.0.0",
100
100
  "@microsoft/api-extractor": "^7.45.1",
101
101
  "@types/mocha": "^9.1.1",
102
102
  "@types/node": "^18.19.0",
@@ -122,18 +122,19 @@
122
122
  "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
123
123
  "api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
124
124
  "build": "fluid-build . --task build",
125
+ "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
126
+ "build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
127
+ "build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
125
128
  "build:commonjs": "fluid-build . --task commonjs",
126
129
  "build:compile": "fluid-build . --task compile",
127
- "build:docs": "concurrently \"npm:build:docs:*\"",
128
- "build:docs:current": "api-extractor run --local",
129
- "build:docs:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
130
+ "build:docs": "api-extractor run --local",
130
131
  "build:esnext": "tsc --project ./tsconfig.json",
131
132
  "build:genver": "gen-version",
132
133
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
133
134
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
134
135
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
135
136
  "check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./internal/test-utils",
136
- "check:biome": "biome check . --formatter-enabled=true",
137
+ "check:biome": "biome check .",
137
138
  "check:exports": "concurrently \"npm:check:exports:*\"",
138
139
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
139
140
  "check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
@@ -142,14 +143,15 @@
142
143
  "check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
143
144
  "check:format": "npm run check:biome",
144
145
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
145
- "ci:build:docs": "concurrently \"npm:ci:build:docs:*\"",
146
- "ci:build:docs:current": "api-extractor run",
147
- "ci:build:docs:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
146
+ "ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
147
+ "ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
148
+ "ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
149
+ "ci:build:docs": "api-extractor run",
148
150
  "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
149
151
  "eslint": "eslint --format stylish src",
150
152
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
151
153
  "format": "npm run format:biome",
152
- "format:biome": "biome check . --formatter-enabled=true --apply",
154
+ "format:biome": "biome check . --write",
153
155
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
154
156
  "lint": "fluid-build . --task lint",
155
157
  "lint:fix": "fluid-build . --task eslint:fix --task format",
package/src/finalSpace.ts CHANGED
@@ -63,11 +63,12 @@ export class FinalSpace {
63
63
  }
64
64
 
65
65
  public equals(other: FinalSpace): boolean {
66
- for (let i = 0; i < this.clusterList.length; i++) {
67
- if (!clustersEqual(this.clusterList[i], other.clusterList[i])) {
66
+ for (const [index, value] of Object.entries(this.clusterList)) {
67
+ if (!clustersEqual(value, other.clusterList[index])) {
68
68
  return false;
69
69
  }
70
70
  }
71
+
71
72
  return this.clusterList.length === other.clusterList.length;
72
73
  }
73
74
  }
@@ -697,7 +697,12 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
697
697
  let baseFinalId = 0;
698
698
  for (let i = 0; i < clusterCount; i++) {
699
699
  const sessionIndex = readNumber(index);
700
- const session = sessions[sessionIndex + sessionOffset][1];
700
+ const sessionArray = sessions[sessionIndex + sessionOffset];
701
+ assert(
702
+ sessionArray !== undefined,
703
+ 0x9d8 /* sessionArray is undefined in IdCompressor.deserialize2_0 */,
704
+ );
705
+ const session = sessionArray[1];
701
706
  const capacity = readNumber(index);
702
707
  const count = readNumber(index);
703
708
  const cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/id-compressor";
9
- export const pkgVersion = "2.1.0-276985";
9
+ export const pkgVersion = "2.1.0";
@@ -4,6 +4,8 @@
4
4
  */
5
5
 
6
6
  /* eslint-disable no-bitwise */
7
+ import { assert } from "@fluidframework/core-utils/internal";
8
+
7
9
  import { NumericUuid } from "./identifiers.js";
8
10
 
9
11
  const halfNumeric = BigInt("0xFFFFFFFFFFFFFFFF");
@@ -41,13 +43,16 @@ export interface Index {
41
43
 
42
44
  export function readNumber(index: Index): number {
43
45
  const value = index.bufferFloat[index.index];
46
+ assert(value !== undefined, 0x9d9 /* value is undefined in readNumber */);
44
47
  index.index += 1;
45
48
  return value;
46
49
  }
47
50
 
48
51
  export function readNumericUuid(index: Index): NumericUuid {
49
52
  const lowerHalf = index.bufferUint[index.index];
53
+ assert(lowerHalf !== undefined, 0x9da /* lowerHalf is undefined in readNumericUuid */);
50
54
  const upperHalf = index.bufferUint[index.index + 1];
55
+ assert(upperHalf !== undefined, 0x9db /* upperHalf is undefined in readNumericUuid */);
51
56
  const value = (upperHalf << sixtyFour) | lowerHalf;
52
57
  index.index += 2;
53
58
  return value as NumericUuid;
@@ -75,6 +75,10 @@ export class SessionSpaceNormalizer {
75
75
  if (ranges.length === 0) {
76
76
  return ranges;
77
77
  }
78
+ assert(
79
+ ranges[0] !== undefined,
80
+ 0x9dd /* ranges[0] is undefined in SessionSpaceNormalizer.getRangesBetween */,
81
+ );
78
82
 
79
83
  // now we touch up the first and last ranges to ensure that if they contain the
80
84
  // queried IDs they are trimmed to start/end with the queried IDs
@@ -93,11 +97,16 @@ export class SessionSpaceNormalizer {
93
97
  }
94
98
 
95
99
  const lastRangeIndex = ranges.length - 1;
96
- const [limitGenCount, limitCount] = ranges[lastRangeIndex];
97
- if (this.rangeContains(ranges[lastRangeIndex], lastGenCount)) {
100
+ const lastRange = ranges[lastRangeIndex];
101
+ assert(
102
+ lastRange !== undefined,
103
+ 0x9de /* lastRange is undefined in SessionSpaceNormalizer.getRangesBetween */,
104
+ );
105
+ const [limitGenCount, limitCount] = lastRange;
106
+ if (this.rangeContains(lastRange, lastGenCount)) {
98
107
  ranges[lastRangeIndex] = [limitGenCount, lastGenCount - limitGenCount + 1];
99
108
  assert(
100
- this.rangeContains(ranges[lastRangeIndex], lastGenCount),
109
+ this.rangeContains(lastRange, lastGenCount),
101
110
  0x954 /* Expected the touched up range to contain the queried ID */,
102
111
  );
103
112
  } else {
package/src/sessions.ts CHANGED
@@ -280,9 +280,11 @@ export class Session {
280
280
  let right = arr.length - 1;
281
281
  while (left <= right) {
282
282
  const mid = Math.floor((left + right) / 2);
283
- const c = comparator(search, arr[mid]);
283
+ const value = arr[mid];
284
+ assert(value !== undefined, 0x9dc /* value is undefined in Session.binarySearch */);
285
+ const c = comparator(search, value);
284
286
  if (c === 0) {
285
- return arr[mid]; // Found the target, return its index.
287
+ return value; // Found the target, return its index.
286
288
  } else if (c > 0) {
287
289
  left = mid + 1; // Continue search on right half.
288
290
  } else {
@@ -293,11 +295,12 @@ export class Session {
293
295
  }
294
296
 
295
297
  public equals(other: Session): boolean {
296
- for (let i = 0; i < this.clusterChain.length; i++) {
297
- if (!clustersEqual(this.clusterChain[i], other.clusterChain[i])) {
298
+ for (const [index, value] of Object.entries(this.clusterChain)) {
299
+ if (!clustersEqual(value, other.clusterChain[index])) {
298
300
  return false;
299
301
  }
300
302
  }
303
+
301
304
  return this.sessionUuid === other.sessionUuid;
302
305
  }
303
306
  }
@@ -24,7 +24,7 @@ export type OpSpaceCompressedId = number & {
24
24
  };
25
25
 
26
26
  /**
27
- * A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
27
+ * A {@link https://datatracker.ietf.org/doc/html/rfc4122 | version 4, variant 1 uuid}.
28
28
  * A 128-bit Universally Unique IDentifier. Represented here
29
29
  * with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
30
30
  * where x is a lowercase hex digit.
package/tsconfig.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "rootDir": "./src",
5
5
  "outDir": "./lib",
6
6
  "exactOptionalPropertyTypes": false,
7
- "noUncheckedIndexedAccess": false,
8
7
  },
9
8
  "include": ["src/**/*"],
10
9
  "exclude": ["src/test/**/*"],