@urun-sh/core 0.2.60 → 0.3.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/internal.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __urunCreateRequire } from 'node:module'; const require = globalThis.require ?? __urunCreateRequire(import.meta.url);
2
- import{E as r,H as t,I as n,J as a,K as s,O as p,P as m,Q as c,U as i,V as l,W as S,X as f,Y as x,Z as C,_ as D,a as e,b as o}from"./chunk-MVSPHHJP.mjs";export{e as ChannelMultiplexer,l as DOC_SYNC_WIRE_CONTRACT_VERSION,o as DeferredChannelMultiplexer,x as DeferredDocConnector,p as LoopbackStreamData,C as SessionDocumentImpl,i as TransportSession,r as allocateSession,D as createPresence,f as createWebsocketDocConnector,S as deriveYjsServerUrl,s as ensureNodeWebRTC,t as isNodeRuntime,n as nodeMediasoupHandlerName,a as nodeWebRTCUnavailableReason,c as streamDataLabel,m as transportStreamData};
2
+ import{$ as C,F as r,I as t,J as n,K as a,L as s,P as p,Q as m,R as c,W as i,X as l,Y as S,Z as f,_ as x,a as e,aa as D,b as o}from"./chunk-WRCXYQH2.mjs";export{e as ChannelMultiplexer,l as DOC_SYNC_WIRE_CONTRACT_VERSION,o as DeferredChannelMultiplexer,x as DeferredDocConnector,p as LoopbackStreamData,C as SessionDocumentImpl,i as TransportSession,r as allocateSession,D as createPresence,f as createWebsocketDocConnector,S as deriveYjsServerUrl,s as ensureNodeWebRTC,t as isNodeRuntime,n as nodeMediasoupHandlerName,a as nodeWebRTCUnavailableReason,c as streamDataLabel,m as transportStreamData};
@@ -117,7 +117,7 @@ declare function createPresence(awareness: Awareness): Presence;
117
117
 
118
118
  type TransportState = 'connecting' | 'connected' | 'reconnecting' | 'renegotiating' | 'disconnected' | 'failed';
119
119
 
120
- type SessionPhaseName = 'idle' | 'queued' | 'unavailable' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended' | 'expired';
120
+ type SessionPhaseName = 'idle' | 'queued' | 'unavailable' | 'provisioning' | 'waiting_for_capacity' | 'connecting' | 'live' | 'error' | 'ended' | 'expired' | 'unknown';
121
121
 
