mindcache 3.3.1 → 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-BgpqZE00.d.mts → CloudAdapter-CeGQhFk9.d.mts} +15 -1
- package/dist/{CloudAdapter-BgpqZE00.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 +60 -1
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +60 -1
- 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 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cloud/index.mjs
CHANGED
|
@@ -182,6 +182,7 @@ var init_CloudAdapter = __esm({
|
|
|
182
182
|
if (!config.baseUrl) {
|
|
183
183
|
throw new Error("MindCache Cloud: baseUrl is required. Please provide the cloud API URL in your configuration.");
|
|
184
184
|
}
|
|
185
|
+
this.setupNetworkDetection();
|
|
185
186
|
}
|
|
186
187
|
ws = null;
|
|
187
188
|
mindcache = null;
|
|
@@ -189,8 +190,52 @@ var init_CloudAdapter = __esm({
|
|
|
189
190
|
reconnectAttempts = 0;
|
|
190
191
|
reconnectTimeout = null;
|
|
191
192
|
_state = "disconnected";
|
|
193
|
+
_isOnline = true;
|
|
194
|
+
// Browser network status
|
|
192
195
|
listeners = {};
|
|
193
196
|
token = null;
|
|
197
|
+
handleOnline = null;
|
|
198
|
+
handleOffline = null;
|
|
199
|
+
/** Browser network status - instantly updated via navigator.onLine */
|
|
200
|
+
get isOnline() {
|
|
201
|
+
return this._isOnline;
|
|
202
|
+
}
|
|
203
|
+
setupNetworkDetection() {
|
|
204
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this._isOnline = navigator.onLine;
|
|
208
|
+
this.handleOnline = () => {
|
|
209
|
+
console.log("\u2601\uFE0F CloudAdapter: Network is back online");
|
|
210
|
+
this._isOnline = true;
|
|
211
|
+
this.emit("network_online");
|
|
212
|
+
if (this._state === "disconnected" || this._state === "error") {
|
|
213
|
+
this.connect();
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
this.handleOffline = () => {
|
|
217
|
+
console.log("\u2601\uFE0F CloudAdapter: Network went offline");
|
|
218
|
+
this._isOnline = false;
|
|
219
|
+
this.emit("network_offline");
|
|
220
|
+
if (this._state === "connected" || this._state === "connecting") {
|
|
221
|
+
this._state = "disconnected";
|
|
222
|
+
this.emit("disconnected");
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
window.addEventListener("online", this.handleOnline);
|
|
226
|
+
window.addEventListener("offline", this.handleOffline);
|
|
227
|
+
}
|
|
228
|
+
cleanupNetworkDetection() {
|
|
229
|
+
if (typeof window === "undefined") {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (this.handleOnline) {
|
|
233
|
+
window.removeEventListener("online", this.handleOnline);
|
|
234
|
+
}
|
|
235
|
+
if (this.handleOffline) {
|
|
236
|
+
window.removeEventListener("offline", this.handleOffline);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
194
239
|
setToken(token) {
|
|
195
240
|
this.token = token;
|
|
196
241
|
}
|
|
@@ -284,6 +329,7 @@ var init_CloudAdapter = __esm({
|
|
|
284
329
|
this.ws.close();
|
|
285
330
|
this.ws = null;
|
|
286
331
|
}
|
|
332
|
+
this.cleanupNetworkDetection();
|
|
287
333
|
this._state = "disconnected";
|
|
288
334
|
this.emit("disconnected");
|
|
289
335
|
}
|
|
@@ -400,7 +446,7 @@ var MindCache = class {
|
|
|
400
446
|
listeners = {};
|
|
401
447
|
globalListeners = [];
|
|
402
448
|
// Metadata
|
|
403
|
-
version = "3.3.
|
|
449
|
+
version = "3.3.2";
|
|
404
450
|
// Internal flag to prevent sync loops when receiving remote updates
|
|
405
451
|
// (Less critical with Yjs but kept for API compat)
|
|
406
452
|
_isRemoteUpdate = false;
|
|
@@ -755,6 +801,19 @@ var MindCache = class {
|
|
|
755
801
|
get isCloud() {
|
|
756
802
|
return this._cloudConfig !== null;
|
|
757
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Browser network status. Returns true if online or in local-only mode.
|
|
806
|
+
* In cloud mode, this updates instantly when network status changes.
|
|
807
|
+
*/
|
|
808
|
+
get isOnline() {
|
|
809
|
+
if (!this._cloudAdapter) {
|
|
810
|
+
if (typeof navigator !== "undefined") {
|
|
811
|
+
return navigator.onLine;
|
|
812
|
+
}
|
|
813
|
+
return true;
|
|
814
|
+
}
|
|
815
|
+
return this._cloudAdapter.isOnline;
|
|
816
|
+
}
|
|
758
817
|
async waitForSync() {
|
|
759
818
|
if (this._isLoaded) {
|
|
760
819
|
return;
|