@whereby.com/browser-sdk 2.1.0-beta3 → 2.1.0

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,83 +1,83 @@
1
1
  import { define, ref } from 'heresy';
2
2
 
3
- function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
4
- if (!roomAttribute) {
5
- throw new Error("Missing room attribute");
6
- }
7
- // Get subdomain from room URL, or use it specified
8
- const m = /https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(roomAttribute);
9
- const subdomain = (m && m[1]) || subdomainAttribute;
10
- if (!subdomain) {
11
- throw new Error("Missing subdomain attribute");
12
- }
13
- if (!m) {
14
- throw new Error("Could not parse room URL");
15
- }
16
- const roomUrl = new URL(roomAttribute);
17
- return {
18
- subdomain,
19
- roomUrl,
20
- };
3
+ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
4
+ if (!roomAttribute) {
5
+ throw new Error("Missing room attribute");
6
+ }
7
+ // Get subdomain from room URL, or use it specified
8
+ const m = /https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(roomAttribute);
9
+ const subdomain = (m && m[1]) || subdomainAttribute;
10
+ if (!subdomain) {
11
+ throw new Error("Missing subdomain attribute");
12
+ }
13
+ if (!m) {
14
+ throw new Error("Could not parse room URL");
15
+ }
16
+ const roomUrl = new URL(roomAttribute);
17
+ return {
18
+ subdomain,
19
+ roomUrl,
20
+ };
21
21
  }
22
22
 
23
- const sdkVersion = "2.1.0-beta3";
23
+ const sdkVersion = "2.1.0";
24
24
 
