meet-addons-devtools
Version:
Set of tools helping developing addons for Meet.rs
1 lines • 15 kB
JavaScript
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s,i,a=n(1);!function(e){e.READY="meet-sdk-ready",e.INIT="meet-sync-init",e.DATA="meet-message-data",e.PARTICIPANTS="meet-message-participants",e.MEET_STATE="meet-state-changed",e.TOOLTIPS="meet-tooltip-reqest",e.ADDON_MODE="meet-addonmode-change",e.REPOSITION="meet-float-reposition",e.USER_PROFILE="meet-userprofile-changed"}(s=t.MessageType||(t.MessageType={})),function(e){e.HIDDEN="hidden",e.MINI="mini",e.NORMAL="normal",e.FULLSCREEN="fullscreen"}(i=t.AddonMode||(t.AddonMode={})),function(e){e.DARK_INDIGO="#303F9F",e.DEEP_ORANGE="#FF5722",e.DARK_GREEN="#388E3C",e.DARK_YELLOW="#FBC02D",e.DEEP_PURPLE="#512DA8",e.DARK_PINK="#C2185B",e.DARK_TEAL="#00796B"}(t.PredefinedColor||(t.PredefinedColor={}));var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(a.ParticipantInfo);t.ParticipantJoinInfo=c;var l=function(){};t.ParticipantLeaveInfo=l,function(e){e.MEETING_DRAFT="MeetingDraft",e.MEETING_CREATED="MeetingCreated",e.MEETING_CANCELED="MeetingCanceled",e.MEETING_ARCHIVED="MeetingArchived",e.SCHEDULING_TIME="SchedulingTime",e.SCHEDULING_FAILED="SchedulingFailed",e.SCHEDULING_COMPLETED="SchedulingCompleted",e.MEETING_STARTED="MeetingStarted",e.MEETING_FAILED="MeetingFailed",e.MEETING_STOPPED="MeetingStopped",e.MEETING_COMPLETED="MeetingCompleted",e.FEEDBACK_COLLECTING="FeedbackCollecting",e.FEEDBACK_FAILED="FeedbackFailed",e.FEEDBACK_COMPLETED="FeedbackCompleted",e.BILLABLE_STARTED="BillableStarted",e.BILLABLE_STOPPED="BillableStopped"}(t.PredefinedMeetingState||(t.PredefinedMeetingState={}));var d=function(){};t.AddonMessage=d;var u=function(e){function t(){var t=e.call(this)||this;return t.mode=i.NORMAL,t.type=s.INIT,t}return r(t,e),t}(d);t.InitMessage=u;var f=function(e){function t(){var t=e.call(this)||this;return t.type=s.READY,t}return r(t,e),t}(d);t.ReadyMessage=f},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=function(){};t.TokenInfo=s;var i=function(){};t.ConfigurationItem=i;var a=function(){};t.HostInfo=a;var c=function(){this.theme="dark"};t.ParticipantUserInfo=c;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(c);t.ParticipantInfo=l;var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(l);t.PrincipalInfo=d},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,o=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(3),i=n(4);o(void 0,void 0,void 0,(function(){var e,t,n,o,a,c,l,d,u,f;return r(this,(function(r){switch(r.label){case 0:return e=window,console.log("[Meet|DevTools]::> START",e.vivani),(n=new Promise((function(e){t=e}))).then(),e.vivani=e.vivani||{},e.vivani.devTools=e.vivani.devTools||{getSessionToken:function(){return n}},o=localStorage.getItem("meet-dev-sdk-host"),a=localStorage.getItem("meet-dev-sdk-addon-id"),o&&a?[4,(c=new s.TokenService).getTenantTokenAsync()]:[2,Promise.reject("[Meet|DevTools]:To use token service please define in local storage meet-dev-sdk-host and meet-dev-sdk-addon-id")];case 1:return l=r.sent(),[4,c.getSessionTokenAsync(l.access_token,a)];case 2:return d=r.sent(),t&&(console.log("[Meet|DevTools]::> w.vivani.getSessionToken -> resolving",d),t(d)),console.log("[Meet|DevTools]::> w.vivani",e.vivani),e.vivani.sdk?"1"===(localStorage.getItem("meet-dev-sdk-type")||"1")?[3,3]:(console.log("[Meet|DevTools]::> not in addon mode - skipping initialization of addon sdk"),[3,5]):[3,5];case 3:return[4,c.getAddonRuntimeInfoAsync(d.token.access_token)];case 4:u=r.sent(),f={configuration:[],mode:i.AddonMode.NORMAL,participants:[],host:{authHost:o.replace("/v1",""),origin:o.replace("/v1","")},principal:{addonIdentifier:a,color:"#303F9F",displayName:"FirstName LastName",isGuest:!1,sessionId:u.sessionId,sessionUserId:u.sessionUserId,sessionUserRole:u.sessionUserRole,tenant:u.tenant,theme:"dark",token:u.token},settings:u.settings,state:i.PredefinedMeetingState.MEETING_STARTED,type:i.MessageType.INIT},console.log("[Meet|DevTools]::> AddonsSdk.onInit",e.vivani),e.vivani.sdk.onInit(f),r.label=5;case 5:return[2]}}))})).then((function(){return console.log("[Meet|DevTools]::> END")}))},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,o=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var s=function(){var e=this;this.getAddonRuntimeInfoAsync=function(t){return o(e,void 0,void 0,(function(){var e,n;return r(this,(function(o){switch(o.label){case 0:return e=localStorage.getItem("meet-dev-sdk-host"),n=localStorage.getItem("meet-dev-sdk-addon-id"),e&&n?[4,fetch(e+"/meetingAddons/"+n,{headers:{Authorization:"bearer "+t,"Content-Type":"application/json"},method:"GET"})]:[2,Promise.reject("[Meet|DevTools]:To use token service please define in local storage meet-dev-sdk-host and meet-dev-sdk-addon-id")];case 1:return[4,o.sent().json()];case 2:return[2,o.sent()]}}))}))},this.getSessionTokenAsync=function(t,n){return o(e,void 0,void 0,(function(){var e,o,s,i,a;return r(this,(function(r){switch(r.label){case 0:if(!(e=localStorage.getItem("meet-dev-sdk-host")))return[2,Promise.reject("[Meet|DevTools]:To use token service please define in local storage meet-dev-sdk-host, meet-dev-sdk-key and meet-dev-sdk-secret")];switch(o=parseInt(localStorage.getItem("meet-dev-sdk-type")||"1")){case 1:return[3,1];case 2:return[3,3]}return[3,6];case 1:return[4,this.createMeetingAsync(n,t)];case 2:return s=r.sent(),[3,6];case 3:return[4,this.createMeetingAsync(n,t)];case 4:return i=r.sent(),[4,this.createEventAsync(i,t)];case 5:return s=r.sent(),[3,6];case 6:return[4,fetch(e+"/token/session/"+s+"/"+o,{headers:{Authorization:"bearer "+t,"Content-Type":"application/json"},method:"GET"})];case 7:return[4,r.sent().json()];case 8:return a=r.sent(),[2,Promise.resolve({token:a,resourceType:o,resourceId:s})]}}))}))},this.getTenantTokenAsync=function(){return o(e,void 0,void 0,(function(){var e,t,n,o;return r(this,(function(r){switch(r.label){case 0:return e=localStorage.getItem("meet-dev-sdk-host"),t=localStorage.getItem("meet-dev-sdk-key"),n=localStorage.getItem("meet-dev-sdk-secret"),e&&t&&n?[4,fetch(e+"/token",{body:JSON.stringify({grant_type:"client_credentials",client_key:t,client_secret:n}),headers:{"Content-Type":"application/json"},method:"POST"})]:[2,Promise.reject("[Meet|DevTools]:To use token service please define in local storage meet-dev-sdk-host, meet-dev-sdk-key and meet-dev-sdk-secret")];case 1:return(o=r.sent()).ok?[4,o.json()]:[3,3];case 2:return[2,r.sent()];case 3:return[2,Promise.reject("[Meet|DevTools]:Invalid credentials meet-dev-sdk-host, meet-dev-sdk-key and meet-dev-sdk-secret")]}}))}))},this.createMeetingAsync=function(t,n){return o(e,void 0,void 0,(function(){var e,o,s,i;return r(this,(function(r){switch(r.label){case 0:return e=localStorage.getItem("meet-dev-sdk-host"),o=localStorage.getItem("meet-dev-sdk-code"),s={code:o,addonsInfo:[{identifier:t}]},o||delete s.code,[4,fetch(e+"/meetings",{body:JSON.stringify(s),headers:{Authorization:"bearer "+n,"Content-Type":"application/json"},method:"POST"})];case 1:return[4,r.sent().json()];case 2:return i=r.sent(),localStorage.setItem("meet-dev-sdk-code",i.code),[2,i.code]}}))}))},this.createEventAsync=function(t,n){return o(e,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e=localStorage.getItem("meet-dev-sdk-host"),o={notifyParticipants:!1,title:"Test event for meet:"+t,description:"Description of the test event",resolutionMode:"fifo",originId:t,participants:[{email:"test-proposer@meet.rs",firstName:"Test",lastName:"Proposer",role:"PowerUser",order:0,timezone:"America/Los_Angeles"},{email:"test-selector@meet.rs",firstName:"Test",lastName:"Selector",role:"User",order:1,timezone:"Europe/Belgrade"}]},[4,fetch(e+"/events",{body:JSON.stringify(o),headers:{Authorization:"bearer "+n,"Content-Type":"application/json"},method:"POST"})];case 1:return[4,r.sent().json()];case 2:return[2,r.sent().code]}}))}))}};t.TokenService=s},function(e,t,n){"use strict";function o(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0});var r,s=n(0);o(n(1)),o(n(0)),function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Errors=9]="Errors"}(r=t.LogLevel||(t.LogLevel={}));var i=function(){function e(){var e=this;this.logging=r.Errors,this.handleReceivedMessage=function(t){if(e.logging<=r.Trace&&console.log("[SDK][Index]::handleReceivedMessage",t),t&&t.source!==window&&t.data&&t.origin)if(e.host&&e.host.origin&&t.origin!==e.host.origin)e.logging<=r.Trace&&console.warn("[SDK][Index]::handleReceivedMessage-invalid message origin",t);else{var n=JSON.parse(t.data);if(n&&n.type){switch(n.type){case s.MessageType.INIT:var o=n;return e.preprocessInitMessage(o),void e.onInit(o);case s.MessageType.DATA:case s.MessageType.READY:case s.MessageType.TOOLTIPS:case s.MessageType.PARTICIPANTS:case s.MessageType.MEET_STATE:case s.MessageType.ADDON_MODE:case s.MessageType.REPOSITION:case s.MessageType.USER_PROFILE:e.logging<=r.Trace&&console.log("[SDK][Index]::handleReceivedMessage-switch",n.type,n);break;default:e.logging<=r.Debug&&e.errorHandler("[AddonsSdk]:onReceived - Unknown host message of type:"+n.type)}e.logging<=r.Trace&&console.log("[SDK][Index]::handleReceivedMessage-onMessage->",n),e.onMessage(n)}else e.logging<=r.Trace&&console.warn("[SDK][Index]::handleReceivedMessage-invalid message data",t)}else e.logging<=r.Trace&&console.warn("[SDK][Index]::handleReceivedMessage-invalid source, data ot origin",t)},this.onInit=this.preprocessInitMessage,this.onMessage=function(t){e.logging<=r.Trace&&console.log("[SDK][onMessage]-NOP",t)},this.errorHandler=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];console.error(["[SDK][ErrorHandler]-NOP",e,t])},this.logging<=r.Debug&&console.log("[SDK][Index]::ctor - observing messages: *",postMessage),window.addEventListener("message",this.handleReceivedMessage)}return e.prototype.ready=function(){var e=JSON.stringify(new s.ReadyMessage);this.logging<=r.Debug&&console.log("[SDK][Index]::ready - origin: *",e),window.parent.postMessage(e,"*")},e.prototype.sendMessage=function(e){if(this.host){var t=JSON.stringify(e);this.logging<=r.Debug&&console.warn("[SDK][Index]::sendMessage",t,this.host.origin),window.parent.postMessage(t,this.host.origin)}else this.errorHandler("You can not send messages before SDK is initialized")},e.prototype.preprocessInitMessage=function(e){this.host=e.host,this.logging<=r.Trace&&console.log("[SDK][Index]::preprocessInitMessage-> host",this.host)},e}();t.AddonsSdk=i;var a=window;a.vivani=a.vivani||{},a.vivani.sdk=a.vivani.sdk||new i,t.default=a.vivani.sdk}]);