@stream-io/video-client 1.33.0 → 1.33.1

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/index.cjs.js CHANGED
@@ -4582,9 +4582,11 @@ const speaking = (a, b) => {
4582
4582
  * @param b the second participant.
4583
4583
  */
4584
4584
  const screenSharing = (a, b) => {
4585
- if (hasScreenShare(a) && !hasScreenShare(b))
4585
+ const hasA = hasScreenShare(a);
4586
+ const hasB = hasScreenShare(b);
4587
+ if (hasA && !hasB)
4586
4588
  return -1;
4587
- if (!hasScreenShare(a) && hasScreenShare(b))
4589
+ if (!hasA && hasB)
4588
4590
  return 1;
4589
4591
  return 0;
4590
4592
  };
@@ -4595,9 +4597,11 @@ const screenSharing = (a, b) => {
4595
4597
  * @param b the second participant.
4596
4598
  */
4597
4599
  const publishingVideo = (a, b) => {
4598
- if (hasVideo(a) && !hasVideo(b))
4600
+ const hasA = hasVideo(a);
4601
+ const hasB = hasVideo(b);
4602
+ if (hasA && !hasB)
4599
4603
  return -1;
4600
- if (!hasVideo(a) && hasVideo(b))
4604
+ if (!hasA && hasB)
4601
4605
  return 1;
4602
4606
  return 0;
4603
4607
  };
@@ -4608,9 +4612,11 @@ const publishingVideo = (a, b) => {
4608
4612
  * @param b the second participant.
4609
4613
  */
4610
4614
  const publishingAudio = (a, b) => {
4611
- if (hasAudio(a) && !hasAudio(b))
4615
+ const hasA = hasAudio(a);
4616
+ const hasB = hasAudio(b);
4617
+ if (hasA && !hasB)
4612
4618
  return -1;
4613
- if (!hasAudio(a) && hasAudio(b))
4619
+ if (!hasA && hasB)
4614
4620
  return 1;
4615
4621
  return 0;
4616
4622
  };
@@ -4641,14 +4647,22 @@ const pinned = (a, b) => {
4641
4647
  * A comparator creator which will set up a comparator which prioritizes
4642
4648
  * participants who are from a specific source (e.g., WebRTC, RTMP, WHIP...).
4643
4649
  *
4644
- * @param source the source to prioritize.
4650
+ * The priority of a source is determined by the order of the sources passed in.
4651
+ * e.g. [SRT, RTMP, WHIP] will prioritize SRT sources first, then RTMP, then WHIP.
4652
+ *
4653
+ * @param sources the sources to prioritize.
4645
4654
  */
4646
- const withParticipantSource = (source) => (a, b) => {
4647
- if (a.source === source && b.source !== source)
4648
- return -1;
4649
- if (a.source !== source && b.source === source)
4650
- return 1;
4651
- return 0;
4655
+ const withParticipantSource = (...sources) => {
4656
+ const priority = (i) => (i === -1 ? Number.MAX_SAFE_INTEGER : i);
4657
+ return (a, b) => {
4658
+ const priorityA = priority(sources.indexOf(a.source));
4659
+ const priorityB = priority(sources.indexOf(b.source));
4660
+ if (priorityA < priorityB)
4661
+ return -1;
4662
+ if (priorityA > priorityB)
4663
+ return 1;
4664
+ return 0;
4665
+ };
4652
4666
  };
4653
4667
  /**
4654
4668
  * A comparator creator which will set up a comparator which prioritizes
@@ -4672,9 +4686,11 @@ const reactionType = (type) => {
4672
4686
  * @param roles the roles to prioritize.
4673
4687
  */
4674
4688
  const role = (...roles) => (a, b) => {
4675
- if (hasAnyRole(a, roles) && !hasAnyRole(b, roles))
4689
+ const hasA = hasAnyRole(a, roles);
4690
+ const hasB = hasAnyRole(b, roles);
4691
+ if (hasA && !hasB)
4676
4692
  return -1;
4677
- if (!hasAnyRole(a, roles) && hasAnyRole(b, roles))
4693
+ if (!hasA && hasB)
4678
4694
  return 1;
4679
4695
  return 0;
4680
4696
  };
@@ -4707,6 +4723,10 @@ const ifInvisibleOrUnknownBy = conditional((a, b) => a.viewportVisibilityState?.
4707
4723
  a.viewportVisibilityState?.videoTrack === exports.VisibilityState.UNKNOWN ||
4708
4724
  b.viewportVisibilityState?.videoTrack === exports.VisibilityState.INVISIBLE ||
4709
4725
  b.viewportVisibilityState?.videoTrack === exports.VisibilityState.UNKNOWN);
4726
+ /**
4727
+ * A comparator that prioritizes participants with video ingress sources.
4728
+ */
4729
+ const withVideoIngressSource = withParticipantSource(ParticipantSource.RTMP, ParticipantSource.SRT, ParticipantSource.WHIP, ParticipantSource.RTSP);
4710
4730
  /**
4711
4731
  * The default sorting preset.
4712
4732
  */
@@ -4714,16 +4734,16 @@ const defaultSortPreset = combineComparators(screenSharing, pinned, ifInvisibleB
4714
4734
  /**
4715
4735
  * The sorting preset for speaker layout.
4716
4736
  */
4717
- const speakerLayoutSortPreset = combineComparators(screenSharing, pinned, dominantSpeaker, ifInvisibleBy(combineComparators(speaking, reactionType('raised-hand'), publishingVideo, publishingAudio)));
4737
+ const speakerLayoutSortPreset = combineComparators(screenSharing, pinned, dominantSpeaker, ifInvisibleBy(combineComparators(speaking, reactionType('raised-hand'), withVideoIngressSource, publishingVideo, publishingAudio)));
4718
4738
  /**
4719
4739
  * The sorting preset for layouts that don't render all participants but
4720
4740
  * instead, render them in pages.
4721
4741
  */
4722
- const paginatedLayoutSortPreset = combineComparators(pinned, ifInvisibleOrUnknownBy(combineComparators(dominantSpeaker, speaking, reactionType('raised-hand'), publishingVideo, publishingAudio)));
4742
+ const paginatedLayoutSortPreset = combineComparators(pinned, ifInvisibleOrUnknownBy(combineComparators(dominantSpeaker, speaking, reactionType('raised-hand'), withVideoIngressSource, publishingVideo, publishingAudio)));
4723
4743
  /**
4724
4744
  * The sorting preset for livestreams and audio rooms.
4725
4745
  */
4726
- const livestreamOrAudioRoomSortPreset = combineComparators(ifInvisibleBy(combineComparators(dominantSpeaker, speaking, reactionType('raised-hand'), withParticipantSource(ParticipantSource.RTMP), publishingVideo, publishingAudio)), role('admin', 'host', 'speaker'));
4746
+ const livestreamOrAudioRoomSortPreset = combineComparators(ifInvisibleBy(combineComparators(dominantSpeaker, speaking, reactionType('raised-hand'), withVideoIngressSource, publishingVideo, publishingAudio)), role('admin', 'host', 'speaker'));
4727
4747
 
4728
4748
  /**
4729
4749
  * Returns the default egress object - when no egress data is available.
@@ -5835,7 +5855,7 @@ const getSdkVersion = (sdk) => {
5835
5855
  return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
5836
5856
  };
5837
5857
 
5838
- const version = "1.33.0";
5858
+ const version = "1.33.1";
5839
5859
  const [major, minor, patch] = version.split('.');
5840
5860
  let sdkInfo = {
5841
5861
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -14778,7 +14798,7 @@ class StreamClient {
14778
14798
  this.getUserAgent = () => {
14779
14799
  if (!this.cachedUserAgent) {
14780
14800
  const { clientAppIdentifier = {} } = this.options;
14781
- const { sdkName = 'js', sdkVersion = "1.33.0", ...extras } = clientAppIdentifier;
14801
+ const { sdkName = 'js', sdkVersion = "1.33.1", ...extras } = clientAppIdentifier;
14782
14802
  this.cachedUserAgent = [
14783
14803
  `stream-video-${sdkName}-v${sdkVersion}`,
14784
14804
  ...Object.entries(extras).map(([key, value]) => `${key}=${value}`),