25
- const boolAttrs = [
26
- "audio",
27
- "background",
28
- "cameraAccess",
29
- "chat",
30
- "people",
31
- "embed",
32
- "emptyRoomInvitation",
33
- "help",
34
- "leaveButton",
35
- "precallReview",
36
- "screenshare",
37
- "video",
38
- "floatSelf",
39
- "recording",
40
- "logo",
41
- "locking",
42
- "participantCount",
43
- "settingsButton",
44
- "pipButton",
45
- "moreButton",
46
- "personality",
47
- "subgridLabels",
48
- "lowData",
49
- "breakout",
50
- ];
51
- define("WherebyEmbed", {
52
- oninit() {
53
- this.iframe = ref();
54
- },
55
- onconnected() {
56
- window.addEventListener("message", this.onmessage.bind(this));
57
- },
58
- ondisconnected() {
59
- window.removeEventListener("message", this.onmessage.bind(this));
60
- },
61
- observedAttributes: [
62
- "displayName",
63
- "minimal",
64
- "room",
65
- "subdomain",
66
- "lang",
67
- "metadata",
68
- "groups",
69
- "virtualBackgroundUrl",
70
- "avatarUrl",
71
- "externalId",
72
- "title",
73
- ...boolAttrs,
74
- ].map((a) => a.toLowerCase()),
75
- onattributechanged({ attributeName, oldValue }) {
76
- if (["room", "subdomain"].includes(attributeName) && oldValue == null)
77
- return;
78
- this.render();
79
- },
80
- style(self) {
25
+ const boolAttrs = [
26
+ "audio",
27
+ "background",
28
+ "cameraAccess",
29
+ "chat",
30
+ "people",
31
+ "embed",
32
+ "emptyRoomInvitation",
33
+ "help",
34
+ "leaveButton",
35
+ "precallReview",
36
+ "screenshare",
37
+ "video",
38
+ "floatSelf",
39
+ "recording",
40
+ "logo",
41
+ "locking",
42
+ "participantCount",
43
+ "settingsButton",
44
+ "pipButton",
45
+ "moreButton",
46
+ "personality",
47
+ "subgridLabels",
48
+ "lowData",
49
+ "breakout",
50
+ ];
51
+ define("WherebyEmbed", {
52
+ oninit() {
53
+ this.iframe = ref();
54
+ },
55
+ onconnected() {
56
+ window.addEventListener("message", this.onmessage.bind(this));
57
+ },
58
+ ondisconnected() {
59
+ window.removeEventListener("message", this.onmessage.bind(this));
60
+ },
61
+ observedAttributes: [
62
+ "displayName",
63
+ "minimal",
64
+ "room",
65
+ "subdomain",
66
+ "lang",
67
+ "metadata",
68
+ "groups",
69
+ "virtualBackgroundUrl",
70
+ "avatarUrl",
71
+ "externalId",
72
+ "title",
73
+ ...boolAttrs,
74
+ ].map((a) => a.toLowerCase()),
75
+ onattributechanged({ attributeName, oldValue }) {
76
+ if (["room", "subdomain"].includes(attributeName) && oldValue == null)
77
+ return;
78
+ this.render();
79
+ },
80
+ style(self) {
81
81
  return `
82
82
  ${self} {
83
83
  display: block;
@@ -87,70 +87,70 @@ define("WherebyEmbed", {
87
87
  height: 100%;
88
88
  width: 100%;
89
89
  }
90
- `;
91
- },
92
- // Commands
93
- _postCommand(command, args = []) {
94
- if (this.iframe.current) {
95
- this.iframe.current.contentWindow.postMessage({ command, args }, this.roomUrl.origin);
96
- }
97
- },
98
- startRecording() {
99
- this._postCommand("start_recording");
100
- },
101
- stopRecording() {
102
- this._postCommand("stop_recording");
103
- },
104
- startStreaming() {
105
- this._postCommand("start_streaming");
106
- },
107
- stopStreaming() {
108
- this._postCommand("stop_streaming");
109
- },
110
- toggleCamera(enabled) {
111
- this._postCommand("toggle_camera", [enabled]);
112
- },
113
- toggleMicrophone(enabled) {
114
- this._postCommand("toggle_microphone", [enabled]);
115
- },
116
- toggleScreenshare(enabled) {
117
- this._postCommand("toggle_screenshare", [enabled]);
118
- },
119
- toggleChat(enabled) {
120
- this._postCommand("toggle_chat", [enabled]);
121
- },
122
- onmessage({ origin, data, }) {
123
- if (!this.roomUrl || origin !== this.roomUrl.origin)
124
- return;
125
- const { type, payload: detail } = data;
126
- this.dispatchEvent(new CustomEvent(type, { detail }));
127
- },
128
- render() {
129
- const { avatarurl: avatarUrl, displayname: displayName, lang, metadata, externalid: externalId, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, title, } = this;
130
- let roomUrl, subdomain;
131
- try {
132
- ({ roomUrl, subdomain } = parseRoomUrlAndSubdomain(room, this.subdomain));
133
- }
134
- catch (error) {
135
- return this.html `Whereby: ${error instanceof Error ? error.message : "unknown error"}`;
136
- }
137
- this.roomUrl = roomUrl;
138
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: sdkVersion, iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang: lang })), (metadata && { metadata: metadata })), (externalId && { externalId })), (groups && { groups: groups })), (virtualBackgroundUrl && { virtualBackgroundUrl: virtualBackgroundUrl })), (avatarUrl && { avatarUrl: avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
139
- // add to URL if set in any way
140
- (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
141
- if (!this.roomUrl.searchParams.has(k)) {
142
- this.roomUrl.searchParams.set(k, v);
143
- }
144
- });
90
+ `;
91
+ },
92
+ // Commands
93
+ _postCommand(command, args = []) {
94
+ if (this.iframe.current) {
95
+ this.iframe.current.contentWindow.postMessage({ command, args }, this.roomUrl.origin);
96
+ }
97
+ },
98
+ startRecording() {
99
+ this._postCommand("start_recording");
100
+ },
101
+ stopRecording() {
102
+ this._postCommand("stop_recording");
103
+ },
104
+ startStreaming() {
105
+ this._postCommand("start_streaming");
106
+ },
107
+ stopStreaming() {
108
+ this._postCommand("stop_streaming");
109
+ },
110
+ toggleCamera(enabled) {
111
+ this._postCommand("toggle_camera", [enabled]);
112
+ },
113
+ toggleMicrophone(enabled) {
114
+ this._postCommand("toggle_microphone", [enabled]);
115
+ },
116
+ toggleScreenshare(enabled) {
117
+ this._postCommand("toggle_screenshare", [enabled]);
118
+ },
119
+ toggleChat(enabled) {
120
+ this._postCommand("toggle_chat", [enabled]);
121
+ },
122
+ onmessage({ origin, data, }) {
123
+ if (!this.roomUrl || origin !== this.roomUrl.origin)
124
+ return;
125
+ const { type, payload: detail } = data;
126
+ this.dispatchEvent(new CustomEvent(type, { detail }));
127
+ },
128
+ render() {
129
+ const { avatarurl: avatarUrl, displayname: displayName, lang, metadata, externalid: externalId, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, title, } = this;
130
+ let roomUrl, subdomain;
131
+ try {
132
+ ({ roomUrl, subdomain } = parseRoomUrlAndSubdomain(room, this.subdomain));
133
+ }
134
+ catch (error) {
135
+ return this.html `Whereby: ${error instanceof Error ? error.message : "unknown error"}`;
136
+ }
137
+ this.roomUrl = roomUrl;
138
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: sdkVersion, iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang: lang })), (metadata && { metadata: metadata })), (externalId && { externalId })), (groups && { groups: groups })), (virtualBackgroundUrl && { virtualBackgroundUrl: virtualBackgroundUrl })), (avatarUrl && { avatarUrl: avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
139
+ // add to URL if set in any way
140
+ (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
141
+ if (!this.roomUrl.searchParams.has(k)) {
142
+ this.roomUrl.searchParams.set(k, v);
143
+ }
144
+ });
145
145
  this.html `
146
146
  <iframe
147
147
  title=${title || "Video calling component"}
148
148
  ref=${this.iframe}
149
149
  src=${this.roomUrl}
150
150
  allow="autoplay; camera; microphone; fullscreen; speaker; display-capture; media-capture" />
151
- `;
152
- },
153
- });
151
+ `;
152
+ },
153
+ });
154
154
  var index = { sdkVersion: sdkVersion };
