@fluidframework/tree 2.10.0-307399 → 2.10.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.
@@ -54,7 +54,11 @@ import {
54
54
  jsonableTreeFromCursor,
55
55
  makeFieldBatchCodec,
56
56
  } from "../feature-libraries/index.js";
57
- import { SharedTreeBranch, getChangeReplaceType } from "../shared-tree-core/index.js";
57
+ import {
58
+ SharedTreeBranch,
59
+ getChangeReplaceType,
60
+ type SharedTreeBranchChange,
61
+ } from "../shared-tree-core/index.js";
58
62
  import { Breakable, TransactionResult, disposeSymbol, fail } from "../util/index.js";
59
63
 
60
64
  import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
@@ -581,7 +585,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
581
585
  this.events.emit("changed", { isLocal: true, kind }, getRevertible);
582
586
  withinEventContext = false;
583
587
  }
584
- } else if (event.type === "replace") {
588
+ } else if (this.isRemoteChangeEvent(event)) {
585
589
  // TODO: figure out how to plumb through commit kind info for remote changes
586
590
  this.events.emit("changed", { isLocal: false, kind: CommitKind.Default });
587
591
  }
@@ -870,6 +874,21 @@ export class TreeCheckout implements ITreeCheckoutFork {
870
874
  rootFields.delete(field);
871
875
  } while (cursor.nextField());
872
876
  }
877
+
878
+ /**
879
+ * `true` iff the given branch change event is due to a remote change
880
+ */
881
+ private isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {
882
+ return (
883
+ // remote changes are only ever applied to the main branch
884
+ !this.isBranch &&
885
+ // remote changes are applied to the main branch by rebasing it onto the trunk,
886
+ // no other rebases are allowed on the main branch so this means any replaces that are not
887
+ // transaction commits are remote changes
888
+ event.type === "replace" &&
889
+ getChangeReplaceType(event) !== "transactionCommit"
890
+ );
891
+ }
873
892
  }
874
893
 
875
894
  /**