@reactor-team/js-sdk 2.11.2 → 2.12.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.mts CHANGED
@@ -136,6 +136,16 @@ interface ReactorState$1 {
136
136
  interface ConnectOptions {
137
137
  /** Maximum number of SDP polling attempts before giving up. Default: 6. */
138
138
  maxAttempts?: number;
139
+ /**
140
+ * When true (default), sends `resume_track` for every recvonly track
141
+ * immediately after the connection is established, causing the backend to
142
+ * begin streaming those tracks — this preserves the pre-multi-connection
143
+ * behaviour where output tracks flow automatically on connect. Set to false
144
+ * to keep recvonly tracks paused on connect and resume them individually via
145
+ * `resumeTrack()` (e.g. multi-connection apps that only subscribe to a
146
+ * subset of peers).
147
+ */
148
+ autoResumeTracks?: boolean;
139
149
  /**
140
150
  * Attach to a session that already exists (e.g. one created by a backend)
141
151
  * instead of creating a new one. When set, `connect()` skips `POST /sessions`
@@ -143,6 +153,18 @@ interface ConnectOptions {
143
153
  * `connect()` must be valid for the account that owns the session.
144
154
  */
145
155
  sessionId?: string;
156
+ /**
157
+ * Use a specific WebRTC connection id instead of minting one. When omitted
158
+ * (default), the transport registers a fresh connection (`POST .../connections`)
159
+ * and the server mints the id. When set, the transport skips registration and
160
+ * sends its SDP offer directly to that connection — so the id must already have
161
+ * been registered under this session (e.g. a backend called `POST .../connections`
162
+ * and handed the id to this client) and must still be open.
163
+ *
164
+ * `connect()` rejects if the id is invalid (out of the server's accepted range)
165
+ * or if no open connection with that id exists for the session.
166
+ */
167
+ connectionId?: number;
146
168
  }
147
169
  /**
148
170
  * Transport-agnostic timing breakdown of the connect() handshake, recorded
@@ -641,11 +663,21 @@ declare class Reactor {
641
663
  private sessionExpiration?;
642
664
  private local;
643
665
  private sessionId?;
666
+ /**
667
+ * True only when the active session was created by THIS connect flow
668
+ * (via `createSession()`). False when the session was adopted via
669
+ * `connect({ sessionId })`. We must never DELETE a session we did not
670
+ * create — another client (or the backend that created it) owns its
671
+ * lifecycle, so on disconnect/teardown/error an adopting client tears
672
+ * down its own transport but leaves the session alive.
673
+ */
674
+ private createdSession;
644
675
  private connectStartTime?;
645
676
  private connectionTimings?;
646
677
  private capabilities?;
647
678
  private tracks;
648
679
  private presetTracks?;
680
+ private autoResumeTracks;
649
681
  private sessionResponse?;
650
682
  private jwtResolver?;
651
683
  /** Per-Reactor recording client. See {@link RecordingClient}. */
@@ -717,6 +749,8 @@ declare class Reactor {
717
749
  */
718
750
  publishTrack(name: string, track: MediaStreamTrack): Promise<void>;
719
751
  unpublishTrack(name: string): Promise<void>;
752
+ pauseTrack(name: string): void;
753
+ resumeTrack(name: string): void;
720
754
  /**
721
755
  * Reconnects to an existing session with a fresh transport.
722
756
  */
@@ -773,6 +807,13 @@ interface ReactorState {
773
807
  sessionExpiration?: number;
774
808
  /** Token source for Coordinator HTTP calls — see {@link JwtSource}. */
775
809
  jwtToken?: JwtSource;
810
+ /**
811
+ * Default connect options set by the provider. Applied as base values
812
+ * whenever `connect()` is called without explicit options, so that
813
+ * provider-level settings like `autoResumeTracks` are honoured for
814
+ * both autoConnect and manual connect calls.
815
+ */
816
+ connectOptions?: ConnectOptions;
776
817
  }
777
818
  interface ReactorActions {
778
819
  sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
@@ -820,6 +861,8 @@ type ReactorStore = ReactorState & ReactorActions & {
820
861
  interface ReactorInitializationProps extends Options {
821
862
  /** Token source for the underlying {@link Reactor} — see {@link JwtSource}. */
822
863
  jwtToken?: JwtSource;
864
+ /** Default connect options applied when `connect()` is called without explicit options. */
865
+ connectOptions?: ConnectOptions;
823
866
  }
824
867
 
825
868
  /**
package/dist/index.d.ts CHANGED
@@ -136,6 +136,16 @@ interface ReactorState$1 {
136
136
  interface ConnectOptions {
137
137
  /** Maximum number of SDP polling attempts before giving up. Default: 6. */
138
138
  maxAttempts?: number;
139
+ /**
140
+ * When true (default), sends `resume_track` for every recvonly track
141
+ * immediately after the connection is established, causing the backend to
142
+ * begin streaming those tracks — this preserves the pre-multi-connection
143
+ * behaviour where output tracks flow automatically on connect. Set to false
144
+ * to keep recvonly tracks paused on connect and resume them individually via
145
+ * `resumeTrack()` (e.g. multi-connection apps that only subscribe to a
146
+ * subset of peers).
147
+ */
148
+ autoResumeTracks?: boolean;
139
149
  /**
140
150
  * Attach to a session that already exists (e.g. one created by a backend)
141
151
  * instead of creating a new one. When set, `connect()` skips `POST /sessions`
@@ -143,6 +153,18 @@ interface ConnectOptions {
143
153
  * `connect()` must be valid for the account that owns the session.
144
154
  */
145
155
  sessionId?: string;
156
+ /**
157
+ * Use a specific WebRTC connection id instead of minting one. When omitted
158
+ * (default), the transport registers a fresh connection (`POST .../connections`)
159
+ * and the server mints the id. When set, the transport skips registration and
160
+ * sends its SDP offer directly to that connection — so the id must already have
161
+ * been registered under this session (e.g. a backend called `POST .../connections`
162
+ * and handed the id to this client) and must still be open.
163
+ *
164
+ * `connect()` rejects if the id is invalid (out of the server's accepted range)
165
+ * or if no open connection with that id exists for the session.
166
+ */
167
+ connectionId?: number;
146
168
  }
147
169
  /**
148
170
  * Transport-agnostic timing breakdown of the connect() handshake, recorded
@@ -641,11 +663,21 @@ declare class Reactor {
641
663
  private sessionExpiration?;
642
664
  private local;
643
665
  private sessionId?;
666
+ /**
667
+ * True only when the active session was created by THIS connect flow
668
+ * (via `createSession()`). False when the session was adopted via
669
+ * `connect({ sessionId })`. We must never DELETE a session we did not
670
+ * create — another client (or the backend that created it) owns its
671
+ * lifecycle, so on disconnect/teardown/error an adopting client tears
672
+ * down its own transport but leaves the session alive.
673
+ */
674
+ private createdSession;
644
675
  private connectStartTime?;
645
676
  private connectionTimings?;
646
677
  private capabilities?;
647
678
  private tracks;
648
679
  private presetTracks?;
680
+ private autoResumeTracks;
649
681
  private sessionResponse?;
650
682
  private jwtResolver?;
651
683
  /** Per-Reactor recording client. See {@link RecordingClient}. */
@@ -717,6 +749,8 @@ declare class Reactor {
717
749
  */
718
750
  publishTrack(name: string, track: MediaStreamTrack): Promise<void>;
719
751
  unpublishTrack(name: string): Promise<void>;
752
+ pauseTrack(name: string): void;
753
+ resumeTrack(name: string): void;
720
754
  /**
721
755
  * Reconnects to an existing session with a fresh transport.
722
756
  */
@@ -773,6 +807,13 @@ interface ReactorState {
773
807
  sessionExpiration?: number;
774
808
  /** Token source for Coordinator HTTP calls — see {@link JwtSource}. */
775
809
  jwtToken?: JwtSource;
810
+ /**
811
+ * Default connect options set by the provider. Applied as base values
812
+ * whenever `connect()` is called without explicit options, so that
813
+ * provider-level settings like `autoResumeTracks` are honoured for
814
+ * both autoConnect and manual connect calls.
815
+ */
816
+ connectOptions?: ConnectOptions;
776
817
  }
777
818
  interface ReactorActions {
778
819
  sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
@@ -820,6 +861,8 @@ type ReactorStore = ReactorState & ReactorActions & {
820
861
  interface ReactorInitializationProps extends Options {
821
862
  /** Token source for the underlying {@link Reactor} — see {@link JwtSource}. */
822
863
  jwtToken?: JwtSource;
864
+ /** Default connect options applied when `connect()` is called without explicit options. */
865
+ connectOptions?: ConnectOptions;
823
866
  }
824
867
 
825
868
  /**