@stream-io/video-client 0.3.22 → 0.3.24

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.
@@ -24,7 +24,7 @@ export declare const descending: <T>(comparator: Comparator<T>) => Comparator<T>
24
24
  * Creates a new comparator which conditionally applies the given comparator.
25
25
  *
26
26
  * @example
27
- * const shouldSortByValue = () => return false; // to turn it off
27
+ * const shouldSortByValue = (a, b) => a % 2 === 0; // return false to turn it off
28
28
  * const byValue = (a, b) => a < b ? - 1 : a > b ? 1 : 0;
29
29
  * const comparator = conditional(shouldSortByValue)(byValue);
30
30
  *
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.3.22";
1
+ export declare const version = "0.3.24";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -177,7 +177,7 @@ export class DynascaleManager {
177
177
  ),
178
178
  takeWhile((participant) => !!participant),
179
179
  distinctUntilChanged(),
180
- shareReplay(1),
180
+ shareReplay({ bufferSize: 1, refCount: true }),
181
181
  );
182
182
 
183
183
  /**
@@ -339,6 +339,7 @@ export class DynascaleManager {
339
339
  ),
340
340
  takeWhile((p) => !!p),
341
341
  distinctUntilChanged(),
342
+ shareReplay({ bufferSize: 1, refCount: true }),
342
343
  );
343
344
 
344
345
  const updateMediaStreamSubscription = participant$
@@ -365,7 +366,8 @@ export class DynascaleManager {
365
366
  getSdkInfo()?.type === SdkType.REACT
366
367
  ? p?.audioOutputDeviceId
367
368
  : selectedDevice;
368
- if ('setSinkId' in audioElement) {
369
+
370
+ if ('setSinkId' in audioElement && typeof deviceId === 'string') {
369
371
  // @ts-expect-error setSinkId is not yet in the lib
370
372
  audioElement.setSinkId(deviceId);
371
373
  }
@@ -227,7 +227,7 @@ describe('DynascaleManager', () => {
227
227
 
228
228
  cleanup?.();
229
229
 
230
- expect(updateSubscription).toHaveBeenCalledWith(
230
+ expect(updateSubscription).toHaveBeenLastCalledWith(
231
231
  'videoTrack',
232
232
  { 'session-id': { dimension: undefined } },
233
233
  DebounceType.FAST,
@@ -278,7 +278,7 @@ describe('DynascaleManager', () => {
278
278
 
279
279
  cleanup?.();
280
280
 
281
- expect(updateSubscription).toHaveBeenCalledWith(
281
+ expect(updateSubscription).toHaveBeenLastCalledWith(
282
282
  'videoTrack',
283
283
  { 'session-id': { dimension: undefined } },
284
284
  DebounceType.FAST,
@@ -366,7 +366,7 @@ describe('DynascaleManager', () => {
366
366
 
367
367
  cleanup?.();
368
368
 
369
- expect(updateSubscription).toHaveBeenCalledWith(
369
+ expect(updateSubscription).toHaveBeenLastCalledWith(
370
370
  'videoTrack',
371
371
  { 'session-id': { dimension: undefined } },
372
372
  DebounceType.FAST,
@@ -436,7 +436,7 @@ describe('DynascaleManager', () => {
436
436
 
437
437
  cleanup?.();
438
438
 
439
- expect(updateSubscription).toHaveBeenCalledWith(
439
+ expect(updateSubscription).toHaveBeenLastCalledWith(
440
440
  'videoTrack',
441
441
  { 'session-id': { dimension: undefined } },
442
442
  DebounceType.FAST,
@@ -39,7 +39,7 @@ export const descending = <T>(comparator: Comparator<T>): Comparator<T> => {
39
39
  * Creates a new comparator which conditionally applies the given comparator.
40
40
  *
41
41
  * @example
42
- * const shouldSortByValue = () => return false; // to turn it off
42
+ * const shouldSortByValue = (a, b) => a % 2 === 0; // return false to turn it off
43
43
  * const byValue = (a, b) => a < b ? - 1 : a > b ? 1 : 0;
44
44
  * const comparator = conditional(shouldSortByValue)(byValue);
45
45
  *
@@ -1,5 +1,5 @@
1
1
  import { BehaviorSubject, Observable } from 'rxjs';
2
- import { distinctUntilChanged, map } from 'rxjs/operators';
2
+ import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
3
3
  import type { Patch } from './rxUtils';
4
4
  import * as RxUtils from './rxUtils';
5
5
  import {
@@ -320,24 +320,30 @@ export class CallState {
320
320
  */
