mindcache 3.3.0 → 3.3.1

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.
@@ -400,7 +400,7 @@ var MindCache = class {
400
400
  listeners = {};
401
401
  globalListeners = [];
402
402
  // Metadata
403
- version = "3.1.0";
403
+ version = "3.3.1";
404
404
  // Internal flag to prevent sync loops when receiving remote updates
405
405
  // (Less critical with Yjs but kept for API compat)
406
406
  _isRemoteUpdate = false;
@@ -460,8 +460,22 @@ var MindCache = class {
460
460
  constructor(options) {
461
461
  this.doc = new Y.Doc();
462
462
  this.rootMap = this.doc.getMap("mindcache");
463
- this.rootMap.observe((event) => {
464
- event.keysChanged.forEach((key) => {
463
+ this.rootMap.observeDeep((events) => {
464
+ const keysAffected = /* @__PURE__ */ new Set();
465
+ events.forEach((event) => {
466
+ if (event.target === this.rootMap) {
467
+ const mapEvent = event;
468
+ mapEvent.keysChanged.forEach((key) => keysAffected.add(key));
469
+ } else if (event.target.parent === this.rootMap) {
470
+ for (const [key, val] of this.rootMap) {
471
+ if (val === event.target) {
472
+ keysAffected.add(key);
473
+ break;
474
+ }
475
+ }
476
+ }
477
+ });
478
+ keysAffected.forEach((key) => {
465
479
  const entryMap = this.rootMap.get(key);
466
480
  if (entryMap) {
467
481
  const value = entryMap.get("value");
@@ -474,8 +488,6 @@ var MindCache = class {
474
488
  }
475
489
  }
476
490
  });
477
- });
478
- this.rootMap.observeDeep((_events) => {
479
491
  this.notifyGlobalListeners();
480
492
  });
481
493
  this.initGlobalUndoManager();