@fluidframework/sequence 2.13.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAC/B,yCAAyC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAMN,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAEtB,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAIN,YAAY,EACZ,6BAA6B,EAC7B,+BAA+B,GAE/B,MAAM,oBAAoB,CAAC;AAE5B,SAAS,YAAY,CAAC,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACX,CAAC;AAED,SAAS,OAAO,CAAC,KAAW,EAAE,KAAW;IACxC,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC;AACpB,CAAC;AAED,S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AI,aAAa,CAAC,aAAa,CAAC;YAC5C,UAAU,IAAI,aAAa,CAAC,aAAa,CAAC;QAC3C,CAAC;aAAM,CAAC;YACP,YAAY,IAAI,aAAa,CAAC,YAAY,CAAC;YAC3C,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC;QAC1C,CAAC;IACF,CAAC;IAED,MAAM,SAAS,GAAG,uBAAuB,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,SAAS,EACT,+BAA+B,CAAC,UAAU,CAAC,EAC3C,+BAA+B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,QAAQ,EAC1E,qBAAqB,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,uBAAuB,CACtC,MAAM,EACN,MAAM,EACN,UAAU,EACV,EAAE,EACF,YAAY,EACZ,SAAS,EACT,6BAA6B,CAAC,UAAU,CAAC,EACzC,6BAA6B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,OAAO,EACvE,qBAAqB,CACrB,CAAC;IAEF,MAAM,SAAS,GAAG;QACjB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CACrC,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,SAAS,EACT,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IAC1E,MAAM,EAAE,sBAAsB;CAC9B,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 import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSequencePlace,\n\tSide,\n\tendpointPosAndSide,\n\taddProperties,\n\tcopyPropertiesAndManager,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tcomputeStickinessFromSide,\n\treservedIntervalIdKey,\n\tsidesFromStickiness,\n} from \"../intervalCollection.js\";\n\nimport {\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n\ttype IIntervalHelpers,\n} from \"./intervalUtils.js\";\n\nfunction compareSides(sideA: Side, sideB: Side): number {\n\tif (sideA === sideB) {\n\t\treturn 0;\n\t}\n\n\tif (sideA === Side.Before) {\n\t\treturn 1;\n\t}\n\n\treturn -1;\n}\n\nfunction minSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.After && sideB === Side.After) {\n\t\treturn Side.After;\n\t}\n\n\treturn Side.Before;\n}\n\nfunction maxSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.Before && sideB === Side.Before) {\n\t\treturn Side.Before;\n\t}\n\n\treturn Side.After;\n}\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoints' positions should be treated exclusively to get\n * reasonable behavior. E.g., an interval referring to \"hello\" in \"hello world\"\n * should have a start position of 0 and an end position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the endpoints of an interval are treated exclusively but cannot be greater\n * than or equal to the length of the associated sequence, there exist special\n * endpoint segments, \"start\" and \"end\", which represent the position immediately\n * before or immediately after the string respectively.\n *\n * If a `SequenceInterval` is created on a sequence with the\n * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints\n * of the interval that are exclusive will have the ability to slide to these\n * special endpoint segments.\n * @alpha\n * @legacy\n */\nexport interface SequenceInterval extends ISerializableInterval {\n\treadonly start: LocalReferencePosition;\n\t/**\n\t * End endpoint of this interval.\n\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t */\n\treadonly end: LocalReferencePosition;\n\treadonly intervalType: IntervalType;\n\treadonly startSide: Side;\n\treadonly endSide: Side;\n\treadonly stickiness: IntervalStickiness;\n\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): SequenceInterval;\n\t/**\n\t * Compares this interval to `b` with standard comparator semantics:\n\t * - returns -1 if this is less than `b`\n\t * - returns 1 if this is greater than `b`\n\t * - returns 0 if this is equivalent to `b`\n\t * @param b - Interval to compare against\n\t */\n\tcompare(b: SequenceInterval): number;\n\t/**\n\t * Compares the start endpoint of this interval to `b`'s start endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareStart(b: SequenceInterval): number;\n\t/**\n\t * Compares the end endpoint of this interval to `b`'s end endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareEnd(b: SequenceInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): SequenceInterval | undefined;\n\t/**\n\t * @returns whether this interval overlaps with `b`.\n\t * Intervals are considered to overlap if their intersection is non-empty.\n\t */\n\toverlaps(b: SequenceInterval): boolean;\n\t/**\n\t * Unions this interval with `b`, returning a new interval.\n\t * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n\t * intermediate values between the two intervals.\n\t */\n\tunion(b: SequenceInterval): SequenceInterval;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\taddPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void;\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tremovePositionChangeListeners(): void;\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\toverlapsPos(bstart: number, bend: number): boolean;\n}\n\nexport class SequenceIntervalClass implements SequenceInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t */\n\tpublic propertyManager?: PropertiesManager;\n\n\t/***/\n\tpublic get stickiness(): IntervalStickiness {\n\t\tconst startSegment = this.start.getSegment();\n\t\tconst endSegment = this.end.getSegment();\n\t\treturn computeStickinessFromSide(\n\t\t\tstartSegment?.endpointType,\n\t\t\tthis.startSide,\n\t\t\tendSegment?.endpointType,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly startSide: Side = Side.Before,\n\t\tpublic readonly endSide: Side = Side.Before,\n\t) {\n\t\tif (props) {\n\t\t\tthis.properties = addProperties(this.properties, props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst { startSide, endSide } = sidesFromStickiness(this.stickiness);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t\tstickiness: this.stickiness,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = addProperties(\n\t\t\t\tserializedInterval.properties,\n\t\t\t\tthis.properties,\n\t\t\t);\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone(): SequenceInterval {\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.startSide,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\tconst dist = compareReferencePositions(this.start, b.start);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(this.startSide, b.startSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval): number {\n\t\tconst dist = compareReferencePositions(this.end, b.end);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(b.endSide, this.endSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\tconst newStart = minReferencePosition(this.start, b.start);\n\t\tconst newEnd = maxReferencePosition(this.end, b.end);\n\n\t\tlet startSide: Side;\n\n\t\tif (this.start === b.start) {\n\t\t\tstartSide = minSide(this.startSide, b.startSide);\n\t\t} else {\n\t\t\tstartSide = this.start === newStart ? this.startSide : b.startSide;\n\t\t}\n\n\t\tlet endSide: Side;\n\n\t\tif (this.end === b.end) {\n\t\t\tendSide = maxSide(this.endSide, b.endSide);\n\t\t} else {\n\t\t\tendSide = this.end === newEnd ? this.endSide : b.endSide;\n\t\t}\n\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tnewStart,\n\t\t\tnewEnd,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior: boolean = false,\n\t) {\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\t\tconst stickiness = computeStickinessFromSide(\n\t\t\tstartPos ?? this.start.getSegment()?.endpointType,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendPos ?? this.end.getSegment()?.endpointType,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (startPos !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstartPos,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (endPos !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tendPos,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tstartRef,\n\t\t\tendRef,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tcopyPropertiesAndManager(this, newInterval);\n\t\treturn newInterval;\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined } | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n\tcanSlideToEndpoint?: boolean,\n): LocalReferencePosition {\n\tif (segoff === \"start\" || segoff === \"end\") {\n\t\treturn client.createLocalReferencePosition(\n\t\t\tsegoff,\n\t\t\tundefined,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t}\n\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(slidingPreference, refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n\texclusive: boolean = false,\n\tuseNewSlidingBehavior: boolean = false,\n): LocalReferencePosition {\n\tlet segoff;\n\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\tsegoff = pos;\n\t\t} else {\n\t\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\t\tclientId: op.clientId,\n\t\t\t});\n\t\t\tsegoff = getSlideToSegoff(segoff, slidingPreference, useNewSlidingBehavior);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff =\n\t\t\tpos === \"start\" || pos === \"end\"\n\t\t\t\t? pos\n\t\t\t\t: client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t\texclusive,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tuseNewSlidingBehavior: boolean = false,\n): SequenceInterval {\n\tconst { startPos, startSide, endPos, endSide } = endpointPosAndSide(\n\t\tstart ?? \"start\",\n\t\tend ?? \"end\",\n\t);\n\tassert(\n\t\tstartPos !== undefined &&\n\t\t\tendPos !== undefined &&\n\t\t\tstartSide !== undefined &&\n\t\t\tendSide !== undefined,\n\t\t0x794 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t);\n\tconst stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op ?? fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstartPos,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tendPos,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceIntervalClass(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstartSide,\n\t\tendSide,\n\t);\n\treturn ival;\n}\n\n/**\n * @deprecated The methods within have substitutions\n * @internal\n */\nexport const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {\n\tcreate: createSequenceInterval,\n};\n"]}
1
+ {"version":3,"file":"sequenceInterval.js","sourceR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;aAAM,CAAC;YACP,YAAY,IAAI,aAAa,CAAC,YAAY,CAAC;YAC3C,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC;QAC1C,CAAC;IACF,CAAC;IAED,MAAM,SAAS,GAAG,uBAAuB,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,SAAS,EACT,+BAA+B,CAAC,UAAU,CAAC,EAC3C,+BAA+B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,QAAQ,EAC1E,qBAAqB,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,uBAAuB,CACtC,MAAM,EACN,MAAM,EACN,UAAU,EACV,EAAE,EACF,YAAY,EACZ,SAAS,EACT,6BAA6B,CAAC,UAAU,CAAC,EACzC,6BAA6B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,OAAO,EACvE,qBAAqB,CACrB,CAAC;IAEF,MAAM,SAAS,GAAG;QACjB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CACrC,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,SAAS,EACT,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IAC1E,MAAM,EAAE,sBAAsB;CAC9B,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 import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSequencePlace,\n\tSide,\n\tendpointPosAndSide,\n\taddProperties,\n\tcopyPropertiesAndManager,\n\ttype ISegmentInternal,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tcomputeStickinessFromSide,\n\treservedIntervalIdKey,\n\tsidesFromStickiness,\n} from \"../intervalCollection.js\";\n\nimport {\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n\ttype IIntervalHelpers,\n} from \"./intervalUtils.js\";\n\nfunction compareSides(sideA: Side, sideB: Side): number {\n\tif (sideA === sideB) {\n\t\treturn 0;\n\t}\n\n\tif (sideA === Side.Before) {\n\t\treturn 1;\n\t}\n\n\treturn -1;\n}\n\nfunction minSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.After && sideB === Side.After) {\n\t\treturn Side.After;\n\t}\n\n\treturn Side.Before;\n}\n\nfunction maxSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.Before && sideB === Side.Before) {\n\t\treturn Side.Before;\n\t}\n\n\treturn Side.After;\n}\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoints' positions should be treated exclusively to get\n * reasonable behavior. E.g., an interval referring to \"hello\" in \"hello world\"\n * should have a start position of 0 and an end position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the endpoints of an interval are treated exclusively but cannot be greater\n * than or equal to the length of the associated sequence, there exist special\n * endpoint segments, \"start\" and \"end\", which represent the position immediately\n * before or immediately after the string respectively.\n *\n * If a `SequenceInterval` is created on a sequence with the\n * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints\n * of the interval that are exclusive will have the ability to slide to these\n * special endpoint segments.\n * @alpha\n * @legacy\n */\nexport interface SequenceInterval extends ISerializableInterval {\n\treadonly start: LocalReferencePosition;\n\t/**\n\t * End endpoint of this interval.\n\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t */\n\treadonly end: LocalReferencePosition;\n\treadonly intervalType: IntervalType;\n\treadonly startSide: Side;\n\treadonly endSide: Side;\n\treadonly stickiness: IntervalStickiness;\n\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): SequenceInterval;\n\t/**\n\t * Compares this interval to `b` with standard comparator semantics:\n\t * - returns -1 if this is less than `b`\n\t * - returns 1 if this is greater than `b`\n\t * - returns 0 if this is equivalent to `b`\n\t * @param b - Interval to compare against\n\t */\n\tcompare(b: SequenceInterval): number;\n\t/**\n\t * Compares the start endpoint of this interval to `b`'s start endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareStart(b: SequenceInterval): number;\n\t/**\n\t * Compares the end endpoint of this interval to `b`'s end endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareEnd(b: SequenceInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): SequenceInterval | undefined;\n\t/**\n\t * @returns whether this interval overlaps with `b`.\n\t * Intervals are considered to overlap if their intersection is non-empty.\n\t */\n\toverlaps(b: SequenceInterval): boolean;\n\t/**\n\t * Unions this interval with `b`, returning a new interval.\n\t * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n\t * intermediate values between the two intervals.\n\t */\n\tunion(b: SequenceInterval): SequenceInterval;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\taddPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void;\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tremovePositionChangeListeners(): void;\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\toverlapsPos(bstart: number, bend: number): boolean;\n}\n\nexport class SequenceIntervalClass implements SequenceInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t */\n\tpublic propertyManager?: PropertiesManager;\n\n\t/***/\n\tpublic get stickiness(): IntervalStickiness {\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\treturn computeStickinessFromSide(\n\t\t\tstartSegment?.endpointType,\n\t\t\tthis.startSide,\n\t\t\tendSegment?.endpointType,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly startSide: Side = Side.Before,\n\t\tpublic readonly endSide: Side = Side.Before,\n\t) {\n\t\tif (props) {\n\t\t\tthis.properties = addProperties(this.properties, props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst { startSide, endSide } = sidesFromStickiness(this.stickiness);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t\tstickiness: this.stickiness,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = addProperties(\n\t\t\t\tserializedInterval.properties,\n\t\t\t\tthis.properties,\n\t\t\t);\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone(): SequenceInterval {\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.startSide,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\tconst dist = compareReferencePositions(this.start, b.start);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(this.startSide, b.startSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval): number {\n\t\tconst dist = compareReferencePositions(this.end, b.end);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(b.endSide, this.endSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\tconst newStart = minReferencePosition(this.start, b.start);\n\t\tconst newEnd = maxReferencePosition(this.end, b.end);\n\n\t\tlet startSide: Side;\n\n\t\tif (this.start === b.start) {\n\t\t\tstartSide = minSide(this.startSide, b.startSide);\n\t\t} else {\n\t\t\tstartSide = this.start === newStart ? this.startSide : b.startSide;\n\t\t}\n\n\t\tlet endSide: Side;\n\n\t\tif (this.end === b.end) {\n\t\t\tendSide = maxSide(this.endSide, b.endSide);\n\t\t} else {\n\t\t\tendSide = this.end === newEnd ? this.endSide : b.endSide;\n\t\t}\n\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tnewStart,\n\t\t\tnewEnd,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior: boolean = false,\n\t) {\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\tconst stickiness = computeStickinessFromSide(\n\t\t\tstartPos ?? startSegment?.endpointType,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendPos ?? endSegment?.endpointType,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (startPos !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstartPos,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (endPos !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tendPos,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tstartRef,\n\t\t\tendRef,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tcopyPropertiesAndManager(this, newInterval);\n\t\treturn newInterval;\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined } | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n\tcanSlideToEndpoint?: boolean,\n): LocalReferencePosition {\n\tif (segoff === \"start\" || segoff === \"end\") {\n\t\treturn client.createLocalReferencePosition(\n\t\t\tsegoff,\n\t\t\tundefined,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t}\n\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(slidingPreference, refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n\texclusive: boolean = false,\n\tuseNewSlidingBehavior: boolean = false,\n): LocalReferencePosition {\n\tlet segoff;\n\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\tsegoff = pos;\n\t\t} else {\n\t\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\t\tclientId: op.clientId,\n\t\t\t});\n\t\t\tsegoff = getSlideToSegoff(segoff, slidingPreference, useNewSlidingBehavior);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff =\n\t\t\tpos === \"start\" || pos === \"end\"\n\t\t\t\t? pos\n\t\t\t\t: client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t\texclusive,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tuseNewSlidingBehavior: boolean = false,\n): SequenceInterval {\n\tconst { startPos, startSide, endPos, endSide } = endpointPosAndSide(\n\t\tstart ?? \"start\",\n\t\tend ?? \"end\",\n\t);\n\tassert(\n\t\tstartPos !== undefined &&\n\t\t\tendPos !== undefined &&\n\t\t\tstartSide !== undefined &&\n\t\t\tendSide !== undefined,\n\t\t0x794 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t);\n\tconst stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op ?? fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstartPos,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tendPos,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceIntervalClass(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstartSide,\n\t\tendSide,\n\t);\n\treturn ival;\n}\n\n/**\n * @deprecated The methods within have substitutions\n * @internal\n */\nexport const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {\n\tcreate: createSequenceInterval,\n};\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/sequence";
8
- export declare const pkgVersion = "2.13.0";
8
+ export declare const pkgVersion = "2.20.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/sequence";
8
- export const pkgVersion = "2.13.0";
8
+ export const pkgVersion = "2.20.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.13.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.20.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.d.ts","sourceRo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,EAAE,gBAAgB,EAC1B,WAAW,EAAE,sBAAsB,EAAE,4BAQrC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EAAE,sBAAsB,EAAE,GACnC,sBAAsB,EAAE,CAwC1B;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,gBAAgB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,sBAAsB,EAAE,4BAsCrC;AAED;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,sBAAsB,EAAE,4BASrC;AA2CD;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,kBAAkB,EACzB,WAAW,EAAE,sBAAsB,EAAE,QAwFrC;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC7C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,sBAAsB,EAAE,QAUrC;AAuRD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,sBAAsB,EAAE,QA8BrC"}
@@ -5,7 +5,7 @@
5
5
  /* eslint-disable no-bitwise */
