@fluidframework/merge-tree 2.50.0 → 2.51.0-347100

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/dist/mergeTree.js CHANGED
@@ -1554,6 +1554,13 @@ class MergeTree {
1554
1554
  * Revert an unacked local op
1555
1555
  */
1556
1556
  rollback(op, localOpMetadata) {
1557
+ if (op.type === ops_js_1.MergeTreeDeltaType.GROUP) {
1558
+ (0, internal_1.assert)(Array.isArray(localOpMetadata), "metadata must be array for group ops");
1559
+ for (let i = op.ops.length - 1; i >= 0; i--) {
1560
+ this.rollback(op.ops[i], localOpMetadata[i]);
1561
+ }
1562
+ return;
1563
+ }
1557
1564
  const rollbackStamp = {
1558
1565
  seq: constants_js_1.TreeMaintenanceSequenceNumber,
1559
1566
  clientId: constants_js_1.NonCollabClient,
@@ -1568,22 +1575,23 @@ class MergeTree {
1568
1575
  pendingSegmentGroup.segments.forEach((segment) => {
1569
1576
  const segmentSegmentGroup = segment?.segmentGroups?.pop();
1570
1577
  (0, internal_1.assert)(segmentSegmentGroup === pendingSegmentGroup, 0x3ee /* Unexpected segmentGroup in segment */);
1571
- (0, internal_1.assert)((0, segmentInfos_js_1.isRemoved)(segment) &&
1572
- segment.removes[0].clientId === this.collabWindow.clientId &&
1573
- segment.removes[0].type === "setRemove", 0x39d /* Rollback segment removedClientId does not match local client */);
1574
- // This also removes obliterates, but that should be ok as we can only remove a segment once.
1575
- // If we were able to remove it locally, that also means there are no remote removals (since rollback is synchronous).
1576
- (0, segmentInfos_js_1.removeRemovalInfo)(segment);
1577
- this.blockUpdatePathLengths(segment.parent, rollbackStamp);
1578
- // Note: optional chaining short-circuits:
1579
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#short-circuiting
1580
- this.mergeTreeDeltaCallback?.({
1581
- op: (0, opBuilder_js_1.createInsertSegmentOp)(this.findRollbackPosition(segment), segment),
1582
- rollback: true,
1583
- }, {
1584
- operation: ops_js_1.MergeTreeDeltaType.INSERT,
1585
- deltaSegments: [{ segment }],
1586
- });
1578
+ (0, internal_1.assert)((0, segmentInfos_js_1.isRemoved)(segment) && segment.removes[0].type === "setRemove", 0x39d /* Rollback segment removedClientId does not match local client */);
1579
+ // if a peer client concurrently deleted the segment, don't revive it on rollback
1580
+ if (segment.removes[0].clientId === this.collabWindow.clientId) {
1581
+ // This also removes obliterates, but that should be ok as we can only remove a segment once.
1582
+ // If we were able to remove it locally, that also means there are no remote removals (since rollback is synchronous).
1583
+ (0, segmentInfos_js_1.removeRemovalInfo)(segment);
1584
+ this.blockUpdatePathLengths(segment.parent, rollbackStamp);
1585
+ // Note: optional chaining short-circuits:
1586
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#short-circuiting
1587
+ this.mergeTreeDeltaCallback?.({
1588
+ op: (0, opBuilder_js_1.createInsertSegmentOp)(this.findRollbackPosition(segment), segment),
1589
+ rollback: true,
1590
+ }, {
1591
+ operation: ops_js_1.MergeTreeDeltaType.INSERT,
1592
+ deltaSegments: [{ segment }],
1593
+ });
1594
+ }
1587
1595
  });
1588
1596
  }
1589
1597
  else if (op.type === ops_js_1.MergeTreeDeltaType.INSERT ||