@korajs/sync 0.1.4 → 0.1.5

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.cts CHANGED
@@ -337,6 +337,7 @@ declare class SyncEngine {
337
337
  private remoteVector;
338
338
  private lastSyncedAt;
339
339
  private currentBatch;
340
+ private reconnecting;
340
341
  private deltaBatchesReceived;
341
342
  private deltaReceiveComplete;
342
343
  private deltaSendComplete;
@@ -355,6 +356,13 @@ declare class SyncEngine {
355
356
  * If streaming, flushes immediately.
356
357
  */
357
358
  pushOperation(op: Operation): Promise<void>;
359
+ /**
360
+ * Mark the engine as being in a reconnection loop. When reconnecting,
361
+ * `getStatus()` returns 'offline' instead of 'syncing' for intermediate
362
+ * states (connecting, handshaking, syncing), since the user is effectively
363
+ * disconnected until reconnection succeeds.
364
+ */
365
+ setReconnecting(value: boolean): void;
358
366
  /**
359
367
  * Get the current developer-facing sync status.
360
368
  */
package/dist/index.d.ts CHANGED
@@ -337,6 +337,7 @@ declare class SyncEngine {
337
337
  private remoteVector;
338
338
  private lastSyncedAt;
339
339
  private currentBatch;
340
+ private reconnecting;
340
341
  private deltaBatchesReceived;
341
342
  private deltaReceiveComplete;
342
343
  private deltaSendComplete;
@@ -355,6 +356,13 @@ declare class SyncEngine {
355
356
  * If streaming, flushes immediately.
356
357
  */
357
358
  pushOperation(op: Operation): Promise<void>;
359
+ /**
360
+ * Mark the engine as being in a reconnection loop. When reconnecting,
361
+ * `getStatus()` returns 'offline' instead of 'syncing' for intermediate
362
+ * states (connecting, handshaking, syncing), since the user is effectively
363
+ * disconnected until reconnection succeeds.
364
+ */
365
+ setReconnecting(value: boolean): void;
358
366
  /**
359
367
  * Get the current developer-facing sync status.
360
368
  */
package/dist/index.js CHANGED
@@ -1173,6 +1173,7 @@ var SyncEngine = class {
1173
1173
  remoteVector = /* @__PURE__ */ new Map();
1174
1174
  lastSyncedAt = null;
1175
1175
  currentBatch = null;
1176
+ reconnecting = false;
1176
1177
  // Track delta exchange state
1177
1178
  deltaBatchesReceived = 0;
1178
1179
  deltaReceiveComplete = false;
@@ -1251,6 +1252,15 @@ var SyncEngine = class {
1251
1252
  this.flushQueue();
1252
1253
  }
1253
1254
  }
1255
+ /**
1256
+ * Mark the engine as being in a reconnection loop. When reconnecting,
1257
+ * `getStatus()` returns 'offline' instead of 'syncing' for intermediate
1258
+ * states (connecting, handshaking, syncing), since the user is effectively
1259
+ * disconnected until reconnection succeeds.
1260
+ */
1261
+ setReconnecting(value) {
1262
+ this.reconnecting = value;
1263
+ }
1254
1264
  /**
1255
1265
  * Get the current developer-facing sync status.
1256
1266
  */
@@ -1262,7 +1272,11 @@ var SyncEngine = class {
1262
1272
  case "connecting":
1263
1273
  case "handshaking":
1264
1274
  case "syncing":
1265
- return { status: "syncing", pendingOperations, lastSyncedAt: this.lastSyncedAt };
1275
+ return {
1276
+ status: this.reconnecting ? "offline" : "syncing",
1277
+ pendingOperations,
1278
+ lastSyncedAt: this.lastSyncedAt
1279
+ };
1266
1280
  case "streaming":
1267
1281
  return {
1268
1282
  status: pendingOperations > 0 ? "syncing" : "synced",