@digitalsamba/embedded-sdk 0.0.17 → 0.0.19
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 +4 -0
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.js +62 -11
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +24 -12
- package/dist/cjs/utils/vars.js +5 -2
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +62 -11
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +24 -12
- package/dist/esm/utils/vars.js +5 -2
- package/dist/initial-config-demo.html +4 -4
- package/dist/types/index.d.ts +5 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +24 -12
- package/dist/umd/index.js +1 -1
- package/dist/virtual-background-demo.html +290 -0
- package/package.json +5 -1
package/dist/umd/index.js
CHANGED
@@ -1 +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))}f(e,t,r,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&f(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 f(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{const e=new URL(t||this.frame.src).toString();this.frame.src=e,this.savedIframeSrc=e}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.cameraEnabled=!0)})),this.on("videoDisabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.cameraEnabled=!1)})),this.on("audioEnabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.micEnabled=!0)})),this.on("audioDisabled",(e=>{var t;"local"===(null===(t=e.data)||void 0===t?void 0:t.type)&&(this.stored.roomState.media.micEnabled=!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("captionsFontSizeChanged",(e=>{this.stored.roomState.captionsState.fontSize=e.data.fontSize}))},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}=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.permissionManager.permissionsMap=o,this.emitUsersUpdated(),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.setFrameSrc=()=>{let e=this.savedIframeSrc;const{team:t,room:s,token:i}=this.initOptions;if(t&&s&&(e=`https://${t}.digitalsamba.com/${s}`),e&&i){const t=new URL(e);t.searchParams.append("token",i),e=t.toString()}if(!e)return void this.logError(h.INVALID_CONFIG);this.frame.src=e;const o=new URL(this.frame.src);this.allowedOrigin=o.origin,this.frame.onload=()=>this.checkTarget()},this.logError=e=>{if(this.reportErrors)throw 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.cameraEnabled=!0,this.sendMessage({type:"enableVideo"})},this.disableVideo=()=>{this.roomSettings.cameraEnabled=!1,this.sendMessage({type:"disableVideo"})},this.toggleVideo=e=>{void 0===e?this.sendMessage({type:"toggleVideo"}):e?this.enableVideo():this.disableVideo()},this.enableAudio=()=>{this.roomSettings.micEnabled=!0,this.sendMessage({type:"enableAudio"})},this.disableAudio=()=>{this.roomSettings.micEnabled=!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.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.showCaptions=()=>{this.roomSettings.showCaptions=!0,this.stored.roomState.captionsState.showCaptions=!0,this.sendMessage({type:"showCaptions"})},this.hideCaptions=()=>{this.roomSettings.showCaptions=!1,this.stored.roomState.captionsState.showCaptions=!1,this.sendMessage({type:"hideCaptions"})},this.toggleCaptions=e=>{void 0===e?(this.stored.roomState.captionsState.showCaptions=!this.stored.roomState.captionsState.showCaptions,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.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]}}t.DigitalSambaEmbedded=l,i=l,l.createControl=e=>new i(e,{},!1)},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.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 frame url specified"})},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:{media:{micEnabled:!1,cameraEnabled:!1},layout:{mode:s.tiled,showToolbar:!0,toolbarPosition:"left"},captionsState:{showCaptions:!1,spokenLanguage:"en",fontSize:"medium"}},users:{}}}},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)})()));
|
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 c(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):m(o,o.length)}function p(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 m(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=m(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 c(this,e,!0)},r.prototype.rawListeners=function(e){return c(this,e,!1)},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},r.prototype.listenerCount=p,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{const e=new URL(t||this.frame.src).toString();this.frame.src=e,this.savedIframeSrc=e}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._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}=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.permissionManager.permissionsMap=o,this.emitUsersUpdated(),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.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.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},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.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.stored.roomState.captionsState.showCaptions=!0,this.sendMessage({type:"showCaptions"})},this.hideCaptions=()=>{this.roomSettings.showCaptions=!1,this.stored.roomState.captionsState.showCaptions=!1,this.sendMessage({type:"hideCaptions"})},this.toggleCaptions=e=>{void 0===e?(this.stored.roomState.captionsState.showCaptions=!this.stored.roomState.captionsState.showCaptions,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.stored.roomState.virtualBackground=t,this.sendMessage({type:"configureVirtualBackground",data:e||{}})},this.enableVirtualBackground=e=>this.configureVirtualBackground(e),this.disableVirtualBackground=()=>{this.roomSettings.virtualBackground=void 0,this.stored.roomState.virtualBackground={enabled:!1},this.sendMessage({type:"disableVirtualBackground"})},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]}}t.DigitalSambaEmbedded=l,i=l,l.createControl=e=>new i(e,{},!1)},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.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 frame url specified"})},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:{media:{audioEnabled:!1,videoEnabled:!1},layout:{mode:s.tiled,showToolbar:!0,toolbarPosition:"left"},captionsState:{showCaptions:!1,spokenLanguage:"en",fontSize:"medium"},virtualBackground:{enabled:!1}},users:{}}}},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,290 @@
|
|
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>Document</title>
|
8
|
+
<!-- <script src="https://unpkg.com/@digitalsamba/embedded-sdk"></script>-->
|
9
|
+
<script src="./umd/index.js"></script>
|
10
|
+
<style>
|
11
|
+
.user-list-row {
|
12
|
+
display: flex;
|
13
|
+
margin-bottom: 8px;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
.user-list-avatar {
|
18
|
+
width: 24px;
|
19
|
+
height: 24px;
|
20
|
+
display: block;
|
21
|
+
border-radius: 50%;
|
22
|
+
margin-right: 8px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.log p {
|
26
|
+
font-size: 14px;
|
27
|
+
line-height: 1;
|
28
|
+
margin: 0 0 4px
|
29
|
+
}
|
30
|
+
|
31
|
+
.buttons button, .captions-buttons button {
|
32
|
+
margin: 2px;
|
33
|
+
}
|
34
|
+
</style>
|
35
|
+
<script>
|
36
|
+
const initialRoomState = {
|
37
|
+
username: "",
|
38
|
+
audioEnabled: false,
|
39
|
+
videoEnabled: false,
|
40
|
+
showToolbar: false,
|
41
|
+
showCaptions: false,
|
42
|
+
layoutMode: 'auto',
|
43
|
+
virtualBackground: undefined
|
44
|
+
}
|
45
|
+
const VBstate = {
|
46
|
+
type: 'blur',
|
47
|
+
value: 'balanced',
|
48
|
+
enforce: false,
|
49
|
+
}
|
50
|
+
const updateVBEnabled = () => {
|
51
|
+
const vbOptions = document.querySelector('.vb-prep-options');
|
52
|
+
|
53
|
+
if(initialRoomState.virtualBackground) {
|
54
|
+
initialRoomState.virtualBackground = undefined
|
55
|
+
vbOptions.style.opacity = '0.5'
|
56
|
+
vbOptions.style.pointerEvents = 'none'
|
57
|
+
} else {
|
58
|
+
initialRoomState.virtualBackground = VBstate;
|
59
|
+
vbOptions.style.opacity = '1'
|
60
|
+
vbOptions.style.pointerEvents = 'all'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
</script>
|
64
|
+
</head>
|
65
|
+
<body>
|
66
|
+
<div>
|
67
|
+
<p>allowed blur options: "balanced", "strong"</p>
|
68
|
+
<p>allowed image options: "office","office2","beach","fireworks","bookshelf","forest","mountain","savannah"
|
69
|
+
</p>
|
70
|
+
</div>
|
71
|
+
<div class="sdk-prep">
|
72
|
+
<h3>Initial settings</h3>
|
73
|
+
|
74
|
+
<label for="prep-username-input">
|
75
|
+
<p>Username:</p>
|
76
|
+
<input type="text" id="prep-username-input">
|
77
|
+
</label>
|
78
|
+
<div class="prep-checkboxes"></div>
|
79
|
+
<fieldset>
|
80
|
+
<legend>Layout mode:</legend>
|
81
|
+
<div>
|
82
|
+
<input type="radio" id="prep-layout-mode1" checked name="contact" value="auto" onchange="initialRoomState.layoutMode = 'auto'" />
|
83
|
+
<label for="prep-layout-mode1">Auto</label>
|
84
|
+
|
85
|
+
<input type="radio" id="contactChoice2" name="contact" value="tiled" onchange="initialRoomState.layoutMode = 'tiled'"/>
|
86
|
+
<label for="contactChoice2">Tiled</label>
|
87
|
+
</div>
|
88
|
+
</fieldset>
|
89
|
+
<fieldset>
|
90
|
+
<legend>Virtual background:</legend>
|
91
|
+
<input type="checkbox" id="prep-vb-enabled" name="vb-enabled" value="auto" onchange="updateVBEnabled()" />
|
92
|
+
<label for="prep-vb-enabled">VB enabled</label>
|
93
|
+
<div class="vb-prep-options" style="opacity: 0.5; pointer-events: none;">
|
94
|
+
<div>
|
95
|
+
<label for="vb-type">VB type</label>
|
96
|
+
<select name="vb-type" id="vb-type" onchange="VBstate.type = this.value">
|
97
|
+
<option value="blur">blur</option>
|
98
|
+
<option value="image">image</option>
|
99
|
+
<option value="imageUrl">imageUrl</option>
|
100
|
+
</select>
|
101
|
+
</div>
|
102
|
+
<div>
|
103
|
+
<label for="prep-vb-value"></label>
|
104
|
+
<input type="text" name="prep-vb-value" id="prep-vb-value" value="balanced" onchange="VBstate.value = this.value">
|
105
|
+
</div>
|
106
|
+
<div>
|
107
|
+
<input type="checkbox" id="prep-vb-enforced" name="vb-enforced" value="auto" onchange="VBstate.enforce = !VBstate.enforce" />
|
108
|
+
<label for="prep-vb-enforced">enforce VB</label>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
</fieldset>
|
112
|
+
<div style="margin-top: 20px">
|
113
|
+
<button type="button" class="sdk-prep-submit">load</button>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
<div class="sdk-ready" style="display: none">
|
117
|
+
<div style="display: flex">
|
118
|
+
<div class="ifp">
|
119
|
+
|
120
|
+
</div>
|
121
|
+
<div style="min-width: 300px ; padding: 0 16px">
|
122
|
+
<h3>Room state</h3>
|
123
|
+
<div class="state">
|
124
|
+
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
<div class="div buttons" style=" border: 1px solid yellow">
|
129
|
+
<button class="c0" style="margin-right: 15px; border: 2px solid blue">LOAD</button>
|
130
|
+
|
131
|
+
<fieldset class="room-vb-fields" style="display: none">
|
132
|
+
<legend>Virtual background:</legend>
|
133
|
+
<div class="vb-room-options">
|
134
|
+
<div>
|
135
|
+
<label for="room-vb-type">VB type</label>
|
136
|
+
<select name="room-vb-type" id="room-vb-type" onchange="VBstate.type = this.value">
|
137
|
+
<option value="blur">blur</option>
|
138
|
+
<option value="image">image</option>
|
139
|
+
<option value="imageUrl">imageUrl</option>
|
140
|
+
</select>
|
141
|
+
</div>
|
142
|
+
<div>
|
143
|
+
<label for="room-vb-value"></label>
|
144
|
+
<input type="text" name="room-vb-value" id="room-vb-value" value="balanced" onchange="VBstate.value = this.value">
|
145
|
+
</div>
|
146
|
+
<div>
|
147
|
+
<input type="checkbox" id="room-vb-enforced" name="room-vb-enforced" value="auto" onchange="VBstate.enforce = !VBstate.enforce" />
|
148
|
+
<label for="room-vb-enforced">enforce VB</label>
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
</fieldset>
|
152
|
+
<button class="enable-vb-button">apply settings</button>
|
153
|
+
<button class="disable-vb-button">disable-vb</button>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<div class="log">
|
157
|
+
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<script async defer>
|
162
|
+
const parent = document.querySelector('.ifp');
|
163
|
+
const frame = document.querySelector('.if');
|
164
|
+
const buttonsParent = document.querySelector('.buttons');
|
165
|
+
const captionsButtonsParent = document.querySelector('.captions-buttons');
|
166
|
+
const participantList = document.querySelector('.participants');
|
167
|
+
const btn0 = document.querySelector('.c0');
|
168
|
+
const prepButton = document.querySelector('.sdk-prep-submit');
|
169
|
+
const prepBlock = document.querySelector('.sdk-prep')
|
170
|
+
const controlsBlock = document.querySelector('.sdk-ready')
|
171
|
+
const prepUsernameInput = document.getElementById('prep-username-input')
|
172
|
+
const prepCheckboxesParent = document.querySelector('.prep-checkboxes')
|
173
|
+
|
174
|
+
const enableVBButton = document.querySelector('.enable-vb-button')
|
175
|
+
const disableVBButton = document.querySelector('.disable-vb-button')
|
176
|
+
|
177
|
+
// change these values to connect to your room
|
178
|
+
const TEAM = 'some-team';
|
179
|
+
const ROOM = 'some-room';
|
180
|
+
let ROOM_URL = 'https://localhost:3000/Public'
|
181
|
+
|
182
|
+
if(window.location.search) {
|
183
|
+
const params = new URLSearchParams(window.location.search);
|
184
|
+
const dynamicRoomUrl = params.get('roomUrl');
|
185
|
+
if(dynamicRoomUrl) {
|
186
|
+
ROOM_URL = dynamicRoomUrl
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
//const api = new DigitalSambaEmbedded({ root: parent, team: TEAM, room: ROOM});
|
191
|
+
// const api = new DigitalSambaEmbedded({ frame});
|
192
|
+
//const api = new DigitalSambaEmbedded({ url: ROOM_URL}, {reportErrors: true});
|
193
|
+
|
194
|
+
const prepCheckboxes = [
|
195
|
+
{control: 'audioEnabled', label: 'Microphone enabled by default'},
|
196
|
+
{control: 'videoEnabled', label: 'Camera enabled by default'},
|
197
|
+
{control: 'showToolbar', label: 'Show toolbar'},
|
198
|
+
{control: 'showCaptions', label: 'Show captions'},
|
199
|
+
];
|
200
|
+
|
201
|
+
prepCheckboxes.forEach(control => {
|
202
|
+
const label = document.createElement('label');
|
203
|
+
label.style.display = 'block'
|
204
|
+
label.htmlFor = 'prep-' + control.control;
|
205
|
+
label.innerHTML = '<span>' + control.label + '</span>'
|
206
|
+
|
207
|
+
|
208
|
+
const field = document.createElement('input');
|
209
|
+
field.type = 'checkbox';
|
210
|
+
field.id = 'prep-' + control.control;
|
211
|
+
|
212
|
+
field.onchange = (e) => {
|
213
|
+
initialRoomState[control.control] = e.target.checked
|
214
|
+
}
|
215
|
+
|
216
|
+
label.appendChild(field);
|
217
|
+
prepCheckboxesParent.appendChild(label)
|
218
|
+
|
219
|
+
})
|
220
|
+
|
221
|
+
prepButton.onclick = () => {
|
222
|
+
prepBlock.style.display = 'none'
|
223
|
+
controlsBlock.style.display = 'block'
|
224
|
+
|
225
|
+
const roomVBType = document.getElementById('room-vb-type');
|
226
|
+
roomVBType.value = VBstate.type;
|
227
|
+
|
228
|
+
const roomVBValue= document.getElementById('room-vb-value');
|
229
|
+
roomVBValue.value = VBstate.value;
|
230
|
+
|
231
|
+
const roomVBEnforce = document.getElementById('room-vb-enforced');
|
232
|
+
roomVBEnforce.checked = VBstate.enforce;
|
233
|
+
|
234
|
+
createControl()
|
235
|
+
}
|
236
|
+
|
237
|
+
prepUsernameInput.onchange = (e) => {
|
238
|
+
initialRoomState.username = e.target.value
|
239
|
+
}
|
240
|
+
|
241
|
+
const vbStateToInitState = (originalConfig) => {
|
242
|
+
if(!originalConfig) return undefined;
|
243
|
+
|
244
|
+
return {
|
245
|
+
[originalConfig.type]: originalConfig.value,
|
246
|
+
enforce: originalConfig.enforce
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
const createControl = () => {
|
251
|
+
initialRoomState.virtualBackground = vbStateToInitState(initialRoomState.virtualBackground)
|
252
|
+
|
253
|
+
const api = DigitalSambaEmbedded.createControl({ url: ROOM_URL, root: parent, roomSettings: initialRoomState });
|
254
|
+
|
255
|
+
const log = document.querySelector('.log');
|
256
|
+
|
257
|
+
api.frame.width = 900;
|
258
|
+
api.frame.height = 700;
|
259
|
+
|
260
|
+
btn0.onclick = () => {api.load({ frameAttributes: {style: "border: 5px solid red"}, reportErrors: true })}
|
261
|
+
|
262
|
+
api.on('*', (data) => {
|
263
|
+
log.innerHTML += `<p>${Number(new Date)}: ev(${data?.type}): ${JSON.stringify(data)}</p>`
|
264
|
+
});
|
265
|
+
|
266
|
+
api.on('frameLoaded', () => {
|
267
|
+
document.querySelector('.room-vb-fields').style.display = 'block'
|
268
|
+
})
|
269
|
+
|
270
|
+
const stateBlock = document.querySelector('.state');
|
271
|
+
|
272
|
+
api.on('roomStateUpdated', ({data}) => {
|
273
|
+
stateBlock.innerHTML = JSON.stringify(data);
|
274
|
+
})
|
275
|
+
|
276
|
+
enableVBButton.onclick = () => {
|
277
|
+
console.warn(vbStateToInitState(VBstate),'---')
|
278
|
+
api.configureVirtualBackground(vbStateToInitState(VBstate));
|
279
|
+
}
|
280
|
+
|
281
|
+
disableVBButton.onclick = () => {
|
282
|
+
api.disableVirtualBackground()
|
283
|
+
}
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
</script>
|
288
|
+
|
289
|
+
</body>
|
290
|
+
</html>
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitalsamba/embedded-sdk",
|
3
3
|
"packageManager": "yarn@3.1.0",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.19",
|
5
5
|
"license": "BSD-2-Clause",
|
6
6
|
"scripts": {
|
7
7
|
"build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types",
|
@@ -11,6 +11,10 @@
|
|
11
11
|
"build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json",
|
12
12
|
"prepare": "husky install"
|
13
13
|
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "https://github.com/digitalsamba/embedded-sdk.git"
|
17
|
+
},
|
14
18
|
"main": "dist/cjs/index.js",
|
15
19
|
"module": "dist/esm/index.js",
|
16
20
|
"umd:main": "dist/umd/index.js",
|