@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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INVALID_URL = exports.ALLOW_ATTRIBUTE_MISSING = exports.INVALID_CONFIG = exports.UNKNOWN_TARGET = exports.RichError = void 0;
3
+ exports.INSECURE_CONTEXT = exports.INVALID_URL = exports.ALLOW_ATTRIBUTE_MISSING = exports.INVALID_CONFIG = exports.UNKNOWN_TARGET = exports.RichError = void 0;
4
4
  class RichError extends Error {
5
5
  constructor(error) {
6
6
  super(error.message);
@@ -22,5 +22,9 @@ exports.ALLOW_ATTRIBUTE_MISSING = new RichError({
22
22
  });
23
23
  exports.INVALID_URL = new RichError({
24
24
  name: 'INVALID_URL',
25
- message: 'Invalid frame url specified',
25
+ message: 'Invalid room URL specified',
26
+ });
27
+ exports.INSECURE_CONTEXT = new RichError({
28
+ name: 'INSECURE_CONTEXT',
29
+ message: 'Initializing embedded app in an insecure context, media capabilities unavailable. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts for details',
26
30
  });
@@ -29,6 +29,7 @@ var PermissionTypes;
29
29
  exports.defaultStoredState = {
30
30
  userId: '',
31
31
  roomState: {
32
+ frameMuted: false,
32
33
  media: {
33
34
  audioEnabled: false,
34
35
  videoEnabled: false,
@@ -37,6 +38,7 @@ exports.defaultStoredState = {
37
38
  mode: LayoutMode.tiled,
38
39
  showToolbar: true,
39
40
  toolbarPosition: 'left',
41
+ localTileMinimized: false,
40
42
  },
41
43
  captionsState: {
42
44
  showCaptions: false,
@@ -48,4 +50,22 @@ exports.defaultStoredState = {
48
50
  },
49
51
  },
50
52
  users: {},
53
+ features: {
54
+ chat: false,
55
+ contentLibrary: false,
56
+ captions: false,
57
+ qa: false,
58
+ endSession: false,
59
+ fullScreen: false,
60
+ languageSelection: false,
61
+ minimizeOwnTile: false,
62
+ participantsList: false,
63
+ pin: false,
64
+ screenshare: false,
65
+ whiteboard: false,
66
+ recordings: false,
67
+ virtualBackgrounds: false,
68
+ raiseHand: true,
69
+ invite: false,
70
+ },
51
71
  };
@@ -0,0 +1,126 @@
1
+ function checkDynamicRoomURL() {
2
+ if(window.location.search) {
3
+ const params = new URLSearchParams(window.location.search);
4
+ const dynamicRoomUrl = params.get('roomUrl');
5
+
6
+ if(dynamicRoomUrl) {
7
+ ROOM_URL = dynamicRoomUrl;
8
+
9
+ loadRoom();
10
+ showScreen('.room-frame');
11
+ }
12
+ }
13
+ }
14
+
15
+ var showLogs = false;
16
+ function toggleLogs() {
17
+ const logList = document.querySelector('.log-list');
18
+
19
+ if(!logList) {
20
+ return;
21
+ }
22
+
23
+ const logsToggle = document.querySelector('.logs-toggle');
24
+ showLogs = !showLogs;
25
+
26
+ logsToggle.innerHTML = showLogs ? 'hide logs' : 'show logs';
27
+ logList.style.display = showLogs ? 'block' : 'none'
28
+
29
+ }
30
+
31
+ function showScreen(target) {
32
+ const activeScreen = document.querySelector('.screen.show');
33
+ const frameScreen = document.querySelector('.screen'+target);
34
+ activeScreen.className = activeScreen.className.replace(' show', '');
35
+ frameScreen.className += ' show';
36
+ }
37
+
38
+
39
+ function updateError(message) {
40
+ const errorElement = document.querySelector('.room-url-error');
41
+ errorElement.innerHTML = message;
42
+ errorElement.style.display = 'block'
43
+ }
44
+
45
+ function onURLChange() {
46
+ const errorElement = document.querySelector('.room-url-error');
47
+ errorElement.style.display = 'none';
48
+ }
49
+
50
+ function initializeLogs() {
51
+ const sidebar = document.querySelector('.sidebar');
52
+ if(!sidebar) {
53
+ return;
54
+ }
55
+
56
+ const logsParent = document.createElement('div');
57
+ logsParent.className = 'logs';
58
+
59
+ sidebar.appendChild(logsParent);
60
+
61
+ const logsToggle = document.createElement('button')
62
+ logsToggle.className = 'logs-toggle';
63
+ logsToggle.type = 'button';
64
+ logsToggle.innerHTML = 'show logs';
65
+ logsToggle.onclick = toggleLogs;
66
+
67
+ logsParent.appendChild(logsToggle);
68
+
69
+ const logList = document.createElement('div');
70
+ logList.style.display = 'none';
71
+ logList.className = 'log-list sidebar-block';
72
+ logsParent.appendChild(logList);
73
+ }
74
+
75
+
76
+ function addJoiningHint(roomURL) {
77
+ const sidebar = document.querySelector('.sidebar');
78
+ if(!sidebar) {
79
+ return;
80
+ }
81
+
82
+ const hintParent = document.createElement('div');
83
+ hintParent.className = 'joining-hint sidebar-block';
84
+
85
+ sidebar.appendChild(hintParent);
86
+
87
+ hintParent.innerHTML = `
88
+ <p class="hint-title">Others can join your room by using this link:</p>
89
+ <p class="hint-link-url">${roomURL}</p>
90
+ <a href="${roomURL}" target="_blank" rel="noopener nofollow">open in new tab</a>
91
+ `
92
+ }
93
+
94
+
95
+ function vbStateToInitState(originalConfig){
96
+ if(!originalConfig) return undefined;
97
+
98
+ return {
99
+ [originalConfig.type]: originalConfig.value,
100
+ enforce: originalConfig.enforce
101
+ }
102
+ }
103
+
104
+
105
+ function initializeParticipantList() {
106
+ //
107
+ const sidebar = document.querySelector('.sidebar');
108
+ if(!sidebar) {
109
+ return;
110
+ }
111
+
112
+ const participantsList = document.createElement('div');
113
+ participantsList.className = 'participants sidebar-block';
114
+
115
+ sidebar.appendChild(participantsList);
116
+ }
117
+
118
+ function logRoomLoad() {
119
+ try {
120
+ const [team, room] = `${ROOM_URL}`.replace(/\?.+/, '').replace('https://', '').split('.digitalsamba.com/');
121
+
122
+ plausible('Room loaded', {props: {team, room}});
123
+ } catch(e) {
124
+ // ignore if something went wrong;
125
+ }
126
+ }
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.DigitalSambaEmbedded=t():e.DigitalSambaEmbedded=t()}(this,(()=>(()=>{"use strict";var e={187:e=>{var t,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};t=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function r(){r.init.call(this)}e.exports=r,e.exports.once=function(e,t){return new Promise((function(s,i){function o(s){e.removeListener(t,r),i(s)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",o),s([].slice.call(arguments))}g(e,t,r,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&g(e,"error",t,{once:!0})}(e,o)}))},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var n=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function h(e,t,s,i){var o,r,n,h;if(a(s),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),r=e._events),n=r[t]),void 0===n)n=r[t]=s,++e._eventsCount;else if("function"==typeof n?n=r[t]=i?[s,n]:[n,s]:i?n.unshift(s):n.push(s),(o=d(e))>0&&n.length>o&&!n.warned){n.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=n.length,h=l,console&&console.warn&&console.warn(h)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},o=l.bind(i);return o.listener=s,i.wrapFn=o,o}function m(e,t,s){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?s?[o.listener||o]:[o]:s?function(e){for(var t=new Array(e.length),s=0;s<t.length;++s)t[s]=e[s].listener||e[s];return t}(o):p(o,o.length)}function c(e){var t=this._events;if(void 0!==t){var s=t[e];if("function"==typeof s)return 1;if(void 0!==s)return s.length}return 0}function p(e,t){for(var s=new Array(t),i=0;i<t;++i)s[i]=e[i];return s}function g(e,t,s,i){if("function"==typeof e.on)i.once?e.once(t,s):e.on(t,s);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(r){i.once&&e.removeEventListener(t,o),s(r)}))}}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return n},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");n=e}}),r.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return d(this)},r.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var o="error"===e,r=this._events;if(void 0!==r)o=o&&void 0===r.error;else if(!o)return!1;if(o){var n;if(t.length>0&&(n=t[0]),n instanceof Error)throw n;var a=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw a.context=n,a}var d=r[e];if(void 0===d)return!1;if("function"==typeof d)i(d,this,t);else{var h=d.length,l=p(d,h);for(s=0;s<h;++s)i(l[s],this,t)}return!0},r.prototype.addListener=function(e,t){return h(this,e,t,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(e,t){return h(this,e,t,!0)},r.prototype.once=function(e,t){return a(t),this.on(e,u(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,u(this,e,t)),this},r.prototype.removeListener=function(e,t){var s,i,o,r,n;if(a(t),void 0===(i=this._events))return this;if(void 0===(s=i[e]))return this;if(s===t||s.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,s.listener||t));else if("function"!=typeof s){for(o=-1,r=s.length-1;r>=0;r--)if(s[r]===t||s[r].listener===t){n=s[r].listener,o=r;break}if(o<0)return this;0===o?s.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(s,o),1===s.length&&(i[e]=s[0]),void 0!==i.removeListener&&this.emit("removeListener",e,n||t)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(e){var t,s,i;if(void 0===(s=this._events))return this;if(void 0===s.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==s[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete s[e]),this;if(0===arguments.length){var o,r=Object.keys(s);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=s[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},r.prototype.listeners=function(e){return m(this,e,!0)},r.prototype.rawListeners=function(e){return m(this,e,!1)},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},r.prototype.listenerCount=c,r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},432:function(e,t,s){var i,o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DigitalSambaEmbedded=void 0;const r=o(s(187)),n=s(737),a=s(480),d=s(604),h=s(517);class l extends r.default{constructor(e={},t={},s=!0){super(),this.roomSettings={},this.savedIframeSrc="",this.allowedOrigin="*",this.connected=!1,this.frame=document.createElement("iframe"),this.reportErrors=!1,this.stored=Object.assign({},a.defaultStoredState),this.permissionManager=new n.PermissionManager(this),this.mountFrame=e=>{const{url:t,frame:s,root:i}=this.initOptions;if(i?i.appendChild(this.frame):s?(this.frame=s,s.allow||this.logError(h.ALLOW_ATTRIBUTE_MISSING)):document.body.appendChild(this.frame),t||this.frame.src&&this.frame.src!==window.location.href)try{let e=t||this.frame.src;e.includes("https://")||(e="https://"+e);const s=new URL(e).toString();this.frame.src=s,this.savedIframeSrc=s}catch(e){this.logError(h.INVALID_URL)}e||(this.savedIframeSrc=this.frame.src,this.frame.src="")},this.load=(e={})=>{this.reportErrors=e.reportErrors||!1,this.setFrameSrc(),this.applyFrameProperties(e),this.frame.style.display="block"},this.onMessage=e=>{if(e.origin!==this.allowedOrigin)return;const t=e.data.DSPayload;t&&t.type&&(a.internalEvents[t.type]?this.handleInternalMessage(e.data):this._emit(t.type,t))},this.setupInternalEventListeners=()=>{this.on("userJoined",(e=>{const{user:t,type:s}=e.data;this.stored.users[t.id]=Object.assign(Object.assign({},t),{kind:s}),"local"===s&&(this.stored.userId=t.id),this.emitUsersUpdated()})),this.on("userLeft",(e=>{var t,s;(null===(s=null===(t=e.data)||void 0===t?void 0:t.user)||void 0===s?void 0:s.id)&&delete this.stored.users[e.data.user.id],this.emitUsersUpdated()})),this.on("permissionsChanged",(e=>{if(this.stored.users[this.stored.userId]){let t=[...this.stored.users[this.stored.userId].dynamicPermissions||[]];Object.entries(e.data).forEach((([e,s])=>{s&&!t.includes(e)&&t.push(e),s||(t=t.filter((t=>t!==e)))})),this.stored.users[this.stored.userId].dynamicPermissions=t}})),this.on("activeSpeakerChanged",(e=>{var t,s;this.stored.activeSpeaker=null===(s=null===(t=e.data)||void 0===t?void 0:t.user)||void 0===s?void 0:s.id})),this.on("videoEnabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.videoEnabled=!0)})),this.on("videoDisabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.videoEnabled=!1)})),this.on("audioEnabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.audioEnabled=!0)})),this.on("audioDisabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.audioEnabled=!1)})),this.on("layoutModeChanged",(e=>{this.stored.roomState.layout.mode=e.data.mode})),this.on("captionsSpokenLanguageChanged",(e=>{this.stored.roomState.captionsState.spokenLanguage=e.data.language})),this.on("captionsEnabled",(()=>{this.stored.roomState.captionsState.showCaptions=!0})),this.on("captionsDisabled",(()=>{this.stored.roomState.captionsState.showCaptions=!1})),this.on("captionsFontSizeChanged",(e=>{this.stored.roomState.captionsState.fontSize=e.data.fontSize})),this.on("virtualBackgroundChanged",(e=>{const{type:t,value:s,enforced:i}=e.data.virtualBackgroundConfig;this.stored.roomState.virtualBackground={enabled:!0,type:t,value:s,enforced:i}})),this.on("virtualBackgroundDisabled",(e=>{this.stored.roomState.virtualBackground={enabled:!1}})),this.on("localTileMinimized",(()=>{this.stored.roomState.layout.localTileMinimized=!0})),this.on("localTileMaximized",(()=>{this.stored.roomState.layout.localTileMinimized=!1})),this.on("userMaximized",(({data:e})=>{this.stored.roomState.layout.content={userId:e.userId,type:e.type},this.stored.roomState.layout.contentMode=e.mode})),this.on("userMinimized",(()=>{this.stored.roomState.layout.content=void 0,this.stored.roomState.layout.contentMode=void 0}))},this._emit=(e,...t)=>(this.emit("*",...t),this.emit(e,...t)),this.handleInternalMessage=e=>{const t=e.DSPayload;switch(t.type){case"roomJoined":{const{users:e,roomState:s,activeSpeaker:i,permissionsMap:o,features:r}=t.data;this.stored.users=Object.assign(Object.assign({},this.stored.users),e),this.stored.roomState=(0,d.createWatchedProxy)(Object.assign({},s),this.emitRoomStateUpdated),this.stored.activeSpeaker=i,this.stored.features=(0,d.createWatchedProxy)(Object.assign({},r),this.emitFeatureSetUpdated),this.permissionManager.permissionsMap=o,this.emitUsersUpdated(),this.emitFeatureSetUpdated(),this.emitRoomStateUpdated(),this._emit("roomJoined",{type:"roomJoined"});break}}},this.emitUsersUpdated=()=>{this._emit("usersUpdated",{type:"usersUpdated",data:{users:this.listUsers()}})},this.emitRoomStateUpdated=()=>{this._emit("roomStateUpdated",{type:"roomStateUpdated",data:{state:this.roomState}})},this.emitFeatureSetUpdated=()=>{this._emit("featureSetUpdated",{type:"featureSetUpdated",data:{state:this.stored.features}})},this.setFrameSrc=()=>{let e=this.savedIframeSrc;const{team:t,room:s,token:i}=this.initOptions;if(t&&s&&(e=`https://${t}.digitalsamba.com/${s}`),e){const t=new URL(e);t.searchParams.append("dsEmbedFrame","true"),i&&t.searchParams.append("token",i),e=t.toString()}if(!e)return void(this.initOptions.url||this.logError(h.INVALID_CONFIG));this.frame.src=e;const o=new URL(this.frame.src);this.allowedOrigin=o.origin,this.frame.onload=()=>{this._emit("frameLoaded",{type:"frameLoaded"}),this.checkTarget()}},this.logError=e=>{if(this.reportErrors)throw e;console.error(e)},this.applyFrameProperties=e=>{e.frameAttributes&&Object.entries(e.frameAttributes).forEach((([e,t])=>{null!=t?this.frame.setAttribute(e,t.toString()):this.frame.removeAttribute(e)})),e.reportErrors&&(this.reportErrors=!0)},this.enableVideo=()=>{this.roomSettings.videoEnabled=!0,this.sendMessage({type:"enableVideo"})},this.disableVideo=()=>{this.roomSettings.videoEnabled=!1,this.sendMessage({type:"disableVideo"})},this.toggleVideo=e=>{void 0===e?this.sendMessage({type:"toggleVideo"}):e?this.enableVideo():this.disableVideo()},this.enableAudio=()=>{this.roomSettings.audioEnabled=!0,this.sendMessage({type:"enableAudio"})},this.disableAudio=()=>{this.roomSettings.audioEnabled=!1,this.sendMessage({type:"disableAudio"})},this.toggleAudio=e=>{void 0===e?this.sendMessage({type:"toggleAudio"}):e?this.enableAudio():this.disableAudio()},this.startScreenshare=()=>{this.sendMessage({type:"startScreenshare"})},this.stopScreenshare=()=>{this.sendMessage({type:"stopScreenshare"})},this.startRecording=()=>{this.sendMessage({type:"startRecording"})},this.stopRecording=()=>{this.sendMessage({type:"stopRecording"})},this.showToolbar=()=>{this.roomSettings.showToolbar=!0,this.stored.roomState.layout.showToolbar=!0,this.sendMessage({type:"showToolbar"})},this.hideToolbar=()=>{this.roomSettings.showToolbar=!1,this.stored.roomState.layout.showToolbar=!1,this.sendMessage({type:"hideToolbar"})},this.changeToolbarPosition=e=>{this.sendMessage({type:"changeToolbarPosition",data:e})},this.changeBrandingOptions=e=>{this.sendMessage({type:"changeBrandingOptions",data:e})},this.changeLayoutMode=e=>{this.roomSettings.layoutMode=e,this.sendMessage({type:"changeLayoutMode",data:e})},this.leaveSession=()=>{this.sendMessage({type:"leaveSession"})},this.endSession=()=>{this.sendMessage({type:"endSession"})},this.toggleToolbar=e=>{void 0===e?(this.stored.roomState.layout.showToolbar=!this.stored.roomState.layout.showToolbar,this.sendMessage({type:"toggleToolbar"})):e?this.showToolbar():this.hideToolbar()},this.requestToggleAudio=(e,t)=>{void 0===t?this.sendMessage({type:"requestToggleAudio",data:e}):t?this.requestMute(e):this.requestUnmute(e)},this.requestMute=e=>{this.sendMessage({type:"requestMute",data:e})},this.requestUnmute=e=>{this.sendMessage({type:"requestUnmute",data:e})},this.removeUser=e=>{this.sendMessage({type:"removeUser",data:e})},this.listUsers=()=>Object.values(this.stored.users),this.getUser=e=>{var t;return null===(t=this.stored.users)||void 0===t?void 0:t[e]},this.showCaptions=()=>{this.roomSettings.showCaptions=!0,this.sendMessage({type:"showCaptions"})},this.hideCaptions=()=>{this.roomSettings.showCaptions=!1,this.sendMessage({type:"hideCaptions"})},this.toggleCaptions=e=>{void 0===e?this.sendMessage({type:"toggleCaptions"}):e?this.showCaptions():this.hideCaptions()},this.configureCaptions=e=>{this.sendMessage({type:"configureCaptions",data:e||{}})},this.raiseHand=()=>{this.sendMessage({type:"raiseHand"})},this.lowerHand=e=>{this.sendMessage({type:"lowerHand",data:e})},this.allowBroadcast=e=>{this.sendMessage({type:"allowBroadcast",data:e})},this.disallowBroadcast=e=>{this.sendMessage({type:"disallowBroadcast",data:e})},this.allowScreenshare=e=>{this.sendMessage({type:"allowScreenshare",data:e})},this.disallowScreenshare=e=>{this.sendMessage({type:"disallowScreenshare",data:e})},this.configureVirtualBackground=e=>{this.roomSettings.virtualBackground=e;const t={enabled:!0,type:void 0,value:"",enforced:e.enforce};["blur","image","imageUrl"].forEach((s=>{e[s]&&(t.type=s,t.value=e[s])})),this.sendMessage({type:"configureVirtualBackground",data:e||{}})},this.enableVirtualBackground=e=>this.configureVirtualBackground(e),this.disableVirtualBackground=()=>{this.roomSettings.virtualBackground=void 0,this.sendMessage({type:"disableVirtualBackground"})},this.muteFrame=()=>{this.roomSettings.muteFrame=!0,this.stored.roomState.frameMuted=!0,this.sendMessage({type:"muteFrame"})},this.unmuteFrame=()=>{this.roomSettings.muteFrame=!1,this.stored.roomState.frameMuted=!1,this.sendMessage({type:"unmuteFrame"})},this.toggleMuteFrame=e=>{void 0===e?(this.roomSettings.muteFrame=!this.roomSettings.muteFrame,this.stored.roomState.frameMuted=!this.stored.roomState.frameMuted,this.sendMessage({type:"toggleMuteFrame"})):e?this.muteFrame():this.unmuteFrame()},this.minimizeLocalTile=()=>{this.sendMessage({type:"minimizeLocalTile"})},this.maximizeLocalTile=()=>{this.sendMessage({type:"maximizeLocalTile"})},this.pinUser=(e,t="media")=>{this.sendMessage({type:"pinUser",data:{tile:t,userId:e}})},this.unpinUser=()=>{this.minimizeContent()},this.maximizeUser=(e,t="media")=>{this.sendMessage({type:"maximizeUser",data:{tile:t,userId:e}})},this.minimizeUser=()=>{this.minimizeContent()},this.minimizeContent=()=>{this.sendMessage({type:"minimizeContent"})},window.isSecureContext||this.logError(h.INSECURE_CONTEXT),this.initOptions=e,this.roomSettings=e.roomSettings||{},this.reportErrors=t.reportErrors||!1,this.frame.allow="camera; microphone; display-capture; autoplay;",this.frame.setAttribute("allowFullscreen","true"),this.mountFrame(s),s?this.load(t):this.frame.style.display="none",window.addEventListener("message",this.onMessage),this.setupInternalEventListeners()}checkTarget(){this.sendMessage({type:"connect",data:this.roomSettings||{}});const e=window.setTimeout((()=>{this.logError(h.UNKNOWN_TARGET)}),a.CONNECT_TIMEOUT);this.on("connected",(()=>{this.connected=!0,clearTimeout(e)}))}sendMessage(e){if(this.frame.contentWindow){if(!this.connected&&"connect"!==e.type)return;this.frame.contentWindow.postMessage(e,{targetOrigin:this.allowedOrigin})}}get roomState(){return this.stored.roomState}get localUser(){return this.stored.users[this.stored.userId]}get features(){return this.stored.features}featureEnabled(e){return!!this.stored.features[e]}}t.DigitalSambaEmbedded=l,i=l,l.createControl=(e,t={})=>new i(e,t,!1),t.default=l},625:(e,t,s)=>{const{DigitalSambaEmbedded:i}=s(432);e.exports=i},737:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionManager=void 0,t.PermissionManager=class{constructor(e){this.permissionsMap={},this.lookupDynamicPermission=(e,t)=>!!t&&t.includes(e),this.lookupPermission=e=>{const{permissionsMap:t,permission:s,targetRole:i,role:o,dynamicPermissions:r}=e;return!(!r||!this.lookupDynamicPermission(s,r))||(!!t[o][s]||Boolean(t[o][`${s}_${i}`]))},this.checkPermissions=({permissions:e,targetRole:t,permissionsMap:s,role:i,dynamicPermissions:o})=>Array.isArray(e)?e.some((e=>this.lookupPermission({permission:e,targetRole:t,role:i,permissionsMap:s,dynamicPermissions:o}))):this.lookupPermission({permission:e,targetRole:t,role:i,permissionsMap:s,dynamicPermissions:o}),this.refinePermissions=(e,{targetRole:t,role:s,userId:i,users:o,permissionsMap:r,localUser:n})=>{const a={permissionsMap:r,permissions:e,targetRole:t,role:n.role,dynamicPermissions:n.dynamicPermissions};return s&&(a.role=s,a.dynamicPermissions=void 0),i&&o&&(a.role=o[i].role,a.dynamicPermissions=o[i].dynamicPermissions),this.checkPermissions(a)},this.hasPermissions=(e,{targetRole:t,role:s,userId:i}={})=>{const o=this.parent.stored.users,r=this.parent.localUser;return!!r&&this.refinePermissions(e,{permissionsMap:this.permissionsMap,role:s,targetRole:t,users:o,userId:i,localUser:r})},this.parent=e}}},517:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.INSECURE_CONTEXT=t.INVALID_URL=t.ALLOW_ATTRIBUTE_MISSING=t.INVALID_CONFIG=t.UNKNOWN_TARGET=t.RichError=void 0;class s extends Error{constructor(e){super(e.message),this.name=e.name}}t.RichError=s,t.UNKNOWN_TARGET=new s({name:"UNKNOWN_TARGET",message:"Could not verify the identity of target frame. Commands may not work"}),t.INVALID_CONFIG=new s({name:"INVALID_INIT_CONFIG",message:"Initializations options are invalid. Missing team name or room ID"}),t.ALLOW_ATTRIBUTE_MISSING=new s({name:"ALLOW_ATTRIBUTE_MISSING",message:"You've provided a frame that is mising 'allow' attribute. Some functionality may not work."}),t.INVALID_URL=new s({name:"INVALID_URL",message:"Invalid room URL specified"}),t.INSECURE_CONTEXT=new s({name:"INSECURE_CONTEXT",message:"Initializing embedded app in an insecure context, media capabilities unavailable. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts for details"})},604:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createWatchedProxy=void 0,t.createWatchedProxy=(e,t)=>new Proxy(e,(e=>{const t={get:(e,s)=>"object"==typeof e[s]&&null!==e[s]?new Proxy(e[s],t):e[s],set:(t,s,i)=>(t[s]=i,e(t),t)};return t})(t))},480:(e,t)=>{var s,i;Object.defineProperty(t,"__esModule",{value:!0}),t.defaultStoredState=t.PermissionTypes=t.LayoutMode=t.internalEvents=t.CONNECT_TIMEOUT=void 0,t.CONNECT_TIMEOUT=1e4,t.internalEvents={roomJoined:!0},function(e){e.tiled="tiled",e.auto="auto"}(s=t.LayoutMode||(t.LayoutMode={})),(i=t.PermissionTypes||(t.PermissionTypes={})).broadcast="broadcast",i.manageBroadcast="manage_broadcast",i.endSession="end_session",i.startSession="start_session",i.removeParticipant="remove_participant",i.screenshare="screenshare",i.manageScreenshare="manage_screenshare",i.recording="recording",i.generalChat="general_chat",i.remoteMuting="remote_muting",i.askRemoteUnmute="ask_remote_unmute",i.raiseHand="raise_hand",i.manageRoles="manage_roles",t.defaultStoredState={userId:"",roomState:{frameMuted:!1,media:{audioEnabled:!1,videoEnabled:!1},layout:{mode:s.tiled,showToolbar:!0,toolbarPosition:"left",localTileMinimized:!1},captionsState:{showCaptions:!1,spokenLanguage:"en",fontSize:"medium"},virtualBackground:{enabled:!1}},users:{},features:{chat:!1,contentLibrary:!1,captions:!1,qa:!1,endSession:!1,fullScreen:!1,languageSelection:!1,minimizeOwnTile:!1,participantsList:!1,pin:!1,screenshare:!1,whiteboard:!1,recordings:!1,virtualBackgrounds:!1,raiseHand:!0,invite:!1}}}},t={};return function s(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,s),r.exports}(625)})()));
@@ -0,0 +1,299 @@
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>Initial settings</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
+ <div class="screen room-url-field show">
24
+ <div class="container">
25
+ <div class="vertical">
26
+ <label for="custom-room-url">
27
+ <span><b>Room URL</b></span>
28
+ <span>Can be found in <a href="https://dashboard.digitalsamba.com/" target="_blank" rel="noopener nofollow">dashboard</a></span>.
29
+ </label>
30
+ <div>
31
+ <input type="text" id="custom-room-url" name="custom-room-url" onkeydown="onURLChange()">
32
+ <!-- kicks off loading -->
33
+ <button onclick="loadCustomRoom()">load room</button>
34
+ </div>
35
+ <p class="room-url-error"></p>
36
+ <p style="margin-top: 30px;" class="init-settings-title">Predefined settings</p>
37
+ <p style="margin-bottom: 15px">These options can be applied prior to joining the room. For
38
+ instance,<br> if you pre-set a username, participant won't be prompted for it.
39
+ <br>
40
+ You can also set defaults for media devices and room UI.
41
+ </p>
42
+
43
+ <div>
44
+ <label for="initial-settings-username">
45
+ Username
46
+ </label>
47
+ <div>
48
+ <input type="text" id="initial-settings-username" onchange="initialSettings.username = this.value">
49
+ </div>
50
+ <div style="display: flex">
51
+ <label class="checkbox-label" for="initial-settings-video">
52
+ <span>Video enabled</span>
53
+ <input type="checkbox" id="initial-settings-video" checked onchange="initialSettings.videoEnabled = !initialSettings.videoEnabled" />
54
+ </label>
55
+ <label class="checkbox-label" for="initial-settings-audio">
56
+ <span>Audio enabled</span>
57
+ <input type="checkbox" id="initial-settings-audio" checked onchange="initialSettings.audioEnabled = !initialSettings.audioEnabled" />
58
+ </label>
59
+ </div>
60
+ <div>
61
+ <label class="checkbox-label" for="initial-settings-toolbar">
62
+ <span>Show toolbar</span>
63
+ <input type="checkbox" id="initial-settings-toolbar" onchange="initialSettings.showToolbar = !initialSettings.showToolbar" />
64
+ </label>
65
+ </div>
66
+ <div>
67
+ <label class="checkbox-label" for="initial-settings-muted">
68
+ <span>Mute frame</span>
69
+ <input type="checkbox" id="initial-settings-muted" onchange="initialSettings.muteFrame = !initialSettings.muteFrame" />
70
+ </label>
71
+ </div>
72
+ <fieldset style="margin-bottom: 10px;">
73
+ <div style="display: flex;">
74
+ <legend style="margin-right: 8px;">Layout mode</legend>
75
+ <div style="display: flex; align-items: center; justify-content: center">
76
+ <input type="radio" id="prep-layout-mode-auto" checked name="layout-mode" value="auto" onchange="initialSettings.layoutMode = 'auto'" />
77
+ <label class="radio-label" for="prep-layout-mode-auto">Auto</label>
78
+
79
+ <input type="radio" id="prep-layout-mode-tiled" name="layout-mode" value="tiled" onchange="initialSettings.layoutMode = 'tiled'" />
80
+ <label class="radio-label" for="prep-layout-mode-tiled">Tiled</label>
81
+ </div>
82
+ </div>
83
+ </fieldset>
84
+ <div>
85
+ <label class="checkbox-label" for="initial-settings-vb">
86
+ <span>Enable virtual background</span>
87
+ <input type="checkbox" id="initial-settings-vb" onchange="toggleVirtualBackground(this.checked)" />
88
+ </label>
89
+ </div>
90
+ <div class="vb-options" style ="display: none">
91
+ <div style="display: flex; align-items: center; justify-content: flex-start">
92
+ <label style="margin-right: 8px;" for="vb-type">Virtual background type</label>
93
+ <select name="vb-type" id="vb-type" onchange="updateVBType(this.value)">
94
+ <option value="blur">blur</option>
95
+ <option value="image">predefined image</option>
96
+ <option value="imageUrl">custom image</option>
97
+ </select>
98
+ </div>
99
+ <div class="vb-value vb-value-blur show">
100
+ <div style="display: flex; align-items: center; justify-content: flex-start">
101
+ <label style="margin-right: 8px;" for="vb-blur-value">Blur strength</label>
102
+ <select name="vb-blur-value" id="vb-blur-value" onchange="VBstate.value = this.value; VBvalues.blur = this.value">
103
+ <option value="balanced">balanced</option>
104
+ <option value="strong">strong</option>
105
+ </select>
106
+ </div>
107
+ </div>
108
+ <div class="vb-value vb-value-image">
109
+ <div style="display: flex; align-items: center; justify-content: flex-start">
110
+ <label style="margin-right: 8px;" for="vb-image-value">Preset name</label>
111
+ <select name="vb-image-value" id="vb-image-value" onchange="VBstate.value = this.value; VBvalues.image = this.value;">
112
+ <option value="office">office</option>
113
+ <option value="office2">office2</option>
114
+ <option value="beach">beach</option>
115
+ <option value="fireworks">fireworks</option>
116
+ <option value="bookshelf">bookshelf</option>
117
+ <option value="forest">forest</option>
118
+ <option value="mountain">mountain</option>
119
+ <option value="savannah">savannah</option>
120
+ </select>
121
+ </div>
122
+ </div>
123
+ <div class="vb-value vb-value-imageUrl">
124
+ <label for="vb-image-url">
125
+ Custom image URL
126
+ </label>
127
+ <div>
128
+ <input type="text" id="vb-image-url" onchange="VBstate.value = this.value; VBvalues.imageUrl = this.value">
129
+ </div>
130
+ </div>
131
+ <div>
132
+ <label class="checkbox-label" for="initial-settings-enforce-vb">
133
+ <span>Allow changing virtual background</span>
134
+ <input type="checkbox" id="initial-settings-enforce-vb" onchange="VBstate.enforce = !this.checked" />
135
+ </label>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ <div class="screen room-frame">
143
+ <div class="container">
144
+ <div class="room-content">
145
+ <div class="frame-area">
146
+ <div class="frame-parent">
147
+ <!-- our frame will load here -->
148
+ </div>
149
+ <div class="frame-controls" style="display: none">
150
+ <button onclick="sambaEmbedded.toggleVideo()">toggle video</button>
151
+ <button onclick="sambaEmbedded.toggleAudio()">toggle audio</button>
152
+ <button onclick="sambaEmbedded.toggleToolbar()">toggle toolbar</button>
153
+ <button onclick="sambaEmbedded.muteFrame()">mute frame</button>
154
+ <button onclick="sambaEmbedded.unmuteFrame()">unmute frame</button>
155
+ <button onclick="sambaEmbedded.toggleMuteFrame()">toggle mute frame</button>
156
+ </div>
157
+ </div>
158
+ <div class="sidebar"></div>
159
+ </div>
160
+ </div>
161
+
162
+ </div>
163
+
164
+ <script async defer>
165
+ let ROOM_URL = "https://localhost:3000/Public";
166
+
167
+ var sambaEmbedded;
168
+
169
+ // defaults for pre-configured state;
170
+ var initialSettings = {
171
+ muteFrame: false,
172
+ username: "",
173
+ audioEnabled: true,
174
+ videoEnabled: true,
175
+ showToolbar: false,
176
+ showCaptions: false,
177
+ layoutMode: "auto",
178
+ virtualBackground: undefined
179
+ };
180
+
181
+ var VBstate = {
182
+ type: "blur",
183
+ value: "balanced",
184
+ enforce: false
185
+ };
186
+
187
+ var VBvalues = {
188
+ blur: 'balanced',
189
+ image: 'office',
190
+ imageUrl: 'string'
191
+ }
192
+
193
+
194
+ // if room is predefined in search params, skip room URL field;
195
+ checkDynamicRoomURL();
196
+
197
+ function loadCustomRoom() {
198
+ const input = document.querySelector("#custom-room-url");
199
+
200
+ if (input.value) {
201
+ ROOM_URL = input.value;
202
+
203
+ initialSettings.virtualBackground = vbStateToInitState(initialSettings.virtualBackground);
204
+
205
+ loadRoom();
206
+ } else {
207
+ updateError("Please enter room URL");
208
+ }
209
+ }
210
+
211
+ function loadRoom() {
212
+ try {
213
+ const parent = document.querySelector(".frame-parent");
214
+ parent.innerHTML = null;
215
+
216
+ // create pre-configured controller instance using given URL;
217
+ // if no frame specified, this pre-creates a frame but doesn't load it yet;
218
+ // other init strategies are available, along with more detailed customization
219
+ // see https://docs.digitalsamba.com/reference/sdk/digitalsambaembedded-class
220
+ sambaEmbedded = DigitalSambaEmbedded.createControl(
221
+ {
222
+ url: ROOM_URL, root: parent,
223
+ // apply predefined room settings
224
+ roomSettings: initialSettings
225
+ },
226
+ { reportErrors: true }
227
+ );
228
+
229
+ // controller instance exposes the frame, so we can customize it a little bit
230
+ sambaEmbedded.frame.width = 1000;
231
+ sambaEmbedded.frame.height = 700;
232
+ sambaEmbedded.frame.style.border = "5px solid #f06859";
233
+ sambaEmbedded.frame.style.borderRadius = "8px";
234
+
235
+ // load samba frame
236
+ sambaEmbedded.load();
237
+ logRoomLoad();
238
+
239
+ addJoiningHint(ROOM_URL);
240
+ initializeLogs();
241
+
242
+ // after loading, controller will start emitting events
243
+ // event listeners can be set up prior to loading;
244
+ setupCustomEventListeners();
245
+
246
+ showScreen(".room-frame");
247
+ } catch (e) {
248
+ updateError(e.message);
249
+ }
250
+ }
251
+
252
+ function setupCustomEventListeners() {
253
+ // catch all events. Useful for logging or debugging;
254
+ sambaEmbedded.on("*", (data) => {
255
+ const logList = document.querySelector(".log-list");
256
+
257
+ if (logList) {
258
+ logList.innerHTML += `<div>
259
+ <p>[${(new Date).toLocaleTimeString()}] event: <b>${data?.type}</b></p>
260
+ ${data.data ? `<p>payload: ${JSON.stringify(data.data)}</p>` : ""}
261
+ </div>`;
262
+
263
+ logList.scrollTop = logList.scrollHeight;
264
+ }
265
+ });
266
+
267
+ // `roomJoined` is fired when local user has joined the room
268
+ // this listener is used to display media device controls after joining
269
+ sambaEmbedded.on("roomJoined", () => {
270
+ const controls = document.querySelector(".frame-controls");
271
+
272
+ controls.style.display = "flex";
273
+ });
274
+ }
275
+
276
+ function toggleVirtualBackground(shouldEnable) {
277
+ const vbOptions = document.querySelector(".vb-options");
278
+
279
+ if (shouldEnable) {
280
+ initialSettings.virtualBackground = VBstate;
281
+ vbOptions.style.display = "block";
282
+ } else {
283
+ initialSettings.virtualBackground = undefined;
284
+ vbOptions.style.display = "none";
285
+ }
286
+ }
287
+
288
+ function updateVBType(newType) {
289
+ VBstate.type = newType;
290
+ const currentOption = document.querySelector(".vb-value.show");
291
+ const newOption = document.querySelector(".vb-value-" + newType);
292
+ currentOption.className = currentOption.className.replace(" show", "");
293
+ newOption.className += " show";
294
+
295
+ VBstate.value = VBvalues[newType];
296
+ }
297
+ </script>
298
+ </body>
299
+ </html>
Binary file