@steve31415/baselib 3.77.0 → 4.0.0

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/README.md CHANGED
@@ -13,8 +13,8 @@ Server subpath exports: `config`, `log`, `auth`, `oauth-resource`, `connector`,
13
13
  `sync` provides the Postgres event-log and server protocol primitives, and
14
14
  `handleSyncEventsRequest`, the one handler for every app's
15
15
  `POST /api/sync/events`; `sync-browser` provides the IndexedDB outbox and
16
- offline-first client, whose live socket is either the app's own (default) or
17
- the connection hub's (`hubUrl`, hub mode).
16
+ offline-first client, whose live socket is the connection hub's (`hubUrl`;
17
+ the app's own socket went in 4.0.0).
18
18
  `app-update` renders build-aware shells, matches their ETags, and fetches
19
19
  retained assets for consumer-owned routes;
20
20
  `app-update-browser` detects a new traffic build and reloads when the app's
@@ -0,0 +1,35 @@
1
+ import type { EventLogEngine } from './engine.js';
2
+ import { type ClientEvent, type EventBody, type HttpEventsResponse, type SyncEvent } from './types.js';
3
+ /** What one request committed, for `afterCommit`: the events it appended,
4
+ * and the stored event of each retried event that had already committed. */
5
+ export interface SyncEventsCommitted<S extends EventBody> {
6
+ applied: SyncEvent<S>[];
7
+ duplicates: SyncEvent<S>[];
8
+ }
9
+ export interface SyncEventsRequestOptions<C extends EventBody, S extends EventBody> {
10
+ engine: EventLogEngine<C, S>;
11
+ /** Chosen by the app's authenticated, authorized route. */
12
+ scopeKey: string;
13
+ /** The request body as parsed JSON (untrusted). */
14
+ body: unknown;
15
+ parseClientEvent(value: unknown): ClientEvent<C>;
16
+ /** Runs once per request, after every event has been applied and before
17
+ * the catch-up is read, when at least one event was applied or was a
18
+ * duplicate: where the app notifies the hub (whose notify must fire on
19
+ * duplicates too, design §5.3). Awaited; it should not throw (a throw fails the
20
+ * request after the commit, and the client's retry is deduplicated). */
21
+ afterCommit?(committed: SyncEventsCommitted<S>): void | Promise<void>;
22
+ }
23
+ /** One handler for every app's `POST /api/sync/events` (connection hub
24
+ * design §5.5). Applies each event of `{clientGuid, events, lastSeq?}`
25
+ * through the engine in order. A request without `lastSeq` (the client's
26
+ * unload beacon) gets the old shape, `{ outcomes }` with
27
+ * duplicates reported as `applied`. A request with it gets frame outcomes
28
+ * (`applied` + committed events, `duplicate` + the stored event, `rejected`
29
+ * + error) and a contiguous catch-up from `lastSeq`, read after the commits:
30
+ * `events` + `currentSeq`, or `reload: true` when too far behind. Throws
31
+ * `SyncError('bad_request')` for a malformed batch (answer 400), and
32
+ * `SyncUnavailableError` when the database fails (answer 5xx; the client
33
+ * retries, and what committed before the failure comes back as duplicates).
34
+ * Events committed before such a failure still get `afterCommit`. */
35
+ export declare function handleSyncEventsRequest<C extends EventBody, S extends EventBody>(options: SyncEventsRequestOptions<C, S>): Promise<HttpEventsResponse<S>>;
@@ -0,0 +1,106 @@
1
+ import { SyncError, } from './types.js';
2
+ function record(value) {
3
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
4
+ ? value
5
+ : null;
6
+ }
7
+ function eventGuid(value) {
8
+ const candidate = record(value);
9
+ return typeof candidate?.eventGuid === 'string' ? candidate.eventGuid : '';
10
+ }
11
+ function parserError(error) {
12
+ return error instanceof SyncError
13
+ ? { code: error.code, message: error.message }
14
+ : { code: 'invalid_payload', message: 'invalid event' };
15
+ }
16
+ /** One handler for every app's `POST /api/sync/events` (connection hub
17
+ * design §5.5). Applies each event of `{clientGuid, events, lastSeq?}`
18
+ * through the engine in order. A request without `lastSeq` (the client's
19
+ * unload beacon) gets the old shape, `{ outcomes }` with
20
+ * duplicates reported as `applied`. A request with it gets frame outcomes
21
+ * (`applied` + committed events, `duplicate` + the stored event, `rejected`
22
+ * + error) and a contiguous catch-up from `lastSeq`, read after the commits:
23
+ * `events` + `currentSeq`, or `reload: true` when too far behind. Throws
24
+ * `SyncError('bad_request')` for a malformed batch (answer 400), and
25
+ * `SyncUnavailableError` when the database fails (answer 5xx; the client
26
+ * retries, and what committed before the failure comes back as duplicates).
27
+ * Events committed before such a failure still get `afterCommit`. */
28
+ export async function handleSyncEventsRequest(options) {
29
+ const batch = parseBatch(options.body);
30
+ const committed = { applied: [], duplicates: [] };
31
+ const runAfterCommit = async () => {
32
+ if (options.afterCommit && (committed.applied.length > 0 || committed.duplicates.length > 0)) {
33
+ await options.afterCommit(committed);
34
+ }
35
+ };
36
+ let outcomes;
37
+ try {
38
+ outcomes = await applyBatch(options.engine, options.scopeKey, batch, options.parseClientEvent, committed);
39
+ }
40
+ catch (error) {
41
+ // Peers must still hear of what committed: the retry reports it only as
42
+ // duplicates. The hook's own failure (likely, mid-outage) yields to the
43
+ // original error; the retry's duplicates run the hook again.
44
+ await runAfterCommit().catch(() => { });
45
+ throw error;
46
+ }
47
+ await runAfterCommit();
48
+ if (batch.lastSeq === undefined)
49
+ return { outcomes: outcomes.map(oldShape) };
50
+ const catchup = await options.engine.catchup(options.scopeKey, batch.lastSeq);
51
+ if (catchup.kind === 'reload')
52
+ return { outcomes, reload: true };
53
+ return { outcomes, events: catchup.events, currentSeq: catchup.currentSeq };
54
+ }
55
+ function parseBatch(request) {
56
+ const envelope = record(request);
57
+ if (!envelope ||
58
+ typeof envelope.clientGuid !== 'string' ||
59
+ envelope.clientGuid.length === 0 ||
60
+ !Array.isArray(envelope.events)) {
61
+ throw new SyncError('bad_request', 'invalid event batch');
62
+ }
63
+ const batch = { clientGuid: envelope.clientGuid, events: envelope.events };
64
+ if (envelope.lastSeq !== undefined) {
65
+ if (!Number.isSafeInteger(envelope.lastSeq) || envelope.lastSeq < 0) {
66
+ throw new SyncError('bad_request', 'invalid lastSeq');
67
+ }
68
+ batch.lastSeq = envelope.lastSeq;
69
+ }
70
+ return batch;
71
+ }
72
+ /** Applies the batch in order, recording into `committed` as it goes, so a
73
+ * caller still has it when an event throws partway. */
74
+ async function applyBatch(engine, scopeKey, batch, parseClientEvent, committed) {
75
+ const outcomes = [];
76
+ for (const value of batch.events) {
77
+ const guid = eventGuid(value);
78
+ let event;
79
+ try {
80
+ event = parseClientEvent(value);
81
+ }
82
+ catch (error) {
83
+ outcomes.push({ eventGuid: guid, status: 'rejected', error: parserError(error) });
84
+ continue;
85
+ }
86
+ const outcome = await engine.apply(scopeKey, batch.clientGuid, event);
87
+ if (outcome.kind === 'rejected') {
88
+ outcomes.push({ eventGuid: event.eventGuid, status: 'rejected', error: outcome.error });
89
+ }
90
+ else if (outcome.kind === 'duplicate') {
91
+ committed.duplicates.push(outcome.event);
92
+ outcomes.push({ eventGuid: event.eventGuid, status: 'duplicate', events: [outcome.event] });
93
+ }
94
+ else {
95
+ committed.applied.push(...outcome.events);
96
+ outcomes.push({ eventGuid: event.eventGuid, status: 'applied', events: outcome.events });
97
+ }
98
+ }
99
+ return outcomes;
100
+ }
101
+ function oldShape(outcome) {
102
+ if (outcome.status === 'rejected') {
103
+ return { eventGuid: outcome.eventGuid, status: 'rejected', error: outcome.error };
104
+ }
105
+ return { eventGuid: outcome.eventGuid, status: 'applied' };
106
+ }
@@ -1,6 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './schema.js';
3
3
  export * from './engine.js';
