@fluidframework/merge-tree 2.0.0-rc.2.0.1 → 2.0.0-rc.3.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 +23 -0
- package/api-report/merge-tree.api.md +16 -4
- package/dist/MergeTreeTextHelper.d.ts.map +1 -1
- package/dist/MergeTreeTextHelper.js.map +1 -1
- package/dist/attributionCollection.d.ts +1 -1
- package/dist/attributionCollection.d.ts.map +1 -1
- package/dist/attributionCollection.js +6 -6
- package/dist/attributionCollection.js.map +1 -1
- package/dist/attributionPolicy.d.ts +2 -2
- package/dist/attributionPolicy.d.ts.map +1 -1
- package/dist/attributionPolicy.js +5 -5
- package/dist/attributionPolicy.js.map +1 -1
- package/dist/client.d.ts +8 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +37 -48
- package/dist/client.js.map +1 -1
- package/dist/collections/list.js +3 -3
- package/dist/collections/list.js.map +1 -1
- package/dist/endOfTreeSegment.d.ts +5 -5
- package/dist/endOfTreeSegment.d.ts.map +1 -1
- package/dist/endOfTreeSegment.js +2 -2
- package/dist/endOfTreeSegment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +76 -0
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js +7 -7
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts +8 -8
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +44 -57
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeDeltaCallback.d.ts +1 -1
- package/dist/mergeTreeDeltaCallback.d.ts.map +1 -1
- package/dist/mergeTreeDeltaCallback.js +4 -0
- package/dist/mergeTreeDeltaCallback.js.map +1 -1
- package/dist/mergeTreeNodeWalk.d.ts +3 -3
- package/dist/mergeTreeNodeWalk.d.ts.map +1 -1
- package/dist/mergeTreeNodeWalk.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +37 -55
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +40 -19
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/opBuilder.d.ts +1 -1
- package/dist/opBuilder.d.ts.map +1 -1
- package/dist/opBuilder.js.map +1 -1
- package/dist/ordinal.js +2 -2
- package/dist/ordinal.js.map +1 -1
- package/dist/partialLengths.d.ts +6 -6
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +13 -13
- package/dist/partialLengths.js.map +1 -1
- package/dist/public.d.ts +12 -0
- package/dist/revertibles.d.ts +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +15 -15
- package/dist/revertibles.js.map +1 -1
- package/dist/segmentPropertiesManager.d.ts.map +1 -1
- package/dist/segmentPropertiesManager.js +2 -2
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotChunks.d.ts +2 -2
- package/dist/snapshotChunks.d.ts.map +1 -1
- package/dist/snapshotChunks.js.map +1 -1
- package/dist/snapshotLoader.d.ts +2 -2
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js +11 -11
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/snapshotV1.d.ts +3 -3
- package/dist/snapshotV1.d.ts.map +1 -1
- package/dist/snapshotV1.js +10 -10
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.d.ts +4 -4
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +9 -10
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/test/Insertion.perf.spec.js.map +1 -1
- package/dist/test/PartialLengths.perf.spec.js +1 -1
- package/dist/test/PartialLengths.perf.spec.js.map +1 -1
- package/dist/test/Removal.perf.spec.js +1 -1
- package/dist/test/Removal.perf.spec.js.map +1 -1
- package/dist/test/Snapshot.perf.spec.js.map +1 -1
- package/dist/test/attributionCollection.perf.spec.js +2 -2
- package/dist/test/attributionCollection.perf.spec.js.map +1 -1
- package/dist/test/attributionCollection.spec.js.map +1 -1
- package/dist/test/attributionPolicy.spec.js.map +1 -1
- package/dist/test/beastTest.spec.d.ts.map +1 -1
- package/dist/test/beastTest.spec.js +7 -7
- package/dist/test/beastTest.spec.js.map +1 -1
- package/dist/test/client.annotateMarker.spec.js.map +1 -1
- package/dist/test/client.apis.spec.d.ts.map +1 -1
- package/dist/test/client.apis.spec.js.map +1 -1
- package/dist/test/client.applyMsg.spec.js +2 -2
- package/dist/test/client.applyMsg.spec.js.map +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.d.ts +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.d.ts.map +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/dist/test/client.attributionFarm.spec.d.ts.map +1 -1
- package/dist/test/client.attributionFarm.spec.js +1 -1
- package/dist/test/client.attributionFarm.spec.js.map +1 -1
- package/dist/test/client.conflictFarm.spec.d.ts.map +1 -1
- package/dist/test/client.conflictFarm.spec.js.map +1 -1
- package/dist/test/client.getPosition.spec.js +1 -1
- package/dist/test/client.getPosition.spec.js.map +1 -1
- package/dist/test/client.localReference.spec.js +6 -6
- package/dist/test/client.localReference.spec.js.map +1 -1
- package/dist/test/client.localReferenceFarm.spec.js +2 -2
- package/dist/test/client.localReferenceFarm.spec.js.map +1 -1
- package/dist/test/client.rebasePosition.spec.js.map +1 -1
- package/dist/test/client.reconnectFarm.spec.d.ts +1 -1
- package/dist/test/client.reconnectFarm.spec.d.ts.map +1 -1
- package/dist/test/client.reconnectFarm.spec.js +1 -1
- package/dist/test/client.reconnectFarm.spec.js.map +1 -1
- package/dist/test/client.replay.spec.js +4 -4
- package/dist/test/client.replay.spec.js.map +1 -1
- package/dist/test/client.rollback.spec.js +2 -2
- package/dist/test/client.rollback.spec.js.map +1 -1
- package/dist/test/client.rollbackFarm.spec.js.map +1 -1
- package/dist/test/client.searchForMarker.spec.js +1 -1
- package/dist/test/client.searchForMarker.spec.js.map +1 -1
- package/dist/test/client.walkSegments.spec.js.map +1 -1
- package/dist/test/collections.list.spec.js.map +1 -1
- package/dist/test/createInsertOnlyAttributionPolicy.spec.js.map +1 -1
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js +3 -3
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
- package/dist/test/mergeTree.annotate.spec.js +1 -1
- package/dist/test/mergeTree.annotate.spec.js.map +1 -1
- package/dist/test/mergeTree.insert.deltaCallback.spec.js +1 -1
- package/dist/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
- package/dist/test/mergeTree.insertingWalk.spec.js +3 -3
- package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -1
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +1 -1
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
- package/dist/test/mergeTree.markRangeRemoved.spec.js +1 -1
- package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
- package/dist/test/mergeTree.walk.spec.js +2 -2
- package/dist/test/mergeTree.walk.spec.js.map +1 -1
- package/dist/test/mergeTree.zamboni.spec.js.map +1 -1
- package/dist/test/mergeTreeOperationRunner.d.ts +2 -2
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/dist/test/mergeTreeOperationRunner.js +3 -3
- package/dist/test/mergeTreeOperationRunner.js.map +1 -1
- package/dist/test/mergeTreeOperationRunner.spec.js.map +1 -1
- package/dist/test/obliterate.concurrent.spec.js +2 -2
- package/dist/test/obliterate.concurrent.spec.js.map +1 -1
- package/dist/test/obliterate.deltaCallback.spec.js +1 -1
- package/dist/test/obliterate.deltaCallback.spec.js.map +1 -1
- package/dist/test/obliterate.partialLength.spec.js.map +1 -1
- package/dist/test/obliterate.reconnect.spec.js.map +1 -1
- package/dist/test/obliterate.spec.js.map +1 -1
- package/dist/test/ordinal.spec.d.ts +4 -0
- package/dist/test/ordinal.spec.d.ts.map +1 -1
- package/dist/test/ordinal.spec.js +4 -4
- package/dist/test/ordinal.spec.js.map +1 -1
- package/dist/test/partialLength.spec.js.map +1 -1
- package/dist/test/properties.spec.js.map +1 -1
- package/dist/test/reconnectHelper.d.ts +1 -1
- package/dist/test/reconnectHelper.d.ts.map +1 -1
- package/dist/test/reconnectHelper.js.map +1 -1
- package/dist/test/resetPendingSegmentsToOp.spec.js +1 -1
- package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
- package/dist/test/revertibleFarm.spec.js +1 -1
- package/dist/test/revertibleFarm.spec.js.map +1 -1
- package/dist/test/revertibles.spec.d.ts.map +1 -1
- package/dist/test/revertibles.spec.js +1 -1
- package/dist/test/revertibles.spec.js.map +1 -1
- package/dist/test/segmentGroupCollection.spec.js.map +1 -1
- package/dist/test/snapshot.spec.js +1 -1
- package/dist/test/snapshot.spec.js.map +1 -1
- package/dist/test/snapshot.utils.d.ts +1 -1
- package/dist/test/snapshot.utils.d.ts.map +1 -1
- package/dist/test/snapshot.utils.js +3 -3
- package/dist/test/snapshot.utils.js.map +1 -1
- package/dist/test/snapshotlegacy.spec.js +8 -8
- package/dist/test/snapshotlegacy.spec.js.map +1 -1
- package/dist/test/sortedSegmentSet.spec.js +2 -2
- package/dist/test/sortedSegmentSet.spec.js.map +1 -1
- package/dist/test/testClient.d.ts +5 -5
- package/dist/test/testClient.d.ts.map +1 -1
- package/dist/test/testClient.js +11 -11
- package/dist/test/testClient.js.map +1 -1
- package/dist/test/testClientLogger.d.ts +1 -1
- package/dist/test/testClientLogger.d.ts.map +1 -1
- package/dist/test/testClientLogger.js +10 -8
- package/dist/test/testClientLogger.js.map +1 -1
- package/dist/test/testSerializer.d.ts.map +1 -1
- package/dist/test/testSerializer.js +2 -2
- package/dist/test/testSerializer.js.map +1 -1
- package/dist/test/testServer.d.ts +1 -1
- package/dist/test/testServer.d.ts.map +1 -1
- package/dist/test/testServer.js +4 -4
- package/dist/test/testServer.js.map +1 -1
- package/dist/test/testUtils.d.ts +5 -5
- package/dist/test/testUtils.d.ts.map +1 -1
- package/dist/test/testUtils.js +3 -3
- package/dist/test/testUtils.js.map +1 -1
- package/dist/test/text.d.ts +1 -1
- package/dist/test/text.d.ts.map +1 -1
- package/dist/test/text.js.map +1 -1
- package/dist/test/tracking.spec.js.map +1 -1
- package/dist/test/wordUnitTests.spec.d.ts.map +1 -1
- package/dist/test/wordUnitTests.spec.js +2 -2
- package/dist/test/wordUnitTests.spec.js.map +1 -1
- package/dist/textSegment.d.ts.map +1 -1
- package/dist/textSegment.js +2 -2
- package/dist/textSegment.js.map +1 -1
- package/dist/zamboni.d.ts +2 -2
- package/dist/zamboni.d.ts.map +1 -1
- package/dist/zamboni.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/MergeTreeTextHelper.d.ts.map +1 -1
- package/lib/MergeTreeTextHelper.js.map +1 -1
- package/lib/attributionCollection.d.ts +1 -1
- package/lib/attributionCollection.d.ts.map +1 -1
- package/lib/attributionCollection.js +1 -1
- package/lib/attributionCollection.js.map +1 -1
- package/lib/attributionPolicy.d.ts +2 -2
- package/lib/attributionPolicy.d.ts.map +1 -1
- package/lib/attributionPolicy.js +4 -4
- package/lib/attributionPolicy.js.map +1 -1
- package/lib/client.d.ts +8 -8
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +14 -25
- package/lib/client.js.map +1 -1
- package/lib/collections/list.js +1 -1
- package/lib/collections/list.js.map +1 -1
- package/lib/endOfTreeSegment.d.ts +5 -5
- package/lib/endOfTreeSegment.d.ts.map +1 -1
- package/lib/endOfTreeSegment.js +2 -2
- package/lib/endOfTreeSegment.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +76 -0
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js +2 -2
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts +8 -8
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +23 -36
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeDeltaCallback.d.ts +1 -1
- package/lib/mergeTreeDeltaCallback.d.ts.map +1 -1
- package/lib/mergeTreeDeltaCallback.js +4 -0
- package/lib/mergeTreeDeltaCallback.js.map +1 -1
- package/lib/mergeTreeNodeWalk.d.ts +3 -3
- package/lib/mergeTreeNodeWalk.d.ts.map +1 -1
- package/lib/mergeTreeNodeWalk.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +37 -55
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +28 -8
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/opBuilder.d.ts +1 -1
- package/lib/opBuilder.d.ts.map +1 -1
- package/lib/opBuilder.js.map +1 -1
- package/lib/ordinal.js +1 -1
- package/lib/ordinal.js.map +1 -1
- package/lib/partialLengths.d.ts +6 -6
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +3 -3
- package/lib/partialLengths.js.map +1 -1
- package/lib/public.d.ts +12 -0
- package/lib/revertibles.d.ts +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +4 -4
- package/lib/revertibles.js.map +1 -1
- package/lib/segmentPropertiesManager.d.ts.map +1 -1
- package/lib/segmentPropertiesManager.js +1 -1
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotChunks.d.ts +2 -2
- package/lib/snapshotChunks.d.ts.map +1 -1
- package/lib/snapshotChunks.js.map +1 -1
- package/lib/snapshotLoader.d.ts +2 -2
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js +2 -2
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/snapshotV1.d.ts +3 -3
- package/lib/snapshotV1.d.ts.map +1 -1
- package/lib/snapshotV1.js +5 -5
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.d.ts +4 -4
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +3 -4
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/test/Insertion.perf.spec.js +1 -1
- package/lib/test/Insertion.perf.spec.js.map +1 -1
- package/lib/test/PartialLengths.perf.spec.js +2 -2
- package/lib/test/PartialLengths.perf.spec.js.map +1 -1
- package/lib/test/Removal.perf.spec.js +2 -2
- package/lib/test/Removal.perf.spec.js.map +1 -1
- package/lib/test/Snapshot.perf.spec.js +2 -2
- package/lib/test/Snapshot.perf.spec.js.map +1 -1
- package/lib/test/attributionCollection.perf.spec.js +4 -4
- package/lib/test/attributionCollection.perf.spec.js.map +1 -1
- package/lib/test/attributionCollection.spec.js.map +1 -1
- package/lib/test/attributionPolicy.spec.js.map +1 -1
- package/lib/test/beastTest.spec.d.ts.map +1 -1
- package/lib/test/beastTest.spec.js +8 -8
- package/lib/test/beastTest.spec.js.map +1 -1
- package/lib/test/client.annotateMarker.spec.js.map +1 -1
- package/lib/test/client.apis.spec.d.ts.map +1 -1
- package/lib/test/client.apis.spec.js.map +1 -1
- package/lib/test/client.applyMsg.spec.js +3 -3
- package/lib/test/client.applyMsg.spec.js.map +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.d.ts +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.d.ts.map +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.js +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/lib/test/client.attributionFarm.spec.d.ts.map +1 -1
- package/lib/test/client.attributionFarm.spec.js +2 -2
- package/lib/test/client.attributionFarm.spec.js.map +1 -1
- package/lib/test/client.conflictFarm.spec.d.ts.map +1 -1
- package/lib/test/client.conflictFarm.spec.js +1 -1
- package/lib/test/client.conflictFarm.spec.js.map +1 -1
- package/lib/test/client.getPosition.spec.js.map +1 -1
- package/lib/test/client.localReference.spec.js +5 -5
- package/lib/test/client.localReference.spec.js.map +1 -1
- package/lib/test/client.localReferenceFarm.spec.js +2 -2
- package/lib/test/client.localReferenceFarm.spec.js.map +1 -1
- package/lib/test/client.rebasePosition.spec.js.map +1 -1
- package/lib/test/client.reconnectFarm.spec.d.ts +1 -1
- package/lib/test/client.reconnectFarm.spec.d.ts.map +1 -1
- package/lib/test/client.reconnectFarm.spec.js +2 -2
- package/lib/test/client.reconnectFarm.spec.js.map +1 -1
- package/lib/test/client.replay.spec.js +3 -3
- package/lib/test/client.replay.spec.js.map +1 -1
- package/lib/test/client.rollback.spec.js +1 -1
- package/lib/test/client.rollback.spec.js.map +1 -1
- package/lib/test/client.rollbackFarm.spec.js +1 -1
- package/lib/test/client.rollbackFarm.spec.js.map +1 -1
- package/lib/test/client.searchForMarker.spec.js +2 -2
- package/lib/test/client.searchForMarker.spec.js.map +1 -1
- package/lib/test/client.walkSegments.spec.js.map +1 -1
- package/lib/test/collections.list.spec.js.map +1 -1
- package/lib/test/createInsertOnlyAttributionPolicy.spec.js.map +1 -1
- package/lib/test/mergeTree.annotate.deltaCallback.spec.js +3 -3
- package/lib/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
- package/lib/test/mergeTree.annotate.spec.js +1 -1
- package/lib/test/mergeTree.annotate.spec.js.map +1 -1
- package/lib/test/mergeTree.insert.deltaCallback.spec.js +1 -1
- package/lib/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
- package/lib/test/mergeTree.insertingWalk.spec.js +3 -3
- package/lib/test/mergeTree.insertingWalk.spec.js.map +1 -1
- package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +1 -1
- package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
- package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
- package/lib/test/mergeTree.walk.spec.js +2 -2
- package/lib/test/mergeTree.walk.spec.js.map +1 -1
- package/lib/test/mergeTree.zamboni.spec.js +1 -1
- package/lib/test/mergeTree.zamboni.spec.js.map +1 -1
- package/lib/test/mergeTreeOperationRunner.d.ts +2 -2
- package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/lib/test/mergeTreeOperationRunner.js +3 -3
- package/lib/test/mergeTreeOperationRunner.js.map +1 -1
- package/lib/test/mergeTreeOperationRunner.spec.js.map +1 -1
- package/lib/test/obliterate.concurrent.spec.js +1 -1
- package/lib/test/obliterate.concurrent.spec.js.map +1 -1
- package/lib/test/obliterate.deltaCallback.spec.js +1 -1
- package/lib/test/obliterate.deltaCallback.spec.js.map +1 -1
- package/lib/test/obliterate.partialLength.spec.js.map +1 -1
- package/lib/test/obliterate.reconnect.spec.js.map +1 -1
- package/lib/test/obliterate.spec.js.map +1 -1
- package/lib/test/ordinal.spec.d.ts +4 -0
- package/lib/test/ordinal.spec.d.ts.map +1 -1
- package/lib/test/ordinal.spec.js.map +1 -1
- package/lib/test/partialLength.spec.js.map +1 -1
- package/lib/test/properties.spec.js.map +1 -1
- package/lib/test/reconnectHelper.d.ts +1 -1
- package/lib/test/reconnectHelper.d.ts.map +1 -1
- package/lib/test/reconnectHelper.js +1 -1
- package/lib/test/reconnectHelper.js.map +1 -1
- package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
- package/lib/test/revertibleFarm.spec.js +3 -3
- package/lib/test/revertibleFarm.spec.js.map +1 -1
- package/lib/test/revertibles.spec.d.ts.map +1 -1
- package/lib/test/revertibles.spec.js +2 -2
- package/lib/test/revertibles.spec.js.map +1 -1
- package/lib/test/segmentGroupCollection.spec.js.map +1 -1
- package/lib/test/snapshot.spec.js +2 -2
- package/lib/test/snapshot.spec.js.map +1 -1
- package/lib/test/snapshot.utils.d.ts +1 -1
- package/lib/test/snapshot.utils.d.ts.map +1 -1
- package/lib/test/snapshot.utils.js +2 -2
- package/lib/test/snapshot.utils.js.map +1 -1
- package/lib/test/snapshotlegacy.spec.js +4 -4
- package/lib/test/snapshotlegacy.spec.js.map +1 -1
- package/lib/test/sortedSegmentSet.spec.js +2 -2
- package/lib/test/sortedSegmentSet.spec.js.map +1 -1
- package/lib/test/testClient.d.ts +5 -5
- package/lib/test/testClient.d.ts.map +1 -1
- package/lib/test/testClient.js +7 -7
- package/lib/test/testClient.js.map +1 -1
- package/lib/test/testClientLogger.d.ts +1 -1
- package/lib/test/testClientLogger.d.ts.map +1 -1
- package/lib/test/testClientLogger.js +9 -7
- package/lib/test/testClientLogger.js.map +1 -1
- package/lib/test/testSerializer.d.ts.map +1 -1
- package/lib/test/testSerializer.js +1 -1
- package/lib/test/testSerializer.js.map +1 -1
- package/lib/test/testServer.d.ts +1 -1
- package/lib/test/testServer.d.ts.map +1 -1
- package/lib/test/testServer.js +2 -2
- package/lib/test/testServer.js.map +1 -1
- package/lib/test/testUtils.d.ts +5 -5
- package/lib/test/testUtils.d.ts.map +1 -1
- package/lib/test/testUtils.js +3 -3
- package/lib/test/testUtils.js.map +1 -1
- package/lib/test/text.d.ts +1 -1
- package/lib/test/text.d.ts.map +1 -1
- package/lib/test/text.js.map +1 -1
- package/lib/test/tracking.spec.js.map +1 -1
- package/lib/test/wordUnitTests.spec.d.ts.map +1 -1
- package/lib/test/wordUnitTests.spec.js +2 -2
- package/lib/test/wordUnitTests.spec.js.map +1 -1
- package/lib/textSegment.d.ts.map +1 -1
- package/lib/textSegment.js +1 -1
- package/lib/textSegment.js.map +1 -1
- package/lib/zamboni.d.ts +2 -2
- package/lib/zamboni.d.ts.map +1 -1
- package/lib/zamboni.js.map +1 -1
- package/package.json +37 -58
- package/src/MergeTreeTextHelper.ts +1 -1
- package/src/attributionCollection.ts +4 -3
- package/src/attributionPolicy.ts +7 -6
- package/src/client.ts +32 -45
- package/src/collections/list.ts +1 -1
- package/src/endOfTreeSegment.ts +5 -4
- package/src/index.ts +5 -1
- package/src/localReference.ts +4 -3
- package/src/mergeTree.ts +66 -84
- package/src/mergeTreeDeltaCallback.ts +3 -1
- package/src/mergeTreeNodeWalk.ts +6 -6
- package/src/mergeTreeNodes.ts +59 -61
- package/src/opBuilder.ts +3 -3
- package/src/ordinal.ts +1 -1
- package/src/partialLengths.ts +11 -10
- package/src/revertibles.ts +6 -5
- package/src/segmentPropertiesManager.ts +3 -2
- package/src/snapshotChunks.ts +3 -2
- package/src/snapshotLoader.ts +10 -12
- package/src/snapshotV1.ts +15 -12
- package/src/snapshotlegacy.ts +8 -6
- package/src/textSegment.ts +2 -1
- package/src/zamboni.ts +7 -7
- package/api-extractor-cjs.json +0 -8
- package/dist/merge-tree-alpha.d.ts +0 -1558
- package/dist/merge-tree-beta.d.ts +0 -230
- package/dist/merge-tree-public.d.ts +0 -230
- package/dist/merge-tree-untrimmed.d.ts +0 -1894
- package/lib/merge-tree-alpha.d.ts +0 -1558
- package/lib/merge-tree-beta.d.ts +0 -230
- package/lib/merge-tree-public.d.ts +0 -230
- package/lib/merge-tree-untrimmed.d.ts +0 -1894
- package/lib/test/types/validateMergeTreePrevious.generated.d.ts +0 -2
- package/lib/test/types/validateMergeTreePrevious.generated.d.ts.map +0 -1
- package/lib/test/types/validateMergeTreePrevious.generated.js +0 -228
- package/lib/test/types/validateMergeTreePrevious.generated.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordUnitTests.spec.js","sourceRoot":"","sources":["../../src/test/wordUnitTests.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,+BAA+B;AAC/B,6DAA6D;AAE7D,gDAAwB;AACxB,gFAAkE;AAClE,+DAAqD;AACrD,sCAA0C;AAC1C,oDAA8D;AAE9D,mDAA6C;AAC7C,iDAA6D;AAC7D,+CAAyC;AAEzC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,oBAAK,CAAC,KAAK,EAAE,CAAC;AAElC,SAAS,mBAAmB,CAAC,KAAY;IACxC,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC;AACtC,CAAC;AAED,SAAgB,YAAY;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC;I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,CAAC;YACvB,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport path from \"path\";\nimport { makeRandom } from \"@fluid-private/stochastic-test-utils\";\nimport { Trace } from \"@fluid-internal/client-utils\";\nimport { ReferenceType } from \"../ops.js\";\nimport { createMap, extend, MapLike } from \"../properties.js\";\nimport { ReferencePosition } from \"../referencePositions.js\";\nimport { TestClient } from \"./testClient.js\";\nimport { loadTextFromFileWithMarkers } from \"./testUtils.js\";\nimport { _dirname } from \"./dirname.cjs\";\n\nconst clock = () => Trace.start();\n\nfunction elapsedMicroseconds(trace: Trace) {\n\treturn trace.trace().duration * 1000;\n}\n\nexport function propertyCopy() {\n\tconst propCount = 2000;\n\tconst iterCount = 1000;\n\tconst map = new Map<string, number>();\n\tconst a: string[] = [];\n\tconst v: number[] = [];\n\tfor (let i = 0; i < propCount; i++) {\n\t\ta[i] = `prop${i}`;\n\t\tv[i] = i;\n\t\tmap.set(a[i], v[i]);\n\t}\n\tlet clockStart = clock();\n\tlet obj: MapLike<number> = {};\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tobj = createMap<number>();\n\t\tfor (let i = 0; i < propCount; i++) {\n\t\t\tobj[a[i]] = v[i];\n\t\t}\n\t}\n\tlet et = elapsedMicroseconds(clockStart);\n\tlet perIter = (et / iterCount).toFixed(3);\n\tlet perProp = (et / (iterCount * propCount)).toFixed(3);\n\tconsole.log(\n\t\t`arr prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const key in obj) {\n\t\t\tbObj[key] = obj[key];\n\t\t}\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(3);\n\tconsole.log(\n\t\t`obj prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\tfor (const [key, value] of map) {\n\t\t\tbObj[key] = value;\n\t\t}\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\tmap.forEach((value, key) => {\n\t\t\tbObj[key] = value;\n\t\t});\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map foreach prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bmap = new Map<string, number>();\n\t\tmap.forEach((value, key) => {\n\t\t\tbmap.set(key, value);\n\t\t});\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map to map foreach prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tconst diffMap = new Map<string, number>();\n\tmap.forEach((value, key) => {\n\t\tif (Math.random() < 0.5) {\n\t\t\tdiffMap.set(key, value);\n\t\t} else {\n\t\t\tdiffMap.set(key, value * 3);\n\t\t}\n\t});\n\tclockStart = clock();\n\tconst grayMap = new Map<string, number>();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tmap.forEach((value, key) => {\n\t\t\tif (diffMap.get(key) !== value) {\n\t\t\t\tgrayMap.set(key, 1);\n\t\t\t}\n\t\t});\n\t}\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(`diff time ${perIter} us per ${propCount} properties; ${perProp} us per property`);\n}\n\nfunction makeBookmarks(client: TestClient, bookmarkCount: number) {\n\tconst random = makeRandom(0xdeadbeef, 0xfeedbed);\n\tconst bookmarks: ReferencePosition[] = [];\n\tconst len = client.getLength();\n\tfor (let i = 0; i < bookmarkCount; i++) {\n\t\tconst pos = random.integer(0, len - 1);\n\t\tconst segoff = client.getContainingSegment(pos);\n\t\tlet refType = ReferenceType.Simple;\n\t\tif (i & 1) {\n\t\t\trefType = ReferenceType.SlideOnRemove;\n\t\t}\n\t\tconst lref = client.mergeTree.createLocalReferencePosition(\n\t\t\tsegoff.segment!,\n\t\t\tsegoff.offset!,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t);\n\t\tbookmarks.push(lref);\n\t}\n\treturn bookmarks;\n}\n\nfunction measureFetch(startFile: string, withBookmarks = false) {\n\tconst bookmarkCount = 20000;\n\tconst client = new TestClient();\n\tloadTextFromFileWithMarkers(startFile, client.mergeTree);\n\tif (withBookmarks) {\n\t\tmakeBookmarks(client, bookmarkCount);\n\t\tconsole.log(`inserting ${bookmarkCount} refs into text`);\n\t}\n\tconst reps = 20;\n\tconst clockStart = clock();\n\tlet count = 0;\n\tfor (let i = 0; i < reps; i++) {\n\t\tfor (let pos = 0; pos < client.getLength(); ) {\n\t\t\t// curPG.pos is ca end\n\t\t\tconst curPG = client.searchForMarker(pos, \"pg\", true)!;\n\t\t\tconst properties = curPG.properties!;\n\t\t\tconst curSegOff = client.getContainingSegment(pos)!;\n\t\t\tconst curSeg = curSegOff.segment!;\n\t\t\t// Combine paragraph and direct properties\n\t\t\textend(properties, curSeg.properties);\n\t\t\tpos += curSeg.cachedLength - curSegOff.offset!;\n\t\t\tcount++;\n\t\t}\n\t}\n\tconst et = elapsedMicroseconds(clockStart);\n\tconsole.log(\n\t\t`fetch of ${count / reps} runs over ${client.getLength()} total chars took ${(\n\t\t\tet / count\n\t\t).toFixed(1)} microseconds per run`,\n\t);\n}\n\nconst baseDir = \"../../src/test/literature\";\nconst filename = path.join(_dirname, baseDir, \"pp.txt\");\nconst testTimeout = 30000;\n\ndescribe(\"Routerlicious\", () => {\n\tdescribe(\"merge-tree\", () => {\n\t\tit(\"wordUnitTest\", () => {\n\t\t\tpropertyCopy();\n\t\t\tmeasureFetch(filename);\n\t\t\tmeasureFetch(filename, true);\n\t\t\tmeasureFetch(filename);\n\t\t\tmeasureFetch(filename, true);\n\t\t}).timeout(testTimeout);\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"wordUnitTests.spec.js","sourceRoot":"","sources":["../../src/test/wordUnitTests.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,+BAA+B;AAC/B,6DAA6D;AAE7D,gDAAwB;AAExB,+DAAqD;AACrD,gFAAkE;AAElE,sCAA0C;AAC1C,oDAA8D;AAG9D,+CAAyC;AACzC,mDAA6C;AAC7C,iDAA6D;AAE7D,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,oBAAK,CAAC,KAAK,EAAE,CAAC;AAElC,SAAS,mBAAmB,CAAC,KAAY;IACxC,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC;AACtC,CAAC;AAED,SAAgB,YAAY;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,CAAC,GAAa,EAAE,CAAC;IACvB,MAAM,CAAC,GAAa,EAAE,CAAC;IACvB,KAAK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":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport path from \"path\";\n\nimport { Trace } from \"@fluid-internal/client-utils\";\nimport { makeRandom } from \"@fluid-private/stochastic-test-utils\";\n\nimport { ReferenceType } from \"../ops.js\";\nimport { MapLike, createMap, extend } from \"../properties.js\";\nimport { ReferencePosition } from \"../referencePositions.js\";\n\nimport { _dirname } from \"./dirname.cjs\";\nimport { TestClient } from \"./testClient.js\";\nimport { loadTextFromFileWithMarkers } from \"./testUtils.js\";\n\nconst clock = () => Trace.start();\n\nfunction elapsedMicroseconds(trace: Trace) {\n\treturn trace.trace().duration * 1000;\n}\n\nexport function propertyCopy() {\n\tconst propCount = 2000;\n\tconst iterCount = 1000;\n\tconst map = new Map<string, number>();\n\tconst a: string[] = [];\n\tconst v: number[] = [];\n\tfor (let i = 0; i < propCount; i++) {\n\t\ta[i] = `prop${i}`;\n\t\tv[i] = i;\n\t\tmap.set(a[i], v[i]);\n\t}\n\tlet clockStart = clock();\n\tlet obj: MapLike<number> = {};\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tobj = createMap<number>();\n\t\tfor (let i = 0; i < propCount; i++) {\n\t\t\tobj[a[i]] = v[i];\n\t\t}\n\t}\n\tlet et = elapsedMicroseconds(clockStart);\n\tlet perIter = (et / iterCount).toFixed(3);\n\tlet perProp = (et / (iterCount * propCount)).toFixed(3);\n\tconsole.log(\n\t\t`arr prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const key in obj) {\n\t\t\tbObj[key] = obj[key];\n\t\t}\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(3);\n\tconsole.log(\n\t\t`obj prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\tfor (const [key, value] of map) {\n\t\t\tbObj[key] = value;\n\t\t}\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bObj = createMap<number>();\n\t\tmap.forEach((value, key) => {\n\t\t\tbObj[key] = value;\n\t\t});\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map foreach prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tclockStart = clock();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tconst bmap = new Map<string, number>();\n\t\tmap.forEach((value, key) => {\n\t\t\tbmap.set(key, value);\n\t\t});\n\t}\n\tet = elapsedMicroseconds(clockStart);\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(\n\t\t`map to map foreach prop init time ${perIter} us per ${propCount} properties; ${perProp} us per property`,\n\t);\n\tconst diffMap = new Map<string, number>();\n\tmap.forEach((value, key) => {\n\t\tif (Math.random() < 0.5) {\n\t\t\tdiffMap.set(key, value);\n\t\t} else {\n\t\t\tdiffMap.set(key, value * 3);\n\t\t}\n\t});\n\tclockStart = clock();\n\tconst grayMap = new Map<string, number>();\n\tfor (let j = 0; j < iterCount; j++) {\n\t\tmap.forEach((value, key) => {\n\t\t\tif (diffMap.get(key) !== value) {\n\t\t\t\tgrayMap.set(key, 1);\n\t\t\t}\n\t\t});\n\t}\n\tperIter = (et / iterCount).toFixed(3);\n\tperProp = (et / (iterCount * propCount)).toFixed(2);\n\tconsole.log(`diff time ${perIter} us per ${propCount} properties; ${perProp} us per property`);\n}\n\nfunction makeBookmarks(client: TestClient, bookmarkCount: number) {\n\tconst random = makeRandom(0xdeadbeef, 0xfeedbed);\n\tconst bookmarks: ReferencePosition[] = [];\n\tconst len = client.getLength();\n\tfor (let i = 0; i < bookmarkCount; i++) {\n\t\tconst pos = random.integer(0, len - 1);\n\t\tconst segoff = client.getContainingSegment(pos);\n\t\tlet refType = ReferenceType.Simple;\n\t\tif (i & 1) {\n\t\t\trefType = ReferenceType.SlideOnRemove;\n\t\t}\n\t\tconst lref = client.mergeTree.createLocalReferencePosition(\n\t\t\tsegoff.segment!,\n\t\t\tsegoff.offset!,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t);\n\t\tbookmarks.push(lref);\n\t}\n\treturn bookmarks;\n}\n\nfunction measureFetch(startFile: string, withBookmarks = false) {\n\tconst bookmarkCount = 20000;\n\tconst client = new TestClient();\n\tloadTextFromFileWithMarkers(startFile, client.mergeTree);\n\tif (withBookmarks) {\n\t\tmakeBookmarks(client, bookmarkCount);\n\t\tconsole.log(`inserting ${bookmarkCount} refs into text`);\n\t}\n\tconst reps = 20;\n\tconst clockStart = clock();\n\tlet count = 0;\n\tfor (let i = 0; i < reps; i++) {\n\t\tfor (let pos = 0; pos < client.getLength(); ) {\n\t\t\t// curPG.pos is ca end\n\t\t\tconst curPG = client.searchForMarker(pos, \"pg\", true)!;\n\t\t\tconst properties = curPG.properties!;\n\t\t\tconst curSegOff = client.getContainingSegment(pos)!;\n\t\t\tconst curSeg = curSegOff.segment!;\n\t\t\t// Combine paragraph and direct properties\n\t\t\textend(properties, curSeg.properties);\n\t\t\tpos += curSeg.cachedLength - curSegOff.offset!;\n\t\t\tcount++;\n\t\t}\n\t}\n\tconst et = elapsedMicroseconds(clockStart);\n\tconsole.log(\n\t\t`fetch of ${count / reps} runs over ${client.getLength()} total chars took ${(\n\t\t\tet / count\n\t\t).toFixed(1)} microseconds per run`,\n\t);\n}\n\nconst baseDir = \"../../src/test/literature\";\nconst filename = path.join(_dirname, baseDir, \"pp.txt\");\nconst testTimeout = 30000;\n\ndescribe(\"Routerlicious\", () => {\n\tdescribe(\"merge-tree\", () => {\n\t\tit(\"wordUnitTest\", () => {\n\t\t\tpropertyCopy();\n\t\t\tmeasureFetch(filename);\n\t\t\tmeasureFetch(filename, true);\n\t\t\tmeasureFetch(filename);\n\t\t\tmeasureFetch(filename, true);\n\t\t}).timeout(testTimeout);\n\t});\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegment.d.ts","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"textSegment.d.ts","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAW9C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACrD,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,WAAW;IA0BxB,IAAI,EAAE,MAAM;IAzB/B,gBAAuB,IAAI,iBAAiB;IAC5C,SAAgB,IAAI,iBAAoB;WAE1B,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,WAAW;WAI7C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW;WAQtC,cAAc,CAAC,IAAI,EAAE,GAAG;gBAUnB,IAAI,EAAE,MAAM;IAKxB,YAAY,IAAI,gBAAgB,GAAG,MAAM;IAMzC,KAAK,CAAC,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAO7B,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IASrC,QAAQ;IAIR,MAAM,CAAC,OAAO,EAAE,QAAQ;IAM/B,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAS1C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC,OAAO,CACN,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV,MAAM,CAAC;CACV"}
|
package/dist/textSegment.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.TextSegment = exports.TextSegmentGranularity = void 0;
|
|
8
|
-
const
|
|
8
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const mergeTreeNodes_js_1 = require("./mergeTreeNodes.js");
|
|
10
10
|
// Maximum length of text segment to be considered to be merged with other segment.
|
|
11
11
|
// Maximum segment length is at least 2x of it (not taking into account initial segment creation).
|
|
@@ -68,7 +68,7 @@ class TextSegment extends mergeTreeNodes_js_1.BaseSegment {
|
|
|
68
68
|
return this.text;
|
|
69
69
|
}
|
|
70
70
|
append(segment) {
|
|
71
|
-
(0,
|
|
71
|
+
(0, internal_1.assert)(TextSegment.is(segment), 0x447 /* can only append text segment */);
|
|
72
72
|
super.append(segment);
|
|
73
73
|
this.text += segment.text;
|
|
74
74
|
}
|
package/dist/textSegment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegment.js","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"textSegment.js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,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YACrC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC;YACnD,OAAO,WAAW,CAAC;SACnB;IACF,CAAC;;AAvEF,kCAwEC;AAvEuB,gBAAI,GAAG,aAAa,AAAhB,CAAiB","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 { BaseSegment, ISegment } from \"./mergeTreeNodes.js\";\nimport { IJSONSegment } from \"./ops.js\";\nimport { PropertySet } from \"./properties.js\";\n\n// Maximum length of text segment to be considered to be merged with other segment.\n// Maximum segment length is at least 2x of it (not taking into account initial segment creation).\n// The bigger it is, the more expensive it is to break segment into sub-segments (on edits)\n// The smaller it is, the more segments we have in snapshots (and in memory) - it's more expensive to load snapshots.\n// Small number also makes ReplayTool produce false positives (\"same\" snapshots have slightly different binary\n// representations). More measurements needs to be done, but it's very likely the right spot is somewhere between\n// 1K-2K mark. That said, we also break segments on newline and there are very few segments that are longer than 256\n// because of it. Must be an even number.\n// Exported for test use only.\nexport const TextSegmentGranularity = 256;\n\n/**\n * @alpha\n */\nexport interface IJSONTextSegment extends IJSONSegment {\n\ttext: string;\n}\n\n/**\n * @alpha\n */\nexport class TextSegment extends BaseSegment {\n\tpublic static readonly type = \"TextSegment\";\n\tpublic readonly type = TextSegment.type;\n\n\tpublic static is(segment: ISegment): segment is TextSegment {\n\t\treturn segment.type === TextSegment.type;\n\t}\n\n\tpublic static make(text: string, props?: PropertySet) {\n\t\tconst seg = new TextSegment(text);\n\t\tif (props) {\n\t\t\tseg.addProperties(props);\n\t\t}\n\t\treturn seg;\n\t}\n\n\tpublic static fromJSONObject(spec: any) {\n\t\tif (typeof spec === \"string\") {\n\t\t\treturn new TextSegment(spec);\n\t\t} else if (spec && typeof spec === \"object\" && \"text\" in spec) {\n\t\t\tconst textSpec = spec as IJSONTextSegment;\n\t\t\treturn TextSegment.make(textSpec.text, textSpec.props as PropertySet);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconstructor(public text: string) {\n\t\tsuper();\n\t\tthis.cachedLength = text.length;\n\t}\n\n\tpublic toJSONObject(): IJSONTextSegment | string {\n\t\t// To reduce snapshot/ops size, we serialize a TextSegment as a plain 'string' if it is\n\t\t// not annotated.\n\t\treturn this.properties ? { text: this.text, props: this.properties } : this.text;\n\t}\n\n\tpublic clone(start = 0, end?: number) {\n\t\tconst text = this.text.substring(start, end);\n\t\tconst b = TextSegment.make(text, this.properties);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn (\n\t\t\t!this.text.endsWith(\"\\n\") &&\n\t\t\tTextSegment.is(segment) &&\n\t\t\t(this.cachedLength <= TextSegmentGranularity ||\n\t\t\t\tsegment.cachedLength <= TextSegmentGranularity)\n\t\t);\n\t}\n\n\tpublic toString() {\n\t\treturn this.text;\n\t}\n\n\tpublic append(segment: ISegment) {\n\t\tassert(TextSegment.is(segment), 0x447 /* can only append text segment */);\n\t\tsuper.append(segment);\n\t\tthis.text += segment.text;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tif (pos > 0) {\n\t\t\tconst remainingText = this.text.substring(pos);\n\t\t\tthis.text = this.text.substring(0, pos);\n\t\t\tthis.cachedLength = this.text.length;\n\t\t\tconst leafSegment = new TextSegment(remainingText);\n\t\t\treturn leafSegment;\n\t\t}\n\t}\n}\n\n/**\n * @deprecated This functionality was not meant to be exported and will be removed in a future release\n * @alpha\n */\nexport interface IMergeTreeTextHelper {\n\tgetText(\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tplaceholder: string,\n\t\tstart?: number,\n\t\tend?: number,\n\t): string;\n}\n"]}
|
package/dist/zamboni.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { MergeTree } from "./mergeTree.js";
|
|
6
|
-
import {
|
|
6
|
+
import { type MergeBlock } from "./mergeTreeNodes.js";
|
|
7
7
|
export declare const zamboniSegmentsMax = 2;
|
|
8
8
|
export declare function zamboniSegments(mergeTree: MergeTree, zamboniSegmentsMaxCount?: number): void;
|
|
9
|
-
export declare function packParent(parent:
|
|
9
|
+
export declare function packParent(parent: MergeBlock, mergeTree: MergeTree): void;
|
|
10
10
|
//# sourceMappingURL=zamboni.d.ts.map
|
package/dist/zamboni.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zamboni.d.ts","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"zamboni.d.ts","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACN,KAAK,UAAU,EAQf,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAKpC,wBAAgB,eAAe,CAC9B,SAAS,EAAE,SAAS,EACpB,uBAAuB,SAAqB,QAuC5C;AAGD,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,QAwDlE"}
|
package/dist/zamboni.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zamboni.js","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA6D;AAE7D,iDAA0D;AAE1D,2EAAuE;AACvE,2DAS6B;AAC7B,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EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;qBACvD,EACD,SAAS,CACT,CAAC;oBAEF,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC3B,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;iBAC9E;qBAAM;oBACN,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACxB,WAAW,GAAG,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;iBAC7D;aACD;iBAAM;gBACN,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,WAAW,GAAG,SAAS,CAAC;aACxB;SACD;KACD;AACF,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 { UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { MergeTreeMaintenanceType } from \"./mergeTreeDeltaCallback.js\";\nimport {\n\tIMergeBlock,\n\tIMergeNode,\n\tISegment,\n\tMarker,\n\tMaxNodesInBlock,\n\tseqLTE,\n\ttoMoveInfo,\n\ttoRemovalInfo,\n} from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\n\nexport const zamboniSegmentsMax = 2;\nfunction underflow(node: IMergeBlock) {\n\treturn node.childCount < MaxNodesInBlock / 2;\n}\n\nexport function zamboniSegments(\n\tmergeTree: MergeTree,\n\tzamboniSegmentsMaxCount = zamboniSegmentsMax,\n) {\n\tif (!mergeTree.collabWindow.collaborating) {\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < zamboniSegmentsMaxCount; i++) {\n\t\tlet segmentToScour = mergeTree.segmentsToScour.peek()?.value;\n\t\tif (!segmentToScour || segmentToScour.maxSeq > mergeTree.collabWindow.minSeq) {\n\t\t\tbreak;\n\t\t}\n\t\tsegmentToScour = mergeTree.segmentsToScour.get()!;\n\t\t// Only skip scouring if needs scour is explicitly false, not true or undefined\n\t\tif (segmentToScour?.segment?.parent && segmentToScour.segment.parent.needsScour !== false) {\n\t\t\tconst block = segmentToScour.segment.parent;\n\t\t\tconst childrenCopy: IMergeNode[] = [];\n\t\t\tscourNode(block, childrenCopy, mergeTree);\n\t\t\t// This will avoid the cost of re-scouring nodes\n\t\t\t// that have recently been scoured\n\t\t\tblock.needsScour = false;\n\n\t\t\tconst newChildCount = childrenCopy.length;\n\n\t\t\tif (newChildCount < block.childCount) {\n\t\t\t\tblock.childCount = newChildCount;\n\t\t\t\tblock.children = childrenCopy;\n\t\t\t\tfor (let j = 0; j < newChildCount; j++) {\n\t\t\t\t\tblock.assignChild(childrenCopy[j], j, false);\n\t\t\t\t}\n\n\t\t\t\tif (underflow(block) && block.parent) {\n\t\t\t\t\tpackParent(block.parent, mergeTree);\n\t\t\t\t} else {\n\t\t\t\t\tmergeTree.nodeUpdateOrdinals(block);\n\t\t\t\t\tmergeTree.blockUpdatePathLengths(block, UnassignedSequenceNumber, -1, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Interior node with all node children\nexport function packParent(parent: IMergeBlock, mergeTree: MergeTree) {\n\tconst children = parent.children;\n\tlet childIndex: number;\n\tlet childBlock: IMergeBlock;\n\tconst holdNodes: IMergeNode[] = [];\n\tfor (childIndex = 0; childIndex < parent.childCount; childIndex++) {\n\t\t// Debug assert not isLeaf()\n\t\tchildBlock = children[childIndex] as IMergeBlock;\n\t\tscourNode(childBlock, holdNodes, mergeTree);\n\t\t// Will replace this block with a packed block\n\t\tchildBlock.parent = undefined;\n\t}\n\tif (holdNodes.length > 0) {\n\t\tconst totalNodeCount = holdNodes.length;\n\t\tconst halfOfMaxNodeCount = MaxNodesInBlock / 2;\n\t\tlet childCount = Math.min(\n\t\t\tMaxNodesInBlock - 1,\n\t\t\tMath.floor(totalNodeCount / halfOfMaxNodeCount),\n\t\t);\n\t\tif (childCount < 1) {\n\t\t\tchildCount = 1;\n\t\t}\n\t\tconst baseNodesInBlockCount = Math.floor(totalNodeCount / childCount);\n\t\tlet remainderCount = totalNodeCount % childCount;\n\t\tconst packedBlocks = new Array<IMergeBlock>(MaxNodesInBlock);\n\t\tlet childrenPackedCount = 0;\n\t\tfor (let nodeIndex = 0; nodeIndex < childCount; nodeIndex++) {\n\t\t\tlet nodeCount = baseNodesInBlockCount;\n\t\t\tif (remainderCount > 0) {\n\t\t\t\tnodeCount++;\n\t\t\t\tremainderCount--;\n\t\t\t}\n\t\t\tconst packedBlock = mergeTree.makeBlock(nodeCount);\n\t\t\tfor (let packedNodeIndex = 0; packedNodeIndex < nodeCount; packedNodeIndex++) {\n\t\t\t\tconst nodeToPack = holdNodes[childrenPackedCount++];\n\t\t\t\tpackedBlock.assignChild(nodeToPack, packedNodeIndex, false);\n\t\t\t}\n\t\t\tpackedBlock.parent = parent;\n\t\t\tpackedBlocks[nodeIndex] = packedBlock;\n\t\t\tmergeTree.nodeUpdateLengthNewStructure(packedBlock);\n\t\t}\n\t\tparent.children = packedBlocks;\n\t\tfor (let j = 0; j < childCount; j++) {\n\t\t\tparent.assignChild(packedBlocks[j], j, false);\n\t\t}\n\t\tparent.childCount = childCount;\n\t} else {\n\t\tparent.children = [];\n\t\tparent.childCount = 0;\n\t}\n\tif (underflow(parent) && parent.parent) {\n\t\tpackParent(parent.parent, mergeTree);\n\t} else {\n\t\tmergeTree.nodeUpdateOrdinals(parent);\n\t\tmergeTree.blockUpdatePathLengths(parent, UnassignedSequenceNumber, -1, true);\n\t}\n}\n\nfunction scourNode(node: IMergeBlock, holdNodes: IMergeNode[], mergeTree: MergeTree) {\n\t// The previous segment is tracked while scouring for the purposes of merging adjacent segments\n\t// when possible.\n\tlet prevSegment: ISegment | undefined;\n\tfor (let k = 0; k < node.childCount; k++) {\n\t\tconst childNode = node.children[k];\n\t\tif (!childNode.isLeaf() || !childNode.segmentGroups.empty) {\n\t\t\tholdNodes.push(childNode);\n\t\t\tprevSegment = undefined;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst segment = childNode;\n\t\tconst removalInfo = toRemovalInfo(segment);\n\t\tconst moveInfo = toMoveInfo(segment);\n\t\tif (removalInfo !== undefined || moveInfo !== undefined) {\n\t\t\t// If the segment's removal is below the MSN and it's not being held onto by a tracking group,\n\t\t\t// it can be unlinked (i.e. removed from the merge-tree)\n\t\t\tif (\n\t\t\t\t((!!removalInfo && seqLTE(removalInfo.removedSeq, mergeTree.collabWindow.minSeq)) ||\n\t\t\t\t\t(!!moveInfo && seqLTE(moveInfo.movedSeq, mergeTree.collabWindow.minSeq))) &&\n\t\t\t\tsegment.trackingCollection.empty\n\t\t\t) {\n\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: MergeTreeMaintenanceType.UNLINK,\n\t\t\t\t\t\tdeltaSegments: [{ segment }],\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\n\t\t\t\tsegment.parent = undefined;\n\n\t\t\t\tif (Marker.is(segment)) {\n\t\t\t\t\tmergeTree.unlinkMarker(segment);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t}\n\n\t\t\tprevSegment = undefined;\n\t\t} else {\n\t\t\tif (segment.seq! <= mergeTree.collabWindow.minSeq) {\n\t\t\t\tconst segmentHasPositiveLength = (mergeTree.localNetLength(segment) ?? 0) > 0;\n\t\t\t\tconst canAppend =\n\t\t\t\t\tprevSegment?.canAppend(segment) &&\n\t\t\t\t\tmatchProperties(prevSegment.properties, segment.properties) &&\n\t\t\t\t\tprevSegment.trackingCollection.matches(segment.trackingCollection) &&\n\t\t\t\t\tsegmentHasPositiveLength;\n\n\t\t\t\tif (canAppend) {\n\t\t\t\t\tprevSegment!.append(segment);\n\t\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: MergeTreeMaintenanceType.APPEND,\n\t\t\t\t\t\t\tdeltaSegments: [{ segment: prevSegment! }, { segment }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\n\t\t\t\t\tsegment.parent = undefined;\n\t\t\t\t\tsegment.trackingCollection.trackingGroups.forEach((tg) => tg.unlink(segment));\n\t\t\t\t} else {\n\t\t\t\t\tholdNodes.push(segment);\n\t\t\t\t\tprevSegment = segmentHasPositiveLength ? segment : undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t\tprevSegment = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"zamboni.js","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA6D;AAE7D,iDAA0D;AAE1D,2EAAuE;AACvE,2DAS6B;AAC7B,mDAAkD;AAErC,QAAA,kBAAkB,GAAG,CAAC,CAAC;AACpC,SAAS,SAAS,CAAC,IAAgB;IAClC,OAAO,IAAI,CAAC,UAAU,GAAG,mCAAe,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,SAAgB,eAAe,CAC9B,SAAoB,EACpB,uBAAuB,GAAG,0BAAkB;IAE5C,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE;QAC1C,OAAO;KACP;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAC,EAAE,EAAE;QACjD,IAAI,cAAc,GAAG,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC;QAC7D,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE;YAC7E,MAAM;SACN;QACD,cAAc,GAAG,SAAS,C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n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { MergeTreeMaintenanceType } from \"./mergeTreeDeltaCallback.js\";\nimport {\n\ttype MergeBlock,\n\tIMergeNode,\n\tISegment,\n\tMarker,\n\tMaxNodesInBlock,\n\tseqLTE,\n\ttoMoveInfo,\n\ttoRemovalInfo,\n} from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\n\nexport const zamboniSegmentsMax = 2;\nfunction underflow(node: MergeBlock) {\n\treturn node.childCount < MaxNodesInBlock / 2;\n}\n\nexport function zamboniSegments(\n\tmergeTree: MergeTree,\n\tzamboniSegmentsMaxCount = zamboniSegmentsMax,\n) {\n\tif (!mergeTree.collabWindow.collaborating) {\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < zamboniSegmentsMaxCount; i++) {\n\t\tlet segmentToScour = mergeTree.segmentsToScour.peek()?.value;\n\t\tif (!segmentToScour || segmentToScour.maxSeq > mergeTree.collabWindow.minSeq) {\n\t\t\tbreak;\n\t\t}\n\t\tsegmentToScour = mergeTree.segmentsToScour.get()!;\n\t\t// Only skip scouring if needs scour is explicitly false, not true or undefined\n\t\tif (segmentToScour?.segment?.parent && segmentToScour.segment.parent.needsScour !== false) {\n\t\t\tconst block = segmentToScour.segment.parent;\n\t\t\tconst childrenCopy: IMergeNode[] = [];\n\t\t\tscourNode(block, childrenCopy, mergeTree);\n\t\t\t// This will avoid the cost of re-scouring nodes\n\t\t\t// that have recently been scoured\n\t\t\tblock.needsScour = false;\n\n\t\t\tconst newChildCount = childrenCopy.length;\n\n\t\t\tif (newChildCount < block.childCount) {\n\t\t\t\tblock.childCount = newChildCount;\n\t\t\t\tblock.children = childrenCopy;\n\t\t\t\tfor (let j = 0; j < newChildCount; j++) {\n\t\t\t\t\tblock.assignChild(childrenCopy[j], j, false);\n\t\t\t\t}\n\n\t\t\t\tif (underflow(block) && block.parent) {\n\t\t\t\t\tpackParent(block.parent, mergeTree);\n\t\t\t\t} else {\n\t\t\t\t\tmergeTree.nodeUpdateOrdinals(block);\n\t\t\t\t\tmergeTree.blockUpdatePathLengths(block, UnassignedSequenceNumber, -1, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Interior node with all node children\nexport function packParent(parent: MergeBlock, mergeTree: MergeTree) {\n\tconst children = parent.children;\n\tlet childIndex: number;\n\tlet childBlock: MergeBlock;\n\tconst holdNodes: IMergeNode[] = [];\n\tfor (childIndex = 0; childIndex < parent.childCount; childIndex++) {\n\t\t// Debug assert not isLeaf()\n\t\tchildBlock = children[childIndex] as MergeBlock;\n\t\tscourNode(childBlock, holdNodes, mergeTree);\n\t\t// Will replace this block with a packed block\n\t\tchildBlock.parent = undefined;\n\t}\n\tif (holdNodes.length > 0) {\n\t\tconst totalNodeCount = holdNodes.length;\n\t\tconst halfOfMaxNodeCount = MaxNodesInBlock / 2;\n\t\tlet childCount = Math.min(\n\t\t\tMaxNodesInBlock - 1,\n\t\t\tMath.floor(totalNodeCount / halfOfMaxNodeCount),\n\t\t);\n\t\tif (childCount < 1) {\n\t\t\tchildCount = 1;\n\t\t}\n\t\tconst baseNodesInBlockCount = Math.floor(totalNodeCount / childCount);\n\t\tlet remainderCount = totalNodeCount % childCount;\n\t\tconst packedBlocks = new Array<MergeBlock>(MaxNodesInBlock);\n\t\tlet childrenPackedCount = 0;\n\t\tfor (let nodeIndex = 0; nodeIndex < childCount; nodeIndex++) {\n\t\t\tlet nodeCount = baseNodesInBlockCount;\n\t\t\tif (remainderCount > 0) {\n\t\t\t\tnodeCount++;\n\t\t\t\tremainderCount--;\n\t\t\t}\n\t\t\tconst packedBlock = mergeTree.makeBlock(nodeCount);\n\t\t\tfor (let packedNodeIndex = 0; packedNodeIndex < nodeCount; packedNodeIndex++) {\n\t\t\t\tconst nodeToPack = holdNodes[childrenPackedCount++];\n\t\t\t\tpackedBlock.assignChild(nodeToPack, packedNodeIndex, false);\n\t\t\t}\n\t\t\tpackedBlock.parent = parent;\n\t\t\tpackedBlocks[nodeIndex] = packedBlock;\n\t\t\tmergeTree.nodeUpdateLengthNewStructure(packedBlock);\n\t\t}\n\t\tparent.children = packedBlocks;\n\t\tfor (let j = 0; j < childCount; j++) {\n\t\t\tparent.assignChild(packedBlocks[j], j, false);\n\t\t}\n\t\tparent.childCount = childCount;\n\t} else {\n\t\tparent.children = [];\n\t\tparent.childCount = 0;\n\t}\n\tif (underflow(parent) && parent.parent) {\n\t\tpackParent(parent.parent, mergeTree);\n\t} else {\n\t\tmergeTree.nodeUpdateOrdinals(parent);\n\t\tmergeTree.blockUpdatePathLengths(parent, UnassignedSequenceNumber, -1, true);\n\t}\n}\n\nfunction scourNode(node: MergeBlock, holdNodes: IMergeNode[], mergeTree: MergeTree) {\n\t// The previous segment is tracked while scouring for the purposes of merging adjacent segments\n\t// when possible.\n\tlet prevSegment: ISegment | undefined;\n\tfor (let k = 0; k < node.childCount; k++) {\n\t\tconst childNode = node.children[k];\n\t\tif (!childNode.isLeaf() || !childNode.segmentGroups.empty) {\n\t\t\tholdNodes.push(childNode);\n\t\t\tprevSegment = undefined;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst segment = childNode;\n\t\tconst removalInfo = toRemovalInfo(segment);\n\t\tconst moveInfo = toMoveInfo(segment);\n\t\tif (removalInfo !== undefined || moveInfo !== undefined) {\n\t\t\t// If the segment's removal is below the MSN and it's not being held onto by a tracking group,\n\t\t\t// it can be unlinked (i.e. removed from the merge-tree)\n\t\t\tif (\n\t\t\t\t((!!removalInfo && seqLTE(removalInfo.removedSeq, mergeTree.collabWindow.minSeq)) ||\n\t\t\t\t\t(!!moveInfo && seqLTE(moveInfo.movedSeq, mergeTree.collabWindow.minSeq))) &&\n\t\t\t\tsegment.trackingCollection.empty\n\t\t\t) {\n\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: MergeTreeMaintenanceType.UNLINK,\n\t\t\t\t\t\tdeltaSegments: [{ segment }],\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\n\t\t\t\tsegment.parent = undefined;\n\n\t\t\t\tif (Marker.is(segment)) {\n\t\t\t\t\tmergeTree.unlinkMarker(segment);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t}\n\n\t\t\tprevSegment = undefined;\n\t\t} else {\n\t\t\tif (segment.seq! <= mergeTree.collabWindow.minSeq) {\n\t\t\t\tconst segmentHasPositiveLength = (mergeTree.localNetLength(segment) ?? 0) > 0;\n\t\t\t\tconst canAppend =\n\t\t\t\t\tprevSegment?.canAppend(segment) &&\n\t\t\t\t\tmatchProperties(prevSegment.properties, segment.properties) &&\n\t\t\t\t\tprevSegment.trackingCollection.matches(segment.trackingCollection) &&\n\t\t\t\t\tsegmentHasPositiveLength;\n\n\t\t\t\tif (canAppend) {\n\t\t\t\t\tprevSegment!.append(segment);\n\t\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: MergeTreeMaintenanceType.APPEND,\n\t\t\t\t\t\t\tdeltaSegments: [{ segment: prevSegment! }, { segment }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\n\t\t\t\t\tsegment.parent = undefined;\n\t\t\t\t\tsegment.trackingCollection.trackingGroups.forEach((tg) => tg.unlink(segment));\n\t\t\t\t} else {\n\t\t\t\t\tholdNodes.push(segment);\n\t\t\t\t\tprevSegment = segmentHasPositiveLength ? segment : undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t\tprevSegment = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/internal.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from "./lib/index.js";
|
package/legacy.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from "./lib/legacy.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeTreeTextHelper.d.ts","sourceRoot":"","sources":["../src/MergeTreeTextHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"MergeTreeTextHelper.d.ts","sourceRoot":"","sources":["../src/MergeTreeTextHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AASrE,qBAAa,mBAAoB,YAAW,oBAAoB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAE1C,OAAO,CACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,SAAK,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAiBb,OAAO,CAAC,aAAa;CAYrB"}
|
|
@@ -1 +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I,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;SACjC;aAAM;YACN,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;YACnC,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SACzD;KACD;SAAM,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,MAAM,eAAe;QACpB,gEAAgE;QAChE,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjF,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IIntegerRange } from \"./client.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"MergeTreeTextHelper.js","sourceRoot":"","sources":["../src/MergeTreeTextHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,gDAAgD;AAChD,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQrE,gDAAgD;AAChD,MAAM,OAAO,mBAAmB;IAC/B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE9C,OAAO,CACb,MAAc,EACd,QAAgB,E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G,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SACzD;KACD;SAAM,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,MAAM,eAAe;QACpB,gEAAgE;QAChE,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjF,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IIntegerRange } from \"./client.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { IMergeTreeTextHelper, TextSegment } from \"./textSegment.js\";\n\ninterface ITextAccumulator {\n\ttextSegment: TextSegment;\n\tplaceholder?: string;\n\tparallelArrays?: boolean;\n}\n\n// eslint-disable-next-line import/no-deprecated\nexport class MergeTreeTextHelper implements IMergeTreeTextHelper {\n\tconstructor(private readonly mergeTree: MergeTree) {}\n\n\tpublic getText(\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tplaceholder = \"\",\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tconst range = this.getValidRange(start, end, refSeq, clientId);\n\n\t\tconst accum: ITextAccumulator = { textSegment: new TextSegment(\"\"), placeholder };\n\n\t\tthis.mergeTree.mapRange<ITextAccumulator>(\n\t\t\tgatherText,\n\t\t\trefSeq,\n\t\t\tclientId,\n\t\t\taccum,\n\t\t\trange.start,\n\t\t\trange.end,\n\t\t);\n\t\treturn accum.textSegment.text;\n\t}\n\n\tprivate getValidRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t): IIntegerRange {\n\t\tconst range: IIntegerRange = {\n\t\t\tend: end ?? this.mergeTree.getLength(refSeq, clientId),\n\t\t\tstart: start ?? 0,\n\t\t};\n\t\treturn range;\n\t}\n}\n\nfunction gatherText(\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\t{ textSegment, placeholder }: ITextAccumulator,\n): boolean {\n\tif (TextSegment.is(segment)) {\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else if (placeholder && placeholder.length > 0) {\n\t\tconst placeholderText =\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\tplaceholder === \"*\" ? `\\n${segment}` : placeholder.repeat(segment.cachedLength);\n\t\ttextSegment.text += placeholderText;\n\t}\n\n\treturn true;\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 { AttributionKey } from "@fluidframework/runtime-definitions";
|
|
5
|
+
import { AttributionKey } from "@fluidframework/runtime-definitions/internal";
|
|
6
6
|
import { ISegment } from "./mergeTreeNodes.js";
|
|
7
7
|
/**
|
|
8
8
|
* @alpha
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributionCollection.d.ts","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,cAAc,EAGd,MAAM,
|
|
1
|
+
{"version":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M,EAAE,MAAM,GAAG,cAAc;IAC3C,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAU/E,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,GAAG;IAKX,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB;IAsB3C,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IA2B1C,MAAM,IAAI,0BAA0B,CAAC,cAAc,CAAC;IAoBpD,KAAK,IAAI,qBAAqB;IAc9B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,qBAAqB;IAkBtE;;OAEG;WACW,8BAA8B,CAC3C,QAAQ,EAAE,QAAQ,EAAE,EACpB,OAAO,EAAE,+BAA+B,GACtC,IAAI;IAuDP;;;;;OAKG;WACW,+BAA+B,CAC5C,QAAQ,EAAE,QAAQ,CAAC;QAClB,WAAW,CAAC,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;QACrD,YAAY,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,+BAA+B;CA8DlC"}
|
|
@@ -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 { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
5
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
6
6
|
// note: treats null and undefined as equivalent
|
|
7
7
|
export function areEqualAttributionKeys(
|
|
8
8
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4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AAI,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;wBAC5C,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;qBAC3D;oBACD,wBAAwB,GAAG,GAAG,CAAC;iBAC/B;gBAED,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;aAC7B;YAED,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACxD,CAAC,CAAC;QAEF,MAAM,YAAY,GAAG,sBAAsB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjE,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAwC,EAAE,CAAC;YACzD,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE;gBACnC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,sBAAsB,CACtD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7D,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;aAC1C;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport {\n\tAttributionKey,\n\tOpAttributionKey,\n\tDetachedAttributionKey,\n} from \"@fluidframework/runtime-definitions\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\n\n/**\n * @alpha\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t *\n\t * @example\n\t *\n\t * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string\n\t * between offsets 0 and 3 was inserted at seq 45 and the section of the string between\n\t * 3 and the length of the string was inserted at seq 46.\n\t *\n\t * @remarks We use null here rather than undefined as round-tripping through JSON converts\n\t * undefineds to null anyway\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @alpha\n */\nexport interface SerializedAttributionCollection extends SequenceOffsets {\n\tchannels?: { [name: string]: SequenceOffsets };\n\t/* Total length; only necessary for validation */\n\tlength: number;\n}\n\n/**\n * @alpha\n */\nexport interface IAttributionCollectionSpec<T> {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\troot: Iterable<{ offset: number; key: T | null }>;\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @alpha\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/***/\n\tserializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection;\n\n\t/**\n\t * Populates attribution information on segments using the provided summary.\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\n * @alpha\n */\nexport interface IAttributionCollection<T> {\n\t/**\n\t * Retrieves the attribution key associated with the provided offset.\n\t * @param channel - When specified, gets an attribution key associated with a particular channel.\n\t */\n\tgetAtOffset(offset: number, channel?: string): AttributionKey | undefined;\n\n\t/**\n\t * Total length of all attribution keys in this collection.\n\t */\n\treadonly length: number;\n\n\treadonly channelNames: Iterable<string>;\n\n\t/**\n\t * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that\n\t * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the\n\t * `i+1`th offset.\n\t * The last entry's key applies to the open interval from the last entry's offset to this collection's length.\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/***/\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/***/\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/***/\n\tclone(): IAttributionCollection<T>;\n\n\t/**\n\t * Updates this collection with new attribution data.\n\t * @param name - Name of the channel that requires an update. Undefined signifies the root channel.\n\t * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root\n\t * channel and 4 other channels, it should call `.update` 5 times).\n\t * @param channel - Updated collection for that channel.\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>): void;\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ta: AttributionKey | null | undefined,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tb: AttributionKey | null | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\n\tif (a.type !== b.type) {\n\t\treturn false;\n\t}\n\n\t// Note: TS can't narrow the type of b inside this switch statement, hence the need for casting.\n\tswitch (a.type) {\n\t\tcase \"op\":\n\t\t\treturn a.seq === (b as OpAttributionKey).seq;\n\t\tcase \"detached\":\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\tcase \"local\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\n\t}\n}\n\nexport class AttributionCollection implements IAttributionCollection<AttributionKey> {\n\tprivate offsets: number[] = [];\n\tprivate keys: (AttributionKey | null)[] = [];\n\n\tprivate channels?: { [name: string]: AttributionCollection };\n\n\tprivate get channelEntries(): [string, AttributionCollection][] {\n\t\treturn Object.entries(this.channels ?? {});\n\t}\n\n\tpublic constructor(\n\t\tprivate _length: number,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tbaseEntry?: AttributionKey | null,\n\t) {\n\t\tif (baseEntry !== undefined) {\n\t\t\tthis.offsets.push(0);\n\t\t\tthis.keys.push(baseEntry);\n\t\t}\n\t}\n\n\tpublic get channelNames(): string[] {\n\t\treturn Object.keys(this.channels ?? {});\n\t}\n\n\tpublic getAtOffset(offset: number): AttributionKey;\n\tpublic getAtOffset(offset: number, channel: string): AttributionKey | undefined;\n\tpublic getAtOffset(offset: number, channel?: string): AttributionKey | undefined {\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getAtOffset(offset);\n\t\t}\n\t\tassert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n\t\treturn this.get(this.findIndex(offset));\n\t}\n\n\tprivate findIndex(offset: number): number {\n\t\t// Note: maximum length here is 256 for text segments. Perf testing shows that linear scan beats binary search\n\t\t// for attribution collections with under ~64 entries, and even at maximum size (which would require a maximum\n\t\t// length segment with every offset having different attribution), getAtOffset is on the order of 100ns.\n\t\tlet i = 0;\n\t\twhile (i < this.offsets.length && offset > this.offsets[i]) {\n\t\t\ti++;\n\t\t}\n\t\treturn this.offsets[i] === offset ? i : i - 1;\n\t}\n\n\tprivate get(index: number): AttributionKey | undefined {\n\t\tconst key = this.keys[index];\n\t\treturn key ?? undefined;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._length;\n\t}\n\n\t/**\n\t * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n\t */\n\tpublic splitAt(pos: number): AttributionCollection {\n\t\tconst splitIndex = this.findIndex(pos);\n\t\tconst splitCollection = new AttributionCollection(this.length - pos);\n\t\tfor (let i = splitIndex; i < this.keys.length; i++) {\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i] - pos, 0));\n\t\t\tsplitCollection.keys.push(this.keys[i]);\n\t\t}\n\n\t\tif (this.channels) {\n\t\t\tsplitCollection.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tsplitCollection.channels[key] = collection.splitAt(pos);\n\t\t\t}\n\t\t}\n\n\t\tconst spliceIndex = this.offsets[splitIndex] === pos ? splitIndex : splitIndex + 1;\n\t\tthis.keys.splice(spliceIndex);\n\t\tthis.offsets.splice(spliceIndex);\n\t\tthis._length = pos;\n\t\treturn splitCollection;\n\t}\n\n\tpublic append(other: AttributionCollection): void {\n\t\tconst lastEntry = this.keys[this.keys.length - 1];\n\t\tfor (let i = 0; i < other.keys.length; i++) {\n\t\t\tif (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {\n\t\t\t\tthis.offsets.push(other.offsets[i] + this.length);\n\t\t\t\tthis.keys.push(other.keys[i]);\n\t\t\t}\n\t\t}\n\n\t\tif (other.channels !== undefined || this.channels !== undefined) {\n\t\t\tthis.channels ??= {};\n\t\t\tfor (const [key, collection] of other.channelEntries) {\n\t\t\t\tconst thisCollection = (this.channels[key] ??= new AttributionCollection(\n\t\t\t\t\tthis.length,\n\t\t\t\t\tnull,\n\t\t\t\t));\n\t\t\t\tthisCollection.append(collection);\n\t\t\t}\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tif (other.channels?.[key] === undefined) {\n\t\t\t\t\tcollection.append(new AttributionCollection(other.length, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._length += other.length;\n\t}\n\n\tpublic getAll(): IAttributionCollectionSpec<AttributionKey> {\n\t\ttype ExtractGeneric<T> = T extends Iterable<infer Q> ? Q : unknown;\n\t\tconst root: ExtractGeneric<IAttributionCollectionSpec<AttributionKey>[\"root\"]>[] =\n\t\t\tnew Array(this.keys.length);\n\t\tfor (let i = 0; i < this.keys.length; i++) {\n\t\t\troot[i] = { offset: this.offsets[i], key: this.keys[i] };\n\t\t}\n\t\tconst result: IAttributionCollectionSpec<AttributionKey> = {\n\t\t\troot,\n\t\t\tlength: this.length,\n\t\t};\n\t\tif (this.channels !== undefined) {\n\t\t\tresult.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tresult.channels[key] = collection.getAll().root;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic clone(): AttributionCollection {\n\t\tconst copy = new AttributionCollection(this.length);\n\t\tcopy.keys = this.keys.slice();\n\t\tcopy.offsets = this.offsets.slice();\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy: Record<string, AttributionCollection> = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tchannelsCopy[key] = collection.clone();\n\t\t\t}\n\t\t\tcopy.channels = channelsCopy;\n\t\t}\n\t\treturn copy;\n\t}\n\n\tpublic update(name: string | undefined, channel: AttributionCollection) {\n\t\tassert(\n\t\t\tchannel.length === this.length,\n\t\t\t0x5c0 /* AttributionCollection channel update should have consistent segment length */,\n\t\t);\n\t\tif (name === undefined) {\n\t\t\tthis.offsets = [...channel.offsets];\n\t\t\tthis.keys = [...channel.keys];\n\t\t} else {\n\t\t\tthis.channels ??= {};\n\t\t\tif (this.channels[name] !== undefined) {\n\t\t\t\tthis.channels[name].update(undefined, channel);\n\t\t\t} else {\n\t\t\t\tthis.channels[name] = channel;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n\t */\n\tpublic static populateAttributionCollections(\n\t\tsegments: ISegment[],\n\t\tsummary: SerializedAttributionCollection,\n\t): void {\n\t\tconst { channels } = summary;\n\t\tassert(\n\t\t\tsummary.seqs.length === summary.posBreakpoints.length,\n\t\t\t0x445 /* Invalid attribution summary blob provided */,\n\t\t);\n\n\t\tconst extractOntoSegments = (\n\t\t\t{ seqs, posBreakpoints }: SequenceOffsets,\n\t\t\tassignToSegment: (collection: AttributionCollection, segment: ISegment) => void,\n\t\t) => {\n\t\t\tlet curIndex = 0;\n\t\t\tlet cumulativeSegPos = 0;\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tconst attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t\tconst pushEntry = (offset: number, seq: AttributionKey | number | null) => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\n\t\t\t\t\t\tseq === null ? null : typeof seq === \"object\" ? seq : { type: \"op\", seq },\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tif (posBreakpoints[curIndex] > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\twhile (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex] - cumulativeSegPos, 0);\n\t\t\t\t\tpushEntry(nextOffset, seqs[curIndex]);\n\t\t\t\t\tcurIndex++;\n\t\t\t\t}\n\n\t\t\t\tif (attribution.offsets.length === 0) {\n\t\t\t\t\tpushEntry(0, seqs[curIndex - 1]);\n\t\t\t\t}\n\n\t\t\t\tassignToSegment(attribution, segment);\n\t\t\t\tcumulativeSegPos += segment.cachedLength;\n\t\t\t}\n\t\t};\n\n\t\textractOntoSegments(summary, (collection, segment) => {\n\t\t\tsegment.attribution = collection;\n\t\t});\n\t\tif (channels) {\n\t\t\tfor (const [name, collectionSpec] of Object.entries(channels)) {\n\t\t\t\textractOntoSegments(collectionSpec, (collection, segment) => {\n\t\t\t\t\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\tcollection;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n\t *\n\t * Note: this operates on segments rather than attribution collections directly so that it can handle cases\n\t * where only some segments have attribution defined.\n\t */\n\tpublic static serializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection {\n\t\tconst allCollectionSpecs: IAttributionCollectionSpec<AttributionKey>[] = [];\n\n\t\tconst allChannelNames = new Set<string>();\n\t\tfor (const segment of segments) {\n\t\t\tconst collection =\n\t\t\t\tsegment.attribution ?? new AttributionCollection(segment.cachedLength, null);\n\t\t\tconst spec = collection.getAll();\n\t\t\tallCollectionSpecs.push(spec);\n\t\t\tif (spec.channels) {\n\t\t\t\tfor (const name of Object.keys(spec.channels)) {\n\t\t\t\t\tallChannelNames.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extractSequenceOffsets = (\n\t\t\tgetSpecEntries: (\n\t\t\t\tspec: IAttributionCollectionSpec<AttributionKey>,\n\t\t\t) => Iterable<{ offset: number; key: AttributionKey | null }>,\n\t\t): SerializedAttributionCollection => {\n\t\t\tconst posBreakpoints: number[] = [];\n\t\t\tconst seqs: (number | AttributionKey | null)[] = [];\n\t\t\tlet mostRecentAttributionKey: AttributionKey | null | undefined;\n\t\t\tlet cumulativePos = 0;\n\n\t\t\tfor (const spec of allCollectionSpecs) {\n\t\t\t\tfor (const { offset, key } of getSpecEntries(spec)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tkey?.type !== \"local\",\n\t\t\t\t\t\t0x5c1 /* local attribution keys should never be put in summaries */,\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tmostRecentAttributionKey === undefined ||\n\t\t\t\t\t\t!areEqualAttributionKeys(key, mostRecentAttributionKey)\n\t\t\t\t\t) {\n\t\t\t\t\t\tposBreakpoints.push(offset + cumulativePos);\n\t\t\t\t\t\tseqs.push(!key ? null : key.type === \"op\" ? key.seq : key);\n\t\t\t\t\t}\n\t\t\t\t\tmostRecentAttributionKey = key;\n\t\t\t\t}\n\n\t\t\t\tcumulativePos += spec.length;\n\t\t\t}\n\n\t\t\treturn { seqs, posBreakpoints, length: cumulativePos };\n\t\t};\n\n\t\tconst blobContents = extractSequenceOffsets((spec) => spec.root);\n\t\tif (allChannelNames.size > 0) {\n\t\t\tconst channels: { [name: string]: SequenceOffsets } = {};\n\t\t\tfor (const name of allChannelNames) {\n\t\t\t\tconst { posBreakpoints, seqs } = extractSequenceOffsets(\n\t\t\t\t\t(spec) => spec.channels?.[name] ?? [{ offset: 0, key: null }],\n\t\t\t\t);\n\t\t\t\tchannels[name] = { posBreakpoints, seqs };\n\t\t\t}\n\t\t\tblobContents.channels = channels;\n\t\t}\n\n\t\treturn blobContents;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAoH9E,gDAAgD;AAChD,MAAM,UAAU,uBAAuB;AACtC,kDAAkD;AAClD,CAAoC;AACpC,kDAAkD;AAClD,CAAoC;IAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,IAAI,CAAC;KACZ;IAED,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,KAAK,CAAC;KACb;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE;QACtB,OAAO,KAAK,CAAC;KACb;IAED,gGAAgG;IAChG,QAAQ,CAAC,CAAC,IAAI,EAAE;QACf,KAAK,IAAI;YACR,OAAO,CAAC,CAAC,GAAG,KAAM,CAAsB,CAAC,GAAG,CAAC;QAC9C,KAAK,UAAU;YACd,OAAO,CAAC,CAAC,EAAE,KAAM,CAA4B,CAAC,EAAE,CAAC;QAClD,KAAK,OAAO;YACX,OAAO,IAAI,CAAC;QACb;YACC,eAAe,CAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;KACrD;AACF,CAAC;AAED,MAAM,OAAO,qBAAqB;IAMjC,IAAY,cAAc;QACzB,OAAO,MAAM,CAAC,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IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7D,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;aAC1C;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAttributionKey,\n\tDetachedAttributionKey,\n\tOpAttributionKey,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { ISegment } from \"./mergeTreeNodes.js\";\n\n/**\n * @alpha\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t *\n\t * @example\n\t *\n\t * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string\n\t * between offsets 0 and 3 was inserted at seq 45 and the section of the string between\n\t * 3 and the length of the string was inserted at seq 46.\n\t *\n\t * @remarks We use null here rather than undefined as round-tripping through JSON converts\n\t * undefineds to null anyway\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @alpha\n */\nexport interface SerializedAttributionCollection extends SequenceOffsets {\n\tchannels?: { [name: string]: SequenceOffsets };\n\t/* Total length; only necessary for validation */\n\tlength: number;\n}\n\n/**\n * @alpha\n */\nexport interface IAttributionCollectionSpec<T> {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\troot: Iterable<{ offset: number; key: T | null }>;\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @alpha\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/***/\n\tserializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection;\n\n\t/**\n\t * Populates attribution information on segments using the provided summary.\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\n * @alpha\n */\nexport interface IAttributionCollection<T> {\n\t/**\n\t * Retrieves the attribution key associated with the provided offset.\n\t * @param channel - When specified, gets an attribution key associated with a particular channel.\n\t */\n\tgetAtOffset(offset: number, channel?: string): AttributionKey | undefined;\n\n\t/**\n\t * Total length of all attribution keys in this collection.\n\t */\n\treadonly length: number;\n\n\treadonly channelNames: Iterable<string>;\n\n\t/**\n\t * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that\n\t * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the\n\t * `i+1`th offset.\n\t * The last entry's key applies to the open interval from the last entry's offset to this collection's length.\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/***/\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/***/\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/***/\n\tclone(): IAttributionCollection<T>;\n\n\t/**\n\t * Updates this collection with new attribution data.\n\t * @param name - Name of the channel that requires an update. Undefined signifies the root channel.\n\t * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root\n\t * channel and 4 other channels, it should call `.update` 5 times).\n\t * @param channel - Updated collection for that channel.\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>): void;\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ta: AttributionKey | null | undefined,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tb: AttributionKey | null | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\n\tif (a.type !== b.type) {\n\t\treturn false;\n\t}\n\n\t// Note: TS can't narrow the type of b inside this switch statement, hence the need for casting.\n\tswitch (a.type) {\n\t\tcase \"op\":\n\t\t\treturn a.seq === (b as OpAttributionKey).seq;\n\t\tcase \"detached\":\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\tcase \"local\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\n\t}\n}\n\nexport class AttributionCollection implements IAttributionCollection<AttributionKey> {\n\tprivate offsets: number[] = [];\n\tprivate keys: (AttributionKey | null)[] = [];\n\n\tprivate channels?: { [name: string]: AttributionCollection };\n\n\tprivate get channelEntries(): [string, AttributionCollection][] {\n\t\treturn Object.entries(this.channels ?? {});\n\t}\n\n\tpublic constructor(\n\t\tprivate _length: number,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tbaseEntry?: AttributionKey | null,\n\t) {\n\t\tif (baseEntry !== undefined) {\n\t\t\tthis.offsets.push(0);\n\t\t\tthis.keys.push(baseEntry);\n\t\t}\n\t}\n\n\tpublic get channelNames(): string[] {\n\t\treturn Object.keys(this.channels ?? {});\n\t}\n\n\tpublic getAtOffset(offset: number): AttributionKey;\n\tpublic getAtOffset(offset: number, channel: string): AttributionKey | undefined;\n\tpublic getAtOffset(offset: number, channel?: string): AttributionKey | undefined {\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getAtOffset(offset);\n\t\t}\n\t\tassert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n\t\treturn this.get(this.findIndex(offset));\n\t}\n\n\tprivate findIndex(offset: number): number {\n\t\t// Note: maximum length here is 256 for text segments. Perf testing shows that linear scan beats binary search\n\t\t// for attribution collections with under ~64 entries, and even at maximum size (which would require a maximum\n\t\t// length segment with every offset having different attribution), getAtOffset is on the order of 100ns.\n\t\tlet i = 0;\n\t\twhile (i < this.offsets.length && offset > this.offsets[i]) {\n\t\t\ti++;\n\t\t}\n\t\treturn this.offsets[i] === offset ? i : i - 1;\n\t}\n\n\tprivate get(index: number): AttributionKey | undefined {\n\t\tconst key = this.keys[index];\n\t\treturn key ?? undefined;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._length;\n\t}\n\n\t/**\n\t * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n\t */\n\tpublic splitAt(pos: number): AttributionCollection {\n\t\tconst splitIndex = this.findIndex(pos);\n\t\tconst splitCollection = new AttributionCollection(this.length - pos);\n\t\tfor (let i = splitIndex; i < this.keys.length; i++) {\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i] - pos, 0));\n\t\t\tsplitCollection.keys.push(this.keys[i]);\n\t\t}\n\n\t\tif (this.channels) {\n\t\t\tsplitCollection.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tsplitCollection.channels[key] = collection.splitAt(pos);\n\t\t\t}\n\t\t}\n\n\t\tconst spliceIndex = this.offsets[splitIndex] === pos ? splitIndex : splitIndex + 1;\n\t\tthis.keys.splice(spliceIndex);\n\t\tthis.offsets.splice(spliceIndex);\n\t\tthis._length = pos;\n\t\treturn splitCollection;\n\t}\n\n\tpublic append(other: AttributionCollection): void {\n\t\tconst lastEntry = this.keys[this.keys.length - 1];\n\t\tfor (let i = 0; i < other.keys.length; i++) {\n\t\t\tif (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {\n\t\t\t\tthis.offsets.push(other.offsets[i] + this.length);\n\t\t\t\tthis.keys.push(other.keys[i]);\n\t\t\t}\n\t\t}\n\n\t\tif (other.channels !== undefined || this.channels !== undefined) {\n\t\t\tthis.channels ??= {};\n\t\t\tfor (const [key, collection] of other.channelEntries) {\n\t\t\t\tconst thisCollection = (this.channels[key] ??= new AttributionCollection(\n\t\t\t\t\tthis.length,\n\t\t\t\t\tnull,\n\t\t\t\t));\n\t\t\t\tthisCollection.append(collection);\n\t\t\t}\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tif (other.channels?.[key] === undefined) {\n\t\t\t\t\tcollection.append(new AttributionCollection(other.length, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._length += other.length;\n\t}\n\n\tpublic getAll(): IAttributionCollectionSpec<AttributionKey> {\n\t\ttype ExtractGeneric<T> = T extends Iterable<infer Q> ? Q : unknown;\n\t\tconst root: ExtractGeneric<IAttributionCollectionSpec<AttributionKey>[\"root\"]>[] =\n\t\t\tnew Array(this.keys.length);\n\t\tfor (let i = 0; i < this.keys.length; i++) {\n\t\t\troot[i] = { offset: this.offsets[i], key: this.keys[i] };\n\t\t}\n\t\tconst result: IAttributionCollectionSpec<AttributionKey> = {\n\t\t\troot,\n\t\t\tlength: this.length,\n\t\t};\n\t\tif (this.channels !== undefined) {\n\t\t\tresult.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tresult.channels[key] = collection.getAll().root;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic clone(): AttributionCollection {\n\t\tconst copy = new AttributionCollection(this.length);\n\t\tcopy.keys = this.keys.slice();\n\t\tcopy.offsets = this.offsets.slice();\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy: Record<string, AttributionCollection> = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tchannelsCopy[key] = collection.clone();\n\t\t\t}\n\t\t\tcopy.channels = channelsCopy;\n\t\t}\n\t\treturn copy;\n\t}\n\n\tpublic update(name: string | undefined, channel: AttributionCollection) {\n\t\tassert(\n\t\t\tchannel.length === this.length,\n\t\t\t0x5c0 /* AttributionCollection channel update should have consistent segment length */,\n\t\t);\n\t\tif (name === undefined) {\n\t\t\tthis.offsets = [...channel.offsets];\n\t\t\tthis.keys = [...channel.keys];\n\t\t} else {\n\t\t\tthis.channels ??= {};\n\t\t\tif (this.channels[name] !== undefined) {\n\t\t\t\tthis.channels[name].update(undefined, channel);\n\t\t\t} else {\n\t\t\t\tthis.channels[name] = channel;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n\t */\n\tpublic static populateAttributionCollections(\n\t\tsegments: ISegment[],\n\t\tsummary: SerializedAttributionCollection,\n\t): void {\n\t\tconst { channels } = summary;\n\t\tassert(\n\t\t\tsummary.seqs.length === summary.posBreakpoints.length,\n\t\t\t0x445 /* Invalid attribution summary blob provided */,\n\t\t);\n\n\t\tconst extractOntoSegments = (\n\t\t\t{ seqs, posBreakpoints }: SequenceOffsets,\n\t\t\tassignToSegment: (collection: AttributionCollection, segment: ISegment) => void,\n\t\t) => {\n\t\t\tlet curIndex = 0;\n\t\t\tlet cumulativeSegPos = 0;\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tconst attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t\tconst pushEntry = (offset: number, seq: AttributionKey | number | null) => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\n\t\t\t\t\t\tseq === null ? null : typeof seq === \"object\" ? seq : { type: \"op\", seq },\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tif (posBreakpoints[curIndex] > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\twhile (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex] - cumulativeSegPos, 0);\n\t\t\t\t\tpushEntry(nextOffset, seqs[curIndex]);\n\t\t\t\t\tcurIndex++;\n\t\t\t\t}\n\n\t\t\t\tif (attribution.offsets.length === 0) {\n\t\t\t\t\tpushEntry(0, seqs[curIndex - 1]);\n\t\t\t\t}\n\n\t\t\t\tassignToSegment(attribution, segment);\n\t\t\t\tcumulativeSegPos += segment.cachedLength;\n\t\t\t}\n\t\t};\n\n\t\textractOntoSegments(summary, (collection, segment) => {\n\t\t\tsegment.attribution = collection;\n\t\t});\n\t\tif (channels) {\n\t\t\tfor (const [name, collectionSpec] of Object.entries(channels)) {\n\t\t\t\textractOntoSegments(collectionSpec, (collection, segment) => {\n\t\t\t\t\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\tcollection;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n\t *\n\t * Note: this operates on segments rather than attribution collections directly so that it can handle cases\n\t * where only some segments have attribution defined.\n\t */\n\tpublic static serializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection {\n\t\tconst allCollectionSpecs: IAttributionCollectionSpec<AttributionKey>[] = [];\n\n\t\tconst allChannelNames = new Set<string>();\n\t\tfor (const segment of segments) {\n\t\t\tconst collection =\n\t\t\t\tsegment.attribution ?? new AttributionCollection(segment.cachedLength, null);\n\t\t\tconst spec = collection.getAll();\n\t\t\tallCollectionSpecs.push(spec);\n\t\t\tif (spec.channels) {\n\t\t\t\tfor (const name of Object.keys(spec.channels)) {\n\t\t\t\t\tallChannelNames.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extractSequenceOffsets = (\n\t\t\tgetSpecEntries: (\n\t\t\t\tspec: IAttributionCollectionSpec<AttributionKey>,\n\t\t\t) => Iterable<{ offset: number; key: AttributionKey | null }>,\n\t\t): SerializedAttributionCollection => {\n\t\t\tconst posBreakpoints: number[] = [];\n\t\t\tconst seqs: (number | AttributionKey | null)[] = [];\n\t\t\tlet mostRecentAttributionKey: AttributionKey | null | undefined;\n\t\t\tlet cumulativePos = 0;\n\n\t\t\tfor (const spec of allCollectionSpecs) {\n\t\t\t\tfor (const { offset, key } of getSpecEntries(spec)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tkey?.type !== \"local\",\n\t\t\t\t\t\t0x5c1 /* local attribution keys should never be put in summaries */,\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tmostRecentAttributionKey === undefined ||\n\t\t\t\t\t\t!areEqualAttributionKeys(key, mostRecentAttributionKey)\n\t\t\t\t\t) {\n\t\t\t\t\t\tposBreakpoints.push(offset + cumulativePos);\n\t\t\t\t\t\tseqs.push(!key ? null : key.type === \"op\" ? key.seq : key);\n\t\t\t\t\t}\n\t\t\t\t\tmostRecentAttributionKey = key;\n\t\t\t\t}\n\n\t\t\t\tcumulativePos += spec.length;\n\t\t\t}\n\n\t\t\treturn { seqs, posBreakpoints, length: cumulativePos };\n\t\t};\n\n\t\tconst blobContents = extractSequenceOffsets((spec) => spec.root);\n\t\tif (allChannelNames.size > 0) {\n\t\t\tconst channels: { [name: string]: SequenceOffsets } = {};\n\t\t\tfor (const name of allChannelNames) {\n\t\t\t\tconst { posBreakpoints, seqs } = extractSequenceOffsets(\n\t\t\t\t\t(spec) => spec.channels?.[name] ?? [{ offset: 0, key: null }],\n\t\t\t\t);\n\t\t\t\tchannels[name] = { posBreakpoints, seqs };\n\t\t\t}\n\t\t\tblobContents.channels = channels;\n\t\t}\n\n\t\treturn blobContents;\n\t}\n}\n"]}
|
|
@@ -23,14 +23,14 @@ export declare function createInsertOnlyAttributionPolicy(): AttributionPolicy;
|
|
|
23
23
|
* const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, "bold");
|
|
24
24
|
* const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, "italic");
|
|
25
25
|
* ```
|
|
26
|
-
* @
|
|
26
|
+
* @internal
|
|
27
27
|
*/
|
|
28
28
|
export declare function createPropertyTrackingAttributionPolicyFactory(...propNames: string[]): () => AttributionPolicy;
|
|
29
29
|
/**
|
|
30
30
|
* Creates an attribution policy which tracks insertion as well as annotation of certain property names.
|
|
31
31
|
* This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and
|
|
32
32
|
* {@link createInsertOnlyAttributionPolicy}: see there for more details.
|
|
33
|
-
* @
|
|
33
|
+
* @internal
|
|
34
34
|
*/
|
|
35
35
|
export declare function createPropertyTrackingAndInsertionAttributionPolicyFactory(...propNames: string[]): () => AttributionPolicy;
|
|
36
36
|
//# sourceMappingURL=attributionPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributionPolicy.d.ts","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"attributionPolicy.d.ts","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA0LnD;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,iBAAiB,CAOrE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,8CAA8C,CAC7D,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,0DAA0D,CACzE,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CASzB"}
|
package/lib/attributionPolicy.js
CHANGED
|
@@ -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 { assert } from "@fluidframework/core-utils";
|
|
5
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { AttributionCollection } from "./attributionCollection.js";
|
|
6
7
|
import { MergeTreeMaintenanceType, } from "./mergeTreeDeltaCallback.js";
|
|
7
8
|
import { MergeTreeDeltaType } from "./ops.js";
|
|
8
|
-
import { AttributionCollection } from "./attributionCollection.js";
|
|
9
9
|
function createAttributionPolicyFromCallbacks({ delta, maintenance, }) {
|
|
10
10
|
let unsubscribe;
|
|
11
11
|
return {
|
|
@@ -136,7 +136,7 @@ export function createInsertOnlyAttributionPolicy() {
|
|
|
136
136
|
* const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, "bold");
|
|
137
137
|
* const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, "italic");
|
|
138
138
|
* ```
|
|
139
|
-
* @
|
|
139
|
+
* @internal
|
|
140
140
|
*/
|
|
141
141
|
export function createPropertyTrackingAttributionPolicyFactory(...propNames) {
|
|
142
142
|
return () => createAttributionPolicyFromCallbacks(combineMergeTreeCallbacks([
|
|
@@ -148,7 +148,7 @@ export function createPropertyTrackingAttributionPolicyFactory(...propNames) {
|
|
|
148
148
|
* Creates an attribution policy which tracks insertion as well as annotation of certain property names.
|
|
149
149
|
* This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and
|
|
150
150
|
* {@link createInsertOnlyAttributionPolicy}: see there for more details.
|
|
151
|
-
* @
|
|
151
|
+
* @internal
|
|
152
152
|
*/
|
|
153
153
|
export function createPropertyTrackingAndInsertionAttributionPolicyFactory(...propNames) {
|
|
154
154
|
return () => createAttributionPolicyFromCallbacks(combineMergeTreeCallbacks([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAMpD,OAAO,EAKN,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAoBnE,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW,GACW;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,gDAAgD;QAChD,MAAM,EAA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AC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,8CAA8C,CAC7D,GAAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0DAA0D,CACzE,GAAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,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\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { AttributionPolicy } from \"./mergeTree.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\nimport { AttributionCollection } from \"./attributionCollection.js\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client) => {\n\t\t\tassert(\n\t\t\t\tunsubscribe === undefined,\n\t\t\t\t0x557 /* cannot attach to multiple clients at once */,\n\t\t\t);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = () => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: () => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached() {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\t// eslint-disable-next-line import/no-deprecated\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(...propNames: string[]): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op, sequencedMessage }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst isLocal = sequencedMessage === undefined;\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\top.props[propName] !== undefined &&\n\t\t\t\t\t// Local changes to the tracked property always take effect\n\t\t\t\t\t(isLocal ||\n\t\t\t\t\t\t// Acked changes only take effect if there isn't a pending local change\n\t\t\t\t\t\t(!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client) => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args) => callbacks.forEach(({ delta }) => delta(...args)),\n\t\tmaintenance: (...args) => callbacks.forEach(({ maintenance }) => maintenance(...args)),\n\t};\n}\n\n/**\n * @returns An {@link AttributionPolicy} which tracks only insertion of content.\n * @internal\n */\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @alpha\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @alpha\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,OAAO,EAKN,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAoB9C,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW,GACW;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,gDAAgD;QAChD,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE;YAC1B,MAAM,CACL,WAAW,KAAK,SAAS,EACzB,KAAK,CAAC,+CAA+C,CACrD,CAAC;YAEF,MAAM,eAAe,GAAkC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAC5E,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAClC,MAAM,qBAAqB,GAAwC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CACnF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAEnC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YACpC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;YAEhD,WAAW,GAAG,GAAG,EAAE;gBAClB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;gBACrC,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;YAClD,CAAC,CAAC;QACH,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACZ,WAAW,EAAE,EAAE,CAAC;YAChB,W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,yBAAyB,CAAC,SAAiC;IACnE,OAAO;QACN,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACpE,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;KACtF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAChD,OAAO,oCAAoC,CAC1C,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;KACpC,CAAC,CACF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,8CAA8C,CAC7D,GAAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0DAA0D,CACzE,GAAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,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\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { AttributionCollection } from \"./attributionCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\nimport { AttributionPolicy } from \"./mergeTree.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client) => {\n\t\t\tassert(\n\t\t\t\tunsubscribe === undefined,\n\t\t\t\t0x557 /* cannot attach to multiple clients at once */,\n\t\t\t);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = () => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: () => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached() {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\t// eslint-disable-next-line import/no-deprecated\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(...propNames: string[]): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op, sequencedMessage }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst isLocal = sequencedMessage === undefined;\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\top.props[propName] !== undefined &&\n\t\t\t\t\t// Local changes to the tracked property always take effect\n\t\t\t\t\t(isLocal ||\n\t\t\t\t\t\t// Acked changes only take effect if there isn't a pending local change\n\t\t\t\t\t\t(!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client) => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args) => callbacks.forEach(({ delta }) => delta(...args)),\n\t\tmaintenance: (...args) => callbacks.forEach(({ maintenance }) => maintenance(...args)),\n\t};\n}\n\n/**\n * @returns An {@link AttributionPolicy} which tracks only insertion of content.\n * @internal\n */\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @internal\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @internal\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
|
package/lib/client.d.ts
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
+
import { type IEventThisPlaceHolder, IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
|
|
7
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
|
-
import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
9
9
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
10
|
-
import {
|
|
10
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
11
11
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
12
12
|
import { LocalReferencePosition, SlidingPreference } from "./localReference.js";
|
|
13
|
+
import { IMergeTreeOptions } from "./mergeTree.js";
|
|
14
|
+
import type { IMergeTreeDeltaCallbackArgs, IMergeTreeDeltaOpArgs, IMergeTreeMaintenanceCallbackArgs } from "./mergeTreeDeltaCallback.js";
|
|
13
15
|
import { CollaborationWindow, ISegment, ISegmentAction, Marker, SegmentGroup } from "./mergeTreeNodes.js";
|
|
14
|
-
import { IJSONSegment, IMergeTreeAnnotateMsg, IMergeTreeGroupMsg, IMergeTreeInsertMsg,
|
|
16
|
+
import { IJSONSegment, IMergeTreeAnnotateMsg, IMergeTreeGroupMsg, IMergeTreeInsertMsg, IMergeTreeObliterateMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ReferenceType } from "./ops.js";
|
|
15
17
|
import { PropertySet } from "./properties.js";
|
|
16
|
-
import { IMergeTreeTextHelper } from "./textSegment.js";
|
|
17
18
|
import { ReferencePosition } from "./referencePositions.js";
|
|
18
|
-
import {
|
|
19
|
-
import { IMergeTreeDeltaCallbackArgs, IMergeTreeDeltaOpArgs, IMergeTreeMaintenanceCallbackArgs } from "./index.js";
|
|
19
|
+
import { IMergeTreeTextHelper } from "./textSegment.js";
|
|
20
20
|
/**
|
|
21
21
|
* A range [start, end)
|
|
22
22
|
* @internal
|