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