@fluidframework/id-compressor 2.13.0 → 2.20.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 (85) hide show
  1. package/.eslintrc.cjs +1 -4
  2. package/CHANGELOG.md +4 -0
  3. package/dist/appendOnlySortedMap.d.ts +37 -16
  4. package/dist/appendOnlySortedMap.d.ts.map +1 -1
  5. package/dist/appendOnlySortedMap.js +39 -21
  6. package/dist/appendOnlySortedMap.js.map +1 -1
  7. package/dist/finalSpace.d.ts +2 -2
  8. package/dist/finalSpace.d.ts.map +1 -1
  9. package/dist/finalSpace.js +5 -4
  10. package/dist/finalSpace.js.map +1 -1
  11. package/dist/idCompressor.d.ts.map +1 -1
  12. package/dist/idCompressor.js +18 -15
  13. package/dist/idCompressor.js.map +1 -1
  14. package/dist/identifiers.d.ts +1 -1
  15. package/dist/identifiers.js +1 -1
  16. package/dist/identifiers.js.map +1 -1
  17. package/dist/package.json +2 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/dist/sessions.js.map +1 -1
  22. package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  23. package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
  24. package/dist/test/idCompressor.perf.spec.js.map +1 -1
  25. package/dist/test/idCompressor.spec.js.map +1 -1
  26. package/dist/test/idCompressorTestUtilities.d.ts +39 -13
  27. package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
  28. package/dist/test/idCompressorTestUtilities.js +67 -56
  29. package/dist/test/idCompressorTestUtilities.js.map +1 -1
  30. package/dist/test/numericUuid.spec.js.map +1 -1
  31. package/dist/test/sessionSpaceNormalizer.spec.js.map +1 -1
  32. package/dist/test/snapshots/summary.spec.js.map +1 -1
  33. package/dist/test/testCommon.d.ts +5 -1
  34. package/dist/test/testCommon.d.ts.map +1 -1
  35. package/dist/test/testCommon.js +2 -0
  36. package/dist/test/testCommon.js.map +1 -1
  37. package/dist/utilities.d.ts.map +1 -1
  38. package/dist/utilities.js +11 -6
  39. package/dist/utilities.js.map +1 -1
  40. package/lib/appendOnlySortedMap.d.ts +37 -16
  41. package/lib/appendOnlySortedMap.d.ts.map +1 -1
  42. package/lib/appendOnlySortedMap.js +39 -21
  43. package/lib/appendOnlySortedMap.js.map +1 -1
  44. package/lib/finalSpace.d.ts +2 -2
  45. package/lib/finalSpace.d.ts.map +1 -1
  46. package/lib/finalSpace.js +5 -4
  47. package/lib/finalSpace.js.map +1 -1
  48. package/lib/idCompressor.d.ts.map +1 -1
  49. package/lib/idCompressor.js +18 -15
  50. package/lib/idCompressor.js.map +1 -1
  51. package/lib/identifiers.d.ts +1 -1
  52. package/lib/identifiers.js +1 -1
  53. package/lib/identifiers.js.map +1 -1
  54. package/lib/packageVersion.d.ts +1 -1
  55. package/lib/packageVersion.js +1 -1
  56. package/lib/packageVersion.js.map +1 -1
  57. package/lib/sessions.js.map +1 -1
  58. package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  59. package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
  60. package/lib/test/idCompressor.perf.spec.js.map +1 -1
  61. package/lib/test/idCompressor.spec.js.map +1 -1
  62. package/lib/test/idCompressorTestUtilities.d.ts +39 -13
  63. package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
  64. package/lib/test/idCompressorTestUtilities.js +42 -31
  65. package/lib/test/idCompressorTestUtilities.js.map +1 -1
  66. package/lib/test/numericUuid.spec.js.map +1 -1
  67. package/lib/test/sessionSpaceNormalizer.spec.js.map +1 -1
  68. package/lib/test/snapshots/summary.spec.js.map +1 -1
  69. package/lib/test/testCommon.d.ts +5 -1
  70. package/lib/test/testCommon.d.ts.map +1 -1
  71. package/lib/test/testCommon.js +2 -0
  72. package/lib/test/testCommon.js.map +1 -1
  73. package/lib/utilities.d.ts.map +1 -1
  74. package/lib/utilities.js +11 -6
  75. package/lib/utilities.js.map +1 -1
  76. package/package.json +8 -8
  77. package/src/appendOnlySortedMap.ts +39 -21
  78. package/src/finalSpace.ts +6 -5
  79. package/src/idCompressor.ts +22 -18
  80. package/src/identifiers.ts +1 -1
  81. package/src/packageVersion.ts +1 -1
  82. package/src/sessions.ts +2 -2
  83. package/src/test/idCompressorTestUtilities.ts +69 -40
  84. package/src/test/testCommon.ts +5 -1
  85. package/src/utilities.ts +12 -7