155
155
 
156
156
  export { index as default };
@@ -1,4 +1,5 @@
1
- import * as React$1 from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
2
3
  import _whereby_jslib_media_src_utils_ServerSocket, { ChatMessage as ChatMessage$2 } from '@whereby/jslib-media/src/utils/ServerSocket';
3
4
  import * as redux_thunk from 'redux-thunk';
4
5
  import { AxiosRequestConfig } from 'axios';
@@ -12,18 +13,15 @@ interface VideoViewSelfProps {
12
13
  stream: MediaStream;
13
14
  muted?: boolean;
14
15
  mirror?: boolean;
15
- style?: React$1.CSSProperties;
16
+ style?: React__default.CSSProperties;
16
17
  onResize?: ({ width, height, stream }: {
17
18
  width: number;
18
19
  height: number;
19
20
  stream: MediaStream;
20
21
  }) => void;
21
- onSetAspectRatio?: ({ aspectRatio }: {
22
- aspectRatio: number;
23
- }) => void;
24
22
  }
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;
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;
27
25
 
28
26
  interface RoomParticipantData {
29
27
  displayName: string;
@@ -555,7 +553,6 @@ interface AppState {
555
553
  displayName: string | null;
556
554
  sdkVersion: string | null;
557
555
  externalId: string | null;
558
- isNodeSdk: boolean;
559
556
  }
560
557
 
561
558
  /**
@@ -694,7 +691,7 @@ declare const createStore: ({ preloadedState, injectServices, }: {
694
691
  fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
695
692
  };
696
693
  }, redux.UnknownAction>;
697
- }, {}>, redux.StoreEnhancer<{}, {}>]>>;
694
+ }>, redux.StoreEnhancer]>>;
698
695
  type Store = ReturnType<typeof createStore>;
699
696
 
700
697
  /**
@@ -705,7 +702,6 @@ interface WaitingParticipantsState {
705
702
  }
706
703
 
707
704
  type LocalMediaOptions = {
708
- disabled?: boolean;
709
705
  audio: boolean;
710
706
  video: boolean;
711
707
  };
@@ -817,6 +813,7 @@ interface RoomConnectionActions {
817
813
  stopCloudRecording(): void;
818
814
  stopScreenshare(): void;
819
815
  }
816
+
820
817
  type VideoViewComponentProps = Omit<React.ComponentProps<typeof _default>, "onResize">;
821
818
  interface RoomConnectionComponents {
822
819
  VideoView: (props: VideoViewComponentProps) => ReturnType<typeof _default>;
@@ -827,34 +824,10 @@ type RoomConnectionRef = {
827
824
  components: RoomConnectionComponents;
828
825
  _ref: Store;
829
826
  };
830
-
831
827
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
832
828
 
833
829
  declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): UseLocalMediaResult;
834
830
 
835
- type Origin = {
836
- top: number;
837
- left: number;
838
- };
839
- type Bounds = {
840
- width: number;
841
- height: number;
842
- };
843
-
844
- interface GridProps {
845
- roomConnection: RoomConnectionRef;
846
- renderParticipant?: ({ cell, participant, }: {
847
- cell: {
848
- clientId: string;
849
- bounds: Bounds;
850
- origin: Origin;
851
- };
852
- participant: RemoteParticipantState | LocalParticipantState;
853
- }) => React$1.ReactNode;
854
- videoGridGap?: number;
855
- }
856
- declare function Grid({ roomConnection, renderParticipant, videoGridGap }: GridProps): React$1.JSX.Element;
857
-
858
831
  declare const sdkVersion = "__SDK_VERSION__";
859
832
 
860
- export { type ChatMessageState as ChatMessage, type LocalParticipantState as LocalParticipant, type RemoteParticipantState as RemoteParticipant, type RoomConnectionState as RoomConnection, type ScreenshareState as Screenshare, type UseLocalMediaResult, Grid as VideoGrid, _default as VideoView, type WaitingParticipantState as WaitingParticipant, sdkVersion, useLocalMedia, useRoomConnection };
833
+ export { type ChatMessageState as ChatMessage, type LocalParticipantState as LocalParticipant, type RemoteParticipantState as RemoteParticipant, type RoomConnectionState as RoomConnection, type ScreenshareState as Screenshare, type UseLocalMediaResult, _default as VideoView, type WaitingParticipantState as WaitingParticipant, sdkVersion, useLocalMedia, useRoomConnection };