@seatlayer/js 0.102.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/{chunk-WFAVFYCD.js → chunk-P7YM5BKA.js} +1 -1
- package/dist/index.cjs +44 -36
- package/dist/index.d.cts +41 -3
- package/dist/index.d.ts +41 -3
- package/dist/index.js +43 -35
- package/dist/manager.cjs +1 -1
- package/dist/manager.js +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -224,8 +224,13 @@ declare class BuyerAccessContext {
|
|
|
224
224
|
/**
|
|
225
225
|
* Handle a 401/403 from a scoped call. Returns true when the caller should
|
|
226
226
|
* retry the same request once with the refreshed bearer.
|
|
227
|
+
*
|
|
228
|
+
* `sentAuthorization` is the `Authorization` header the failed request
|
|
229
|
+
* carried. When the caller has it, the "did the refresh change anything"
|
|
230
|
+
* check below compares against exactly that bearer; without it, the bearer
|
|
231
|
+
* this context last issued stands in.
|
|
227
232
|
*/
|
|
228
|
-
handleFailure(status: number, code: string | undefined): Promise<boolean>;
|
|
233
|
+
handleFailure(status: number, code: string | undefined, sentAuthorization?: string | null): Promise<boolean>;
|
|
229
234
|
/** Host-driven re-acquisition (after the buyer signs in again, say). */
|
|
230
235
|
refresh(reason?: BuyerAccessRefreshReason): Promise<boolean>;
|
|
231
236
|
/** Drop the bearer. Called on destroy so nothing outlives the widget. */
|
|
@@ -270,7 +275,9 @@ declare function createBuyerAccessContext(options: {
|
|
|
270
275
|
* - close code 4401 distinguishes an expired session (refresh/reconnect) from
|
|
271
276
|
* a genuinely revoked one (typed terminal state, never a reconnect loop);
|
|
272
277
|
* - liveness by ping/pong only. Silence is normal and carries no information
|
|
273
|
-
* (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}).
|
|
274
281
|
*/
|
|
275
282
|
|
|
276
283
|
/** The projected status of one unit, as the server words it on the wire. */
|
|
@@ -358,6 +365,13 @@ interface BuyerRealtimeOptions {
|
|
|
358
365
|
* terminal revoked state, exactly as the runtimes before 0.94 read it.
|
|
359
366
|
*/
|
|
360
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;
|
|
361
375
|
/** Test seam. Defaults to the global WebSocket. */
|
|
362
376
|
socketFactory?: (url: string, protocols: string[]) => WebSocket;
|
|
363
377
|
/** Test seam for the keepalive/backoff timers. */
|
|
@@ -385,7 +399,14 @@ declare class BuyerRealtimeClient {
|
|
|
385
399
|
private useQueryMarker;
|
|
386
400
|
private hidden;
|
|
387
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;
|
|
388
407
|
constructor(options: BuyerRealtimeOptions);
|
|
408
|
+
/** True while availability is being read on a timer instead of the socket. */
|
|
409
|
+
get polling(): boolean;
|
|
389
410
|
/** Negotiated protocol, for tests and diagnostics. */
|
|
390
411
|
get protocol(): 'v1' | 'legacy' | null;
|
|
391
412
|
get snapshotVersion(): number | null;
|
|
@@ -399,6 +420,16 @@ declare class BuyerRealtimeClient {
|
|
|
399
420
|
/** The server answered our resume; cancel the fallback resync. */
|
|
400
421
|
private answered;
|
|
401
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;
|
|
402
433
|
/**
|
|
403
434
|
* Liveness is ping/pong, and only ping/pong. A socket that receives nothing
|
|
404
435
|
* for minutes is the normal, correct state for a narrowly-scoped buyer on a
|
|
@@ -5257,7 +5288,8 @@ interface PerformanceGroupCheckoutHandoff {
|
|
|
5257
5288
|
/** What the wrapper is showing the buyer right now, for host telemetry. */
|
|
5258
5289
|
interface PerformanceGroupStatusEvent {
|
|
5259
5290
|
/** `checkout`: the hosted checkout could not start; the seats stay held. */
|
|
5260
|
-
|
|
5291
|
+
/** `session_ended`: the buyer's session ended; the map stopped updating. */
|
|
5292
|
+
kind: 'idle' | 'pending' | 'recovery_failed' | 'sales_closed' | 'revision_changed' | 'checkout' | 'session_ended';
|
|
5261
5293
|
message: string;
|
|
5262
5294
|
/** The short operation reference from §12, when one applies. */
|
|
5263
5295
|
reference?: string;
|
|
@@ -5535,6 +5567,12 @@ declare class PerformanceGroupPicker {
|
|
|
5535
5567
|
private setInteractionLocked;
|
|
5536
5568
|
private announce;
|
|
5537
5569
|
private showStatus;
|
|
5570
|
+
/**
|
|
5571
|
+
* The availability poll stopped because the buyer's session ended. The map
|
|
5572
|
+
* on screen is now stale, so the picker says that plainly, and the host is
|
|
5573
|
+
* told through `onError` so it can offer a fresh session.
|
|
5574
|
+
*/
|
|
5575
|
+
private sessionEnded;
|
|
5538
5576
|
private clearStatus;
|
|
5539
5577
|
private operationChanged;
|
|
5540
5578
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -224,8 +224,13 @@ declare class BuyerAccessContext {
|
|
|
224
224
|
/**
|
|
225
225
|
* Handle a 401/403 from a scoped call. Returns true when the caller should
|
|
226
226
|
* retry the same request once with the refreshed bearer.
|
|
227
|
+
*
|
|
228
|
+
* `sentAuthorization` is the `Authorization` header the failed request
|
|
229
|
+
* carried. When the caller has it, the "did the refresh change anything"
|
|
230
|
+
* check below compares against exactly that bearer; without it, the bearer
|
|
231
|
+
* this context last issued stands in.
|
|
227
232
|
*/
|
|
228
|
-
handleFailure(status: number, code: string | undefined): Promise<boolean>;
|
|
233
|
+
handleFailure(status: number, code: string | undefined, sentAuthorization?: string | null): Promise<boolean>;
|
|
229
234
|
/** Host-driven re-acquisition (after the buyer signs in again, say). */
|
|
230
235
|
refresh(reason?: BuyerAccessRefreshReason): Promise<boolean>;
|
|
231
236
|
/** Drop the bearer. Called on destroy so nothing outlives the widget. */
|
|
@@ -270,7 +275,9 @@ declare function createBuyerAccessContext(options: {
|
|
|
270
275
|
* - close code 4401 distinguishes an expired session (refresh/reconnect) from
|
|
271
276
|
* a genuinely revoked one (typed terminal state, never a reconnect loop);
|
|
272
277
|
* - liveness by ping/pong only. Silence is normal and carries no information
|
|
273
|
-
* (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}).
|
|
274
281
|
*/
|
|
275
282
|
|
|
276
283
|
/** The projected status of one unit, as the server words it on the wire. */
|
|
@@ -358,6 +365,13 @@ interface BuyerRealtimeOptions {
|
|
|
358
365
|
* terminal revoked state, exactly as the runtimes before 0.94 read it.
|
|
359
366
|
*/
|
|
360
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;
|
|
361
375
|
/** Test seam. Defaults to the global WebSocket. */
|
|
362
376
|
socketFactory?: (url: string, protocols: string[]) => WebSocket;
|
|
363
377
|
/** Test seam for the keepalive/backoff timers. */
|
|
@@ -385,7 +399,14 @@ declare class BuyerRealtimeClient {
|
|
|
385
399
|
private useQueryMarker;
|
|
386
400
|
private hidden;
|
|
387
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;
|
|
388
407
|
constructor(options: BuyerRealtimeOptions);
|
|
408
|
+
/** True while availability is being read on a timer instead of the socket. */
|
|
409
|
+
get polling(): boolean;
|
|
389
410
|
/** Negotiated protocol, for tests and diagnostics. */
|
|
390
411
|
get protocol(): 'v1' | 'legacy' | null;
|
|
391
412
|
get snapshotVersion(): number | null;
|
|
@@ -399,6 +420,16 @@ declare class BuyerRealtimeClient {
|
|
|
399
420
|
/** The server answered our resume; cancel the fallback resync. */
|
|
400
421
|
private answered;
|
|
401
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;
|
|
402
433
|
/**
|
|
403
434
|
* Liveness is ping/pong, and only ping/pong. A socket that receives nothing
|
|
404
435
|
* for minutes is the normal, correct state for a narrowly-scoped buyer on a
|
|
@@ -5257,7 +5288,8 @@ interface PerformanceGroupCheckoutHandoff {
|
|
|
5257
5288
|
/** What the wrapper is showing the buyer right now, for host telemetry. */
|
|
5258
5289
|
interface PerformanceGroupStatusEvent {
|
|
5259
5290
|
/** `checkout`: the hosted checkout could not start; the seats stay held. */
|
|
5260
|
-
|
|
5291
|
+
/** `session_ended`: the buyer's session ended; the map stopped updating. */
|
|
5292
|
+
kind: 'idle' | 'pending' | 'recovery_failed' | 'sales_closed' | 'revision_changed' | 'checkout' | 'session_ended';
|
|
5261
5293
|
message: string;
|
|
5262
5294
|
/** The short operation reference from §12, when one applies. */
|
|
5263
5295
|
reference?: string;
|
|
@@ -5535,6 +5567,12 @@ declare class PerformanceGroupPicker {
|
|
|
5535
5567
|
private setInteractionLocked;
|
|
5536
5568
|
private announce;
|
|
5537
5569
|
private showStatus;
|
|
5570
|
+
/**
|
|
5571
|
+
* The availability poll stopped because the buyer's session ended. The map
|
|
5572
|
+
* on screen is now stale, so the picker says that plainly, and the host is
|
|
5573
|
+
* told through `onError` so it can offer a fresh session.
|
|
5574
|
+
*/
|
|
5575
|
+
private sessionEnded;
|
|
5538
5576
|
private clearStatus;
|
|
5539
5577
|
private operationChanged;
|
|
5540
5578
|
/**
|