@@ -1 +1 @@
1
- {"version":3,"file":"sessionSpaceNormalizer.spec.js","sourceRoot":"","sources":["../../src/test/sessionSpaceNormalizer.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACvB,MAAM,UAAU,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACjD,MAAM,UAAU,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAChD,UAAU,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACzD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC,CAA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AAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\n\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\n\nimport { makeLocalId } from \"./testCommon.js\";\n\ndescribe(\"SessionSpaceNormalizer\", () => {\n\tit(\"can be empty\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), false);\n\t});\n\n\tit(\"can answer queries with a single range\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 5);\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-2)), true);\n\t});\n\n\tit(\"can answer queries with discontiguous ranges\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 2);\n\t\tnormalizer.addLocalRange(6, 4);\n\t\tnormalizer.addLocalRange(15, 1);\n\t\tassert.equal(normalizer.contains(makeLocalId(-11)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-3)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-7)), true);\n\t});\n\n\tit(\"can answer queries with contiguous ranges\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 2);\n\t\tnormalizer.addLocalRange(3, 4);\n\t\tnormalizer.addLocalRange(15, 1);\n\t\tnormalizer.addLocalRange(16, 2);\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-4)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-6)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-7)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-8)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-15)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-17)), true);\n\t});\n\n\tit(\"can compute the ranges between a query\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 10), []);\n\n\t\tnormalizer.addLocalRange(2, 1);\n\t\tnormalizer.addLocalRange(4, 3);\n\t\tnormalizer.addLocalRange(9, 1);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 10), [\n\t\t\t[2, 1],\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(2, 9), [\n\t\t\t[2, 1],\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 9), [\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 8), [[4, 3]]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(5, 9), [\n\t\t\t[5, 2],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 5), [\n\t\t\t[2, 1],\n\t\t\t[4, 2],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(4, 4), [[4, 1]]);\n\t\tassert.deepEqual(normalizer.getRangesBetween(5, 5), [[5, 1]]);\n\t\tassert.deepEqual(normalizer.getRangesBetween(6, 6), [[6, 1]]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 3), []);\n\t});\n});\n"]}
1
+ {"version":3,"file":"sessionSpaceNormalizer.spec.js","sourceRoot":"","sources":["../../src/test/sessionSpaceNormalizer.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAE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SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YACnD,CAAC,CAAC,EAAE,CAAC,CAAC;YACN,CAAC,CAAC,EAAE,CAAC,CAAC;SACN,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YACnD,CAAC,CAAC,EAAE,CAAC,CAAC;YACN,CAAC,CAAC,EAAE,CAAC,CAAC;SACN,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-nodejs-modules */\nimport { strict as assert } from \"node:assert\";\n\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\n\nimport { makeLocalId } from \"./testCommon.js\";\n\ndescribe(\"SessionSpaceNormalizer\", () => {\n\tit(\"can be empty\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), false);\n\t});\n\n\tit(\"can answer queries with a single range\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 5);\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-2)), true);\n\t});\n\n\tit(\"can answer queries with discontiguous ranges\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 2);\n\t\tnormalizer.addLocalRange(6, 4);\n\t\tnormalizer.addLocalRange(15, 1);\n\t\tassert.equal(normalizer.contains(makeLocalId(-11)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-3)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-7)), true);\n\t});\n\n\tit(\"can answer queries with contiguous ranges\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\t\tnormalizer.addLocalRange(1, 2);\n\t\tnormalizer.addLocalRange(3, 4);\n\t\tnormalizer.addLocalRange(15, 1);\n\t\tnormalizer.addLocalRange(16, 2);\n\t\tassert.equal(normalizer.contains(makeLocalId(-1)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-4)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-6)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-7)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-8)), false);\n\t\tassert.equal(normalizer.contains(makeLocalId(-15)), true);\n\t\tassert.equal(normalizer.contains(makeLocalId(-17)), true);\n\t});\n\n\tit(\"can compute the ranges between a query\", () => {\n\t\tconst normalizer = new SessionSpaceNormalizer();\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 10), []);\n\n\t\tnormalizer.addLocalRange(2, 1);\n\t\tnormalizer.addLocalRange(4, 3);\n\t\tnormalizer.addLocalRange(9, 1);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 10), [\n\t\t\t[2, 1],\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(2, 9), [\n\t\t\t[2, 1],\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 9), [\n\t\t\t[4, 3],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 8), [[4, 3]]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(5, 9), [\n\t\t\t[5, 2],\n\t\t\t[9, 1],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(1, 5), [\n\t\t\t[2, 1],\n\t\t\t[4, 2],\n\t\t]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(4, 4), [[4, 1]]);\n\t\tassert.deepEqual(normalizer.getRangesBetween(5, 5), [[5, 1]]);\n\t\tassert.deepEqual(normalizer.getRangesBetween(6, 6), [[6, 1]]);\n\n\t\tassert.deepEqual(normalizer.getRangesBetween(3, 3), []);\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"summary.spec.js","sourceRoot":"","sources":["../../../src/test/snapshots/summary.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6CAA6C;AAE7C,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAChF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAa,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,mBAAmB,GAAG,OAAO,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Q,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE9C,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-nodejs-modules */\n\nimport { strict as assert } from \"assert\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"fs\";\nimport path from \"path\";\n\nimport { SessionId, createIdCompressor } from \"../../index.js\";\n\nimport { _dirname } from \"./dirname.cjs\";\n\nconst regenerateSnapshots = process.argv.includes(\"--snapshot\");\n\nlet currentTestName: string | undefined;\nlet currentTestFile: string | undefined;\n\n// Simple filter to avoid tests with a name that would accidentally be parsed as directory traversal or other confusing things.\nconst nameCheck = new RegExp(/^[^\"/\\\\]+$/);\n\nassert(_dirname.match(/(dist|lib)[/\\\\]test[/\\\\]snapshots$/));\nconst snapshotsFolder = path.join(_dirname, `../../../src/test/snapshots`);\nassert(existsSync(snapshotsFolder));\n\n/**\n * Delete the existing test file directory and recreate it.\n *\n * If the directory does not already exist, this will create it.\n *\n * @param dirPath - The path within the `snapshots` directory.\n */\nfunction useSnapshotDirectory(dirPath: string = \"files\"): void {\n\tconst normalizedDir = path.join(snapshotsFolder, dirPath);\n\t// Basic sanity check to avoid bugs like accidentally recursively deleting everything under `/` if something went wrong (like dirPath navigated up directories a lot).\n\tassert(normalizedDir.startsWith(snapshotsFolder));\n\n\tif (regenerateSnapshots) {\n\t\tif (existsSync(normalizedDir)) {\n\t\t\tconsole.log(`removing snapshot directory: ${normalizedDir}`);\n\t\t\trmSync(normalizedDir, { recursive: true, force: true });\n\t\t}\n\t\tmkdirSync(normalizedDir, { recursive: true });\n\t}\n\n\tbeforeEach(function (): void {\n\t\tcurrentTestName = this.currentTest?.title.replace(/ /g, \"-\") ?? assert.fail();\n\t\tcurrentTestFile = path.join(normalizedDir, currentTestName);\n\t});\n\n\tafterEach(() => {\n\t\tcurrentTestFile = undefined;\n\t\tcurrentTestName = undefined;\n\t});\n}\n\nfunction takeSnapshot(data: string, suffix: string = \"\"): void {\n\tassert(\n\t\tcurrentTestName !== undefined,\n\t\t\"use `useSnapshotDirectory` to configure the tests containing describe block to take snapshots\",\n\t);\n\tassert(currentTestFile !== undefined);\n\n\t// Ensure test name doesn't accidentally navigate up directories or things like that.\n\t// Done here instead of in beforeEach so errors surface better.\n\tif (nameCheck.test(currentTestName) === false) {\n\t\tassert.fail(`Expected test name to pass sanitization: \"${currentTestName}\"`);\n\t}\n\n\tconst fullFile = currentTestFile + suffix;\n\n\tconst exists = existsSync(fullFile);\n\tif (regenerateSnapshots) {\n\t\tassert(exists === false, \"snapshot should not already exist: possible name collision.\");\n\t\twriteFileSync(fullFile, data);\n\t} else {\n\t\tassert(exists, `test snapshot file does not exist: \"${fullFile}\"`);\n\t\tconst pastData = readFileSync(fullFile, \"utf-8\");\n\t\tassert.equal(data, pastData, `snapshot different for \"${currentTestName}\"`);\n\t}\n}\n\ndescribe(\"snapshot tests\", () => {\n\tconst client1 = \"403f1e16-5265-4074-8507-417d99a05ee9\" as SessionId;\n\tconst client2 = \"4b02675a-5a81-428d-b7b7-d8c33a16bfde\" as SessionId;\n\n\tuseSnapshotDirectory();\n\n\tit(\"empty compressor summary\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst summary = compressor.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t});\n\n\tit(\"compressor with finalized range from one client\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"compressors with finalized ranges from two clients\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t\tcompressor2.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tconst idRange2 = compressor2.takeNextCreationRange();\n\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\t\tcompressor.finalizeCreationRange(idRange2);\n\t\tcompressor2.finalizeCreationRange(idRange2);\n\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"expansion semantics\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tcompressor[\"nextRequestedClusterSize\"] = 2;\n\t\tcompressor.generateCompressedId();\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\n\t\tfor (let i = 0; i < 3; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\n\t\tconst expansionIdRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(expansionIdRange);\n\t\tcompressor2.finalizeCreationRange(expansionIdRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n});\n"]}
1
+ {"version":3,"file":"summary.spec.js","sourceRoot":"","sources":["../../../src/test/snapshots/summary.spec.ts"],"names":[],"mappings":"AAAA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AC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;QAC5D,UAAU,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACnD,WAAW,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE9C,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-nodejs-modules */\n\nimport { strict as assert } from \"node:assert\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { SessionId, createIdCompressor } from \"../../index.js\";\n\nimport { _dirname } from \"./dirname.cjs\";\n\nconst regenerateSnapshots = process.argv.includes(\"--snapshot\");\n\nlet currentTestName: string | undefined;\nlet currentTestFile: string | undefined;\n\n// Simple filter to avoid tests with a name that would accidentally be parsed as directory traversal or other confusing things.\nconst nameCheck = new RegExp(/^[^\"/\\\\]+$/);\n\nassert(_dirname.match(/(dist|lib)[/\\\\]test[/\\\\]snapshots$/));\nconst snapshotsFolder = path.join(_dirname, `../../../src/test/snapshots`);\nassert(existsSync(snapshotsFolder));\n\n/**\n * Delete the existing test file directory and recreate it.\n *\n * If the directory does not already exist, this will create it.\n *\n * @param dirPath - The path within the `snapshots` directory.\n */\nfunction useSnapshotDirectory(dirPath: string = \"files\"): void {\n\tconst normalizedDir = path.join(snapshotsFolder, dirPath);\n\t// Basic sanity check to avoid bugs like accidentally recursively deleting everything under `/` if something went wrong (like dirPath navigated up directories a lot).\n\tassert(normalizedDir.startsWith(snapshotsFolder));\n\n\tif (regenerateSnapshots) {\n\t\tif (existsSync(normalizedDir)) {\n\t\t\tconsole.log(`removing snapshot directory: ${normalizedDir}`);\n\t\t\trmSync(normalizedDir, { recursive: true, force: true });\n\t\t}\n\t\tmkdirSync(normalizedDir, { recursive: true });\n\t}\n\n\tbeforeEach(function (): void {\n\t\tcurrentTestName = this.currentTest?.title.replace(/ /g, \"-\") ?? assert.fail();\n\t\tcurrentTestFile = path.join(normalizedDir, currentTestName);\n\t});\n\n\tafterEach(() => {\n\t\tcurrentTestFile = undefined;\n\t\tcurrentTestName = undefined;\n\t});\n}\n\nfunction takeSnapshot(data: string, suffix: string = \"\"): void {\n\tassert(\n\t\tcurrentTestName !== undefined,\n\t\t\"use `useSnapshotDirectory` to configure the tests containing describe block to take snapshots\",\n\t);\n\tassert(currentTestFile !== undefined);\n\n\t// Ensure test name doesn't accidentally navigate up directories or things like that.\n\t// Done here instead of in beforeEach so errors surface better.\n\tif (nameCheck.test(currentTestName) === false) {\n\t\tassert.fail(`Expected test name to pass sanitization: \"${currentTestName}\"`);\n\t}\n\n\tconst fullFile = currentTestFile + suffix;\n\n\tconst exists = existsSync(fullFile);\n\tif (regenerateSnapshots) {\n\t\tassert(exists === false, \"snapshot should not already exist: possible name collision.\");\n\t\twriteFileSync(fullFile, data);\n\t} else {\n\t\tassert(exists, `test snapshot file does not exist: \"${fullFile}\"`);\n\t\tconst pastData = readFileSync(fullFile, \"utf8\");\n\t\tassert.equal(data, pastData, `snapshot different for \"${currentTestName}\"`);\n\t}\n}\n\ndescribe(\"snapshot tests\", () => {\n\tconst client1 = \"403f1e16-5265-4074-8507-417d99a05ee9\" as SessionId;\n\tconst client2 = \"4b02675a-5a81-428d-b7b7-d8c33a16bfde\" as SessionId;\n\n\tuseSnapshotDirectory();\n\n\tit(\"empty compressor summary\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst summary = compressor.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t});\n\n\tit(\"compressor with finalized range from one client\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"compressors with finalized ranges from two clients\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t\tcompressor2.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tconst idRange2 = compressor2.takeNextCreationRange();\n\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\t\tcompressor.finalizeCreationRange(idRange2);\n\t\tcompressor2.finalizeCreationRange(idRange2);\n\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"expansion semantics\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tcompressor[\"nextRequestedClusterSize\"] = 2;\n\t\tcompressor.generateCompressedId();\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\n\t\tfor (let i = 0; i < 3; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\n\t\tconst expansionIdRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(expansionIdRange);\n\t\tcompressor2.finalizeCreationRange(expansionIdRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n});\n"]}
@@ -26,10 +26,12 @@ export type LocalCompressedId = number & {
26
26
  readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
27
27
  } & SessionSpaceCompressedId;
