@whereby.com/browser-sdk 2.0.0 → 2.1.0-beta1

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.
@@ -1,4 +1,6 @@
1
- interface WherebyEmbedAttributes {
1
+ import { ReactHTMLElement } from 'react';
2
+
3
+ interface WherebyEmbedElementAttributes extends ReactHTMLElement<HTMLElement> {
2
4
  audio: string;
3
5
  avatarUrl: string;
4
6
  background: string;
@@ -35,10 +37,68 @@ interface WherebyEmbedAttributes {
35
37
  video: string;
36
38
  virtualBackgroundUrl: string;
37
39
  }
40
+ interface WherebyEmbedElementEventMap {
41
+ ready: CustomEvent;
42
+ knock: CustomEvent;
43
+ participantupdate: CustomEvent<{
44
+ count: number;
45
+ }>;
46
+ join: CustomEvent;
47
+ leave: CustomEvent<{
48
+ removed: boolean;
49
+ }>;
50
+ participant_join: CustomEvent<{
51
+ participant: {
52
+ metadata: string;
53
+ };
54
+ }>;
55
+ participant_leave: CustomEvent<{
56
+ participant: {
57
+ metadata: string;
58
+ };
59
+ }>;
60
+ microphone_toggle: CustomEvent<{
61
+ enabled: boolean;
62
+ }>;
63
+ camera_toggle: CustomEvent<{
64
+ enabled: boolean;
65
+ }>;
66
+ chat_toggle: CustomEvent<{
67
+ open: boolean;
68
+ }>;
69
+ pip_toggle: CustomEvent<{
70
+ open: boolean;
71
+ }>;
72
+ deny_device_permission: CustomEvent<{
73
+ denied: boolean;
74
+ }>;
75
+ screenshare_toggle: CustomEvent<{
76
+ enabled: boolean;
77
+ }>;
78
+ streaming_status_change: CustomEvent<{
79
+ status: string;
80
+ }>;
81
+ connection_status_change: CustomEvent<{
82
+ status: "stable" | "unstable";
83
+ }>;
84
+ }
85
+ interface WherebyEmbedElementCommands {
86
+ startRecording: () => void;
87
+ stopRecording: () => void;
88
+ startStreaming: () => void;
89
+ stopStreaming: () => void;
90
+ toggleCamera: (enabled?: boolean) => void;
91
+ toggleMicrophone: (enabled?: boolean) => void;
92
+ toggleScreenshare: (enabled?: boolean) => void;
93
+ toogleChat: (enabled?: boolean) => void;
94
+ }
95
+ interface WherebyEmbedElement extends HTMLIFrameElement, WherebyEmbedElementCommands {
96
+ addEventListener<K extends keyof (WherebyEmbedElementEventMap & HTMLElementEventMap)>(type: K, listener: (this: HTMLIFrameElement, ev: (WherebyEmbedElementEventMap & HTMLElementEventMap)[K]) => void, options?: boolean | AddEventListenerOptions | undefined): void;
97
+ }
38
98
  declare global {
39
99
  namespace JSX {
40
100
  interface IntrinsicElements {
41
- ["whereby-embed"]: Partial<WherebyEmbedAttributes>;
101
+ ["whereby-embed"]: Partial<WherebyEmbedElementAttributes>;
42
102
  }
43
103
  }
44
104
  }
@@ -46,4 +106,4 @@ declare const _default: {
46
106
  sdkVersion: string;
47
107
  };
48
108
 
49
- export { _default as default };
109
+ export { type WherebyEmbedElement, _default as default };
@@ -20,7 +20,7 @@ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
20
20
  };
21
21
  }
22
22
 
23
- const sdkVersion = "2.0.0";
23
+ const sdkVersion = "2.1.0-beta1";
24
24
 
