@digitalsamba/embedded-sdk 0.0.20 → 0.0.25

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.
@@ -0,0 +1,333 @@
1
+
2
+ html, body, div, span, applet, object, iframe,
3
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4
+ a, abbr, acronym, address, big, cite, code,
5
+ del, dfn, em, img, ins, kbd, q, s, samp,
6
+ small, strike, strong, sub, sup, tt, var,
7
+ b, u, i, center,
8
+ dl, dt, dd, ol, ul, li,
9
+ fieldset, form, label, legend,
10
+ table, caption, tbody, tfoot, thead, tr, th, td,
11
+ article, aside, canvas, details, embed,
12
+ figure, figcaption, footer, header, hgroup,
13
+ menu, nav, output, ruby, section, summary,
14
+ time, mark, audio, video {
15
+ margin: 0;
16
+ padding: 0;
17
+ border: 0;
18
+ font-size: 100%;
19
+ font: inherit;
20
+ vertical-align: baseline;
21
+ }
22
+ button {
23
+ cursor: pointer;
24
+ }
25
+ /* HTML5 display-role reset for older browsers */
26
+ article, aside, details, figcaption, figure,
27
+ footer, header, hgroup, menu, nav, section {
28
+ display: block;
29
+ }
30
+ body {
31
+ color: rgb(50, 63, 102);
32
+ line-height: 1;
33
+ }
34
+ ol, ul {
35
+ list-style: none;
36
+ }
37
+ blockquote, q {
38
+ quotes: none;
39
+ }
40
+ blockquote:before, blockquote:after,
41
+ q:before, q:after {
42
+ content: '';
43
+ content: none;
44
+ }
45
+ table {
46
+ border-collapse: collapse;
47
+ border-spacing: 0;
48
+ }
49
+
50
+ body {
51
+ background: #f4f5f8;
52
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
53
+ }
54
+
55
+ .topbar {
56
+ background: #fff;
57
+ box-shadow: 0 8px 16px rgba(34,35,38,.05), 0 4px 8px rgba(34,35,38,.05);
58
+ }
59
+
60
+ a {
61
+ font-size: 16px;
62
+ color: rgb(55, 113, 224);
63
+ text-decoration: none;
64
+ }
65
+
66
+ .user-list-row {
67
+ display: flex;
68
+ margin: 12px 0 8px;
69
+ align-items: center;
70
+ }
71
+
72
+ .user-list-avatar {
73
+ width: 24px;
74
+ height: 24px;
75
+ display: block;
76
+ border-radius: 50%;
77
+ margin-right: 8px;
78
+ text-align: center;
79
+ font-size: 20px;
80
+ line-height: 1;
81
+ color: #fff;
82
+ }
83
+
84
+ .speaker-indicator {
85
+ width: 8px;
86
+ height: 8px;
87
+ display: block;
88
+ border-radius: 50%;
89
+ margin-right: 8px;
90
+ background: #4cd964;
91
+ opacity: 0;
92
+ margin-left: 8px;
93
+ }
94
+
95
+ .speaker-indicator.show {
96
+ opacity: 1
97
+ }
98
+
99
+ .container {
100
+ padding: 0 15px;
101
+ display: flex;
102
+ flex-grow: 1;
103
+ flex-wrap: wrap;
104
+ }
105
+
106
+ .topbar .container {
107
+ padding: 7.5px 15px;
108
+ align-items: center;
109
+ justify-content: space-between;
110
+ }
111
+
112
+ .logo {
113
+ width: 327px;
114
+ border-width: 0px;
115
+ border: 0px;
116
+ height: auto;
117
+ max-width: 100%;
118
+ vertical-align: middle;
119
+ }
120
+
121
+ .room-content {
122
+ display: flex;
123
+ }
124
+
125
+ .screen {
126
+ display: none;
127
+ min-height: calc(100vh - 75px);
128
+ }
129
+
130
+ .screen.show {
131
+ display: flex;
132
+ }
133
+
134
+ .room-url-field .container {
135
+ display: flex;
136
+ flex-direction: column;
137
+ align-items: center;
138
+ justify-content: center;
139
+ }
140
+
141
+ .room-url-field label {
142
+ margin-bottom: 10px;
143
+ display: block;
144
+ }
145
+ .room-url-field label b {
146
+ font-size: 18px;
147
+
148
+ display: block;
149
+ margin-bottom: 5px;
150
+ font-weight: 700;
151
+ }
152
+
153
+ .checkbox-label {
154
+ display: flex;
155
+ align-items: center;
156
+ margin-right: 15px;
157
+ }
158
+
159
+ .room-url-field label.radio-label {
160
+ margin: 0;
161
+ margin-right: 8px;
162
+ }
163
+
164
+ .init-settings-title {
165
+ font-size: 18px;
166
+ font-weight: 700;
167
+ margin-bottom: 5px;
168
+ }
169
+
170
+ .room-url-field input[type=text] {
171
+ border: 2px solid rgb(50, 63, 102);
172
+ margin-bottom: 10px;
173
+ border-radius: 8px;
174
+ width: 420px;
175
+ padding: 8px;
176
+ font-size: 14px;
177
+ }
178
+
179
+ .room-url-field select {
180
+ border: 2px solid rgb(50, 63, 102);
181
+ margin-bottom: 10px;
182
+ border-radius: 8px;
183
+ padding: 8px;
184
+ font-size: 14px;
185
+ }
186
+
187
+ .room-url-error {
188
+ color: crimson;
189
+ }
190
+
191
+ .room-url-field button {
192
+ margin-bottom: 10px;
193
+ border-radius: 8px;
194
+ padding: 8px 16px;
195
+ background: rgb(55, 113, 224);
196
+ border: 2px solid rgb(55, 113, 224);
197
+ color: #fff;
198
+ font-size: 14px;
199
+ text-transform: uppercase;
200
+ }
201
+
202
+ .room-url-field .vertical {
203
+ display: flex;
204
+ flex-direction: column;
205
+ }
206
+ .room-content {
207
+ max-width: 100%;
208
+ display: grid;
209
+ grid-template-columns: repeat(12, minmax(0, 1fr));
210
+ gap: 30px;
211
+ }
212
+
213
+ .room-frame {
214
+ align-items: flex-start;
215
+ }
216
+
217
+ .frame-area {
218
+ justify-self: center;
219
+ grid-column: span 7 / span 7;
220
+ }
221
+
222
+ .room-frame .container {
223
+ padding: 15px 15px;
224
+ }
225
+
226
+ iframe {
227
+ max-width: 100%;
228
+ }
229
+
230
+ .sidebar {
231
+ grid-column: span 5 / span 5;
232
+ }
233
+
234
+ @media (max-width: 1023px) {
235
+ .frame-area {
236
+ grid-column: 1 / -1;
237
+ }
238
+
239
+ .sidebar {
240
+ grid-column: 1 / -1;
241
+ }
242
+ }
243
+
244
+ .sidebar-block {
245
+ border: 1px solid #dfdfdf;
246
+ background: #fff;
247
+ padding: 15px;
248
+ border-radius: 8px;
249
+ margin-bottom: 15px;
250
+ }
251
+ .hint-title {
252
+ margin-bottom: 10px;
253
+ }
254
+ .hint-link-url {
255
+ font-size: 18px;
256
+ font-weight: 700;
257
+ margin-bottom: 10px;
258
+ word-wrap: break-word;
259
+ line-height: 1.25;
260
+ }
261
+
262
+ .logs-toggle {
263
+ background: none;
264
+ border: none;
265
+ color: rgb(55, 113, 224);
266
+ margin-bottom: 7.5px;
267
+ }
268
+
269
+ .log-list {
270
+ max-height: 60vh;
271
+ overflow-y: auto;
272
+ word-wrap: break-word;
273
+ }
274
+
275
+ .log-list div {
276
+ max-width: 90%;
277
+ }
278
+
279
+ .log-list p {
280
+ font-size: 14px;
281
+ margin-bottom: 4px;
282
+ }
283
+ .log-list b {
284
+ font-weight: 700;
285
+ }
286
+
287
+ .branding-controls {
288
+ display: flex;
289
+ flex-wrap: wrap;
290
+ }
291
+
292
+ .frame-controls, .branding-controls {
293
+ margin-top: 15px;
294
+ }
295
+
296
+ .frame-controls button, .branding-controls button {
297
+ border-radius: 8px;
298
+ padding: 8px 16px;
299
+ background: #fff;
300
+ border: 2px solid rgb(55, 113, 224);
301
+ color: rgb(55, 113, 224);
302
+ font-size: 14px;
303
+ text-transform: uppercase;
304
+ margin-right: 8px;
305
+ }
306
+
307
+ .vb-value {
308
+ display: none;
309
+ }
310
+ .vb-value.show {
311
+ display: block;
312
+ }
313
+
314
+ .participants {
315
+ display: none;
316
+ }
317
+ .participants.show {
318
+ display: block
319
+ }
320
+
321
+ .user-list-row button {
322
+ margin: 0px 4px;
323
+ font-size: 14px;
324
+ border: none;
325
+ background: none;
326
+ font-weight: 700;
327
+ color: rgb(55, 113, 224);
328
+ }
329
+
330
+ .branding-control-parent.disabled {
331
+ opacity: .5;
332
+ pointer-events: none;
333
+ }
@@ -0,0 +1,212 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <title>Simple videoroom</title>
8
+ <script src="./index.js"></script>
9
+ <script src="./helper.js"></script>
10
+ <script defer data-domain="digitalsamba.github.io" src="https://plausible.wbcnf.net/js/script.js"></script>
11
+ <script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
12
+ <link rel="stylesheet" href="./style.css">
13
+ </head>
14
+
15
+ <body>
16
+ <nav class="topbar">
17
+ <div class="container">
18
+ <img class="logo" src="logo.png" alt="DigitalSamba">
19
+ <a href="https://github.com/digitalsamba/embedded-sdk" target="_blank" rel="noopener nofollow">View on GitHub</a>
20
+ </div>
21
+ </nav>
22
+
23
+
24
+ <div class="screen room-url-field show">
25
+ <div class="container">
26
+ <div class="vertical">
27
+ <label for="custom-room-url">
28
+ <span><b>Room URL</b></span>
29
+ <span>Can be found in <a href="https://dashboard.digitalsamba.com/" target="_blank" rel="noopener nofollow">dashboard</a></span>.
30
+ </label>
31
+ <div>
32
+ <input type="text" id="custom-room-url" name="custom-room-url" onkeydown="onURLChange()">
33
+ <!-- kicks off loading -->
34
+ <button onclick="loadCustomRoom()">load room</button>
35
+ </div>
36
+ <p class="room-url-error"></p>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <div class="screen room-frame">
41
+ <div class="container">
42
+ <div class="room-content">
43
+ <div class="frame-area">
44
+ <div class="frame-parent">
45
+ <!-- our frame will load here -->
46
+ </div>
47
+ <div class="frame-controls" style="display: none">
48
+ <button onclick="sambaEmbedded.toggleVideo()">toggle video</button>
49
+ <button onclick="sambaEmbedded.toggleAudio()">toggle audio</button>
50
+ <button onclick="sambaEmbedded.toggleToolbar()">toggle toolbar</button>
51
+ <button onclick="sambaEmbedded.changeToolbarPosition('left')">toolbar to left</button>
52
+ <button onclick="sambaEmbedded.changeToolbarPosition('right')">toolbar to right</button>
53
+ <button onclick="sambaEmbedded.changeToolbarPosition('bottom')">toolbar to bottom</button>
54
+ </div>
55
+ <div class="branding-controls">
56
+ <div style="display: flex; flex-grow: 1; margin-bottom: 20px">
57
+ <div>
58
+ <label class="checkbox-label" for="branding-palette">
59
+ <span>Custom palette</span>
60
+ <input type="checkbox" id="branding-palette" onchange="toggleBrandingOption('paletteMode')" />
61
+ </label>
62
+ <div class="js--paletteMode-parent branding-control-parent disabled">
63
+ <label style="margin-right: 8px;" for="branding-paletteMode-input">Value</label>
64
+ <select name="branding-palette-mode" id="branding-paletteMode-input" onchange="brandingConfig.paletteMode = this.value">
65
+ <option value="light">light</option>
66
+ <option value="dark">dark</option>
67
+ </select>
68
+ </div>
69
+ </div>
70
+ <div>
71
+ <label class="checkbox-label" for="branding-primary-color">
72
+ <span>Custom primary color</span>
73
+ <input type="checkbox" id="branding-primary-color" onchange="toggleBrandingOption('primaryColor')" />
74
+ </label>
75
+ <div class="js--primaryColor-parent branding-control-parent disabled">
76
+ <label for="branding-primaryColor-input">
77
+ <span>Value</span>
78
+ <input type="color" id="branding-primaryColor-input" onchange="brandingConfig.primaryColor = this.value">
79
+ </label>
80
+ </div>
81
+ </div>
82
+ <div>
83
+ <label class="checkbox-label" for="branding-toolbar-color">
84
+ <span>Custom toolbar color</span>
85
+ <input type="checkbox" id="branding-toolbar-color" onchange="toggleBrandingOption('toolbarColor')" />
86
+ </label>
87
+ <div class="js--toolbarColor-parent branding-control-parent disabled">
88
+ <label for="branding-toolbarColor-input">
89
+ <span>Value</span>
90
+ <input type="color" id="branding-toolbarColor-input" onchange="brandingConfig.toolbarColor = this.value">
91
+ </label>
92
+ </div>
93
+ </div>
94
+ <div>
95
+ <label class="checkbox-label" for="branding-room-bg-color">
96
+ <span>Custom room background</span>
97
+ <input type="checkbox" id="branding-room-bg-color" onchange="toggleBrandingOption('roomBackgroundColor')" />
98
+ </label>
99
+ <div class="js--roomBackgroundColor-parent branding-control-parent disabled">
100
+ <label for="branding-roomBackgroundColor-input">
101
+ <span>Value</span>
102
+ <input type="color" id="branding-roomBackgroundColor-input" onchange="brandingConfig.roomBackgroundColor = this.value"></label>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ <button onclick="sambaEmbedded.changeBrandingOptions(brandingConfig)">Apply custom branding</button>
107
+ </div>
108
+ </div>
109
+ <div class="sidebar"></div>
110
+ </div>
111
+ </div>
112
+
113
+ </div>
114
+
115
+ <script async defer>
116
+ let ROOM_URL = 'https://localhost:3000/Public';
117
+
118
+ var sambaEmbedded;
119
+ var brandingConfig = {
120
+
121
+ }
122
+ // if room is predefined in search params, skip room URL field;
123
+ checkDynamicRoomURL();
124
+
125
+ function loadCustomRoom() {
126
+ const input = document.querySelector('#custom-room-url');
127
+
128
+ if(input.value) {
129
+ ROOM_URL = input.value;
130
+ loadRoom();
131
+ } else {
132
+ updateError('Please enter room URL')
133
+ }
134
+ }
135
+
136
+ function loadRoom() {
137
+ try {
138
+ const parent = document.querySelector('.frame-parent');
139
+ parent.innerHTML = null;
140
+
141
+ // create pre-configured controller instance using given URL;
142
+ // if no frame specified, this pre-creates a frame but doesn't load it yet;
143
+ // other init strategies are available, along with more detailed customization
144
+ // see https://docs.digitalsamba.com/reference/sdk/digitalsambaembedded-class
145
+ sambaEmbedded = DigitalSambaEmbedded.createControl(
146
+ { url: ROOM_URL, root: parent, roomSettings: {showToolbar: false } },
147
+ {reportErrors: true}
148
+ );
149
+
150
+ // controller instance exposes the frame, so we can customize it a little bit
151
+ sambaEmbedded.frame.width = 1000;
152
+ sambaEmbedded.frame.height = 700;
153
+ sambaEmbedded.frame.style.border = '5px solid #f06859';
154
+ sambaEmbedded.frame.style.borderRadius = '8px';
155
+
156
+ // load samba frame
157
+ sambaEmbedded.load();
158
+ logRoomLoad();
159
+
160
+ addJoiningHint(ROOM_URL);
161
+ initializeLogs();
162
+
163
+ // after loading, controller will start emitting events
164
+ // event listeners can be set up prior to loading;
165
+ setupCustomEventListeners();
166
+
167
+ showScreen('.room-frame');
168
+ } catch (e) {
169
+ updateError(e.message)
170
+ }
171
+ }
172
+
173
+ function setupCustomEventListeners() {
174
+ // catch all events. Useful for logging or debugging;
175
+ sambaEmbedded.on('*', (data) => {
176
+ const logList = document.querySelector('.log-list');
177
+
178
+ if(logList) {
179
+ logList.innerHTML += `<div>
180
+ <p>[${(new Date).toLocaleTimeString()}] event: <b>${data?.type}</b></p>
181
+ ${data.data ? `<p>payload: ${JSON.stringify(data.data)}</p>` : ''}
182
+ </div>`;
183
+
184
+ logList.scrollTop = logList.scrollHeight;
185
+ }
186
+ })
187
+
188
+ // `roomJoined` is fired when local user has joined the room
189
+ // this listener is used to display media device controls after joining
190
+ sambaEmbedded.on('roomJoined', () => {
191
+ const controls = document.querySelector('.frame-controls');
192
+
193
+ controls.style.display = 'flex';
194
+ })
195
+ }
196
+
197
+ function toggleBrandingOption(option) {
198
+ console.warn(option, brandingConfig[option]);
199
+ const controlParent = document.querySelector('.js--'+option+'-parent');
200
+
201
+ if(brandingConfig[option]) {
202
+ delete brandingConfig[option];
203
+ controlParent.className += ' disabled'
204
+ } else {
205
+ const input = document.getElementById('branding-'+option+'-input');
206
+ brandingConfig[option] = input.value;
207
+ controlParent.className = controlParent.className.replace(' disabled', '');
208
+ }
209
+ }
210
+ </script>
211
+ </body>
212
+ </html>
@@ -2,7 +2,7 @@
2
2
  import EventEmitter from 'events';
