@urun-sh/core 0.2.15 → 0.2.17

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.
@@ -1,5 +1,5 @@
1
- import { b as AppOptions, a as App$1, K as SessionPhase, T as SessionStatus, O as SessionPhaseName, A as AccessTokenOptions$1, y as RuntimeArtifact, z as RuntimeArtifactDownload, R as Recording, G as Session$1, C as ChannelEndpoint, _ as TransportSession, c as AttachOptions, v as RecordingsAccessor, B as RuntimeArtifactsAccessor, U as SessionStream$1, Z as StreamDataTransport, I as SessionDocumentImpl, Y as StreamChunkOptions, g as ChunkReadable, P as Presence, k as DocConnector, w as RequestOptions, x as RequestStreamOptions, X as StoreOptions, W as Store, e as ChannelMultiplexer, J as SessionFailureKind } from './stream-data-b249LZR2.mjs';
2
- export { L as Layer, l as LayoutConfig, m as LayoutContext, M as MediaChunkBinding, o as MediaChunkSource, p as MediaChunkSourceFactory, q as MediaRecorderChunkSourceOptions, r as PresenceState, s as RecordingBucket, t as RecordingLifecycle, u as RecordingStatus, E as RuntimeAvailability, S as SceneContext, F as SceneGraph, H as SessionDocument, N as SessionPhaseError, V as SessionText, a0 as TransportState, a4 as isPendingRecording, a5 as mediaRecorderChunkSource } from './stream-data-b249LZR2.mjs';
1
+ import { b as AppOptions, a as App$1, N as SessionPhase, U as SessionStatus, Q as SessionPhaseName, A as AccessTokenOptions$1, y as RuntimeArtifact, z as RuntimeArtifactDownload, R as Recording, G as Session$1, C as ChannelEndpoint, $ as TransportSession, c as AttachOptions, v as RecordingsAccessor, B as RuntimeArtifactsAccessor, J as SessionEndResult, V as SessionStream$1, _ as StreamDataTransport, I as SessionDocumentImpl, Z as StreamChunkOptions, g as ChunkReadable, P as Presence, k as DocConnector, w as RequestOptions, x as RequestStreamOptions, Y as StoreOptions, X as Store, e as ChannelMultiplexer, K as SessionFailureKind, a1 as TransportState } from './stream-data-rqyqR75F.mjs';
2
+ export { L as Layer, l as LayoutConfig, m as LayoutContext, M as MediaChunkBinding, o as MediaChunkSource, p as MediaChunkSourceFactory, q as MediaRecorderChunkSourceOptions, r as PresenceState, s as RecordingBucket, t as RecordingLifecycle, u as RecordingStatus, E as RuntimeAvailability, S as SceneContext, F as SceneGraph, H as SessionDocument, O as SessionPhaseError, W as SessionText, a5 as isPendingRecording, a6 as mediaRecorderChunkSource } from './stream-data-rqyqR75F.mjs';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
5
5
 
