@seatlayer/js 0.103.0 → 0.104.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/dist/index.d.cts CHANGED
@@ -275,7 +275,9 @@ declare function createBuyerAccessContext(options: {
275
275
  * - close code 4401 distinguishes an expired session (refresh/reconnect) from
276
276
  * a genuinely revoked one (typed terminal state, never a reconnect loop);
277
277
  * - liveness by ping/pong only. Silence is normal and carries no information
278
- * (protocol doc §5) — a quiet socket is never treated as a dead one.
278
+ * (protocol doc §5) — a quiet socket is never treated as a dead one;
279
+ * - a polling fallback for a network that will not upgrade at all (see
280
+ * {@link FALLBACK_AFTER_FAILED_UPGRADES}).
279
281
  */
280
282
 
281
283
  /** The projected status of one unit, as the server words it on the wire. */
@@ -363,6 +365,13 @@ interface BuyerRealtimeOptions {
363
365
  * terminal revoked state, exactly as the runtimes before 0.94 read it.
364
366
  */
365
367
  onIdleExpired?: () => void;
368
+ /**
369
+ * The availability read the polling fallback runs. Defaults to the sink's
370
+ * coalesced `resync`, which every sink already has.
371
+ */
372
+ poll?: () => void | Promise<void>;
373
+ /** The client just fell back to polling. The count beacon is sent anyway. */
374
+ onFallbackPolling?: () => void;
366
375
  /** Test seam. Defaults to the global WebSocket. */
367
376
  socketFactory?: (url: string, protocols: string[]) => WebSocket;
368
377
  /** Test seam for the keepalive/backoff timers. */
@@ -390,7 +399,14 @@ declare class BuyerRealtimeClient {
390
399
  private useQueryMarker;
391
400
  private hidden;
392
401
  private closedSections;
402
+ /** Upgrades in a row that closed (or threw) before they ever opened. */
403
+ private failedUpgrades;
404
+ /** Armed only while the socket cannot upgrade. See FALLBACK_AFTER_FAILED_UPGRADES. */
405
+ private pollTimer;
406
+ private fellBack;
393
407
  constructor(options: BuyerRealtimeOptions);
408
+ /** True while availability is being read on a timer instead of the socket. */
409
+ get polling(): boolean;
394
410
  /** Negotiated protocol, for tests and diagnostics. */
395
411
  get protocol(): 'v1' | 'legacy' | null;
396
412
  get snapshotVersion(): number | null;
@@ -404,6 +420,16 @@ declare class BuyerRealtimeClient {
404
420
  /** The server answered our resume; cancel the fallback resync. */
405
421
  private answered;
406
422
  private reportIfAccessError;
423
+ private upgradeFailed;
424
+ /**
425
+ * Read availability every FALLBACK_POLL_MS while the tab is visible.
426
+ *
427
+ * A hidden tab reads nothing — the widget's own visibility catch-up re-reads
428
+ * the moment the buyer comes back — so a forgotten tab behind a strict proxy
429
+ * costs no more than one that is closed. Stops the moment a socket opens.
430
+ */
431
+ private startPolling;
432
+ private stopPolling;
407
433
  /**
408
434
  * Liveness is ping/pong, and only ping/pong. A socket that receives nothing
409
435
  * for minutes is the normal, correct state for a narrowly-scoped buyer on a
package/dist/index.d.ts CHANGED
@@ -275,7 +275,9 @@ declare function createBuyerAccessContext(options: {
275
275
  * - close code 4401 distinguishes an expired session (refresh/reconnect) from
276
276
  * a genuinely revoked one (typed terminal state, never a reconnect loop);
277
277
  * - liveness by ping/pong only. Silence is normal and carries no information
278
- * (protocol doc §5) — a quiet socket is never treated as a dead one.
278
+ * (protocol doc §5) — a quiet socket is never treated as a dead one;
279
+ * - a polling fallback for a network that will not upgrade at all (see
280
+ * {@link FALLBACK_AFTER_FAILED_UPGRADES}).
279
281
  */
280
282
 
281
283
  /** The projected status of one unit, as the server words it on the wire. */
@@ -363,6 +365,13 @@ interface BuyerRealtimeOptions {
363
365
  * terminal revoked state, exactly as the runtimes before 0.94 read it.
364
366
  */
365
367
  onIdleExpired?: () => void;
368
+ /**
369
+ * The availability read the polling fallback runs. Defaults to the sink's
370
+ * coalesced `resync`, which every sink already has.
371
+ */
372
+ poll?: () => void | Promise<void>;
373
+ /** The client just fell back to polling. The count beacon is sent anyway. */
374
+ onFallbackPolling?: () => void;
366
375
  /** Test seam. Defaults to the global WebSocket. */
367
376
  socketFactory?: (url: string, protocols: string[]) => WebSocket;
368
377
  /** Test seam for the keepalive/backoff timers. */
@@ -390,7 +399,14 @@ declare class BuyerRealtimeClient {
390
399
  private useQueryMarker;
391
400
  private hidden;
392
401
  private closedSections;
402
+ /** Upgrades in a row that closed (or threw) before they ever opened. */
403
+ private failedUpgrades;
404
+ /** Armed only while the socket cannot upgrade. See FALLBACK_AFTER_FAILED_UPGRADES. */
405
+ private pollTimer;
406
+ private fellBack;
393
407
  constructor(options: BuyerRealtimeOptions);
408
+ /** True while availability is being read on a timer instead of the socket. */
409
+ get polling(): boolean;
394
410
  /** Negotiated protocol, for tests and diagnostics. */
395
411
  get protocol(): 'v1' | 'legacy' | null;
396
412
  get snapshotVersion(): number | null;
@@ -404,6 +420,16 @@ declare class BuyerRealtimeClient {
404
420
  /** The server answered our resume; cancel the fallback resync. */
405
421
  private answered;
406
422
  private reportIfAccessError;
423
+ private upgradeFailed;
424
+ /**
425
+ * Read availability every FALLBACK_POLL_MS while the tab is visible.
426
+ *
427
+ * A hidden tab reads nothing — the widget's own visibility catch-up re-reads
428
+ * the moment the buyer comes back — so a forgotten tab behind a strict proxy
429
+ * costs no more than one that is closed. Stops the moment a socket opens.
430
+ */
431
+ private startPolling;
432
+ private stopPolling;
407
433
  /**
408
434
  * Liveness is ping/pong, and only ping/pong. A socket that receives nothing
409
435
  * for minutes is the normal, correct state for a narrowly-scoped buyer on a