122
122
  interface RuntimeAvailability {
123
123
  state: 'unavailable' | 'starting' | 'busy';
@@ -213,6 +213,8 @@ interface SessionPhase {
213
213
  endsAt?: Date;
214
214
 
215
215
  error?: SessionPhaseError;
216
+
217
+ reason?: string;
216
218
  }
217
219
 
218
220
  interface SessionStatus {
@@ -600,6 +602,8 @@ interface AppOptions {
600
602
 
601
603
  allowWebTransport?: boolean;
602
604
 
605
+ allowWebRtcFallback?: boolean;
606
+
603
607
  releaseOnLeave?: boolean;
604
608
 
605
609
  sessionKey?: string;
@@ -660,6 +664,9 @@ interface SessionGatewayResponse {
660
664
  ends_at?: string;
661
665
  error_code?: string;
662
666
  error_message?: string;
667
+
668
+ message?: string;
669
+ error?: string;
663
670
  }
664
671
 
665
672
  interface AdmissionUpdate {
@@ -779,6 +786,329 @@ declare class DeferredChannelMultiplexer implements ChannelEndpoint {
779
786
  private detachTarget;
780
787
  }
781
788
 
789
+ type WtMicSource = MediaStreamTrack | AudioNode;
790
+
791
+ interface WtMicUplinkHandle {
792
+ setSource(source: WtMicSource | null): void;
793
+ }
794
+
795
+ interface WtAudioUplinkSeam {
796
+ onUplink(handle: WtMicUplinkHandle): void;
797
+ onUplinkLost(reason: string): void;
798
+ }
799
+
800
+ interface WtCamUplinkHandle {
801
+ setSource(track: MediaStreamTrack | null): void;
802
+
803
+ requestKeyframe(): void;
804
+ }
805
+
806
+ interface WtVideoUplinkSeam {
807
+ onUplink(handle: WtCamUplinkHandle): void;
808
+ onUplinkLost(reason: string): void;
809
+ }
810
+
811
+ declare const WT_DATA_STREAM_VERSION = 1;
812
+
813
+ interface WtDataEnvelope {
814
+ name: string;
815
+ payload: unknown;
816
+ }
817
+
818
+ interface WtDataLaneSink {
819
+ onData(name: string, payload: unknown): void;
820
+ onLaneError(err: Error): void;
821
+ }
822
+
823
+ interface QuicStreamDataTransport {
824
+
825
+ markStreamDataLaneQuic(): void;
826
+
827
+ dispatchQuicStreamData(name: string, payload: unknown): void;
828
+
829
+ quicStreamDataLaneLost(reason: string): void;
830
+
831
+ raiseQuicStreamDataError(err: Error): void;
832
+ }
833
+
834
+ declare class WtDataStreamParser {
835
+ private buf;
836
+ private name;
837
+ private ended;
838
+
839
+ get streamName(): string | null;
840
+ push(chunk: Uint8Array): WtDataEnvelope[];
841
+
842
+ finish(): void;
843
+ }
844
+
845
+ interface WtByteReader {
846
+ read(): Promise<{
847
+ value?: Uint8Array;
848
+ done: boolean;
849
+ }>;
850
+ cancel?(reason?: unknown): Promise<void>;
851
+ }
852
+ interface WtIncomingUniStream {
853
+ getReader(): WtByteReader;
854
+ }
855
+ interface WtIncomingUniStreams {
856
+ getReader(): {
857
+ read(): Promise<{
858
+ value?: WtIncomingUniStream;
859
+ done: boolean;
860
+ }>;
861
+ };
862
+ }
863
+
864
+ declare function consumeWtDataStreams(incoming: WtIncomingUniStreams, sink: WtDataLaneSink): Promise<void>;
865
+
866
+ interface MediaSession {
867
+ readonly kind: 'webtransport' | 'webrtc';
868
+ start(): Promise<void>;
869
+ stop(): Promise<void>;
870
+
871
+ onDead(cb: (reason: string) => void): void;
872
+
873
+ stats(): {
874
+ recvBps: number;
875
+ lossPct: number;
876
+ jitterMs: number;
877
+ };
878
+
879
+ readonly firstMedia: Promise<void>;
880
+
881
+ consumeDataStreams?(sink: WtDataLaneSink): void;
882
+ }
883
+
884
+ interface Signaling {
885
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
886
+ notify(method: string, params?: unknown): void;
887
+
888
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
889
+ }
890
+
891
+ interface SignalCarrier {
892
+
893
+ sendSignal(msg: Record<string, unknown>): void;
894
+
895
+ onSignal(handler: (msg: Record<string, unknown>) => void): () => void;
896
+ }
897
+ declare class TransportSessionSignaling implements Signaling {
898
+ private carrier;
899
+ private requestTimeoutMs;
900
+ constructor(carrier: SignalCarrier, requestTimeoutMs?: number);
901
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
902
+ notify(method: string, params?: unknown): void;
903
+ on(method: string, handler: (params: Record<string, unknown>) => void): () => void;
904
+ }
905
+
906
+ interface TransportOfferRequest {
907
+ sessionId: string;
908
+ capabilities: {
909
+
910
+ webtransport: boolean;
911
+
912
+ webcodecs: boolean;
913
+
914
+ codecs: string[];
915
+
916
+ wtData?: boolean;
917
+
918
+ wtAudio?: boolean;
919
+
920
+ wtAudioUp?: boolean;
921
+
922
+ wtVideoUp?: boolean;
923
+
924
+ wtDataUp?: boolean;
925
+ };
926
+ }
927
+ interface TransportOfferResponse {
928
+
929
+ webrtc: {
930
+ routerRtpCapabilities: unknown;
931
+ };
932
+
933
+ webtransport?: {
934
+ url: string;
935
+
936
+ certHashes: string[];
937
+
938
+ token: string;
939
+
940
+ codec?: string;
941
+
942
+ data?: boolean;
943
+
944
+ audio?: {
945
+ codec: string;
946
+ sampleRate: number;
947
+ channels: number;
948
+ };
949
+
950
+ audioUp?: boolean;
951
+
952
+ videoUp?: boolean;
953
+
954
+ dataUp?: boolean;
955
+ };
956
+ }
957
+ interface TransportEstablishedNotify {
958
+ sessionId: string;
959
+ transport: 'webtransport' | 'webrtc';
960
+
961
+ fallbackReason?: string;
962
+ }
963
+ type WtControlMessage = {
964
+ t: 'hello';
965
+ token: string;
966
+ sessionId: string;
967
+ } | {
968
+ t: 'hello-ack';
969
+ codec: string;
970
+ width: number;
971
+ height: number;
972
+ } | {
973
+ t: 'ping';
974
+ ts: number;
975
+ } | {
976
+ t: 'pong';
977
+ ts: number;
978
+ } | {
979
+ t: 'keyframe-request';
980
+ } | {
981
+ t: 'feedback';
982
+ recvBps: number;
983
+ lossPct: number;
984
+ jitterMs: number;
985
+ };
986
+
987
+ declare const WT_CONTROL_FRAME_MAX: number;
988
+
989
+ declare function encodeWtControlFrame(msg: WtControlMessage): Uint8Array;
990
+
991
+ declare class WtControlDecoder {
992
+ private buf;
993
+ push(bytes: Uint8Array): WtControlMessage[];
994
+ }
995
+ declare const DGRAM_HEADER_BYTES = 12;
996
+ interface DgramHeader {
997
+ groupId: number;
998
+ frameSeq: number;
999
+ keyframe: boolean;
1000
+ fragIndex: number;
1001
+ fragCount: number;
1002
+
1003
+ lane: number;
1004
+ }
1005
+
1006
+ declare function parseDgramHeader(view: DataView): DgramHeader;
1007
+
1008
+ declare function writeDgramHeader(h: Omit<DgramHeader, 'lane'> & {
1009
+ lane?: number;
1010
+ }): Uint8Array;
1011
+
1012
+ interface WtAudioLaneSeam {
1013
+
1014
+ jitterBufferTargetMs?: number;
1015
+
1016
+ onTrack: (track: MediaStreamTrack | null) => void;
1017
+ }
1018
+
1019
+ interface WtDataUplinkTransport {
1020
+ openUniStream(): Promise<{
1021
+ write(chunk: Uint8Array): Promise<void>;
1022
+ close(): Promise<void>;
1023
+ }>;
1024
+ }
1025
+
1026
+ declare class WtDataUplinkSender {
1027
+ private transport;
1028
+ private streams;
1029
+ private dead;
1030
+ private deadCb;
1031
+
1032
+ private chain;
1033
+ constructor(transport: WtDataUplinkTransport);
1034
+ onDead(cb: (reason: string) => void): void;
1035
+
1036
+ send(name: string, envelope: Uint8Array): Promise<void>;
1037
+ stop(reason?: string): void;
1038
+ private die;
1039
+ }
1040
+
1041
+ interface WtDataUplinkSeam {
1042
+ onUplink(sender: WtDataUplinkSender): void;
1043
+ onUplinkLost(reason: string): void;
1044
+ }
1045
+
1046
+ interface NegotiatorDataLaneSeam {
1047
+
1048
+ onData(name: string, payload: unknown): void;
1049
+
1050
+ onQuicLane(): void;
1051
+
1052
+ onQuicLaneLost(reason: string): void;
1053
+
1054
+ onLaneError(err: Error): void;
1055
+ }
1056
+ interface NegotiatorOptions {
1057
+
1058
+ quicDeadlineMs?: number;
1059
+
1060
+ allowWebTransport?: boolean;
1061
+ onTransportChange?: (kind: MediaSession['kind'], reason?: string) => void;
1062
+
1063
+ canvas?: HTMLCanvasElement;
1064
+
1065
+ createWebRtcSession: () => MediaSession;
1066
+ createWebTransportSession?: (offer: NonNullable<TransportOfferResponse['webtransport']>) => MediaSession;
1067
+
1068
+ dataLane?: NegotiatorDataLaneSeam;
1069
+
1070
+ audioLane?: WtAudioLaneSeam;
1071
+
1072
+ audioUplink?: WtAudioUplinkSeam;
1073
+
1074
+ videoUplink?: WtVideoUplinkSeam;
1075
+
1076
+ dataUplink?: WtDataUplinkSeam;
1077
+
1078
+ webRtcDial?: {
1079
+ proceed(reason: string): void;
1080
+ skip(reason: string): void;
1081
+ };
1082
+
1083
+ allowWebRtcFallback?: boolean;
1084
+
1085
+ onWtRequiredOutage?: (reason: string) => void;
1086
+ }
1087
+ declare class TransportNegotiator {
1088
+ private signaling;
1089
+ private sessionId;
1090
+ private opts;
1091
+ private session;
1092
+ private offer;
1093
+
1094
+ private quicDataLane;
1095
+
1096
+ private wtOnlyLeg;
1097
+ constructor(signaling: Signaling, sessionId: string, opts: NegotiatorOptions);
1098
+ get activeTransport(): MediaSession['kind'] | null;
1099
+ connect(): Promise<MediaSession>;
1100
+ disconnect(): Promise<void>;
1101
+
1102
+ retryWebTransport(): Promise<MediaSession | null>;
1103
+
1104
+ private engageQuicDataLane;
1105
+ private createWebTransportSession;
1106
+ private startWebRtc;
1107
+
1108
+ private armFailover;
1109
+ private notifyEstablished;
1110
+ }
1111
+
782
1112
  interface TransportConnection {
783
1113
  url: string;
784
1114
  sessionId: string;
@@ -817,6 +1147,8 @@ interface TransportEvents {
817
1147
 
818
1148
  signal: (msg: Record<string, unknown>) => void;
819
1149
  }
1150
+
1151
+ declare const SIGNALING_PROTOCOL_VERSION = "v1";
820
1152
  interface SessionStartOptions {
821
1153
  app?: string;
822
1154
  functionName?: string;
@@ -853,6 +1185,9 @@ declare class TransportSession {
853
1185
  private _videoProducer;
854
1186
  private _publishedAudio;
855
1187
  private _publishedVideo;
1188
+ private _wtMicUplink;
1189
+ private _wtCamUplink;
1190
+ private _wtDataUpSender;
856
1191
  private _pendingProduce;
857
1192
  private _multiplexer;
858
1193
  private _reconnectAttempts;
@@ -973,6 +1308,8 @@ declare class TransportSession {
973
1308
  to?: string;
974
1309
  }): Promise<void>;
975
1310
 
1311
+ get wtDataUplinkSeam(): WtDataUplinkSeam;
1312
+
976
1313
  private _awaitSendTransport;
977
1314
 
978
1315
  private _settleSendTransportWaiters;
@@ -1016,6 +1353,15 @@ declare class TransportSession {
1016
1353
  private _onStreamSeeked;
1017
1354
 
1018
1355
  private _onStatus;
1356
+
1357
+ private _webRtcDialHeld;
1358
+
1359
+ private _heldRouterCaps;
1360
+
1361
+ holdWebRtcDial(): {
1362
+ proceed: (reason: string) => void;
1363
+ skip: (reason: string) => void;
1364
+ };
1019
1365
  private _onRouterCapabilities;
1020
1366
  private _onCreateRecvTransport;
1021
1367
 
@@ -1039,6 +1385,14 @@ declare class TransportSession {
1039
1385
  private _onConsumeData;
1040
1386
  private _onConsume;
1041
1387
 
1388
+
1389
+ get audioPlayoutOptions(): {
1390
+ jitterBufferTargetMs?: number;
1391
+ } | undefined;
1392
+
1393
+ get wtMicUplinkSeam(): WtAudioUplinkSeam;
1394
+
1395
+ get wtCamUplinkSeam(): WtVideoUplinkSeam;
1042
1396
  private _jitterBufferTargetMs;
1043
1397
 
1044
1398
  private _capJitterBuffer;
@@ -1187,4 +1541,4 @@ interface DataChannelTransport {
1187
1541
 
1188
1542
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
1189
1543
 
1190
- export { SessionDocumentImpl as $, type AccessTokenOptions$1 as A, type PrewakeResult as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type PrewakeStatus as E, type RecordingBucket as F, type RecordingLifecycle as G, type RecordingStatus as H, type InboundStatsSample as I, type RecordingsAccessor as J, type ReleaseSessionBeaconOptions as K, LoopbackStreamData as L, type MediaChunkBinding as M, type RequestOptions as N, type RequestStreamOptions as O, type Presence as P, type RuntimeArtifact as Q, type Recording as R, type RuntimeArtifactDownload as S, type RuntimeArtifactsAccessor as T, type RuntimeAvailability as U, type RuntimeWakeDetail as V, type RuntimeWakeGolden as W, type RuntimeWakeReasonCode as X, type Session as Y, type SessionDiagnostic as Z, type SessionDocument as _, type AccessTokenOptions as a, type SessionEndResult as a0, type SessionFailureKind as a1, type SessionPhase as a2, type SessionPhaseError as a3, type SessionPhaseName as a4, type SessionStartOptions as a5, type SessionStatsOptions as a6, type SessionStatsSample as a7, type SessionStatus as a8, type SessionStream as a9, type SessionText as aa, type Store as ab, type StoreOptions as ac, type StreamChunkOptions as ad, type StreamDataTransport as ae, TransportSession as af, type TransportSessionOptions as ag, type TransportState as ah, type VideoPlayoutOptions as ai, allocateSession as aj, createPresence as ak, createWebsocketDocConnector as al, deriveYjsServerUrl as am, derivedLegName as an, derivedLegRole as ao, isPendingRecording as ap, mediaRecorderChunkSource as aq, prewake as ar, releaseSessionBeacon as as, streamDataLabel as at, transportStreamData as au, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type AudioPlayoutOptions as i, type ChannelMessage as j, ChannelMultiplexer as k, type ChannelName as l, type ChunkReadable as m, DOC_SYNC_WIRE_CONTRACT_VERSION as n, DeferredChannelMultiplexer as o, DeferredDocConnector as p, type DerivedLegRole as q, type DocConnection as r, type DocConnectionState as s, type DocConnector as t, type DocTokenSupplier as u, type MediaChunkSource as v, type MediaChunkSourceFactory as w, type MediaRecorderChunkSourceOptions as x, type PresenceState as y, type PrewakeOptions as z };
1544
+ export { type RuntimeWakeDetail as $, type AccessTokenOptions$1 as A, type MediaSession as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type NegotiatorOptions as E, type PresenceState as F, type PrewakeOptions as G, type PrewakeResult as H, type InboundStatsSample as I, type PrewakeStatus as J, type RecordingBucket as K, LoopbackStreamData as L, type MediaChunkBinding as M, type NegotiatorDataLaneSeam as N, type RecordingLifecycle as O, type Presence as P, type QuicStreamDataTransport as Q, type Recording as R, type RecordingStatus as S, type RecordingsAccessor as T, type ReleaseSessionBeaconOptions as U, type RequestOptions as V, type RequestStreamOptions as W, type RuntimeArtifact as X, type RuntimeArtifactDownload as Y, type RuntimeArtifactsAccessor as Z, type RuntimeAvailability as _, type AccessTokenOptions as a, type RuntimeWakeGolden as a0, type RuntimeWakeReasonCode as a1, SIGNALING_PROTOCOL_VERSION as a2, type Session as a3, type SessionDiagnostic as a4, type SessionDocument as a5, SessionDocumentImpl as a6, type SessionEndResult as a7, type SessionFailureKind as a8, type SessionPhase as a9, type WtAudioUplinkSeam as aA, WtControlDecoder as aB, type WtControlMessage as aC, type WtDataEnvelope as aD, type WtDataLaneSink as aE, WtDataStreamParser as aF, WtDataUplinkSender as aG, type WtVideoUplinkSeam as aH, allocateSession as aI, consumeWtDataStreams as aJ, createPresence as aK, createWebsocketDocConnector as aL, deriveYjsServerUrl as aM, derivedLegName as aN, derivedLegRole as aO, encodeWtControlFrame as aP, isPendingRecording as aQ, mediaRecorderChunkSource as aR, parseDgramHeader as aS, prewake as aT, releaseSessionBeacon as aU, streamDataLabel as aV, transportStreamData as aW, writeDgramHeader as aX, type SessionPhaseError as aa, type SessionPhaseName as ab, type SessionStartOptions as ac, type SessionStatsOptions as ad, type SessionStatsSample as ae, type SessionStatus as af, type SessionStream as ag, type SessionText as ah, type SignalCarrier as ai, type Signaling as aj, type Store as ak, type StoreOptions as al, type StreamChunkOptions as am, type StreamDataTransport as an, type TransportEstablishedNotify as ao, TransportNegotiator as ap, type TransportOfferRequest as aq, type TransportOfferResponse as ar, TransportSession as as, type TransportSessionOptions as at, TransportSessionSignaling as au, type TransportState as av, type VideoPlayoutOptions as aw, WT_CONTROL_FRAME_MAX as ax, WT_DATA_STREAM_VERSION as ay, type WtAudioLaneSeam as az, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type AudioPlayoutOptions as i, type ChannelMessage as j, ChannelMultiplexer as k, type ChannelName as l, type ChunkReadable as m, DGRAM_HEADER_BYTES as n, DOC_SYNC_WIRE_CONTRACT_VERSION as o, DeferredChannelMultiplexer as p, DeferredDocConnector as q, type DerivedLegRole as r, type DgramHeader as s, type DocConnection as t, type DocConnectionState as u, type DocConnector as v, type DocTokenSupplier as w, type MediaChunkSource as x, type MediaChunkSourceFactory as y, type MediaRecorderChunkSourceOptions as z };