@@ -247,6 +247,8 @@ declare class Session implements Session$1 {
247
247
 
248
248
  private _docConnector;
249
249
 
250
+ private _docEndpointKey;
251
+
250
252
  private _streamData;
251
253
 
252
254
  private _presence;
@@ -254,6 +256,8 @@ declare class Session implements Session$1 {
254
256
  private _activity;
255
257
 
256
258
  private _activeRequests;
259
+ private _endHandler?;
260
+ private _endPromise?;
257
261
 
258
262
  private _recordingsAuth?;
259
263
 
@@ -287,6 +291,8 @@ declare class Session implements Session$1 {
287
291
  setArtifactsAuth(auth: RuntimeArtifactsClientOptions): void;
288
292
  private _requireArtifactsAuth;
289
293
  setSessionId(sessionId: string): void;
294
+
295
+ setEndHandler(handler: () => Promise<SessionEndResult>): void;
290
296
  stream(name: string): SessionStream;
291
297
 
292
298
  doc(key: string): SessionDocumentImpl;
@@ -320,6 +326,7 @@ declare class Session implements Session$1 {
320
326
  recover(): void;
321
327
 
322
328
  onRecovery(hook: () => void): () => void;
329
+ end(): Promise<SessionEndResult>;
323
330
  disconnect(): void;
324
331
  }
325
332
 
@@ -341,6 +348,25 @@ interface VideoStreamOptions {
341
348
 
342
349
  declare function videoStream(source: ReadableStream<Uint8Array>, options?: VideoStreamOptions): MediaStream;
343
350
 
351
+ declare class SessionEndUnavailableError extends Error {
352
+ readonly code = "session_end_unavailable";
353
+ constructor(message?: string, options?: {
354
+ cause?: unknown;
355
+ });
356
+ }
357
+
358
+ declare class SessionEndError extends Error {
359
+ readonly code: string;
360
+ readonly httpStatus?: number;
361
+ readonly requestId: string;
362
+ constructor(message: string, options: {
363
+ requestId: string;
364
+ code?: string;
365
+ httpStatus?: number;
366
+ cause?: unknown;
367
+ });
368
+ }
369
+
344
370
  declare class RequestError extends Error {
345
371
 
346
372
  readonly requestId?: string;
@@ -548,4 +574,254 @@ interface InputPresencePublisher {
548
574
 
549
575
  declare function createInputPresencePublisher(options: InputPresencePublisherOptions): InputPresencePublisher;
550
576
 
551
- export { ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, FOREGROUND_COALESCE_MS, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type VideoStreamOptions, type WhenLiveOptions, createActivityTracker, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, isDurationString, isWakingPhase, normalizeRetention, observePageLifecycle, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };
577
+ interface MediaSession {
578
+ readonly kind: 'webtransport' | 'webrtc';
579
+ start(): Promise<void>;
580
+ stop(): Promise<void>;
581
+
582
+ onDead(cb: (reason: string) => void): void;
583
+
584
+ stats(): {
585
+ recvBps: number;
586
+ lossPct: number;
587
+ jitterMs: number;
588
+ };
589
+ }
590
+
591
+ interface Signaling {
592
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
593
+ notify(method: string, params?: unknown): void;
594
+
595
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
596
+ }
597
+
598
+ interface SignalCarrier {
599
+
600
+ sendSignal(msg: Record<string, unknown>): void;
601
+
602
+ onSignal(handler: (msg: Record<string, unknown>) => void): () => void;
603
+ }
604
+ declare class TransportSessionSignaling implements Signaling {
605
+ private carrier;
606
+ private requestTimeoutMs;
607
+ constructor(carrier: SignalCarrier, requestTimeoutMs?: number);
608
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
609
+ notify(method: string, params?: unknown): void;
610
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
611
+ }
612
+
613
+ interface TransportOfferRequest {
614
+ sessionId: string;
615
+ capabilities: {
616
+
617
+ webtransport: boolean;
618
+
619
+ webcodecs: boolean;
620
+
621
+ codecs: string[];
622
+ };
623
+ }
624
+ interface TransportOfferResponse {
625
+
626
+ webrtc: {
627
+ routerRtpCapabilities: unknown;
628
+ };
629
+
630
+ webtransport?: {
631
+ url: string;
632
+
633
+ certHashes: string[];
634
+
635
+ token: string;
636
+ codec: string;
637
+ };
638
+ }
639
+ interface TransportEstablishedNotify {
640
+ sessionId: string;
641
+ transport: 'webtransport' | 'webrtc';
642
+
643
+ fallbackReason?: string;
644
+ }
645
+ type WtControlMessage = {
646
+ t: 'hello';
647
+ token: string;
648
+ sessionId: string;
649
+ } | {
650
+ t: 'hello-ack';
651
+ codec: string;
652
+ width: number;
653
+ height: number;
654
+ } | {
655
+ t: 'ping';
656
+ ts: number;
657
+ } | {
658
+ t: 'pong';
659
+ ts: number;
660
+ } | {
661
+ t: 'keyframe-request';
662
+ } | {
663
+ t: 'feedback';
664
+ recvBps: number;
665
+ lossPct: number;
666
+ jitterMs: number;
667
+ };
668
+
669
+ declare const WT_CONTROL_FRAME_MAX: number;
670
+
671
+ declare function encodeWtControlFrame(msg: WtControlMessage): Uint8Array;
672
+
673
+ declare class WtControlDecoder {
674
+ private buf;
675
+ push(bytes: Uint8Array): WtControlMessage[];
676
+ }
677
+ declare const DGRAM_HEADER_BYTES = 12;
678
+ interface DgramHeader {
679
+ groupId: number;
680
+ frameSeq: number;
681
+ keyframe: boolean;
682
+ fragIndex: number;
683
+ fragCount: number;
684
+ }
685
+
686
+ declare function parseDgramHeader(view: DataView): DgramHeader;
687
+
688
+ declare function writeDgramHeader(h: DgramHeader): Uint8Array;
689
+
690
+ interface NegotiatorOptions {
691
+
692
+ quicDeadlineMs?: number;
693
+
694
+ allowWebTransport?: boolean;
695
+ onTransportChange?: (kind: MediaSession['kind'], reason?: string) => void;
696
+
697
+ canvas?: HTMLCanvasElement;
698
+
699
+ createWebRtcSession: () => MediaSession;
700
+ createWebTransportSession?: (offer: NonNullable<TransportOfferResponse['webtransport']>) => MediaSession;
701
+ }
702
+ declare class TransportNegotiator {
703
+ private signaling;
704
+ private sessionId;
705
+ private opts;
706
+ private session;
707
+ private offer;
708
+ constructor(signaling: Signaling, sessionId: string, opts: NegotiatorOptions);
709
+ get activeTransport(): MediaSession['kind'] | null;
710
+ connect(): Promise<MediaSession>;
711
+ disconnect(): Promise<void>;
712
+ private createWebTransportSession;
713
+ private startWebRtc;
714
+
715
+ private armFailover;
716
+ private notifyEstablished;
717
+ }
718
+
719
+ declare class WebTransportSession implements MediaSession {
720
+ private offer;
721
+ private sessionId;
722
+ private canvas;
723
+ readonly kind: "webtransport";
724
+ private wt;
725
+ private decoder;
726
+ private writer;
727
+ private deadCb;
728
+ private deadFired;
729
+ private stopped;
730
+ private feedbackTimer;
731
+ private reassembler;
732
+ private lastArrivalTs;
733
+ private jitterEwmaMs;
734
+ private lastStats;
735
+ private firstFrameResolve;
736
+ private firstFrameReject;
737
+ constructor(offer: NonNullable<TransportOfferResponse['webtransport']>, sessionId: string, canvas: HTMLCanvasElement);
738
+
739
+ start(): Promise<void>;
740
+ stop(): Promise<void>;
741
+ onDead(cb: (reason: string) => void): void;
742
+ stats(): {
743
+ recvBps: number;
744
+ lossPct: number;
745
+ jitterMs: number;
746
+ };
747
+ private initDecoder;
748
+ private datagramLoop;
749
+ private decodeFrame;
750
+ private sendControl;
751
+ private readControl;
752
+ private controlLoop;
753
+
754
+ private feedbackLoop;
755
+ private die;
756
+ }
757
+
758
+ interface ConsumingTransport {
759
+ getTrackByName(name: string): MediaStreamTrack | undefined;
760
+ on(event: 'track', handler: (track: MediaStreamTrack) => void): () => void;
761
+ on(event: 'stateChange', handler: (state: TransportState) => void): () => void;
762
+ }
763
+ declare class WebRtcSession implements MediaSession {
764
+ private transport;
765
+ private streamName;
766
+ readonly kind: "webrtc";
767
+ private deadCb;
768
+ private deadFired;
769
+ private unsubscribers;
770
+ constructor(transport: ConsumingTransport, streamName?: string);
771
+
772
+ start(): Promise<void>;
773
+
774
+ stop(): Promise<void>;
775
+ onDead(cb: (reason: string) => void): void;
776
+ stats(): {
777
+ recvBps: number;
778
+ lossPct: number;
779
+ jitterMs: number;
780
+ };
781
+ private die;
782
+ }
783
+
784
+ interface ReassembledFrame {
785
+ seq: number;
786
+ groupId: number;
787
+ keyframe: boolean;
788
+ data: Uint8Array;
789
+ }
790
+ interface ReassemblerCallbacks {
791
+
792
+ onFrame(frame: ReassembledFrame): void;
793
+
794
+ onKeyframeNeeded(): void;
795
+ }
796
+ interface ReassemblerOptions {
797
+
798
+ now?: () => number;
799
+
800
+ keyframeRequestDebounceMs?: number;
801
+ }
802
+ declare class FrameReassembler {
803
+ private cb;
804
+ private pending;
805
+ private newestGroupSeen;
806
+ private newestFrameDelivered;
807
+ private needKeyframe;
808
+ private kfRequestedAt;
809
+ private now;
810
+ private debounceMs;
811
+ private bytesInWindow;
812
+ private framesDelivered;
813
+ private framesAbandoned;
814
+ constructor(cb: ReassemblerCallbacks, opts?: ReassemblerOptions);
815
+
816
+ push(chunk: Uint8Array): void;
817
+
818
+ drainWindow(): {
819
+ bytes: number;
820
+ delivered: number;
821
+ abandoned: number;
822
+ };
823
+ private deliver;
824
+ private requestKeyframe;
825
+ }
826
+
827
+ export { ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ConsumingTransport, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DGRAM_HEADER_BYTES, type DgramHeader, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, type MediaSession, type NegotiatorOptions, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, type SignalCarrier, type Signaling, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type TransportEstablishedNotify, TransportNegotiator, type TransportOfferRequest, type TransportOfferResponse, TransportSessionSignaling, TransportState, type VideoStreamOptions, WT_CONTROL_FRAME_MAX, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtControlDecoder, type WtControlMessage, createActivityTracker, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, encodeWtControlFrame, isDurationString, isWakingPhase, normalizeRetention, observePageLifecycle, parseDgramHeader, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive, writeDgramHeader };
@@ -1,5 +1,5 @@
1
- import { b as AppOptions, a as App$1, K as SessionPhase, T as SessionStatus, O as SessionPhaseName, A as AccessTokenOptions$1, y as RuntimeArtifact, z as RuntimeArtifactDownload, R as Recording, G as Session$1, C as ChannelEndpoint, _ as TransportSession, c as AttachOptions, v as RecordingsAccessor, B as RuntimeArtifactsAccessor, U as SessionStream$1, Z as StreamDataTransport, I as SessionDocumentImpl, Y as StreamChunkOptions, g as ChunkReadable, P as Presence, k as DocConnector, w as RequestOptions, x as RequestStreamOptions, X as StoreOptions, W as Store, e as ChannelMultiplexer, J as SessionFailureKind } from './stream-data-b249LZR2.js';
2
- export { L as Layer, l as LayoutConfig, m as LayoutContext, M as MediaChunkBinding, o as MediaChunkSource, p as MediaChunkSourceFactory, q as MediaRecorderChunkSourceOptions, r as PresenceState, s as RecordingBucket, t as RecordingLifecycle, u as RecordingStatus, E as RuntimeAvailability, S as SceneContext, F as SceneGraph, H as SessionDocument, N as SessionPhaseError, V as SessionText, a0 as TransportState, a4 as isPendingRecording, a5 as mediaRecorderChunkSource } from './stream-data-b249LZR2.js';
1
+ import { b as AppOptions, a as App$1, N as SessionPhase, U as SessionStatus, Q as SessionPhaseName, A as AccessTokenOptions$1, y as RuntimeArtifact, z as RuntimeArtifactDownload, R as Recording, G as Session$1, C as ChannelEndpoint, $ as TransportSession, c as AttachOptions, v as RecordingsAccessor, B as RuntimeArtifactsAccessor, J as SessionEndResult, V as SessionStream$1, _ as StreamDataTransport, I as SessionDocumentImpl, Z as StreamChunkOptions, g as ChunkReadable, P as Presence, k as DocConnector, w as RequestOptions, x as RequestStreamOptions, Y as StoreOptions, X as Store, e as ChannelMultiplexer, K as SessionFailureKind, a1 as TransportState } from './stream-data-rqyqR75F.js';
2
+ export { L as Layer, l as LayoutConfig, m as LayoutContext, M as MediaChunkBinding, o as MediaChunkSource, p as MediaChunkSourceFactory, q as MediaRecorderChunkSourceOptions, r as PresenceState, s as RecordingBucket, t as RecordingLifecycle, u as RecordingStatus, E as RuntimeAvailability, S as SceneContext, F as SceneGraph, H as SessionDocument, O as SessionPhaseError, W as SessionText, a5 as isPendingRecording, a6 as mediaRecorderChunkSource } from './stream-data-rqyqR75F.js';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
5
5
 
@@ -247,6 +247,8 @@ declare class Session implements Session$1 {
247
247
 
248
248
  private _docConnector;
249
249
 
250
+ private _docEndpointKey;
251
+
250
252
  private _streamData;
251
253
 
252
254
  private _presence;
@@ -254,6 +256,8 @@ declare class Session implements Session$1 {
254
256
  private _activity;
255
257
 
256
258
  private _activeRequests;
259
+ private _endHandler?;
260
+ private _endPromise?;
257
261
 
258
262
  private _recordingsAuth?;
259
263
 
@@ -287,6 +291,8 @@ declare class Session implements Session$1 {
287
291
  setArtifactsAuth(auth: RuntimeArtifactsClientOptions): void;
288
292
  private _requireArtifactsAuth;
289
293
  setSessionId(sessionId: string): void;
294
+
295
+ setEndHandler(handler: () => Promise<SessionEndResult>): void;
290
296
  stream(name: string): SessionStream;
291
297
 
292
298
  doc(key: string): SessionDocumentImpl;
@@ -320,6 +326,7 @@ declare class Session implements Session$1 {
320
326
  recover(): void;
321
327
 
322
328
  onRecovery(hook: () => void): () => void;
329
+ end(): Promise<SessionEndResult>;
323
330
  disconnect(): void;
324
331
  }
325
332
 
@@ -341,6 +348,25 @@ interface VideoStreamOptions {
341
348
 
342
349
  declare function videoStream(source: ReadableStream<Uint8Array>, options?: VideoStreamOptions): MediaStream;
343
350
 
351
+ declare class SessionEndUnavailableError extends Error {
352
+ readonly code = "session_end_unavailable";
353
+ constructor(message?: string, options?: {
354
+ cause?: unknown;
355
+ });
356
+ }
357
+
358
+ declare class SessionEndError extends Error {
359
+ readonly code: string;
360
+ readonly httpStatus?: number;
361
+ readonly requestId: string;
362
+ constructor(message: string, options: {
363
+ requestId: string;
364
+ code?: string;
365
+ httpStatus?: number;
366
+ cause?: unknown;
367
+ });
368
+ }
369
+
344
370
  declare class RequestError extends Error {
345
371
 
346
372
  readonly requestId?: string;
@@ -548,4 +574,254 @@ interface InputPresencePublisher {
548
574
 
549
575
  declare function createInputPresencePublisher(options: InputPresencePublisherOptions): InputPresencePublisher;
550
576
 
551
- export { ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, FOREGROUND_COALESCE_MS, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type VideoStreamOptions, type WhenLiveOptions, createActivityTracker, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, isDurationString, isWakingPhase, normalizeRetention, observePageLifecycle, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive };
577
+ interface MediaSession {
578
+ readonly kind: 'webtransport' | 'webrtc';
579
+ start(): Promise<void>;
580
+ stop(): Promise<void>;
581
+
582
+ onDead(cb: (reason: string) => void): void;
583
+
584
+ stats(): {
585
+ recvBps: number;
586
+ lossPct: number;
587
+ jitterMs: number;
588
+ };
589
+ }
590
+
591
+ interface Signaling {
592
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
593
+ notify(method: string, params?: unknown): void;
594
+
595
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
596
+ }
597
+
598
+ interface SignalCarrier {
599
+
600
+ sendSignal(msg: Record<string, unknown>): void;
601
+
602
+ onSignal(handler: (msg: Record<string, unknown>) => void): () => void;
603
+ }
604
+ declare class TransportSessionSignaling implements Signaling {
605
+ private carrier;
606
+ private requestTimeoutMs;
607
+ constructor(carrier: SignalCarrier, requestTimeoutMs?: number);
608
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
609
+ notify(method: string, params?: unknown): void;
610
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
611
+ }
612
+
613
+ interface TransportOfferRequest {
614
+ sessionId: string;
615
+ capabilities: {
616
+
617
+ webtransport: boolean;
618
+
619
+ webcodecs: boolean;
620
+
621
+ codecs: string[];
622
+ };
623
+ }
624
+ interface TransportOfferResponse {
625
+
626
+ webrtc: {
627
+ routerRtpCapabilities: unknown;
628
+ };
629
+
630
+ webtransport?: {
631
+ url: string;
632
+
633
+ certHashes: string[];
634
+
635
+ token: string;
636
+ codec: string;
637
+ };
638
+ }
639
+ interface TransportEstablishedNotify {
640
+ sessionId: string;
641
+ transport: 'webtransport' | 'webrtc';
642
+
643
+ fallbackReason?: string;
644
+ }
645
+ type WtControlMessage = {
646
+ t: 'hello';
647
+ token: string;
648
+ sessionId: string;
649
+ } | {
650
+ t: 'hello-ack';
651
+ codec: string;
652
+ width: number;
653
+ height: number;
654
+ } | {
655
+ t: 'ping';
656
+ ts: number;
657
+ } | {
658
+ t: 'pong';
659
+ ts: number;
660
+ } | {
661
+ t: 'keyframe-request';
662
+ } | {
663
+ t: 'feedback';
664
+ recvBps: number;
665
+ lossPct: number;
666
+ jitterMs: number;
667
+ };
668
+
669
+ declare const WT_CONTROL_FRAME_MAX: number;
670
+
671
+ declare function encodeWtControlFrame(msg: WtControlMessage): Uint8Array;
672
+
673
+ declare class WtControlDecoder {
674
+ private buf;
675
+ push(bytes: Uint8Array): WtControlMessage[];
676
+ }
677
+ declare const DGRAM_HEADER_BYTES = 12;
678
+ interface DgramHeader {
679
+ groupId: number;
680
+ frameSeq: number;
681
+ keyframe: boolean;
682
+ fragIndex: number;
683
+ fragCount: number;
684
+ }
685
+
686
+ declare function parseDgramHeader(view: DataView): DgramHeader;
687
+
688
+ declare function writeDgramHeader(h: DgramHeader): Uint8Array;
689
+
690
+ interface NegotiatorOptions {
691
+
692
+ quicDeadlineMs?: number;
693
+
694
+ allowWebTransport?: boolean;
695
+ onTransportChange?: (kind: MediaSession['kind'], reason?: string) => void;
696
+
697
+ canvas?: HTMLCanvasElement;
698
+
699
+ createWebRtcSession: () => MediaSession;
700
+ createWebTransportSession?: (offer: NonNullable<TransportOfferResponse['webtransport']>) => MediaSession;
701
+ }
702
+ declare class TransportNegotiator {
703
+ private signaling;
704
+ private sessionId;
705
+ private opts;
706
+ private session;
707
+ private offer;
708
+ constructor(signaling: Signaling, sessionId: string, opts: NegotiatorOptions);
709
+ get activeTransport(): MediaSession['kind'] | null;
710
+ connect(): Promise<MediaSession>;
711
+ disconnect(): Promise<void>;
712
+ private createWebTransportSession;
713
+ private startWebRtc;
714
+
715
+ private armFailover;
716
+ private notifyEstablished;
717
+ }
718
+
719
+ declare class WebTransportSession implements MediaSession {
720
+ private offer;
721
+ private sessionId;
722
+ private canvas;
723
+ readonly kind: "webtransport";
724
+ private wt;
725
+ private decoder;
726
+ private writer;
727
+ private deadCb;
728
+ private deadFired;
729
+ private stopped;
730
+ private feedbackTimer;
731
+ private reassembler;
732
+ private lastArrivalTs;
733
+ private jitterEwmaMs;
734
+ private lastStats;
735
+ private firstFrameResolve;
736
+ private firstFrameReject;
737
+ constructor(offer: NonNullable<TransportOfferResponse['webtransport']>, sessionId: string, canvas: HTMLCanvasElement);
738
+
739
+ start(): Promise<void>;
740
+ stop(): Promise<void>;
741
+ onDead(cb: (reason: string) => void): void;
742
+ stats(): {
743
+ recvBps: number;
744
+ lossPct: number;
745
+ jitterMs: number;
746
+ };
747
+ private initDecoder;
748
+ private datagramLoop;
749
+ private decodeFrame;
750
+ private sendControl;
751
+ private readControl;
752
+ private controlLoop;
753
+
754
+ private feedbackLoop;
755
+ private die;
756
+ }
757
+
758
+ interface ConsumingTransport {
759
+ getTrackByName(name: string): MediaStreamTrack | undefined;
760
+ on(event: 'track', handler: (track: MediaStreamTrack) => void): () => void;
761
+ on(event: 'stateChange', handler: (state: TransportState) => void): () => void;
762
+ }
763
+ declare class WebRtcSession implements MediaSession {
764
+ private transport;
765
+ private streamName;
766
+ readonly kind: "webrtc";
767
+ private deadCb;
768
+ private deadFired;
769
+ private unsubscribers;
770
+ constructor(transport: ConsumingTransport, streamName?: string);
771
+
772
+ start(): Promise<void>;
773
+
774
+ stop(): Promise<void>;
775
+ onDead(cb: (reason: string) => void): void;
776
+ stats(): {
777
+ recvBps: number;
778
+ lossPct: number;
779
+ jitterMs: number;
780
+ };
781
+ private die;
782
+ }
783
+
784
+ interface ReassembledFrame {
785
+ seq: number;
786
+ groupId: number;
787
+ keyframe: boolean;
788
+ data: Uint8Array;
789
+ }
790
+ interface ReassemblerCallbacks {
791
+
792
+ onFrame(frame: ReassembledFrame): void;
793
+
794
+ onKeyframeNeeded(): void;
795
+ }
796
+ interface ReassemblerOptions {
797
+
798
+ now?: () => number;
799
+
800
+ keyframeRequestDebounceMs?: number;
801
+ }
802
+ declare class FrameReassembler {
803
+ private cb;
804
+ private pending;
805
+ private newestGroupSeen;
806
+ private newestFrameDelivered;
807
+ private needKeyframe;
808
+ private kfRequestedAt;
809
+ private now;
810
+ private debounceMs;
811
+ private bytesInWindow;
812
+ private framesDelivered;
813
+ private framesAbandoned;
814
+ constructor(cb: ReassemblerCallbacks, opts?: ReassemblerOptions);
815
+
816
+ push(chunk: Uint8Array): void;
817
+
818
+ drainWindow(): {
819
+ bytes: number;
820
+ delivered: number;
821
+ abandoned: number;
822
+ };
823
+ private deliver;
824
+ private requestKeyframe;
825
+ }
826
+
827
+ export { ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ConsumingTransport, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DGRAM_HEADER_BYTES, type DgramHeader, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, type MediaSession, type NegotiatorOptions, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, type SignalCarrier, type Signaling, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type TransportEstablishedNotify, TransportNegotiator, type TransportOfferRequest, type TransportOfferResponse, TransportSessionSignaling, TransportState, type VideoStreamOptions, WT_CONTROL_FRAME_MAX, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtControlDecoder, type WtControlMessage, createActivityTracker, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, encodeWtControlFrame, isDurationString, isWakingPhase, normalizeRetention, observePageLifecycle, parseDgramHeader, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive, writeDgramHeader };