@urun-sh/core 0.2.4 → 0.2.6

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 +1 @@
1
- import{a as e,b as r,c as o,d as t,e as a,g as n,h as p,i as s,j as m,l as c,m as i,n as f,o as x}from"./chunk-QU4I4XC5.mjs";export{e as ChannelMultiplexer,r as DeferredChannelMultiplexer,f as DeferredDocConnector,n as LoopbackStreamData,m as TransportSession,x as createPresence,i as createWebsocketDocConnector,c as deriveYjsServerUrl,a as ensureNodeWebRTC,o as isNodeRuntime,t as nodeMediasoupHandlerName,s as streamDataLabel,p as transportStreamData};
1
+ import{a as e,b as r,c as o,d as t,e as a,g as n,h as p,i as s,j as m,l as c,m as i,n as f,o as x}from"./chunk-H23H4OCS.mjs";export{e as ChannelMultiplexer,r as DeferredChannelMultiplexer,f as DeferredDocConnector,n as LoopbackStreamData,m as TransportSession,x as createPresence,i as createWebsocketDocConnector,c as deriveYjsServerUrl,a as ensureNodeWebRTC,o as isNodeRuntime,t as nodeMediasoupHandlerName,s as streamDataLabel,p as transportStreamData};
@@ -95,6 +95,19 @@ type TransportState = 'connecting' | 'connected' | 'reconnecting' | 'renegotiati
95
95
 
96
96
  type SessionPhaseName = 'idle' | 'queued' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
97
97
 
