@fluid-experimental/tree 2.74.0 → 2.81.0-374083

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 (116) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/assertTagging.config.mjs +14 -0
  3. package/dist/Checkout.js.map +1 -1
  4. package/dist/Common.d.ts.map +1 -1
  5. package/dist/Common.js.map +1 -1
  6. package/dist/MergeHealth.d.ts.map +1 -1
  7. package/dist/MergeHealth.js.map +1 -1
  8. package/dist/SharedTree.js.map +1 -1
  9. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  10. package/dist/SharedTreeEncoder.js.map +1 -1
  11. package/dist/UndoRedoHandler.d.ts.map +1 -1
  12. package/dist/UndoRedoHandler.js.map +1 -1
  13. package/dist/id-compressor/IdCompressor.js.map +1 -1
  14. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
  15. package/dist/migration-shim/migrationDeltaHandler.d.ts +2 -2
  16. package/dist/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
  17. package/dist/migration-shim/migrationDeltaHandler.js.map +1 -1
  18. package/dist/migration-shim/migrationShim.d.ts +5 -5
  19. package/dist/migration-shim/migrationShim.d.ts.map +1 -1
  20. package/dist/migration-shim/migrationShim.js +1 -0
  21. package/dist/migration-shim/migrationShim.js.map +1 -1
  22. package/dist/migration-shim/migrationShimFactory.d.ts +3 -3
  23. package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
  24. package/dist/migration-shim/migrationShimFactory.js.map +1 -1
  25. package/dist/migration-shim/sharedTreeDeltaHandler.d.ts +2 -2
  26. package/dist/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
  27. package/dist/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
  28. package/dist/migration-shim/sharedTreeShim.d.ts +5 -5
  29. package/dist/migration-shim/sharedTreeShim.d.ts.map +1 -1
  30. package/dist/migration-shim/sharedTreeShim.js.map +1 -1
  31. package/dist/migration-shim/sharedTreeShimFactory.d.ts +1 -1
  32. package/dist/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
  33. package/dist/migration-shim/sharedTreeShimFactory.js.map +1 -1
  34. package/dist/migration-shim/shimChannelServices.d.ts +1 -1
  35. package/dist/migration-shim/shimChannelServices.d.ts.map +1 -1
  36. package/dist/migration-shim/shimChannelServices.js.map +1 -1
  37. package/dist/migration-shim/shimDeltaConnection.d.ts +2 -2
  38. package/dist/migration-shim/shimDeltaConnection.d.ts.map +1 -1
  39. package/dist/migration-shim/shimDeltaConnection.js.map +1 -1
  40. package/dist/migration-shim/shimHandle.d.ts +1 -1
  41. package/dist/migration-shim/shimHandle.d.ts.map +1 -1
  42. package/dist/migration-shim/shimHandle.js.map +1 -1
  43. package/dist/migration-shim/types.d.ts +4 -4
  44. package/dist/migration-shim/types.d.ts.map +1 -1
  45. package/dist/migration-shim/types.js.map +1 -1
  46. package/dist/migration-shim/utils.d.ts +3 -3
  47. package/dist/migration-shim/utils.d.ts.map +1 -1
  48. package/dist/migration-shim/utils.js.map +1 -1
  49. package/eslint.config.mts +5 -4
  50. package/lib/Checkout.js.map +1 -1
  51. package/lib/Common.d.ts.map +1 -1
  52. package/lib/Common.js.map +1 -1
  53. package/lib/MergeHealth.d.ts.map +1 -1
  54. package/lib/MergeHealth.js.map +1 -1
  55. package/lib/SharedTree.js.map +1 -1
  56. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  57. package/lib/SharedTreeEncoder.js.map +1 -1
  58. package/lib/UndoRedoHandler.d.ts.map +1 -1
  59. package/lib/UndoRedoHandler.js.map +1 -1
  60. package/lib/id-compressor/IdCompressor.js.map +1 -1
  61. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
  62. package/lib/migration-shim/migrationDeltaHandler.d.ts +2 -2
  63. package/lib/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
  64. package/lib/migration-shim/migrationDeltaHandler.js.map +1 -1
  65. package/lib/migration-shim/migrationShim.d.ts +5 -5
  66. package/lib/migration-shim/migrationShim.d.ts.map +1 -1
  67. package/lib/migration-shim/migrationShim.js +1 -0
  68. package/lib/migration-shim/migrationShim.js.map +1 -1
  69. package/lib/migration-shim/migrationShimFactory.d.ts +3 -3
  70. package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
  71. package/lib/migration-shim/migrationShimFactory.js.map +1 -1
  72. package/lib/migration-shim/sharedTreeDeltaHandler.d.ts +2 -2
  73. package/lib/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
  74. package/lib/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
  75. package/lib/migration-shim/sharedTreeShim.d.ts +5 -5
  76. package/lib/migration-shim/sharedTreeShim.d.ts.map +1 -1
  77. package/lib/migration-shim/sharedTreeShim.js.map +1 -1
  78. package/lib/migration-shim/sharedTreeShimFactory.d.ts +1 -1
  79. package/lib/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
  80. package/lib/migration-shim/sharedTreeShimFactory.js.map +1 -1
  81. package/lib/migration-shim/shimChannelServices.d.ts +1 -1
  82. package/lib/migration-shim/shimChannelServices.d.ts.map +1 -1
  83. package/lib/migration-shim/shimChannelServices.js.map +1 -1
  84. package/lib/migration-shim/shimDeltaConnection.d.ts +2 -2
  85. package/lib/migration-shim/shimDeltaConnection.d.ts.map +1 -1
  86. package/lib/migration-shim/shimDeltaConnection.js.map +1 -1
  87. package/lib/migration-shim/shimHandle.d.ts +1 -1
  88. package/lib/migration-shim/shimHandle.d.ts.map +1 -1
  89. package/lib/migration-shim/shimHandle.js.map +1 -1
  90. package/lib/migration-shim/types.d.ts +4 -4
  91. package/lib/migration-shim/types.d.ts.map +1 -1
  92. package/lib/migration-shim/types.js.map +1 -1
  93. package/lib/migration-shim/utils.d.ts +3 -3
  94. package/lib/migration-shim/utils.d.ts.map +1 -1
  95. package/lib/migration-shim/utils.js.map +1 -1
  96. package/package.json +32 -32
  97. package/src/Checkout.ts +1 -1
  98. package/src/Common.ts +5 -1
  99. package/src/MergeHealth.ts +5 -5
  100. package/src/SharedTree.ts +2 -2
  101. package/src/SharedTreeEncoder.ts +9 -2
  102. package/src/UndoRedoHandler.ts +5 -5
  103. package/src/id-compressor/IdCompressor.ts +1 -1
  104. package/src/id-compressor/SessionIdNormalizer.ts +1 -1
  105. package/src/migration-shim/migrationDeltaHandler.ts +2 -2
  106. package/src/migration-shim/migrationShim.ts +11 -13
  107. package/src/migration-shim/migrationShimFactory.ts +7 -10
  108. package/src/migration-shim/sharedTreeDeltaHandler.ts +2 -2
  109. package/src/migration-shim/sharedTreeShim.ts +14 -14
  110. package/src/migration-shim/sharedTreeShimFactory.ts +5 -5
  111. package/src/migration-shim/shimChannelServices.ts +4 -4
  112. package/src/migration-shim/shimDeltaConnection.ts +5 -5
  113. package/src/migration-shim/shimHandle.ts +1 -1
  114. package/src/migration-shim/types.ts +8 -8
  115. package/src/migration-shim/utils.ts +3 -3
  116. package/.eslintrc.cjs +0 -45
