@enplug/sdk-player
Advanced tools
@@ -1,2 +0,2 @@ | ||
var enplug=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t){e.exports={name:"@enplug/sdk-player",version:"0.8.9",description:"Enplug Player SDK",main:"./src/index.ts",typings:"./src/index.d.ts",scripts:{clean:"rimraf dist/ && mkdirp dist",lint:"tslint -c tslint.json './src/**/*.ts' -e './**/*.d.ts'",test:"karma start test/karma.conf.js",bundle:"npm run clean && webpack",start:"npm-run-all clean lint test",release:"npm run bundle && enplug-release-sdk","release-dev":"npm run bundle && enplug-release-sdk --dev"},repository:{type:"git",url:"git+https://github.com/Enplug/sdk.git"},keywords:["Enplug"],author:"Enplug",license:"ISC",bugs:{url:"https://github.com/Enplug/sdk/issues"},files:["src/","dist/"],homepage:"https://github.com/Enplug/sdk#readme",devDependencies:{"@enplug/scripts":"1.1.15-beta2","@types/jasmine":"^2.6.0","@types/node":"^8.0.45","command-line-args":"^4.0.7","es6-shim":"^0.35.3",fs:"0.0.1-security",inquirer:"^3.2.0","jasmine-core":"^2.8.0",karma:"^1.7.1","karma-chrome-launcher":"^2.2.0","karma-jasmine":"^1.1.0","karma-phantomjs-launcher":"~1.0.4","karma-phantomjs-shim":"~1.5.0","karma-spec-reporter":"0.0.31","karma-typescript":"~3.0.7",mkdirp:"^0.5.1","npm-run-all":"^4.1.1",path:"^0.12.7",rimraf:"^2.6.2",s3:"^4.4.0",shelljs:"^0.7.8","ts-loader":"^3.1.1",tslint:"^5.7.0",typescript:"^2.5.3","uglifyjs-webpack-plugin":"^1.0.1",webpack:"^3.8.1"},config:{destination:"sdk/v1",destinationDev:"sdk/dev",aws:{buckets:["apps.enplug.in","apps.enplug.com"],s3:{cache:!1,overwrite:!0,region:"us-west-2",sslEnabled:!0,apiVersion:"2016-05-01",params:{ACL:"public-read"}}}}}},function(e,t,n){var r,i;r=[n,t,n(0)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.version=n.version,this.resolveMap=new Map}return e.prototype.dispose=function(){this.resolveMap=null,this.playerEvents=null,this.version=null,this.destroyCallbackFn=null},e.prototype.send=function(e,t,n){var r=this,i=this.getQueryParam("apptoken"),o=this.createToken(),s=this.getAppUrl(),a={service:e,action:t,payload:n,token:o,appToken:i,appUrl:s,playerSdkVersion:this.version};return this.validateOutboundMessage(a)?new Promise(function(e,t){r.resolveMap.set(o,[e,t]),r.sendToPlayer(a)}):Promise.reject("[Enplug SDK: "+this.version+"] Message invalid.")},e.prototype.setDestroyHandler=function(e){this.destroyCallbackFn=e},e.prototype.receive=function(e){if(e.token&&this.resolveMap.has(e.token)){var t=this.resolveMap.get(e.token);this.dispatchMessageToApp(e,t)}else"event"===e.service&&this.dispatchEvent(e)},e.prototype.setEventsBus=function(e){this.playerEvents=e},e.prototype.getQueryParam=function(e){var t=new URL(window.location.href).searchParams;return t?t.get(e):""},e.prototype.validateOutboundMessage=function(e){return e&&null!=e.service&&null!=e.action},e.prototype.dispatchMessageToApp=function(e,t){var n=t[0],r=t[1];"error"===e.action?(console.log("[Enplug SDK: "+this.version+"] Error received: "+e.payload.message),r(e.payload)):"reload"===e.action?window.location.reload():n(e.payload)},e.prototype.dispatchEvent=function(e){var t=this;if("destroy"===e.action){var n=function(){var e=t.send("status","destroy-finished");return t.destroyCallbackFn&&t.destroyCallbackFn(),e};this.playerEvents.fireEvent(e.action,n)}else this.playerEvents.fireEvent(e.action,e.payload)},e.prototype.createToken=function(){var e=Math.random().toString(36).substr(2);return this.resolveMap.has(e)?this.createToken():e},e.prototype.getAppUrl=function(){return""+window.location.host+window.location.pathname},e}();t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r,i;r=[n,t,n(0),n(4),n(5),n(6),n(7),n(3),n(8),n(9),n(10),n(11),n(12)],void 0!==(i=function(e,t,n,r,i,o,s,a,u,l,p,c,d){"use strict";function f(e){var t,f=n.version;e._epBridge?(console.log("[Enplug SDK: "+f+"] Creating bridge from standard implementation (JavaBridge)."),t=new s.default(e._epBridge)):e._epBridgeSend?(console.log("[Enplug SDK: "+f+"] Creating bridge from CEF implementation (CefBridge)."),t=new o.default(e._epBridgeSend)):(console.log("[Enplug SDK: "+f+"] No global sender found. Assuming WebPlayer (WebBridge)."),t=new d.default),t.setDestroyHandler(function(){console.log("[Enplug SDK] Disposing Player SDK."),h.dispose(),g.dispose(),t.dispose(),v.dispose(),y.dispose(),b.dispose(),m.dispose(),_.dispose(),h=null,g=null,t=null,v=null,y=null,b=null,m=null,_=null;var e=document.querySelectorAll("script");if(e&&e.length)for(var n=0;n<e.length;n++){var r=e[n],i=r.parentNode;i&&i.removeChild(r)}e=null}.bind(this));var h=new r.default(t),g=new i.default(t),v=new u.default(t),y=new a.default(t),b=new l.default(t),m=new p.default(t),_=new c.default(t);return{appStatus:h,assets:g,notifications:y,off:v.off.bind(v),on:v.on.bind(v),once:v.once.bind(v),playRecorder:b,settings:m,social:_}}Object.defineProperty(t,"__esModule",{value:!0}),t.createEnplugPlayerSDK=f,t.default=f(window)}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r;void 0!==(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.dispose=function(){this.bridge=null},e.prototype.post=function(e){return this.bridge.send("notification","post",{message:e}).then(function(e){return e?e.notificationId:""})},e}();t.default=n}.apply(t,[n,t]))&&(e.exports=r)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.canInterruptInternal=!0,this.version=n.version}return e.prototype.dispose=function(){this.bridge=null,this.version=null,this.canInterruptInternal=null},e.prototype.start=function(){return this.bridge.send("status","start")},e.prototype.hide=function(){return this.bridge.send("status","hide")},e.prototype.error=function(){return this.bridge.send("status","error")},e.prototype.setCanInterrupt=function(e){var t=this;if("boolean"!=typeof e)return Promise.reject(new TypeError("[Enplug SDK: "+this.version+"] You can only set canInterrupt to a boolean value"));var n=this.canInterruptInternal;return this.canInterruptInternal=e,this.bridge.send("status","set-interrupt",{canInterrupt:e}).then(function(){return e},function(e){return t.canInterruptInternal=n,n})},Object.defineProperty(e.prototype,"canInterrupt",{get:function(){return Promise.resolve(this.canInterruptInternal)},enumerable:!0,configurable:!0}),e.prototype.getTrigger=function(){return this.bridge.send("status","get-trigger")},e}();t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r;void 0!==(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.dispose=function(){this.bridge=null},e.prototype.getList=function(){return this.bridge.send("asset","get-list")},e.prototype.getNext=function(){return this.bridge.send("asset","get-next")},e.prototype.getAsset=function(){return this.bridge.send("asset","get-asset")},e.prototype.getTheme=function(){return this.bridge.send("asset","get-theme")},e}();t.default=n}.apply(t,[n,t]))&&(e.exports=r)},function(e,t,n){var r,i,o=this&&this.__extends||function(){var e=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])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();r=[n,t,n(1)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var n=e.call(this)||this;return n.cefGlobalSend=t,window._epBridge={receive:n.receive.bind(n)},n}return o(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),window._epBridge.receive=null},t.prototype.sendToPlayer=function(e){return this.cefGlobalSend({request:JSON.stringify(e),persistent:!1})},t.prototype.receive=function(t){try{var n=JSON.parse(t);e.prototype.receive.call(this,n)}catch(e){}},t}(n.default);t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r,i,o=this&&this.__extends||function(){var e=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])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();r=[n,t,n(1)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var n=e.call(this)||this;return n.javaGlobal=t,n.javaGlobal.receive=n.receive.bind(n),n}return o(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this.javaGlobal.receive=null,this.javaGlobal=null},t.prototype.sendToPlayer=function(e){this.javaGlobal.send(JSON.stringify(e))},t.prototype.receive=function(t){try{var n=JSON.parse(t);e.prototype.receive.call(this,n)}catch(e){}},t}(n.default);t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.handlerMap=new Map,this.version=n.version,this.bridge.setEventsBus(this)}return e.prototype.dispose=function(){var e=this;this.bridge=null,this.version=null,this.handlerMap.forEach(function(t,n){t.forEach(function(t){e.off(n,t)}),t=null}),this.handlerMap=null},e.prototype.on=function(e,t){this.checkArgumentTypes(e,t),this.handlerMap.has(e)?this.handlerMap.get(e).add(t):this.handlerMap.set(e,new Set([t])),this.bridge.send("event","set-listener",{eventName:e})},e.prototype.off=function(e,t){if(this.checkArgumentTypes(e,t),this.handlerMap.has(e)){var n=this.handlerMap.get(e);n.has(t)&&n.delete(t)}},e.prototype.once=function(e,t){var n=this;this.checkArgumentTypes(e,t);var r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n.off(e,r),t.apply(void 0,i)};this.on(e,r)},e.prototype.fireEvent=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this.handlerMap.get(e);r&&r.forEach(function(e){e.apply(void 0,t)})},e.prototype.checkArgumentTypes=function(e,t){if(null==e||"string"!=typeof e)throw new TypeError("[Enplug SDK: "+this.version+"] An event name is required to attach an event handler");if(null==t||"function"!=typeof t)throw new TypeError("[Enplug SDK: "+this.version+"] A handler function is required for .on/.off/.once")},e}();t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r;void 0!==(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.dispose=function(){this.bridge=null},e.prototype.report=function(e,t,n,r){void 0===r&&(r="");var i={assetId:e,referenceId:t,playDuration:n};return""!==r&&(i.additionalInfo=r),this.bridge.send("playrecorder","report",i)},e}();t.default=n}.apply(t,[n,t]))&&(e.exports=r)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.version=n.version}return e.prototype.dispose=function(){this.bridge=null,this.version=null,this.is4KCache=null},Object.defineProperty(e.prototype,"all",{get:function(){var e=this;return this.bridge.send("settings","get-all").then(function(t){return console.log("[Enplug SDK: "+e.version+"] Settings: Returning all settings: "+t),t})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"is4K",{get:function(){var e=this;return this.is4KCache?Promise.resolve(this.is4K):this.bridge.send("settings","is4K").then(function(t){return console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting is4k: "+(t&&t.value)),e.is4KCache=t.value,e.is4KCache},function(){return!1})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transitionType",{get:function(){var e=this;return this.bridge.send("settings","transition-type").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting transition-type: "+(t&&t.value)),t.value):"NONE"},function(){return"NONE"})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"whitelabel",{get:function(){var e=this;return this.bridge.send("settings","get-whitelabel").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting whitelabel: "+(t&&t.value)),t.value):""},function(){return""})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isMuted",{get:function(){var e=this;return this.bridge.send("settings","is-muted").then(function(t){return!(!t||!t.value)&&(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting is-muted: "+(t&&t.value)),t.value)},function(){return!1})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoning",{get:function(){var e=this;return this.bridge.send("settings","get-zoning-info").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning zoning info: "+t.value),t.value):null})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"locale",{get:function(){var e=this;return this.bridge.send("settings","get-locale").then(function(t){if(!t||!t.value)return"en";console.log("[Enplug SDK: "+e.version+"] Settings: Returning locale info: "+t.value)})},enumerable:!0,configurable:!0}),e}();t.default=r}.apply(t,r))&&(e.exports=i)},function(e,t,n){var r;void 0!==(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.dispose=function(){this.bridge=null},e.prototype.getItems=function(){return this.bridge.send("social","get-items")},e}();t.default=n}.apply(t,[n,t]))&&(e.exports=r)},function(e,t,n){var r,i,o=this&&this.__extends||function(){var e=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])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();r=[n,t,n(1)],void 0!==(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(){var t=e.call(this)||this;return t.destination=t.getQueryParam("origin"),window.epBridge={receive:t.receive.bind(t)},window.addEventListener("message",t.handleIframeMessage.bind(t)),t}return o(t,e),t.prototype.dispose=function(){window.removeEventListener("message",this.handleIframeMessage.bind(this)),this.destination=null,window.epBridge.receive=null,e.prototype.dispose.call(this)},t.prototype.handleIframeMessage=function(e){e.origin===this.destination&&this.receive(e.data)},t.prototype.sendToPlayer=function(e){var t=this.destination.startsWith("file://")?"*":this.destination;parent.postMessage(e,t)},t.prototype.validateOutboundMessage=function(t){return e.prototype.validateOutboundMessage.call(this,t)},t}(n.default);t.default=r}.apply(t,r))&&(e.exports=i)}]).default; | ||
var enplug=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},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){e.exports={name:"@enplug/sdk-player",version:"0.9.14-dev-1",description:"Enplug Player SDK",main:"./src/index.ts",typings:"./src/index.d.ts",scripts:{clean:"rimraf dist/ && mkdirp dist",lint:"tslint -c tslint.json './src/**/*.ts' -e './**/*.d.ts'",test:"karma start test/karma.conf.js",bundle:"npm run clean && webpack",start:"npm-run-all clean lint test",release:"npm run bundle && enplug-release-sdk","release:dev":"npm run bundle && enplug-release-sdk --dev"},repository:{type:"git",url:"git+https://github.com/Enplug/sdk.git"},keywords:["Enplug"],author:"Enplug",license:"ISC",bugs:{url:"https://github.com/Enplug/sdk/issues"},files:["src/","dist/"],homepage:"https://github.com/Enplug/sdk#readme",devDependencies:{"@enplug/scripts":"1.1.15-beta2","@types/jasmine":"^2.6.0","@types/node":"^8.0.45","command-line-args":"^4.0.7","es6-shim":"^0.35.3",fs:"0.0.1-security",inquirer:"^3.2.0","jasmine-core":"^2.8.0",karma:"^1.7.1","karma-chrome-launcher":"^2.2.0","karma-jasmine":"^1.1.0","karma-phantomjs-launcher":"~1.0.4","karma-phantomjs-shim":"~1.5.0","karma-spec-reporter":"0.0.31","karma-typescript":"~3.0.7",mkdirp:"^0.5.1","npm-run-all":"^4.1.1",path:"^0.12.7",rimraf:"^2.6.2",s3:"^4.4.0",shelljs:"^0.7.8","ts-loader":"^3.1.1",tslint:"^5.7.0",typescript:"^2.5.3","uglifyjs-webpack-plugin":"^1.0.1",webpack:"^3.8.1"},config:{destination:"sdk/v1",destinationDev:"sdk/dev",aws:{buckets:["apps.enplug.in","apps.enplug.com"],s3:{cache:!1,overwrite:!0,region:"us-west-2",sslEnabled:!0,apiVersion:"2016-05-01",params:{ACL:"public-read"}}}}}},function(e,t,n){var r,i;r=[n,t,n(0)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.version=n.version,this.resolveMap=new Map}return e.prototype.send=function(e,t,n){var r=this,i=this.getQueryParam("apptoken"),o=this.createToken(),s=this.getAppUrl(),a={service:e,action:t,payload:n,token:o,appToken:i,appUrl:s,playerSdkVersion:this.version};return this.validateOutboundMessage(a)?new Promise(function(e,t){r.resolveMap.set(o,[e,t]),r.sendToPlayer(a)}):Promise.reject("[Enplug SDK: "+this.version+"] Message invalid.")},e.prototype.receive=function(e){if(e&&"object"==typeof e.payload&&!Array.isArray(e.payload)&&(e.payload=this.replaceMediaUrlsWithBlobUrls(e.payload)),e&&Array.isArray(e.payload)){for(var t=[],n=0,r=e.payload;n<r.length;n++){var i=r[n],o=this.replaceMediaUrlsWithBlobUrls(i);t.push(o)}e.payload=t}if(e.token&&this.resolveMap.has(e.token)){var s=this.resolveMap.get(e.token);this.dispatchMessageToApp(e,s)}else"event"===e.service&&this.dispatchEvent(e)},e.prototype.replaceMediaUrlsWithBlobUrls=function(e,t){if(!e)return e;if(!(t=t||e.blobs)||!t.size)return e;for(var n in e)e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]&&"blobs"!==n?e[n]=this.replaceMediaUrlsWithBlobUrls(e[n],t):t.has(e[n])&&(e[n]=window.URL.createObjectURL(t.get(e[n]))));return e},e.prototype.setEventsBus=function(e){this.playerEvents=e},e.prototype.getQueryParam=function(e){var t=new URL(window.location.href).searchParams;return t?t.get(e):""},e.prototype.validateOutboundMessage=function(e){return e&&null!=e.service&&null!=e.action},e.prototype.dispatchMessageToApp=function(e,t){var n=t[0],r=t[1];"error"===e.action?(console.log("[Enplug SDK: "+this.version+"] Error received: "+e.payload.message),r(e.payload)):"reload"===e.action?window.location.reload():n(e.payload)},e.prototype.dispatchEvent=function(e){var t=this;if("destroy"===e.action){this.playerEvents.fireEvent(e.action,function(){return t.send("status","destroy-finished")})}else this.playerEvents.fireEvent(e.action,e.payload)},e.prototype.createToken=function(){var e=Math.random().toString(36).substr(2);return this.resolveMap.has(e)?this.createToken():e},e.prototype.getAppUrl=function(){return""+window.location.host+window.location.pathname},e}();t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r,i;r=[n,t,n(0),n(4),n(5),n(6),n(7),n(3),n(8),n(9),n(10),n(11),n(12)],void 0===(i=function(e,t,n,r,i,o,s,a,u,p,l,c,d){"use strict";function f(e){var t,f=n.version;e._epBridge?(console.log("[Enplug SDK: "+f+"] Creating bridge from standard implementation (JavaBridge)."),t=new s.default(e._epBridge)):e._epBridgeSend?(console.log("[Enplug SDK: "+f+"] Creating bridge from CEF implementation (CefBridge)."),t=new o.default(e._epBridgeSend)):(console.log("[Enplug SDK: "+f+"] No global sender found. Assuming WebPlayer (WebBridge)."),t=new d.default);var g=new r.default(t),h=new i.default(t),v=new u.default(t),y=new a.default(t),b=new p.default(t),m=new l.default(t),_=new c.default(t);return{appStatus:g,assets:h,notifications:y,off:v.off.bind(v),on:v.on.bind(v),once:v.once.bind(v),playRecorder:b,settings:m,social:_}}Object.defineProperty(t,"__esModule",{value:!0}),t.createEnplugPlayerSDK=f,t.default=f(window)}.apply(t,r))||(e.exports=i)},function(e,t,n){var r;void 0===(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.post=function(e){return this.bridge.send("notification","post",{message:e}).then(function(e){return e?e.notificationId:""})},e}();t.default=n}.apply(t,[n,t]))||(e.exports=r)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.canInterruptInternal=!0,this.version=n.version}return e.prototype.start=function(){return this.bridge.send("status","start")},e.prototype.hide=function(){return this.bridge.send("status","hide")},e.prototype.error=function(){return this.bridge.send("status","error")},e.prototype.setCanInterrupt=function(e){var t=this;if("boolean"!=typeof e)return Promise.reject(new TypeError("[Enplug SDK: "+this.version+"] You can only set canInterrupt to a boolean value"));var n=this.canInterruptInternal;return this.canInterruptInternal=e,this.bridge.send("status","set-interrupt",{canInterrupt:e}).then(function(){return e},function(e){return t.canInterruptInternal=n,n})},Object.defineProperty(e.prototype,"canInterrupt",{get:function(){return Promise.resolve(this.canInterruptInternal)},enumerable:!0,configurable:!0}),e.prototype.getTrigger=function(){return this.bridge.send("status","get-trigger")},e}();t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r;void 0===(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.downloadFile=function(e){return this.bridge.send("asset","download-file",{url:e}).then(function(t){return t?window.URL.createObjectURL(t):e})},e.prototype.getList=function(){return this.bridge.send("asset","get-list")},e.prototype.getNext=function(){return this.bridge.send("asset","get-next")},e.prototype.getAsset=function(){return this.bridge.send("asset","get-asset")},e.prototype.getTheme=function(){return this.bridge.send("asset","get-theme")},e}();t.default=n}.apply(t,[n,t]))||(e.exports=r)},function(e,t,n){var r,i,o,s=this&&this.__extends||(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])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});r=[n,t,n(1)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var n=e.call(this)||this;return n.cefGlobalSend=t,window._epBridge={receive:n.receive.bind(n)},n}return s(t,e),t.prototype.sendToPlayer=function(e){return this.cefGlobalSend({request:JSON.stringify(e),persistent:!1})},t.prototype.receive=function(t){try{var n=JSON.parse(t);e.prototype.receive.call(this,n)}catch(e){}},t}(n.default);t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r,i,o,s=this&&this.__extends||(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])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});r=[n,t,n(1)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var n=e.call(this)||this;return n.javaGlobal=t,n.javaGlobal.receive=n.receive.bind(n),n}return s(t,e),t.prototype.sendToPlayer=function(e){this.javaGlobal.send(JSON.stringify(e))},t.prototype.receive=function(t){try{var n=JSON.parse(t);e.prototype.receive.call(this,n)}catch(e){}},t}(n.default);t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.handlerMap=new Map,this.version=n.version,this.bridge.setEventsBus(this)}return e.prototype.on=function(e,t){this.checkArgumentTypes(e,t),this.handlerMap.has(e)?this.handlerMap.get(e).add(t):this.handlerMap.set(e,new Set([t])),this.bridge.send("event","set-listener",{eventName:e})},e.prototype.off=function(e,t){if(this.checkArgumentTypes(e,t),this.handlerMap.has(e)){var n=this.handlerMap.get(e);n.has(t)&&n.delete(t)}},e.prototype.once=function(e,t){var n=this;this.checkArgumentTypes(e,t);var r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n.off(e,r),t.apply(void 0,i)};this.on(e,r)},e.prototype.fireEvent=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this.handlerMap.get(e);r&&r.forEach(function(e){e.apply(void 0,t)})},e.prototype.checkArgumentTypes=function(e,t){if(null==e||"string"!=typeof e)throw new TypeError("[Enplug SDK: "+this.version+"] An event name is required to attach an event handler");if(null==t||"function"!=typeof t)throw new TypeError("[Enplug SDK: "+this.version+"] A handler function is required for .on/.off/.once")},e}();t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r;void 0===(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.report=function(e,t,n,r){void 0===r&&(r="");var i={assetId:e,referenceId:t,playDuration:n};return""!==r&&(i.additionalInfo=r),this.bridge.send("playrecorder","report",i)},e}();t.default=n}.apply(t,[n,t]))||(e.exports=r)},function(e,t,n){var r,i;r=[n,t,n(0)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.bridge=e,this.version=n.version}return Object.defineProperty(e.prototype,"all",{get:function(){var e=this;return this.bridge.send("settings","get-all").then(function(t){return console.log("[Enplug SDK: "+e.version+"] Settings: Returning all settings: "+t),t})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"is4K",{get:function(){var e=this;return this.is4KCache?Promise.resolve(this.is4K):this.bridge.send("settings","is4K").then(function(t){return console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting is4k: "+(t&&t.value)),e.is4KCache=t.value,e.is4KCache},function(){return!1})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transitionType",{get:function(){var e=this;return this.bridge.send("settings","transition-type").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting transition-type: "+(t&&t.value)),t.value):"NONE"},function(){return"NONE"})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"whitelabel",{get:function(){var e=this;return this.bridge.send("settings","get-whitelabel").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting whitelabel: "+(t&&t.value)),t.value):""},function(){return""})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isMuted",{get:function(){var e=this;return this.bridge.send("settings","is-muted").then(function(t){return!(!t||!t.value)&&(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting is-muted: "+(t&&t.value)),t.value)},function(){return!1})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoning",{get:function(){var e=this;return this.bridge.send("settings","get-zoning-info").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning zoning info: "+t.value),t.value):null})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"locale",{get:function(){var e=this;return this.bridge.send("settings","get-locale").then(function(t){if(!t||!t.value)return"en";console.log("[Enplug SDK: "+e.version+"] Settings: Returning locale info: "+t.value)})},enumerable:!0,configurable:!0}),e}();t.default=r}.apply(t,r))||(e.exports=i)},function(e,t,n){var r;void 0===(r=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.bridge=e}return e.prototype.getFeeds=function(){return this.bridge.send("social","get-feeds")},e.prototype.getItems=function(){return this.bridge.send("social","get-items")},e}();t.default=n}.apply(t,[n,t]))||(e.exports=r)},function(e,t,n){var r,i,o,s=this&&this.__extends||(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])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});r=[n,t,n(1)],void 0===(i=function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(){var t=e.call(this)||this;return t.destination=t.getQueryParam("origin"),window.epBridge={receive:t.receive.bind(t)},window.addEventListener("message",t.handleIframeMessage.bind(t)),t}return s(t,e),t.prototype.handleIframeMessage=function(e){if(e.origin===this.destination){var t=e.data;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(n){t=e.data}this.receive(t)}},t.prototype.sendToPlayer=function(e){var t=this.destination.startsWith("file://")?"*":this.destination;parent.postMessage(e,t)},t.prototype.validateOutboundMessage=function(t){return e.prototype.validateOutboundMessage.call(this,t)},t}(n.default);t.default=r}.apply(t,r))||(e.exports=i)}]).default; | ||
//# sourceMappingURL=player.js.map |
{ | ||
"name": "@enplug/sdk-player", | ||
"version": "0.8.9", | ||
"version": "0.9.15.1", | ||
"description": "Enplug Player SDK", | ||
@@ -14,3 +14,3 @@ "main": "./src/index.ts", | ||
"release": "npm run bundle && enplug-release-sdk", | ||
"release-dev": "npm run bundle && enplug-release-sdk --dev" | ||
"release:dev": "npm run bundle && enplug-release-sdk --dev" | ||
}, | ||
@@ -17,0 +17,0 @@ "repository": { |
@@ -16,8 +16,2 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
this.version = null; | ||
this.canInterruptInternal = null; | ||
} | ||
start(): Promise<boolean> { | ||
@@ -24,0 +18,0 @@ return this.bridge.send(Service.AppStatus, Action.Start); |
@@ -13,6 +13,10 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
downloadFile(url: string): Promise<string> { | ||
return this.bridge.send(Service.Assets, Action.DownloadFile, {url}).then((blob: Blob) => { | ||
if (blob) { | ||
return window.URL.createObjectURL(blob); | ||
} | ||
return url; | ||
}); | ||
} | ||
getList(): Promise<any[]> { | ||
@@ -19,0 +23,0 @@ return this.bridge.send(Service.Assets, Action.GetList); |
@@ -21,13 +21,5 @@ /** | ||
private playerEvents: PlayerEvents; | ||
private destroyCallbackFn: () => void; | ||
constructor() { } | ||
dispose() { | ||
this.resolveMap = null; | ||
this.playerEvents = null; | ||
this.version = null; | ||
this.destroyCallbackFn = null; | ||
} | ||
/** | ||
@@ -66,10 +58,2 @@ * Validates the data to be sent to the player and sends them. | ||
/** | ||
* Sets function which will be called when the underlying app calls its done() callback following the destroy event. | ||
* @param {Function} callbackFn | ||
*/ | ||
setDestroyHandler(callbackFn: () => void) { | ||
this.destroyCallbackFn = callbackFn; | ||
} | ||
/** | ||
* Handles incoming message and dispatches it for apps consumption. | ||
@@ -79,2 +63,16 @@ * @param {InboundMessage} message A message that arrived from the player. | ||
receive(message: InboundMessage) { | ||
// Payload is of type object but not an array | ||
if (message && typeof message.payload === 'object' && !Array.isArray(message.payload)) { | ||
message.payload = this.replaceMediaUrlsWithBlobUrls(message.payload); | ||
} | ||
// Payload is an array. | ||
if (message && Array.isArray(message.payload)) { | ||
const updatedPayload = []; | ||
for (const data of message.payload) { | ||
const updatedData = this.replaceMediaUrlsWithBlobUrls(data); | ||
updatedPayload.push(updatedData); | ||
} | ||
message.payload = updatedPayload; | ||
} | ||
if (message.token && this.resolveMap.has(message.token)) { | ||
@@ -89,2 +87,28 @@ const promiseResolutionFunctions = this.resolveMap.get(message.token); | ||
/** | ||
* Recursively iterates through a given object and replaces all of the instances of media URLs | ||
* (specified in a blobs map) with an ObjectURL. | ||
* @param data - Object within which all of media URLs are replaced with ObjectURLs | ||
* @param blobs - Optional mapping of media URLs to Blobs. | ||
*/ | ||
replaceMediaUrlsWithBlobUrls(data: any, blobs?: Map<string, Blob>): any { | ||
if (!data) { | ||
return data; | ||
} | ||
blobs = blobs || data.blobs; | ||
if (!blobs || !blobs.size) { | ||
return data; | ||
} | ||
for (const key in data) { | ||
if (data.hasOwnProperty(key)) { | ||
if (data[key] && typeof data[key] === 'object' && key !== 'blobs') { | ||
data[key] = this.replaceMediaUrlsWithBlobUrls(data[key], blobs); | ||
} else if (blobs.has(data[key])) { | ||
data[key] = window.URL.createObjectURL(blobs.get(data[key])); | ||
} | ||
} | ||
} | ||
return data; | ||
} | ||
/** | ||
* Actually sends the data to the player. Concrete implementation depends on the player type. | ||
@@ -150,7 +174,3 @@ * @param message | ||
const done = () => { | ||
const sendResponse = this.send(Service.Status, Action.DestroyFinished); | ||
if (this.destroyCallbackFn) { | ||
this.destroyCallbackFn(); | ||
} | ||
return sendResponse; | ||
return this.send(Service.Status, Action.DestroyFinished); | ||
}; | ||
@@ -157,0 +177,0 @@ this.playerEvents.fireEvent(message.action, done); |
@@ -19,7 +19,2 @@ /** | ||
public dispose() { | ||
super.dispose(); | ||
window['_epBridge'].receive = null; | ||
} | ||
sendToPlayer(message: OutboundMessage) { | ||
@@ -26,0 +21,0 @@ return this.cefGlobalSend({ |
@@ -15,8 +15,2 @@ /** | ||
public dispose() { | ||
super.dispose(); | ||
this.javaGlobal.receive = null; | ||
this.javaGlobal = null; | ||
} | ||
sendToPlayer(message: OutboundMessage) { | ||
@@ -23,0 +17,0 @@ this.javaGlobal.send(JSON.stringify(message)); |
@@ -23,12 +23,13 @@ /** | ||
public dispose() { | ||
window.removeEventListener('message', this.handleIframeMessage.bind(this)); | ||
this.destination = null; | ||
window['epBridge'].receive = null; | ||
super.dispose(); | ||
} | ||
handleIframeMessage(event: any) { | ||
if (event.origin === this.destination) { | ||
this.receive(event.data); | ||
let incomingMessage = event.data; | ||
if (typeof event.data === 'string') { | ||
try { | ||
incomingMessage = JSON.parse(event.data); | ||
} catch (e) { | ||
incomingMessage = event.data; | ||
} | ||
} | ||
this.receive(incomingMessage); | ||
} | ||
@@ -35,0 +36,0 @@ } |
@@ -27,2 +27,3 @@ /** | ||
// Assets | ||
DownloadFile = 'download-file', | ||
GetAsset = 'get-asset', | ||
@@ -51,2 +52,3 @@ GetList = 'get-list', | ||
// Social | ||
GetFeeds = 'get-feeds', | ||
GetItems = 'get-items', | ||
@@ -53,0 +55,0 @@ } |
@@ -15,2 +15,3 @@ /** | ||
namespace assets { | ||
const downloadFile: (url: string) => Promise<string>; | ||
const getList: () => Promise<any[]>; | ||
@@ -37,5 +38,6 @@ const getNext: () => Promise<any>; | ||
const getItems: () => Promise<any[]>; | ||
const getFeeds: () => Promise<any[]>; | ||
} | ||
const on: (eventName: string, eventHandler: (...args) => any) => void; | ||
const off: (eventName: string) => void; | ||
const off: (eventName: string, eventHandler: (...args) => any) => void; | ||
const once: (eventName: string, eventHandler: (...args) => any) => void; | ||
@@ -42,0 +44,0 @@ } |
@@ -38,50 +38,10 @@ /** | ||
bridge.setDestroyHandler(dispose.bind(this)); | ||
const appStatus = new AppStatus(bridge); | ||
const assets = new Assets(bridge); | ||
const events = new PlayerEvents(bridge); | ||
const notifications = new Notifications(bridge); | ||
const playRecorder = new PlayRecorder(bridge); | ||
const settings = new Settings(bridge); | ||
const social = new Social(bridge); | ||
let appStatus = new AppStatus(bridge); | ||
let assets = new Assets(bridge); | ||
let events = new PlayerEvents(bridge); | ||
let notifications = new Notifications(bridge); | ||
let playRecorder = new PlayRecorder(bridge); | ||
let settings = new Settings(bridge); | ||
let social = new Social(bridge); | ||
/** | ||
* Disposes created objects. | ||
*/ | ||
function dispose() { | ||
console.log(`[Enplug SDK] Disposing Player SDK.`); | ||
appStatus.dispose(); | ||
assets.dispose(); | ||
bridge.dispose(); | ||
events.dispose(); | ||
notifications.dispose(); | ||
playRecorder.dispose(); | ||
settings.dispose(); | ||
social.dispose(); | ||
appStatus = null; | ||
assets = null; | ||
bridge = null; | ||
events = null; | ||
notifications = null; | ||
playRecorder = null; | ||
settings = null; | ||
social = null; | ||
/* tslint:disable */ | ||
let scripts = document.querySelectorAll('script'); | ||
if (scripts && scripts.length) { | ||
for (let i = 0; i < scripts.length; i++) { | ||
const script = scripts[i]; | ||
const parentNode = script.parentNode; | ||
if (parentNode) { | ||
parentNode.removeChild(script); | ||
} | ||
} | ||
} | ||
scripts = null; | ||
/* tslint:enable */ | ||
} | ||
return { | ||
@@ -88,0 +48,0 @@ appStatus, |
@@ -43,3 +43,3 @@ /** | ||
}) | ||
.catch(() => { | ||
.catch((error) => { | ||
console.warn(`[<% app_name %>|enplug-offline-worker] Error adding static resources to cache ${config.cacheVersion}.`, error); | ||
@@ -85,2 +85,7 @@ }) | ||
self.addEventListener('fetch', (event) => { | ||
// Ignore POST requests | ||
if (event.request.method === 'POST') { | ||
return false; | ||
} | ||
// Get rid of the app token to generalize URL for caching. Having unique URLs for each request | ||
@@ -90,2 +95,9 @@ // will only make the cache get bigger over time. | ||
for (const noCacheUrl of config.noCacheUrls) { | ||
if (event.request.url.indexOf(noCacheUrl) >= 0) { | ||
return false; | ||
} | ||
} | ||
console.log(`[<% app_name %>|enplug-offline-worker] URL to cache: ${cacheUrl}`); | ||
var cacheRequest = new Request(cacheUrl, { | ||
@@ -148,23 +160,2 @@ mode: 'cors' | ||
} | ||
// When a cors request fails, attempt to fetch using no-cors. | ||
var noCorsRequest = new Request(event.request.url, { | ||
mode: 'no-cors' | ||
}); | ||
return fetch(noCorsRequest).then((noCorsResponse) => { | ||
if (noCorsResponse) { | ||
var noCorsResponseToCache = noCorsResponse.clone(); | ||
caches.open(config.cacheVersion).then( | ||
// Cache response and update the time of caching this particular request. | ||
(cache) => { | ||
console.log(`[<% app_name %>|enplug-offline-worker] Caching ${cacheUrl}.`); | ||
cache.put(cacheRequest, noCorsResponseToCache); | ||
setCachedTime(cacheUrl); | ||
}, | ||
(error) => console.warn(`[<% app_name %>|enplug-offline-worker] Unable to cache no-cors response ${cacheUrl}`, error) | ||
); | ||
return noCorsResponse; | ||
} | ||
}); | ||
}); | ||
@@ -171,0 +162,0 @@ })); |
@@ -12,6 +12,2 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
} | ||
post(message: string): Promise<string> { | ||
@@ -18,0 +14,0 @@ return this.bridge.send(Service.Notifications, Action.Post, { message }).then((payload) => { |
@@ -14,6 +14,2 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
} | ||
report(assetId: string, referenceId: any, playDuration: number, additionalInfo: string = '') { | ||
@@ -20,0 +16,0 @@ // The typing lets us add properties dynamically. |
@@ -19,14 +19,2 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
this.version = null; | ||
this.handlerMap.forEach((eventHandlers: Set<any>, eventName: string) => { | ||
eventHandlers.forEach((eventHandler: any) => { | ||
this.off(eventName, eventHandler); | ||
}); | ||
eventHandlers = null; | ||
}); | ||
this.handlerMap = null; | ||
} | ||
/** | ||
@@ -33,0 +21,0 @@ * Lets apps listen for events. The events are triggered by messages with `service == 'event` coming from the player |
@@ -17,8 +17,2 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
this.version = null; | ||
this.is4KCache = null; | ||
} | ||
get all(): Promise<any> { | ||
@@ -25,0 +19,0 @@ return this.bridge.send(Service.Settings, Action.GetAll).then((payload: any) => { |
@@ -11,4 +11,4 @@ /** | ||
dispose() { | ||
this.bridge = null; | ||
getFeeds(): Promise<any[]> { | ||
return this.bridge.send(Service.Social, Action.GetFeeds); | ||
} | ||
@@ -15,0 +15,0 @@ |
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
99000
1.03%20
5.26%1162
4.12%3
50%