98
+ type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended';
99
+
100
+ interface SessionPhaseError {
101
+
102
+ reason: string;
103
+
104
+ code?: string;
105
+
106
+ kind?: SessionFailureKind;
107
+
108
+ httpStatus?: number;
109
+ }
110
+
98
111
  interface SessionPhase {
99
112
 
100
113
  name: SessionPhaseName;
@@ -108,10 +121,29 @@ interface SessionPhase {
108
121
 
109
122
  sessionId?: string;
110
123
 
111
- error?: {
112
- reason: string;
113
- code?: string;
124
+ error?: SessionPhaseError;
125
+ }
126
+
127
+ interface SessionStatus {
128
+
129
+ phase: SessionPhaseName;
130
+
131
+ transportState: TransportState;
132
+
133
+ sessionId?: string;
134
+
135
+ requestId?: string;
136
+
137
+ lastServerStatus?: string;
138
+
139
+ elapsedMs?: number;
140
+
141
+ queue?: {
142
+ position: number;
143
+ depth: number;
114
144
  };
145
+
146
+ error?: SessionPhaseError;
115
147
  }
116
148
 
117
149
  interface TransportSessionOptions {
@@ -314,6 +346,8 @@ interface Session {
314
346
 
315
347
  readonly phase: SessionPhase;
316
348
 
349
+ readonly status: SessionStatus;
350
+
317
351
  stream(name: string): SessionStream;
318
352
 
319
353
  doc(key: string): SessionDocument;
@@ -570,6 +604,12 @@ declare class TransportSession {
570
604
  private _requestId;
571
605
  private _liveReached;
572
606
 
607
+ private _lastServerStatus;
608
+
609
+ private _forceResolveOnNextConnect;
610
+
611
+ private _connectStartedAt;
612
+
573
613
  private _mediaMonitorTimer;
574
614
 
575
615
  private _lastInboundTotal;
@@ -604,11 +644,15 @@ declare class TransportSession {
604
644
 
605
645
  private _pendingDataProduce;
606
646
 
647
+ private _sendTransportWaiters;
648
+
607
649
  get consumerId(): string;
608
650
  get state(): TransportState;
609
651
 
610
652
  get currentIncarnation(): number;
611
653
  get phase(): SessionPhase;
654
+
655
+ get status(): SessionStatus;
612
656
  get sessionId(): string | null;
613
657
  get tracks(): Map<string, MediaStreamTrack>;
614
658
  get multiplexer(): ChannelMultiplexer | null;
@@ -636,10 +680,16 @@ declare class TransportSession {
636
680
 
637
681
  sendStreamData(name: string, payload: unknown, _options?: {
638
682
  to?: string;
639
- }): void;
683
+ }): Promise<void>;
684
+
685
+ private _awaitSendTransport;
686
+
687
+ private _settleSendTransportWaiters;
640
688
 
641
689
  private _ensureDataProducer;
642
690
 
691
+ private _awaitDataChannelOpen;
692
+
643
693
  private _dispatchStreamData;
644
694
 
645
695
  private _streamNameFromLabel;
@@ -660,6 +710,8 @@ declare class TransportSession {
660
710
  private _flushStreamSubscribes;
661
711
  private _handleMessage;
662
712
 
713
+ private _onServerError;
714
+
663
715
  private _onStreamSeeked;
664
716
 
665
717
  private _onStatus;
@@ -713,6 +765,8 @@ declare class TransportSession {
713
765
  private _setPhase;
714
766
 
715
767
  private _emitError;
768
+
769
+ reportAllocationFailure(error: Error, httpStatus?: number): void;
716
770
  }
717
771
 
718
772
  interface StreamDataTransport {
@@ -723,7 +777,7 @@ interface StreamDataTransport {
723
777
 
724
778
  sendData(name: string, payload: unknown, options?: {
725
779
  to?: string;
726
- }): void;
780
+ }): Promise<void>;
727
781
  }
728
782
 
729
783
  declare class LoopbackStreamData implements StreamDataTransport {
@@ -733,7 +787,7 @@ declare class LoopbackStreamData implements StreamDataTransport {
733
787
  onData(name: string, handler: (payload: unknown) => void): () => void;
734
788
  sendData(name: string, payload: unknown, options?: {
735
789
  to?: string;
736
- }): void;
790
+ }): Promise<void>;
737
791
  }
738
792
 
739
793
  interface DataChannelTransport {
@@ -741,9 +795,9 @@ interface DataChannelTransport {
741
795
  onStreamData(name: string, handler: (payload: unknown) => void): () => void;
742
796
  sendStreamData(name: string, payload: unknown, options?: {
743
797
  to?: string;
744
- }): void;
798
+ }): Promise<void>;
745
799
  }
746
800
 
747
801
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
748
802
 
749
- export { mediaRecorderChunkSource as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionPhase as G, type SessionPhaseName as H, type SessionStartOptions as I, type SessionStream as J, type SessionText as K, type Layer as L, type MediaChunkBinding as M, type Store as N, type StoreOptions as O, type Presence as P, type StreamChunkOptions as Q, type Recording as R, type SceneContext as S, type StreamDataTransport as T, TransportSession as U, type TransportSessionOptions as V, type TransportState as W, createPresence as X, createWebsocketDocConnector as Y, deriveYjsServerUrl as Z, isPendingRecording as _, type App as a, streamDataLabel as a0, transportStreamData as a1, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
803
+ export { createWebsocketDocConnector as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionFailureKind as G, type SessionPhase as H, type SessionPhaseError as I, type SessionPhaseName as J, type SessionStartOptions as K, type Layer as L, type MediaChunkBinding as M, type SessionStatus as N, type SessionStream as O, type Presence as P, type SessionText as Q, type Recording as R, type SceneContext as S, type Store as T, type StoreOptions as U, type StreamChunkOptions as V, type StreamDataTransport as W, TransportSession as X, type TransportSessionOptions as Y, type TransportState as Z, createPresence as _, type App as a, deriveYjsServerUrl as a0, isPendingRecording as a1, mediaRecorderChunkSource as a2, streamDataLabel as a3, transportStreamData as a4, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
@@ -95,6 +95,19 @@ type TransportState = 'connecting' | 'connected' | 'reconnecting' | 'renegotiati
95
95
 
96
96
  type SessionPhaseName = 'idle' | 'queued' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
97
97
 
98
+ type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended';
99
+
100
+ interface SessionPhaseError {
101
+
102
+ reason: string;
103
+
104
+ code?: string;
105
+
106
+ kind?: SessionFailureKind;
107
+
108
+ httpStatus?: number;
109
+ }
110
+
98
111
  interface SessionPhase {
99
112
 
100
113
  name: SessionPhaseName;
@@ -108,10 +121,29 @@ interface SessionPhase {
108
121
 
109
122
  sessionId?: string;
110
123
 
111
- error?: {
112
- reason: string;
113
- code?: string;
124
+ error?: SessionPhaseError;
125
+ }
126
+
127
+ interface SessionStatus {
128
+
129
+ phase: SessionPhaseName;
130
+
131
+ transportState: TransportState;
132
+
133
+ sessionId?: string;
134
+
135
+ requestId?: string;
136
+
137
+ lastServerStatus?: string;
138
+
139
+ elapsedMs?: number;
140
+
141
+ queue?: {
142
+ position: number;
143
+ depth: number;
114
144
  };
145
+
146
+ error?: SessionPhaseError;
115
147
  }
116
148
 
117
149
  interface TransportSessionOptions {
@@ -314,6 +346,8 @@ interface Session {
314
346
 
315
347
  readonly phase: SessionPhase;
316
348
 
349
+ readonly status: SessionStatus;
350
+
317
351
  stream(name: string): SessionStream;
318
352
 
319
353
  doc(key: string): SessionDocument;
@@ -570,6 +604,12 @@ declare class TransportSession {
570
604
  private _requestId;
571
605
  private _liveReached;
572
606
 
607
+ private _lastServerStatus;
608
+
609
+ private _forceResolveOnNextConnect;
610
+
611
+ private _connectStartedAt;
612
+
573
613
  private _mediaMonitorTimer;
574
614
 
575
615
  private _lastInboundTotal;
@@ -604,11 +644,15 @@ declare class TransportSession {
604
644
 
605
645
  private _pendingDataProduce;
606
646
 
647
+ private _sendTransportWaiters;
648
+
607
649
  get consumerId(): string;
608
650
  get state(): TransportState;
609
651
 
610
652
  get currentIncarnation(): number;
611
653
  get phase(): SessionPhase;
654
+
655
+ get status(): SessionStatus;
612
656
  get sessionId(): string | null;
613
657
  get tracks(): Map<string, MediaStreamTrack>;
614
658
  get multiplexer(): ChannelMultiplexer | null;
@@ -636,10 +680,16 @@ declare class TransportSession {
636
680
 
637
681
  sendStreamData(name: string, payload: unknown, _options?: {
638
682
  to?: string;
639
- }): void;
683
+ }): Promise<void>;
684
+
685
+ private _awaitSendTransport;
686
+
687
+ private _settleSendTransportWaiters;
640
688
 
641
689
  private _ensureDataProducer;
642
690
 
691
+ private _awaitDataChannelOpen;
692
+
643
693
  private _dispatchStreamData;
644
694
 
645
695
  private _streamNameFromLabel;
@@ -660,6 +710,8 @@ declare class TransportSession {
660
710
  private _flushStreamSubscribes;
661
711
  private _handleMessage;
662
712
 
713
+ private _onServerError;
714
+
663
715
  private _onStreamSeeked;
664
716
 
665
717
  private _onStatus;
@@ -713,6 +765,8 @@ declare class TransportSession {
713
765
  private _setPhase;
714
766
 
715
767
  private _emitError;
768
+
769
+ reportAllocationFailure(error: Error, httpStatus?: number): void;
716
770
  }
717
771
 
718
772
  interface StreamDataTransport {
@@ -723,7 +777,7 @@ interface StreamDataTransport {
723
777
 
724
778
  sendData(name: string, payload: unknown, options?: {
725
779
  to?: string;
726
- }): void;
780
+ }): Promise<void>;
727
781
  }
728
782
 
729
783
  declare class LoopbackStreamData implements StreamDataTransport {
@@ -733,7 +787,7 @@ declare class LoopbackStreamData implements StreamDataTransport {
733
787
  onData(name: string, handler: (payload: unknown) => void): () => void;
734
788
  sendData(name: string, payload: unknown, options?: {
735
789
  to?: string;
736
- }): void;
790
+ }): Promise<void>;
737
791
  }
738
792
 
739
793
  interface DataChannelTransport {
@@ -741,9 +795,9 @@ interface DataChannelTransport {
741
795
  onStreamData(name: string, handler: (payload: unknown) => void): () => void;
742
796
  sendStreamData(name: string, payload: unknown, options?: {
743
797
  to?: string;
744
- }): void;
798
+ }): Promise<void>;
745
799
  }
746
800
 
747
801
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
748
802
 
749
- export { mediaRecorderChunkSource as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionPhase as G, type SessionPhaseName as H, type SessionStartOptions as I, type SessionStream as J, type SessionText as K, type Layer as L, type MediaChunkBinding as M, type Store as N, type StoreOptions as O, type Presence as P, type StreamChunkOptions as Q, type Recording as R, type SceneContext as S, type StreamDataTransport as T, TransportSession as U, type TransportSessionOptions as V, type TransportState as W, createPresence as X, createWebsocketDocConnector as Y, deriveYjsServerUrl as Z, isPendingRecording as _, type App as a, streamDataLabel as a0, transportStreamData as a1, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
803
+ export { createWebsocketDocConnector as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionFailureKind as G, type SessionPhase as H, type SessionPhaseError as I, type SessionPhaseName as J, type SessionStartOptions as K, type Layer as L, type MediaChunkBinding as M, type SessionStatus as N, type SessionStream as O, type Presence as P, type SessionText as Q, type Recording as R, type SceneContext as S, type Store as T, type StoreOptions as U, type StreamChunkOptions as V, type StreamDataTransport as W, TransportSession as X, type TransportSessionOptions as Y, type TransportState as Z, createPresence as _, type App as a, deriveYjsServerUrl as a0, isPendingRecording as a1, mediaRecorderChunkSource as a2, streamDataLabel as a3, transportStreamData as a4, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urun-sh/core",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Core transport and channel primitives for the urun TypeScript SDK",
5
5
  "repository": {
6
6
  "type": "git",