@fluidframework/merge-tree 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +0 -6
- package/api-extractor-esm.json +17 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +0 -4
- package/api-report/merge-tree.api.md +4 -9
- package/dist/client.d.ts +0 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -7
- package/dist/client.js.map +1 -1
- package/dist/merge-tree-alpha.d.ts +27 -12
- package/dist/merge-tree-beta.d.ts +0 -16
- package/dist/merge-tree-public.d.ts +0 -16
- package/dist/merge-tree-untrimmed.d.ts +5 -29
- package/dist/mergeTree.d.ts +0 -17
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +0 -130
- package/dist/mergeTree.js.map +1 -1
- package/dist/ops.d.ts +1 -1
- package/dist/ops.js +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/revertibles.d.ts +4 -4
- package/dist/revertibles.js +3 -3
- package/dist/revertibles.js.map +1 -1
- package/dist/test/Insertion.perf.spec.d.ts +6 -0
- package/dist/test/Insertion.perf.spec.d.ts.map +1 -0
- package/dist/test/Insertion.perf.spec.js +113 -0
- package/dist/test/Insertion.perf.spec.js.map +1 -0
- package/dist/test/PartialLengths.perf.spec.d.ts +6 -0
- package/dist/test/PartialLengths.perf.spec.d.ts.map +1 -0
- package/dist/test/PartialLengths.perf.spec.js +67 -0
- package/dist/test/PartialLengths.perf.spec.js.map +1 -0
- package/dist/test/Removal.perf.spec.d.ts +6 -0
- package/dist/test/Removal.perf.spec.d.ts.map +1 -0
- package/dist/test/Removal.perf.spec.js +166 -0
- package/dist/test/Removal.perf.spec.js.map +1 -0
- package/dist/test/Snapshot.perf.spec.d.ts +6 -0
- package/dist/test/Snapshot.perf.spec.d.ts.map +1 -0
- package/dist/test/Snapshot.perf.spec.js +33 -0
- package/dist/test/Snapshot.perf.spec.js.map +1 -0
- package/dist/test/attributionCollection.perf.spec.d.ts +6 -0
- package/dist/test/attributionCollection.perf.spec.d.ts.map +1 -0
- package/dist/test/attributionCollection.perf.spec.js +231 -0
- package/dist/test/attributionCollection.perf.spec.js.map +1 -0
- package/dist/test/attributionCollection.spec.d.ts +6 -0
- package/dist/test/attributionCollection.spec.d.ts.map +1 -0
- package/dist/test/attributionCollection.spec.js +486 -0
- package/dist/test/attributionCollection.spec.js.map +1 -0
- package/dist/test/attributionPolicy.spec.d.ts +6 -0
- package/dist/test/attributionPolicy.spec.d.ts.map +1 -0
- package/dist/test/attributionPolicy.spec.js +189 -0
- package/dist/test/attributionPolicy.spec.js.map +1 -0
- package/dist/test/beastTest.d.ts +54 -0
- package/dist/test/beastTest.d.ts.map +1 -0
- package/dist/test/beastTest.js +1333 -0
- package/dist/test/beastTest.js.map +1 -0
- package/dist/test/client.annotateMarker.spec.d.ts +6 -0
- package/dist/test/client.annotateMarker.spec.d.ts.map +1 -0
- package/dist/test/client.annotateMarker.spec.js +45 -0
- package/dist/test/client.annotateMarker.spec.js.map +1 -0
- package/dist/test/client.apis.d.ts +7 -0
- package/dist/test/client.apis.d.ts.map +1 -0
- package/dist/test/client.apis.js +72 -0
- package/dist/test/client.apis.js.map +1 -0
- package/dist/test/client.applyMsg.spec.d.ts +6 -0
- package/dist/test/client.applyMsg.spec.d.ts.map +1 -0
- package/dist/test/client.applyMsg.spec.js +500 -0
- package/dist/test/client.applyMsg.spec.js.map +1 -0
- package/dist/test/client.applyStashedOpFarm.spec.d.ts +12 -0
- package/dist/test/client.applyStashedOpFarm.spec.d.ts.map +1 -0
- package/dist/test/client.applyStashedOpFarm.spec.js +144 -0
- package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -0
- package/dist/test/client.attributionFarm.spec.d.ts +7 -0
- package/dist/test/client.attributionFarm.spec.d.ts.map +1 -0
- package/dist/test/client.attributionFarm.spec.js +96 -0
- package/dist/test/client.attributionFarm.spec.js.map +1 -0
- package/dist/test/client.conflictFarm.spec.d.ts +15 -0
- package/dist/test/client.conflictFarm.spec.d.ts.map +1 -0
- package/dist/test/client.conflictFarm.spec.js +88 -0
- package/dist/test/client.conflictFarm.spec.js.map +1 -0
- package/dist/test/client.getPosition.spec.d.ts +6 -0
- package/dist/test/client.getPosition.spec.d.ts.map +1 -0
- package/dist/test/client.getPosition.spec.js +54 -0
- package/dist/test/client.getPosition.spec.js.map +1 -0
- package/dist/test/client.localReference.spec.d.ts +6 -0
- package/dist/test/client.localReference.spec.d.ts.map +1 -0
- package/dist/test/client.localReference.spec.js +439 -0
- package/dist/test/client.localReference.spec.js.map +1 -0
- package/dist/test/client.localReferenceFarm.spec.d.ts +6 -0
- package/dist/test/client.localReferenceFarm.spec.d.ts.map +1 -0
- package/dist/test/client.localReferenceFarm.spec.js +88 -0
- package/dist/test/client.localReferenceFarm.spec.js.map +1 -0
- package/dist/test/client.rebasePosition.spec.d.ts +6 -0
- package/dist/test/client.rebasePosition.spec.d.ts.map +1 -0
- package/dist/test/client.rebasePosition.spec.js +102 -0
- package/dist/test/client.rebasePosition.spec.js.map +1 -0
- package/dist/test/client.reconnectFarm.spec.d.ts +12 -0
- package/dist/test/client.reconnectFarm.spec.d.ts.map +1 -0
- package/dist/test/client.reconnectFarm.spec.js +91 -0
- package/dist/test/client.reconnectFarm.spec.js.map +1 -0
- package/dist/test/client.replay.spec.d.ts +6 -0
- package/dist/test/client.replay.spec.d.ts.map +1 -0
- package/dist/test/client.replay.spec.js +85 -0
- package/dist/test/client.replay.spec.js.map +1 -0
- package/dist/test/client.rollback.spec.d.ts +6 -0
- package/dist/test/client.rollback.spec.d.ts.map +1 -0
- package/dist/test/client.rollback.spec.js +453 -0
- package/dist/test/client.rollback.spec.js.map +1 -0
- package/dist/test/client.rollbackFarm.spec.d.ts +6 -0
- package/dist/test/client.rollbackFarm.spec.d.ts.map +1 -0
- package/dist/test/client.rollbackFarm.spec.js +48 -0
- package/dist/test/client.rollbackFarm.spec.js.map +1 -0
- package/dist/test/client.searchForMarker.spec.d.ts +6 -0
- package/dist/test/client.searchForMarker.spec.d.ts.map +1 -0
- package/dist/test/client.searchForMarker.spec.js +446 -0
- package/dist/test/client.searchForMarker.spec.js.map +1 -0
- package/dist/test/client.walkSegments.spec.d.ts +6 -0
- package/dist/test/client.walkSegments.spec.d.ts.map +1 -0
- package/dist/test/client.walkSegments.spec.js +54 -0
- package/dist/test/client.walkSegments.spec.js.map +1 -0
- package/dist/test/collections.list.spec.d.ts +6 -0
- package/dist/test/collections.list.spec.d.ts.map +1 -0
- package/dist/test/collections.list.spec.js +84 -0
- package/dist/test/collections.list.spec.js.map +1 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.d.ts +6 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.d.ts.map +1 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.js +35 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.js.map +1 -0
- package/dist/test/index.d.ts +13 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +88 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js +142 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.annotate.spec.d.ts +6 -0
- package/dist/test/mergeTree.annotate.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.annotate.spec.js +448 -0
- package/dist/test/mergeTree.annotate.spec.js.map +1 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.js +126 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.insertingWalk.spec.d.ts +6 -0
- package/dist/test/mergeTree.insertingWalk.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.insertingWalk.spec.js +279 -0
- package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +178 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.d.ts +6 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.js +130 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -0
- package/dist/test/mergeTree.walk.spec.d.ts +6 -0
- package/dist/test/mergeTree.walk.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.walk.spec.js +63 -0
- package/dist/test/mergeTree.walk.spec.js.map +1 -0
- package/dist/test/mergeTree.zamboni.spec.d.ts +6 -0
- package/dist/test/mergeTree.zamboni.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.zamboni.spec.js +52 -0
- package/dist/test/mergeTree.zamboni.spec.js.map +1 -0
- package/dist/test/mergeTreeOperationRunner.d.ts +63 -0
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -0
- package/dist/test/mergeTreeOperationRunner.js +245 -0
- package/dist/test/mergeTreeOperationRunner.js.map +1 -0
- package/dist/test/mergeTreeOperationRunner.spec.d.ts +6 -0
- package/dist/test/mergeTreeOperationRunner.spec.d.ts.map +1 -0
- package/dist/test/mergeTreeOperationRunner.spec.js +156 -0
- package/dist/test/mergeTreeOperationRunner.spec.js.map +1 -0
- package/dist/test/obliterate.concurrent.spec.d.ts +6 -0
- package/dist/test/obliterate.concurrent.spec.d.ts.map +1 -0
- package/dist/test/obliterate.concurrent.spec.js +1446 -0
- package/dist/test/obliterate.concurrent.spec.js.map +1 -0
- package/dist/test/obliterate.partialLength.spec.d.ts +6 -0
- package/dist/test/obliterate.partialLength.spec.d.ts.map +1 -0
- package/dist/test/obliterate.partialLength.spec.js +279 -0
- package/dist/test/obliterate.partialLength.spec.js.map +1 -0
- package/dist/test/obliterate.reconnect.spec.d.ts +6 -0
- package/dist/test/obliterate.reconnect.spec.d.ts.map +1 -0
- package/dist/test/obliterate.reconnect.spec.js +164 -0
- package/dist/test/obliterate.reconnect.spec.js.map +1 -0
- package/dist/test/obliterate.spec.d.ts +6 -0
- package/dist/test/obliterate.spec.d.ts.map +1 -0
- package/dist/test/obliterate.spec.js +162 -0
- package/dist/test/obliterate.spec.js.map +1 -0
- package/dist/test/ordinal.spec.d.ts +2 -0
- package/dist/test/ordinal.spec.d.ts.map +1 -0
- package/dist/test/ordinal.spec.js +43 -0
- package/dist/test/ordinal.spec.js.map +1 -0
- package/dist/test/partialLength.spec.d.ts +6 -0
- package/dist/test/partialLength.spec.d.ts.map +1 -0
- package/dist/test/partialLength.spec.js +282 -0
- package/dist/test/partialLength.spec.js.map +1 -0
- package/dist/test/properties.spec.d.ts +6 -0
- package/dist/test/properties.spec.d.ts.map +1 -0
- package/dist/test/properties.spec.js +55 -0
- package/dist/test/properties.spec.js.map +1 -0
- package/dist/test/reconnectHelper.d.ts +48 -0
- package/dist/test/reconnectHelper.d.ts.map +1 -0
- package/dist/test/reconnectHelper.js +86 -0
- package/dist/test/reconnectHelper.js.map +1 -0
- package/dist/test/resetPendingSegmentsToOp.spec.d.ts +6 -0
- package/dist/test/resetPendingSegmentsToOp.spec.d.ts.map +1 -0
- package/dist/test/resetPendingSegmentsToOp.spec.js +218 -0
- package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -0
- package/dist/test/revertibleFarm.spec.d.ts +6 -0
- package/dist/test/revertibleFarm.spec.d.ts.map +1 -0
- package/dist/test/revertibleFarm.spec.js +124 -0
- package/dist/test/revertibleFarm.spec.js.map +1 -0
- package/dist/test/revertibles.spec.d.ts +17 -0
- package/dist/test/revertibles.spec.d.ts.map +1 -0
- package/dist/test/revertibles.spec.js +385 -0
- package/dist/test/revertibles.spec.js.map +1 -0
- package/dist/test/segmentGroupCollection.spec.d.ts +6 -0
- package/dist/test/segmentGroupCollection.spec.d.ts.map +1 -0
- package/dist/test/segmentGroupCollection.spec.js +60 -0
- package/dist/test/segmentGroupCollection.spec.js.map +1 -0
- package/dist/test/snapshot.spec.d.ts +6 -0
- package/dist/test/snapshot.spec.d.ts.map +1 -0
- package/dist/test/snapshot.spec.js +178 -0
- package/dist/test/snapshot.spec.js.map +1 -0
- package/dist/test/snapshot.utils.d.ts +33 -0
- package/dist/test/snapshot.utils.d.ts.map +1 -0
- package/dist/test/snapshot.utils.js +109 -0
- package/dist/test/snapshot.utils.js.map +1 -0
- package/dist/test/snapshotlegacy.spec.d.ts +6 -0
- package/dist/test/snapshotlegacy.spec.d.ts.map +1 -0
- package/dist/test/snapshotlegacy.spec.js +139 -0
- package/dist/test/snapshotlegacy.spec.js.map +1 -0
- package/dist/test/sortedSegmentSet.spec.d.ts +6 -0
- package/dist/test/sortedSegmentSet.spec.d.ts.map +1 -0
- package/dist/test/sortedSegmentSet.spec.js +95 -0
- package/dist/test/sortedSegmentSet.spec.js.map +1 -0
- package/dist/test/testClient.d.ts +119 -0
- package/dist/test/testClient.d.ts.map +1 -0
- package/dist/test/testClient.js +439 -0
- package/dist/test/testClient.js.map +1 -0
- package/dist/test/testClientLogger.d.ts +44 -0
- package/dist/test/testClientLogger.d.ts.map +1 -0
- package/dist/test/testClientLogger.js +287 -0
- package/dist/test/testClientLogger.js.map +1 -0
- package/dist/test/testSerializer.d.ts +18 -0
- package/dist/test/testSerializer.d.ts.map +1 -0
- package/dist/test/testSerializer.js +33 -0
- package/dist/test/testSerializer.js.map +1 -0
- package/dist/test/testServer.d.ts +36 -0
- package/dist/test/testServer.d.ts.map +1 -0
- package/dist/test/testServer.js +138 -0
- package/dist/test/testServer.js.map +1 -0
- package/dist/test/testUtils.d.ts +69 -0
- package/dist/test/testUtils.d.ts.map +1 -0
- package/dist/test/testUtils.js +149 -0
- package/dist/test/testUtils.js.map +1 -0
- package/dist/test/text.d.ts +9 -0
- package/dist/test/text.d.ts.map +1 -0
- package/dist/test/text.js +76 -0
- package/dist/test/text.js.map +1 -0
- package/dist/test/tracking.spec.d.ts +6 -0
- package/dist/test/tracking.spec.d.ts.map +1 -0
- package/dist/test/tracking.spec.js +120 -0
- package/dist/test/tracking.spec.js.map +1 -0
- package/dist/test/wordUnitTests.d.ts +6 -0
- package/dist/test/wordUnitTests.d.ts.map +1 -0
- package/dist/test/wordUnitTests.js +172 -0
- package/dist/test/wordUnitTests.js.map +1 -0
- package/lib/{MergeTreeTextHelper.d.ts → MergeTreeTextHelper.d.mts} +3 -3
- package/lib/MergeTreeTextHelper.d.mts.map +1 -0
- package/lib/{MergeTreeTextHelper.js → MergeTreeTextHelper.mjs} +5 -10
- package/lib/MergeTreeTextHelper.mjs.map +1 -0
- package/lib/{attributionCollection.d.ts → attributionCollection.d.mts} +2 -2
- package/lib/attributionCollection.d.mts.map +1 -0
- package/lib/{attributionCollection.js → attributionCollection.mjs} +9 -14
- package/lib/attributionCollection.mjs.map +1 -0
- package/lib/{attributionPolicy.d.ts → attributionPolicy.d.mts} +2 -2
- package/lib/attributionPolicy.d.mts.map +1 -0
- package/lib/{attributionPolicy.js → attributionPolicy.mjs} +21 -27
- package/lib/attributionPolicy.mjs.map +1 -0
- package/lib/{client.d.ts → client.d.mts} +9 -16
- package/lib/client.d.mts.map +1 -0
- package/lib/{client.js → client.mjs} +101 -110
- package/lib/client.mjs.map +1 -0
- package/lib/collections/{index.d.ts → index.d.mts} +3 -3
- package/lib/collections/index.d.mts.map +1 -0
- package/lib/collections/index.mjs +7 -0
- package/lib/collections/index.mjs.map +1 -0
- package/lib/collections/{list.d.ts → list.d.mts} +1 -1
- package/lib/collections/list.d.mts.map +1 -0
- package/lib/collections/{list.js → list.mjs} +6 -11
- package/lib/collections/list.mjs.map +1 -0
- package/lib/collections/{rbTree.d.ts → rbTree.d.mts} +1 -1
- package/lib/collections/rbTree.d.mts.map +1 -0
- package/lib/collections/{rbTree.js → rbTree.mjs} +16 -20
- package/lib/collections/rbTree.mjs.map +1 -0
- package/lib/{constants.d.ts → constants.d.mts} +1 -1
- package/lib/constants.d.mts.map +1 -0
- package/lib/constants.mjs +32 -0
- package/lib/constants.mjs.map +1 -0
- package/lib/{endOfTreeSegment.d.ts → endOfTreeSegment.d.mts} +4 -4
- package/lib/endOfTreeSegment.d.mts.map +1 -0
- package/lib/{endOfTreeSegment.js → endOfTreeSegment.mjs} +13 -18
- package/lib/endOfTreeSegment.mjs.map +1 -0
- package/lib/{index.d.ts → index.d.mts} +21 -21
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +24 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{localReference.d.ts → localReference.d.mts} +7 -7
- package/lib/localReference.d.mts.map +1 -0
- package/lib/{localReference.js → localReference.mjs} +38 -47
- package/lib/localReference.mjs.map +1 -0
- package/lib/{merge-tree-alpha.d.ts → merge-tree-alpha.d.mts} +27 -12
- package/lib/{merge-tree-beta.d.ts → merge-tree-beta.d.mts} +0 -16
- package/lib/{merge-tree-public.d.ts → merge-tree-public.d.mts} +0 -16
- package/lib/{merge-tree-untrimmed.d.ts → merge-tree-untrimmed.d.mts} +5 -29
- package/lib/{mergeTree.d.ts → mergeTree.d.mts} +12 -29
- package/lib/mergeTree.d.mts.map +1 -0
- package/lib/{mergeTree.js → mergeTree.mjs} +203 -340
- package/lib/mergeTree.mjs.map +1 -0
- package/lib/{mergeTreeDeltaCallback.d.ts → mergeTreeDeltaCallback.d.mts} +4 -8
- package/lib/mergeTreeDeltaCallback.d.mts.map +1 -0
- package/lib/{mergeTreeDeltaCallback.js → mergeTreeDeltaCallback.mjs} +2 -5
- package/lib/mergeTreeDeltaCallback.mjs.map +1 -0
- package/lib/{mergeTreeNodeWalk.d.ts → mergeTreeNodeWalk.d.mts} +2 -2
- package/lib/mergeTreeNodeWalk.d.mts.map +1 -0
- package/lib/{mergeTreeNodeWalk.js → mergeTreeNodeWalk.mjs} +14 -21
- package/lib/mergeTreeNodeWalk.mjs.map +1 -0
- package/lib/{mergeTreeNodes.d.ts → mergeTreeNodes.d.mts} +12 -12
- package/lib/mergeTreeNodes.d.mts.map +1 -0
- package/lib/{mergeTreeNodes.js → mergeTreeNodes.mjs} +60 -76
- package/lib/mergeTreeNodes.mjs.map +1 -0
- package/lib/{mergeTreeTracking.d.ts → mergeTreeTracking.d.mts} +3 -3
- package/lib/mergeTreeTracking.d.mts.map +1 -0
- package/lib/{mergeTreeTracking.js → mergeTreeTracking.mjs} +6 -13
- package/lib/mergeTreeTracking.mjs.map +1 -0
- package/lib/{opBuilder.d.ts → opBuilder.d.mts} +4 -4
- package/lib/opBuilder.d.mts.map +1 -0
- package/lib/{opBuilder.js → opBuilder.mjs} +15 -25
- package/lib/opBuilder.mjs.map +1 -0
- package/lib/{ops.d.ts → ops.d.mts} +2 -2
- package/lib/ops.d.mts.map +1 -0
- package/lib/{ops.js → ops.mjs} +5 -8
- package/lib/ops.mjs.map +1 -0
- package/lib/{ordinal.d.ts → ordinal.d.mts} +1 -1
- package/lib/ordinal.d.mts.map +1 -0
- package/lib/{ordinal.js → ordinal.mjs} +4 -9
- package/lib/ordinal.mjs.map +1 -0
- package/lib/{partialLengths.d.ts → partialLengths.d.mts} +4 -4
- package/lib/partialLengths.d.mts.map +1 -0
- package/lib/{partialLengths.js → partialLengths.mjs} +38 -46
- package/lib/partialLengths.mjs.map +1 -0
- package/lib/{properties.d.ts → properties.d.mts} +1 -1
- package/lib/properties.d.mts.map +1 -0
- package/lib/{properties.js → properties.mjs} +7 -16
- package/lib/properties.mjs.map +1 -0
- package/lib/{referencePositions.d.ts → referencePositions.d.mts} +5 -5
- package/lib/referencePositions.d.mts.map +1 -0
- package/lib/referencePositions.mjs +70 -0
- package/lib/referencePositions.mjs.map +1 -0
- package/lib/{revertibles.d.ts → revertibles.d.mts} +12 -12
- package/lib/revertibles.d.mts.map +1 -0
- package/lib/{revertibles.js → revertibles.mjs} +60 -67
- package/lib/revertibles.mjs.map +1 -0
- package/lib/{segmentGroupCollection.d.ts → segmentGroupCollection.d.mts} +2 -2
- package/lib/segmentGroupCollection.d.mts.map +1 -0
- package/lib/{segmentGroupCollection.js → segmentGroupCollection.mjs} +5 -9
- package/lib/segmentGroupCollection.mjs.map +1 -0
- package/lib/{segmentPropertiesManager.d.ts → segmentPropertiesManager.d.mts} +3 -3
- package/lib/segmentPropertiesManager.d.mts.map +1 -0
- package/lib/{segmentPropertiesManager.js → segmentPropertiesManager.mjs} +14 -20
- package/lib/{segmentPropertiesManager.js.map → segmentPropertiesManager.mjs.map} +1 -1
- package/lib/{snapshotChunks.d.ts → snapshotChunks.d.mts} +4 -4
- package/lib/snapshotChunks.d.mts.map +1 -0
- package/lib/{snapshotChunks.js → snapshotChunks.mjs} +10 -17
- package/lib/snapshotChunks.mjs.map +1 -0
- package/lib/{snapshotLoader.d.ts → snapshotLoader.d.mts} +3 -3
- package/lib/snapshotLoader.d.mts.map +1 -0
- package/lib/{snapshotLoader.js → snapshotLoader.mjs} +33 -38
- package/lib/snapshotLoader.mjs.map +1 -0
- package/lib/{snapshotV1.d.ts → snapshotV1.d.mts} +4 -4
- package/lib/snapshotV1.d.mts.map +1 -0
- package/lib/{snapshotV1.js → snapshotV1.mjs} +28 -32
- package/lib/snapshotV1.mjs.map +1 -0
- package/lib/{snapshotlegacy.d.ts → snapshotlegacy.d.mts} +3 -3
- package/lib/snapshotlegacy.d.mts.map +1 -0
- package/lib/{snapshotlegacy.js → snapshotlegacy.mjs} +21 -26
- package/lib/snapshotlegacy.mjs.map +1 -0
- package/lib/{sortedSegmentSet.d.ts → sortedSegmentSet.d.mts} +4 -4
- package/lib/sortedSegmentSet.d.mts.map +1 -0
- package/lib/{sortedSegmentSet.js → sortedSegmentSet.mjs} +3 -8
- package/lib/sortedSegmentSet.mjs.map +1 -0
- package/lib/{sortedSet.d.ts → sortedSet.d.mts} +1 -1
- package/lib/sortedSet.d.mts.map +1 -0
- package/lib/{sortedSet.js → sortedSet.mjs} +2 -6
- package/lib/sortedSet.mjs.map +1 -0
- package/lib/{textSegment.d.ts → textSegment.d.mts} +4 -4
- package/lib/textSegment.d.mts.map +1 -0
- package/lib/{textSegment.js → textSegment.mjs} +8 -12
- package/lib/textSegment.mjs.map +1 -0
- package/lib/{zamboni.d.ts → zamboni.d.mts} +3 -3
- package/lib/zamboni.d.mts.map +1 -0
- package/lib/{zamboni.js → zamboni.mjs} +22 -28
- package/lib/zamboni.mjs.map +1 -0
- package/package.json +95 -164
- package/src/client.ts +0 -8
- package/src/mergeTree.ts +0 -226
- package/src/ops.ts +1 -1
- package/src/revertibles.ts +4 -4
- package/lib/MergeTreeTextHelper.d.ts.map +0 -1
- package/lib/MergeTreeTextHelper.js.map +0 -1
- package/lib/attributionCollection.d.ts.map +0 -1
- package/lib/attributionCollection.js.map +0 -1
- package/lib/attributionPolicy.d.ts.map +0 -1
- package/lib/attributionPolicy.js.map +0 -1
- package/lib/client.d.ts.map +0 -1
- package/lib/client.js.map +0 -1
- package/lib/collections/index.d.ts.map +0 -1
- package/lib/collections/index.js +0 -14
- package/lib/collections/index.js.map +0 -1
- package/lib/collections/list.d.ts.map +0 -1
- package/lib/collections/list.js.map +0 -1
- package/lib/collections/rbTree.d.ts.map +0 -1
- package/lib/collections/rbTree.js.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -35
- package/lib/constants.js.map +0 -1
- package/lib/endOfTreeSegment.d.ts.map +0 -1
- package/lib/endOfTreeSegment.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -80
- package/lib/index.js.map +0 -1
- package/lib/localReference.d.ts.map +0 -1
- package/lib/localReference.js.map +0 -1
- package/lib/mergeTree.d.ts.map +0 -1
- package/lib/mergeTree.js.map +0 -1
- package/lib/mergeTreeDeltaCallback.d.ts.map +0 -1
- package/lib/mergeTreeDeltaCallback.js.map +0 -1
- package/lib/mergeTreeNodeWalk.d.ts.map +0 -1
- package/lib/mergeTreeNodeWalk.js.map +0 -1
- package/lib/mergeTreeNodes.d.ts.map +0 -1
- package/lib/mergeTreeNodes.js.map +0 -1
- package/lib/mergeTreeTracking.d.ts.map +0 -1
- package/lib/mergeTreeTracking.js.map +0 -1
- package/lib/opBuilder.d.ts.map +0 -1
- package/lib/opBuilder.js.map +0 -1
- package/lib/ops.d.ts.map +0 -1
- package/lib/ops.js.map +0 -1
- package/lib/ordinal.d.ts.map +0 -1
- package/lib/ordinal.js.map +0 -1
- package/lib/partialLengths.d.ts.map +0 -1
- package/lib/partialLengths.js.map +0 -1
- package/lib/properties.d.ts.map +0 -1
- package/lib/properties.js.map +0 -1
- package/lib/referencePositions.d.ts.map +0 -1
- package/lib/referencePositions.js +0 -80
- package/lib/referencePositions.js.map +0 -1
- package/lib/revertibles.d.ts.map +0 -1
- package/lib/revertibles.js.map +0 -1
- package/lib/segmentGroupCollection.d.ts.map +0 -1
- package/lib/segmentGroupCollection.js.map +0 -1
- package/lib/segmentPropertiesManager.d.ts.map +0 -1
- package/lib/snapshotChunks.d.ts.map +0 -1
- package/lib/snapshotChunks.js.map +0 -1
- package/lib/snapshotLoader.d.ts.map +0 -1
- package/lib/snapshotLoader.js.map +0 -1
- package/lib/snapshotV1.d.ts.map +0 -1
- package/lib/snapshotV1.js.map +0 -1
- package/lib/snapshotlegacy.d.ts.map +0 -1
- package/lib/snapshotlegacy.js.map +0 -1
- package/lib/sortedSegmentSet.d.ts.map +0 -1
- package/lib/sortedSegmentSet.js.map +0 -1
- package/lib/sortedSet.d.ts.map +0 -1
- package/lib/sortedSet.js.map +0 -1
- package/lib/textSegment.d.ts.map +0 -1
- package/lib/textSegment.js.map +0 -1
- package/lib/zamboni.d.ts.map +0 -1
- package/lib/zamboni.js.map +0 -1
- package/merge-tree.test-files.tar +0 -0
- package/src/mergeTreeExample1.pdf +0 -0
- package/tsconfig.esnext.json +0 -6
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.toLatestVersion = exports.serializeAsMaxSupportedVersion = exports.serializeAsMinSupportedVersion = exports.hasMergeInfo = void 0;
|
|
8
|
-
const snapshotlegacy_1 = require("./snapshotlegacy");
|
|
5
|
+
import { SnapshotLegacy } from "./snapshotlegacy.mjs";
|
|
9
6
|
/**
|
|
10
7
|
* Returns true if the given 'spec' is an IJSONSegmentWithMergeInfo.
|
|
11
8
|
*/
|
|
12
|
-
function hasMergeInfo(spec) {
|
|
9
|
+
export function hasMergeInfo(spec) {
|
|
13
10
|
return !!spec && typeof spec === "object" && "json" in spec;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
function serializeAsMinSupportedVersion(path, chunk, logger, options, serializer, bind) {
|
|
12
|
+
export function serializeAsMinSupportedVersion(path, chunk, logger, options, serializer, bind) {
|
|
17
13
|
let targetChuck;
|
|
18
14
|
if (chunk.version !== undefined) {
|
|
19
15
|
logger.send({
|
|
@@ -30,7 +26,7 @@ function serializeAsMinSupportedVersion(path, chunk, logger, options, serializer
|
|
|
30
26
|
break;
|
|
31
27
|
case "1":
|
|
32
28
|
const chunkV1 = chunk;
|
|
33
|
-
const headerMetadata = path ===
|
|
29
|
+
const headerMetadata = path === SnapshotLegacy.header ? chunkV1.headerMetadata : undefined;
|
|
34
30
|
targetChuck = {
|
|
35
31
|
version: undefined,
|
|
36
32
|
chunkStartSegmentIndex: chunkV1.startIndex,
|
|
@@ -49,13 +45,11 @@ function serializeAsMinSupportedVersion(path, chunk, logger, options, serializer
|
|
|
49
45
|
}
|
|
50
46
|
return serializer.stringify(targetChuck, bind);
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
function serializeAsMaxSupportedVersion(path, chunk, logger, options, serializer, bind) {
|
|
48
|
+
export function serializeAsMaxSupportedVersion(path, chunk, logger, options, serializer, bind) {
|
|
54
49
|
const targetChuck = toLatestVersion(path, chunk, logger, options);
|
|
55
50
|
return serializer.stringify(targetChuck, bind);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
function toLatestVersion(path, chunk, logger, options) {
|
|
52
|
+
export function toLatestVersion(path, chunk, logger, options) {
|
|
59
53
|
switch (chunk.version) {
|
|
60
54
|
case undefined: {
|
|
61
55
|
const chunkLegacy = chunk;
|
|
@@ -75,15 +69,14 @@ function toLatestVersion(path, chunk, logger, options) {
|
|
|
75
69
|
throw new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
|
-
exports.toLatestVersion = toLatestVersion;
|
|
79
72
|
function buildHeaderMetadataForLegacyChunk(path, chunk, options) {
|
|
80
|
-
if (path ===
|
|
73
|
+
if (path === SnapshotLegacy.header) {
|
|
81
74
|
if (chunk.headerMetadata !== undefined) {
|
|
82
75
|
return chunk.headerMetadata;
|
|
83
76
|
}
|
|
84
|
-
const chunkIds = [{ id:
|
|
77
|
+
const chunkIds = [{ id: SnapshotLegacy.header }];
|
|
85
78
|
if (chunk.chunkLengthChars < chunk.totalLengthChars) {
|
|
86
|
-
chunkIds.push({ id:
|
|
79
|
+
chunkIds.push({ id: SnapshotLegacy.body });
|
|
87
80
|
}
|
|
88
81
|
return {
|
|
89
82
|
orderedChunkMetadata: chunkIds,
|
|
@@ -95,4 +88,4 @@ function buildHeaderMetadataForLegacyChunk(path, chunk, options) {
|
|
|
95
88
|
}
|
|
96
89
|
return undefined;
|
|
97
90
|
}
|
|
98
|
-
//# sourceMappingURL=snapshotChunks.
|
|
91
|
+
//# sourceMappingURL=snapshotChunks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotChunks.mjs","sourceRoot":"","s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AiC,CACzC,IAAY,EACZ,KAA2B,EAC3B,OAAgC;IAEhC,IAAI,IAAI,KAAK,cAAc,CAAC,MAAM,EAAE;QACnC,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,EAAE;YACvC,OAAO,KAAK,CAAC,cAAc,CAAC;SAC5B;QACD,MAAM,QAAQ,GAAmC,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,IAAI,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAiB,EAAE;YACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;SAC3C;QACD,OAAO;YACN,oBAAoB,EAAE,QAAQ;YAC9B,iBAAiB,EAAE,KAAK,CAAC,sBAAuB;YAChD,cAAc,EAAE,KAAK,CAAC,mBAAoB;YAC1C,WAAW,EAAE,KAAK,CAAC,gBAAiB;YACpC,iBAAiB,EAAE,KAAK,CAAC,iBAAkB;SAC3C,CAAC;KACF;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { PropertySet } from \"./properties\";\nimport { SnapshotLegacy } from \"./snapshotlegacy\";\nimport { IJSONSegment } from \"./ops\";\nimport { SerializedAttributionCollection } from \"./attributionCollection\";\n\nexport interface VersionedMergeTreeChunk {\n\tversion: undefined | \"1\";\n}\n\nexport type JsonSegmentSpecs = IJSONSegment | IJSONSegmentWithMergeInfo;\n\nexport interface MergeTreeChunkLegacy extends VersionedMergeTreeChunk {\n\tversion: undefined;\n\tchunkStartSegmentIndex: number;\n\tchunkSegmentCount: number;\n\tchunkLengthChars: number;\n\ttotalLengthChars?: number;\n\ttotalSegmentCount?: number;\n\tchunkSequenceNumber?: number;\n\tchunkMinSequenceNumber?: number;\n\tsegmentTexts: JsonSegmentSpecs[];\n\theaderMetadata?: MergeTreeHeaderMetadata;\n\tattribution?: SerializedAttributionCollection;\n}\n\nexport interface MergeTreeHeaderChunkMetadata {\n\tid: string;\n}\n\nexport interface MergeTreeHeaderMetadata {\n\ttotalLength: number;\n\ttotalSegmentCount: number;\n\torderedChunkMetadata: MergeTreeHeaderChunkMetadata[];\n\tsequenceNumber: number;\n\tminSequenceNumber: number;\n}\n\nexport interface MergeTreeChunkV1 extends VersionedMergeTreeChunk {\n\tversion: \"1\";\n\tstartIndex: number;\n\tsegmentCount: number;\n\tlength: number;\n\tsegments: JsonSegmentSpecs[];\n\theaderMetadata: MergeTreeHeaderMetadata | undefined;\n\tattribution?: SerializedAttributionCollection;\n}\n\n/**\n * Used during snapshotting to record the metadata required to merge segments above the MSN\n * to the raw output of `ISegment.toJSONObject()`. (Note that IJSONSegment may be a raw\n * string or array, which is why this interface wraps the original IJSONSegment instead of\n * extending it.)\n */\nexport interface IJSONSegmentWithMergeInfo {\n\tjson: IJSONSegment;\n\tclient?: string;\n\tseq?: number;\n\tremovedClientIds?: string[];\n\tremovedSeq?: number;\n\tmovedClientIds?: string[];\n\tmovedSeq?: number;\n\tmovedSeqs?: number[];\n}\n\n/**\n * Returns true if the given 'spec' is an IJSONSegmentWithMergeInfo.\n */\nexport function hasMergeInfo(\n\tspec: IJSONSegment | IJSONSegmentWithMergeInfo,\n): spec is IJSONSegmentWithMergeInfo {\n\treturn !!spec && typeof spec === \"object\" && \"json\" in spec;\n}\n\nexport function serializeAsMinSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: ITelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n) {\n\tlet targetChuck: MergeTreeChunkLegacy;\n\n\tif (chunk.version !== undefined) {\n\t\tlogger.send({\n\t\t\teventName: \"MergeTreeChunk:serializeAsMinSupportedVersion\",\n\t\t\tcategory: \"generic\",\n\t\t\tfromChunkVersion: chunk.version,\n\t\t\ttoChunkVersion: undefined,\n\t\t});\n\t}\n\n\tswitch (chunk.version) {\n\t\tcase undefined:\n\t\t\ttargetChuck = chunk as MergeTreeChunkLegacy;\n\t\t\ttargetChuck.headerMetadata = buildHeaderMetadataForLegacyChunk(\n\t\t\t\tpath,\n\t\t\t\ttargetChuck,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tbreak;\n\n\t\tcase \"1\":\n\t\t\tconst chunkV1 = chunk as MergeTreeChunkV1;\n\t\t\tconst headerMetadata =\n\t\t\t\tpath === SnapshotLegacy.header ? chunkV1.headerMetadata : undefined;\n\t\t\ttargetChuck = {\n\t\t\t\tversion: undefined,\n\t\t\t\tchunkStartSegmentIndex: chunkV1.startIndex,\n\t\t\t\tchunkLengthChars: chunkV1.length,\n\t\t\t\tchunkSegmentCount: chunkV1.segmentCount,\n\t\t\t\tsegmentTexts: chunkV1.segments,\n\t\t\t\ttotalLengthChars: headerMetadata?.totalLength,\n\t\t\t\ttotalSegmentCount: headerMetadata?.totalSegmentCount,\n\t\t\t\tchunkSequenceNumber: headerMetadata?.sequenceNumber,\n\t\t\t\tchunkMinSequenceNumber: headerMetadata?.minSequenceNumber,\n\t\t\t\theaderMetadata,\n\t\t\t};\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t}\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function serializeAsMaxSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: ITelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n) {\n\tconst targetChuck = toLatestVersion(path, chunk, logger, options);\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function toLatestVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: ITelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n): MergeTreeChunkV1 {\n\tswitch (chunk.version) {\n\t\tcase undefined: {\n\t\t\tconst chunkLegacy = chunk as MergeTreeChunkLegacy;\n\t\t\treturn {\n\t\t\t\tversion: \"1\",\n\t\t\t\tlength: chunkLegacy.chunkLengthChars,\n\t\t\t\tsegmentCount: chunkLegacy.chunkSegmentCount,\n\t\t\t\theaderMetadata: buildHeaderMetadataForLegacyChunk(path, chunkLegacy, options),\n\t\t\t\tsegments: chunkLegacy.segmentTexts,\n\t\t\t\tstartIndex: chunkLegacy.chunkStartSegmentIndex,\n\t\t\t\tattribution: chunkLegacy.attribution,\n\t\t\t};\n\t\t}\n\t\tcase \"1\":\n\t\t\treturn chunk as MergeTreeChunkV1;\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t}\n}\n\nfunction buildHeaderMetadataForLegacyChunk(\n\tpath: string,\n\tchunk: MergeTreeChunkLegacy,\n\toptions: PropertySet | undefined,\n): MergeTreeHeaderMetadata | undefined {\n\tif (path === SnapshotLegacy.header) {\n\t\tif (chunk.headerMetadata !== undefined) {\n\t\t\treturn chunk.headerMetadata;\n\t\t}\n\t\tconst chunkIds: MergeTreeHeaderChunkMetadata[] = [{ id: SnapshotLegacy.header }];\n\t\tif (chunk.chunkLengthChars < chunk.totalLengthChars!) {\n\t\t\tchunkIds.push({ id: SnapshotLegacy.body });\n\t\t}\n\t\treturn {\n\t\t\torderedChunkMetadata: chunkIds,\n\t\t\tminSequenceNumber: chunk.chunkMinSequenceNumber!,\n\t\t\tsequenceNumber: chunk.chunkSequenceNumber!,\n\t\t\ttotalLength: chunk.totalLengthChars!,\n\t\t\ttotalSegmentCount: chunk.totalSegmentCount!,\n\t\t};\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -6,8 +6,8 @@ import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
9
|
-
import { Client } from "./client";
|
|
10
|
-
import { MergeTree } from "./mergeTree";
|
|
9
|
+
import { Client } from "./client.mjs";
|
|
10
|
+
import { MergeTree } from "./mergeTree.mjs";
|
|
11
11
|
export declare class SnapshotLoader {
|
|
12
12
|
private readonly runtime;
|
|
13
13
|
private readonly client;
|
|
@@ -31,4 +31,4 @@ export declare class SnapshotLoader {
|
|
|
31
31
|
*/
|
|
32
32
|
private loadCatchupOps;
|
|
33
33
|
}
|
|
34
|
-
//# sourceMappingURL=snapshotLoader.d.
|
|
34
|
+
//# sourceMappingURL=snapshotLoader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotLoader.d.mts","sourceRoot":"","sources":["../src/snapshotLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAMI,EAAE,gBAAgB,EAAE,MAAM,oCAAoC;OAC9D,EAEN,mBAAmB,EAEnB,MAAM,iCAAiC;OACjC,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OACzE,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC;OAGvC,EAAE,MAAM,EAAE;OAOV,EAAE,SAAS,EAAE;AAEpB,qBAAa,cAAc;IAIzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAG3B,OAAO,EAAE,sBAAsB,EAE/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACrC,MAAM,EAAE,mBAAmB,EACV,UAAU,EAAE,gBAAgB;IAKjC,UAAU,CACtB,QAAQ,EAAE,sBAAsB,GAC9B,OAAO,CAAC;QAAE,WAAW,EAAE,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAA;KAAE,CAAC;YAiBnD,qBAAqB;IA4BnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAsD5B;IAEF,OAAO,CAAC,UAAU;YAsCJ,QAAQ;IA0FtB,OAAO,CAAC,kBAAkB;IAwB1B;;;;;OAKG;YACW,cAAc;CAK5B"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const snapshotV1_1 = require("./snapshotV1");
|
|
16
|
-
const snapshotlegacy_1 = require("./snapshotlegacy");
|
|
17
|
-
class SnapshotLoader {
|
|
5
|
+
import { bufferToString } from "@fluid-internal/client-utils";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
|
+
import { createChildLogger, UsageError, } from "@fluidframework/telemetry-utils";
|
|
8
|
+
import { AttachState } from "@fluidframework/container-definitions";
|
|
9
|
+
import { NonCollabClient, UniversalSequenceNumber } from "./constants.mjs";
|
|
10
|
+
import { hasMergeInfo } from "./snapshotChunks.mjs";
|
|
11
|
+
import { SnapshotV1 } from "./snapshotV1.mjs";
|
|
12
|
+
import { SnapshotLegacy } from "./snapshotlegacy.mjs";
|
|
13
|
+
export class SnapshotLoader {
|
|
18
14
|
constructor(runtime,
|
|
19
15
|
// eslint-disable-next-line import/no-deprecated
|
|
20
16
|
client, mergeTree, logger, serializer) {
|
|
@@ -24,15 +20,15 @@ class SnapshotLoader {
|
|
|
24
20
|
this.serializer = serializer;
|
|
25
21
|
this.specToSegment = (spec) => {
|
|
26
22
|
let seg;
|
|
27
|
-
if (
|
|
23
|
+
if (hasMergeInfo(spec)) {
|
|
28
24
|
seg = this.client.specToSegment(spec.json);
|
|
29
25
|
// `specToSegment()` initializes `seg` with the LocalClientId. Overwrite this with
|
|
30
26
|
// the `spec` client (if specified). Otherwise overwrite with `NonCollabClient`.
|
|
31
27
|
seg.clientId =
|
|
32
28
|
spec.client !== undefined
|
|
33
29
|
? this.client.getOrAddShortClientId(spec.client)
|
|
34
|
-
:
|
|
35
|
-
seg.seq = spec.seq ??
|
|
30
|
+
: NonCollabClient;
|
|
31
|
+
seg.seq = spec.seq ?? UniversalSequenceNumber;
|
|
36
32
|
if (spec.removedSeq !== undefined) {
|
|
37
33
|
seg.removedSeq = spec.removedSeq;
|
|
38
34
|
}
|
|
@@ -61,19 +57,19 @@ class SnapshotLoader {
|
|
|
61
57
|
}
|
|
62
58
|
else {
|
|
63
59
|
seg = this.client.specToSegment(spec);
|
|
64
|
-
seg.seq =
|
|
60
|
+
seg.seq = UniversalSequenceNumber;
|
|
65
61
|
// `specToSegment()` initializes `seg` with the LocalClientId. We must overwrite this with
|
|
66
62
|
// `NonCollabClient`.
|
|
67
|
-
seg.clientId =
|
|
63
|
+
seg.clientId = NonCollabClient;
|
|
68
64
|
}
|
|
69
65
|
return seg;
|
|
70
66
|
};
|
|
71
|
-
this.logger =
|
|
67
|
+
this.logger = createChildLogger({ logger, namespace: "SnapshotLoader" });
|
|
72
68
|
}
|
|
73
69
|
async initialize(services) {
|
|
74
|
-
const headerLoadedP = services.readBlob(
|
|
75
|
-
|
|
76
|
-
return this.loadHeader(
|
|
70
|
+
const headerLoadedP = services.readBlob(SnapshotLegacy.header).then((header) => {
|
|
71
|
+
assert(!!header, 0x05f /* "Missing blob header on legacy snapshot!" */);
|
|
72
|
+
return this.loadHeader(bufferToString(header, "utf8"));
|
|
77
73
|
});
|
|
78
74
|
const catchupOpsP = this.loadBodyAndCatchupOps(headerLoadedP, services);
|
|
79
75
|
catchupOpsP.catch((err) => this.logger.sendErrorEvent({ eventName: "CatchupOpsLoadFailure" }, err));
|
|
@@ -89,7 +85,7 @@ class SnapshotLoader {
|
|
|
89
85
|
const blobs = await blobsP;
|
|
90
86
|
if (blobs.length === headerChunk.headerMetadata.orderedChunkMetadata.length + 1) {
|
|
91
87
|
headerChunk.headerMetadata.orderedChunkMetadata.forEach((md) => blobs.splice(blobs.indexOf(md.id), 1));
|
|
92
|
-
|
|
88
|
+
assert(blobs.length === 1, 0x060 /* There should be only one blob with catch up ops */);
|
|
93
89
|
// TODO: The 'Snapshot.catchupOps' tree entry is purely for backwards compatibility.
|
|
94
90
|
// (See https://github.com/microsoft/FluidFramework/issues/84)
|
|
95
91
|
return this.loadCatchupOps(services.readBlob(blobs[0]));
|
|
@@ -100,7 +96,7 @@ class SnapshotLoader {
|
|
|
100
96
|
return [];
|
|
101
97
|
}
|
|
102
98
|
loadHeader(header) {
|
|
103
|
-
const chunk =
|
|
99
|
+
const chunk = SnapshotV1.processChunk(SnapshotLegacy.header, header, this.logger, this.mergeTree.options, this.serializer);
|
|
104
100
|
const segs = chunk.segments.map(this.specToSegment);
|
|
105
101
|
this.extractAttribution(segs, chunk);
|
|
106
102
|
this.mergeTree.reloadFromSegments(segs);
|
|
@@ -109,7 +105,7 @@ class SnapshotLoader {
|
|
|
109
105
|
}
|
|
110
106
|
// If we load a detached container from snapshot, then we don't supply a default clientId
|
|
111
107
|
// because we don't want to start collaboration.
|
|
112
|
-
if (this.runtime.attachState !==
|
|
108
|
+
if (this.runtime.attachState !== AttachState.Detached) {
|
|
113
109
|
// specify a default client id, "snapshot" here as we
|
|
114
110
|
// should enter collaboration/op sending mode if we load
|
|
115
111
|
// a snapshot in any case (summary or attach message)
|
|
@@ -126,8 +122,8 @@ class SnapshotLoader {
|
|
|
126
122
|
}
|
|
127
123
|
async loadBody(chunk1, services) {
|
|
128
124
|
const headerMetadata = chunk1.headerMetadata;
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
assert(chunk1.length <= headerMetadata.totalLength, 0x061 /* "Mismatch in totalLength" */);
|
|
126
|
+
assert(chunk1.segmentCount <= headerMetadata.totalSegmentCount, 0x062 /* "Mismatch in totalSegmentCount" */);
|
|
131
127
|
if (chunk1.segmentCount === headerMetadata.totalSegmentCount) {
|
|
132
128
|
return;
|
|
133
129
|
}
|
|
@@ -135,7 +131,7 @@ class SnapshotLoader {
|
|
|
135
131
|
const segs = [];
|
|
136
132
|
let lengthSofar = chunk1.length;
|
|
137
133
|
for (let chunkIndex = 1; chunkIndex < headerMetadata.orderedChunkMetadata.length; chunkIndex++) {
|
|
138
|
-
const chunk = await
|
|
134
|
+
const chunk = await SnapshotV1.loadChunk(services, headerMetadata.orderedChunkMetadata[chunkIndex].id, this.logger, this.mergeTree.options, this.serializer);
|
|
139
135
|
lengthSofar += chunk.length;
|
|
140
136
|
// Deserialize each chunk segment and append it to the end of the MergeTree.
|
|
141
137
|
const newSegs = chunk.segments.map(this.specToSegment);
|
|
@@ -143,21 +139,21 @@ class SnapshotLoader {
|
|
|
143
139
|
chunksWithAttribution += chunk.attribution !== undefined ? 1 : 0;
|
|
144
140
|
segs.push(...newSegs);
|
|
145
141
|
}
|
|
146
|
-
|
|
142
|
+
assert(chunksWithAttribution === 0 ||
|
|
147
143
|
chunksWithAttribution === headerMetadata.orderedChunkMetadata.length, 0x4c0 /* all or no chunks should have attribution information */);
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
assert(lengthSofar === headerMetadata.totalLength, 0x063 /* "Mismatch in totalLength" */);
|
|
145
|
+
assert(chunk1.segmentCount + segs.length === headerMetadata.totalSegmentCount, 0x064 /* "Mismatch in totalSegmentCount" */);
|
|
150
146
|
// Helper to insert segments at the end of the MergeTree.
|
|
151
147
|
const mergeTree = this.mergeTree;
|
|
152
148
|
const append = (segments, cli, seq) => {
|
|
153
149
|
mergeTree.insertSegments(mergeTree.root.cachedLength ?? 0, segments,
|
|
154
|
-
/* refSeq: */
|
|
150
|
+
/* refSeq: */ UniversalSequenceNumber, cli, seq, undefined);
|
|
155
151
|
};
|
|
156
152
|
// Helpers to batch-insert segments that are below the min seq
|
|
157
153
|
const batch = [];
|
|
158
154
|
const flushBatch = () => {
|
|
159
155
|
if (batch.length > 0) {
|
|
160
|
-
append(batch,
|
|
156
|
+
append(batch, NonCollabClient, UniversalSequenceNumber);
|
|
161
157
|
}
|
|
162
158
|
};
|
|
163
159
|
for (const seg of segs) {
|
|
@@ -165,7 +161,7 @@ class SnapshotLoader {
|
|
|
165
161
|
const seq = seg.seq;
|
|
166
162
|
// If the segment can be batch inserted, add it to the 'batch' array. Otherwise, flush
|
|
167
163
|
// any batched segments and then insert the current segment individually.
|
|
168
|
-
if (cli ===
|
|
164
|
+
if (cli === NonCollabClient && seq === UniversalSequenceNumber) {
|
|
169
165
|
batch.push(seg);
|
|
170
166
|
}
|
|
171
167
|
else {
|
|
@@ -182,7 +178,7 @@ class SnapshotLoader {
|
|
|
182
178
|
if (chunk.attribution) {
|
|
183
179
|
const { attributionPolicy } = this.mergeTree;
|
|
184
180
|
if (attributionPolicy === undefined) {
|
|
185
|
-
throw new
|
|
181
|
+
throw new UsageError("Attribution policy must be provided when loading a document with attribution information.");
|
|
186
182
|
}
|
|
187
183
|
const { isAttached, attach, serializer } = attributionPolicy;
|
|
188
184
|
if (!isAttached) {
|
|
@@ -204,8 +200,7 @@ class SnapshotLoader {
|
|
|
204
200
|
* SharedObject.processCore.
|
|
205
201
|
*/
|
|
206
202
|
async loadCatchupOps(rawMessages) {
|
|
207
|
-
return JSON.parse(
|
|
203
|
+
return JSON.parse(bufferToString(await rawMessages, "utf8"));
|
|
208
204
|
}
|
|
209
205
|
}
|
|
210
|
-
|
|
211
|
-
//# sourceMappingURL=snapshotLoader.js.map
|
|
206
|
+
//# sourceMappingURL=snapshotLoader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sn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AC,cAAc,CAAC,MAAM,WAAW,EAAE,MAAM,CAAC,CAAgC,CAAC;IAC7F,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport {\n\tcreateChildLogger,\n\tITelemetryLoggerExt,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client\";\nimport { NonCollabClient, UniversalSequenceNumber } from \"./constants\";\nimport { ISegment } from \"./mergeTreeNodes\";\nimport { IJSONSegment } from \"./ops\";\nimport { IJSONSegmentWithMergeInfo, hasMergeInfo, MergeTreeChunkV1 } from \"./snapshotChunks\";\nimport { SnapshotV1 } from \"./snapshotV1\";\nimport { SnapshotLegacy } from \"./snapshotlegacy\";\nimport { MergeTree } from \"./mergeTree\";\n\nexport class SnapshotLoader {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tconstructor(\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly client: Client,\n\t\tprivate readonly mergeTree: MergeTree,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly serializer: IFluidSerializer,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"SnapshotLoader\" });\n\t}\n\n\tpublic async initialize(\n\t\tservices: IChannelStorageService,\n\t): Promise<{ catchupOpsP: Promise<ISequencedDocumentMessage[]> }> {\n\t\tconst headerLoadedP = services.readBlob(SnapshotLegacy.header).then((header) => {\n\t\t\tassert(!!header, 0x05f /* \"Missing blob header on legacy snapshot!\" */);\n\t\t\treturn this.loadHeader(bufferToString(header, \"utf8\"));\n\t\t});\n\n\t\tconst catchupOpsP = this.loadBodyAndCatchupOps(headerLoadedP, services);\n\n\t\tcatchupOpsP.catch((err) =>\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"CatchupOpsLoadFailure\" }, err),\n\t\t);\n\n\t\tawait headerLoadedP;\n\n\t\treturn { catchupOpsP };\n\t}\n\n\tprivate async loadBodyAndCatchupOps(\n\t\theaderChunkP: Promise<MergeTreeChunkV1>,\n\t\tservices: IChannelStorageService,\n\t): Promise<ISequencedDocumentMessage[]> {\n\t\tconst blobsP = services.list(\"\");\n\t\tconst headerChunk = await headerChunkP;\n\n\t\t// TODO we shouldn't need to wait on the body being complete to finish initialization.\n\t\t// To fully support this we need to be able to process inbound ops for pending segments.\n\t\tawait this.loadBody(headerChunk, services);\n\n\t\tconst blobs = await blobsP;\n\t\tif (blobs.length === headerChunk.headerMetadata!.orderedChunkMetadata.length + 1) {\n\t\t\theaderChunk.headerMetadata!.orderedChunkMetadata.forEach((md) =>\n\t\t\t\tblobs.splice(blobs.indexOf(md.id), 1),\n\t\t\t);\n\t\t\tassert(blobs.length === 1, 0x060 /* There should be only one blob with catch up ops */);\n\n\t\t\t// TODO: The 'Snapshot.catchupOps' tree entry is purely for backwards compatibility.\n\t\t\t// (See https://github.com/microsoft/FluidFramework/issues/84)\n\n\t\t\treturn this.loadCatchupOps(services.readBlob(blobs[0]));\n\t\t} else if (blobs.length !== headerChunk.headerMetadata!.orderedChunkMetadata.length) {\n\t\t\tthrow new Error(\"Unexpected blobs in snapshot\");\n\t\t}\n\t\treturn [];\n\t}\n\n\tprivate readonly specToSegment = (spec: IJSONSegment | IJSONSegmentWithMergeInfo) => {\n\t\tlet seg: ISegment;\n\n\t\tif (hasMergeInfo(spec)) {\n\t\t\tseg = this.client.specToSegment(spec.json);\n\n\t\t\t// `specToSegment()` initializes `seg` with the LocalClientId. Overwrite this with\n\t\t\t// the `spec` client (if specified). Otherwise overwrite with `NonCollabClient`.\n\t\t\tseg.clientId =\n\t\t\t\tspec.client !== undefined\n\t\t\t\t\t? this.client.getOrAddShortClientId(spec.client)\n\t\t\t\t\t: NonCollabClient;\n\n\t\t\tseg.seq = spec.seq ?? UniversalSequenceNumber;\n\n\t\t\tif (spec.removedSeq !== undefined) {\n\t\t\t\tseg.removedSeq = spec.removedSeq;\n\t\t\t}\n\t\t\tif (spec.movedSeq !== undefined) {\n\t\t\t\tseg.movedSeq = spec.movedSeq;\n\t\t\t}\n\t\t\tif (spec.movedSeqs !== undefined) {\n\t\t\t\tseg.movedSeqs = spec.movedSeqs;\n\t\t\t}\n\t\t\t// this format had a bug where it didn't store all the overlap clients\n\t\t\t// this is for back compat, so we change the singular id to an array\n\t\t\t// this will only cause problems if there is an overlapping delete\n\t\t\t// spanning the snapshot, which should be rare\n\t\t\tconst specAsBuggyFormat: IJSONSegmentWithMergeInfo & { removedClient?: string } = spec;\n\t\t\tif (specAsBuggyFormat.removedClient !== undefined) {\n\t\t\t\tseg.removedClientIds = [\n\t\t\t\t\tthis.client.getOrAddShortClientId(specAsBuggyFormat.removedClient),\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (spec.removedClientIds !== undefined) {\n\t\t\t\tseg.removedClientIds = spec.removedClientIds?.map((sid) =>\n\t\t\t\t\tthis.client.getOrAddShortClientId(sid),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (spec.movedClientIds !== undefined) {\n\t\t\t\tseg.movedClientIds = spec.movedClientIds?.map((sid) =>\n\t\t\t\t\tthis.client.getOrAddShortClientId(sid),\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tseg = this.client.specToSegment(spec);\n\t\t\tseg.seq = UniversalSequenceNumber;\n\n\t\t\t// `specToSegment()` initializes `seg` with the LocalClientId. We must overwrite this with\n\t\t\t// `NonCollabClient`.\n\t\t\tseg.clientId = NonCollabClient;\n\t\t}\n\n\t\treturn seg;\n\t};\n\n\tprivate loadHeader(header: string): MergeTreeChunkV1 {\n\t\tconst chunk = SnapshotV1.processChunk(\n\t\t\tSnapshotLegacy.header,\n\t\t\theader,\n\t\t\tthis.logger,\n\t\t\tthis.mergeTree.options,\n\t\t\tthis.serializer,\n\t\t);\n\t\tconst segs = chunk.segments.map(this.specToSegment);\n\t\tthis.extractAttribution(segs, chunk);\n\n\t\tthis.mergeTree.reloadFromSegments(segs);\n\n\t\tif (chunk.headerMetadata === undefined) {\n\t\t\tthrow new Error(\"header metadata not available\");\n\t\t}\n\t\t// If we load a detached container from snapshot, then we don't supply a default clientId\n\t\t// because we don't want to start collaboration.\n\t\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\t// specify a default client id, \"snapshot\" here as we\n\t\t\t// should enter collaboration/op sending mode if we load\n\t\t\t// a snapshot in any case (summary or attach message)\n\t\t\t// once we get a client id this will be called with that\n\t\t\t// clientId in the connected event\n\t\t\tthis.client.startOrUpdateCollaboration(\n\t\t\t\tthis.runtime.clientId ?? \"snapshot\",\n\n\t\t\t\t// TODO: Make 'minSeq' non-optional once the new snapshot format becomes the default?\n\t\t\t\t// (See https://github.com/microsoft/FluidFramework/issues/84)\n\t\t\t\t/* minSeq: */ chunk.headerMetadata.minSequenceNumber ??\n\t\t\t\t\tchunk.headerMetadata.sequenceNumber,\n\t\t\t\t/* currentSeq: */ chunk.headerMetadata.sequenceNumber,\n\t\t\t);\n\t\t}\n\n\t\treturn chunk;\n\t}\n\n\tprivate async loadBody(\n\t\tchunk1: MergeTreeChunkV1,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\tconst headerMetadata = chunk1.headerMetadata!;\n\t\tassert(chunk1.length <= headerMetadata.totalLength, 0x061 /* \"Mismatch in totalLength\" */);\n\n\t\tassert(\n\t\t\tchunk1.segmentCount <= headerMetadata.totalSegmentCount,\n\t\t\t0x062 /* \"Mismatch in totalSegmentCount\" */,\n\t\t);\n\n\t\tif (chunk1.segmentCount === headerMetadata.totalSegmentCount) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet chunksWithAttribution = chunk1.attribution !== undefined ? 1 : 0;\n\t\tconst segs: ISegment[] = [];\n\t\tlet lengthSofar = chunk1.length;\n\t\tfor (\n\t\t\tlet chunkIndex = 1;\n\t\t\tchunkIndex < headerMetadata.orderedChunkMetadata.length;\n\t\t\tchunkIndex++\n\t\t) {\n\t\t\tconst chunk = await SnapshotV1.loadChunk(\n\t\t\t\tservices,\n\t\t\t\theaderMetadata.orderedChunkMetadata[chunkIndex].id,\n\t\t\t\tthis.logger,\n\t\t\t\tthis.mergeTree.options,\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tlengthSofar += chunk.length;\n\t\t\t// Deserialize each chunk segment and append it to the end of the MergeTree.\n\t\t\tconst newSegs = chunk.segments.map(this.specToSegment);\n\t\t\tthis.extractAttribution(newSegs, chunk);\n\t\t\tchunksWithAttribution += chunk.attribution !== undefined ? 1 : 0;\n\t\t\tsegs.push(...newSegs);\n\t\t}\n\n\t\tassert(\n\t\t\tchunksWithAttribution === 0 ||\n\t\t\t\tchunksWithAttribution === headerMetadata.orderedChunkMetadata.length,\n\t\t\t0x4c0 /* all or no chunks should have attribution information */,\n\t\t);\n\n\t\tassert(lengthSofar === headerMetadata.totalLength, 0x063 /* \"Mismatch in totalLength\" */);\n\n\t\tassert(\n\t\t\tchunk1.segmentCount + segs.length === headerMetadata.totalSegmentCount,\n\t\t\t0x064 /* \"Mismatch in totalSegmentCount\" */,\n\t\t);\n\n\t\t// Helper to insert segments at the end of the MergeTree.\n\t\tconst mergeTree = this.mergeTree;\n\t\tconst append = (segments: ISegment[], cli: number, seq: number) => {\n\t\t\tmergeTree.insertSegments(\n\t\t\t\tmergeTree.root.cachedLength ?? 0,\n\t\t\t\tsegments,\n\t\t\t\t/* refSeq: */ UniversalSequenceNumber,\n\t\t\t\tcli,\n\t\t\t\tseq,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t};\n\n\t\t// Helpers to batch-insert segments that are below the min seq\n\t\tconst batch: ISegment[] = [];\n\t\tconst flushBatch = () => {\n\t\t\tif (batch.length > 0) {\n\t\t\t\tappend(batch, NonCollabClient, UniversalSequenceNumber);\n\t\t\t}\n\t\t};\n\n\t\tfor (const seg of segs) {\n\t\t\tconst cli = seg.clientId;\n\t\t\tconst seq = seg.seq;\n\n\t\t\t// If the segment can be batch inserted, add it to the 'batch' array. Otherwise, flush\n\t\t\t// any batched segments and then insert the current segment individually.\n\t\t\tif (cli === NonCollabClient && seq === UniversalSequenceNumber) {\n\t\t\t\tbatch.push(seg);\n\t\t\t} else {\n\t\t\t\tflushBatch();\n\t\t\t\tappend([seg], cli, seq!);\n\t\t\t}\n\t\t}\n\n\t\tflushBatch();\n\t}\n\n\tprivate extractAttribution(segments: ISegment[], chunk: MergeTreeChunkV1): void {\n\t\tthis.mergeTree.options ??= {};\n\t\tthis.mergeTree.options.attribution ??= {};\n\t\tif (chunk.attribution) {\n\t\t\tconst { attributionPolicy } = this.mergeTree;\n\t\t\tif (attributionPolicy === undefined) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"Attribution policy must be provided when loading a document with attribution information.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { isAttached, attach, serializer } = attributionPolicy;\n\t\t\tif (!isAttached) {\n\t\t\t\tattach(this.client);\n\t\t\t}\n\t\t\tserializer.populateAttributionCollections(segments, chunk.attribution);\n\t\t} else {\n\t\t\tconst { attributionPolicy } = this.mergeTree;\n\t\t\tif (attributionPolicy?.isAttached) {\n\t\t\t\tattributionPolicy?.detach();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * If loading from a snapshot, get the catchup messages.\n\t * @param rawMessages - The messages in original encoding\n\t * @returns The decoded messages, but handles aren't parsed. Matches the format that will be passed in\n\t * SharedObject.processCore.\n\t */\n\tprivate async loadCatchupOps(\n\t\trawMessages: Promise<ArrayBufferLike>,\n\t): Promise<ISequencedDocumentMessage[]> {\n\t\treturn JSON.parse(bufferToString(await rawMessages, \"utf8\")) as ISequencedDocumentMessage[];\n\t}\n}\n"]}
|
|
@@ -7,9 +7,9 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
8
8
|
import { IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
9
9
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
10
|
-
import { PropertySet } from "./properties";
|
|
11
|
-
import { JsonSegmentSpecs, MergeTreeChunkV1 } from "./snapshotChunks";
|
|
12
|
-
import { MergeTree } from "./mergeTree";
|
|
10
|
+
import { PropertySet } from "./properties.mjs";
|
|
11
|
+
import { JsonSegmentSpecs, MergeTreeChunkV1 } from "./snapshotChunks.mjs";
|
|
12
|
+
import { MergeTree } from "./mergeTree.mjs";
|
|
13
13
|
export declare class SnapshotV1 {
|
|
14
14
|
mergeTree: MergeTree;
|
|
15
15
|
private readonly getLongClientId;
|
|
@@ -33,4 +33,4 @@ export declare class SnapshotV1 {
|
|
|
33
33
|
static loadChunk(storage: IChannelStorageService, path: string, logger: ITelemetryLoggerExt, options: PropertySet | undefined, serializer?: IFluidSerializer): Promise<MergeTreeChunkV1>;
|
|
34
34
|
static processChunk(path: string, chunk: string, logger: ITelemetryLoggerExt, options: PropertySet | undefined, serializer?: IFluidSerializer): MergeTreeChunkV1;
|
|
35
35
|
}
|
|
36
|
-
//# sourceMappingURL=snapshotV1.d.
|
|
36
|
+
//# sourceMappingURL=snapshotV1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotV1.d.mts","sourceRoot":"","sources":["../src/snapshotV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,mBAAmB,EAAqB,MAAM,iCAAiC;OACjF,EAAE,YAAY,EAAE,MAAM,iCAAiC;OACvD,EAAE,gBAAgB,EAAE,MAAM,oCAAoC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E,WAAW,GAAG,SAAS,EAChC,UAAU,CAAC,EAAE,gBAAgB,GAC3B,gBAAgB;CAInB"}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const mergeTreeNodeWalk_1 = require("./mergeTreeNodeWalk");
|
|
17
|
-
class SnapshotV1 {
|
|
5
|
+
import { createChildLogger } from "@fluidframework/telemetry-utils";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
|
+
import { bufferToString } from "@fluid-internal/client-utils";
|
|
8
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
9
|
+
import { UnassignedSequenceNumber } from "./constants.mjs";
|
|
10
|
+
import { matchProperties } from "./properties.mjs";
|
|
11
|
+
import { toLatestVersion, serializeAsMaxSupportedVersion, } from "./snapshotChunks.mjs";
|
|
12
|
+
import { SnapshotLegacy } from "./snapshotlegacy.mjs";
|
|
13
|
+
import { walkAllChildSegments } from "./mergeTreeNodeWalk.mjs";
|
|
14
|
+
export class SnapshotV1 {
|
|
18
15
|
constructor(mergeTree, logger, getLongClientId, filename, onCompletion) {
|
|
19
16
|
this.mergeTree = mergeTree;
|
|
20
17
|
this.getLongClientId = getLongClientId;
|
|
21
18
|
this.filename = filename;
|
|
22
19
|
this.onCompletion = onCompletion;
|
|
23
|
-
this.logger =
|
|
20
|
+
this.logger = createChildLogger({ logger, namespace: "Snapshot" });
|
|
24
21
|
this.chunkSize = mergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotV1.chunkSize;
|
|
25
22
|
const { currentSeq, minSeq } = mergeTree.collabWindow;
|
|
26
23
|
this.header = {
|
|
@@ -54,7 +51,7 @@ class SnapshotV1 {
|
|
|
54
51
|
segmentCount++;
|
|
55
52
|
}
|
|
56
53
|
const attributionSerializer = this.mergeTree.attributionPolicy?.serializer;
|
|
57
|
-
|
|
54
|
+
assert(!hasAttribution || attributionSerializer !== undefined, 0x55a /* attribution serializer must be provided when there are segments with attribution. */);
|
|
58
55
|
return {
|
|
59
56
|
version: "1",
|
|
60
57
|
segmentCount,
|
|
@@ -85,18 +82,18 @@ class SnapshotV1 {
|
|
|
85
82
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
86
83
|
const headerChunk = chunks.shift();
|
|
87
84
|
headerChunk.headerMetadata = this.header;
|
|
88
|
-
headerChunk.headerMetadata.orderedChunkMetadata = [{ id:
|
|
85
|
+
headerChunk.headerMetadata.orderedChunkMetadata = [{ id: SnapshotLegacy.header }];
|
|
89
86
|
const blobs = [];
|
|
90
87
|
chunks.forEach((chunk, index) => {
|
|
91
|
-
const id = `${
|
|
88
|
+
const id = `${SnapshotLegacy.body}_${index}`;
|
|
92
89
|
this.header.orderedChunkMetadata.push({ id });
|
|
93
90
|
blobs.push([
|
|
94
91
|
id,
|
|
95
|
-
|
|
92
|
+
serializeAsMaxSupportedVersion(id, chunk, this.logger, this.mergeTree.options, serializer, bind),
|
|
96
93
|
]);
|
|
97
94
|
});
|
|
98
|
-
const builder = new
|
|
99
|
-
builder.addBlob(
|
|
95
|
+
const builder = new SummaryTreeBuilder();
|
|
96
|
+
builder.addBlob(SnapshotLegacy.header, serializeAsMaxSupportedVersion(SnapshotLegacy.header, headerChunk, this.logger, this.mergeTree.options, serializer, bind));
|
|
100
97
|
blobs.forEach((value) => {
|
|
101
98
|
builder.addBlob(value[0], value[1]);
|
|
102
99
|
});
|
|
@@ -132,7 +129,7 @@ class SnapshotV1 {
|
|
|
132
129
|
// there is a pending insert op that will deliver the segment on reconnection.
|
|
133
130
|
// b) The segment was removed at or below the MSN. Pending ops can no longer reference this
|
|
134
131
|
// segment, and therefore we can discard it.
|
|
135
|
-
if (segment.seq ===
|
|
132
|
+
if (segment.seq === UnassignedSequenceNumber ||
|
|
136
133
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
137
134
|
segment.removedSeq <= minSeq ||
|
|
138
135
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -146,8 +143,8 @@ class SnapshotV1 {
|
|
|
146
143
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
144
|
segment.seq <= minSeq && // Segment is below the MSN, and...
|
|
148
145
|
(segment.removedSeq === undefined || // .. Segment has not been removed, or...
|
|
149
|
-
segment.removedSeq ===
|
|
150
|
-
(segment.movedSeq === undefined || segment.movedSeq ===
|
|
146
|
+
segment.removedSeq === UnassignedSequenceNumber) && // .. Removal op to be delivered on reconnect
|
|
147
|
+
(segment.movedSeq === undefined || segment.movedSeq === UnassignedSequenceNumber)) {
|
|
151
148
|
// This segment is below the MSN, which means that future ops will not reference it. Attempt to
|
|
152
149
|
// coalesce the new segment with the previous (if any).
|
|
153
150
|
if (!prev) {
|
|
@@ -155,7 +152,7 @@ class SnapshotV1 {
|
|
|
155
152
|
prev = segment;
|
|
156
153
|
}
|
|
157
154
|
else if (prev.canAppend(segment) &&
|
|
158
|
-
|
|
155
|
+
matchProperties(prev.properties, segment.properties)) {
|
|
159
156
|
// We have a compatible pair. Replace `prev` with the coalesced segment. Clone to avoid
|
|
160
157
|
// modifying the segment instances currently in the MergeTree.
|
|
161
158
|
prev = prev.clone();
|
|
@@ -190,7 +187,7 @@ class SnapshotV1 {
|
|
|
190
187
|
// We have already dispensed with removed segments below the MSN and removed segments with unassigned
|
|
191
188
|
// sequence numbers. Any remaining removal info should be preserved.
|
|
192
189
|
if (segment.removedSeq !== undefined) {
|
|
193
|
-
|
|
190
|
+
assert(segment.removedSeq !== UnassignedSequenceNumber &&
|
|
194
191
|
segment.removedSeq > minSeq, 0x065 /* "On removal info preservation, segment has invalid removed sequence number!" */);
|
|
195
192
|
raw.removedSeq = segment.removedSeq;
|
|
196
193
|
// back compat for when we split overlap and removed client
|
|
@@ -201,13 +198,13 @@ class SnapshotV1 {
|
|
|
201
198
|
raw.removedClientIds = segment.removedClientIds?.map((id) => this.getLongClientId(id));
|
|
202
199
|
}
|
|
203
200
|
if (segment.movedSeq !== undefined) {
|
|
204
|
-
|
|
201
|
+
assert(segment.movedSeq !== UnassignedSequenceNumber && segment.movedSeq > minSeq, 0x873 /* On move info preservation, segment has invalid moved sequence number! */);
|
|
205
202
|
raw.movedSeq = segment.movedSeq;
|
|
206
203
|
raw.movedSeqs = segment.movedSeqs;
|
|
207
204
|
raw.movedClientIds = segment.movedClientIds?.map((id) => this.getLongClientId(id));
|
|
208
205
|
}
|
|
209
206
|
// Sanity check that we are preserving either the seq > minSeq or a (re)moved segment's info.
|
|
210
|
-
|
|
207
|
+
assert((raw.seq !== undefined && raw.client !== undefined) ||
|
|
211
208
|
(raw.removedSeq !== undefined && raw.removedClientIds !== undefined) ||
|
|
212
209
|
(raw.movedSeq !== undefined &&
|
|
213
210
|
raw.movedClientIds !== undefined &&
|
|
@@ -219,22 +216,21 @@ class SnapshotV1 {
|
|
|
219
216
|
}
|
|
220
217
|
return true;
|
|
221
218
|
};
|
|
222
|
-
|
|
219
|
+
walkAllChildSegments(mergeTree.root, extractSegment);
|
|
223
220
|
// If the last segment in the walk was coalescable, push it now.
|
|
224
221
|
pushSeg(prev);
|
|
225
222
|
return this.segments;
|
|
226
223
|
}
|
|
227
224
|
static async loadChunk(storage, path, logger, options, serializer) {
|
|
228
225
|
const blob = await storage.readBlob(path);
|
|
229
|
-
const chunkAsString =
|
|
226
|
+
const chunkAsString = bufferToString(blob, "utf8");
|
|
230
227
|
return SnapshotV1.processChunk(path, chunkAsString, logger, options, serializer);
|
|
231
228
|
}
|
|
232
229
|
static processChunk(path, chunk, logger, options, serializer) {
|
|
233
230
|
const chunkObj = serializer ? serializer.parse(chunk) : JSON.parse(chunk);
|
|
234
|
-
return
|
|
231
|
+
return toLatestVersion(path, chunkObj, logger, options);
|
|
235
232
|
}
|
|
236
233
|
}
|
|
237
|
-
exports.SnapshotV1 = SnapshotV1;
|
|
238
234
|
// Split snapshot into two entries - headers (small) and body (overflow) for faster loading initial content
|
|
239
235
|
// Please note that this number has no direct relationship to anything other than size of raw text (characters).
|
|
240
236
|
// As we produce json for the blob (and then send over the wire compressed), this number
|
|
@@ -242,4 +238,4 @@ exports.SnapshotV1 = SnapshotV1;
|
|
|
242
238
|
// For test with small number of chunks it would be closer to blob size,
|
|
243
239
|
// for very chunky text, blob size can easily be 4x-8x of that number.
|
|
244
240
|
SnapshotV1.chunkSize = 10000;
|
|
245
|
-
//# sourceMappingURL=snapshotV1.
|
|
241
|
+
//# sourceMappingURL=snapshotV1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotV1.mjs","sourceRoot":"","sources":["../src/snapshotV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAuB,iBAAiB,EAAE,MAAM,iCAAiC;OAGjF,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAC5C,EAAE,cAAc,EAAE,MAAM,8BAA8B;OAGtD,EAAE,kBAAkB,EAAE,MAAM,+BAA+B;OAC3D,EAAE,wBAAwB,EAAE;OAE5B,EAAE,eAAe,EAAe;OAChC,EAKN,eAAe,EACf,8BAA8B,GAC9B;OACM,EAAE,cAAc,EAAE;OAElB,EAAE,oBAAoB,EAAE;AAG/B,MAAM,OAAO,UAAU;IAgBtB,YACQ,SAAoB,EAC3B,MAA2B,EACV,eAAuC,EACjD,QAAiB,EACjB,YAAyB;QAJzB,cAAS,GAAT,SAAS,CAAW;QAEV,oBAAe,GAAf,eAAe,CAAwB;QACjD,aAAQ,GAAR,QAAQ,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAa;QAEhC,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,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G,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;;AAzUD,2GAA2G;AAC3G,gHAAgH;AAChH,wFAAwF;AACxF,8FAA8F;AAC9F,wEAAwE;AACxE,sEAAsE;AAC/C,oBAAS,GAAW,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { AttributionKey, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { UnassignedSequenceNumber } from \"./constants\";\nimport { ISegment } from \"./mergeTreeNodes\";\nimport { matchProperties, PropertySet } from \"./properties\";\nimport {\n\tIJSONSegmentWithMergeInfo,\n\tJsonSegmentSpecs,\n\tMergeTreeHeaderMetadata,\n\tMergeTreeChunkV1,\n\ttoLatestVersion,\n\tserializeAsMaxSupportedVersion,\n} from \"./snapshotChunks\";\nimport { SnapshotLegacy } from \"./snapshotlegacy\";\nimport { MergeTree } from \"./mergeTree\";\nimport { walkAllChildSegments } from \"./mergeTreeNodeWalk\";\nimport { IAttributionCollection } from \"./attributionCollection\";\n\nexport class SnapshotV1 {\n\t// Split snapshot into two entries - headers (small) and body (overflow) for faster loading initial content\n\t// Please note that this number has no direct relationship to anything other than size of raw text (characters).\n\t// As we produce json for the blob (and then send over the wire compressed), this number\n\t// is really hard to correlate with any actual metric that matters (like bytes over the wire).\n\t// For test with small number of chunks it would be closer to blob size,\n\t// for very chunky text, blob size can easily be 4x-8x of that number.\n\tpublic static readonly chunkSize: number = 10000;\n\n\tprivate readonly header: MergeTreeHeaderMetadata;\n\tprivate readonly segments: JsonSegmentSpecs[];\n\tprivate readonly segmentLengths: number[];\n\tprivate readonly attributionCollections: IAttributionCollection<AttributionKey>[];\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly chunkSize: number;\n\n\tconstructor(\n\t\tpublic mergeTree: MergeTree,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly getLongClientId: (id: number) => string,\n\t\tpublic filename?: string,\n\t\tpublic onCompletion?: () => void,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"Snapshot\" });\n\t\tthis.chunkSize = mergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotV1.chunkSize;\n\n\t\tconst { currentSeq, minSeq } = mergeTree.collabWindow;\n\t\tthis.header = {\n\t\t\tminSequenceNumber: minSeq,\n\t\t\tsequenceNumber: currentSeq,\n\t\t\torderedChunkMetadata: [],\n\t\t\ttotalLength: 0,\n\t\t\ttotalSegmentCount: 0,\n\t\t};\n\n\t\tthis.segments = [];\n\t\tthis.segmentLengths = [];\n\t\tthis.attributionCollections = [];\n\t}\n\n\tprivate getSeqLengthSegs(\n\t\tallSegments: JsonSegmentSpecs[],\n\t\tallLengths: number[],\n\t\tattributionCollections: IAttributionCollection<AttributionKey>[],\n\t\tapproxSequenceLength: number,\n\t\tstartIndex = 0,\n\t): MergeTreeChunkV1 {\n\t\tconst segments: JsonSegmentSpecs[] = [];\n\t\tconst collections: {\n\t\t\tattribution: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}[] = [];\n\t\tlet length = 0;\n\t\tlet segmentCount = 0;\n\t\tlet hasAttribution = false;\n\t\twhile (length < approxSequenceLength && startIndex + segmentCount < allSegments.length) {\n\t\t\tconst pseg = allSegments[startIndex + segmentCount];\n\t\t\tsegments.push(pseg);\n\t\t\tlength += allLengths[startIndex + segmentCount];\n\t\t\tif (attributionCollections[startIndex + segmentCount]) {\n\t\t\t\thasAttribution = true;\n\t\t\t\tcollections.push({\n\t\t\t\t\tattribution: attributionCollections[startIndex + segmentCount],\n\t\t\t\t\tcachedLength: allLengths[startIndex + segmentCount],\n\t\t\t\t});\n\t\t\t}\n\t\t\tsegmentCount++;\n\t\t}\n\n\t\tconst attributionSerializer = this.mergeTree.attributionPolicy?.serializer;\n\t\tassert(\n\t\t\t!hasAttribution || attributionSerializer !== undefined,\n\t\t\t0x55a /* attribution serializer must be provided when there are segments with attribution. */,\n\t\t);\n\n\t\treturn {\n\t\t\tversion: \"1\",\n\t\t\tsegmentCount,\n\t\t\tlength,\n\t\t\tsegments,\n\t\t\tstartIndex,\n\t\t\theaderMetadata: undefined,\n\t\t\tattribution: hasAttribution\n\t\t\t\t? attributionSerializer?.serializeAttributionCollections(collections)\n\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Emits the snapshot to an ISummarizeResult. If provided the optional IFluidSerializer will be used when\n\t * serializing the summary data rather than JSON.stringify.\n\t */\n\temit(serializer: IFluidSerializer, bind: IFluidHandle): ISummaryTreeWithStats {\n\t\tconst chunks: MergeTreeChunkV1[] = [];\n\t\tthis.header.totalSegmentCount = 0;\n\t\tthis.header.totalLength = 0;\n\t\tdo {\n\t\t\tconst chunk = this.getSeqLengthSegs(\n\t\t\t\tthis.segments,\n\t\t\t\tthis.segmentLengths,\n\t\t\t\tthis.attributionCollections,\n\t\t\t\tthis.chunkSize,\n\t\t\t\tthis.header.totalSegmentCount,\n\t\t\t);\n\t\t\tchunks.push(chunk);\n\t\t\tthis.header.totalSegmentCount += chunk.segmentCount;\n\t\t\tthis.header.totalLength += chunk.length;\n\t\t} while (this.header.totalSegmentCount < this.segments.length);\n\n\t\t// The do while loop should have added at least one chunk\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst headerChunk = chunks.shift()!;\n\t\theaderChunk.headerMetadata = this.header;\n\t\theaderChunk.headerMetadata.orderedChunkMetadata = [{ id: SnapshotLegacy.header }];\n\t\tconst blobs: [key: string, content: string][] = [];\n\t\tchunks.forEach((chunk, index) => {\n\t\t\tconst id = `${SnapshotLegacy.body}_${index}`;\n\t\t\tthis.header.orderedChunkMetadata.push({ id });\n\t\t\tblobs.push([\n\t\t\t\tid,\n\t\t\t\tserializeAsMaxSupportedVersion(\n\t\t\t\t\tid,\n\t\t\t\t\tchunk,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tthis.mergeTree.options,\n\t\t\t\t\tserializer,\n\t\t\t\t\tbind,\n\t\t\t\t),\n\t\t\t]);\n\t\t});\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(\n\t\t\tSnapshotLegacy.header,\n\t\t\tserializeAsMaxSupportedVersion(\n\t\t\t\tSnapshotLegacy.header,\n\t\t\t\theaderChunk,\n\t\t\t\tthis.logger,\n\t\t\t\tthis.mergeTree.options,\n\t\t\t\tserializer,\n\t\t\t\tbind,\n\t\t\t),\n\t\t);\n\t\tblobs.forEach((value) => {\n\t\t\tbuilder.addBlob(value[0], value[1]);\n\t\t});\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\textractSync() {\n\t\tconst mergeTree = this.mergeTree;\n\t\tconst minSeq = this.header.minSequenceNumber;\n\n\t\t// Helper to add the given `MergeTreeChunkV0SegmentSpec` to the snapshot.\n\t\tconst pushSegRaw = (\n\t\t\tjson: JsonSegmentSpecs,\n\t\t\tlength: number,\n\t\t\tattribution: IAttributionCollection<AttributionKey> | undefined,\n\t\t) => {\n\t\t\tthis.segments.push(json);\n\t\t\tthis.segmentLengths.push(length);\n\t\t\tif (attribution) {\n\t\t\t\tthis.attributionCollections.push(attribution);\n\t\t\t}\n\t\t};\n\n\t\t// Helper to serialize the given `segment` and add it to the snapshot (if a segment is provided).\n\t\tconst pushSeg = (segment?: ISegment) => {\n\t\t\tif (segment) {\n\t\t\t\tif (\n\t\t\t\t\tsegment.properties !== undefined &&\n\t\t\t\t\tObject.keys(segment.properties).length === 0\n\t\t\t\t) {\n\t\t\t\t\tsegment.properties = undefined;\n\t\t\t\t\tsegment.propertyManager = undefined;\n\t\t\t\t}\n\t\t\t\tpushSegRaw(segment.toJSONObject(), segment.cachedLength, segment.attribution);\n\t\t\t}\n\t\t};\n\n\t\tlet prev: ISegment | undefined;\n\t\tconst extractSegment = (segment: ISegment) => {\n\t\t\t// Elide segments that do not need to be included in the snapshot. A segment may be elided if\n\t\t\t// either condition is true:\n\t\t\t// a) The segment has not yet been ACKed. We do not need to snapshot unACKed segments because\n\t\t\t// there is a pending insert op that will deliver the segment on reconnection.\n\t\t\t// b) The segment was removed at or below the MSN. Pending ops can no longer reference this\n\t\t\t// segment, and therefore we can discard it.\n\t\t\tif (\n\t\t\t\tsegment.seq === UnassignedSequenceNumber ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tsegment.removedSeq! <= minSeq ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tsegment.movedSeq! <= minSeq\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Next determine if the snapshot needs to preserve information required for merging the segment\n\t\t\t// (seq, client, etc.) This information is only needed if the segment is above the MSN (and doesn't\n\t\t\t// have a pending remove.)\n\t\t\tif (\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tsegment.seq! <= minSeq && // Segment is below the MSN, and...\n\t\t\t\t(segment.removedSeq === undefined || // .. Segment has not been removed, or...\n\t\t\t\t\tsegment.removedSeq === UnassignedSequenceNumber) && // .. Removal op to be delivered on reconnect\n\t\t\t\t(segment.movedSeq === undefined || segment.movedSeq === UnassignedSequenceNumber)\n\t\t\t) {\n\t\t\t\t// This segment is below the MSN, which means that future ops will not reference it. Attempt to\n\t\t\t\t// coalesce the new segment with the previous (if any).\n\t\t\t\tif (!prev) {\n\t\t\t\t\t// We do not have a previous candidate for coalescing. Make the current segment the new candidate.\n\t\t\t\t\tprev = segment;\n\t\t\t\t} else if (\n\t\t\t\t\tprev.canAppend(segment) &&\n\t\t\t\t\tmatchProperties(prev.properties, segment.properties)\n\t\t\t\t) {\n\t\t\t\t\t// We have a compatible pair. Replace `prev` with the coalesced segment. Clone to avoid\n\t\t\t\t\t// modifying the segment instances currently in the MergeTree.\n\t\t\t\t\tprev = prev.clone();\n\t\t\t\t\tprev.append(segment.clone());\n\t\t\t\t} else {\n\t\t\t\t\t// The segment pair could not be coalesced. Record the `prev` segment in the snapshot\n\t\t\t\t\t// and make the current segment the new candidate for coalescing.\n\t\t\t\t\tpushSeg(prev);\n\t\t\t\t\tprev = segment;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// This segment needs to preserve its metadata as it may be referenced by future ops. It's ineligible\n\t\t\t\t// for coalescing, so emit the 'prev' segment now (if any).\n\t\t\t\tpushSeg(prev);\n\t\t\t\tprev = undefined;\n\n\t\t\t\tif (\n\t\t\t\t\tsegment.properties !== undefined &&\n\t\t\t\t\tObject.keys(segment.properties).length === 0\n\t\t\t\t) {\n\t\t\t\t\tsegment.properties = undefined;\n\t\t\t\t\tsegment.propertyManager = undefined;\n\t\t\t\t}\n\t\t\t\tconst raw: IJSONSegmentWithMergeInfo & { removedClient?: string } = {\n\t\t\t\t\tjson: segment.toJSONObject(),\n\t\t\t\t};\n\t\t\t\t// If the segment insertion is above the MSN, record the insertion merge info.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (segment.seq! > minSeq) {\n\t\t\t\t\traw.seq = segment.seq;\n\t\t\t\t\traw.client = this.getLongClientId(segment.clientId);\n\t\t\t\t}\n\t\t\t\t// We have already dispensed with removed segments below the MSN and removed segments with unassigned\n\t\t\t\t// sequence numbers. Any remaining removal info should be preserved.\n\t\t\t\tif (segment.removedSeq !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsegment.removedSeq !== UnassignedSequenceNumber &&\n\t\t\t\t\t\t\tsegment.removedSeq > minSeq,\n\t\t\t\t\t\t0x065 /* \"On removal info preservation, segment has invalid removed sequence number!\" */,\n\t\t\t\t\t);\n\t\t\t\t\traw.removedSeq = segment.removedSeq;\n\n\t\t\t\t\t// back compat for when we split overlap and removed client\n\t\t\t\t\traw.removedClient =\n\t\t\t\t\t\tsegment.removedClientIds !== undefined\n\t\t\t\t\t\t\t? this.getLongClientId(segment.removedClientIds[0])\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\traw.removedClientIds = segment.removedClientIds?.map((id) =>\n\t\t\t\t\t\tthis.getLongClientId(id),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (segment.movedSeq !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsegment.movedSeq !== UnassignedSequenceNumber && segment.movedSeq > minSeq,\n\t\t\t\t\t\t0x873 /* On move info preservation, segment has invalid moved sequence number! */,\n\t\t\t\t\t);\n\t\t\t\t\traw.movedSeq = segment.movedSeq;\n\t\t\t\t\traw.movedSeqs = segment.movedSeqs;\n\t\t\t\t\traw.movedClientIds = segment.movedClientIds?.map((id) =>\n\t\t\t\t\t\tthis.getLongClientId(id),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Sanity check that we are preserving either the seq > minSeq or a (re)moved segment's info.\n\t\t\t\tassert(\n\t\t\t\t\t(raw.seq !== undefined && raw.client !== undefined) ||\n\t\t\t\t\t\t(raw.removedSeq !== undefined && raw.removedClientIds !== undefined) ||\n\t\t\t\t\t\t(raw.movedSeq !== undefined &&\n\t\t\t\t\t\t\traw.movedClientIds !== undefined &&\n\t\t\t\t\t\t\traw.movedClientIds.length > 0 &&\n\t\t\t\t\t\t\traw.movedSeqs !== undefined &&\n\t\t\t\t\t\t\traw.movedSeqs.length > 0),\n\t\t\t\t\t0x066 /* \"Corrupted preservation of segment metadata!\" */,\n\t\t\t\t);\n\n\t\t\t\t// Record the segment with it's required metadata.\n\t\t\t\tpushSegRaw(raw, segment.cachedLength, segment.attribution);\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\twalkAllChildSegments(mergeTree.root, extractSegment);\n\n\t\t// If the last segment in the walk was coalescable, push it now.\n\t\tpushSeg(prev);\n\n\t\treturn this.segments;\n\t}\n\n\tpublic static async loadChunk(\n\t\tstorage: IChannelStorageService,\n\t\tpath: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\toptions: PropertySet | undefined,\n\t\tserializer?: IFluidSerializer,\n\t): Promise<MergeTreeChunkV1> {\n\t\tconst blob = await storage.readBlob(path);\n\t\tconst chunkAsString = bufferToString(blob, \"utf8\");\n\t\treturn SnapshotV1.processChunk(path, chunkAsString, logger, options, serializer);\n\t}\n\n\tpublic static processChunk(\n\t\tpath: string,\n\t\tchunk: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\toptions: PropertySet | undefined,\n\t\tserializer?: IFluidSerializer,\n\t): MergeTreeChunkV1 {\n\t\tconst chunkObj = serializer ? serializer.parse(chunk) : JSON.parse(chunk);\n\t\treturn toLatestVersion(path, chunkObj, logger, options);\n\t}\n}\n"]}
|
|
@@ -7,8 +7,8 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
8
8
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
9
9
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { ISegment } from "./mergeTreeNodes";
|
|
11
|
-
import { MergeTree } from "./mergeTree";
|
|
10
|
+
import { ISegment } from "./mergeTreeNodes.mjs";
|
|
11
|
+
import { MergeTree } from "./mergeTree.mjs";
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
@@ -34,4 +34,4 @@ export declare class SnapshotLegacy {
|
|
|
34
34
|
emit(catchUpMsgs: ISequencedDocumentMessage[], serializer: IFluidSerializer, bind: IFluidHandle): ISummaryTreeWithStats;
|
|
35
35
|
extractSync(): ISegment[];
|
|
36
36
|
}
|
|
37
|
-
//# sourceMappingURL=snapshotlegacy.d.
|
|
37
|
+
//# sourceMappingURL=snapshotlegacy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotlegacy.d.mts","sourceRoot":"","sources":["../src/snapshotlegacy.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAII,EAAE,mBAAmB,EAAqB,MAAM,iCAAiC;OAEjF,EAAE,YAAY,EAAE,MAAM,iCAAiC;OACvD,EAAE,gBAAgB,EAAE,MAAM,oCAAoC;OAC9D,EAAE,qBAAqB,EAAE,MAAM,qCAAqC;OACpE,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OAGzE,EAAE,QAAQ,EAAE;OAOZ,EAAE,SAAS,EAAE;AAapB;;GAEG;AACH,qBAAa,cAAc;IAoBlB,SAAS,EAAE,SAAS;IAEpB,QAAQ,CAAC;IACT,YAAY,CAAC,SAAQ,IAAI;IAtBjC,gBAAuB,MAAM,YAAY;IACzC,gBAAuB,IAAI,UAAU;IACrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAQlD,gBAAuB,gBAAgB,EAAE,MAAM,CAAS;IAExD,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAG3B,SAAS,EAAE,SAAS,EAC3B,MAAM,EAAE,mBAAmB,EACpB,QAAQ,CAAC,oBAAQ,EACjB,YAAY,CAAC,SAAQ,IAAI,aAAA;IAOjC,OAAO,CAAC,gBAAgB;IAgDxB;;;OAGG;IACH,IAAI,CACH,WAAW,EAAE,yBAAyB,EAAE,EACxC,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,qBAAqB;IAgExB,WAAW;CA4EX"}
|