@@ -1 +1 @@
1
- {"version":3,"file":"SessionIdNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAW,oBAAoB,EAAE,4BAA4B,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAO,mBAAmB;IAkB/B,YAAoC,mBAAmB,KAAK;QAAxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAjBpD,gBAAW,GAAsB,CAAC,CAAsB,CAAC;QAChD,aAAQ,GAIrB,IAAI,yBAAyB,CAChC,4BAA4B,EAC5B,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,EAAE;YACpB,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC/B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,CAAC;gBAC3C,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;AACF,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 { Mutable, compareFiniteNumbers, compareFiniteNumbersReversed, fail } from '../Common.js';\nimport { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers.js';\n\nimport { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap.js';\nimport { SerializedSessionIdNormalizer } from './persisted-types/index.js';\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * ```\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n * ```\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * ```\n * for each index in the range of IDs created by a session:\n * \tthe local form if it exists, otherwise the final form\n * ```\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ?? fail('Local ID was never recorded with this normalizer.');\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail('Local ID was never recorded with this normalizer.');\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,\n\t * if the ID was created by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-unary-minus\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail('Final ranges not aligned with owning local range.');\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 0x657 /* Local ID space must start at -1. */);\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(localId === firstLocal - finalDelta, 0x658 /* Local ID space must be contiguous. */);\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers one or more final IDs with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)\n\t * starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.\n\t *\n\t * An example:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Subsequently calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t *\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void {\n\t\tassert(lastFinal >= firstFinal, 0x659 /* Malformed normalization range. */);\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail('Final IDs must be added to an existing local range.');\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] = this.getAlignmentOfLastRange(\n\t\t\t\tfirstLocal,\n\t\t\t\tfinalRanges\n\t\t\t);\n\t\t\tnextLocal = Math.min(this.nextLocalId, lastAlignedLocal - (lastFinal - firstFinal) - 2) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(alignedLocal >= lastLocal, 0x65a /* Gaps in final space must align to a local. */);\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).\n\t *\n\t * The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with\n\t * as many finals from the registered block as possible.\n\t *\n\t * It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such\n\t * generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,\n\t * a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,\n\t * those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier\n\t * creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second\n\t * creation range is finalized.\n\t *\n\t * A usage example:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, X, X, X]\n\t * Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, 7]\n\t * Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, X]\n\t *\n\t */\n\tpublic registerFinalIdBlock(firstFinalInBlock: FinalCompressedId, count: number, rangeObject: TRangeObject): void {\n\t\tassert(count >= 1, 0x65b /* Malformed normalization block. */);\n\t\tconst [firstLocal, [lastLocal, finalRanges]] =\n\t\t\tthis.idRanges.last() ?? fail('Final ID block should not be registered before any locals.');\n\t\tlet unalignedLocalCount: number;\n\t\tif (finalRanges === undefined) {\n\t\t\tunalignedLocalCount = firstLocal - lastLocal + 1;\n\t\t} else {\n\t\t\tconst [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tunalignedLocalCount = lastAlignedLocal - lastLocal;\n\t\t}\n\t\tassert(\n\t\t\tunalignedLocalCount > 0,\n\t\t\t0x65c /* Final ID block should not be registered without an existing local range. */\n\t\t);\n\t\tconst lastFinal = (firstFinalInBlock + Math.min(unalignedLocalCount, count) - 1) as FinalCompressedId;\n\t\tthis.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);\n\t}\n\n\tprivate getAlignmentOfLastRange(\n\t\tfirstLocal: LocalCompressedId,\n\t\tfinalRanges: FinalRanges<TRangeObject>\n\t): [\n\t\tfirstAlignedLocal: LocalCompressedId,\n\t\tlastAlignedLocal: LocalCompressedId,\n\t\tlastAlignedFinal: FinalCompressedId,\n\t\tlastFinalRange: FinalRange<TRangeObject>,\n\t] {\n\t\tconst isSingle = isSingleRange(finalRanges);\n\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\tif (isSingle) {\n\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\tlastFinalRange = finalRanges;\n\t\t} else {\n\t\t\t[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t}\n\n\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\treturn [firstAlignedLocal, lastAlignedLocal as LocalCompressedId, lastAlignedFinal, lastFinalRange];\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = {\n\t\t\tlocalRanges: [],\n\t\t\tnextLocalId: this.nextLocalId,\n\t\t};\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [LocalCompressedId, FinalCompressedId, FinalCompressedId][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(serializedFinalRanges.length !== 0, 0x65d /* Empty range should not be reified. */);\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\tnormalizer.nextLocalId = serialized.nextLocalId;\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b\n\t): boolean {\n\t\treturn (\n\t\t\tthis.nextLocalId === other.nextLocalId &&\n\t\t\tthis.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t\t}\n\n\t\t\t\tconst rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>) => {\n\t\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfirstFinalA === firstFinalB && lastFinalA === lastFinalB && compareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t\t}\n\n\t\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t\t})\n\t\t);\n\t}\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject,\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(ranges: FinalRanges<TRangeObject>): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction getFirstRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(finalRange: FinalRange<TRangeObject>): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"SessionIdNormalizer.js","sourceRoot":"","sources":["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K,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,QAAQ,CAAC,CAAC,OAAO,CAChB,UAA6B,EAC7B,WAAkD;IAElD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACP,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC3C,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;AACF,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 { Mutable, compareFiniteNumbers, compareFiniteNumbersReversed, fail } from '../Common.js';\nimport { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers.js';\n\nimport { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap.js';\nimport { SerializedSessionIdNormalizer } from './persisted-types/index.js';\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * ```\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n * ```\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * ```\n * for each index in the range of IDs created by a session:\n * \tthe local form if it exists, otherwise the final form\n * ```\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ?? fail('Local ID was never recorded with this normalizer.');\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail('Local ID was never recorded with this normalizer.');\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,\n\t * if the ID was created by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-unary-minus\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail('Final ranges not aligned with owning local range.');\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 0x657 /* Local ID space must start at -1. */);\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(localId === firstLocal - finalDelta, 0x658 /* Local ID space must be contiguous. */);\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers one or more final IDs with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)\n\t * starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.\n\t *\n\t * An example:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Subsequently calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t *\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void {\n\t\tassert(lastFinal >= firstFinal, 0x659 /* Malformed normalization range. */);\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail('Final IDs must be added to an existing local range.');\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] = this.getAlignmentOfLastRange(\n\t\t\t\tfirstLocal,\n\t\t\t\tfinalRanges\n\t\t\t);\n\t\t\tnextLocal = Math.min(this.nextLocalId, lastAlignedLocal - (lastFinal - firstFinal) - 2) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(alignedLocal >= lastLocal, 0x65a /* Gaps in final space must align to a local. */);\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).\n\t *\n\t * The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with\n\t * as many finals from the registered block as possible.\n\t *\n\t * It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such\n\t * generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,\n\t * a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,\n\t * those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier\n\t * creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second\n\t * creation range is finalized.\n\t *\n\t * A usage example:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, X, X, X]\n\t * Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, 7]\n\t * Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, X]\n\t *\n\t */\n\tpublic registerFinalIdBlock(firstFinalInBlock: FinalCompressedId, count: number, rangeObject: TRangeObject): void {\n\t\tassert(count >= 1, 0x65b /* Malformed normalization block. */);\n\t\tconst [firstLocal, [lastLocal, finalRanges]] =\n\t\t\tthis.idRanges.last() ?? fail('Final ID block should not be registered before any locals.');\n\t\tlet unalignedLocalCount: number;\n\t\tif (finalRanges === undefined) {\n\t\t\tunalignedLocalCount = firstLocal - lastLocal + 1;\n\t\t} else {\n\t\t\tconst [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tunalignedLocalCount = lastAlignedLocal - lastLocal;\n\t\t}\n\t\tassert(\n\t\t\tunalignedLocalCount > 0,\n\t\t\t0x65c /* Final ID block should not be registered without an existing local range. */\n\t\t);\n\t\tconst lastFinal = (firstFinalInBlock + Math.min(unalignedLocalCount, count) - 1) as FinalCompressedId;\n\t\tthis.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);\n\t}\n\n\tprivate getAlignmentOfLastRange(\n\t\tfirstLocal: LocalCompressedId,\n\t\tfinalRanges: FinalRanges<TRangeObject>\n\t): [\n\t\tfirstAlignedLocal: LocalCompressedId,\n\t\tlastAlignedLocal: LocalCompressedId,\n\t\tlastAlignedFinal: FinalCompressedId,\n\t\tlastFinalRange: FinalRange<TRangeObject>,\n\t] {\n\t\tconst isSingle = isSingleRange(finalRanges);\n\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\tif (isSingle) {\n\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\tlastFinalRange = finalRanges;\n\t\t} else {\n\t\t\t[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t}\n\n\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\treturn [firstAlignedLocal, lastAlignedLocal as LocalCompressedId, lastAlignedFinal, lastFinalRange];\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = {\n\t\t\tlocalRanges: [],\n\t\t\tnextLocalId: this.nextLocalId,\n\t\t};\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [LocalCompressedId, FinalCompressedId, FinalCompressedId][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(serializedFinalRanges.length !== 0, 0x65d /* Empty range should not be reified. */);\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\tnormalizer.nextLocalId = serialized.nextLocalId;\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b\n\t): boolean {\n\t\treturn (\n\t\t\tthis.nextLocalId === other.nextLocalId &&\n\t\t\tthis.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t\t}\n\n\t\t\t\tconst rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>): boolean => {\n\t\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfirstFinalA === firstFinalB && lastFinalA === lastFinalB && compareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t\t}\n\n\t\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t\t})\n\t\t);\n\t}\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject,\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(ranges: FinalRanges<TRangeObject>): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction getFirstRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(finalRange: FinalRange<TRangeObject>): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IChannelAttributes, type IDeltaHandler } from '@fluidframework/datastore-definitions/internal';
5
+ import type { IChannelAttributes, IDeltaHandler } from '@fluidframework/datastore-definitions/internal';
6
6
  import { type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
7
7
  import type { IRuntimeMessageCollection } from '@fluidframework/runtime-definitions/internal';
8
- import { type IOpContents, type IShimDeltaHandler } from './types.js';
8
+ import type { IOpContents, IShimDeltaHandler } from './types.js';
9
9
  /**
10
10
  * Handles incoming and outgoing deltas/ops for the Migration Shim distributed data structure.
11
11
  * Intercepts processing of ops to allow for migration, and swapping from LegacySharedTree to new SharedTree
@@ -1 +1 @@
1
- {"version":3,"file":"migrationDeltaHandler.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,gDAAgD,CAAC;A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D,OAAO,IAAI,CAAC,YAAY,EAAE,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACK,YAAY,CAAC,QAAqB;QACzC,MAAM,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC,qDAAqD,CAAC,CAAC;QAC9F,yCAAyC;QACzC,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QAED,+BAA+B;QAC/B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,gCAAgC;QAChC,MAAM,CACL,eAAe,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,UAAU,CAAC,EAC9D,KAAK,CAAC,iDAAiD,CACvD,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;CACD","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';\nimport { type IChannelAttributes, type IDeltaHandler } from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { IRuntimeMessageCollection, IRuntimeMessagesContent } from '@fluidframework/runtime-definitions/internal';\n\nimport { type IOpContents, type IShimDeltaHandler } from './types.js';\nimport { attributesMatch, isBarrierOp, isStampedOp } from './utils.js';\n\n/**\n * Handles incoming and outgoing deltas/ops for the Migration Shim distributed data structure.\n * Intercepts processing of ops to allow for migration, and swapping from LegacySharedTree to new SharedTree\n *\n * Able to process v1 and v2 ops, differentiate between them, understand the various states and drop v1 ops after\n * migration.\n *\n * TODO: After the MSN of the barrier op, it needs to process v2 ops without needing to check for the v2 stamp.\n */\nexport class MigrationShimDeltaHandler implements IShimDeltaHandler {\n\tprivate legacyTreeHandler?: IDeltaHandler;\n\tprivate newTreeHandler?: IDeltaHandler;\n\tpublic constructor(\n\t\t// Maybe it would be better to pass in a different interface?\n\t\tpublic readonly processMigrateOp: (\n\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\tlocalOpMetadata: unknown\n\t\t) => boolean,\n\t\tprivate readonly submitLocalMessage: (message: IOpContents) => void,\n\t\tprivate readonly attributes: IChannelAttributes\n\t) {}\n\t// Introduction of invariant, we always expect an old handler.\n\tpublic hasTreeDeltaHandler(): boolean {\n\t\treturn this.legacyTreeHandler !== undefined;\n\t}\n\n\tprivate get treeDeltaHandler(): IDeltaHandler {\n\t\tconst handler = this.newTreeHandler ?? this.legacyTreeHandler;\n\t\tassert(handler !== undefined, 0x7e2 /* No handler to process op */);\n\t\treturn handler;\n\t}\n\n\tprivate _attached = false;\n\tpublic get attached(): boolean {\n\t\treturn this._attached;\n\t}\n\n\tpublic markAttached(): void {\n\t\tthis._attached = true;\n\t}\n\n\tpublic isPreAttachState(): boolean {\n\t\tconst preAttach = this.legacyTreeHandler === undefined && this.newTreeHandler === undefined;\n\t\tassert(!preAttach || !this.attached, 0x82a /* Should not be attached in preAttach state */);\n\t\treturn preAttach;\n\t}\n\n\tpublic isUsingOldV1(): boolean {\n\t\treturn this.legacyTreeHandler !== undefined && this.newTreeHandler === undefined;\n\t}\n\n\tpublic isUsingNewV2(): boolean {\n\t\tconst isUsingV2 = this.legacyTreeHandler !== undefined && this.newTreeHandler !== undefined;\n\t\tassert(!isUsingV2 || this.attached, 0x82b /* Should be attached if in v2 state */);\n\t\treturn isUsingV2;\n\t}\n\n\t// Allow for the handler to be swapped out for the new SharedTree's handler\n\tpublic attachTreeDeltaHandler(treeDeltaHandler: IDeltaHandler): void {\n\t\tassert(!this.isUsingNewV2(), 0x7e3 /* Can't swap tree handlers more than once! */);\n\t\tif (this.isPreAttachState()) {\n\t\t\tthis.legacyTreeHandler = treeDeltaHandler;\n\t\t\treturn;\n\t\t}\n\t\tassert(this.isUsingOldV1(), 0x7e4 /* Can only swap handlers after the old handler is loaded */);\n\t\tthis.newTreeHandler = treeDeltaHandler;\n\t\tassert(this.isUsingNewV2(), 0x7e5 /* Should be using new handler after swap */);\n\t}\n\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n\t\t// This allows us to process the migrate op and prevent the shared object from processing the wrong ops\n\t\tassert(!this.isPreAttachState(), 0x82c /* Can't process ops before attaching tree handler */);\n\t\tif (message.type !== MessageType.Operation) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst contents = message.contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(contents)) {\n\t\t\tthis.processMigrateOp(message, local, localOpMetadata);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.shouldDropOp(contents)) {\n\t\t\treturn;\n\t\t}\n\t\tconst messagesContent: IRuntimeMessagesContent[] = [\n\t\t\t{\n\t\t\t\tcontents,\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber: message.clientSequenceNumber,\n\t\t\t},\n\t\t];\n\t\t// Another thought, flatten the IShimDeltaHandler and the MigrationShim into one class\n\t\treturn this.treeDeltaHandler.processMessages({ envelope: message, messagesContent, local });\n\t}\n\n\tpublic processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process({ ...envelope, contents, clientSequenceNumber }, local, localOpMetadata);\n\t\t}\n\t}\n\n\tpublic setConnectionState(connected: boolean): void {\n\t\treturn this.treeDeltaHandler.setConnectionState(connected);\n\t}\n\n\tpublic reSubmit(contents: unknown, localOpMetadata: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(opContents)) {\n\t\t\tthis.submitLocalMessage(opContents);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.shouldDropOp(opContents)) {\n\t\t\treturn;\n\t\t}\n\t\treturn this.treeDeltaHandler.reSubmit(contents, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp(contents: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(opContents)) {\n\t\t\tthis.submitLocalMessage(opContents);\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\t!this.shouldDropOp(opContents),\n\t\t\t0x8aa /* MigrationShim should not be able to apply v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\tthis.treeDeltaHandler.applyStashedOp(contents);\n\t}\n\n\tpublic rollback?(contents: unknown, localOpMetadata: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (isBarrierOp(opContents)) {\n\t\t\tthrow new Error('MigrationShim does not support rollback of barrier ops');\n\t\t}\n\t\treturn this.treeDeltaHandler.rollback?.(contents, localOpMetadata);\n\t}\n\n\tprivate isInV1StateAndIsBarrierOp(contents: IOpContents): boolean {\n\t\treturn this.isUsingOldV1() && isBarrierOp(contents);\n\t}\n\n\t/**\n\t * We should drop an op when we are v2 state and the op is a v1 op or a migrate op.\n\t *\n\t * @param contents - op contents we expect to interrogate, this could be anything\n\t * @returns whether or not we should drop the op\n\t */\n\tprivate shouldDropOp(contents: IOpContents): boolean {\n\t\tassert(!this.isPreAttachState(), 0x82d /* Can't process ops before attaching tree handler */);\n\t\t// Don't drop ops when we are in v1 state\n\t\tif (this.isUsingOldV1()) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Drop v1 ops when in v2 state\n\t\tif (!isStampedOp(contents)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Don't drop v2 ops in v2 state\n\t\tassert(\n\t\t\tattributesMatch(contents.fluidMigrationStamp, this.attributes),\n\t\t\t0x82e /* Unexpected v2 op with mismatched attributes */\n\t\t);\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"migrationDeltaHandler.js","sourceRoot":"","sources":["../../src/migration-shim/migrationDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GA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T License.\n */\n\nimport { assert } from '@fluidframework/core-utils/internal';\nimport type { IChannelAttributes, IDeltaHandler } from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { IRuntimeMessageCollection, IRuntimeMessagesContent } from '@fluidframework/runtime-definitions/internal';\n\nimport type { IOpContents, IShimDeltaHandler } from './types.js';\nimport { attributesMatch, isBarrierOp, isStampedOp } from './utils.js';\n\n/**\n * Handles incoming and outgoing deltas/ops for the Migration Shim distributed data structure.\n * Intercepts processing of ops to allow for migration, and swapping from LegacySharedTree to new SharedTree\n *\n * Able to process v1 and v2 ops, differentiate between them, understand the various states and drop v1 ops after\n * migration.\n *\n * TODO: After the MSN of the barrier op, it needs to process v2 ops without needing to check for the v2 stamp.\n */\nexport class MigrationShimDeltaHandler implements IShimDeltaHandler {\n\tprivate legacyTreeHandler?: IDeltaHandler;\n\tprivate newTreeHandler?: IDeltaHandler;\n\tpublic constructor(\n\t\t// Maybe it would be better to pass in a different interface?\n\t\tpublic readonly processMigrateOp: (\n\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\tlocalOpMetadata: unknown\n\t\t) => boolean,\n\t\tprivate readonly submitLocalMessage: (message: IOpContents) => void,\n\t\tprivate readonly attributes: IChannelAttributes\n\t) {}\n\t// Introduction of invariant, we always expect an old handler.\n\tpublic hasTreeDeltaHandler(): boolean {\n\t\treturn this.legacyTreeHandler !== undefined;\n\t}\n\n\tprivate get treeDeltaHandler(): IDeltaHandler {\n\t\tconst handler = this.newTreeHandler ?? this.legacyTreeHandler;\n\t\tassert(handler !== undefined, 0x7e2 /* No handler to process op */);\n\t\treturn handler;\n\t}\n\n\tprivate _attached = false;\n\tpublic get attached(): boolean {\n\t\treturn this._attached;\n\t}\n\n\tpublic markAttached(): void {\n\t\tthis._attached = true;\n\t}\n\n\tpublic isPreAttachState(): boolean {\n\t\tconst preAttach = this.legacyTreeHandler === undefined && this.newTreeHandler === undefined;\n\t\tassert(!preAttach || !this.attached, 0x82a /* Should not be attached in preAttach state */);\n\t\treturn preAttach;\n\t}\n\n\tpublic isUsingOldV1(): boolean {\n\t\treturn this.legacyTreeHandler !== undefined && this.newTreeHandler === undefined;\n\t}\n\n\tpublic isUsingNewV2(): boolean {\n\t\tconst isUsingV2 = this.legacyTreeHandler !== undefined && this.newTreeHandler !== undefined;\n\t\tassert(!isUsingV2 || this.attached, 0x82b /* Should be attached if in v2 state */);\n\t\treturn isUsingV2;\n\t}\n\n\t// Allow for the handler to be swapped out for the new SharedTree's handler\n\tpublic attachTreeDeltaHandler(treeDeltaHandler: IDeltaHandler): void {\n\t\tassert(!this.isUsingNewV2(), 0x7e3 /* Can't swap tree handlers more than once! */);\n\t\tif (this.isPreAttachState()) {\n\t\t\tthis.legacyTreeHandler = treeDeltaHandler;\n\t\t\treturn;\n\t\t}\n\t\tassert(this.isUsingOldV1(), 0x7e4 /* Can only swap handlers after the old handler is loaded */);\n\t\tthis.newTreeHandler = treeDeltaHandler;\n\t\tassert(this.isUsingNewV2(), 0x7e5 /* Should be using new handler after swap */);\n\t}\n\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n\t\t// This allows us to process the migrate op and prevent the shared object from processing the wrong ops\n\t\tassert(!this.isPreAttachState(), 0x82c /* Can't process ops before attaching tree handler */);\n\t\tif (message.type !== MessageType.Operation) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst contents = message.contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(contents)) {\n\t\t\tthis.processMigrateOp(message, local, localOpMetadata);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.shouldDropOp(contents)) {\n\t\t\treturn;\n\t\t}\n\t\tconst messagesContent: IRuntimeMessagesContent[] = [\n\t\t\t{\n\t\t\t\tcontents,\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber: message.clientSequenceNumber,\n\t\t\t},\n\t\t];\n\t\t// Another thought, flatten the IShimDeltaHandler and the MigrationShim into one class\n\t\treturn this.treeDeltaHandler.processMessages({ envelope: message, messagesContent, local });\n\t}\n\n\tpublic processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process({ ...envelope, contents, clientSequenceNumber }, local, localOpMetadata);\n\t\t}\n\t}\n\n\tpublic setConnectionState(connected: boolean): void {\n\t\treturn this.treeDeltaHandler.setConnectionState(connected);\n\t}\n\n\tpublic reSubmit(contents: unknown, localOpMetadata: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(opContents)) {\n\t\t\tthis.submitLocalMessage(opContents);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.shouldDropOp(opContents)) {\n\t\t\treturn;\n\t\t}\n\t\treturn this.treeDeltaHandler.reSubmit(contents, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp(contents: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (this.isInV1StateAndIsBarrierOp(opContents)) {\n\t\t\tthis.submitLocalMessage(opContents);\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\t!this.shouldDropOp(opContents),\n\t\t\t0x8aa /* MigrationShim should not be able to apply v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\tthis.treeDeltaHandler.applyStashedOp(contents);\n\t}\n\n\tpublic rollback?(contents: unknown, localOpMetadata: unknown): void {\n\t\tconst opContents = contents as IOpContents;\n\t\tif (isBarrierOp(opContents)) {\n\t\t\tthrow new Error('MigrationShim does not support rollback of barrier ops');\n\t\t}\n\t\treturn this.treeDeltaHandler.rollback?.(contents, localOpMetadata);\n\t}\n\n\tprivate isInV1StateAndIsBarrierOp(contents: IOpContents): boolean {\n\t\treturn this.isUsingOldV1() && isBarrierOp(contents);\n\t}\n\n\t/**\n\t * We should drop an op when we are v2 state and the op is a v1 op or a migrate op.\n\t *\n\t * @param contents - op contents we expect to interrogate, this could be anything\n\t * @returns whether or not we should drop the op\n\t */\n\tprivate shouldDropOp(contents: IOpContents): boolean {\n\t\tassert(!this.isPreAttachState(), 0x82d /* Can't process ops before attaching tree handler */);\n\t\t// Don't drop ops when we are in v1 state\n\t\tif (this.isUsingOldV1()) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Drop v1 ops when in v2 state\n\t\tif (!isStampedOp(contents)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Don't drop v2 ops in v2 state\n\t\tassert(\n\t\t\tattributesMatch(contents.fluidMigrationStamp, this.attributes),\n\t\t\t0x82e /* Unexpected v2 op with mismatched attributes */\n\t\t);\n\t\treturn false;\n\t}\n}\n"]}
@@ -2,13 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';
5
+ import type { IEvent, IFluidHandle, IFluidLoadable } from '@fluidframework/core-interfaces';
6
6
  import { type IChannelAttributes, IChannelFactory, type IFluidDataStoreRuntime, type IChannel, type IChannelServices } from '@fluidframework/datastore-definitions/internal';
7
- import { type IExperimentalIncrementalSummaryContext, type IGarbageCollectionData, type ISummaryTreeWithStats, type ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
7
+ import type { IExperimentalIncrementalSummaryContext, IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
8
8
  import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';
9
- import { type ITree } from '@fluidframework/tree';
10
- import { type SharedTree as LegacySharedTree, type SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';
11
- import { type IShim } from './types.js';
9
+ import type { ITree } from '@fluidframework/tree';
10
+ import type { SharedTree as LegacySharedTree, SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';
11
+ import type { IShim } from './types.js';
12
12
  /**
13
13
  * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"migrationShim.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtG,OAAO,EACN,KAAK,kBAAkB,EACvB,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,MAAM,gDAAgD,CAAC;AAIxD,OAAO,EACN,KAAK,sCAAsC,EAC3C,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAuB,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAC9G,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACN,KAAK,UAAU,IAAI,gBAAgB,EACnC,KAAK,iBAAiB,IAAI,uBAAuB,EACjD,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC9C;;OAEG;IACH,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB;;;OAGG;IACH,aAAa,EAAE,kBAAkB,CAAC;IAClC;;;OAGG;IACH,aAAa,EAAE,kBAAkB,CAAC;CAClC;AAID;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAc,SAAQ,6BAA6B,CAAC,eAAe,CAAE,YAAW,KAAK;aAEhF,EAAE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EG;IACH,OAAO,CAAC,yBAAyB;IAQjC;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAOjC;IAGK,eAAe,IAAI,IAAI;IAU9B,IAAW,WAAW,IAAI,QAAQ,GAAG,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAE9D;IAEY,IAAI,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrD,MAAM,IAAI,IAAI;IAIrB,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IACM,gBAAgB,CACtB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,EAC9B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,EAChC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAC9C,qBAAqB;IAGX,SAAS,CACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,EAC9B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,EAChC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,SAAS,EAChD,yBAAyB,CAAC,EAAE,sCAAsC,GAAG,SAAS,GAC5E,OAAO,CAAC,qBAAqB,CAAC;IAG1B,UAAU,IAAI,OAAO;IAKrB,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAMhD,OAAO,CAAC,SAAS;IAgBjB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAiBzB,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,sBAAsB;IAG/D,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAW,cAAc,IAAI,cAAc,CAE1C;CACD"}
@@ -85,6 +85,7 @@ export class MigrationShim extends EventEmitterWithErrorHandling {
85
85
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}
86
86
  */
87
87
  closeWithError(error) {
88
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- intentional behavior
88
89
  if (this.closeError === undefined) {
89
90
  this.closeError = error;
90
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,WAAW,EAAkC,MAAM,6CAA6C,CAAC;AAS1G,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAQ9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,aAAc,SAAQ,6BAA8C;IAChF,YACiB,EAAU,EACT,OAA+B,EAC/B,iBAA0C,EAC1C,cAAsC,EACtC,yBAAiF;QAElG,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAN9E,OAAE,GAAF,EAAE,CAAQ;QACT,YAAO,GAAP,OAAO,CAAwB;QAC/B,sBAAiB,GAAjB,iBAAiB,CAAyB;QAC1C,mBAAc,GAAd,cAAc,CAAwB;QACtC,8BAAyB,GAAzB,yBAAyB,CAAwD;QAYlF,qBAAgB,GAAG,CAAC,OAAkC,EAAW,EAAE;YACnF,IAAI,OAAO,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AC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport {\n\ttype IChannelAttributes,\n\tIChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannel,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { SessionId } from '@fluidframework/id-compressor';\nimport type { IIdCompressorCore } from '@fluidframework/id-compressor/internal';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';\nimport { type ITree } from '@fluidframework/tree';\n\nimport {\n\ttype SharedTree as LegacySharedTree,\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n} from '../SharedTree.js';\n\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IOpContents, type IShim } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\nconst ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee' as SessionId;\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (message.type !== MessageType.Operation || (message.contents as Partial<IMigrationOp>).type !== 'barrier') {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id);\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tconst { idCompressor } = this.runtime;\n\t\tif (idCompressor !== undefined) {\n\t\t\t(idCompressor as unknown as IIdCompressorCore).beginGhostSession(ghostSessionId, () =>\n\t\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\t}\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: (IChannel & ITree) | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): IChannel & (LegacySharedTree | ITree) {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t);\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
1
+ {"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,WAAW,EAAkC,MAAM,6CAA6C,CAAC;AAS1G,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAK9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;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qBAAqB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACK,wBAAwB,CAAC,QAA0B;QAC1D,MAAM,CACL,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,2BAA2B,KAAK,SAAS,EAC7E,KAAK,CAAC,uBAAuB,CAC7B,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,2BAA2B,GAAG,IAAI,2BAA2B,CACjE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACF,MAAM,YAAY,GAAyB;YAC1C,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,CAAC,2BAA2B;SACjD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport type { IEvent, IFluidHandle, IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport {\n\ttype IChannelAttributes,\n\tIChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannel,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { SessionId } from '@fluidframework/id-compressor';\nimport type { IIdCompressorCore } from '@fluidframework/id-compressor/internal';\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';\nimport type { ITree } from '@fluidframework/tree';\n\nimport type { SharedTree as LegacySharedTree, SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';\n\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport type { IOpContents, IShim } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\nconst ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee' as SessionId;\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (message.type !== MessageType.Operation || (message.contents as Partial<IMigrationOp>).type !== 'barrier') {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id);\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tconst { idCompressor } = this.runtime;\n\t\tif (idCompressor !== undefined) {\n\t\t\t(idCompressor as unknown as IIdCompressorCore).beginGhostSession(ghostSessionId, () =>\n\t\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\t}\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: (IChannel & ITree) | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- intentional behavior\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): IChannel & (LegacySharedTree | ITree) {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t);\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IChannelAttributes, type IChannelFactory, type IFluidDataStoreRuntime, type IChannelServices } from '@fluidframework/datastore-definitions/internal';
6
- import { type ITree } from '@fluidframework/tree';
7
- import { type SharedTree as LegacySharedTree, type SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';
5
+ import type { IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from '@fluidframework/datastore-definitions/internal';
6
+ import type { ITree } from '@fluidframework/tree';
7
+ import type { SharedTree as LegacySharedTree, SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';
8
8
  import { MigrationShim } from './migrationShim.js';
9
9
  /**
10
10
  * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link MigrationShim}.
@@ -1 +1 @@
1
- {"version":3,"file":"migrationShimFactory.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACN,KAAK,UAAU,IAAI,gBAAgB,EACnC,KAAK,iBAAiB,IAAI,uBAAuB,EACjD,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAE1D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBAFpB,UAAU,EAAE,uBAAuB,EACnC,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,EAClC,oBAAoB,EAA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;;OAIG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;;;OAKG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAQzB;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAMzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"migrationShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAc7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,oBAAoB;IAChC,YACkB,UAAmC,EACnC,UAAkC,EAClC,oBAA+E;QAF/E,eAAU,GAAV,UAAU,CAAyB;QACnC,eAAU,GAAV,UAAU,CAAwB;QAClC,yBAAoB,GAApB,oBAAoB,CAA2D;IAC9F,CAAC;IAEJ;;;;OAIG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,mKAAmK;QACnK,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrG,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClH,MAAM,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,oCAAoC;QACpC,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClH,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,aAAa,CAAC;IACtB,CAAC;CACD","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';\nimport {\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport { type ITree } from '@fluidframework/tree';\n\nimport {\n\ttype SharedTree as LegacySharedTree,\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n} from '../SharedTree.js';\n\nimport { MigrationShim } from './migrationShim.js';\nimport { attributesMatch } from './utils.js';\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link MigrationShim}.\n *\n * Creates the migration shim that allows a migration from legacy shared tree to shared tree.\n * @remarks\n *\n * It takes over the attributes of the legacy factory, so that it is loaded instead of the normal legacy factory. Once migration finishes, the shim it produces will change its attributes to those of the new factory - meaning that on the next summarization the shim will write a summary that will cause future clients to load a different factory and shim (the SharedTreeShimFactory and SharedTreeShim).\n * 1. pre-migration\n *\n * @sealed\n * @internal\n */\nexport class MigrationShimFactory implements IChannelFactory {\n\tpublic constructor(\n\t\tprivate readonly oldFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewChannelFn: (oldChannel: LegacySharedTree, newChannel: ITree) => void\n\t) {}\n\n\t/**\n\t * This factory takes over the type of the oldFactory to load in its place. The user must not include the MigrationShimFactory and the oldFactory in the same registry to avoid conflict.\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.oldFactory.type;\n\t}\n\n\t/**\n\t * Should be the LegacySharedTree attributes\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.oldFactory.attributes;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.load}\n\t *\n\t * Should be loading the MigrationShim - it should just load the old tree as this makes the factory's\n\t * responsibility simple. Trying to follow the Single Responsibility Principle here.\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes\n\t): Promise<MigrationShim> {\n\t\t// TODO: remove attributes check and move it to an automated test that constructing a MigrationShimFactory and checking its attributes/type matches the oldFactory.\n\t\tassert(attributesMatch(attributes, this.oldFactory.attributes), 0x7ea /* Attributes do not match */);\n\t\tconst migrationShim = new MigrationShim(id, runtime, this.oldFactory, this.newFactory, this.populateNewChannelFn);\n\t\tawait migrationShim.load(services);\n\t\treturn migrationShim;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.create}\n\t *\n\t * Create MigrationShim that can hot swap from one DDS to a new DDS. We want the capability of creating an old tree\n\t * as when this code rolls out, there may be clients on the v1 version of the code, and we may want to have a dark\n\t * rollout capability.\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): MigrationShim {\n\t\t// Maybe this should throw an error.\n\t\tconst migrationShim = new MigrationShim(id, runtime, this.oldFactory, this.newFactory, this.populateNewChannelFn);\n\t\tmigrationShim.create();\n\t\treturn migrationShim;\n\t}\n}\n"]}
1
+ {"version":3,"file":"migrationShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAW7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,oBAAoB;IAChC,YACkB,UAAmC,EACnC,UAAkC,EAClC,oBAA+E;QAF/E,eAAU,GAAV,UAAU,CAAyB;QACnC,eAAU,GAAV,UAAU,CAAwB;QAClC,yBAAoB,GAApB,oBAAoB,CAA2D;IAC9F,CAAC;IAEJ;;;;OAIG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,mKAAmK;QACnK,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrG,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClH,MAAM,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,oCAAoC;QACpC,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClH,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,aAAa,CAAC;IACtB,CAAC;CACD","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';\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport type { ITree } from '@fluidframework/tree';\n\nimport type { SharedTree as LegacySharedTree, SharedTreeFactory as LegacySharedTreeFactory } from '../SharedTree.js';\n\nimport { MigrationShim } from './migrationShim.js';\nimport { attributesMatch } from './utils.js';\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link MigrationShim}.\n *\n * Creates the migration shim that allows a migration from legacy shared tree to shared tree.\n * @remarks\n *\n * It takes over the attributes of the legacy factory, so that it is loaded instead of the normal legacy factory. Once migration finishes, the shim it produces will change its attributes to those of the new factory - meaning that on the next summarization the shim will write a summary that will cause future clients to load a different factory and shim (the SharedTreeShimFactory and SharedTreeShim).\n * 1. pre-migration\n *\n * @sealed\n * @internal\n */\nexport class MigrationShimFactory implements IChannelFactory {\n\tpublic constructor(\n\t\tprivate readonly oldFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewChannelFn: (oldChannel: LegacySharedTree, newChannel: ITree) => void\n\t) {}\n\n\t/**\n\t * This factory takes over the type of the oldFactory to load in its place. The user must not include the MigrationShimFactory and the oldFactory in the same registry to avoid conflict.\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.oldFactory.type;\n\t}\n\n\t/**\n\t * Should be the LegacySharedTree attributes\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.oldFactory.attributes;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.load}\n\t *\n\t * Should be loading the MigrationShim - it should just load the old tree as this makes the factory's\n\t * responsibility simple. Trying to follow the Single Responsibility Principle here.\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes\n\t): Promise<MigrationShim> {\n\t\t// TODO: remove attributes check and move it to an automated test that constructing a MigrationShimFactory and checking its attributes/type matches the oldFactory.\n\t\tassert(attributesMatch(attributes, this.oldFactory.attributes), 0x7ea /* Attributes do not match */);\n\t\tconst migrationShim = new MigrationShim(id, runtime, this.oldFactory, this.newFactory, this.populateNewChannelFn);\n\t\tawait migrationShim.load(services);\n\t\treturn migrationShim;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.create}\n\t *\n\t * Create MigrationShim that can hot swap from one DDS to a new DDS. We want the capability of creating an old tree\n\t * as when this code rolls out, there may be clients on the v1 version of the code, and we may want to have a dark\n\t * rollout capability.\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): MigrationShim {\n\t\t// Maybe this should throw an error.\n\t\tconst migrationShim = new MigrationShim(id, runtime, this.oldFactory, this.newFactory, this.populateNewChannelFn);\n\t\tmigrationShim.create();\n\t\treturn migrationShim;\n\t}\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IChannelAttributes, type IDeltaHandler } from '@fluidframework/datastore-definitions/internal';
5
+ import type { IChannelAttributes, IDeltaHandler } from '@fluidframework/datastore-definitions/internal';
6
6
  import type { IRuntimeMessageCollection } from '@fluidframework/runtime-definitions/internal';
7
- import { type IShimDeltaHandler } from './types.js';
7
+ import type { IShimDeltaHandler } from './types.js';
8
8
  /**
9
9
  * Handles incoming and outgoing deltas/ops for the SharedTreeShim distributed data structure.
10
10
  * This serves as an adapter to the real DeltaHandler, filter/process migration ops
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeDeltaHandler.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAE7G,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,8CAA8C,CAAC;AAEvH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGtE;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,YAAW,iBAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,kBAAkB;IAElE,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAEM,YAAY,IAAI,IAAI;IAIpB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAKpD,mBAAmB,IAAI,OAAO;IAIrC,OAAO,CAAC,OAAO;IAsBR,eAAe,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAQpE,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAK5C,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAS3D,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAQ9C;;;OAGG;IACI,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAQnE;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAYpB"}
1
+ {"version":3,"file":"sharedTreeDeltaHandler.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAExG,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,8CAA8C,CAAC;AAEvH,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGjE;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,YAAW,iBAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,kBAAkB;IAElE,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAEM,YAAY,IAAI,IAAI;IAIpB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAKpD,mBAAmB,IAAI,OAAO;IAIrC,OAAO,CAAC,OAAO;IAsBR,eAAe,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAQpE,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAK5C,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAS3D,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAQ9C;;;OAGG;IACI,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAQnE;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAYpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeDeltaHandler.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GA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QAC3D,MAAM,CACL,CAAC,IAAI,CAAC,YAAY,CAAC,QAAuB,CAAC,EAC3C,KAAK,CAAC,wFAAwF,CAC9F,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,QAAqB;QACzC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,gCAAgC;QAChC,MAAM,CACL,eAAe,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,UAAU,CAAC,EAC9D,KAAK,CAAC,iDAAiD,CACvD,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;CACD","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';\nimport { type IChannelAttributes, type IDeltaHandler } from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { IRuntimeMessageCollection, IRuntimeMessagesContent } from '@fluidframework/runtime-definitions/internal';\n\nimport { type IOpContents, type IShimDeltaHandler } from './types.js';\nimport { attributesMatch, isStampedOp } from './utils.js';\n\n/**\n * Handles incoming and outgoing deltas/ops for the SharedTreeShim distributed data structure.\n * This serves as an adapter to the real DeltaHandler, filter/process migration ops\n *\n * This should just have the ability to drop v1 & migrate ops, and process v2 ops. There may be an opportunity to\n * combine this class with the MigrationShimDeltaHandler, but for now the classes are separated. Once it is clear what\n * exact code can be shared between the two classes is and how it can be merge, we may figure out a way of merging\n * MigrationShimDeltaHandler and SharedTreeShimDeltaHandler.\n */\nexport class SharedTreeShimDeltaHandler implements IShimDeltaHandler {\n\tpublic constructor(private readonly attributes: IChannelAttributes) {}\n\n\tprivate _handler?: IDeltaHandler;\n\tprivate get handler(): IDeltaHandler {\n\t\tconst handler = this._handler;\n\t\tassert(handler !== undefined, 0x7eb /* No handler to process op */);\n\t\treturn handler;\n\t}\n\n\tprivate _attached = false;\n\tpublic get attached(): boolean {\n\t\treturn this._attached;\n\t}\n\n\tpublic markAttached(): void {\n\t\tthis._attached = true;\n\t}\n\n\tpublic attachTreeDeltaHandler(handler: IDeltaHandler): void {\n\t\tassert(this._handler === undefined, 0x7ec /* Should only be able to connect once! */);\n\t\tthis._handler = handler;\n\t}\n\n\tpublic hasTreeDeltaHandler(): boolean {\n\t\treturn this._handler !== undefined;\n\t}\n\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n\t\t// This allows us to process the migrate op and prevent the shared object from processing the wrong ops\n\t\t// Drop v1 ops\n\t\tassert(this.hasTreeDeltaHandler(), 0x831 /* Can't process ops before attaching tree handler */);\n\n\t\tif (message.type !== MessageType.Operation) {\n\t\t\treturn;\n\t\t}\n\t\tconst contents = message.contents as IOpContents;\n\t\tif (this.shouldDropOp(contents)) {\n\t\t\treturn;\n\t\t}\n\t\tconst messagesContent: IRuntimeMessagesContent[] = [\n\t\t\t{\n\t\t\t\tcontents,\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber: message.clientSequenceNumber,\n\t\t\t},\n\t\t];\n\t\treturn this.handler.processMessages({ envelope: message, messagesContent, local });\n\t}\n\n\tpublic processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process({ ...envelope, contents, clientSequenceNumber }, local, localOpMetadata);\n\t\t}\n\t}\n\n\t// No idea whether any of the below 4 methods work as expected\n\tpublic setConnectionState(connected: boolean): void {\n\t\treturn this.handler.setConnectionState(connected);\n\t}\n\n\t// Resubmitting v1 ops should fail. We should not be resubmitting v1 ops.\n\tpublic reSubmit(contents: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x832 /* Should not be able to rollback v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\treturn this.handler.reSubmit(contents, localOpMetadata);\n\t}\n\n\t// We are not capable of applying stashed v1 ops.\n\tpublic applyStashedOp(contents: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x8ab /* SharedTreeShim should not be able to apply v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\tthis.handler.applyStashedOp(contents);\n\t}\n\n\t/**\n\t * We cannot rollback v1 ops, we have already migrated and are in v2 state, thus we should not be able to generate.\n\t * v1 ops\n\t */\n\tpublic rollback?(contents: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x833 /* Should not be able to rollback v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\treturn this.handler.rollback?.(contents, localOpMetadata);\n\t}\n\n\t/**\n\t * The SharedTreeShimDeltaHandler is already in a v2 state. Thus it should drop all v1 and migrate ops.\n\t * @param contents - the interrogable op contents to figure out if this is a v1 op, a migrate op, or a v2 op.\n\t * @returns whether or not the op is a v1 or migrate op and should be dropped/ignored.\n\t */\n\tprivate shouldDropOp(contents: IOpContents): boolean {\n\t\tif (!isStampedOp(contents)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Don't drop v2 ops in v2 state\n\t\tassert(\n\t\t\tattributesMatch(contents.fluidMigrationStamp, this.attributes),\n\t\t\t0x834 /* Unexpected v2 op with mismatched attributes */\n\t\t);\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTreeDeltaHandler.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeDeltaHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAkC,MAAM,6CAA6C,CA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ACF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,QAAqB;QACzC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,gCAAgC;QAChC,MAAM,CACL,eAAe,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,UAAU,CAAC,EAC9D,KAAK,CAAC,iDAAiD,CACvD,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;CACD","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';\nimport type { IChannelAttributes, IDeltaHandler } from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { IRuntimeMessageCollection, IRuntimeMessagesContent } from '@fluidframework/runtime-definitions/internal';\n\nimport type { IOpContents, IShimDeltaHandler } from './types.js';\nimport { attributesMatch, isStampedOp } from './utils.js';\n\n/**\n * Handles incoming and outgoing deltas/ops for the SharedTreeShim distributed data structure.\n * This serves as an adapter to the real DeltaHandler, filter/process migration ops\n *\n * This should just have the ability to drop v1 & migrate ops, and process v2 ops. There may be an opportunity to\n * combine this class with the MigrationShimDeltaHandler, but for now the classes are separated. Once it is clear what\n * exact code can be shared between the two classes is and how it can be merge, we may figure out a way of merging\n * MigrationShimDeltaHandler and SharedTreeShimDeltaHandler.\n */\nexport class SharedTreeShimDeltaHandler implements IShimDeltaHandler {\n\tpublic constructor(private readonly attributes: IChannelAttributes) {}\n\n\tprivate _handler?: IDeltaHandler;\n\tprivate get handler(): IDeltaHandler {\n\t\tconst handler = this._handler;\n\t\tassert(handler !== undefined, 0x7eb /* No handler to process op */);\n\t\treturn handler;\n\t}\n\n\tprivate _attached = false;\n\tpublic get attached(): boolean {\n\t\treturn this._attached;\n\t}\n\n\tpublic markAttached(): void {\n\t\tthis._attached = true;\n\t}\n\n\tpublic attachTreeDeltaHandler(handler: IDeltaHandler): void {\n\t\tassert(this._handler === undefined, 0x7ec /* Should only be able to connect once! */);\n\t\tthis._handler = handler;\n\t}\n\n\tpublic hasTreeDeltaHandler(): boolean {\n\t\treturn this._handler !== undefined;\n\t}\n\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n\t\t// This allows us to process the migrate op and prevent the shared object from processing the wrong ops\n\t\t// Drop v1 ops\n\t\tassert(this.hasTreeDeltaHandler(), 0x831 /* Can't process ops before attaching tree handler */);\n\n\t\tif (message.type !== MessageType.Operation) {\n\t\t\treturn;\n\t\t}\n\t\tconst contents = message.contents as IOpContents;\n\t\tif (this.shouldDropOp(contents)) {\n\t\t\treturn;\n\t\t}\n\t\tconst messagesContent: IRuntimeMessagesContent[] = [\n\t\t\t{\n\t\t\t\tcontents,\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber: message.clientSequenceNumber,\n\t\t\t},\n\t\t];\n\t\treturn this.handler.processMessages({ envelope: message, messagesContent, local });\n\t}\n\n\tpublic processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process({ ...envelope, contents, clientSequenceNumber }, local, localOpMetadata);\n\t\t}\n\t}\n\n\t// No idea whether any of the below 4 methods work as expected\n\tpublic setConnectionState(connected: boolean): void {\n\t\treturn this.handler.setConnectionState(connected);\n\t}\n\n\t// Resubmitting v1 ops should fail. We should not be resubmitting v1 ops.\n\tpublic reSubmit(contents: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x832 /* Should not be able to rollback v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\treturn this.handler.reSubmit(contents, localOpMetadata);\n\t}\n\n\t// We are not capable of applying stashed v1 ops.\n\tpublic applyStashedOp(contents: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x8ab /* SharedTreeShim should not be able to apply v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\tthis.handler.applyStashedOp(contents);\n\t}\n\n\t/**\n\t * We cannot rollback v1 ops, we have already migrated and are in v2 state, thus we should not be able to generate.\n\t * v1 ops\n\t */\n\tpublic rollback?(contents: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\t!this.shouldDropOp(contents as IOpContents),\n\t\t\t0x833 /* Should not be able to rollback v1 ops as they shouldn't have been created locally. */\n\t\t);\n\t\treturn this.handler.rollback?.(contents, localOpMetadata);\n\t}\n\n\t/**\n\t * The SharedTreeShimDeltaHandler is already in a v2 state. Thus it should drop all v1 and migrate ops.\n\t * @param contents - the interrogable op contents to figure out if this is a v1 op, a migrate op, or a v2 op.\n\t * @returns whether or not the op is a v1 or migrate op and should be dropped/ignored.\n\t */\n\tprivate shouldDropOp(contents: IOpContents): boolean {\n\t\tif (!isStampedOp(contents)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Don't drop v2 ops in v2 state\n\t\tassert(\n\t\t\tattributesMatch(contents.fluidMigrationStamp, this.attributes),\n\t\t\t0x834 /* Unexpected v2 op with mismatched attributes */\n\t\t);\n\t\treturn false;\n\t}\n}\n"]}
@@ -2,11 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';
6
- import { type IChannel, type IChannelAttributes, type IChannelFactory, type IFluidDataStoreRuntime, type IChannelServices } from '@fluidframework/datastore-definitions/internal';
7
- import { type IExperimentalIncrementalSummaryContext, type IGarbageCollectionData, type ISummaryTreeWithStats, type ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
8
- import { type ITree } from '@fluidframework/tree';
9
- import { type IShim } from './types.js';
5
+ import type { IFluidHandle, IFluidLoadable } from '@fluidframework/core-interfaces';
6
+ import type { IChannel, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from '@fluidframework/datastore-definitions/internal';
7
+ import type { IExperimentalIncrementalSummaryContext, IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
8
+ import type { ITree } from '@fluidframework/tree';
9
+ import type { IShim } from './types.js';
10
10
  /**
11
11
  * SharedTreeShim is loaded by clients that join after the migration completes, and holds the new SharedTree.
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeShim.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEzF,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,KAAK,sCAAsC,EAC3C,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAMlD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,YAAW,KAAK;aAE1B,EAAE,EAAE,MAAM;aACV,OAAO,EAAE,sBAAsB;aAC/B,iBAAiB,EAAE,eAAe,CAAC,KAAK,CAAC;gBAFzC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,iBAAiB,EAAE,eAAe,CAAC,KAAK,CAAC;IAM1D,OAAO,CA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I,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEO,wBAAwB,CAAC,QAA0B;QAC1D,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,YAAY,GAAG;YACpB,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,oBAAoB,CACxC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,iBAAiB,CAAC,UAAU,CACjC;SACD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport {\n\ttype IChannel,\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport { type ITree } from '@fluidframework/tree';\n\nimport { SharedTreeShimDeltaHandler } from './sharedTreeDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim } from './types.js';\n\n/**\n * SharedTreeShim is loaded by clients that join after the migration completes, and holds the new SharedTree.\n *\n * @remarks\n *\n * Its sole responsibility should be to drop v1 & migrate ops. It should not be responsible for any other migration\n * logic. This should make the classes easier to reason about.\n * about.\n *\n * @internal\n */\nexport class SharedTreeShim implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly sharedTreeFactory: IChannelFactory<ITree>\n\t) {\n\t\tthis.newTreeShimDeltaHandler = new SharedTreeShimDeltaHandler(sharedTreeFactory.attributes);\n\t\tthis.handle = new ShimHandle<SharedTreeShim>(this);\n\t}\n\n\tprivate readonly newTreeShimDeltaHandler: SharedTreeShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate _currentTree?: ITree & IChannel;\n\tpublic get currentTree(): ITree & IChannel {\n\t\tassert(this._currentTree !== undefined, 0x7ed /* No current tree initialized */);\n\t\treturn this._currentTree;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\n\tpublic handle: IFluidHandle<SharedTreeShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\treturn this.currentTree.connect(shimServices);\n\t}\n\n\t// The goal here is to mimic the SharedObject.load functionality\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\t// This weird shimServices logic is to enable rehydration of the SharedTreeShim from a snapshot in a detached\n\t\t// state.\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._currentTree = await this.sharedTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.sharedTreeFactory.attributes\n\t\t);\n\t}\n\n\tpublic create(): void {\n\t\tthis._currentTree = this.sharedTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(this.services === undefined, 0x7ee /* Already connected */);\n\t\tthis.services = services;\n\t\tconst shimServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.newTreeShimDeltaHandler,\n\t\t\t\tthis.sharedTreeFactory.attributes\n\t\t\t),\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTreeShim.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAgB7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA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;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from '@fluidframework/container-definitions';\nimport type { IFluidHandle, IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport type {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport type { ITree } from '@fluidframework/tree';\n\nimport { SharedTreeShimDeltaHandler } from './sharedTreeDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport type { IShim } from './types.js';\n\n/**\n * SharedTreeShim is loaded by clients that join after the migration completes, and holds the new SharedTree.\n *\n * @remarks\n *\n * Its sole responsibility should be to drop v1 & migrate ops. It should not be responsible for any other migration\n * logic. This should make the classes easier to reason about.\n * about.\n *\n * @internal\n */\nexport class SharedTreeShim implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly sharedTreeFactory: IChannelFactory<ITree>\n\t) {\n\t\tthis.newTreeShimDeltaHandler = new SharedTreeShimDeltaHandler(sharedTreeFactory.attributes);\n\t\tthis.handle = new ShimHandle<SharedTreeShim>(this);\n\t}\n\n\tprivate readonly newTreeShimDeltaHandler: SharedTreeShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate _currentTree?: ITree & IChannel;\n\tpublic get currentTree(): ITree & IChannel {\n\t\tassert(this._currentTree !== undefined, 0x7ed /* No current tree initialized */);\n\t\treturn this._currentTree;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\n\tpublic handle: IFluidHandle<SharedTreeShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\treturn this.currentTree.connect(shimServices);\n\t}\n\n\t// The goal here is to mimic the SharedObject.load functionality\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\t// This weird shimServices logic is to enable rehydration of the SharedTreeShim from a snapshot in a detached\n\t\t// state.\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._currentTree = await this.sharedTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.sharedTreeFactory.attributes\n\t\t);\n\t}\n\n\tpublic create(): void {\n\t\tthis._currentTree = this.sharedTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(this.services === undefined, 0x7ee /* Already connected */);\n\t\tthis.services = services;\n\t\tconst shimServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.newTreeShimDeltaHandler,\n\t\t\t\tthis.sharedTreeFactory.attributes\n\t\t\t),\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IChannelAttributes, type IChannelFactory, type IFluidDataStoreRuntime, type IChannelServices } from '@fluidframework/datastore-definitions/internal';
5
+ import type { IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from '@fluidframework/datastore-definitions/internal';
6
6
  import type { ITree } from '@fluidframework/tree';
7
7
  import { SharedTreeShim } from './sharedTreeShim.js';
8
8
  /**