@fluidframework/sequence 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.204906
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 +95 -0
- package/README.md +130 -0
- package/api-extractor.json +1 -1
- package/api-report/sequence.api.md +717 -0
- package/dist/defaultMap.d.ts +1 -1
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +6 -6
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +22 -2
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +164 -16
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +174 -54
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +17 -3
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js +12 -6
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts +19 -2
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js +10 -5
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.d.ts +6 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.js +3 -0
- package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
- package/dist/intervalIndex/index.d.ts +4 -4
- package/dist/intervalIndex/index.d.ts.map +1 -1
- package/dist/intervalIndex/index.js +5 -1
- package/dist/intervalIndex/index.js.map +1 -1
- package/dist/intervalIndex/intervalIndex.d.ts +1 -0
- package/dist/intervalIndex/intervalIndex.d.ts.map +1 -1
- package/dist/intervalIndex/intervalIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +17 -6
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js +17 -4
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +5 -2
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +9 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +17 -3
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js +12 -8
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervalTree.d.ts +1 -1
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervals/interval.d.ts +4 -2
- package/dist/intervals/interval.d.ts.map +1 -1
- package/dist/intervals/interval.js +14 -5
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +51 -18
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +18 -10
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +28 -13
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +124 -43
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts +3 -15
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +11 -19
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence-alpha.d.ts +1587 -0
- package/dist/sequence-beta.d.ts +1507 -0
- package/dist/sequence-public.d.ts +1507 -0
- package/dist/sequence-untrimmed.d.ts +1759 -0
- package/dist/sequence.d.ts +8 -4
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +53 -48
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +4 -0
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +3 -0
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sequenceFactory.d.ts +3 -0
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/sequenceFactory.js +4 -1
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +5 -0
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +11 -9
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.d.ts +6 -3
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedSequence.js +10 -8
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts +17 -2
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +21 -7
- package/dist/sharedString.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/defaultMap.d.ts +1 -1
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +6 -6
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +22 -2
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +164 -16
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +172 -55
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts +17 -3
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js +12 -7
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts +19 -2
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointIndex.js +10 -6
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/idIntervalIndex.d.ts +6 -0
- package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -1
- package/lib/intervalIndex/idIntervalIndex.js +3 -0
- package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
- package/lib/intervalIndex/index.d.ts +4 -4
- package/lib/intervalIndex/index.d.ts.map +1 -1
- package/lib/intervalIndex/index.js +4 -4
- package/lib/intervalIndex/index.js.map +1 -1
- package/lib/intervalIndex/intervalIndex.d.ts +1 -0
- package/lib/intervalIndex/intervalIndex.d.ts.map +1 -1
- package/lib/intervalIndex/intervalIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +17 -6
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +18 -5
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +5 -2
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +9 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts +17 -3
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js +12 -9
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervalTree.d.ts +1 -1
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervals/interval.d.ts +4 -2
- package/lib/intervals/interval.d.ts.map +1 -1
- package/lib/intervals/interval.js +14 -5
- package/lib/intervals/interval.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +51 -18
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js +14 -6
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +28 -13
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js +125 -42
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts +3 -15
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +11 -19
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts +8 -4
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +56 -49
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +4 -0
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +3 -0
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sequenceFactory.d.ts +3 -0
- package/lib/sequenceFactory.d.ts.map +1 -1
- package/lib/sequenceFactory.js +4 -1
- package/lib/sequenceFactory.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +5 -0
- package/lib/sharedIntervalCollection.d.ts.map +1 -1
- package/lib/sharedIntervalCollection.js +11 -9
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.d.ts +6 -3
- package/lib/sharedSequence.d.ts.map +1 -1
- package/lib/sharedSequence.js +10 -8
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sharedString.d.ts +17 -2
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +21 -7
- package/lib/sharedString.js.map +1 -1
- package/package.json +31 -30
- package/src/defaultMapInterfaces.ts +22 -2
- package/src/index.ts +4 -1
- package/src/intervalCollection.ts +423 -82
- package/src/intervalIndex/endpointInRangeIndex.ts +23 -11
- package/src/intervalIndex/endpointIndex.ts +22 -9
- package/src/intervalIndex/idIntervalIndex.ts +7 -1
- package/src/intervalIndex/index.ts +12 -3
- package/src/intervalIndex/intervalIndex.ts +1 -0
- package/src/intervalIndex/overlappingIntervalsIndex.ts +40 -15
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +10 -1
- package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -1
- package/src/intervalIndex/startpointInRangeIndex.ts +23 -18
- package/src/intervals/interval.ts +35 -8
- package/src/intervals/intervalUtils.ts +61 -27
- package/src/intervals/sequenceInterval.ts +197 -47
- package/src/localValues.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +14 -36
- package/src/sequence.ts +14 -5
- package/src/sequenceDeltaEvent.ts +4 -0
- package/src/sequenceFactory.ts +4 -1
- package/src/sharedIntervalCollection.ts +5 -0
- package/src/sharedSequence.ts +6 -3
- package/src/sharedString.ts +25 -2
package/lib/revertibles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE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,CAAC,CAAC,KAAK,CAAC;YACtB,QAAQ,KAAK,EAAE;gBACd,KAAK,cAAc,CAAC,GAAG;oBACtB,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAChC,MAAM;gBACP,KAAK,cAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,cAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,cAAc,CAAC,gBAAgB;oBACnC,0BAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC5C,MAAM;gBACP,KAAK,cAAc,CAAC,eAAe;oBAClC,yBAAyB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC3C,MAAM;gBACP;oBACC,eAAe,CAAC,KAAK,CAAC,CAAC;aACxB;SACD;aAAM;YACN,+BAA+B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable no-bitwise */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tSortedSet,\n\tgetSlideToSegoff,\n} from \"@fluidframework/merge-tree\";\nimport { IntervalOpType, SequenceInterval } from \"./intervals\";\nimport { SharedString, SharedStringSegment } from \"./sharedString\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n *\n * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to\n * be set as true on the underlying merge tree in order to function correctly.\n *\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\ntype IntervalOpType = typeof IntervalOpType[keyof typeof IntervalOpType];\n\n/**\n * Data for undoing edits affecting Intervals.\n *\n * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to\n * be set as true on the underlying merge tree in order to function correctly.\n *\n * @alpha\n */\nexport type IntervalRevertible =\n\t| {\n\t\t\tevent: typeof IntervalOpType.CHANGE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.ADD;\n\t\t\tinterval: SequenceInterval;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.DELETE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.PROPERTY_CHANGED;\n\t\t\tinterval: SequenceInterval;\n\t\t\tpropertyDeltas: PropertySet;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.POSITION_REMOVE;\n\t\t\tintervals: {\n\t\t\t\tintervalId: string;\n\t\t\t\tlabel: string;\n\t\t\t\tstartOffset?: number; // interval start index within a removed range\n\t\t\t\tendOffset?: number; // interval end index within a removed range\n\t\t\t}[];\n\t\t\t// local refs used by IntervalOpType.CHANGE and DELETE revertibles\n\t\t\trevertibleRefs: {\n\t\t\t\trevertible: IntervalRevertible;\n\t\t\t\toffset: number;\n\t\t\t\tisStart: boolean;\n\t\t\t}[];\n\t\t\tmergeTreeRevertible: MergeTreeDeltaRevertible;\n\t };\n\ntype TypedRevertible<T extends IntervalRevertible[\"event\"]> = IntervalRevertible & { event: T };\n\nfunction getUpdatedIdFromInterval(interval: SequenceInterval): string {\n\tconst maybeId = interval.getIntervalId();\n\treturn getUpdatedId(maybeId);\n}\n\nfunction getUpdatedId(intervalId: string): string {\n\treturn idMap.get(intervalId) ?? intervalId;\n}\n\n/**\n * Create revertibles for adding an interval\n * @alpha\n */\nexport function appendAddIntervalToRevertibles(\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.ADD,\n\t\tinterval,\n\t});\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for deleting an interval\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: SharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment;\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst startRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tinterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tinterval.start.slidingPreference,\n\t);\n\tconst endRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tinterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tinterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.DELETE,\n\t\tinterval,\n\t\tstart: startRef,\n\t\tend: endRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for moving endpoints of an interval\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: SharedString,\n\tnewInterval: SequenceInterval,\n\tpreviousInterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = previousInterval.start.getSegment() as SharedStringSegment;\n\t// This logic is needed because the ReferenceType StayOnRemove cannot be used\n\t// on removed segments. This works for revertibles because the old position of the\n\t// interval within the removed segment is handled by the remove range revertible.\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst prevStartRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tpreviousInterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tpreviousInterval.start.slidingPreference,\n\t);\n\tconst prevEndRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tpreviousInterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tpreviousInterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.CHANGE,\n\t\tinterval: newInterval,\n\t\tstart: prevStartRef,\n\t\tend: prevEndRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for changing properties of an interval\n * @alpha\n */\nexport function appendIntervalPropertyChangedToRevertibles(\n\tinterval: SequenceInterval,\n\tdeltas: PropertySet,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.PROPERTY_CHANGED,\n\t\tinterval,\n\t\tpropertyDeltas: deltas,\n\t});\n\n\treturn revertibles;\n}\n\nfunction addIfIntervalEndpoint(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\tstartIntervals: { offset: number; interval: SequenceInterval }[],\n\tendIntervals: { offset: number; interval: SequenceInterval }[],\n) {\n\tif (refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tstartIntervals.push({ offset: segmentLengths + interval.start.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t} else if (refTypeIncludesFlag(ref.refType, ReferenceType.RangeEnd)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tendIntervals.push({ offset: segmentLengths + interval.end.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction addIfRevertibleRef(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\trevertibleRefs: {\n\t\trevertible: IntervalRevertible;\n\t\toffset: number;\n\t\tisStart: boolean;\n\t}[],\n) {\n\tconst revertible = ref.properties?.revertible;\n\tif (revertible) {\n\t\trevertibleRefs.push({\n\t\t\trevertible,\n\t\t\toffset: segmentLengths + ref.getOffset(),\n\t\t\tisStart: refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin),\n\t\t});\n\t}\n}\n\n/**\n * Create revertibles for SharedStringDeltas, handling indirectly modified intervals\n * (e.g. reverting remove of a range that contains an interval will move the interval back)\n *\n * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to\n * be set as true on the underlying merge tree in order to function correctly.\n *\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: SharedString,\n\tdelta: SequenceDeltaEvent,\n\trevertibles: SharedStringRevertible[],\n) {\n\tif (delta.ranges.length === 0) {\n\t\treturn;\n\t}\n\tif (delta.deltaOperation === MergeTreeDeltaType.REMOVE) {\n\t\tconst startIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst endIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst revertibleRefs: {\n\t\t\trevertible: IntervalRevertible;\n\t\t\toffset: number;\n\t\t\tisStart: boolean;\n\t\t}[] = [];\n\t\tlet segmentLengths = 0;\n\n\t\t// find interval endpoints in each segment\n\t\tfor (const deltaRange of delta.ranges) {\n\t\t\tconst refs = deltaRange.segment.localRefs;\n\t\t\tif (refs !== undefined && deltaRange.position !== -1) {\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\taddIfIntervalEndpoint(ref, segmentLengths, startIntervals, endIntervals);\n\t\t\t\t\taddIfRevertibleRef(ref, segmentLengths, revertibleRefs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegmentLengths += deltaRange.segment.cachedLength;\n\t\t}\n\n\t\tif (startIntervals.length > 0 || endIntervals.length > 0 || revertibleRefs.length > 0) {\n\t\t\tconst removeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t\t\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, removeRevertibles);\n\t\t\tassert(\n\t\t\t\tremoveRevertibles.length === 1,\n\t\t\t\t0x6c4 /* Remove revertible should be a single delta */,\n\t\t\t);\n\n\t\t\tconst revertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE> = {\n\t\t\t\tevent: IntervalOpType.POSITION_REMOVE,\n\t\t\t\tintervals: [],\n\t\t\t\trevertibleRefs,\n\t\t\t\tmergeTreeRevertible: removeRevertibles[0],\n\t\t\t};\n\n\t\t\t// add an interval for each startInterval, accounting for any corresponding endIntervals\n\t\t\tstartIntervals.forEach(({ interval, offset }) => {\n\t\t\t\t// find any corresponding end for this interval\n\t\t\t\tconst endIntervalIndex = endIntervals.findIndex((end) => {\n\t\t\t\t\treturn end.interval === interval;\n\t\t\t\t});\n\t\t\t\tlet endOffset: number | undefined;\n\t\t\t\tif (endIntervalIndex !== -1) {\n\t\t\t\t\tendOffset = endIntervals[endIntervalIndex].offset;\n\t\t\t\t\tendIntervals.splice(endIntervalIndex, 1);\n\t\t\t\t}\n\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tstartOffset: offset,\n\t\t\t\t\tendOffset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// add any remaining endIntervals that aren't matched with a startInterval\n\t\t\tendIntervals.forEach(({ interval, offset }) => {\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tendOffset: offset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\trevertibles.push(revertible);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Handle any merge tree delta that is not REMOVE or is REMOVE with no interval endpoints\n\tconst mergeTreeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t// Allow merging MergeTreeDeltaRevertible with previous\n\tif (revertibles.length > 0 && isMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])) {\n\t\tmergeTreeRevertibles.push(revertibles.pop() as MergeTreeDeltaRevertible);\n\t}\n\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, mergeTreeRevertibles);\n\trevertibles.push(...mergeTreeRevertibles);\n}\n\n/**\n * Clean up resources held by revertibles that are no longer needed.\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.forEach((r) => {\n\t\tif (isMergeTreeDeltaRevertible(r)) {\n\t\t\tdiscardMergeTreeDeltaRevertible([r]);\n\t\t} else if (r.event === IntervalOpType.CHANGE || r.event === IntervalOpType.DELETE) {\n\t\t\tsharedString.removeLocalReferencePosition(r.start);\n\t\t\tsharedString.removeLocalReferencePosition(r.end);\n\t\t}\n\t});\n}\n\nfunction getSlidePosition(string: SharedString, lref: LocalReferencePosition, pos: number): number {\n\tconst slide = getSlideToSegoff(\n\t\t{ segment: lref.getSegment(), offset: undefined },\n\t\tlref.slidingPreference,\n\t);\n\treturn slide?.segment !== undefined &&\n\t\tslide.offset !== undefined &&\n\t\tstring.getPosition(slide.segment) !== -1 &&\n\t\t(pos < 0 || pos >= string.getLength())\n\t\t? string.getPosition(slide.segment) + slide.offset\n\t\t: pos;\n}\n\nfunction isValidRange(start: number, end: number, string: SharedString) {\n\treturn (\n\t\tstart >= 0 &&\n\t\tstart < string.getLength() &&\n\t\tend >= 0 &&\n\t\tend < string.getLength() &&\n\t\tstart <= end\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.ADD>,\n) {\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tstring.getIntervalCollection(label).removeIntervalById(id);\n}\n\nfunction revertLocalDelete(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.DELETE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\tconst type = revertible.interval.intervalType;\n\t// reusing the id causes eventual consistency bugs, so it is removed here and recreated in add\n\tconst { intervalId, ...props } = revertible.interval.properties;\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tconst int = collection.add(startSlidePos, endSlidePos, type, props);\n\n\t\tidMap.forEach((newId, oldId) => {\n\t\t\tif (intervalId === newId) {\n\t\t\t\tidMap.set(oldId, getUpdatedIdFromInterval(int));\n\t\t\t}\n\t\t});\n\t\tidMap.set(intervalId, int.getIntervalId());\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalChange(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.CHANGE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tcollection.change(id, startSlidePos, endSlidePos);\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalPropertyChanged(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.PROPERTY_CHANGED>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst newProps = revertible.propertyDeltas;\n\tstring.getIntervalCollection(label).changeProperties(id, newProps);\n}\n\nfunction newPosition(offset: number | undefined, restoredRanges: SortedRangeSet) {\n\tif (offset === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet offsetFromSegment = offset;\n\tfor (const rangeInfo of restoredRanges.items) {\n\t\tif (offsetFromSegment < rangeInfo.length) {\n\t\t\t// find the segment inside the range\n\t\t\tfor (const range of rangeInfo.ranges) {\n\t\t\t\tif (range.segment.cachedLength > offsetFromSegment) {\n\t\t\t\t\treturn { segment: range.segment, offset: offsetFromSegment };\n\t\t\t\t}\n\t\t\t\toffsetFromSegment -= range.segment.cachedLength;\n\t\t\t}\n\t\t}\n\t\toffsetFromSegment -= rangeInfo.length;\n\t}\n\n\treturn undefined;\n}\n\nfunction newEndpointPosition(\n\toffset: number | undefined,\n\trestoredRanges: SortedRangeSet,\n\tsharedString: SharedString,\n) {\n\tconst pos = newPosition(offset, restoredRanges);\n\treturn pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;\n}\n\ninterface RangeInfo {\n\tranges: readonly Readonly<ISequenceDeltaRange<MergeTreeDeltaOperationType>>[];\n\tlength: number;\n}\n\nclass SortedRangeSet extends SortedSet<RangeInfo, string> {\n\tprotected getKey(item: RangeInfo): string {\n\t\treturn item.ranges[0].segment.ordinal;\n\t}\n}\n\nfunction revertLocalSequenceRemove(\n\tsharedString: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE>,\n) {\n\tconst restoredRanges = new SortedRangeSet();\n\tconst saveSegments = (event: SequenceDeltaEvent) => {\n\t\tif (event.ranges.length > 0) {\n\t\t\tlet length = 0;\n\t\t\tevent.ranges.forEach((range) => {\n\t\t\t\tlength += range.segment.cachedLength;\n\t\t\t});\n\t\t\trestoredRanges.addOrUpdate({ ranges: event.ranges, length });\n\t\t}\n\t};\n\tsharedString.on(\"sequenceDelta\", saveSegments);\n\trevertMergeTreeDeltaRevertibles(sharedString, [revertible.mergeTreeRevertible]);\n\tsharedString.off(\"sequenceDelta\", saveSegments);\n\n\trevertible.intervals.forEach((intervalInfo) => {\n\t\tconst intervalCollection = sharedString.getIntervalCollection(intervalInfo.label);\n\t\tconst intervalId = getUpdatedId(intervalInfo.intervalId);\n\t\tconst interval = intervalCollection.getIntervalById(intervalId);\n\t\tif (interval !== undefined) {\n\t\t\tconst newStart = newEndpointPosition(\n\t\t\t\tintervalInfo.startOffset,\n\t\t\t\trestoredRanges,\n\t\t\t\tsharedString,\n\t\t\t);\n\t\t\tconst newEnd = newEndpointPosition(\n\t\t\t\tintervalInfo.endOffset,\n\t\t\t\trestoredRanges,\n\t\t\t\tsharedString,\n\t\t\t);\n\t\t\t// only move interval if start <= end\n\t\t\tif (\n\t\t\t\t(newStart === undefined &&\n\t\t\t\t\tnewEnd !== undefined &&\n\t\t\t\t\tsharedString.localReferencePositionToPosition(interval.start) <= newEnd) ||\n\t\t\t\t(newEnd === undefined &&\n\t\t\t\t\tnewStart !== undefined &&\n\t\t\t\t\tsharedString.localReferencePositionToPosition(interval.end) >= newStart) ||\n\t\t\t\t(newStart !== undefined && newEnd !== undefined && newStart <= newEnd)\n\t\t\t) {\n\t\t\t\tintervalCollection.change(intervalId, newStart, newEnd);\n\t\t\t}\n\t\t}\n\t});\n\n\t// fix up the local references used by delete and change revertibles\n\trevertible.revertibleRefs.forEach((revertibleRef) => {\n\t\tassert(\n\t\t\trevertibleRef.revertible.event === IntervalOpType.CHANGE ||\n\t\t\t\trevertibleRef.revertible.event === IntervalOpType.DELETE,\n\t\t\t0x6c5 /* revertible is not delete or change */,\n\t\t);\n\t\tconst pos = newPosition(revertibleRef.offset, restoredRanges);\n\t\tif (pos !== undefined) {\n\t\t\tif (revertibleRef.isStart) {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.start);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeBegin,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.start = newRef;\n\t\t\t} else {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.end);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeEnd,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.end = newRef;\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Invoke revertibles to reverse prior edits\n *\n * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to\n * be set as true on the underlying merge tree in order to function correctly.\n *\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tif (\"event\" in r) {\n\t\t\tconst event = r.event;\n\t\t\tswitch (event) {\n\t\t\t\tcase IntervalOpType.ADD:\n\t\t\t\t\trevertLocalAdd(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.DELETE:\n\t\t\t\t\trevertLocalDelete(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.CHANGE:\n\t\t\t\t\trevertLocalChange(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.PROPERTY_CHANGED:\n\t\t\t\t\trevertLocalPropertyChanged(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.POSITION_REMOVE:\n\t\t\t\t\trevertLocalSequenceRemove(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(event);\n\t\t\t}\n\t\t} else {\n\t\t\trevertMergeTreeDeltaRevertibles(sharedString, [r]);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EACN,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAI1B,kBAAkB,EAElB,aAAa,EACb,mBAAmB,EACnB,+BAA+B,EAC/B,SAAS,EACT,gBAAgB,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAW/D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAkDxC,SAAS,wBAAwB,CAAC,QAA0B;IAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;IACzC,OA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AAC;SACnD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable no-bitwise */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tSortedSet,\n\tgetSlideToSegoff,\n} from \"@fluidframework/merge-tree\";\nimport { IntervalOpType, SequenceInterval } from \"./intervals\";\nimport { SharedString, SharedStringSegment } from \"./sharedString\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n *\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\ntype IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];\n\n/**\n * Data for undoing edits affecting Intervals.\n *\n * @alpha\n */\nexport type IntervalRevertible =\n\t| {\n\t\t\tevent: typeof IntervalOpType.CHANGE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.ADD;\n\t\t\tinterval: SequenceInterval;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.DELETE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.PROPERTY_CHANGED;\n\t\t\tinterval: SequenceInterval;\n\t\t\tpropertyDeltas: PropertySet;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.POSITION_REMOVE;\n\t\t\tintervals: {\n\t\t\t\tintervalId: string;\n\t\t\t\tlabel: string;\n\t\t\t\tstartOffset?: number; // interval start index within a removed range\n\t\t\t\tendOffset?: number; // interval end index within a removed range\n\t\t\t}[];\n\t\t\t// local refs used by IntervalOpType.CHANGE and DELETE revertibles\n\t\t\trevertibleRefs: {\n\t\t\t\trevertible: IntervalRevertible;\n\t\t\t\toffset: number;\n\t\t\t\tisStart: boolean;\n\t\t\t}[];\n\t\t\tmergeTreeRevertible: MergeTreeDeltaRevertible;\n\t };\n\ntype TypedRevertible<T extends IntervalRevertible[\"event\"]> = IntervalRevertible & { event: T };\n\nfunction getUpdatedIdFromInterval(interval: SequenceInterval): string {\n\tconst maybeId = interval.getIntervalId();\n\treturn getUpdatedId(maybeId);\n}\n\nfunction getUpdatedId(intervalId: string): string {\n\treturn idMap.get(intervalId) ?? intervalId;\n}\n\n/**\n * Create revertibles for adding an interval\n * @alpha\n */\nexport function appendAddIntervalToRevertibles(\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.ADD,\n\t\tinterval,\n\t});\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for deleting an interval\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: SharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment;\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst startRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tinterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tinterval.start.slidingPreference,\n\t);\n\tconst endRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tinterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tinterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.DELETE,\n\t\tinterval,\n\t\tstart: startRef,\n\t\tend: endRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for moving endpoints of an interval\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: SharedString,\n\tnewInterval: SequenceInterval,\n\tpreviousInterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = previousInterval.start.getSegment() as SharedStringSegment;\n\t// This logic is needed because the ReferenceType StayOnRemove cannot be used\n\t// on removed segments. This works for revertibles because the old position of the\n\t// interval within the removed segment is handled by the remove range revertible.\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst prevStartRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tpreviousInterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tpreviousInterval.start.slidingPreference,\n\t);\n\tconst prevEndRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tpreviousInterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tpreviousInterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.CHANGE,\n\t\tinterval: newInterval,\n\t\tstart: prevStartRef,\n\t\tend: prevEndRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for changing properties of an interval\n * @alpha\n */\nexport function appendIntervalPropertyChangedToRevertibles(\n\tinterval: SequenceInterval,\n\tdeltas: PropertySet,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.PROPERTY_CHANGED,\n\t\tinterval,\n\t\tpropertyDeltas: deltas,\n\t});\n\n\treturn revertibles;\n}\n\nfunction addIfIntervalEndpoint(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\tstartIntervals: { offset: number; interval: SequenceInterval }[],\n\tendIntervals: { offset: number; interval: SequenceInterval }[],\n) {\n\tif (refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tstartIntervals.push({ offset: segmentLengths + interval.start.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t} else if (refTypeIncludesFlag(ref.refType, ReferenceType.RangeEnd)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tendIntervals.push({ offset: segmentLengths + interval.end.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction addIfRevertibleRef(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\trevertibleRefs: {\n\t\trevertible: IntervalRevertible;\n\t\toffset: number;\n\t\tisStart: boolean;\n\t}[],\n) {\n\tconst revertible = ref.properties?.revertible;\n\tif (revertible) {\n\t\trevertibleRefs.push({\n\t\t\trevertible,\n\t\t\toffset: segmentLengths + ref.getOffset(),\n\t\t\tisStart: refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin),\n\t\t});\n\t}\n}\n\n/**\n * Create revertibles for SharedStringDeltas, handling indirectly modified intervals\n * (e.g. reverting remove of a range that contains an interval will move the interval back)\n *\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: SharedString,\n\tdelta: SequenceDeltaEvent,\n\trevertibles: SharedStringRevertible[],\n) {\n\tif (delta.ranges.length === 0) {\n\t\treturn;\n\t}\n\tif (delta.deltaOperation === MergeTreeDeltaType.REMOVE) {\n\t\tconst startIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst endIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst revertibleRefs: {\n\t\t\trevertible: IntervalRevertible;\n\t\t\toffset: number;\n\t\t\tisStart: boolean;\n\t\t}[] = [];\n\t\tlet segmentLengths = 0;\n\n\t\t// find interval endpoints in each segment\n\t\tfor (const deltaRange of delta.ranges) {\n\t\t\tconst refs = deltaRange.segment.localRefs;\n\t\t\tif (refs !== undefined && deltaRange.position !== -1) {\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\taddIfIntervalEndpoint(ref, segmentLengths, startIntervals, endIntervals);\n\t\t\t\t\taddIfRevertibleRef(ref, segmentLengths, revertibleRefs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegmentLengths += deltaRange.segment.cachedLength;\n\t\t}\n\n\t\tif (startIntervals.length > 0 || endIntervals.length > 0 || revertibleRefs.length > 0) {\n\t\t\tconst removeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t\t\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, removeRevertibles);\n\t\t\tassert(\n\t\t\t\tremoveRevertibles.length === 1,\n\t\t\t\t0x6c4 /* Remove revertible should be a single delta */,\n\t\t\t);\n\n\t\t\tconst revertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE> = {\n\t\t\t\tevent: IntervalOpType.POSITION_REMOVE,\n\t\t\t\tintervals: [],\n\t\t\t\trevertibleRefs,\n\t\t\t\tmergeTreeRevertible: removeRevertibles[0],\n\t\t\t};\n\n\t\t\t// add an interval for each startInterval, accounting for any corresponding endIntervals\n\t\t\tstartIntervals.forEach(({ interval, offset }) => {\n\t\t\t\t// find any corresponding end for this interval\n\t\t\t\tconst endIntervalIndex = endIntervals.findIndex((end) => {\n\t\t\t\t\treturn end.interval === interval;\n\t\t\t\t});\n\t\t\t\tlet endOffset: number | undefined;\n\t\t\t\tif (endIntervalIndex !== -1) {\n\t\t\t\t\tendOffset = endIntervals[endIntervalIndex].offset;\n\t\t\t\t\tendIntervals.splice(endIntervalIndex, 1);\n\t\t\t\t}\n\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tstartOffset: offset,\n\t\t\t\t\tendOffset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// add any remaining endIntervals that aren't matched with a startInterval\n\t\t\tendIntervals.forEach(({ interval, offset }) => {\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tendOffset: offset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\trevertibles.push(revertible);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Handle any merge tree delta that is not REMOVE or is REMOVE with no interval endpoints\n\tconst mergeTreeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t// Allow merging MergeTreeDeltaRevertible with previous\n\tif (revertibles.length > 0 && isMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])) {\n\t\tmergeTreeRevertibles.push(revertibles.pop() as MergeTreeDeltaRevertible);\n\t}\n\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, mergeTreeRevertibles);\n\trevertibles.push(...mergeTreeRevertibles);\n}\n\n/**\n * Clean up resources held by revertibles that are no longer needed.\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.forEach((r) => {\n\t\tif (isMergeTreeDeltaRevertible(r)) {\n\t\t\tdiscardMergeTreeDeltaRevertible([r]);\n\t\t} else if (r.event === IntervalOpType.CHANGE || r.event === IntervalOpType.DELETE) {\n\t\t\tsharedString.removeLocalReferencePosition(r.start);\n\t\t\tsharedString.removeLocalReferencePosition(r.end);\n\t\t}\n\t});\n}\n\nfunction getSlidePosition(string: SharedString, lref: LocalReferencePosition, pos: number): number {\n\tconst slide = getSlideToSegoff(\n\t\t{ segment: lref.getSegment(), offset: undefined },\n\t\tlref.slidingPreference,\n\t);\n\treturn slide?.segment !== undefined &&\n\t\tslide.offset !== undefined &&\n\t\tstring.getPosition(slide.segment) !== -1 &&\n\t\t(pos < 0 || pos >= string.getLength())\n\t\t? string.getPosition(slide.segment) + slide.offset\n\t\t: pos;\n}\n\nfunction isValidRange(start: number, end: number, string: SharedString) {\n\treturn (\n\t\tstart >= 0 &&\n\t\tstart < string.getLength() &&\n\t\tend >= 0 &&\n\t\tend < string.getLength() &&\n\t\tstart <= end\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.ADD>,\n) {\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tstring.getIntervalCollection(label).removeIntervalById(id);\n}\n\nfunction revertLocalDelete(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.DELETE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\t// reusing the id causes eventual consistency bugs, so it is removed here and recreated in add\n\tconst { intervalId, ...props } = revertible.interval.properties;\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tconst int = collection.add({\n\t\t\tstart: startSlidePos,\n\t\t\tend: endSlidePos,\n\t\t\tprops,\n\t\t});\n\n\t\tidMap.forEach((newId, oldId) => {\n\t\t\tif (intervalId === newId) {\n\t\t\t\tidMap.set(oldId, getUpdatedIdFromInterval(int));\n\t\t\t}\n\t\t});\n\t\tidMap.set(intervalId, int.getIntervalId());\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalChange(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.CHANGE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tcollection.change(id, startSlidePos, endSlidePos);\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalPropertyChanged(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.PROPERTY_CHANGED>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst newProps = revertible.propertyDeltas;\n\tstring.getIntervalCollection(label).changeProperties(id, newProps);\n}\n\nfunction newPosition(offset: number | undefined, restoredRanges: SortedRangeSet) {\n\tif (offset === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet offsetFromSegment = offset;\n\tfor (const rangeInfo of restoredRanges.items) {\n\t\tif (offsetFromSegment < rangeInfo.length) {\n\t\t\t// find the segment inside the range\n\t\t\tfor (const range of rangeInfo.ranges) {\n\t\t\t\tif (range.segment.cachedLength > offsetFromSegment) {\n\t\t\t\t\treturn { segment: range.segment, offset: offsetFromSegment };\n\t\t\t\t}\n\t\t\t\toffsetFromSegment -= range.segment.cachedLength;\n\t\t\t}\n\t\t}\n\t\toffsetFromSegment -= rangeInfo.length;\n\t}\n\n\treturn undefined;\n}\n\nfunction newEndpointPosition(\n\toffset: number | undefined,\n\trestoredRanges: SortedRangeSet,\n\tsharedString: SharedString,\n) {\n\tconst pos = newPosition(offset, restoredRanges);\n\treturn pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;\n}\n\ninterface RangeInfo {\n\tranges: readonly Readonly<ISequenceDeltaRange<MergeTreeDeltaOperationType>>[];\n\tlength: number;\n}\n\nclass SortedRangeSet extends SortedSet<RangeInfo, string> {\n\tprotected getKey(item: RangeInfo): string {\n\t\treturn item.ranges[0].segment.ordinal;\n\t}\n}\n\nfunction revertLocalSequenceRemove(\n\tsharedString: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE>,\n) {\n\tconst restoredRanges = new SortedRangeSet();\n\tconst saveSegments = (event: SequenceDeltaEvent) => {\n\t\tif (event.ranges.length > 0) {\n\t\t\tlet length = 0;\n\t\t\tevent.ranges.forEach((range) => {\n\t\t\t\tlength += range.segment.cachedLength;\n\t\t\t});\n\t\t\trestoredRanges.addOrUpdate({ ranges: event.ranges, length });\n\t\t}\n\t};\n\tsharedString.on(\"sequenceDelta\", saveSegments);\n\trevertMergeTreeDeltaRevertibles(sharedString, [revertible.mergeTreeRevertible]);\n\tsharedString.off(\"sequenceDelta\", saveSegments);\n\n\trevertible.intervals.forEach((intervalInfo) => {\n\t\tconst intervalCollection = sharedString.getIntervalCollection(intervalInfo.label);\n\t\tconst intervalId = getUpdatedId(intervalInfo.intervalId);\n\t\tconst interval = intervalCollection.getIntervalById(intervalId);\n\t\tif (interval !== undefined) {\n\t\t\tconst start =\n\t\t\t\tnewEndpointPosition(intervalInfo.startOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.start);\n\t\t\tconst end =\n\t\t\t\tnewEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.end);\n\t\t\tif (start <= end) {\n\t\t\t\tintervalCollection.change(intervalId, start, end);\n\t\t\t}\n\t\t}\n\t});\n\n\t// fix up the local references used by delete and change revertibles\n\trevertible.revertibleRefs.forEach((revertibleRef) => {\n\t\tassert(\n\t\t\trevertibleRef.revertible.event === IntervalOpType.CHANGE ||\n\t\t\t\trevertibleRef.revertible.event === IntervalOpType.DELETE,\n\t\t\t0x6c5 /* revertible is not delete or change */,\n\t\t);\n\t\tconst pos = newPosition(revertibleRef.offset, restoredRanges);\n\t\tif (pos !== undefined) {\n\t\t\tif (revertibleRef.isStart) {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.start);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeBegin,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.start = newRef;\n\t\t\t} else {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.end);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeEnd,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.end = newRef;\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Invoke revertibles to reverse prior edits\n *\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tif (\"event\" in r) {\n\t\t\tconst event = r.event;\n\t\t\tswitch (event) {\n\t\t\t\tcase IntervalOpType.ADD:\n\t\t\t\t\trevertLocalAdd(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.DELETE:\n\t\t\t\t\trevertLocalDelete(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.CHANGE:\n\t\t\t\t\trevertLocalChange(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.PROPERTY_CHANGED:\n\t\t\t\t\trevertLocalPropertyChanged(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.POSITION_REMOVE:\n\t\t\t\t\trevertLocalSequenceRemove(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(event);\n\t\t\t}\n\t\t} else {\n\t\t\trevertMergeTreeDeltaRevertibles(sharedString, [r]);\n\t\t}\n\t}\n}\n"]}
|
package/lib/sequence.d.ts
CHANGED
|
@@ -45,12 +45,16 @@ import { ISharedIntervalCollection } from "./sharedIntervalCollection";
|
|
|
45
45
|
* - `event` - Various information on the segments that were modified.
|
|
46
46
|
*
|
|
47
47
|
* - `target` - The sequence itself.
|
|
48
|
+
* @public
|
|
48
49
|
*/
|
|
49
50
|
export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
|
|
50
51
|
(event: "createIntervalCollection", listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
51
52
|
(event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): any;
|
|
52
53
|
(event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): any;
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
54
58
|
export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
|
|
55
59
|
private readonly dataStoreRuntime;
|
|
56
60
|
id: string;
|
|
@@ -86,7 +90,7 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
86
90
|
*/
|
|
87
91
|
removeRange(start: number, end: number): IMergeTreeRemoveMsg;
|
|
88
92
|
/**
|
|
89
|
-
* @deprecated
|
|
93
|
+
* @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime
|
|
90
94
|
*/
|
|
91
95
|
groupOperation(groupOp: IMergeTreeGroupMsg): void;
|
|
92
96
|
/**
|
|
@@ -131,7 +135,7 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
131
135
|
* @param refType - ReferenceType for the created local reference
|
|
132
136
|
* @param properties - PropertySet to place on the created local reference
|
|
133
137
|
*/
|
|
134
|
-
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference): LocalReferencePosition;
|
|
138
|
+
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
|
|
135
139
|
/**
|
|
136
140
|
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
137
141
|
*/
|
|
@@ -156,7 +160,7 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
156
160
|
*/
|
|
157
161
|
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
|
|
158
162
|
/**
|
|
159
|
-
* @deprecated
|
|
163
|
+
* @deprecated This method will no longer be public in an upcoming release as it is not safe to use outside of this class
|
|
160
164
|
*/
|
|
161
165
|
submitSequenceMessage(message: IMergeTreeOp): void;
|
|
162
166
|
/**
|
|
@@ -180,7 +184,7 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
180
184
|
*/
|
|
181
185
|
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
|
|
182
186
|
/**
|
|
183
|
-
* @deprecated
|
|
187
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
184
188
|
*/
|
|
185
189
|
getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
|
|
186
190
|
/**
|
package/lib/sequence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,MAAM,EAMN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,MAAM,EAMN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,sBAAsB,E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CAAC,gBAAgB,CAAC;IAIlF;;;;;;;;;;;OAWG;IACI,2BAA2B,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAI9D;;OAEG;IACH,SAAS,CAAC,aAAa,CACtB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAcxB;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CAAC,UAAU,EAAE,iBAAiB;IAQzD;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAapE;;OAEG;IACH,SAAS,CAAC,SAAS;IAKnB;;OAEG;IACH,SAAS,CAAC,YAAY;IAEtB;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAgB7D;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IA6DxD;;OAEG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO;IA0BzB;;OAEG;IACH,SAAS,CAAC,SAAS;IAQnB;;OAEG;IACH,SAAS,CAAC,mBAAmB;IAK7B;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI/C,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,mBAAmB;IA0C3B,OAAO,CAAC,+BAA+B;IAYvC,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,6BAA6B;CAuBrC;AA4BD;;GAEG;AACH,wBAAgB,yBAAyB,SAExC"}
|
package/lib/sequence.js
CHANGED
|
@@ -8,7 +8,9 @@ import { LoggingError, createChildLogger } from "@fluidframework/telemetry-utils
|
|
|
8
8
|
import { MessageType } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { Client, createAnnotateRangeOp,
|
|
10
10
|
// eslint-disable-next-line import/no-deprecated
|
|
11
|
-
createGroupOp, createInsertOp, createRemoveRangeOp,
|
|
11
|
+
createGroupOp, createInsertOp, createRemoveRangeOp,
|
|
12
|
+
// eslint-disable-next-line import/no-deprecated
|
|
13
|
+
matchProperties, MergeTreeDeltaType, } from "@fluidframework/merge-tree";
|
|
12
14
|
import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
13
15
|
import { makeHandlesSerializable, parseHandles, SharedObject, } from "@fluidframework/shared-object-base";
|
|
14
16
|
import { DefaultMap } from "./defaultMap";
|
|
@@ -16,48 +18,10 @@ import { SequenceIntervalCollectionValueType, } from "./intervalCollection";
|
|
|
16
18
|
import { SequenceDeltaEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
|
|
17
19
|
const snapshotFileName = "header";
|
|
18
20
|
const contentPath = "content";
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
19
24
|
export class SharedSegmentSequence extends SharedObject {
|
|
20
|
-
constructor(dataStoreRuntime, id, attributes, segmentFromSpec) {
|
|
21
|
-
super(id, dataStoreRuntime, attributes, "fluid_sequence_");
|
|
22
|
-
this.dataStoreRuntime = dataStoreRuntime;
|
|
23
|
-
this.id = id;
|
|
24
|
-
this.segmentFromSpec = segmentFromSpec;
|
|
25
|
-
/** `Deferred` that triggers once the object is loaded */
|
|
26
|
-
this.loadedDeferred = new Deferred();
|
|
27
|
-
// cache out going ops created when partial loading
|
|
28
|
-
this.loadedDeferredOutgoingOps = [];
|
|
29
|
-
// cache incoming ops that arrive when partial loading
|
|
30
|
-
this.deferIncomingOps = true;
|
|
31
|
-
this.loadedDeferredIncomingOps = [];
|
|
32
|
-
this.messagesSinceMSNChange = [];
|
|
33
|
-
this.guardReentrancy =
|
|
34
|
-
dataStoreRuntime.options.sharedStringPreventReentrancy ?? true
|
|
35
|
-
? ensureNoReentrancy
|
|
36
|
-
: createReentrancyDetector((depth) => {
|
|
37
|
-
if (totalReentrancyLogs > 0) {
|
|
38
|
-
totalReentrancyLogs--;
|
|
39
|
-
this.logger.sendTelemetryEvent({ eventName: "LocalOpReentry", depth }, new LoggingError(reentrancyErrorMessage));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
this.loadedDeferred.promise.catch((error) => {
|
|
43
|
-
this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
|
|
44
|
-
});
|
|
45
|
-
this.client = new Client(segmentFromSpec, createChildLogger({
|
|
46
|
-
logger: this.logger,
|
|
47
|
-
namespace: "SharedSegmentSequence.MergeTreeClient",
|
|
48
|
-
}), dataStoreRuntime.options);
|
|
49
|
-
this.client.prependListener("delta", (opArgs, deltaArgs) => {
|
|
50
|
-
const event = new SequenceDeltaEvent(opArgs, deltaArgs, this.client);
|
|
51
|
-
if (opArgs.stashed !== true && event.isLocal) {
|
|
52
|
-
this.submitSequenceMessage(opArgs.op);
|
|
53
|
-
}
|
|
54
|
-
this.emit("sequenceDelta", event, this);
|
|
55
|
-
});
|
|
56
|
-
this.client.on("maintenance", (args, opArgs) => {
|
|
57
|
-
this.emit("maintenance", new SequenceMaintenanceEvent(opArgs, args, this.client), this);
|
|
58
|
-
});
|
|
59
|
-
this.intervalCollections = new DefaultMap(this.serializer, this.handle, (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata), new SequenceIntervalCollectionValueType(), dataStoreRuntime.options);
|
|
60
|
-
}
|
|
61
25
|
get loaded() {
|
|
62
26
|
return this.loadedDeferred.promise;
|
|
63
27
|
}
|
|
@@ -73,6 +37,7 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
73
37
|
}
|
|
74
38
|
if (lastAnnotate &&
|
|
75
39
|
lastAnnotate.pos2 === r.position &&
|
|
40
|
+
// eslint-disable-next-line import/no-deprecated
|
|
76
41
|
matchProperties(lastAnnotate.props, props)) {
|
|
77
42
|
lastAnnotate.pos2 += r.segment.cachedLength;
|
|
78
43
|
}
|
|
@@ -100,6 +65,47 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
100
65
|
}
|
|
101
66
|
return ops;
|
|
102
67
|
}
|
|
68
|
+
constructor(dataStoreRuntime, id, attributes, segmentFromSpec) {
|
|
69
|
+
super(id, dataStoreRuntime, attributes, "fluid_sequence_");
|
|
70
|
+
this.dataStoreRuntime = dataStoreRuntime;
|
|
71
|
+
this.id = id;
|
|
72
|
+
this.segmentFromSpec = segmentFromSpec;
|
|
73
|
+
/** `Deferred` that triggers once the object is loaded */
|
|
74
|
+
this.loadedDeferred = new Deferred();
|
|
75
|
+
// cache out going ops created when partial loading
|
|
76
|
+
this.loadedDeferredOutgoingOps = [];
|
|
77
|
+
// cache incoming ops that arrive when partial loading
|
|
78
|
+
this.deferIncomingOps = true;
|
|
79
|
+
this.loadedDeferredIncomingOps = [];
|
|
80
|
+
this.messagesSinceMSNChange = [];
|
|
81
|
+
this.guardReentrancy =
|
|
82
|
+
dataStoreRuntime.options.sharedStringPreventReentrancy ?? true
|
|
83
|
+
? ensureNoReentrancy
|
|
84
|
+
: createReentrancyDetector((depth) => {
|
|
85
|
+
if (totalReentrancyLogs > 0) {
|
|
86
|
+
totalReentrancyLogs--;
|
|
87
|
+
this.logger.sendTelemetryEvent({ eventName: "LocalOpReentry", depth }, new LoggingError(reentrancyErrorMessage));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
this.loadedDeferred.promise.catch((error) => {
|
|
91
|
+
this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
|
|
92
|
+
});
|
|
93
|
+
this.client = new Client(segmentFromSpec, createChildLogger({
|
|
94
|
+
logger: this.logger,
|
|
95
|
+
namespace: "SharedSegmentSequence.MergeTreeClient",
|
|
96
|
+
}), dataStoreRuntime.options);
|
|
97
|
+
this.client.prependListener("delta", (opArgs, deltaArgs) => {
|
|
98
|
+
const event = new SequenceDeltaEvent(opArgs, deltaArgs, this.client);
|
|
99
|
+
if (opArgs.stashed !== true && event.isLocal) {
|
|
100
|
+
this.submitSequenceMessage(opArgs.op);
|
|
101
|
+
}
|
|
102
|
+
this.emit("sequenceDelta", event, this);
|
|
103
|
+
});
|
|
104
|
+
this.client.on("maintenance", (args, opArgs) => {
|
|
105
|
+
this.emit("maintenance", new SequenceMaintenanceEvent(opArgs, args, this.client), this);
|
|
106
|
+
});
|
|
107
|
+
this.intervalCollections = new DefaultMap(this.serializer, this.handle, (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata), new SequenceIntervalCollectionValueType(), dataStoreRuntime.options);
|
|
108
|
+
}
|
|
103
109
|
/**
|
|
104
110
|
* @param start - The inclusive start of the range to remove
|
|
105
111
|
* @param end - The exclusive end of the range to remove
|
|
@@ -108,7 +114,7 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
108
114
|
return this.guardReentrancy(() => this.client.removeRangeLocal(start, end));
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
|
-
* @deprecated
|
|
117
|
+
* @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime
|
|
112
118
|
*/
|
|
113
119
|
groupOperation(groupOp) {
|
|
114
120
|
this.guardReentrancy(() => this.client.localTransaction(groupOp));
|
|
@@ -161,8 +167,8 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
161
167
|
* @param refType - ReferenceType for the created local reference
|
|
162
168
|
* @param properties - PropertySet to place on the created local reference
|
|
163
169
|
*/
|
|
164
|
-
createLocalReferencePosition(segment, offset, refType, properties, slidingPreference) {
|
|
165
|
-
return this.client.createLocalReferencePosition(segment, offset, refType, properties, slidingPreference);
|
|
170
|
+
createLocalReferencePosition(segment, offset, refType, properties, slidingPreference, canSlideToEndpoint) {
|
|
171
|
+
return this.client.createLocalReferencePosition(segment, offset, refType, properties, slidingPreference, canSlideToEndpoint);
|
|
166
172
|
}
|
|
167
173
|
/**
|
|
168
174
|
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
@@ -194,7 +200,7 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
194
200
|
return this.client.resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId);
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
|
-
* @deprecated
|
|
203
|
+
* @deprecated This method will no longer be public in an upcoming release as it is not safe to use outside of this class
|
|
198
204
|
*/
|
|
199
205
|
submitSequenceMessage(message) {
|
|
200
206
|
if (!this.isAttached()) {
|
|
@@ -237,7 +243,7 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
237
243
|
this.client.walkSegments(handler, start, end, accum, splitRange);
|
|
238
244
|
}
|
|
239
245
|
/**
|
|
240
|
-
* @deprecated
|
|
246
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
241
247
|
*/
|
|
242
248
|
getStackContext(startPos, rangeLabels) {
|
|
243
249
|
return this.client.getStackContext(startPos, rangeLabels);
|
|
@@ -373,7 +379,8 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
373
379
|
if (m.minimumSequenceNumber < collabWindow.minSeq ||
|
|
374
380
|
m.referenceSequenceNumber < collabWindow.minSeq ||
|
|
375
381
|
m.sequenceNumber <= collabWindow.minSeq ||
|
|
376
|
-
|
|
382
|
+
// sequenceNumber could be the same if messages are part of a grouped batch
|
|
383
|
+
m.sequenceNumber < collabWindow.currentSeq) {
|
|
377
384
|
throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({
|
|
378
385
|
op: {
|
|
379
386
|
seq: m.sequenceNumber,
|
|
@@ -442,7 +449,7 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
442
449
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
443
450
|
*/
|
|
444
451
|
applyStashedOp(content) {
|
|
445
|
-
return this.client.applyStashedOp(content);
|
|
452
|
+
return this.client.applyStashedOp(parseHandles(content, this.serializer));
|
|
446
453
|
}
|
|
447
454
|
summarizeMergeTree(serializer) {
|
|
448
455
|
// Are we fully loaded? If not, things will go south
|