New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@enplug/sdk-player

Package Overview
Dependencies
Maintainers
10
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enplug/sdk-player - npm Package Compare versions

Comparing version 0.11.0-dev.2 to 0.11.0-dev.3

1191

dist/player.js

@@ -1,2 +0,1191 @@

var enplug=function(r){var s={};function n(e){if(s[e])return s[e].exports;var t=s[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}return n.m=r,n.c=s,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(r,s,function(e){return t[e]}.bind(null,s));return 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){e.exports=JSON.parse('{"name":"@enplug/sdk-player","version":"0.11.0-dev.2","description":"Enplug Player SDK","scripts":{"clean":"rimraf dist/ && mkdirp dist","lint":"tslint -c tslint.json \'./src/**/*.ts\' -e \'./**/*.d.ts\'","test":"ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json","bundle":"npm run clean && webpack","bundle:prod":"npm run clean && webpack --env.production && npm run generateTypings","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","generateTypings":"tsc --project tsconfig.types.json"},"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":["dist/","types/src/","index.d.ts"],"homepage":"https://github.com/Enplug/sdk#readme","devDependencies":{"@enplug/scripts":"^1.9.1","@types/jasmine":"^3.6.9","@types/node":"^14.14.41","command-line-args":"^4.0.7","es6-shim":"^0.35.3","fs":"0.0.1-security","inquirer":"^6.0.0","jasmine":"^3.7.0","jasmine-browser-runner":"^0.4.0","jasmine-core":"^3.7.1","jasmine-spec-reporter":"^7.0.0","karma":"~6.0.0","karma-jasmine":"~4.0.0","karma-phantomjs-launcher":"1.0.4","karma-phantomjs-shim":"1.5.0","karma-requirejs":"^1.1.0","karma-spec-reporter":"0.0.32","karma-typescript":"~5.5.1","mkdirp":"^0.5.1","npm-run-all":"^4.1.1","path":"^0.12.7","phantomjs-shim":"^0.1.0","rimraf":"^2.6.2","s3":"^4.4.0","shelljs":"^0.7.8","ts-loader":"^6.2.1","ts-node":"^9.1.1","tslint":"^5.7.0","typescript":"~4.0.0","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"}}}},"dependencies":{}}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(0);t.default=class{constructor(e){this.window=e,this.version=s.version,this.resolveMap=new Map}send(e,t,r){var s=this.getQueryParam("apptoken");const n=this.createToken();var i=this.getAppUrl();const o={service:e,action:t,payload:r,token:n,appToken:s,appUrl:i,playerSdkVersion:this.version};return this.validateOutboundMessage(o)?new Promise((e,t)=>{this.resolveMap.set(n,[e,t]),this.sendToPlayer(o)}).catch(e=>{console.log(`[Enplug SDK: ${this.version}] Promise error: ${e}`)}):Promise.reject(`[Enplug SDK: ${this.version}] Message invalid.`)}receive(e){if(e&&"object"==typeof e.payload&&!Array.isArray(e.payload)&&(e.payload=this.replaceMediaUrlsWithBlobUrls(e.payload)),e&&Array.isArray(e.payload)){const s=[];for(const n of e.payload){var t=this.replaceMediaUrlsWithBlobUrls(n);s.push(t)}e.payload=s}if("reload"===e.action)return this.window.location.reload();var r;e.token&&this.resolveMap.has(e.token)?(r=this.resolveMap.get(e.token),this.dispatchMessageToApp(e,r)):"event"===e.service&&this.dispatchEvent(e)}replaceMediaUrlsWithBlobUrls(e,t){if(!e)return e;const r={};if(!(t=t||e.blobs)||!t.size)return e;for(const n in e){var s;e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]&&"blobs"!==n?e[n]=this.replaceMediaUrlsWithBlobUrls(e[n],t):t.has(e[n])&&(s=e[n],e[n]=this.window.URL.createObjectURL(t.get(e[n])),r[e[n]]=s))}return e.blobUrls=r,e}setEventsBus(e){this.playerEvents=e}getQueryParam(e,t){const r=t||new URL(this.window.location.href),s=r.searchParams,n=new Map;if(!s&&"string"==typeof r.search)for(const o of r.search.replace("?","").split("&")){var i=o.split("=");n.set(i[0],i[1])}return s?s.get(e)||"":n.get(e)||""}validateOutboundMessage(e){return e&&null!=e.service&&null!=e.action}dispatchMessageToApp(e,t){try{const[r]=t;r(e&&e.payload)}catch(e){console.warn(`[Enplug SDK: ${this.version}] Error dispatching message to app: ${e}`)}}dispatchEvent(e){"destroy"===e.action?this.playerEvents.fireEvent(e.action,()=>this.send("status","destroy-finished")):this.playerEvents.fireEvent(e.action,e.payload)}createToken(){var e=Math.random().toString(36).substr(2);return this.resolveMap.has(e)?this.createToken():e}getAppUrl(){return`${this.window.location.host}${this.window.location.pathname}`}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createEnplugPlayerSDK=void 0;const s=r(3);Object.defineProperty(t,"createEnplugPlayerSDK",{enumerable:!0,get:function(){return s.createEnplugPlayerSDK}}),t.default=s.createEnplugPlayerSDK(window)},function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createEnplugPlayerSDK=void 0;const d=s(r(4)),g=s(r(5)),p=s(r(6)),h=s(r(7)),f=s(r(8)),v=s(r(9)),b=s(r(10)),y=s(r(11)),m=s(r(12)),w=s(r(13)),S=s(r(14)),k=s(r(16)),_=r(0);t.createEnplugPlayerSDK=function(e){var t=_.version;let r;r=e._epBridge?(console.log(`[Enplug SDK: ${t}] Creating bridge from standard implementation (JavaBridge).`),new w.default(e._epBridge,e)):e._epBridgeSend?(console.log(`[Enplug SDK: ${t}] Creating bridge from CEF implementation (CefBridge).`),new m.default(e._epBridgeSend,e)):(console.log(`[Enplug SDK: ${t}] No global sender found. Assuming WebPlayer (WebBridge).`),new S.default(e));const s=new d.default(r);var n=new g.default(r),i=new y.default(r),o=new p.default(r);const a=new k.default(r);var l=new h.default(r),u=new f.default(r),c=new v.default(r),t=new b.default(r);return e.addEventListener("load",()=>{s.listenForTouchEvents(e.document.body)}),{appStatus:s,assets:n,cache:i,desktopAlerts:o,notifications:l,off:a.off.bind(a),on:a.on.bind(a),once:a.once.bind(a),playRecorder:u,settings:c,social:t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(0);t.default=class{constructor(e){this.bridge=e,this.canInterruptInternal=!0,this.version=s.version}registerServiceWorker(e,t){const n=e?`[${e} | Service Worker]`:"[Service Worker]";try{return t=t||"./enplug-offline-worker.js",new Promise((r,s)=>{"serviceWorker"in navigator&&navigator.userAgent.indexOf("iPad")<0&&navigator.userAgent.indexOf("iPhone")<0?navigator.serviceWorker.register(t).then(t=>{console.log(`${n} ServiceWorker registration successful with scope: `,t.scope),this.serviceWorkerTimer=setTimeout(()=>{console.log(`${n} Service worker failed to resolve it state to activated.`),console.log(`${n} Current sw registration: ${JSON.stringify(t)}`),s()},1e4);const e=t.installing||t.waiting;e?e.addEventListener("statechange",e=>{e=e&&e.target&&e.target.state;console.log(`${n} Service worker state changed to: ${e}`),t.active?(console.log(`${n} Service worker has become active.`),clearTimeout(this.serviceWorkerTimer),r(null)):"activated"===e?(console.log(`${n} Service worker has been activated`),clearTimeout(this.serviceWorkerTimer),r(null)):"redundant"===e&&(console.log(`${n} Service either failed to install or has been replaced by newer version.`),clearTimeout(this.serviceWorkerTimer),s())}):!e&&t.active&&(console.log(`${n} Service worker is active.`),clearTimeout(this.serviceWorkerTimer),r(null))},e=>{console.warn(`${n}ServiceWorker registration failed: ${e}`,e),clearTimeout(this.serviceWorkerTimer),s(`${n} Error registering service worker: ${JSON.stringify(e)}`)}):(clearTimeout(this.serviceWorkerTimer),s(`${n} Browser does not support service workers. User agent: ${navigator.userAgent}`))})}catch(e){return console.error(`${n} Error inside registerServiceWorker(). ${e}`),clearTimeout(this.serviceWorkerTimer),Promise.reject()}}start(){return this.bridge.send("status","start")}hide(){return this.bridge.send("status","hide")}error(e){return this.bridge.send("status","error",e)}setCanInterrupt(e){if("boolean"!=typeof e)return Promise.reject(new TypeError(`[Enplug SDK: ${this.version}] You can only set canInterrupt to a boolean value`));const t=this.canInterruptInternal;return this.canInterruptInternal=e,this.bridge.send("status","set-interrupt",{canInterrupt:e}).then(()=>e,e=>this.canInterruptInternal=t)}get canInterrupt(){return Promise.resolve(this.canInterruptInternal)}getTrigger(){return this.bridge.send("status","get-trigger")}toggleSound(e){return this.bridge.send("status","toggle-sound",{enabled:e})}listenForTouchEvents(e){e&&(e.addEventListener("click",()=>{console.log("[Player SDK] Screen was touched (click or touch)."),this.bridge.send("status","screen-touched")},!0),e.addEventListener("keyup",()=>{console.log("[Player SDK] Screen was touched (keyup)."),this.bridge.send("status","screen-touched")},!0))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}getList(){return this.bridge.send("asset","get-list")}getNext(){return this.bridge.send("asset","get-next")}getAsset(){return this.bridge.send("asset","get-asset")}getTheme(){return this.bridge.send("asset","get-theme")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}error(){return this.bridge.send("desktopalerts","error")}getNext(){return this.bridge.send("desktopalerts","get-next")}hide(){return this.bridge.send("desktopalerts","hide")}openUrl(e){return this.bridge.send("desktopalerts","open-url",e)}ready(){return this.bridge.send("desktopalerts","ready")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}post(e){return this.bridge.send("notification","post",{message:e}).then(e=>e?e.notificationId:"")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}report(e,t,r,s=""){const n={assetId:e,referenceId:t,playDuration:r};return""!==s&&(n.additionalInfo=s),this.bridge.send("playrecorder","report",n)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(0);t.default=class{constructor(e){this.bridge=e,this.version=s.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"}}get all(){return this.bridge.send("settings","get-all").then(e=>(console.log(`[Enplug SDK: ${this.version}] Settings: Returning all settings: ${JSON.stringify(e)}`),e&&e.locale&&(e.locale=this.mapLocaleCode(e.locale)),e))}get deviceId(){return this.bridge.send("settings","get-deviceid").then(e=>{e=this.getPayloadValue(e);return e?(console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting deviveId: ${e}`),e):""},()=>"")}get is4K(){return this.is4KCache?Promise.resolve(this.is4K):this.bridge.send("settings","is4K").then(e=>{e=this.getPayloadValue(e);return console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting is4k: ${e}`),this.is4KCache=e,this.is4KCache},()=>!1)}get transitionType(){return this.bridge.send("settings","transition-type").then(e=>{e=this.getPayloadValue(e);return e?(console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting transition-type: ${e}`),e):"NONE"},()=>"NONE")}get whitelabel(){return this.bridge.send("settings","get-whitelabel").then(e=>{e=this.getPayloadValue(e);return e?(console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting whitelabel: ${e}`),e):""},()=>"")}get isMuted(){return this.bridge.send("settings","is-muted").then(e=>{e=this.getPayloadValue(e);return!!e&&(console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting is-muted: ${e}`),e)},()=>!1)}get zoning(){return this.bridge.send("settings","get-zoning-info").then(e=>{e=this.getPayloadValue(e);return e?(console.log(`[Enplug SDK: ${this.version}] Settings: Returning zoning info: ${JSON.stringify(e)}`),e):null})}get locale(){return this.bridge.send("settings","get-locale").then(e=>{e=this.getPayloadValue(e);return e?(console.log(`[Enplug SDK: ${this.version}] Settings: Returning locale info: ${JSON.stringify(e)}`),this.mapLocaleCode(e)):"en"})}getPayloadValue(e){return!0===e||!1===e?e:e?"object"==typeof e&&e.hasOwnProperty("value")?e.value:e:""}mapLocaleCode(e){return this.localesMap[e]||e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}getFeeds(){return this.bridge.send("social","get-feeds")}getItems(){return this.bridge.send("social","get-items")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.bridge=e}getFile(t){return this.bridge.send("cache","get-file",t).then(e=>e?window.URL.createObjectURL(e):t)}}},function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});class n extends s(r(1)).default{constructor(e,t){super(t),this.cefGlobalSend=e,this.window._epBridge={receive:this.receive.bind(this)}}sendToPlayer(e){return this.cefGlobalSend({request:JSON.stringify(e),persistent:!1})}receive(e){try{var t=JSON.parse(e);super.receive(t)}catch(e){}}}t.default=n},function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});class n extends s(r(1)).default{constructor(e,t){super(t),this.javaGlobal=e,this.javaGlobal.receive=this.receive.bind(this)}sendToPlayer(e){this.javaGlobal.send(JSON.stringify(e))}receive(e){try{var t=JSON.parse(e);super.receive(t)}catch(e){}}}t.default=n},function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});s=s(r(1));const n=r(15);class i extends s.default{constructor(e){super(e),this.destination=this.getQueryParam("origin"),this.window.epBridge={receive:this.receive.bind(this)},this.window.addEventListener("message",this.handleIframeMessage.bind(this))}handleIframeMessage(r){if(r.origin===this.destination){let t=r.data;if("string"==typeof r.data)try{t=JSON.parse(r.data)}catch(e){t=r.data}this.receive(t)}else if(r.data&&"screen-touched"===r.data.action){const e=r.data;e.appToken=this.getQueryParam("apptoken"),this.sendToPlayer(e)}}sendToPlayer(e){var t=(t=this.destination&&this.destination.startsWith("file://")?"*":this.destination)||n.environment.appsUrl;parent.postMessage(e,t)}validateOutboundMessage(e){return super.validateOutboundMessage(e)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.environment=void 0,t.environment={appsUrl:"https://apps.enplug.com"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(0);t.default=class{constructor(e){this.bridge=e,this.handlerMap=new Map,this.version=s.version,this.bridge.setEventsBus(this)}on(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})}off(e,t){if(this.checkArgumentTypes(e,t),this.handlerMap.has(e)){const r=this.handlerMap.get(e);r.has(t)&&r.delete(t)}}once(t,r){this.checkArgumentTypes(t,r);const s=(...e)=>{this.off(t,s),r(...e)};this.on(t,s)}fireEvent(e,...t){const r=this.handlerMap.get(e);r&&r.forEach(e=>{e(...t)})}checkArgumentTypes(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`)}}}]).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, scripts, repository, keywords, author, license, bugs, files, homepage, devDependencies, config, dependencies, default */
/***/ (function(module) {
module.exports = JSON.parse("{\"name\":\"@enplug/sdk-player\",\"version\":\"0.11.0-dev.2\",\"description\":\"Enplug Player SDK\",\"scripts\":{\"clean\":\"rimraf dist/ && mkdirp dist\",\"lint\":\"tslint -c tslint.json './src/**/*.ts' -e './**/*.d.ts'\",\"test\":\"ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json\",\"bundle\":\"npm run clean && webpack\",\"bundle:prod\":\"npm run clean && webpack --env.production && npm run generateTypings\",\"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\",\"generateTypings\":\"tsc --project tsconfig.types.json\"},\"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\":[\"dist/\",\"types/src/\",\"index.d.ts\"],\"homepage\":\"https://github.com/Enplug/sdk#readme\",\"devDependencies\":{\"@enplug/scripts\":\"^1.9.1\",\"@types/jasmine\":\"^3.6.9\",\"@types/node\":\"^14.14.41\",\"command-line-args\":\"^4.0.7\",\"es6-shim\":\"^0.35.3\",\"fs\":\"0.0.1-security\",\"inquirer\":\"^6.0.0\",\"jasmine\":\"^3.7.0\",\"jasmine-browser-runner\":\"^0.4.0\",\"jasmine-core\":\"^3.7.1\",\"jasmine-spec-reporter\":\"^7.0.0\",\"karma\":\"~6.0.0\",\"karma-jasmine\":\"~4.0.0\",\"karma-phantomjs-launcher\":\"1.0.4\",\"karma-phantomjs-shim\":\"1.5.0\",\"karma-requirejs\":\"^1.1.0\",\"karma-spec-reporter\":\"0.0.32\",\"karma-typescript\":\"~5.5.1\",\"mkdirp\":\"^0.5.1\",\"npm-run-all\":\"^4.1.1\",\"path\":\"^0.12.7\",\"phantomjs-shim\":\"^0.1.0\",\"rimraf\":\"^2.6.2\",\"s3\":\"^4.4.0\",\"shelljs\":\"^0.7.8\",\"ts-loader\":\"^6.2.1\",\"ts-node\":\"^9.1.1\",\"tslint\":\"^5.7.0\",\"typescript\":\"~4.0.0\",\"uglifyjs-webpack-plugin\":\"^2.2.0\",\"webpack\":\"^4.41.2\",\"webpack-cli\":\"^3.3.1\"},\"config\":{\"destination\":\"sdk/v1\",\"destinationDev\":\"sdk/dev/\",\"aws\":{\"buckets\":[\"dev-apps.enplug.in\",\"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\"}}}},\"dependencies\":{}}");
/***/ }),
/***/ "./src/app-status.ts":
/*!***************************!*\
!*** ./src/app-status.ts ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const pkg = __webpack_require__(/*! ../package.json */ "./package.json");
class AppStatus {
constructor(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.
*/
registerServiceWorker(appId, swFilePath) {
const SW_TAG = appId ? `[${appId} | Service Worker]` : '[Service Worker]';
try {
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);
this.serviceWorkerTimer = setTimeout(() => {
// If server worker fails to resolve its state in 10 seconds, we assume it failed. This is done as
// a safeguard to ensure that no matter what, the app will be started.
console.log(`${SW_TAG} Service worker failed to resolve it state to activated.`);
console.log(`${SW_TAG} Current sw registration: ${JSON.stringify(registration)}`);
reject();
}, 10000);
// 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', (stateEvent) => {
const state = stateEvent && stateEvent.target && stateEvent.target['state'];
console.log(`${SW_TAG} Service worker state changed to: ${state}`);
if (registration.active) {
console.log(`${SW_TAG} Service worker has become active.`);
clearTimeout(this.serviceWorkerTimer);
resolve(null);
return;
}
else if (state === 'activated') {
console.log(`${SW_TAG} Service worker has been activated`);
clearTimeout(this.serviceWorkerTimer);
resolve(null);
}
else if (state === 'redundant') {
console.log(`${SW_TAG} Service either failed to install or has been replaced by newer version.`);
clearTimeout(this.serviceWorkerTimer);
reject();
}
});
}
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.`);
clearTimeout(this.serviceWorkerTimer);
resolve(null);
}
}, (err) => {
// Registration failed
console.warn(`${SW_TAG}ServiceWorker registration failed: ${err}`, err);
clearTimeout(this.serviceWorkerTimer);
reject(`${SW_TAG} Error registering service worker: ${JSON.stringify(err)}`);
});
}
else {
clearTimeout(this.serviceWorkerTimer);
reject(`${SW_TAG} Browser does not support service workers. User agent: ${navigator.userAgent}`);
}
});
}
catch (err) {
console.error(`${SW_TAG} Error inside registerServiceWorker(). ${err}`);
clearTimeout(this.serviceWorkerTimer);
return Promise.reject();
}
}
start() {
return this.bridge.send("status" /* AppStatus */, "start" /* Start */);
}
hide() {
return this.bridge.send("status" /* AppStatus */, "hide" /* Hide */);
}
error(errorMessage) {
return this.bridge.send("status" /* AppStatus */, "error" /* Error */, errorMessage);
}
setCanInterrupt(canInterrupt) {
// 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.
const previousCanInterrupt = this.canInterruptInternal;
this.canInterruptInternal = canInterrupt;
return this.bridge.send("status" /* AppStatus */, "set-interrupt" /* SetInterrupt */, { canInterrupt }).then(() => {
return canInterrupt;
}, (error) => {
this.canInterruptInternal = previousCanInterrupt;
return previousCanInterrupt;
});
}
/**
* Handles `enplug.status.canInterrupt`.
*/
get canInterrupt() {
return Promise.resolve(this.canInterruptInternal);
}
/**
* Handles `enplug.status.getTrigger()` used by social apps.
*/
getTrigger() {
return this.bridge.send("status" /* AppStatus */, "get-trigger" /* GetTrigger */);
}
/**
* Handles `enplug.status.toggleSound()` calls.
*/
toggleSound(enabled) {
return this.bridge.send("status" /* AppStatus */, "toggle-sound" /* ToggleSound */, { enabled });
}
listenForTouchEvents(body) {
if (body) {
body.addEventListener('click', () => {
console.log(`[Player SDK] Screen was touched (click or touch).`);
this.bridge.send("status" /* AppStatus */, "screen-touched" /* ScreenTouched */);
}, true);
body.addEventListener('keyup', () => {
console.log(`[Player SDK] Screen was touched (keyup).`);
this.bridge.send("status" /* AppStatus */, "screen-touched" /* ScreenTouched */);
}, true);
}
}
}
exports.default = AppStatus;
/***/ }),
/***/ "./src/assets.ts":
/*!***********************!*\
!*** ./src/assets.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Assets {
constructor(bridge) {
this.bridge = bridge;
}
getList() {
return this.bridge.send("asset" /* Assets */, "get-list" /* GetList */);
}
getNext() {
return this.bridge.send("asset" /* Assets */, "get-next" /* GetNext */);
}
getAsset() {
return this.bridge.send("asset" /* Assets */, "get-asset" /* GetAsset */);
}
getTheme() {
return this.bridge.send("asset" /* Assets */, "get-theme" /* GetTheme */);
}
}
exports.default = Assets;
/***/ }),
/***/ "./src/bridge/bridge.ts":
/*!******************************!*\
!*** ./src/bridge/bridge.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const pkg = __webpack_require__(/*! ../../package.json */ "./package.json");
class Bridge {
constructor(window) {
this.window = window;
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.
*/
send(service, action, payload) {
const appToken = this.getQueryParam('apptoken');
const token = this.createToken();
const appUrl = this.getAppUrl();
const message = {
service,
action,
payload,
token,
appToken,
appUrl,
playerSdkVersion: this.version,
};
if (this.validateOutboundMessage(message)) {
return new Promise((resolve, reject) => {
this.resolveMap.set(token, [resolve, reject]);
this.sendToPlayer(message);
}).catch((err) => {
console.log(`[Enplug SDK: ${this.version}] Promise error: ${err}`);
});
}
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.
*/
receive(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)) {
const updatedPayload = [];
for (const data of message.payload) {
const 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 this.window.location.reload();
}
if (message.token && this.resolveMap.has(message.token)) {
const 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.
*/
replaceMediaUrlsWithBlobUrls(data, blobs) {
if (!data) {
return data;
}
const blobUrls = {};
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])) {
const originalUrl = data[key];
data[key] = this.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
*/
setEventsBus(playerEvents) {
this.playerEvents = playerEvents;
}
/**
* Gets a value from URL query by key.
* @param {string} key
*/
getQueryParam(key, queryUrl) {
const url = queryUrl || new URL(this.window.location.href);
const params = url.searchParams;
const legacyParams = new Map();
// Older browsers don't support searchParams
if (!params && typeof url.search === 'string') {
const searchParams = url.search.replace('?', '').split('&');
for (const param of searchParams) {
const paramParts = param.split('=');
legacyParams.set(paramParts[0], paramParts[1]);
}
}
if (params) {
return params.get(key) || '';
}
return legacyParams.get(key) || '';
}
/**
* Checks whether the message is good to be sent.
* @param {OutboundMessage} message
*/
validateOutboundMessage(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.
*/
dispatchMessageToApp(message, promiseResolutionFunctions) {
try {
const [resolve, reject] = promiseResolutionFunctions;
resolve(message && message.payload);
}
catch (err) {
console.warn(`[Enplug SDK: ${this.version}] Error dispatching message to app: ${err}`);
}
}
/**
* 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
*/
dispatchEvent(message) {
// In case of action === 'destroy', the argument passed to the event handler has to be a "done" callback.
if (message.action === "destroy" /* Destroy */) {
const done = () => {
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.
*/
createToken() {
const 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.
*/
getAppUrl() {
return `${this.window.location.host}${this.window.location.pathname}`;
}
}
exports.default = Bridge;
/***/ }),
/***/ "./src/bridge/cef-bridge.ts":
/*!**********************************!*\
!*** ./src/bridge/cef-bridge.ts ***!
\**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* An implementation of the Bridge for Windows (CEF) Players.
*
* @author Arkadiusz Gochnio (arek@enplug.com)
*/
const bridge_1 = __importDefault(__webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts"));
class CefBridge extends bridge_1.default {
constructor(cefGlobalSend, window) {
super(window);
this.cefGlobalSend = cefGlobalSend;
/*tslint:disable:no-string-literal*/
this.window['_epBridge'] = {
receive: this.receive.bind(this),
};
}
sendToPlayer(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
*/
receive(message) {
try {
const jsonMessage = JSON.parse(message);
super.receive(jsonMessage);
}
catch (e) {
// Ignore the message silently.
}
}
}
exports.default = CefBridge;
/***/ }),
/***/ "./src/bridge/java-bridge.ts":
/*!***********************************!*\
!*** ./src/bridge/java-bridge.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* An implementation of Bridge for Android devices (Java).
*
* @author Arkadiusz Gochnio (arek@enplug.com)
*/
const bridge_1 = __importDefault(__webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts"));
class JavaBridge extends bridge_1.default {
constructor(javaGlobal, window) {
super(window);
this.javaGlobal = javaGlobal;
this.javaGlobal.receive = this.receive.bind(this);
}
sendToPlayer(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
*/
receive(message) {
try {
const jsonMessage = JSON.parse(message);
super.receive(jsonMessage);
}
catch (e) {
// Ignore the message silently.
}
}
}
exports.default = JavaBridge;
/***/ }),
/***/ "./src/bridge/web-bridge.ts":
/*!**********************************!*\
!*** ./src/bridge/web-bridge.ts ***!
\**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* An implementation of Bridge for Web based players.
*
* @author Arkadiusz Gochnio (arek@enplug.com)
*/
const bridge_1 = __importDefault(__webpack_require__(/*! ./bridge */ "./src/bridge/bridge.ts"));
const environment_1 = __webpack_require__(/*! ../environment/environment */ "./src/environment/environment.ts");
class WebBridge extends bridge_1.default {
constructor(window) {
super(window);
this.destination = this.getQueryParam('origin');
/*tslint:disable:no-string-literal*/
this.window['epBridge'] = {
receive: this.receive.bind(this),
};
this.window.addEventListener('message', this.handleIframeMessage.bind(this));
}
handleIframeMessage(event) {
if (event.origin === this.destination) {
let 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 */) {
const dataWithAppToken = event.data;
dataWithAppToken.appToken = this.getQueryParam('apptoken');
this.sendToPlayer(dataWithAppToken);
}
}
sendToPlayer(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 '*'.
let destination = this.destination && this.destination.startsWith('file://') ? '*' : this.destination;
destination = destination || environment_1.environment.appsUrl;
parent.postMessage(message, destination);
}
validateOutboundMessage(message) {
const validationResult = super.validateOutboundMessage(message);
return validationResult;
}
}
exports.default = WebBridge;
/***/ }),
/***/ "./src/cache.ts":
/*!**********************!*\
!*** ./src/cache.ts ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Cache {
constructor(bridge) {
this.bridge = bridge;
}
getFile(url) {
return this.bridge.send("cache" /* Cache */, "get-file" /* GetFile */, url).then((blob) => {
if (blob) {
return window.URL.createObjectURL(blob);
}
return url;
});
}
}
exports.default = Cache;
/***/ }),
/***/ "./src/desktop-alerts.ts":
/*!*******************************!*\
!*** ./src/desktop-alerts.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class DesktopAlerts {
constructor(bridge) {
this.bridge = bridge;
}
error() {
return this.bridge.send("desktopalerts" /* DesktopAlerts */, "error" /* Error */);
}
getNext() {
return this.bridge.send("desktopalerts" /* DesktopAlerts */, "get-next" /* GetNext */);
}
hide() {
return this.bridge.send("desktopalerts" /* DesktopAlerts */, "hide" /* Hide */);
}
openUrl(url) {
return this.bridge.send("desktopalerts" /* DesktopAlerts */, "open-url" /* OpenUrl */, url);
}
ready() {
return this.bridge.send("desktopalerts" /* DesktopAlerts */, "ready" /* Ready */);
}
}
exports.default = DesktopAlerts;
/***/ }),
/***/ "./src/environment/environment.ts":
/*!****************************************!*\
!*** ./src/environment/environment.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.environment = void 0;
exports.environment = {
appsUrl: 'https://apps.enplug.in'
};
/***/ }),
/***/ "./src/index.ts":
/*!**********************!*\
!*** ./src/index.ts ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* This is a main entry point. This file gets imported to client app and constructs a Bridge instance, depending on
* available globals. Then it builds an Enplug object and exports it.
*
* @author Arkadiusz Gochnio arek@enplug.com
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEnplugPlayerSDK = void 0;
const sdk_1 = __webpack_require__(/*! ./sdk */ "./src/sdk.ts");
Object.defineProperty(exports, "createEnplugPlayerSDK", { enumerable: true, get: function () { return sdk_1.createEnplugPlayerSDK; } });
exports.default = sdk_1.createEnplugPlayerSDK(window);
/***/ }),
/***/ "./src/notifications.ts":
/*!******************************!*\
!*** ./src/notifications.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Notifications {
constructor(bridge) {
this.bridge = bridge;
}
post(message) {
return this.bridge.send("notification" /* Notifications */, "post" /* Post */, { message }).then((payload) => {
return payload ? payload.notificationId : '';
});
}
}
exports.default = Notifications;
/***/ }),
/***/ "./src/play-recorder.ts":
/*!******************************!*\
!*** ./src/play-recorder.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Provides apps with a method to report for how long something was displayed on the screen.
*
* @author Arkadiusz Gochnio (arek@enplug.com)
*/
Object.defineProperty(exports, "__esModule", { value: true });
class PlayRecorder {
constructor(bridge) {
this.bridge = bridge;
}
report(assetId, referenceId, playDuration, additionalInfo = '') {
// The typing lets us add properties dynamically.
const payload = {
assetId,
referenceId,
playDuration,
};
if (additionalInfo !== '') {
payload.additionalInfo = additionalInfo;
}
// TODO: Should this actually return something?
return this.bridge.send("playrecorder" /* PlayRecorder */, "report" /* Report */, payload);
}
}
exports.default = PlayRecorder;
/***/ }),
/***/ "./src/player-events.ts":
/*!******************************!*\
!*** ./src/player-events.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const pkg = __webpack_require__(/*! ../package.json */ "./package.json");
class PlayerEvents {
constructor(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.
*/
on(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 });
}
/**
* Removes a handler function from listening to the event.
* @param {string} eventName - Name of the event.
* @param {Function} eventHandler - Handler function to remove.
*/
off(eventName, eventHandler) {
this.checkArgumentTypes(eventName, eventHandler);
if (this.handlerMap.has(eventName)) {
const 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.
*/
once(eventName, eventHandler) {
this.checkArgumentTypes(eventName, eventHandler);
const tmpFn = (...args) => {
this.off(eventName, tmpFn);
eventHandler(...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`.
*/
fireEvent(eventName, ...args) {
const handlerSet = this.handlerMap.get(eventName);
if (handlerSet) {
handlerSet.forEach((handler) => {
handler(...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.
*/
checkArgumentTypes(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`);
}
}
}
exports.default = PlayerEvents;
/***/ }),
/***/ "./src/sdk.ts":
/*!********************!*\
!*** ./src/sdk.ts ***!
\********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEnplugPlayerSDK = void 0;
const app_status_1 = __importDefault(__webpack_require__(/*! ./app-status */ "./src/app-status.ts"));
const assets_1 = __importDefault(__webpack_require__(/*! ./assets */ "./src/assets.ts"));
const desktop_alerts_1 = __importDefault(__webpack_require__(/*! ./desktop-alerts */ "./src/desktop-alerts.ts"));
const notifications_1 = __importDefault(__webpack_require__(/*! ./notifications */ "./src/notifications.ts"));
const play_recorder_1 = __importDefault(__webpack_require__(/*! ./play-recorder */ "./src/play-recorder.ts"));
const settings_1 = __importDefault(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
const social_1 = __importDefault(__webpack_require__(/*! ./social */ "./src/social.ts"));
const cache_1 = __importDefault(__webpack_require__(/*! ./cache */ "./src/cache.ts"));
const cef_bridge_1 = __importDefault(__webpack_require__(/*! ./bridge/cef-bridge */ "./src/bridge/cef-bridge.ts"));
const java_bridge_1 = __importDefault(__webpack_require__(/*! ./bridge/java-bridge */ "./src/bridge/java-bridge.ts"));
const web_bridge_1 = __importDefault(__webpack_require__(/*! ./bridge/web-bridge */ "./src/bridge/web-bridge.ts"));
const player_events_1 = __importDefault(__webpack_require__(/*! ./player-events */ "./src/player-events.ts"));
const pkg = __webpack_require__(/*! ../package.json */ "./package.json");
/**
* Creates appropriate bridge version, depending on the detected globals.
*/
function createEnplugPlayerSDK(window) {
const version = pkg.version;
let 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'], window);
}
else if (window['_epBridgeSend']) {
console.log(`[Enplug SDK: ${version}] Creating bridge from CEF implementation (CefBridge).`);
bridge = new cef_bridge_1.default(window['_epBridgeSend'], window);
}
else {
console.log(`[Enplug SDK: ${version}] No global sender found. Assuming WebPlayer (WebBridge).`);
bridge = new web_bridge_1.default(window);
}
const appStatus = new app_status_1.default(bridge);
const assets = new assets_1.default(bridge);
const cache = new cache_1.default(bridge);
const desktopAlerts = new desktop_alerts_1.default(bridge);
const events = new player_events_1.default(bridge);
const notifications = new notifications_1.default(bridge);
const playRecorder = new play_recorder_1.default(bridge);
const settings = new settings_1.default(bridge);
const social = new social_1.default(bridge);
window.addEventListener('load', () => {
appStatus.listenForTouchEvents(window.document.body);
});
return {
appStatus,
assets,
cache,
desktopAlerts,
notifications,
off: events.off.bind(events),
on: events.on.bind(events),
once: events.once.bind(events),
playRecorder,
settings,
social,
};
}
exports.createEnplugPlayerSDK = createEnplugPlayerSDK;
/***/ }),
/***/ "./src/settings.ts":
/*!*************************!*\
!*** ./src/settings.ts ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const pkg = __webpack_require__(/*! ../package.json */ "./package.json");
class Settings {
constructor(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',
};
}
get all() {
return this.bridge.send("settings" /* Settings */, "get-all" /* GetAll */).then((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;
});
}
get deviceId() {
return this.bridge.send("settings" /* Settings */, "get-deviceid" /* GetDeviceId */).then((payload) => {
const id = this.getPayloadValue(payload);
if (id) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting deviveId: ${id}`);
return id;
}
else {
return '';
}
}, () => '');
}
get is4K() {
if (this.is4KCache) {
return Promise.resolve(this.is4K);
}
return this.bridge.send("settings" /* Settings */, "is4K" /* Is4K */).then((payload) => {
const is4kScreen = this.getPayloadValue(payload);
console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting is4k: ${is4kScreen}`);
this.is4KCache = is4kScreen;
return this.is4KCache;
}, () => false);
}
get transitionType() {
return this.bridge.send("settings" /* Settings */, "transition-type" /* TransitionType */).then((payload) => {
const transition = this.getPayloadValue(payload);
if (transition) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting transition-type: ${transition}`);
return transition;
}
else {
return "NONE" /* None */;
}
}, () => "NONE" /* None */);
}
get whitelabel() {
return this.bridge.send("settings" /* Settings */, "get-whitelabel" /* GetWhitelabel */).then((payload) => {
const label = this.getPayloadValue(payload);
if (label) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting whitelabel: ${label}`);
return label;
}
else {
return '';
}
}, () => '');
}
get isMuted() {
return this.bridge.send("settings" /* Settings */, "is-muted" /* IsMuted */).then((payload) => {
const muted = this.getPayloadValue(payload);
if (muted) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning setting is-muted: ${muted}`);
return muted;
}
else {
return false;
}
}, () => false);
}
get zoning() {
return this.bridge.send("settings" /* Settings */, "get-zoning-info" /* GetZoningInfo */).then((payload) => {
const zoningInfo = this.getPayloadValue(payload);
if (zoningInfo) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning zoning info: ${JSON.stringify(zoningInfo)}`);
return zoningInfo;
}
else {
return null;
}
});
}
get locale() {
return this.bridge.send("settings" /* Settings */, "get-locale" /* GetLocale */).then((payload) => {
const localeCode = this.getPayloadValue(payload);
if (localeCode) {
console.log(`[Enplug SDK: ${this.version}] Settings: Returning locale info: ${JSON.stringify(localeCode)}`);
return this.mapLocaleCode(localeCode);
}
else {
return 'en';
}
});
}
/**
* Extracts SDK payload in a backwards compatible matter. Accepts payloads as both payload = {'value': <response>}
* and payload = <response>;
* @param payload
*/
getPayloadValue(payload) {
if (payload === true || payload === false) {
return payload;
}
if (!payload) {
return '';
}
// For non-objects (string, boolean) return payload itself.
if (typeof payload !== 'object') {
return payload;
}
// If object has property 'value', return it. If it doesn't, return payload object itself.
if (payload.hasOwnProperty('value')) {
return payload.value;
}
return payload;
}
/**
* Maps locale code from the server format to one used by the apps.
* @param {string} locale Locale as sent in the schedule.
*/
mapLocaleCode(inputLocale) {
return this.localesMap[inputLocale] ? this.localesMap[inputLocale] : inputLocale;
}
}
exports.default = Settings;
/***/ }),
/***/ "./src/social.ts":
/*!***********************!*\
!*** ./src/social.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Social {
constructor(bridge) {
this.bridge = bridge;
}
getFeeds() {
return this.bridge.send("social" /* Social */, "get-feeds" /* GetFeeds */);
}
getItems() {
return this.bridge.send("social" /* Social */, "get-items" /* GetItems */);
}
}
exports.default = Social;
/***/ })
/******/ })["default"];
//# sourceMappingURL=player.js.map

3

package.json
{
"name": "@enplug/sdk-player",
"version": "0.11.0-dev.2",
"version": "0.11.0-dev.3",
"description": "Enplug Player SDK",

@@ -74,2 +74,3 @@ "scripts": {

"buckets": [
"dev-apps.enplug.in",
"apps.enplug.in",

@@ -76,0 +77,0 @@ "apps.enplug.com"

export * from './external-types';
export * from './sdk';
export * from './app-status';
export * from './settings';
export * from './cache';
export * from './desktop-alerts';
export * from './notifications';
export * from './play-recorder';
export * from './player-events';
export * from './settings';
export * from './social';

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc