@signalwire/js 4.0.0-beta.1 → 4.0.0-beta.3

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 CHANGED
@@ -6685,7 +6685,7 @@ var require_share = /* @__PURE__ */ __commonJSMin(((exports) => {
6685
6685
  var Subject_1$6 = require_Subject();
6686
6686
  var Subscriber_1$1 = require_Subscriber();
6687
6687
  var lift_1$19 = require_lift();
6688
- function share$1(options) {
6688
+ function share$3(options) {
6689
6689
  if (options === void 0) options = {};
6690
6690
  var _a = options.connector, connector = _a === void 0 ? function() {
6691
6691
  return new Subject_1$6.Subject();
@@ -6743,7 +6743,7 @@ var require_share = /* @__PURE__ */ __commonJSMin(((exports) => {
6743
6743
  })(wrapperSource);
6744
6744
  };
6745
6745
  }
6746
- exports.share = share$1;
6746
+ exports.share = share$3;
6747
6747
  function handleReset(reset, on) {
6748
6748
  var args = [];
6749
6749
  for (var _i = 2; _i < arguments.length; _i++) args[_i - 2] = arguments[_i];
@@ -8941,11 +8941,21 @@ var Destroyable = class {
8941
8941
  this._destroyed$ = new import_cjs$22.Subject();
8942
8942
  }
8943
8943
  destroy() {
8944
+ this._observableCache?.clear();
8944
8945
  this.subscriptions.forEach((sub) => sub.unsubscribe());
8945
8946
  this.subjects.forEach((subject) => subject.complete());
8946
8947
  this._destroyed$.next();
8947
8948
  this._destroyed$.complete();
8948
8949
  }
8950
+ cachedObservable(key, factory) {
8951
+ this._observableCache ??= /* @__PURE__ */ new Map();
8952
+ let cached = this._observableCache.get(key);
8953
+ if (!cached) {
8954
+ cached = factory();
8955
+ this._observableCache.set(key, cached);
8956
+ }
8957
+ return cached;
8958
+ }
8949
8959
  subscribeTo(observable, observerOrNext) {
8950
8960
  const subscription = observable.subscribe(observerOrNext);
8951
8961
  this.subscriptions.push(subscription);
@@ -8966,7 +8976,7 @@ var Destroyable = class {
8966
8976
  return subject;
8967
8977
  }
8968
8978
  get $() {
8969
- return (0, import_cjs$22.merge)(...this.subjects.map((s) => s instanceof import_cjs$22.BehaviorSubject ? s.pipe((0, import_cjs$22.skip)(1)) : s)).pipe((0, import_cjs$22.map)((_) => this));
8979
+ return this.cachedObservable("$", () => (0, import_cjs$22.merge)(...this.subjects.map((s) => s instanceof import_cjs$22.BehaviorSubject ? s.pipe((0, import_cjs$22.skip)(1)) : s)).pipe((0, import_cjs$22.map)((_) => this)));
8970
8980
  }
8971
8981
  /**
8972
8982
  * Observable that emits when the instance is destroyed
@@ -9954,8 +9964,9 @@ const selectDevice = (devices = [], selected, preferred) => {
9954
9964
  return selected;
9955
9965
  };
9956
9966
  var NavigatorDeviceController = class extends Destroyable {
9957
- constructor() {
9967
+ constructor(webRTCApiProvider) {
9958
9968
  super();
9969
+ this.webRTCApiProvider = webRTCApiProvider;
9959
9970
  this.deviceChangeHandler = () => {
9960
9971
  logger$19.debug("[DeviceController] Device change detected");
9961
9972
  this.enumerateDevices();
@@ -9979,25 +9990,25 @@ var NavigatorDeviceController = class extends Destroyable {
9979
9990
  return {};
9980
9991
  }
9981
9992
  get errors$() {
9982
- return this._errors$.asObservable().pipe((0, import_cjs$20.takeUntil)(this.destroyed$));
9993
+ return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$20.takeUntil)(this.destroyed$)));
9983
9994
  }
9984
9995
  get audioInputDevices$() {
9985
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
9996
+ return this.cachedObservable("audioInputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9986
9997
  }
9987
9998
  get audioOutputDevices$() {
9988
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
9999
+ return this.cachedObservable("audioOutputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9989
10000
  }
9990
10001
  get videoInputDevices$() {
9991
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
10002
+ return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9992
10003
  }
9993
10004
  get selectedAudioInputDevice$() {
9994
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio input device changed:", info)));
10005
+ return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio input device changed:", info))));
9995
10006
  }
9996
10007
  get selectedAudioOutputDevice$() {
9997
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio output device changed:", info)));
10008
+ return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio output device changed:", info))));
9998
10009
  }
9999
10010
  get selectedVideoInputDevice$() {
10000
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected video input device changed:", info)));
10011
+ return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected video input device changed:", info))));
10001
10012
  }
10002
10013
  get selectedAudioInputDevice() {
10003
10014
  return this._selectedDevicesState$.value.audioinput;
@@ -10037,24 +10048,22 @@ var NavigatorDeviceController = class extends Destroyable {
10037
10048
  });
10038
10049
  }
10039
10050
  init() {
10040
- if (navigator.mediaDevices) {
10041
- this.subscribeTo(this._devicesState$.pipe((0, import_cjs$20.debounceTime)(PreferencesContainer.instance.deviceDebounceTime)), (devicesState) => {
10042
- const currentSelected = this._selectedDevicesState$.value;
10043
- const newAudioInput = selectDevice(devicesState.audioinput, currentSelected.audioinput, PreferencesContainer.instance.preferredAudioInput);
10044
- const newAudioOutput = selectDevice(devicesState.audiooutput, currentSelected.audiooutput, PreferencesContainer.instance.preferredAudioOutput);
10045
- const newVideoInput = selectDevice(devicesState.videoinput, currentSelected.videoinput, PreferencesContainer.instance.preferredVideoInput);
10046
- if (newAudioInput !== currentSelected.audioinput || newAudioOutput !== currentSelected.audiooutput || newVideoInput !== currentSelected.videoinput) this._selectedDevicesState$.next({
10047
- audioinput: newAudioInput,
10048
- audiooutput: newAudioOutput,
10049
- videoinput: newVideoInput
10050
- });
10051
+ this.subscribeTo(this._devicesState$.pipe((0, import_cjs$20.debounceTime)(PreferencesContainer.instance.deviceDebounceTime)), (devicesState) => {
10052
+ const currentSelected = this._selectedDevicesState$.value;
10053
+ const newAudioInput = selectDevice(devicesState.audioinput, currentSelected.audioinput, PreferencesContainer.instance.preferredAudioInput);
10054
+ const newAudioOutput = selectDevice(devicesState.audiooutput, currentSelected.audiooutput, PreferencesContainer.instance.preferredAudioOutput);
10055
+ const newVideoInput = selectDevice(devicesState.videoinput, currentSelected.videoinput, PreferencesContainer.instance.preferredVideoInput);
10056
+ if (newAudioInput !== currentSelected.audioinput || newAudioOutput !== currentSelected.audiooutput || newVideoInput !== currentSelected.videoinput) this._selectedDevicesState$.next({
10057
+ audioinput: newAudioInput,
10058
+ audiooutput: newAudioOutput,
10059
+ videoinput: newVideoInput
10051
10060
  });
10052
- this.enumerateDevices();
10053
- }
10061
+ });
10062
+ this.enumerateDevices();
10054
10063
  }
10055
10064
  enableDeviceMonitoring() {
10056
10065
  this.disableDeviceMonitoring();
10057
- navigator.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
10066
+ this.webRTCApiProvider.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
10058
10067
  if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, import_cjs$20.interval)(PreferencesContainer.instance.devicePollingInterval).subscribe(() => {
10059
10068
  logger$19.debug("[DeviceController] Polling devices due to interval");
10060
10069
  this.enumerateDevices();
@@ -10062,7 +10071,7 @@ var NavigatorDeviceController = class extends Destroyable {
10062
10071
  this.enumerateDevices();
10063
10072
  }
10064
10073
  disableDeviceMonitoring() {
10065
- navigator.mediaDevices.removeEventListener("devicechange", this.deviceChangeHandler);
10074
+ this.webRTCApiProvider.mediaDevices.removeEventListener("devicechange", this.deviceChangeHandler);
10066
10075
  if (this._devicesPoolingSubscription) {
10067
10076
  this._devicesPoolingSubscription.unsubscribe();
10068
10077
  this._devicesPoolingSubscription = void 0;
@@ -10070,7 +10079,7 @@ var NavigatorDeviceController = class extends Destroyable {
10070
10079
  }
10071
10080
  async enumerateDevices() {
10072
10081
  try {
10073
- const devicesByKind = (await navigator.mediaDevices.enumerateDevices()).reduce((acc, device) => {
10082
+ const devicesByKind = (await this.webRTCApiProvider.mediaDevices.enumerateDevices()).reduce((acc, device) => {
10074
10083
  acc[device.kind].push(device);
10075
10084
  return acc;
10076
10085
  }, {
@@ -10093,7 +10102,7 @@ var NavigatorDeviceController = class extends Destroyable {
10093
10102
  if (deviceInfo.kind === "audiooutput") return null;
10094
10103
  try {
10095
10104
  const constraints = this.deviceInfoToConstraints(deviceInfo);
10096
- const stream = await navigator.mediaDevices.getUserMedia({
10105
+ const stream = await this.webRTCApiProvider.mediaDevices.getUserMedia({
10097
10106
  audio: deviceInfo.kind === "audioinput" ? constraints : false,
10098
10107
  video: deviceInfo.kind === "videoinput" ? constraints : false
10099
10108
  });
@@ -10265,9 +10274,23 @@ var DependencyContainer = class {
10265
10274
  this._webSocketConstructor = WebSocketConstructor;
10266
10275
  }
10267
10276
  get deviceController() {
10268
- this._deviceController ??= new NavigatorDeviceController();
10277
+ this._deviceController ??= new NavigatorDeviceController(this.webRTCApiProvider);
10269
10278
  return this._deviceController;
10270
10279
  }
10280
+ get webRTCApiProvider() {
10281
+ if (!this._webRTCApiProvider) {
10282
+ if (typeof RTCPeerConnection === "undefined" || typeof navigator === "undefined") throw new DependencyError("WebRTCApiProvider: RTCPeerConnection or navigator.mediaDevices is not available. Please provide a custom webRTCApiProvider in SignalWireOptions.");
10283
+ this._webRTCApiProvider = {
10284
+ RTCPeerConnection,
10285
+ mediaDevices: navigator.mediaDevices
10286
+ };
10287
+ }
10288
+ return this._webRTCApiProvider;
10289
+ }
10290
+ set webRTCApiProvider(webRTCApiProvider) {
10291
+ this._webRTCApiProvider = webRTCApiProvider;
10292
+ this._deviceController = void 0;
10293
+ }
10271
10294
  get authorizationStateKey() {
10272
10295
  return `sw:${this.subscriberId}:as`;
10273
10296
  }
@@ -11658,7 +11681,7 @@ var SelfCapabilities = class extends Destroyable {
11658
11681
  }
11659
11682
  /** Observable for self member capabilities */
11660
11683
  get self$() {
11661
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.self), (0, import_cjs$17.distinctUntilChanged)());
11684
+ return this.cachedObservable("self$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.self), (0, import_cjs$17.distinctUntilChanged)()));
11662
11685
  }
11663
11686
  /** Current self member capabilities */
11664
11687
  get self() {
@@ -11666,7 +11689,7 @@ var SelfCapabilities = class extends Destroyable {
11666
11689
  }
11667
11690
  /** Observable for other member capabilities */
11668
11691
  get member$() {
11669
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.member), (0, import_cjs$17.distinctUntilChanged)());
11692
+ return this.cachedObservable("member$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.member), (0, import_cjs$17.distinctUntilChanged)()));
11670
11693
  }
11671
11694
  /** Current other member capabilities */
11672
11695
  get member() {
@@ -11674,7 +11697,7 @@ var SelfCapabilities = class extends Destroyable {
11674
11697
  }
11675
11698
  /** Observable for end call capability */
11676
11699
  get end$() {
11677
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.end), (0, import_cjs$17.distinctUntilChanged)());
11700
+ return this.cachedObservable("end$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.end), (0, import_cjs$17.distinctUntilChanged)()));
11678
11701
  }
11679
11702
  /** Current end call capability */
11680
11703
  get end() {
@@ -11682,7 +11705,7 @@ var SelfCapabilities = class extends Destroyable {
11682
11705
  }
11683
11706
  /** Observable for set layout capability */
11684
11707
  get setLayout$() {
11685
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.setLayout), (0, import_cjs$17.distinctUntilChanged)());
11708
+ return this.cachedObservable("setLayout$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.setLayout), (0, import_cjs$17.distinctUntilChanged)()));
11686
11709
  }
11687
11710
  /** Current set layout capability */
11688
11711
  get setLayout() {
@@ -11690,7 +11713,7 @@ var SelfCapabilities = class extends Destroyable {
11690
11713
  }
11691
11714
  /** Observable for send digit capability */
11692
11715
  get sendDigit$() {
11693
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.sendDigit), (0, import_cjs$17.distinctUntilChanged)());
11716
+ return this.cachedObservable("sendDigit$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.sendDigit), (0, import_cjs$17.distinctUntilChanged)()));
11694
11717
  }
11695
11718
  /** Current send digit capability */
11696
11719
  get sendDigit() {
@@ -11698,7 +11721,7 @@ var SelfCapabilities = class extends Destroyable {
11698
11721
  }
11699
11722
  /** Observable for vmuted hide capability */
11700
11723
  get vmutedHide$() {
11701
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.vmutedHide), (0, import_cjs$17.distinctUntilChanged)());
11724
+ return this.cachedObservable("vmutedHide$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.vmutedHide), (0, import_cjs$17.distinctUntilChanged)()));
11702
11725
  }
11703
11726
  /** Current vmuted hide capability */
11704
11727
  get vmutedHide() {
@@ -11706,7 +11729,7 @@ var SelfCapabilities = class extends Destroyable {
11706
11729
  }
11707
11730
  /** Observable for lock capability */
11708
11731
  get lock$() {
11709
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.lock), (0, import_cjs$17.distinctUntilChanged)());
11732
+ return this.cachedObservable("lock$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.lock), (0, import_cjs$17.distinctUntilChanged)()));
11710
11733
  }
11711
11734
  /** Current lock capability */
11712
11735
  get lock() {
@@ -11714,7 +11737,7 @@ var SelfCapabilities = class extends Destroyable {
11714
11737
  }
11715
11738
  /** Observable for device capability */
11716
11739
  get device$() {
11717
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.device), (0, import_cjs$17.distinctUntilChanged)());
11740
+ return this.cachedObservable("device$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.device), (0, import_cjs$17.distinctUntilChanged)()));
11718
11741
  }
11719
11742
  /** Current device capability */
11720
11743
  get device() {
@@ -11722,7 +11745,7 @@ var SelfCapabilities = class extends Destroyable {
11722
11745
  }
11723
11746
  /** Observable for screenshare capability */
11724
11747
  get screenshare$() {
11725
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.screenshare), (0, import_cjs$17.distinctUntilChanged)());
11748
+ return this.cachedObservable("screenshare$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.screenshare), (0, import_cjs$17.distinctUntilChanged)()));
11726
11749
  }
11727
11750
  /** Current screenshare capability */
11728
11751
  get screenshare() {
@@ -11775,83 +11798,83 @@ var Participant = class extends Destroyable {
11775
11798
  }
11776
11799
  /** Observable of the participant's display name. */
11777
11800
  get name$() {
11778
- return this._state$.pipe((0, import_operators$1.map)((state) => state.name), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11801
+ return this.cachedObservable("name$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.name), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11779
11802
  }
11780
11803
  /** Observable of the participant type (e.g. `'member'`, `'screen'`). */
11781
11804
  get type$() {
11782
- return this._state$.pipe((0, import_operators$1.map)((state) => state.type), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11805
+ return this.cachedObservable("type$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.type), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11783
11806
  }
11784
11807
  /** Observable indicating whether the participant has raised their hand. */
11785
11808
  get handraised$() {
11786
- return this._state$.pipe((0, import_operators$1.map)((state) => state.handraised), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11809
+ return this.cachedObservable("handraised$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.handraised), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11787
11810
  }
11788
11811
  /** Observable indicating whether the participant is visible in the layout. */
11789
11812
  get visible$() {
11790
- return this._state$.pipe((0, import_operators$1.map)((state) => state.visible), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11813
+ return this.cachedObservable("visible$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.visible), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11791
11814
  }
11792
11815
  /** Observable indicating whether the participant's audio is muted. */
11793
11816
  get audioMuted$() {
11794
- return this._state$.pipe((0, import_operators$1.map)((state) => state.audio_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11817
+ return this.cachedObservable("audioMuted$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.audio_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11795
11818
  }
11796
11819
  /** Observable indicating whether the participant's video is muted. */
11797
11820
  get videoMuted$() {
11798
- return this._state$.pipe((0, import_operators$1.map)((state) => state.video_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11821
+ return this.cachedObservable("videoMuted$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.video_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11799
11822
  }
11800
11823
  /** Observable indicating whether the participant is deafened. */
11801
11824
  get deaf$() {
11802
- return this._state$.pipe((0, import_operators$1.map)((state) => state.deaf), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11825
+ return this.cachedObservable("deaf$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.deaf), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11803
11826
  }
11804
11827
  /** Observable of the participant's microphone input volume. */
11805
11828
  get inputVolume$() {
11806
- return this._state$.pipe((0, import_operators$1.map)((state) => state.input_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11829
+ return this.cachedObservable("inputVolume$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.input_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11807
11830
  }
11808
11831
  /** Observable of the participant's speaker output volume. */
11809
11832
  get outputVolume$() {
11810
- return this._state$.pipe((0, import_operators$1.map)((state) => state.output_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11833
+ return this.cachedObservable("outputVolume$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.output_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11811
11834
  }
11812
11835
  /** Observable of the microphone input sensitivity level. */
11813
11836
  get inputSensitivity$() {
11814
- return this._state$.pipe((0, import_operators$1.map)((state) => state.input_sensitivity), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11837
+ return this.cachedObservable("inputSensitivity$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.input_sensitivity), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11815
11838
  }
11816
11839
  /** Observable indicating whether echo cancellation is enabled. */
11817
11840
  get echoCancellation$() {
11818
- return this._state$.pipe((0, import_operators$1.map)((state) => state.echo_cancellation), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11841
+ return this.cachedObservable("echoCancellation$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.echo_cancellation), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11819
11842
  }
11820
11843
  /** Observable indicating whether auto-gain control is enabled. */
11821
11844
  get autoGain$() {
11822
- return this._state$.pipe((0, import_operators$1.map)((state) => state.auto_gain), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11845
+ return this.cachedObservable("autoGain$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.auto_gain), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11823
11846
  }
11824
11847
  /** Observable indicating whether noise suppression is enabled. */
11825
11848
  get noiseSuppression$() {
11826
- return this._state$.pipe((0, import_operators$1.map)((state) => state.noise_suppression), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11849
+ return this.cachedObservable("noiseSuppression$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.noise_suppression), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11827
11850
  }
11828
11851
  /** Observable indicating whether low-bitrate mode is active. */
11829
11852
  get lowbitrate$() {
11830
- return this._state$.pipe((0, import_operators$1.map)((state) => state.lowbitrate), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11853
+ return this.cachedObservable("lowbitrate$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.lowbitrate), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11831
11854
  }
11832
11855
  /** Observable indicating whether noise reduction is active. */
11833
11856
  get denoise$() {
11834
- return this._state$.pipe((0, import_operators$1.map)((state) => state.denoise), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11857
+ return this.cachedObservable("denoise$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.denoise), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11835
11858
  }
11836
11859
  /** Observable of custom metadata for this participant. */
11837
11860
  get meta$() {
11838
- return this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11861
+ return this.cachedObservable("meta$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11839
11862
  }
11840
11863
  /** Observable of the participant's subscriber ID. */
11841
11864
  get subscriberId$() {
11842
- return this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11865
+ return this.cachedObservable("subscriberId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11843
11866
  }
11844
11867
  /** Observable of the participant's address ID. */
11845
11868
  get addressId$() {
11846
- return this._state$.pipe((0, import_operators$1.map)((state) => state.address_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11869
+ return this.cachedObservable("addressId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.address_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11847
11870
  }
11848
11871
  /** Observable of the server node ID for this participant. */
11849
11872
  get nodeId$() {
11850
- return this._state$.pipe((0, import_operators$1.map)((state) => state.node_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11873
+ return this.cachedObservable("nodeId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.node_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11851
11874
  }
11852
11875
  /** Observable indicating whether the participant is currently speaking. */
11853
11876
  get isTalking$() {
11854
- return this._state$.pipe((0, import_operators$1.map)((state) => state.talking), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11877
+ return this.cachedObservable("isTalking$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.talking), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11855
11878
  }
11856
11879
  /** Whether the participant is currently speaking. */
11857
11880
  get isTalking() {
@@ -11859,7 +11882,7 @@ var Participant = class extends Destroyable {
11859
11882
  }
11860
11883
  /** Observable of the participant's layout position. */
11861
11884
  get position$() {
11862
- return this._state$.pipe((0, import_operators$1.map)((state) => state.position), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11885
+ return this.cachedObservable("position$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.position), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11863
11886
  }
11864
11887
  /** Current layout position. */
11865
11888
  get position() {
@@ -12178,7 +12201,7 @@ function isJSONRPCRequest(value) {
12178
12201
  return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && hasProperty(value, "method") && typeof value.method === "string";
12179
12202
  }
12180
12203
  function isJSONRPCResponse(value) {
12181
- return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && hasProperty(value, "result");
12204
+ return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && (hasProperty(value, "result") || hasProperty(value, "error"));
12182
12205
  }
12183
12206
 
12184
12207
  //#endregion
@@ -12376,10 +12399,10 @@ var CallEventsManager = class extends Destroyable {
12376
12399
  this.initSubscriptions();
12377
12400
  }
12378
12401
  get participants$() {
12379
- return this._participants$.asObservable().pipe((0, import_cjs$14.map)((participantsRecord) => Object.values(participantsRecord)));
12402
+ return this.cachedObservable("participants$", () => this._participants$.asObservable().pipe((0, import_cjs$14.map)((participantsRecord) => Object.values(participantsRecord))));
12380
12403
  }
12381
12404
  get self$() {
12382
- return this._self$.asObservable().pipe(filterNull());
12405
+ return this.cachedObservable("self$", () => this._self$.asObservable().pipe(filterNull()));
12383
12406
  }
12384
12407
  get status$() {
12385
12408
  return this._status$.asObservable();
@@ -12397,40 +12420,40 @@ var CallEventsManager = class extends Destroyable {
12397
12420
  return this.callIds.has(callId);
12398
12421
  }
12399
12422
  get recording$() {
12400
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recording), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12423
+ return this.cachedObservable("recording$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recording), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12401
12424
  }
12402
12425
  get recordings$() {
12403
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recordings), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12426
+ return this.cachedObservable("recordings$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recordings), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12404
12427
  }
12405
12428
  get streaming$() {
12406
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streaming), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12429
+ return this.cachedObservable("streaming$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streaming), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12407
12430
  }
12408
12431
  get streams$() {
12409
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streams), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12432
+ return this.cachedObservable("streams$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streams), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12410
12433
  }
12411
12434
  get playbacks$() {
12412
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.playbacks), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12435
+ return this.cachedObservable("playbacks$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.playbacks), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12413
12436
  }
12414
12437
  get raiseHandPriority$() {
12415
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.prioritize_handraise), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12438
+ return this.cachedObservable("raiseHandPriority$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.prioritize_handraise), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12416
12439
  }
12417
12440
  get locked$() {
12418
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.locked), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12441
+ return this.cachedObservable("locked$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.locked), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12419
12442
  }
12420
12443
  get meta$() {
12421
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.meta), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12444
+ return this.cachedObservable("meta$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.meta), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12422
12445
  }
12423
12446
  get capabilities$() {
12424
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.capabilities), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12447
+ return this.cachedObservable("capabilities$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.capabilities), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12425
12448
  }
12426
12449
  get layout$() {
12427
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_name), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12450
+ return this.cachedObservable("layout$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_name), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12428
12451
  }
12429
12452
  get layouts$() {
12430
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layouts), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12453
+ return this.cachedObservable("layouts$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layouts), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12431
12454
  }
12432
12455
  get layoutLayers$() {
12433
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_layers), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12456
+ return this.cachedObservable("layoutLayers$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_layers), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12434
12457
  }
12435
12458
  get self() {
12436
12459
  return this._self$.value;
@@ -12566,19 +12589,19 @@ var CallEventsManager = class extends Destroyable {
12566
12589
  this._participants$.next(this._participants$.value);
12567
12590
  }
12568
12591
  get callJoinedEvent$() {
12569
- return this.webRtcCallSession.callEvent$.pipe((0, import_cjs$14.filter)(isCallJoinedPayload), (0, import_cjs$14.tap)((event) => {
12592
+ return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, import_cjs$14.filter)(isCallJoinedPayload), (0, import_cjs$14.tap)((event) => {
12570
12593
  logger$15.debug("[CallEventsManager] Call joined event:", event);
12571
- }));
12594
+ })));
12572
12595
  }
12573
12596
  get layoutChangedEvent$() {
12574
- return this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$14.tap)((event) => {
12597
+ return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$14.tap)((event) => {
12575
12598
  logger$15.debug("[CallEventsManager] Layout changed event:", event);
12576
- }));
12599
+ })));
12577
12600
  }
12578
12601
  get memberUpdates$() {
12579
- return (0, import_cjs$14.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, import_cjs$14.map)((event) => event.member), (0, import_cjs$14.tap)((event) => {
12602
+ return this.cachedObservable("memberUpdates$", () => (0, import_cjs$14.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, import_cjs$14.map)((event) => event.member), (0, import_cjs$14.tap)((event) => {
12580
12603
  logger$15.debug("[CallEventsManager] Member update event:", event);
12581
- }));
12604
+ })));
12582
12605
  }
12583
12606
  destroy() {
12584
12607
  Object.values(this._participants$.value).forEach((participant) => {
@@ -13220,7 +13243,7 @@ var RTCPeerConnectionController = class extends Destroyable {
13220
13243
  logger$11.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
13221
13244
  return;
13222
13245
  }
13223
- const streamTrack = (await navigator.mediaDevices.getUserMedia({ [kind]: {
13246
+ const streamTrack = (await this.getUserMedia({ [kind]: {
13224
13247
  ...track.getConstraints(),
13225
13248
  ...this.deviceController.deviceInfoToConstraints(deviceInfo)
13226
13249
  } })).getTracks().find((t) => t.kind === kind);
@@ -13309,43 +13332,43 @@ var RTCPeerConnectionController = class extends Destroyable {
13309
13332
  };
13310
13333
  }
13311
13334
  get iceGatheringState$() {
13312
- return this._iceGatheringState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13335
+ return this.cachedObservable("iceGatheringState$", () => this._iceGatheringState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13313
13336
  }
13314
13337
  get mediaTrackEnded$() {
13315
- return this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13338
+ return this.cachedObservable("mediaTrackEnded$", () => this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13316
13339
  }
13317
13340
  get errors$() {
13318
- return this._errors$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13341
+ return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13319
13342
  }
13320
13343
  get iceCandidates$() {
13321
- return this._iceCandidates$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13344
+ return this.cachedObservable("iceCandidates$", () => this._iceCandidates$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13322
13345
  }
13323
13346
  get initialized$() {
13324
- return this._initialized$.asObservable().pipe((0, import_cjs$11.filter)((initialized) => initialized), (0, import_cjs$11.takeUntil)(this.destroyed$));
13347
+ return this.cachedObservable("initialized$", () => this._initialized$.asObservable().pipe((0, import_cjs$11.filter)((initialized) => initialized), (0, import_cjs$11.takeUntil)(this.destroyed$)));
13325
13348
  }
13326
13349
  get remoteDescription$() {
13327
- return this._remoteDescription$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13350
+ return this.cachedObservable("remoteDescription$", () => this._remoteDescription$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13328
13351
  }
13329
13352
  get localStream$() {
13330
- return this.localStreamController.localStream$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13353
+ return this.cachedObservable("localStream$", () => this.localStreamController.localStream$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13331
13354
  }
13332
13355
  get remoteStream$() {
13333
- return this._remoteStream$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13356
+ return this.cachedObservable("remoteStream$", () => this._remoteStream$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13334
13357
  }
13335
13358
  get localAudioTracks$() {
13336
- return this.localStreamController.localAudioTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13359
+ return this.cachedObservable("localAudioTracks$", () => this.localStreamController.localAudioTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13337
13360
  }
13338
13361
  get localVideoTracks$() {
13339
- return this.localStreamController.localVideoTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13362
+ return this.cachedObservable("localVideoTracks$", () => this.localStreamController.localVideoTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13340
13363
  }
13341
13364
  get iceConnectionState$() {
13342
- return this._iceConnectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13365
+ return this.cachedObservable("iceConnectionState$", () => this._iceConnectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13343
13366
  }
13344
13367
  get connectionState$() {
13345
- return this._connectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13368
+ return this.cachedObservable("connectionState$", () => this._connectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13346
13369
  }
13347
13370
  get signalingState$() {
13348
- return this._signalingState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13371
+ return this.cachedObservable("signalingState$", () => this._signalingState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13349
13372
  }
13350
13373
  get type() {
13351
13374
  return this._type;
@@ -13411,7 +13434,7 @@ var RTCPeerConnectionController = class extends Destroyable {
13411
13434
  };
13412
13435
  }
13413
13436
  get WebRTCPeerConnectionConstructor() {
13414
- return this.options.WebRTCPeerConnectionConstructor ?? RTCPeerConnection;
13437
+ return this.options.webRTCApiProvider?.RTCPeerConnection ?? RTCPeerConnection;
13415
13438
  }
13416
13439
  get offerOptions() {
13417
13440
  const options = { iceRestart: this.firstSDPExchangeCompleted ? true : void 0 };
@@ -13678,10 +13701,12 @@ var RTCPeerConnectionController = class extends Destroyable {
13678
13701
  }
13679
13702
  }
13680
13703
  async getUserMedia(constraints) {
13681
- return this.options.getUserMedia?.(constraints) ?? navigator.mediaDevices.getUserMedia(constraints);
13704
+ return (this.options.webRTCApiProvider?.mediaDevices ?? navigator.mediaDevices).getUserMedia(constraints);
13682
13705
  }
13683
13706
  async getDisplayMedia(options) {
13684
- return this.options.getDisplayMedia?.(options) ?? navigator.mediaDevices.getDisplayMedia(options);
13707
+ const mediaDevices = this.options.webRTCApiProvider?.mediaDevices ?? navigator.mediaDevices;
13708
+ if (!mediaDevices.getDisplayMedia) throw new DependencyError("getDisplayMedia is not supported by the current WebRTC provider");
13709
+ return mediaDevices.getDisplayMedia(options);
13685
13710
  }
13686
13711
  async setupRemoteTracks() {
13687
13712
  if (!this.peerConnection) throw new DependencyError("RTCPeerConnection is not initialized");
@@ -13846,11 +13871,12 @@ var VertoManager = class extends Destroyable {
13846
13871
  }
13847
13872
  };
13848
13873
  var WebRTCVertoManager = class extends VertoManager {
13849
- constructor(webRtcCallSession, attachManager, deviceController, options = {}) {
13874
+ constructor(webRtcCallSession, attachManager, deviceController, webRTCApiProvider, options = {}) {
13850
13875
  super(webRtcCallSession);
13851
13876
  this.webRtcCallSession = webRtcCallSession;
13852
13877
  this.attachManager = attachManager;
13853
13878
  this.deviceController = deviceController;
13879
+ this.webRTCApiProvider = webRTCApiProvider;
13854
13880
  this._rtcPeerConnections$ = this.createBehaviorSubject([]);
13855
13881
  this._selfId$ = this.createBehaviorSubject(null);
13856
13882
  this._signalingStatus$ = this.createBehaviorSubject(null);
@@ -13924,11 +13950,11 @@ var WebRTCVertoManager = class extends VertoManager {
13924
13950
  return rtcPeerConnection;
13925
13951
  }
13926
13952
  get signalingStatus$() {
13927
- return (0, import_cjs$10.merge)(this._signalingStatus$.pipe(filterNull()), this.mainPeerConnection.connectionState$.pipe((0, import_cjs$10.filter)((connectionState) => [
13953
+ return this.cachedObservable("signalingStatus$", () => (0, import_cjs$10.merge)(this._signalingStatus$.pipe(filterNull()), this.mainPeerConnection.connectionState$.pipe((0, import_cjs$10.filter)((connectionState) => [
13928
13954
  "connected",
13929
13955
  "disconnected",
13930
13956
  "failed"
13931
- ].includes(connectionState))));
13957
+ ].includes(connectionState)))));
13932
13958
  }
13933
13959
  initSubscriptions() {
13934
13960
  this.subscribeTo(this.vertoAnswer$, (event) => {
@@ -13976,19 +14002,19 @@ var WebRTCVertoManager = class extends VertoManager {
13976
14002
  return this._selfId$.value;
13977
14003
  }
13978
14004
  get vertoAnswer$() {
13979
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14005
+ return this.cachedObservable("vertoAnswer$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13980
14006
  }
13981
14007
  get vertoMediaParams$() {
13982
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14008
+ return this.cachedObservable("vertoMediaParams$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13983
14009
  }
13984
14010
  get vertoBye$() {
13985
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14011
+ return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13986
14012
  }
13987
14013
  get vertoAttach$() {
13988
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14014
+ return this.cachedObservable("vertoAttach$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13989
14015
  }
13990
14016
  get vertoPing$() {
13991
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14017
+ return this.cachedObservable("vertoPing$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13992
14018
  }
13993
14019
  async executeVerto(message, optionals = {}) {
13994
14020
  const webrtcVertoMessage = WebrtcVerto({
@@ -14013,7 +14039,7 @@ var WebRTCVertoManager = class extends VertoManager {
14013
14039
  }
14014
14040
  async sendLocalDescription(message, rtcPeerConnController) {
14015
14041
  const vertoMethod = message.method;
14016
- const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController);
14042
+ const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMethod);
14017
14043
  try {
14018
14044
  const response = await this.executeVerto(message, optionalsParams);
14019
14045
  switch (vertoMethod) {
@@ -14090,6 +14116,7 @@ var WebRTCVertoManager = class extends VertoManager {
14090
14116
  inputVideoStream: options.inputVideoStream,
14091
14117
  receiveAudio: options.receiveAudio,
14092
14118
  receiveVideo: options.receiveVideo,
14119
+ webRTCApiProvider: this.webRTCApiProvider,
14093
14120
  ...this.RTCPeerConnectionConfig
14094
14121
  }, options.initOffer, this.deviceController);
14095
14122
  this.setupLocalDescriptionHandler(rtcPeerConnController);
@@ -14156,18 +14183,18 @@ var WebRTCVertoManager = class extends VertoManager {
14156
14183
  this.callSession?.destroy();
14157
14184
  });
14158
14185
  }
14159
- getSendLocalSDPOptionalParams(rtcPeerConnController) {
14186
+ getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMethod) {
14160
14187
  let subscribe = void 0;
14161
- const initial = !rtcPeerConnController.firstSDPExchangeCompleted;
14162
- if (initial) {
14188
+ if (!rtcPeerConnController.firstSDPExchangeCompleted) {
14163
14189
  subscribe = [];
14164
14190
  if (rtcPeerConnController.isMainDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeMainDevice);
14165
14191
  else if (rtcPeerConnController.isAdditionalDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeAdditionalDevice);
14166
14192
  else if (rtcPeerConnController.isScreenShare) subscribe.push(...PreferencesContainer.instance.inviteSubscribeScreenshare);
14167
14193
  }
14194
+ const isInvite = vertoMethod === "verto.invite";
14168
14195
  return {
14169
14196
  callID: rtcPeerConnController.id,
14170
- node_id: initial ? "" : this._nodeId$.value ?? "",
14197
+ node_id: isInvite ? "" : this._nodeId$.value ?? "",
14171
14198
  subscribe
14172
14199
  };
14173
14200
  }
@@ -14268,7 +14295,8 @@ var WebRTCVertoManager = class extends VertoManager {
14268
14295
  rtcPeerConnController = new RTCPeerConnectionController({
14269
14296
  ...options,
14270
14297
  ...this.RTCPeerConnectionConfig,
14271
- propose
14298
+ propose,
14299
+ webRTCApiProvider: this.webRTCApiProvider
14272
14300
  }, void 0, this.deviceController);
14273
14301
  this.setupLocalDescriptionHandler(rtcPeerConnController);
14274
14302
  if (propose === "screenshare") this._screenShareId = rtcPeerConnController.id;
@@ -14550,7 +14578,7 @@ var WebRTCCall = class extends Destroyable {
14550
14578
  }
14551
14579
  /** Observable of the current call status (e.g. `'ringing'`, `'connected'`). */
14552
14580
  get status$() {
14553
- return (0, import_cjs$9.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$);
14581
+ return this.cachedObservable("status$", () => (0, import_cjs$9.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$));
14554
14582
  }
14555
14583
  /** Observable of the participants list, emits on join/leave/update. */
14556
14584
  get participants$() {
@@ -14654,7 +14682,7 @@ var WebRTCCall = class extends Destroyable {
14654
14682
  return this.vertoManager.mediaDirections;
14655
14683
  }
14656
14684
  get participantsId$() {
14657
- return this.participants$.pipe((0, import_cjs$9.map)((participants) => participants.map((participant) => participant.id)));
14685
+ return this.cachedObservable("participantsId$", () => this.participants$.pipe((0, import_cjs$9.map)((participants) => participants.map((participant) => participant.id))));
14658
14686
  }
14659
14687
  /** Executes a raw JSON-RPC request on the client session. */
14660
14688
  async execute(request, options) {
@@ -14689,35 +14717,35 @@ var WebRTCCall = class extends Destroyable {
14689
14717
  }
14690
14718
  }
14691
14719
  get callSessionEvents$() {
14692
- return this.clientSession.signalingEvent$.pipe((0, import_cjs$9.filter)((event) => this.isCallSessionEvent(event)), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Received call session event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14720
+ return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, import_cjs$9.filter)((event) => this.isCallSessionEvent(event)), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Received call session event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14693
14721
  }
14694
14722
  /** Observable of call-updated events. */
14695
14723
  get callUpdated$() {
14696
- return this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14724
+ return this.cachedObservable("callUpdated$", () => this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14697
14725
  }
14698
14726
  /** Observable of member-joined events. */
14699
14727
  get memberJoined$() {
14700
- return this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14728
+ return this.cachedObservable("memberJoined$", () => this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14701
14729
  }
14702
14730
  /** Observable of member-left events. */
14703
14731
  get memberLeft$() {
14704
- return this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14732
+ return this.cachedObservable("memberLeft$", () => this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14705
14733
  }
14706
14734
  /** Observable of member-updated events (mute, volume, etc.). */
14707
14735
  get memberUpdated$() {
14708
- return this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14736
+ return this.cachedObservable("memberUpdated$", () => this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14709
14737
  }
14710
14738
  /** Observable of member-talking events (speech start/stop). */
14711
14739
  get memberTalking$() {
14712
- return this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14740
+ return this.cachedObservable("memberTalking$", () => this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14713
14741
  }
14714
14742
  /** Observable of call state-change events. */
14715
14743
  get callStates$() {
14716
- return this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14744
+ return this.cachedObservable("callStates$", () => this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14717
14745
  }
14718
14746
  /** Observable of layout-changed events. */
14719
14747
  get layoutUpdates$() {
14720
- return this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14748
+ return this.cachedObservable("layoutUpdates$", () => this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14721
14749
  }
14722
14750
  /** Underlying `RTCPeerConnection`, for advanced use cases. */
14723
14751
  get rtcPeerConnection() {
@@ -14725,19 +14753,19 @@ var WebRTCCall = class extends Destroyable {
14725
14753
  }
14726
14754
  /** Observable of raw signaling events as plain objects. */
14727
14755
  get signalingEvent$() {
14728
- return this.callEvent$.pipe((0, import_cjs$9.map)((event) => JSON.parse(JSON.stringify(event))));
14756
+ return this.cachedObservable("signalingEvent$", () => this.callEvent$.pipe((0, import_cjs$9.map)((event) => JSON.parse(JSON.stringify(event)))));
14729
14757
  }
14730
14758
  /** Observable of WebRTC-specific signaling messages. */
14731
14759
  get webrtcMessages$() {
14732
- return this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a WebRTC message event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14760
+ return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a WebRTC message event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14733
14761
  }
14734
14762
  /** Observable of call-level signaling events. */
14735
14763
  get callEvent$() {
14736
- return this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a call event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14764
+ return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a call event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14737
14765
  }
14738
14766
  /** Observable of layout-changed signaling events. */
14739
14767
  get layoutEvent$() {
14740
- return this.callEvent$.pipe(filterAs(isLayoutChangedMetadata, "params"));
14768
+ return this.cachedObservable("layoutEvent$", () => this.callEvent$.pipe(filterAs(isLayoutChangedMetadata, "params")));
14741
14769
  }
14742
14770
  /** Hangs up the call and releases all resources. */
14743
14771
  async hangup() {
@@ -14798,10 +14826,11 @@ var WebRTCCall = class extends Destroyable {
14798
14826
  * Eliminates circular dependencies by centralizing Call and Manager creation.
14799
14827
  */
14800
14828
  var CallFactory = class {
14801
- constructor(sessionManager, deviceController, attachManager) {
14829
+ constructor(sessionManager, deviceController, attachManager, webRTCApiProvider) {
14802
14830
  this.sessionManager = sessionManager;
14803
14831
  this.deviceController = deviceController;
14804
14832
  this.attachManager = attachManager;
14833
+ this.webRTCApiProvider = webRTCApiProvider;
14805
14834
  }
14806
14835
  /**
14807
14836
  * Create a new WebRTCCall with properly initialized managers
@@ -14810,7 +14839,7 @@ var CallFactory = class {
14810
14839
  return new WebRTCCall(this.sessionManager, options, {
14811
14840
  initializeManagers: (callInstance) => {
14812
14841
  return {
14813
- vertoManager: new WebRTCVertoManager(callInstance, this.attachManager, this.deviceController, {
14842
+ vertoManager: new WebRTCVertoManager(callInstance, this.attachManager, this.deviceController, this.webRTCApiProvider, {
14814
14843
  nodeId: options.nodeId,
14815
14844
  onError: (error) => {
14816
14845
  callInstance.emitError(error);
@@ -14890,7 +14919,7 @@ var EntityCollection = class extends Destroyable {
14890
14919
  return this.fetchController.hasMore ?? true;
14891
14920
  }
14892
14921
  get updated$() {
14893
- return this.loading$.pipe((0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.skip)(1), (0, import_cjs$8.filter)((loading) => !loading), (0, import_cjs$8.map)(() => void 0), (0, import_cjs$8.takeUntil)(this._destroy$));
14922
+ return this.cachedObservable("updated$", () => this.loading$.pipe((0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.skip)(1), (0, import_cjs$8.filter)((loading) => !loading), (0, import_cjs$8.map)(() => void 0), (0, import_cjs$8.takeUntil)(this._destroy$)));
14894
14923
  }
14895
14924
  get values() {
14896
14925
  return Array.from(this.collectionData.values());
@@ -14970,7 +14999,7 @@ var EntityCollectionTransformed = class {
14970
14999
  return this.originalCollection.values.filter(this.filter).map(this.mapper);
14971
15000
  }
14972
15001
  get values$() {
14973
- return this.originalCollection.values$.pipe((0, import_cjs$8.map)((values) => values.filter(this.filter).map(this.mapper)));
15002
+ return this._values$ ??= this.originalCollection.values$.pipe((0, import_cjs$8.map)((values) => values.filter(this.filter).map(this.mapper)));
14974
15003
  }
14975
15004
  get$(id) {
14976
15005
  const original$ = this.originalCollection.get$(id);
@@ -15044,7 +15073,7 @@ var Address = class extends Destroyable {
15044
15073
  }
15045
15074
  /** Observable of the human-readable display name. */
15046
15075
  get displayName$() {
15047
- return this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.display_name), (0, import_cjs$7.takeUntil)(this.destroyed$));
15076
+ return this.cachedObservable("displayName$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.display_name), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15048
15077
  }
15049
15078
  /** Human-readable display name. */
15050
15079
  get displayName() {
@@ -15053,7 +15082,7 @@ var Address = class extends Destroyable {
15053
15082
  }
15054
15083
  /** Observable of the preview image URL. */
15055
15084
  get previewUrl$() {
15056
- return this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.preview_url), (0, import_cjs$7.takeUntil)(this.destroyed$));
15085
+ return this.cachedObservable("previewUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.preview_url), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15057
15086
  }
15058
15087
  /** Preview image URL. */
15059
15088
  get previewUrl() {
@@ -15062,7 +15091,7 @@ var Address = class extends Destroyable {
15062
15091
  }
15063
15092
  /** Observable of the cover image URL. */
15064
15093
  get coverUrl$() {
15065
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.cover_url), (0, import_cjs$7.takeUntil)(this.destroyed$));
15094
+ return this.cachedObservable("coverUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.cover_url), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15066
15095
  }
15067
15096
  /** Cover image URL. */
15068
15097
  get coverUrl() {
@@ -15071,7 +15100,7 @@ var Address = class extends Destroyable {
15071
15100
  }
15072
15101
  /** Observable of the underlying resource ID. */
15073
15102
  get resourceId$() {
15074
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.resource_id), (0, import_cjs$7.takeUntil)(this.destroyed$));
15103
+ return this.cachedObservable("resourceId$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.resource_id), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15075
15104
  }
15076
15105
  /** Underlying resource ID. */
15077
15106
  get resourceId() {
@@ -15080,7 +15109,7 @@ var Address = class extends Destroyable {
15080
15109
  }
15081
15110
  /** Observable of the resource type (e.g. `'room'`, `'subscriber'`). */
15082
15111
  get type$() {
15083
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.type), (0, import_cjs$7.takeUntil)(this.destroyed$));
15112
+ return this.cachedObservable("type$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.type), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15084
15113
  }
15085
15114
  /** Resource type (e.g. `'room'`, `'subscriber'`). */
15086
15115
  get type() {
@@ -15089,7 +15118,7 @@ var Address = class extends Destroyable {
15089
15118
  }
15090
15119
  /** Observable of available communication channels (audio, video, messaging). */
15091
15120
  get channels$() {
15092
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.channels), (0, import_cjs$7.takeUntil)(this.destroyed$));
15121
+ return this.cachedObservable("channels$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.channels), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15093
15122
  }
15094
15123
  /** Available communication channels. */
15095
15124
  get channels() {
@@ -15103,7 +15132,7 @@ var Address = class extends Destroyable {
15103
15132
  }
15104
15133
  /** Observable indicating whether the address (room) is locked. */
15105
15134
  get locked$() {
15106
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.locked), (0, import_cjs$7.takeUntil)(this.destroyed$));
15135
+ return this.cachedObservable("locked$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.locked), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15107
15136
  }
15108
15137
  /** Sends a text message to this address. */
15109
15138
  async sendText(text) {
@@ -15226,7 +15255,7 @@ const getAddressSearchURI = (options) => {
15226
15255
  return name;
15227
15256
  };
15228
15257
  var ClientSessionManager = class extends Destroyable {
15229
- constructor(credential, transport, storage, authorizationStateKey, deviceController, attachManager) {
15258
+ constructor(credential, transport, storage, authorizationStateKey, deviceController, attachManager, webRTCApiProvider) {
15230
15259
  super();
15231
15260
  this.credential = credential;
15232
15261
  this.transport = transport;
@@ -15249,11 +15278,11 @@ var ClientSessionManager = class extends Destroyable {
15249
15278
  this._calls$ = this.createBehaviorSubject({});
15250
15279
  this._iceServers$ = this.createBehaviorSubject([]);
15251
15280
  attachManager.setSession(this);
15252
- this.callFactory = new CallFactory(this, deviceController, attachManager);
15281
+ this.callFactory = new CallFactory(this, deviceController, attachManager, webRTCApiProvider);
15253
15282
  this.initialized$ = (0, import_cjs$5.defer)(() => (0, import_cjs$5.from)(this.init())).pipe((0, import_cjs$5.shareReplay)(1), (0, import_cjs$5.takeUntil)(this.destroyed$));
15254
15283
  }
15255
15284
  get incomingCalls$() {
15256
- return this.calls$.pipe((0, import_cjs$5.map)((calls) => calls.filter((call) => call.direction === "inbound")));
15285
+ return this.cachedObservable("incomingCalls$", () => this.calls$.pipe((0, import_cjs$5.map)((calls) => calls.filter((call) => call.direction === "inbound"))));
15257
15286
  }
15258
15287
  get incomingCalls() {
15259
15288
  return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
@@ -15265,7 +15294,7 @@ var ClientSessionManager = class extends Destroyable {
15265
15294
  return this._subscriberInfo$.value;
15266
15295
  }
15267
15296
  get calls$() {
15268
- return this._calls$.pipe((0, import_cjs$5.map)((calls) => Object.values(calls)));
15297
+ return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$5.map)((calls) => Object.values(calls))));
15269
15298
  }
15270
15299
  get calls() {
15271
15300
  return Object.values(this._calls$.value);
@@ -15368,20 +15397,20 @@ var ClientSessionManager = class extends Destroyable {
15368
15397
  }
15369
15398
  }
15370
15399
  get authStateEvent$() {
15371
- return this.signalingEvent$.pipe((0, import_cjs$5.tap)((msg) => {
15400
+ return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, import_cjs$5.tap)((msg) => {
15372
15401
  logger$6.debug("[Session] Received incoming message:", msg);
15373
15402
  }), filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, import_cjs$5.tap)((event) => {
15374
15403
  logger$6.debug("[Session] Authorization state event received:", event.authorization_state);
15375
- }));
15404
+ })));
15376
15405
  }
15377
15406
  get signalingEvent$() {
15378
- return this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"));
15407
+ return this.cachedObservable("signalingEvent$", () => this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"), (0, import_cjs$5.share)()));
15379
15408
  }
15380
15409
  get vertoInvite$() {
15381
- return this.signalingEvent$.pipe((0, import_cjs$5.filter)(isWebrtcMessageMetadata), (0, import_cjs$5.filter)((event) => isVertoInviteMessage(event.params)), (0, import_cjs$5.map)((event) => ({
15410
+ return this.cachedObservable("vertoInvite$", () => this.signalingEvent$.pipe((0, import_cjs$5.filter)(isWebrtcMessageMetadata), (0, import_cjs$5.filter)((event) => isVertoInviteMessage(event.params)), (0, import_cjs$5.map)((event) => ({
15382
15411
  node_id: event.node_id,
15383
15412
  ...event.params.params
15384
- })));
15413
+ }))));
15385
15414
  }
15386
15415
  get contexts() {
15387
15416
  return [];
@@ -15546,6 +15575,9 @@ var ClientSessionWrapper = class {
15546
15575
  get signalingEvent$() {
15547
15576
  return this.clientSessionManager.signalingEvent$;
15548
15577
  }
15578
+ get iceServers() {
15579
+ return this.clientSessionManager.iceServers;
15580
+ }
15549
15581
  async execute(request, options) {
15550
15582
  return this.clientSessionManager.execute(request, options);
15551
15583
  }
@@ -16138,6 +16170,7 @@ var SignalWire = class extends Destroyable {
16138
16170
  if (this._options.storageImplementation) this._deps.storageImpl = this._options.storageImplementation;
16139
16171
  if (this._options.webSocketConstructor) this._deps.WebSocket = this._options.webSocketConstructor;
16140
16172
  if (this._options.savePreferences) this.preferences.enableSavePreferences(this._deps.storage);
16173
+ if (this._options.webRTCApiProvider) this._deps.webRTCApiProvider = this._options.webRTCApiProvider;
16141
16174
  this._deviceController = this._deps.deviceController;
16142
16175
  if (!this._options.skipDeviceMonitoring) this._deviceController.enableDeviceMonitoring();
16143
16176
  this.subscribeTo(this._deviceController.errors$, (error) => {
@@ -16193,7 +16226,7 @@ var SignalWire = class extends Destroyable {
16193
16226
  async init() {
16194
16227
  this._subscriber$.next(new Subscriber(this._deps.http));
16195
16228
  if (!this._options.skipConnection) await this.connect();
16196
- if (this._options.skipReconnect && this._attachManager) await this._attachManager.flush();
16229
+ if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
16197
16230
  if (!this._options.skipRegister) this.register();
16198
16231
  this.handleAttachments();
16199
16232
  }
@@ -16262,7 +16295,7 @@ var SignalWire = class extends Destroyable {
16262
16295
  };
16263
16296
  this._transport = new TransportManager(this._deps.storage, this._deps.protocolKey, this._deps.WebSocket, PreferencesContainer.instance.relayHost ?? this._deps.relayHost, errorHandler);
16264
16297
  this._attachManager = new AttachManager(this._deps.storage, this._deps.deviceController, PreferencesContainer.instance.reconnectCallsTimeout, this._deps.attachedCallsKey);
16265
- this._clientSession = new ClientSessionManager(this._deps.credential, this._transport, this._deps.storage, this._deps.authorizationStateKey, this._deps.deviceController, this._attachManager);
16298
+ this._clientSession = new ClientSessionManager(this._deps.credential, this._transport, this._deps.storage, this._deps.authorizationStateKey, this._deps.deviceController, this._attachManager, this._deps.webRTCApiProvider);
16266
16299
  this._publicSession = new ClientSessionWrapper(this._clientSession);
16267
16300
  this.subscribeTo(this._clientSession.errors$, (error) => {
16268
16301
  this._errors$.next(error);
@@ -16332,7 +16365,7 @@ var SignalWire = class extends Destroyable {
16332
16365
  }
16333
16366
  /** Observable that emits `true` when the client is both connected and authenticated. */
16334
16367
  get ready$() {
16335
- return this._isConnected$.pipe((0, import_cjs.switchMap)((connected) => connected ? this._clientSession.authenticated$ : (0, import_cjs.of)(false)));
16368
+ return this.cachedObservable("ready$", () => this._isConnected$.pipe((0, import_cjs.switchMap)((connected) => connected ? this._clientSession.authenticated$ : (0, import_cjs.of)(false))));
16336
16369
  }
16337
16370
  /** Observable stream of errors from transport, authentication, and devices. */
16338
16371
  get errors$() {
@@ -16624,5 +16657,5 @@ emitReadyEvent();
16624
16657
  if (typeof process === "undefined") globalThis.process = { env: { NODE_ENV: "production" } };
16625
16658
 
16626
16659
  //#endregion
16627
- export { Address, CallCreateError, ClientPreferences, CollectionFetchError, MediaTrackError, MessageParseError, Participant, SelfParticipant, SignalWire, StaticCredentialProvider, Subscriber, VertoPongError, WebRTCCall, embeddableCall, isSelfParticipant, ready, version };
16660
+ export { Address, CallCreateError, ClientPreferences, CollectionFetchError, InvalidCredentialsError, MediaTrackError, MessageParseError, Participant, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, Subscriber, UnexpectedError, VertoPongError, WebRTCCall, embeddableCall, isSelfParticipant, ready, version };
16628
16661
  //# sourceMappingURL=browser.mjs.map