mindcache 3.4.2 → 3.4.3
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-D2xxVv4E.d.mts → CloudAdapter-CJS3Sh4f.d.mts} +4 -1
- package/dist/{CloudAdapter-D2xxVv4E.d.ts → CloudAdapter-CJS3Sh4f.d.ts} +4 -1
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +42 -7
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +42 -7
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -31
- package/dist/index.d.ts +4 -31
- package/dist/index.js +42 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -7
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +33 -0
- package/dist/server.d.ts +33 -0
- package/dist/server.js +2280 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +2250 -0
- package/dist/server.mjs.map +1 -0
- package/package.json +6 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AccessLevel,
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-CJS3Sh4f.mjs';
|
|
2
|
+
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, m as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, j as HistoryOptions, K as KeyAttributes, i as KeyEntry, f as KeyType, L as Listener, k as MindCacheCloudOptions, l as MindCacheIndexedDBOptions, h as STM, i as STMEntry, g as SystemTag, n as SystemTagHelpers } from './CloudAdapter-CJS3Sh4f.mjs';
|
|
3
|
+
export { IndexedDBAdapter, IndexedDBConfig } from './server.mjs';
|
|
3
4
|
import 'yjs';
|
|
4
5
|
|
|
5
|
-
interface IndexedDBConfig {
|
|
6
|
-
/** Database name (defaults to 'mindcache_db') */
|
|
7
|
-
dbName?: string;
|
|
8
|
-
/** Store name (defaults to 'mindcache_store') */
|
|
9
|
-
storeName?: string;
|
|
10
|
-
/** Storage key (defaults to 'mindcache_data') */
|
|
11
|
-
key?: string;
|
|
12
|
-
/** Debounce time in ms for saving (defaults to 1000) */
|
|
13
|
-
debounceMs?: number;
|
|
14
|
-
}
|
|
15
|
-
declare class IndexedDBAdapter {
|
|
16
|
-
private config;
|
|
17
|
-
private mindcache;
|
|
18
|
-
private unsubscribe;
|
|
19
|
-
private saveTimeout;
|
|
20
|
-
private db;
|
|
21
|
-
private dbName;
|
|
22
|
-
private storeName;
|
|
23
|
-
private key;
|
|
24
|
-
constructor(config?: IndexedDBConfig);
|
|
25
|
-
attach(mc: MindCache): Promise<void>;
|
|
26
|
-
detach(): void;
|
|
27
|
-
private initDB;
|
|
28
|
-
private load;
|
|
29
|
-
private scheduleSave;
|
|
30
|
-
private save;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
6
|
interface UseMindCacheResult {
|
|
34
7
|
/** The MindCache instance, null until loaded */
|
|
35
8
|
mindcache: MindCache | null;
|
|
@@ -61,4 +34,4 @@ declare function useMindCache(options?: MindCacheOptions): UseMindCacheResult;
|
|
|
61
34
|
|
|
62
35
|
declare const mindcache: MindCache;
|
|
63
36
|
|
|
64
|
-
export {
|
|
37
|
+
export { MindCache, MindCacheOptions, type UseMindCacheResult, mindcache, useMindCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AccessLevel,
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-CJS3Sh4f.js';
|
|
2
|
+
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, m as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, j as HistoryOptions, K as KeyAttributes, i as KeyEntry, f as KeyType, L as Listener, k as MindCacheCloudOptions, l as MindCacheIndexedDBOptions, h as STM, i as STMEntry, g as SystemTag, n as SystemTagHelpers } from './CloudAdapter-CJS3Sh4f.js';
|
|
3
|
+
export { IndexedDBAdapter, IndexedDBConfig } from './server.js';
|
|
3
4
|
import 'yjs';
|
|
4
5
|
|
|
5
|
-
interface IndexedDBConfig {
|
|
6
|
-
/** Database name (defaults to 'mindcache_db') */
|
|
7
|
-
dbName?: string;
|
|
8
|
-
/** Store name (defaults to 'mindcache_store') */
|
|
9
|
-
storeName?: string;
|
|
10
|
-
/** Storage key (defaults to 'mindcache_data') */
|
|
11
|
-
key?: string;
|
|
12
|
-
/** Debounce time in ms for saving (defaults to 1000) */
|
|
13
|
-
debounceMs?: number;
|
|
14
|
-
}
|
|
15
|
-
declare class IndexedDBAdapter {
|
|
16
|
-
private config;
|
|
17
|
-
private mindcache;
|
|
18
|
-
private unsubscribe;
|
|
19
|
-
private saveTimeout;
|
|
20
|
-
private db;
|
|
21
|
-
private dbName;
|
|
22
|
-
private storeName;
|
|
23
|
-
private key;
|
|
24
|
-
constructor(config?: IndexedDBConfig);
|
|
25
|
-
attach(mc: MindCache): Promise<void>;
|
|
26
|
-
detach(): void;
|
|
27
|
-
private initDB;
|
|
28
|
-
private load;
|
|
29
|
-
private scheduleSave;
|
|
30
|
-
private save;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
6
|
interface UseMindCacheResult {
|
|
34
7
|
/** The MindCache instance, null until loaded */
|
|
35
8
|
mindcache: MindCache | null;
|
|
@@ -61,4 +34,4 @@ declare function useMindCache(options?: MindCacheOptions): UseMindCacheResult;
|
|
|
61
34
|
|
|
62
35
|
declare const mindcache: MindCache;
|
|
63
36
|
|
|
64
|
-
export {
|
|
37
|
+
export { MindCache, MindCacheOptions, type UseMindCacheResult, mindcache, useMindCache };
|
package/dist/index.js
CHANGED
|
@@ -206,6 +206,7 @@ var init_CloudAdapter = __esm({
|
|
|
206
206
|
RECONNECT_DELAY = 1e3;
|
|
207
207
|
MAX_RECONNECT_DELAY = 3e4;
|
|
208
208
|
exports.CloudAdapter = class {
|
|
209
|
+
// Track if initial sync is complete
|
|
209
210
|
constructor(config) {
|
|
210
211
|
this.config = config;
|
|
211
212
|
if (!config.baseUrl) {
|
|
@@ -225,6 +226,7 @@ var init_CloudAdapter = __esm({
|
|
|
225
226
|
token = null;
|
|
226
227
|
handleOnline = null;
|
|
227
228
|
handleOffline = null;
|
|
229
|
+
_synced = false;
|
|
228
230
|
/** Browser network status - instantly updated via navigator.onLine */
|
|
229
231
|
get isOnline() {
|
|
230
232
|
return this._isOnline;
|
|
@@ -407,10 +409,14 @@ var init_CloudAdapter = __esm({
|
|
|
407
409
|
const encoder = encoding__namespace.createEncoder();
|
|
408
410
|
const decoder = decoding__namespace.createDecoder(new Uint8Array(event.data));
|
|
409
411
|
if (this.mindcache) {
|
|
410
|
-
syncProtocol__namespace.readSyncMessage(decoder, encoder, this.mindcache.doc, this);
|
|
412
|
+
const messageType = syncProtocol__namespace.readSyncMessage(decoder, encoder, this.mindcache.doc, this);
|
|
411
413
|
if (encoding__namespace.length(encoder) > 0) {
|
|
412
414
|
this.sendBinary(encoding__namespace.toUint8Array(encoder));
|
|
413
415
|
}
|
|
416
|
+
if (!this._synced && (messageType === 1 || messageType === 2)) {
|
|
417
|
+
this._synced = true;
|
|
418
|
+
this.emit("synced");
|
|
419
|
+
}
|
|
414
420
|
}
|
|
415
421
|
}
|
|
416
422
|
} catch (error) {
|
|
@@ -517,7 +523,7 @@ var MindCache = class {
|
|
|
517
523
|
_historyOptions = { maxEntries: 100, snapshotInterval: 10 };
|
|
518
524
|
_historyEnabled = false;
|
|
519
525
|
constructor(options) {
|
|
520
|
-
this.doc = new Y__namespace.Doc();
|
|
526
|
+
this.doc = options?.doc || new Y__namespace.Doc();
|
|
521
527
|
this.rootMap = this.doc.getMap("mindcache");
|
|
522
528
|
this.rootMap.observeDeep((events) => {
|
|
523
529
|
const keysAffected = /* @__PURE__ */ new Set();
|
|
@@ -1639,7 +1645,10 @@ var MindCache = class {
|
|
|
1639
1645
|
}
|
|
1640
1646
|
lines.push("```");
|
|
1641
1647
|
} else {
|
|
1642
|
-
lines.push(
|
|
1648
|
+
lines.push("- **Value**:");
|
|
1649
|
+
lines.push("```");
|
|
1650
|
+
lines.push(String(value));
|
|
1651
|
+
lines.push("```");
|
|
1643
1652
|
}
|
|
1644
1653
|
lines.push("");
|
|
1645
1654
|
});
|
|
@@ -1674,7 +1683,7 @@ var MindCache = class {
|
|
|
1674
1683
|
for (const line of lines) {
|
|
1675
1684
|
if (line.startsWith("### ") && !line.startsWith("### Appendix")) {
|
|
1676
1685
|
if (currentKey && currentValue !== null) {
|
|
1677
|
-
this.set_value(currentKey, currentValue, currentAttributes);
|
|
1686
|
+
this.set_value(currentKey, currentValue.trim(), currentAttributes);
|
|
1678
1687
|
}
|
|
1679
1688
|
currentKey = line.substring(4).trim();
|
|
1680
1689
|
currentAttributes = {};
|
|
@@ -1717,10 +1726,24 @@ var MindCache = class {
|
|
|
1717
1726
|
continue;
|
|
1718
1727
|
}
|
|
1719
1728
|
if (line.startsWith("- **Value**:") && !line.includes("[See Appendix")) {
|
|
1720
|
-
|
|
1729
|
+
const afterValue = line.substring(12).trim();
|
|
1730
|
+
if (afterValue === "") {
|
|
1731
|
+
currentValue = "";
|
|
1732
|
+
} else if (afterValue === "```" || afterValue === "```json") {
|
|
1733
|
+
inCodeBlock = true;
|
|
1734
|
+
codeBlockContent = [];
|
|
1735
|
+
currentValue = "";
|
|
1736
|
+
} else if (afterValue.startsWith("```")) {
|
|
1737
|
+
inCodeBlock = true;
|
|
1738
|
+
codeBlockContent = [afterValue.substring(3)];
|
|
1739
|
+
currentValue = "";
|
|
1740
|
+
} else {
|
|
1741
|
+
currentValue = afterValue;
|
|
1742
|
+
}
|
|
1721
1743
|
continue;
|
|
1722
1744
|
}
|
|
1723
|
-
|
|
1745
|
+
const trimmedLine = line.trim();
|
|
1746
|
+
if (trimmedLine === "```json" || trimmedLine === "```") {
|
|
1724
1747
|
if (inCodeBlock) {
|
|
1725
1748
|
inCodeBlock = false;
|
|
1726
1749
|
if (currentKey && codeBlockContent.length > 0) {
|
|
@@ -1729,15 +1752,27 @@ var MindCache = class {
|
|
|
1729
1752
|
codeBlockContent = [];
|
|
1730
1753
|
} else {
|
|
1731
1754
|
inCodeBlock = true;
|
|
1755
|
+
codeBlockContent = [];
|
|
1732
1756
|
}
|
|
1733
1757
|
continue;
|
|
1734
1758
|
}
|
|
1735
1759
|
if (inCodeBlock) {
|
|
1736
1760
|
codeBlockContent.push(line);
|
|
1761
|
+
} else if (currentKey && currentValue !== null) {
|
|
1762
|
+
currentValue += "\n" + line;
|
|
1737
1763
|
}
|
|
1738
1764
|
}
|
|
1739
1765
|
if (currentKey && currentValue !== null) {
|
|
1740
|
-
this.set_value(currentKey, currentValue, currentAttributes);
|
|
1766
|
+
this.set_value(currentKey, currentValue.trim(), currentAttributes);
|
|
1767
|
+
}
|
|
1768
|
+
const hasParsedKeys = lines.some((line) => line.startsWith("### ") && !line.startsWith("### Appendix"));
|
|
1769
|
+
if (!hasParsedKeys && markdown.trim().length > 0) {
|
|
1770
|
+
this.set_value("imported_content", markdown.trim(), {
|
|
1771
|
+
type: "text",
|
|
1772
|
+
systemTags: ["SystemPrompt", "LLMWrite"],
|
|
1773
|
+
// Default assumptions
|
|
1774
|
+
zIndex: 0
|
|
1775
|
+
});
|
|
1741
1776
|
}
|
|
1742
1777
|
}
|
|
1743
1778
|
/**
|