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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-WvuWM4fD.mjs';
2
- export { A as AccessLevel, C as CloudAdapter, j as CloudAdapterEvents, h as CloudConfig, i as ConnectionState, D as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, e as HistoryOptions, K as KeyAttributes, b as KeyType, L as Listener, f as MindCacheCloudOptions, g as MindCacheIndexedDBOptions, c as STM, d as STMEntry, S as SystemTag } from './CloudAdapter-WvuWM4fD.mjs';
1
+ import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-C0UyG6OY.mjs';
2
+ export { A as AccessLevel, C as CloudAdapter, j as CloudAdapterEvents, h as CloudConfig, i as ConnectionState, D as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, e as HistoryOptions, K as KeyAttributes, b as KeyType, L as Listener, f as MindCacheCloudOptions, g as MindCacheIndexedDBOptions, c as STM, d as STMEntry, S as SystemTag } from './CloudAdapter-C0UyG6OY.mjs';
3
3
  import 'yjs';
4
4
 
5
5
  interface IndexedDBConfig {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-WvuWM4fD.js';
2
- export { A as AccessLevel, C as CloudAdapter, j as CloudAdapterEvents, h as CloudConfig, i as ConnectionState, D as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, e as HistoryOptions, K as KeyAttributes, b as KeyType, L as Listener, f as MindCacheCloudOptions, g as MindCacheIndexedDBOptions, c as STM, d as STMEntry, S as SystemTag } from './CloudAdapter-WvuWM4fD.js';
1
+ import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-C0UyG6OY.js';
2
+ export { A as AccessLevel, C as CloudAdapter, j as CloudAdapterEvents, h as CloudConfig, i as ConnectionState, D as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, e as HistoryOptions, K as KeyAttributes, b as KeyType, L as Listener, f as MindCacheCloudOptions, g as MindCacheIndexedDBOptions, c as STM, d as STMEntry, S as SystemTag } from './CloudAdapter-C0UyG6OY.js';
3
3
  import 'yjs';
4
4
 
5
5
  interface IndexedDBConfig {
package/dist/index.js CHANGED
@@ -74,7 +74,7 @@ var init_IndexedDBAdapter = __esm({
74
74
  await this.initDB();
75
75
  await this.load();
76
76
  const listener = () => {
77
- if (this.mindcache && !this.mindcache.isRemoteUpdate()) {
77
+ if (this.mindcache) {
78
78
  this.scheduleSave();
79
79
  }
80
80
  };
@@ -478,7 +478,6 @@ var MindCache = class {
478
478
  version = "3.3.2";
479
479
  // Internal flag to prevent sync loops when receiving remote updates
480
480
  // (Less critical with Yjs but kept for API compat)
481
- _isRemoteUpdate = false;
482
481
  normalizeSystemTags(tags) {
483
482
  const normalized = [];
484
483
  let hasSystemPrompt = false;
@@ -900,10 +899,6 @@ var MindCache = class {
900
899
  this._idbProvider = null;
901
900
  }
902
901
  }
903
- // Legacy bridge
904
- isRemoteUpdate() {
905
- return false;
906
- }
907
902
  // Serialize state
908
903
  serialize() {
909
904
  const json = {};
@@ -1099,6 +1094,14 @@ var MindCache = class {
1099
1094
  mergedAttrs.systemTags = this.normalizeSystemTags(mergedAttrs.systemTags);
1100
1095
  }
1101
1096
  entryMap.set("attributes", mergedAttrs);
1097
+ const currentValue = entryMap.get("value");
1098
+ if (mergedAttrs.type === "document" && !(currentValue instanceof Y__namespace.Text)) {
1099
+ const strValue = typeof currentValue === "string" ? currentValue : String(currentValue ?? "");
1100
+ entryMap.set("value", new Y__namespace.Text(strValue));
1101
+ this.getUndoManager(key);
1102
+ } else if (mergedAttrs.type !== "document" && currentValue instanceof Y__namespace.Text) {
1103
+ entryMap.set("value", currentValue.toString());
1104
+ }
1102
1105
  });
1103
1106
  }
1104
1107
  set_value(key, value, attributes) {
@@ -1109,10 +1112,15 @@ var MindCache = class {
1109
1112
  if (existingEntry) {
1110
1113
  const existingAttrs = existingEntry.get("attributes");
1111
1114
  if (existingAttrs?.type === "document") {
1112
- if (typeof value === "string") {
1113
- this._replaceDocumentText(key, value);
1115
+ if (!attributes?.type || attributes.type === "document") {
1116
+ if (typeof value === "string") {
1117
+ this._replaceDocumentText(key, value);
1118
+ }
1119
+ if (attributes) {
1120
+ this.set_attributes(key, attributes);
1121
+ }
1122
+ return;
1114
1123
  }
1115
- return;
1116
1124
  }
1117
1125
  }
1118
1126
  if (!existingEntry && attributes?.type === "document") {
@@ -1144,7 +1152,13 @@ var MindCache = class {
1144
1152
  normalizedAttributes.systemTags.push("template");
1145
1153
  }
1146
1154
  }
1147
- entryMap.set("value", value);
1155
+ let valueToSet = value;
1156
+ if (normalizedAttributes.type === "document" && !(valueToSet instanceof Y__namespace.Text)) {
1157
+ valueToSet = new Y__namespace.Text(typeof value === "string" ? value : String(value ?? ""));
1158
+ } else if (normalizedAttributes.type !== "document" && valueToSet instanceof Y__namespace.Text) {
1159
+ valueToSet = valueToSet.toString();
1160
+ }
1161
+ entryMap.set("value", valueToSet);
1148
1162
  entryMap.set("attributes", normalizedAttributes);
1149
1163
  });
1150
1164
  }