mindcache 3.3.2 → 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/{CloudAdapter-CeGQhFk9.d.mts → CloudAdapter-C0UyG6OY.d.mts} +2 -13
- package/dist/{CloudAdapter-CeGQhFk9.d.ts → CloudAdapter-C0UyG6OY.d.ts} +2 -13
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +60 -31
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +60 -31
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +60 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -406,11 +404,6 @@ declare class MindCache {
|
|
|
406
404
|
* @returns Y.Text or undefined if key doesn't exist or isn't a document
|
|
407
405
|
*/
|
|
408
406
|
get_document(key: string): Y.Text | undefined;
|
|
409
|
-
/**
|
|
410
|
-
* Get plain text content of a document key.
|
|
411
|
-
* For collaborative editing, use get_document() and bind to an editor.
|
|
412
|
-
*/
|
|
413
|
-
get_document_text(key: string): string | undefined;
|
|
414
407
|
/**
|
|
415
408
|
* Insert text at a position in a document key.
|
|
416
409
|
*/
|
|
@@ -420,15 +413,11 @@ declare class MindCache {
|
|
|
420
413
|
*/
|
|
421
414
|
delete_text(key: string, index: number, length: number): void;
|
|
422
415
|
/**
|
|
423
|
-
* Replace all text in a document key.
|
|
416
|
+
* Replace all text in a document key (private - use set_value for public API).
|
|
424
417
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
425
418
|
* This preserves concurrent edits and provides better undo granularity.
|
|
426
|
-
*
|
|
427
|
-
* @param key - The document key
|
|
428
|
-
* @param newText - The new text content
|
|
429
|
-
* @param diffThreshold - Percentage (0-1) of change above which full replace is used (default: 0.8)
|
|
430
419
|
*/
|
|
431
|
-
|
|
420
|
+
private _replaceDocumentText;
|
|
432
421
|
subscribe(key: string, listener: Listener): () => void;
|
|
433
422
|
subscribeToAll(listener: GlobalListener): () => void;
|
|
434
423
|
unsubscribeFromAll(listener: GlobalListener): void;
|
|
@@ -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;
|
|
@@ -406,11 +404,6 @@ declare class MindCache {
|
|
|
406
404
|
* @returns Y.Text or undefined if key doesn't exist or isn't a document
|
|
407
405
|
*/
|
|
408
406
|
get_document(key: string): Y.Text | undefined;
|
|
409
|
-
/**
|
|
410
|
-
* Get plain text content of a document key.
|
|
411
|
-
* For collaborative editing, use get_document() and bind to an editor.
|
|
412
|
-
*/
|
|
413
|
-
get_document_text(key: string): string | undefined;
|
|
414
407
|
/**
|
|
415
408
|
* Insert text at a position in a document key.
|
|
416
409
|
*/
|
|
@@ -420,15 +413,11 @@ declare class MindCache {
|
|
|
420
413
|
*/
|
|
421
414
|
delete_text(key: string, index: number, length: number): void;
|
|
422
415
|
/**
|
|
423
|
-
* Replace all text in a document key.
|
|
416
|
+
* Replace all text in a document key (private - use set_value for public API).
|
|
424
417
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
425
418
|
* This preserves concurrent edits and provides better undo granularity.
|
|
426
|
-
*
|
|
427
|
-
* @param key - The document key
|
|
428
|
-
* @param newText - The new text content
|
|
429
|
-
* @param diffThreshold - Percentage (0-1) of change above which full replace is used (default: 0.8)
|
|
430
419
|
*/
|
|
431
|
-
|
|
420
|
+
private _replaceDocumentText;
|
|
432
421
|
subscribe(key: string, listener: Listener): () => void;
|
|
433
422
|
subscribeToAll(listener: GlobalListener): () => void;
|
|
434
423
|
unsubscribeFromAll(listener: GlobalListener): void;
|
package/dist/cloud/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-
|
|
2
|
-
export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-
|
|
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
|
/**
|
package/dist/cloud/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindCache, h as CloudConfig, C as CloudAdapter } from '../CloudAdapter-
|
|
2
|
-
export { m as ClearOperation, j as CloudAdapterEvents, i as ConnectionState, l as DeleteOperation, O as Operation, k as SetOperation } from '../CloudAdapter-
|
|
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
|
/**
|
package/dist/cloud/index.js
CHANGED
|
@@ -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
|
|
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;
|
|
@@ -547,14 +546,30 @@ var MindCache = class {
|
|
|
547
546
|
break;
|
|
548
547
|
}
|
|
549
548
|
}
|
|
549
|
+
} else {
|
|
550
|
+
let current = event.target;
|
|
551
|
+
while (current && current.parent) {
|
|
552
|
+
if (current.parent.parent === this.rootMap) {
|
|
553
|
+
for (const [key, val] of this.rootMap) {
|
|
554
|
+
if (val === current.parent) {
|
|
555
|
+
keysAffected.add(key);
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
current = current.parent;
|
|
562
|
+
}
|
|
550
563
|
}
|
|
551
564
|
});
|
|
552
565
|
keysAffected.forEach((key) => {
|
|
553
566
|
const entryMap = this.rootMap.get(key);
|
|
554
567
|
if (entryMap) {
|
|
555
568
|
const value = entryMap.get("value");
|
|
569
|
+
const attrs = entryMap.get("attributes");
|
|
570
|
+
const resolvedValue = attrs?.type === "document" && value instanceof Y__namespace.Text ? value.toString() : value;
|
|
556
571
|
if (this.listeners[key]) {
|
|
557
|
-
this.listeners[key].forEach((l) => l(
|
|
572
|
+
this.listeners[key].forEach((l) => l(resolvedValue));
|
|
558
573
|
}
|
|
559
574
|
} else {
|
|
560
575
|
if (this.listeners[key]) {
|
|
@@ -684,12 +699,19 @@ var MindCache = class {
|
|
|
684
699
|
if (event.target === this.rootMap) {
|
|
685
700
|
const mapEvent = event;
|
|
686
701
|
mapEvent.keysChanged.forEach((key) => keysAffected.add(key));
|
|
687
|
-
} else
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
702
|
+
} else {
|
|
703
|
+
let current = event.target;
|
|
704
|
+
while (current && current.parent) {
|
|
705
|
+
if (current.parent === this.rootMap) {
|
|
706
|
+
for (const [key, val] of this.rootMap) {
|
|
707
|
+
if (val === current) {
|
|
708
|
+
keysAffected.add(key);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
691
712
|
break;
|
|
692
713
|
}
|
|
714
|
+
current = current.parent;
|
|
693
715
|
}
|
|
694
716
|
}
|
|
695
717
|
});
|
|
@@ -876,10 +898,6 @@ var MindCache = class {
|
|
|
876
898
|
this._idbProvider = null;
|
|
877
899
|
}
|
|
878
900
|
}
|
|
879
|
-
// Legacy bridge
|
|
880
|
-
isRemoteUpdate() {
|
|
881
|
-
return false;
|
|
882
|
-
}
|
|
883
901
|
// Serialize state
|
|
884
902
|
serialize() {
|
|
885
903
|
const json = {};
|
|
@@ -1075,6 +1093,14 @@ var MindCache = class {
|
|
|
1075
1093
|
mergedAttrs.systemTags = this.normalizeSystemTags(mergedAttrs.systemTags);
|
|
1076
1094
|
}
|
|
1077
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
|
+
}
|
|
1078
1104
|
});
|
|
1079
1105
|
}
|
|
1080
1106
|
set_value(key, value, attributes) {
|
|
@@ -1085,12 +1111,21 @@ var MindCache = class {
|
|
|
1085
1111
|
if (existingEntry) {
|
|
1086
1112
|
const existingAttrs = existingEntry.get("attributes");
|
|
1087
1113
|
if (existingAttrs?.type === "document") {
|
|
1088
|
-
if (
|
|
1089
|
-
|
|
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;
|
|
1090
1122
|
}
|
|
1091
|
-
return;
|
|
1092
1123
|
}
|
|
1093
1124
|
}
|
|
1125
|
+
if (!existingEntry && attributes?.type === "document") {
|
|
1126
|
+
this.set_document(key, typeof value === "string" ? value : "", attributes);
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1094
1129
|
let entryMap = this.rootMap.get(key);
|
|
1095
1130
|
const isNewEntry = !entryMap;
|
|
1096
1131
|
if (isNewEntry) {
|
|
@@ -1116,7 +1151,13 @@ var MindCache = class {
|
|
|
1116
1151
|
normalizedAttributes.systemTags.push("template");
|
|
1117
1152
|
}
|
|
1118
1153
|
}
|
|
1119
|
-
|
|
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);
|
|
1120
1161
|
entryMap.set("attributes", normalizedAttributes);
|
|
1121
1162
|
});
|
|
1122
1163
|
}
|
|
@@ -1831,14 +1872,6 @@ var MindCache = class {
|
|
|
1831
1872
|
}
|
|
1832
1873
|
return void 0;
|
|
1833
1874
|
}
|
|
1834
|
-
/**
|
|
1835
|
-
* Get plain text content of a document key.
|
|
1836
|
-
* For collaborative editing, use get_document() and bind to an editor.
|
|
1837
|
-
*/
|
|
1838
|
-
get_document_text(key) {
|
|
1839
|
-
const yText = this.get_document(key);
|
|
1840
|
-
return yText?.toString();
|
|
1841
|
-
}
|
|
1842
1875
|
/**
|
|
1843
1876
|
* Insert text at a position in a document key.
|
|
1844
1877
|
*/
|
|
@@ -1858,15 +1891,11 @@ var MindCache = class {
|
|
|
1858
1891
|
}
|
|
1859
1892
|
}
|
|
1860
1893
|
/**
|
|
1861
|
-
* Replace all text in a document key.
|
|
1894
|
+
* Replace all text in a document key (private - use set_value for public API).
|
|
1862
1895
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
1863
1896
|
* This preserves concurrent edits and provides better undo granularity.
|
|
1864
|
-
*
|
|
1865
|
-
* @param key - The document key
|
|
1866
|
-
* @param newText - The new text content
|
|
1867
|
-
* @param diffThreshold - Percentage (0-1) of change above which full replace is used (default: 0.8)
|
|
1868
1897
|
*/
|
|
1869
|
-
|
|
1898
|
+
_replaceDocumentText(key, newText, diffThreshold = 0.8) {
|
|
1870
1899
|
const yText = this.get_document(key);
|
|
1871
1900
|
if (!yText) {
|
|
1872
1901
|
return;
|
|
@@ -1972,7 +2001,7 @@ var MindCache = class {
|
|
|
1972
2001
|
},
|
|
1973
2002
|
execute: async ({ value }) => {
|
|
1974
2003
|
if (isDocument) {
|
|
1975
|
-
this.
|
|
2004
|
+
this._replaceDocumentText(key, value);
|
|
1976
2005
|
} else {
|
|
1977
2006
|
this.set_value(key, value);
|
|
1978
2007
|
}
|
|
@@ -2128,7 +2157,7 @@ var MindCache = class {
|
|
|
2128
2157
|
switch (action) {
|
|
2129
2158
|
case "write":
|
|
2130
2159
|
if (isDocument) {
|
|
2131
|
-
this.
|
|
2160
|
+
this._replaceDocumentText(key, value);
|
|
2132
2161
|
} else {
|
|
2133
2162
|
this.set_value(key, value);
|
|
2134
2163
|
}
|