@whereby.com/browser-sdk 2.1.0-beta4 → 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-beta4";
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,10 +1,11 @@
1
- import * as React$1 from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import _whereby_jslib_media_src_utils_ServerSocket, { ChatMessage as ChatMessage$2 } from '@whereby/jslib-media/src/utils/ServerSocket';
2
4
  import * as redux_thunk from 'redux-thunk';
3
5
  import { AxiosRequestConfig } from 'axios';
4
6
  import EventEmitter from 'events';
5
7
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
6
8
  import * as redux from 'redux';
7
- import _whereby_jslib_media_src_utils_ServerSocket, { ChatMessage as ChatMessage$2 } from '@whereby/jslib-media/src/utils/ServerSocket';
8
9
  import RtcManagerDispatcher from '@whereby/jslib-media/src/webrtc/RtcManagerDispatcher';
9
10
  import RtcManager from '@whereby/jslib-media/src/webrtc/RtcManager';
10
11
 
@@ -12,18 +13,67 @@ 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;
25
+
26
+ interface RoomParticipantData {
27
+ displayName: string;
28
+ id: string;
29
+ stream?: MediaStream;
30
+ isAudioEnabled: boolean;
31
+ isVideoEnabled: boolean;
32
+ }
33
+ declare class RoomParticipant {
34
+ readonly displayName: string;
35
+ readonly id: string;
36
+ readonly stream?: MediaStream;
37
+ readonly isAudioEnabled: boolean;
38
+ readonly isLocalParticipant: boolean;
39
+ readonly isVideoEnabled: boolean;
40
+ constructor({ displayName, id, stream, isAudioEnabled, isVideoEnabled }: RoomParticipantData);
41
+ }
42
+ type StreamState = "new_accept" | "to_accept" | "old_accept" | "done_accept" | "to_unaccept" | "done_unaccept" | "auto";
43
+ interface Stream {
44
+ id: string;
45
+ state: StreamState;
46
+ }
47
+ interface RemoteParticipant {
48
+ id: string;
49
+ displayName: string;
50
+ isAudioEnabled: boolean;
51
+ isVideoEnabled: boolean;
52
+ isLocalParticipant: boolean;
53
+ stream: (MediaStream & {
54
+ inboundId?: string;
55
+ }) | null;
56
+ streams: Stream[];
57
+ newJoiner: boolean;
58
+ presentationStream: (MediaStream & {
59
+ inboundId?: string;
60
+ }) | null;
61
+ }
62
+ declare class LocalParticipant extends RoomParticipant {
63
+ readonly isLocalParticipant = true;
64
+ constructor({ displayName, id, stream, isAudioEnabled, isVideoEnabled }: RoomParticipantData);
65
+ }
66
+ interface WaitingParticipant {
67
+ id: string;
68
+ displayName: string | null;
69
+ }
70
+ interface Screenshare {
71
+ participantId: string;
72
+ id: string;
73
+ hasAudioTrack: boolean;
74
+ stream?: MediaStream;
75
+ isLocal: boolean;
76
+ }
27
77
 
28
78
  type Json = string | number | boolean | null | Array<Json> | {
29
79
  [key: string]: Json;
@@ -445,65 +495,6 @@ declare class OrganizationService {
445
495
  }): Promise<undefined>;
446
496
  }
447
497
 
448
- interface RoomParticipantData {
449
- displayName: string;
450
- id: string;
451
- stream?: MediaStream;
452
- isAudioEnabled: boolean;
453
- isVideoEnabled: boolean;
454
- }
455
- declare class RoomParticipant {
456
- readonly displayName: string;
457
- readonly id: string;
458
- readonly stream?: MediaStream;
459
- readonly isAudioEnabled: boolean;
460
- readonly isLocalParticipant: boolean;
461
- readonly isVideoEnabled: boolean;
462
- constructor({ displayName, id, stream, isAudioEnabled, isVideoEnabled }: RoomParticipantData);
463
- }
464
- type StreamState = "new_accept" | "to_accept" | "old_accept" | "done_accept" | "to_unaccept" | "done_unaccept" | "auto";
465
- interface Stream {
466
- id: string;
467
- state: StreamState;
468
- }
469
- interface RemoteParticipant {
470
- id: string;
471
- displayName: string;
472
- isAudioEnabled: boolean;
473
- isVideoEnabled: boolean;
474
- isLocalParticipant: boolean;
475
- stream: (MediaStream & {
476
- inboundId?: string;
477
- }) | null;
478
- streams: Stream[];
479
- newJoiner: boolean;
480
- presentationStream: (MediaStream & {
481
- inboundId?: string;
482
- }) | null;
483
- }
484
- declare class LocalParticipant extends RoomParticipant {
485
- readonly isLocalParticipant = true;
486
- constructor({ displayName, id, stream, isAudioEnabled, isVideoEnabled }: RoomParticipantData);
487
- }
488
- interface WaitingParticipant {
489
- id: string;
490
- displayName: string | null;
491
- }
492
- interface Screenshare {
493
- participantId: string;
494
- id: string;
495
- hasAudioTrack: boolean;
496
- stream?: MediaStream;
497
- isLocal: boolean;
498
- }
499
-
500
- /**
501
- * Reducer
502
- */
503
- interface WaitingParticipantsState {
504
- waitingParticipants: WaitingParticipant[];
505
- }
506
-
507
498
  /**
508
499
  * Reducer
509
500
  */
