@fluidframework/sequence 2.0.0-internal.7.2.1 → 2.0.0-internal.7.3.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-extractor.json +4 -1
  3. package/dist/intervalCollection.d.ts +2 -2
  4. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  5. package/dist/intervals/intervalUtils.js +1 -0
  6. package/dist/intervals/intervalUtils.js.map +1 -1
  7. package/dist/packageVersion.d.ts +1 -1
  8. package/dist/packageVersion.js +1 -1
  9. package/dist/packageVersion.js.map +1 -1
  10. package/dist/revertibles.d.ts.map +1 -1
  11. package/dist/revertibles.js +34 -12
  12. package/dist/revertibles.js.map +1 -1
  13. package/dist/sequence-alpha.d.ts +1587 -0
  14. package/dist/sequence-beta.d.ts +1507 -0
  15. package/dist/sequence-public.d.ts +1507 -0
  16. package/dist/sequence-untrimmed.d.ts +1759 -0
  17. package/dist/sequence.d.ts.map +1 -1
  18. package/dist/sequence.js +3 -4
  19. package/dist/sequence.js.map +1 -1
  20. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  21. package/dist/sequenceDeltaEvent.js +1 -0
  22. package/dist/sequenceDeltaEvent.js.map +1 -1
  23. package/dist/tsdoc-metadata.json +1 -1
  24. package/lib/intervalCollection.d.ts +2 -2
  25. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  26. package/lib/intervals/intervalUtils.js +1 -0
  27. package/lib/intervals/intervalUtils.js.map +1 -1
  28. package/lib/packageVersion.d.ts +1 -1
  29. package/lib/packageVersion.js +1 -1
  30. package/lib/packageVersion.js.map +1 -1
  31. package/lib/revertibles.d.ts.map +1 -1
  32. package/lib/revertibles.js +34 -12
  33. package/lib/revertibles.js.map +1 -1
  34. package/lib/sequence-alpha.d.ts +1587 -0
  35. package/lib/sequence-beta.d.ts +1507 -0
  36. package/lib/sequence-public.d.ts +1507 -0
  37. package/lib/sequence-untrimmed.d.ts +1759 -0
  38. package/lib/sequence.d.ts.map +1 -1
  39. package/lib/sequence.js +2 -7
  40. package/lib/sequence.js.map +1 -1
  41. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  42. package/lib/sequenceDeltaEvent.js +1 -0
  43. package/lib/sequenceDeltaEvent.js.map +1 -1
  44. package/package.json +36 -28
  45. package/src/intervals/intervalUtils.ts +1 -0
  46. package/src/packageVersion.ts +1 -1
  47. package/src/revertibles.ts +86 -9
  48. package/src/sequence.ts +3 -4
  49. package/src/sequenceDeltaEvent.ts +2 -0
  50. package/tsconfig.esnext.json +1 -2
  51. package/tsconfig.json +5 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/sequence
2
2
 
3
+ ## 2.0.0-internal.7.3.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-internal.7.2.0
4
8
 
5
9
  ### Minor Changes
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "@fluidframework/build-common/api-extractor-base.json"
3
+ "extends": "@fluidframework/build-common/api-extractor-base.json",
4
+ "dtsRollup": {
5
+ "enabled": true
6
+ }
4
7
  }