6
6
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
7
  import { MergeTreeDeltaType, ReferenceType, SlidingPreference, // eslint-disable-next-line import/no-deprecated
8
- SortedSet, appendToMergeTreeDeltaRevertibles, discardMergeTreeDeltaRevertible, getSlideToSegoff, isMergeTreeDeltaRevertible, refTypeIncludesFlag, revertMergeTreeDeltaRevertibles, Side, segmentIsRemoved, } from "@fluidframework/merge-tree/internal";
8
+ appendToMergeTreeDeltaRevertibles, discardMergeTreeDeltaRevertible, getSlideToSegoff, isMergeTreeDeltaRevertible, refTypeIncludesFlag, revertMergeTreeDeltaRevertibles, Side, segmentIsRemoved, SortedSegmentSet, } from "@fluidframework/merge-tree/internal";
9
9
  import { IntervalOpType, SequenceIntervalClass } from "./intervals/index.js";
10
10
  const idMap = new Map();
11
11
  function getUpdatedIdFromInterval(interval) {
@@ -180,7 +180,7 @@ export function appendSharedStringDeltaToRevertibles(string, delta, revertibles)
180
180
  }
181
181
  revertible.intervals.push({
182
182
  intervalId: interval.getIntervalId(),
183
- label: interval.properties.referenceRangeLabels?.[0],
183
+ label: interval.properties.referenceRangeLabels[0],
184
184
  startOffset: offset,
185
185
  endOffset,
186
186
  });
