@signalwire/js 4.0.0-dev-20260911195739 → 4.0.0-dev-20260914173015
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/browser.mjs +89 -39
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +89 -39
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +84 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +13 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +84 -40
- package/dist/index.mjs.map +1 -1
- package/dist/operators/index.cjs +1 -1
- package/dist/operators/index.mjs +1 -1
- package/dist/{operators-Cgz7QUVJ.cjs → operators-BJ6QW1VP.cjs} +13 -1
- package/dist/operators-BJ6QW1VP.cjs.map +1 -0
- package/dist/{operators-B0xqG7Eu.mjs → operators-BVxi3KpN.mjs} +8 -2
- package/dist/operators-BVxi3KpN.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/operators-B0xqG7Eu.mjs.map +0 -1
- package/dist/operators-Cgz7QUVJ.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_operators = require('./operators-
|
|
1
|
+
const require_operators = require('./operators-BJ6QW1VP.cjs');
|
|
2
2
|
let jwt_decode = require("jwt-decode");
|
|
3
3
|
let rxjs = require("rxjs");
|
|
4
4
|
let uuid = require("uuid");
|
|
@@ -5301,38 +5301,32 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5301
5301
|
this.negotiationNeeded$.next();
|
|
5302
5302
|
};
|
|
5303
5303
|
this.updateSelectedInputDevice = async (kind, deviceInfo) => {
|
|
5304
|
+
const { localStream } = this;
|
|
5305
|
+
if (!localStream) {
|
|
5306
|
+
logger$17.warn("[RTCPeerConnectionController] No local stream available to update input device.");
|
|
5307
|
+
return;
|
|
5308
|
+
}
|
|
5309
|
+
const currentTrack = localStream.getTracks().find((track) => track.kind === kind);
|
|
5310
|
+
if (!currentTrack) {
|
|
5311
|
+
logger$17.debug(`[RTCPeerConnectionController] No ${kind} track to switch.`);
|
|
5312
|
+
return;
|
|
5313
|
+
}
|
|
5314
|
+
if (!deviceInfo) {
|
|
5315
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
5316
|
+
this.stopTrackSender(kind);
|
|
5317
|
+
return;
|
|
5318
|
+
}
|
|
5319
|
+
const constraints = {
|
|
5320
|
+
...currentTrack.getConstraints(),
|
|
5321
|
+
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
5322
|
+
};
|
|
5304
5323
|
try {
|
|
5305
|
-
const
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
return;
|
|
5309
|
-
}
|
|
5310
|
-
logger$17.debug(`[RTCPeerConnectionController] Updating selected ${kind} input device:`, localStream.getTracks());
|
|
5311
|
-
const track = localStream.getTracks().find((track$1) => track$1.kind === kind);
|
|
5312
|
-
if (track) {
|
|
5313
|
-
this.transceiverController?.stopTrackSender(kind);
|
|
5314
|
-
this.localStreamController.removeTrack(track.id);
|
|
5315
|
-
logger$17.debug(`[RTCPeerConnectionController] Stopped existing ${kind} track: ${track.id}`, localStream.getTracks());
|
|
5316
|
-
if (!deviceInfo) {
|
|
5317
|
-
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
5318
|
-
return;
|
|
5319
|
-
}
|
|
5320
|
-
const streamTrack = (await this.getUserMedia({ [kind]: {
|
|
5321
|
-
...track.getConstraints(),
|
|
5322
|
-
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
5323
|
-
} })).getTracks().find((t) => t.kind === kind);
|
|
5324
|
-
if (streamTrack) {
|
|
5325
|
-
logger$17.debug(`[RTCPeerConnectionController] Adding new ${kind} track: ${streamTrack.id}`);
|
|
5326
|
-
this.localStreamController.addTrack(streamTrack);
|
|
5327
|
-
await this.transceiverController?.replaceSenderTrack(kind, streamTrack);
|
|
5328
|
-
logger$17.debug(`[RTCPeerConnectionController] Added new ${kind} track: ${streamTrack.id}`, this.localStream?.getTracks());
|
|
5329
|
-
}
|
|
5330
|
-
}
|
|
5331
|
-
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo?.label);
|
|
5324
|
+
const newTrack = await this.acquireInputTrack(kind, constraints, deviceInfo, currentTrack);
|
|
5325
|
+
await this.attachInputTrack(kind, newTrack, currentTrack);
|
|
5326
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo.label, newTrack.id);
|
|
5332
5327
|
} catch (error) {
|
|
5333
5328
|
logger$17.error(`[RTCPeerConnectionController] Failed to select ${kind} input device:`, error);
|
|
5334
5329
|
this._errors$.next(new require_operators.MediaTrackError("updateSelectedInputDevice", kind, error));
|
|
5335
|
-
throw error;
|
|
5336
5330
|
}
|
|
5337
5331
|
};
|
|
5338
5332
|
this._isNegotiating$ = this.createBehaviorSubject(false);
|
|
@@ -6035,6 +6029,61 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
6035
6029
|
this._localAudioPipeline.setInputTrack(newTrack);
|
|
6036
6030
|
}
|
|
6037
6031
|
/**
|
|
6032
|
+
* Capture the newly selected device, leaving the current capture running.
|
|
6033
|
+
*
|
|
6034
|
+
* A rejection must leave the current track sending, so nothing is released
|
|
6035
|
+
* until the replacement is in hand. The one exception is hardware that admits
|
|
6036
|
+
* a single opener — a phone's front and back cameras, typically — which
|
|
6037
|
+
* rejects the second capture until the first is closed.
|
|
6038
|
+
*/
|
|
6039
|
+
async acquireInputTrack(kind, constraints, deviceInfo, currentTrack) {
|
|
6040
|
+
try {
|
|
6041
|
+
return await this.captureTrack(kind, constraints, deviceInfo.deviceId);
|
|
6042
|
+
} catch (error) {
|
|
6043
|
+
if (!require_operators.isMediaDeviceInUse(error)) throw error;
|
|
6044
|
+
logger$17.warn(`[RTCPeerConnectionController] ${kind} device is held exclusively; releasing the current capture to retry:`, error);
|
|
6045
|
+
const previousDeviceId = currentTrack.getSettings().deviceId;
|
|
6046
|
+
this.stopTrackSender(kind);
|
|
6047
|
+
try {
|
|
6048
|
+
return await this.captureTrack(kind, constraints, deviceInfo.deviceId);
|
|
6049
|
+
} catch (retryError) {
|
|
6050
|
+
await this.restorePreviousInputTrack(kind, constraints, previousDeviceId, currentTrack);
|
|
6051
|
+
throw retryError;
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
async captureTrack(kind, constraints, deviceId) {
|
|
6056
|
+
const { stream, fallbackLevel } = await getUserMediaWithFallback({ getUserMedia: async (c) => this.getUserMedia(c) }, { [kind]: constraints }, kind, deviceId);
|
|
6057
|
+
const track = stream.getTracks().find((t) => t.kind === kind);
|
|
6058
|
+
if (!track) {
|
|
6059
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
6060
|
+
throw new require_operators.MediaTrackError("updateSelectedInputDevice", kind, /* @__PURE__ */ new Error("getUserMedia returned no track of the requested kind"));
|
|
6061
|
+
}
|
|
6062
|
+
if (fallbackLevel !== "exact") logger$17.warn(`[RTCPeerConnectionController] ${kind} device acquired at fallback level '${fallbackLevel}'; the capture may not be the requested device.`);
|
|
6063
|
+
return track;
|
|
6064
|
+
}
|
|
6065
|
+
/** Best-effort return to the device that was released for an exclusive retry. */
|
|
6066
|
+
async restorePreviousInputTrack(kind, constraints, previousDeviceId, releasedTrack) {
|
|
6067
|
+
try {
|
|
6068
|
+
const restored = await this.captureTrack(kind, constraints, previousDeviceId);
|
|
6069
|
+
await this.attachInputTrack(kind, restored, releasedTrack);
|
|
6070
|
+
} catch (error) {
|
|
6071
|
+
logger$17.error(`[RTCPeerConnectionController] Failed to restore the previous ${kind} device:`, error);
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
async attachInputTrack(kind, newTrack, oldTrack) {
|
|
6075
|
+
const pipelineOwnsAudio = kind === "audio" && this._localAudioPipeline;
|
|
6076
|
+
if (!pipelineOwnsAudio) try {
|
|
6077
|
+
await this.transceiverController?.replaceSenderTrack(kind, newTrack);
|
|
6078
|
+
} catch (error) {
|
|
6079
|
+
newTrack.stop();
|
|
6080
|
+
throw error;
|
|
6081
|
+
}
|
|
6082
|
+
this.localStreamController.removeTrack(oldTrack.id);
|
|
6083
|
+
this.localStreamController.addTrack(newTrack);
|
|
6084
|
+
if (pipelineOwnsAudio) this._localAudioPipeline?.setInputTrack(newTrack);
|
|
6085
|
+
}
|
|
6086
|
+
/**
|
|
6038
6087
|
* Return the lazily-created {@link LocalAudioPipeline}, constructing it on
|
|
6039
6088
|
* first access. On creation the current audio sender's track is routed
|
|
6040
6089
|
* through the pipeline (input → gain → analyser → destination) and the
|
|
@@ -6769,16 +6818,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6769
6818
|
const webrtcVertoMessage = WebrtcVerto(params);
|
|
6770
6819
|
const response = await this.webRtcCallSession.execute(webrtcVertoMessage);
|
|
6771
6820
|
const nonFatal = message.method === "verto.info" ? { fatal: false } : void 0;
|
|
6772
|
-
if (response.error) {
|
|
6773
|
-
const error = new require_operators.JSONRPCError(response.error.code, response.error.message, response.error.data);
|
|
6774
|
-
this.reportLegError(error, this._rtcPeerConnectionsMap.get(params.callID), nonFatal);
|
|
6775
|
-
return response;
|
|
6776
|
-
}
|
|
6777
6821
|
const innerResult = require_operators.getValueFrom(response, "result.result");
|
|
6778
|
-
|
|
6779
|
-
|
|
6822
|
+
const failure = response.error ?? innerResult?.error;
|
|
6823
|
+
if (failure) {
|
|
6824
|
+
const error = new require_operators.JSONRPCError(failure.code, failure.message, failure.data);
|
|
6825
|
+
if (message.method === "verto.invite") throw error;
|
|
6780
6826
|
this.reportLegError(error, this._rtcPeerConnectionsMap.get(params.callID), nonFatal);
|
|
6781
|
-
return response;
|
|
6782
6827
|
}
|
|
6783
6828
|
return response;
|
|
6784
6829
|
}
|
|
@@ -6833,7 +6878,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6833
6878
|
if (rtcPeerConnController.isMainDevice) this._signalingStatus$.next(status);
|
|
6834
6879
|
}
|
|
6835
6880
|
processInviteResponse(response, rtcPeerConnController) {
|
|
6836
|
-
if (
|
|
6881
|
+
if (require_operators.getValueFrom(response, "result.result.result.message") === "CALL CREATED") {
|
|
6837
6882
|
this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
|
|
6838
6883
|
const nodeId = require_operators.getValueFrom(response, "result.node_id") ?? null;
|
|
6839
6884
|
const memberId = require_operators.getValueFrom(response, "result.result.result.memberID") ?? null;
|
|
@@ -6860,8 +6905,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6860
6905
|
logger$16.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
|
|
6861
6906
|
} else {
|
|
6862
6907
|
logger$16.error("[WebRTCManager] Verto invite failed:", response);
|
|
6863
|
-
|
|
6864
|
-
this.reportLegError(inviteError, rtcPeerConnController);
|
|
6908
|
+
this.reportLegError(/* @__PURE__ */ new Error("Verto invite failed: unexpected response"), rtcPeerConnController);
|
|
6865
6909
|
}
|
|
6866
6910
|
}
|
|
6867
6911
|
get RTCPeerConnectionConfig() {
|