-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebOSTV-dev.js
More file actions
1 lines (1 loc) · 12 KB
/
webOSTV-dev.js
File metadata and controls
1 lines (1 loc) · 12 KB
1
!function(){"use strict";var e={d:function(r,t){for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var r=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}e.r(r),e.d(r,{APP:function(){return a},DRM:function(){return j},LGUDID:function(){return C},connection:function(){return R},drmAgent:function(){return E},launch:function(){return s},launchParams:function(){return l}});var u={},c=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.bridge=null,this.cancelled=!1,this.subscribe=!1},r=[{key:"send",value:function(e){var r=e.service,t=void 0===r?"":r,o=e.method,c=void 0===o?"":o,a=e.parameters,s=void 0===a?{}:a,l=e.onSuccess,f=void 0===l?function(){}:l,d=e.onFailure,b=void 0===d?function(){}:d,v=e.onComplete,p=void 0===v?function(){}:v,m=e.subscribe,y=void 0!==m&&m;if(!window.PalmServiceBridge){var h={errorCode:-1,errorText:"PalmServiceBridge is not found.",returnValue:!1};return b(h),p(h),console.error("PalmServiceBridge is not found."),this}this.ts&&u[this.ts]&&delete u[this.ts];var O,g=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?n(Object(t),!0).forEach((function(r){var n,o,u;n=e,o=r,u=t[r],(o=i(o))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},s);return this.subscribe=y,this.subscribe&&(g.subscribe=this.subscribe),g.subscribe&&(this.subscribe=g.subscribe),this.ts=Date.now(),u[this.ts]=this,this.bridge=new PalmServiceBridge,this.bridge.onservicecallback=this.callback.bind(this,f,b,p),this.bridge.call(("/"!==(O=t).slice(-1)&&(O+="/"),O+c),JSON.stringify(g)),this}},{key:"callback",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(!this.cancelled){var o={};try{o=JSON.parse(n)}catch(e){o={errorCode:-1,errorText:n,returnValue:!1}}var i=o,u=i.errorCode,c=i.returnValue;u||!1===c?(o.returnValue=!1,r(o)):(o.returnValue=!0,e(o)),t(o),this.subscribe||this.cancel()}}},{key:"cancel",value:function(){this.cancelled=!0,null!==this.bridge&&(this.bridge.cancel(),this.bridge=null),this.ts&&u[this.ts]&&delete u[this.ts]}}],r&&o(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}(),a={BROWSER:"APP_BROWSER"},s=function(e){var r=e.id,t=void 0===r?"":r,n=e.params,o=void 0===n?{}:n,i=e.onSuccess,u=void 0===i?function(){}:i,s=e.onFailure,l=void 0===s?function(){}:s,f={id:t,params:o};a.BROWSER===t&&(f.params.target=o.target||"",f.params.fullMode=!0,f.id="com.webos.app.browser"),function(e){var r=e.parameters,t=e.onSuccess,n=e.onFailure;(new c).send({service:"luna://com.webos.applicationManager",method:"launch",parameters:r,onComplete:function(e){var r=e.returnValue,o=e.errorCode,i=e.errorText;return!0===r?t():n({errorCode:o,errorText:i})}})}({parameters:f,onSuccess:u,onFailure:l})},l=function(){var e={};if(window.PalmSystem&&""!==window.PalmSystem.launchParams)try{e=JSON.parse(window.PalmSystem.launchParams)}catch(e){console.error("JSON parsing error")}return e},f=function(){return window.PalmSystem&&window.PalmSystem.identifier?window.PalmSystem.identifier.split(" ")[0]:""};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function v(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach((function(r){var n,o,i;n=e,o=r,i=t[r],(o=m(o))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function p(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function m(e){var r=function(e,r){if("object"!=d(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==d(r)?r:r+""}var y={NOT_ERROR:-1,CLIENT_NOT_LOADED:0,VENDOR_ERROR:500,API_NOT_SUPPORTED:501,WRONG_CLIENT_ID:502,KEY_NOT_FOUND:503,INVALID_PARAMS:504,UNSUPPORTED_DRM_TYPE:505,INVALID_KEY_FORMAT:506,INVALID_TIME_INFO:507,UNKNOWN_ERROR:599},h={PLAYREADY:"playready",WIDEVINE:"widevine"},O=function(e){var r=e.method,t=e.parameters,n=e.onComplete;(new c).send({service:"luna://com.webos.service.drm",onComplete:n,method:r,parameters:t})},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};setTimeout((function(){return e(r)}),0)},S=function(e){return 2===e.state&&""!==e.getClientId()},w=function(e,r){var t=r.errorCode,n=void 0===t?y.UNKNOWN_ERROR:t,o=r.errorText,i={errorCode:n,errorText:void 0===o?"Unknown error.":o};return e.setError(i),i},P={errorCode:y.CLIENT_NOT_LOADED,errorText:"DRM client is not loaded."},T=function(){return e=function e(r){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.clientId="",this.drmType=r,this.errorCode=y.NOT_ERROR,this.errorText="",this.state=0},(r=[{key:"getClientId",value:function(){return this.clientId}},{key:"getDrmType",value:function(){return this.drmType}},{key:"getErrorCode",value:function(){return this.errorCode}},{key:"getErrorText",value:function(){return this.errorText}},{key:"setError",value:function(e){var r=e.errorCode,t=e.errorText;this.errorCode=r,this.errorText=t}},{key:"isLoaded",value:function(e){var r=this,t=e.onSuccess,n=void 0===t?function(){}:t,o=e.onFailure,i=void 0===o?function(){}:o;O({method:"isLoaded",parameters:{appId:f()},onComplete:function(e){if(!0===e.returnValue){if(r.clientId=e.clientId||"",r.state=e.loadStatus?2:0,!0===e.loadStatus&&e.drmType!==r.drmType)return i(w(r,{errorCode:y.UNKNOWN_ERROR,errorText:"DRM types of set and loaded are not matched."}));var t=v({},e);return delete t.returnValue,n(t)}return i(w(r,e))}})}},{key:"load",value:function(e){var r=this,t=e.onSuccess,n=void 0===t?function(){}:t,o=e.onFailure,i=void 0===o?function(){}:o;if(1!==this.state&&2!==this.state){var u={appId:f(),drmType:this.drmType};this.state=1,O({method:"load",onComplete:function(e){return!0===e.returnValue?(r.clientId=e.clientId,r.state=2,n({clientId:r.clientId})):i(w(r,e))},parameters:u})}else g(n,{isLoaded:!0,clientId:this.clientId})}},{key:"unload",value:function(e){var r=this,t=e.onSuccess,n=void 0===t?function(){}:t,o=e.onFailure,i=void 0===o?function(){}:o;if(S(this)){var u={clientId:this.clientId};this.state=3,O({method:"unload",onComplete:function(e){return!0===e.returnValue?(r.clientId="",r.state=0,n()):i(w(r,e))},parameters:u})}else g(i,w(this,P))}},{key:"getRightsError",value:function(e){var r=this,t=e.onSuccess,n=void 0===t?function(){}:t,o=e.onFailure,i=void 0===o?function(){}:o;S(this)?O({method:"getRightsError",parameters:{clientId:this.clientId,subscribe:!0},onComplete:function(e){if(!0===e.returnValue){var t=v({},e);return delete t.returnValue,n(t)}return i(w(r,e))}}):g(i,w(this,P))}},{key:"sendDrmMessage",value:function(e){var r=this,t=e.msg,n=void 0===t?"":t,o=e.onSuccess,i=void 0===o?function(){}:o,u=e.onFailure,c=void 0===u?function(){}:u;if(S(this)){var a=function(e){var r="",t="";switch(e){case h.PLAYREADY:r="application/vnd.ms-playready.initiator+xml",t="urn:dvb:casystemid:19219";break;case h.WIDEVINE:r="application/widevine+xml",t="urn:dvb:casystemid:19156"}return{msgType:r,drmSystemId:t}}(this.drmType),s=v({clientId:this.clientId,msg:n},a);O({method:"sendDrmMessage",onComplete:function(e){if(!0===e.returnValue){var t=v({},e);return delete t.returnValue,i(t)}return c(w(r,e))},parameters:s})}else g(c,w(this,P))}}])&&p(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}(),j={Error:y,Type:h},E=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return""===e?null:new T(e)};function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function I(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}var R={getStatus:function(e){var r=e.onSuccess,t=void 0===r?function(){}:r,n=e.onFailure,o=void 0===n?function(){}:n,i=e.subscribe,u=void 0!==i&&i,a="webos.service";navigator.userAgent.indexOf("537.41")>-1&&(a="palm"),function(e){var r=e.service,t=e.subscribe,n=e.onSuccess,o=e.onFailure;(new c).send({service:r,method:"getStatus",parameters:{subscribe:t},onComplete:function(e){var r=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?I(Object(t),!0).forEach((function(r){var n,o,i,u;n=e,o=r,i=t[r],u=function(e,r){if("object"!=D(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o),(o="symbol"==D(u)?u:u+"")in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},e);if(delete r.returnValue,!0===e.returnValue)return delete r.subscribe,void n(r);delete r.returnValue,o(r)}})}({service:"luna://com.".concat(a,".connectionmanager"),subscribe:u,onSuccess:t,onFailure:o})}},C=function(e){var r=e.onSuccess,t=void 0===r?function(){}:r,n=e.onFailure,o=void 0===n?function(){}:n;-1!==navigator.userAgent.indexOf("Chrome")?(new c).send({service:"luna://com.webos.service.sm",method:"deviceid/getIDs",parameters:{idType:["LGUDID"]},onComplete:function(e){if(!0!==e.returnValue)o({errorCode:e.errorCode,errorText:e.errorText});else{var r=e.idList.filter((function(e){return"LGUDID"===e.idType}))[0].idValue;t({id:r})}}}):setTimeout((function(){o({errorCode:"ERROR.000",errorText:"Not supported."})}),0)};window.webOSDev=r}();