3
3
  import { PermissionManager } from './utils/PermissionManager';
4
4
  import { LayoutMode } from './utils/vars';
5
- import { CaptionsOptions, EmbeddedInstance, InitialRoomSettings, InitOptions, InstanceProperties, Stored, UserId, VirtualBackgroundOptions } from './types';
5
+ import { BrandingOptionsConfig, CaptionsOptions, EmbeddedInstance, FeatureFlag, InitialRoomSettings, InitOptions, InstanceProperties, Stored, UserId, UserTileType, VirtualBackgroundOptions } from './types';
6
6
  export declare class DigitalSambaEmbedded extends EventEmitter implements EmbeddedInstance {
7
7
  initOptions: Partial<InitOptions>;
8
8
  roomSettings: Partial<InitialRoomSettings>;
@@ -14,7 +14,7 @@ export declare class DigitalSambaEmbedded extends EventEmitter implements Embedd
14
14
  stored: Stored;
15
15
  permissionManager: PermissionManager;
16
16
  constructor(options?: Partial<InitOptions>, instanceProperties?: Partial<InstanceProperties>, loadImmediately?: boolean);
17
- static createControl: (initOptions: Partial<InitOptions>) => DigitalSambaEmbedded;
17
+ static createControl: (initOptions: Partial<InitOptions>, instanceProperties?: InstanceProperties) => DigitalSambaEmbedded;
18
18
  private mountFrame;
19
19
  load: (instanceProperties?: InstanceProperties) => void;
20
20
  private onMessage;
@@ -23,6 +23,7 @@ export declare class DigitalSambaEmbedded extends EventEmitter implements Embedd
23
23
  private handleInternalMessage;
24
24
  private emitUsersUpdated;
25
25
  private emitRoomStateUpdated;
26
+ private emitFeatureSetUpdated;
26
27
  private setFrameSrc;
27
28
  private checkTarget;
28
29
  private sendMessage;
@@ -30,6 +31,8 @@ export declare class DigitalSambaEmbedded extends EventEmitter implements Embedd
30
31
  private applyFrameProperties;
31
32
  get roomState(): import("./types").RoomState;
32
33
  get localUser(): import("./types").User;
34
+ get features(): import("./types").FeatureSet;
35
+ featureEnabled(feature: FeatureFlag): boolean;
33
36
  enableVideo: () => void;
34
37
  disableVideo: () => void;
35
38
  toggleVideo: (enable?: boolean) => void;
@@ -42,6 +45,8 @@ export declare class DigitalSambaEmbedded extends EventEmitter implements Embedd
42
45
  stopRecording: () => void;
43
46
  showToolbar: () => void;
44
47
  hideToolbar: () => void;
48
+ changeToolbarPosition: (side: 'left' | 'right' | 'bottom') => void;
49
+ changeBrandingOptions: (brandingOptionsConfig: Partial<BrandingOptionsConfig>) => void;
45
50
  changeLayoutMode: (mode: LayoutMode) => void;
46
51
  leaveSession: () => void;
47
52
  endSession: () => void;
@@ -65,5 +70,15 @@ export declare class DigitalSambaEmbedded extends EventEmitter implements Embedd
65
70
  configureVirtualBackground: (options: VirtualBackgroundOptions) => void;
66
71
  enableVirtualBackground: (options: VirtualBackgroundOptions) => void;
67
72
  disableVirtualBackground: () => void;
73
+ muteFrame: () => void;
74
+ unmuteFrame: () => void;
75
+ toggleMuteFrame: (mute?: boolean) => void;
76
+ minimizeLocalTile: () => void;
77
+ maximizeLocalTile: () => void;
78
+ pinUser: (userId: UserId, tile?: UserTileType) => void;
79
+ unpinUser: () => void;
80
+ maximizeUser: (userId: UserId, tile?: UserTileType) => void;
81
+ minimizeUser: () => void;
82
+ minimizeContent: () => void;
68
83
  }
69
84
  export default DigitalSambaEmbedded;