@@ -67,8 +67,8 @@ export declare function sidesFromStickiness(stickiness: IntervalStickiness): {
67
67
  export declare function endpointPosAndSide(start: SequencePlace | undefined, end: SequencePlace | undefined): {
68
68
  startSide: Side | undefined;
69
69
  endSide: Side | undefined;
70
- startPos: number | "start" | "end" | undefined;
71
- endPos: number | "start" | "end" | undefined;
70
+ startPos: number | "end" | "start" | undefined;
71
+ endPos: number | "end" | "start" | undefined;
72
72
  };
73
73
  export declare function computeStickinessFromSide(startPos?: number | "start" | "end" | undefined, startSide?: Side, endPos?: number | "start" | "end" | undefined, endSide?: Side): IntervalStickiness;
74
74
  export declare function createIntervalIndex(): LocalIntervalCollection<Interval>;
@@ -1 +1 @@
1
- {"version":3,"file":"intervalU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C,EAAE,OAAO,EACtB,qBAAqB,CAAC,EAAE,OAAO,GAC7B,SAAS,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;;;OAIG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE9F,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,kBAAkB,GAAG,iBAAiB,CAKjG;AAED,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,kBAAkB,GAAG,iBAAiB,CAK/F"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.endReferenceSlidingPreference = exports.startReferenceSlidingPreference = exports.IntervalStickiness = exports.IntervalType = exports.IntervalOpType = void 0;
8
+ /* eslint-disable import/no-deprecated */
8
9
  /* eslint-disable no-bitwise */
9
10
  const merge_tree_1 = require("@fluidframework/merge-tree");
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"intervalUtils.js","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,2DAKoC;AA2DpC;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC7B,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,iBAAiB;IACnC,eAAe,EAAE,gBAAgB;CACxB,CAAC;AAEX;;GAEG;AACH,IAAY,YAoBX;AApBD,WAAY,YAAY;IACvB,mDAAY,CAAA;IACZ;;OAEG;IACH,+CAAU,CAAA;IAEV;;;;;OAKG;IACH,iEAAmB,CAAA;IAEnB;;;OAGG;IACH,yDAAe,CAAA;AAChB,CAAC,EApBW,YAAY,4BAAZ,YAAY,QAoBvB;AA+HD;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG;IACjC;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;OAEG;IACH,KAAK,EAAE,IAAI;IAEX;;;;OAIG;IACH,GAAG,EAAE,IAAI;IAET;;OAEG;IACH,IAAI,EAAE,IAAI;CACD,CAAC;AAaX,SAAgB,+BAA+B,CAAC,UAA8B;IAC7E,oDAAoD;IACpD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QACnD,CAAC,CAAC,8BAAiB,CAAC,OAAO;QAC3B,CAAC,CAAC,8BAAiB,CAAC,QAAQ,CAAC;AAC/B,CAAC;AALD,0EAKC;AAED,SAAgB,6BAA6B,CAAC,UAA8B;IAC3E,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QACjD,CAAC,CAAC,8BAAiB,CAAC,QAAQ;QAC5B,CAAC,CAAC,8BAAiB,CAAC,OAAO,CAAC;AAC9B,CAAC;AALD,sEAKC","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 {\n\tClient,\n\tPropertiesManager,\n\tPropertySet,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { SequencePlace, Side } from \"../intervalCollection\";\n\n/**\n * Basic interval abstraction\n * @public\n */\nexport interface IInterval {\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): IInterval;\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: IInterval): 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: IInterval): 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: IInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t * @internal\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): IInterval | 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: IInterval): 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 * @internal\n\t */\n\tunion(b: IInterval): IInterval;\n}\n\n/**\n * Values are used in persisted formats (ops) and revertibles.\n * @alpha\n */\nexport const IntervalOpType = {\n\tADD: \"add\",\n\tDELETE: \"delete\",\n\tCHANGE: \"change\",\n\tPROPERTY_CHANGED: \"propertyChanged\",\n\tPOSITION_REMOVE: \"positionRemove\",\n} as const;\n\n/**\n * @public\n */\nexport enum IntervalType {\n\tSimple = 0x0,\n\t/**\n\t * @deprecated this functionality is no longer supported and will be removed\n\t */\n\tNest = 0x1,\n\n\t/**\n\t * SlideOnRemove indicates that the ends of the interval will slide if the segment\n\t * they reference is removed and acked.\n\t * See `packages\\dds\\merge-tree\\docs\\REFERENCEPOSITIONS.md` for details\n\t * SlideOnRemove is the default interval behavior and does not need to be specified.\n\t */\n\tSlideOnRemove = 0x2, // SlideOnRemove is default behavior - all intervals are SlideOnRemove\n\n\t/**\n\t * A temporary interval, used internally\n\t * @internal\n\t */\n\tTransient = 0x4,\n}\n\n/**\n * Serialized object representation of an interval.\n * This representation is used for ops that create or change intervals.\n * @internal\n */\nexport interface ISerializedInterval {\n\t/**\n\t * Sequence number at which `start` and `end` should be interpreted\n\t *\n\t * @remarks It's unclear that this is necessary to store here.\n\t * This should just be the refSeq on the op that modified the interval, which should be available via other means.\n\t * At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.\n\t */\n\tsequenceNumber: number;\n\t/** Start position of the interval */\n\tstart: number | \"start\" | \"end\";\n\t/** End position of the interval */\n\tend: number | \"start\" | \"end\";\n\t/** Interval type to create */\n\tintervalType: IntervalType;\n\t/**\n\t * The stickiness of this interval\n\t */\n\tstickiness?: IntervalStickiness;\n\tstartSide?: Side;\n\tendSide?: Side;\n\t/** Any properties the interval has */\n\tproperties?: PropertySet;\n}\n\n/**\n * @public\n */\nexport interface ISerializableInterval extends IInterval {\n\t/** Serializable bag of properties associated with the interval. */\n\tproperties: PropertySet;\n\t/** @internal */\n\tpropertyManager: PropertiesManager;\n\t/** @internal */\n\tserialize(): ISerializedInterval;\n\t/** @internal */\n\taddProperties(\n\t\tprops: PropertySet,\n\t\tcollaborating?: boolean,\n\t\tseq?: number,\n\t): PropertySet | undefined;\n\t/**\n\t * Gets the id associated with this interval.\n\t * When the interval is used as part of an interval collection, this id can be used to modify or remove the\n\t * interval.\n\t * @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions\n\t * of Fluid didn't always write interval ids.\n\t */\n\tgetIntervalId(): string | undefined;\n}\n\n/**\n * Represents a change that should be applied to an existing interval.\n * Changes can modify any of start/end/properties, with `undefined` signifying no change should be made.\n * @internal\n */\nexport type SerializedIntervalDelta = Omit<ISerializedInterval, \"start\" | \"end\" | \"properties\"> &\n\tPartial<Pick<ISerializedInterval, \"start\" | \"end\" | \"properties\">>;\n\n/**\n * A size optimization to avoid redundantly storing keys when serializing intervals\n * as JSON for summaries.\n *\n * Intervals are of the format:\n *\n * [\n * start,\n * end,\n * sequenceNumber,\n * intervalType,\n * properties,\n * stickiness?,\n * startSide?,\n * endSide?,\n * ]\n */\nexport type CompressedSerializedInterval =\n\t| [\n\t\t\tnumber | \"start\" | \"end\",\n\t\t\tnumber | \"start\" | \"end\",\n\t\t\tnumber,\n\t\t\tIntervalType,\n\t\t\tPropertySet,\n\t\t\tIntervalStickiness,\n\t ]\n\t| [number | \"start\" | \"end\", number | \"start\" | \"end\", number, IntervalType, PropertySet];\n\n/**\n * @sealed\n * @deprecated The methods within have substitutions\n * @public\n */\nexport interface IIntervalHelpers<TInterval extends ISerializableInterval> {\n\t/**\n\t *\n\t * @param label - label of the interval collection this interval is being added to. This parameter is\n\t * irrelevant for transient intervals.\n\t * @param start - numerical start position of the interval\n\t * @param end - numerical end position of the interval\n\t * @param client - client creating the interval\n\t * @param intervalType - Type of interval to create. Default is SlideOnRemove\n\t * @param op - If this create came from a remote client, op that created it. Default is undefined (i.e. local)\n\t * @param fromSnapshot - If this create came from loading a snapshot. Default is false.\n\t * @param startSide - The side on which the start position lays. See\n\t * {@link SequencePlace} for additional context\n\t * @param endSide - The side on which the end position lays. See\n\t * {@link SequencePlace} for additional context\n\t */\n\tcreate(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\tclient: Client | undefined,\n\t\tintervalType: IntervalType,\n\t\top?: ISequencedDocumentMessage,\n\t\tfromSnapshot?: boolean,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): TInterval;\n}\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n *\n * @internal\n */\nexport const IntervalStickiness = {\n\t/**\n\t * Interval does not expand to include adjacent segments\n\t */\n\tNONE: 0b00,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the start\n\t */\n\tSTART: 0b01,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the end\n\t *\n\t * This is the default stickiness\n\t */\n\tEND: 0b10,\n\n\t/**\n\t * Interval expands to include all segments inserted adjacent to it\n\t */\n\tFULL: 0b11,\n} as const;\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n *\n * @internal\n */\nexport type IntervalStickiness = (typeof IntervalStickiness)[keyof typeof IntervalStickiness];\n\nexport function startReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any start stickiness, prefer sliding backwards\n\treturn (stickiness & IntervalStickiness.START) === 0\n\t\t? SlidingPreference.FORWARD\n\t\t: SlidingPreference.BACKWARD;\n}\n\nexport function endReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any end stickiness, prefer sliding forwards\n\treturn (stickiness & IntervalStickiness.END) === 0\n\t\t? SlidingPreference.BACKWARD\n\t\t: SlidingPreference.FORWARD;\n}\n"]}
1
+ {"version":3,"file":"intervalUtils.js","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AACzC,+BAA+B;AAE/B,2DAKoC;AA2DpC;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC7B,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,iBAAiB;IACnC,eAAe,EAAE,gBAAgB;CACxB,CAAC;AAEX;;GAEG;AACH,IAAY,YAoBX;AApBD,WAAY,YAAY;IACvB,mDAAY,CAAA;IACZ;;OAEG;IACH,+CAAU,CAAA;IAEV;;;;;OAKG;IACH,iEAAmB,CAAA;IAEnB;;;OAGG;IACH,yDAAe,CAAA;AAChB,CAAC,EApBW,YAAY,4BAAZ,YAAY,QAoBvB;AA+HD;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG;IACjC;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;OAEG;IACH,KAAK,EAAE,IAAI;IAEX;;;;OAIG;IACH,GAAG,EAAE,IAAI;IAET;;OAEG;IACH,IAAI,EAAE,IAAI;CACD,CAAC;AAaX,SAAgB,+BAA+B,CAAC,UAA8B;IAC7E,oDAAoD;IACpD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QACnD,CAAC,CAAC,8BAAiB,CAAC,OAAO;QAC3B,CAAC,CAAC,8BAAiB,CAAC,QAAQ,CAAC;AAC/B,CAAC;AALD,0EAKC;AAED,SAAgB,6BAA6B,CAAC,UAA8B;IAC3E,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QACjD,CAAC,CAAC,8BAAiB,CAAC,QAAQ;QAC5B,CAAC,CAAC,8BAAiB,CAAC,OAAO,CAAC;AAC9B,CAAC;AALD,sEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n/* eslint-disable no-bitwise */\n\nimport {\n\tClient,\n\tPropertiesManager,\n\tPropertySet,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { SequencePlace, Side } from \"../intervalCollection\";\n\n/**\n * Basic interval abstraction\n * @public\n */\nexport interface IInterval {\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): IInterval;\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: IInterval): 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: IInterval): 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: IInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t * @internal\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): IInterval | 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: IInterval): 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 * @internal\n\t */\n\tunion(b: IInterval): IInterval;\n}\n\n/**\n * Values are used in persisted formats (ops) and revertibles.\n * @alpha\n */\nexport const IntervalOpType = {\n\tADD: \"add\",\n\tDELETE: \"delete\",\n\tCHANGE: \"change\",\n\tPROPERTY_CHANGED: \"propertyChanged\",\n\tPOSITION_REMOVE: \"positionRemove\",\n} as const;\n\n/**\n * @public\n */\nexport enum IntervalType {\n\tSimple = 0x0,\n\t/**\n\t * @deprecated this functionality is no longer supported and will be removed\n\t */\n\tNest = 0x1,\n\n\t/**\n\t * SlideOnRemove indicates that the ends of the interval will slide if the segment\n\t * they reference is removed and acked.\n\t * See `packages\\dds\\merge-tree\\docs\\REFERENCEPOSITIONS.md` for details\n\t * SlideOnRemove is the default interval behavior and does not need to be specified.\n\t */\n\tSlideOnRemove = 0x2, // SlideOnRemove is default behavior - all intervals are SlideOnRemove\n\n\t/**\n\t * A temporary interval, used internally\n\t * @internal\n\t */\n\tTransient = 0x4,\n}\n\n/**\n * Serialized object representation of an interval.\n * This representation is used for ops that create or change intervals.\n * @internal\n */\nexport interface ISerializedInterval {\n\t/**\n\t * Sequence number at which `start` and `end` should be interpreted\n\t *\n\t * @remarks It's unclear that this is necessary to store here.\n\t * This should just be the refSeq on the op that modified the interval, which should be available via other means.\n\t * At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.\n\t */\n\tsequenceNumber: number;\n\t/** Start position of the interval */\n\tstart: number | \"start\" | \"end\";\n\t/** End position of the interval */\n\tend: number | \"start\" | \"end\";\n\t/** Interval type to create */\n\tintervalType: IntervalType;\n\t/**\n\t * The stickiness of this interval\n\t */\n\tstickiness?: IntervalStickiness;\n\tstartSide?: Side;\n\tendSide?: Side;\n\t/** Any properties the interval has */\n\tproperties?: PropertySet;\n}\n\n/**\n * @public\n */\nexport interface ISerializableInterval extends IInterval {\n\t/** Serializable bag of properties associated with the interval. */\n\tproperties: PropertySet;\n\t/** @internal */\n\tpropertyManager: PropertiesManager;\n\t/** @internal */\n\tserialize(): ISerializedInterval;\n\t/** @internal */\n\taddProperties(\n\t\tprops: PropertySet,\n\t\tcollaborating?: boolean,\n\t\tseq?: number,\n\t): PropertySet | undefined;\n\t/**\n\t * Gets the id associated with this interval.\n\t * When the interval is used as part of an interval collection, this id can be used to modify or remove the\n\t * interval.\n\t * @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions\n\t * of Fluid didn't always write interval ids.\n\t */\n\tgetIntervalId(): string | undefined;\n}\n\n/**\n * Represents a change that should be applied to an existing interval.\n * Changes can modify any of start/end/properties, with `undefined` signifying no change should be made.\n * @internal\n */\nexport type SerializedIntervalDelta = Omit<ISerializedInterval, \"start\" | \"end\" | \"properties\"> &\n\tPartial<Pick<ISerializedInterval, \"start\" | \"end\" | \"properties\">>;\n\n/**\n * A size optimization to avoid redundantly storing keys when serializing intervals\n * as JSON for summaries.\n *\n * Intervals are of the format:\n *\n * [\n * start,\n * end,\n * sequenceNumber,\n * intervalType,\n * properties,\n * stickiness?,\n * startSide?,\n * endSide?,\n * ]\n */\nexport type CompressedSerializedInterval =\n\t| [\n\t\t\tnumber | \"start\" | \"end\",\n\t\t\tnumber | \"start\" | \"end\",\n\t\t\tnumber,\n\t\t\tIntervalType,\n\t\t\tPropertySet,\n\t\t\tIntervalStickiness,\n\t ]\n\t| [number | \"start\" | \"end\", number | \"start\" | \"end\", number, IntervalType, PropertySet];\n\n/**\n * @sealed\n * @deprecated The methods within have substitutions\n * @public\n */\nexport interface IIntervalHelpers<TInterval extends ISerializableInterval> {\n\t/**\n\t *\n\t * @param label - label of the interval collection this interval is being added to. This parameter is\n\t * irrelevant for transient intervals.\n\t * @param start - numerical start position of the interval\n\t * @param end - numerical end position of the interval\n\t * @param client - client creating the interval\n\t * @param intervalType - Type of interval to create. Default is SlideOnRemove\n\t * @param op - If this create came from a remote client, op that created it. Default is undefined (i.e. local)\n\t * @param fromSnapshot - If this create came from loading a snapshot. Default is false.\n\t * @param startSide - The side on which the start position lays. See\n\t * {@link SequencePlace} for additional context\n\t * @param endSide - The side on which the end position lays. See\n\t * {@link SequencePlace} for additional context\n\t */\n\tcreate(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\tclient: Client | undefined,\n\t\tintervalType: IntervalType,\n\t\top?: ISequencedDocumentMessage,\n\t\tfromSnapshot?: boolean,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): TInterval;\n}\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n *\n * @internal\n */\nexport const IntervalStickiness = {\n\t/**\n\t * Interval does not expand to include adjacent segments\n\t */\n\tNONE: 0b00,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the start\n\t */\n\tSTART: 0b01,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the end\n\t *\n\t * This is the default stickiness\n\t */\n\tEND: 0b10,\n\n\t/**\n\t * Interval expands to include all segments inserted adjacent to it\n\t */\n\tFULL: 0b11,\n} as const;\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n *\n * @internal\n */\nexport type IntervalStickiness = (typeof IntervalStickiness)[keyof typeof IntervalStickiness];\n\nexport function startReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any start stickiness, prefer sliding backwards\n\treturn (stickiness & IntervalStickiness.START) === 0\n\t\t? SlidingPreference.FORWARD\n\t\t: SlidingPreference.BACKWARD;\n}\n\nexport function endReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any end stickiness, prefer sliding forwards\n\treturn (stickiness & IntervalStickiness.END) === 0\n\t\t? SlidingPreference.BACKWARD\n\t\t: SlidingPreference.FORWARD;\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.0.0-internal.7.2.1";
8
+ export declare const pkgVersion = "2.0.0-internal.7.3.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/sequence";
11
- exports.pkgVersion = "2.0.0-internal.7.2.1";
11
+ exports.pkgVersion = "2.0.0-internal.7.3.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,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.0.0-internal.7.2.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,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.0.0-internal.7.3.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.d.ts","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,sBAAsB,EAEtB,wBAAwB,EAExB,WAAW,EAMX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAuB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,wBAAwB,GAAG,kBAAkB,CAAC;AAInF,KAAK,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAC3B;IACA,KAAK,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,GAAG,EAAE,sBAAsB,CAAC;CAC3B,GACD;IACA,KAAK,EAAE,OAAO,cAAc,CAAC,GAAG,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;CAC1B,GACD;IACA,KAAK,EAAE,OA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,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,EAAE,QAUrC;AAoRD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,EAAE,QA8BrC"}
@@ -3,11 +3,13 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- /* eslint-disable no-bitwise */
7
6
  Object.defineProperty(exports, "__esModule", { value: true });
