mindcache 3.4.0 → 3.4.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.
@@ -143,7 +143,6 @@ declare class MindCache {
143
143
  private listeners;
144
144
  private globalListeners;
145
145
  readonly version = "3.3.2";
146
- private _isRemoteUpdate;
147
146
  private normalizeSystemTags;
148
147
  private _cloudAdapter;
149
148
  private _connectionState;
@@ -219,7 +218,6 @@ declare class MindCache {
219
218
  get isOnline(): boolean;
220
219
  waitForSync(): Promise<void>;
221
220
  disconnect(): void;
222
- isRemoteUpdate(): boolean;
223
221
  serialize(): STM;
224
222
  deserialize(data: STM): void;
225
223
  private encodeFileToBase64;
@@ -143,7 +143,6 @@ declare class MindCache {
143
143
  private listeners;
144
144
  private globalListeners;
145
145
  readonly version = "3.3.2";
146
- private _isRemoteUpdate;
147
146
  private normalizeSystemTags;
148
147
  private _cloudAdapter;
149
148
  private _connectionState;
@@ -219,7 +218,6 @@ declare class MindCache {
219
218
  get isOnline(): boolean;
220
219
  waitForSync(): Promise<void>;
221
220
  disconnect(): void;
222
- isRemoteUpdate(): boolean;
223
221
  serialize(): STM;
224
222
  deserialize(data: STM): void;
225
223
  private encodeFileToBase64;
@@ -1,5 +1,5 @@
1
- import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-WvuWM4fD.mjs';
2
- export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-WvuWM4fD.mjs';
1
+ import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-C0UyG6OY.mjs';
2
+ export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-C0UyG6OY.mjs';
3
3
  import 'yjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-WvuWM4fD.js';
2
- export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-WvuWM4fD.js';
1
+ import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-C0UyG6OY.js';
2
+ export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-C0UyG6OY.js';
3
3
  import 'yjs';
4
4
 
5
5
  /**
@@ -73,7 +73,7 @@ var init_IndexedDBAdapter = __esm({
73
73
  await this.initDB();
74
74
  await this.load();
75
75
  const listener = () => {
76
- if (this.mindcache && !this.mindcache.isRemoteUpdate()) {
76
+ if (this.mindcache) {
77
77
  this.scheduleSave();
78
78
  }
79
79
  };
@@ -477,7 +477,6 @@ var MindCache = class {
477
477
  version = "3.3.2";
478
478
  // Internal flag to prevent sync loops when receiving remote updates
479
479
  // (Less critical with Yjs but kept for API compat)
480
- _isRemoteUpdate = false;
481
480
  normalizeSystemTags(tags) {
482
481
  const normalized = [];
483
482
  let hasSystemPrompt = false;
@@ -899,10 +898,6 @@ var MindCache = class {
899
898
  this._idbProvider = null;
900
899
  }
901
900
  }
902
- // Legacy bridge
903
- isRemoteUpdate() {
904
- return false;
905
- }
906
901
  // Serialize state
907
902
  serialize() {
908
903
  const json = {};
@@ -1098,6 +1093,14 @@ var MindCache = class {
1098
1093
  mergedAttrs.systemTags = this.normalizeSystemTags(mergedAttrs.systemTags);
1099
1094
  }
1100
1095
  entryMap.set("attributes", mergedAttrs);
1096
+ const currentValue = entryMap.get("value");
1097
+ if (mergedAttrs.type === "document" && !(currentValue instanceof Y__namespace.Text)) {
1098
+ const strValue = typeof currentValue === "string" ? currentValue : String(currentValue ?? "");
1099
+ entryMap.set("value", new Y__namespace.Text(strValue));
1100
+ this.getUndoManager(key);
1101
+ } else if (mergedAttrs.type !== "document" && currentValue instanceof Y__namespace.Text) {
1102
+ entryMap.set("value", currentValue.toString());
1103
+ }
1101
1104
  });
1102
1105
  }
1103
1106
  set_value(key, value, attributes) {
@@ -1108,10 +1111,15 @@ var MindCache = class {
1108
1111
  if (existingEntry) {
1109
1112
  const existingAttrs = existingEntry.get("attributes");
1110
1113
  if (existingAttrs?.type === "document") {
1111
- if (typeof value === "string") {
1112
- this._replaceDocumentText(key, value);
1114
+ if (!attributes?.type || attributes.type === "document") {
1115
+ if (typeof value === "string") {
1116
+ this._replaceDocumentText(key, value);
1117
+ }
1118
+ if (attributes) {
1119
+ this.set_attributes(key, attributes);
1120
+ }
1121
+ return;
1113
1122
  }
1114
- return;
1115
1123
  }
1116
1124
  }
1117
1125
  if (!existingEntry && attributes?.type === "document") {
@@ -1143,7 +1151,13 @@ var MindCache = class {
1143
1151
  normalizedAttributes.systemTags.push("template");
1144
1152
  }
1145
1153
  }
1146
- entryMap.set("value", value);
1154
+ let valueToSet = value;
1155
+ if (normalizedAttributes.type === "document" && !(valueToSet instanceof Y__namespace.Text)) {
1156
+ valueToSet = new Y__namespace.Text(typeof value === "string" ? value : String(value ?? ""));
1157
+ } else if (normalizedAttributes.type !== "document" && valueToSet instanceof Y__namespace.Text) {
1158
+ valueToSet = valueToSet.toString();
1159
+ }
1160
+ entryMap.set("value", valueToSet);
1147
1161
  entryMap.set("attributes", normalizedAttributes);
1148
1162
  });
1149
1163
  }