@pylonsync/sync 0.3.298 → 0.3.300
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.ts +6 -0
- package/dist/local-store.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.ts +25 -0
- package/src/local-store.ts +8 -0
package/dist/index.d.ts
CHANGED
|
@@ -340,6 +340,12 @@ export declare class SyncEngine {
|
|
|
340
340
|
* `useSyncStatus` is just a thin reader.
|
|
341
341
|
*/
|
|
342
342
|
connectionStatus(): SyncConnectionStatus;
|
|
343
|
+
/**
|
|
344
|
+
* Count of optimistic writes still queued locally (not yet acked by the
|
|
345
|
+
* server) — i.e. the offline outbox depth. 0 when fully synced. Read by the
|
|
346
|
+
* dev HUD's sync row; also handy for a "saving…" indicator.
|
|
347
|
+
*/
|
|
348
|
+
pendingCount(): number;
|
|
343
349
|
/**
|
|
344
350
|
* Mutate connection status + notify subscribers. Idempotent — same-
|
|
345
351
|
* status calls are a no-op so the WS onopen → connected transition
|
package/dist/local-store.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export declare class LocalStore {
|
|
|
33
33
|
* by `SyncEngine.reconcile` to know which tables to diff against
|
|
34
34
|
* server truth. */
|
|
35
35
|
entityNames(): string[];
|
|
36
|
+
/** Total rows held across all entity tables — the local replica size.
|
|
37
|
+
* Read by the dev HUD's sync row. */
|
|
38
|
+
size(): number;
|
|
36
39
|
/**
|
|
37
40
|
* Remove a row whose absence was confirmed by the server-truth
|
|
38
41
|
* reconciler. Records a tombstone at `tombstoneSeq` so a stale
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -487,6 +487,15 @@ export class SyncEngine {
|
|
|
487
487
|
return this._connectionStatus;
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Count of optimistic writes still queued locally (not yet acked by the
|
|
492
|
+
* server) — i.e. the offline outbox depth. 0 when fully synced. Read by the
|
|
493
|
+
* dev HUD's sync row; also handy for a "saving…" indicator.
|
|
494
|
+
*/
|
|
495
|
+
pendingCount(): number {
|
|
496
|
+
return this.mutations.pending().length;
|
|
497
|
+
}
|
|
498
|
+
|
|
490
499
|
/**
|
|
491
500
|
* Mutate connection status + notify subscribers. Idempotent — same-
|
|
492
501
|
* status calls are a no-op so the WS onopen → connected transition
|
|
@@ -533,6 +542,22 @@ export class SyncEngine {
|
|
|
533
542
|
if (this.config.multiTab === false) {
|
|
534
543
|
this.isMultiTabLeader = true;
|
|
535
544
|
}
|
|
545
|
+
// Dev HUD hook: in dev (the server injects `__PYLON_DEV__` into the page),
|
|
546
|
+
// publish a tiny read-only status probe the floating dev overlay polls for
|
|
547
|
+
// the sync row (connection + offline-outbox depth). Gated on the dev marker
|
|
548
|
+
// so it's never present in production. Defensive — never let it break init.
|
|
549
|
+
try {
|
|
550
|
+
const g = globalThis as Record<string, unknown>;
|
|
551
|
+
if (typeof window !== "undefined" && g.__PYLON_DEV__) {
|
|
552
|
+
g.__pylonDevSync = {
|
|
553
|
+
status: () => this.connectionStatus(),
|
|
554
|
+
pending: () => this.pendingCount(),
|
|
555
|
+
rows: () => this.store.size(),
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
} catch {
|
|
559
|
+
// ignore — the HUD just won't show a sync row
|
|
560
|
+
}
|
|
536
561
|
}
|
|
537
562
|
|
|
538
563
|
/**
|
package/src/local-store.ts
CHANGED
|
@@ -60,6 +60,14 @@ export class LocalStore {
|
|
|
60
60
|
return names;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** Total rows held across all entity tables — the local replica size.
|
|
64
|
+
* Read by the dev HUD's sync row. */
|
|
65
|
+
size(): number {
|
|
66
|
+
let n = 0;
|
|
67
|
+
for (const table of this.tables.values()) n += table.size;
|
|
68
|
+
return n;
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
/**
|
|
64
72
|
* Remove a row whose absence was confirmed by the server-truth
|
|
65
73
|
* reconciler. Records a tombstone at `tombstoneSeq` so a stale
|