25
25
  const boolAttrs = [
26
26
  "audio",
@@ -119,7 +119,7 @@ define("WherebyEmbed", {
119
119
  toggleChat(enabled) {
120
120
  this._postCommand("toggle_chat", [enabled]);
121
121
  },
122
- onmessage({ origin, data }) {
122
+ onmessage({ origin, data, }) {
123
123
  if (!this.roomUrl || origin !== this.roomUrl.origin)
124
124
  return;
125
125
  const { type, payload: detail } = data;
@@ -147,7 +147,7 @@ define("WherebyEmbed", {
147
147
  title=${title || "Video calling component"}
148
148
  ref=${this.iframe}
149
149
  src=${this.roomUrl}
150
- allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
150
+ allow="autoplay; camera; microphone; fullscreen; speaker; display-capture; media-capture" />
151
151
  `;
152
152
  },
153
153
  });
@@ -1,5 +1,4 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
1
+ import * as React$1 from 'react';
3
2
  import _whereby_jslib_media_src_utils_ServerSocket, { ChatMessage as ChatMessage$2 } from '@whereby/jslib-media/src/utils/ServerSocket';
4
3
  import * as redux_thunk from 'redux-thunk';
5
4
  import { AxiosRequestConfig } from 'axios';
@@ -13,15 +12,18 @@ interface VideoViewSelfProps {
13
12
  stream: MediaStream;
14
13
  muted?: boolean;
15
14
  mirror?: boolean;
16
- style?: React__default.CSSProperties;
15
+ style?: React$1.CSSProperties;
17
16
  onResize?: ({ width, height, stream }: {
18
17
  width: number;
19
18
  height: number;
20
19
  stream: MediaStream;
21
20
  }) => void;
21
+ onSetAspectRatio?: ({ aspectRatio }: {
22
+ aspectRatio: number;
23
+ }) => void;
22
24
  }
23
- type VideoViewProps = VideoViewSelfProps & React__default.DetailedHTMLProps<React__default.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
24
- declare const _default: ({ muted, mirror, stream, onResize, ...rest }: VideoViewProps) => React__default.JSX.Element;
25
+ type VideoViewProps = VideoViewSelfProps & React$1.DetailedHTMLProps<React$1.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
26
+ declare const _default: ({ muted, mirror, stream, onResize, onSetAspectRatio, ...rest }: VideoViewProps) => React$1.JSX.Element;
25
27
 
26
28
  interface RoomParticipantData {
27
29
  displayName: string;
@@ -813,7 +815,6 @@ interface RoomConnectionActions {
813
815
  stopCloudRecording(): void;
814
816
  stopScreenshare(): void;
815
817
  }
816
-
817
818
  type VideoViewComponentProps = Omit<React.ComponentProps<typeof _default>, "onResize">;
818
819
  interface RoomConnectionComponents {
819
820
  VideoView: (props: VideoViewComponentProps) => ReturnType<typeof _default>;
@@ -824,6 +825,7 @@ type RoomConnectionRef = {
824
825
  components: RoomConnectionComponents;
825
826
  _ref: Store;
826
827
  };
828
+
827
829
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
828
830
 
829
831
  declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): UseLocalMediaResult;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useRef, useEffect, useState, useCallback } from 'react';
2
+ import { useState, useEffect, useCallback } from 'react';
3
3
  import { createListenerMiddleware, createSlice, createAsyncThunk, createAction, createSelector, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
4
4
  import { io } from 'socket.io-client';
5
5
  import adapter from 'webrtc-adapter';
@@ -85,19 +85,26 @@ function debounce(fn, { delay = 500, edges } = {}) {
85
85
  }
86
86
 
87
87
  var VideoView = (_a) => {
88
- var { muted, mirror = false, stream, onResize } = _a, rest = __rest(_a, ["muted", "mirror", "stream", "onResize"]);
89
- const videoEl = useRef(null);
90
- useEffect(() => {
91
- if (!videoEl.current || !onResize) {
88
+ var { muted, mirror = false, stream, onResize, onSetAspectRatio } = _a, rest = __rest(_a, ["muted", "mirror", "stream", "onResize", "onSetAspectRatio"]);
89
+ const videoEl = React.useRef(null);
90
+ React.useEffect(() => {
91
+ if (!videoEl.current) {
92
92
  return;
93
93
  }
94
94
  const resizeObserver = new ResizeObserver(debounce(() => {
95
95
  if (videoEl.current && (stream === null || stream === void 0 ? void 0 : stream.id)) {
96
- onResize({
97
- width: videoEl.current.clientWidth,
98
- height: videoEl.current.clientHeight,
99
- stream,
100
- });
96
+ if (onResize) {
97
+ onResize({
98
+ width: videoEl.current.clientWidth,
99
+ height: videoEl.current.clientHeight,
100
+ stream,
101
+ });
102
+ }
103
+ const h = videoEl.current.videoHeight;
104
+ const w = videoEl.current.videoWidth;
105
+ if (w && h && w + h > 20 && onSetAspectRatio) {
106
+ onSetAspectRatio({ aspectRatio: w / h });
107
+ }
101
108
  }
102
109
  }, { delay: 1000, edges: true }));
103
110
  resizeObserver.observe(videoEl.current);
@@ -105,7 +112,7 @@ var VideoView = (_a) => {
105
112
  resizeObserver.disconnect();
106
113
  };
107
114
  }, [stream]);
108
- useEffect(() => {
115
+ React.useEffect(() => {
109
116
  if (!videoEl.current) {
110
117
  return;
111
118
  }
@@ -118,7 +125,7 @@ var VideoView = (_a) => {
118
125
  videoEl.current.muted = Boolean(muted);
119
126
  }
120
127
  }, [muted, stream, videoEl]);
121
- return (React__default.createElement("video", Object.assign({ ref: videoEl, autoPlay: true, playsInline: true }, rest, { style: Object.assign({ transform: mirror ? "scaleX(-1)" : "none", width: "100%", height: "100%" }, rest.style) })));
128
+ return (React.createElement("video", Object.assign({ ref: videoEl, autoPlay: true, playsInline: true }, rest, { style: Object.assign({ transform: mirror ? "scaleX(-1)" : "none", width: "100%", height: "100%" }, rest.style) })));
122
129
  };
123
130
 
124
131
  const listenerMiddleware = createListenerMiddleware();
@@ -1434,7 +1441,7 @@ const doStartLocalMedia = createAppAsyncThunk("localMedia/doStartLocalMedia", (p
1434
1441
  const onDeviceChange = debounce(() => {
1435
1442
  dispatch(doUpdateDeviceList());
1436
1443
  }, { delay: 500 });
1437
- if (global.navigator.mediaDevices) {
1444
+ if (navigator.mediaDevices) {
1438
1445
  navigator.mediaDevices.addEventListener("devicechange", onDeviceChange);
1439
1446
  }
1440
1447
  // Resolve if existing stream is passed
@@ -1466,7 +1473,7 @@ const doStopLocalMedia = createAppThunk(() => (dispatch, getState) => {
1466
1473
  stream === null || stream === void 0 ? void 0 : stream.getTracks().forEach((track) => {
1467
1474
  track.stop();
1468
1475
  });
1469
- if (global.navigator.mediaDevices && onDeviceChange) {
1476
+ if (navigator.mediaDevices && onDeviceChange) {
1470
1477
  navigator.mediaDevices.removeEventListener("devicechange", onDeviceChange);
1471
1478
  }
1472
1479
  dispatch(localMediaStopped());
@@ -7586,7 +7593,7 @@ const doRejectWaitingParticipant = createAppThunk((payload) => (dispatch, getSta
7586
7593
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
7587
7594
 
7588
7595
  var _a;
7589
- const IS_DEV = (_a = process.env.REACT_APP_IS_DEV === "true") !== null && _a !== void 0 ? _a : false;
7596
+ const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
7590
7597
  const rootReducer = combineReducers({
7591
7598
  app: appSlice.reducer,
7592
7599
  chat: chatSlice.reducer,
@@ -8683,7 +8690,7 @@ const selectRoomConnectionState = createSelector(selectChatMessages, selectCloud
8683
8690
  return state;
8684
8691
  });
8685
8692
 
8686
- const sdkVersion = "2.0.0";
8693
+ const sdkVersion = "2.1.0-beta1";
8687
8694
 
8688
8695
  const initialState$1 = {
8689
8696
  chatMessages: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whereby.com/browser-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-beta1",
4
4
  "description": "Modules for integration Whereby video in web apps",
5
5
  "author": "Whereby AS",
6
6
  "license": "MIT",
@@ -96,6 +96,7 @@
96
96
  "rimraf": "^3.0.2",
97
97
  "rollup": "^4.3.0",
98
98
  "rollup-plugin-dts": "^6.1.0",
99
+ "rollup-plugin-polyfill-node": "^0.13.0",
99
100
  "rollup-plugin-terser": "^7.0.2",
100
101
  "rollup-plugin-typescript2": "^0.36.0",
101
102
  "storybook": "^7.5.2",