@signalwire/js 4.0.0-dev-20260303132237 → 4.0.0-dev-20260303135558

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
@@ -6934,7 +6934,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
6934
6934
  var innerFrom_1$6 = require_innerFrom();
6935
6935
  var lift_1$13 = require_lift();
6936
6936
  var OperatorSubscriber_1$11 = require_OperatorSubscriber();
6937
- function switchMap$2(project, resultSelector) {
6937
+ function switchMap$3(project, resultSelector) {
6938
6938
  return lift_1$13.operate(function(source, subscriber) {
6939
6939
  var innerSubscriber = null;
6940
6940
  var index = 0;
@@ -6958,7 +6958,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
6958
6958
  }));
6959
6959
  });
6960
6960
  }
6961
- exports.switchMap = switchMap$2;
6961
+ exports.switchMap = switchMap$3;
6962
6962
  }));
6963
6963
 
6964
6964
  //#endregion
@@ -14236,8 +14236,7 @@ var WebRTCVertoManager = class extends VertoManager {
14236
14236
  userVariables: {
14237
14237
  memberCallId: this.webRtcCallSession.id,
14238
14238
  memberId,
14239
- ...this.webRtcCallSession.options.userVariables,
14240
- ...PreferencesContainer.instance.userVariables
14239
+ ...this.webRtcCallSession.userVariables
14241
14240
  },
14242
14241
  screenShare: rtcPeerConnectionController.isScreenShare,
14243
14242
  additionalDevice: rtcPeerConnectionController.isAdditionalDevice,
@@ -14436,6 +14435,20 @@ var ParticipantFactory = class {
14436
14435
  //#region src/core/entities/Call.ts
14437
14436
  var import_cjs$9 = require_cjs();
14438
14437
  const logger$9 = getLogger();
14438
+ const fromDestinationParams = (destination) => {
14439
+ if (!destination) return {};
14440
+ try {
14441
+ const url = new URL(`destination:${destination}`);
14442
+ const params = {};
14443
+ url.searchParams.forEach((value, key) => {
14444
+ params[key] = value;
14445
+ });
14446
+ return params;
14447
+ } catch (error) {
14448
+ logger$9.warn(`Failed to parse destination URI: ${destination}`, error);
14449
+ return {};
14450
+ }
14451
+ };
14439
14452
  /**
14440
14453
  * Concrete WebRTC call implementation.
14441
14454
  *
@@ -14453,8 +14466,21 @@ var WebRTCCall = class extends Destroyable {
14453
14466
  this._errors$ = this.createSubject();
14454
14467
  this._answered$ = this.createReplaySubject();
14455
14468
  this._holdState = false;
14469
+ this._userVariables$ = this.createBehaviorSubject({ ...PreferencesContainer.instance.userVariables });
14456
14470
  this.id = options.callId ?? v4_default();
14457
14471
  this.to = options.to;
14472
+ this._userVariables$.next({
14473
+ ...this._userVariables$.value,
14474
+ ...fromDestinationParams(options.to),
14475
+ ...options.userVariables
14476
+ });
14477
+ this.subscribeTo(this.webrtcMessages$, (message) => {
14478
+ const userVars = getValueFrom(message, "params.userVariables");
14479
+ if (userVars) this._userVariables$.next({
14480
+ ...this._userVariables$.value,
14481
+ ...userVars
14482
+ });
14483
+ });
14458
14484
  const managers = initialization.initializeManagers(this);
14459
14485
  this.vertoManager = managers.vertoManager;
14460
14486
  this.callEventsManager = managers.callEventsManager;
@@ -14668,6 +14694,21 @@ var WebRTCCall = class extends Destroyable {
14668
14694
  get remoteStream() {
14669
14695
  return this.vertoManager.remoteStream;
14670
14696
  }
14697
+ /** Observable of custom user variables associated with the call. */
14698
+ get userVariables$() {
14699
+ return this._userVariables$.asObservable();
14700
+ }
14701
+ /** a copy of the current custom user variables of the call. */
14702
+ get userVariables() {
14703
+ return { ...this._userVariables$.value };
14704
+ }
14705
+ /** Merge current custom user variables of the call. */
14706
+ set userVariables(variables) {
14707
+ this._userVariables$.next({
14708
+ ...this._userVariables$.value,
14709
+ ...variables
14710
+ });
14711
+ }
14671
14712
  /** @internal */
14672
14713
  createParticipant(memberId, selfId) {
14673
14714
  if (memberId === (selfId ?? this.vertoManager.selfId)) return this.participantFactory.createSelfParticipant(memberId);
@@ -14866,7 +14907,10 @@ var Fetcher = class {
14866
14907
  this.nextUrl = `${this.endpoint}?${params}`;
14867
14908
  }
14868
14909
  async next() {
14869
- if (!this.nextUrl) return [];
14910
+ if (!this.nextUrl) {
14911
+ this.hasMore = false;
14912
+ return [];
14913
+ }
14870
14914
  const response = await this.http.request({
14871
14915
  ...GET_PARAMS,
14872
14916
  url: this.nextUrl
@@ -14874,6 +14918,7 @@ var Fetcher = class {
14874
14918
  if (response.ok && !!response.body) {
14875
14919
  const result = JSON.parse(response.body);
14876
14920
  this.nextUrl = result.links.next;
14921
+ this.hasMore = !!this.nextUrl;
14877
14922
  return result.data.filter(this.filter).map(this.mapper);
14878
14923
  }
14879
14924
  logger$8.error("Failed to fetch entity");
@@ -14895,6 +14940,7 @@ var EntityCollection = class extends Destroyable {
14895
14940
  this.onError = onError;
14896
14941
  this.loading$ = this.createBehaviorSubject(false);
14897
14942
  this.values$ = this.createReplaySubject(1);
14943
+ this._hasMore$ = this.createBehaviorSubject(true);
14898
14944
  this.collectionData = /* @__PURE__ */ new Map();
14899
14945
  this.observablesRegistry = /* @__PURE__ */ new Map();
14900
14946
  this.upsertData = (data) => {
@@ -14910,7 +14956,7 @@ var EntityCollection = class extends Destroyable {
14910
14956
  this._destroy$ = new import_cjs$8.Subject();
14911
14957
  this.updateSubscription = this.update$.subscribe(this.upsertData);
14912
14958
  this.loading$.next(false);
14913
- this.hasMore$ = (0, import_cjs$8.defer)(() => (0, import_cjs$8.from)(this.init())).pipe((0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this._destroy$));
14959
+ this.hasMore$ = (0, import_cjs$8.defer)(() => (0, import_cjs$8.from)(this.init())).pipe((0, import_cjs$8.switchMap)(() => this._hasMore$), (0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this._destroy$));
14914
14960
  }
14915
14961
  get loading() {
14916
14962
  return this.loading$.value;
@@ -14925,17 +14971,21 @@ var EntityCollection = class extends Destroyable {
14925
14971
  return Array.from(this.collectionData.values());
14926
14972
  }
14927
14973
  async init() {
14928
- if (this.fetchController.hasMore === false) return Promise.resolve(false);
14974
+ if (this.fetchController.hasMore === false) {
14975
+ this._hasMore$.next(false);
14976
+ return;
14977
+ }
14929
14978
  await this.fetchMore();
14930
- return this.fetchController.hasMore ?? true;
14931
14979
  }
14932
14980
  async fetchMore() {
14933
14981
  try {
14934
14982
  this.loading$.next(true);
14935
14983
  (await this.fetchController.next()).forEach(this.upsertData);
14984
+ this._hasMore$.next(this.fetchController.hasMore ?? false);
14936
14985
  this.loading$.next(false);
14937
14986
  } catch (error) {
14938
14987
  logger$8.error(`Failed to fetch initial collection data`, error);
14988
+ this._hasMore$.next(this.fetchController.hasMore ?? false);
14939
14989
  this.loading$.next(false);
14940
14990
  this.onError?.(new CollectionFetchError("fetchMore", error));
14941
14991
  }
@@ -15507,7 +15557,8 @@ var ClientSessionManager = class extends Destroyable {
15507
15557
  to: invite.callee_id_number,
15508
15558
  fromName: invite.caller_id_name,
15509
15559
  from: invite.caller_id_number,
15510
- displayDirection: invite.display_direction
15560
+ displayDirection: invite.display_direction,
15561
+ userVariables: invite.userVariables
15511
15562
  });
15512
15563
  await (0, import_cjs$5.firstValueFrom)(callSession.status$);
15513
15564
  this._calls$.next({