@signalwire/js 4.0.0-rc.0 → 4.0.0-rc.2

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
@@ -342,6 +342,12 @@ interface MediaOptions {
342
342
  receiveAudio?: boolean;
343
343
  /** Whether to receive remote video. */
344
344
  receiveVideo?: boolean;
345
+ /**
346
+ * When local media can't be acquired (permission denied or device
347
+ * unavailable), continue the call in receive-only mode instead of failing.
348
+ * Defaults to `true`. Ignored when the call is not set to receive any media.
349
+ */
350
+ fallbackToReceiveOnly?: boolean;
345
351
  }
346
352
  //#endregion
347
353
  //#region src/containers/PreferencesContainer.d.ts
@@ -812,7 +818,7 @@ interface Member {
812
818
  member_id: string;
813
819
  call_id: string;
814
820
  name: string;
815
- type: 'member' | 'screen';
821
+ type: 'member' | 'screen' | 'device' | (string & {});
816
822
  parent_id?: string;
817
823
  requested_position?: string;
818
824
  handraised: boolean;
@@ -820,17 +826,17 @@ interface Member {
820
826
  audio_muted: boolean;
821
827
  video_muted: boolean;
822
828
  deaf: boolean;
823
- input_volume: number;
824
- output_volume: number;
825
- input_sensitivity: number;
829
+ input_volume?: number;
830
+ output_volume?: number;
831
+ input_sensitivity?: number;
826
832
  echo_cancellation: boolean;
827
833
  auto_gain: boolean;
828
834
  noise_suppression: boolean;
829
835
  lowbitrate: boolean;
830
836
  denoise: boolean;
831
- talking: boolean;
832
- isAudience: boolean;
833
- meta: Record<string, unknown>;
837
+ talking?: boolean;
838
+ isAudience?: boolean;
839
+ meta?: Record<string, unknown>;
834
840
  subscriber_id: string;
835
841
  address_id: string;
836
842
  updated?: string[];
@@ -952,6 +958,15 @@ interface RoomUpdatedPayload {
952
958
  room_id: string;
953
959
  room_session_id: string;
954
960
  }
961
+ /**
962
+ * Describes the peer (remote) call referenced from a call.state event.
963
+ *
964
+ * Mirrors the backend (relay.c) `peer` shape.
965
+ */
966
+ interface CallStateRelatedCall {
967
+ call_id?: string;
968
+ node_id?: string;
969
+ }
955
970
  interface CallStatePayload {
956
971
  call_id: string;
957
972
  node_id: string;
@@ -959,10 +974,19 @@ interface CallStatePayload {
959
974
  call_state: SignalingCallStates;
960
975
  direction: CallDirection;
961
976
  device: CallDevice;
962
- start_time: number;
963
- answer_time: number;
964
- end_time: number;
977
+ /**
978
+ * Epoch timestamps for the call lifecycle. Optional because pre-answer
979
+ * states (e.g. `created`, `ringing`) do not have an `answer_time`/`end_time`
980
+ * and the backend reports them as `0` or omits them.
981
+ */
982
+ start_time?: number;
983
+ answer_time?: number;
984
+ end_time?: number;
965
985
  room_session_id: string;
986
+ /** The peer (remote) call this call is connected to, if any. */
987
+ peer?: CallStateRelatedCall;
988
+ /** Application-defined tag associated with the call. */
989
+ tag?: string;
966
990
  }
967
991
  interface CallPlayPayload {
968
992
  control_id: string;
@@ -1168,6 +1192,32 @@ declare class MediaTrackError extends Error {
1168
1192
  originalError: unknown;
1169
1193
  constructor(operation: string, kind: string, originalError: unknown);
1170
1194
  }
1195
+ /**
1196
+ * Failure to acquire local media (camera, microphone, or screen capture)
1197
+ * via `getUserMedia`/`getDisplayMedia`.
1198
+ *
1199
+ * Non-fatal by default: screenshare and additional-device failures never
1200
+ * end the call, and main-connection failures degrade to receive-only when
1201
+ * possible. The wrapping site sets `fatal` to `true` only when the call
1202
+ * cannot continue (receive-only fallback disabled or no receive intent).
1203
+ */
1204
+ declare class MediaAccessError extends Error {
1205
+ /** The SDK operation that failed, e.g. `'acquireLocalMedia'`, `'startScreenShare'`, `'addInputDevice'`. */
1206
+ operation: string;
1207
+ /** The media being acquired: `'audio' | 'video' | 'audiovideo' | 'screen'`. */
1208
+ media: string;
1209
+ /** The raw `getUserMedia`/`getDisplayMedia` error (typically a `DOMException`). */
1210
+ originalError: unknown;
1211
+ /** Whether this failure terminates the call. */
1212
+ readonly fatal: boolean;
1213
+ constructor(/** The SDK operation that failed, e.g. `'acquireLocalMedia'`, `'startScreenShare'`, `'addInputDevice'`. */
1214
+ operation: string, /** The media being acquired: `'audio' | 'video' | 'audiovideo' | 'screen'`. */
1215
+ media: string, /** The raw `getUserMedia`/`getDisplayMedia` error (typically a `DOMException`). */
1216
+ originalError: unknown, /** Whether this failure terminates the call. */
1217
+ fatal?: boolean);
1218
+ /** True when the underlying failure is a permission denial (user or policy). */
1219
+ get denied(): boolean;
1220
+ }
1171
1221
  declare class DPoPInitError extends Error {
1172
1222
  originalError: unknown;
1173
1223
  constructor(originalError: unknown, message?: string);
@@ -1508,6 +1558,8 @@ interface MemberCapabilities {
1508
1558
  readonly meta: boolean;
1509
1559
  readonly remove: boolean;
1510
1560
  readonly audioFlags: boolean;
1561
+ readonly denoise: boolean;
1562
+ readonly lowbitrate: boolean;
1511
1563
  }
1512
1564
  /**
1513
1565
  * Call-level capabilities state
@@ -1861,6 +1913,8 @@ declare class Participant extends Destroyable implements CallParticipant {
1861
1913
  get addressId(): string | undefined;
1862
1914
  /** Server node ID for this participant, or `undefined` if not available. */
1863
1915
  get nodeId(): string | undefined;
1916
+ /** Call ID for this participant's leg, or `undefined` if not available. */
1917
+ get callId(): string | undefined;
1864
1918
  /** @internal */
1865
1919
  get value(): Partial<Member>;
1866
1920
  /** Toggles the deafened state (mutes/unmutes incoming audio). */
@@ -1885,6 +1939,7 @@ declare class Participant extends Destroyable implements CallParticipant {
1885
1939
  toggleAudioInputAutoGain(): Promise<void>;
1886
1940
  /** Toggles noise suppression on the audio input. */
1887
1941
  toggleNoiseSuppression(): Promise<void>;
1942
+ /** Toggles low-bitrate mode for this participant's media. */
1888
1943
  toggleLowbitrate(): Promise<void>;
1889
1944
  /**
1890
1945
  * Adjusts the **conference-only** microphone energy gate / sensitivity level
@@ -1925,6 +1980,14 @@ declare class Participant extends Destroyable implements CallParticipant {
1925
1980
  setAudioOutputVolume(value: number): Promise<void>;
1926
1981
  /**
1927
1982
  * Sets the participant's position in the video layout.
1983
+ *
1984
+ * Requires the `member.position` capability. The gateway keys positions by the
1985
+ * **target member's own** `call_id`/`node_id` (see issue #19400 and the legacy
1986
+ * `setPositions` implementation), so this sends the participant's own call
1987
+ * context — matching {@link Participant.remove}. A resolved promise does not
1988
+ * guarantee a visible change: the backend silently returns `200` (no-op) for
1989
+ * non-conference targets.
1990
+ *
1928
1991
  * @param value - The {@link VideoPosition} to assign (e.g. `'auto'`, `'reserved-0'`).
1929
1992
  */
1930
1993
  setPosition(value: VideoPosition): Promise<void>;
@@ -1983,7 +2046,15 @@ declare class SelfParticipant extends Participant implements CallSelfParticipant
1983
2046
  * Sets echoCancellation, noiseSuppression, and autoGainControl to true.
1984
2047
  */
1985
2048
  disableStudioAudio(): Promise<void>;
1986
- /** Starts sharing the local screen. */
2049
+ /**
2050
+ * Starts sharing the local screen.
2051
+ *
2052
+ * The call is unaffected when acquisition fails.
2053
+ *
2054
+ * @throws The raw `getDisplayMedia` error. A dismissed picker or a
2055
+ * permission denial rejects with a `NotAllowedError` `DOMException` —
2056
+ * inspect `error.name` to tell benign cancels apart from real failures.
2057
+ */
1987
2058
  startScreenShare(): Promise<void>;
1988
2059
  /** Observable of the current screen share status. */
1989
2060
  get screenShareStatus$(): Observable<ScreenShareStatus>;
@@ -1991,7 +2062,14 @@ declare class SelfParticipant extends Participant implements CallSelfParticipant
1991
2062
  get screenShareStatus(): ScreenShareStatus;
1992
2063
  /** Stops the current screen share. */
1993
2064
  stopScreenShare(): Promise<void>;
1994
- /** Adds an additional media input device to the call. */
2065
+ /**
2066
+ * Adds an additional media input device to the call.
2067
+ *
2068
+ * The call is unaffected when acquisition fails.
2069
+ *
2070
+ * @throws The raw `getUserMedia` error (e.g. `NotAllowedError` on
2071
+ * permission denial) — inspect `error.name` to decide how to react.
2072
+ */
1995
2073
  addAdditionalDevice(options: MediaOptions): Promise<void>;
1996
2074
  /** Removes an additional media input device by ID. */
1997
2075
  removeAdditionalDevice(id: string): Promise<void>;
@@ -2098,6 +2176,7 @@ interface CallParticipant {
2098
2176
  readonly userId: string | undefined;
2099
2177
  readonly addressId: string | undefined;
2100
2178
  readonly nodeId: string | undefined;
2179
+ readonly callId: string | undefined;
2101
2180
  readonly isTalking: boolean;
2102
2181
  readonly position: LayoutLayer | undefined;
2103
2182
  readonly isAudience: boolean;
@@ -3112,7 +3191,34 @@ declare class ClientSessionManager extends Destroyable implements SessionState {
3112
3191
  private get authentication();
3113
3192
  connect(): Promise<void>;
3114
3193
  private handleAuthenticationError;
3194
+ /**
3195
+ * Clear the resume state (authorization_state + protocol) only.
3196
+ *
3197
+ * This is the stale-auth-state recovery helper used by handleAuthError:
3198
+ * the server rejected a reconnect, so the resume state is discarded and a
3199
+ * fresh connect follows. Attach records are deliberately preserved — the
3200
+ * session lives on through the reconnect and reattachCalls() needs the
3201
+ * stored call references afterwards. Do NOT add detachAll() here.
3202
+ *
3203
+ * For public teardown (disconnect/destroy), use {@link teardownSessionState}
3204
+ * instead, which clears the attach records as well.
3205
+ */
3115
3206
  cleanupStoredConnectionParams(): Promise<void>;
3207
+ /**
3208
+ * Public-teardown helper for disconnect()/destroy(). Clears the resume
3209
+ * state (authorization_state + protocol) AND the attach records as one
3210
+ * atomic unit.
3211
+ *
3212
+ * The two stores are coupled: the backend only honors attach records
3213
+ * within the session identified by the resume state, so ending the
3214
+ * session must clear both. Clearing one without the other strands records
3215
+ * no future session can honor (disconnect) or revives a session the
3216
+ * developer explicitly ended (destroy).
3217
+ *
3218
+ * Distinct from {@link cleanupStoredConnectionParams}, which keeps the
3219
+ * attach records for the stale-auth-state recovery path.
3220
+ */
3221
+ teardownSessionState(): Promise<void>;
3116
3222
  protected updateAuthState(authorization_state: string): Promise<void>;
3117
3223
  reauthenticate(token: string, dpopToken?: string, options?: {
3118
3224
  clientBound?: boolean;
@@ -3424,8 +3530,12 @@ interface SignalWireOptions {
3424
3530
  * When `false` (default), session data lives in `sessionStorage` and is
3425
3531
  * lost on reload.
3426
3532
  *
3427
- * Call {@link SignalWire.destroy | destroy()} to clear all persisted state
3428
- * (explicit logout).
3533
+ * Both {@link SignalWire.disconnect | disconnect()} and
3534
+ * {@link SignalWire.destroy | destroy()} end the session and clear the
3535
+ * persisted resume state and attach records; credentials and device
3536
+ * preferences survive. Use `resetToDefaults()` for a full wipe, or
3537
+ * `unregister()` to temporarily stop receiving inbound calls while keeping
3538
+ * the session alive.
3429
3539
  */
3430
3540
  persistSession?: boolean;
3431
3541
  /** Custom storage implementation for persistence. */
@@ -3639,6 +3749,14 @@ declare class SignalWire extends Destroyable implements DeviceController {
3639
3749
  /**
3640
3750
  * Disconnects the WebSocket and tears down the current session.
3641
3751
  *
3752
+ * Ends the session identified by the protocol and clears its persisted
3753
+ * resume state (`authorization_state` + protocol) and attach records
3754
+ * together — a later {@link connect} with the same credentials starts a
3755
+ * fresh session and cannot reattach to the ended session's calls.
3756
+ * Credentials and device preferences are preserved. To temporarily stop
3757
+ * receiving inbound calls while keeping the session alive, use
3758
+ * `unregister()` instead.
3759
+ *
3642
3760
  * The client can be reconnected by calling {@link connect} again,
3643
3761
  * which creates a fresh transport and session.
3644
3762
  */
@@ -3820,7 +3938,15 @@ declare class SignalWire extends Destroyable implements DeviceController {
3820
3938
  * attached call IDs, and all SDK storage keys, then re-enumerates devices.
3821
3939
  */
3822
3940
  resetToDefaults(): Promise<void>;
3823
- /** Destroys the client, clearing timers and releasing all resources. */
3941
+ /**
3942
+ * Destroys the client, clearing timers and releasing all resources.
3943
+ *
3944
+ * Intentionally destroying the client ends its session: the resume state
3945
+ * (`authorization_state` + protocol) and the attach records are both
3946
+ * cleared. Credentials and device preferences are preserved — use
3947
+ * {@link resetToDefaults} for a full wipe. To temporarily stop receiving
3948
+ * inbound calls while keeping the session alive, use `unregister()`.
3949
+ */
3824
3950
  destroy(): void;
3825
3951
  }
3826
3952
  //#endregion
@@ -4153,6 +4279,25 @@ declare class RTCPeerConnectionController extends Destroyable {
4153
4279
  */
4154
4280
  private setupTrackHandling;
4155
4281
  private setupLocalTracks;
4282
+ /** True for a main connection with no local media to send. */
4283
+ private hasNoLocalMediaToSend;
4284
+ /** The media kinds this connection wants to send: 'audiovideo' | 'video' | 'audio'. */
4285
+ private get requestedMediaKinds();
4286
+ /**
4287
+ * Handle a local media acquisition failure with a typed, semantically
4288
+ * accurate MediaAccessError created at the acquisition site:
4289
+ * - Auxiliary connections (screenshare / additional-device) throw a
4290
+ * non-fatal error — VertoManager surfaces it and the call is unaffected.
4291
+ * - The main connection degrades to receive-only when allowed (default),
4292
+ * otherwise fails with a fatal error.
4293
+ */
4294
+ private handleLocalMediaFailure;
4295
+ /**
4296
+ * Negotiate receive-only m-lines when there are no local tracks to send.
4297
+ * Only offer-type connections add transceivers — answer-type connections
4298
+ * reuse the transceivers created from the remote offer.
4299
+ */
4300
+ private setupReceiveOnlyTransceivers;
4156
4301
  private getUserMedia;
4157
4302
  private getDisplayMedia;
4158
4303
  private setupRemoteTracks;
@@ -4698,10 +4843,21 @@ declare class WebRTCCall extends Destroyable implements CallManager {
4698
4843
  /** Observable that emits `true` when answered, `false` when rejected. */
4699
4844
  get answered$(): Observable<boolean>;
4700
4845
  /**
4701
- * Sets the call layout and participant positions.
4846
+ * Sets the call layout and, optionally, individual participant positions.
4847
+ *
4848
+ * The gateway `call.layout.set` DTO has **no** `positions` member, so when
4849
+ * `positions` is provided this method issues a `call.member.position.set`
4850
+ * request per member (via {@link Participant.setPosition}, which keys each
4851
+ * position by that member's own call context) alongside `call.layout.set`
4852
+ * (issue #19400, Flag #6).
4853
+ *
4854
+ * **These operations are NOT atomic.** The layout is applied first, then each
4855
+ * member position sequentially, so members may briefly flash into their
4856
+ * default slots before being moved to the requested positions.
4702
4857
  *
4703
4858
  * @param layout - Layout name (must be one of {@link layouts}).
4704
- * @param positions - Map of member IDs to {@link VideoPosition} values.
4859
+ * @param positions - Optional map of member IDs to {@link VideoPosition} values.
4860
+ * When omitted or empty, only the layout is changed.
4705
4861
  * @throws {InvalidParams} If the layout is not in the available {@link layouts}.
4706
4862
  *
4707
4863
  * @example
@@ -4711,7 +4867,7 @@ declare class WebRTCCall extends Destroyable implements CallManager {
4711
4867
  * });
4712
4868
  * ```
4713
4869
  */
4714
- setLayout(layout: string, positions: Record<string, VideoPosition>): Promise<void>;
4870
+ setLayout(layout: string, positions?: Record<string, VideoPosition>): Promise<void>;
4715
4871
  /**
4716
4872
  * Transfers the call to another destination.
4717
4873
  *
@@ -4815,5 +4971,5 @@ declare const version: string;
4815
4971
  */
4816
4972
  declare const ready: boolean;
4817
4973
  //#endregion
4818
- export { Address, type AddressHistory, type AudioConstraintsEvent, type AuthenticateContext, type Call, type CallAddress, type CallCapabilitiesState, CallCreateError, type CallDiagnosticSummary, type CallDirection, type CallError, type CallErrorKind, type NetworkIssue as CallNetworkIssue, type NetworkIssue, type NetworkMetrics as CallNetworkMetrics, type NetworkMetrics, type CallOptions, type CallParticipant, type CallSelfParticipant, type CallState, type CallStatus, type Capability, ClientPreferences, CollectionFetchError, type ConstraintFallbackEvent, type CredentialNoRefreshHandlerWarning, type CredentialProvider, type CredentialRefreshFallbackReason, type CredentialRefreshFallbackWarning, DPoPInitError, type DebugOptions, type DeviceController, type DeviceRecoveryEvent, DeviceTokenError, type DiagnosticEvent, type DialOptions, type Directory, EmbedTokenCredentialProvider, type ExecuteMethod, InvalidCredentialsError, type JSONRPCErrorResponse, type JSONRPCRequest, type JSONRPCResponse, type JSONRPCSuccessResponse, type LayoutLayer, type LogLevel, type MediaDirection, type MediaDirections, type MediaOptions, type MediaParamsEvent, MediaTrackError, type MemberCapabilities, MessageParseError, type NodeSocketAdapter, type OnOffCapability, OverconstrainedFallbackError, Participant, type PendingRPCOptions, type PermissionResult, type PlatformCapabilities, PreflightError, type PreflightOptions, type PreflightResult, type QualityLevel, RecoveryError, type RecoveryEvent, type RecoveryState, type ResilienceCallStatus, type SATClaims, type SDKCredential, type SDKLogger, type SDKWarning, type ScreenShareStatus, type SelectDeviceOptions, SelfCapabilities, SelfParticipant, type SessionDiagnostics, type SessionState, SignalWire, type SignalWireOptions, StaticCredentialProvider, type Storage, type StoredDevicePreference, type TextMessage, TokenRefreshError, type TransferOptions, UnexpectedError, User, type UserPresence, VertoPongError, type VideoPosition, type WebRTCApiProvider, WebRTCCall, type WebRTCMediaDevices, type WebSocketAdapter, embeddableCall, getLogger, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
4974
+ export { Address, type AddressHistory, type AudioConstraintsEvent, type AuthenticateContext, type Call, type CallAddress, type CallCapabilitiesState, CallCreateError, type CallDiagnosticSummary, type CallDirection, type CallError, type CallErrorKind, type NetworkIssue as CallNetworkIssue, type NetworkIssue, type NetworkMetrics as CallNetworkMetrics, type NetworkMetrics, type CallOptions, type CallParticipant, type CallSelfParticipant, type CallState, type CallStatus, type Capability, ClientPreferences, CollectionFetchError, type ConstraintFallbackEvent, type CredentialNoRefreshHandlerWarning, type CredentialProvider, type CredentialRefreshFallbackReason, type CredentialRefreshFallbackWarning, DPoPInitError, type DebugOptions, type DeviceController, type DeviceRecoveryEvent, DeviceTokenError, type DiagnosticEvent, type DialOptions, type Directory, EmbedTokenCredentialProvider, type ExecuteMethod, InvalidCredentialsError, type JSONRPCErrorResponse, type JSONRPCRequest, type JSONRPCResponse, type JSONRPCSuccessResponse, type LayoutLayer, type LogLevel, MediaAccessError, type MediaDirection, type MediaDirections, type MediaOptions, type MediaParamsEvent, MediaTrackError, type MemberCapabilities, MessageParseError, type NodeSocketAdapter, type OnOffCapability, OverconstrainedFallbackError, Participant, type PendingRPCOptions, type PermissionResult, type PlatformCapabilities, PreflightError, type PreflightOptions, type PreflightResult, type QualityLevel, RecoveryError, type RecoveryEvent, type RecoveryState, type ResilienceCallStatus, type SATClaims, type SDKCredential, type SDKLogger, type SDKWarning, type ScreenShareStatus, type SelectDeviceOptions, SelfCapabilities, SelfParticipant, type SessionDiagnostics, type SessionState, SignalWire, type SignalWireOptions, StaticCredentialProvider, type Storage, type StoredDevicePreference, type TextMessage, TokenRefreshError, type TransferOptions, UnexpectedError, User, type UserPresence, VertoPongError, type VideoPosition, type WebRTCApiProvider, WebRTCCall, type WebRTCMediaDevices, type WebSocketAdapter, embeddableCall, getLogger, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
4819
4975
  //# sourceMappingURL=index.d.mts.map