8
7
  exports.revertSharedStringRevertibles = exports.discardSharedStringRevertibles = exports.appendSharedStringDeltaToRevertibles = exports.appendIntervalPropertyChangedToRevertibles = exports.appendChangeIntervalToRevertibles = exports.appendDeleteIntervalToRevertibles = exports.appendAddIntervalToRevertibles = void 0;
8
+ /* eslint-disable import/no-deprecated */
9
+ /* eslint-disable no-bitwise */
9
10
  const core_utils_1 = require("@fluidframework/core-utils");
10
11
  const merge_tree_1 = require("@fluidframework/merge-tree");
12
+ const intervalCollection_1 = require("./intervalCollection");
11
13
  const intervals_1 = require("./intervals");
12
14
  const idMap = new Map();
13
15
  function getUpdatedIdFromInterval(interval) {
@@ -227,18 +229,36 @@ function getSlidePosition(string, lref, pos) {
227
229
  ? string.getPosition(slide.segment) + slide.offset
228
230
  : pos;
229
231
  }
230
- function isValidRange(start, end, string) {
232
+ function isValidRange(start, startSlide, end, endSlide, string) {
231
233
  return (start >= 0 &&
232
234
  start < string.getLength() &&
233
235
  end >= 0 &&
234
236
  end < string.getLength() &&
235
- start <= end);
237
+ (start < end ||
238
+ (start === end &&
239
+ (startSlide === merge_tree_1.SlidingPreference.FORWARD ||
240
+ endSlide !== merge_tree_1.SlidingPreference.FORWARD))));
236
241
  }
237
242
  function revertLocalAdd(string, revertible) {
238
243
  const id = getUpdatedIdFromInterval(revertible.interval);
239
244
  const label = revertible.interval.properties.referenceRangeLabels[0];
240
245
  string.getIntervalCollection(label).removeIntervalById(id);
241
246
  }
247
+ function createSequencePlace(pos, newSlidingPreference, oldSlidingPreference = undefined) {
248
+ return newSlidingPreference === merge_tree_1.SlidingPreference.BACKWARD ||
249
+ (newSlidingPreference === undefined && oldSlidingPreference === merge_tree_1.SlidingPreference.BACKWARD)
250
+ ? {
251
+ pos,
252
+ side: intervalCollection_1.Side.After,
253
+ }
254
+ : newSlidingPreference === merge_tree_1.SlidingPreference.FORWARD &&
255
+ oldSlidingPreference === merge_tree_1.SlidingPreference.BACKWARD
256
+ ? {
257
+ pos,
258
+ side: intervalCollection_1.Side.Before,
259
+ }
260
+ : pos; // Avoid setting side if possible since stickiness may not be enabled
261
+ }
242
262
  function revertLocalDelete(string, revertible) {
243
263
  const label = revertible.interval.properties.referenceRangeLabels[0];
244
264
  const collection = string.getIntervalCollection(label);
@@ -248,10 +268,10 @@ function revertLocalDelete(string, revertible) {
248
268
  const endSlidePos = getSlidePosition(string, revertible.end, end);
249
269
  // reusing the id causes eventual consistency bugs, so it is removed here and recreated in add
250
270
  const { intervalId, ...props } = revertible.interval.properties;
251
- if (isValidRange(startSlidePos, endSlidePos, string)) {
271
+ if (isValidRange(startSlidePos, revertible.start.slidingPreference, endSlidePos, revertible.end.slidingPreference, string)) {
252
272
  const int = collection.add({
253
- start: startSlidePos,
254
- end: endSlidePos,
273
+ start: createSequencePlace(startSlidePos, revertible.start.slidingPreference),
274
+ end: createSequencePlace(endSlidePos, revertible.end.slidingPreference),
255
275
  props,
256
276
  });
257
277
  idMap.forEach((newId, oldId) => {
@@ -272,8 +292,10 @@ function revertLocalChange(string, revertible) {
272
292
  const startSlidePos = getSlidePosition(string, revertible.start, start);
273
293
  const end = string.localReferencePositionToPosition(revertible.end);
274
294
  const endSlidePos = getSlidePosition(string, revertible.end, end);
275
- if (isValidRange(startSlidePos, endSlidePos, string)) {
276
- collection.change(id, startSlidePos, endSlidePos);
295
+ const interval = collection.getIntervalById(id);
296
+ if (interval !== undefined &&
297
+ isValidRange(startSlidePos, revertible.start.slidingPreference ?? interval.start.slidingPreference, endSlidePos, revertible.end.slidingPreference ?? interval.end.slidingPreference, string)) {
298
+ collection.change(id, createSequencePlace(startSlidePos, revertible.start.slidingPreference, interval.start.slidingPreference), createSequencePlace(endSlidePos, revertible.end.slidingPreference, interval.end.slidingPreference));
277
299
  }
278
300
  string.removeLocalReferencePosition(revertible.start);
279
301
  string.removeLocalReferencePosition(revertible.end);
@@ -335,8 +357,8 @@ function revertLocalSequenceRemove(sharedString, revertible) {
335
357
  sharedString.localReferencePositionToPosition(interval.start);
336
358
  const end = newEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString) ??
337
359
  sharedString.localReferencePositionToPosition(interval.end);
338
- if (start <= end) {
339
- intervalCollection.change(intervalId, start, end);
360
+ if (isValidRange(start, interval.start.slidingPreference, end, interval.end.slidingPreference, sharedString)) {
361
+ intervalCollection.change(intervalId, createSequencePlace(start, interval.start.slidingPreference), createSequencePlace(end, interval.end.slidingPreference));
340
362
  }
341
363
  }
342
364
  });
@@ -348,12 +370,12 @@ function revertLocalSequenceRemove(sharedString, revertible) {
348
370
  if (pos !== undefined) {
349
371
  if (revertibleRef.isStart) {
350
372
  sharedString.removeLocalReferencePosition(revertibleRef.revertible.start);
351
- const newRef = sharedString.createLocalReferencePosition(pos.segment, pos.offset, merge_tree_1.ReferenceType.StayOnRemove | merge_tree_1.ReferenceType.RangeBegin, { revertible: revertibleRef.revertible });
373
+ const newRef = sharedString.createLocalReferencePosition(pos.segment, pos.offset, merge_tree_1.ReferenceType.StayOnRemove | merge_tree_1.ReferenceType.RangeBegin, { revertible: revertibleRef.revertible }, revertibleRef.revertible.start.slidingPreference);
352
374
  revertibleRef.revertible.start = newRef;
353
375
  }
354
376
  else {
355
377
  sharedString.removeLocalReferencePosition(revertibleRef.revertible.end);
356
- const newRef = sharedString.createLocalReferencePosition(pos.segment, pos.offset, merge_tree_1.ReferenceType.StayOnRemove | merge_tree_1.ReferenceType.RangeEnd, { revertible: revertibleRef.revertible });
378
+ const newRef = sharedString.createLocalReferencePosition(pos.segment, pos.offset, merge_tree_1.ReferenceType.StayOnRemove | merge_tree_1.ReferenceType.RangeEnd, { revertible: revertibleRef.revertible }, revertibleRef.revertible.end.slidingPreference);
357
379
  revertibleRef.revertible.end = newRef;
358
380
  }
359
381
  }
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,+BAA+B;;;AAE/B,2DAAqE;AACrE,2DAcoC;AACpC,2CAA+D;AAW/D,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;;;GAGG;AACH,SAAgB,8BAA8B,CAC7C,QAA0B,EAC1B,WAAqC;IAErC,WAAW,CAAC,IAAI,CAAC;QAChB,KAAK,EAAE,0BAAc,CAAC,GAAG;QACzB,QAAQ;KACR,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC;AAVD,wEAUC;AAED;;;GAGG;AACH,SAAgB,iCAAiC,CAChD,MAAoB,EACpB,QAA0B,EAC1B,WAAqC;IAErC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAyB,CAAC;IACpE,MAAM,SAAS,GACd,QAAQ,CAAC,UAAU,KAAK,SAAS;QAChC,CAAC,CAAC,0BAAa,CAAC,aAAa,GAAG,0BAAa,CAAC,UAAU;QACxD,CAAC,CAAC,0BAAa,CAAC,YAAY,GAAG,0BAAa,CAAC,UAAU,CAAC;IAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAyB,CAAC;I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C,KAAK,CAAC;YACtB,QAAQ,KAAK,EAAE;gBACd,KAAK,0BAAc,CAAC,GAAG;oBACtB,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAChC,MAAM;gBACP,KAAK,0BAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,0BAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,0BAAc,CAAC,gBAAgB;oBACnC,0BAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC5C,MAAM;gBACP,KAAK,0BAAc,CAAC,eAAe;oBAClC,yBAAyB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC3C,MAAM;gBACP;oBACC,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAC;aACxB;SACD;aAAM;YACN,IAAA,4CAA+B,EAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;KACD;AACF,CAAC;AAhCD,sEAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable no-bitwise */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tSortedSet,\n\tgetSlideToSegoff,\n} from \"@fluidframework/merge-tree\";\nimport { IntervalOpType, SequenceInterval } from \"./intervals\";\nimport { SharedString, SharedStringSegment } from \"./sharedString\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n *\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\ntype IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];\n\n/**\n * Data for undoing edits affecting Intervals.\n *\n * @alpha\n */\nexport type IntervalRevertible =\n\t| {\n\t\t\tevent: typeof IntervalOpType.CHANGE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.ADD;\n\t\t\tinterval: SequenceInterval;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.DELETE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.PROPERTY_CHANGED;\n\t\t\tinterval: SequenceInterval;\n\t\t\tpropertyDeltas: PropertySet;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.POSITION_REMOVE;\n\t\t\tintervals: {\n\t\t\t\tintervalId: string;\n\t\t\t\tlabel: string;\n\t\t\t\tstartOffset?: number; // interval start index within a removed range\n\t\t\t\tendOffset?: number; // interval end index within a removed range\n\t\t\t}[];\n\t\t\t// local refs used by IntervalOpType.CHANGE and DELETE revertibles\n\t\t\trevertibleRefs: {\n\t\t\t\trevertible: IntervalRevertible;\n\t\t\t\toffset: number;\n\t\t\t\tisStart: boolean;\n\t\t\t}[];\n\t\t\tmergeTreeRevertible: MergeTreeDeltaRevertible;\n\t };\n\ntype TypedRevertible<T extends IntervalRevertible[\"event\"]> = IntervalRevertible & { event: T };\n\nfunction getUpdatedIdFromInterval(interval: SequenceInterval): string {\n\tconst maybeId = interval.getIntervalId();\n\treturn getUpdatedId(maybeId);\n}\n\nfunction getUpdatedId(intervalId: string): string {\n\treturn idMap.get(intervalId) ?? intervalId;\n}\n\n/**\n * Create revertibles for adding an interval\n * @alpha\n */\nexport function appendAddIntervalToRevertibles(\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.ADD,\n\t\tinterval,\n\t});\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for deleting an interval\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: SharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment;\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst startRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tinterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tinterval.start.slidingPreference,\n\t);\n\tconst endRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tinterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tinterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.DELETE,\n\t\tinterval,\n\t\tstart: startRef,\n\t\tend: endRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for moving endpoints of an interval\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: SharedString,\n\tnewInterval: SequenceInterval,\n\tpreviousInterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = previousInterval.start.getSegment() as SharedStringSegment;\n\t// This logic is needed because the ReferenceType StayOnRemove cannot be used\n\t// on removed segments. This works for revertibles because the old position of the\n\t// interval within the removed segment is handled by the remove range revertible.\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst prevStartRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tpreviousInterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tpreviousInterval.start.slidingPreference,\n\t);\n\tconst prevEndRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tpreviousInterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tpreviousInterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.CHANGE,\n\t\tinterval: newInterval,\n\t\tstart: prevStartRef,\n\t\tend: prevEndRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for changing properties of an interval\n * @alpha\n */\nexport function appendIntervalPropertyChangedToRevertibles(\n\tinterval: SequenceInterval,\n\tdeltas: PropertySet,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.PROPERTY_CHANGED,\n\t\tinterval,\n\t\tpropertyDeltas: deltas,\n\t});\n\n\treturn revertibles;\n}\n\nfunction addIfIntervalEndpoint(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\tstartIntervals: { offset: number; interval: SequenceInterval }[],\n\tendIntervals: { offset: number; interval: SequenceInterval }[],\n) {\n\tif (refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tstartIntervals.push({ offset: segmentLengths + interval.start.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t} else if (refTypeIncludesFlag(ref.refType, ReferenceType.RangeEnd)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tendIntervals.push({ offset: segmentLengths + interval.end.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction addIfRevertibleRef(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\trevertibleRefs: {\n\t\trevertible: IntervalRevertible;\n\t\toffset: number;\n\t\tisStart: boolean;\n\t}[],\n) {\n\tconst revertible = ref.properties?.revertible;\n\tif (revertible) {\n\t\trevertibleRefs.push({\n\t\t\trevertible,\n\t\t\toffset: segmentLengths + ref.getOffset(),\n\t\t\tisStart: refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin),\n\t\t});\n\t}\n}\n\n/**\n * Create revertibles for SharedStringDeltas, handling indirectly modified intervals\n * (e.g. reverting remove of a range that contains an interval will move the interval back)\n *\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: SharedString,\n\tdelta: SequenceDeltaEvent,\n\trevertibles: SharedStringRevertible[],\n) {\n\tif (delta.ranges.length === 0) {\n\t\treturn;\n\t}\n\tif (delta.deltaOperation === MergeTreeDeltaType.REMOVE) {\n\t\tconst startIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst endIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst revertibleRefs: {\n\t\t\trevertible: IntervalRevertible;\n\t\t\toffset: number;\n\t\t\tisStart: boolean;\n\t\t}[] = [];\n\t\tlet segmentLengths = 0;\n\n\t\t// find interval endpoints in each segment\n\t\tfor (const deltaRange of delta.ranges) {\n\t\t\tconst refs = deltaRange.segment.localRefs;\n\t\t\tif (refs !== undefined && deltaRange.position !== -1) {\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\taddIfIntervalEndpoint(ref, segmentLengths, startIntervals, endIntervals);\n\t\t\t\t\taddIfRevertibleRef(ref, segmentLengths, revertibleRefs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegmentLengths += deltaRange.segment.cachedLength;\n\t\t}\n\n\t\tif (startIntervals.length > 0 || endIntervals.length > 0 || revertibleRefs.length > 0) {\n\t\t\tconst removeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t\t\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, removeRevertibles);\n\t\t\tassert(\n\t\t\t\tremoveRevertibles.length === 1,\n\t\t\t\t0x6c4 /* Remove revertible should be a single delta */,\n\t\t\t);\n\n\t\t\tconst revertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE> = {\n\t\t\t\tevent: IntervalOpType.POSITION_REMOVE,\n\t\t\t\tintervals: [],\n\t\t\t\trevertibleRefs,\n\t\t\t\tmergeTreeRevertible: removeRevertibles[0],\n\t\t\t};\n\n\t\t\t// add an interval for each startInterval, accounting for any corresponding endIntervals\n\t\t\tstartIntervals.forEach(({ interval, offset }) => {\n\t\t\t\t// find any corresponding end for this interval\n\t\t\t\tconst endIntervalIndex = endIntervals.findIndex((end) => {\n\t\t\t\t\treturn end.interval === interval;\n\t\t\t\t});\n\t\t\t\tlet endOffset: number | undefined;\n\t\t\t\tif (endIntervalIndex !== -1) {\n\t\t\t\t\tendOffset = endIntervals[endIntervalIndex].offset;\n\t\t\t\t\tendIntervals.splice(endIntervalIndex, 1);\n\t\t\t\t}\n\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tstartOffset: offset,\n\t\t\t\t\tendOffset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// add any remaining endIntervals that aren't matched with a startInterval\n\t\t\tendIntervals.forEach(({ interval, offset }) => {\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tendOffset: offset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\trevertibles.push(revertible);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Handle any merge tree delta that is not REMOVE or is REMOVE with no interval endpoints\n\tconst mergeTreeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t// Allow merging MergeTreeDeltaRevertible with previous\n\tif (revertibles.length > 0 && isMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])) {\n\t\tmergeTreeRevertibles.push(revertibles.pop() as MergeTreeDeltaRevertible);\n\t}\n\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, mergeTreeRevertibles);\n\trevertibles.push(...mergeTreeRevertibles);\n}\n\n/**\n * Clean up resources held by revertibles that are no longer needed.\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.forEach((r) => {\n\t\tif (isMergeTreeDeltaRevertible(r)) {\n\t\t\tdiscardMergeTreeDeltaRevertible([r]);\n\t\t} else if (r.event === IntervalOpType.CHANGE || r.event === IntervalOpType.DELETE) {\n\t\t\tsharedString.removeLocalReferencePosition(r.start);\n\t\t\tsharedString.removeLocalReferencePosition(r.end);\n\t\t}\n\t});\n}\n\nfunction getSlidePosition(string: SharedString, lref: LocalReferencePosition, pos: number): number {\n\tconst slide = getSlideToSegoff(\n\t\t{ segment: lref.getSegment(), offset: undefined },\n\t\tlref.slidingPreference,\n\t);\n\treturn slide?.segment !== undefined &&\n\t\tslide.offset !== undefined &&\n\t\tstring.getPosition(slide.segment) !== -1 &&\n\t\t(pos < 0 || pos >= string.getLength())\n\t\t? string.getPosition(slide.segment) + slide.offset\n\t\t: pos;\n}\n\nfunction isValidRange(start: number, end: number, string: SharedString) {\n\treturn (\n\t\tstart >= 0 &&\n\t\tstart < string.getLength() &&\n\t\tend >= 0 &&\n\t\tend < string.getLength() &&\n\t\tstart <= end\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.ADD>,\n) {\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tstring.getIntervalCollection(label).removeIntervalById(id);\n}\n\nfunction revertLocalDelete(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.DELETE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\t// reusing the id causes eventual consistency bugs, so it is removed here and recreated in add\n\tconst { intervalId, ...props } = revertible.interval.properties;\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tconst int = collection.add({\n\t\t\tstart: startSlidePos,\n\t\t\tend: endSlidePos,\n\t\t\tprops,\n\t\t});\n\n\t\tidMap.forEach((newId, oldId) => {\n\t\t\tif (intervalId === newId) {\n\t\t\t\tidMap.set(oldId, getUpdatedIdFromInterval(int));\n\t\t\t}\n\t\t});\n\t\tidMap.set(intervalId, int.getIntervalId());\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalChange(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.CHANGE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\tif (isValidRange(startSlidePos, endSlidePos, string)) {\n\t\tcollection.change(id, startSlidePos, endSlidePos);\n\t}\n\n\tstring.removeLocalReferencePosition(revertible.start);\n\tstring.removeLocalReferencePosition(revertible.end);\n}\n\nfunction revertLocalPropertyChanged(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.PROPERTY_CHANGED>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst newProps = revertible.propertyDeltas;\n\tstring.getIntervalCollection(label).changeProperties(id, newProps);\n}\n\nfunction newPosition(offset: number | undefined, restoredRanges: SortedRangeSet) {\n\tif (offset === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet offsetFromSegment = offset;\n\tfor (const rangeInfo of restoredRanges.items) {\n\t\tif (offsetFromSegment < rangeInfo.length) {\n\t\t\t// find the segment inside the range\n\t\t\tfor (const range of rangeInfo.ranges) {\n\t\t\t\tif (range.segment.cachedLength > offsetFromSegment) {\n\t\t\t\t\treturn { segment: range.segment, offset: offsetFromSegment };\n\t\t\t\t}\n\t\t\t\toffsetFromSegment -= range.segment.cachedLength;\n\t\t\t}\n\t\t}\n\t\toffsetFromSegment -= rangeInfo.length;\n\t}\n\n\treturn undefined;\n}\n\nfunction newEndpointPosition(\n\toffset: number | undefined,\n\trestoredRanges: SortedRangeSet,\n\tsharedString: SharedString,\n) {\n\tconst pos = newPosition(offset, restoredRanges);\n\treturn pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;\n}\n\ninterface RangeInfo {\n\tranges: readonly Readonly<ISequenceDeltaRange<MergeTreeDeltaOperationType>>[];\n\tlength: number;\n}\n\nclass SortedRangeSet extends SortedSet<RangeInfo, string> {\n\tprotected getKey(item: RangeInfo): string {\n\t\treturn item.ranges[0].segment.ordinal;\n\t}\n}\n\nfunction revertLocalSequenceRemove(\n\tsharedString: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE>,\n) {\n\tconst restoredRanges = new SortedRangeSet();\n\tconst saveSegments = (event: SequenceDeltaEvent) => {\n\t\tif (event.ranges.length > 0) {\n\t\t\tlet length = 0;\n\t\t\tevent.ranges.forEach((range) => {\n\t\t\t\tlength += range.segment.cachedLength;\n\t\t\t});\n\t\t\trestoredRanges.addOrUpdate({ ranges: event.ranges, length });\n\t\t}\n\t};\n\tsharedString.on(\"sequenceDelta\", saveSegments);\n\trevertMergeTreeDeltaRevertibles(sharedString, [revertible.mergeTreeRevertible]);\n\tsharedString.off(\"sequenceDelta\", saveSegments);\n\n\trevertible.intervals.forEach((intervalInfo) => {\n\t\tconst intervalCollection = sharedString.getIntervalCollection(intervalInfo.label);\n\t\tconst intervalId = getUpdatedId(intervalInfo.intervalId);\n\t\tconst interval = intervalCollection.getIntervalById(intervalId);\n\t\tif (interval !== undefined) {\n\t\t\tconst start =\n\t\t\t\tnewEndpointPosition(intervalInfo.startOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.start);\n\t\t\tconst end =\n\t\t\t\tnewEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.end);\n\t\t\tif (start <= end) {\n\t\t\t\tintervalCollection.change(intervalId, start, end);\n\t\t\t}\n\t\t}\n\t});\n\n\t// fix up the local references used by delete and change revertibles\n\trevertible.revertibleRefs.forEach((revertibleRef) => {\n\t\tassert(\n\t\t\trevertibleRef.revertible.event === IntervalOpType.CHANGE ||\n\t\t\t\trevertibleRef.revertible.event === IntervalOpType.DELETE,\n\t\t\t0x6c5 /* revertible is not delete or change */,\n\t\t);\n\t\tconst pos = newPosition(revertibleRef.offset, restoredRanges);\n\t\tif (pos !== undefined) {\n\t\t\tif (revertibleRef.isStart) {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.start);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeBegin,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.start = newRef;\n\t\t\t} else {\n\t\t\t\tsharedString.removeLocalReferencePosition(revertibleRef.revertible.end);\n\t\t\t\tconst newRef = sharedString.createLocalReferencePosition(\n\t\t\t\t\tpos.segment as SharedStringSegment,\n\t\t\t\t\tpos.offset,\n\t\t\t\t\tReferenceType.StayOnRemove | ReferenceType.RangeEnd,\n\t\t\t\t\t{ revertible: revertibleRef.revertible },\n\t\t\t\t);\n\t\t\t\trevertibleRef.revertible.end = newRef;\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Invoke revertibles to reverse prior edits\n *\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tif (\"event\" in r) {\n\t\t\tconst event = r.event;\n\t\t\tswitch (event) {\n\t\t\t\tcase IntervalOpType.ADD:\n\t\t\t\t\trevertLocalAdd(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.DELETE:\n\t\t\t\t\trevertLocalDelete(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.CHANGE:\n\t\t\t\t\trevertLocalChange(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.PROPERTY_CHANGED:\n\t\t\t\t\trevertLocalPropertyChanged(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.POSITION_REMOVE:\n\t\t\t\t\trevertLocalSequenceRemove(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(event);\n\t\t\t}\n\t\t} else {\n\t\t\trevertMergeTreeDeltaRevertibles(sharedString, [r]);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AACzC,+BAA+B;AAE/B,2DAAqE;AACrE,2DAeoC;AACpC,6DAAmE;AACnE,2CAA+D;AAW/D,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;;;GAGG;AACH,SAAgB,8BAA8B,CAC7C,QAA0B,EAC1B,WAAqC;IAErC,WAAW,CAAC,IAAI,CAAC;QAChB,KAAK,EAAE,0BAAc,CAAC,GAAG;QACzB,QAAQ;KACR,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC;AAVD,wEAUC;AAED;;;GAGG;AACH,SAAgB,iCAAiC,CAChD,MAAoB,EACpB,QAA0B,EAC1B,WAAqC;IAErC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAyB,CAAC;IACpE,MAAM,SAAS,GACd,QAAQ,CAAC,UAAU,KAAK,SAAS;QAChC,CAAC,CAAC,0BAAa,CAAC,aAAa,GAAG,0BAAa,CAAC,UAAU;QACxD,CAAC,CAAC,0BAAa,CAAC,YAAY,GAAG,0BAAa,CAAC,UAAU,CAAC;IAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,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U,CAAC,GAAG,CAAC,iBAAiB,CAC9C,CAAC;gBACF,aAAa,CAAC,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC;aACtC;SACD;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAC5C,YAA0B,EAC1B,WAAqC;IAErC,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,oEAAoE;QACpE,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAG,CAAC;QAC7B,IAAI,OAAO,IAAI,CAAC,EAAE;YACjB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;YACtB,QAAQ,KAAK,EAAE;gBACd,KAAK,0BAAc,CAAC,GAAG;oBACtB,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAChC,MAAM;gBACP,KAAK,0BAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,0BAAc,CAAC,MAAM;oBACzB,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,0BAAc,CAAC,gBAAgB;oBACnC,0BAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC5C,MAAM;gBACP,KAAK,0BAAc,CAAC,eAAe;oBAClC,yBAAyB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;oBAC3C,MAAM;gBACP;oBACC,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAC;aACxB;SACD;aAAM;YACN,IAAA,4CAA+B,EAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;KACD;AACF,CAAC;AAhCD,sEAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n/* eslint-disable no-bitwise */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tLocalReferencePosition,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tReferenceType,\n\trefTypeIncludesFlag,\n\trevertMergeTreeDeltaRevertibles,\n\tSortedSet,\n\tgetSlideToSegoff,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { InteriorSequencePlace, Side } from \"./intervalCollection\";\nimport { IntervalOpType, SequenceInterval } from \"./intervals\";\nimport { SharedString, SharedStringSegment } from \"./sharedString\";\nimport { ISequenceDeltaRange, SequenceDeltaEvent } from \"./sequenceDeltaEvent\";\n\n/**\n * Data for undoing edits on SharedStrings and Intervals.\n *\n * @alpha\n */\nexport type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;\n\nconst idMap = new Map<string, string>();\n\ntype IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];\n\n/**\n * Data for undoing edits affecting Intervals.\n *\n * @alpha\n */\nexport type IntervalRevertible =\n\t| {\n\t\t\tevent: typeof IntervalOpType.CHANGE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.ADD;\n\t\t\tinterval: SequenceInterval;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.DELETE;\n\t\t\tinterval: SequenceInterval;\n\t\t\tstart: LocalReferencePosition;\n\t\t\tend: LocalReferencePosition;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.PROPERTY_CHANGED;\n\t\t\tinterval: SequenceInterval;\n\t\t\tpropertyDeltas: PropertySet;\n\t }\n\t| {\n\t\t\tevent: typeof IntervalOpType.POSITION_REMOVE;\n\t\t\tintervals: {\n\t\t\t\tintervalId: string;\n\t\t\t\tlabel: string;\n\t\t\t\tstartOffset?: number; // interval start index within a removed range\n\t\t\t\tendOffset?: number; // interval end index within a removed range\n\t\t\t}[];\n\t\t\t// local refs used by IntervalOpType.CHANGE and DELETE revertibles\n\t\t\trevertibleRefs: {\n\t\t\t\trevertible: IntervalRevertible;\n\t\t\t\toffset: number;\n\t\t\t\tisStart: boolean;\n\t\t\t}[];\n\t\t\tmergeTreeRevertible: MergeTreeDeltaRevertible;\n\t };\n\ntype TypedRevertible<T extends IntervalRevertible[\"event\"]> = IntervalRevertible & { event: T };\n\nfunction getUpdatedIdFromInterval(interval: SequenceInterval): string {\n\tconst maybeId = interval.getIntervalId();\n\treturn getUpdatedId(maybeId);\n}\n\nfunction getUpdatedId(intervalId: string): string {\n\treturn idMap.get(intervalId) ?? intervalId;\n}\n\n/**\n * Create revertibles for adding an interval\n * @alpha\n */\nexport function appendAddIntervalToRevertibles(\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.ADD,\n\t\tinterval,\n\t});\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for deleting an interval\n * @alpha\n */\nexport function appendDeleteIntervalToRevertibles(\n\tstring: SharedString,\n\tinterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = interval.start.getSegment() as SharedStringSegment;\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = interval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst startRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tinterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tinterval.start.slidingPreference,\n\t);\n\tconst endRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tinterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tinterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.DELETE,\n\t\tinterval,\n\t\tstart: startRef,\n\t\tend: endRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for moving endpoints of an interval\n * @alpha\n */\nexport function appendChangeIntervalToRevertibles(\n\tstring: SharedString,\n\tnewInterval: SequenceInterval,\n\tpreviousInterval: SequenceInterval,\n\trevertibles: SharedStringRevertible[],\n) {\n\tconst startSeg = previousInterval.start.getSegment() as SharedStringSegment;\n\t// This logic is needed because the ReferenceType StayOnRemove cannot be used\n\t// on removed segments. This works for revertibles because the old position of the\n\t// interval within the removed segment is handled by the remove range revertible.\n\tconst startType =\n\t\tstartSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeBegin\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeBegin;\n\tconst endSeg = previousInterval.end.getSegment() as SharedStringSegment;\n\tconst endType =\n\t\tendSeg.removedSeq !== undefined\n\t\t\t? ReferenceType.SlideOnRemove | ReferenceType.RangeEnd\n\t\t\t: ReferenceType.StayOnRemove | ReferenceType.RangeEnd;\n\tconst prevStartRef = string.createLocalReferencePosition(\n\t\tstartSeg,\n\t\tpreviousInterval.start.getOffset(),\n\t\tstartType,\n\t\tundefined,\n\t\tpreviousInterval.start.slidingPreference,\n\t);\n\tconst prevEndRef = string.createLocalReferencePosition(\n\t\tendSeg,\n\t\tpreviousInterval.end.getOffset(),\n\t\tendType,\n\t\tundefined,\n\t\tpreviousInterval.end.slidingPreference,\n\t);\n\tconst revertible = {\n\t\tevent: IntervalOpType.CHANGE,\n\t\tinterval: newInterval,\n\t\tstart: prevStartRef,\n\t\tend: prevEndRef,\n\t};\n\trevertible.start.addProperties({ revertible });\n\trevertible.end.addProperties({ revertible });\n\trevertibles.push(revertible);\n\n\treturn revertibles;\n}\n\n/**\n * Create revertibles for changing properties of an interval\n * @alpha\n */\nexport function appendIntervalPropertyChangedToRevertibles(\n\tinterval: SequenceInterval,\n\tdeltas: PropertySet,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.push({\n\t\tevent: IntervalOpType.PROPERTY_CHANGED,\n\t\tinterval,\n\t\tpropertyDeltas: deltas,\n\t});\n\n\treturn revertibles;\n}\n\nfunction addIfIntervalEndpoint(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\tstartIntervals: { offset: number; interval: SequenceInterval }[],\n\tendIntervals: { offset: number; interval: SequenceInterval }[],\n) {\n\tif (refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tstartIntervals.push({ offset: segmentLengths + interval.start.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t} else if (refTypeIncludesFlag(ref.refType, ReferenceType.RangeEnd)) {\n\t\tconst interval = ref.properties?.interval;\n\t\tif (interval && interval instanceof SequenceInterval) {\n\t\t\tendIntervals.push({ offset: segmentLengths + interval.end.getOffset(), interval });\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction addIfRevertibleRef(\n\tref: LocalReferencePosition,\n\tsegmentLengths: number,\n\trevertibleRefs: {\n\t\trevertible: IntervalRevertible;\n\t\toffset: number;\n\t\tisStart: boolean;\n\t}[],\n) {\n\tconst revertible = ref.properties?.revertible;\n\tif (revertible) {\n\t\trevertibleRefs.push({\n\t\t\trevertible,\n\t\t\toffset: segmentLengths + ref.getOffset(),\n\t\t\tisStart: refTypeIncludesFlag(ref.refType, ReferenceType.RangeBegin),\n\t\t});\n\t}\n}\n\n/**\n * Create revertibles for SharedStringDeltas, handling indirectly modified intervals\n * (e.g. reverting remove of a range that contains an interval will move the interval back)\n *\n * @alpha\n */\nexport function appendSharedStringDeltaToRevertibles(\n\tstring: SharedString,\n\tdelta: SequenceDeltaEvent,\n\trevertibles: SharedStringRevertible[],\n) {\n\tif (delta.ranges.length === 0) {\n\t\treturn;\n\t}\n\tif (delta.deltaOperation === MergeTreeDeltaType.REMOVE) {\n\t\tconst startIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst endIntervals: { offset: number; interval: SequenceInterval }[] = [];\n\t\tconst revertibleRefs: {\n\t\t\trevertible: IntervalRevertible;\n\t\t\toffset: number;\n\t\t\tisStart: boolean;\n\t\t}[] = [];\n\t\tlet segmentLengths = 0;\n\n\t\t// find interval endpoints in each segment\n\t\tfor (const deltaRange of delta.ranges) {\n\t\t\tconst refs = deltaRange.segment.localRefs;\n\t\t\tif (refs !== undefined && deltaRange.position !== -1) {\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\taddIfIntervalEndpoint(ref, segmentLengths, startIntervals, endIntervals);\n\t\t\t\t\taddIfRevertibleRef(ref, segmentLengths, revertibleRefs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegmentLengths += deltaRange.segment.cachedLength;\n\t\t}\n\n\t\tif (startIntervals.length > 0 || endIntervals.length > 0 || revertibleRefs.length > 0) {\n\t\t\tconst removeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t\t\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, removeRevertibles);\n\t\t\tassert(\n\t\t\t\tremoveRevertibles.length === 1,\n\t\t\t\t0x6c4 /* Remove revertible should be a single delta */,\n\t\t\t);\n\n\t\t\tconst revertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE> = {\n\t\t\t\tevent: IntervalOpType.POSITION_REMOVE,\n\t\t\t\tintervals: [],\n\t\t\t\trevertibleRefs,\n\t\t\t\tmergeTreeRevertible: removeRevertibles[0],\n\t\t\t};\n\n\t\t\t// add an interval for each startInterval, accounting for any corresponding endIntervals\n\t\t\tstartIntervals.forEach(({ interval, offset }) => {\n\t\t\t\t// find any corresponding end for this interval\n\t\t\t\tconst endIntervalIndex = endIntervals.findIndex((end) => {\n\t\t\t\t\treturn end.interval === interval;\n\t\t\t\t});\n\t\t\t\tlet endOffset: number | undefined;\n\t\t\t\tif (endIntervalIndex !== -1) {\n\t\t\t\t\tendOffset = endIntervals[endIntervalIndex].offset;\n\t\t\t\t\tendIntervals.splice(endIntervalIndex, 1);\n\t\t\t\t}\n\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tstartOffset: offset,\n\t\t\t\t\tendOffset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// add any remaining endIntervals that aren't matched with a startInterval\n\t\t\tendIntervals.forEach(({ interval, offset }) => {\n\t\t\t\trevertible.intervals.push({\n\t\t\t\t\tintervalId: interval.getIntervalId(),\n\t\t\t\t\tlabel: interval.properties.referenceRangeLabels[0],\n\t\t\t\t\tendOffset: offset,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\trevertibles.push(revertible);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Handle any merge tree delta that is not REMOVE or is REMOVE with no interval endpoints\n\tconst mergeTreeRevertibles: MergeTreeDeltaRevertible[] = [];\n\t// Allow merging MergeTreeDeltaRevertible with previous\n\tif (revertibles.length > 0 && isMergeTreeDeltaRevertible(revertibles[revertibles.length - 1])) {\n\t\tmergeTreeRevertibles.push(revertibles.pop() as MergeTreeDeltaRevertible);\n\t}\n\tappendToMergeTreeDeltaRevertibles(delta.deltaArgs, mergeTreeRevertibles);\n\trevertibles.push(...mergeTreeRevertibles);\n}\n\n/**\n * Clean up resources held by revertibles that are no longer needed.\n * @alpha\n */\nexport function discardSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\trevertibles.forEach((r) => {\n\t\tif (isMergeTreeDeltaRevertible(r)) {\n\t\t\tdiscardMergeTreeDeltaRevertible([r]);\n\t\t} else if (r.event === IntervalOpType.CHANGE || r.event === IntervalOpType.DELETE) {\n\t\t\tsharedString.removeLocalReferencePosition(r.start);\n\t\t\tsharedString.removeLocalReferencePosition(r.end);\n\t\t}\n\t});\n}\n\nfunction getSlidePosition(string: SharedString, lref: LocalReferencePosition, pos: number): number {\n\tconst slide = getSlideToSegoff(\n\t\t{ segment: lref.getSegment(), offset: undefined },\n\t\tlref.slidingPreference,\n\t);\n\treturn slide?.segment !== undefined &&\n\t\tslide.offset !== undefined &&\n\t\tstring.getPosition(slide.segment) !== -1 &&\n\t\t(pos < 0 || pos >= string.getLength())\n\t\t? string.getPosition(slide.segment) + slide.offset\n\t\t: pos;\n}\n\nfunction isValidRange(\n\tstart: number,\n\tstartSlide: SlidingPreference | undefined,\n\tend: number,\n\tendSlide: SlidingPreference | undefined,\n\tstring: SharedString,\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 ||\n\t\t\t\t\tendSlide !== SlidingPreference.FORWARD)))\n\t);\n}\n\nfunction revertLocalAdd(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.ADD>,\n) {\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tstring.getIntervalCollection(label).removeIntervalById(id);\n}\n\nfunction 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 }\n\t\t: newSlidingPreference === SlidingPreference.FORWARD &&\n\t\t oldSlidingPreference === SlidingPreference.BACKWARD\n\t\t? {\n\t\t\t\tpos,\n\t\t\t\tside: Side.Before,\n\t\t }\n\t\t: pos; // Avoid setting side if possible since stickiness may not be enabled\n}\n\nfunction revertLocalDelete(\n\tstring: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.DELETE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\t// reusing the id causes eventual consistency bugs, so it is removed here and recreated in add\n\tconst { intervalId, ...props } = revertible.interval.properties;\n\tif (\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: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.CHANGE>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst collection = string.getIntervalCollection(label);\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst start = string.localReferencePositionToPosition(revertible.start);\n\tconst startSlidePos = getSlidePosition(string, revertible.start, start);\n\tconst end = string.localReferencePositionToPosition(revertible.end);\n\tconst endSlidePos = getSlidePosition(string, revertible.end, end);\n\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(\n\t\t\tid,\n\t\t\tcreateSequencePlace(\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\tcreateSequencePlace(\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: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.PROPERTY_CHANGED>,\n) {\n\tconst label = revertible.interval.properties.referenceRangeLabels[0];\n\tconst id = getUpdatedIdFromInterval(revertible.interval);\n\tconst newProps = revertible.propertyDeltas;\n\tstring.getIntervalCollection(label).changeProperties(id, newProps);\n}\n\nfunction newPosition(offset: number | undefined, restoredRanges: SortedRangeSet) {\n\tif (offset === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet offsetFromSegment = offset;\n\tfor (const rangeInfo of restoredRanges.items) {\n\t\tif (offsetFromSegment < rangeInfo.length) {\n\t\t\t// find the segment inside the range\n\t\t\tfor (const range of rangeInfo.ranges) {\n\t\t\t\tif (range.segment.cachedLength > offsetFromSegment) {\n\t\t\t\t\treturn { segment: range.segment, offset: offsetFromSegment };\n\t\t\t\t}\n\t\t\t\toffsetFromSegment -= range.segment.cachedLength;\n\t\t\t}\n\t\t}\n\t\toffsetFromSegment -= rangeInfo.length;\n\t}\n\n\treturn undefined;\n}\n\nfunction newEndpointPosition(\n\toffset: number | undefined,\n\trestoredRanges: SortedRangeSet,\n\tsharedString: SharedString,\n) {\n\tconst pos = newPosition(offset, restoredRanges);\n\treturn pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;\n}\n\ninterface RangeInfo {\n\tranges: readonly Readonly<ISequenceDeltaRange<MergeTreeDeltaOperationType>>[];\n\tlength: number;\n}\n\nclass SortedRangeSet extends SortedSet<RangeInfo, string> {\n\tprotected getKey(item: RangeInfo): string {\n\t\treturn item.ranges[0].segment.ordinal;\n\t}\n}\n\nfunction revertLocalSequenceRemove(\n\tsharedString: SharedString,\n\trevertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE>,\n) {\n\tconst restoredRanges = new SortedRangeSet();\n\tconst saveSegments = (event: SequenceDeltaEvent) => {\n\t\tif (event.ranges.length > 0) {\n\t\t\tlet length = 0;\n\t\t\tevent.ranges.forEach((range) => {\n\t\t\t\tlength += range.segment.cachedLength;\n\t\t\t});\n\t\t\trestoredRanges.addOrUpdate({ ranges: event.ranges, length });\n\t\t}\n\t};\n\tsharedString.on(\"sequenceDelta\", saveSegments);\n\trevertMergeTreeDeltaRevertibles(sharedString, [revertible.mergeTreeRevertible]);\n\tsharedString.off(\"sequenceDelta\", saveSegments);\n\n\trevertible.intervals.forEach((intervalInfo) => {\n\t\tconst intervalCollection = sharedString.getIntervalCollection(intervalInfo.label);\n\t\tconst intervalId = getUpdatedId(intervalInfo.intervalId);\n\t\tconst interval = intervalCollection.getIntervalById(intervalId);\n\t\tif (interval !== undefined) {\n\t\t\tconst start =\n\t\t\t\tnewEndpointPosition(intervalInfo.startOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.start);\n\t\t\tconst end =\n\t\t\t\tnewEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString) ??\n\t\t\t\tsharedString.localReferencePositionToPosition(interval.end);\n\t\t\tif (\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(\n\t\t\t\t\tintervalId,\n\t\t\t\t\tcreateSequencePlace(start, interval.start.slidingPreference),\n\t\t\t\t\tcreateSequencePlace(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 *\n * @alpha\n */\nexport function revertSharedStringRevertibles(\n\tsharedString: SharedString,\n\trevertibles: SharedStringRevertible[],\n) {\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tif (\"event\" in r) {\n\t\t\tconst event = r.event;\n\t\t\tswitch (event) {\n\t\t\t\tcase IntervalOpType.ADD:\n\t\t\t\t\trevertLocalAdd(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.DELETE:\n\t\t\t\t\trevertLocalDelete(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.CHANGE:\n\t\t\t\t\trevertLocalChange(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.PROPERTY_CHANGED:\n\t\t\t\t\trevertLocalPropertyChanged(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IntervalOpType.POSITION_REMOVE:\n\t\t\t\t\trevertLocalSequenceRemove(sharedString, r);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(event);\n\t\t\t}\n\t\t} else {\n\t\t\trevertMergeTreeDeltaRevertibles(sharedString, [r]);\n\t\t}\n\t}\n}\n"]}