4
- export * from './broadcaster.js';
5
- export * from './session.js';
4
+ export * from './http-events.js';
6
5
  export * from './db-bridge.js';
@@ -1,6 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './schema.js';
3
3
  export * from './engine.js';
4
- export * from './broadcaster.js';
5
- export * from './session.js';
4
+ export * from './http-events.js';
6
5
  export * from './db-bridge.js';
@@ -20,71 +20,23 @@ export declare class SyncError extends Error {
20
20
  /** `EventLogEngine.apply` could not reach a verdict: a failure that is not
21
21
  * about the event (a dropped connection, a failover, a deploy's schema skew)
22
22
  * outlasted its retry. Not a rejection: the client must keep the event and
23
- * re-send it, which its GUID makes safe. `SyncSocketSession` closes the
24
- * socket with 1011 (the client reconnects and re-sends); an HTTP route lets
25
- * it propagate to a 5xx (the client retries). The engine has already logged
23
+ * re-send it, which its GUID makes safe. The HTTP route lets it propagate to
24
+ * a 5xx (the client retries). The engine has already logged
26
25
  * `sync.apply_failed` (ERROR); `cause` is the last failure. */
27
26
  export declare class SyncUnavailableError extends Error {
28
27
  constructor(cause: unknown);
29
28
  }
30
- export interface WsConnect {
31
- type: 'connect';
32
- clientGuid: string;
33
- lastSeq: number;
34
- }
35
- export interface WsClientEvent<T extends EventBody> {
36
- type: 'event';
37
- clientGuid: string;
38
- event: ClientEvent<T>;
39
- }
40
- export interface WsPing {
41
- type: 'ping';
42
- }
43
- export type WsClientMessage<T extends EventBody> = WsConnect | WsClientEvent<T> | WsPing;
44
- export interface WsEventBroadcast<T extends EventBody> {
45
- type: 'event';
46
- event: SyncEvent<T>;
47
- }
48
- export interface WsCatchup<T extends EventBody> {
49
- type: 'catchup';
50
- events: SyncEvent<T>[];
51
- currentSeq: number;
52
- buildId?: string;
53
- }
54
- export interface WsReload {
55
- type: 'reload';
56
- }
57
- export interface WsRejection {
58
- type: 'rejection';
59
- eventGuid: string;
60
- error: {
61
- code: string;
62
- message: string;
63
- };
64
- }
65
- export interface WsPong {
66
- type: 'pong';
67
- buildId?: string;
68
- }
69
- /** Prompt to verify the canonical traffic build over authenticated HTTP. */
70
- export interface WsBuildChanged {
71
- type: 'build_changed';
72
- }
73
- /** Durable events may have advanced; answer with connect(lastSeq). */
74
- export interface WsSyncAvailable {
75
- type: 'sync_available';
76
- }
77
- export type WsServerMessage<T extends EventBody> = WsEventBroadcast<T> | WsCatchup<T> | WsReload | WsRejection | WsPong | WsBuildChanged | WsSyncAvailable;
78
29
  export interface HttpEventsRequest<T extends EventBody> {
79
30
  clientGuid: string;
80
31
  events: ClientEvent<T>[];
81
- /** The tab's current sequence (hub-mode clients). A request that carries it
82
- * is answered with outcome frames and a catch-up from it
83
- * (`handleSyncEventsRequest`); one without it, the old shape. */
32
+ /** The tab's current sequence (every `SyncClient` POST). A request that
33
+ * carries it is answered with outcome frames and a catch-up from it
34
+ * (`handleSyncEventsRequest`); one without it (the unload beacon), the old
35
+ * shape. */
84
36
  lastSeq?: number;
85
37
  }
86
- /** One event's outcome in the old response shape: what clients that send no
87
- * `lastSeq` get, and all they read (anything but `rejected` is applied). */
38
+ /** One event's outcome in the old response shape: what a request without
39
+ * `lastSeq` gets (anything but `rejected` is applied). */
88
40
  export interface HttpEventOutcome {
89
41
  eventGuid: string;
90
42
  status: 'applied' | 'rejected';
@@ -9,9 +9,8 @@ export class SyncError extends Error {
9
9
  /** `EventLogEngine.apply` could not reach a verdict: a failure that is not
10
10
  * about the event (a dropped connection, a failover, a deploy's schema skew)
11
11
  * outlasted its retry. Not a rejection: the client must keep the event and
12
- * re-send it, which its GUID makes safe. `SyncSocketSession` closes the
13
- * socket with 1011 (the client reconnects and re-sends); an HTTP route lets
14
- * it propagate to a 5xx (the client retries). The engine has already logged
12
+ * re-send it, which its GUID makes safe. The HTTP route lets it propagate to
13
+ * a 5xx (the client retries). The engine has already logged
15
14
  * `sync.apply_failed` (ERROR); `cause` is the last failure. */
16
15
  export class SyncUnavailableError extends Error {
17
16
  constructor(cause) {
@@ -85,13 +85,9 @@ export interface SyncClientOptions<B, C extends EventBody, S extends EventBody,
85
85
  fetchBootstrap(signal: AbortSignal): Promise<B>;
86
86
  fetchCatchup(afterSeq: number, signal: AbortSignal): Promise<CatchupResult<S>>;
87
87
  beaconUrl: string;
88
- /** The app's own sync socket. Needed only without `hubUrl`: an app whose
89
- * server no longer serves one omits it (since 3.75.0). */
90
- socketUrl?(): string;
91
88
  runtime: SyncBrowserRuntime;
92
89
  authState: {
93
90
  isBlocked(): boolean;
94
- markBlocked(): void;
95
91
  onBlocked(listener: () => void): () => void;
96
92
  };
97
93
  logger: Pick<BrowserLogger, 'info' | 'warn' | 'error'>;
@@ -111,26 +107,24 @@ export interface SyncClientOptions<B, C extends EventBody, S extends EventBody,
111
107
  /** While hidden and disconnected, one HTTP catch-up per this interval
112
108
  * (default 5 min). */
113
109
  backgroundCatchupMs?: number;
114
- /** POSTs events to the app's batch endpoint (the beacon URL) and returns
115
- * its response. Lets a hidden, disconnected page deliver pending edits and
116
- * learn about rejections; without it the page beacons once. Hub mode
117
- * requires it: every mutation travels here, with `lastSeq`, and the
118
- * response's frames and catch-up (`handleSyncEventsRequest`) settle it. */
119
- postEvents?(body: {
110
+ /** POSTs events to the app's batch endpoint (the beacon URL's route) and
111
+ * returns its response. Every mutation travels here, with `lastSeq`, and
112
+ * the response's frames and catch-up (`handleSyncEventsRequest`) settle it. */
113
+ postEvents(body: {
120
114
  clientGuid: string;
121
115
  events: ClientEvent<C>[];
122
116
  lastSeq?: number;
123
117
  }, signal: AbortSignal): Promise<HttpEventsResponse<S>>;
124
- /** Hub mode (connection hub design §5.4–§5.5): the hub's base URL, e.g.
125
- * `https://hub.apps.snewman.net`. The live socket goes to
126
- * `wss://<hub>/api/ws?app=<app>` and carries hints only; mutations go over
127
- * `postEvents` and catch-ups over `fetchCatchup`, against the app.
128
- * Unset or empty: the same-origin socket (`socketUrl`), exactly as before.
129
- * Requires `app` and `postEvents`. One of `hubUrl` and `socketUrl` must be
130
- * set: the constructor throws otherwise. */
131
- hubUrl?: string;
132
- /** This app's name on the hub socket (hub mode). */
133
- app?: string;
118
+ /** The connection hub's base URL (connection hub design §5.4–§5.5), e.g.
119
+ * `https://hub.apps.snewman.net`: pass `pageHubUrl()`, the page shell's
120
+ * `pw-hub-url`. The live socket goes to `wss://<hub>/api/ws?app=<app>` and
121
+ * carries hints only; mutations go over `postEvents` and catch-ups over
122
+ * `fetchCatchup`, against the app. Since 4.0.0 there is no same-origin
123
+ * socket to fall back to: the constructor throws when this is undefined or
124
+ * empty (a shell without the meta is a misconfiguration, said at once). */
125
+ hubUrl: string | undefined;
126
+ /** This app's name on the hub socket. */
127
+ app: string;
134
128
  }
135
129
  export declare class SyncClient<B, C extends EventBody, S extends EventBody, Summary = unknown> {
136
130
  private readonly options;
@@ -164,8 +158,6 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
164
158
  private outageEscalated;
165
159
  private halted;
166
160
  private refetchInFlight;
167
- private probeInFlight;
168
- private probeRequested;
169
161
  private resyncTimes;
170
162
  /** Forward-gap events delivered while a resync is reconciling; drained
171
163
  * after the bootstrap installs. Non-null exactly while reconciling. */
@@ -182,12 +174,10 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
182
174
  private disposed;
183
175
  private hiddenSince;
184
176
  private hiddenSocketFailed;
185
- private beaconedWhileDormant;
186
177
  private backgroundTickTimer;
187
178
  private lastTickAt;
188
179
  private catchupSlot;
189
- private readonly httpApplied;
190
- private connectReplyTimer;
180
+ private wakeReplyTimer;
191
181
  private socketCreatedHidden;
192
182
  private socketOpenedAt;
193
183
  private candidate;
@@ -200,8 +190,7 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
200
190
  private stallCoveredUntil;
201
191
  private visibleSinceMono;
202
192
  private readonly counters;
203
- private readonly hub;
204
- /** Where the live socket goes: the hub's URL, or the app's own. */
193
+ /** The hub socket's URL. */
205
194
  private readonly socketUrl;
206
195
  /** The live hub socket answered our `connect`. */
207
196
  private hubAcked;
@@ -256,7 +245,6 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
256
245
  hasUnsafeWork(): boolean;
257
246
  hasUnresolvedFailures(): boolean;
258
247
  dismissFailure(eventGuid: string): void;
259
- refreshConnectionForBuild(): void;
260
248
  state(): SyncClientState;
261
249
  subscribe(listener: (state: SyncClientState) => void): () => void;
262
250
  private installRuntimeListeners;
@@ -298,11 +286,12 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
298
286
  private armRollover;
299
287
  private rolloverDelayMs;
300
288
  /** Make-before-break, as notes' document sockets do: a replacement connects
301
- * while the live socket keeps serving (sends, echoes, state), and takes over
302
- * when the server answers its connect. Nothing the user sees changes, even
303
- * with an edit unsent. The replacement's handshake re-runs the server's
304
- * identity check; a 4403 halts as on any socket. If it fails, the live socket
305
- * keeps serving until the server's age cap closes it (1012). */
289
+ * while the live socket keeps serving hints, and takes over when the hub
290
+ * acks its connect. Nothing the user sees changes, even with an edit
291
+ * unsent. The replacement's handshake re-runs the hub's identity check; a
292
+ * 4403 asks the app whether the session is gone, as on the live socket. If
293
+ * it fails, the live socket keeps serving until the hub's age cap closes it
294
+ * (1012). */
306
295
  private startRollover;
307
296
  private promoteCandidate;
308
297
  /** Abandons a rollover's replacement; `failure` logs why and tries again
@@ -315,11 +304,10 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
315
304
  private cancelBackgroundTick;
316
305
  private backgroundTick;
317
306
  private unsettledPending;
318
- private postPendingOverHttp;
319
307
  /** The HTTP catch-up (review S5): one slot, a return aborts any other
320
- * kind in flight, every kind gives up after 15 s. Hub mode: a request that
321
- * finds the slot busy queues one more catch-up to start when it frees (one
322
- * in flight, at most one queued), and the outcome feeds the app-request
308
+ * kind in flight, every kind gives up after 15 s. A request that finds the
309
+ * slot busy queues one more catch-up to start when it frees (one in
310
+ * flight, at most one queued), and the outcome feeds the app-request
323
311
  * ladder. */
324
312
  private runCatchup;
325
313
  private withTimeout;
@@ -333,21 +321,15 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
333
321
  /** The first failure of a return, before sync is back, retries quickly
334
322
  * (once per return); anything else takes the ladder. */
335
323
  private takeQuickRetry;
324
+ /** The 1-2-4-8-16-30 s ladder's next step after `attempts` failures, or
325
+ * 250 ms for a return's first failure. Both the hub socket and app
326
+ * requests retry on it, each with its own count. */
327
+ private nextRetryDelayMs;
336
328
  private scheduleReconnect;
337
- /** One HTTP round trip while the visible socket is down: delivers pending
338
- * events (`postEvents`), then catches up — which applies their echoes, so
339
- * the writes confirm — and doubles as the session probe (an expired
340
- * session halts through the auth state). A WebSocket handshake can be
341
- * stuck for minutes behind another one in the browser's per-IP queue while
342
- * HTTP works at once (notes, 2026-10-01), so writes must not wait for it. */
343
- private probeSession;
344
329
  private startOutage;
345
330
  /** ERROR only after OUTAGE_ESCALATE_MS of visible, on-time outage; re-armed
346
331
  * on each return so an outage that began hidden still escalates (S3). */
347
332
  private armEscalation;
348
- private dispatchMessage;
349
- private handleMessage;
350
- private handleSocketCatchup;
351
333
  /** Returns false when a forward gap prevented application. */
352
334
  private handleServerEvent;
353
335
  private handleRejection;
@@ -361,38 +343,28 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
361
343
  /** On return: a verdict needs 60 s of visible time (review B2). */
362
344
  private rearmFailureTimers;
363
345
  private failUnconfirmed;
364
- /** Logs and closes the open outage, if any: on a live (re)connection, or
365
- * (`via: 'background-catchup'`) when a hidden page's HTTP catch-up
366
- * succeeds without a socket after the outage escalated to ERROR. A hidden
367
- * page stops attempting its socket after one hidden failure, so an
368
- * escalated outage that went hidden stayed open, its ERROR unanswered by
369
- * any recovery line, until the page was next shown (notes 2026-11-16,
370
- * task a0f43dda: a tab left hidden for 9+ hours). The page is current
371
- * then; the return reconnects as usual and a failure there opens a new
372
- * outage. An outage that never escalated keeps its single log on return,
373
- * which reports the whole hidden spell. */
346
+ /** Logs and closes the open outage, if any, once sync is established
347
+ * again. */
374
348
  private endOutage;
375
349
  private onSyncEstablished;
376
350
  private requestReload;
377
351
  private resyncFromServer;
378
- /** Applies the events delivered while the bootstrap was in flight. On a
379
- * single socket they are contiguous with the install point, so this is
380
- * where a resync under a live stream converges; a hole (socket replaced
381
- * mid-fetch, buffer overflow) schedules a fresh resync via the normal gap
382
- * path instead. */
352
+ /** Applies the events delivered while the bootstrap was in flight (hint
353
+ * catch-ups, POST frames). Contiguous with the install point, they are
354
+ * where a resync under a live stream converges; a hole (an answer that
355
+ * skipped ahead, buffer overflow) schedules a fresh resync via the normal
356
+ * gap path instead. */
383
357
  private drainAfterResync;
384
358
  /** A stall episode ends only on proven convergence: a resync whose drain
385
- * scheduled nothing further, or a complete socket catch-up. A successful
359
+ * scheduled nothing further, or a complete catch-up under the hub's ack. A successful
386
360
  * reconcile alone is not convergence — in a chronic diverge-reconverge
387
361
  * cycle every reconcile succeeds. */
388
362
  private endResyncEpisode;
389
363
  private scheduleResyncRetry;
390
364
  private scheduleResyncFailureRetry;
391
365
  private cancelResyncFailureRetry;
392
- private sendConnect;
393
366
  private connectMessage;
394
367
  private sendRaw;
395
- private trySend;
396
368
  private flushViaBeacon;
397
369
  private updateConnectedState;
398
370
  private updatePendingState;
@@ -402,11 +374,11 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
402
374
  private halt;
403
375
  private clearConnectionTimers;
404
376
  private clearAllTimers;
405
- /** Live: the socket is open and, in hub mode, the hub answered our
406
- * `connect` and the last app request succeeded (a pong overdue replaces
407
- * the socket, so an open one has been heard from recently). */
377
+ /** Live: the socket is open, the hub answered our `connect` and the last
378
+ * app request succeeded (a pong overdue replaces the socket, so an open one
379
+ * has been heard from recently). */
408
380
  private isLive;
409
- /** Hub mode: is this close a quiet reconnect? 1012, 1013 or 4408 on a
381
+ /** Is this close a quiet reconnect? 1012, 1013 or 4408 on a
410
382
  * socket the hub had acked, and fewer than HUB_QUIET_CLOSE_BURST such
411
383
  * closes in the last minute; anything else takes the outage path. */
412
384
  private takeQuietHubClose;
@@ -415,10 +387,10 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
415
387
  /** Established needs a complete catch-up that began under the current ack
416
388
  * (review 3.60.1, finding 3). */
417
389
  private establishesUnder;
418
- /** Hub mode's state: live as `connected`/`syncing`; otherwise a countdown
390
+ /** The state: live as `connected`/`syncing`; otherwise a countdown
419
391
  * to whichever ladder (hub socket or app request) retries first; otherwise
420
392
  * `connecting`, or `disconnected` once something has failed. */
421
- private refreshHubState;
393
+ private refreshState;
422
394
  private handleHubMessage;
423
395
  /** The hub routes hints to this socket from now on. Established still
424
396
  * needs a catch-up that began after this (design §5.4); one queues behind
@@ -456,7 +428,7 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
456
428
  /** Re-send paths (established, resync, return): post the unsettled edits
457
429
  * unless a POST is already in flight. */
458
430
  private kickPost;
459
- /** Hub mode's mutation path: every unsettled edit in one POST, one POST in
431
+ /** The mutation path: every unsettled edit in one POST, one POST in
460
432
  * flight per tab. An edit submitted meanwhile posts after it succeeds; a
461
433
  * failure leaves the retry to the app-request ladder. */
462
434
  private runPost;
@@ -465,8 +437,7 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
465
437
  * carries the own events in order with any writer that interleaved, so no
466
438
  * forward gap trips a resync. Then the outcomes: frames confirm their
467
439
  * pending entry by GUID even at or below the tab's sequence (a resync may
468
- * have moved it past them, review round 2 B1); rejections settle as on
469
- * the socket. */
440
+ * have moved it past them, review round 2 B1). */
470
441
  private applyPostResponse;
471
442
  private detachSocket;
472
443
  private abortable;