@signalwire/js 4.0.0-dev-20260410161919 → 4.0.0-dev-20260413184400
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 +934 -614
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +934 -614
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +698 -379
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +688 -369
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser.umd.js
CHANGED
|
@@ -3394,7 +3394,7 @@ var require_map = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3394
3394
|
exports.map = void 0;
|
|
3395
3395
|
var lift_1$64 = require_lift();
|
|
3396
3396
|
var OperatorSubscriber_1$54 = require_OperatorSubscriber();
|
|
3397
|
-
function map$
|
|
3397
|
+
function map$19(project, thisArg) {
|
|
3398
3398
|
return lift_1$64.operate(function(source, subscriber) {
|
|
3399
3399
|
var index = 0;
|
|
3400
3400
|
source.subscribe(OperatorSubscriber_1$54.createOperatorSubscriber(subscriber, function(value) {
|
|
@@ -3402,7 +3402,7 @@ var require_map = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3402
3402
|
}));
|
|
3403
3403
|
});
|
|
3404
3404
|
}
|
|
3405
|
-
exports.map = map$
|
|
3405
|
+
exports.map = map$19;
|
|
3406
3406
|
}));
|
|
3407
3407
|
|
|
3408
3408
|
//#endregion
|
|
@@ -4144,7 +4144,7 @@ var require_timer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4144
4144
|
var async_1$11 = require_async();
|
|
4145
4145
|
var isScheduler_1 = require_isScheduler();
|
|
4146
4146
|
var isDate_1$1 = require_isDate();
|
|
4147
|
-
function timer$
|
|
4147
|
+
function timer$2(dueTime, intervalOrScheduler, scheduler) {
|
|
4148
4148
|
if (dueTime === void 0) dueTime = 0;
|
|
4149
4149
|
if (scheduler === void 0) scheduler = async_1$11.async;
|
|
4150
4150
|
var intervalDuration = -1;
|
|
@@ -4163,7 +4163,7 @@ var require_timer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4163
4163
|
}, due);
|
|
4164
4164
|
});
|
|
4165
4165
|
}
|
|
4166
|
-
exports.timer = timer$
|
|
4166
|
+
exports.timer = timer$2;
|
|
4167
4167
|
}));
|
|
4168
4168
|
|
|
4169
4169
|
//#endregion
|
|
@@ -4297,7 +4297,7 @@ var require_filter = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4297
4297
|
exports.filter = void 0;
|
|
4298
4298
|
var lift_1$62 = require_lift();
|
|
4299
4299
|
var OperatorSubscriber_1$49 = require_OperatorSubscriber();
|
|
4300
|
-
function filter$
|
|
4300
|
+
function filter$16(predicate, thisArg) {
|
|
4301
4301
|
return lift_1$62.operate(function(source, subscriber) {
|
|
4302
4302
|
var index = 0;
|
|
4303
4303
|
source.subscribe(OperatorSubscriber_1$49.createOperatorSubscriber(subscriber, function(value) {
|
|
@@ -4305,7 +4305,7 @@ var require_filter = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4305
4305
|
}));
|
|
4306
4306
|
});
|
|
4307
4307
|
}
|
|
4308
|
-
exports.filter = filter$
|
|
4308
|
+
exports.filter = filter$16;
|
|
4309
4309
|
}));
|
|
4310
4310
|
|
|
4311
4311
|
//#endregion
|
|
@@ -6938,7 +6938,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
6938
6938
|
var innerFrom_1$6 = require_innerFrom();
|
|
6939
6939
|
var lift_1$13 = require_lift();
|
|
6940
6940
|
var OperatorSubscriber_1$11 = require_OperatorSubscriber();
|
|
6941
|
-
function switchMap$
|
|
6941
|
+
function switchMap$7(project, resultSelector) {
|
|
6942
6942
|
return lift_1$13.operate(function(source, subscriber) {
|
|
6943
6943
|
var innerSubscriber = null;
|
|
6944
6944
|
var index = 0;
|
|
@@ -6962,7 +6962,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
6962
6962
|
}));
|
|
6963
6963
|
});
|
|
6964
6964
|
}
|
|
6965
|
-
exports.switchMap = switchMap$
|
|
6965
|
+
exports.switchMap = switchMap$7;
|
|
6966
6966
|
}));
|
|
6967
6967
|
|
|
6968
6968
|
//#endregion
|
|
@@ -7586,7 +7586,7 @@ var require_withLatestFrom = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
7586
7586
|
var identity_1$1 = require_identity();
|
|
7587
7587
|
var noop_1$1 = require_noop();
|
|
7588
7588
|
var args_1 = require_args();
|
|
7589
|
-
function withLatestFrom$
|
|
7589
|
+
function withLatestFrom$2() {
|
|
7590
7590
|
var inputs = [];
|
|
7591
7591
|
for (var _i = 0; _i < arguments.length; _i++) inputs[_i] = arguments[_i];
|
|
7592
7592
|
var project = args_1.popResultSelector(inputs);
|
|
@@ -7615,7 +7615,7 @@ var require_withLatestFrom = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
7615
7615
|
}));
|
|
7616
7616
|
});
|
|
7617
7617
|
}
|
|
7618
|
-
exports.withLatestFrom = withLatestFrom$
|
|
7618
|
+
exports.withLatestFrom = withLatestFrom$2;
|
|
7619
7619
|
}));
|
|
7620
7620
|
|
|
7621
7621
|
//#endregion
|
|
@@ -8937,13 +8937,13 @@ var require_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
8937
8937
|
|
|
8938
8938
|
//#endregion
|
|
8939
8939
|
//#region src/behaviors/Destroyable.ts
|
|
8940
|
-
var import_cjs$
|
|
8940
|
+
var import_cjs$28 = require_cjs();
|
|
8941
8941
|
var Destroyable = class {
|
|
8942
8942
|
constructor() {
|
|
8943
8943
|
this.subscriptions = [];
|
|
8944
8944
|
this.subjects = [];
|
|
8945
|
-
this._destroyed$ = new import_cjs$
|
|
8946
|
-
this._change$ = new import_cjs$
|
|
8945
|
+
this._destroyed$ = new import_cjs$28.Subject();
|
|
8946
|
+
this._change$ = new import_cjs$28.Subject();
|
|
8947
8947
|
}
|
|
8948
8948
|
destroy() {
|
|
8949
8949
|
this._observableCache?.clear();
|
|
@@ -8980,7 +8980,7 @@ var Destroyable = class {
|
|
|
8980
8980
|
this._observableCache ??= /* @__PURE__ */ new Map();
|
|
8981
8981
|
let cached = this._observableCache.get(publicKey);
|
|
8982
8982
|
if (!cached) {
|
|
8983
|
-
cached = factory().pipe((0, import_cjs$
|
|
8983
|
+
cached = factory().pipe((0, import_cjs$28.observeOn)(import_cjs$28.asapScheduler));
|
|
8984
8984
|
this._observableCache.set(publicKey, cached);
|
|
8985
8985
|
}
|
|
8986
8986
|
return cached;
|
|
@@ -8994,32 +8994,32 @@ var Destroyable = class {
|
|
|
8994
8994
|
* Do NOT use for observables consumed internally by the SDK.
|
|
8995
8995
|
*/
|
|
8996
8996
|
deferEmission(observable) {
|
|
8997
|
-
return observable.pipe((0, import_cjs$
|
|
8997
|
+
return observable.pipe((0, import_cjs$28.observeOn)(import_cjs$28.asapScheduler));
|
|
8998
8998
|
}
|
|
8999
8999
|
subscribeTo(observable, observerOrNext) {
|
|
9000
9000
|
const subscription = observable.subscribe(observerOrNext);
|
|
9001
9001
|
this.subscriptions.push(subscription);
|
|
9002
9002
|
}
|
|
9003
9003
|
createSubject() {
|
|
9004
|
-
const subject = new import_cjs$
|
|
9004
|
+
const subject = new import_cjs$28.Subject();
|
|
9005
9005
|
this.subjects.push(subject);
|
|
9006
|
-
this.subscriptions.push(subject.pipe((0, import_cjs$
|
|
9006
|
+
this.subscriptions.push(subject.pipe((0, import_cjs$28.map)(() => void 0)).subscribe(this._change$));
|
|
9007
9007
|
return subject;
|
|
9008
9008
|
}
|
|
9009
9009
|
createReplaySubject(bufferSize, windowTime$1) {
|
|
9010
|
-
const subject = new import_cjs$
|
|
9010
|
+
const subject = new import_cjs$28.ReplaySubject(bufferSize, windowTime$1);
|
|
9011
9011
|
this.subjects.push(subject);
|
|
9012
|
-
this.subscriptions.push(subject.pipe((0, import_cjs$
|
|
9012
|
+
this.subscriptions.push(subject.pipe((0, import_cjs$28.map)(() => void 0)).subscribe(this._change$));
|
|
9013
9013
|
return subject;
|
|
9014
9014
|
}
|
|
9015
9015
|
createBehaviorSubject(initialValue) {
|
|
9016
|
-
const subject = new import_cjs$
|
|
9016
|
+
const subject = new import_cjs$28.BehaviorSubject(initialValue);
|
|
9017
9017
|
this.subjects.push(subject);
|
|
9018
|
-
this.subscriptions.push(subject.pipe((0, import_cjs$
|
|
9018
|
+
this.subscriptions.push(subject.pipe((0, import_cjs$28.skip)(1), (0, import_cjs$28.map)(() => void 0)).subscribe(this._change$));
|
|
9019
9019
|
return subject;
|
|
9020
9020
|
}
|
|
9021
9021
|
get $() {
|
|
9022
|
-
return this._change$.pipe((0, import_cjs$
|
|
9022
|
+
return this._change$.pipe((0, import_cjs$28.map)(() => this));
|
|
9023
9023
|
}
|
|
9024
9024
|
/**
|
|
9025
9025
|
* Observable that emits when the instance is destroyed
|
|
@@ -9478,9 +9478,9 @@ var require_loglevel = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9478
9478
|
defaultLogger$1 = new Logger();
|
|
9479
9479
|
defaultLogger$1.getLogger = function getLogger$1(name) {
|
|
9480
9480
|
if (typeof name !== "symbol" && typeof name !== "string" || name === "") throw new TypeError("You must supply a name when creating a logger.");
|
|
9481
|
-
var logger$
|
|
9482
|
-
if (!logger$
|
|
9483
|
-
return logger$
|
|
9481
|
+
var logger$30 = _loggersByName[name];
|
|
9482
|
+
if (!logger$30) logger$30 = _loggersByName[name] = new Logger(name, defaultLogger$1.methodFactory);
|
|
9483
|
+
return logger$30;
|
|
9484
9484
|
};
|
|
9485
9485
|
var _log = typeof window !== undefinedType ? window.log : void 0;
|
|
9486
9486
|
defaultLogger$1.noConflict = function() {
|
|
@@ -9520,15 +9520,15 @@ const shouldStringify = (payload) => {
|
|
|
9520
9520
|
return true;
|
|
9521
9521
|
};
|
|
9522
9522
|
const wsTraffic = ({ type, payload }) => {
|
|
9523
|
-
const logger$
|
|
9523
|
+
const logger$30 = getLoggerInstance();
|
|
9524
9524
|
const { logWsTraffic } = debugOptions ?? {};
|
|
9525
9525
|
if (!logWsTraffic) return;
|
|
9526
9526
|
const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;
|
|
9527
|
-
return logger$
|
|
9527
|
+
return logger$30.debug(`${type.toUpperCase()}: \n`, msg, "\n");
|
|
9528
9528
|
};
|
|
9529
9529
|
const getLogger = () => {
|
|
9530
|
-
const logger$
|
|
9531
|
-
return new Proxy(logger$
|
|
9530
|
+
const logger$30 = getLoggerInstance();
|
|
9531
|
+
return new Proxy(logger$30, { get(target, prop, receiver) {
|
|
9532
9532
|
if (prop === "wsTraffic") return wsTraffic;
|
|
9533
9533
|
return Reflect.get(target, prop, receiver);
|
|
9534
9534
|
} });
|
|
@@ -9577,8 +9577,8 @@ const asyncRetry = async ({ asyncCallable, maxRetries: retries = DEFAULT_MAX_RET
|
|
|
9577
9577
|
|
|
9578
9578
|
//#endregion
|
|
9579
9579
|
//#region src/controllers/HTTPRequestController.ts
|
|
9580
|
-
var import_cjs$
|
|
9581
|
-
const logger$
|
|
9580
|
+
var import_cjs$27 = require_cjs();
|
|
9581
|
+
const logger$29 = getLogger();
|
|
9582
9582
|
const GET_PARAMS = {
|
|
9583
9583
|
method: "GET",
|
|
9584
9584
|
headers: { Accept: "application/json" }
|
|
@@ -9613,9 +9613,9 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9613
9613
|
constructor(baseURL, getCredential, options = {}) {
|
|
9614
9614
|
this.baseURL = baseURL;
|
|
9615
9615
|
this.getCredential = getCredential;
|
|
9616
|
-
this._responses$ = new import_cjs$
|
|
9617
|
-
this._errors$ = new import_cjs$
|
|
9618
|
-
this._status$ = new import_cjs$
|
|
9616
|
+
this._responses$ = new import_cjs$27.Subject();
|
|
9617
|
+
this._errors$ = new import_cjs$27.Subject();
|
|
9618
|
+
this._status$ = new import_cjs$27.BehaviorSubject("idle");
|
|
9619
9619
|
this.maxRetries = options.maxRetries ?? HTTPRequestController.defaultMaxRetries;
|
|
9620
9620
|
this.retryDelayMin = options.retryDelayMin ?? HTTPRequestController.defaultRetryDelayMinMs;
|
|
9621
9621
|
this.retryDelayMax = options.retryDelayMax ?? HTTPRequestController.defaultRetryDelayMaxMs;
|
|
@@ -9641,7 +9641,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9641
9641
|
this._responses$.next(response);
|
|
9642
9642
|
return response;
|
|
9643
9643
|
} catch (error) {
|
|
9644
|
-
logger$
|
|
9644
|
+
logger$29.error("[HTTPRequestController] Request error:", error);
|
|
9645
9645
|
this._status$.next("error");
|
|
9646
9646
|
const err = error instanceof Error ? error : new Error("HTTP request failed", { cause: error });
|
|
9647
9647
|
this._errors$.next(err);
|
|
@@ -9668,7 +9668,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9668
9668
|
const url = this.buildURL(request.url);
|
|
9669
9669
|
const headers = this.buildHeaders(request.headers);
|
|
9670
9670
|
const timeout$5 = request.timeout ?? this.requestTimeout;
|
|
9671
|
-
logger$
|
|
9671
|
+
logger$29.debug("[HTTPRequestController] Executing request:", {
|
|
9672
9672
|
method: request.method,
|
|
9673
9673
|
url,
|
|
9674
9674
|
headers: Object.keys(headers).reduce((acc, key) => {
|
|
@@ -9688,7 +9688,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9688
9688
|
});
|
|
9689
9689
|
clearTimeout(timeoutId);
|
|
9690
9690
|
const httpResponse = await this.convertResponse(response);
|
|
9691
|
-
logger$
|
|
9691
|
+
logger$29.debug("[HTTPRequestController] Response received:", {
|
|
9692
9692
|
status: response.status,
|
|
9693
9693
|
statusText: response.statusText,
|
|
9694
9694
|
headers: [...response.headers.entries()],
|
|
@@ -9698,7 +9698,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9698
9698
|
} catch (error) {
|
|
9699
9699
|
clearTimeout(timeoutId);
|
|
9700
9700
|
if (error instanceof Error && error.name === "AbortError") throw new RequestTimeoutError(`Request timeout after ${timeout$5}ms`, { cause: error });
|
|
9701
|
-
logger$
|
|
9701
|
+
logger$29.error("[HTTPRequestController] Request failed:", error);
|
|
9702
9702
|
throw error;
|
|
9703
9703
|
}
|
|
9704
9704
|
}
|
|
@@ -9712,8 +9712,8 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
9712
9712
|
const credential = this.getCredential();
|
|
9713
9713
|
if (credential.token) {
|
|
9714
9714
|
headers.Authorization = `Bearer ${credential.token}`;
|
|
9715
|
-
logger$
|
|
9716
|
-
} else logger$
|
|
9715
|
+
logger$29.debug("[HTTPRequestController] Using Bearer token auth, token length:", credential.token.length);
|
|
9716
|
+
} else logger$29.warn("[HTTPRequestController] No credentials available for authentication");
|
|
9717
9717
|
return headers;
|
|
9718
9718
|
}
|
|
9719
9719
|
/**
|
|
@@ -9862,6 +9862,19 @@ const DEFAULT_RECONNECT_DELAY_MAX_MS = 3e3;
|
|
|
9862
9862
|
const DEFAULT_DEVICE_DEBOUNCE_TIME_MS = 1500;
|
|
9863
9863
|
const DEFAULT_DEVICE_POLLING_INTERVAL_MS = 0;
|
|
9864
9864
|
const PREFERENCES_STORAGE_KEY = "sw:preferences";
|
|
9865
|
+
/** Scope value that enables automatic token refresh. */
|
|
9866
|
+
const SAT_REFRESH_SCOPE = "sat:refresh";
|
|
9867
|
+
/** API endpoints for device token operations. */
|
|
9868
|
+
const DEVICE_TOKEN_ENDPOINT = "/api/fabric/subscriber/devices/token";
|
|
9869
|
+
const DEVICE_REFRESH_ENDPOINT = "/api/fabric/subscriber/devices/refresh";
|
|
9870
|
+
/** Default device token TTL in seconds (15 minutes). */
|
|
9871
|
+
const DEVICE_TOKEN_DEFAULT_EXPIRE_IN = 900;
|
|
9872
|
+
/** Buffer time in milliseconds before expiry to trigger refresh. */
|
|
9873
|
+
const DEVICE_TOKEN_REFRESH_BUFFER_MS = 3e4;
|
|
9874
|
+
/** Maximum retry attempts for device token refresh on transient failure. */
|
|
9875
|
+
const DEVICE_TOKEN_REFRESH_MAX_RETRIES = 3;
|
|
9876
|
+
/** Base delay in milliseconds for exponential backoff on refresh retry. */
|
|
9877
|
+
const DEVICE_TOKEN_REFRESH_RETRY_BASE_MS = 1e3;
|
|
9865
9878
|
/** JSON-RPC error code for requester validation failure (corrupted auth state). */
|
|
9866
9879
|
const RPC_ERROR_REQUESTER_VALIDATION_FAILED = -32003;
|
|
9867
9880
|
/** JSON-RPC error code for invalid params (e.g., missing authentication block). */
|
|
@@ -9952,7 +9965,7 @@ function fromMsToSec(milliseconds) {
|
|
|
9952
9965
|
|
|
9953
9966
|
//#endregion
|
|
9954
9967
|
//#region src/containers/PreferencesContainer.ts
|
|
9955
|
-
const logger$
|
|
9968
|
+
const logger$28 = getLogger();
|
|
9956
9969
|
var PreferencesContainer = class PreferencesContainer {
|
|
9957
9970
|
static get instance() {
|
|
9958
9971
|
this._instance ??= new PreferencesContainer();
|
|
@@ -10614,7 +10627,7 @@ var ClientPreferences = class {
|
|
|
10614
10627
|
if (!this._storage) return;
|
|
10615
10628
|
const data = collectStoredPreferences();
|
|
10616
10629
|
this._storage.setItem(PREFERENCES_STORAGE_KEY, data, "local").catch((error) => {
|
|
10617
|
-
logger$
|
|
10630
|
+
logger$28.error(`[ClientPreferences] Failed to save preferences: ${String(error)}`);
|
|
10618
10631
|
});
|
|
10619
10632
|
}
|
|
10620
10633
|
/** Loads preferences from storage and applies them to the container. */
|
|
@@ -10623,15 +10636,15 @@ var ClientPreferences = class {
|
|
|
10623
10636
|
this._storage.getItem(PREFERENCES_STORAGE_KEY, "local").then((stored) => {
|
|
10624
10637
|
if (stored) applyStoredPreferences(stored);
|
|
10625
10638
|
}).catch((error) => {
|
|
10626
|
-
logger$
|
|
10639
|
+
logger$28.error(`[ClientPreferences] Failed to load preferences: ${String(error)}`);
|
|
10627
10640
|
});
|
|
10628
10641
|
}
|
|
10629
10642
|
};
|
|
10630
10643
|
|
|
10631
10644
|
//#endregion
|
|
10632
10645
|
//#region src/controllers/NavigatorDeviceController.ts
|
|
10633
|
-
var import_cjs$
|
|
10634
|
-
const logger$
|
|
10646
|
+
var import_cjs$26 = require_cjs();
|
|
10647
|
+
const logger$27 = getLogger();
|
|
10635
10648
|
/** Maps a device kind to its storage key. */
|
|
10636
10649
|
const DEVICE_STORAGE_KEYS = {
|
|
10637
10650
|
audioinput: DEVICE_STORAGE_KEY_AUDIO_INPUT,
|
|
@@ -10653,7 +10666,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10653
10666
|
super();
|
|
10654
10667
|
this.webRTCApiProvider = webRTCApiProvider;
|
|
10655
10668
|
this.deviceChangeHandler = () => {
|
|
10656
|
-
logger$
|
|
10669
|
+
logger$27.debug("[DeviceController] Device change detected");
|
|
10657
10670
|
this.enumerateDevices();
|
|
10658
10671
|
};
|
|
10659
10672
|
this._devicesState$ = this.createBehaviorSubject(initialDevicesState);
|
|
@@ -10690,17 +10703,17 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10690
10703
|
return {};
|
|
10691
10704
|
}
|
|
10692
10705
|
get errors$() {
|
|
10693
|
-
return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$
|
|
10706
|
+
return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10694
10707
|
}
|
|
10695
10708
|
/** Observable that emits when the SDK auto-switches a device. */
|
|
10696
10709
|
get deviceRecovered$() {
|
|
10697
|
-
return this._deviceRecovered$.asObservable().pipe((0, import_cjs$
|
|
10710
|
+
return this._deviceRecovered$.asObservable().pipe((0, import_cjs$26.takeUntil)(this.destroyed$));
|
|
10698
10711
|
}
|
|
10699
10712
|
get videoInputDisabled$() {
|
|
10700
|
-
return this.cachedObservable("videoInputDisabled$", () => this._videoInputDisabled$.asObservable().pipe((0, import_cjs$
|
|
10713
|
+
return this.cachedObservable("videoInputDisabled$", () => this._videoInputDisabled$.asObservable().pipe((0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10701
10714
|
}
|
|
10702
10715
|
get audioInputDisabled$() {
|
|
10703
|
-
return this.cachedObservable("audioInputDisabled$", () => this._audioInputDisabled$.asObservable().pipe((0, import_cjs$
|
|
10716
|
+
return this.cachedObservable("audioInputDisabled$", () => this._audioInputDisabled$.asObservable().pipe((0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10704
10717
|
}
|
|
10705
10718
|
get videoInputDisabled() {
|
|
10706
10719
|
return this._videoInputDisabled$.value;
|
|
@@ -10709,22 +10722,22 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10709
10722
|
return this._audioInputDisabled$.value;
|
|
10710
10723
|
}
|
|
10711
10724
|
get audioInputDevices$() {
|
|
10712
|
-
return this.cachedObservable("audioInputDevices$", () => this._devicesState$.pipe((0, import_cjs$
|
|
10725
|
+
return this.cachedObservable("audioInputDevices$", () => this._devicesState$.pipe((0, import_cjs$26.map)((state) => state.audioinput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10713
10726
|
}
|
|
10714
10727
|
get audioOutputDevices$() {
|
|
10715
|
-
return this.cachedObservable("audioOutputDevices$", () => this._devicesState$.pipe((0, import_cjs$
|
|
10728
|
+
return this.cachedObservable("audioOutputDevices$", () => this._devicesState$.pipe((0, import_cjs$26.map)((state) => state.audiooutput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10716
10729
|
}
|
|
10717
10730
|
get videoInputDevices$() {
|
|
10718
|
-
return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, import_cjs$
|
|
10731
|
+
return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, import_cjs$26.map)((state) => state.videoinput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$)));
|
|
10719
10732
|
}
|
|
10720
10733
|
get selectedAudioInputDevice$() {
|
|
10721
|
-
return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$
|
|
10734
|
+
return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$26.map)((state) => state.audioinput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$), (0, import_cjs$26.tap)((info) => logger$27.debug("[DeviceController] Selected audio input device changed:", info))));
|
|
10722
10735
|
}
|
|
10723
10736
|
get selectedAudioOutputDevice$() {
|
|
10724
|
-
return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$
|
|
10737
|
+
return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$26.map)((state) => state.audiooutput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$), (0, import_cjs$26.tap)((info) => logger$27.debug("[DeviceController] Selected audio output device changed:", info))));
|
|
10725
10738
|
}
|
|
10726
10739
|
get selectedVideoInputDevice$() {
|
|
10727
|
-
return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$
|
|
10740
|
+
return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$26.map)((state) => state.videoinput), (0, import_cjs$26.distinctUntilChanged)(), (0, import_cjs$26.takeUntil)(this.destroyed$), (0, import_cjs$26.tap)((info) => logger$27.debug("[DeviceController] Selected video input device changed:", info))));
|
|
10728
10741
|
}
|
|
10729
10742
|
get selectedAudioInputDevice() {
|
|
10730
10743
|
if (this._audioInputDisabled$.value) return null;
|
|
@@ -10799,7 +10812,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10799
10812
|
if (device) this.persistDeviceSelection("audioinput", device);
|
|
10800
10813
|
}
|
|
10801
10814
|
selectVideoInputDevice(device) {
|
|
10802
|
-
logger$
|
|
10815
|
+
logger$27.debug("[DeviceController] Setting selected video input device:", device);
|
|
10803
10816
|
if (this._videoInputDisabled$.value && device) this._videoInputDisabled$.next(false);
|
|
10804
10817
|
const previous = this._selectedDevicesState$.value.videoinput;
|
|
10805
10818
|
if (previous && previous.deviceId !== device?.deviceId) this._deviceHistory.push("videoinput", previous);
|
|
@@ -10820,7 +10833,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10820
10833
|
}
|
|
10821
10834
|
init() {
|
|
10822
10835
|
this.loadPersistedDevices();
|
|
10823
|
-
this.subscribeTo(this._devicesState$.pipe((0, import_cjs$
|
|
10836
|
+
this.subscribeTo(this._devicesState$.pipe((0, import_cjs$26.debounceTime)(PreferencesContainer.instance.deviceDebounceTime)), (devicesState) => {
|
|
10824
10837
|
const currentSelected = this._selectedDevicesState$.value;
|
|
10825
10838
|
const newAudioInput = this._audioInputDisabled$.value ? null : this.resolveDevice("audioinput", devicesState.audioinput, currentSelected.audioinput, PreferencesContainer.instance.preferredAudioInput);
|
|
10826
10839
|
const newAudioOutput = this.resolveDevice("audiooutput", devicesState.audiooutput, currentSelected.audiooutput, PreferencesContainer.instance.preferredAudioOutput);
|
|
@@ -10856,7 +10869,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10856
10869
|
}
|
|
10857
10870
|
const fromHistory = this._deviceHistory.findInHistory(kind, devices);
|
|
10858
10871
|
if (fromHistory) {
|
|
10859
|
-
logger$
|
|
10872
|
+
logger$27.debug(`[DeviceController] Device disappeared, falling back to history: ${fromHistory.label}`);
|
|
10860
10873
|
this.emitDeviceRecovered(kind, selected, fromHistory, "device_disconnected");
|
|
10861
10874
|
return fromHistory;
|
|
10862
10875
|
}
|
|
@@ -10909,7 +10922,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10909
10922
|
try {
|
|
10910
10923
|
await this._storageManager.setItem(DEVICE_STORAGE_KEYS[kind], stored, "local");
|
|
10911
10924
|
} catch (error) {
|
|
10912
|
-
logger$
|
|
10925
|
+
logger$27.error(`[DeviceController] Failed to persist device selection for ${kind}:`, error);
|
|
10913
10926
|
}
|
|
10914
10927
|
}
|
|
10915
10928
|
async loadPersistedDevices() {
|
|
@@ -10925,7 +10938,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10925
10938
|
[kind]: stored
|
|
10926
10939
|
};
|
|
10927
10940
|
} catch (error) {
|
|
10928
|
-
logger$
|
|
10941
|
+
logger$27.error(`[DeviceController] Failed to load persisted device for ${kind}:`, error);
|
|
10929
10942
|
}
|
|
10930
10943
|
}
|
|
10931
10944
|
/** Clears device history, persisted selections, and re-enumerates devices. */
|
|
@@ -10942,8 +10955,8 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10942
10955
|
enableDeviceMonitoring() {
|
|
10943
10956
|
this.disableDeviceMonitoring();
|
|
10944
10957
|
this.webRTCApiProvider.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
|
|
10945
|
-
if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, import_cjs$
|
|
10946
|
-
logger$
|
|
10958
|
+
if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, import_cjs$26.interval)(PreferencesContainer.instance.devicePollingInterval).subscribe(() => {
|
|
10959
|
+
logger$27.debug("[DeviceController] Polling devices due to interval");
|
|
10947
10960
|
this.enumerateDevices();
|
|
10948
10961
|
});
|
|
10949
10962
|
this.enumerateDevices();
|
|
@@ -10969,13 +10982,13 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10969
10982
|
videoinput: []
|
|
10970
10983
|
});
|
|
10971
10984
|
this._devicesState$.next(devicesByKind);
|
|
10972
|
-
logger$
|
|
10985
|
+
logger$27.debug("[DeviceController] Devices enumerated:", {
|
|
10973
10986
|
audioInputs: devicesByKind.audioinput.length,
|
|
10974
10987
|
audioOutputs: devicesByKind.audiooutput.length,
|
|
10975
10988
|
videoInputs: devicesByKind.videoinput.length
|
|
10976
10989
|
});
|
|
10977
10990
|
} catch (error) {
|
|
10978
|
-
logger$
|
|
10991
|
+
logger$27.error("[DeviceController] Failed to enumerate devices:", error);
|
|
10979
10992
|
this._errors$.next(error);
|
|
10980
10993
|
}
|
|
10981
10994
|
}
|
|
@@ -10991,7 +11004,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
10991
11004
|
stream.getTracks().forEach((t) => t.stop());
|
|
10992
11005
|
return capabilities;
|
|
10993
11006
|
} catch (error) {
|
|
10994
|
-
logger$
|
|
11007
|
+
logger$27.error("[DeviceController] Failed to get device capabilities:", error);
|
|
10995
11008
|
this._errors$.next(error);
|
|
10996
11009
|
throw error;
|
|
10997
11010
|
}
|
|
@@ -11242,7 +11255,7 @@ var DependencyContainer = class {
|
|
|
11242
11255
|
|
|
11243
11256
|
//#endregion
|
|
11244
11257
|
//#region src/controllers/CryptoController.ts
|
|
11245
|
-
const logger$
|
|
11258
|
+
const logger$26 = getLogger();
|
|
11246
11259
|
const DPOP_DB_NAME = "sw-dpop";
|
|
11247
11260
|
const DPOP_DB_VERSION = 1;
|
|
11248
11261
|
const DPOP_STORE_NAME = "keys";
|
|
@@ -11301,7 +11314,7 @@ async function loadKeyPairFromDB() {
|
|
|
11301
11314
|
tx.oncomplete = () => db.close();
|
|
11302
11315
|
});
|
|
11303
11316
|
} catch (error) {
|
|
11304
|
-
logger$
|
|
11317
|
+
logger$26.warn("[DPoP] Failed to load key pair from IndexedDB:", error);
|
|
11305
11318
|
return null;
|
|
11306
11319
|
}
|
|
11307
11320
|
}
|
|
@@ -11321,7 +11334,7 @@ async function saveKeyPairToDB(keyPair) {
|
|
|
11321
11334
|
};
|
|
11322
11335
|
});
|
|
11323
11336
|
} catch (error) {
|
|
11324
|
-
logger$
|
|
11337
|
+
logger$26.warn("[DPoP] Failed to save key pair to IndexedDB:", error);
|
|
11325
11338
|
}
|
|
11326
11339
|
}
|
|
11327
11340
|
async function deleteKeyPairFromDB() {
|
|
@@ -11340,7 +11353,7 @@ async function deleteKeyPairFromDB() {
|
|
|
11340
11353
|
};
|
|
11341
11354
|
});
|
|
11342
11355
|
} catch (error) {
|
|
11343
|
-
logger$
|
|
11356
|
+
logger$26.warn("[DPoP] Failed to delete key pair from IndexedDB:", error);
|
|
11344
11357
|
}
|
|
11345
11358
|
}
|
|
11346
11359
|
/**
|
|
@@ -11400,13 +11413,13 @@ var CryptoController = class {
|
|
|
11400
11413
|
this._publicJwk = await crypto.subtle.exportKey("jwk", stored.publicKey);
|
|
11401
11414
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
11402
11415
|
this._initialized = true;
|
|
11403
|
-
logger$
|
|
11416
|
+
logger$26.debug("[DPoP] Key pair restored from IndexedDB, fingerprint:", this._fingerprint);
|
|
11404
11417
|
return this._fingerprint;
|
|
11405
11418
|
} catch (error) {
|
|
11406
|
-
logger$
|
|
11419
|
+
logger$26.warn("[DPoP] Stored key pair unusable, generating new one:", error);
|
|
11407
11420
|
await deleteKeyPairFromDB();
|
|
11408
11421
|
}
|
|
11409
|
-
logger$
|
|
11422
|
+
logger$26.debug("[DPoP] Generating RSA key pair");
|
|
11410
11423
|
this._keyPair = await crypto.subtle.generateKey({
|
|
11411
11424
|
name: "RSASSA-PKCS1-v1_5",
|
|
11412
11425
|
modulusLength: 2048,
|
|
@@ -11421,7 +11434,7 @@ var CryptoController = class {
|
|
|
11421
11434
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
11422
11435
|
this._initialized = true;
|
|
11423
11436
|
await saveKeyPairToDB(this._keyPair);
|
|
11424
|
-
logger$
|
|
11437
|
+
logger$26.debug("[DPoP] Key pair generated and persisted, fingerprint:", this._fingerprint);
|
|
11425
11438
|
return this._fingerprint;
|
|
11426
11439
|
}
|
|
11427
11440
|
/**
|
|
@@ -11487,7 +11500,7 @@ var CryptoController = class {
|
|
|
11487
11500
|
this._fingerprint = null;
|
|
11488
11501
|
this._initialized = false;
|
|
11489
11502
|
deleteKeyPairFromDB();
|
|
11490
|
-
logger$
|
|
11503
|
+
logger$26.debug("[DPoP] Controller destroyed");
|
|
11491
11504
|
}
|
|
11492
11505
|
get publicJwk() {
|
|
11493
11506
|
if (!this._publicJwk) throw new DPoPInitError("CryptoController not initialized. Call init() first.");
|
|
@@ -11510,8 +11523,8 @@ var CryptoController = class {
|
|
|
11510
11523
|
|
|
11511
11524
|
//#endregion
|
|
11512
11525
|
//#region src/controllers/NetworkMonitor.ts
|
|
11513
|
-
var import_cjs$
|
|
11514
|
-
const logger$
|
|
11526
|
+
var import_cjs$25 = require_cjs();
|
|
11527
|
+
const logger$25 = getLogger();
|
|
11515
11528
|
/**
|
|
11516
11529
|
* Safely check whether we are running in a browser environment
|
|
11517
11530
|
* with `window` and the relevant event targets.
|
|
@@ -11554,13 +11567,13 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11554
11567
|
this.attachListeners();
|
|
11555
11568
|
}
|
|
11556
11569
|
get isOnline$() {
|
|
11557
|
-
return this._isOnline$.asObservable().pipe((0, import_cjs$
|
|
11570
|
+
return this._isOnline$.asObservable().pipe((0, import_cjs$25.takeUntil)(this._destroyed$));
|
|
11558
11571
|
}
|
|
11559
11572
|
get isOnline() {
|
|
11560
11573
|
return this._isOnline$.value;
|
|
11561
11574
|
}
|
|
11562
11575
|
get networkChange$() {
|
|
11563
|
-
return this._networkChange$.asObservable().pipe((0, import_cjs$
|
|
11576
|
+
return this._networkChange$.asObservable().pipe((0, import_cjs$25.takeUntil)(this._destroyed$));
|
|
11564
11577
|
}
|
|
11565
11578
|
destroy() {
|
|
11566
11579
|
this.removeListeners();
|
|
@@ -11568,7 +11581,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11568
11581
|
}
|
|
11569
11582
|
attachListeners() {
|
|
11570
11583
|
if (!hasBrowserNetworkEvents()) {
|
|
11571
|
-
logger$
|
|
11584
|
+
logger$25.debug("NetworkMonitor: no browser environment detected, skipping event listeners");
|
|
11572
11585
|
return;
|
|
11573
11586
|
}
|
|
11574
11587
|
window.addEventListener("online", this._onOnline);
|
|
@@ -11576,7 +11589,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11576
11589
|
const connection = getNetworkConnection();
|
|
11577
11590
|
if (connection) connection.addEventListener("change", this._onConnectionChange);
|
|
11578
11591
|
this._listenersAttached = true;
|
|
11579
|
-
logger$
|
|
11592
|
+
logger$25.debug("NetworkMonitor: event listeners attached");
|
|
11580
11593
|
}
|
|
11581
11594
|
removeListeners() {
|
|
11582
11595
|
if (!this._listenersAttached) return;
|
|
@@ -11587,10 +11600,10 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11587
11600
|
if (connection) connection.removeEventListener("change", this._onConnectionChange);
|
|
11588
11601
|
}
|
|
11589
11602
|
this._listenersAttached = false;
|
|
11590
|
-
logger$
|
|
11603
|
+
logger$25.debug("NetworkMonitor: event listeners removed");
|
|
11591
11604
|
}
|
|
11592
11605
|
handleOnline() {
|
|
11593
|
-
logger$
|
|
11606
|
+
logger$25.info("NetworkMonitor: browser went online");
|
|
11594
11607
|
this._isOnline$.next(true);
|
|
11595
11608
|
this._networkChange$.next({
|
|
11596
11609
|
type: "online",
|
|
@@ -11599,7 +11612,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11599
11612
|
});
|
|
11600
11613
|
}
|
|
11601
11614
|
handleOffline() {
|
|
11602
|
-
logger$
|
|
11615
|
+
logger$25.info("NetworkMonitor: browser went offline");
|
|
11603
11616
|
this._isOnline$.next(false);
|
|
11604
11617
|
this._networkChange$.next({
|
|
11605
11618
|
type: "offline",
|
|
@@ -11608,7 +11621,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
11608
11621
|
}
|
|
11609
11622
|
handleConnectionChange() {
|
|
11610
11623
|
const networkType = getNetworkType();
|
|
11611
|
-
logger$
|
|
11624
|
+
logger$25.info(`NetworkMonitor: connection changed — effectiveType=${networkType ?? "unknown"}`);
|
|
11612
11625
|
this._networkChange$.next({
|
|
11613
11626
|
type: "connection_change",
|
|
11614
11627
|
timestamp: Date.now(),
|
|
@@ -11723,8 +11736,8 @@ function getNavigatorMediaDevices() {
|
|
|
11723
11736
|
|
|
11724
11737
|
//#endregion
|
|
11725
11738
|
//#region src/controllers/PreflightRunner.ts
|
|
11726
|
-
var import_cjs$
|
|
11727
|
-
const logger$
|
|
11739
|
+
var import_cjs$24 = require_cjs();
|
|
11740
|
+
const logger$24 = getLogger();
|
|
11728
11741
|
const DEFAULT_MEDIA_TEST_DURATION_S = 10;
|
|
11729
11742
|
const ICE_GATHERING_TIMEOUT_MS = 1e4;
|
|
11730
11743
|
const SIGNALING_RTT_TIMEOUT_MS = 5e3;
|
|
@@ -11773,7 +11786,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11773
11786
|
if (!this._options.skipMediaTest) try {
|
|
11774
11787
|
bandwidth = await this.testMediaBandwidth(destination);
|
|
11775
11788
|
} catch (error) {
|
|
11776
|
-
logger$
|
|
11789
|
+
logger$24.warn("[PreflightRunner] Media bandwidth test failed:", error);
|
|
11777
11790
|
warnings.push("Media bandwidth test failed");
|
|
11778
11791
|
}
|
|
11779
11792
|
return {
|
|
@@ -11785,7 +11798,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11785
11798
|
warnings
|
|
11786
11799
|
};
|
|
11787
11800
|
} catch (error) {
|
|
11788
|
-
logger$
|
|
11801
|
+
logger$24.error("[PreflightRunner] Preflight test failed:", error);
|
|
11789
11802
|
throw new PreflightError("preflight", error instanceof Error ? error : new Error(String(error)));
|
|
11790
11803
|
} finally {
|
|
11791
11804
|
this.destroy();
|
|
@@ -11816,7 +11829,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11816
11829
|
if (track.kind === "video" && track.readyState === "live") videoWorking = true;
|
|
11817
11830
|
}
|
|
11818
11831
|
} catch (error) {
|
|
11819
|
-
logger$
|
|
11832
|
+
logger$24.warn("[PreflightRunner] Device test failed:", error);
|
|
11820
11833
|
} finally {
|
|
11821
11834
|
if (audioStream) audioStream.getTracks().forEach((t) => t.stop());
|
|
11822
11835
|
}
|
|
@@ -11839,18 +11852,19 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11839
11852
|
let pc;
|
|
11840
11853
|
try {
|
|
11841
11854
|
pc = new RTCPeerConnection({ iceServers: this.iceServers });
|
|
11855
|
+
const peerConnection = pc;
|
|
11842
11856
|
const candidateTypes = /* @__PURE__ */ new Set();
|
|
11843
11857
|
const startTime = Date.now();
|
|
11844
11858
|
const gatheringComplete = new Promise((resolve) => {
|
|
11845
|
-
const timer$
|
|
11846
|
-
|
|
11859
|
+
const timer$3 = setTimeout(resolve, ICE_GATHERING_TIMEOUT_MS);
|
|
11860
|
+
peerConnection.onicecandidate = (event) => {
|
|
11847
11861
|
if (event.candidate) {
|
|
11848
11862
|
const candidateStr = event.candidate.candidate;
|
|
11849
11863
|
if (candidateStr.includes("typ host")) candidateTypes.add("host");
|
|
11850
11864
|
if (candidateStr.includes("typ srflx")) candidateTypes.add("srflx");
|
|
11851
11865
|
if (candidateStr.includes("typ relay")) candidateTypes.add("relay");
|
|
11852
11866
|
} else {
|
|
11853
|
-
clearTimeout(timer$
|
|
11867
|
+
clearTimeout(timer$3);
|
|
11854
11868
|
resolve();
|
|
11855
11869
|
}
|
|
11856
11870
|
};
|
|
@@ -11873,7 +11887,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11873
11887
|
rttMs
|
|
11874
11888
|
};
|
|
11875
11889
|
} catch (error) {
|
|
11876
|
-
logger$
|
|
11890
|
+
logger$24.warn("[PreflightRunner] ICE connectivity test failed:", error);
|
|
11877
11891
|
return {
|
|
11878
11892
|
type: "failed",
|
|
11879
11893
|
turnReachable: false,
|
|
@@ -11891,7 +11905,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11891
11905
|
audio: true,
|
|
11892
11906
|
video: false
|
|
11893
11907
|
});
|
|
11894
|
-
await (0, import_cjs$
|
|
11908
|
+
await (0, import_cjs$24.firstValueFrom)(call.status$.pipe((0, import_cjs$24.filter)((s) => s === "connected"), (0, import_cjs$24.take)(1), (0, import_cjs$24.timeout)(SIGNALING_RTT_TIMEOUT_MS)));
|
|
11895
11909
|
const durationMs = this._options.duration * 1e3;
|
|
11896
11910
|
await new Promise((resolve) => setTimeout(resolve, durationMs));
|
|
11897
11911
|
const metrics = call.networkMetrics;
|
|
@@ -11920,8 +11934,8 @@ var PreflightRunner = class extends Destroyable {
|
|
|
11920
11934
|
|
|
11921
11935
|
//#endregion
|
|
11922
11936
|
//#region src/controllers/VisibilityController.ts
|
|
11923
|
-
var import_cjs$
|
|
11924
|
-
const logger$
|
|
11937
|
+
var import_cjs$23 = require_cjs();
|
|
11938
|
+
const logger$23 = getLogger();
|
|
11925
11939
|
/**
|
|
11926
11940
|
* Checks whether the document visibility API is available.
|
|
11927
11941
|
*/
|
|
@@ -11958,15 +11972,15 @@ var VisibilityController = class extends Destroyable {
|
|
|
11958
11972
|
this._boundHandler = this._handleVisibilityChange.bind(this);
|
|
11959
11973
|
if (this._hasVisibilityApi) {
|
|
11960
11974
|
document.addEventListener("visibilitychange", this._boundHandler);
|
|
11961
|
-
logger$
|
|
11962
|
-
} else logger$
|
|
11975
|
+
logger$23.debug("VisibilityController: listening for visibilitychange events");
|
|
11976
|
+
} else logger$23.debug("VisibilityController: document visibility API not available, defaulting to visible");
|
|
11963
11977
|
}
|
|
11964
11978
|
/**
|
|
11965
11979
|
* Observable of the current visibility state.
|
|
11966
11980
|
* Emits 'visible' or 'hidden'. Always starts with the current state.
|
|
11967
11981
|
*/
|
|
11968
11982
|
get visibility$() {
|
|
11969
|
-
return this._visibility$.pipe((0, import_cjs$
|
|
11983
|
+
return this._visibility$.pipe((0, import_cjs$23.takeUntil)(this._destroyed$));
|
|
11970
11984
|
}
|
|
11971
11985
|
/**
|
|
11972
11986
|
* The current visibility state value.
|
|
@@ -11979,12 +11993,12 @@ var VisibilityController = class extends Destroyable {
|
|
|
11979
11993
|
* Each event includes the previous state, new state, and timestamp.
|
|
11980
11994
|
*/
|
|
11981
11995
|
get visibilityChange$() {
|
|
11982
|
-
return this._visibilityChange$.pipe((0, import_cjs$
|
|
11996
|
+
return this._visibilityChange$.pipe((0, import_cjs$23.takeUntil)(this._destroyed$));
|
|
11983
11997
|
}
|
|
11984
11998
|
destroy() {
|
|
11985
11999
|
if (this._hasVisibilityApi) {
|
|
11986
12000
|
document.removeEventListener("visibilitychange", this._boundHandler);
|
|
11987
|
-
logger$
|
|
12001
|
+
logger$23.debug("VisibilityController: removed visibilitychange listener");
|
|
11988
12002
|
}
|
|
11989
12003
|
super.destroy();
|
|
11990
12004
|
}
|
|
@@ -12002,7 +12016,7 @@ var VisibilityController = class extends Destroyable {
|
|
|
12002
12016
|
timestamp: Date.now()
|
|
12003
12017
|
};
|
|
12004
12018
|
this._visibilityChange$.next(changeEvent);
|
|
12005
|
-
logger$
|
|
12019
|
+
logger$23.debug("VisibilityController: visibility changed", {
|
|
12006
12020
|
from: previousState,
|
|
12007
12021
|
to: newState
|
|
12008
12022
|
});
|
|
@@ -12011,13 +12025,13 @@ var VisibilityController = class extends Destroyable {
|
|
|
12011
12025
|
|
|
12012
12026
|
//#endregion
|
|
12013
12027
|
//#region src/behaviors/Fetchable.ts
|
|
12014
|
-
var import_cjs$
|
|
12028
|
+
var import_cjs$22 = require_cjs();
|
|
12015
12029
|
var Fetchable = class extends Destroyable {
|
|
12016
12030
|
constructor(fromPath, http) {
|
|
12017
12031
|
super();
|
|
12018
12032
|
this.fromPath = fromPath;
|
|
12019
12033
|
this.http = http;
|
|
12020
|
-
this.fetched$ = (0, import_cjs$
|
|
12034
|
+
this.fetched$ = (0, import_cjs$22.defer)(() => (0, import_cjs$22.from)(this.fetch())).pipe((0, import_cjs$22.shareReplay)(1), (0, import_cjs$22.takeUntil)(this.destroyed$));
|
|
12021
12035
|
}
|
|
12022
12036
|
async fetch() {
|
|
12023
12037
|
const response = await this.http.request({
|
|
@@ -12252,7 +12266,7 @@ const RPCEventAckResponse = (id) => makeRPCResponse({
|
|
|
12252
12266
|
|
|
12253
12267
|
//#endregion
|
|
12254
12268
|
//#region src/managers/AttachManager.ts
|
|
12255
|
-
const logger$
|
|
12269
|
+
const logger$22 = getLogger();
|
|
12256
12270
|
var AttachManager = class {
|
|
12257
12271
|
constructor(storage, deviceController, reconnectCallsTimeout, attachKey) {
|
|
12258
12272
|
this.storage = storage;
|
|
@@ -12264,6 +12278,7 @@ var AttachManager = class {
|
|
|
12264
12278
|
const attached = await this.readAttached();
|
|
12265
12279
|
for (const callId of Object.keys(attached)) await this.detach({
|
|
12266
12280
|
id: callId,
|
|
12281
|
+
nodeId: attached[callId].nodeId,
|
|
12267
12282
|
mediaDirections: attached[callId].mediaDirections
|
|
12268
12283
|
});
|
|
12269
12284
|
}
|
|
@@ -12274,7 +12289,7 @@ var AttachManager = class {
|
|
|
12274
12289
|
try {
|
|
12275
12290
|
return await this.storage.getItem(this.attachKey) ?? {};
|
|
12276
12291
|
} catch (error) {
|
|
12277
|
-
logger$
|
|
12292
|
+
logger$22.warn("[AttachManager] Failed to retrieve attached calls from storage", error);
|
|
12278
12293
|
return {};
|
|
12279
12294
|
}
|
|
12280
12295
|
}
|
|
@@ -12282,20 +12297,20 @@ var AttachManager = class {
|
|
|
12282
12297
|
try {
|
|
12283
12298
|
await this.storage.setItem(this.attachKey, attached);
|
|
12284
12299
|
} catch (error) {
|
|
12285
|
-
logger$
|
|
12300
|
+
logger$22.warn("[AttachManager] Failed to write attached calls to storage", error);
|
|
12286
12301
|
}
|
|
12287
12302
|
}
|
|
12288
12303
|
async attach(call) {
|
|
12289
12304
|
if (!call.to) {
|
|
12290
|
-
logger$
|
|
12305
|
+
logger$22.warn("[AttachManager] Skip attach for calls with no destination");
|
|
12291
12306
|
return;
|
|
12292
12307
|
}
|
|
12293
12308
|
const attachment = {
|
|
12309
|
+
nodeId: call.nodeId,
|
|
12294
12310
|
destination: call.to,
|
|
12295
12311
|
mediaDirections: call.mediaDirections,
|
|
12296
12312
|
audioInputDevice: call.mediaDirections.audio !== "inactive" ? this.deviceController.selectedAudioInputDevice : null,
|
|
12297
12313
|
videoInputDevice: call.mediaDirections.video !== "inactive" ? this.deviceController.selectedVideoInputDevice : null,
|
|
12298
|
-
nodeId: call.nodeId,
|
|
12299
12314
|
attachedAt: Date.now()
|
|
12300
12315
|
};
|
|
12301
12316
|
const updated = {
|
|
@@ -12338,15 +12353,15 @@ var AttachManager = class {
|
|
|
12338
12353
|
callId,
|
|
12339
12354
|
...options
|
|
12340
12355
|
});
|
|
12341
|
-
logger$
|
|
12356
|
+
logger$22.info(`[AttachManager] Reattached call ${callId} (attempt ${attempt})`);
|
|
12342
12357
|
succeeded = true;
|
|
12343
12358
|
break;
|
|
12344
12359
|
} catch (error) {
|
|
12345
|
-
logger$
|
|
12360
|
+
logger$22.warn(`[AttachManager] Reattach attempt ${attempt}/3 failed for call ${callId}:`, error);
|
|
12346
12361
|
if (attempt < 3) await new Promise((r) => setTimeout(r, (attempt + 1) * 1e3));
|
|
12347
12362
|
}
|
|
12348
12363
|
if (!succeeded) {
|
|
12349
|
-
logger$
|
|
12364
|
+
logger$22.warn(`[AttachManager] Reattach failed after 3 attempts for call ${callId}, removing reference`);
|
|
12350
12365
|
await this.detach({
|
|
12351
12366
|
id: callId,
|
|
12352
12367
|
mediaDirections: attachment.mediaDirections
|
|
@@ -12360,12 +12375,13 @@ var AttachManager = class {
|
|
|
12360
12375
|
*/
|
|
12361
12376
|
buildCallOptions(attachment) {
|
|
12362
12377
|
const { audio: audioDirection, video: videoDirection } = attachment.mediaDirections;
|
|
12363
|
-
const { audioInputDevice, videoInputDevice } = attachment;
|
|
12378
|
+
const { audioInputDevice, videoInputDevice, nodeId } = attachment;
|
|
12364
12379
|
const receiveAudio = audioDirection.includes("recv");
|
|
12365
12380
|
const receiveVideo = videoDirection.includes("recv");
|
|
12366
12381
|
const sendAudio = audioDirection.includes("send");
|
|
12367
12382
|
const sendVideo = videoDirection.includes("send");
|
|
12368
12383
|
return {
|
|
12384
|
+
nodeId,
|
|
12369
12385
|
receiveAudio,
|
|
12370
12386
|
receiveVideo,
|
|
12371
12387
|
inputAudioDeviceConstraints: sendAudio ? {
|
|
@@ -12376,7 +12392,6 @@ var AttachManager = class {
|
|
|
12376
12392
|
video: true,
|
|
12377
12393
|
...this.deviceController.deviceInfoToConstraints(videoInputDevice)
|
|
12378
12394
|
} : void 0,
|
|
12379
|
-
nodeId: attachment.nodeId ?? void 0,
|
|
12380
12395
|
reattach: true
|
|
12381
12396
|
};
|
|
12382
12397
|
}
|
|
@@ -13252,7 +13267,7 @@ var require_operators = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13252
13267
|
//#endregion
|
|
13253
13268
|
//#region src/operators/filterNull.ts
|
|
13254
13269
|
var import_operators$1 = require_operators();
|
|
13255
|
-
var import_cjs$
|
|
13270
|
+
var import_cjs$21 = require_cjs();
|
|
13256
13271
|
/**
|
|
13257
13272
|
* RxJS operator that filters out `null` and `undefined` values with type narrowing.
|
|
13258
13273
|
*
|
|
@@ -13264,7 +13279,7 @@ var import_cjs$20 = require_cjs();
|
|
|
13264
13279
|
* ```
|
|
13265
13280
|
*/
|
|
13266
13281
|
function filterNull() {
|
|
13267
|
-
return (0, import_cjs$
|
|
13282
|
+
return (0, import_cjs$21.filter)((value) => value != null);
|
|
13268
13283
|
}
|
|
13269
13284
|
|
|
13270
13285
|
//#endregion
|
|
@@ -13392,7 +13407,7 @@ function computeCapabilities(capabilities) {
|
|
|
13392
13407
|
|
|
13393
13408
|
//#endregion
|
|
13394
13409
|
//#region src/core/capabilities/SelfCapabilities.ts
|
|
13395
|
-
var import_cjs$
|
|
13410
|
+
var import_cjs$20 = require_cjs();
|
|
13396
13411
|
/**
|
|
13397
13412
|
* SelfCapabilities manages the capability state for the self participant.
|
|
13398
13413
|
*
|
|
@@ -13428,7 +13443,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13428
13443
|
}
|
|
13429
13444
|
/** Observable for self member capabilities */
|
|
13430
13445
|
get self$() {
|
|
13431
|
-
return this.cachedObservable("self$", () => this._state$.pipe((0, import_cjs$
|
|
13446
|
+
return this.cachedObservable("self$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.self), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13432
13447
|
}
|
|
13433
13448
|
/** Current self member capabilities */
|
|
13434
13449
|
get self() {
|
|
@@ -13436,7 +13451,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13436
13451
|
}
|
|
13437
13452
|
/** Observable for other member capabilities */
|
|
13438
13453
|
get member$() {
|
|
13439
|
-
return this.cachedObservable("member$", () => this._state$.pipe((0, import_cjs$
|
|
13454
|
+
return this.cachedObservable("member$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.member), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13440
13455
|
}
|
|
13441
13456
|
/** Current other member capabilities */
|
|
13442
13457
|
get member() {
|
|
@@ -13444,7 +13459,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13444
13459
|
}
|
|
13445
13460
|
/** Observable for end call capability */
|
|
13446
13461
|
get end$() {
|
|
13447
|
-
return this.cachedObservable("end$", () => this._state$.pipe((0, import_cjs$
|
|
13462
|
+
return this.cachedObservable("end$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.end), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13448
13463
|
}
|
|
13449
13464
|
/** Current end call capability */
|
|
13450
13465
|
get end() {
|
|
@@ -13452,7 +13467,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13452
13467
|
}
|
|
13453
13468
|
/** Observable for set layout capability */
|
|
13454
13469
|
get setLayout$() {
|
|
13455
|
-
return this.cachedObservable("setLayout$", () => this._state$.pipe((0, import_cjs$
|
|
13470
|
+
return this.cachedObservable("setLayout$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.setLayout), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13456
13471
|
}
|
|
13457
13472
|
/** Current set layout capability */
|
|
13458
13473
|
get setLayout() {
|
|
@@ -13460,7 +13475,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13460
13475
|
}
|
|
13461
13476
|
/** Observable for send digit capability */
|
|
13462
13477
|
get sendDigit$() {
|
|
13463
|
-
return this.cachedObservable("sendDigit$", () => this._state$.pipe((0, import_cjs$
|
|
13478
|
+
return this.cachedObservable("sendDigit$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.sendDigit), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13464
13479
|
}
|
|
13465
13480
|
/** Current send digit capability */
|
|
13466
13481
|
get sendDigit() {
|
|
@@ -13468,7 +13483,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13468
13483
|
}
|
|
13469
13484
|
/** Observable for vmuted hide capability */
|
|
13470
13485
|
get vmutedHide$() {
|
|
13471
|
-
return this.cachedObservable("vmutedHide$", () => this._state$.pipe((0, import_cjs$
|
|
13486
|
+
return this.cachedObservable("vmutedHide$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.vmutedHide), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13472
13487
|
}
|
|
13473
13488
|
/** Current vmuted hide capability */
|
|
13474
13489
|
get vmutedHide() {
|
|
@@ -13476,7 +13491,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13476
13491
|
}
|
|
13477
13492
|
/** Observable for lock capability */
|
|
13478
13493
|
get lock$() {
|
|
13479
|
-
return this.cachedObservable("lock$", () => this._state$.pipe((0, import_cjs$
|
|
13494
|
+
return this.cachedObservable("lock$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.lock), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13480
13495
|
}
|
|
13481
13496
|
/** Current lock capability */
|
|
13482
13497
|
get lock() {
|
|
@@ -13484,7 +13499,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13484
13499
|
}
|
|
13485
13500
|
/** Observable for device capability */
|
|
13486
13501
|
get device$() {
|
|
13487
|
-
return this.cachedObservable("device$", () => this._state$.pipe((0, import_cjs$
|
|
13502
|
+
return this.cachedObservable("device$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.device), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13488
13503
|
}
|
|
13489
13504
|
/** Current device capability */
|
|
13490
13505
|
get device() {
|
|
@@ -13492,7 +13507,7 @@ var SelfCapabilities = class extends Destroyable {
|
|
|
13492
13507
|
}
|
|
13493
13508
|
/** Observable for screenshare capability */
|
|
13494
13509
|
get screenshare$() {
|
|
13495
|
-
return this.cachedObservable("screenshare$", () => this._state$.pipe((0, import_cjs$
|
|
13510
|
+
return this.cachedObservable("screenshare$", () => this._state$.pipe((0, import_cjs$20.map)((state) => state.screenshare), (0, import_cjs$20.distinctUntilChanged)()));
|
|
13496
13511
|
}
|
|
13497
13512
|
/** Current screenshare capability */
|
|
13498
13513
|
get screenshare() {
|
|
@@ -13519,7 +13534,7 @@ function toggleHandraiseMethod(is) {
|
|
|
13519
13534
|
|
|
13520
13535
|
//#endregion
|
|
13521
13536
|
//#region src/core/entities/Participant.ts
|
|
13522
|
-
const logger$
|
|
13537
|
+
const logger$21 = getLogger();
|
|
13523
13538
|
const initialState = {};
|
|
13524
13539
|
/**
|
|
13525
13540
|
* Represents a participant in a call.
|
|
@@ -13897,7 +13912,7 @@ var SelfParticipant = class extends Participant {
|
|
|
13897
13912
|
try {
|
|
13898
13913
|
await this.vertoManager.addScreenMedia();
|
|
13899
13914
|
} catch (error) {
|
|
13900
|
-
logger$
|
|
13915
|
+
logger$21.error("[Participant.startScreenShare] Screen share error:", error);
|
|
13901
13916
|
}
|
|
13902
13917
|
}
|
|
13903
13918
|
/** Observable of the current screen share status. */
|
|
@@ -13917,7 +13932,7 @@ var SelfParticipant = class extends Participant {
|
|
|
13917
13932
|
try {
|
|
13918
13933
|
await this.vertoManager.addInputDevice(options);
|
|
13919
13934
|
} catch (error) {
|
|
13920
|
-
logger$
|
|
13935
|
+
logger$21.error("[Participant.startScreenShare] Screen share error:", error);
|
|
13921
13936
|
}
|
|
13922
13937
|
}
|
|
13923
13938
|
/** Removes an additional media input device by ID. */
|
|
@@ -13979,7 +13994,7 @@ var SelfParticipant = class extends Participant {
|
|
|
13979
13994
|
*/
|
|
13980
13995
|
exitStudioModeIfActive() {
|
|
13981
13996
|
if (this._studioAudio$.value) {
|
|
13982
|
-
logger$
|
|
13997
|
+
logger$21.debug("[SelfParticipant] Exiting studio audio mode due to individual flag toggle");
|
|
13983
13998
|
this._studioAudio$.next(false);
|
|
13984
13999
|
}
|
|
13985
14000
|
}
|
|
@@ -14003,7 +14018,7 @@ var SelfParticipant = class extends Participant {
|
|
|
14003
14018
|
try {
|
|
14004
14019
|
await super.mute();
|
|
14005
14020
|
} catch (error) {
|
|
14006
|
-
logger$
|
|
14021
|
+
logger$21.warn("[Participant.toggleAudioInput] Server Error while muting audio input, proceeding with local toggle anyway", error);
|
|
14007
14022
|
} finally {
|
|
14008
14023
|
this.vertoManager.muteMainAudioInputDevice();
|
|
14009
14024
|
}
|
|
@@ -14013,7 +14028,7 @@ var SelfParticipant = class extends Participant {
|
|
|
14013
14028
|
try {
|
|
14014
14029
|
await super.unmute();
|
|
14015
14030
|
} catch (error) {
|
|
14016
|
-
logger$
|
|
14031
|
+
logger$21.warn("[Participant.toggleAudioInput] Server Error while unmuting audio input, proceeding with local toggle anyway", error);
|
|
14017
14032
|
} finally {
|
|
14018
14033
|
await this.vertoManager.unmuteMainAudioInputDevice();
|
|
14019
14034
|
}
|
|
@@ -14023,7 +14038,7 @@ var SelfParticipant = class extends Participant {
|
|
|
14023
14038
|
try {
|
|
14024
14039
|
await super.muteVideo();
|
|
14025
14040
|
} catch (error) {
|
|
14026
|
-
logger$
|
|
14041
|
+
logger$21.warn("[Participant.toggleVideoInput] Server Error while muting video input, proceeding with local toggle anyway", error);
|
|
14027
14042
|
} finally {
|
|
14028
14043
|
this.vertoManager.muteMainVideoInputDevice();
|
|
14029
14044
|
}
|
|
@@ -14033,7 +14048,7 @@ var SelfParticipant = class extends Participant {
|
|
|
14033
14048
|
try {
|
|
14034
14049
|
await super.unmuteVideo();
|
|
14035
14050
|
} catch (error) {
|
|
14036
|
-
logger$
|
|
14051
|
+
logger$21.warn("[Participant.toggleVideoInput] Server Error while unmuting video input, proceeding with local toggle anyway", error);
|
|
14037
14052
|
} finally {
|
|
14038
14053
|
await this.vertoManager.unmuteMainVideoInputDevice();
|
|
14039
14054
|
}
|
|
@@ -14137,7 +14152,7 @@ const getValueFrom = (obj, path, defaultValue) => {
|
|
|
14137
14152
|
|
|
14138
14153
|
//#endregion
|
|
14139
14154
|
//#region src/operators/filterEventAs.ts
|
|
14140
|
-
var import_cjs$
|
|
14155
|
+
var import_cjs$19 = require_cjs();
|
|
14141
14156
|
var import_operators = require_operators();
|
|
14142
14157
|
/**
|
|
14143
14158
|
* RxJS operator that filters events based on a predicate and maps matching events.
|
|
@@ -14171,7 +14186,7 @@ var import_operators = require_operators();
|
|
|
14171
14186
|
* ```
|
|
14172
14187
|
*/
|
|
14173
14188
|
function ifIsMap(predicate, mapFn) {
|
|
14174
|
-
return (0, import_cjs$
|
|
14189
|
+
return (0, import_cjs$19.pipe)((0, import_operators.filter)(predicate), (0, import_operators.map)(mapFn));
|
|
14175
14190
|
}
|
|
14176
14191
|
/**
|
|
14177
14192
|
* Generic RxJS operator that filters events using a type guard and extracts a property.
|
|
@@ -14213,38 +14228,38 @@ function ifIsMap(predicate, mapFn) {
|
|
|
14213
14228
|
* ```
|
|
14214
14229
|
*/
|
|
14215
14230
|
function filterAs(predicate, resultPath) {
|
|
14216
|
-
return (0, import_cjs$
|
|
14231
|
+
return (0, import_cjs$19.pipe)(ifIsMap(predicate, (event) => {
|
|
14217
14232
|
return getValueFrom(event, resultPath);
|
|
14218
14233
|
}), (0, import_operators.filter)((value) => value !== void 0));
|
|
14219
14234
|
}
|
|
14220
14235
|
|
|
14221
14236
|
//#endregion
|
|
14222
14237
|
//#region src/operators/throwOnRPCError.ts
|
|
14223
|
-
var import_cjs$
|
|
14224
|
-
const logger$
|
|
14238
|
+
var import_cjs$18 = require_cjs();
|
|
14239
|
+
const logger$20 = getLogger();
|
|
14225
14240
|
/**
|
|
14226
14241
|
* RxJS operator that throws a {@link JSONRPCError} when the RPC response contains an error.
|
|
14227
14242
|
* Passes successful responses through unchanged.
|
|
14228
14243
|
*/
|
|
14229
14244
|
function throwOnRPCError() {
|
|
14230
|
-
return (0, import_cjs$
|
|
14245
|
+
return (0, import_cjs$18.map)((response) => {
|
|
14231
14246
|
if (response.error) {
|
|
14232
|
-
logger$
|
|
14247
|
+
logger$20.error("[throwOnRPCError] RPC error response:", {
|
|
14233
14248
|
code: response.error.code,
|
|
14234
14249
|
message: response.error.message,
|
|
14235
14250
|
data: response.error.data
|
|
14236
14251
|
});
|
|
14237
14252
|
throw new JSONRPCError(response.error.code, response.error.message, response.error.data);
|
|
14238
14253
|
}
|
|
14239
|
-
logger$
|
|
14254
|
+
logger$20.debug("[throwOnRPCError] RPC successful response:", response);
|
|
14240
14255
|
return response;
|
|
14241
14256
|
});
|
|
14242
14257
|
}
|
|
14243
14258
|
|
|
14244
14259
|
//#endregion
|
|
14245
14260
|
//#region src/managers/CallEventsManager.ts
|
|
14246
|
-
var import_cjs$
|
|
14247
|
-
const logger$
|
|
14261
|
+
var import_cjs$17 = require_cjs();
|
|
14262
|
+
const logger$19 = getLogger();
|
|
14248
14263
|
const initialSessionState = {};
|
|
14249
14264
|
/** @internal */
|
|
14250
14265
|
var CallEventsManager = class extends Destroyable {
|
|
@@ -14260,7 +14275,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14260
14275
|
this.initSubscriptions();
|
|
14261
14276
|
}
|
|
14262
14277
|
get participants$() {
|
|
14263
|
-
return this.cachedObservable("participants$", () => this._participants$.asObservable().pipe((0, import_cjs$
|
|
14278
|
+
return this.cachedObservable("participants$", () => this._participants$.asObservable().pipe((0, import_cjs$17.map)((participantsRecord) => Object.values(participantsRecord))));
|
|
14264
14279
|
}
|
|
14265
14280
|
get participants() {
|
|
14266
14281
|
return Object.values(this._participants$.value);
|
|
@@ -14278,40 +14293,40 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14278
14293
|
return this.callIds.has(callId);
|
|
14279
14294
|
}
|
|
14280
14295
|
get recording$() {
|
|
14281
|
-
return this.cachedObservable("recording$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14296
|
+
return this.cachedObservable("recording$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.recording), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14282
14297
|
}
|
|
14283
14298
|
get recordings$() {
|
|
14284
|
-
return this.cachedObservable("recordings$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14299
|
+
return this.cachedObservable("recordings$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.recordings), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14285
14300
|
}
|
|
14286
14301
|
get streaming$() {
|
|
14287
|
-
return this.cachedObservable("streaming$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14302
|
+
return this.cachedObservable("streaming$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.streaming), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14288
14303
|
}
|
|
14289
14304
|
get streams$() {
|
|
14290
|
-
return this.cachedObservable("streams$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14305
|
+
return this.cachedObservable("streams$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.streams), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14291
14306
|
}
|
|
14292
14307
|
get playbacks$() {
|
|
14293
|
-
return this.cachedObservable("playbacks$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14308
|
+
return this.cachedObservable("playbacks$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.playbacks), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14294
14309
|
}
|
|
14295
14310
|
get raiseHandPriority$() {
|
|
14296
|
-
return this.cachedObservable("raiseHandPriority$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14311
|
+
return this.cachedObservable("raiseHandPriority$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.prioritize_handraise), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14297
14312
|
}
|
|
14298
14313
|
get locked$() {
|
|
14299
|
-
return this.cachedObservable("locked$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14314
|
+
return this.cachedObservable("locked$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.locked), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14300
14315
|
}
|
|
14301
14316
|
get meta$() {
|
|
14302
|
-
return this.cachedObservable("meta$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14317
|
+
return this.cachedObservable("meta$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.meta), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14303
14318
|
}
|
|
14304
14319
|
get capabilities$() {
|
|
14305
|
-
return this.cachedObservable("capabilities$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14320
|
+
return this.cachedObservable("capabilities$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.capabilities), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14306
14321
|
}
|
|
14307
14322
|
get layout$() {
|
|
14308
|
-
return this.cachedObservable("layout$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14323
|
+
return this.cachedObservable("layout$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.layout_name), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14309
14324
|
}
|
|
14310
14325
|
get layouts$() {
|
|
14311
|
-
return this.cachedObservable("layouts$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14326
|
+
return this.cachedObservable("layouts$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.layouts), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14312
14327
|
}
|
|
14313
14328
|
get layoutLayers$() {
|
|
14314
|
-
return this.cachedObservable("layoutLayers$", () => this._sessionState$.pipe((0, import_cjs$
|
|
14329
|
+
return this.cachedObservable("layoutLayers$", () => this._sessionState$.pipe((0, import_cjs$17.map)((state) => state.layout_layers), (0, import_cjs$17.distinctUntilChanged)(), filterNull()));
|
|
14315
14330
|
}
|
|
14316
14331
|
get self() {
|
|
14317
14332
|
return this._self$.value;
|
|
@@ -14348,7 +14363,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14348
14363
|
}
|
|
14349
14364
|
initSubscriptions() {
|
|
14350
14365
|
this.subscribeTo(this.callJoinedEvent$, (callJoinedEvent) => {
|
|
14351
|
-
logger$
|
|
14366
|
+
logger$19.debug("[CallEventsManager] Handling call.joined event for call/session IDs:", {
|
|
14352
14367
|
callId: callJoinedEvent.call_id,
|
|
14353
14368
|
roomSessionId: callJoinedEvent.room_session_id
|
|
14354
14369
|
});
|
|
@@ -14375,19 +14390,19 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14375
14390
|
if (this._self$.value?.capabilities.setLayout) this.updateLayouts();
|
|
14376
14391
|
});
|
|
14377
14392
|
this.subscribeTo(this.memberUpdates$, (member) => {
|
|
14378
|
-
logger$
|
|
14393
|
+
logger$19.debug("[CallEventsManager] Handling member update event for member ID:", member);
|
|
14379
14394
|
this.upsertParticipant(member);
|
|
14380
14395
|
});
|
|
14381
14396
|
this.subscribeTo(this.webRtcCallSession.memberLeft$, (memberLeftEvent) => {
|
|
14382
|
-
logger$
|
|
14397
|
+
logger$19.debug("[CallEventsManager] Handling member.left event for member ID:", memberLeftEvent.member.member_id);
|
|
14383
14398
|
const participants = { ...this._participants$.value };
|
|
14384
14399
|
if (memberLeftEvent.member.member_id in participants) {
|
|
14385
14400
|
delete participants[memberLeftEvent.member.member_id];
|
|
14386
14401
|
this._participants$.next(participants);
|
|
14387
|
-
} else logger$
|
|
14402
|
+
} else logger$19.warn(`[CallEventsManager] Received member.left event for unknown member ID: ${memberLeftEvent.member.member_id}`);
|
|
14388
14403
|
});
|
|
14389
14404
|
this.subscribeTo(this.webRtcCallSession.callUpdated$, (callUpdatedEvent) => {
|
|
14390
|
-
logger$
|
|
14405
|
+
logger$19.debug("[CallEventsManager] Handling call.updated event:", callUpdatedEvent);
|
|
14391
14406
|
const roomSession = callUpdatedEvent.room_session;
|
|
14392
14407
|
this._sessionState$.next({
|
|
14393
14408
|
...this._sessionState$.value,
|
|
@@ -14402,7 +14417,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14402
14417
|
});
|
|
14403
14418
|
});
|
|
14404
14419
|
this.subscribeTo(this.layoutChangedEvent$, (layoutChangedEvent) => {
|
|
14405
|
-
logger$
|
|
14420
|
+
logger$19.debug("[CallEventsManager] Handling layout.changed event:", layoutChangedEvent);
|
|
14406
14421
|
this._sessionState$.next({
|
|
14407
14422
|
...this._sessionState$.value,
|
|
14408
14423
|
layout_name: layoutChangedEvent.id,
|
|
@@ -14412,10 +14427,10 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14412
14427
|
});
|
|
14413
14428
|
}
|
|
14414
14429
|
updateParticipantPositions(layoutChangedEvent) {
|
|
14415
|
-
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$
|
|
14416
|
-
layoutChangedEvent.layers.filter((layer) =>
|
|
14417
|
-
if (!
|
|
14418
|
-
logger$
|
|
14430
|
+
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$19.warn("[CallEventsManager] No layers with member_id found in layout.changed event. Nothing to update.");
|
|
14431
|
+
layoutChangedEvent.layers.filter((layer) => !!layer.member_id).filter((layer) => {
|
|
14432
|
+
if (!(layer.member_id in this._participants$.value)) {
|
|
14433
|
+
logger$19.warn(`[CallEventsManager] Skipping layout layer for unknown member_id: ${layer.member_id}`);
|
|
14419
14434
|
return false;
|
|
14420
14435
|
}
|
|
14421
14436
|
return true;
|
|
@@ -14438,7 +14453,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14438
14453
|
layouts: response.result.layouts
|
|
14439
14454
|
});
|
|
14440
14455
|
}).catch((error) => {
|
|
14441
|
-
logger$
|
|
14456
|
+
logger$19.error("[CallEventsManager] Error fetching layouts:", error);
|
|
14442
14457
|
});
|
|
14443
14458
|
}
|
|
14444
14459
|
updateParticipants(members) {
|
|
@@ -14454,7 +14469,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14454
14469
|
}
|
|
14455
14470
|
const participant = this._participants$.value[member.member_id];
|
|
14456
14471
|
const oldValue = participant.value;
|
|
14457
|
-
logger$
|
|
14472
|
+
logger$19.debug("[CallEventsManager] Updating participant:", member.member_id, {
|
|
14458
14473
|
oldValue,
|
|
14459
14474
|
newValue: member
|
|
14460
14475
|
});
|
|
@@ -14466,18 +14481,18 @@ var CallEventsManager = class extends Destroyable {
|
|
|
14466
14481
|
this._participants$.next(this._participants$.value);
|
|
14467
14482
|
}
|
|
14468
14483
|
get callJoinedEvent$() {
|
|
14469
|
-
return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, import_cjs$
|
|
14470
|
-
logger$
|
|
14484
|
+
return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, import_cjs$17.filter)(isCallJoinedPayload), (0, import_cjs$17.tap)((event) => {
|
|
14485
|
+
logger$19.debug("[CallEventsManager] Call joined event:", event);
|
|
14471
14486
|
})));
|
|
14472
14487
|
}
|
|
14473
14488
|
get layoutChangedEvent$() {
|
|
14474
|
-
return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$
|
|
14475
|
-
logger$
|
|
14489
|
+
return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$17.tap)((event) => {
|
|
14490
|
+
logger$19.debug("[CallEventsManager] Layout changed event:", event);
|
|
14476
14491
|
})));
|
|
14477
14492
|
}
|
|
14478
14493
|
get memberUpdates$() {
|
|
14479
|
-
return this.cachedObservable("memberUpdates$", () => (0, import_cjs$
|
|
14480
|
-
logger$
|
|
14494
|
+
return this.cachedObservable("memberUpdates$", () => (0, import_cjs$17.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, import_cjs$17.map)((event) => event.member), (0, import_cjs$17.tap)((event) => {
|
|
14495
|
+
logger$19.debug("[CallEventsManager] Member update event:", event);
|
|
14481
14496
|
})));
|
|
14482
14497
|
}
|
|
14483
14498
|
destroy() {
|
|
@@ -14733,8 +14748,8 @@ function appendStereoParams(fmtpLine, maxBitrate) {
|
|
|
14733
14748
|
|
|
14734
14749
|
//#endregion
|
|
14735
14750
|
//#region src/controllers/ICEGatheringController.ts
|
|
14736
|
-
var import_cjs$
|
|
14737
|
-
const logger$
|
|
14751
|
+
var import_cjs$16 = require_cjs();
|
|
14752
|
+
const logger$18 = getLogger();
|
|
14738
14753
|
var ICEGatheringController = class extends Destroyable {
|
|
14739
14754
|
constructor(peerConnection, peerConnectionControllerNegotiating$, options = {}) {
|
|
14740
14755
|
super();
|
|
@@ -14742,23 +14757,23 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14742
14757
|
this.peerConnectionControllerNegotiating$ = peerConnectionControllerNegotiating$;
|
|
14743
14758
|
this.onicegatheringstatechangeHandler = () => {
|
|
14744
14759
|
const { iceGatheringState } = this.peerConnection;
|
|
14745
|
-
logger$
|
|
14760
|
+
logger$18.debug(`[ICEGatheringController] ICE gathering state changed to: ${iceGatheringState}`);
|
|
14746
14761
|
if (iceGatheringState === "gathering") this._iceCandidatesState.next({
|
|
14747
14762
|
state: "gathering",
|
|
14748
14763
|
validSDP: false
|
|
14749
14764
|
});
|
|
14750
14765
|
};
|
|
14751
14766
|
this.onicecandidateHandler = (event) => {
|
|
14752
|
-
logger$
|
|
14767
|
+
logger$18.debug("[ICEGatheringController] ICE candidate event received:", event.candidate);
|
|
14753
14768
|
this.removeTimer("iceCandidateTimer");
|
|
14754
14769
|
if (event.candidate) this.iceCandidateTimer = setTimeout(() => {
|
|
14755
14770
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
14756
|
-
logger$
|
|
14771
|
+
logger$18.warn("[ICEGatheringController] ICE candidate timeout, using current SDP");
|
|
14757
14772
|
this.handleICECandidateTimeout();
|
|
14758
14773
|
}
|
|
14759
14774
|
}, this.iceCandidateTimeout);
|
|
14760
14775
|
else {
|
|
14761
|
-
logger$
|
|
14776
|
+
logger$18.debug("[ICEGatheringController] ICE gathering completed: null candidate received");
|
|
14762
14777
|
this.removeTimer("iceGatheringTimer");
|
|
14763
14778
|
this.handleICEGatheringComplete();
|
|
14764
14779
|
}
|
|
@@ -14771,12 +14786,12 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14771
14786
|
this.iceGatheringTimeout = options.iceGatheringTimeout ?? DEFAULT_ICE_GATHERING_TIMEOUT_MS;
|
|
14772
14787
|
this.relayOnly = options.relayOnly ?? false;
|
|
14773
14788
|
this.setupEventListeners();
|
|
14774
|
-
this.subscribeTo(this.peerConnectionControllerNegotiating$.pipe((0, import_cjs$
|
|
14789
|
+
this.subscribeTo(this.peerConnectionControllerNegotiating$.pipe((0, import_cjs$16.filter)((isNegotiating) => isNegotiating)), (isNegotiating) => {
|
|
14775
14790
|
if (isNegotiating) {
|
|
14776
14791
|
this.setupEventListeners();
|
|
14777
14792
|
this.iceGatheringTimer = setTimeout(() => {
|
|
14778
14793
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
14779
|
-
logger$
|
|
14794
|
+
logger$18.warn("[ICEGatheringController] ICE gathering timeout, using current SDP");
|
|
14780
14795
|
this.handleICEGatheringTimeout();
|
|
14781
14796
|
}
|
|
14782
14797
|
}, this.iceGatheringTimeout);
|
|
@@ -14790,7 +14805,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14790
14805
|
this.peerConnection.addEventListener("icegatheringstatechange", this.onicegatheringstatechangeHandler);
|
|
14791
14806
|
}
|
|
14792
14807
|
get iceCandidatesState$() {
|
|
14793
|
-
return this._iceCandidatesState.pipe((0, import_cjs$
|
|
14808
|
+
return this._iceCandidatesState.pipe((0, import_cjs$16.withLatestFrom)(this.peerConnectionControllerNegotiating$), (0, import_cjs$16.filter)(([_, isNegotiating]) => isNegotiating), (0, import_cjs$16.map)(([state, _]) => state.state));
|
|
14794
14809
|
}
|
|
14795
14810
|
get hasValidLocalDescriptionSDP() {
|
|
14796
14811
|
const sdp = this.peerConnection.localDescription?.sdp;
|
|
@@ -14803,9 +14818,9 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14803
14818
|
this.relayOnly = value;
|
|
14804
14819
|
}
|
|
14805
14820
|
handleICEGatheringComplete() {
|
|
14806
|
-
logger$
|
|
14807
|
-
logger$
|
|
14808
|
-
logger$
|
|
14821
|
+
logger$18.debug("[ICEGatheringController] Handling ICE gathering complete");
|
|
14822
|
+
logger$18.debug(`[ICEGatheringController] Checking ICE gathering state: ${this.peerConnection.iceGatheringState}`);
|
|
14823
|
+
logger$18.debug("[ICEGatheringController] ICE gathering complete");
|
|
14809
14824
|
this._iceCandidatesState.next({
|
|
14810
14825
|
state: "complete",
|
|
14811
14826
|
validSDP: this.hasValidLocalDescriptionSDP
|
|
@@ -14821,21 +14836,21 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14821
14836
|
this.removeTimer("iceGatheringTimer");
|
|
14822
14837
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
14823
14838
|
if (validSDP) {
|
|
14824
|
-
logger$
|
|
14839
|
+
logger$18.debug("[ICEGatheringController] Local SDP is valid");
|
|
14825
14840
|
this._iceCandidatesState.next({
|
|
14826
14841
|
state: "timeout",
|
|
14827
14842
|
validSDP
|
|
14828
14843
|
});
|
|
14829
14844
|
this.stopGathering();
|
|
14830
|
-
} else logger$
|
|
14845
|
+
} else logger$18.debug("### ICE gathering timeout\n", this.peerConnection.localDescription?.sdp);
|
|
14831
14846
|
}
|
|
14832
14847
|
handleICECandidateTimeout() {
|
|
14833
14848
|
if (this.iceCandidateTimer) this.removeTimer("iceCandidateTimer");
|
|
14834
|
-
logger$
|
|
14849
|
+
logger$18.warn("[ICEGatheringController] ICE candidate timeout");
|
|
14835
14850
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
14836
14851
|
if (!validSDP && !this.relayOnly) this.restartICEGatheringWithRelayOnly();
|
|
14837
14852
|
else {
|
|
14838
|
-
logger$
|
|
14853
|
+
logger$18.debug("[ICEGatheringController] Using current SDP due to ICE candidate timeout");
|
|
14839
14854
|
this._iceCandidatesState.next({
|
|
14840
14855
|
state: "timeout",
|
|
14841
14856
|
validSDP
|
|
@@ -14844,7 +14859,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14844
14859
|
}
|
|
14845
14860
|
}
|
|
14846
14861
|
restartICEGatheringWithRelayOnly() {
|
|
14847
|
-
logger$
|
|
14862
|
+
logger$18.debug("[ICEGatheringController] Restarting ICE gathering with relay-only candidates");
|
|
14848
14863
|
this.relayOnly = true;
|
|
14849
14864
|
this.peerConnection.setConfiguration({
|
|
14850
14865
|
...this.peerConnection.getConfiguration(),
|
|
@@ -14852,14 +14867,14 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14852
14867
|
});
|
|
14853
14868
|
if (!(this.peerConnection.connectionState === "connected")) this.peerConnection.restartIce();
|
|
14854
14869
|
}
|
|
14855
|
-
removeTimer(timer$
|
|
14856
|
-
if (this[timer$
|
|
14857
|
-
clearTimeout(this[timer$
|
|
14858
|
-
this[timer$
|
|
14870
|
+
removeTimer(timer$3) {
|
|
14871
|
+
if (this[timer$3]) {
|
|
14872
|
+
clearTimeout(this[timer$3]);
|
|
14873
|
+
this[timer$3] = void 0;
|
|
14859
14874
|
}
|
|
14860
14875
|
}
|
|
14861
14876
|
clearAllTimers() {
|
|
14862
|
-
logger$
|
|
14877
|
+
logger$18.debug("[ICEGatheringController] Clearing all timers");
|
|
14863
14878
|
this.removeTimer("iceGatheringTimer");
|
|
14864
14879
|
this.removeTimer("iceCandidateTimer");
|
|
14865
14880
|
}
|
|
@@ -14868,7 +14883,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14868
14883
|
this.peerConnection.removeEventListener("icecandidate", this.onicecandidateHandler);
|
|
14869
14884
|
}
|
|
14870
14885
|
destroy() {
|
|
14871
|
-
logger$
|
|
14886
|
+
logger$18.debug("[ICEGatheringController] Destroying ICEGatheringController");
|
|
14872
14887
|
this.clearAllTimers();
|
|
14873
14888
|
this.removeEventListeners();
|
|
14874
14889
|
super.destroy();
|
|
@@ -14877,8 +14892,8 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
14877
14892
|
|
|
14878
14893
|
//#endregion
|
|
14879
14894
|
//#region src/controllers/LocalStreamController.ts
|
|
14880
|
-
var import_cjs$
|
|
14881
|
-
const logger$
|
|
14895
|
+
var import_cjs$15 = require_cjs();
|
|
14896
|
+
const logger$17 = getLogger();
|
|
14882
14897
|
var LocalStreamController = class extends Destroyable {
|
|
14883
14898
|
constructor(options) {
|
|
14884
14899
|
super();
|
|
@@ -14892,16 +14907,16 @@ var LocalStreamController = class extends Destroyable {
|
|
|
14892
14907
|
this._mediaTrackEnded$ = this.createSubject();
|
|
14893
14908
|
}
|
|
14894
14909
|
get localStream$() {
|
|
14895
|
-
return this._localStream$.asObservable().pipe((0, import_cjs$
|
|
14910
|
+
return this._localStream$.asObservable().pipe((0, import_cjs$15.takeUntil)(this.destroyed$));
|
|
14896
14911
|
}
|
|
14897
14912
|
get localAudioTracks$() {
|
|
14898
|
-
return this._localAudioTracks$.asObservable().pipe((0, import_cjs$
|
|
14913
|
+
return this._localAudioTracks$.asObservable().pipe((0, import_cjs$15.takeUntil)(this.destroyed$));
|
|
14899
14914
|
}
|
|
14900
14915
|
get localVideoTracks$() {
|
|
14901
|
-
return this._localVideoTracks$.asObservable().pipe((0, import_cjs$
|
|
14916
|
+
return this._localVideoTracks$.asObservable().pipe((0, import_cjs$15.takeUntil)(this.destroyed$));
|
|
14902
14917
|
}
|
|
14903
14918
|
get mediaTrackEnded$() {
|
|
14904
|
-
return this._mediaTrackEnded$.asObservable().pipe((0, import_cjs$
|
|
14919
|
+
return this._mediaTrackEnded$.asObservable().pipe((0, import_cjs$15.takeUntil)(this.destroyed$));
|
|
14905
14920
|
}
|
|
14906
14921
|
get localStream() {
|
|
14907
14922
|
return this._localStream$.value;
|
|
@@ -14916,26 +14931,26 @@ var LocalStreamController = class extends Destroyable {
|
|
|
14916
14931
|
* Build the local media stream based on the provided options.
|
|
14917
14932
|
*/
|
|
14918
14933
|
async buildLocalStream() {
|
|
14919
|
-
logger$
|
|
14934
|
+
logger$17.debug("[LocalStreamController] Building local media stream.");
|
|
14920
14935
|
let stream;
|
|
14921
14936
|
if (this.options.inputAudioStream ?? this.options.inputVideoStream) {
|
|
14922
14937
|
const tracks = [...this.options.inputAudioStream?.getTracks() ?? [], ...this.options.inputVideoStream?.getTracks() ?? []];
|
|
14923
14938
|
stream = new MediaStream(tracks);
|
|
14924
14939
|
} else if (this.options.propose === "screenshare") {
|
|
14925
|
-
logger$
|
|
14940
|
+
logger$17.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
|
|
14926
14941
|
stream = await this.options.getDisplayMedia({
|
|
14927
14942
|
video: true,
|
|
14928
14943
|
audio: Boolean(this.options.inputAudioDeviceConstraints)
|
|
14929
14944
|
});
|
|
14930
|
-
logger$
|
|
14945
|
+
logger$17.debug("[LocalStreamController] Screen share media obtained:", stream);
|
|
14931
14946
|
} else {
|
|
14932
14947
|
const constraints = {
|
|
14933
14948
|
audio: this.options.inputAudioDeviceConstraints,
|
|
14934
14949
|
video: this.options.inputVideoDeviceConstraints
|
|
14935
14950
|
};
|
|
14936
|
-
logger$
|
|
14951
|
+
logger$17.debug("[LocalStreamController] Requesting user media with constraints:", constraints);
|
|
14937
14952
|
stream = await this.options.getUserMedia(constraints);
|
|
14938
|
-
logger$
|
|
14953
|
+
logger$17.debug("[LocalStreamController] User media obtained:", stream);
|
|
14939
14954
|
}
|
|
14940
14955
|
this._localStream$.next(stream);
|
|
14941
14956
|
return stream;
|
|
@@ -14952,7 +14967,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
14952
14967
|
this._localStream$.next(localStream);
|
|
14953
14968
|
if (track.kind === "video") this._localVideoTracks$.next(localStream.getVideoTracks());
|
|
14954
14969
|
else this._localAudioTracks$.next(localStream.getAudioTracks());
|
|
14955
|
-
logger$
|
|
14970
|
+
logger$17.debug(`[LocalStreamController] ${track.kind} track added:`, track.id);
|
|
14956
14971
|
return localStream;
|
|
14957
14972
|
}
|
|
14958
14973
|
/**
|
|
@@ -14964,7 +14979,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
14964
14979
|
const stream = this._localStream$.value;
|
|
14965
14980
|
const track = stream?.getTracks().find((t) => t.id === trackId);
|
|
14966
14981
|
if (!track) {
|
|
14967
|
-
logger$
|
|
14982
|
+
logger$17.debug(`[LocalStreamController] track not found: ${trackId}`);
|
|
14968
14983
|
return;
|
|
14969
14984
|
}
|
|
14970
14985
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
@@ -14973,7 +14988,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
14973
14988
|
this._localStream$.next(stream);
|
|
14974
14989
|
if (track.kind === "video") this._localVideoTracks$.next(stream?.getVideoTracks() ?? []);
|
|
14975
14990
|
else this._localAudioTracks$.next(stream?.getAudioTracks() ?? []);
|
|
14976
|
-
logger$
|
|
14991
|
+
logger$17.debug(`[LocalStreamController] ${track.kind} track removed:`, trackId);
|
|
14977
14992
|
return track;
|
|
14978
14993
|
}
|
|
14979
14994
|
/**
|
|
@@ -15008,7 +15023,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
15008
15023
|
*/
|
|
15009
15024
|
stopAllTracks() {
|
|
15010
15025
|
this._localStream$.value?.getTracks().forEach((track) => {
|
|
15011
|
-
logger$
|
|
15026
|
+
logger$17.debug(`[LocalStreamController] Stopping local track: ${track.kind}`);
|
|
15012
15027
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
15013
15028
|
track.stop();
|
|
15014
15029
|
});
|
|
@@ -15024,7 +15039,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
15024
15039
|
|
|
15025
15040
|
//#endregion
|
|
15026
15041
|
//#region src/controllers/TransceiverController.ts
|
|
15027
|
-
const logger$
|
|
15042
|
+
const logger$16 = getLogger();
|
|
15028
15043
|
const getDirection = (send, recv) => {
|
|
15029
15044
|
if (send && recv) return "sendrecv";
|
|
15030
15045
|
else if (send && !recv) return "sendonly";
|
|
@@ -15126,7 +15141,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
15126
15141
|
sendEncodings: isAudio ? void 0 : this.sendEncodings,
|
|
15127
15142
|
streams: direction === "recvonly" ? void 0 : [localStream]
|
|
15128
15143
|
};
|
|
15129
|
-
logger$
|
|
15144
|
+
logger$16.debug(`[TransceiverController] Setting up transceiver sender for local ${track.kind} track:`, {
|
|
15130
15145
|
transceiver,
|
|
15131
15146
|
transceiverParams
|
|
15132
15147
|
});
|
|
@@ -15134,11 +15149,11 @@ var TransceiverController = class extends Destroyable {
|
|
|
15134
15149
|
await transceiver.sender.replaceTrack(track);
|
|
15135
15150
|
transceiver.direction = transceiverParams.direction;
|
|
15136
15151
|
if (transceiverParams.streams?.some((stream) => Boolean(stream))) {
|
|
15137
|
-
logger$
|
|
15152
|
+
logger$16.debug(`[TransceiverController] Setting streams for transceiver sender for local ${track.kind} track:`, transceiverParams.streams);
|
|
15138
15153
|
transceiver.sender.setStreams(...transceiverParams.streams);
|
|
15139
15154
|
}
|
|
15140
15155
|
} else {
|
|
15141
|
-
logger$
|
|
15156
|
+
logger$16.debug(`[TransceiverController] Adding new transceiver for local ${track.kind} track:`, track.id);
|
|
15142
15157
|
this.peerConnection.addTransceiver(track, transceiverParams);
|
|
15143
15158
|
}
|
|
15144
15159
|
}
|
|
@@ -15152,13 +15167,13 @@ var TransceiverController = class extends Destroyable {
|
|
|
15152
15167
|
if (options.updateTransceiverDirection) transceiver.direction = "inactive";
|
|
15153
15168
|
}
|
|
15154
15169
|
} catch (error) {
|
|
15155
|
-
logger$
|
|
15170
|
+
logger$16.error("[TransceiverController] stopTrackSender error", kind, error);
|
|
15156
15171
|
this.options.onError?.(new MediaTrackError("stopTrackSender", kind, error));
|
|
15157
15172
|
}
|
|
15158
15173
|
}
|
|
15159
15174
|
async restoreTrackSender(kind) {
|
|
15160
15175
|
try {
|
|
15161
|
-
logger$
|
|
15176
|
+
logger$16.debug("[TransceiverController] restoreTrackSender called", kind);
|
|
15162
15177
|
const constraints = {};
|
|
15163
15178
|
const transceivers = this.transceiverByKind(kind);
|
|
15164
15179
|
for (const transceiver of transceivers) {
|
|
@@ -15168,23 +15183,23 @@ var TransceiverController = class extends Destroyable {
|
|
|
15168
15183
|
if (trackKind === "audio" || trackKind === "video") constraints[trackKind] = this.getConstraintsFor(trackKind);
|
|
15169
15184
|
}
|
|
15170
15185
|
}
|
|
15171
|
-
logger$
|
|
15186
|
+
logger$16.debug("[TransceiverController] restoreTrackSender constraints:", constraints);
|
|
15172
15187
|
if (Object.keys(constraints).length === 0) {
|
|
15173
|
-
logger$
|
|
15188
|
+
logger$16.warn("[TransceiverController] restoreTrackSender: no tracks need restoration", kind);
|
|
15174
15189
|
return;
|
|
15175
15190
|
}
|
|
15176
15191
|
const newTracks = (await this.options.getUserMedia(constraints)).getTracks();
|
|
15177
|
-
logger$
|
|
15192
|
+
logger$16.debug("[TransceiverController] restoreTrackSender new tracks:", newTracks);
|
|
15178
15193
|
for (const newTrack of newTracks) {
|
|
15179
15194
|
this.options.localStreamController.addTrack(newTrack);
|
|
15180
15195
|
const trackKind = newTrack.kind;
|
|
15181
15196
|
const transceiverOfKind = this.transceiverByKind(trackKind)[0];
|
|
15182
15197
|
transceiverOfKind.direction = trackKind === "audio" ? this.audioDirection : this.videoDirection;
|
|
15183
|
-
logger$
|
|
15198
|
+
logger$16.debug("[TransceiverController] restoreTrackSender setting direction for", trackKind, transceiverOfKind.direction);
|
|
15184
15199
|
await transceiverOfKind.sender.replaceTrack(newTrack);
|
|
15185
15200
|
}
|
|
15186
15201
|
} catch (error) {
|
|
15187
|
-
logger$
|
|
15202
|
+
logger$16.error("[TransceiverController] restoreTrackSender error", kind, error);
|
|
15188
15203
|
this.options.onError?.(new MediaTrackError("restoreTrackSender", kind, error));
|
|
15189
15204
|
}
|
|
15190
15205
|
}
|
|
@@ -15225,14 +15240,14 @@ var TransceiverController = class extends Destroyable {
|
|
|
15225
15240
|
};
|
|
15226
15241
|
try {
|
|
15227
15242
|
await track.applyConstraints(constraintsToApply);
|
|
15228
|
-
logger$
|
|
15229
|
-
logger$
|
|
15243
|
+
logger$16.debug(`[TransceiverController] Updated ${kind} sender constraints:`, constraintsToApply);
|
|
15244
|
+
logger$16.debug(`[TransceiverController] Updated ${kind} sender constraints:`, track.getConstraints());
|
|
15230
15245
|
} catch (error) {
|
|
15231
|
-
logger$
|
|
15246
|
+
logger$16.warn(`[TransceiverController] applyConstraints failed for ${kind} track ${track.id}, attempting track replacement fallback:`, error);
|
|
15232
15247
|
try {
|
|
15233
15248
|
await this.replaceTrackFallback(sender, track, kind, constraintsToApply);
|
|
15234
15249
|
} catch (fallbackError) {
|
|
15235
|
-
logger$
|
|
15250
|
+
logger$16.warn(`[TransceiverController] Track replacement fallback also failed for ${kind} track:`, fallbackError);
|
|
15236
15251
|
this.options.onError?.(new MediaTrackError("updateSendersConstraints", kind, fallbackError));
|
|
15237
15252
|
}
|
|
15238
15253
|
}
|
|
@@ -15260,7 +15275,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
15260
15275
|
if (!newTrack) throw new MediaTrackError("replaceTrackFallback", kind, /* @__PURE__ */ new Error("getUserMedia returned no track of the requested kind"));
|
|
15261
15276
|
await sender.replaceTrack(newTrack);
|
|
15262
15277
|
this.options.localStreamController.addTrack(newTrack);
|
|
15263
|
-
logger$
|
|
15278
|
+
logger$16.debug(`[TransceiverController] Track replacement fallback succeeded for ${kind}. New track: ${newTrack.id}`);
|
|
15264
15279
|
}
|
|
15265
15280
|
getMediaDirections() {
|
|
15266
15281
|
if (this.peerConnection.connectionState === "connected") return this.peerConnection.getTransceivers().reduce((acc, transceiver) => {
|
|
@@ -15290,60 +15305,60 @@ var TransceiverController = class extends Destroyable {
|
|
|
15290
15305
|
|
|
15291
15306
|
//#endregion
|
|
15292
15307
|
//#region src/controllers/RTCPeerConnectionController.ts
|
|
15293
|
-
var import_cjs$
|
|
15294
|
-
const logger$
|
|
15308
|
+
var import_cjs$14 = require_cjs();
|
|
15309
|
+
const logger$15 = getLogger();
|
|
15295
15310
|
var RTCPeerConnectionController = class extends Destroyable {
|
|
15296
15311
|
constructor(options = {}, remoteSessionDescription, deviceController) {
|
|
15297
15312
|
super();
|
|
15298
15313
|
this.options = options;
|
|
15299
15314
|
this.firstSDPExchangeCompleted = false;
|
|
15300
15315
|
this.negotiationNeeded$ = this.createSubject();
|
|
15301
|
-
this.localDescription$ = (0, import_cjs$
|
|
15316
|
+
this.localDescription$ = (0, import_cjs$14.defer)(() => (0, import_cjs$14.from)(this.init())).pipe((0, import_cjs$14.switchMap)(() => this.iceGatheringController.iceCandidatesState$.pipe((0, import_cjs$14.filter)((iceCandidateState) => !["new", "gathering"].includes(iceCandidateState)), (0, import_cjs$14.tap)(() => {
|
|
15302
15317
|
this.negotiationEnded();
|
|
15303
|
-
}), (0, import_cjs$
|
|
15318
|
+
}), (0, import_cjs$14.filter)(() => this.shouldEmitLocalDescription), (0, import_cjs$14.map)(() => this.peerConnection?.localDescription), filterNull(), (0, import_cjs$14.tap)((desc) => {
|
|
15304
15319
|
if (desc.type === "answer") this._type = "offer";
|
|
15305
|
-
}))), (0, import_cjs$
|
|
15320
|
+
}))), (0, import_cjs$14.shareReplay)(1), (0, import_cjs$14.takeUntil)(this.destroyed$));
|
|
15306
15321
|
this.connectionTimeout = 3e3;
|
|
15307
15322
|
this.oniceconnectionstatechangeHandler = () => {
|
|
15308
15323
|
if (this.peerConnection) {
|
|
15309
15324
|
const { iceConnectionState } = this.peerConnection;
|
|
15310
|
-
logger$
|
|
15325
|
+
logger$15.debug(`[RTCPeerConnectionController] ICE connection state changed to: ${iceConnectionState}`);
|
|
15311
15326
|
this._iceConnectionState$.next(this.peerConnection.iceConnectionState);
|
|
15312
15327
|
}
|
|
15313
15328
|
};
|
|
15314
15329
|
this.onconnectionstatechangeHandler = () => {
|
|
15315
15330
|
if (this.peerConnection) {
|
|
15316
15331
|
const { connectionState } = this.peerConnection;
|
|
15317
|
-
logger$
|
|
15332
|
+
logger$15.debug(`[RTCPeerConnectionController] Connection state changed to: ${connectionState}`);
|
|
15318
15333
|
if (connectionState === "connected") this.removeConnectionTimer();
|
|
15319
15334
|
this._connectionState$.next(this.peerConnection.connectionState);
|
|
15320
15335
|
}
|
|
15321
15336
|
};
|
|
15322
15337
|
this.onsignalingstatechangeHandler = () => {
|
|
15323
|
-
logger$
|
|
15338
|
+
logger$15.debug(`[RTCPeerConnectionController] Signaling state changed to: ${this.peerConnection?.signalingState}`);
|
|
15324
15339
|
};
|
|
15325
15340
|
this.onicegatheringstatechangeHandler = () => {
|
|
15326
15341
|
if (this.peerConnection) this._iceGatheringState$.next(this.peerConnection.iceGatheringState);
|
|
15327
15342
|
};
|
|
15328
15343
|
this.onnegotiationneededHandler = (event) => {
|
|
15329
|
-
logger$
|
|
15344
|
+
logger$15.debug("[RTCPeerConnectionController] Negotiation needed event received.", event);
|
|
15330
15345
|
this.negotiationNeeded$.next();
|
|
15331
15346
|
};
|
|
15332
15347
|
this.updateSelectedInputDevice = async (kind, deviceInfo) => {
|
|
15333
15348
|
try {
|
|
15334
15349
|
const { localStream } = this;
|
|
15335
15350
|
if (!localStream) {
|
|
15336
|
-
logger$
|
|
15351
|
+
logger$15.warn("[RTCPeerConnectionController] No local stream available to update input device.");
|
|
15337
15352
|
return;
|
|
15338
15353
|
}
|
|
15339
|
-
logger$
|
|
15354
|
+
logger$15.debug(`[RTCPeerConnectionController] Updating selected ${kind} input device:`, localStream.getTracks());
|
|
15340
15355
|
const track = localStream.getTracks().find((track$1) => track$1.kind === kind);
|
|
15341
15356
|
if (track) {
|
|
15342
15357
|
this.transceiverController?.stopTrackSender(kind);
|
|
15343
15358
|
this.localStream?.removeTrack(track);
|
|
15344
|
-
logger$
|
|
15359
|
+
logger$15.debug(`[RTCPeerConnectionController] Stopped existing ${kind} track: ${track.id}`, localStream.getTracks());
|
|
15345
15360
|
if (!deviceInfo) {
|
|
15346
|
-
logger$
|
|
15361
|
+
logger$15.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
15347
15362
|
return;
|
|
15348
15363
|
}
|
|
15349
15364
|
const streamTrack = (await this.getUserMedia({ [kind]: {
|
|
@@ -15351,15 +15366,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15351
15366
|
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
15352
15367
|
} })).getTracks().find((t) => t.kind === kind);
|
|
15353
15368
|
if (streamTrack) {
|
|
15354
|
-
logger$
|
|
15369
|
+
logger$15.debug(`[RTCPeerConnectionController] Adding new ${kind} track: ${streamTrack.id}`);
|
|
15355
15370
|
this.localStream?.addTrack(streamTrack);
|
|
15356
15371
|
await this.transceiverController?.replaceSenderTrack(kind, streamTrack);
|
|
15357
|
-
logger$
|
|
15372
|
+
logger$15.debug(`[RTCPeerConnectionController] Added new ${kind} track: ${streamTrack.id}`, this.localStream?.getTracks());
|
|
15358
15373
|
}
|
|
15359
15374
|
}
|
|
15360
|
-
logger$
|
|
15375
|
+
logger$15.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo?.label);
|
|
15361
15376
|
} catch (error) {
|
|
15362
|
-
logger$
|
|
15377
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to select ${kind} input device:`, error);
|
|
15363
15378
|
this._errors$.next(error);
|
|
15364
15379
|
throw error;
|
|
15365
15380
|
}
|
|
@@ -15445,43 +15460,43 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15445
15460
|
};
|
|
15446
15461
|
}
|
|
15447
15462
|
get iceGatheringState$() {
|
|
15448
|
-
return this.cachedObservable("iceGatheringState$", () => this._iceGatheringState$.asObservable().pipe((0, import_cjs$
|
|
15463
|
+
return this.cachedObservable("iceGatheringState$", () => this._iceGatheringState$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15449
15464
|
}
|
|
15450
15465
|
get mediaTrackEnded$() {
|
|
15451
|
-
return this.cachedObservable("mediaTrackEnded$", () => this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$
|
|
15466
|
+
return this.cachedObservable("mediaTrackEnded$", () => this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15452
15467
|
}
|
|
15453
15468
|
get errors$() {
|
|
15454
|
-
return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$
|
|
15469
|
+
return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15455
15470
|
}
|
|
15456
15471
|
get iceCandidates$() {
|
|
15457
|
-
return this.cachedObservable("iceCandidates$", () => this._iceCandidates$.asObservable().pipe((0, import_cjs$
|
|
15472
|
+
return this.cachedObservable("iceCandidates$", () => this._iceCandidates$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15458
15473
|
}
|
|
15459
15474
|
get initialized$() {
|
|
15460
|
-
return this.cachedObservable("initialized$", () => this._initialized$.asObservable().pipe((0, import_cjs$
|
|
15475
|
+
return this.cachedObservable("initialized$", () => this._initialized$.asObservable().pipe((0, import_cjs$14.filter)((initialized) => initialized), (0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15461
15476
|
}
|
|
15462
15477
|
get remoteDescription$() {
|
|
15463
|
-
return this.cachedObservable("remoteDescription$", () => this._remoteDescription$.asObservable().pipe((0, import_cjs$
|
|
15478
|
+
return this.cachedObservable("remoteDescription$", () => this._remoteDescription$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15464
15479
|
}
|
|
15465
15480
|
get localStream$() {
|
|
15466
|
-
return this.cachedObservable("localStream$", () => this.localStreamController.localStream$.pipe((0, import_cjs$
|
|
15481
|
+
return this.cachedObservable("localStream$", () => this.localStreamController.localStream$.pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15467
15482
|
}
|
|
15468
15483
|
get remoteStream$() {
|
|
15469
|
-
return this.cachedObservable("remoteStream$", () => this._remoteStream$.asObservable().pipe((0, import_cjs$
|
|
15484
|
+
return this.cachedObservable("remoteStream$", () => this._remoteStream$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15470
15485
|
}
|
|
15471
15486
|
get localAudioTracks$() {
|
|
15472
|
-
return this.cachedObservable("localAudioTracks$", () => this.localStreamController.localAudioTracks$.pipe((0, import_cjs$
|
|
15487
|
+
return this.cachedObservable("localAudioTracks$", () => this.localStreamController.localAudioTracks$.pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15473
15488
|
}
|
|
15474
15489
|
get localVideoTracks$() {
|
|
15475
|
-
return this.cachedObservable("localVideoTracks$", () => this.localStreamController.localVideoTracks$.pipe((0, import_cjs$
|
|
15490
|
+
return this.cachedObservable("localVideoTracks$", () => this.localStreamController.localVideoTracks$.pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15476
15491
|
}
|
|
15477
15492
|
get iceConnectionState$() {
|
|
15478
|
-
return this.cachedObservable("iceConnectionState$", () => this._iceConnectionState$.asObservable().pipe((0, import_cjs$
|
|
15493
|
+
return this.cachedObservable("iceConnectionState$", () => this._iceConnectionState$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15479
15494
|
}
|
|
15480
15495
|
get connectionState$() {
|
|
15481
|
-
return this.cachedObservable("connectionState$", () => this._connectionState$.asObservable().pipe((0, import_cjs$
|
|
15496
|
+
return this.cachedObservable("connectionState$", () => this._connectionState$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15482
15497
|
}
|
|
15483
15498
|
get signalingState$() {
|
|
15484
|
-
return this.cachedObservable("signalingState$", () => this._signalingState$.asObservable().pipe((0, import_cjs$
|
|
15499
|
+
return this.cachedObservable("signalingState$", () => this._signalingState$.asObservable().pipe((0, import_cjs$14.takeUntil)(this.destroyed$)));
|
|
15485
15500
|
}
|
|
15486
15501
|
get type() {
|
|
15487
15502
|
return this._type;
|
|
@@ -15594,17 +15609,17 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15594
15609
|
async doInit() {
|
|
15595
15610
|
try {
|
|
15596
15611
|
this.setupPeerConnection();
|
|
15597
|
-
this.subscribeTo(this.negotiationNeeded$.pipe((0, import_cjs$
|
|
15612
|
+
this.subscribeTo(this.negotiationNeeded$.pipe((0, import_cjs$14.auditTime)(0), (0, import_cjs$14.exhaustMap)(async () => this.startNegotiation())), {
|
|
15598
15613
|
next: () => {
|
|
15599
|
-
logger$
|
|
15614
|
+
logger$15.debug("[RTCPeerConnectionController] Start Negotiation completed successfully");
|
|
15600
15615
|
},
|
|
15601
15616
|
error: (error) => {
|
|
15602
|
-
logger$
|
|
15617
|
+
logger$15.error("[RTCPeerConnectionController] Start Negotiation error:", error);
|
|
15603
15618
|
this._errors$.next(error);
|
|
15604
15619
|
}
|
|
15605
15620
|
});
|
|
15606
|
-
this.subscribeTo((0, import_cjs$
|
|
15607
|
-
logger$
|
|
15621
|
+
this.subscribeTo((0, import_cjs$14.merge)(this.deviceController.selectedAudioInputDevice$.pipe((0, import_cjs$14.map)((deviceInfo) => ["audio", deviceInfo])), this.deviceController.selectedVideoInputDevice$.pipe((0, import_cjs$14.map)((deviceInfo) => ["video", deviceInfo]))).pipe((0, import_cjs$14.skipWhile)(() => !this.localStreamController.localStream)), async ([kind, deviceInfo]) => {
|
|
15622
|
+
logger$15.debug(`[RTCPeerConnectionController] Selected input device changed for:`, {
|
|
15608
15623
|
kind,
|
|
15609
15624
|
deviceInfo
|
|
15610
15625
|
});
|
|
@@ -15621,7 +15636,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15621
15636
|
this._initialized$.next(true);
|
|
15622
15637
|
}
|
|
15623
15638
|
} catch (error) {
|
|
15624
|
-
logger$
|
|
15639
|
+
logger$15.error("[RTCPeerConnectionController] Initialization error:", error);
|
|
15625
15640
|
this._errors$.next(error);
|
|
15626
15641
|
this.destroy();
|
|
15627
15642
|
}
|
|
@@ -15653,22 +15668,22 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15653
15668
|
}
|
|
15654
15669
|
async startNegotiation() {
|
|
15655
15670
|
if (this.isNegotiating) {
|
|
15656
|
-
logger$
|
|
15671
|
+
logger$15.debug("[RTCPeerConnectionController] Negotiation already in progress, skipping.");
|
|
15657
15672
|
return;
|
|
15658
15673
|
}
|
|
15659
15674
|
this.setupEventListeners();
|
|
15660
15675
|
if (this.type === "answer") {
|
|
15661
|
-
logger$
|
|
15676
|
+
logger$15.debug("[RTCPeerConnectionController] This is an answer type still, skipping offer creation.");
|
|
15662
15677
|
return;
|
|
15663
15678
|
}
|
|
15664
15679
|
this._isNegotiating$.next(true);
|
|
15665
|
-
logger$
|
|
15680
|
+
logger$15.debug("[RTCPeerConnectionController] Starting negotiation.");
|
|
15666
15681
|
try {
|
|
15667
15682
|
const { offerOptions } = this;
|
|
15668
|
-
logger$
|
|
15683
|
+
logger$15.debug("[RTCPeerConnectionController] Creating offer with options:", offerOptions);
|
|
15669
15684
|
await this.createOffer(offerOptions);
|
|
15670
15685
|
} catch (error) {
|
|
15671
|
-
logger$
|
|
15686
|
+
logger$15.error("[RTCPeerConnectionController] Error during negotiation:", error);
|
|
15672
15687
|
this._errors$.next(error);
|
|
15673
15688
|
}
|
|
15674
15689
|
}
|
|
@@ -15684,14 +15699,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15684
15699
|
let readyToConnect = status !== "failed";
|
|
15685
15700
|
try {
|
|
15686
15701
|
if (status === "received" && sdp) {
|
|
15687
|
-
logger$
|
|
15702
|
+
logger$15.debug("[RTCPeerConnectionController] Received answer SDP:", sdp);
|
|
15688
15703
|
await this._setRemoteDescription({
|
|
15689
15704
|
type: "answer",
|
|
15690
15705
|
sdp
|
|
15691
15706
|
});
|
|
15692
15707
|
}
|
|
15693
15708
|
} catch (error) {
|
|
15694
|
-
logger$
|
|
15709
|
+
logger$15.error("[RTCPeerConnectionController] Error updating answer status:", error);
|
|
15695
15710
|
this._errors$.next(error);
|
|
15696
15711
|
readyToConnect = false;
|
|
15697
15712
|
} finally {
|
|
@@ -15710,7 +15725,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15710
15725
|
await this.handleOfferReceived();
|
|
15711
15726
|
break;
|
|
15712
15727
|
case "failed":
|
|
15713
|
-
logger$
|
|
15728
|
+
logger$15.error("[RTCPeerConnectionController] Offer failed to be processed by remote.");
|
|
15714
15729
|
break;
|
|
15715
15730
|
case "sent":
|
|
15716
15731
|
default:
|
|
@@ -15742,7 +15757,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15742
15757
|
}
|
|
15743
15758
|
await this.setupLocalTracks();
|
|
15744
15759
|
const { answerOptions } = this;
|
|
15745
|
-
logger$
|
|
15760
|
+
logger$15.debug("[RTCPeerConnectionController] Creating inbound answer with options:", answerOptions);
|
|
15746
15761
|
await this.createAnswer(answerOptions);
|
|
15747
15762
|
}
|
|
15748
15763
|
async handleOfferReceived() {
|
|
@@ -15750,7 +15765,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15750
15765
|
this._isNegotiating$.next(true);
|
|
15751
15766
|
await this._setRemoteDescription(this.sdpInit);
|
|
15752
15767
|
const { answerOptions } = this;
|
|
15753
|
-
logger$
|
|
15768
|
+
logger$15.debug("[RTCPeerConnectionController] Creating answer with options:", answerOptions);
|
|
15754
15769
|
await this.createAnswer(answerOptions);
|
|
15755
15770
|
}
|
|
15756
15771
|
readyToConnect() {
|
|
@@ -15758,7 +15773,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15758
15773
|
this.connectionTimer = setTimeout(() => {
|
|
15759
15774
|
this.removeConnectionTimer();
|
|
15760
15775
|
if (this.peerConnection?.connectionState !== "connected") {
|
|
15761
|
-
logger$
|
|
15776
|
+
logger$15.debug("[RTCPeerConnectionController] Connection timeout, restarting ICE gathering with relay only.");
|
|
15762
15777
|
this.iceGatheringController.restartICEGatheringWithRelayOnly();
|
|
15763
15778
|
}
|
|
15764
15779
|
}, this.connectionTimeout);
|
|
@@ -15780,14 +15795,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15780
15795
|
const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
|
|
15781
15796
|
if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
|
|
15782
15797
|
result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
|
|
15783
|
-
logger$
|
|
15798
|
+
logger$15.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
|
|
15784
15799
|
preferredAudioCodecs,
|
|
15785
15800
|
preferredVideoCodecs
|
|
15786
15801
|
});
|
|
15787
15802
|
}
|
|
15788
15803
|
if (stereo) {
|
|
15789
15804
|
result = enableStereoOpus(result);
|
|
15790
|
-
logger$
|
|
15805
|
+
logger$15.debug("[RTCPeerConnectionController] Applied stereo Opus to SDP");
|
|
15791
15806
|
}
|
|
15792
15807
|
return Promise.resolve(result);
|
|
15793
15808
|
}
|
|
@@ -15846,18 +15861,18 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15846
15861
|
...this.peerConnection.getConfiguration(),
|
|
15847
15862
|
iceTransportPolicy: "relay"
|
|
15848
15863
|
});
|
|
15849
|
-
logger$
|
|
15864
|
+
logger$15.debug("[RTCPeerConnectionController] ICE transport policy set to relay-only");
|
|
15850
15865
|
} catch (error) {
|
|
15851
|
-
logger$
|
|
15866
|
+
logger$15.warn("[RTCPeerConnectionController] Failed to set relay-only policy:", error);
|
|
15852
15867
|
}
|
|
15853
15868
|
this.setupEventListeners();
|
|
15854
15869
|
this._isNegotiating$.next(true);
|
|
15855
|
-
logger$
|
|
15870
|
+
logger$15.debug(`[RTCPeerConnectionController] Triggering ICE restart${relayOnly ? " (relay-only)" : ""}.`);
|
|
15856
15871
|
try {
|
|
15857
15872
|
const offer = await this.peerConnection.createOffer({ iceRestart: true });
|
|
15858
15873
|
await this.setLocalDescription(offer);
|
|
15859
15874
|
} catch (error) {
|
|
15860
|
-
logger$
|
|
15875
|
+
logger$15.error("[RTCPeerConnectionController] ICE restart offer failed:", error);
|
|
15861
15876
|
this._errors$.next(error);
|
|
15862
15877
|
this.negotiationEnded();
|
|
15863
15878
|
if (policyChanged) this.restoreIceTransportPolicy();
|
|
@@ -15871,9 +15886,9 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15871
15886
|
...this.peerConnection.getConfiguration(),
|
|
15872
15887
|
iceTransportPolicy: this.options.relayOnly ? "relay" : "all"
|
|
15873
15888
|
});
|
|
15874
|
-
logger$
|
|
15889
|
+
logger$15.debug("[RTCPeerConnectionController] ICE transport policy restored");
|
|
15875
15890
|
} catch (error) {
|
|
15876
|
-
logger$
|
|
15891
|
+
logger$15.warn("[RTCPeerConnectionController] Failed to restore ICE transport policy:", error);
|
|
15877
15892
|
}
|
|
15878
15893
|
}
|
|
15879
15894
|
/**
|
|
@@ -15885,13 +15900,13 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15885
15900
|
await this.setupRemoteTracks();
|
|
15886
15901
|
}
|
|
15887
15902
|
async setupLocalTracks() {
|
|
15888
|
-
logger$
|
|
15903
|
+
logger$15.debug("[RTCPeerConnectionController] Setting up local tracks/transceivers.");
|
|
15889
15904
|
const localStream = this.localStream ?? await this.localStreamController.buildLocalStream();
|
|
15890
15905
|
if (this.transceiverController?.useAddStream ?? false) {
|
|
15891
|
-
logger$
|
|
15906
|
+
logger$15.warn("[RTCPeerConnectionController] Using deprecated addStream API to add local stream.");
|
|
15892
15907
|
this.peerConnection?.addStream(localStream);
|
|
15893
15908
|
if (!this.isNegotiating) {
|
|
15894
|
-
logger$
|
|
15909
|
+
logger$15.debug("[RTCPeerConnectionController] Forcing negotiationneeded after local tracks setup.");
|
|
15895
15910
|
this.negotiationNeeded$.next();
|
|
15896
15911
|
}
|
|
15897
15912
|
return;
|
|
@@ -15907,7 +15922,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15907
15922
|
const transceivers = (kind === "audio" ? this.transceiverController?.audioTransceivers : this.transceiverController?.videoTransceivers) ?? [];
|
|
15908
15923
|
await this.transceiverController?.setupTransceiverSender(track, localStream, transceivers[index]);
|
|
15909
15924
|
} else {
|
|
15910
|
-
logger$
|
|
15925
|
+
logger$15.debug(`[RTCPeerConnectionController] Using addTrack for local ${kind} track:`, track.id);
|
|
15911
15926
|
this.peerConnection?.addTrack(track, localStream);
|
|
15912
15927
|
}
|
|
15913
15928
|
}
|
|
@@ -15924,7 +15939,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15924
15939
|
async setupRemoteTracks() {
|
|
15925
15940
|
if (!this.peerConnection) throw new DependencyError("RTCPeerConnection is not initialized");
|
|
15926
15941
|
this.peerConnection.ontrack = (event) => {
|
|
15927
|
-
logger$
|
|
15942
|
+
logger$15.debug("[RTCPeerConnectionController] Remote track received:", event.track.kind);
|
|
15928
15943
|
if (event.streams[0]) this._remoteStream$.next(event.streams[0]);
|
|
15929
15944
|
else {
|
|
15930
15945
|
const existingTracks = this._remoteStream$.value?.getTracks() ?? [];
|
|
@@ -15950,9 +15965,9 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15950
15965
|
try {
|
|
15951
15966
|
const localStream = this.localStreamController.addTrack(track);
|
|
15952
15967
|
this.peerConnection.addTrack(track, localStream);
|
|
15953
|
-
logger$
|
|
15968
|
+
logger$15.debug(`[RTCPeerConnectionController] ${track.kind} track added:`, track.id);
|
|
15954
15969
|
} catch (error) {
|
|
15955
|
-
logger$
|
|
15970
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to add ${track.kind} track:`, error);
|
|
15956
15971
|
this._errors$.next(error);
|
|
15957
15972
|
throw error;
|
|
15958
15973
|
}
|
|
@@ -15969,15 +15984,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15969
15984
|
}
|
|
15970
15985
|
const sender = this.peerConnection.getSenders().find((sender$1) => sender$1.track?.id === trackId);
|
|
15971
15986
|
if (!sender) {
|
|
15972
|
-
logger$
|
|
15987
|
+
logger$15.debug(`[RTCPeerConnectionController] track not found: ${trackId}`);
|
|
15973
15988
|
return;
|
|
15974
15989
|
}
|
|
15975
15990
|
try {
|
|
15976
15991
|
this.peerConnection.removeTrack(sender);
|
|
15977
15992
|
this.localStreamController.removeTrack(trackId);
|
|
15978
|
-
logger$
|
|
15993
|
+
logger$15.debug(`[RTCPeerConnectionController] ${sender.track?.kind} track removed:`, trackId);
|
|
15979
15994
|
} catch (error) {
|
|
15980
|
-
logger$
|
|
15995
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to remove ${sender.track?.kind} track:`, error);
|
|
15981
15996
|
this._errors$.next(error);
|
|
15982
15997
|
throw error;
|
|
15983
15998
|
}
|
|
@@ -16004,7 +16019,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16004
16019
|
async replaceAudioTrackWithConstraints(constraints) {
|
|
16005
16020
|
const senders = this.peerConnection?.getSenders().filter((s) => s.track?.kind === "audio" && s.track.readyState === "live");
|
|
16006
16021
|
if (!senders || senders.length === 0) {
|
|
16007
|
-
logger$
|
|
16022
|
+
logger$15.warn("[RTCPeerConnectionController] No live audio sender to replace");
|
|
16008
16023
|
return;
|
|
16009
16024
|
}
|
|
16010
16025
|
for (const sender of senders) {
|
|
@@ -16022,7 +16037,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16022
16037
|
const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
|
|
16023
16038
|
await sender.replaceTrack(newTrack);
|
|
16024
16039
|
this.localStreamController.addTrack(newTrack);
|
|
16025
|
-
logger$
|
|
16040
|
+
logger$15.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
|
|
16026
16041
|
}
|
|
16027
16042
|
}
|
|
16028
16043
|
/**
|
|
@@ -16030,7 +16045,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16030
16045
|
* Completes all observables to prevent memory leaks.
|
|
16031
16046
|
*/
|
|
16032
16047
|
destroy() {
|
|
16033
|
-
logger$
|
|
16048
|
+
logger$15.debug(`[RTCPeerConnectionController] Destroying RTCPeerConnectionController. ${this.propose}`);
|
|
16034
16049
|
this.removeConnectionTimer();
|
|
16035
16050
|
this._iceGatheringController?.destroy();
|
|
16036
16051
|
this.localStreamController.destroy();
|
|
@@ -16054,7 +16069,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16054
16069
|
}
|
|
16055
16070
|
stopRemoteTracks() {
|
|
16056
16071
|
this._remoteStream$.value?.getTracks().forEach((track) => {
|
|
16057
|
-
logger$
|
|
16072
|
+
logger$15.debug(`[RTCPeerConnectionController] Stopping remote track: ${track.kind}`);
|
|
16058
16073
|
track.stop();
|
|
16059
16074
|
});
|
|
16060
16075
|
}
|
|
@@ -16071,7 +16086,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16071
16086
|
...params,
|
|
16072
16087
|
sdp: finalRemote
|
|
16073
16088
|
};
|
|
16074
|
-
logger$
|
|
16089
|
+
logger$15.debug("[RTCPeerConnectionController] Setting remote description:", answer);
|
|
16075
16090
|
return this.peerConnection.setRemoteDescription(answer);
|
|
16076
16091
|
}
|
|
16077
16092
|
};
|
|
@@ -16109,8 +16124,8 @@ function isVertoPingInnerParams(value) {
|
|
|
16109
16124
|
|
|
16110
16125
|
//#endregion
|
|
16111
16126
|
//#region src/managers/VertoManager.ts
|
|
16112
|
-
var import_cjs$
|
|
16113
|
-
const logger$
|
|
16127
|
+
var import_cjs$13 = require_cjs();
|
|
16128
|
+
const logger$14 = getLogger();
|
|
16114
16129
|
var VertoManager = class extends Destroyable {
|
|
16115
16130
|
constructor(callSession) {
|
|
16116
16131
|
super();
|
|
@@ -16136,6 +16151,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16136
16151
|
this._screenShareTimeoutMs = 5e4;
|
|
16137
16152
|
this._nodeId$ = this.createBehaviorSubject(options.nodeId ?? null);
|
|
16138
16153
|
this.onError = options.onError;
|
|
16154
|
+
this.onModifyFailed = options.onModifyFailed;
|
|
16139
16155
|
this.initSubscriptions();
|
|
16140
16156
|
this.initMainPeerConnection();
|
|
16141
16157
|
}
|
|
@@ -16148,7 +16164,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16148
16164
|
try {
|
|
16149
16165
|
await this.executeVerto(vertoModifyMessage);
|
|
16150
16166
|
} catch (error) {
|
|
16151
|
-
logger$
|
|
16167
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto hold:", error);
|
|
16152
16168
|
throw error;
|
|
16153
16169
|
}
|
|
16154
16170
|
}
|
|
@@ -16161,7 +16177,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16161
16177
|
try {
|
|
16162
16178
|
await this.executeVerto(vertoModifyMessage);
|
|
16163
16179
|
} catch (error) {
|
|
16164
|
-
logger$
|
|
16180
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto unhold:", error);
|
|
16165
16181
|
throw error;
|
|
16166
16182
|
}
|
|
16167
16183
|
}
|
|
@@ -16201,7 +16217,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16201
16217
|
return rtcPeerConnection;
|
|
16202
16218
|
}
|
|
16203
16219
|
get signalingStatus$() {
|
|
16204
|
-
return this.cachedObservable("signalingStatus$", () => (0, import_cjs$
|
|
16220
|
+
return this.cachedObservable("signalingStatus$", () => (0, import_cjs$13.merge)(this._signalingStatus$.pipe(filterNull()), this.mainPeerConnection.connectionState$.pipe((0, import_cjs$13.filter)((connectionState) => [
|
|
16205
16221
|
"connected",
|
|
16206
16222
|
"disconnected",
|
|
16207
16223
|
"failed"
|
|
@@ -16214,7 +16230,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16214
16230
|
if (event.member_id) this.setSelfIdIfNull(event.member_id);
|
|
16215
16231
|
});
|
|
16216
16232
|
this.subscribeTo(this.vertoMedia$, (event) => {
|
|
16217
|
-
logger$
|
|
16233
|
+
logger$14.debug("[WebRTCManager] Received Verto media event (early media SDP):", event);
|
|
16218
16234
|
this._signalingStatus$.next("ringing");
|
|
16219
16235
|
const { sdp, callID } = event;
|
|
16220
16236
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -16223,7 +16239,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16223
16239
|
});
|
|
16224
16240
|
});
|
|
16225
16241
|
this.subscribeTo(this.vertoAnswer$, (event) => {
|
|
16226
|
-
logger$
|
|
16242
|
+
logger$14.debug("[WebRTCManager] Received Verto answer event:", event);
|
|
16227
16243
|
this._signalingStatus$.next("connecting");
|
|
16228
16244
|
const { sdp, callID } = event;
|
|
16229
16245
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -16232,7 +16248,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16232
16248
|
});
|
|
16233
16249
|
});
|
|
16234
16250
|
this.subscribeTo(this.vertoMediaParams$, (event) => {
|
|
16235
|
-
logger$
|
|
16251
|
+
logger$14.debug("[WebRTCManager] Received Verto mediaParams event:", event);
|
|
16236
16252
|
const { mediaParams, callID } = event;
|
|
16237
16253
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(callID);
|
|
16238
16254
|
const { audio, video } = mediaParams;
|
|
@@ -16246,13 +16262,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16246
16262
|
timestamp: Date.now()
|
|
16247
16263
|
});
|
|
16248
16264
|
} catch (error) {
|
|
16249
|
-
logger$
|
|
16265
|
+
logger$14.warn("[WebRTCManager] Error applying server-pushed media params:", error);
|
|
16250
16266
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16251
16267
|
}
|
|
16252
16268
|
})();
|
|
16253
16269
|
});
|
|
16254
16270
|
this.subscribeTo(this.vertoPing$, (vertoPing) => {
|
|
16255
|
-
this.attachManager.attach(this.
|
|
16271
|
+
this.attachManager.attach(this.buildAttachableCall());
|
|
16256
16272
|
this.sendVertoPong(vertoPing);
|
|
16257
16273
|
});
|
|
16258
16274
|
}
|
|
@@ -16268,13 +16284,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16268
16284
|
*/
|
|
16269
16285
|
setNodeIdIfNull(nodeId) {
|
|
16270
16286
|
if (!this._nodeId$.value && nodeId) {
|
|
16271
|
-
logger$
|
|
16287
|
+
logger$14.debug(`[WebRTCManager] Early node_id set: ${nodeId}`);
|
|
16272
16288
|
this._nodeId$.next(nodeId);
|
|
16273
16289
|
}
|
|
16274
16290
|
}
|
|
16275
16291
|
setSelfIdIfNull(selfId) {
|
|
16276
16292
|
if (!this._selfId$.value && selfId) {
|
|
16277
|
-
logger$
|
|
16293
|
+
logger$14.debug(`[WebRTCManager] Early selfId set: ${selfId}`);
|
|
16278
16294
|
this._selfId$.next(selfId);
|
|
16279
16295
|
}
|
|
16280
16296
|
}
|
|
@@ -16283,7 +16299,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16283
16299
|
const vertoPongMessage = VertoPong({ ...vertoPing });
|
|
16284
16300
|
await this.executeVerto(vertoPongMessage);
|
|
16285
16301
|
} catch (error) {
|
|
16286
|
-
logger$
|
|
16302
|
+
logger$14.warn("[WebRTCManager] Call might disconnect, error sending Verto pong:", error);
|
|
16287
16303
|
this.onError?.(new VertoPongError(error));
|
|
16288
16304
|
}
|
|
16289
16305
|
}
|
|
@@ -16293,7 +16309,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16293
16309
|
if (audio) await this.mainPeerConnection.updateSendersConstraints("audio", audio);
|
|
16294
16310
|
if (video) await this.mainPeerConnection.updateSendersConstraints("video", video);
|
|
16295
16311
|
} catch (error) {
|
|
16296
|
-
logger$
|
|
16312
|
+
logger$14.warn("[WebRTCManager] Error updating media constraints:", error);
|
|
16297
16313
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16298
16314
|
throw error;
|
|
16299
16315
|
}
|
|
@@ -16301,6 +16317,15 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16301
16317
|
get selfId() {
|
|
16302
16318
|
return this._selfId$.value;
|
|
16303
16319
|
}
|
|
16320
|
+
/** Build an AttachableCall from the current call state. */
|
|
16321
|
+
buildAttachableCall(idOverride) {
|
|
16322
|
+
return {
|
|
16323
|
+
nodeId: this.nodeId ?? void 0,
|
|
16324
|
+
id: idOverride ?? this.webRtcCallSession.id,
|
|
16325
|
+
to: this.webRtcCallSession.to,
|
|
16326
|
+
mediaDirections: this.webRtcCallSession.mediaDirections
|
|
16327
|
+
};
|
|
16328
|
+
}
|
|
16304
16329
|
/**
|
|
16305
16330
|
* Request a video keyframe via RTCP PLI/FIR.
|
|
16306
16331
|
*
|
|
@@ -16314,20 +16339,20 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16314
16339
|
try {
|
|
16315
16340
|
const pc = this.mainPeerConnection.peerConnection;
|
|
16316
16341
|
if (!pc) {
|
|
16317
|
-
logger$
|
|
16342
|
+
logger$14.warn("[WebRTCManager] No peer connection for keyframe request");
|
|
16318
16343
|
return;
|
|
16319
16344
|
}
|
|
16320
16345
|
const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
|
|
16321
16346
|
if (!videoReceiver) {
|
|
16322
|
-
logger$
|
|
16347
|
+
logger$14.warn("[WebRTCManager] No video receiver for keyframe request");
|
|
16323
16348
|
return;
|
|
16324
16349
|
}
|
|
16325
16350
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
16326
16351
|
videoReceiver.requestKeyFrame();
|
|
16327
|
-
logger$
|
|
16328
|
-
} else logger$
|
|
16352
|
+
logger$14.debug("[WebRTCManager] Keyframe requested via RTCRtpReceiver.requestKeyFrame()");
|
|
16353
|
+
} else logger$14.debug("[WebRTCManager] requestKeyFrame() not supported, skipping");
|
|
16329
16354
|
} catch (error) {
|
|
16330
|
-
logger$
|
|
16355
|
+
logger$14.warn("[WebRTCManager] Keyframe request failed (non-fatal):", error);
|
|
16331
16356
|
}
|
|
16332
16357
|
}
|
|
16333
16358
|
/**
|
|
@@ -16345,13 +16370,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16345
16370
|
try {
|
|
16346
16371
|
const controller = this.mainPeerConnection;
|
|
16347
16372
|
if (!controller.peerConnection) {
|
|
16348
|
-
logger$
|
|
16373
|
+
logger$14.warn("[WebRTCManager] No peer connection for ICE restart");
|
|
16349
16374
|
return;
|
|
16350
16375
|
}
|
|
16351
16376
|
await controller.triggerIceRestart(relayOnly);
|
|
16352
|
-
logger$
|
|
16377
|
+
logger$14.info(`[WebRTCManager] ICE restart initiated${relayOnly ? " (relay-only)" : ""}`);
|
|
16353
16378
|
} catch (error) {
|
|
16354
|
-
logger$
|
|
16379
|
+
logger$14.error("[WebRTCManager] ICE restart failed:", error);
|
|
16355
16380
|
throw error;
|
|
16356
16381
|
}
|
|
16357
16382
|
}
|
|
@@ -16369,13 +16394,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16369
16394
|
const entries = Array.from(this._rtcPeerConnectionsMap.entries());
|
|
16370
16395
|
for (const [id, controller] of entries) try {
|
|
16371
16396
|
if (!controller.peerConnection) {
|
|
16372
|
-
logger$
|
|
16397
|
+
logger$14.debug(`[WebRTCManager] No peer connection for leg ${id}, skipping ICE restart`);
|
|
16373
16398
|
continue;
|
|
16374
16399
|
}
|
|
16375
16400
|
await controller.triggerIceRestart(relayOnly);
|
|
16376
|
-
logger$
|
|
16401
|
+
logger$14.info(`[WebRTCManager] ICE restart initiated for leg ${id}${relayOnly ? " (relay-only)" : ""}`);
|
|
16377
16402
|
} catch (error) {
|
|
16378
|
-
logger$
|
|
16403
|
+
logger$14.warn(`[WebRTCManager] ICE restart failed for leg ${id}:`, error);
|
|
16379
16404
|
}
|
|
16380
16405
|
}
|
|
16381
16406
|
/**
|
|
@@ -16387,7 +16412,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16387
16412
|
requestKeyframeAll() {
|
|
16388
16413
|
for (const [id, controller] of this._rtcPeerConnectionsMap) {
|
|
16389
16414
|
if (controller.isScreenShare) {
|
|
16390
|
-
logger$
|
|
16415
|
+
logger$14.debug(`[WebRTCManager] Skipping keyframe for send-only screen share leg ${id}`);
|
|
16391
16416
|
continue;
|
|
16392
16417
|
}
|
|
16393
16418
|
try {
|
|
@@ -16397,33 +16422,33 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16397
16422
|
if (!videoReceiver) continue;
|
|
16398
16423
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
16399
16424
|
videoReceiver.requestKeyFrame();
|
|
16400
|
-
logger$
|
|
16425
|
+
logger$14.debug(`[WebRTCManager] Keyframe requested for leg ${id}`);
|
|
16401
16426
|
}
|
|
16402
16427
|
} catch (error) {
|
|
16403
|
-
logger$
|
|
16428
|
+
logger$14.warn(`[WebRTCManager] Keyframe request failed for leg ${id} (non-fatal):`, error);
|
|
16404
16429
|
}
|
|
16405
16430
|
}
|
|
16406
16431
|
}
|
|
16407
16432
|
get callJoinedEvent$() {
|
|
16408
|
-
return this.webRtcCallSession.callEvent$.pipe((0, import_cjs$
|
|
16433
|
+
return this.webRtcCallSession.callEvent$.pipe((0, import_cjs$13.filter)(isCallJoinedPayload), (0, import_cjs$13.takeUntil)(this.destroyed$));
|
|
16409
16434
|
}
|
|
16410
16435
|
get vertoMedia$() {
|
|
16411
|
-
return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaInnerParams, "params"), (0, import_cjs$
|
|
16436
|
+
return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaInnerParams, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$));
|
|
16412
16437
|
}
|
|
16413
16438
|
get vertoAnswer$() {
|
|
16414
|
-
return this.cachedObservable("vertoAnswer$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$
|
|
16439
|
+
return this.cachedObservable("vertoAnswer$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$)));
|
|
16415
16440
|
}
|
|
16416
16441
|
get vertoMediaParams$() {
|
|
16417
|
-
return this.cachedObservable("vertoMediaParams$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$
|
|
16442
|
+
return this.cachedObservable("vertoMediaParams$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$)));
|
|
16418
16443
|
}
|
|
16419
16444
|
get vertoBye$() {
|
|
16420
|
-
return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$
|
|
16445
|
+
return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$)));
|
|
16421
16446
|
}
|
|
16422
16447
|
get vertoAttach$() {
|
|
16423
|
-
return this.cachedObservable("vertoAttach$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$
|
|
16448
|
+
return this.cachedObservable("vertoAttach$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$)));
|
|
16424
16449
|
}
|
|
16425
16450
|
get vertoPing$() {
|
|
16426
|
-
return this.cachedObservable("vertoPing$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$
|
|
16451
|
+
return this.cachedObservable("vertoPing$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$13.takeUntil)(this.destroyed$)));
|
|
16427
16452
|
}
|
|
16428
16453
|
async executeVerto(message, optionals = {}) {
|
|
16429
16454
|
const webrtcVertoMessage = WebrtcVerto({
|
|
@@ -16448,7 +16473,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16448
16473
|
}
|
|
16449
16474
|
async sendLocalDescription(message, rtcPeerConnController) {
|
|
16450
16475
|
const vertoMethod = message.method;
|
|
16451
|
-
const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController,
|
|
16476
|
+
const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController, message);
|
|
16452
16477
|
try {
|
|
16453
16478
|
const response = await this.executeVerto(message, optionalsParams);
|
|
16454
16479
|
switch (vertoMethod) {
|
|
@@ -16461,8 +16486,9 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16461
16486
|
default:
|
|
16462
16487
|
}
|
|
16463
16488
|
} catch (error) {
|
|
16464
|
-
logger$
|
|
16489
|
+
logger$14.error(`[WebRTCManager] Error sending Verto ${vertoMethod}:`, error);
|
|
16465
16490
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16491
|
+
if (vertoMethod === "verto.modify") this.onModifyFailed?.();
|
|
16466
16492
|
}
|
|
16467
16493
|
}
|
|
16468
16494
|
async processModifyResponse(response, rtcPeerConnController) {
|
|
@@ -16475,7 +16501,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16475
16501
|
sdp
|
|
16476
16502
|
});
|
|
16477
16503
|
} catch (error) {
|
|
16478
|
-
logger$
|
|
16504
|
+
logger$14.warn("[WebRTCManager] Error processing modify response:", error);
|
|
16479
16505
|
const modifyError = error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
16480
16506
|
this.onError?.(modifyError);
|
|
16481
16507
|
}
|
|
@@ -16487,19 +16513,24 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16487
16513
|
this._nodeId$.next(getValueFrom(response, "result.node_id") ?? null);
|
|
16488
16514
|
const memberId = getValueFrom(response, "result.result.result.memberID") ?? null;
|
|
16489
16515
|
const callId = getValueFrom(response, "result.result.result.callID") ?? null;
|
|
16490
|
-
logger$
|
|
16516
|
+
logger$14.debug("[WebRTCManager] Verto invite response:", {
|
|
16491
16517
|
callId,
|
|
16492
16518
|
memberId,
|
|
16493
16519
|
response
|
|
16494
16520
|
});
|
|
16495
16521
|
this._selfId$.next(memberId);
|
|
16496
16522
|
rtcPeerConnController.setMemberId(memberId);
|
|
16497
|
-
if (callId)
|
|
16498
|
-
|
|
16499
|
-
|
|
16500
|
-
logger$
|
|
16523
|
+
if (callId) {
|
|
16524
|
+
this.webRtcCallSession.addCallId(callId);
|
|
16525
|
+
this.attachManager.attach(this.buildAttachableCall(callId));
|
|
16526
|
+
} else logger$14.warn("[WebRTCManager] Cannot attach call, missing callId:", {
|
|
16527
|
+
nodeId: this.nodeId,
|
|
16528
|
+
callId
|
|
16529
|
+
});
|
|
16530
|
+
logger$14.info("[WebRTCManager] Verto invite successful");
|
|
16531
|
+
logger$14.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
|
|
16501
16532
|
} else {
|
|
16502
|
-
logger$
|
|
16533
|
+
logger$14.error("[WebRTCManager] Verto invite failed:", response);
|
|
16503
16534
|
const inviteError = response.error ? new JSONRPCError(response.error.code, response.error.message, response.error.data) : /* @__PURE__ */ new Error("Verto invite failed: unexpected response");
|
|
16504
16535
|
this.onError?.(inviteError);
|
|
16505
16536
|
}
|
|
@@ -16544,17 +16575,17 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16544
16575
|
if (options.initOffer) this.handleInboundAnswer(rtcPeerConnController);
|
|
16545
16576
|
}
|
|
16546
16577
|
async handleInboundAnswer(rtcPeerConnController) {
|
|
16547
|
-
logger$
|
|
16548
|
-
const vertoByeOrAccepted = await (0, import_cjs$
|
|
16578
|
+
logger$14.debug("[WebRTCManager] Waiting for inbound call to be accepted or rejected");
|
|
16579
|
+
const vertoByeOrAccepted = await (0, import_cjs$13.firstValueFrom)((0, import_cjs$13.race)(this.vertoBye$, this.webRtcCallSession.answered$).pipe((0, import_cjs$13.takeUntil)(this.destroyed$))).catch(() => null);
|
|
16549
16580
|
if (vertoByeOrAccepted === null) {
|
|
16550
|
-
logger$
|
|
16581
|
+
logger$14.debug("[WebRTCManager] Inbound answer handler aborted (destroyed).");
|
|
16551
16582
|
return;
|
|
16552
16583
|
}
|
|
16553
16584
|
if (isVertoByeMessage(vertoByeOrAccepted)) {
|
|
16554
|
-
logger$
|
|
16585
|
+
logger$14.info("[WebRTCManager] Inbound call ended by remote before answer.");
|
|
16555
16586
|
this.callSession?.destroy();
|
|
16556
16587
|
} else if (!vertoByeOrAccepted) {
|
|
16557
|
-
logger$
|
|
16588
|
+
logger$14.info("[WebRTCManager] Inbound call rejected by user.");
|
|
16558
16589
|
try {
|
|
16559
16590
|
await this.bye("USER_BUSY");
|
|
16560
16591
|
} finally {
|
|
@@ -16562,21 +16593,22 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16562
16593
|
this.callSession?.destroy();
|
|
16563
16594
|
}
|
|
16564
16595
|
} else {
|
|
16565
|
-
logger$
|
|
16596
|
+
logger$14.debug("[WebRTCManager] Inbound call accepted, creating SDP answer");
|
|
16566
16597
|
const answerOptions = this.webRtcCallSession.answerMediaOptions;
|
|
16567
16598
|
try {
|
|
16568
16599
|
await rtcPeerConnController.acceptInbound(answerOptions);
|
|
16569
16600
|
} catch (error) {
|
|
16570
|
-
logger$
|
|
16601
|
+
logger$14.error("[WebRTCManager] Error creating inbound answer:", error);
|
|
16571
16602
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16572
16603
|
}
|
|
16573
16604
|
}
|
|
16574
16605
|
}
|
|
16575
16606
|
setupVertoAttachHandler() {
|
|
16576
16607
|
this.subscribeTo(this.vertoAttach$, async (vertoAttach) => {
|
|
16577
|
-
logger$
|
|
16608
|
+
logger$14.debug("[WebRTCManager] Received Verto attach event for existing call:", vertoAttach);
|
|
16578
16609
|
const { callID } = vertoAttach;
|
|
16579
16610
|
await this.attachManager.attach({
|
|
16611
|
+
nodeId: this.nodeId ?? void 0,
|
|
16580
16612
|
id: callID,
|
|
16581
16613
|
to: vertoAttach.callee_id_number,
|
|
16582
16614
|
mediaDirections: {
|
|
@@ -16587,12 +16619,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16587
16619
|
});
|
|
16588
16620
|
}
|
|
16589
16621
|
initObservables(rtcPeerConnController) {
|
|
16590
|
-
this.mediaDirections$ = rtcPeerConnController.connectionState$.pipe((0, import_cjs$
|
|
16591
|
-
this.localStream$ = rtcPeerConnController.localStream$.pipe(filterNull(), (0, import_cjs$
|
|
16592
|
-
this.remoteStream$ = rtcPeerConnController.remoteStream$.pipe(filterNull(), (0, import_cjs$
|
|
16622
|
+
this.mediaDirections$ = rtcPeerConnController.connectionState$.pipe((0, import_cjs$13.filter)((state) => state === "connected"), (0, import_cjs$13.map)(() => rtcPeerConnController.mediaDirections), (0, import_cjs$13.startWith)(rtcPeerConnController.mediaDirections), (0, import_cjs$13.takeUntil)(this.destroyed$));
|
|
16623
|
+
this.localStream$ = rtcPeerConnController.localStream$.pipe(filterNull(), (0, import_cjs$13.takeUntil)(this.destroyed$));
|
|
16624
|
+
this.remoteStream$ = rtcPeerConnController.remoteStream$.pipe(filterNull(), (0, import_cjs$13.takeUntil)(this.destroyed$));
|
|
16593
16625
|
}
|
|
16594
16626
|
setupLocalDescriptionHandler(rtcPeerConnController) {
|
|
16595
|
-
this.subscribeTo(rtcPeerConnController.localDescription$.pipe((0, import_cjs$
|
|
16627
|
+
this.subscribeTo(rtcPeerConnController.localDescription$.pipe((0, import_cjs$13.filter)((description) => description !== null), (0, import_cjs$13.takeUntil)(this.destroyed$)), (description) => {
|
|
16596
16628
|
const { type, sdp } = description;
|
|
16597
16629
|
const dialogParams = this.dialogParams(rtcPeerConnController);
|
|
16598
16630
|
const initial = !rtcPeerConnController.firstSDPExchangeCompleted;
|
|
@@ -16621,11 +16653,11 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16621
16653
|
setupVertoByeHandler() {
|
|
16622
16654
|
this.subscribeTo(this.vertoBye$, () => {
|
|
16623
16655
|
this._signalingStatus$.next("disconnected");
|
|
16624
|
-
this.attachManager.detach(this.
|
|
16656
|
+
this.attachManager.detach(this.buildAttachableCall());
|
|
16625
16657
|
this.callSession?.destroy();
|
|
16626
16658
|
});
|
|
16627
16659
|
}
|
|
16628
|
-
getSendLocalSDPOptionalParams(rtcPeerConnController,
|
|
16660
|
+
getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMessage) {
|
|
16629
16661
|
let subscribe = void 0;
|
|
16630
16662
|
if (!rtcPeerConnController.firstSDPExchangeCompleted) {
|
|
16631
16663
|
subscribe = [];
|
|
@@ -16633,7 +16665,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16633
16665
|
else if (rtcPeerConnController.isAdditionalDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeAdditionalDevice);
|
|
16634
16666
|
else if (rtcPeerConnController.isScreenShare) subscribe.push(...PreferencesContainer.instance.inviteSubscribeScreenshare);
|
|
16635
16667
|
}
|
|
16636
|
-
const isInvite =
|
|
16668
|
+
const isInvite = isVertoInviteMessage(vertoMessage);
|
|
16637
16669
|
const isReattach = isInvite && this.webRtcCallSession.options.reattach;
|
|
16638
16670
|
return {
|
|
16639
16671
|
callID: rtcPeerConnController.id,
|
|
@@ -16642,13 +16674,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16642
16674
|
};
|
|
16643
16675
|
}
|
|
16644
16676
|
async sendLocalDescriptionOnceAccepted(vertoMessageRequest, rtcPeerConnectionController) {
|
|
16645
|
-
logger$
|
|
16646
|
-
const vertoByeOrAccepted = await (0, import_cjs$
|
|
16677
|
+
logger$14.debug("[WebRTCManager] Waiting for call to be accepted or ended before sending answer");
|
|
16678
|
+
const vertoByeOrAccepted = await (0, import_cjs$13.firstValueFrom)((0, import_cjs$13.race)(this.vertoBye$, this.webRtcCallSession.answered$));
|
|
16647
16679
|
if (isVertoByeMessage(vertoByeOrAccepted)) {
|
|
16648
|
-
logger$
|
|
16680
|
+
logger$14.info("[WebRTCManager] Call ended before answer was sent.");
|
|
16649
16681
|
this.callSession?.destroy();
|
|
16650
16682
|
} else if (!vertoByeOrAccepted) {
|
|
16651
|
-
logger$
|
|
16683
|
+
logger$14.info("[WebRTCManager] Call was not accepted, sending verto.bye.");
|
|
16652
16684
|
try {
|
|
16653
16685
|
await this.bye("USER_BUSY");
|
|
16654
16686
|
} finally {
|
|
@@ -16656,14 +16688,14 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16656
16688
|
this.callSession?.destroy();
|
|
16657
16689
|
}
|
|
16658
16690
|
} else {
|
|
16659
|
-
logger$
|
|
16691
|
+
logger$14.debug("[WebRTCManager] Call accepted, sending answer");
|
|
16660
16692
|
try {
|
|
16661
16693
|
this._signalingStatus$.next("connecting");
|
|
16662
16694
|
await this.sendLocalDescription(vertoMessageRequest, rtcPeerConnectionController);
|
|
16663
16695
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "sent" });
|
|
16664
|
-
await this.attachManager.attach(this.
|
|
16696
|
+
await this.attachManager.attach(this.buildAttachableCall());
|
|
16665
16697
|
} catch (error) {
|
|
16666
|
-
logger$
|
|
16698
|
+
logger$14.error("[WebRTCManager] Error sending Verto answer:", error);
|
|
16667
16699
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16668
16700
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "failed" });
|
|
16669
16701
|
}
|
|
@@ -16752,12 +16784,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16752
16784
|
this.subscribeTo(rtcPeerConnController.errors$, (error) => {
|
|
16753
16785
|
this.onError?.(error);
|
|
16754
16786
|
});
|
|
16755
|
-
await (0, import_cjs$
|
|
16787
|
+
await (0, import_cjs$13.firstValueFrom)(rtcPeerConnController.connectionState$.pipe((0, import_cjs$13.filter)((state) => state === "connected"), (0, import_cjs$13.take)(1), (0, import_cjs$13.timeout)(this._screenShareTimeoutMs)));
|
|
16756
16788
|
this._screenShareStatus$.next("started");
|
|
16757
|
-
logger$
|
|
16789
|
+
logger$14.info("[WebRTCManager] Screen share started successfully.");
|
|
16758
16790
|
return rtcPeerConnController.id;
|
|
16759
16791
|
} catch (error) {
|
|
16760
|
-
logger$
|
|
16792
|
+
logger$14.warn("[WebRTCManager] Error initializing additional peer connection:", error);
|
|
16761
16793
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
16762
16794
|
if (rtcPeerConnController) rtcPeerConnController.destroy();
|
|
16763
16795
|
this._screenShareStatus$.next("none");
|
|
@@ -16776,9 +16808,9 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16776
16808
|
if (removeTrack) return this.mainPeerConnection.stopTrackSender(removeTrack, { updateTransceiverDirection: true });
|
|
16777
16809
|
}
|
|
16778
16810
|
async removeScreenMedia() {
|
|
16779
|
-
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$
|
|
16811
|
+
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$14.warn("[WebRTCManager] No active screen share to stop.");
|
|
16780
16812
|
if (!this._screenShareId) {
|
|
16781
|
-
logger$
|
|
16813
|
+
logger$14.debug("[WebRTCManager] No screen share peer connection found.");
|
|
16782
16814
|
return;
|
|
16783
16815
|
}
|
|
16784
16816
|
this._screenShareStatus$.next("stopping");
|
|
@@ -16807,12 +16839,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16807
16839
|
dialogParams: this.dialogParams(rtcPeerConnController)
|
|
16808
16840
|
}));
|
|
16809
16841
|
} catch (error) {
|
|
16810
|
-
logger$
|
|
16842
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
|
|
16811
16843
|
throw error;
|
|
16812
16844
|
}
|
|
16813
16845
|
}
|
|
16814
16846
|
async bye(cause) {
|
|
16815
|
-
this.attachManager.detach(this.
|
|
16847
|
+
this.attachManager.detach(this.buildAttachableCall());
|
|
16816
16848
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(this.webRtcCallSession.id);
|
|
16817
16849
|
if (rtcPeerConnController) await this.executeVertoBye(rtcPeerConnController, cause);
|
|
16818
16850
|
}
|
|
@@ -16825,7 +16857,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16825
16857
|
try {
|
|
16826
16858
|
await this.executeVerto(vertoInfoMessage);
|
|
16827
16859
|
} catch (error) {
|
|
16828
|
-
logger$
|
|
16860
|
+
logger$14.warn("[WebRTCManager] Error sending DTMF digits:", error);
|
|
16829
16861
|
throw error;
|
|
16830
16862
|
}
|
|
16831
16863
|
}
|
|
@@ -16836,10 +16868,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16836
16868
|
action: "transfer"
|
|
16837
16869
|
});
|
|
16838
16870
|
try {
|
|
16839
|
-
logger$
|
|
16871
|
+
logger$14.debug("[WebRTCManager] Transferring call with options:", options);
|
|
16840
16872
|
await this.executeVerto(message);
|
|
16841
16873
|
} catch (error) {
|
|
16842
|
-
logger$
|
|
16874
|
+
logger$14.error("[WebRTCManager] Error transferring call:", error);
|
|
16843
16875
|
throw error;
|
|
16844
16876
|
}
|
|
16845
16877
|
}
|
|
@@ -16855,8 +16887,8 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
16855
16887
|
|
|
16856
16888
|
//#endregion
|
|
16857
16889
|
//#region src/controllers/RTCStatsMonitor.ts
|
|
16858
|
-
var import_cjs$
|
|
16859
|
-
const logger$
|
|
16890
|
+
var import_cjs$12 = require_cjs();
|
|
16891
|
+
const logger$13 = getLogger();
|
|
16860
16892
|
const DEFAULT_POLLING_INTERVAL_MS = 1e3;
|
|
16861
16893
|
const DEFAULT_BASELINE_SAMPLES = 10;
|
|
16862
16894
|
const DEFAULT_NO_AUDIO_PACKET_THRESHOLD_MS = 2e3;
|
|
@@ -16872,6 +16904,12 @@ function computePacketLossPercent(lost, received) {
|
|
|
16872
16904
|
if (total === 0) return 0;
|
|
16873
16905
|
return lost / total * 100;
|
|
16874
16906
|
}
|
|
16907
|
+
function isInboundRtpStat(stat) {
|
|
16908
|
+
return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "inbound-rtp";
|
|
16909
|
+
}
|
|
16910
|
+
function isCandidatePairStat(stat) {
|
|
16911
|
+
return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "candidate-pair";
|
|
16912
|
+
}
|
|
16875
16913
|
var RTCStatsMonitor = class extends Destroyable {
|
|
16876
16914
|
constructor(peerConnection, config = {}) {
|
|
16877
16915
|
super();
|
|
@@ -16912,7 +16950,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
16912
16950
|
}
|
|
16913
16951
|
/** Simple boolean health indicator. */
|
|
16914
16952
|
get isNetworkHealthy$() {
|
|
16915
|
-
return this.cachedObservable("isNetworkHealthy$", () => this._networkIssues$.pipe((0, import_cjs$
|
|
16953
|
+
return this.cachedObservable("isNetworkHealthy$", () => this._networkIssues$.pipe((0, import_cjs$12.map)((issues) => issues.length === 0), (0, import_cjs$12.distinctUntilChanged)(), (0, import_cjs$12.takeUntil)(this.destroyed$)));
|
|
16916
16954
|
}
|
|
16917
16955
|
/** Whether the network is currently healthy. */
|
|
16918
16956
|
get isNetworkHealthy() {
|
|
@@ -16928,7 +16966,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
16928
16966
|
}
|
|
16929
16967
|
/** Emits individual critical issues for the recovery pipeline. */
|
|
16930
16968
|
get criticalIssue$() {
|
|
16931
|
-
return this.cachedObservable("criticalIssue$", () => this._networkIssues$.pipe((0, import_cjs$
|
|
16969
|
+
return this.cachedObservable("criticalIssue$", () => this._networkIssues$.pipe((0, import_cjs$12.mergeMap)((issues) => (0, import_cjs$12.from)(issues.filter((i) => i.severity === "critical"))), (0, import_cjs$12.takeUntil)(this.destroyed$)));
|
|
16932
16970
|
}
|
|
16933
16971
|
/** Emits each raw stats sample extracted from the peer connection. */
|
|
16934
16972
|
get sample$() {
|
|
@@ -16940,32 +16978,32 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
16940
16978
|
const now = Date.now();
|
|
16941
16979
|
this.lastAudioPacketChangeTime = now;
|
|
16942
16980
|
this.lastVideoPacketChangeTime = now;
|
|
16943
|
-
logger$
|
|
16944
|
-
this.subscribeTo((0, import_cjs$
|
|
16945
|
-
logger$
|
|
16946
|
-
return import_cjs$
|
|
16947
|
-
}))), (0, import_cjs$
|
|
16948
|
-
this.subscribeTo(this._sample$.pipe((0, import_cjs$
|
|
16981
|
+
logger$13.debug("[RTCStatsMonitor] Starting stats monitoring");
|
|
16982
|
+
this.subscribeTo((0, import_cjs$12.interval)(this.pollingIntervalMs).pipe((0, import_cjs$12.filter)(() => this.running), (0, import_cjs$12.switchMap)(() => (0, import_cjs$12.from)(this.peerConnection.getStats()).pipe((0, import_cjs$12.catchError)((err) => {
|
|
16983
|
+
logger$13.warn("[RTCStatsMonitor] Failed to get stats:", err);
|
|
16984
|
+
return import_cjs$12.EMPTY;
|
|
16985
|
+
}))), (0, import_cjs$12.filter)(() => this.running), (0, import_cjs$12.map)((report) => this.extractSample(report))), (sample$1) => this._sample$.next(sample$1));
|
|
16986
|
+
this.subscribeTo(this._sample$.pipe((0, import_cjs$12.take)(this.baselineSampleCount), (0, import_cjs$12.toArray)(), (0, import_cjs$12.map)((samples) => ({
|
|
16949
16987
|
rtt: samples.reduce((s, b) => s + b.roundTripTime, 0) / samples.length,
|
|
16950
16988
|
jitter: samples.reduce((s, b) => s + b.audioJitter, 0) / samples.length,
|
|
16951
16989
|
ready: true
|
|
16952
16990
|
}))), (baseline) => {
|
|
16953
|
-
logger$
|
|
16991
|
+
logger$13.debug(`[RTCStatsMonitor] Baseline established: rtt=${baseline.rtt.toFixed(1)}ms, jitter=${baseline.jitter.toFixed(1)}ms`);
|
|
16954
16992
|
this._baseline$.next(baseline);
|
|
16955
16993
|
});
|
|
16956
|
-
this.subscribeTo(this._sample$.pipe((0, import_cjs$
|
|
16994
|
+
this.subscribeTo(this._sample$.pipe((0, import_cjs$12.scan)((acc, sample$1) => ({
|
|
16957
16995
|
prev: acc.current,
|
|
16958
16996
|
current: sample$1
|
|
16959
16997
|
}), {
|
|
16960
16998
|
prev: null,
|
|
16961
16999
|
current: null
|
|
16962
|
-
}), (0, import_cjs$
|
|
17000
|
+
}), (0, import_cjs$12.filter)((pair) => pair.current !== null)), ({ prev, current }) => {
|
|
16963
17001
|
const now$1 = current.timestamp;
|
|
16964
17002
|
this.updatePacketTracking(current, now$1);
|
|
16965
17003
|
const issues = this.detectIssues(current, prev, now$1);
|
|
16966
17004
|
this._networkIssues$.next(issues);
|
|
16967
17005
|
});
|
|
16968
|
-
this.subscribeTo(this._sample$.pipe((0, import_cjs$
|
|
17006
|
+
this.subscribeTo(this._sample$.pipe((0, import_cjs$12.scan)((history, sample$1) => {
|
|
16969
17007
|
const cutoff = sample$1.timestamp - this.historyWindowSeconds * 1e3;
|
|
16970
17008
|
const metrics = {
|
|
16971
17009
|
timestamp: sample$1.timestamp,
|
|
@@ -16987,10 +17025,10 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
16987
17025
|
stop() {
|
|
16988
17026
|
if (!this.running) return;
|
|
16989
17027
|
this.running = false;
|
|
16990
|
-
logger$
|
|
17028
|
+
logger$13.debug("[RTCStatsMonitor] Stopping stats monitoring");
|
|
16991
17029
|
}
|
|
16992
17030
|
destroy() {
|
|
16993
|
-
logger$
|
|
17031
|
+
logger$13.debug("[RTCStatsMonitor] Destroying RTCStatsMonitor");
|
|
16994
17032
|
this.stop();
|
|
16995
17033
|
super.destroy();
|
|
16996
17034
|
}
|
|
@@ -17003,17 +17041,15 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
17003
17041
|
let roundTripTime = 0;
|
|
17004
17042
|
let availableOutgoingBitrate;
|
|
17005
17043
|
report.forEach((stat) => {
|
|
17006
|
-
if (stat.
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
videoPacketsLost += stat.packetsLost ?? 0;
|
|
17014
|
-
}
|
|
17044
|
+
if (isInboundRtpStat(stat)) if (stat.kind === "audio") {
|
|
17045
|
+
audioPacketsReceived += stat.packetsReceived ?? this.lastAudioPacketsReceived;
|
|
17046
|
+
audioPacketsLost += stat.packetsLost ?? 0;
|
|
17047
|
+
audioJitter = Math.max(audioJitter, (stat.jitter ?? 0) * 1e3);
|
|
17048
|
+
} else {
|
|
17049
|
+
videoPacketsReceived += stat.packetsReceived ?? this.lastVideoPacketsReceived;
|
|
17050
|
+
videoPacketsLost += stat.packetsLost ?? 0;
|
|
17015
17051
|
}
|
|
17016
|
-
if (stat
|
|
17052
|
+
if (isCandidatePairStat(stat) && stat.state === "succeeded" && stat.nominated) {
|
|
17017
17053
|
roundTripTime = stat.currentRoundTripTime ? stat.currentRoundTripTime * 1e3 : this.lastRoundTripTime;
|
|
17018
17054
|
availableOutgoingBitrate = stat.availableOutgoingBitrate ?? this.lastAvailableOutgoingBitrate;
|
|
17019
17055
|
}
|
|
@@ -17120,8 +17156,8 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
17120
17156
|
|
|
17121
17157
|
//#endregion
|
|
17122
17158
|
//#region src/managers/CallRecoveryManager.ts
|
|
17123
|
-
var import_cjs$
|
|
17124
|
-
const logger$
|
|
17159
|
+
var import_cjs$11 = require_cjs();
|
|
17160
|
+
const logger$12 = getLogger();
|
|
17125
17161
|
const DEFAULT_DEBOUNCE_TIME_MS = 2e3;
|
|
17126
17162
|
const DEFAULT_COOLDOWN_MS = 1e4;
|
|
17127
17163
|
const DEFAULT_ICE_GRACE_PERIOD_MS = 3e3;
|
|
@@ -17157,7 +17193,7 @@ const DEGRADATION_ONLY_ISSUES = new Set([
|
|
|
17157
17193
|
* A state machine tracks the pipeline: IDLE -> DEBOUNCING -> RECOVERING -> COOLDOWN.
|
|
17158
17194
|
*/
|
|
17159
17195
|
var CallRecoveryManager = class extends Destroyable {
|
|
17160
|
-
constructor(callbacks, config = {}) {
|
|
17196
|
+
constructor(callbacks, inputs, config = {}) {
|
|
17161
17197
|
super();
|
|
17162
17198
|
this._recoveryState$ = this.createBehaviorSubject("idle");
|
|
17163
17199
|
this._recoveryEvent$ = this.createSubject();
|
|
@@ -17171,6 +17207,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17171
17207
|
this._cooldownUntil = 0;
|
|
17172
17208
|
this._pipelineStop$ = this.createSubject();
|
|
17173
17209
|
this._callbacks = callbacks;
|
|
17210
|
+
this._inputs = inputs;
|
|
17174
17211
|
this._config = {
|
|
17175
17212
|
debounceTimeMs: config.debounceTimeMs ?? DEFAULT_DEBOUNCE_TIME_MS,
|
|
17176
17213
|
cooldownMs: config.cooldownMs ?? DEFAULT_COOLDOWN_MS,
|
|
@@ -17190,16 +17227,16 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17190
17227
|
this.initDegradationRecoveryPipeline();
|
|
17191
17228
|
}
|
|
17192
17229
|
get recoveryState$() {
|
|
17193
|
-
return this._recoveryState$.asObservable().pipe((0, import_cjs$
|
|
17230
|
+
return this._recoveryState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
|
|
17194
17231
|
}
|
|
17195
17232
|
get recoveryState() {
|
|
17196
17233
|
return this._recoveryState$.value;
|
|
17197
17234
|
}
|
|
17198
17235
|
get recoveryEvent$() {
|
|
17199
|
-
return this._recoveryEvent$.asObservable().pipe((0, import_cjs$
|
|
17236
|
+
return this._recoveryEvent$.asObservable().pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
|
|
17200
17237
|
}
|
|
17201
17238
|
get bandwidthConstrained$() {
|
|
17202
|
-
return this._bandwidthConstrained$.asObservable().pipe((0, import_cjs$
|
|
17239
|
+
return this._bandwidthConstrained$.asObservable().pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
|
|
17203
17240
|
}
|
|
17204
17241
|
get bandwidthConstrained() {
|
|
17205
17242
|
return this._bandwidthConstrained$.value;
|
|
@@ -17217,10 +17254,10 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17217
17254
|
*/
|
|
17218
17255
|
async requestIceRestart() {
|
|
17219
17256
|
if (this._recoveryState$.value === "recovering") {
|
|
17220
|
-
logger$
|
|
17257
|
+
logger$12.info("CallRecoveryManager: manual ICE restart skipped — recovery already in progress");
|
|
17221
17258
|
return;
|
|
17222
17259
|
}
|
|
17223
|
-
logger$
|
|
17260
|
+
logger$12.info("CallRecoveryManager: manual ICE restart requested");
|
|
17224
17261
|
this.transitionTo("recovering");
|
|
17225
17262
|
await this.executeIceRestart(false);
|
|
17226
17263
|
this.startCooldown();
|
|
@@ -17236,7 +17273,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17236
17273
|
* WebSocket reconnect or call state recovers to 'connected'.
|
|
17237
17274
|
*/
|
|
17238
17275
|
reset() {
|
|
17239
|
-
logger$
|
|
17276
|
+
logger$12.info("CallRecoveryManager: resetting counters");
|
|
17240
17277
|
this._attemptCount = 0;
|
|
17241
17278
|
this._keyframeBurstCount = 0;
|
|
17242
17279
|
this._keyframeBurstStart = 0;
|
|
@@ -17245,6 +17282,22 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17245
17282
|
this.transitionTo("idle");
|
|
17246
17283
|
}
|
|
17247
17284
|
/**
|
|
17285
|
+
* Notify the recovery manager that a verto.modify (ICE restart SDP exchange)
|
|
17286
|
+
* failed at the signaling layer. Resets cooldown and pushes a new trigger
|
|
17287
|
+
* so recovery can re-attempt.
|
|
17288
|
+
*/
|
|
17289
|
+
notifyModifyFailed() {
|
|
17290
|
+
if (this._recoveryState$.value === "cooldown" || this._recoveryState$.value === "idle") {
|
|
17291
|
+
logger$12.info("CallRecoveryManager: verto.modify failed — re-entering recovery");
|
|
17292
|
+
this._cooldownUntil = 0;
|
|
17293
|
+
this.transitionTo("idle");
|
|
17294
|
+
this.pushTrigger({
|
|
17295
|
+
source: "network",
|
|
17296
|
+
detail: "modify_failed_during_recovery"
|
|
17297
|
+
});
|
|
17298
|
+
}
|
|
17299
|
+
}
|
|
17300
|
+
/**
|
|
17248
17301
|
* Feed bandwidth information for graceful degradation (Section 22).
|
|
17249
17302
|
* Call this from the stats monitor with current available outgoing bitrate.
|
|
17250
17303
|
*/
|
|
@@ -17259,7 +17312,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17259
17312
|
reason: `bandwidth ${bitrateKbps}kbps below threshold ${this._config.degradationBitrateThreshold}kbps`,
|
|
17260
17313
|
timestamp: Date.now()
|
|
17261
17314
|
});
|
|
17262
|
-
logger$
|
|
17315
|
+
logger$12.warn(`CallRecoveryManager: disabling video — bandwidth ${bitrateKbps}kbps < ${this._config.degradationBitrateThreshold}kbps`);
|
|
17263
17316
|
} else if (wasConstrained && bitrateKbps >= this._config.degradationRecoveryThreshold) {
|
|
17264
17317
|
this._bandwidthConstrained$.next(false);
|
|
17265
17318
|
this._callbacks.enableVideo();
|
|
@@ -17268,7 +17321,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17268
17321
|
reason: `bandwidth ${bitrateKbps}kbps recovered above ${this._config.degradationRecoveryThreshold}kbps`,
|
|
17269
17322
|
timestamp: Date.now()
|
|
17270
17323
|
});
|
|
17271
|
-
logger$
|
|
17324
|
+
logger$12.info(`CallRecoveryManager: restoring video — bandwidth ${bitrateKbps}kbps >= ${this._config.degradationRecoveryThreshold}kbps`);
|
|
17272
17325
|
}
|
|
17273
17326
|
}
|
|
17274
17327
|
/**
|
|
@@ -17287,14 +17340,14 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17287
17340
|
handleWebSocketReconnect() {
|
|
17288
17341
|
const pcState = this._callbacks.getPeerConnectionState();
|
|
17289
17342
|
if (pcState === "connected" || pcState === "completed") {
|
|
17290
|
-
logger$
|
|
17343
|
+
logger$12.info("CallRecoveryManager: signal-only reconnect — peer connection still alive");
|
|
17291
17344
|
this.emitEvent({
|
|
17292
17345
|
action: "signal_reconnect",
|
|
17293
17346
|
reason: "WebSocket reconnected, peer connection still connected",
|
|
17294
17347
|
timestamp: Date.now()
|
|
17295
17348
|
});
|
|
17296
17349
|
} else {
|
|
17297
|
-
logger$
|
|
17350
|
+
logger$12.info("CallRecoveryManager: full reconnect — peer connection also down");
|
|
17298
17351
|
this.emitEvent({
|
|
17299
17352
|
action: "full_reconnect",
|
|
17300
17353
|
reason: "WebSocket reconnected, peer connection not connected — ICE restart needed",
|
|
@@ -17313,12 +17366,12 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17313
17366
|
super.destroy();
|
|
17314
17367
|
}
|
|
17315
17368
|
initPipeline() {
|
|
17316
|
-
this.subscribeTo(this._trigger$.pipe((0, import_cjs$
|
|
17369
|
+
this.subscribeTo(this._trigger$.pipe((0, import_cjs$11.tap)(() => {
|
|
17317
17370
|
if (this._recoveryState$.value === "idle") this.transitionTo("debouncing");
|
|
17318
|
-
}), (0, import_cjs$
|
|
17371
|
+
}), (0, import_cjs$11.debounceTime)(this._config.debounceTimeMs), (0, import_cjs$11.withLatestFrom)(this._inputs.signalingReady$), (0, import_cjs$11.filter)(([, signalingReady]) => this.passGateChecks(signalingReady)), (0, import_cjs$11.map)(([trigger]) => trigger), (0, import_cjs$11.exhaustMap)((trigger) => this.executeTieredRecovery(trigger)), (0, import_cjs$11.takeUntil)((0, import_cjs$11.merge)(this._destroyed$, this._pipelineStop$))), {
|
|
17319
17372
|
next: () => {},
|
|
17320
17373
|
error: (err) => {
|
|
17321
|
-
logger$
|
|
17374
|
+
logger$12.error("CallRecoveryManager: pipeline error", err);
|
|
17322
17375
|
this.transitionTo("idle");
|
|
17323
17376
|
}
|
|
17324
17377
|
});
|
|
@@ -17334,10 +17387,10 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17334
17387
|
initDegradationRecoveryPipeline() {
|
|
17335
17388
|
if (!this._config.enableAutoDegradation) return;
|
|
17336
17389
|
const delayMs = this._config.packetLossRecoveryDelaySec * 1e3;
|
|
17337
|
-
this.subscribeTo((0, import_cjs$
|
|
17338
|
-
if (constrained && !hasPacketLoss) return (0, import_cjs$
|
|
17339
|
-
return import_cjs$
|
|
17340
|
-
}), (0, import_cjs$
|
|
17390
|
+
this.subscribeTo((0, import_cjs$11.combineLatest)([this._bandwidthConstrained$, this._hasPacketLoss$]).pipe((0, import_cjs$11.switchMap)(([constrained, hasPacketLoss]) => {
|
|
17391
|
+
if (constrained && !hasPacketLoss) return (0, import_cjs$11.timer)(delayMs);
|
|
17392
|
+
return import_cjs$11.EMPTY;
|
|
17393
|
+
}), (0, import_cjs$11.takeUntil)(this._destroyed$)), () => {
|
|
17341
17394
|
this._bandwidthConstrained$.next(false);
|
|
17342
17395
|
this._callbacks.enableVideo();
|
|
17343
17396
|
this.emitEvent({
|
|
@@ -17345,27 +17398,27 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17345
17398
|
reason: `no packet loss for ${this._config.packetLossRecoveryDelaySec}s — restoring video`,
|
|
17346
17399
|
timestamp: Date.now()
|
|
17347
17400
|
});
|
|
17348
|
-
logger$
|
|
17401
|
+
logger$12.info(`CallRecoveryManager: restoring video — no packet loss for ${this._config.packetLossRecoveryDelaySec}s`);
|
|
17349
17402
|
});
|
|
17350
17403
|
}
|
|
17351
|
-
passGateChecks() {
|
|
17404
|
+
passGateChecks(signalingReady) {
|
|
17352
17405
|
if (this._callbacks.isNegotiating()) {
|
|
17353
|
-
logger$
|
|
17406
|
+
logger$12.debug("CallRecoveryManager: gate blocked — negotiation in progress");
|
|
17354
17407
|
this.transitionTo("idle");
|
|
17355
17408
|
return false;
|
|
17356
17409
|
}
|
|
17357
|
-
if (!
|
|
17358
|
-
logger$
|
|
17410
|
+
if (!signalingReady) {
|
|
17411
|
+
logger$12.debug("CallRecoveryManager: gate blocked — signaling not ready");
|
|
17359
17412
|
this.transitionTo("idle");
|
|
17360
17413
|
return false;
|
|
17361
17414
|
}
|
|
17362
17415
|
if (!this._callbacks.isCallConnected()) {
|
|
17363
|
-
logger$
|
|
17416
|
+
logger$12.debug("CallRecoveryManager: gate blocked — call not connected");
|
|
17364
17417
|
this.transitionTo("idle");
|
|
17365
17418
|
return false;
|
|
17366
17419
|
}
|
|
17367
17420
|
if (this.isCooldownActive()) {
|
|
17368
|
-
logger$
|
|
17421
|
+
logger$12.debug("CallRecoveryManager: gate blocked — cooldown active");
|
|
17369
17422
|
this.transitionTo("cooldown");
|
|
17370
17423
|
return false;
|
|
17371
17424
|
}
|
|
@@ -17376,17 +17429,17 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17376
17429
|
}
|
|
17377
17430
|
executeTieredRecovery(trigger) {
|
|
17378
17431
|
this.transitionTo("recovering");
|
|
17379
|
-
logger$
|
|
17380
|
-
return (0, import_cjs$
|
|
17381
|
-
logger$
|
|
17432
|
+
logger$12.info(`CallRecoveryManager: starting tiered recovery — source=${trigger.source} detail=${trigger.detail}`);
|
|
17433
|
+
return (0, import_cjs$11.from)(this.runTiers(trigger)).pipe((0, import_cjs$11.tap)(() => this.startCooldown()), (0, import_cjs$11.catchError)((err) => {
|
|
17434
|
+
logger$12.error("CallRecoveryManager: tiered recovery failed", err);
|
|
17382
17435
|
this.startCooldown();
|
|
17383
|
-
return import_cjs$
|
|
17436
|
+
return import_cjs$11.EMPTY;
|
|
17384
17437
|
}));
|
|
17385
17438
|
}
|
|
17386
17439
|
async runTiers(trigger) {
|
|
17387
17440
|
this.executeKeyframe(trigger.detail);
|
|
17388
17441
|
if (trigger.issueType && DEGRADATION_ONLY_ISSUES.has(trigger.issueType)) {
|
|
17389
|
-
logger$
|
|
17442
|
+
logger$12.debug(`CallRecoveryManager: degradation-only issue (${trigger.issueType}) — Tier 1 only, skipping ICE restart`);
|
|
17390
17443
|
return;
|
|
17391
17444
|
}
|
|
17392
17445
|
if (this._attemptCount < this._config.maxAttempts) {
|
|
@@ -17403,13 +17456,13 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17403
17456
|
maxAttempts: this._config.maxAttempts,
|
|
17404
17457
|
timestamp: Date.now()
|
|
17405
17458
|
});
|
|
17406
|
-
logger$
|
|
17459
|
+
logger$12.warn("CallRecoveryManager: max recovery attempts reached");
|
|
17407
17460
|
}
|
|
17408
17461
|
}
|
|
17409
17462
|
executeKeyframe(reason) {
|
|
17410
17463
|
const now = Date.now();
|
|
17411
17464
|
if (now < this._keyframeCooldownUntil) {
|
|
17412
|
-
logger$
|
|
17465
|
+
logger$12.debug("CallRecoveryManager: keyframe request skipped — cooldown active");
|
|
17413
17466
|
return;
|
|
17414
17467
|
}
|
|
17415
17468
|
if (now - this._keyframeBurstStart > this._config.keyframeBurstWindowMs) {
|
|
@@ -17418,7 +17471,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17418
17471
|
}
|
|
17419
17472
|
if (this._keyframeBurstCount >= this._config.keyframeMaxBurst) {
|
|
17420
17473
|
this._keyframeCooldownUntil = now + this._config.keyframeCooldownMs;
|
|
17421
|
-
logger$
|
|
17474
|
+
logger$12.debug(`CallRecoveryManager: keyframe burst limit reached (${this._config.keyframeMaxBurst}), cooldown until ${this._keyframeCooldownUntil}`);
|
|
17422
17475
|
return;
|
|
17423
17476
|
}
|
|
17424
17477
|
this._keyframeBurstCount += 1;
|
|
@@ -17428,12 +17481,12 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17428
17481
|
reason,
|
|
17429
17482
|
timestamp: now
|
|
17430
17483
|
});
|
|
17431
|
-
logger$
|
|
17484
|
+
logger$12.debug(`CallRecoveryManager: keyframe requested (burst ${this._keyframeBurstCount}/${this._config.keyframeMaxBurst})`);
|
|
17432
17485
|
}
|
|
17433
17486
|
async executeIceRestart(relayOnly) {
|
|
17434
17487
|
this._attemptCount += 1;
|
|
17435
17488
|
const tier = relayOnly ? "Tier 3 (relay-only)" : "Tier 2 (standard)";
|
|
17436
|
-
logger$
|
|
17489
|
+
logger$12.info(`CallRecoveryManager: ${tier} ICE restart — attempt ${this._attemptCount}/${this._config.maxAttempts}`);
|
|
17437
17490
|
this.emitEvent({
|
|
17438
17491
|
action: "reinvite_started",
|
|
17439
17492
|
reason: `${tier} ICE restart`,
|
|
@@ -17450,7 +17503,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17450
17503
|
maxAttempts: this._config.maxAttempts,
|
|
17451
17504
|
timestamp: Date.now()
|
|
17452
17505
|
});
|
|
17453
|
-
logger$
|
|
17506
|
+
logger$12.info(`CallRecoveryManager: ${tier} ICE restart succeeded`);
|
|
17454
17507
|
this._attemptCount = 0;
|
|
17455
17508
|
return true;
|
|
17456
17509
|
}
|
|
@@ -17461,7 +17514,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17461
17514
|
maxAttempts: this._config.maxAttempts,
|
|
17462
17515
|
timestamp: Date.now()
|
|
17463
17516
|
});
|
|
17464
|
-
logger$
|
|
17517
|
+
logger$12.warn(`CallRecoveryManager: ${tier} ICE restart failed`);
|
|
17465
17518
|
return false;
|
|
17466
17519
|
} catch {
|
|
17467
17520
|
this.emitEvent({
|
|
@@ -17471,7 +17524,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17471
17524
|
maxAttempts: this._config.maxAttempts,
|
|
17472
17525
|
timestamp: Date.now()
|
|
17473
17526
|
});
|
|
17474
|
-
logger$
|
|
17527
|
+
logger$12.warn(`CallRecoveryManager: ${tier} ICE restart timed out`);
|
|
17475
17528
|
return false;
|
|
17476
17529
|
}
|
|
17477
17530
|
}
|
|
@@ -17492,7 +17545,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17492
17545
|
transitionTo(state) {
|
|
17493
17546
|
const prev = this._recoveryState$.value;
|
|
17494
17547
|
if (prev !== state) {
|
|
17495
|
-
logger$
|
|
17548
|
+
logger$12.debug(`CallRecoveryManager: state ${prev} -> ${state}`);
|
|
17496
17549
|
this._recoveryState$.next(state);
|
|
17497
17550
|
}
|
|
17498
17551
|
}
|
|
@@ -17500,7 +17553,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
17500
17553
|
this._cooldownUntil = Date.now() + this._config.cooldownMs;
|
|
17501
17554
|
this.transitionTo("cooldown");
|
|
17502
17555
|
if (this._cooldownSubscription) this._cooldownSubscription.unsubscribe();
|
|
17503
|
-
this._cooldownSubscription = (0, import_cjs$
|
|
17556
|
+
this._cooldownSubscription = (0, import_cjs$11.timer)(this._config.cooldownMs).pipe((0, import_cjs$11.take)(1), (0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.filter)(() => this._recoveryState$.value === "cooldown")).subscribe(() => this.transitionTo("idle"));
|
|
17504
17557
|
}
|
|
17505
17558
|
emitEvent(event) {
|
|
17506
17559
|
this._recoveryEvent$.next(event);
|
|
@@ -17594,8 +17647,8 @@ function mosToQualityLevel(mos) {
|
|
|
17594
17647
|
|
|
17595
17648
|
//#endregion
|
|
17596
17649
|
//#region src/core/entities/Call.ts
|
|
17597
|
-
var import_cjs$
|
|
17598
|
-
const logger$
|
|
17650
|
+
var import_cjs$10 = require_cjs();
|
|
17651
|
+
const logger$11 = getLogger();
|
|
17599
17652
|
/**
|
|
17600
17653
|
* Ratio between the critical and warning RTT spike multipliers.
|
|
17601
17654
|
* Warning threshold = baseline * warningMultiplier (default 3x)
|
|
@@ -17613,7 +17666,7 @@ const fromDestinationParams = (destination) => {
|
|
|
17613
17666
|
});
|
|
17614
17667
|
return params;
|
|
17615
17668
|
} catch (error) {
|
|
17616
|
-
logger$
|
|
17669
|
+
logger$11.warn(`Failed to parse destination URI: ${destination}`, error);
|
|
17617
17670
|
return {};
|
|
17618
17671
|
}
|
|
17619
17672
|
};
|
|
@@ -17669,10 +17722,13 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17669
17722
|
const { deviceController, networkChange$ } = initialization;
|
|
17670
17723
|
this._networkChange$ = networkChange$;
|
|
17671
17724
|
this.participantFactory = new ParticipantFactory(this.executeMethod.bind(this), this.vertoManager, deviceController);
|
|
17672
|
-
this.subscribeTo((0, import_cjs$
|
|
17725
|
+
this.subscribeTo((0, import_cjs$10.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$).pipe((0, import_cjs$10.distinctUntilChanged)(), (0, import_cjs$10.takeUntil)(this._destroyed$)), (status) => {
|
|
17673
17726
|
this._lastMergedStatus = status;
|
|
17674
17727
|
if (status === "connected" && !this._statsMonitor) this.initResilienceSubsystems();
|
|
17675
|
-
else if (status === "disconnected"
|
|
17728
|
+
else if (status === "disconnected") {
|
|
17729
|
+
this._statsMonitor?.destroy();
|
|
17730
|
+
this._statsMonitor = void 0;
|
|
17731
|
+
} else if (status === "destroyed" || status === "failed") this.stopResilienceSubsystems();
|
|
17676
17732
|
});
|
|
17677
17733
|
}
|
|
17678
17734
|
/** Observable stream of errors from media, signaling, and peer connection layers. */
|
|
@@ -17691,13 +17747,17 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17691
17747
|
this.destroy();
|
|
17692
17748
|
}
|
|
17693
17749
|
}
|
|
17750
|
+
/** Notify the recovery manager that a verto.modify signaling exchange failed. */
|
|
17751
|
+
notifyModifyFailed() {
|
|
17752
|
+
this._recoveryManager?.notifyModifyFailed();
|
|
17753
|
+
}
|
|
17694
17754
|
/** Whether this call is `'inbound'` or `'outbound'`. */
|
|
17695
17755
|
get direction() {
|
|
17696
17756
|
return this.options.initOffer ? "inbound" : "outbound";
|
|
17697
17757
|
}
|
|
17698
17758
|
/** Observable of the address associated with this call. */
|
|
17699
17759
|
get address$() {
|
|
17700
|
-
return this.deferEmission((0, import_cjs$
|
|
17760
|
+
return this.deferEmission((0, import_cjs$10.from)([this.address])).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17701
17761
|
}
|
|
17702
17762
|
/** Display name of the caller. */
|
|
17703
17763
|
get fromName() {
|
|
@@ -17776,7 +17836,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17776
17836
|
}
|
|
17777
17837
|
/** Observable of layout layer positions for all participants. */
|
|
17778
17838
|
get layoutLayers$() {
|
|
17779
|
-
return this.deferEmission(this.callEventsManager.layoutLayers$).pipe((0, import_cjs$
|
|
17839
|
+
return this.deferEmission(this.callEventsManager.layoutLayers$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17780
17840
|
}
|
|
17781
17841
|
/** Current snapshot of layout layers. */
|
|
17782
17842
|
get layoutLayers() {
|
|
@@ -17804,7 +17864,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17804
17864
|
if (isJSONRPCErrorResponse(response)) throw new JSONRPCError(parseInt(response.result?.code ?? "0"), `Error response from method ${method}: ${response.result?.code} ${response.result?.message}`, void 0, void 0, request.id);
|
|
17805
17865
|
return response;
|
|
17806
17866
|
} catch (error) {
|
|
17807
|
-
logger$
|
|
17867
|
+
logger$11.error(`[Call] Error executing method ${method} with params`, params, error);
|
|
17808
17868
|
throw error;
|
|
17809
17869
|
}
|
|
17810
17870
|
}
|
|
@@ -17831,45 +17891,45 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17831
17891
|
}
|
|
17832
17892
|
/** Observable of the current call status (e.g. `'ringing'`, `'connected'`). */
|
|
17833
17893
|
get status$() {
|
|
17834
|
-
return this.publicCachedObservable("status$", () => (0, import_cjs$
|
|
17894
|
+
return this.publicCachedObservable("status$", () => (0, import_cjs$10.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$).pipe((0, import_cjs$10.distinctUntilChanged)(), (0, import_cjs$10.tap)((status) => {
|
|
17835
17895
|
this._lastMergedStatus = status;
|
|
17836
17896
|
})));
|
|
17837
17897
|
}
|
|
17838
17898
|
/** Observable of the participants list, emits on join/leave/update. */
|
|
17839
17899
|
get participants$() {
|
|
17840
|
-
return this.deferEmission(this.callEventsManager.participants$).pipe((0, import_cjs$
|
|
17900
|
+
return this.deferEmission(this.callEventsManager.participants$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17841
17901
|
}
|
|
17842
17902
|
/** Observable of the local (self) participant. */
|
|
17843
17903
|
get self$() {
|
|
17844
|
-
return this.deferEmission(this.callEventsManager.self$).pipe((0, import_cjs$
|
|
17904
|
+
return this.deferEmission(this.callEventsManager.self$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17845
17905
|
}
|
|
17846
17906
|
/** Observable indicating whether the call is being recorded. */
|
|
17847
17907
|
get recording$() {
|
|
17848
|
-
return this.deferEmission(this.callEventsManager.recording$).pipe((0, import_cjs$
|
|
17908
|
+
return this.deferEmission(this.callEventsManager.recording$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17849
17909
|
}
|
|
17850
17910
|
/** Observable indicating whether the call is being streamed. */
|
|
17851
17911
|
get streaming$() {
|
|
17852
|
-
return this.deferEmission(this.callEventsManager.streaming$).pipe((0, import_cjs$
|
|
17912
|
+
return this.deferEmission(this.callEventsManager.streaming$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17853
17913
|
}
|
|
17854
17914
|
/** Observable indicating whether raise-hand priority is active. */
|
|
17855
17915
|
get raiseHandPriority$() {
|
|
17856
|
-
return this.deferEmission(this.callEventsManager.raiseHandPriority$).pipe((0, import_cjs$
|
|
17916
|
+
return this.deferEmission(this.callEventsManager.raiseHandPriority$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17857
17917
|
}
|
|
17858
17918
|
/** Observable indicating whether the call room is locked. */
|
|
17859
17919
|
get locked$() {
|
|
17860
|
-
return this.deferEmission(this.callEventsManager.locked$).pipe((0, import_cjs$
|
|
17920
|
+
return this.deferEmission(this.callEventsManager.locked$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17861
17921
|
}
|
|
17862
17922
|
/** Observable of custom metadata associated with the call. */
|
|
17863
17923
|
get meta$() {
|
|
17864
|
-
return this.deferEmission(this.callEventsManager.meta$).pipe((0, import_cjs$
|
|
17924
|
+
return this.deferEmission(this.callEventsManager.meta$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17865
17925
|
}
|
|
17866
17926
|
/** Observable of the call's capability flags. */
|
|
17867
17927
|
get capabilities$() {
|
|
17868
|
-
return this.deferEmission(this.callEventsManager.capabilities$).pipe((0, import_cjs$
|
|
17928
|
+
return this.deferEmission(this.callEventsManager.capabilities$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17869
17929
|
}
|
|
17870
17930
|
/** Observable of the current layout name. */
|
|
17871
17931
|
get layout$() {
|
|
17872
|
-
return this.deferEmission(this.callEventsManager.layout$).pipe((0, import_cjs$
|
|
17932
|
+
return this.deferEmission(this.callEventsManager.layout$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17873
17933
|
}
|
|
17874
17934
|
/** Current call status. */
|
|
17875
17935
|
get status() {
|
|
@@ -17901,7 +17961,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17901
17961
|
}
|
|
17902
17962
|
/** Observable of available layout names. */
|
|
17903
17963
|
get layouts$() {
|
|
17904
|
-
return this.deferEmission(this.callEventsManager.layouts$).pipe((0, import_cjs$
|
|
17964
|
+
return this.deferEmission(this.callEventsManager.layouts$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17905
17965
|
}
|
|
17906
17966
|
/** Current snapshot of available layout names. */
|
|
17907
17967
|
get layouts() {
|
|
@@ -17909,7 +17969,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17909
17969
|
}
|
|
17910
17970
|
/** Observable of the local media stream (camera/microphone). */
|
|
17911
17971
|
get localStream$() {
|
|
17912
|
-
return this.deferEmission(this.vertoManager.localStream$).pipe((0, import_cjs$
|
|
17972
|
+
return this.deferEmission(this.vertoManager.localStream$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17913
17973
|
}
|
|
17914
17974
|
/** Current local media stream, or `null` if not available. */
|
|
17915
17975
|
get localStream() {
|
|
@@ -17917,7 +17977,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
17917
17977
|
}
|
|
17918
17978
|
/** Observable of the remote media stream from the far end. */
|
|
17919
17979
|
get remoteStream$() {
|
|
17920
|
-
return this.deferEmission(this.vertoManager.remoteStream$).pipe((0, import_cjs$
|
|
17980
|
+
return this.deferEmission(this.vertoManager.remoteStream$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
17921
17981
|
}
|
|
17922
17982
|
/** Current remote media stream, or `null` if not available. */
|
|
17923
17983
|
get remoteStream() {
|
|
@@ -18007,9 +18067,9 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18007
18067
|
*/
|
|
18008
18068
|
initResilienceSubsystems() {
|
|
18009
18069
|
const pc = this.rtcPeerConnection;
|
|
18010
|
-
logger$
|
|
18070
|
+
logger$11.debug(`[Call] initResilienceSubsystems: pc=${pc ? "exists" : "undefined"}, connectionState=${pc?.connectionState}`);
|
|
18011
18071
|
if (!pc) {
|
|
18012
|
-
logger$
|
|
18072
|
+
logger$11.warn("[Call] No peer connection available, skipping resilience init");
|
|
18013
18073
|
return;
|
|
18014
18074
|
}
|
|
18015
18075
|
try {
|
|
@@ -18044,21 +18104,20 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18044
18104
|
disableVideo: () => {
|
|
18045
18105
|
try {
|
|
18046
18106
|
this.vertoManager.muteMainVideoInputDevice();
|
|
18047
|
-
logger$
|
|
18107
|
+
logger$11.debug("[Call] Recovery manager disabled video");
|
|
18048
18108
|
} catch {
|
|
18049
|
-
logger$
|
|
18109
|
+
logger$11.debug("[Call] Recovery manager failed to disable video");
|
|
18050
18110
|
}
|
|
18051
18111
|
},
|
|
18052
18112
|
enableVideo: () => {
|
|
18053
18113
|
this.vertoManager.unmuteMainVideoInputDevice().catch(() => {
|
|
18054
|
-
logger$
|
|
18114
|
+
logger$11.debug("[Call] Recovery manager failed to enable video");
|
|
18055
18115
|
});
|
|
18056
18116
|
},
|
|
18057
18117
|
isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
|
|
18058
|
-
isWebSocketConnected: () => this._lastMergedStatus !== "disconnected",
|
|
18059
18118
|
isCallConnected: () => this._lastMergedStatus === "connected",
|
|
18060
18119
|
getPeerConnectionState: () => pc.connectionState
|
|
18061
|
-
}, {
|
|
18120
|
+
}, { signalingReady$: this.clientSession.authenticated$ }, {
|
|
18062
18121
|
debounceTimeMs: prefs.recoveryDebounceTime,
|
|
18063
18122
|
cooldownMs: prefs.recoveryCooldown,
|
|
18064
18123
|
iceGracePeriodMs: prefs.iceDisconnectedGracePeriod,
|
|
@@ -18101,6 +18160,15 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18101
18160
|
});
|
|
18102
18161
|
this.subscribeTo(this._recoveryManager.recoveryEvent$, (event) => {
|
|
18103
18162
|
this._recoveryEvent$.next(event);
|
|
18163
|
+
if (event.action === "max_attempts_reached") {
|
|
18164
|
+
logger$11.warn("[Call] All recovery attempts exhausted, terminating call");
|
|
18165
|
+
this.emitError({
|
|
18166
|
+
kind: "network",
|
|
18167
|
+
fatal: true,
|
|
18168
|
+
error: /* @__PURE__ */ new Error("Call recovery failed: all attempts exhausted"),
|
|
18169
|
+
callId: this.id
|
|
18170
|
+
});
|
|
18171
|
+
}
|
|
18104
18172
|
});
|
|
18105
18173
|
this.subscribeTo(this._recoveryManager.bandwidthConstrained$, (constrained) => {
|
|
18106
18174
|
this._bandwidthConstrained$.next(constrained);
|
|
@@ -18112,14 +18180,14 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18112
18180
|
});
|
|
18113
18181
|
else if (event.type === "online") this._recoveryManager?.handleWebSocketReconnect();
|
|
18114
18182
|
});
|
|
18115
|
-
this.subscribeTo(this.clientSession.authenticated$.pipe((0, import_cjs$
|
|
18116
|
-
logger$
|
|
18183
|
+
this.subscribeTo(this.clientSession.authenticated$.pipe((0, import_cjs$10.skip)(1), (0, import_cjs$10.filter)(Boolean)), () => {
|
|
18184
|
+
logger$11.debug("[Call] WebSocket reconnected — notifying recovery manager");
|
|
18117
18185
|
this._recoveryManager?.handleWebSocketReconnect();
|
|
18118
18186
|
});
|
|
18119
18187
|
this._statsMonitor.start();
|
|
18120
|
-
logger$
|
|
18188
|
+
logger$11.debug("[Call] Resilience subsystems initialized for call", this.id);
|
|
18121
18189
|
} catch (error) {
|
|
18122
|
-
logger$
|
|
18190
|
+
logger$11.warn("[Call] Failed to initialize resilience subsystems:", error);
|
|
18123
18191
|
}
|
|
18124
18192
|
}
|
|
18125
18193
|
/**
|
|
@@ -18141,14 +18209,14 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18141
18209
|
}
|
|
18142
18210
|
/** Observable of the current audio/video send/receive directions. */
|
|
18143
18211
|
get mediaDirections$() {
|
|
18144
|
-
return this.deferEmission(this.vertoManager.mediaDirections$).pipe((0, import_cjs$
|
|
18212
|
+
return this.deferEmission(this.vertoManager.mediaDirections$).pipe((0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
18145
18213
|
}
|
|
18146
18214
|
/** Current audio/video send/receive directions. */
|
|
18147
18215
|
get mediaDirections() {
|
|
18148
18216
|
return this.vertoManager.mediaDirections;
|
|
18149
18217
|
}
|
|
18150
18218
|
get participantsId$() {
|
|
18151
|
-
return this.cachedObservable("participantsId$", () => this.participants$.pipe((0, import_cjs$
|
|
18219
|
+
return this.cachedObservable("participantsId$", () => this.participants$.pipe((0, import_cjs$10.map)((participants) => participants.map((participant) => participant.id))));
|
|
18152
18220
|
}
|
|
18153
18221
|
/**
|
|
18154
18222
|
* Executes a raw JSON-RPC request on the client session.
|
|
@@ -18181,48 +18249,48 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18181
18249
|
}
|
|
18182
18250
|
isCallSessionEvent(event) {
|
|
18183
18251
|
try {
|
|
18184
|
-
logger$
|
|
18252
|
+
logger$11.debug("[Call] Checking if event is for this call session:", event);
|
|
18185
18253
|
const callId = getValueFrom(event, "params.params.callID") ?? getValueFrom(event, "params.call_id");
|
|
18186
18254
|
const roomSessionId = getValueFrom(event, "params.room_session_id");
|
|
18187
|
-
logger$
|
|
18255
|
+
logger$11.debug(`[Call] Extracted session identifiers callID: ${callId} and roomSessionID: ${roomSessionId} from event:`);
|
|
18188
18256
|
return callId === this.id || !!callId && this.callEventsManager.isCallIdValid(callId) || !!roomSessionId && this.callEventsManager.isRoomSessionIdValid(roomSessionId);
|
|
18189
18257
|
} catch (error) {
|
|
18190
|
-
logger$
|
|
18258
|
+
logger$11.error("[Call] Error checking if event is for this call session:", error);
|
|
18191
18259
|
return false;
|
|
18192
18260
|
}
|
|
18193
18261
|
}
|
|
18194
18262
|
get callSessionEvents$() {
|
|
18195
|
-
return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, import_cjs$
|
|
18196
|
-
logger$
|
|
18197
|
-
}), (0, import_cjs$
|
|
18263
|
+
return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, import_cjs$10.filter)((event) => this.isCallSessionEvent(event)), (0, import_cjs$10.tap)((event) => {
|
|
18264
|
+
logger$11.debug("[Call] Received call session event:", event);
|
|
18265
|
+
}), (0, import_cjs$10.takeUntil)(this.destroyed$), (0, import_cjs$10.share)()));
|
|
18198
18266
|
}
|
|
18199
18267
|
/** Observable of call-updated events. */
|
|
18200
18268
|
get callUpdated$() {
|
|
18201
|
-
return this.publicCachedObservable("callUpdated$", () => this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$
|
|
18269
|
+
return this.publicCachedObservable("callUpdated$", () => this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18202
18270
|
}
|
|
18203
18271
|
/** Observable of member-joined events, emitted when a remote participant joins the call. */
|
|
18204
18272
|
get memberJoined$() {
|
|
18205
|
-
return this.publicCachedObservable("memberJoined$", () => this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$
|
|
18273
|
+
return this.publicCachedObservable("memberJoined$", () => this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18206
18274
|
}
|
|
18207
18275
|
/** Observable of member-left events, emitted when a participant leaves the call. */
|
|
18208
18276
|
get memberLeft$() {
|
|
18209
|
-
return this.publicCachedObservable("memberLeft$", () => this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$
|
|
18277
|
+
return this.publicCachedObservable("memberLeft$", () => this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18210
18278
|
}
|
|
18211
18279
|
/** Observable of member-updated events (mute, volume, etc.). */
|
|
18212
18280
|
get memberUpdated$() {
|
|
18213
|
-
return this.publicCachedObservable("memberUpdated$", () => this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$
|
|
18281
|
+
return this.publicCachedObservable("memberUpdated$", () => this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18214
18282
|
}
|
|
18215
18283
|
/** Observable of member-talking events (speech start/stop). */
|
|
18216
18284
|
get memberTalking$() {
|
|
18217
|
-
return this.publicCachedObservable("memberTalking$", () => this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$
|
|
18285
|
+
return this.publicCachedObservable("memberTalking$", () => this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18218
18286
|
}
|
|
18219
18287
|
/** Observable of call state-change events. */
|
|
18220
18288
|
get callStates$() {
|
|
18221
|
-
return this.publicCachedObservable("callStates$", () => this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$
|
|
18289
|
+
return this.publicCachedObservable("callStates$", () => this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18222
18290
|
}
|
|
18223
18291
|
/** Observable of layout-changed events. */
|
|
18224
18292
|
get layoutUpdates$() {
|
|
18225
|
-
return this.publicCachedObservable("layoutUpdates$", () => this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$
|
|
18293
|
+
return this.publicCachedObservable("layoutUpdates$", () => this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
|
|
18226
18294
|
}
|
|
18227
18295
|
/** Underlying `RTCPeerConnection`, for advanced use cases. */
|
|
18228
18296
|
get rtcPeerConnection() {
|
|
@@ -18230,7 +18298,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18230
18298
|
}
|
|
18231
18299
|
/** Observable of raw signaling events as plain objects. */
|
|
18232
18300
|
get signalingEvent$() {
|
|
18233
|
-
return this.publicCachedObservable("signalingEvent$", () => this.callEvent$.pipe((0, import_cjs$
|
|
18301
|
+
return this.publicCachedObservable("signalingEvent$", () => this.callEvent$.pipe((0, import_cjs$10.map)((event) => JSON.parse(JSON.stringify(event)))));
|
|
18234
18302
|
}
|
|
18235
18303
|
/**
|
|
18236
18304
|
* Subscribe to a custom signaling event type on this call.
|
|
@@ -18258,16 +18326,16 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18258
18326
|
subscribe(eventType) {
|
|
18259
18327
|
const cached = this._customSubscriptions.get(eventType);
|
|
18260
18328
|
if (cached) return cached;
|
|
18261
|
-
const filtered$ = this.callSessionEvents$.pipe((0, import_cjs$
|
|
18329
|
+
const filtered$ = this.callSessionEvents$.pipe((0, import_cjs$10.filter)((event) => event.event_type === eventType), (0, import_cjs$10.map)((event) => JSON.parse(JSON.stringify(event))), (0, import_cjs$10.takeUntil)(this._destroyed$));
|
|
18262
18330
|
this._customSubscriptions.set(eventType, filtered$);
|
|
18263
18331
|
this._sendVertoSubscribe(eventType);
|
|
18264
18332
|
return filtered$;
|
|
18265
18333
|
}
|
|
18266
18334
|
get webrtcMessages$() {
|
|
18267
|
-
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$
|
|
18335
|
+
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$10.tap)((event) => logger$11.debug("[Call] Event is a WebRTC message event:", event)), (0, import_cjs$10.takeUntil)(this.destroyed$), (0, import_cjs$10.share)()));
|
|
18268
18336
|
}
|
|
18269
18337
|
get callEvent$() {
|
|
18270
|
-
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$
|
|
18338
|
+
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$10.tap)((event) => logger$11.debug("[Call] Event is a call event:", event)), (0, import_cjs$10.takeUntil)(this.destroyed$), (0, import_cjs$10.share)()));
|
|
18271
18339
|
}
|
|
18272
18340
|
get layoutEvent$() {
|
|
18273
18341
|
return this.cachedObservable("layoutEvent$", () => this.callEvent$.pipe(filterAs(isLayoutChangedMetadata, "params")));
|
|
@@ -18360,7 +18428,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18360
18428
|
*/
|
|
18361
18429
|
async setLayout(layout, positions) {
|
|
18362
18430
|
if (!this.layouts.includes(layout)) throw new InvalidParams(`Layout ${layout} is not available in the current call layouts: ${this.layouts.join(", ")}`);
|
|
18363
|
-
const selfId = await (0, import_cjs$
|
|
18431
|
+
const selfId = await (0, import_cjs$10.firstValueFrom)(this.selfId$.pipe((0, import_cjs$10.filter)((id) => id !== null)));
|
|
18364
18432
|
await this.executeMethod(selfId, "call.layout.set", {
|
|
18365
18433
|
layout,
|
|
18366
18434
|
positions
|
|
@@ -18401,10 +18469,10 @@ var WebRTCCall = class extends Destroyable {
|
|
|
18401
18469
|
message
|
|
18402
18470
|
};
|
|
18403
18471
|
this.clientSession.execute(WebrtcVerto(params)).catch((error) => {
|
|
18404
|
-
logger$
|
|
18472
|
+
logger$11.warn(`[Call] verto.subscribe for '${eventType}' failed (non-fatal):`, error);
|
|
18405
18473
|
});
|
|
18406
18474
|
} catch (error) {
|
|
18407
|
-
logger$
|
|
18475
|
+
logger$11.warn(`[Call] Failed to send verto.subscribe for '${eventType}':`, error);
|
|
18408
18476
|
}
|
|
18409
18477
|
}
|
|
18410
18478
|
};
|
|
@@ -18426,6 +18494,7 @@ function inferCallErrorKind(error) {
|
|
|
18426
18494
|
function isFatalError(error) {
|
|
18427
18495
|
if (error instanceof VertoPongError) return false;
|
|
18428
18496
|
if (error instanceof MediaTrackError) return false;
|
|
18497
|
+
if (error instanceof RPCTimeoutError) return false;
|
|
18429
18498
|
return true;
|
|
18430
18499
|
}
|
|
18431
18500
|
/**
|
|
@@ -18457,6 +18526,9 @@ var CallFactory = class {
|
|
|
18457
18526
|
callId: callInstance.id
|
|
18458
18527
|
};
|
|
18459
18528
|
callInstance.emitError(callError);
|
|
18529
|
+
},
|
|
18530
|
+
onModifyFailed: () => {
|
|
18531
|
+
callInstance.notifyModifyFailed();
|
|
18460
18532
|
}
|
|
18461
18533
|
}),
|
|
18462
18534
|
callEventsManager: new CallEventsManager(callInstance)
|
|
@@ -18470,8 +18542,8 @@ var CallFactory = class {
|
|
|
18470
18542
|
|
|
18471
18543
|
//#endregion
|
|
18472
18544
|
//#region src/behaviors/Collection.ts
|
|
18473
|
-
var import_cjs$
|
|
18474
|
-
const logger$
|
|
18545
|
+
var import_cjs$9 = require_cjs();
|
|
18546
|
+
const logger$10 = getLogger();
|
|
18475
18547
|
var Fetcher = class {
|
|
18476
18548
|
constructor(endpoint, params, http) {
|
|
18477
18549
|
this.endpoint = endpoint;
|
|
@@ -18495,7 +18567,7 @@ var Fetcher = class {
|
|
|
18495
18567
|
this.hasMore = !!this.nextUrl;
|
|
18496
18568
|
return result.data.filter(this.filter).map(this.mapper);
|
|
18497
18569
|
}
|
|
18498
|
-
logger$
|
|
18570
|
+
logger$10.error("Failed to fetch entity");
|
|
18499
18571
|
return [];
|
|
18500
18572
|
}
|
|
18501
18573
|
async id(v) {
|
|
@@ -18536,10 +18608,10 @@ var EntityCollection = class extends Destroyable {
|
|
|
18536
18608
|
this.values$.next(Array.from(this.collectionData.values()));
|
|
18537
18609
|
};
|
|
18538
18610
|
this._hasMore$ = this.createBehaviorSubject(true);
|
|
18539
|
-
this._destroy$ = new import_cjs$
|
|
18611
|
+
this._destroy$ = new import_cjs$9.Subject();
|
|
18540
18612
|
this.updateSubscription = this.update$.subscribe(this.upsertData);
|
|
18541
18613
|
this.loading$.next(false);
|
|
18542
|
-
this.hasMore$ = (0, import_cjs$
|
|
18614
|
+
this.hasMore$ = (0, import_cjs$9.defer)(() => (0, import_cjs$9.from)(this.init())).pipe((0, import_cjs$9.switchMap)(() => this._hasMore$), (0, import_cjs$9.distinctUntilChanged)(), (0, import_cjs$9.shareReplay)(1), (0, import_cjs$9.takeUntil)(this._destroy$));
|
|
18543
18615
|
}
|
|
18544
18616
|
get loading() {
|
|
18545
18617
|
return this.loading$.value;
|
|
@@ -18548,7 +18620,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
18548
18620
|
return this.fetchController.hasMore ?? true;
|
|
18549
18621
|
}
|
|
18550
18622
|
get updated$() {
|
|
18551
|
-
return this.cachedObservable("updated$", () => this.loading$.pipe((0, import_cjs$
|
|
18623
|
+
return this.cachedObservable("updated$", () => this.loading$.pipe((0, import_cjs$9.distinctUntilChanged)(), (0, import_cjs$9.skip)(1), (0, import_cjs$9.filter)((loading) => !loading), (0, import_cjs$9.map)(() => void 0), (0, import_cjs$9.takeUntil)(this._destroy$)));
|
|
18552
18624
|
}
|
|
18553
18625
|
get values() {
|
|
18554
18626
|
return Array.from(this.collectionData.values());
|
|
@@ -18567,7 +18639,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
18567
18639
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
18568
18640
|
this.loading$.next(false);
|
|
18569
18641
|
} catch (error) {
|
|
18570
|
-
logger$
|
|
18642
|
+
logger$10.error(`Failed to fetch initial collection data`, error);
|
|
18571
18643
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
18572
18644
|
this.loading$.next(false);
|
|
18573
18645
|
this.onError?.(new CollectionFetchError("fetchMore", error));
|
|
@@ -18581,14 +18653,14 @@ var EntityCollection = class extends Destroyable {
|
|
|
18581
18653
|
if (data) this.upsertData(data);
|
|
18582
18654
|
return data;
|
|
18583
18655
|
} catch (error) {
|
|
18584
|
-
logger$
|
|
18656
|
+
logger$10.error(`Failed to fetch data for (${String(key)}:${String(value)}) :`, error);
|
|
18585
18657
|
this.loading$.next(false);
|
|
18586
18658
|
this.onError?.(new CollectionFetchError(`tryFetch(${String(key)})`, error));
|
|
18587
18659
|
}
|
|
18588
18660
|
}
|
|
18589
18661
|
get$(id) {
|
|
18590
18662
|
if (!this.observablesRegistry.has(id)) {
|
|
18591
|
-
this.observablesRegistry.set(id, new import_cjs$
|
|
18663
|
+
this.observablesRegistry.set(id, new import_cjs$9.ReplaySubject(1));
|
|
18592
18664
|
const data = this.collectionData.get(id);
|
|
18593
18665
|
if (data) this.observablesRegistry.get(id)?.next(data);
|
|
18594
18666
|
else this.tryFetch("id", id);
|
|
@@ -18612,9 +18684,9 @@ var EntityCollection = class extends Destroyable {
|
|
|
18612
18684
|
}
|
|
18613
18685
|
};
|
|
18614
18686
|
var EntityCollectionTransformed = class {
|
|
18615
|
-
constructor(originalCollection, filter$
|
|
18687
|
+
constructor(originalCollection, filter$17 = (i) => !!i, mapper = (item) => item) {
|
|
18616
18688
|
this.originalCollection = originalCollection;
|
|
18617
|
-
this.filter = filter$
|
|
18689
|
+
this.filter = filter$17;
|
|
18618
18690
|
this.mapper = mapper;
|
|
18619
18691
|
}
|
|
18620
18692
|
get loading$() {
|
|
@@ -18633,15 +18705,15 @@ var EntityCollectionTransformed = class {
|
|
|
18633
18705
|
return this.originalCollection.values.filter(this.filter).map(this.mapper);
|
|
18634
18706
|
}
|
|
18635
18707
|
get values$() {
|
|
18636
|
-
return this._values$ ??= this.originalCollection.values$.pipe((0, import_cjs$
|
|
18708
|
+
return this._values$ ??= this.originalCollection.values$.pipe((0, import_cjs$9.map)((values) => values.filter(this.filter).map(this.mapper)));
|
|
18637
18709
|
}
|
|
18638
18710
|
get$(id) {
|
|
18639
18711
|
const original$ = this.originalCollection.get$(id);
|
|
18640
|
-
return !original$ ? original$ : original$.pipe((0, import_cjs$
|
|
18712
|
+
return !original$ ? original$ : original$.pipe((0, import_cjs$9.pipe)((0, import_cjs$9.filter)(this.filter), (0, import_cjs$9.map)(this.mapper)));
|
|
18641
18713
|
}
|
|
18642
18714
|
async find$(key, value) {
|
|
18643
18715
|
const original$ = await this.originalCollection.find$(key, value);
|
|
18644
|
-
return !original$ ? original$ : original$.pipe((0, import_cjs$
|
|
18716
|
+
return !original$ ? original$ : original$.pipe((0, import_cjs$9.pipe)((0, import_cjs$9.filter)(this.filter), (0, import_cjs$9.map)(this.mapper)));
|
|
18645
18717
|
}
|
|
18646
18718
|
loadMore() {
|
|
18647
18719
|
this.originalCollection.loadMore();
|
|
@@ -18653,7 +18725,7 @@ var EntityCollectionTransformed = class {
|
|
|
18653
18725
|
|
|
18654
18726
|
//#endregion
|
|
18655
18727
|
//#region src/core/entities/Address.ts
|
|
18656
|
-
var import_cjs$
|
|
18728
|
+
var import_cjs$8 = require_cjs();
|
|
18657
18729
|
/**
|
|
18658
18730
|
* Represents a contact or room in the directory.
|
|
18659
18731
|
*
|
|
@@ -18671,8 +18743,8 @@ var Address = class extends Destroyable {
|
|
|
18671
18743
|
if (this._conversationMessages.hasMore) this._conversationMessages.loadMore();
|
|
18672
18744
|
return this._conversationMessages;
|
|
18673
18745
|
};
|
|
18674
|
-
this.textMessages$ = (0, import_cjs$
|
|
18675
|
-
this.history$ = (0, import_cjs$
|
|
18746
|
+
this.textMessages$ = (0, import_cjs$8.defer)(this.initConversationMessages).pipe((0, import_cjs$8.map)(() => this.textMessage), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this.destroyed$));
|
|
18747
|
+
this.history$ = (0, import_cjs$8.defer)(this.initConversationMessages).pipe((0, import_cjs$8.map)(() => this.history), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this.destroyed$));
|
|
18676
18748
|
this._state$ = this.createBehaviorSubject(null);
|
|
18677
18749
|
}
|
|
18678
18750
|
/** @internal */
|
|
@@ -18707,7 +18779,7 @@ var Address = class extends Destroyable {
|
|
|
18707
18779
|
}
|
|
18708
18780
|
/** Observable of the human-readable display name. */
|
|
18709
18781
|
get displayName$() {
|
|
18710
|
-
return this.cachedObservable("displayName$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18782
|
+
return this.cachedObservable("displayName$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.map)((state) => state.display_name), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18711
18783
|
}
|
|
18712
18784
|
/** Human-readable display name. */
|
|
18713
18785
|
get displayName() {
|
|
@@ -18716,7 +18788,7 @@ var Address = class extends Destroyable {
|
|
|
18716
18788
|
}
|
|
18717
18789
|
/** Observable of the preview image URL. */
|
|
18718
18790
|
get previewUrl$() {
|
|
18719
|
-
return this.cachedObservable("previewUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18791
|
+
return this.cachedObservable("previewUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.map)((state) => state.preview_url), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18720
18792
|
}
|
|
18721
18793
|
/** Preview image URL. */
|
|
18722
18794
|
get previewUrl() {
|
|
@@ -18725,7 +18797,7 @@ var Address = class extends Destroyable {
|
|
|
18725
18797
|
}
|
|
18726
18798
|
/** Observable of the cover image URL. */
|
|
18727
18799
|
get coverUrl$() {
|
|
18728
|
-
return this.cachedObservable("coverUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18800
|
+
return this.cachedObservable("coverUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.map)((state) => state.cover_url), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18729
18801
|
}
|
|
18730
18802
|
/** Cover image URL. */
|
|
18731
18803
|
get coverUrl() {
|
|
@@ -18734,7 +18806,7 @@ var Address = class extends Destroyable {
|
|
|
18734
18806
|
}
|
|
18735
18807
|
/** Observable of the underlying resource ID. */
|
|
18736
18808
|
get resourceId$() {
|
|
18737
|
-
return this.cachedObservable("resourceId$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18809
|
+
return this.cachedObservable("resourceId$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.map)((state) => state.resource_id), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18738
18810
|
}
|
|
18739
18811
|
/** Underlying resource ID. */
|
|
18740
18812
|
get resourceId() {
|
|
@@ -18743,7 +18815,7 @@ var Address = class extends Destroyable {
|
|
|
18743
18815
|
}
|
|
18744
18816
|
/** Observable of the resource type (e.g. `'room'`, `'subscriber'`). */
|
|
18745
18817
|
get type$() {
|
|
18746
|
-
return this.cachedObservable("type$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18818
|
+
return this.cachedObservable("type$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.map)((state) => state.type), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18747
18819
|
}
|
|
18748
18820
|
/** Resource type (e.g. `'room'`, `'subscriber'`). */
|
|
18749
18821
|
get type() {
|
|
@@ -18752,7 +18824,7 @@ var Address = class extends Destroyable {
|
|
|
18752
18824
|
}
|
|
18753
18825
|
/** Observable of available communication channels (audio, video, messaging). */
|
|
18754
18826
|
get channels$() {
|
|
18755
|
-
return this.cachedObservable("channels$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18827
|
+
return this.cachedObservable("channels$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.map)((state) => state.channels), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18756
18828
|
}
|
|
18757
18829
|
/** Available communication channels. */
|
|
18758
18830
|
get channels() {
|
|
@@ -18766,7 +18838,7 @@ var Address = class extends Destroyable {
|
|
|
18766
18838
|
}
|
|
18767
18839
|
/** Observable indicating whether the address (room) is locked. */
|
|
18768
18840
|
get locked$() {
|
|
18769
|
-
return this.cachedObservable("locked$", () => this._state$.pipe(filterNull(), (0, import_cjs$
|
|
18841
|
+
return this.cachedObservable("locked$", () => this._state$.pipe(filterNull(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.map)((state) => state.locked), (0, import_cjs$8.takeUntil)(this.destroyed$)));
|
|
18770
18842
|
}
|
|
18771
18843
|
/**
|
|
18772
18844
|
* Sends a text message to this address.
|
|
@@ -18832,14 +18904,14 @@ var Address = class extends Destroyable {
|
|
|
18832
18904
|
|
|
18833
18905
|
//#endregion
|
|
18834
18906
|
//#region src/core/utils.ts
|
|
18835
|
-
var import_cjs$
|
|
18836
|
-
const logger$
|
|
18907
|
+
var import_cjs$7 = require_cjs();
|
|
18908
|
+
const logger$9 = getLogger();
|
|
18837
18909
|
const isRPCConnectResult = (e) => {
|
|
18838
|
-
logger$
|
|
18910
|
+
logger$9.debug("isRPCConnectResult check:", e);
|
|
18839
18911
|
if (!e || typeof e !== "object") return false;
|
|
18840
18912
|
const result = e;
|
|
18841
18913
|
const is = typeof result.identity === "string" && typeof result.protocol === "string" && typeof result.authorization === "object" && typeof result.authorization.jti === "string" && typeof result.authorization.project_id === "string" && typeof result.authorization.fabric_subscriber === "object";
|
|
18842
|
-
logger$
|
|
18914
|
+
logger$9.debug("isRPCConnectResult check result:", is);
|
|
18843
18915
|
return is;
|
|
18844
18916
|
};
|
|
18845
18917
|
var PendingRPC = class PendingRPC {
|
|
@@ -18848,7 +18920,7 @@ var PendingRPC = class PendingRPC {
|
|
|
18848
18920
|
}
|
|
18849
18921
|
constructor(request, responses$, options) {
|
|
18850
18922
|
this.id = v4_default();
|
|
18851
|
-
logger$
|
|
18923
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}: method:${request.method}] Creating PendingRPC`);
|
|
18852
18924
|
this.request = request;
|
|
18853
18925
|
const timeoutMs = options?.timeoutMs ?? PendingRPC.defaultTimeoutMs;
|
|
18854
18926
|
const signal = options?.signal;
|
|
@@ -18858,38 +18930,38 @@ var PendingRPC = class PendingRPC {
|
|
|
18858
18930
|
return;
|
|
18859
18931
|
}
|
|
18860
18932
|
let isSettled = false;
|
|
18861
|
-
const subscription = (0, import_cjs$
|
|
18862
|
-
const timer$
|
|
18933
|
+
const subscription = (0, import_cjs$7.race)(responses$.pipe((0, import_cjs$7.filter)((result) => result.id === request.id), (0, import_cjs$7.take)(1)), new import_cjs$7.Observable((subscriber) => {
|
|
18934
|
+
const timer$3 = setTimeout(() => {
|
|
18863
18935
|
subscriber.error(new RPCTimeoutError(request.id, timeoutMs));
|
|
18864
18936
|
}, timeoutMs);
|
|
18865
|
-
return () => clearTimeout(timer$
|
|
18866
|
-
}), signal ? new import_cjs$
|
|
18937
|
+
return () => clearTimeout(timer$3);
|
|
18938
|
+
}), signal ? new import_cjs$7.Observable((subscriber) => {
|
|
18867
18939
|
const abortHandler = () => {
|
|
18868
18940
|
subscriber.error(new DOMException("The operation was aborted", "AbortError"));
|
|
18869
18941
|
};
|
|
18870
18942
|
signal.addEventListener("abort", abortHandler);
|
|
18871
18943
|
return () => signal.removeEventListener("abort", abortHandler);
|
|
18872
|
-
}) : import_cjs$
|
|
18944
|
+
}) : import_cjs$7.NEVER).subscribe({
|
|
18873
18945
|
next: (response) => {
|
|
18874
18946
|
isSettled = true;
|
|
18875
18947
|
if (response.error) {
|
|
18876
18948
|
const rpcError = new JSONRPCError(response.error.code, response.error.message, response.error.data, void 0, request.id);
|
|
18877
|
-
logger$
|
|
18949
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with RPC error:`, rpcError);
|
|
18878
18950
|
reject(rpcError);
|
|
18879
18951
|
} else {
|
|
18880
|
-
logger$
|
|
18952
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Resolving promise with response:`, response);
|
|
18881
18953
|
resolve(response);
|
|
18882
18954
|
}
|
|
18883
18955
|
subscription.unsubscribe();
|
|
18884
18956
|
},
|
|
18885
18957
|
error: (error) => {
|
|
18886
|
-
logger$
|
|
18958
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with error:`, error);
|
|
18887
18959
|
isSettled = true;
|
|
18888
18960
|
reject(error);
|
|
18889
18961
|
subscription.unsubscribe();
|
|
18890
18962
|
},
|
|
18891
18963
|
complete: () => {
|
|
18892
|
-
logger$
|
|
18964
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Observable completed`);
|
|
18893
18965
|
if (!isSettled) reject(new RPCTimeoutError(request.id, timeoutMs));
|
|
18894
18966
|
subscription.unsubscribe();
|
|
18895
18967
|
}
|
|
@@ -18909,8 +18981,8 @@ var PendingRPC = class PendingRPC {
|
|
|
18909
18981
|
|
|
18910
18982
|
//#endregion
|
|
18911
18983
|
//#region src/managers/ClientSessionManager.ts
|
|
18912
|
-
var import_cjs$
|
|
18913
|
-
const logger$
|
|
18984
|
+
var import_cjs$6 = require_cjs();
|
|
18985
|
+
const logger$8 = getLogger();
|
|
18914
18986
|
const getAddressSearchURI = (options) => {
|
|
18915
18987
|
const to = options.to?.split("?")[0];
|
|
18916
18988
|
const from$9 = options.from?.startsWith("subscriber://") ? options.from.replace("subscriber://", "") : options.from;
|
|
@@ -18945,10 +19017,10 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
18945
19017
|
this._iceServers$ = this.createBehaviorSubject([]);
|
|
18946
19018
|
attachManager.setSession(this);
|
|
18947
19019
|
this.callFactory = new CallFactory(this, deviceController, attachManager, webRTCApiProvider, networkChange$);
|
|
18948
|
-
this.initialized$ = (0, import_cjs$
|
|
19020
|
+
this.initialized$ = (0, import_cjs$6.defer)(() => (0, import_cjs$6.from)(this.init())).pipe((0, import_cjs$6.shareReplay)(1), (0, import_cjs$6.takeUntil)(this.destroyed$));
|
|
18949
19021
|
}
|
|
18950
19022
|
get incomingCalls$() {
|
|
18951
|
-
return this.cachedObservable("incomingCalls$", () => this.calls$.pipe((0, import_cjs$
|
|
19023
|
+
return this.cachedObservable("incomingCalls$", () => this.calls$.pipe((0, import_cjs$6.map)((calls) => calls.filter((call) => call.direction === "inbound"))));
|
|
18952
19024
|
}
|
|
18953
19025
|
get incomingCalls() {
|
|
18954
19026
|
return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
|
|
@@ -18960,7 +19032,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
18960
19032
|
return this._subscriberInfo$.value;
|
|
18961
19033
|
}
|
|
18962
19034
|
get calls$() {
|
|
18963
|
-
return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$
|
|
19035
|
+
return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$6.map)((calls) => Object.values(calls))));
|
|
18964
19036
|
}
|
|
18965
19037
|
get calls() {
|
|
18966
19038
|
return Object.values(this._calls$.value);
|
|
@@ -19004,7 +19076,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19004
19076
|
try {
|
|
19005
19077
|
return await this.transport.execute(request, options);
|
|
19006
19078
|
} catch (error) {
|
|
19007
|
-
logger$
|
|
19079
|
+
logger$8.debug("[Session] Execute Error", error);
|
|
19008
19080
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
19009
19081
|
throw error;
|
|
19010
19082
|
}
|
|
@@ -19018,40 +19090,40 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19018
19090
|
return true;
|
|
19019
19091
|
}
|
|
19020
19092
|
setupMessageHandlers() {
|
|
19021
|
-
logger$
|
|
19093
|
+
logger$8.debug("[Session] Setting up message handlers");
|
|
19022
19094
|
this.subscribeTo(this.authStateEvent$, async (authStateEvent) => {
|
|
19023
|
-
logger$
|
|
19095
|
+
logger$8.debug("[Session] Authorization state event received:", authStateEvent);
|
|
19024
19096
|
try {
|
|
19025
19097
|
await this.updateAuthorizationStateInStorage(authStateEvent.authorization_state);
|
|
19026
19098
|
} catch (error) {
|
|
19027
|
-
logger$
|
|
19099
|
+
logger$8.error("[Session] Failed to handle authorization state update:", error);
|
|
19028
19100
|
this._errors$.next(new AuthStateHandlerError(error));
|
|
19029
19101
|
}
|
|
19030
19102
|
});
|
|
19031
|
-
this.subscribeTo(this.transport.connectionStatus$.pipe((0, import_cjs$
|
|
19032
|
-
logger$
|
|
19033
|
-
return (0, import_cjs$
|
|
19103
|
+
this.subscribeTo(this.transport.connectionStatus$.pipe((0, import_cjs$6.filter)((status) => status === "connected"), (0, import_cjs$6.exhaustMap)(() => {
|
|
19104
|
+
logger$8.debug("[Session] Connection established, initiating authentication");
|
|
19105
|
+
return (0, import_cjs$6.from)(this.authenticate()).pipe((0, import_cjs$6.catchError)((error) => {
|
|
19034
19106
|
this.handleAuthenticationError(error).catch((err) => {
|
|
19035
|
-
logger$
|
|
19107
|
+
logger$8.error("[Session] Error handling authentication failure:", err);
|
|
19036
19108
|
});
|
|
19037
|
-
return import_cjs$
|
|
19109
|
+
return import_cjs$6.EMPTY;
|
|
19038
19110
|
}));
|
|
19039
19111
|
})), void 0);
|
|
19040
19112
|
this.subscribeTo(this.vertoInvite$, async (invite) => {
|
|
19041
|
-
logger$
|
|
19113
|
+
logger$8.debug("[Session] Verto invite received:", invite);
|
|
19042
19114
|
try {
|
|
19043
19115
|
await this.createInboundCall(invite);
|
|
19044
19116
|
} catch (error) {
|
|
19045
|
-
logger$
|
|
19117
|
+
logger$8.error("[Session] Error handling Verto invite:", error);
|
|
19046
19118
|
this._errors$.next(new VertoInviteHandlerError(error));
|
|
19047
19119
|
}
|
|
19048
19120
|
});
|
|
19049
19121
|
this.subscribeTo(this.vertoAttach$, async (attach) => {
|
|
19050
|
-
logger$
|
|
19122
|
+
logger$8.debug("[Session] Verto attach received:", attach);
|
|
19051
19123
|
try {
|
|
19052
19124
|
await this.handleVertoAttach(attach);
|
|
19053
19125
|
} catch (error) {
|
|
19054
|
-
logger$
|
|
19126
|
+
logger$8.error("[Session] Error handling Verto attach:", error);
|
|
19055
19127
|
this._errors$.next(new VertoAttachHandlerError(error));
|
|
19056
19128
|
}
|
|
19057
19129
|
});
|
|
@@ -19061,49 +19133,49 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19061
19133
|
const storedState = await this.storage.getItem(this.authorizationStateKey);
|
|
19062
19134
|
this.authorizationState$.next(storedState ?? void 0);
|
|
19063
19135
|
} catch (error) {
|
|
19064
|
-
logger$
|
|
19136
|
+
logger$8.error("Failed to retrieve authorization state from storage:", error);
|
|
19065
19137
|
this.authorizationState$.next(void 0);
|
|
19066
19138
|
}
|
|
19067
19139
|
}
|
|
19068
19140
|
async updateAuthorizationStateInStorage(authorizationState) {
|
|
19069
19141
|
if (!authorizationState) {
|
|
19070
|
-
logger$
|
|
19142
|
+
logger$8.debug("[Session] Removing authorization state from storage");
|
|
19071
19143
|
try {
|
|
19072
19144
|
await this.storage.removeItem(this.authorizationStateKey);
|
|
19073
19145
|
this.authorizationState$.next(void 0);
|
|
19074
19146
|
} catch (error) {
|
|
19075
|
-
logger$
|
|
19147
|
+
logger$8.error("Failed to remove authorization state from storage:", error);
|
|
19076
19148
|
throw error;
|
|
19077
19149
|
}
|
|
19078
19150
|
return;
|
|
19079
19151
|
}
|
|
19080
19152
|
try {
|
|
19081
|
-
logger$
|
|
19153
|
+
logger$8.debug("[Session] Updating authorization state in storage");
|
|
19082
19154
|
await this.storage.setItem(this.authorizationStateKey, authorizationState);
|
|
19083
19155
|
this.authorizationState$.next(authorizationState);
|
|
19084
19156
|
} catch (error) {
|
|
19085
|
-
logger$
|
|
19157
|
+
logger$8.error("Failed to retrieve authorization state from storage:", error);
|
|
19086
19158
|
throw error;
|
|
19087
19159
|
}
|
|
19088
19160
|
}
|
|
19089
19161
|
get authStateEvent$() {
|
|
19090
|
-
return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, import_cjs$
|
|
19091
|
-
logger$
|
|
19092
|
-
}), filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, import_cjs$
|
|
19093
|
-
logger$
|
|
19162
|
+
return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, import_cjs$6.tap)((msg) => {
|
|
19163
|
+
logger$8.debug("[Session] Received incoming message:", msg);
|
|
19164
|
+
}), filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, import_cjs$6.tap)((event) => {
|
|
19165
|
+
logger$8.debug("[Session] Authorization state event received:", event.authorization_state);
|
|
19094
19166
|
})));
|
|
19095
19167
|
}
|
|
19096
19168
|
get signalingEvent$() {
|
|
19097
|
-
return this.cachedObservable("signalingEvent$", () => this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"), (0, import_cjs$
|
|
19169
|
+
return this.cachedObservable("signalingEvent$", () => this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"), (0, import_cjs$6.share)()));
|
|
19098
19170
|
}
|
|
19099
19171
|
get vertoInvite$() {
|
|
19100
|
-
return this.cachedObservable("vertoInvite$", () => this.signalingEvent$.pipe((0, import_cjs$
|
|
19172
|
+
return this.cachedObservable("vertoInvite$", () => this.signalingEvent$.pipe((0, import_cjs$6.filter)(isWebrtcMessageMetadata), (0, import_cjs$6.filter)((event) => isVertoInviteMessage(event.params)), (0, import_cjs$6.map)((event) => ({
|
|
19101
19173
|
node_id: event.node_id,
|
|
19102
19174
|
...event.params.params
|
|
19103
19175
|
}))));
|
|
19104
19176
|
}
|
|
19105
19177
|
get vertoAttach$() {
|
|
19106
|
-
return this.cachedObservable("vertoAttach$", () => this.signalingEvent$.pipe((0, import_cjs$
|
|
19178
|
+
return this.cachedObservable("vertoAttach$", () => this.signalingEvent$.pipe((0, import_cjs$6.filter)(isWebrtcMessageMetadata), (0, import_cjs$6.filter)((event) => isVertoAttachMessage(event.params)), (0, import_cjs$6.map)((event) => ({
|
|
19107
19179
|
node_id: event.node_id,
|
|
19108
19180
|
...event.params.params
|
|
19109
19181
|
}))));
|
|
@@ -19123,20 +19195,20 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19123
19195
|
return { jwt_token: credential.token };
|
|
19124
19196
|
}
|
|
19125
19197
|
async connect() {
|
|
19126
|
-
await (0, import_cjs$
|
|
19198
|
+
await (0, import_cjs$6.firstValueFrom)(this.initialized$);
|
|
19127
19199
|
await this.transport.connect();
|
|
19128
|
-
await (0, import_cjs$
|
|
19200
|
+
await (0, import_cjs$6.firstValueFrom)(this.authenticated$.pipe((0, import_cjs$6.takeUntil)(this.destroyed$), (0, import_cjs$6.filter)(Boolean), (0, import_cjs$6.take)(1), (0, import_cjs$6.timeout)({ first: 15e3 })));
|
|
19129
19201
|
}
|
|
19130
19202
|
async handleAuthenticationError(error) {
|
|
19131
|
-
logger$
|
|
19203
|
+
logger$8.error("Authentication error:", error);
|
|
19132
19204
|
const isRecoverableAuthError = error instanceof JSONRPCError && (error.code === RPC_ERROR_REQUESTER_VALIDATION_FAILED || error.code === RPC_ERROR_INVALID_PARAMS || error.code === RPC_ERROR_AUTHENTICATION_FAILED);
|
|
19133
|
-
const hasStoredState = await (0, import_cjs$
|
|
19205
|
+
const hasStoredState = await (0, import_cjs$6.firstValueFrom)(this.authorizationState$.pipe((0, import_cjs$6.take)(1))) !== void 0;
|
|
19134
19206
|
if (isRecoverableAuthError && hasStoredState) {
|
|
19135
|
-
logger$
|
|
19207
|
+
logger$8.debug("[Session] Recoverable auth error — cleaning up stored state and reconnecting fresh");
|
|
19136
19208
|
try {
|
|
19137
19209
|
await this.cleanupStoredConnectionParams();
|
|
19138
19210
|
} catch (cleanupError) {
|
|
19139
|
-
logger$
|
|
19211
|
+
logger$8.error("Failed to cleanup stored connection params:", cleanupError);
|
|
19140
19212
|
} finally {
|
|
19141
19213
|
this.transport.reconnect();
|
|
19142
19214
|
}
|
|
@@ -19151,44 +19223,44 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19151
19223
|
try {
|
|
19152
19224
|
await this.storage.setItem(this.authorizationStateKey, authorization_state);
|
|
19153
19225
|
} catch (error) {
|
|
19154
|
-
logger$
|
|
19226
|
+
logger$8.error("Failed to update authorization state in storage:", error);
|
|
19155
19227
|
this._errors$.next(new AuthStateHandlerError(error));
|
|
19156
19228
|
}
|
|
19157
19229
|
}
|
|
19158
19230
|
async reauthenticate(token, dpopToken, options) {
|
|
19159
|
-
logger$
|
|
19231
|
+
logger$8.debug("[Session] Re-authenticating session");
|
|
19160
19232
|
try {
|
|
19161
19233
|
let resolvedDpopToken = dpopToken;
|
|
19162
19234
|
if (!resolvedDpopToken && this.dpopManager?.initialized) try {
|
|
19163
19235
|
resolvedDpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
19164
19236
|
} catch (error) {
|
|
19165
19237
|
if (this._clientBound) throw error;
|
|
19166
|
-
logger$
|
|
19238
|
+
logger$8.warn("[Session] Failed to create DPoP proof for reauthenticate:", error);
|
|
19167
19239
|
}
|
|
19168
19240
|
const request = RPCReauthenticate({
|
|
19169
19241
|
project: this._authorization$.value?.project_id ?? "",
|
|
19170
19242
|
jwt_token: token,
|
|
19171
19243
|
...resolvedDpopToken ? { dpop_token: resolvedDpopToken } : {}
|
|
19172
19244
|
});
|
|
19173
|
-
await (0, import_cjs$
|
|
19174
|
-
logger$
|
|
19245
|
+
await (0, import_cjs$6.lastValueFrom)((0, import_cjs$6.from)(this.transport.execute(request)).pipe(throwOnRPCError(), (0, import_cjs$6.take)(1), (0, import_cjs$6.catchError)((err) => {
|
|
19246
|
+
logger$8.error("[Session] Re-authentication RPC failed:", err);
|
|
19175
19247
|
throw err;
|
|
19176
19248
|
})));
|
|
19177
19249
|
if (options?.clientBound) this._clientBound = true;
|
|
19178
|
-
logger$
|
|
19250
|
+
logger$8.debug("[Session] Re-authentication successful, updating stored auth state");
|
|
19179
19251
|
} catch (error) {
|
|
19180
|
-
logger$
|
|
19252
|
+
logger$8.error("[Session] Re-authentication failed:", error);
|
|
19181
19253
|
this._errors$.next(new AuthStateHandlerError(error));
|
|
19182
19254
|
throw error;
|
|
19183
19255
|
}
|
|
19184
19256
|
}
|
|
19185
19257
|
async authenticate() {
|
|
19186
|
-
logger$
|
|
19187
|
-
const persistedParams = await (0, import_cjs$
|
|
19258
|
+
logger$8.debug("[Session] Starting authentication process");
|
|
19259
|
+
const persistedParams = await (0, import_cjs$6.firstValueFrom)((0, import_cjs$6.combineLatest)({
|
|
19188
19260
|
protocol: this.transport.protocol$,
|
|
19189
19261
|
authorization_state: this.authorizationState$
|
|
19190
|
-
}).pipe((0, import_cjs$
|
|
19191
|
-
logger$
|
|
19262
|
+
}).pipe((0, import_cjs$6.take)(1)));
|
|
19263
|
+
logger$8.debug("[Session] Persisted params:\n", {
|
|
19192
19264
|
protocol: persistedParams.protocol,
|
|
19193
19265
|
authStateLength: persistedParams.authorization_state?.length
|
|
19194
19266
|
});
|
|
@@ -19196,16 +19268,16 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19196
19268
|
const storedToken = this.getCredential().token;
|
|
19197
19269
|
const isReconnect = hasReconnectState && storedToken;
|
|
19198
19270
|
let dpopToken;
|
|
19199
|
-
if (isReconnect) logger$
|
|
19271
|
+
if (isReconnect) logger$8.debug("[Session] Reconnecting with stored jwt_token + authorization_state");
|
|
19200
19272
|
else if (this.onBeforeReconnect && this._clientBound) {
|
|
19201
|
-
logger$
|
|
19273
|
+
logger$8.debug("[Session] Refreshing credentials before fresh connect");
|
|
19202
19274
|
await this.onBeforeReconnect();
|
|
19203
19275
|
}
|
|
19204
19276
|
if ((!isReconnect || this._clientBound) && this.dpopManager?.initialized) try {
|
|
19205
19277
|
dpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.connect" });
|
|
19206
19278
|
} catch (error) {
|
|
19207
19279
|
if (this._clientBound) throw error;
|
|
19208
|
-
logger$
|
|
19280
|
+
logger$8.warn("[Session] Failed to create DPoP proof for connect, proceeding without:", error);
|
|
19209
19281
|
}
|
|
19210
19282
|
const rpcConnectRequest = RPCConnect({
|
|
19211
19283
|
authentication: isReconnect ? { jwt_token: storedToken } : this.authentication,
|
|
@@ -19221,13 +19293,13 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19221
19293
|
protocol: persistedParams.protocol
|
|
19222
19294
|
} : {}
|
|
19223
19295
|
});
|
|
19224
|
-
const response = await (0, import_cjs$
|
|
19225
|
-
logger$
|
|
19226
|
-
}), (0, import_cjs$
|
|
19227
|
-
logger$
|
|
19296
|
+
const response = await (0, import_cjs$6.lastValueFrom)((0, import_cjs$6.from)(this.transport.execute(rpcConnectRequest)).pipe(throwOnRPCError(), (0, import_cjs$6.map)((res) => res.result), (0, import_cjs$6.filter)(isRPCConnectResult), (0, import_cjs$6.tap)(() => {
|
|
19297
|
+
logger$8.debug("[Session] Response passed filter, processing authentication result");
|
|
19298
|
+
}), (0, import_cjs$6.take)(1), (0, import_cjs$6.catchError)((err) => {
|
|
19299
|
+
logger$8.error("[Session] Authentication RPC failed:", err);
|
|
19228
19300
|
throw err;
|
|
19229
19301
|
})));
|
|
19230
|
-
logger$
|
|
19302
|
+
logger$8.debug("[Session] Processing authentication result:", {
|
|
19231
19303
|
hasProtocol: !!response.protocol,
|
|
19232
19304
|
hasAuthorization: !!response.authorization,
|
|
19233
19305
|
hasIceServers: !!response.ice_servers
|
|
@@ -19236,7 +19308,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19236
19308
|
this._authorization$.next(response.authorization);
|
|
19237
19309
|
this._iceServers$.next(response.ice_servers ?? []);
|
|
19238
19310
|
this._authenticated$.next(true);
|
|
19239
|
-
logger$
|
|
19311
|
+
logger$8.debug("[Session] Authentication completed successfully");
|
|
19240
19312
|
}
|
|
19241
19313
|
async disconnect() {
|
|
19242
19314
|
this.transport.disconnect();
|
|
@@ -19255,7 +19327,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19255
19327
|
displayDirection: invite.display_direction,
|
|
19256
19328
|
userVariables: invite.userVariables
|
|
19257
19329
|
});
|
|
19258
|
-
await (0, import_cjs$
|
|
19330
|
+
await (0, import_cjs$6.firstValueFrom)(callSession.status$);
|
|
19259
19331
|
this._calls$.next({
|
|
19260
19332
|
[`${callSession.id}`]: callSession,
|
|
19261
19333
|
...this._calls$.value
|
|
@@ -19273,11 +19345,11 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19273
19345
|
async handleVertoAttach(attach) {
|
|
19274
19346
|
const { callID } = attach;
|
|
19275
19347
|
if (callID in this._calls$.value) {
|
|
19276
|
-
logger$
|
|
19348
|
+
logger$8.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
|
|
19277
19349
|
return;
|
|
19278
19350
|
}
|
|
19279
19351
|
const storedOptions = this.attachManager.consumePendingAttachment(callID);
|
|
19280
|
-
logger$
|
|
19352
|
+
logger$8.debug(`[Session] Creating reattached call for callID: ${callID}`);
|
|
19281
19353
|
const callSession = await this.createCall({
|
|
19282
19354
|
nodeId: attach.node_id,
|
|
19283
19355
|
callId: callID,
|
|
@@ -19288,7 +19360,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19288
19360
|
reattach: true,
|
|
19289
19361
|
...storedOptions
|
|
19290
19362
|
});
|
|
19291
|
-
await (0, import_cjs$
|
|
19363
|
+
await (0, import_cjs$6.firstValueFrom)(callSession.status$);
|
|
19292
19364
|
this._calls$.next({
|
|
19293
19365
|
[`${callSession.id}`]: callSession,
|
|
19294
19366
|
...this._calls$.value
|
|
@@ -19302,16 +19374,16 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19302
19374
|
to: destinationURI,
|
|
19303
19375
|
...options
|
|
19304
19376
|
});
|
|
19305
|
-
await (0, import_cjs$
|
|
19377
|
+
await (0, import_cjs$6.firstValueFrom)((0, import_cjs$6.race)(callSession.selfId$.pipe((0, import_cjs$6.filter)((id) => Boolean(id)), (0, import_cjs$6.take)(1), (0, import_cjs$6.timeout)(this.callCreateTimeout)), callSession.errors$.pipe((0, import_cjs$6.take)(1), (0, import_cjs$6.switchMap)((callError) => (0, import_cjs$6.throwError)(() => callError.error)))));
|
|
19306
19378
|
this._calls$.next({
|
|
19307
19379
|
[`${callSession.id}`]: callSession,
|
|
19308
19380
|
...this._calls$.value
|
|
19309
19381
|
});
|
|
19310
19382
|
return callSession;
|
|
19311
19383
|
} catch (error) {
|
|
19312
|
-
logger$
|
|
19384
|
+
logger$8.error("[Session] Error creating outbound call:", error);
|
|
19313
19385
|
callSession?.destroy();
|
|
19314
|
-
const callError = new CallCreateError(error instanceof import_cjs$
|
|
19386
|
+
const callError = new CallCreateError(error instanceof import_cjs$6.TimeoutError ? "Call create timeout" : "Call creation failed", error, "outbound");
|
|
19315
19387
|
this._errors$.next(callError);
|
|
19316
19388
|
throw callError;
|
|
19317
19389
|
}
|
|
@@ -19327,16 +19399,16 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19327
19399
|
address = this._directory.get(addressId);
|
|
19328
19400
|
if (!address) throw new DependencyError(`Address ID: ${addressId} not found`);
|
|
19329
19401
|
} catch {
|
|
19330
|
-
logger$
|
|
19402
|
+
logger$8.warn(`[Session] Directory lookup failed for ${addressURI}, proceeding with raw URI`);
|
|
19331
19403
|
}
|
|
19332
19404
|
const callSession = this.callFactory.createCall(address, { ...options });
|
|
19333
|
-
this.subscribeTo(callSession.status$.pipe((0, import_cjs$
|
|
19405
|
+
this.subscribeTo(callSession.status$.pipe((0, import_cjs$6.filter)((status) => status === "destroyed"), (0, import_cjs$6.take)(1)), () => {
|
|
19334
19406
|
const { [`${callSession.id}`]: _, ...remainingCalls } = this._calls$.value;
|
|
19335
19407
|
this._calls$.next(remainingCalls);
|
|
19336
19408
|
});
|
|
19337
19409
|
return callSession;
|
|
19338
19410
|
} catch (error) {
|
|
19339
|
-
logger$
|
|
19411
|
+
logger$8.error("[Session] Error creating call session:", error);
|
|
19340
19412
|
throw new CallCreateError("Call create error", error, options.initOffer ? "inbound" : "outbound");
|
|
19341
19413
|
}
|
|
19342
19414
|
}
|
|
@@ -19384,8 +19456,8 @@ const isString = (obj) => typeof obj === "string";
|
|
|
19384
19456
|
|
|
19385
19457
|
//#endregion
|
|
19386
19458
|
//#region src/managers/ConversationsManager.ts
|
|
19387
|
-
var import_cjs$
|
|
19388
|
-
const logger$
|
|
19459
|
+
var import_cjs$5 = require_cjs();
|
|
19460
|
+
const logger$7 = getLogger();
|
|
19389
19461
|
var ConversationMessagesFetcher = class extends Fetcher {
|
|
19390
19462
|
constructor(groupId, http) {
|
|
19391
19463
|
super(`/api/fabric/conversations/${groupId}/messages`, "page_size=100", http);
|
|
@@ -19425,13 +19497,13 @@ var ConversationsManager = class {
|
|
|
19425
19497
|
}
|
|
19426
19498
|
throw new ConversationError("Join Failed - Unexpected response");
|
|
19427
19499
|
} catch (error) {
|
|
19428
|
-
logger$
|
|
19500
|
+
logger$7.error("[ConversationsManager] Failed to join conversation:", error);
|
|
19429
19501
|
throw error;
|
|
19430
19502
|
}
|
|
19431
19503
|
}
|
|
19432
19504
|
async getConversationMessageCollection(addressId) {
|
|
19433
19505
|
const groupId = this.groupIds.get(addressId) ?? await this.join(addressId);
|
|
19434
|
-
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(filterAs(isConversationMessageMetadata, "params"), (0, import_cjs$
|
|
19506
|
+
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(filterAs(isConversationMessageMetadata, "params"), (0, import_cjs$5.tap)((event) => logger$7.debug("[ConversationsManager ] Conversation Event:", event)), (0, import_cjs$5.map)((params) => ({ ...params }))), this.http, this.onError));
|
|
19435
19507
|
}
|
|
19436
19508
|
async sendText(text, destinationAddressId) {
|
|
19437
19509
|
const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
|
|
@@ -19448,12 +19520,222 @@ var ConversationsManager = class {
|
|
|
19448
19520
|
})).ok) return;
|
|
19449
19521
|
throw new ConversationError("Send Text Failed - Unexpected response");
|
|
19450
19522
|
} catch (error) {
|
|
19451
|
-
logger$
|
|
19523
|
+
logger$7.error("[ConversationsManager] Failed to send text message:", error);
|
|
19452
19524
|
throw error;
|
|
19453
19525
|
}
|
|
19454
19526
|
}
|
|
19455
19527
|
};
|
|
19456
19528
|
|
|
19529
|
+
//#endregion
|
|
19530
|
+
//#region src/managers/DeviceTokenManager.ts
|
|
19531
|
+
var import_cjs$4 = require_cjs();
|
|
19532
|
+
const logger$6 = getLogger();
|
|
19533
|
+
/**
|
|
19534
|
+
* Resolves the token expiry timestamp (epoch seconds) using a 3-tier priority chain:
|
|
19535
|
+
* 1. `data.expires_at` — server-provided absolute timestamp
|
|
19536
|
+
* 2. `data.expires_in` — server-provided relative lifetime
|
|
19537
|
+
* 3. Fallback to `DEVICE_TOKEN_DEFAULT_EXPIRE_IN` with a warning
|
|
19538
|
+
*/
|
|
19539
|
+
function resolveExpiresAt(data) {
|
|
19540
|
+
if (data.expires_at) return data.expires_at;
|
|
19541
|
+
if (data.expires_in) return Math.floor(Date.now() / 1e3) + data.expires_in;
|
|
19542
|
+
logger$6.warn("[DeviceToken] Could not determine token expiry, using default");
|
|
19543
|
+
return Math.floor(Date.now() / 1e3) + DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
19544
|
+
}
|
|
19545
|
+
/**
|
|
19546
|
+
* Resolves the token TTL in seconds from a fresh response.
|
|
19547
|
+
* Called at token receive time so `expires_at - now` reflects the original lifetime.
|
|
19548
|
+
*
|
|
19549
|
+
* 1. `data.expires_in` — server-provided TTL directly
|
|
19550
|
+
* 2. `data.expires_at - now` — derive TTL from absolute timestamp
|
|
19551
|
+
* 3. Fallback to `DEVICE_TOKEN_DEFAULT_EXPIRE_IN`
|
|
19552
|
+
*/
|
|
19553
|
+
function resolveExpireIn(data) {
|
|
19554
|
+
if (data.expires_in) return data.expires_in;
|
|
19555
|
+
if (data.expires_at) return Math.max(data.expires_at - Math.floor(Date.now() / 1e3), 1);
|
|
19556
|
+
return DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
19557
|
+
}
|
|
19558
|
+
/**
|
|
19559
|
+
* Manages the Client Bound SAT lifecycle: activation, token exchange,
|
|
19560
|
+
* reauthentication, and automatic refresh scheduling.
|
|
19561
|
+
*
|
|
19562
|
+
* Extends {@link Destroyable} for automatic RxJS subscription and subject cleanup.
|
|
19563
|
+
* Uses a reactive pipeline (`BehaviorSubject` + `switchMap(timer())`) instead of
|
|
19564
|
+
* raw `setTimeout` for refresh scheduling.
|
|
19565
|
+
*/
|
|
19566
|
+
var DeviceTokenManager = class extends Destroyable {
|
|
19567
|
+
constructor(dpopManager, http, errorHandler, getCredential) {
|
|
19568
|
+
super();
|
|
19569
|
+
this.dpopManager = dpopManager;
|
|
19570
|
+
this.http = http;
|
|
19571
|
+
this.errorHandler = errorHandler;
|
|
19572
|
+
this.getCredential = getCredential;
|
|
19573
|
+
this._currentToken$ = this.createBehaviorSubject(null);
|
|
19574
|
+
this._refreshInProgress = false;
|
|
19575
|
+
this._effectiveExpireIn = DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
19576
|
+
this.subscribeTo(this._currentToken$.pipe((0, import_cjs$4.filter)(Boolean), (0, import_cjs$4.switchMap)((tokenData) => {
|
|
19577
|
+
const expiresAt = resolveExpiresAt(tokenData);
|
|
19578
|
+
const refreshIn = Math.max(expiresAt * 1e3 - Date.now() - DEVICE_TOKEN_REFRESH_BUFFER_MS, 1e3);
|
|
19579
|
+
logger$6.debug(`[DeviceToken] Scheduling Client Bound SAT refresh in ${refreshIn}ms`);
|
|
19580
|
+
return (0, import_cjs$4.timer)(refreshIn);
|
|
19581
|
+
})), () => {
|
|
19582
|
+
this.executeRefresh();
|
|
19583
|
+
});
|
|
19584
|
+
}
|
|
19585
|
+
/** Current token TTL in milliseconds. Used to extend cached credential expiry on refresh. */
|
|
19586
|
+
get effectiveExpireIn() {
|
|
19587
|
+
return this._effectiveExpireIn;
|
|
19588
|
+
}
|
|
19589
|
+
/**
|
|
19590
|
+
* Activates the Client Bound SAT flow when the subscriber's token has
|
|
19591
|
+
* `sat:refresh` scope.
|
|
19592
|
+
*
|
|
19593
|
+
* Steps:
|
|
19594
|
+
* 1. Check subscriber's `sat_claims` for `sat:refresh` scope
|
|
19595
|
+
* 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
|
|
19596
|
+
* 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
|
|
19597
|
+
* 4. Emit token to trigger the reactive refresh pipeline
|
|
19598
|
+
*/
|
|
19599
|
+
async activate(subscriber, session, updateCredential) {
|
|
19600
|
+
const { satClaims } = subscriber;
|
|
19601
|
+
if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
|
|
19602
|
+
logger$6.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
|
|
19603
|
+
return;
|
|
19604
|
+
}
|
|
19605
|
+
this._session = session;
|
|
19606
|
+
this._updateCredential = updateCredential;
|
|
19607
|
+
try {
|
|
19608
|
+
const tokenData = await this.obtainToken();
|
|
19609
|
+
if (!tokenData.expires_at && !tokenData.expires_in && satClaims.expires_at) tokenData.expires_at = satClaims.expires_at;
|
|
19610
|
+
this._effectiveExpireIn = resolveExpireIn(tokenData);
|
|
19611
|
+
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
19612
|
+
await session.reauthenticate(tokenData.token, rpcProof, { clientBound: true });
|
|
19613
|
+
updateCredential({ token: tokenData.token });
|
|
19614
|
+
logger$6.info("[DeviceToken] Client Bound SAT activated successfully");
|
|
19615
|
+
this._currentToken$.next(tokenData);
|
|
19616
|
+
} catch (error) {
|
|
19617
|
+
logger$6.error("[DeviceToken] Failed to activate Client Bound SAT:", error);
|
|
19618
|
+
this.errorHandler(new DPoPInitError(error, "Failed to activate Client Bound SAT"));
|
|
19619
|
+
const credential = this.getCredential();
|
|
19620
|
+
const expiresAt = satClaims.expires_at ?? (credential.expiry_at ? credential.expiry_at / 1e3 : Date.now() / 1e3 + DEVICE_TOKEN_DEFAULT_EXPIRE_IN / 1e3);
|
|
19621
|
+
this._currentToken$.next({
|
|
19622
|
+
token: credential.token ?? "",
|
|
19623
|
+
expires_at: expiresAt
|
|
19624
|
+
});
|
|
19625
|
+
}
|
|
19626
|
+
}
|
|
19627
|
+
/**
|
|
19628
|
+
* Obtains a Client Bound SAT from `/api/fabric/subscriber/devices/token`.
|
|
19629
|
+
* Returns the full {@link DeviceTokenResponse} including expiry metadata.
|
|
19630
|
+
*/
|
|
19631
|
+
async obtainToken() {
|
|
19632
|
+
const dpopProof = await this.dpopManager.createHttpProof({
|
|
19633
|
+
method: "POST",
|
|
19634
|
+
uri: DEVICE_TOKEN_ENDPOINT
|
|
19635
|
+
});
|
|
19636
|
+
const response = await this.http.request({
|
|
19637
|
+
url: DEVICE_TOKEN_ENDPOINT,
|
|
19638
|
+
...POST_PARAMS,
|
|
19639
|
+
body: JSON.stringify({
|
|
19640
|
+
dpop_token: dpopProof,
|
|
19641
|
+
expire_in: DEVICE_TOKEN_DEFAULT_EXPIRE_IN
|
|
19642
|
+
})
|
|
19643
|
+
});
|
|
19644
|
+
if (!response.ok || !response.body) throw new DeviceTokenError(`Failed to obtain device token: ${response.status} ${response.statusText}`);
|
|
19645
|
+
const data = JSON.parse(response.body);
|
|
19646
|
+
if (!data.token) throw new DeviceTokenError("Device token response missing token field");
|
|
19647
|
+
return data;
|
|
19648
|
+
}
|
|
19649
|
+
/**
|
|
19650
|
+
* Refreshes the Client Bound SAT via `/api/fabric/subscriber/devices/refresh`.
|
|
19651
|
+
*
|
|
19652
|
+
* Creates a fresh DPoP proof, calls the refresh endpoint, reauthenticates
|
|
19653
|
+
* the WebSocket session, and returns the new token data (scheduling is
|
|
19654
|
+
* handled by the reactive pipeline).
|
|
19655
|
+
*/
|
|
19656
|
+
async refreshToken(session, currentToken, updateCredential) {
|
|
19657
|
+
logger$6.debug("[DeviceToken] Refreshing Client Bound SAT");
|
|
19658
|
+
const dpopProof = await this.dpopManager.createHttpProof({
|
|
19659
|
+
method: "POST",
|
|
19660
|
+
uri: DEVICE_REFRESH_ENDPOINT,
|
|
19661
|
+
accessToken: currentToken
|
|
19662
|
+
});
|
|
19663
|
+
const response = await this.http.request({
|
|
19664
|
+
url: DEVICE_REFRESH_ENDPOINT,
|
|
19665
|
+
...POST_PARAMS,
|
|
19666
|
+
body: JSON.stringify({
|
|
19667
|
+
dpop_token: dpopProof,
|
|
19668
|
+
expire_in: this._effectiveExpireIn
|
|
19669
|
+
})
|
|
19670
|
+
});
|
|
19671
|
+
if (!response.ok || !response.body) throw new TokenRefreshError(`Failed to refresh device token: ${response.status} ${response.statusText}`);
|
|
19672
|
+
const data = JSON.parse(response.body);
|
|
19673
|
+
if (!data.token) throw new TokenRefreshError("Device token refresh response missing token field");
|
|
19674
|
+
if (!data.expires_at && !data.expires_in) data.expires_in = this._effectiveExpireIn;
|
|
19675
|
+
this._effectiveExpireIn = resolveExpireIn(data);
|
|
19676
|
+
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
19677
|
+
await session.reauthenticate(data.token, rpcProof);
|
|
19678
|
+
updateCredential({ token: data.token });
|
|
19679
|
+
logger$6.info("[DeviceToken] Client Bound SAT refreshed successfully");
|
|
19680
|
+
return data;
|
|
19681
|
+
}
|
|
19682
|
+
/**
|
|
19683
|
+
* Executes a refresh with retry and exponential backoff.
|
|
19684
|
+
* On success, emits to `_currentToken$` to schedule the next refresh.
|
|
19685
|
+
* On all retries exhausted, emits to `errorHandler`.
|
|
19686
|
+
*/
|
|
19687
|
+
async executeRefresh() {
|
|
19688
|
+
if (this._refreshInProgress) {
|
|
19689
|
+
logger$6.debug("[DeviceToken] Refresh already in progress, skipping");
|
|
19690
|
+
return;
|
|
19691
|
+
}
|
|
19692
|
+
const session = this._session;
|
|
19693
|
+
const updateCredential = this._updateCredential;
|
|
19694
|
+
if (!session || !updateCredential) {
|
|
19695
|
+
logger$6.warn("[DeviceToken] Cannot refresh: session or updateCredential not set");
|
|
19696
|
+
return;
|
|
19697
|
+
}
|
|
19698
|
+
if (!session.authenticated) {
|
|
19699
|
+
logger$6.debug("[DeviceToken] Session not authenticated, deferring refresh");
|
|
19700
|
+
return;
|
|
19701
|
+
}
|
|
19702
|
+
this._refreshInProgress = true;
|
|
19703
|
+
try {
|
|
19704
|
+
const currentToken = this.getCredential().token;
|
|
19705
|
+
if (!currentToken) throw new TokenRefreshError("No current token available for refresh");
|
|
19706
|
+
const newTokenData = await this.retryRefresh(session, currentToken, updateCredential);
|
|
19707
|
+
this._currentToken$.next(newTokenData);
|
|
19708
|
+
} catch (error) {
|
|
19709
|
+
logger$6.error("[DeviceToken] Automatic Client Bound SAT refresh failed:", error);
|
|
19710
|
+
this.errorHandler(error instanceof TokenRefreshError ? error : new TokenRefreshError("Automatic token refresh failed", error));
|
|
19711
|
+
} finally {
|
|
19712
|
+
this._refreshInProgress = false;
|
|
19713
|
+
}
|
|
19714
|
+
}
|
|
19715
|
+
/**
|
|
19716
|
+
* Retries `refreshToken()` up to `DEVICE_TOKEN_REFRESH_MAX_RETRIES` times
|
|
19717
|
+
* with exponential backoff (1s, 2s, 4s).
|
|
19718
|
+
*/
|
|
19719
|
+
async retryRefresh(session, currentToken, updateCredential) {
|
|
19720
|
+
let lastError;
|
|
19721
|
+
for (let attempt = 0; attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES; attempt++) try {
|
|
19722
|
+
return await this.refreshToken(session, currentToken, updateCredential);
|
|
19723
|
+
} catch (error) {
|
|
19724
|
+
lastError = error;
|
|
19725
|
+
if (attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES - 1) {
|
|
19726
|
+
const delay$1 = DEVICE_TOKEN_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt);
|
|
19727
|
+
logger$6.warn(`[DeviceToken] Refresh attempt ${attempt + 1} failed, retrying in ${delay$1}ms`);
|
|
19728
|
+
await new Promise((resolve) => setTimeout(resolve, delay$1));
|
|
19729
|
+
}
|
|
19730
|
+
}
|
|
19731
|
+
throw lastError instanceof Error ? lastError : new TokenRefreshError("All refresh retries exhausted", lastError);
|
|
19732
|
+
}
|
|
19733
|
+
/** Cleans up the manager, cancelling the reactive pipeline and all subscriptions. */
|
|
19734
|
+
destroy() {
|
|
19735
|
+
super.destroy();
|
|
19736
|
+
}
|
|
19737
|
+
};
|
|
19738
|
+
|
|
19457
19739
|
//#endregion
|
|
19458
19740
|
//#region src/managers/DiagnosticsCollector.ts
|
|
19459
19741
|
const logger$5 = getLogger();
|
|
@@ -20387,13 +20669,43 @@ var SignalWire = class extends Destroyable {
|
|
|
20387
20669
|
this._errors$.next(error);
|
|
20388
20670
|
});
|
|
20389
20671
|
await this._clientSession.connect();
|
|
20390
|
-
|
|
20391
|
-
|
|
20392
|
-
|
|
20672
|
+
if (this._dpopManager?.initialized) {
|
|
20673
|
+
if (this._refreshTimerId) {
|
|
20674
|
+
clearTimeout(this._refreshTimerId);
|
|
20675
|
+
this._refreshTimerId = void 0;
|
|
20676
|
+
logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
|
|
20677
|
+
}
|
|
20678
|
+
this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
|
|
20679
|
+
await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
|
|
20680
|
+
this._deps.credential = {
|
|
20681
|
+
...this._deps.credential,
|
|
20682
|
+
...cred
|
|
20683
|
+
};
|
|
20684
|
+
});
|
|
20685
|
+
}
|
|
20686
|
+
this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs.skip)(1), (0, import_cjs.filter)(Boolean)), async () => {
|
|
20687
|
+
try {
|
|
20688
|
+
if (this._deviceTokenManager) {
|
|
20689
|
+
await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
|
|
20690
|
+
this._deps.credential = {
|
|
20691
|
+
...this._deps.credential,
|
|
20692
|
+
...cred
|
|
20693
|
+
};
|
|
20694
|
+
});
|
|
20695
|
+
logger$1.debug("[SignalWire] Client Bound SAT re-activated after reconnect");
|
|
20696
|
+
}
|
|
20697
|
+
} catch (error) {
|
|
20698
|
+
logger$1.error("[SignalWire] Client Bound SAT re-activation failed (non-fatal):", error);
|
|
20699
|
+
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
20700
|
+
}
|
|
20701
|
+
try {
|
|
20702
|
+
logger$1.debug("[SignalWire] Re-registering subscriber after reconnect");
|
|
20703
|
+
await this.register();
|
|
20393
20704
|
logger$1.debug("[SignalWire] Subscriber re-registered successfully after reconnect");
|
|
20394
|
-
}
|
|
20705
|
+
} catch (error) {
|
|
20395
20706
|
logger$1.error("[SignalWire] Re-registration failed after reconnect:", error);
|
|
20396
|
-
|
|
20707
|
+
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
20708
|
+
}
|
|
20397
20709
|
});
|
|
20398
20710
|
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getSubscriberFromAddressId(), errorHandler);
|
|
20399
20711
|
const directory = new DirectoryManager(this._deps.http, this._clientSession, conversationManager, errorHandler);
|
|
@@ -20816,6 +21128,8 @@ var SignalWire = class extends Destroyable {
|
|
|
20816
21128
|
* Triggers the browser's media permission dialog and captures the user's device selections.
|
|
20817
21129
|
*
|
|
20818
21130
|
* @param options - Which permissions to request.
|
|
21131
|
+
* @param options.audio - Whether to request audio permission.
|
|
21132
|
+
* @param options.video - Whether to request video permission.
|
|
20819
21133
|
* @returns The permission result with selected devices.
|
|
20820
21134
|
*/
|
|
20821
21135
|
async requestMediaPermissions(options = {
|
|
@@ -20847,8 +21161,14 @@ var SignalWire = class extends Destroyable {
|
|
|
20847
21161
|
logger$1.warn("[SignalWire] Media permission request failed:", error);
|
|
20848
21162
|
}
|
|
20849
21163
|
await this._deviceController.enumerateDevices();
|
|
20850
|
-
if (audioGranted && selectedAudioDevice)
|
|
20851
|
-
|
|
21164
|
+
if (audioGranted && selectedAudioDevice) {
|
|
21165
|
+
const audioDeviceId = selectedAudioDevice.deviceId;
|
|
21166
|
+
selectedAudioDevice = this.audioInputDevices.find((d) => d.deviceId === audioDeviceId) ?? selectedAudioDevice;
|
|
21167
|
+
}
|
|
21168
|
+
if (videoGranted && selectedVideoDevice) {
|
|
21169
|
+
const videoDeviceId = selectedVideoDevice.deviceId;
|
|
21170
|
+
selectedVideoDevice = this.videoInputDevices.find((d) => d.deviceId === videoDeviceId) ?? selectedVideoDevice;
|
|
21171
|
+
}
|
|
20852
21172
|
if (audioGranted && selectedAudioDevice && !this.selectedAudioInputDevice) this.selectAudioInputDevice(selectedAudioDevice);
|
|
20853
21173
|
if (videoGranted && selectedVideoDevice && !this.selectedVideoInputDevice) this.selectVideoInputDevice(selectedVideoDevice);
|
|
20854
21174
|
return {
|