@@ -189,7 +189,7 @@ export function appendSharedStringDeltaToRevertibles(string, delta, revertibles)
189
189
  endIntervals.forEach(({ interval, offset }) => {
190
190
  revertible.intervals.push({
191
191
  intervalId: interval.getIntervalId(),
192
- label: interval.properties.referenceRangeLabels?.[0],
192
+ label: interval.properties.referenceRangeLabels[0],
193
193
  endOffset: offset,
194
194
  });
195
195
  });
@@ -243,7 +243,7 @@ function isValidRange(start, startSlide, end, endSlide, string) {
243
243
  }
244
244
  function revertLocalAdd(string, revertible) {
245
245
  const id = getUpdatedIdFromInterval(revertible.interval);
246
- const label = revertible.interval.properties.referenceRangeLabels?.[0];
246
+ const label = revertible.interval.properties.referenceRangeLabels[0];
247
247
  string.getIntervalCollection(label).removeIntervalById(id);
248
248
  }
249
249
  function createSequencePlace(pos, newSlidingPreference, oldSlidingPreference = undefined) {
@@ -262,7 +262,7 @@ function createSequencePlace(pos, newSlidingPreference, oldSlidingPreference = u
262
262
  : pos; // Avoid setting side if possible since stickiness may not be enabled
263
263
  }
264
264
  function revertLocalDelete(string, revertible) {
265
- const label = revertible.interval.properties.referenceRangeLabels?.[0];
265
+ const label = revertible.interval.properties.referenceRangeLabels[0];
266
266
  const collection = string.getIntervalCollection(label);
267
267
  const start = string.localReferencePositionToPosition(revertible.start);
268
268
  const startSlidePos = getSlidePosition(string, revertible.start, start);
@@ -287,7 +287,7 @@ function revertLocalDelete(string, revertible) {
287
287
  string.removeLocalReferencePosition(revertible.end);
288
288
  }
289
289
  function revertLocalChange(string, revertible) {
290
- const label = revertible.interval.properties.referenceRangeLabels?.[0];
290
+ const label = revertible.interval.properties.referenceRangeLabels[0];
291
291
  const collection = string.getIntervalCollection(label);
292
292
  const id = getUpdatedIdFromInterval(revertible.interval);
293
293
  const start = string.localReferencePositionToPosition(revertible.start);
@@ -306,7 +306,7 @@ function revertLocalChange(string, revertible) {
306
306
  string.removeLocalReferencePosition(revertible.end);
307
307
  }
308
308
  function revertLocalPropertyChanged(string, revertible) {
309
- const label = revertible.interval.properties.referenceRangeLabels?.[0];
309
+ const label = revertible.interval.properties.referenceRangeLabels[0];
310
310
  const id = getUpdatedIdFromInterval(revertible.interval);
311
311
  const newProps = revertible.propertyDeltas;
312
312
  string.getIntervalCollection(label).change(id, { props: newProps });
@@ -335,10 +335,7 @@ function newEndpointPosition(offset, restoredRanges, sharedString) {
335
335
  return pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;
336
336
  }
337
337
  // eslint-disable-next-line import/no-deprecated
338
- class SortedRangeSet extends SortedSet {
339
- getKey(item) {
340
- return item.ranges[0].segment.ordinal;
341
- }
338
+ class SortedRangeSet extends SortedSegmentSet {
342
339
  }
343
340
  function revertLocalSequenceRemove(sharedString, revertible) {
344
341
  const restoredRanges = new SortedRangeSet();
@@ -348,7 +345,11 @@ function revertLocalSequenceRemove(sharedString, revertible) {
348
345
  event.ranges.forEach((range) => {
349
346
  length += range.segment.cachedLength;
350
347
  });
351
- restoredRanges.addOrUpdate({ ranges: event.ranges, length });
348
+ restoredRanges.addOrUpdate({
349
+ ranges: event.ranges,
350
+ length,
351
+ segment: event.ranges[0].segment,
352
+ });
352
353
  }
353
354
  };
354
355
  sharedString.on("sequenceDelta", saveSegments);
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAG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AAY,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;YACzB,CAAC;QACF,CAAC;aAAM,CAAC;YACP,+BAA+B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;IACF,CAAC;AACF,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\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference, // eslint-disable-next-line import/no-deprecated\n\tSortedSet,\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tgetSlideToSegoff,\n\tisMergeTreeDeltaRevertible,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tInteriorSequencePlace,\n\tSide,\n\ttype ISegmentInternal,\n\tsegmentIsRemoved,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IntervalOpType, SequenceInterval, SequenceIntervalClass } from \"./intervals/index.js\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent.js\";\nimport { ISharedString, SharedStringSegment } from \"./sharedString.js\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n * @legacy\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\n/**\n * Data for undoing edits affecting Intervals.\n * @legacy\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 & {\n\tevent: T;\n};\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 * @legacy\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 * @legacy\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: ISharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n): SharedStringRevertible[] {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment | undefined;\n\tif (!startSeg) {\n\t\treturn revertibles;\n\t}\n\tconst startType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment | undefined;\n\tif (!endSeg) {\n\t\treturn revertibles;\n\t}\n\tconst endType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\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 * @legacy\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: ISharedString,\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 = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\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 * @legacy\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 SequenceIntervalClass) {\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 SequenceIntervalClass) {\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 * @legacy\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: ISharedString,\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 segment: ISegmentInternal = deltaRange.segment;\n\t\t\tconst refs = 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 (\n\t\trevertibles.length > 0 &&\n\t\tisMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])\n\t) {\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 * @legacy\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: ISharedString,\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(\n\tstring: ISharedString,\n\tlref: LocalReferencePosition,\n\tpos: number,\n): 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(\n\tstart: number,\n\tstartSlide: SlidingPreference | undefined,\n\tend: number,\n\tendSlide: SlidingPreference | undefined,\n\tstring: ISharedString,\n) {\n\treturn (\n\t\tstart >= 0 &&\n\t\tstart < string.getLength() &&\n\t\tend >= 0 &&\n\t\tend < string.getLength() &&\n\t\t(start < end ||\n\t\t\t(start === end &&\n\t\t\t\t(startSlide === SlidingPreference.FORWARD || endSlide !== SlidingPreference.FORWARD)))\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: ISharedString,\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 createSequencePlace(\n\tpos: number,\n\tnewSlidingPreference: SlidingPreference | undefined,\n\toldSlidingPreference: SlidingPreference | undefined = undefined,\n): number | InteriorSequencePlace {\n\treturn newSlidingPreference === SlidingPreference.BACKWARD ||\n\t\t(newSlidingPreference === undefined && oldSlidingPreference === SlidingPreference.BACKWARD)\n\t\t? {\n\t\t\t\tpos,\n\t\t\t\tside: Side.After,\n\t\t\t}\n\t\t: newSlidingPreference === SlidingPreference.FORWARD &&\n\t\t\t\toldSlidingPreference === SlidingPreference.BACKWARD\n\t\t\t? {\n\t\t\t\t\tpos,\n\t\t\t\t\tside: Side.Before,\n\t\t\t\t}\n\t\t\t: pos; // Avoid setting side if possible since stickiness may not be enabled\n}\n\nfunction revertLocalDelete(\n\tstring: ISharedString,\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 (\n\t\tisValidRange(\n\t\t\tstartSlidePos,\n\t\t\trevertible.start.slidingPreference,\n\t\t\tendSlidePos,\n\t\t\trevertible.end.slidingPreference,\n\t\t\tstring,\n\t\t)\n\t) {\n\t\tconst int = collection.add({\n\t\t\tstart: createSequencePlace(startSlidePos, revertible.start.slidingPreference),\n\t\t\tend: createSequencePlace(endSlidePos, revertible.end.slidingPreference),\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: ISharedString,\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\tconst interval = collection.getIntervalById(id);\n\tif (\n\t\tinterval !== undefined &&\n\t\tisValidRange(\n\t\t\tstartSlidePos,\n\t\t\trevertible.start.slidingPreference ?? interval.start.slidingPreference,\n\t\t\tendSlidePos,\n\t\t\trevertible.end.slidingPreference ?? interval.end.slidingPreference,\n\t\t\tstring,\n\t\t)\n\t) {\n\t\tcollection.change(id, {\n\t\t\tstart: createSequencePlace(\n\t\t\t\tstartSlidePos,\n\t\t\t\trevertible.start.slidingPreference,\n\t\t\t\tinterval.start.slidingPreference,\n\t\t\t),\n\t\t\tend: createSequencePlace(\n\t\t\t\tendSlidePos,\n\t\t\t\trevertible.end.slidingPreference,\n\t\t\t\tinterval.end.slidingPreference,\n\t\t\t),\n\t\t});\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalPropertyChanged(\n\tstring: ISharedString,\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).change(id, { props: 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: ISharedString,\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\n// eslint-disable-next-line import/no-deprecated\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: ISharedString,\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 (\n\t\t\t\tisValidRange(\n\t\t\t\t\tstart,\n\t\t\t\t\tinterval.start.slidingPreference,\n\t\t\t\t\tend,\n\t\t\t\t\tinterval.end.slidingPreference,\n\t\t\t\t\tsharedString,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tintervalCollection.change(intervalId, {\n\t\t\t\t\tstart: createSequencePlace(start, interval.start.slidingPreference),\n\t\t\t\t\tend: createSequencePlace(end, interval.end.slidingPreference),\n\t\t\t\t});\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\trevertibleRef.revertible.start.slidingPreference,\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\trevertibleRef.revertible.end.slidingPreference,\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 * @legacy\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: ISharedString,\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;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAIN,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EAAE,gDAAgD;AACnE,iCAAiC,EACjC,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,EAE/B,IAAI,EAEJ,gBAAgB,EAChB,gBAAgB,GAEhB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAoB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAW/F,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAkDxC,SAAS,wBAAwB,CAAC,QAA0B;IAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;IACzC,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,YAAY,CAAC,UAAkB;IACvC,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC5C,CAAC;AAED;;;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AC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,oEAAoE;QACpE,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAG,CAAC;QAC7B,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;YACtB,QAAQ,KAAK,EAAE,CAAC;gBACf,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;YACzB,CAAC;QACF,CAAC;aAAM,CAAC;YACP,+BAA+B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;IACF,CAAC;AACF,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\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference, // eslint-disable-next-line import/no-deprecated\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tgetSlideToSegoff,\n\tisMergeTreeDeltaRevertible,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tInteriorSequencePlace,\n\tSide,\n\ttype ISegmentInternal,\n\tsegmentIsRemoved,\n\tSortedSegmentSet,\n\ttype ISegment,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IntervalOpType, SequenceInterval, SequenceIntervalClass } from \"./intervals/index.js\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent.js\";\nimport { ISharedString, SharedStringSegment } from \"./sharedString.js\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n * @legacy\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\n/**\n * Data for undoing edits affecting Intervals.\n * @legacy\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 & {\n\tevent: T;\n};\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 * @legacy\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 * @legacy\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: ISharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n): SharedStringRevertible[] {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment | undefined;\n\tif (!startSeg) {\n\t\treturn revertibles;\n\t}\n\tconst startType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment | undefined;\n\tif (!endSeg) {\n\t\treturn revertibles;\n\t}\n\tconst endType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\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 * @legacy\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: ISharedString,\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 = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType = segmentIsRemoved(startSeg)\n\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\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 * @legacy\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 SequenceIntervalClass) {\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 SequenceIntervalClass) {\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 * @legacy\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: ISharedString,\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 segment: ISegmentInternal = deltaRange.segment;\n\t\t\tconst refs = 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 (\n\t\trevertibles.length > 0 &&\n\t\tisMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])\n\t) {\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 * @legacy\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: ISharedString,\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(\n\tstring: ISharedString,\n\tlref: LocalReferencePosition,\n\tpos: number,\n): 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(\n\tstart: number,\n\tstartSlide: SlidingPreference | undefined,\n\tend: number,\n\tendSlide: SlidingPreference | undefined,\n\tstring: ISharedString,\n) {\n\treturn (\n\t\tstart >= 0 &&\n\t\tstart < string.getLength() &&\n\t\tend >= 0 &&\n\t\tend < string.getLength() &&\n\t\t(start < end ||\n\t\t\t(start === end &&\n\t\t\t\t(startSlide === SlidingPreference.FORWARD || endSlide !== SlidingPreference.FORWARD)))\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: ISharedString,\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 createSequencePlace(\n\tpos: number,\n\tnewSlidingPreference: SlidingPreference | undefined,\n\toldSlidingPreference: SlidingPreference | undefined = undefined,\n): number | InteriorSequencePlace {\n\treturn newSlidingPreference === SlidingPreference.BACKWARD ||\n\t\t(newSlidingPreference === undefined && oldSlidingPreference === SlidingPreference.BACKWARD)\n\t\t? {\n\t\t\t\tpos,\n\t\t\t\tside: Side.After,\n\t\t\t}\n\t\t: newSlidingPreference === SlidingPreference.FORWARD &&\n\t\t\t\toldSlidingPreference === SlidingPreference.BACKWARD\n\t\t\t? {\n\t\t\t\t\tpos,\n\t\t\t\t\tside: Side.Before,\n\t\t\t\t}\n\t\t\t: pos; // Avoid setting side if possible since stickiness may not be enabled\n}\n\nfunction revertLocalDelete(\n\tstring: ISharedString,\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 (\n\t\tisValidRange(\n\t\t\tstartSlidePos,\n\t\t\trevertible.start.slidingPreference,\n\t\t\tendSlidePos,\n\t\t\trevertible.end.slidingPreference,\n\t\t\tstring,\n\t\t)\n\t) {\n\t\tconst int = collection.add({\n\t\t\tstart: createSequencePlace(startSlidePos, revertible.start.slidingPreference),\n\t\t\tend: createSequencePlace(endSlidePos, revertible.end.slidingPreference),\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: ISharedString,\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\tconst interval = collection.getIntervalById(id);\n\tif (\n\t\tinterval !== undefined &&\n\t\tisValidRange(\n\t\t\tstartSlidePos,\n\t\t\trevertible.start.slidingPreference ?? interval.start.slidingPreference,\n\t\t\tendSlidePos,\n\t\t\trevertible.end.slidingPreference ?? interval.end.slidingPreference,\n\t\t\tstring,\n\t\t)\n\t) {\n\t\tcollection.change(id, {\n\t\t\tstart: createSequencePlace(\n\t\t\t\tstartSlidePos,\n\t\t\t\trevertible.start.slidingPreference,\n\t\t\t\tinterval.start.slidingPreference,\n\t\t\t),\n\t\t\tend: createSequencePlace(\n\t\t\t\tendSlidePos,\n\t\t\t\trevertible.end.slidingPreference,\n\t\t\t\tinterval.end.slidingPreference,\n\t\t\t),\n\t\t});\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalPropertyChanged(\n\tstring: ISharedString,\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).change(id, { props: 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: ISharedString,\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\tsegment: ISegment;\n}\n\n// eslint-disable-next-line import/no-deprecated\nclass SortedRangeSet extends SortedSegmentSet<RangeInfo> {}\n\nfunction revertLocalSequenceRemove(\n\tsharedString: ISharedString,\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({\n\t\t\t\tranges: event.ranges,\n\t\t\t\tlength,\n\t\t\t\tsegment: event.ranges[0].segment,\n\t\t\t});\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 (\n\t\t\t\tisValidRange(\n\t\t\t\t\tstart,\n\t\t\t\t\tinterval.start.slidingPreference,\n\t\t\t\t\tend,\n\t\t\t\t\tinterval.end.slidingPreference,\n\t\t\t\t\tsharedString,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tintervalCollection.change(intervalId, {\n\t\t\t\t\tstart: createSequencePlace(start, interval.start.slidingPreference),\n\t\t\t\t\tend: createSequencePlace(end, interval.end.slidingPreference),\n\t\t\t\t});\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\trevertibleRef.revertible.start.slidingPreference,\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\trevertibleRef.revertible.end.slidingPreference,\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 * @legacy\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: ISharedString,\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/sequence",
3
- "version": "2.13.0",
3
+ "version": "2.20.0",
4
4
  "description": "Distributed sequence",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -79,33 +79,33 @@
79
79
  "temp-directory": "nyc/.nyc_output"
80
80
  },
81
81
  "dependencies": {
82
- "@fluid-internal/client-utils": "~2.13.0",
83
- "@fluidframework/core-interfaces": "~2.13.0",
84
- "@fluidframework/core-utils": "~2.13.0",
85
- "@fluidframework/datastore-definitions": "~2.13.0",
86
- "@fluidframework/driver-definitions": "~2.13.0",
87
- "@fluidframework/merge-tree": "~2.13.0",
88
- "@fluidframework/runtime-definitions": "~2.13.0",
89
- "@fluidframework/runtime-utils": "~2.13.0",
90
- "@fluidframework/shared-object-base": "~2.13.0",
91
- "@fluidframework/telemetry-utils": "~2.13.0",
82
+ "@fluid-internal/client-utils": "~2.20.0",
83
+ "@fluidframework/core-interfaces": "~2.20.0",
84
+ "@fluidframework/core-utils": "~2.20.0",
85
+ "@fluidframework/datastore-definitions": "~2.20.0",
86
+ "@fluidframework/driver-definitions": "~2.20.0",
87
+ "@fluidframework/merge-tree": "~2.20.0",
88
+ "@fluidframework/runtime-definitions": "~2.20.0",
89
+ "@fluidframework/runtime-utils": "~2.20.0",
90
+ "@fluidframework/shared-object-base": "~2.20.0",
91
+ "@fluidframework/telemetry-utils": "~2.20.0",
92
92
  "double-ended-queue": "^2.1.0-0",
93
93
  "uuid": "^9.0.0"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@arethetypeswrong/cli": "^0.17.1",
97
97
  "@biomejs/biome": "~1.9.3",
98
- "@fluid-internal/mocha-test-setup": "~2.13.0",
99
- "@fluid-private/stochastic-test-utils": "~2.13.0",
100
- "@fluid-private/test-dds-utils": "~2.13.0",
98
+ "@fluid-internal/mocha-test-setup": "~2.20.0",
99
+ "@fluid-private/stochastic-test-utils": "~2.20.0",
100
+ "@fluid-private/test-dds-utils": "~2.20.0",
101
101
  "@fluid-tools/benchmark": "^0.50.0",
102
102
  "@fluid-tools/build-cli": "^0.51.0",
103
103
  "@fluidframework/build-common": "^2.0.3",
104
104
  "@fluidframework/build-tools": "^0.51.0",
105
- "@fluidframework/container-definitions": "~2.13.0",
105
+ "@fluidframework/container-definitions": "~2.20.0",
106
106
  "@fluidframework/eslint-config-fluid": "^5.6.0",
107
- "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.12.0",
108
- "@fluidframework/test-runtime-utils": "~2.13.0",
107
+ "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.13.0",
108
+ "@fluidframework/test-runtime-utils": "~2.20.0",
109
109
  "@microsoft/api-extractor": "7.47.8",
110
110
  "@types/diff": "^3.5.1",
111
111
  "@types/double-ended-queue": "^2.1.0",
@@ -136,7 +136,56 @@
136
136
  }
137
137
  },
138
138
  "typeValidation": {
139
- "broken": {},
139
+ "broken": {
140
+ "Class_BaseSegment": {
141
+ "backCompat": false
142
+ },
143
+ "Class_Marker": {
144
+ "backCompat": false
145
+ },
146
+ "Class_TextSegment": {
147
+ "backCompat": false
148
+ },
149
+ "Class_TrackingGroup": {
150
+ "backCompat": false
151
+ },
152
+ "ClassStatics_BaseSegment": {
153
+ "backCompat": false
154
+ },
155
+ "ClassStatics_Marker": {
156
+ "backCompat": false
157
+ },
158
+ "ClassStatics_TextSegment": {
159
+ "backCompat": false
160
+ },
161
+ "ClassStatics_TrackingGroup": {
162
+ "backCompat": false
163
+ },
164
+ "Interface_ISegment": {
165
+ "backCompat": false
166
+ },
167
+ "Interface_ISequenceDeltaRange": {
168
+ "backCompat": false
169
+ },
170
+ "Interface_SequenceDeltaEvent": {
171
+ "backCompat": false
172
+ },
173
+ "Interface_SequenceEvent": {
174
+ "backCompat": false
175
+ },
176
+ "Interface_SequenceMaintenanceEvent": {
177
+ "backCompat": false
178
+ },
179
+ "TypeAlias_IntervalRevertible": {
180
+ "backCompat": false
181
+ },
182
+ "TypeAlias_SharedStringRevertible": {
183
+ "backCompat": false
184
+ },
185
+ "TypeAlias_SharedStringSegment": {
186
+ "backCompat": false
187
+ }
188
+ },
140
189
  "entrypoint": "legacy"
141
190
  },
142
191
  "scripts": {
@@ -29,6 +29,7 @@ import {
29
29
  endpointPosAndSide,
30
30
  addProperties,
31
31
  copyPropertiesAndManager,
32
+ type ISegmentInternal,
32
33
  } from "@fluidframework/merge-tree/internal";
33
34
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
34
35
 
@@ -196,8 +197,8 @@ export class SequenceIntervalClass implements SequenceInterval {
196
197
 
197
198
  /***/
198
199
  public get stickiness(): IntervalStickiness {
199
- const startSegment = this.start.getSegment();
200
- const endSegment = this.end.getSegment();
200
+ const startSegment: ISegmentInternal | undefined = this.start.getSegment();
201
+ const endSegment: ISegmentInternal | undefined = this.end.getSegment();
201
202
  return computeStickinessFromSide(
202
203
  startSegment?.endpointType,
203
204
  this.startSide,
@@ -428,10 +429,12 @@ export class SequenceIntervalClass implements SequenceInterval {
428
429
  useNewSlidingBehavior: boolean = false,
429
430
  ) {
430
431
  const { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);
432
+ const startSegment: ISegmentInternal | undefined = this.start.getSegment();
433
+ const endSegment: ISegmentInternal | undefined = this.end.getSegment();
431
434
  const stickiness = computeStickinessFromSide(
432
- startPos ?? this.start.getSegment()?.endpointType,
435
+ startPos ?? startSegment?.endpointType,
433
436
  startSide ?? this.startSide,
434
- endPos ?? this.end.getSegment()?.endpointType,
437
+ endPos ?? endSegment?.endpointType,
435
438
  endSide ?? this.endSide,
436
439
  );
437
440
  const getRefType = (baseType: ReferenceType): ReferenceType => {