@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/browser.umd.js
CHANGED
|
@@ -9100,6 +9100,8 @@ const MEDIA_ACCESS_DENIAL_NAMES = [
|
|
|
9100
9100
|
"SecurityError",
|
|
9101
9101
|
"PermissionDeniedError"
|
|
9102
9102
|
];
|
|
9103
|
+
/** Error names browsers use when the capture hardware is already held exclusively. */
|
|
9104
|
+
const MEDIA_DEVICE_IN_USE_NAMES = ["NotReadableError", "TrackStartError"];
|
|
9103
9105
|
/** Default polling interval for RTCPeerConnection.getStats() in milliseconds. */
|
|
9104
9106
|
const DEFAULT_STATS_POLLING_INTERVAL_MS = 1e3;
|
|
9105
9107
|
/** Number of initial samples used to build a baseline for spike detection. */
|
|
@@ -9438,6 +9440,10 @@ var MediaTrackError = class extends Error {
|
|
|
9438
9440
|
function isMediaAccessDenial(originalError) {
|
|
9439
9441
|
return originalError instanceof Error && MEDIA_ACCESS_DENIAL_NAMES.includes(originalError.name);
|
|
9440
9442
|
}
|
|
9443
|
+
/** True when a `getUserMedia` rejection means the hardware is already held exclusively. */
|
|
9444
|
+
function isMediaDeviceInUse(originalError) {
|
|
9445
|
+
return originalError instanceof Error && MEDIA_DEVICE_IN_USE_NAMES.includes(originalError.name);
|
|
9446
|
+
}
|
|
9441
9447
|
/**
|
|
9442
9448
|
* Failure to acquire local media (camera, microphone, or screen capture)
|
|
9443
9449
|
* via `getUserMedia`/`getDisplayMedia`.
|
|
@@ -16056,38 +16062,32 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16056
16062
|
this.negotiationNeeded$.next();
|
|
16057
16063
|
};
|
|
16058
16064
|
this.updateSelectedInputDevice = async (kind, deviceInfo) => {
|
|
16065
|
+
const { localStream } = this;
|
|
16066
|
+
if (!localStream) {
|
|
16067
|
+
logger$17.warn("[RTCPeerConnectionController] No local stream available to update input device.");
|
|
16068
|
+
return;
|
|
16069
|
+
}
|
|
16070
|
+
const currentTrack = localStream.getTracks().find((track) => track.kind === kind);
|
|
16071
|
+
if (!currentTrack) {
|
|
16072
|
+
logger$17.debug(`[RTCPeerConnectionController] No ${kind} track to switch.`);
|
|
16073
|
+
return;
|
|
16074
|
+
}
|
|
16075
|
+
if (!deviceInfo) {
|
|
16076
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
16077
|
+
this.stopTrackSender(kind);
|
|
16078
|
+
return;
|
|
16079
|
+
}
|
|
16080
|
+
const constraints = {
|
|
16081
|
+
...currentTrack.getConstraints(),
|
|
16082
|
+
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
16083
|
+
};
|
|
16059
16084
|
try {
|
|
16060
|
-
const
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
return;
|
|
16064
|
-
}
|
|
16065
|
-
logger$17.debug(`[RTCPeerConnectionController] Updating selected ${kind} input device:`, localStream.getTracks());
|
|
16066
|
-
const track = localStream.getTracks().find((track$1) => track$1.kind === kind);
|
|
16067
|
-
if (track) {
|
|
16068
|
-
this.transceiverController?.stopTrackSender(kind);
|
|
16069
|
-
this.localStreamController.removeTrack(track.id);
|
|
16070
|
-
logger$17.debug(`[RTCPeerConnectionController] Stopped existing ${kind} track: ${track.id}`, localStream.getTracks());
|
|
16071
|
-
if (!deviceInfo) {
|
|
16072
|
-
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
16073
|
-
return;
|
|
16074
|
-
}
|
|
16075
|
-
const streamTrack = (await this.getUserMedia({ [kind]: {
|
|
16076
|
-
...track.getConstraints(),
|
|
16077
|
-
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
16078
|
-
} })).getTracks().find((t) => t.kind === kind);
|
|
16079
|
-
if (streamTrack) {
|
|
16080
|
-
logger$17.debug(`[RTCPeerConnectionController] Adding new ${kind} track: ${streamTrack.id}`);
|
|
16081
|
-
this.localStreamController.addTrack(streamTrack);
|
|
16082
|
-
await this.transceiverController?.replaceSenderTrack(kind, streamTrack);
|
|
16083
|
-
logger$17.debug(`[RTCPeerConnectionController] Added new ${kind} track: ${streamTrack.id}`, this.localStream?.getTracks());
|
|
16084
|
-
}
|
|
16085
|
-
}
|
|
16086
|
-
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo?.label);
|
|
16085
|
+
const newTrack = await this.acquireInputTrack(kind, constraints, deviceInfo, currentTrack);
|
|
16086
|
+
await this.attachInputTrack(kind, newTrack, currentTrack);
|
|
16087
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo.label, newTrack.id);
|
|
16087
16088
|
} catch (error) {
|
|
16088
16089
|
logger$17.error(`[RTCPeerConnectionController] Failed to select ${kind} input device:`, error);
|
|
16089
16090
|
this._errors$.next(new MediaTrackError("updateSelectedInputDevice", kind, error));
|
|
16090
|
-
throw error;
|
|
16091
16091
|
}
|
|
16092
16092
|
};
|
|
16093
16093
|
this._isNegotiating$ = this.createBehaviorSubject(false);
|
|
@@ -16790,6 +16790,61 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16790
16790
|
this._localAudioPipeline.setInputTrack(newTrack);
|
|
16791
16791
|
}
|
|
16792
16792
|
/**
|
|
16793
|
+
* Capture the newly selected device, leaving the current capture running.
|
|
16794
|
+
*
|
|
16795
|
+
* A rejection must leave the current track sending, so nothing is released
|
|
16796
|
+
* until the replacement is in hand. The one exception is hardware that admits
|
|
16797
|
+
* a single opener — a phone's front and back cameras, typically — which
|
|
16798
|
+
* rejects the second capture until the first is closed.
|
|
16799
|
+
*/
|
|
16800
|
+
async acquireInputTrack(kind, constraints, deviceInfo, currentTrack) {
|
|
16801
|
+
try {
|
|
16802
|
+
return await this.captureTrack(kind, constraints, deviceInfo.deviceId);
|
|
16803
|
+
} catch (error) {
|
|
16804
|
+
if (!isMediaDeviceInUse(error)) throw error;
|
|
16805
|
+
logger$17.warn(`[RTCPeerConnectionController] ${kind} device is held exclusively; releasing the current capture to retry:`, error);
|
|
16806
|
+
const previousDeviceId = currentTrack.getSettings().deviceId;
|
|
16807
|
+
this.stopTrackSender(kind);
|
|
16808
|
+
try {
|
|
16809
|
+
return await this.captureTrack(kind, constraints, deviceInfo.deviceId);
|
|
16810
|
+
} catch (retryError) {
|
|
16811
|
+
await this.restorePreviousInputTrack(kind, constraints, previousDeviceId, currentTrack);
|
|
16812
|
+
throw retryError;
|
|
16813
|
+
}
|
|
16814
|
+
}
|
|
16815
|
+
}
|
|
16816
|
+
async captureTrack(kind, constraints, deviceId) {
|
|
16817
|
+
const { stream, fallbackLevel } = await getUserMediaWithFallback({ getUserMedia: async (c) => this.getUserMedia(c) }, { [kind]: constraints }, kind, deviceId);
|
|
16818
|
+
const track = stream.getTracks().find((t) => t.kind === kind);
|
|
16819
|
+
if (!track) {
|
|
16820
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
16821
|
+
throw new MediaTrackError("updateSelectedInputDevice", kind, /* @__PURE__ */ new Error("getUserMedia returned no track of the requested kind"));
|
|
16822
|
+
}
|
|
16823
|
+
if (fallbackLevel !== "exact") logger$17.warn(`[RTCPeerConnectionController] ${kind} device acquired at fallback level '${fallbackLevel}'; the capture may not be the requested device.`);
|
|
16824
|
+
return track;
|
|
16825
|
+
}
|
|
16826
|
+
/** Best-effort return to the device that was released for an exclusive retry. */
|
|
16827
|
+
async restorePreviousInputTrack(kind, constraints, previousDeviceId, releasedTrack) {
|
|
16828
|
+
try {
|
|
16829
|
+
const restored = await this.captureTrack(kind, constraints, previousDeviceId);
|
|
16830
|
+
await this.attachInputTrack(kind, restored, releasedTrack);
|
|
16831
|
+
} catch (error) {
|
|
16832
|
+
logger$17.error(`[RTCPeerConnectionController] Failed to restore the previous ${kind} device:`, error);
|
|
16833
|
+
}
|
|
16834
|
+
}
|
|
16835
|
+
async attachInputTrack(kind, newTrack, oldTrack) {
|
|
16836
|
+
const pipelineOwnsAudio = kind === "audio" && this._localAudioPipeline;
|
|
16837
|
+
if (!pipelineOwnsAudio) try {
|
|
16838
|
+
await this.transceiverController?.replaceSenderTrack(kind, newTrack);
|
|
16839
|
+
} catch (error) {
|
|
16840
|
+
newTrack.stop();
|
|
16841
|
+
throw error;
|
|
16842
|
+
}
|
|
16843
|
+
this.localStreamController.removeTrack(oldTrack.id);
|
|
16844
|
+
this.localStreamController.addTrack(newTrack);
|
|
16845
|
+
if (pipelineOwnsAudio) this._localAudioPipeline?.setInputTrack(newTrack);
|
|
16846
|
+
}
|
|
16847
|
+
/**
|
|
16793
16848
|
* Return the lazily-created {@link LocalAudioPipeline}, constructing it on
|
|
16794
16849
|
* first access. On creation the current audio sender's track is routed
|
|
16795
16850
|
* through the pipeline (input → gain → analyser → destination) and the
|
|
@@ -17525,16 +17580,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
17525
17580
|
const webrtcVertoMessage = WebrtcVerto(params);
|
|
17526
17581
|
const response = await this.webRtcCallSession.execute(webrtcVertoMessage);
|
|
17527
17582
|
const nonFatal = message.method === "verto.info" ? { fatal: false } : void 0;
|
|
17528
|
-
if (response.error) {
|
|
17529
|
-
const error = new JSONRPCError(response.error.code, response.error.message, response.error.data);
|
|
17530
|
-
this.reportLegError(error, this._rtcPeerConnectionsMap.get(params.callID), nonFatal);
|
|
17531
|
-
return response;
|
|
17532
|
-
}
|
|
17533
17583
|
const innerResult = getValueFrom(response, "result.result");
|
|
17534
|
-
|
|
17535
|
-
|
|
17584
|
+
const failure = response.error ?? innerResult?.error;
|
|
17585
|
+
if (failure) {
|
|
17586
|
+
const error = new JSONRPCError(failure.code, failure.message, failure.data);
|
|
17587
|
+
if (message.method === "verto.invite") throw error;
|
|
17536
17588
|
this.reportLegError(error, this._rtcPeerConnectionsMap.get(params.callID), nonFatal);
|
|
17537
|
-
return response;
|
|
17538
17589
|
}
|
|
17539
17590
|
return response;
|
|
17540
17591
|
}
|
|
@@ -17589,7 +17640,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
17589
17640
|
if (rtcPeerConnController.isMainDevice) this._signalingStatus$.next(status);
|
|
17590
17641
|
}
|
|
17591
17642
|
processInviteResponse(response, rtcPeerConnController) {
|
|
17592
|
-
if (
|
|
17643
|
+
if (getValueFrom(response, "result.result.result.message") === "CALL CREATED") {
|
|
17593
17644
|
this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
|
|
17594
17645
|
const nodeId = getValueFrom(response, "result.node_id") ?? null;
|
|
17595
17646
|
const memberId = getValueFrom(response, "result.result.result.memberID") ?? null;
|
|
@@ -17616,8 +17667,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
17616
17667
|
logger$16.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
|
|
17617
17668
|
} else {
|
|
17618
17669
|
logger$16.error("[WebRTCManager] Verto invite failed:", response);
|
|
17619
|
-
|
|
17620
|
-
this.reportLegError(inviteError, rtcPeerConnController);
|
|
17670
|
+
this.reportLegError(/* @__PURE__ */ new Error("Verto invite failed: unexpected response"), rtcPeerConnController);
|
|
17621
17671
|
}
|
|
17622
17672
|
}
|
|
17623
17673
|
get RTCPeerConnectionConfig() {
|