28
28
  /**
29
+ * Returns true if the supplied ID is a final ID.
29
30
  * @returns true if the supplied ID is a final ID.
30
31
  */
31
32
  export declare function isFinalId(id: CompressedId): id is FinalCompressedId;
32
33
  /**
34
+ * Returns true if the supplied ID is a local ID.
33
35
  * @returns true if the supplied ID is a local ID.
34
36
  */
35
37
  export declare function isLocalId(id: CompressedId): id is LocalCompressedId;
@@ -52,7 +54,9 @@ export type Mutable<T> = {
52
54
  */
53
55
  export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V;
54
56
  export declare function incrementStableId(stableId: StableId, offset: number): StableId;
55
- /** An immutable view of an `IdCompressor` */
57
+ /**
58
+ * An immutable view of an `IdCompressor`
59
+ */
56
60
  export type ReadonlyIdCompressor = Omit<IdCompressor, "generateCompressedId" | "generateCompressedIdRange" | "takeNextCreationRange" | "finalizeCreationRange">;
57
61
  /**
58
62
  * Asserts a value is not undefined, and returns the value.
@@ -1 +1 @@
1
- {"version":3,"file":"testCommon.d.ts","sourceRoot":"","sources":["../../src/test/testCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOtF;;;GAGG;AACH,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;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAOxF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAE9E;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACtC,YAAY,EACV,sBAAsB,GACtB,2BAA2B,GAC3B,uBAAuB,GACvB,uBAAuB,CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,GAAG,SAAS,EACpB,OAAO,SAAgC,GACrC,CAAC,CAGH;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE3C"}
@@ -5,12 +5,14 @@
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
6
  import { numericUuidFromStableId, offsetNumericUuid, stableIdFromNumericUuid, } from "../utilities.js";
7
7
  /**
8
+ * Returns true if the supplied ID is a final ID.
8
9
  * @returns true if the supplied ID is a final ID.
9
10
  */
10
11
  export function isFinalId(id) {
11
12
  return id >= 0;
12
13
  }
13
14
  /**
15
+ * Returns true if the supplied ID is a local ID.
14
16
  * @returns true if the supplied ID is a local ID.
15
17
  */
16
18
  export function isLocalId(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"testCommon.js","sourceRoot":"","sources":["../../src/test/testCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,iBAAiB,CAAC;AAgCzB;;GAE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served.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from \"../index.js\";\nimport {\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n} from \"../utilities.js\";\n\n/**\n * An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.\n * Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.\n */\nexport type CompressedId =\n\t| SessionSpaceCompressedId\n\t| OpSpaceCompressedId\n\t| FinalCompressedId\n\t| LocalCompressedId;\n\n/**\n * A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).\n * It can only be used/decompressed in the context of the originating document.\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: \"5d83d1e2-98b7-4e4e-a889-54c855cfa73d\";\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: \"9209432d-a959-4df7-b2ad-767ead4dbcae\";\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: \"6fccb42f-e2a4-4243-bd29-f13d12b9c6d1\";\n} & SessionSpaceCompressedId; // Same brand as CompressedId, as local IDs are always locally normalized\n\n/**\n * @returns true if the supplied ID is a final ID.\n */\nexport function isFinalId(id: CompressedId): id is FinalCompressedId {\n\treturn id >= 0;\n}\n\n/**\n * @returns true if the supplied ID is a local ID.\n */\nexport function isLocalId(id: CompressedId): id is LocalCompressedId {\n\treturn id < 0;\n}\n\n/**\n * Turns a negative integer into a local compressed ID. For testing only.\n */\nexport function makeLocalId(negativeInteger: number): LocalCompressedId {\n\tconst id = negativeInteger as CompressedId;\n\tassert(isLocalId(id), \"Not a negative integer.\");\n\treturn id;\n}\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\nexport function incrementStableId(stableId: StableId, offset: number): StableId {\n\treturn stableIdFromNumericUuid(offsetNumericUuid(numericUuidFromStableId(stableId), offset));\n}\n\n/** An immutable view of an `IdCompressor` */\nexport type ReadonlyIdCompressor = Omit<\n\tIdCompressor,\n\t| \"generateCompressedId\"\n\t| \"generateCompressedIdRange\"\n\t| \"takeNextCreationRange\"\n\t| \"finalizeCreationRange\"\n>;\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n *\n * @remarks\n * When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.\n * Using `?? fail` allows for message formatting without incurring the cost of formatting the message\n * in the non failing case.\n *\n * Example:\n * ```typescript\n * x ?? fail(`x should exist for ${y}`)\n * ```\n *\n * Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.\n *\n * Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.\n * This pattern is preferred because it is more general (same approach works with typeof, instance of,\n * comparison to other values etc.).\n *\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(\n\tvalue: T | undefined,\n\tmessage = \"value must not be undefined\",\n): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails.\n */\nexport function fail(message: string): never {\n\tassert(false, message);\n}\n"]}
1
+ {"version":3,"file":"testCommon.js","sourceRoot":"","sources":["../../src/test/testCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,iBAAiB,CAAC;AAgCzB;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAgB;IACzC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAgB;IACzC,OAAO,EAAE,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,eAAuB;IAClD,MAAM,EAAE,GAAG,eAA+B,CAAC;IAC3C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,yBAAyB,CAAC,CAAC;IACjD,OAAO,EAAE,CAAC;AACX,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAO,GAAc,EAAE,GAAM,EAAE,YAA2B;IACpF,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,MAAc;IACnE,OAAO,uBAAuB,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9F,CAAC;AAaD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAoB,EACpB,OAAO,GAAG,6BAA6B;IAEvC,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from \"../index.js\";\nimport {\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n} from \"../utilities.js\";\n\n/**\n * An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.\n * Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.\n */\nexport type CompressedId =\n\t| SessionSpaceCompressedId\n\t| OpSpaceCompressedId\n\t| FinalCompressedId\n\t| LocalCompressedId;\n\n/**\n * A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).\n * It can only be used/decompressed in the context of the originating document.\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: \"5d83d1e2-98b7-4e4e-a889-54c855cfa73d\";\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: \"9209432d-a959-4df7-b2ad-767ead4dbcae\";\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: \"6fccb42f-e2a4-4243-bd29-f13d12b9c6d1\";\n} & SessionSpaceCompressedId; // Same brand as CompressedId, as local IDs are always locally normalized\n\n/**\n * Returns true if the supplied ID is a final ID.\n * @returns true if the supplied ID is a final ID.\n */\nexport function isFinalId(id: CompressedId): id is FinalCompressedId {\n\treturn id >= 0;\n}\n\n/**\n * Returns true if the supplied ID is a local ID.\n * @returns true if the supplied ID is a local ID.\n */\nexport function isLocalId(id: CompressedId): id is LocalCompressedId {\n\treturn id < 0;\n}\n\n/**\n * Turns a negative integer into a local compressed ID. For testing only.\n */\nexport function makeLocalId(negativeInteger: number): LocalCompressedId {\n\tconst id = negativeInteger as CompressedId;\n\tassert(isLocalId(id), \"Not a negative integer.\");\n\treturn id;\n}\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\nexport function incrementStableId(stableId: StableId, offset: number): StableId {\n\treturn stableIdFromNumericUuid(offsetNumericUuid(numericUuidFromStableId(stableId), offset));\n}\n\n/**\n * An immutable view of an `IdCompressor`\n */\nexport type ReadonlyIdCompressor = Omit<\n\tIdCompressor,\n\t| \"generateCompressedId\"\n\t| \"generateCompressedIdRange\"\n\t| \"takeNextCreationRange\"\n\t| \"finalizeCreationRange\"\n>;\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n *\n * @remarks\n * When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.\n * Using `?? fail` allows for message formatting without incurring the cost of formatting the message\n * in the non failing case.\n *\n * Example:\n * ```typescript\n * x ?? fail(`x should exist for ${y}`)\n * ```\n *\n * Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.\n *\n * Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.\n * This pattern is preferred because it is more general (same approach works with typeof, instance of,\n * comparison to other values etc.).\n *\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(\n\tvalue: T | undefined,\n\tmessage = \"value must not be undefined\",\n): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails.\n */\nexport function fail(message: string): never {\n\tassert(false, message);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAmBvD;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAG3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAG7D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAuCvD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAA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gB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ,CA4CvD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAEtE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAEvE;AAeD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAWvE;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,QAAQ,CAY1E;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAEvF;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,WAAW,CAEhF;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,WAAW,CAE3E"}
package/lib/utilities.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /* eslint-disable no-bitwise */
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { v4 } from "uuid";
8
- const hexadecimalCharCodes = Array.from("09afAF").map((c) => c.charCodeAt(0));
8
+ const hexadecimalCharCodes = [..."09afAF"].map((c) => c.codePointAt(0));
9
9
  function isHexadecimalCharacter(charCode) {
10
10
  return ((charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||
11
11
  (charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||
@@ -55,16 +55,18 @@ export function isStableId(str) {
55
55
  case 8:
56
56
  case 13:
57
57
  case 18:
58
- case 23:
58
+ case 23: {
59
59
  if (str.charAt(i) !== "-") {
60
60
  return false;
61
61
  }
62
62
  break;
63
- case 14:
63
+ }
64
+ case 14: {
64
65
  if (str.charAt(i) !== "4") {
65
66
  return false;
66
67
  }
67
68
  break;
69
+ }
68
70
  case 19: {
69
71
  const char = str.charAt(i);
70
72
  if (char !== "8" && char !== "9" && char !== "a" && char !== "b") {
@@ -72,11 +74,14 @@ export function isStableId(str) {
72
74
  }
73
75
  break;
74
76
  }
75
- default:
76
- if (!isHexadecimalCharacter(str.charCodeAt(i))) {
77
+ default: {
78
+ const codePoint = str.codePointAt(i);
79
+ assert(codePoint !== undefined, 0xaaf /* Unexpected undefined code point */);
80
+ if (!isHexadecimalCharacter(codePoint)) {
77
81
  return false;
78
82
  }
79
83
  break;
84
+ }
80
85
  }
81
86
  }
82
87
  return true;
@@ -137,7 +142,7 @@ export function stableIdFromNumericUuid(numericUuid) {
137
142
  const uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;
138
143
  // Pad to 32 characters, inserting leading zeroes if needed
139
144
  const uuidString = uuidU128.toString(16).padStart(32, "0");
140
- return `${uuidString.substring(0, 8)}-${uuidString.substring(8, 12)}-${uuidString.substring(12, 16)}-${uuidString.substring(16, 20)}-${uuidString.substring(20, 32)}`;
145
+ return `${uuidString.slice(0, 8)}-${uuidString.slice(8, 12)}-${uuidString.slice(12, 16)}-${uuidString.slice(16, 20)}-${uuidString.slice(20, 32)}`;
141
146
  }
142
147
  export function offsetNumericUuid(numericUuid, offset) {
143
148
  return (numericUuid + BigInt(offset));
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts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,MAAM,CAAC,MAAM,CAAC,CAAgB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAc,EAAE,CAAc;IAClE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAc,EAAE,CAAc;IAC7D,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { v4 } from \"uuid\";\n\nimport { LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport { SessionId, StableId } from \"./types/index.js\";\n\nconst hexadecimalCharCodes = Array.from(\"09afAF\").map((c) => c.charCodeAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number,\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/**\n * Generate a random session ID\n * @legacy\n * @alpha\n */\nexport function createSessionId(): SessionId {\n\treturn assertIsStableId(v4()) as SessionId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n * @internal\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), 0x4a3 /* Expected a StableId */);\n\treturn stableId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsSessionId(stableId: string): SessionId {\n\tassertIsStableId(stableId);\n\treturn stableId as SessionId;\n}\n\n/**\n * Generate a random stable ID\n * @internal\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n * @internal\n */\nexport function isStableId(str: string): str is StableId {\n\tif (str.length !== 36) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23:\n\t\t\t\tif (str.charAt(i) !== \"-\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 14:\n\t\t\t\tif (str.charAt(i) !== \"4\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 19: {\n\t\t\t\tconst char = str.charAt(i);\n\t\t\t\tif (char !== \"8\" && char !== \"9\" && char !== \"a\" && char !== \"b\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tif (!isHexadecimalCharacter(str.charCodeAt(i))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * A numeric comparator used for sorting in ascending order.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares bigints to form a strict partial ordering.\n */\nexport function compareBigints<T extends bigint>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\nexport function genCountFromLocalId(localId: LocalCompressedId): number {\n\treturn -localId;\n}\n\nexport function localIdFromGenCount(genCount: number): LocalCompressedId {\n\treturn -genCount as LocalCompressedId;\n}\n\n// xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx\nconst versionMask = 0x4n << (19n * 4n); // Version 4\nconst variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)\nconst upperMask = 0xffffffffffffn << (20n * 4n);\n// Upper mask when version/variant bits are removed\nconst strippedUpperMask = upperMask >> 6n;\nconst middieBittiesMask = 0xfffn << (16n * 4n);\n// Middie mask when version/variant bits are removed\nconst strippedMiddieBittiesMask = middieBittiesMask >> 2n;\n// Note: leading character should be 3 to mask at 0011\n// The more-significant half of the N nibble is used to denote the variant (10xx)\nconst lowerMask = 0x3fffffffffffffffn;\n\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuidU128 = BigInt(`0x${stableId.replace(/-/g, \"\")}`);\n\tconst upperMasked = uuidU128 & upperMask;\n\tconst middieBittiesMasked = uuidU128 & middieBittiesMask;\n\tconst lowerMasked = uuidU128 & lowerMask;\n\n\tconst upperMaskedPlaced = upperMasked >> 6n;\n\tconst middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;\n\n\tconst id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;\n\treturn id as NumericUuid;\n}\n\nexport function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId {\n\t// bitwise reverse transform\n\tconst upperMasked = (numericUuid & strippedUpperMask) << 6n;\n\tconst middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;\n\tconst lowerMasked = numericUuid & lowerMask;\n\tconst uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;\n\t// Pad to 32 characters, inserting leading zeroes if needed\n\tconst uuidString = uuidU128.toString(16).padStart(32, \"0\");\n\treturn `${uuidString.substring(0, 8)}-${uuidString.substring(8, 12)}-${uuidString.substring(\n\t\t12,\n\t\t16,\n\t)}-${uuidString.substring(16, 20)}-${uuidString.substring(20, 32)}` as StableId;\n}\n\nexport function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid {\n\treturn (numericUuid + BigInt(offset)) as NumericUuid;\n}\n\nexport function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a - b) as NumericUuid;\n}\n\nexport function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a + b) as NumericUuid;\n}\n"]}
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAK1B,MAAM,oBAAoB,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAOrE,CAAC;AAEF,SAAS,sBAAsB,CAAC,QAAgB;IAC/C,OAAO,CACN,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO,gBAAgB,CAAC,EAAE,EAAE,CAAc,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC9D,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,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AAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAC9E,EAAE,EACF,EAAE,CACF,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAc,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAwB,EAAE,MAAc;IACzE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAgB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAc,EAAE,CAAc;IAClE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAc,EAAE,CAAc;IAC7D,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { v4 } from \"uuid\";\n\nimport { LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport { SessionId, StableId } from \"./types/index.js\";\n\nconst hexadecimalCharCodes = [...\"09afAF\"].map((c) => c.codePointAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number,\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/**\n * Generate a random session ID\n * @legacy\n * @alpha\n */\nexport function createSessionId(): SessionId {\n\treturn assertIsStableId(v4()) as SessionId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n * @internal\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), 0x4a3 /* Expected a StableId */);\n\treturn stableId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsSessionId(stableId: string): SessionId {\n\tassertIsStableId(stableId);\n\treturn stableId as SessionId;\n}\n\n/**\n * Generate a random stable ID\n * @internal\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n * @internal\n */\nexport function isStableId(str: string): str is StableId {\n\tif (str.length !== 36) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23: {\n\t\t\t\tif (str.charAt(i) !== \"-\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 14: {\n\t\t\t\tif (str.charAt(i) !== \"4\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 19: {\n\t\t\t\tconst char = str.charAt(i);\n\t\t\t\tif (char !== \"8\" && char !== \"9\" && char !== \"a\" && char !== \"b\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tconst codePoint = str.codePointAt(i);\n\t\t\t\tassert(codePoint !== undefined, 0xaaf /* Unexpected undefined code point */);\n\t\t\t\tif (!isHexadecimalCharacter(codePoint)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * A numeric comparator used for sorting in ascending order.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares bigints to form a strict partial ordering.\n */\nexport function compareBigints<T extends bigint>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\nexport function genCountFromLocalId(localId: LocalCompressedId): number {\n\treturn -localId;\n}\n\nexport function localIdFromGenCount(genCount: number): LocalCompressedId {\n\treturn -genCount as LocalCompressedId;\n}\n\n// xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx\nconst versionMask = 0x4n << (19n * 4n); // Version 4\nconst variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)\nconst upperMask = 0xffffffffffffn << (20n * 4n);\n// Upper mask when version/variant bits are removed\nconst strippedUpperMask = upperMask >> 6n;\nconst middieBittiesMask = 0xfffn << (16n * 4n);\n// Middie mask when version/variant bits are removed\nconst strippedMiddieBittiesMask = middieBittiesMask >> 2n;\n// Note: leading character should be 3 to mask at 0011\n// The more-significant half of the N nibble is used to denote the variant (10xx)\nconst lowerMask = 0x3fffffffffffffffn;\n\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuidU128 = BigInt(`0x${stableId.replace(/-/g, \"\")}`);\n\tconst upperMasked = uuidU128 & upperMask;\n\tconst middieBittiesMasked = uuidU128 & middieBittiesMask;\n\tconst lowerMasked = uuidU128 & lowerMask;\n\n\tconst upperMaskedPlaced = upperMasked >> 6n;\n\tconst middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;\n\n\tconst id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;\n\treturn id as NumericUuid;\n}\n\nexport function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId {\n\t// bitwise reverse transform\n\tconst upperMasked = (numericUuid & strippedUpperMask) << 6n;\n\tconst middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;\n\tconst lowerMasked = numericUuid & lowerMask;\n\tconst uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;\n\t// Pad to 32 characters, inserting leading zeroes if needed\n\tconst uuidString = uuidU128.toString(16).padStart(32, \"0\");\n\treturn `${uuidString.slice(0, 8)}-${uuidString.slice(8, 12)}-${uuidString.slice(\n\t\t12,\n\t\t16,\n\t)}-${uuidString.slice(16, 20)}-${uuidString.slice(20, 32)}` as StableId;\n}\n\nexport function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid {\n\treturn (numericUuid + BigInt(offset)) as NumericUuid;\n}\n\nexport function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a - b) as NumericUuid;\n}\n\nexport function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a + b) as NumericUuid;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/id-compressor",
3
- "version": "2.13.0",
3
+ "version": "2.20.0",
4
4
  "description": "ID compressor",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -81,24 +81,24 @@
81
81
  "temp-directory": "nyc/.nyc_output"
82
82
  },
83
83
  "dependencies": {
84
- "@fluid-internal/client-utils": "~2.13.0",
85
- "@fluidframework/core-interfaces": "~2.13.0",
86
- "@fluidframework/core-utils": "~2.13.0",
87
- "@fluidframework/telemetry-utils": "~2.13.0",
84
+ "@fluid-internal/client-utils": "~2.20.0",
85
+ "@fluidframework/core-interfaces": "~2.20.0",
86
+ "@fluidframework/core-utils": "~2.20.0",
87
+ "@fluidframework/telemetry-utils": "~2.20.0",
88
88
  "@tylerbu/sorted-btree-es6": "^1.8.0",
89
89
  "uuid": "^9.0.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@arethetypeswrong/cli": "^0.17.1",
93
93
  "@biomejs/biome": "~1.9.3",
94
- "@fluid-internal/mocha-test-setup": "~2.13.0",
95
- "@fluid-private/stochastic-test-utils": "~2.13.0",
94
+ "@fluid-internal/mocha-test-setup": "~2.20.0",
95
+ "@fluid-private/stochastic-test-utils": "~2.20.0",
96
96
  "@fluid-tools/benchmark": "^0.50.0",
97
97
  "@fluid-tools/build-cli": "^0.51.0",
98
98
  "@fluidframework/build-common": "^2.0.3",
99
99
  "@fluidframework/build-tools": "^0.51.0",
100
100
  "@fluidframework/eslint-config-fluid": "^5.6.0",
101
- "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.12.0",
101
+ "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.13.0",
102
102
  "@microsoft/api-extractor": "7.47.8",
103
103
  "@types/mocha": "^10.0.10",
104
104
  "@types/node": "^18.19.0",
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- /* eslint-disable tsdoc/syntax */
7
6
  /* eslint-disable no-bitwise */
8
7
  import { assert } from "@fluidframework/core-utils/internal";
9
8
 
@@ -20,6 +19,7 @@ export class AppendOnlySortedMap<K, V> {
20
19
  public constructor(protected readonly comparator: (a: K, b: K) => number) {}
21
20
 
22
21
  /**
22
+ * Gets the size of the map.
23
23
  * @returns the number of entries in this map
24
24
  */
25
25
  public get size(): number {
@@ -27,6 +27,7 @@ export class AppendOnlySortedMap<K, V> {
27
27
  }
28
28
 
29
29
  /**
30
+ * Gets the min key in the map.
30
31
  * @returns the min key in the map.
31
32
  */
32
33
  public minKey(): K | undefined {
@@ -34,6 +35,7 @@ export class AppendOnlySortedMap<K, V> {
34
35
  }
35
36
 
36
37
  /**
38
+ * Gets the max key in the map.
37
39
  * @returns the max key in the map.
38
40
  */
39
41
  public maxKey(): K | undefined {
@@ -41,6 +43,7 @@ export class AppendOnlySortedMap<K, V> {
41
43
  }
42
44
 
43
45
  /**
46
+ * Gets the min value in the map.
44
47
  * @returns the min value in the map.
45
48
  */
46
49
  public minValue(): V | undefined {
@@ -48,14 +51,16 @@ export class AppendOnlySortedMap<K, V> {
48
51
  }
49
52
 
50
53
  /**
51
- * @returns the min value in the map.
54
+ * Gets the max value in the map.
55
+ * @returns the max value in the map.
52
56
  */
53
57
  public maxValue(): V | undefined {
54
58
  return this.elements[this.elements.length - 1] as V | undefined;
55
59
  }
56
60
 
57
61
  /**
58
- * @returns the min key in the map.
62
+ * Gets the first key/value pair in the map.
63
+ * @returns the first pair if it exists, or undefined otherwise.
59
64
  */
60
65
  public first(): [K, V] | undefined {
61
66
  const { elements } = this;
@@ -67,7 +72,8 @@ export class AppendOnlySortedMap<K, V> {
67
72
  }
68
73
 
69
74
  /**
70
- * @returns the max key in the map.
75
+ * Gets the last key/value pair in the map.
76
+ * @returns the last pair if it exists, or undefined otherwise.
71
77
  */
72
78
  public last(): [K, V] | undefined {
73
79
  const { elements } = this;
@@ -80,7 +86,9 @@ export class AppendOnlySortedMap<K, V> {
80
86
  }
81
87
 
82
88
  /**
83
- * Returns the element at the insertion index.
89
+ * Gets the entry at the specified index.
90
+ * @param index - the entry index
91
+ * @returns the key/value pair if it exists, or undefined otherwise.
84
92
  */
85
93
  public getAtIndex(index: number): [K, V] | undefined {
86
94
  const realIndex = index * 2;
@@ -92,6 +100,7 @@ export class AppendOnlySortedMap<K, V> {
92
100
  }
93
101
 
94
102
  /**
103
+ * Gets the entries in the map.
95
104
  * @returns an iterable of the entries in the map.
96
105
  */
97
106
  public *entries(): IterableIterator<readonly [K, V]> {
@@ -102,6 +111,7 @@ export class AppendOnlySortedMap<K, V> {
102
111
  }
103
112
 
104
113
  /**
114
+ * Gets the keys in the map.
105
115
  * @returns an iterable of the keys in the map.
106
116
  */
107
117
  public *keys(): IterableIterator<K> {
@@ -112,6 +122,7 @@ export class AppendOnlySortedMap<K, V> {
112
122
  }
113
123
 
114
124
  /**
125
+ * Gets the values in the map.
115
126
  * @returns an iterable of the values in the map.
116
127
  */
117
128
  public *values(): IterableIterator<V> {
@@ -122,6 +133,7 @@ export class AppendOnlySortedMap<K, V> {
122
133
  }
123
134
 
124
135
  /**
136
+ * Gets the entries in the map, reversed.
125
137
  * @returns an iterable of the entries in the map, reversed.
126
138
  */
127
139
  public *entriesReversed(): IterableIterator<readonly [K, V]> {
@@ -132,9 +144,9 @@ export class AppendOnlySortedMap<K, V> {
132
144
  }
133
145
 
134
146
  /**
135
- * Adds a new key/value pair to the map. `key` must be > to all keys in the map.
136
- * @param key - the key to add.
137
- * @param value - the value to add.
147
+ * Appends a new key/value pair at the end of the map. `key` must be greater than all other keys in the map.
148
+ * @param key - the key to add
149
+ * @param value - the value to add
138
150
  */
139
151
  public append(key: K, value: V): void {
140
152
  const { elements } = this;
@@ -142,15 +154,14 @@ export class AppendOnlySortedMap<K, V> {
142
154
  if (length !== 0 && this.comparator(key, this.maxKey() as K) <= 0) {
143
155
  throw new Error("Inserted key must be > all others in the map.");
144
156
  }
145
- elements.push(key);
146
- elements.push(value);
157
+ elements.push(key, value);
147
158
  }
148
159
 
149
160
  /**
150
- * Replaces the last key/value pair with the given one. If the map is empty, it simply appends.
151
- * `key` must be > to all keys in the map prior to the one replaced.
152
- * @param key - the key to add.
153
- * @param value - the value to add.
161
+ * Replaces the last key/value pair with a new one. If the map is empty, the new pair is appended.
162
+ * 'key' must be greater than all other keys in the map.
163
+ * @param key - the key to set
164
+ * @param value - the value to set
154
165
  */
155
166
  public replaceLast(key: K, value: V): void {
156
167
  const { elements, comparator } = this;
@@ -162,13 +173,13 @@ export class AppendOnlySortedMap<K, V> {
162
173
  throw new Error("Inserted key must be > all others in the map.");
163
174
  }
164
175
  }
165
- elements.push(key);
166
- elements.push(value);
176
+ elements.push(key, value);
167
177
  }
168
178
 
169
179
  /**
170
- * @param key - the key to lookup.
171
- * @returns the value associated with `key` if such an entry exists, and undefined otherwise.
180
+ * Gets the value associated with a given key.
181
+ * @param key - the key to lookup
182
+ * @returns the value if it exists, or undefined otherwise.
172
183
  */
173
184
  public get(key: K): V | undefined {
174
185
  const index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);
@@ -179,15 +190,16 @@ export class AppendOnlySortedMap<K, V> {
179
190
  }
180
191
 
181
192
  /**
182
- * @param key - the key to lookup.
183
- * @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry
184
- * exists, and undefined otherwise.
193
+ * Gets the pair associated with the given key or the next smaller key.
194
+ * @param key - the key to lookup
195
+ * @returns the pair if it exists, or undefined otherwise.
185
196
  */
186
197
  public getPairOrNextLower(key: K): readonly [K, V] | undefined {
187
198
  return this.getPairOrNextLowerBy(key, this.comparator);
188
199
  }
189
200
 
190
201
  /**
202
+ * Gets the pair associated with the given key or the next higher key.
191
203
  * @param key - the key to lookup.
192
204
  * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry
193
205
  * exists, and undefined otherwise.
@@ -293,6 +305,12 @@ export class AppendOnlySortedMap<K, V> {
293
305
  return keyIndex;
294
306
  }
295
307
 
308
+ /**
309
+ * Gets the pair associated with the given key or next higher key.
310
+ * @param search - the search value
311
+ * @param comparator - a comparison function
312
+ * @returns the pair if it exists, or undefined otherwise.
313
+ */
296
314
  protected getPairOrNextHigherBy<T>(
297
315
  search: T,
298
316
  comparator: (search: T, key: K, value: V) => number,
package/src/finalSpace.ts CHANGED
@@ -29,7 +29,7 @@ export class FinalSpace {
29
29
  return this.clusterList[this.clusterList.length - 1];
30
30
  }
31
31
 
32
- public addCluster(newCluster: IdCluster) {
32
+ public addCluster(newCluster: IdCluster): void {
33
33
  const lastCluster = this.getLastCluster();
34
34
  assert(
35
35
  lastCluster === undefined ||
@@ -40,7 +40,7 @@ export class FinalSpace {
40
40
  }
41
41
 
42
42
  /**
43
- * @returns the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.
43
+ * Gets the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.
44
44
  * Note: this does not include allocated but unfinalized space in clusters.
45
45
  */
46
46
  public getFinalizedIdLimit(): FinalCompressedId {
@@ -51,7 +51,7 @@ export class FinalSpace {
51
51
  }
52
52
 
53
53
  /**
54
- * @returns the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.
54
+ * Gets the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.
55
55
  * Note: this does includes all allocated IDs in clusters.
56
56
  */
57
57
  public getAllocatedIdLimit(): FinalCompressedId {
@@ -62,8 +62,9 @@ export class FinalSpace {
62
62
  }
63
63
 
64
64
  public equals(other: FinalSpace): boolean {
65
- for (const [index, value] of Object.entries(this.clusterList)) {
66
- if (!clustersEqual(value, other.clusterList[index])) {
65
+ for (let i = 0; i < this.clusterList.length; i++) {
66
+ const cluster = this.clusterList[i] as IdCluster;
67
+ if (!clustersEqual(cluster, other.clusterList[i] as IdCluster)) {
67
68
  return false;
68
69
  }
69
70
  }