@@ -562,7 +553,6 @@ interface AppState {
562
553
  displayName: string | null;
563
554
  sdkVersion: string | null;
564
555
  externalId: string | null;
565
- isNodeSdk: boolean;
566
556
  }
567
557
 
568
558
  /**
@@ -573,34 +563,6 @@ interface DeviceCredentialsState {
573
563
  data?: Credentials | null;
574
564
  }
575
565
 
576
- type LocalMediaOptions = {
577
- disabled?: boolean;
578
- audio: boolean;
579
- video: boolean;
580
- };
581
- /**
582
- * Reducer
583
- */
584
- interface LocalMediaState$1 {
585
- busyDeviceIds: string[];
586
- cameraDeviceError?: unknown;
587
- cameraEnabled: boolean;
588
- currentCameraDeviceId?: string;
589
- currentMicrophoneDeviceId?: string;
590
- devices: MediaDeviceInfo[];
591
- isSettingCameraDevice: boolean;
592
- isSettingMicrophoneDevice: boolean;
593
- isTogglingCamera: boolean;
594
- microphoneDeviceError?: unknown;
595
- microphoneEnabled: boolean;
596
- options?: LocalMediaOptions;
597
- status: "" | "stopped" | "starting" | "started" | "error";
598
- startError?: unknown;
599
- stream?: MediaStream;
600
- isSwitchingStream: boolean;
601
- onDeviceChange?: () => void;
602
- }
603
-
604
566
  /**
605
567
  * Reducer
606
568
  */
@@ -729,10 +691,42 @@ declare const createStore: ({ preloadedState, injectServices, }: {
729
691
  fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
730
692
  };
731
693
  }, redux.UnknownAction>;
732
- }, {}>, redux.StoreEnhancer<{}, {}>]>>;
694
+ }>, redux.StoreEnhancer]>>;
733
695
  type Store = ReturnType<typeof createStore>;
734
696
 
735
- declare const sdkVersion = "__SDK_VERSION__";
697
+ /**
698
+ * Reducer
699
+ */
700
+ interface WaitingParticipantsState {
701
+ waitingParticipants: WaitingParticipant[];
702
+ }
703
+
704
+ type LocalMediaOptions = {
705
+ audio: boolean;
706
+ video: boolean;
707
+ };
708
+ /**
709
+ * Reducer
710
+ */
711
+ interface LocalMediaState$1 {
712
+ busyDeviceIds: string[];
713
+ cameraDeviceError?: unknown;
714
+ cameraEnabled: boolean;
715
+ currentCameraDeviceId?: string;
716
+ currentMicrophoneDeviceId?: string;
717
+ devices: MediaDeviceInfo[];
718
+ isSettingCameraDevice: boolean;
719
+ isSettingMicrophoneDevice: boolean;
720
+ isTogglingCamera: boolean;
721
+ microphoneDeviceError?: unknown;
722
+ microphoneEnabled: boolean;
723
+ options?: LocalMediaOptions;
724
+ status: "" | "stopped" | "starting" | "started" | "error";
725
+ startError?: unknown;
726
+ stream?: MediaStream;
727
+ isSwitchingStream: boolean;
728
+ onDeviceChange?: () => void;
729
+ }
736
730
 
737
731
  interface LocalMediaState {
738
732
  currentCameraDeviceId?: string;
@@ -819,6 +813,7 @@ interface RoomConnectionActions {
819
813
  stopCloudRecording(): void;
820
814
  stopScreenshare(): void;
821
815
  }
816
+
822
817
  type VideoViewComponentProps = Omit<React.ComponentProps<typeof _default>, "onResize">;
823
818
  interface RoomConnectionComponents {
824
819
  VideoView: (props: VideoViewComponentProps) => ReturnType<typeof _default>;
@@ -829,32 +824,10 @@ type RoomConnectionRef = {
829
824
  components: RoomConnectionComponents;
830
825
  _ref: Store;
831
826
  };
832
-
833
827
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
834
828
 
835
829
  declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): UseLocalMediaResult;
836
830
 
837
- type Origin = {
838
- top: number;
839
- left: number;
840
- };
841
- type Bounds = {
842
- width: number;
843
- height: number;
844
- };
845
-
846
- interface GridProps {
847
- roomConnection: RoomConnectionRef;
848
- renderParticipant?: ({ cell, participant, }: {
849
- cell: {
850
- clientId: string;
851
- bounds: Bounds;
852
- origin: Origin;
853
- };
854
- participant: RemoteParticipantState | LocalParticipantState;
855
- }) => React$1.ReactNode;
856
- videoGridGap?: number;
857
- }
858
- declare function Grid({ roomConnection, renderParticipant, videoGridGap }: GridProps): React$1.JSX.Element;
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 };