mindcache 3.3.0 → 3.3.2
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-CSncOr3V.d.mts → CloudAdapter-CeGQhFk9.d.mts} +15 -1
- package/dist/{CloudAdapter-CSncOr3V.d.ts → CloudAdapter-CeGQhFk9.d.ts} +15 -1
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +76 -5
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +76 -5
- 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 +76 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-
|
|
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-
|
|
1
|
+
import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-CeGQhFk9.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-CeGQhFk9.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-
|
|
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-
|
|
1
|
+
import { M as MindCache, a as MindCacheOptions } from './CloudAdapter-CeGQhFk9.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-CeGQhFk9.js';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
|
|
5
5
|
interface IndexedDBConfig {
|
package/dist/index.js
CHANGED
|
@@ -211,6 +211,7 @@ var init_CloudAdapter = __esm({
|
|
|
211
211
|
if (!config.baseUrl) {
|
|
212
212
|
throw new Error("MindCache Cloud: baseUrl is required. Please provide the cloud API URL in your configuration.");
|
|
213
213
|
}
|
|
214
|
+
this.setupNetworkDetection();
|
|
214
215
|
}
|
|
215
216
|
ws = null;
|
|
216
217
|
mindcache = null;
|
|
@@ -218,8 +219,52 @@ var init_CloudAdapter = __esm({
|
|
|
218
219
|
reconnectAttempts = 0;
|
|
219
220
|
reconnectTimeout = null;
|
|
220
221
|
_state = "disconnected";
|
|
222
|
+
_isOnline = true;
|
|
223
|
+
// Browser network status
|
|
221
224
|
listeners = {};
|
|
222
225
|
token = null;
|
|
226
|
+
handleOnline = null;
|
|
227
|
+
handleOffline = null;
|
|
228
|
+
/** Browser network status - instantly updated via navigator.onLine */
|
|
229
|
+
get isOnline() {
|
|
230
|
+
return this._isOnline;
|
|
231
|
+
}
|
|
232
|
+
setupNetworkDetection() {
|
|
233
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this._isOnline = navigator.onLine;
|
|
237
|
+
this.handleOnline = () => {
|
|
238
|
+
console.log("\u2601\uFE0F CloudAdapter: Network is back online");
|
|
239
|
+
this._isOnline = true;
|
|
240
|
+
this.emit("network_online");
|
|
241
|
+
if (this._state === "disconnected" || this._state === "error") {
|
|
242
|
+
this.connect();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
this.handleOffline = () => {
|
|
246
|
+
console.log("\u2601\uFE0F CloudAdapter: Network went offline");
|
|
247
|
+
this._isOnline = false;
|
|
248
|
+
this.emit("network_offline");
|
|
249
|
+
if (this._state === "connected" || this._state === "connecting") {
|
|
250
|
+
this._state = "disconnected";
|
|
251
|
+
this.emit("disconnected");
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
window.addEventListener("online", this.handleOnline);
|
|
255
|
+
window.addEventListener("offline", this.handleOffline);
|
|
256
|
+
}
|
|
257
|
+
cleanupNetworkDetection() {
|
|
258
|
+
if (typeof window === "undefined") {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (this.handleOnline) {
|
|
262
|
+
window.removeEventListener("online", this.handleOnline);
|
|
263
|
+
}
|
|
264
|
+
if (this.handleOffline) {
|
|
265
|
+
window.removeEventListener("offline", this.handleOffline);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
223
268
|
setToken(token) {
|
|
224
269
|
this.token = token;
|
|
225
270
|
}
|
|
@@ -313,6 +358,7 @@ var init_CloudAdapter = __esm({
|
|
|
313
358
|
this.ws.close();
|
|
314
359
|
this.ws = null;
|
|
315
360
|
}
|
|
361
|
+
this.cleanupNetworkDetection();
|
|
316
362
|
this._state = "disconnected";
|
|
317
363
|
this.emit("disconnected");
|
|
318
364
|
}
|
|
@@ -429,7 +475,7 @@ var MindCache = class {
|
|
|
429
475
|
listeners = {};
|
|
430
476
|
globalListeners = [];
|
|
431
477
|
// Metadata
|
|
432
|
-
version = "3.
|
|
478
|
+
version = "3.3.2";
|
|
433
479
|
// Internal flag to prevent sync loops when receiving remote updates
|
|
434
480
|
// (Less critical with Yjs but kept for API compat)
|
|
435
481
|
_isRemoteUpdate = false;
|
|
@@ -489,8 +535,22 @@ var MindCache = class {
|
|
|
489
535
|
constructor(options) {
|
|
490
536
|
this.doc = new Y__namespace.Doc();
|
|
491
537
|
this.rootMap = this.doc.getMap("mindcache");
|
|
492
|
-
this.rootMap.
|
|
493
|
-
|
|
538
|
+
this.rootMap.observeDeep((events) => {
|
|
539
|
+
const keysAffected = /* @__PURE__ */ new Set();
|
|
540
|
+
events.forEach((event) => {
|
|
541
|
+
if (event.target === this.rootMap) {
|
|
542
|
+
const mapEvent = event;
|
|
543
|
+
mapEvent.keysChanged.forEach((key) => keysAffected.add(key));
|
|
544
|
+
} else if (event.target.parent === this.rootMap) {
|
|
545
|
+
for (const [key, val] of this.rootMap) {
|
|
546
|
+
if (val === event.target) {
|
|
547
|
+
keysAffected.add(key);
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
keysAffected.forEach((key) => {
|
|
494
554
|
const entryMap = this.rootMap.get(key);
|
|
495
555
|
if (entryMap) {
|
|
496
556
|
const value = entryMap.get("value");
|
|
@@ -503,8 +563,6 @@ var MindCache = class {
|
|
|
503
563
|
}
|
|
504
564
|
}
|
|
505
565
|
});
|
|
506
|
-
});
|
|
507
|
-
this.rootMap.observeDeep((_events) => {
|
|
508
566
|
this.notifyGlobalListeners();
|
|
509
567
|
});
|
|
510
568
|
this.initGlobalUndoManager();
|
|
@@ -772,6 +830,19 @@ var MindCache = class {
|
|
|
772
830
|
get isCloud() {
|
|
773
831
|
return this._cloudConfig !== null;
|
|
774
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Browser network status. Returns true if online or in local-only mode.
|
|
835
|
+
* In cloud mode, this updates instantly when network status changes.
|
|
836
|
+
*/
|
|
837
|
+
get isOnline() {
|
|
838
|
+
if (!this._cloudAdapter) {
|
|
839
|
+
if (typeof navigator !== "undefined") {
|
|
840
|
+
return navigator.onLine;
|
|
841
|
+
}
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
return this._cloudAdapter.isOnline;
|
|
845
|
+
}
|
|
775
846
|
async waitForSync() {
|
|
776
847
|
if (this._isLoaded) {
|
|
777
848
|
return;
|