@enplug/sdk-player
Advanced tools
Comparing version 0.10.3 to 0.10.8
1138
dist/player.js
@@ -1,2 +0,1138 @@ | ||
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.10.3",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.6.0","@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:"^6.0.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),n(13)],void 0===(i=function(e,t,n,r,i,o,s,a,u,p,l,c,d,f){"use strict";function g(e){var t,g=n.version;e._epBridge?(console.log("[Enplug SDK: "+g+"] Creating bridge from standard implementation (JavaBridge)."),t=new a.default(e._epBridge)):e._epBridgeSend?(console.log("[Enplug SDK: "+g+"] Creating bridge from CEF implementation (CefBridge)."),t=new s.default(e._epBridgeSend)):(console.log("[Enplug SDK: "+g+"] No global sender found. Assuming WebPlayer (WebBridge)."),t=new f.default);var h=new r.default(t),v=new i.default(t),y=new o.default(t),b=new p.default(t),m=new u.default(t),_=new l.default(t),w=new c.default(t),O=new d.default(t);return{appStatus:h,assets:v,cache:y,notifications:m,off:b.off.bind(b),on:b.on.bind(b),once:b.once.bind(b),playRecorder:_,settings:w,social:O}}Object.defineProperty(t,"__esModule",{value:!0}),t.createEnplugPlayerSDK=g,t.default=g(window)}.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.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.prototype.toggleSound=function(e){return this.bridge.send("status","toggle-sound",{enabled:e})},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.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;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.getFile=function(e){return this.bridge.send("cache","get-file",e).then(function(t){return t?window.URL.createObjectURL(t):e})},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;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.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: "+JSON.stringify(t)),t})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceId",{get:function(){var e=this;return this.bridge.send("settings","get-deviceid").then(function(t){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning setting deviveId: "+(t&&t.value)),t.value):""},function(){return""})},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: "+JSON.stringify(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){return t&&t.value?(console.log("[Enplug SDK: "+e.version+"] Settings: Returning locale info: "+JSON.stringify(t.value)),t.value):"en"})},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; | ||
var enplug = | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts"); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ "./package.json": | ||
/*!**********************!*\ | ||
!*** ./package.json ***! | ||
\**********************/ | ||
/*! exports provided: name, version, description, main, typings, scripts, repository, keywords, author, license, bugs, files, homepage, devDependencies, config, default */ | ||
/***/ (function(module) { | ||
module.exports = {"name":"@enplug/sdk-player","version":"0.10.8","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","bundle:prod":"npm run clean && webpack --env.production","start":"npm-run-all clean lint test","release":"npm run bundle && enplug-release-sdk","release:prod":"npm run bundle:prod && 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.9.1","@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":"^6.0.0","jasmine":"^3.3.1","jasmine-core":"^2.99.1","karma":"^1.7.1","karma-chrome-launcher":"^2.2.0","karma-jasmine":"^1.1.2","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":"^6.2.1","tslint":"^5.7.0","typescript":"^2.9.2","uglifyjs-webpack-plugin":"^2.2.0","webpack":"^4.41.2","webpack-cli":"^3.3.1"},"config":{"destination":"sdk/v1","destinationDev":"sdk/dev/","aws":{"buckets":["apps.enplug.in","apps.enplug.com"],"s3":{"cache":false,"overwrite":true,"region":"us-west-2","sslEnabled":true,"apiVersion":"2016-05-01","params":{"ACL":"public-read"}}}}}; | ||
/***/ }), | ||
/***/ "./src/app-status.ts": | ||
/*!***************************!*\ | ||
!*** ./src/app-status.ts ***! | ||
\***************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ../package.json */ "./package.json")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, pkg) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var AppStatus = /** @class */ (function () { | ||
function AppStatus(bridge) { | ||
this.bridge = bridge; | ||
this.canInterruptInternal = true; | ||
this.version = pkg.version; | ||
} | ||
/** | ||
* Registers a service worker to enable offline support for the app. | ||
* @param appId - Optional app ID. Appended to logs for easier debugging. | ||
* @param swFilePath - Optional path to the service worker file. Defaults to Enplug apps' 'enplug-offline-worker.js' | ||
* @returns - Promise resolves when service worker registration was a success. It rejects when it was a failure. | ||
*/ | ||
AppStatus.prototype.registerServiceWorker = function (appId, swFilePath) { | ||
var SW_TAG = appId ? "[" + appId + " | Service Worker]" : '[Service Worker]'; | ||
swFilePath = swFilePath || './enplug-offline-worker.js'; | ||
return new Promise(function (resolve, reject) { | ||
if ('serviceWorker' in navigator && | ||
navigator.userAgent.indexOf('iPad') < 0 && | ||
navigator.userAgent.indexOf('iPhone') < 0) { | ||
navigator.serviceWorker.register(swFilePath).then(function (registration) { | ||
console.log(SW_TAG + " ServiceWorker registration successful with scope: ", registration.scope); | ||
// We need to check whether service worker is in a non-active state. If so, we listen for a state change | ||
// to "active". | ||
var sw = registration.installing || registration.waiting; | ||
// Possible states: | ||
// installing - the install event has fired, but not yet complete | ||
// installed - install complete | ||
// activating - the activate event has fired, but not yet complete | ||
// activated - fully active | ||
// redundant - discarded. Either failed install, or it's been replaced by a newer version | ||
if (sw) { | ||
sw.addEventListener('statechange', function (state) { | ||
if (registration.active) { | ||
console.log(SW_TAG + " Service worker has become active."); | ||
resolve(); | ||
} | ||
}); | ||
} | ||
else if (!sw && registration.active) { | ||
// Service worker is already active. No need to wait for statechange. This will always be true when | ||
// we're offline. | ||
console.log(SW_TAG + " Service worker is active."); | ||
resolve(); | ||
} | ||
}, function (err) { | ||
// Registration failed | ||
console.warn(SW_TAG + "ServiceWorker registration failed: " + err, err); | ||
reject(SW_TAG + " Error registering service worker: " + JSON.stringify(err)); | ||
}); | ||
} | ||
else { | ||
reject(SW_TAG + " Browser does not support service workers. User agent: " + navigator.userAgent); | ||
} | ||
}); | ||
}; | ||
AppStatus.prototype.start = function () { | ||
return this.bridge.send("status" /* AppStatus */, "start" /* Start */); | ||
}; | ||
AppStatus.prototype.hide = function () { | ||
return this.bridge.send("status" /* AppStatus */, "hide" /* Hide */); | ||
}; | ||
AppStatus.prototype.error = function (errorMessage) { | ||
return this.bridge.send("status" /* AppStatus */, "error" /* Error */, errorMessage); | ||
}; | ||
AppStatus.prototype.setCanInterrupt = function (canInterrupt) { | ||
var _this = this; | ||
// The SDK is compiled to regular JS and this method might be called with a wrong type. | ||
if (typeof canInterrupt !== 'boolean') { | ||
return Promise.reject(new TypeError("[Enplug SDK: " + this.version + "] You can only set canInterrupt to a boolean value")); | ||
} | ||
// Optimistic update before we send the new value to the bridge. | ||
// We still need to retain the old value in case of an error from the backend. | ||
var previousCanInterrupt = this.canInterruptInternal; | ||
this.canInterruptInternal = canInterrupt; | ||
return this.bridge.send("status" /* AppStatus */, "set-interrupt" /* SetInterrupt */, { canInterrupt: canInterrupt }).then(function () { | ||
return canInterrupt; | ||
}, function (error) { | ||
_this.canInterruptInternal = previousCanInterrupt; | ||
return previousCanInterrupt; | ||
}); | ||
}; | ||
Object.defineProperty(AppStatus.prototype, "canInterrupt", { | ||
/** | ||
* Handles `enplug.status.canInterrupt`. | ||
*/ | ||
get: function () { | ||
return Promise.resolve(this.canInterruptInternal); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Handles `enplug.status.getTrigger()` used by social apps. | ||
*/ | ||
AppStatus.prototype.getTrigger = function () { | ||
return this.bridge.send("status" /* AppStatus */, "get-trigger" /* GetTrigger */); | ||
}; | ||
/** | ||
* Handles `enplug.status.toggleSound()` calls. | ||
*/ | ||
AppStatus.prototype.toggleSound = function (enabled) { | ||
return this.bridge.send("status" /* AppStatus */, "toggle-sound" /* ToggleSound */, { enabled: enabled }); | ||
}; | ||
AppStatus.prototype.listenForTouchEvents = function (body) { | ||
var _this = this; | ||
if (body) { | ||
body.addEventListener('click', function () { | ||
console.log("[Player SDK] Screen was touched."); | ||
_this.bridge.send("status" /* AppStatus */, "screen-touched" /* ScreenTouched */); | ||
}, true); | ||
} | ||
}; | ||
return AppStatus; | ||
}()); | ||
exports.default = AppStatus; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/assets.ts": | ||
/*!***********************!*\ | ||
!*** ./src/assets.ts ***! | ||
\***********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Assets = /** @class */ (function () { | ||
function Assets(bridge) { | ||
this.bridge = bridge; | ||
} | ||
Assets.prototype.getList = function () { | ||
return this.bridge.send("asset" /* Assets */, "get-list" /* GetList */); | ||
}; | ||
Assets.prototype.getNext = function () { | ||
return this.bridge.send("asset" /* Assets */, "get-next" /* GetNext */); | ||
}; | ||
Assets.prototype.getAsset = function () { | ||
return this.bridge.send("asset" /* Assets */, "get-asset" /* GetAsset */); | ||
}; | ||
Assets.prototype.getTheme = function () { | ||
return this.bridge.send("asset" /* Assets */, "get-theme" /* GetTheme */); | ||
}; | ||
return Assets; | ||
}()); | ||
exports.default = Assets; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/bridge/bridge.ts": | ||
/*!******************************!*\ | ||
!*** ./src/bridge/bridge.ts ***! | ||
\******************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ../../package.json */ "./package.json")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, pkg) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Bridge = /** @class */ (function () { | ||
function Bridge() { | ||
this.version = pkg.version; | ||
this.resolveMap = new Map(); | ||
} | ||
/** | ||
* Validates the data to be sent to the player and sends them. | ||
* It assigns a `token` to the request. It creates and returns a promise, which resolve functions are stored in | ||
* `resolveMap` property. These are fired when `receive` method gets a respose with matching `token`. | ||
* @param {Service} service Informing the player of the kind od request being sent here. | ||
* @param {Action} action Informing the player of the specific action to be taken upon this request. | ||
* @param {any} payload Additional data to be sent along the request. | ||
*/ | ||
Bridge.prototype.send = function (service, action, payload) { | ||
var _this = this; | ||
var appToken = this.getQueryParam('apptoken'); | ||
var token = this.createToken(); | ||
var appUrl = this.getAppUrl(); | ||
var message = { | ||
service: service, | ||
action: action, | ||
payload: payload, | ||
token: token, | ||
appToken: appToken, | ||
appUrl: appUrl, | ||
playerSdkVersion: this.version, | ||
}; | ||
if (this.validateOutboundMessage(message)) { | ||
return new Promise(function (resolve, reject) { | ||
_this.resolveMap.set(token, [resolve, reject]); | ||
_this.sendToPlayer(message); | ||
}); | ||
} | ||
else { | ||
return Promise.reject("[Enplug SDK: " + this.version + "] Message invalid."); | ||
} | ||
}; | ||
/** | ||
* Handles incoming message and dispatches it for apps consumption. | ||
* @param {InboundMessage} message A message that arrived from the player. | ||
*/ | ||
Bridge.prototype.receive = function (message) { | ||
// 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)) { | ||
var updatedPayload = []; | ||
for (var _i = 0, _a = message.payload; _i < _a.length; _i++) { | ||
var data = _a[_i]; | ||
var updatedData = this.replaceMediaUrlsWithBlobUrls(data); | ||
updatedPayload.push(updatedData); | ||
} | ||
message.payload = updatedPayload; | ||
} | ||
// Reload is not initiated by an App. As such, it doesn't need to dispatch any responses to it. | ||
if (message.action === "reload" /* Reload */) { | ||
return window.location.reload(); | ||
} | ||
if (message.token && this.resolveMap.has(message.token)) { | ||
var promiseResolutionFunctions = this.resolveMap.get(message.token); | ||
this.dispatchMessageToApp(message, promiseResolutionFunctions); | ||
} | ||
else if (message.service === "event" /* Event */) { | ||
this.dispatchEvent(message); | ||
} | ||
}; | ||
/** | ||
* 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. | ||
*/ | ||
Bridge.prototype.replaceMediaUrlsWithBlobUrls = function (data, blobs) { | ||
if (!data) { | ||
return data; | ||
} | ||
var blobUrls = {}; | ||
blobs = blobs || data.blobs; | ||
if (!blobs || !blobs.size) { | ||
return data; | ||
} | ||
for (var 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])) { | ||
var originalUrl = data[key]; | ||
data[key] = window.URL.createObjectURL(blobs.get(data[key])); | ||
blobUrls[data[key]] = originalUrl; | ||
} | ||
} | ||
} | ||
data['blobUrls'] = blobUrls; | ||
return data; | ||
}; | ||
/** | ||
* Sets the PlayerEvents instance for this bridge for player events passing. | ||
* @param {PlayerEvents} playerEvents | ||
*/ | ||
Bridge.prototype.setEventsBus = function (playerEvents) { | ||
this.playerEvents = playerEvents; | ||
}; | ||
/** | ||
* Gets a value from URL query by key. | ||
* @param {string} key | ||
*/ | ||
Bridge.prototype.getQueryParam = function (key) { | ||
var params = (new URL(window.location.href)).searchParams; | ||
return params ? params.get(key) : ''; | ||
}; | ||
/** | ||
* Checks whether the message is good to be sent. | ||
* @param {OutboundMessage} message | ||
*/ | ||
Bridge.prototype.validateOutboundMessage = function (message) { | ||
return message && message.service != null && message.action != null; | ||
}; | ||
/** | ||
* Takes appropriate action depending on a message type. | ||
* If the message has `isError` flag set, it will call the `reject` function. | ||
* If the message has `Reload` action, it will reload the browser window. | ||
* Otherwise, it will call resolve function. | ||
* @param {InboubdMessage} message | ||
* @param {Function[]} promiseResolutionFunctions A resolve and reject funtions in an array. | ||
*/ | ||
Bridge.prototype.dispatchMessageToApp = function (message, promiseResolutionFunctions) { | ||
var resolve = promiseResolutionFunctions[0], reject = promiseResolutionFunctions[1]; | ||
if (message.action === "error" /* Error */) { | ||
console.log("[Enplug SDK: " + this.version + "] Error received: " + JSON.stringify(message)); | ||
reject(message && message.payload); | ||
} | ||
else { | ||
resolve(message && message.payload); | ||
} | ||
}; | ||
/** | ||
* Deals with incoming events. The action parameter will be used as a event name and handlers | ||
* for that event name will be fired. If the event name is `destroy`, the handler parameters will be set to a `done` | ||
* function. | ||
* @param message | ||
*/ | ||
Bridge.prototype.dispatchEvent = function (message) { | ||
var _this = this; | ||
// In case of action === 'destroy', the argument passed to the event handler has to be a "done" callback. | ||
if (message.action === "destroy" /* Destroy */) { | ||
var done = function () { | ||
return _this.send("status" /* Status */, "destroy-finished" /* DestroyFinished */); | ||
}; | ||
this.playerEvents.fireEvent(message.action, done); | ||
} | ||
else { | ||
this.playerEvents.fireEvent(message.action, message.payload); | ||
} | ||
}; | ||
/** | ||
* Creates a unique string token. | ||
*/ | ||
Bridge.prototype.createToken = function () { | ||
var token = Math.random().toString(36).substr(2); | ||
// Make sure a unique token is created. If created token already exists, create a different one. | ||
if (this.resolveMap.has(token)) { | ||
return this.createToken(); | ||
} | ||
return token; | ||
}; | ||
/** | ||
* Returns a value for `appUrl` property in the outbound message. | ||
*/ | ||
Bridge.prototype.getAppUrl = function () { | ||
return "" + window.location.host + window.location.pathname; | ||
}; | ||
return Bridge; | ||
}()); | ||
exports.default = Bridge; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/bridge/cef-bridge.ts": | ||
/*!**********************************!*\ | ||
!*** ./src/bridge/cef-bridge.ts ***! | ||
\**********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, bridge_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var CefBridge = /** @class */ (function (_super) { | ||
__extends(CefBridge, _super); | ||
function CefBridge(cefGlobalSend) { | ||
var _this = _super.call(this) || this; | ||
_this.cefGlobalSend = cefGlobalSend; | ||
/*tslint:disable:no-string-literal*/ | ||
window['_epBridge'] = { | ||
receive: _this.receive.bind(_this), | ||
}; | ||
return _this; | ||
} | ||
CefBridge.prototype.sendToPlayer = function (message) { | ||
return this.cefGlobalSend({ | ||
request: JSON.stringify(message), | ||
persistent: false, | ||
}); | ||
}; | ||
/** | ||
* CefPlayer will send a string message that needs to be parsed into InboundMessage before processing further. | ||
* NOTE: While the `message` is known be a string, Typescript doesn't allow to change the type of the parameter | ||
* in the subclass method, so we have to go with `any`. | ||
* @param {any} message | ||
*/ | ||
CefBridge.prototype.receive = function (message) { | ||
try { | ||
var jsonMessage = JSON.parse(message); | ||
_super.prototype.receive.call(this, jsonMessage); | ||
} | ||
catch (e) { | ||
// Ignore the message silently. | ||
} | ||
}; | ||
return CefBridge; | ||
}(bridge_1.default)); | ||
exports.default = CefBridge; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/bridge/java-bridge.ts": | ||
/*!***********************************!*\ | ||
!*** ./src/bridge/java-bridge.ts ***! | ||
\***********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, bridge_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var JavaBridge = /** @class */ (function (_super) { | ||
__extends(JavaBridge, _super); | ||
function JavaBridge(javaGlobal) { | ||
var _this = _super.call(this) || this; | ||
_this.javaGlobal = javaGlobal; | ||
_this.javaGlobal.receive = _this.receive.bind(_this); | ||
return _this; | ||
} | ||
JavaBridge.prototype.sendToPlayer = function (message) { | ||
this.javaGlobal.send(JSON.stringify(message)); | ||
}; | ||
/** | ||
* Java player will send a string message that needs to be parsed into InboundMessage before processing further. | ||
* NOTE: While the `message` is known be a string, Typescript doesn't allow to change the type of the parameter | ||
* in the subclass method, so we have to go with `any`. | ||
* @param {any} message | ||
*/ | ||
JavaBridge.prototype.receive = function (message) { | ||
try { | ||
var jsonMessage = JSON.parse(message); | ||
_super.prototype.receive.call(this, jsonMessage); | ||
} | ||
catch (e) { | ||
// Ignore the message silently. | ||
} | ||
}; | ||
return JavaBridge; | ||
}(bridge_1.default)); | ||
exports.default = JavaBridge; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/bridge/web-bridge.ts": | ||
/*!**********************************!*\ | ||
!*** ./src/bridge/web-bridge.ts ***! | ||
\**********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts"), __webpack_require__(/*! ../environment/environment */ "./src/environment/environment.ts")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, bridge_1, environment_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var WebBridge = /** @class */ (function (_super) { | ||
__extends(WebBridge, _super); | ||
function WebBridge() { | ||
var _this = _super.call(this) || this; | ||
_this.destination = _this.getQueryParam('origin'); | ||
/*tslint:disable:no-string-literal*/ | ||
window['epBridge'] = { | ||
receive: _this.receive.bind(_this), | ||
}; | ||
window.addEventListener('message', _this.handleIframeMessage.bind(_this)); | ||
return _this; | ||
} | ||
WebBridge.prototype.handleIframeMessage = function (event) { | ||
if (event.origin === this.destination) { | ||
var incomingMessage = event.data; | ||
if (typeof event.data === 'string') { | ||
try { | ||
incomingMessage = JSON.parse(event.data); | ||
} | ||
catch (e) { | ||
incomingMessage = event.data; | ||
} | ||
} | ||
this.receive(incomingMessage); | ||
} | ||
else if (event.data && event.data.action === "screen-touched" /* ScreenTouched */) { | ||
var dataWithAppToken = event.data; | ||
dataWithAppToken.appToken = this.getQueryParam('apptoken'); | ||
this.sendToPlayer(dataWithAppToken); | ||
} | ||
}; | ||
WebBridge.prototype.sendToPlayer = function (message) { | ||
// In order to support Electron framework, we need to make sure we can send messages to pages with destination | ||
// which starts with file://. That destination is not supported so, we replace it with a '*'. | ||
var destination = this.destination && this.destination.startsWith('file://') ? '*' : this.destination; | ||
destination = destination || environment_1.environment.appsUrl; | ||
parent.postMessage(message, destination); | ||
}; | ||
WebBridge.prototype.validateOutboundMessage = function (message) { | ||
var validationResult = _super.prototype.validateOutboundMessage.call(this, message); | ||
return validationResult; | ||
}; | ||
return WebBridge; | ||
}(bridge_1.default)); | ||
exports.default = WebBridge; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/cache.ts": | ||
/*!**********************!*\ | ||
!*** ./src/cache.ts ***! | ||
\**********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Cache = /** @class */ (function () { | ||
function Cache(bridge) { | ||
this.bridge = bridge; | ||
} | ||
Cache.prototype.getFile = function (url) { | ||
return this.bridge.send("cache" /* Cache */, "get-file" /* GetFile */, url).then(function (blob) { | ||
if (blob) { | ||
return window.URL.createObjectURL(blob); | ||
} | ||
return url; | ||
}); | ||
}; | ||
return Cache; | ||
}()); | ||
exports.default = Cache; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/environment/environment.ts": | ||
/*!****************************************!*\ | ||
!*** ./src/environment/environment.ts ***! | ||
\****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.environment = { | ||
appsUrl: 'https://apps.enplug.in' | ||
}; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/index.ts": | ||
/*!**********************!*\ | ||
!*** ./src/index.ts ***! | ||
\**********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ../package.json */ "./package.json"), __webpack_require__(/*! ./app-status */ "./src/app-status.ts"), __webpack_require__(/*! ./assets */ "./src/assets.ts"), __webpack_require__(/*! ./cache */ "./src/cache.ts"), __webpack_require__(/*! ./bridge/cef-bridge */ "./src/bridge/cef-bridge.ts"), __webpack_require__(/*! ./bridge/java-bridge */ "./src/bridge/java-bridge.ts"), __webpack_require__(/*! ./notifications */ "./src/notifications.ts"), __webpack_require__(/*! ./player-events */ "./src/player-events.ts"), __webpack_require__(/*! ./play-recorder */ "./src/play-recorder.ts"), __webpack_require__(/*! ./settings */ "./src/settings.ts"), __webpack_require__(/*! ./social */ "./src/social.ts"), __webpack_require__(/*! ./bridge/web-bridge */ "./src/bridge/web-bridge.ts")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, pkg, app_status_1, assets_1, cache_1, cef_bridge_1, java_bridge_1, notifications_1, player_events_1, play_recorder_1, settings_1, social_1, web_bridge_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Creates appropriate bridge version, depending on the detected globals. | ||
*/ | ||
function createEnplugPlayerSDK(window) { | ||
var version = pkg.version; | ||
var bridge; | ||
/* tslint:disable:no-string-literal */ | ||
if (window['_epBridge']) { | ||
console.log("[Enplug SDK: " + version + "] Creating bridge from standard implementation (JavaBridge)."); | ||
bridge = new java_bridge_1.default(window['_epBridge']); | ||
} | ||
else if (window['_epBridgeSend']) { | ||
console.log("[Enplug SDK: " + version + "] Creating bridge from CEF implementation (CefBridge)."); | ||
bridge = new cef_bridge_1.default(window['_epBridgeSend']); | ||
} | ||
else { | ||
console.log("[Enplug SDK: " + version + "] No global sender found. Assuming WebPlayer (WebBridge)."); | ||
bridge = new web_bridge_1.default(); | ||
} | ||
var appStatus = new app_status_1.default(bridge); | ||
var assets = new assets_1.default(bridge); | ||
var cache = new cache_1.default(bridge); | ||
var events = new player_events_1.default(bridge); | ||
var notifications = new notifications_1.default(bridge); | ||
var playRecorder = new play_recorder_1.default(bridge); | ||
var settings = new settings_1.default(bridge); | ||
var social = new social_1.default(bridge); | ||
window.addEventListener('load', function () { | ||
appStatus.listenForTouchEvents(window.document.body); | ||
}); | ||
return { | ||
appStatus: appStatus, | ||
assets: assets, | ||
cache: cache, | ||
notifications: notifications, | ||
off: events.off.bind(events), | ||
on: events.on.bind(events), | ||
once: events.once.bind(events), | ||
playRecorder: playRecorder, | ||
settings: settings, | ||
social: social, | ||
}; | ||
} | ||
exports.createEnplugPlayerSDK = createEnplugPlayerSDK; | ||
/* tslint:disable:variable-name */ | ||
exports.default = createEnplugPlayerSDK(window); | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/notifications.ts": | ||
/*!******************************!*\ | ||
!*** ./src/notifications.ts ***! | ||
\******************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Notifications = /** @class */ (function () { | ||
function Notifications(bridge) { | ||
this.bridge = bridge; | ||
} | ||
Notifications.prototype.post = function (message) { | ||
return this.bridge.send("notification" /* Notifications */, "post" /* Post */, { message: message }).then(function (payload) { | ||
return payload ? payload.notificationId : ''; | ||
}); | ||
}; | ||
return Notifications; | ||
}()); | ||
exports.default = Notifications; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/play-recorder.ts": | ||
/*!******************************!*\ | ||
!*** ./src/play-recorder.ts ***! | ||
\******************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** | ||
* Provides apps with a method to report for how long something was displayed on the screen. | ||
* | ||
* @author Arkadiusz Gochnio (arek@enplug.com) | ||
*/ | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PlayRecorder = /** @class */ (function () { | ||
function PlayRecorder(bridge) { | ||
this.bridge = bridge; | ||
} | ||
PlayRecorder.prototype.report = function (assetId, referenceId, playDuration, additionalInfo) { | ||
if (additionalInfo === void 0) { additionalInfo = ''; } | ||
// The typing lets us add properties dynamically. | ||
var payload = { | ||
assetId: assetId, | ||
referenceId: referenceId, | ||
playDuration: playDuration, | ||
}; | ||
if (additionalInfo !== '') { | ||
payload.additionalInfo = additionalInfo; | ||
} | ||
// TODO: Should this actually return something? | ||
return this.bridge.send("playrecorder" /* PlayRecorder */, "report" /* Report */, payload); | ||
}; | ||
return PlayRecorder; | ||
}()); | ||
exports.default = PlayRecorder; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/player-events.ts": | ||
/*!******************************!*\ | ||
!*** ./src/player-events.ts ***! | ||
\******************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ../package.json */ "./package.json")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, pkg) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PlayerEvents = /** @class */ (function () { | ||
function PlayerEvents(bridge) { | ||
this.bridge = bridge; | ||
this.handlerMap = new Map(); | ||
this.version = pkg.version; | ||
this.bridge.setEventsBus(this); | ||
} | ||
/** | ||
* Lets apps listen for events. The events are triggered by messages with `service == 'event` coming from the player | ||
* through the bridge. | ||
* @param {string} eventName - Name of the event. | ||
* @param {Function} eventHandler - An event handler, called when the event occurs. | ||
*/ | ||
PlayerEvents.prototype.on = function (eventName, eventHandler) { | ||
this.checkArgumentTypes(eventName, eventHandler); | ||
if (this.handlerMap.has(eventName)) { | ||
this.handlerMap.get(eventName).add(eventHandler); | ||
} | ||
else { | ||
this.handlerMap.set(eventName, new Set([eventHandler])); | ||
} | ||
this.bridge.send("event" /* Event */, "set-listener" /* SetListener */, { eventName: eventName }); | ||
}; | ||
/** | ||
* Removes a handler function from listening to the event. | ||
* @param {string} eventName - Name of the event. | ||
* @param {Function} eventHandler - Handler function to remove. | ||
*/ | ||
PlayerEvents.prototype.off = function (eventName, eventHandler) { | ||
this.checkArgumentTypes(eventName, eventHandler); | ||
if (this.handlerMap.has(eventName)) { | ||
var handlerSet = this.handlerMap.get(eventName); | ||
if (handlerSet.has(eventHandler)) { | ||
handlerSet.delete(eventHandler); | ||
} | ||
} | ||
}; | ||
/** | ||
* Lets apps listen for an event. After it occurs once, it removes the listener. | ||
* @param {string} eventName - Name of the event. | ||
* @param {Function} eventHandler - Handler function to fire when the event occurs. | ||
*/ | ||
PlayerEvents.prototype.once = function (eventName, eventHandler) { | ||
var _this = this; | ||
this.checkArgumentTypes(eventName, eventHandler); | ||
var tmpFn = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.off(eventName, tmpFn); | ||
eventHandler.apply(void 0, args); | ||
}; | ||
this.on(eventName, tmpFn); | ||
}; | ||
/** | ||
* Calls all handler functions associated with the event. | ||
* @param {string} eventName - Name of the event. | ||
* @param {ArgumentList} args - All arguments passed to this function besides `eventName`. | ||
*/ | ||
PlayerEvents.prototype.fireEvent = function (eventName) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
var handlerSet = this.handlerMap.get(eventName); | ||
if (handlerSet) { | ||
handlerSet.forEach(function (handler) { | ||
handler.apply(void 0, args); | ||
}); | ||
} | ||
}; | ||
/** | ||
* Checks whether arguments passed to the event pubsub functions are valid. The SDK may be used by JS clients | ||
* without type safety, so this is necessary. | ||
*/ | ||
PlayerEvents.prototype.checkArgumentTypes = function (eventName, eventHandler) { | ||
if (eventName == null || typeof eventName !== 'string') { | ||
throw new TypeError("[Enplug SDK: " + this.version + "] An event name is required to attach an event handler"); | ||
} | ||
if (eventHandler == null || typeof eventHandler !== 'function') { | ||
throw new TypeError("[Enplug SDK: " + this.version + "] A handler function is required for .on/.off/.once"); | ||
} | ||
}; | ||
return PlayerEvents; | ||
}()); | ||
exports.default = PlayerEvents; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/settings.ts": | ||
/*!*************************!*\ | ||
!*** ./src/settings.ts ***! | ||
\*************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ../package.json */ "./package.json")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, pkg) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Settings = /** @class */ (function () { | ||
function Settings(bridge) { | ||
this.bridge = bridge; | ||
this.version = pkg.version; | ||
this.localesMap = { | ||
'ar': 'ar_SA', | ||
'cs': 'cs_CZ', | ||
'de-de': 'de_DE', | ||
'en-us': 'en_US', | ||
'es-es': 'es_ES', | ||
'fi-fi': 'fi_FI', | ||
'fr-fr': 'fr_FR', | ||
'hu': 'hu_HU', | ||
'it-it': 'it_IT', | ||
'ja': 'ja_JP', | ||
'nl-nl': 'nl_NL', | ||
'pl': 'pl_PL', | ||
'pt-br': 'pt_BR', | ||
'ro': 'ro_RO', | ||
'ru': 'ru_RU', | ||
'sk': 'sk_SK', | ||
'sl': 'sl_SI', | ||
'th': 'th_TH', | ||
}; | ||
} | ||
Object.defineProperty(Settings.prototype, "all", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "get-all" /* GetAll */).then(function (payload) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning all settings: " + JSON.stringify(payload)); | ||
if (payload && payload.locale) { | ||
payload.locale = _this.mapLocaleCode(payload.locale); | ||
} | ||
return payload; | ||
}); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "deviceId", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "get-deviceid" /* GetDeviceId */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning setting deviveId: " + (payload && payload.value)); | ||
return payload.value; | ||
} | ||
else { | ||
return ''; | ||
} | ||
}, function () { return ''; }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "is4K", { | ||
get: function () { | ||
var _this = this; | ||
if (this.is4KCache) { | ||
return Promise.resolve(this.is4K); | ||
} | ||
return this.bridge.send("settings" /* Settings */, "is4K" /* Is4K */).then(function (payload) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning setting is4k: " + (payload && payload.value)); | ||
_this.is4KCache = payload.value; | ||
return _this.is4KCache; | ||
}, function () { return false; }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "transitionType", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "transition-type" /* TransitionType */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning setting transition-type: " + (payload && payload.value)); | ||
return payload.value; | ||
} | ||
else { | ||
return "NONE" /* None */; | ||
} | ||
}, function () { return "NONE" /* None */; }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "whitelabel", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "get-whitelabel" /* GetWhitelabel */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning setting whitelabel: " + (payload && payload.value)); | ||
return payload.value; | ||
} | ||
else { | ||
return ''; | ||
} | ||
}, function () { return ''; }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "isMuted", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "is-muted" /* IsMuted */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning setting is-muted: " + (payload && payload.value)); | ||
return payload.value; | ||
} | ||
else { | ||
return false; | ||
} | ||
}, function () { return false; }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "zoning", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "get-zoning-info" /* GetZoningInfo */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning zoning info: " + JSON.stringify(payload.value)); | ||
return payload.value; | ||
} | ||
else { | ||
return null; | ||
} | ||
}); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Settings.prototype, "locale", { | ||
get: function () { | ||
var _this = this; | ||
return this.bridge.send("settings" /* Settings */, "get-locale" /* GetLocale */).then(function (payload) { | ||
if (payload && payload.value) { | ||
console.log("[Enplug SDK: " + _this.version + "] Settings: Returning locale info: " + JSON.stringify(payload.value)); | ||
return _this.mapLocaleCode(payload.value); | ||
} | ||
else { | ||
return 'en'; | ||
} | ||
}); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Maps locale code from the server format to one used by the apps. | ||
* @param {string} locale Locale as sent in the schedule. | ||
*/ | ||
Settings.prototype.mapLocaleCode = function (inputLocale) { | ||
return this.localesMap[inputLocale] ? this.localesMap[inputLocale] : inputLocale; | ||
}; | ||
return Settings; | ||
}()); | ||
exports.default = Settings; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }), | ||
/***/ "./src/social.ts": | ||
/*!***********************!*\ | ||
!*** ./src/social.ts ***! | ||
\***********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Social = /** @class */ (function () { | ||
function Social(bridge) { | ||
this.bridge = bridge; | ||
} | ||
Social.prototype.getFeeds = function () { | ||
return this.bridge.send("social" /* Social */, "get-feeds" /* GetFeeds */); | ||
}; | ||
Social.prototype.getItems = function () { | ||
return this.bridge.send("social" /* Social */, "get-items" /* GetItems */); | ||
}; | ||
return Social; | ||
}()); | ||
exports.default = Social; | ||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
/***/ }) | ||
/******/ })["default"]; | ||
//# sourceMappingURL=player.js.map |
{ | ||
"name": "@enplug/sdk-player", | ||
"version": "0.10.3", | ||
"version": "0.10.8", | ||
"description": "Enplug Player SDK", | ||
@@ -12,4 +12,6 @@ "main": "./src/index.ts", | ||
"bundle": "npm run clean && webpack", | ||
"bundle:prod": "npm run clean && webpack --env.production", | ||
"start": "npm-run-all clean lint test", | ||
"release": "npm run bundle && enplug-release-sdk", | ||
"release:prod": "npm run bundle:prod && enplug-release-sdk", | ||
"release:dev": "npm run bundle && enplug-release-sdk --dev" | ||
@@ -35,3 +37,3 @@ }, | ||
"devDependencies": { | ||
"@enplug/scripts": "^1.6.0", | ||
"@enplug/scripts": "^1.9.1", | ||
"@types/jasmine": "^2.6.0", | ||
@@ -43,6 +45,7 @@ "@types/node": "^8.0.45", | ||
"inquirer": "^6.0.0", | ||
"jasmine-core": "^2.8.0", | ||
"jasmine": "^3.3.1", | ||
"jasmine-core": "^2.99.1", | ||
"karma": "^1.7.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-jasmine": "^1.1.2", | ||
"karma-phantomjs-launcher": "~1.0.4", | ||
@@ -58,7 +61,8 @@ "karma-phantomjs-shim": "~1.5.0", | ||
"shelljs": "^0.7.8", | ||
"ts-loader": "^3.1.1", | ||
"ts-loader": "^6.2.1", | ||
"tslint": "^5.7.0", | ||
"typescript": "^2.5.3", | ||
"uglifyjs-webpack-plugin": "^1.0.1", | ||
"webpack": "^3.8.1" | ||
"typescript": "^2.9.2", | ||
"uglifyjs-webpack-plugin": "^2.2.0", | ||
"webpack": "^4.41.2", | ||
"webpack-cli": "^3.3.1" | ||
}, | ||
@@ -65,0 +69,0 @@ "config": { |
@@ -16,2 +16,54 @@ /** | ||
/** | ||
* Registers a service worker to enable offline support for the app. | ||
* @param appId - Optional app ID. Appended to logs for easier debugging. | ||
* @param swFilePath - Optional path to the service worker file. Defaults to Enplug apps' 'enplug-offline-worker.js' | ||
* @returns - Promise resolves when service worker registration was a success. It rejects when it was a failure. | ||
*/ | ||
registerServiceWorker(appId?: string, swFilePath?: string): Promise<string> { | ||
const SW_TAG = appId ? `[${appId} | Service Worker]` : '[Service Worker]'; | ||
swFilePath = swFilePath || './enplug-offline-worker.js'; | ||
return new Promise((resolve, reject) => { | ||
if ( | ||
'serviceWorker' in navigator && | ||
navigator.userAgent.indexOf('iPad') < 0 && | ||
navigator.userAgent.indexOf('iPhone') < 0 | ||
) { | ||
navigator.serviceWorker.register(swFilePath).then((registration) => { | ||
console.log(`${SW_TAG} ServiceWorker registration successful with scope: `, registration.scope); | ||
// We need to check whether service worker is in a non-active state. If so, we listen for a state change | ||
// to "active". | ||
const sw = registration.installing || registration.waiting; | ||
// Possible states: | ||
// installing - the install event has fired, but not yet complete | ||
// installed - install complete | ||
// activating - the activate event has fired, but not yet complete | ||
// activated - fully active | ||
// redundant - discarded. Either failed install, or it's been replaced by a newer version | ||
if (sw) { | ||
sw.addEventListener('statechange', (state) => { | ||
if (registration.active) { | ||
console.log(`${SW_TAG} Service worker has become active.`); | ||
resolve(); | ||
} | ||
}); | ||
} else if (!sw && registration.active) { | ||
// Service worker is already active. No need to wait for statechange. This will always be true when | ||
// we're offline. | ||
console.log(`${SW_TAG} Service worker is active.`); | ||
resolve(); | ||
} | ||
}, (err) => { | ||
// Registration failed | ||
console.warn(`${SW_TAG}ServiceWorker registration failed: ${err}`, err); | ||
reject(`${SW_TAG} Error registering service worker: ${JSON.stringify(err)}`); | ||
}); | ||
} else { | ||
reject(`${SW_TAG} Browser does not support service workers. User agent: ${navigator.userAgent}`); | ||
} | ||
}); | ||
} | ||
start(): Promise<boolean> { | ||
@@ -25,4 +77,4 @@ return this.bridge.send(Service.AppStatus, Action.Start); | ||
error(): Promise<boolean> { | ||
return this.bridge.send(Service.AppStatus, Action.Error); | ||
error(errorMessage?: string): Promise<boolean> { | ||
return this.bridge.send(Service.AppStatus, Action.Error, errorMessage); | ||
} | ||
@@ -32,3 +84,3 @@ | ||
// The SDK is compiled to regular JS and this method might be called with a wrong type. | ||
if ( typeof canInterrupt !== 'boolean') { | ||
if (typeof canInterrupt !== 'boolean') { | ||
return Promise.reject( | ||
@@ -71,2 +123,12 @@ new TypeError(`[Enplug SDK: ${this.version}] You can only set canInterrupt to a boolean value`)); | ||
} | ||
listenForTouchEvents(body) { | ||
if (body) { | ||
body.addEventListener('click', () => { | ||
console.log(`[Player SDK] Screen was touched.`); | ||
this.bridge.send(Service.AppStatus, Action.ScreenTouched); | ||
}, true); | ||
} | ||
} | ||
} |
@@ -75,2 +75,7 @@ /** | ||
// Reload is not initiated by an App. As such, it doesn't need to dispatch any responses to it. | ||
if (message.action === Action.Reload) { | ||
return window.location.reload(); | ||
} | ||
if (message.token && this.resolveMap.has(message.token)) { | ||
@@ -94,2 +99,3 @@ const promiseResolutionFunctions = this.resolveMap.get(message.token); | ||
} | ||
const blobUrls = {}; | ||
blobs = blobs || data.blobs; | ||
@@ -104,6 +110,10 @@ if (!blobs || !blobs.size) { | ||
} else if (blobs.has(data[key])) { | ||
const originalUrl = data[key]; | ||
data[key] = window.URL.createObjectURL(blobs.get(data[key])); | ||
blobUrls[data[key]] = originalUrl; | ||
} | ||
} | ||
} | ||
data['blobUrls'] = blobUrls; | ||
return data; | ||
@@ -154,8 +164,6 @@ } | ||
if (message.action === Action.Error) { | ||
console.log(`[Enplug SDK: ${this.version}] Error received: ${message.payload.message}`); | ||
reject(message.payload); | ||
} else if (message.action === Action.Reload) { | ||
window.location.reload(); | ||
console.log(`[Enplug SDK: ${this.version}] Error received: ${JSON.stringify(message)}`); | ||
reject(message && message.payload); | ||
} else { | ||
resolve(message.payload); | ||
resolve(message && message.payload); | ||
} | ||
@@ -162,0 +170,0 @@ } |
@@ -7,4 +7,6 @@ /** | ||
import Bridge from './bridge'; | ||
import {InboundMessage, OutboundMessage} from '../enums'; | ||
import {Action, InboundMessage, OutboundMessage} from '../enums'; | ||
import { environment } from '../environment/environment'; | ||
export default class WebBridge extends Bridge { | ||
@@ -35,2 +37,6 @@ | ||
this.receive(incomingMessage); | ||
} else if (event.data && event.data.action === Action.ScreenTouched) { | ||
const dataWithAppToken = event.data; | ||
dataWithAppToken.appToken = this.getQueryParam('apptoken'); | ||
this.sendToPlayer(dataWithAppToken); | ||
} | ||
@@ -42,3 +48,4 @@ } | ||
// which starts with file://. That destination is not supported so, we replace it with a '*'. | ||
const destination = this.destination.startsWith('file://') ? '*' : this.destination; | ||
let destination = this.destination && this.destination.startsWith('file://') ? '*' : this.destination; | ||
destination = destination || environment.appsUrl; | ||
parent.postMessage(message, destination); | ||
@@ -45,0 +52,0 @@ } |
@@ -25,2 +25,3 @@ /** | ||
SetInterrupt = 'set-interrupt', | ||
ScreenTouched = 'screen-touched', | ||
Start = 'start', | ||
@@ -27,0 +28,0 @@ ToggleSound = 'toggle-sound', |
@@ -11,2 +11,3 @@ /** | ||
const hide: () => Promise<boolean>; | ||
const registerServiceWorker: (appId?: string, swFilePath?: string) => Promise<string>; | ||
const setCanInterrupt: (canInterrupt: boolean) => Promise<boolean>; | ||
@@ -13,0 +14,0 @@ const start: () => Promise<boolean>; |
@@ -48,2 +48,6 @@ /** | ||
window.addEventListener('load', () => { | ||
appStatus.listenForTouchEvents(window.document.body); | ||
}); | ||
return { | ||
@@ -64,4 +68,3 @@ appStatus, | ||
/* tslint:disable:variable-name */ | ||
export default createEnplugPlayerSDK(window); | ||
export {createEnplugPlayerSDK}; |
@@ -14,2 +14,22 @@ /** | ||
private version = (pkg as any).version as string; | ||
private localesMap: { [key: string]: string } = { | ||
'ar': 'ar_SA', | ||
'cs': 'cs_CZ', | ||
'de-de': 'de_DE', | ||
'en-us': 'en_US', | ||
'es-es': 'es_ES', | ||
'fi-fi': 'fi_FI', | ||
'fr-fr': 'fr_FR', | ||
'hu': 'hu_HU', | ||
'it-it': 'it_IT', | ||
'ja': 'ja_JP', | ||
'nl-nl': 'nl_NL', | ||
'pl': 'pl_PL', | ||
'pt-br': 'pt_BR', | ||
'ro': 'ro_RO', | ||
'ru': 'ru_RU', | ||
'sk': 'sk_SK', | ||
'sl': 'sl_SI', | ||
'th': 'th_TH', | ||
}; | ||
@@ -21,2 +41,5 @@ constructor(private bridge: Bridge) { } | ||
console.log(`[Enplug SDK: ${this.version}] Settings: Returning all settings: ${JSON.stringify(payload)}`); | ||
if (payload && payload.locale) { | ||
payload.locale = this.mapLocaleCode(payload.locale); | ||
} | ||
return payload; | ||
@@ -99,3 +122,3 @@ }); | ||
console.log(`[Enplug SDK: ${this.version}] Settings: Returning locale info: ${JSON.stringify(payload.value)}`); | ||
return payload.value; | ||
return this.mapLocaleCode(payload.value); | ||
} else { | ||
@@ -106,2 +129,10 @@ return 'en'; | ||
} | ||
/** | ||
* Maps locale code from the server format to one used by the apps. | ||
* @param {string} locale Locale as sent in the schedule. | ||
*/ | ||
mapLocaleCode(inputLocale: string): string { | ||
return this.localesMap[inputLocale] ? this.localesMap[inputLocale] : inputLocale; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
143684
2072
0
28