@stream-io/video-client 0.3.20 → 0.3.21

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
@@ -9477,9 +9477,23 @@ class DynascaleManager {
9477
9477
  if (!boundParticipant)
9478
9478
  return;
9479
9479
  const requestTrackWithDimensions = (debounceType, dimension) => {
9480
+ if (dimension && (dimension.width === 0 || dimension.height === 0)) {
9481
+ // ignore 0x0 dimensions. this can happen when the video element
9482
+ // is not visible (e.g., has display: none).
9483
+ // we treat this as "unsubscription" as we don't want to keep
9484
+ // consuming bandwidth for a video that is not visible on the screen.
9485
+ this.logger('debug', `Ignoring 0x0 dimension`, boundParticipant);
9486
+ dimension = undefined;
9487
+ }
9480
9488
  this.call.updateSubscriptionsPartial(trackType, { [sessionId]: { dimension } }, debounceType);
9481
9489
  };
9482
9490
  const participant$ = this.call.state.participants$.pipe(rxjs.map((participants) => participants.find((participant) => participant.sessionId === sessionId)), rxjs.takeWhile((participant) => !!participant), rxjs.distinctUntilChanged(), rxjs.shareReplay(1));
9491
+ /**
9492
+ * Since the video elements are now being removed from the DOM (React SDK) upon
9493
+ * visibility change, this subscription is not in use an stays here only for the
9494
+ * plain JS integrations where integrators might choose not to remove the video
9495
+ * elements from the DOM.
9496
+ */
9483
9497
  // keep copy for resize observer handler
9484
9498
  let viewportVisibilityState;
9485
9499
  const viewportVisibilityStateSubscription = boundParticipant.isLocalParticipant
@@ -9524,6 +9538,8 @@ class DynascaleManager {
9524
9538
  lastDimensions = currentDimensions;
9525
9539
  });
9526
9540
  resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(videoElement);
9541
+ // element renders and gets bound - track subscription gets
9542
+ // triggered first other ones get skipped on initial subscriptions
9527
9543
  const publishedTracksSubscription = boundParticipant.isLocalParticipant
9528
9544
  ? null
9529
9545
  : participant$
@@ -9533,14 +9549,14 @@ class DynascaleManager {
9533
9549
  .subscribe((isPublishing) => {
9534
9550
  if (isPublishing) {
9535
9551
  // the participant just started to publish a track
9536
- requestTrackWithDimensions(exports.DebounceType.IMMEDIATE, {
9552
+ requestTrackWithDimensions(exports.DebounceType.FAST, {
9537
9553
  width: videoElement.clientWidth,
9538
9554
  height: videoElement.clientHeight,
9539
9555
  });
9540
9556
  }
9541
9557
  else {
9542
9558
  // the participant just stopped publishing a track
9543
- requestTrackWithDimensions(exports.DebounceType.IMMEDIATE, undefined);
9559
+ requestTrackWithDimensions(exports.DebounceType.FAST, undefined);
9544
9560
  }
9545
9561
  });
9546
9562
  const streamSubscription = participant$
@@ -9565,7 +9581,7 @@ class DynascaleManager {
9565
9581
  // https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
9566
9582
  videoElement.muted = true;
9567
9583
  return () => {
9568
- requestTrackWithDimensions(exports.DebounceType.IMMEDIATE, undefined);
9584
+ requestTrackWithDimensions(exports.DebounceType.FAST, undefined);
9569
9585
  viewportVisibilityStateSubscription === null || viewportVisibilityStateSubscription === void 0 ? void 0 : viewportVisibilityStateSubscription.unsubscribe();
9570
9586
  publishedTracksSubscription === null || publishedTracksSubscription === void 0 ? void 0 : publishedTracksSubscription.unsubscribe();
9571
9587
  streamSubscription.unsubscribe();
@@ -13132,7 +13148,7 @@ class WSConnectionFallback {
13132
13148
  }
13133
13149
  }
13134
13150
 
13135
- const version = '0.3.20';
13151
+ const version = '0.3.21';
13136
13152
 
13137
13153
  const logger = getLogger(['location']);
13138
13154
  const HINT_URL = `https://hint.stream-io-video.com/`;