321
321
  constructor() {
322
322
  this.logger = getLogger(['CallState']);
323
- this.participants$ = this.participantsSubject.pipe(
324
- map((ps) => ps.sort(this.sortParticipantsBy)),
323
+ this.participants$ = this.participantsSubject.asObservable().pipe(
324
+ // TODO: replace with Array.toSorted once available
325
+ map((ps) => [...ps].sort(this.sortParticipantsBy)),
326
+ shareReplay({ bufferSize: 1, refCount: true }),
325
327
  );
326
328
 
327
329
  this.localParticipant$ = this.participants$.pipe(
328
330
  map((participants) => participants.find(isStreamVideoLocalParticipant)),
331
+ shareReplay({ bufferSize: 1, refCount: true }),
329
332
  );
330
333
 
331
334
  this.remoteParticipants$ = this.participants$.pipe(
332
335
  map((participants) => participants.filter((p) => !p.isLocalParticipant)),
336
+ shareReplay({ bufferSize: 1, refCount: true }),
333
337
  );
334
338
 
335
339
  this.pinnedParticipants$ = this.participants$.pipe(
336
340
  map((participants) => participants.filter((p) => !!p.pin)),
341
+ shareReplay({ bufferSize: 1, refCount: true }),
337
342
  );
338
343
 
339
344
  this.dominantSpeaker$ = this.participants$.pipe(
340
345
  map((participants) => participants.find((p) => p.isDominantSpeaker)),
346
+ shareReplay({ bufferSize: 1, refCount: true }),
341
347
  );
342
348
 
343
349
  this.hasOngoingScreenShare$ = this.participants$.pipe(
@@ -347,6 +353,7 @@ export class CallState {
347
353
  ),
348
354
  ),
349
355
  distinctUntilChanged(),
356
+ shareReplay({ bufferSize: 1, refCount: true }),
350
357
  );
351
358
 
352
359
  this.startedAt$ = this.startedAtSubject.asObservable();
@@ -66,7 +66,8 @@ describe('CallState', () => {
66
66
  });
67
67
 
68
68
  const ps2 = state.participants;
69
- expect(ps2.map((p) => p.name)).toEqual(['F', 'B', 'E', 'A', 'C', 'D']);
69
+ // should resolve in initial - non-mutated state as set at the beginning
70
+ expect(ps2.map((p) => p.name)).toEqual(['A', 'B', 'C', 'D', 'E', 'F']);
70
71
  });
71
72
 
72
73
  it('should support custom sorting', () => {
@@ -1,5 +1,4 @@
1
- import { Observable, Subject } from 'rxjs';
2
- import { take } from 'rxjs/operators';
1
+ import { Observable, Subject, combineLatest } from 'rxjs';
3
2
 
4
3
  /**
5
4
  * A value or a function which takes the current value and returns a new value.
@@ -15,10 +14,9 @@ export type Patch<T> = T | ((currentValue: T) => T);
15
14
  export const getCurrentValue = <T>(observable$: Observable<T>) => {
16
15
  let value!: T;
17
16
  let err: Error | undefined = undefined;
18
- observable$
19
- .pipe(take(1))
17
+ combineLatest([observable$])
20
18
  .subscribe({
21
- next: (v) => {
19
+ next: ([v]) => {
22
20
  value = v;
23
21
  },
24
22
  error: (e) => {