@fluidframework/merge-tree 2.4.0-294316 → 2.4.0-297385
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-report/merge-tree.legacy.alpha.api.md +25 -5
- package/dist/attributionPolicy.d.ts.map +1 -1
- package/dist/attributionPolicy.js +10 -3
- package/dist/attributionPolicy.js.map +1 -1
- package/dist/client.d.ts +14 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +97 -9
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/dist/localReference.d.ts +1 -1
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts +22 -8
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +98 -24
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +27 -2
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +2 -18
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/opBuilder.d.ts +15 -1
- package/dist/opBuilder.d.ts.map +1 -1
- package/dist/opBuilder.js +28 -1
- package/dist/opBuilder.js.map +1 -1
- package/dist/ops.d.ts +27 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +1 -0
- package/dist/ops.js.map +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +4 -2
- package/dist/revertibles.js.map +1 -1
- package/dist/sequencePlace.d.ts +4 -0
- package/dist/sequencePlace.d.ts.map +1 -1
- package/dist/sequencePlace.js +17 -1
- package/dist/sequencePlace.js.map +1 -1
- package/dist/snapshotV1.d.ts.map +1 -1
- package/dist/snapshotV1.js +0 -2
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +0 -1
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/test/client.annotateMarker.spec.js.map +1 -1
- package/dist/test/client.applyMsg.spec.js +3 -3
- package/dist/test/client.applyMsg.spec.js.map +1 -1
- package/dist/test/client.localReference.spec.js.map +1 -1
- package/dist/test/client.rollback.spec.js.map +1 -1
- package/dist/test/mergeTree.annotate.spec.js +29 -19
- package/dist/test/mergeTree.annotate.spec.js.map +1 -1
- package/dist/test/obliterate.concurrent.spec.js +18 -0
- package/dist/test/obliterate.concurrent.spec.js.map +1 -1
- package/dist/test/obliterate.rangeExpansion.spec.js +109 -53
- package/dist/test/obliterate.rangeExpansion.spec.js.map +1 -1
- package/dist/test/obliterate.spec.js +2 -2
- package/dist/test/obliterate.spec.js.map +1 -1
- package/dist/test/reconnectHelper.d.ts +8 -6
- package/dist/test/reconnectHelper.d.ts.map +1 -1
- package/dist/test/reconnectHelper.js +14 -13
- package/dist/test/reconnectHelper.js.map +1 -1
- package/dist/test/revertibleFarm.spec.js.map +1 -1
- package/dist/test/testClientLogger.d.ts.map +1 -1
- package/dist/test/testClientLogger.js +19 -8
- package/dist/test/testClientLogger.js.map +1 -1
- package/dist/zamboni.js +2 -1
- package/dist/zamboni.js.map +1 -1
- package/lib/attributionPolicy.d.ts.map +1 -1
- package/lib/attributionPolicy.js +10 -3
- package/lib/attributionPolicy.js.map +1 -1
- package/lib/client.d.ts +14 -4
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +98 -10
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -0
- package/lib/localReference.d.ts +1 -1
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts +22 -8
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +100 -26
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +27 -2
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +2 -18
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/opBuilder.d.ts +15 -1
- package/lib/opBuilder.d.ts.map +1 -1
- package/lib/opBuilder.js +26 -0
- package/lib/opBuilder.js.map +1 -1
- package/lib/ops.d.ts +27 -1
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js +1 -0
- package/lib/ops.js.map +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +5 -3
- package/lib/revertibles.js.map +1 -1
- package/lib/sequencePlace.d.ts +4 -0
- package/lib/sequencePlace.d.ts.map +1 -1
- package/lib/sequencePlace.js +15 -0
- package/lib/sequencePlace.js.map +1 -1
- package/lib/snapshotV1.d.ts.map +1 -1
- package/lib/snapshotV1.js +0 -2
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +0 -1
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/test/client.annotateMarker.spec.js.map +1 -1
- package/lib/test/client.applyMsg.spec.js +3 -3
- package/lib/test/client.applyMsg.spec.js.map +1 -1
- package/lib/test/client.localReference.spec.js.map +1 -1
- package/lib/test/client.rollback.spec.js.map +1 -1
- package/lib/test/mergeTree.annotate.spec.js +29 -19
- package/lib/test/mergeTree.annotate.spec.js.map +1 -1
- package/lib/test/obliterate.concurrent.spec.js +18 -0
- package/lib/test/obliterate.concurrent.spec.js.map +1 -1
- package/lib/test/obliterate.rangeExpansion.spec.js +109 -53
- package/lib/test/obliterate.rangeExpansion.spec.js.map +1 -1
- package/lib/test/obliterate.spec.js +2 -2
- package/lib/test/obliterate.spec.js.map +1 -1
- package/lib/test/reconnectHelper.d.ts +8 -6
- package/lib/test/reconnectHelper.d.ts.map +1 -1
- package/lib/test/reconnectHelper.js +15 -14
- package/lib/test/reconnectHelper.js.map +1 -1
- package/lib/test/revertibleFarm.spec.js.map +1 -1
- package/lib/test/testClientLogger.d.ts.map +1 -1
- package/lib/test/testClientLogger.js +19 -8
- package/lib/test/testClientLogger.js.map +1 -1
- package/lib/zamboni.js +2 -1
- package/lib/zamboni.js.map +1 -1
- package/package.json +31 -18
- package/src/attributionPolicy.ts +5 -0
- package/src/client.ts +136 -21
- package/src/index.ts +2 -0
- package/src/localReference.ts +5 -5
- package/src/mergeTree.ts +200 -75
- package/src/mergeTreeNodes.ts +37 -23
- package/src/opBuilder.ts +32 -0
- package/src/ops.ts +23 -1
- package/src/revertibles.ts +12 -5
- package/src/sequencePlace.ts +16 -0
- package/src/snapshotV1.ts +0 -2
- package/src/snapshotlegacy.ts +0 -1
- package/src/zamboni.ts +3 -2
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACN,iCAAiC,EACjC,8CAA8C,EAC9C,0DAA0D,GAC1D,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EASN,OAAO,EAGP,YAAY,GAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EACN,oCAAoC,EACpC,wBAAwB,EAExB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIN,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAQN,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EAOnB,MAAM,EACN,SAAS,EACT,mBAAmB,EACnB,2BAA2B,EAE3B,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACN,iCAAiC,EACjC,8CAA8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AAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAA0C,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EACN,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAG1B,+BAA+B,GAC/B,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIAttributionCollection,\n\tIAttributionCollectionSerializer,\n\tIAttributionCollectionSpec,\n\tSerializedAttributionCollection,\n\tSequenceOffsets,\n} from \"./attributionCollection.js\";\nexport {\n\tcreateInsertOnlyAttributionPolicy,\n\tcreatePropertyTrackingAttributionPolicyFactory,\n\tcreatePropertyTrackingAndInsertionAttributionPolicyFactory,\n} from \"./attributionPolicy.js\";\nexport { Client, IClientEvents } from \"./client.js\";\nexport {\n\tConflictAction,\n\tDictionary,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tKeyComparer,\n\tProperty,\n\tPropertyAction,\n\tQProperty,\n\tRBColor,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n\tSortedDictionary,\n} from \"./collections/index.js\";\nexport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nexport {\n\tcreateDetachedLocalReferencePosition,\n\tLocalReferenceCollection,\n\tLocalReferencePosition,\n\tSlidingPreference,\n} from \"./localReference.js\";\nexport {\n\tAttributionPolicy,\n\tIMergeTreeAttributionOptions,\n\tIMergeTreeOptions,\n\tgetSlideToSegoff,\n} from \"./mergeTree.js\";\nexport {\n\tIMergeTreeClientSequenceArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nexport {\n\tBaseSegment,\n\tCollaborationWindow,\n\tdebugMarkerToString,\n\tIJSONMarkerSegment,\n\tIMergeNodeCommon,\n\tIMoveInfo,\n\tIRemovalInfo,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tMergeNode,\n\treservedMarkerIdKey,\n\treservedMarkerSimpleTypeKey,\n\tSegmentGroup,\n\ttoRemovalInfo,\n\tObliterateInfo,\n\tISegmentInternal,\n} from \"./mergeTreeNodes.js\";\nexport {\n\tTrackable,\n\tTrackingGroup,\n\tITrackingGroup,\n\tTrackingGroupCollection,\n} from \"./mergeTreeTracking.js\";\nexport {\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n\tcreateObliterateRangeOp,\n} from \"./opBuilder.js\";\nexport {\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDelta,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIRelativePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nexport {\n\taddProperties,\n\tcreateMap,\n\tMapLike,\n\tmatchProperties,\n\tPropertySet,\n} from \"./properties.js\";\nexport {\n\tcompareReferencePositions,\n\tDetachedReferencePosition,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\tReferencePosition,\n\trefGetTileLabels,\n\trefHasTileLabel,\n\trefHasTileLabels,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\treservedTileLabelsKey,\n} from \"./referencePositions.js\";\nexport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\nexport { PropertiesManager, PropertiesRollback } from \"./segmentPropertiesManager.js\";\nexport {\n\tInteriorSequencePlace,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"./sequencePlace.js\";\nexport { SortedSet } from \"./sortedSet.js\";\nexport { SortedSegmentSet, SortedSegmentSetItem } from \"./sortedSegmentSet.js\";\nexport { IJSONTextSegment, IMergeTreeTextHelper, TextSegment } from \"./textSegment.js\";\nexport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeRevertibleDriver,\n\trevertMergeTreeDeltaRevertibles,\n} from \"./revertibles.js\";\n"]}
|
package/lib/legacy.d.ts
CHANGED
package/lib/localReference.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISegment } from "./mergeTreeNodes.js";
|
|
5
|
+
import { type ISegment } from "./mergeTreeNodes.js";
|
|
6
6
|
import { TrackingGroupCollection } from "./mergeTreeTracking.js";
|
|
7
7
|
import { ReferenceType } from "./ops.js";
|
|
8
8
|
import { PropertySet } from "./properties.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localReference.d.ts","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,
|
|
1
|
+
{"version":3,"file":"localReference.d.ts","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAiB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAuB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AAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegment | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegment | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegment {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegment | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @legacy\n * @alpha\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegment, seg2: ISegment): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegment): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegment,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegment): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localReference.js","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAY,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAiB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAe,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAqB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,CAAC;IACX;;OAEG;IACH,OAAO,EAAE,CAAC;CACD,CAAC;AAUX,SAAS,sBAAsB,CAAC,OAAsB;IACrD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3D,EAAE,cAAc,CAAC;IAClB,CAAC;IACD,IAAI,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/D,EAAE,cAAc,CAAC;IAClB,CAAC;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,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { ISegmentInternal, type ISegment } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegmentInternal | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegmentInternal | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegmentInternal | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @legacy\n * @alpha\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegment, seg2: ISegment): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegment): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegment,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegment): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
|
package/lib/mergeTree.d.ts
CHANGED
|
@@ -9,11 +9,12 @@ import { DoublyLinkedList } from "./collections/index.js";
|
|
|
9
9
|
import { EndOfTreeSegment, StartOfTreeSegment } from "./endOfTreeSegment.js";
|
|
10
10
|
import { LocalReferencePosition, SlidingPreference } from "./localReference.js";
|
|
11
11
|
import { IMergeTreeDeltaOpArgs, MergeTreeDeltaCallback, MergeTreeMaintenanceCallback } from "./mergeTreeDeltaCallback.js";
|
|
12
|
-
import { CollaborationWindow, IMergeNode,
|
|
12
|
+
import { CollaborationWindow, IMergeNode, ISegmentAction, ISegmentLeaf, Marker, MergeBlock, SegmentGroup, type ISegmentInternal } from "./mergeTreeNodes.js";
|
|
13
13
|
import { IMergeTreeDeltaOp, IRelativePosition, ReferenceType } from "./ops.js";
|
|
14
14
|
import { PropertySet } from "./properties.js";
|
|
15
15
|
import { ReferencePosition } from "./referencePositions.js";
|
|
16
16
|
import { PropertiesRollback } from "./segmentPropertiesManager.js";
|
|
17
|
+
import { type InteriorSequencePlace } from "./sequencePlace.js";
|
|
17
18
|
/**
|
|
18
19
|
* @legacy
|
|
19
20
|
* @alpha
|
|
@@ -68,11 +69,22 @@ export interface IMergeTreeOptions {
|
|
|
68
69
|
* @defaultValue `false`
|
|
69
70
|
*/
|
|
70
71
|
mergeTreeEnableObliterateReconnect?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Enables support for obliterate endpoint expansion.
|
|
74
|
+
* When enabled, obliterate operations can have sidedness specified for their endpoints.
|
|
75
|
+
* If an endpoint is externally anchored
|
|
76
|
+
* (aka the start is after a given position, or the end is before a given position),
|
|
77
|
+
* then concurrent inserts adjacent to the exclusive endpoint of an obliterated range will be included in the obliteration
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue `false`
|
|
80
|
+
*/
|
|
81
|
+
mergeTreeEnableSidedObliterate?: boolean;
|
|
71
82
|
}
|
|
72
83
|
export declare function errorIfOptionNotTrue(options: IMergeTreeOptions | undefined, option: keyof IMergeTreeOptions): void;
|
|
73
84
|
/**
|
|
74
85
|
* @legacy
|
|
75
86
|
* @alpha
|
|
87
|
+
* @deprecated This functionality was not meant to be exported and will be removed in a future release
|
|
76
88
|
*/
|
|
77
89
|
export interface IMergeTreeAttributionOptions {
|
|
78
90
|
/**
|
|
@@ -98,6 +110,7 @@ export interface IMergeTreeAttributionOptions {
|
|
|
98
110
|
* @sealed
|
|
99
111
|
* @legacy
|
|
100
112
|
* @alpha
|
|
113
|
+
* @deprecated This functionality was not meant to be exported and will be removed in a future release
|
|
101
114
|
*/
|
|
102
115
|
export interface AttributionPolicy {
|
|
103
116
|
/**
|
|
@@ -137,10 +150,10 @@ export declare function findRootMergeBlock(segmentOrNode: IMergeNode | undefined
|
|
|
137
150
|
* @internal
|
|
138
151
|
*/
|
|
139
152
|
export declare function getSlideToSegoff(segoff: {
|
|
140
|
-
segment:
|
|
153
|
+
segment: ISegmentInternal | undefined;
|
|
141
154
|
offset: number | undefined;
|
|
142
155
|
}, slidingPreference?: SlidingPreference, useNewSlidingBehavior?: boolean): {
|
|
143
|
-
segment:
|
|
156
|
+
segment: ISegmentInternal | undefined;
|
|
144
157
|
offset: number | undefined;
|
|
145
158
|
};
|
|
146
159
|
/**
|
|
@@ -180,10 +193,10 @@ export declare class MergeTree {
|
|
|
180
193
|
* default is to consider the local client's current perspective. Only local sequence
|
|
181
194
|
* numbers corresponding to un-acked operations give valid results.
|
|
182
195
|
*/
|
|
183
|
-
localNetLength(segment:
|
|
196
|
+
localNetLength(segment: ISegmentLeaf, refSeq?: number, localSeq?: number): number | undefined;
|
|
184
197
|
unlinkMarker(marker: Marker): void;
|
|
185
198
|
private addNode;
|
|
186
|
-
reloadFromSegments(segments:
|
|
199
|
+
reloadFromSegments(segments: ISegmentLeaf[]): void;
|
|
187
200
|
startCollaboration(localClientId: number, minSeq: number, currentSeq: number): void;
|
|
188
201
|
private addToLRUSet;
|
|
189
202
|
getLength(refSeq: number, clientId: number): number;
|
|
@@ -192,7 +205,7 @@ export declare class MergeTree {
|
|
|
192
205
|
*/
|
|
193
206
|
get length(): number | undefined;
|
|
194
207
|
getPosition(node: IMergeNode, refSeq: number, clientId: number, localSeq?: number): number;
|
|
195
|
-
getContainingSegment<T extends
|
|
208
|
+
getContainingSegment<T extends ISegmentLeaf>(pos: number, refSeq: number, clientId: number, localSeq?: number): {
|
|
196
209
|
segment: T | undefined;
|
|
197
210
|
offset: number | undefined;
|
|
198
211
|
};
|
|
@@ -265,7 +278,7 @@ export declare class MergeTree {
|
|
|
265
278
|
* @param clientId - The client id with which to compute the position.
|
|
266
279
|
*/
|
|
267
280
|
posFromRelativePos(relativePos: IRelativePosition, refseq?: number, clientId?: number): number;
|
|
268
|
-
insertSegments(pos: number, segments:
|
|
281
|
+
insertSegments(pos: number, segments: ISegmentLeaf[], refSeq: number, clientId: number, seq: number, opArgs: IMergeTreeDeltaOpArgs | undefined): void;
|
|
269
282
|
/**
|
|
270
283
|
* Resolves a remote client's position against the local sequence
|
|
271
284
|
* and returns the remote client's position relative to the local
|
|
@@ -300,7 +313,8 @@ export declare class MergeTree {
|
|
|
300
313
|
* @param rollback - Whether this is for a local rollback and what kind
|
|
301
314
|
*/
|
|
302
315
|
annotateRange(start: number, end: number, props: PropertySet, refSeq: number, clientId: number, seq: number, opArgs: IMergeTreeDeltaOpArgs, rollback?: PropertiesRollback): void;
|
|
303
|
-
|
|
316
|
+
private obliterateRangeSided;
|
|
317
|
+
obliterateRange(start: number | InteriorSequencePlace, end: number | InteriorSequencePlace, refSeq: number, clientId: number, seq: number, overwrite: boolean | undefined, opArgs: IMergeTreeDeltaOpArgs): void;
|
|
304
318
|
markRangeRemoved(start: number, end: number, refSeq: number, clientId: number, seq: number, overwrite: boolean | undefined, opArgs: IMergeTreeDeltaOpArgs): void;
|
|
305
319
|
/**
|
|
306
320
|
* Revert an unacked local op
|
package/lib/mergeTree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTree.d.ts","sourceRoot":"","sources":["../src/mergeTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAU,IAAI,EAAa,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAY,MAAM,wBAAwB,CAAC;AAOpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAEN,sBAAsB,EACtB,iBAAiB,EAIjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,qBAAqB,EAErB,sBAAsB,EACtB,4BAA4B,EAE5B,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAGN,mBAAmB,EACnB,UAAU,EAGV,
|
|
1
|
+
{"version":3,"file":"mergeTree.d.ts","sourceRoot":"","sources":["../src/mergeTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAU,IAAI,EAAa,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAY,MAAM,wBAAwB,CAAC;A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nE,4BAA4B,CAClC,IAAI,EAAE,sBAAsB,GAC1B,sBAAsB,GAAG,SAAS;IAKrC,WAAW,qBAAgC;IAC3C,SAAS,mBAA8B;IAEhC,4BAA4B,CAClC,QAAQ,EAAE,YAAY,GAAG,OAAO,GAAG,KAAK,EACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,WAAW,GAAG,SAAS,EACnC,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,kBAAkB,CAAC,EAAE,OAAO,GAC1B,sBAAsB;IAwCzB,OAAO,CAAC,yBAAyB;IAqGjC;;;;;;;;;;;;;;;;;;;OAmBG;IACI,yBAAyB,IAAI,IAAI;IAkCxC,OAAO,CAAC,WAAW;IA8CZ,sBAAsB,CAC5B,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,YAAY,UAAQ,GAClB,IAAI;IAYP,OAAO,CAAC,iBAAiB;IAsBzB;;;;;;OAMG;IACI,QAAQ,CAAC,WAAW,EAC1B,OAAO,EAAE,cAAc,CAAC,WAAW,CAAC,EACpC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,EACZ,UAAU,GAAE,OAAe,EAC3B,aAAa,GAAE,MAAe,GAC5B,IAAI;IAsBP;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,OAAO;CAgEf"}
|
package/lib/mergeTree.js
CHANGED
|
@@ -19,10 +19,13 @@ import { createAnnotateRangeOp, createInsertSegmentOp, createRemoveRangeOp, } fr
|
|
|
19
19
|
import { MergeTreeDeltaType, ReferenceType, } from "./ops.js";
|
|
20
20
|
import { PartialSequenceLengths } from "./partialLengths.js";
|
|
21
21
|
import { PerspectiveImpl, isSegmentPresent } from "./perspective.js";
|
|
22
|
-
import { createMap, extend, extendIfUndefined } from "./properties.js";
|
|
22
|
+
import { clone, createMap, extend, extendIfUndefined } from "./properties.js";
|
|
23
23
|
import { DetachedReferencePosition, refGetTileLabels, refHasTileLabel, refTypeIncludesFlag, } from "./referencePositions.js";
|
|
24
24
|
// eslint-disable-next-line import/no-deprecated
|
|
25
|
-
import {
|
|
25
|
+
import { SegmentGroupCollection } from "./segmentGroupCollection.js";
|
|
26
|
+
// eslint-disable-next-line import/no-deprecated
|
|
27
|
+
import { PropertiesManager, PropertiesRollback } from "./segmentPropertiesManager.js";
|
|
28
|
+
import { Side } from "./sequencePlace.js";
|
|
26
29
|
import { SortedSegmentSet } from "./sortedSegmentSet.js";
|
|
27
30
|
import { zamboniSegments } from "./zamboni.js";
|
|
28
31
|
function markSegmentMoved(seg, moveInfo) {
|
|
@@ -259,6 +262,27 @@ export class MergeTree {
|
|
|
259
262
|
return {};
|
|
260
263
|
}
|
|
261
264
|
const next = segment.splitAt(pos);
|
|
265
|
+
if (segment?.segmentGroups) {
|
|
266
|
+
// eslint-disable-next-line import/no-deprecated
|
|
267
|
+
next.segmentGroups ?? (next.segmentGroups = new SegmentGroupCollection(next));
|
|
268
|
+
segment.segmentGroups.copyTo(next);
|
|
269
|
+
}
|
|
270
|
+
if (segment.prevObliterateByInserter) {
|
|
271
|
+
next.prevObliterateByInserter = segment.prevObliterateByInserter;
|
|
272
|
+
}
|
|
273
|
+
if (segment.properties) {
|
|
274
|
+
if (segment.propertyManager === undefined) {
|
|
275
|
+
next.properties = clone(segment.properties);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// eslint-disable-next-line import/no-deprecated
|
|
279
|
+
next.propertyManager ?? (next.propertyManager = new PropertiesManager());
|
|
280
|
+
next.properties = segment.propertyManager.copyTo(segment.properties, next.properties, next.propertyManager);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (segment.localRefs) {
|
|
284
|
+
segment.localRefs.split(pos, next);
|
|
285
|
+
}
|
|
262
286
|
this.mergeTreeMaintenanceCallback?.({
|
|
263
287
|
operation: MergeTreeMaintenanceType.SPLIT,
|
|
264
288
|
deltaSegments: [{ segment }, { segment: next }],
|
|
@@ -760,13 +784,15 @@ export class MergeTree {
|
|
|
760
784
|
segment: pendingSegment,
|
|
761
785
|
});
|
|
762
786
|
});
|
|
763
|
-
if (opArgs.op.type === MergeTreeDeltaType.OBLITERATE
|
|
787
|
+
if (opArgs.op.type === MergeTreeDeltaType.OBLITERATE ||
|
|
788
|
+
opArgs.op.type === MergeTreeDeltaType.OBLITERATE_SIDED) {
|
|
764
789
|
this.obliterates.addOrUpdate(pendingSegmentGroup.obliterateInfo);
|
|
765
790
|
}
|
|
766
791
|
// Perform slides after all segments have been acked, so that
|
|
767
792
|
// positions after slide are final
|
|
768
793
|
if (opArgs.op.type === MergeTreeDeltaType.REMOVE ||
|
|
769
|
-
opArgs.op.type === MergeTreeDeltaType.OBLITERATE
|
|
794
|
+
opArgs.op.type === MergeTreeDeltaType.OBLITERATE ||
|
|
795
|
+
opArgs.op.type === MergeTreeDeltaType.OBLITERATE_SIDED) {
|
|
770
796
|
this.slideAckedRemovedSegmentReferences(pendingSegmentGroup.segments);
|
|
771
797
|
}
|
|
772
798
|
this.mergeTreeMaintenanceCallback?.({
|
|
@@ -804,7 +830,9 @@ export class MergeTree {
|
|
|
804
830
|
if (previousProps) {
|
|
805
831
|
_segmentGroup.previousProps.push(previousProps);
|
|
806
832
|
}
|
|
807
|
-
|
|
833
|
+
// eslint-disable-next-line import/no-deprecated
|
|
834
|
+
const segmentGroups = (segment.segmentGroups ?? (segment.segmentGroups = new SegmentGroupCollection(segment)));
|
|
835
|
+
segmentGroups.enqueue(_segmentGroup);
|
|
808
836
|
return _segmentGroup;
|
|
809
837
|
}
|
|
810
838
|
// TODO: error checking
|
|
@@ -966,9 +994,9 @@ export class MergeTree {
|
|
|
966
994
|
});
|
|
967
995
|
}
|
|
968
996
|
this.updateRoot(splitNode);
|
|
969
|
-
saveIfLocal(newSegment);
|
|
970
997
|
insertPos += newSegment.cachedLength;
|
|
971
998
|
if (!this.options?.mergeTreeEnableObliterate || this.obliterates.empty()) {
|
|
999
|
+
saveIfLocal(newSegment);
|
|
972
1000
|
continue;
|
|
973
1001
|
}
|
|
974
1002
|
// eslint-disable-next-line import/no-deprecated
|
|
@@ -995,13 +1023,13 @@ export class MergeTree {
|
|
|
995
1023
|
movedSeqs.unshift(ob.seq);
|
|
996
1024
|
}
|
|
997
1025
|
else {
|
|
998
|
-
if (newest === undefined || normalizedNewestSeq < normalizedObSeq) {
|
|
999
|
-
normalizedNewestSeq = normalizedObSeq;
|
|
1000
|
-
newest = ob;
|
|
1001
|
-
}
|
|
1002
1026
|
movedClientIds.push(ob.clientId);
|
|
1003
1027
|
movedSeqs.push(ob.seq);
|
|
1004
1028
|
}
|
|
1029
|
+
if (newest === undefined || normalizedNewestSeq < normalizedObSeq) {
|
|
1030
|
+
normalizedNewestSeq = normalizedObSeq;
|
|
1031
|
+
newest = ob;
|
|
1032
|
+
}
|
|
1005
1033
|
}
|
|
1006
1034
|
}
|
|
1007
1035
|
if (oldest && newest?.clientId !== clientId) {
|
|
@@ -1021,6 +1049,10 @@ export class MergeTree {
|
|
|
1021
1049
|
this.blockUpdatePathLengths(newSegment.parent, seq, clientId);
|
|
1022
1050
|
}
|
|
1023
1051
|
}
|
|
1052
|
+
else if (oldest && newest?.clientId === clientId) {
|
|
1053
|
+
newSegment.prevObliterateByInserter = newest;
|
|
1054
|
+
}
|
|
1055
|
+
saveIfLocal(newSegment);
|
|
1024
1056
|
}
|
|
1025
1057
|
}
|
|
1026
1058
|
}
|
|
@@ -1197,7 +1229,10 @@ export class MergeTree {
|
|
|
1197
1229
|
assert(!Marker.is(segment) ||
|
|
1198
1230
|
!(reservedMarkerIdKey in props) ||
|
|
1199
1231
|
props.markerId === segment.properties?.markerId, 0x5ad /* Cannot change the markerId of an existing marker */);
|
|
1200
|
-
|
|
1232
|
+
// eslint-disable-next-line import/no-deprecated
|
|
1233
|
+
const propertyManager = (segment.propertyManager ?? (segment.propertyManager = new PropertiesManager()));
|
|
1234
|
+
const properties = (segment.properties ?? (segment.properties = createMap()));
|
|
1235
|
+
const propertyDeltas = propertyManager.addProperties(properties, props, seq, this.collabWindow.collaborating, rollback);
|
|
1201
1236
|
if (!isRemovedOrMoved(segment)) {
|
|
1202
1237
|
deltaSegments.push({ segment, propertyDeltas });
|
|
1203
1238
|
}
|
|
@@ -1227,10 +1262,11 @@ export class MergeTree {
|
|
|
1227
1262
|
zamboniSegments(this);
|
|
1228
1263
|
}
|
|
1229
1264
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
this.ensureIntervalBoundary(
|
|
1265
|
+
obliterateRangeSided(start, end, refSeq, clientId, seq, overwrite = false, opArgs) {
|
|
1266
|
+
const startPos = start.side === Side.Before ? start.pos : start.pos + 1;
|
|
1267
|
+
const endPos = end.side === Side.Before ? end.pos : end.pos + 1;
|
|
1268
|
+
this.ensureIntervalBoundary(startPos, refSeq, clientId);
|
|
1269
|
+
this.ensureIntervalBoundary(endPos, refSeq, clientId);
|
|
1234
1270
|
let _overwrite = overwrite;
|
|
1235
1271
|
const localOverlapWithRefs = [];
|
|
1236
1272
|
const movedSegments = [];
|
|
@@ -1245,18 +1281,46 @@ export class MergeTree {
|
|
|
1245
1281
|
localSeq,
|
|
1246
1282
|
segmentGroup: undefined,
|
|
1247
1283
|
};
|
|
1248
|
-
const { segment: startSeg } = this.getContainingSegment(start, refSeq, clientId);
|
|
1249
|
-
const { segment: endSeg } = this.getContainingSegment(end
|
|
1284
|
+
const { segment: startSeg } = this.getContainingSegment(start.pos, refSeq, clientId);
|
|
1285
|
+
const { segment: endSeg } = this.getContainingSegment(end.pos, refSeq, clientId);
|
|
1250
1286
|
assert(startSeg !== undefined && endSeg !== undefined, 0xa3f /* segments cannot be undefined */);
|
|
1251
|
-
obliterate.start = this.createLocalReferencePosition(startSeg, 0, ReferenceType.StayOnRemove, {
|
|
1287
|
+
obliterate.start = this.createLocalReferencePosition(startSeg, start.side === Side.Before ? 0 : Math.max(startSeg.cachedLength - 1, 0), ReferenceType.StayOnRemove, {
|
|
1252
1288
|
obliterate,
|
|
1253
1289
|
});
|
|
1254
|
-
obliterate.end = this.createLocalReferencePosition(endSeg, endSeg.cachedLength - 1, ReferenceType.StayOnRemove, {
|
|
1290
|
+
obliterate.end = this.createLocalReferencePosition(endSeg, end.side === Side.Before ? 0 : Math.max(endSeg.cachedLength - 1, 0), ReferenceType.StayOnRemove, {
|
|
1255
1291
|
obliterate,
|
|
1256
1292
|
});
|
|
1293
|
+
// Always create a segment group for obliterate,
|
|
1294
|
+
// even if there are no segments currently in the obliteration range.
|
|
1295
|
+
// Segments may be concurrently inserted into the obliteration range,
|
|
1296
|
+
// at which point they are added to the segment group.
|
|
1297
|
+
obliterate.segmentGroup = {
|
|
1298
|
+
segments: [],
|
|
1299
|
+
localSeq,
|
|
1300
|
+
refSeq: this.collabWindow.currentSeq,
|
|
1301
|
+
obliterateInfo: obliterate,
|
|
1302
|
+
};
|
|
1303
|
+
if (this.collabWindow.collaborating && clientId === this.collabWindow.clientId) {
|
|
1304
|
+
this.pendingSegments.push(obliterate.segmentGroup);
|
|
1305
|
+
}
|
|
1306
|
+
this.obliterates.addOrUpdate(obliterate);
|
|
1257
1307
|
const markMoved = (segment, pos, _start, _end) => {
|
|
1258
|
-
|
|
1308
|
+
if ((start.side === Side.After && startPos === pos + segment.cachedLength) || // exclusive start segment
|
|
1309
|
+
(end.side === Side.Before &&
|
|
1310
|
+
endPos === pos &&
|
|
1311
|
+
isSegmentPresent(segment, { refSeq, localSeq })) // exclusive end segment
|
|
1312
|
+
) {
|
|
1313
|
+
// We walk these segments because we want to also walk any concurrently inserted segments between here and the obliterated segments.
|
|
1314
|
+
// These segments are outside of the obliteration range though, so return true to keep walking.
|
|
1315
|
+
return true;
|
|
1316
|
+
}
|
|
1259
1317
|
const existingMoveInfo = toMoveInfo(segment);
|
|
1318
|
+
if (segment.prevObliterateByInserter?.seq === UnassignedSequenceNumber) {
|
|
1319
|
+
// We chose to not obliterate this segment because we are aware of an unacked local obliteration.
|
|
1320
|
+
// The local obliterate has not been sequenced yet, so it is still the newest obliterate we are aware of.
|
|
1321
|
+
// Other clients will also choose not to obliterate this segment because the most recent obliteration has the same clientId
|
|
1322
|
+
return true;
|
|
1323
|
+
}
|
|
1260
1324
|
if (clientId !== segment.clientId &&
|
|
1261
1325
|
segment.seq !== undefined &&
|
|
1262
1326
|
seq !== UnassignedSequenceNumber &&
|
|
@@ -1297,7 +1361,6 @@ export class MergeTree {
|
|
|
1297
1361
|
if (segment.movedSeq === UnassignedSequenceNumber &&
|
|
1298
1362
|
clientId === this.collabWindow.clientId) {
|
|
1299
1363
|
obliterate.segmentGroup = this.addToPendingList(segment, obliterate.segmentGroup, localSeq);
|
|
1300
|
-
(_a = obliterate.segmentGroup).obliterateInfo ?? (_a.obliterateInfo = obliterate);
|
|
1301
1364
|
}
|
|
1302
1365
|
else {
|
|
1303
1366
|
if (MergeTree.options.zamboniSegments) {
|
|
@@ -1316,8 +1379,8 @@ export class MergeTree {
|
|
|
1316
1379
|
}
|
|
1317
1380
|
return true;
|
|
1318
1381
|
};
|
|
1319
|
-
this.nodeMap(refSeq, clientId, markMoved, undefined, afterMarkMoved, start, end
|
|
1320
|
-
|
|
1382
|
+
this.nodeMap(refSeq, clientId, markMoved, undefined, afterMarkMoved, start.pos, end.pos + 1, // include the segment containing the end reference
|
|
1383
|
+
undefined, seq === UnassignedSequenceNumber ? undefined : seq);
|
|
1321
1384
|
this.slideAckedRemovedSegmentReferences(localOverlapWithRefs);
|
|
1322
1385
|
// opArgs == undefined => test code
|
|
1323
1386
|
if (movedSegments.length > 0) {
|
|
@@ -1338,6 +1401,17 @@ export class MergeTree {
|
|
|
1338
1401
|
zamboniSegments(this);
|
|
1339
1402
|
}
|
|
1340
1403
|
}
|
|
1404
|
+
obliterateRange(start, end, refSeq, clientId, seq, overwrite = false, opArgs) {
|
|
1405
|
+
errorIfOptionNotTrue(this.options, "mergeTreeEnableObliterate");
|
|
1406
|
+
if (this.options?.mergeTreeEnableSidedObliterate) {
|
|
1407
|
+
assert(typeof start === "object" && typeof end === "object", "Start and end must be of type InteriorSequencePlace if mergeTreeEnableSidedObliterate is enabled.");
|
|
1408
|
+
this.obliterateRangeSided(start, end, refSeq, clientId, seq, overwrite, opArgs);
|
|
1409
|
+
}
|
|
1410
|
+
else {
|
|
1411
|
+
assert(typeof start === "number" && typeof end === "number", "Start and end must be numbers if mergeTreeEnableSidedObliterate is not enabled.");
|
|
1412
|
+
this.obliterateRangeSided({ pos: start, side: Side.Before }, { pos: end - 1, side: Side.After }, refSeq, clientId, seq, overwrite, opArgs);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1341
1415
|
markRangeRemoved(start, end, refSeq, clientId, seq, overwrite = false, opArgs) {
|
|
1342
1416
|
let _overwrite = overwrite;
|
|
1343
1417
|
this.ensureIntervalBoundary(start, refSeq, clientId);
|
|
@@ -1431,10 +1505,10 @@ export class MergeTree {
|
|
|
1431
1505
|
if (pendingSegmentGroup === undefined || pendingSegmentGroup !== localOpMetadata) {
|
|
1432
1506
|
throw new Error("Rollback op doesn't match last edit");
|
|
1433
1507
|
}
|
|
1434
|
-
// Disabling because a for of loop causes the type of segment to be
|
|
1508
|
+
// Disabling because a for of loop causes the type of segment to be ISegmentLeaf, which does not have parent information stored
|
|
1435
1509
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
1436
1510
|
pendingSegmentGroup.segments.forEach((segment) => {
|
|
1437
|
-
const segmentSegmentGroup = segment
|
|
1511
|
+
const segmentSegmentGroup = segment?.segmentGroups?.pop?.();
|
|
1438
1512
|
assert(segmentSegmentGroup === pendingSegmentGroup, 0x3ee /* Unexpected segmentGroup in segment */);
|
|
1439
1513
|
assert(segment.removedClientIds !== undefined &&
|
|
1440
1514
|
segment.removedClientIds[0] === this.collabWindow.clientId, 0x39d /* Rollback segment removedClientId does not match local client */);
|
|
@@ -1462,7 +1536,7 @@ export class MergeTree {
|
|
|
1462
1536
|
}
|
|
1463
1537
|
let i = 0;
|
|
1464
1538
|
for (const segment of pendingSegmentGroup.segments) {
|
|
1465
|
-
const segmentSegmentGroup = segment
|
|
1539
|
+
const segmentSegmentGroup = segment?.segmentGroups?.pop?.();
|
|
1466
1540
|
assert(segmentSegmentGroup === pendingSegmentGroup, 0x3ef /* Unexpected segmentGroup in segment */);
|
|
1467
1541
|
const start = this.findRollbackPosition(segment);
|
|
1468
1542
|
if (op.type === MergeTreeDeltaType.INSERT) {
|