@whereby.com/browser-sdk 2.0.0-beta3 → 2.0.0-beta4

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/README.md CHANGED
@@ -1,10 +1,5 @@
1
1
  # `@whereby.com/browser-sdk`
2
2
 
3
- > [!WARNING]
4
- > This is a pre-release of the v2 version of this library, adding support for
5
- > more custom integration using React hooks and plain JavaScript classes in
6
- > addition to the web component for embedding.
7
-
8
3
  Whereby browser SDK is a library for seamless integration of Whereby
9
4
  (https://whereby.com) video calls into your web application.
10
5
 
@@ -23,6 +18,7 @@ yarn add @whereby.com/browser-sdk
23
18
  ```
24
19
 
25
20
  ## Usage
21
+
26
22
  > [!IMPORTANT]
27
23
  > In order to make use of this functionality, you must have a Whereby account
28
24
  > from which you can create room urls, either [manually or through our
@@ -1,28 +1,39 @@
1
- declare const sdkVersion = "__SDK_VERSION__";
2
-
3
1
  interface WherebyEmbedAttributes {
4
2
  audio: string;
5
3
  avatarUrl: string;
6
4
  background: string;
5
+ breakout: string;
7
6
  cameraAccess: string;
8
7
  chat: string;
9
8
  displayName: string;
10
9
  emptyRoomInvitation: string;
11
10
  externalId: string;
12
11
  floatSelf: string;
12
+ groups: string;
13
13
  help: string;
14
+ lang: string;
14
15
  leaveButton: string;
16
+ locking: string;
15
17
  logo: string;
18
+ lowData: string;
19
+ metadata: string;
20
+ minimal: string;
21
+ moreButton: string;
22
+ participantCount: string;
16
23
  people: string;
24
+ pipButton: string;
17
25
  precallReview: string;
18
26
  recording: string;
19
- screenshare: string;
20
- video: string;
21
- virtualBackgroundUrl: string;
22
27
  room: string;
28
+ settingsButton: string;
29
+ screenshare: string;
23
30
  style: {
24
31
  [key: string]: string;
25
32
  };
33
+ subgridLabels: string;
34
+ title: string;
35
+ video: string;
36
+ virtualBackgroundUrl: string;
26
37
  }
27
38
  declare global {
28
39
  namespace JSX {
@@ -31,5 +42,8 @@ declare global {
31
42
  }
32
43
  }
33
44
  }
45
+ declare const _default: {
46
+ sdkVersion: string;
47
+ };
34
48
 
35
- export { sdkVersion };
49
+ export { _default as default };
@@ -1,11 +1,31 @@
1
1
  import { define, ref } from 'heresy';
2
2
 
3
- const sdkVersion = "2.0.0-beta3";
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
+ }
22
+
23
+ const sdkVersion = "2.0.0-beta4";
4
24
 
5
25
  const boolAttrs = [
6
26
  "audio",
7
27
  "background",
8
- "cameraaccess",
28
+ "cameraAccess",
9
29
  "chat",
10
30
  "people",
11
31
  "embed",
@@ -49,6 +69,7 @@ define("WherebyEmbed", {
49
69
  "virtualBackgroundUrl",
50
70
  "avatarUrl",
51
71
  "externalId",
72
+ "title",
52
73
  ...boolAttrs,
53
74
  ].map((a) => a.toLowerCase()),
54
75
  onattributechanged({ attributeName, oldValue }) {
@@ -71,7 +92,7 @@ define("WherebyEmbed", {
71
92
  // Commands
72
93
  _postCommand(command, args = []) {
73
94
  if (this.iframe.current) {
74
- this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
95
+ this.iframe.current.contentWindow.postMessage({ command, args }, this.roomUrl.origin);
75
96
  }
76
97
  },
77
98
  startRecording() {
@@ -80,6 +101,12 @@ define("WherebyEmbed", {
80
101
  stopRecording() {
81
102
  this._postCommand("stop_recording");
82
103
  },
104
+ startStreaming() {
105
+ this._postCommand("start_streaming");
106
+ },
107
+ stopStreaming() {
108
+ this._postCommand("stop_streaming");
109
+ },
83
110
  toggleCamera(enabled) {
84
111
  this._postCommand("toggle_camera", [enabled]);
85
112
  },
@@ -89,44 +116,41 @@ define("WherebyEmbed", {
89
116
  toggleScreenshare(enabled) {
90
117
  this._postCommand("toggle_screenshare", [enabled]);
91
118
  },
119
+ toggleChat(enabled) {
120
+ this._postCommand("toggle_chat", [enabled]);
121
+ },
92
122
  onmessage({ origin, data }) {
93
- if (origin !== this.url.origin)
123
+ if (!this.roomUrl || origin !== this.roomUrl.origin)
94
124
  return;
95
125
  const { type, payload: detail } = data;
96
126
  this.dispatchEvent(new CustomEvent(type, { detail }));
97
127
  },
98
128
  render() {
99
- const { avatarurl: avatarUrl, displayname: displayName, externalId: externalId, lang, metadata, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, } = this;
100
- if (!room)
101
- return this.html `Whereby: Missing room attribute.`;
102
- // Get subdomain from room URL, or use it specified
103
- const m = /https:\/\/([^.]+)(\.whereby.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(room);
104
- const subdomain = (m && m[1]) || this.subdomain;
105
- if (!subdomain)
106
- return this.html `Whereby: Missing subdomain attr.`;
107
- if (!m) {
108
- return this.html `could not parse URL.`;
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));
109
133
  }
110
- const baseURL = m[2] || `.whereby.com`;
111
- this.url = new URL(room, `https://${subdomain}${baseURL}`);
112
- const roomUrl = new URL(room);
113
- if (roomUrl.searchParams.get("roomKey")) {
114
- this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
134
+ catch (error) {
135
+ return this.html `Whereby: ${error instanceof Error ? error.message : "unknown error"}`;
115
136
  }
116
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-beta3", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (externalId && { externalId })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
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(
117
139
  // add to URL if set in any way
118
140
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
119
- if (!this.url.searchParams.has(k) && typeof v === "string") {
120
- this.url.searchParams.set(k, v);
141
+ if (!this.roomUrl.searchParams.has(k)) {
142
+ this.roomUrl.searchParams.set(k, v);
121
143
  }
122
144
  });
123
- return this.html `
124
- <iframe
125
- ref=${this.iframe}
126
- src=${this.url}
127
- allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
128
- `;
129
- },
130
- });
145
+ this.html `
146
+ <iframe
147
+ title=${title || "Video calling component"}
148
+ ref=${this.iframe}
149
+ src=${this.roomUrl}
150
+ allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
151
+ `;
152
+ },
153
+ });
154
+ var index = { sdkVersion: sdkVersion };
131
155
 
132
- export { sdkVersion };
156
+ export { index as default };