@whereby.com/browser-sdk 2.0.0-alpha2 → 2.0.0-alpha4

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/lib.cjs.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var heresy = require('heresy');
6
- var React = require('react');
7
6
  var tslib = require('tslib');
7
+ var React = require('react');
8
8
  var adapter = require('webrtc-adapter');
9
9
  var io = require('socket.io-client');
10
10
  var SDPUtils = require('sdp');
@@ -130,7 +130,7 @@ heresy.define("WherebyEmbed", {
130
130
  if (!subdomain)
131
131
  return this.html `Whereby: Missing subdomain attr.`;
132
132
  const url = new URL(room, `https://${subdomain}.whereby.com`);
133
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha2", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
133
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha4", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
134
134
  // add to URL if set in any way
135
135
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
136
136
  if (!url.searchParams.has(k) && typeof v === "string") {
@@ -146,13 +146,23 @@ heresy.define("WherebyEmbed", {
146
146
  },
147
147
  });
148
148
 
149
- var VideoElement = ({ stream, style }) => {
150
- const videoEl = React.useCallback((node) => {
151
- if (node !== null && node.srcObject !== stream) {
152
- node.srcObject = stream;
149
+ var VideoView = (_a) => {
150
+ var { muted, stream } = _a, rest = tslib.__rest(_a, ["muted", "stream"]);
151
+ const videoEl = React.useRef(null);
152
+ React.useEffect(() => {
153
+ if (!videoEl.current) {
154
+ return;
155
+ }
156
+ if (videoEl.current.srcObject !== stream) {
157
+ videoEl.current.srcObject = stream;
158
+ }
159
+ // Handle muting programatically, not as video attribute
160
+ // https://stackoverflow.com/questions/14111917/html5-video-muted-but-still-playing
161
+ if (videoEl.current.muted !== muted) {
162
+ videoEl.current.muted = Boolean(muted);
153
163
  }
154
- }, []);
155
- return React__default["default"].createElement("video", { ref: videoEl, autoPlay: true, playsInline: true, style: style });
164
+ }, [muted, stream, videoEl]);
165
+ return React__default["default"].createElement("video", Object.assign({ ref: videoEl, autoPlay: true, playsInline: true }, rest));
156
166
  };
157
167
 
158
168
  const EVENTS = {
@@ -5456,12 +5466,12 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
5456
5466
  },
5457
5467
  },
5458
5468
  {
5459
- VideoView: VideoElement,
5469
+ VideoView,
5460
5470
  },
5461
5471
  ];
5462
5472
  }
5463
5473
 
5464
- const sdkVersion = "2.0.0-alpha2";
5474
+ const sdkVersion = "2.0.0-alpha4";
5465
5475
 
5466
5476
  exports.sdkVersion = sdkVersion;
5467
5477
  exports.useRoomConnection = useRoomConnection;
package/dist/lib.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { define, ref } from 'heresy';
2
- import React, { useCallback, useState, useReducer, useEffect } from 'react';
3
- import { __awaiter } from 'tslib';
2
+ import { __rest, __awaiter } from 'tslib';
3
+ import React, { useRef, useEffect, useState, useReducer } from 'react';
4
4
  import adapter from 'webrtc-adapter';
5
5
  import io from 'socket.io-client';
6
6
  import SDPUtils from 'sdp';
@@ -115,7 +115,7 @@ define("WherebyEmbed", {
115
115
  if (!subdomain)
116
116
  return this.html `Whereby: Missing subdomain attr.`;
117
117
  const url = new URL(room, `https://${subdomain}.whereby.com`);
118
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha2", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
118
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha4", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
119
119
  // add to URL if set in any way
120
120
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
121
121
  if (!url.searchParams.has(k) && typeof v === "string") {
@@ -131,13 +131,23 @@ define("WherebyEmbed", {
131
131
  },
132
132
  });
133
133
 
134
- var VideoElement = ({ stream, style }) => {
135
- const videoEl = useCallback((node) => {
136
- if (node !== null && node.srcObject !== stream) {
137
- node.srcObject = stream;
134
+ var VideoView = (_a) => {
135
+ var { muted, stream } = _a, rest = __rest(_a, ["muted", "stream"]);
136
+ const videoEl = useRef(null);
137
+ useEffect(() => {
138
+ if (!videoEl.current) {
139
+ return;
140
+ }
141
+ if (videoEl.current.srcObject !== stream) {
142
+ videoEl.current.srcObject = stream;
143
+ }
144
+ // Handle muting programatically, not as video attribute
145
+ // https://stackoverflow.com/questions/14111917/html5-video-muted-but-still-playing
146
+ if (videoEl.current.muted !== muted) {
147
+ videoEl.current.muted = Boolean(muted);
138
148
  }
139
- }, []);
140
- return React.createElement("video", { ref: videoEl, autoPlay: true, playsInline: true, style: style });
149
+ }, [muted, stream, videoEl]);
150
+ return React.createElement("video", Object.assign({ ref: videoEl, autoPlay: true, playsInline: true }, rest));
141
151
  };
142
152
 
143
153
  const EVENTS = {
@@ -5441,11 +5451,11 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
5441
5451
  },
5442
5452
  },
5443
5453
  {
5444
- VideoView: VideoElement,
5454
+ VideoView,
5445
5455
  },
5446
5456
  ];
5447
5457
  }
5448
5458
 
5449
- const sdkVersion = "2.0.0-alpha2";
5459
+ const sdkVersion = "2.0.0-alpha4";
5450
5460
 
5451
5461
  export { sdkVersion, useRoomConnection };
package/dist/types.d.ts CHANGED
@@ -31,11 +31,12 @@ declare global {
31
31
  }
32
32
  }
33
33
 
34
- interface VideoElProps {
34
+ interface VideoViewSelfProps {
35
35
  stream: MediaStream;
36
36
  style?: React.CSSProperties;
37
37
  }
38
- declare const _default: ({ stream, style }: VideoElProps) => JSX.Element;
38
+ type VideoViewProps = VideoViewSelfProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
39
+ declare const _default: ({ muted, stream, ...rest }: VideoViewProps) => JSX.Element;
39
40
 
40
41
  interface RoomParticipantData {
41
42
  displayName: string;
@@ -99,6 +100,6 @@ interface RoomConnectionComponents {
99
100
  }
100
101
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions: RoomConnectionOptions): [state: RoomState, actions: RoomConnectionActions, components: RoomConnectionComponents];
101
102
 
102
- declare const sdkVersion = "2.0.0-alpha2";
103
+ declare const sdkVersion = "2.0.0-alpha4";
103
104
 
104
105
  export { sdkVersion, useRoomConnection };