senza-sdk 4.1.3 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/package.json +4 -4
- package/src/alarmManager.js +0 -1
- package/src/api.js +2 -3
- package/src/messageManager.js +0 -1
- package/src/remotePlayer.js +0 -1
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.senza=t():e.senza=t()}(this,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ClientAssertionError:()=>ae,ConnectReason:()=>V,alarmManager:()=>U,auth:()=>B,deviceManager:()=>A,envInfo:()=>se,getClientAssertion:()=>de,getConnectReason:()=>Z,getDeviceInfo:()=>oe,getPlatformInfo:()=>ee,getTriggerEvent:()=>Y,init:()=>K,initSequence:()=>p,isRunningE2E:()=>ie,lifecycle:()=>N,messageManager:()=>J,platformManager:()=>L,remotePlayer:()=>_,setTimezone:()=>te,showSequence:()=>h,uiReady:()=>ne,writeLicenseResponse:()=>re});var i={};e.r(i),e.d(i,{ClientAssertionError:()=>ae,ConnectReason:()=>V,alarmManager:()=>U,auth:()=>B,deviceManager:()=>A,envInfo:()=>se,getClientAssertion:()=>de,getConnectReason:()=>Z,getDeviceInfo:()=>oe,getPlatformInfo:()=>ee,getTriggerEvent:()=>Y,init:()=>K,initSequence:()=>p,isRunningE2E:()=>ie,lifecycle:()=>N,messageManager:()=>J,platformManager:()=>L,remotePlayer:()=>_,setTimezone:()=>te,showSequence:()=>h,uiReady:()=>ne,writeLicenseResponse:()=>re});const n={version:"4.1.3"},{version:o}=n,s=5;function r(){return Math.round(1e5*Math.random())+"-"+ee().sessionInfo?.connectionId}class a{constructor(e){this.logFields=e}debug(...e){console.debug(this.formatLogString(e))}log(...e){console.log(this.formatLogString(e))}info(...e){console.info(this.formatLogString(e))}warn(...e){console.warn(this.formatLogString(e))}error(...e){console.error(this.formatLogString(e))}withFields(e){return new a({...this.logFields,...e})}formatLogString(e){let t="[hs-sdk] "+e.join(" ");return this.logFields&&(t+=" [log-fields] "+JSON.stringify(this.logFields)),t}}const d=new a({sdkVersion:o,url:window?.location?.href??""});async function l(e){if(window.cefQuery)return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),a={type:"restRequest",name:e,method:"GET",fcid:n},l={target:"TC",waitForResponse:!0,message:JSON.stringify(a)};let c=0;const u=window.cefQuery({request:JSON.stringify(l),persistent:!1,onSuccess:i=>{c&&clearTimeout(c),o.info(`Got restResponse for ${e}: ${i}`),t(i)},onFailure:(t,n)=>{c&&clearTimeout(c);const s=`failed to get restResponse for ${e}: ${t} ${n}`;o.error(s),i(s)}});c=setTimeout((()=>{window.cefQueryCancel(u);const t=`failed to get restResponse for ${e}: reached timeout of ${1e3*s} ms`;o.error(t),i(t)}),1e3*s)}));d.error("getRestResponse: window.cefQuery is undefined")}const c=new class{sessionInfoStr="{}";get sessionInfoObj(){try{return JSON.parse(this.sessionInfoStr)}catch(e){return void d.warn("Failed to return sdk")}}setSessionInfoStr(e){try{JSON.parse(e)}catch(e){throw Error("Failed to parse sessionInfo")}this.sessionInfoStr=e}},u={BACK:27,HOME:36,LEFT:37,RIGHT:39,UP:38,DOWN:40,ENTER:13},f={root:{top:"5vh",left:"82vw",height:"90vh",fontSize:"16px",width:"16vw",position:"fixed",zIndex:1e4,overflow:"hidden",visibility:"hidden"},item:{backgroundColor:"white",color:"black",fontSize:"12px",display:"flex",padding:"6px",border:"1px solid black",borderTop:"none"},item_key:{borderTopLeftRadius:"6px",borderTopRightRadius:"6px",marginTop:"20px",borderBottom:"3px solid black"},component:{fontWeight:"bold",width:"5vw"},component_key:{fontWeight:"normal",color:"darkgray"},id:{textAlign:"left",fontWeight:"normal",flex:1},id_key:{fontWeight:"bold"},time:{fontVariantNumeric:"tabular-nums",width:"3vw"},time_key:{fontWeight:"bold"}};let g=performance.now();const y=(e,t)=>"key"===t?new Date(e).toLocaleTimeString("en-US",{hour12:!1}):`${(e/1e3).toFixed(2)}s`,w=(e,t,i)=>{Object.entries(e).forEach((([e,n])=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((o=>{if(i&&i(o))return;const s=n[o];"function"==typeof s&&(n[o]=function(...i){return t(e,o,...i),s.apply(this,i)})}))}))},m=(e,t)=>{e.innerHTML="",t.forEach(((i,n)=>{const o=document.createElement("div");Object.assign(o.style,{...f.item,...f[`item_${i?.component}`]}),["component","id","time"].forEach((e=>{if(i[e]){const t=document.createElement("div");Object.assign(t.style,f[e],f[`${e}_${i.component}`]),t.textContent="time"===e?y(i.time,i.component):i[e],o.appendChild(t)}})),e.appendChild(o),n===t.length-1&&o.scrollIntoView({behavior:"smooth"})}))},p=e=>{if(!e)return void d.error("No components to sequence");let t=document.getElementById("sequence-container");if(t)return;t=(()=>{const e=document.createElement("div");return e.id="sequence-container",Object.assign(e.style,f.root),document.body.appendChild(e),e})();const i=new Proxy([],{set:(e,n,o)=>(e[n]=o,"length"!==n&&m(t,i),!0)});window.printSequence=()=>(e=>{const t=e.map((e=>{const t=e.separator?"\n":"",i=e?.time?` ${y(e.time,e?.component)}`:"";if(e.args){const n=e.args.map((e=>"object"==typeof e?"object":e)).join(", ");return`${t}${e.component}.${e.id}(${n})${i}`}return`\n${e.component}: ${e.id}${i}`}));d.log("sequence:\n",t.join("\n"))})(i),((e,t)=>{t.push({component:"key",id:"BOOT",time:Date.now()}),w(e,((e,i,...n)=>{t.push({component:e,id:i,args:n,time:performance.now()-g})}),(e=>e.startsWith("_")||e.startsWith("get"))),(e=>{window.addEventListener("keydown",(t=>{var i;e.push({component:"key",id:(i=t.keyCode,Object.entries(u).find((([,e])=>e===i))?.[0]||String(i)),time:Date.now()}),g=performance.now()}))})(t),d.log("Sequence initialized.")})(e,i),m(t,i)},h=(e=!0)=>{const t=document.getElementById("sequence-container");t?t.style.visibility=e?"visible":"hidden":d.error("Sequence not initialized")},T=e=>JSON.parse(JSON.stringify(e));class v extends Error{constructor(e,t){super(t),this.code=e,this.msg=t}}function S(){const e=window.getPlaybackInfo?window.getPlaybackInfo():JSON.stringify({playbackPosition:0,assetDuration:0});let t;try{t=JSON.parse(e)}catch(i){d.error(`Playback Info parse failed. playbackStr = ${e}`),t={playbackPosition:0,assetDuration:0}}return t}function b(e){try{const t=JSON.stringify(e);window.setPlaybackInfo&&window.setPlaybackInfo(t)}catch(e){d.error("Playback Info to json string failed")}}class I extends EventTarget{constructor(){super(),this._config={preferredAudioLanguage:"",preferredSubtitlesLanguage:""},this._selectedAudioTrack="",this._selectedSubtitlesTrack="",this._availableAudioTracks=[],this._availableTextTracks=[],this._textTrackVisibility=!1,this._ptsSessionId=0,this._videoElement=void 0,this._isInitialized=!1,"undefined"!=typeof document&&document.addEventListener("hs/playbackInfoEvent",(()=>{d.info("Got hs/playbackInfoEvent"),this.dispatchEvent(new Event("timeupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/playback",(e=>{d.info("Got hs/playback event with detail",JSON.stringify(e?.detail)),this._availabilityStartTime=e?.detail?.availabilityStartTime,this._updateTracks(e?.detail),this.dispatchEvent(new Event("tracksupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/EOS",(()=>{d.info("Got hs/EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/ui_inactive",(()=>{d.info("Got hs/ui_inactive event")})),"undefined"!=typeof document&&document.addEventListener("hs/senzaPlayerSetRate",(e=>{this._videoElement&&(this._videoElement.playbackRate=e.detail.rate)})),"undefined"!=typeof document&&document.addEventListener("hs/senzaPlayerSetTime",(e=>{this._videoElement?(d.info(`Adding ${e.detail} seconds to current time ${this._videoElement.currentTime}`),this._videoElement.playbackRate=1,this._videoElement.currentTime+=e.detail):d.warn("video element is NOT set")})),"undefined"!=typeof document&&document.addEventListener("hs/ERR",(e=>{d.info("Got hs/ERR event"),delete e?.detail?.type,delete e?.detail?.eventCode,this.dispatchEvent(new CustomEvent("error",e))})),"undefined"!=typeof document&&document.addEventListener("hs/getLicense",(e=>{d.info("Got hs/getLicense event");const t=e?.detail,i=Uint8Array.from(t.request,(e=>e.charCodeAt(0))),n=new ArrayBuffer(i.byteLength);new Uint8Array(n).set(i),this.licenseRequest=n;const o=t.fcid,s=t.sessionId,r=new CustomEvent("license-request",{detail:{licenseRequest:n}});r.writeLicenseResponse=(e,t)=>{re(e,t,o,s)},this.dispatchEvent(r)}))}LoadMode=Object.freeze({NOT_LOADED:"notLoaded",LOADING:"loading",LOADED:"loaded",UNLOADING:"unloading"});async _init(e,t){let i={isLoaded:!1,playbackUrl:""};if(window.cefQuery){const e=r(),t=d.withFields({FCID:e}),n={type:"playerState",fcid:e},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};try{const e=await new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:i=>{t.log("playerState request successfully returned",i),e(i)},onFailure:(e,n)=>{t.error(`playerState request failed: ${e} ${n}`),i()}})}));i=JSON.parse(e)}catch{t.error("either failed to get or failed to parse player state")}}this._loadMode=i?.isLoaded?this.LoadMode.LOADED:this.LoadMode.NOT_LOADED,this._loadedUrl=i?.playbackUrl||"",this._isInitialized=!0,this._setPlayableUriTimeout=e?.setPlayableUriTimeout??5e3,this._unloadTimeout=e?.unloadTimeout??5e3,this._requestVideoFrameInfo=e?.requestVideoFrameInfo??!0;let n={};try{n=JSON.parse(t?.playbackMetadata||"{}")}catch(e){d.error(`failed to parse playbackMetadata: ${e.message}`)}this._availabilityStartTime=n.availabilityStartTime,this._updateTracks(n)}_updateTracks(e){if(this._availableAudioTracks=e?.availableAudioTracks||this._availableAudioTracks,this._availableTextTracks=e?.availableSubtitlesTracks||this._availableTextTracks,"VOD"===e?.assetType&&(this._availableTextTracks=function(e){if(!e||e.length<1)return e;e.sort(((e,t)=>e.lang.toLowerCase()>t.lang.toLowerCase()?1:-1));const t=[{lang:"af",id:"*:af"},{lang:"ar",id:"*:ar"},{lang:"az",id:"*:az"},{lang:"bg",id:"*:bg"},{lang:"bs",id:"*:bs"},{lang:"ca",id:"*:ca"},{lang:"cs",id:"*:cs"},{lang:"cy",id:"*:cy"},{lang:"da",id:"*:da"},{lang:"de",id:"*:de"},{lang:"el",id:"*:el"},{lang:"en",id:"*:en"},{lang:"es",id:"*:es"},{lang:"es-MX",id:"*:es-MX"},{lang:"et",id:"*:et"},{lang:"fi",id:"*:fi"},{lang:"fr",id:"*:fr"},{lang:"fr-CA",id:"*:fr-CA"},{lang:"ga",id:"*:ga"},{lang:"ha",id:"*:ha"},{lang:"he",id:"*:he"},{lang:"hr",id:"*:hr"},{lang:"ht",id:"*:ht"},{lang:"hu",id:"*:hu"},{lang:"id",id:"*:id"},{lang:"is",id:"*:is"},{lang:"it",id:"*:it"},{lang:"kk",id:"*:kk"},{lang:"lt",id:"*:lt"},{lang:"lv",id:"*:lv"},{lang:"mk",id:"*:mk"},{lang:"mn",id:"*:mn"},{lang:"ms",id:"*:ms"},{lang:"mt",id:"*:mt"},{lang:"nl",id:"*:nl"},{lang:"no",id:"*:no"},{lang:"pl",id:"*:pl"},{lang:"pt",id:"*:pt"},{lang:"pt-PT",id:"*:pt-PT"},{lang:"ro",id:"*:ro"},{lang:"ru",id:"*:ru"},{lang:"sk",id:"*:sk"},{lang:"sl",id:"*:sl"},{lang:"so",id:"*:so"},{lang:"sq",id:"*:sq"},{lang:"sr",id:"*:sr"},{lang:"sv",id:"*:sv"},{lang:"sw",id:"*:sw"},{lang:"tl",id:"*:tl"},{lang:"tr",id:"*:tr"},{lang:"uk",id:"*:uk"},{lang:"uz",id:"*:uz"},{lang:"vi",id:"*:vi"},{lang:"zh",id:"*:zh"}],i=[...e];for(const n of t)e.find((e=>e.lang===n.lang))||(n.autoTranslate=!0,i.push(n));return i}(this._availableTextTracks)),this._availableAudioTracks){const e=this._availableAudioTracks.find((e=>!0===e.selected));this._selectedAudioTrack=e?.id||""}if(this._availableTextTracks){const e=this._availableTextTracks.find((e=>!0===e.selected));e?(this._selectedSubtitlesTrack=e.id,this._textTrackVisibility=!0):(this._selectedSubtitlesTrack="",this._textTrackVisibility=!1)}}getConfiguration(){return T(this._config)}configure(e){Object.entries(e).forEach((([e,t])=>{void 0!==this._config[e]&&(this._config[e]=t)}))}_changeLoadMode(e){this._loadMode!==e&&(this._loadMode=e,this.dispatchEvent(new Event("onloadmodechange")))}_handle_video_frame_info(e){if(!this._requestVideoFrameInfo||void 0===e)return void(this._videoElement=void 0);const t=r(),i=d.withFields({fcid:t}),n=(e,i)=>{const o={type:"currentFramePTS",fcid:t,currentFramePTS:i.mediaTime.toString(),ptsSessionId:this._ptsSessionId},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1}),this._videoElement?.requestVideoFrameCallback(n)};i.log("handle_video_frame_pts: requesting video frame info"),void 0!==this._videoElement&&this._videoElement===e||(e.requestVideoFrameCallback(n),e.addEventListener("loadstart",(e=>{this._ptsSessionId++,d.info("videoElement, loadstart ptsSessionId=",this._ptsSessionId," event=",e)}))),this._videoElement=e}_reset(){this._availableAudioTracks=[],this._availableTextTracks=[],this._selectedAudioTrack="",this._selectedSubtitlesTrack="",this._availabilityStartTime=void 0}registerVideoElement(e){this.attach(e)}attach(e){this._handle_video_frame_info(e)}async load(e,t){if(!this._isInitialized)throw new v(6500,"Cannot call load() if remote player is not initialized");if(e&&window.cefQuery){const i=await N.getState();if("background"===i||"inTransitionToBackground"===i)throw new v(6002,"Cannot call load() while in state 'background' or 'inTransitionToBackground'");if(this._loadMode===this.LoadMode.LOADING)throw new v(6501,"Cannot call load() while previous load is still in progress");this._reset();const n=this._loadMode;return this._changeLoadMode(this.LoadMode.LOADING),new Promise(((i,o)=>{b({playbackPosition:0});const s=r(),a=t??0,l=d.withFields({FCID:s,loadUrl:e,playbackPosition:a});l.log("remotePlayer load: sending setPlayableUri request");const c={type:"setPlayableUri",url:e,timeout:this._setPlayableUriTimeout,autoPlay:!1,playbackPosition:a,fcid:s},u={target:"TC",waitForResponse:!0,message:JSON.stringify(c)};let f=0;const g=Date.now(),y=window.cefQuery({request:JSON.stringify(u),persistent:!1,onSuccess:()=>{const n=Date.now()-g;l.withFields({duration:n}).log(`setPlayableUri completed successfully after ${n} ms`),t>0&&b({playbackPosition:t}),f&&(clearTimeout(f),f=0),this._changeLoadMode(this.LoadMode.LOADED),this._loadedUrl=e,this.dispatchEvent(new Event("canplay")),i()},onFailure:(e,t)=>{const i=Date.now()-g;l.withFields({duration:i}).log(`setPlayableUri failed after ${i} ms. Error code: ${e}, error message: ${t}`),f&&(clearTimeout(f),f=0),99===e?this._changeLoadMode(n):(this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=""),o(new v(e,t))}});l.log(`window.cefQuery for setPlayableUri returned query id ${y}`);const w=this._setPlayableUriTimeout+1e3;f=setTimeout((()=>{l.log(`setPlayableUri reached timeout of ${w} ms, canceling query id ${y}`),window.cefQueryCancel(y),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl="",o(new v(6e3,`load reached timeout of ${w} ms`))}),w,y)}))}d.error("remotePlayer load: either window.cefQuery or url is undefined")}async unload(){if(!this._isInitialized)throw new v(6500,"Cannot call unload() if remote player is not initialized");if(window.cefQuery){if(this._loadMode===this.LoadMode.LOADING)throw new v(6502,"Cannot call unload() while load is still in progress");const e=this._loadMode;return this._changeLoadMode(this.LoadMode.UNLOADING),new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n});o.log("remotePlayer unload");const s={type:"remotePlayer.unload",class:"remotePlayer",action:"unload",fcid:n},a={target:"TC",waitForResponse:!0,message:JSON.stringify(s)};let l=0;const c=Date.now(),u=window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{const e=Date.now()-c;o.withFields({duration:e}).log(`unload completed successfully after ${e} ms`),l&&(clearTimeout(l),l=0),this._reset(),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=void 0,t()},onFailure:(t,n)=>{const s=Date.now()-c;o.withFields({duration:s}).log(`unload failed after ${s} ms. Error code: ${t}, error message: ${n}`),l&&(clearTimeout(l),l=0),this._changeLoadMode(e),i(new v(t,n))}});o.log(`window.cefQuery for unload returned query id ${u}`);const f=this._unloadTimeout+1e3;l=setTimeout((()=>{o.log(`unload reached timeout of ${f} ms, canceling query id ${u}`),window.cefQueryCancel(u),this._changeLoadMode(e),i(new v(6e3,`unload reached timeout of ${f} ms`))}),f,u)}))}d.error("remotePlayer unload: window.cefQuery is undefined")}play(){if(!this._isInitialized)throw new v(6500,"Cannot call play() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new v(6001,"Cannot call play() if player is not loaded");const e=r(),t=d.withFields({FCID:e});t.log("remotePlayer play: sending play action");const i=this._selectedAudioTrack||this._config.preferredAudioLanguage||"";let n="";this._textTrackVisibility&&(n=this._selectedSubtitlesTrack||this._config.preferredSubtitlesLanguage||"");const o={type:"remotePlayer.play",class:"remotePlayer",action:"play",fcid:e,audioLanguage:i,subtitlesLanguage:n,playbackPosition:this.currentTime},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};return new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{t.log("remotePlayer play request successfully sent"),e()},onFailure:(e,n)=>{t.error(`remotePlayer play request failed: ${e} ${n}`),i(new v(e,n))}})}))}return d.error("remotePlayer play: window.cefQuery is undefined"),Promise.resolve(void 0)}pause(){if(!this._isInitialized)throw new v(6500,"Cannot call pause() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new v(6001,"Cannot call pause() if player is not loaded");const e=r(),t=d.withFields({FCID:e});t.log("remotePlayer pause: sending pause request");const i={type:"remotePlayer.pause",class:"remotePlayer",action:"pause",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};return new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("remotePlayer pause request successfully sent"),e()},onFailure:(e,n)=>{t.error(`remotePlayer pause request failed: ${e} ${n}`),i(new v(e,n))}})}))}return d.error("remotePlayer pause: window.cefQuery is undefined"),Promise.resolve(void 0)}getAssetUri(){if(!this._isInitialized)throw new v(6500,"Cannot call getAssetUri() if remote player is not initialized");return this._loadedUrl}getLoadMode(){if(!this._isInitialized)throw new v(6500,"Cannot call getLoadMode() if remote player is not initialized");return this._loadMode}getTextTracks(){return T(this._availableTextTracks)}getAudioTracks(){return T(this._availableAudioTracks)}selectAudioTrack(e){for(const t of this.getAudioTracks())if(t.id===e)return void(this._selectedAudioTrack=e);d.warn(`Invalid audioTrackId ${e}`)}selectTextTrack(e){for(const t of this.getTextTracks())if(t.id===e)return void(this._selectedSubtitlesTrack=e);d.warn(`Invalid textTrackId ${e}`)}setTextTrackVisibility(e){const t=this._textTrackVisibility;if("boolean"!=typeof e)throw new TypeError("visible parameter must be a boolean");const i=e;i!==t&&(this._textTrackVisibility=i,i||(this._selectedSubtitlesTrack=""))}get currentTime(){return S()?.playbackPosition}set currentTime(e){if(b({playbackPosition:e}),window.cefQuery){const t=r(),i=d.withFields({FCID:t});i.log("setting remotePlayer currentTime");const n={type:"remotePlayer.seek",class:"remotePlayer",action:"seek",playbackPosition:e,fcid:t},o={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{i.log("remotePlayer seek request successfully sent")},onFailure:(e,t)=>{i.error(`remotePlayer seek request failed: ${e} ${t}`)}})}else d.error("setting remotePlayer currentTime: window.cefQuery is undefined")}get duration(){return S()?.assetDuration}get textTrackVisibility(){return this._textTrackVisibility}getPresentationStartTimeAsDate(){return void 0===this._availabilityStartTime?null:new Date(1e3*this._availabilityStartTime)}}const _=new I;"undefined"!=typeof window&&(window.remotePlayer=_,Object.defineProperty(window,"senzaRemotePlayer",{value:_,writable:!1,configurable:!1}));class O extends EventTarget{UiState=Object.freeze({UNKNOWN:"unknown",FOREGROUND:"foreground",IN_TRANSITION_TO_FOREGROUND:"inTransitionToForeground",BACKGROUND:"background",IN_TRANSITION_TO_BACKGROUND:"inTransitionToBackground"});constructor(){super(),this._isInitialized=!1,this._inTransition=!1,"undefined"!=typeof document&&document.addEventListener("hs/uistatechange",(e=>{d.log("Got hs/uistatechange",e.detail);const t=new Event("onstatechange");t.state=e.detail,this._state=t.state,this.dispatchEvent(t)})),"undefined"!=typeof document&&document.addEventListener("hs/systemInactivity",(e=>{d.log("Got hs/systemInactivity",e.detail);const t=new Event("userinactivity");t.timeout=e.detail.timeout,this.dispatchEvent(t)}))}async _init(){window.cefQuery&&(this._state=await new Promise((e=>{window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{d.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(t,i)=>{d.error(`uiState request failed: ${t} ${i}`),e(this.UiState.UNKNOWN)}})})),this._isInitialized=!0)}get state(){return this._isInitialized||(this._state=this.UiState.UNKNOWN),this._state}getState(){if(window.cefQuery)return new Promise(((e,t)=>{window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{d.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(e,i)=>{d.error(`uiState request failed: ${e} ${i}`),t(i)}})}));d.warn("lifecycle getState is not supported if NOT running e2e")}moveToForeground(){return window.cefQuery?this._inTransition||this._state===this.UiState.FOREGROUND||this._state===this.UiState.IN_TRANSITION_TO_FOREGROUND?(d.warn(`lifecycle moveToForeground: No need to transition to foreground, state: ${this._state} transition: ${this._inTransition}`),Promise.resolve(!1)):(this._inTransition=!0,new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});n.log("lifecycle moveToForeground: sending uiActiveRequest action"),window.cefQuery({request:JSON.stringify({action:"uiActiveRequest",fcid:i}),persistent:!1,onSuccess:()=>{n.log("uiActiveRequest successfully sent"),this._inTransition=!1,e(!0)},onFailure:(e,i)=>{this._inTransition=!1,n.error(`uiActiveRequest failed: ${e} ${i}`),t(`uiActiveRequest failed: ${e} ${i}`)}})}))):(d.warn("lifecycle moveToForeground: window.cefQuery is undefined"),Promise.resolve(!1))}moveToBackground(){return window.cefQuery?this._inTransition||this._state===this.UiState.BACKGROUND||this._state===this.UiState.IN_TRANSITION_TO_BACKGROUND?(d.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`),Promise.resolve(!1)):(this._inTransition=!0,new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});n.log("lifecycle moveToBackground: sending play action");const o=_.getConfiguration(),s=_._selectedAudioTrack||o.preferredAudioLanguage||"",a=_._selectedSubtitlesTrack||o.preferredSubtitlesLanguage||"";window.cefQuery({request:JSON.stringify({action:"play",fcid:i,audioLanguage:s,subtitlesLanguage:a}),persistent:!1,onSuccess:()=>{n.log("[ moveToBackground ] play successfully sent"),this._inTransition=!1,e(!0)},onFailure:(e,i)=>{this._inTransition=!1,n.error(`[ moveToBackground ] play failed: ${e} ${i}`),t(`[ moveToBackground ] play failed: ${e} ${i}`)}})}))):(d.warn("lifecycle moveToBackground: window.cefQuery is undefined"),Promise.resolve(!1))}moveToUiStandby(){return window.cefQuery?new Promise(((e,t)=>{const i=r(),n={target:"TC",waitForResponse:!1,message:JSON.stringify({type:"uiStandbyRequest",fcid:i})},o=d.withFields({FCID:i});o.log("lifecycle moveToUiStandby: sending uiStandbyRequest"),window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{o.log("[ moveToUiStandby ] moveToUiStandby successfully sent"),e(!0)},onFailure:(e,i)=>{o.error(`[ moveToUiStandby ] moveToUiStandby failed: ${e} ${i}`),t(`moveToUiStandby failed: ${e} ${i}`)}})})):(d.warn("moveToUiStandby was called in local dev"),Promise.resolve(!0))}switchTenant(e){if(e&&e.length>0){if(e===ee().sessionInfo?.tenantId)return d.warn(`SwitchTenant requires a different tenantId than the current one. CurrentTenantId=${ee().sessionInfo?.tenantId} and tenantId=${e}`),Promise.reject("SwitchTenant requires a different tenantId than the current one");const t=ee().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId,i=ee().sessionInfo?.homeSessionInfo?.tenantId;return d.log(`SwitchTenant for ${e}`),window.cefQuery?new Promise(((n,o)=>{const s=r(),a=d.withFields({FCID:s}),l={type:"reconnect",fcid:s,session:btoa(JSON.stringify({tenantId:e,...ee().sessionInfo?.tenantId===t&&e!==i&&{returnToTenantId:t}}))},c={target:"TC",waitForResponse:!1,message:JSON.stringify(l)};window.cefQuery({request:JSON.stringify(c),persistent:!1,onSuccess:()=>{a.log("SwitchTenant request successfully sent"),n(!0)},onFailure:(e,t)=>{a.error(`SwitchTenant failed: ${e} ${t}`),o(`SwitchTenant failed: ${e} ${t}`)}})})):(d.warn("SwitchTenant is not supported if NOT running e2e"),Promise.reject("SwitchTenant is not supported if NOT running e2e"))}return d.warn("SwitchTenant requires a valid tenantId string parameter"),Promise.reject("SwitchTenant requires a valid tenantId string parameter")}exitApplication(){return window.cefQuery?new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});let o,s;const a=c.sessionInfoObj;a?.homeSessionInfo&&(a?.returnToTenantId||a?.homeSessionInfo.tenantId!==a?.tenantId)?(s={type:"reconnect",splashUrl:a?.homeSessionInfo.tenantInfo.tenantSettings.applicationSwitchSplashUrl,fcid:i},a?.returnToTenantId&&(a?.returnToTenantId===a?.homeSessionInfo.tenantInfo.contentHubTenantId&&(s.splashUrl=a?.homeSessionInfo.contentHubTenantInfo.tenantSettings.applicationSwitchSplashUrl),s.session=btoa(JSON.stringify({tenantId:a?.returnToTenantId}))),o={target:"TC",waitForResponse:!1,message:JSON.stringify(s)}):(s={type:"launchHomeApplication",fcid:i},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)}),window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{n.log(`exitApplication request with type: '${s.type}' successfully sent`),e(!0)},onFailure:(e,i)=>{n.error(`exitApplication request with type: '${s.type}' failed: ${e} ${i}`),t(`exitApplication request with type: '${s.type}' failed: ${e} ${i}`)}})})):(d.warn("exitApplication is not supported if NOT running e2e"),Promise.reject("exitApplication is not supported if NOT running e2e"))}}const N=new O,k={};let E,$,F=0;async function P(){if(!E)try{const e=await l("wifi-ap-data");E=JSON.parse(e)}catch(e){d.error(e)}}async function q(){if(F+5e3<Date.now())try{const e=await l("wifi-status");$=JSON.parse(e),F=Date.now()}catch(e){d.error(e)}}class C extends EventTarget{constructor(){super(),k.level=0,k.quality=0,k.ssid="unknown",k.bssid="unknown","undefined"!=typeof document&&document.addEventListener("wifiSignalReport",(e=>{d.log("Got wifiSignalReport",JSON.stringify(e.detail)),k.level=e.detail.level,k.quality=e.detail.quality,k.ssid=e.detail.ssid,k.bssid=e.detail.bssid,this.dispatchEvent(new Event("wifiInfoUpdated"))}))}get deviceInfo(){const e=c.sessionInfoObj;return ie()&&e?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp,countryCode:e.general?.location?.["x-country-code"]}:(d.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0",countryCode:"XX"})}get wifiInfo(){return k}reboot(){return new Promise(((e,t)=>{if(window.cefQuery){const i=r(),n=d.withFields({FCID:i}),o={type:"reboot",fcid:i},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{n.log("reboot request successfully sent"),e(!0)},onFailure:(e,i)=>{n.error(`reboot failed: ${e} ${i}`),t(`reboot failed: ${e} ${i}`)}})}else d.warn("reboot is not supported if NOT running e2e"),t("reboot is not supported if NOT running e2e")}))}clearWifi(){return new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i}),o={type:"resetWifi",fcid:i},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{n.log("clearWifi successfully sent"),e(!0)},onFailure:(e,i)=>{n.error(`clearWifi failed: ${e} ${i}`),t(`clearWifi failed: ${e} ${i}`)}})}))}sendDataToDevice(e){if("string"!=typeof e)throw new Error("data must be of type 'string'");return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),s={type:"externalCommand",data:{command:"forward",payload:e},fcid:n},a={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{o.log("externalCommand successfully sent"),t()},onFailure:(e,t)=>{o.error(`externalCommand failed: ${e} ${t}`),i(`externalCommand failed: ${e} ${t}`)}})}))}async factoryReset(e=!0){if("boolean"!=typeof e)throw new Error("reboot param must be of type 'boolean'");return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),s={type:"factoryReset",fcid:n,reboot:e},a={target:"TC",waitForResponse:!0,message:JSON.stringify(s)};let l=0;const c=window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{l&&clearTimeout(l),o.log("factoryReset successfully sent"),t(!0)},onFailure:(e,t)=>{l&&clearTimeout(l),o.error(`factoryReset failed: ${e} ${t}`),i(`factoryReset failed: ${e} ${t}`)}});l=setTimeout((()=>{o.error("factoryReset failed: reached timeout of 5000 ms"),window.cefQueryCancel(c),i("factoryReset failed: reached timeout of 5000 ms")}),5e3)}))}async getWifiInfo(){return await Promise.all([P(),q()]),{...E,...$}}}const A=new C;"undefined"!=typeof window&&Object.defineProperty(window,"senzaDeviceManager",{value:A,writable:!1,configurable:!1});class R extends EventTarget{constructor(){super()}get appConfig(){const e=c.sessionInfoObj,t=e.homeSessionInfo?.appConfig||{};return d.info("PlatformManager get appConfig: \n"+JSON.stringify(t,null,2)),t}setTimezone(e){if(window.cefQuery){const t={message:JSON.stringify({type:"setTimeZone",timezone:e}),waitForResponse:!1,target:"UI-Streamer"};window.cefQuery({request:JSON.stringify(t),persistent:!1,onSuccess:()=>{d.log("PlatformManager timezome is successfully set to",e)},onFailure:(t,i)=>{d.error(`PlatformManager error occurred setting timezone to ${e}: ${t} ${i}`)}})}}}const L=new R;class D extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/alarmFiredEvent",(e=>{d.log("Got hs/alarmFiredEvent",JSON.stringify(e.detail)),e.detail?.alarmName&&this.dispatchEvent(new CustomEvent(e.detail.alarmName,{detail:e.detail.payload}))}))}addAlarm(e,t,i=""){if("string"!=typeof i)throw Error("data must be a string");const n=r(),o=d.withFields({alarmName:e,FCID:n});if(o.log(`addAlarm called for ${e} to be fired at ${t}`),window.cefQuery){const s={type:"addAlarm",fcid:n,alarmName:e,alarmTime:t,payload:i},r={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(r),persistent:!1,onSuccess:()=>{o.log("addAlarm request successfully sent")},onFailure:(e,t)=>{o.error(`addAlarm failed: ${e} ${t}`)}})}else o.warn("addAlarm is not supported if NOT running e2e")}deleteAlarm(e){const t=r(),i=d.withFields({alarmName:e,FCID:t});if(i.log(`deleteAlarm called for ${e}`),window.cefQuery){const n={type:"deleteAlarm",fcid:t,alarmName:e},o={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{i.log("deleteAlarm request successfully sent")},onFailure:(e,t)=>{i.error(`deleteAlarm failed: ${e} ${t}`)}})}else i.warn("deleteAlarm is not supported if NOT running e2e")}deleteAllAlarms(){if(window.cefQuery){const e=r(),t=d.withFields({FCID:e}),i={type:"deleteAllAlarms",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("deleteAllAlarms request successfully sent")},onFailure:(e,i)=>{t.error(`deleteAllAlarms failed: ${e} ${i}`)}})}else d.warn("deleteAllAlarms is not supported if NOT running e2e")}getActiveAlarms(){throw Error("NOT IMPLEMENTED")}}const U=new D;"undefined"!=typeof window&&(window.alarmManager=U,Object.defineProperty(window,"senzaAlarmManager",{value:U,writable:!1,configurable:!1}));class Q extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/externalEvent",(e=>{d.log("Got hs/externalEvent",JSON.stringify(e.detail)),this.dispatchEvent(new CustomEvent("message",{detail:{eventName:e.detail.eventName,payload:e.detail.payload,fcid:e.detail.fcid}}))}))}async registerGroups(e){return d.log(`register called for ${e}`),new Promise(((t,i)=>{if(window.cefQuery){const n=r(),o=d.withFields({FCID:n}),s={type:"registerGroupEvent",fcid:n,groups:e},a={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{o.log("registerGroupEvent request successfully sent"),t(!0)},onFailure:(e,t)=>{o.error(`registerGroupEvent failed: ${e} ${t}`),i(`registerGroupEvent failed: ${e} ${t}`)}})}else d.warn("registerGroupEvent is not supported if NOT running e2e"),i("registerGroupEvent is not supported if NOT running e2e")}))}}const J=new Q;let M,x;"undefined"!=typeof window&&(window.messageManager=J,Object.defineProperty(window,"senzaMessageManager",{value:J,writable:!1,configurable:!1})),N.getState()?.then((e=>{x=e})),N.addEventListener("onstatechange",(e=>{x=e.state}));const X=e=>{"background"!==x&&"inTransitionToBackground"!==x||(M&&clearTimeout(M),M=setTimeout((()=>{"background"!==x&&"inTransitionToBackground"!==x||d.log(`${e.type} event received while in '${x}' state and there was no call to lifecycle.moveToForeground() for 500 ms. Make sure to call it if you want to move to foreground.`),M=0}),500))};"undefined"!=typeof document&&document.addEventListener("keydown",X),_.addEventListener("error",X),_.addEventListener("ended",X);const{version:z}=n;let j;const G="1.0";"undefined"!=typeof document&&document.addEventListener("keydown",(e=>{d.log(`Got ${e.key} key`)}));const B={getToken:async function(){return j?Promise.resolve(j):(d.log("getToken wait for promise updateSession event"),new Promise((e=>{document.addEventListener("updateSession",(t=>{j=t.detail?.updateObj,d.log(`onUpdateSessionEvent: token= ${j}`),e(j)}),{once:!0})})))},forceTokenUpdate:function(){if(j=null,window.cefQuery){const e=r(),t=d.withFields({FCID:e});t.log("forceTokenUpdate: sending updateSessionRequest");const i={type:"updateSessionRequest",updateKey:"authorization",parentPath:"settings.webUI.backendHeaders.Authorization",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("updateSessionRequest successfully sent")},onFailure:(e,i)=>{t.error(`updateSessionRequest failed: ${e} ${i}`)}})}else d.error("forceTokenUpdate: window.cefQuery is undefined")},getClientAssertion:de},V=Object.freeze({UNKNOWN:"unknown",INITIAL_CONNECTION:"initial_connection",UI_RELEASE:"ui_release",UI_TERMINATION:"ui_termination",WEBRTC_ERROR:"webrtc_error",UI_WATCHDOG:"ui_watchdog"});let W=V.UNKNOWN,H={};async function K(){if(d.log(`init ${z}`),window.diagnostics||d.error("[ init ] window.diagnostics is undefined"),window.cefQuery){await new Promise(((e,t)=>{window.cefQuery({request:"apiVersion "+G,persistent:!1,onSuccess:()=>{d.log("api version compatability check succeeded"),e()},onFailure:(e,i)=>{d.error("api version compatability check failed: "+i),t(i)}})}));const e=await new Promise((e=>{window.cefQuery({request:"sessionInfo",persistent:!1,onSuccess:t=>{d.log("sessionInfo request successfully returned "+t),e(t)},onFailure:(e,t)=>{d.error(`sessionInfo request failed: ${e} ${t}`)}})}));c.setSessionInfoStr(e);const t=JSON.parse(e);j=t?.settings?.webUI?.backendHeaders?.Authorization,d.log(`authToken: token = ${j}`),document.addEventListener("updateSession",(e=>{j=e.detail?.updateObj,d.log(`onUpdateSessionEvent: token = ${j}`)})),W=await new Promise((e=>{const t=r(),i=d.withFields({FCID:t}),n={type:"connectReason",fcid:t},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:t=>{i.log(`connectReason request successfully returned '${t}'`),e(t)},onFailure:(t,n)=>{i.error(`connectReason request failed: ${t} ${n}`),e(V.UNKNOWN)}})}));const i=await new Promise((e=>{const t=r(),i=d.withFields({FCID:t}),n={type:"triggerEvent",fcid:t},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:t=>{i.log(`triggerEvent request successfully returned '${t}'`),e(t)},onFailure:(t,n)=>{i.error(`triggerEvent request failed: ${t} ${n}`),e("")}})}));H={};let n={};if(i)try{n=JSON.parse(i),H.type=n.type,"keyPressEvent"===H.type?H.data={keyValue:n.keyValue}:"alarmFiredEvent"===H.type?H.data={alarmName:n.alarmName,payload:n.payload}:"userAlertEvent"===H.type?H.data={eventCode:n.eventCode,message:n.message}:"externalEvent"===H.type?H.data={eventName:n.eventName,payload:n.payload}:"videoPlaybackEvent"===H.type?H.data={eventCode:n.eventCode,errorCode:n.errorCode}:d.warn("unknown trigger event type",H.type)}catch(e){d.error(`failed to parse trigger event string ${i}: ${e.message}`)}await _._init(t?.settings?.["ui-streamer"],n),await N._init();const o=t?.settings?.["ui-streamer"]?.devSequence;o&&(p({lifecycle:N,remotePlayer:_}),h(!0))}else j=ee().sessionInfo?.settings?.webUI?.backendHeaders?.Authorization,d.log(`authToken dummy: token = ${j}`);window.auth=B,Object.defineProperty(window,"senzaAuth",{value:B,writable:!1,configurable:!1}),window.close=()=>{d.warn("window.close is disabled on Senza platform. Use lifecycle.exitApplication() instead.")}}function Z(){return W}function Y(){return H}function ee(){if("undefined"==typeof window||!window.diagnostics)return"undefined"==typeof window||window.diagnostics||d.error("[ getPlatformInfo ] window.diagnostics is undefined"),{version:"X.X.XX-X",pod:"ui-streamer-X.X.XX-X-QWERT-ASDFG-XXX-XXXXXX-XXXXX",podIP:"0.0.0.0",sessionInfo:{userAgent:"SynamediaSenza/XX.YY.ZZ",connectionId:"dummy",deviceId:"123456789",community:"LocalDev",tenant:"XXXXXX",tenantId:"XXXXXX",manifest:{transcontainer:"X.X.XX-X"},settings:{webUI:{backendHeaders:{Authorization:"Bearer dummytoken"}}},homeSessionInfo:{tenantId:"XXXXXX",community:"LocalDev"}}};try{const e=window.diagnostics()||{};return e.sessionInfo=c.sessionInfoObj,e}catch(e){d.error("Could not get platform info",e.stack)}}function te(e){if(window.cefQuery){const t={message:JSON.stringify({type:"setTimeZone",timezone:e}),waitForResponse:!1,target:"UI-Streamer"};window.cefQuery({request:JSON.stringify(t),persistent:!1,onSuccess:()=>{d.log("timezome is successfully set to",e)},onFailure:(t,i)=>{d.error(`error occurred setting timezone to ${e}: ${t} ${i}`)}})}}function ie(){return!("undefined"==typeof window||!window.cefQuery)}function ne(){window.cefQuery?window.cefQuery({request:"uiReady",persistent:!1,onSuccess:()=>{d.log("uiReady request successfully sent")},onFailure:(e,t)=>{d.error(`uiReady request failed: ${e} ${t}`)}}):d.error("uiReady: window.cefQuery is undefined")}function oe(){const e=c.sessionInfoObj;return ie()?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp}:(d.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0"})}const se={remoteBrowserIp:window.diagnostics?window.diagnostics().podIP:"127.0.0.1",sdkVersion:z};function re(e,t,i,n){if(200===e&&(t=window.btoa(String.fromCharCode.apply(null,new Uint8Array(t)))),window.cefQuery){const o={type:"updateLicense",sessionId:n,fcid:i};o[200===e?"response":"error"]=t;const s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{d.log("updateLicense request successfully sent")},onFailure:(e,t)=>{d.error(`updateLicense request failed: ${e} ${t}`)}})}}class ae extends Error{constructor(e,t){super(t),this.code=e}}function de(){if(window.cefQuery)return d.log("getClientAssertion is called"),new Promise(((e,t)=>{window.cefQuery({request:"client_assertion",persistent:!1,onSuccess:i=>{try{const t=JSON.parse(i);d.log(`client_assertion request successfully returned ${i}`),e(t)}catch(e){d.error(`Failed to parse client assertion ${i}`),t(new ae(0,"Failed to parse client assertion"))}},onFailure:(e,i)=>{d.log(`client_assertion request failed: ${e} ${i}`),t(new ae(e,i))}})}));d.warn("getClientAssertion is not supported if NOT running e2e")}return"undefined"!=typeof window&&(window.hs=i),t})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.senza=t():e.senza=t()}(this,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ClientAssertionError:()=>ae,ConnectReason:()=>V,alarmManager:()=>U,auth:()=>B,deviceManager:()=>A,envInfo:()=>se,getClientAssertion:()=>de,getConnectReason:()=>Z,getDeviceInfo:()=>oe,getPlatformInfo:()=>ee,getTriggerEvent:()=>Y,init:()=>K,initSequence:()=>p,isRunningE2E:()=>ie,lifecycle:()=>N,messageManager:()=>J,platformManager:()=>L,remotePlayer:()=>_,setTimezone:()=>te,showSequence:()=>h,uiReady:()=>ne,writeLicenseResponse:()=>re});var i={};e.r(i),e.d(i,{ClientAssertionError:()=>ae,ConnectReason:()=>V,alarmManager:()=>U,auth:()=>B,deviceManager:()=>A,envInfo:()=>se,getClientAssertion:()=>de,getConnectReason:()=>Z,getDeviceInfo:()=>oe,getPlatformInfo:()=>ee,getTriggerEvent:()=>Y,init:()=>K,initSequence:()=>p,isRunningE2E:()=>ie,lifecycle:()=>N,messageManager:()=>J,platformManager:()=>L,remotePlayer:()=>_,setTimezone:()=>te,showSequence:()=>h,uiReady:()=>ne,writeLicenseResponse:()=>re});const n={version:"4.1.4"},{version:o}=n,s=5;function r(){return Math.round(1e5*Math.random())+"-"+ee().sessionInfo?.connectionId}class a{constructor(e){this.logFields=e}debug(...e){console.debug(this.formatLogString(e))}log(...e){console.log(this.formatLogString(e))}info(...e){console.info(this.formatLogString(e))}warn(...e){console.warn(this.formatLogString(e))}error(...e){console.error(this.formatLogString(e))}withFields(e){return new a({...this.logFields,...e})}formatLogString(e){let t="[hs-sdk] "+e.join(" ");return this.logFields&&(t+=" [log-fields] "+JSON.stringify(this.logFields)),t}}const d=new a({sdkVersion:o,url:window?.location?.href??""});async function l(e){if(window.cefQuery)return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),a={type:"restRequest",name:e,method:"GET",fcid:n},l={target:"TC",waitForResponse:!0,message:JSON.stringify(a)};let c=0;const u=window.cefQuery({request:JSON.stringify(l),persistent:!1,onSuccess:i=>{c&&clearTimeout(c),o.info(`Got restResponse for ${e}: ${i}`),t(i)},onFailure:(t,n)=>{c&&clearTimeout(c);const s=`failed to get restResponse for ${e}: ${t} ${n}`;o.error(s),i(s)}});c=setTimeout((()=>{window.cefQueryCancel(u);const t=`failed to get restResponse for ${e}: reached timeout of ${1e3*s} ms`;o.error(t),i(t)}),1e3*s)}));d.error("getRestResponse: window.cefQuery is undefined")}const c=new class{sessionInfoStr="{}";get sessionInfoObj(){try{return JSON.parse(this.sessionInfoStr)}catch(e){return void d.warn("Failed to return sdk")}}setSessionInfoStr(e){try{JSON.parse(e)}catch(e){throw Error("Failed to parse sessionInfo")}this.sessionInfoStr=e}},u={BACK:27,HOME:36,LEFT:37,RIGHT:39,UP:38,DOWN:40,ENTER:13},f={root:{top:"5vh",left:"82vw",height:"90vh",fontSize:"16px",width:"16vw",position:"fixed",zIndex:1e4,overflow:"hidden",visibility:"hidden"},item:{backgroundColor:"white",color:"black",fontSize:"12px",display:"flex",padding:"6px",border:"1px solid black",borderTop:"none"},item_key:{borderTopLeftRadius:"6px",borderTopRightRadius:"6px",marginTop:"20px",borderBottom:"3px solid black"},component:{fontWeight:"bold",width:"5vw"},component_key:{fontWeight:"normal",color:"darkgray"},id:{textAlign:"left",fontWeight:"normal",flex:1},id_key:{fontWeight:"bold"},time:{fontVariantNumeric:"tabular-nums",width:"3vw"},time_key:{fontWeight:"bold"}};let g=performance.now();const y=(e,t)=>"key"===t?new Date(e).toLocaleTimeString("en-US",{hour12:!1}):`${(e/1e3).toFixed(2)}s`,w=(e,t,i)=>{Object.entries(e).forEach((([e,n])=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((o=>{if(i&&i(o))return;const s=n[o];"function"==typeof s&&(n[o]=function(...i){return t(e,o,...i),s.apply(this,i)})}))}))},m=(e,t)=>{e.innerHTML="",t.forEach(((i,n)=>{const o=document.createElement("div");Object.assign(o.style,{...f.item,...f[`item_${i?.component}`]}),["component","id","time"].forEach((e=>{if(i[e]){const t=document.createElement("div");Object.assign(t.style,f[e],f[`${e}_${i.component}`]),t.textContent="time"===e?y(i.time,i.component):i[e],o.appendChild(t)}})),e.appendChild(o),n===t.length-1&&o.scrollIntoView({behavior:"smooth"})}))},p=e=>{if(!e)return void d.error("No components to sequence");let t=document.getElementById("sequence-container");if(t)return;t=(()=>{const e=document.createElement("div");return e.id="sequence-container",Object.assign(e.style,f.root),document.body.appendChild(e),e})();const i=new Proxy([],{set:(e,n,o)=>(e[n]=o,"length"!==n&&m(t,i),!0)});window.printSequence=()=>(e=>{const t=e.map((e=>{const t=e.separator?"\n":"",i=e?.time?` ${y(e.time,e?.component)}`:"";if(e.args){const n=e.args.map((e=>"object"==typeof e?"object":e)).join(", ");return`${t}${e.component}.${e.id}(${n})${i}`}return`\n${e.component}: ${e.id}${i}`}));d.log("sequence:\n",t.join("\n"))})(i),((e,t)=>{t.push({component:"key",id:"BOOT",time:Date.now()}),w(e,((e,i,...n)=>{t.push({component:e,id:i,args:n,time:performance.now()-g})}),(e=>e.startsWith("_")||e.startsWith("get"))),(e=>{window.addEventListener("keydown",(t=>{var i;e.push({component:"key",id:(i=t.keyCode,Object.entries(u).find((([,e])=>e===i))?.[0]||String(i)),time:Date.now()}),g=performance.now()}))})(t),d.log("Sequence initialized.")})(e,i),m(t,i)},h=(e=!0)=>{const t=document.getElementById("sequence-container");t?t.style.visibility=e?"visible":"hidden":d.error("Sequence not initialized")},T=e=>JSON.parse(JSON.stringify(e));class v extends Error{constructor(e,t){super(t),this.code=e,this.msg=t}}function S(){const e=window.getPlaybackInfo?window.getPlaybackInfo():JSON.stringify({playbackPosition:0,assetDuration:0});let t;try{t=JSON.parse(e)}catch(i){d.error(`Playback Info parse failed. playbackStr = ${e}`),t={playbackPosition:0,assetDuration:0}}return t}function b(e){try{const t=JSON.stringify(e);window.setPlaybackInfo&&window.setPlaybackInfo(t)}catch(e){d.error("Playback Info to json string failed")}}class I extends EventTarget{constructor(){super(),this._config={preferredAudioLanguage:"",preferredSubtitlesLanguage:""},this._selectedAudioTrack="",this._selectedSubtitlesTrack="",this._availableAudioTracks=[],this._availableTextTracks=[],this._textTrackVisibility=!1,this._ptsSessionId=0,this._videoElement=void 0,this._isInitialized=!1,"undefined"!=typeof document&&document.addEventListener("hs/playbackInfoEvent",(()=>{d.info("Got hs/playbackInfoEvent"),this.dispatchEvent(new Event("timeupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/playback",(e=>{d.info("Got hs/playback event with detail",JSON.stringify(e?.detail)),this._availabilityStartTime=e?.detail?.availabilityStartTime,this._updateTracks(e?.detail),this.dispatchEvent(new Event("tracksupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/EOS",(()=>{d.info("Got hs/EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/ui_inactive",(()=>{d.info("Got hs/ui_inactive event")})),"undefined"!=typeof document&&document.addEventListener("hs/senzaPlayerSetRate",(e=>{this._videoElement&&(this._videoElement.playbackRate=e.detail.rate)})),"undefined"!=typeof document&&document.addEventListener("hs/senzaPlayerSetTime",(e=>{this._videoElement?(d.info(`Adding ${e.detail} seconds to current time ${this._videoElement.currentTime}`),this._videoElement.playbackRate=1,this._videoElement.currentTime+=e.detail):d.warn("video element is NOT set")})),"undefined"!=typeof document&&document.addEventListener("hs/ERR",(e=>{d.info("Got hs/ERR event"),delete e?.detail?.type,delete e?.detail?.eventCode,this.dispatchEvent(new CustomEvent("error",e))})),"undefined"!=typeof document&&document.addEventListener("hs/getLicense",(e=>{d.info("Got hs/getLicense event");const t=e?.detail,i=Uint8Array.from(t.request,(e=>e.charCodeAt(0))),n=new ArrayBuffer(i.byteLength);new Uint8Array(n).set(i),this.licenseRequest=n;const o=t.fcid,s=t.sessionId,r=new CustomEvent("license-request",{detail:{licenseRequest:n}});r.writeLicenseResponse=(e,t)=>{re(e,t,o,s)},this.dispatchEvent(r)}))}LoadMode=Object.freeze({NOT_LOADED:"notLoaded",LOADING:"loading",LOADED:"loaded",UNLOADING:"unloading"});async _init(e,t){let i={isLoaded:!1,playbackUrl:""};if(window.cefQuery){const e=r(),t=d.withFields({FCID:e}),n={type:"playerState",fcid:e},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};try{const e=await new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:i=>{t.log("playerState request successfully returned",i),e(i)},onFailure:(e,n)=>{t.error(`playerState request failed: ${e} ${n}`),i()}})}));i=JSON.parse(e)}catch{t.error("either failed to get or failed to parse player state")}}this._loadMode=i?.isLoaded?this.LoadMode.LOADED:this.LoadMode.NOT_LOADED,this._loadedUrl=i?.playbackUrl||"",this._isInitialized=!0,this._setPlayableUriTimeout=e?.setPlayableUriTimeout??5e3,this._unloadTimeout=e?.unloadTimeout??5e3,this._requestVideoFrameInfo=e?.requestVideoFrameInfo??!0;let n={};try{n=JSON.parse(t?.playbackMetadata||"{}")}catch(e){d.error(`failed to parse playbackMetadata: ${e.message}`)}this._availabilityStartTime=n.availabilityStartTime,this._updateTracks(n)}_updateTracks(e){if(this._availableAudioTracks=e?.availableAudioTracks||this._availableAudioTracks,this._availableTextTracks=e?.availableSubtitlesTracks||this._availableTextTracks,"VOD"===e?.assetType&&(this._availableTextTracks=function(e){if(!e||e.length<1)return e;e.sort(((e,t)=>e.lang.toLowerCase()>t.lang.toLowerCase()?1:-1));const t=[{lang:"af",id:"*:af"},{lang:"ar",id:"*:ar"},{lang:"az",id:"*:az"},{lang:"bg",id:"*:bg"},{lang:"bs",id:"*:bs"},{lang:"ca",id:"*:ca"},{lang:"cs",id:"*:cs"},{lang:"cy",id:"*:cy"},{lang:"da",id:"*:da"},{lang:"de",id:"*:de"},{lang:"el",id:"*:el"},{lang:"en",id:"*:en"},{lang:"es",id:"*:es"},{lang:"es-MX",id:"*:es-MX"},{lang:"et",id:"*:et"},{lang:"fi",id:"*:fi"},{lang:"fr",id:"*:fr"},{lang:"fr-CA",id:"*:fr-CA"},{lang:"ga",id:"*:ga"},{lang:"ha",id:"*:ha"},{lang:"he",id:"*:he"},{lang:"hr",id:"*:hr"},{lang:"ht",id:"*:ht"},{lang:"hu",id:"*:hu"},{lang:"id",id:"*:id"},{lang:"is",id:"*:is"},{lang:"it",id:"*:it"},{lang:"kk",id:"*:kk"},{lang:"lt",id:"*:lt"},{lang:"lv",id:"*:lv"},{lang:"mk",id:"*:mk"},{lang:"mn",id:"*:mn"},{lang:"ms",id:"*:ms"},{lang:"mt",id:"*:mt"},{lang:"nl",id:"*:nl"},{lang:"no",id:"*:no"},{lang:"pl",id:"*:pl"},{lang:"pt",id:"*:pt"},{lang:"pt-PT",id:"*:pt-PT"},{lang:"ro",id:"*:ro"},{lang:"ru",id:"*:ru"},{lang:"sk",id:"*:sk"},{lang:"sl",id:"*:sl"},{lang:"so",id:"*:so"},{lang:"sq",id:"*:sq"},{lang:"sr",id:"*:sr"},{lang:"sv",id:"*:sv"},{lang:"sw",id:"*:sw"},{lang:"tl",id:"*:tl"},{lang:"tr",id:"*:tr"},{lang:"uk",id:"*:uk"},{lang:"uz",id:"*:uz"},{lang:"vi",id:"*:vi"},{lang:"zh",id:"*:zh"}],i=[...e];for(const n of t)e.find((e=>e.lang===n.lang))||(n.autoTranslate=!0,i.push(n));return i}(this._availableTextTracks)),this._availableAudioTracks){const e=this._availableAudioTracks.find((e=>!0===e.selected));this._selectedAudioTrack=e?.id||""}if(this._availableTextTracks){const e=this._availableTextTracks.find((e=>!0===e.selected));e?(this._selectedSubtitlesTrack=e.id,this._textTrackVisibility=!0):(this._selectedSubtitlesTrack="",this._textTrackVisibility=!1)}}getConfiguration(){return T(this._config)}configure(e){Object.entries(e).forEach((([e,t])=>{void 0!==this._config[e]&&(this._config[e]=t)}))}_changeLoadMode(e){this._loadMode!==e&&(this._loadMode=e,this.dispatchEvent(new Event("onloadmodechange")))}_handle_video_frame_info(e){if(!this._requestVideoFrameInfo||void 0===e)return void(this._videoElement=void 0);const t=r(),i=d.withFields({fcid:t}),n=(e,i)=>{const o={type:"currentFramePTS",fcid:t,currentFramePTS:i.mediaTime.toString(),ptsSessionId:this._ptsSessionId},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1}),this._videoElement?.requestVideoFrameCallback(n)};i.log("handle_video_frame_pts: requesting video frame info"),void 0!==this._videoElement&&this._videoElement===e||(e.requestVideoFrameCallback(n),e.addEventListener("loadstart",(e=>{this._ptsSessionId++,d.info("videoElement, loadstart ptsSessionId=",this._ptsSessionId," event=",e)}))),this._videoElement=e}_reset(){this._availableAudioTracks=[],this._availableTextTracks=[],this._selectedAudioTrack="",this._selectedSubtitlesTrack="",this._availabilityStartTime=void 0}registerVideoElement(e){this.attach(e)}attach(e){this._handle_video_frame_info(e)}async load(e,t){if(!this._isInitialized)throw new v(6500,"Cannot call load() if remote player is not initialized");if(e&&window.cefQuery){const i=await N.getState();if("background"===i||"inTransitionToBackground"===i)throw new v(6002,"Cannot call load() while in state 'background' or 'inTransitionToBackground'");if(this._loadMode===this.LoadMode.LOADING)throw new v(6501,"Cannot call load() while previous load is still in progress");this._reset();const n=this._loadMode;return this._changeLoadMode(this.LoadMode.LOADING),new Promise(((i,o)=>{b({playbackPosition:0});const s=r(),a=t??0,l=d.withFields({FCID:s,loadUrl:e,playbackPosition:a});l.log("remotePlayer load: sending setPlayableUri request");const c={type:"setPlayableUri",url:e,timeout:this._setPlayableUriTimeout,autoPlay:!1,playbackPosition:a,fcid:s},u={target:"TC",waitForResponse:!0,message:JSON.stringify(c)};let f=0;const g=Date.now(),y=window.cefQuery({request:JSON.stringify(u),persistent:!1,onSuccess:()=>{const n=Date.now()-g;l.withFields({duration:n}).log(`setPlayableUri completed successfully after ${n} ms`),t>0&&b({playbackPosition:t}),f&&(clearTimeout(f),f=0),this._changeLoadMode(this.LoadMode.LOADED),this._loadedUrl=e,this.dispatchEvent(new Event("canplay")),i()},onFailure:(e,t)=>{const i=Date.now()-g;l.withFields({duration:i}).log(`setPlayableUri failed after ${i} ms. Error code: ${e}, error message: ${t}`),f&&(clearTimeout(f),f=0),99===e?this._changeLoadMode(n):(this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=""),o(new v(e,t))}});l.log(`window.cefQuery for setPlayableUri returned query id ${y}`);const w=this._setPlayableUriTimeout+1e3;f=setTimeout((()=>{l.log(`setPlayableUri reached timeout of ${w} ms, canceling query id ${y}`),window.cefQueryCancel(y),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl="",o(new v(6e3,`load reached timeout of ${w} ms`))}),w,y)}))}d.error("remotePlayer load: either window.cefQuery or url is undefined")}async unload(){if(!this._isInitialized)throw new v(6500,"Cannot call unload() if remote player is not initialized");if(window.cefQuery){if(this._loadMode===this.LoadMode.LOADING)throw new v(6502,"Cannot call unload() while load is still in progress");const e=this._loadMode;return this._changeLoadMode(this.LoadMode.UNLOADING),new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n});o.log("remotePlayer unload");const s={type:"remotePlayer.unload",class:"remotePlayer",action:"unload",fcid:n},a={target:"TC",waitForResponse:!0,message:JSON.stringify(s)};let l=0;const c=Date.now(),u=window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{const e=Date.now()-c;o.withFields({duration:e}).log(`unload completed successfully after ${e} ms`),l&&(clearTimeout(l),l=0),this._reset(),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=void 0,t()},onFailure:(t,n)=>{const s=Date.now()-c;o.withFields({duration:s}).log(`unload failed after ${s} ms. Error code: ${t}, error message: ${n}`),l&&(clearTimeout(l),l=0),this._changeLoadMode(e),i(new v(t,n))}});o.log(`window.cefQuery for unload returned query id ${u}`);const f=this._unloadTimeout+1e3;l=setTimeout((()=>{o.log(`unload reached timeout of ${f} ms, canceling query id ${u}`),window.cefQueryCancel(u),this._changeLoadMode(e),i(new v(6e3,`unload reached timeout of ${f} ms`))}),f,u)}))}d.error("remotePlayer unload: window.cefQuery is undefined")}play(){if(!this._isInitialized)throw new v(6500,"Cannot call play() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new v(6001,"Cannot call play() if player is not loaded");const e=r(),t=d.withFields({FCID:e});t.log("remotePlayer play: sending play action");const i=this._selectedAudioTrack||this._config.preferredAudioLanguage||"";let n="";this._textTrackVisibility&&(n=this._selectedSubtitlesTrack||this._config.preferredSubtitlesLanguage||"");const o={type:"remotePlayer.play",class:"remotePlayer",action:"play",fcid:e,audioLanguage:i,subtitlesLanguage:n,playbackPosition:this.currentTime},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};return new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{t.log("remotePlayer play request successfully sent"),e()},onFailure:(e,n)=>{t.error(`remotePlayer play request failed: ${e} ${n}`),i(new v(e,n))}})}))}return d.error("remotePlayer play: window.cefQuery is undefined"),Promise.resolve(void 0)}pause(){if(!this._isInitialized)throw new v(6500,"Cannot call pause() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new v(6001,"Cannot call pause() if player is not loaded");const e=r(),t=d.withFields({FCID:e});t.log("remotePlayer pause: sending pause request");const i={type:"remotePlayer.pause",class:"remotePlayer",action:"pause",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};return new Promise(((e,i)=>{window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("remotePlayer pause request successfully sent"),e()},onFailure:(e,n)=>{t.error(`remotePlayer pause request failed: ${e} ${n}`),i(new v(e,n))}})}))}return d.error("remotePlayer pause: window.cefQuery is undefined"),Promise.resolve(void 0)}getAssetUri(){if(!this._isInitialized)throw new v(6500,"Cannot call getAssetUri() if remote player is not initialized");return this._loadedUrl}getLoadMode(){if(!this._isInitialized)throw new v(6500,"Cannot call getLoadMode() if remote player is not initialized");return this._loadMode}getTextTracks(){return T(this._availableTextTracks)}getAudioTracks(){return T(this._availableAudioTracks)}selectAudioTrack(e){for(const t of this.getAudioTracks())if(t.id===e)return void(this._selectedAudioTrack=e);d.warn(`Invalid audioTrackId ${e}`)}selectTextTrack(e){for(const t of this.getTextTracks())if(t.id===e)return void(this._selectedSubtitlesTrack=e);d.warn(`Invalid textTrackId ${e}`)}setTextTrackVisibility(e){const t=this._textTrackVisibility;if("boolean"!=typeof e)throw new TypeError("visible parameter must be a boolean");const i=e;i!==t&&(this._textTrackVisibility=i,i||(this._selectedSubtitlesTrack=""))}get currentTime(){return S()?.playbackPosition}set currentTime(e){if(b({playbackPosition:e}),window.cefQuery){const t=r(),i=d.withFields({FCID:t});i.log("setting remotePlayer currentTime");const n={type:"remotePlayer.seek",class:"remotePlayer",action:"seek",playbackPosition:e,fcid:t},o={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{i.log("remotePlayer seek request successfully sent")},onFailure:(e,t)=>{i.error(`remotePlayer seek request failed: ${e} ${t}`)}})}else d.error("setting remotePlayer currentTime: window.cefQuery is undefined")}get duration(){return S()?.assetDuration}get textTrackVisibility(){return this._textTrackVisibility}getPresentationStartTimeAsDate(){return void 0===this._availabilityStartTime?null:new Date(1e3*this._availabilityStartTime)}}const _=new I;"undefined"!=typeof window&&Object.defineProperty(window,"senzaRemotePlayer",{value:_,writable:!1,configurable:!1});class O extends EventTarget{UiState=Object.freeze({UNKNOWN:"unknown",FOREGROUND:"foreground",IN_TRANSITION_TO_FOREGROUND:"inTransitionToForeground",BACKGROUND:"background",IN_TRANSITION_TO_BACKGROUND:"inTransitionToBackground"});constructor(){super(),this._isInitialized=!1,this._inTransition=!1,"undefined"!=typeof document&&document.addEventListener("hs/uistatechange",(e=>{d.log("Got hs/uistatechange",e.detail);const t=new Event("onstatechange");t.state=e.detail,this._state=t.state,this.dispatchEvent(t)})),"undefined"!=typeof document&&document.addEventListener("hs/systemInactivity",(e=>{d.log("Got hs/systemInactivity",e.detail);const t=new Event("userinactivity");t.timeout=e.detail.timeout,this.dispatchEvent(t)}))}async _init(){window.cefQuery&&(this._state=await new Promise((e=>{window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{d.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(t,i)=>{d.error(`uiState request failed: ${t} ${i}`),e(this.UiState.UNKNOWN)}})})),this._isInitialized=!0)}get state(){return this._isInitialized||(this._state=this.UiState.UNKNOWN),this._state}getState(){if(window.cefQuery)return new Promise(((e,t)=>{window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{d.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(e,i)=>{d.error(`uiState request failed: ${e} ${i}`),t(i)}})}));d.warn("lifecycle getState is not supported if NOT running e2e")}moveToForeground(){return window.cefQuery?this._inTransition||this._state===this.UiState.FOREGROUND||this._state===this.UiState.IN_TRANSITION_TO_FOREGROUND?(d.warn(`lifecycle moveToForeground: No need to transition to foreground, state: ${this._state} transition: ${this._inTransition}`),Promise.resolve(!1)):(this._inTransition=!0,new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});n.log("lifecycle moveToForeground: sending uiActiveRequest action"),window.cefQuery({request:JSON.stringify({action:"uiActiveRequest",fcid:i}),persistent:!1,onSuccess:()=>{n.log("uiActiveRequest successfully sent"),this._inTransition=!1,e(!0)},onFailure:(e,i)=>{this._inTransition=!1,n.error(`uiActiveRequest failed: ${e} ${i}`),t(`uiActiveRequest failed: ${e} ${i}`)}})}))):(d.warn("lifecycle moveToForeground: window.cefQuery is undefined"),Promise.resolve(!1))}moveToBackground(){return window.cefQuery?this._inTransition||this._state===this.UiState.BACKGROUND||this._state===this.UiState.IN_TRANSITION_TO_BACKGROUND?(d.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`),Promise.resolve(!1)):(this._inTransition=!0,new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});n.log("lifecycle moveToBackground: sending play action");const o=_.getConfiguration(),s=_._selectedAudioTrack||o.preferredAudioLanguage||"",a=_._selectedSubtitlesTrack||o.preferredSubtitlesLanguage||"";window.cefQuery({request:JSON.stringify({action:"play",fcid:i,audioLanguage:s,subtitlesLanguage:a}),persistent:!1,onSuccess:()=>{n.log("[ moveToBackground ] play successfully sent"),this._inTransition=!1,e(!0)},onFailure:(e,i)=>{this._inTransition=!1,n.error(`[ moveToBackground ] play failed: ${e} ${i}`),t(`[ moveToBackground ] play failed: ${e} ${i}`)}})}))):(d.warn("lifecycle moveToBackground: window.cefQuery is undefined"),Promise.resolve(!1))}moveToUiStandby(){return window.cefQuery?new Promise(((e,t)=>{const i=r(),n={target:"TC",waitForResponse:!1,message:JSON.stringify({type:"uiStandbyRequest",fcid:i})},o=d.withFields({FCID:i});o.log("lifecycle moveToUiStandby: sending uiStandbyRequest"),window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{o.log("[ moveToUiStandby ] moveToUiStandby successfully sent"),e(!0)},onFailure:(e,i)=>{o.error(`[ moveToUiStandby ] moveToUiStandby failed: ${e} ${i}`),t(`moveToUiStandby failed: ${e} ${i}`)}})})):(d.warn("moveToUiStandby was called in local dev"),Promise.resolve(!0))}switchTenant(e){if(e&&e.length>0){if(e===ee().sessionInfo?.tenantId)return d.warn(`SwitchTenant requires a different tenantId than the current one. CurrentTenantId=${ee().sessionInfo?.tenantId} and tenantId=${e}`),Promise.reject("SwitchTenant requires a different tenantId than the current one");const t=ee().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId,i=ee().sessionInfo?.homeSessionInfo?.tenantId;return d.log(`SwitchTenant for ${e}`),window.cefQuery?new Promise(((n,o)=>{const s=r(),a=d.withFields({FCID:s}),l={type:"reconnect",fcid:s,session:btoa(JSON.stringify({tenantId:e,...ee().sessionInfo?.tenantId===t&&e!==i&&{returnToTenantId:t}}))},c={target:"TC",waitForResponse:!1,message:JSON.stringify(l)};window.cefQuery({request:JSON.stringify(c),persistent:!1,onSuccess:()=>{a.log("SwitchTenant request successfully sent"),n(!0)},onFailure:(e,t)=>{a.error(`SwitchTenant failed: ${e} ${t}`),o(`SwitchTenant failed: ${e} ${t}`)}})})):(d.warn("SwitchTenant is not supported if NOT running e2e"),Promise.reject("SwitchTenant is not supported if NOT running e2e"))}return d.warn("SwitchTenant requires a valid tenantId string parameter"),Promise.reject("SwitchTenant requires a valid tenantId string parameter")}exitApplication(){return window.cefQuery?new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i});let o,s;const a=c.sessionInfoObj;a?.homeSessionInfo&&(a?.returnToTenantId||a?.homeSessionInfo.tenantId!==a?.tenantId)?(s={type:"reconnect",splashUrl:a?.homeSessionInfo.tenantInfo.tenantSettings.applicationSwitchSplashUrl,fcid:i},a?.returnToTenantId&&(a?.returnToTenantId===a?.homeSessionInfo.tenantInfo.contentHubTenantId&&(s.splashUrl=a?.homeSessionInfo.contentHubTenantInfo.tenantSettings.applicationSwitchSplashUrl),s.session=btoa(JSON.stringify({tenantId:a?.returnToTenantId}))),o={target:"TC",waitForResponse:!1,message:JSON.stringify(s)}):(s={type:"launchHomeApplication",fcid:i},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)}),window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{n.log(`exitApplication request with type: '${s.type}' successfully sent`),e(!0)},onFailure:(e,i)=>{n.error(`exitApplication request with type: '${s.type}' failed: ${e} ${i}`),t(`exitApplication request with type: '${s.type}' failed: ${e} ${i}`)}})})):(d.warn("exitApplication is not supported if NOT running e2e"),Promise.reject("exitApplication is not supported if NOT running e2e"))}}const N=new O,k={};let E,$,F=0;async function P(){if(!E)try{const e=await l("wifi-ap-data");E=JSON.parse(e)}catch(e){d.error(e)}}async function q(){if(F+5e3<Date.now())try{const e=await l("wifi-status");$=JSON.parse(e),F=Date.now()}catch(e){d.error(e)}}class C extends EventTarget{constructor(){super(),k.level=0,k.quality=0,k.ssid="unknown",k.bssid="unknown","undefined"!=typeof document&&document.addEventListener("wifiSignalReport",(e=>{d.log("Got wifiSignalReport",JSON.stringify(e.detail)),k.level=e.detail.level,k.quality=e.detail.quality,k.ssid=e.detail.ssid,k.bssid=e.detail.bssid,this.dispatchEvent(new Event("wifiInfoUpdated"))}))}get deviceInfo(){const e=c.sessionInfoObj;return ie()&&e?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp,countryCode:e.general?.location?.["x-country-code"]}:(d.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0",countryCode:"XX"})}get wifiInfo(){return k}reboot(){return new Promise(((e,t)=>{if(window.cefQuery){const i=r(),n=d.withFields({FCID:i}),o={type:"reboot",fcid:i},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{n.log("reboot request successfully sent"),e(!0)},onFailure:(e,i)=>{n.error(`reboot failed: ${e} ${i}`),t(`reboot failed: ${e} ${i}`)}})}else d.warn("reboot is not supported if NOT running e2e"),t("reboot is not supported if NOT running e2e")}))}clearWifi(){return new Promise(((e,t)=>{const i=r(),n=d.withFields({FCID:i}),o={type:"resetWifi",fcid:i},s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{n.log("clearWifi successfully sent"),e(!0)},onFailure:(e,i)=>{n.error(`clearWifi failed: ${e} ${i}`),t(`clearWifi failed: ${e} ${i}`)}})}))}sendDataToDevice(e){if("string"!=typeof e)throw new Error("data must be of type 'string'");return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),s={type:"externalCommand",data:{command:"forward",payload:e},fcid:n},a={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{o.log("externalCommand successfully sent"),t()},onFailure:(e,t)=>{o.error(`externalCommand failed: ${e} ${t}`),i(`externalCommand failed: ${e} ${t}`)}})}))}async factoryReset(e=!0){if("boolean"!=typeof e)throw new Error("reboot param must be of type 'boolean'");return new Promise(((t,i)=>{const n=r(),o=d.withFields({FCID:n}),s={type:"factoryReset",fcid:n,reboot:e},a={target:"TC",waitForResponse:!0,message:JSON.stringify(s)};let l=0;const c=window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{l&&clearTimeout(l),o.log("factoryReset successfully sent"),t(!0)},onFailure:(e,t)=>{l&&clearTimeout(l),o.error(`factoryReset failed: ${e} ${t}`),i(`factoryReset failed: ${e} ${t}`)}});l=setTimeout((()=>{o.error("factoryReset failed: reached timeout of 5000 ms"),window.cefQueryCancel(c),i("factoryReset failed: reached timeout of 5000 ms")}),5e3)}))}async getWifiInfo(){return await Promise.all([P(),q()]),{...E,...$}}}const A=new C;"undefined"!=typeof window&&Object.defineProperty(window,"senzaDeviceManager",{value:A,writable:!1,configurable:!1});class R extends EventTarget{constructor(){super()}get appConfig(){const e=c.sessionInfoObj,t=e.homeSessionInfo?.appConfig||{};return d.info("PlatformManager get appConfig: \n"+JSON.stringify(t,null,2)),t}setTimezone(e){if(window.cefQuery){const t={message:JSON.stringify({type:"setTimeZone",timezone:e}),waitForResponse:!1,target:"UI-Streamer"};window.cefQuery({request:JSON.stringify(t),persistent:!1,onSuccess:()=>{d.log("PlatformManager timezome is successfully set to",e)},onFailure:(t,i)=>{d.error(`PlatformManager error occurred setting timezone to ${e}: ${t} ${i}`)}})}}}const L=new R;class D extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/alarmFiredEvent",(e=>{d.log("Got hs/alarmFiredEvent",JSON.stringify(e.detail)),e.detail?.alarmName&&this.dispatchEvent(new CustomEvent(e.detail.alarmName,{detail:e.detail.payload}))}))}addAlarm(e,t,i=""){if("string"!=typeof i)throw Error("data must be a string");const n=r(),o=d.withFields({alarmName:e,FCID:n});if(o.log(`addAlarm called for ${e} to be fired at ${t}`),window.cefQuery){const s={type:"addAlarm",fcid:n,alarmName:e,alarmTime:t,payload:i},r={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(r),persistent:!1,onSuccess:()=>{o.log("addAlarm request successfully sent")},onFailure:(e,t)=>{o.error(`addAlarm failed: ${e} ${t}`)}})}else o.warn("addAlarm is not supported if NOT running e2e")}deleteAlarm(e){const t=r(),i=d.withFields({alarmName:e,FCID:t});if(i.log(`deleteAlarm called for ${e}`),window.cefQuery){const n={type:"deleteAlarm",fcid:t,alarmName:e},o={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{i.log("deleteAlarm request successfully sent")},onFailure:(e,t)=>{i.error(`deleteAlarm failed: ${e} ${t}`)}})}else i.warn("deleteAlarm is not supported if NOT running e2e")}deleteAllAlarms(){if(window.cefQuery){const e=r(),t=d.withFields({FCID:e}),i={type:"deleteAllAlarms",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("deleteAllAlarms request successfully sent")},onFailure:(e,i)=>{t.error(`deleteAllAlarms failed: ${e} ${i}`)}})}else d.warn("deleteAllAlarms is not supported if NOT running e2e")}getActiveAlarms(){throw Error("NOT IMPLEMENTED")}}const U=new D;"undefined"!=typeof window&&Object.defineProperty(window,"senzaAlarmManager",{value:U,writable:!1,configurable:!1});class Q extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/externalEvent",(e=>{d.log("Got hs/externalEvent",JSON.stringify(e.detail)),this.dispatchEvent(new CustomEvent("message",{detail:{eventName:e.detail.eventName,payload:e.detail.payload,fcid:e.detail.fcid}}))}))}async registerGroups(e){return d.log(`register called for ${e}`),new Promise(((t,i)=>{if(window.cefQuery){const n=r(),o=d.withFields({FCID:n}),s={type:"registerGroupEvent",fcid:n,groups:e},a={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(a),persistent:!1,onSuccess:()=>{o.log("registerGroupEvent request successfully sent"),t(!0)},onFailure:(e,t)=>{o.error(`registerGroupEvent failed: ${e} ${t}`),i(`registerGroupEvent failed: ${e} ${t}`)}})}else d.warn("registerGroupEvent is not supported if NOT running e2e"),i("registerGroupEvent is not supported if NOT running e2e")}))}}const J=new Q;let x,X;"undefined"!=typeof window&&Object.defineProperty(window,"senzaMessageManager",{value:J,writable:!1,configurable:!1}),N.getState()?.then((e=>{X=e})),N.addEventListener("onstatechange",(e=>{X=e.state}));const M=e=>{"background"!==X&&"inTransitionToBackground"!==X||(x&&clearTimeout(x),x=setTimeout((()=>{"background"!==X&&"inTransitionToBackground"!==X||d.log(`${e.type} event received while in '${X}' state and there was no call to lifecycle.moveToForeground() for 500 ms. Make sure to call it if you want to move to foreground.`),x=0}),500))};"undefined"!=typeof document&&document.addEventListener("keydown",M),_.addEventListener("error",M),_.addEventListener("ended",M);const{version:z}=n;let j;const G="1.0";"undefined"!=typeof document&&document.addEventListener("keydown",(e=>{d.log(`Got ${e.key} key`)}));const B={getToken:async function(){return j?Promise.resolve(j):(d.log("getToken wait for promise updateSession event"),new Promise((e=>{document.addEventListener("updateSession",(t=>{j=t.detail?.updateObj,d.log(`onUpdateSessionEvent: token= ${j}`),e(j)}),{once:!0})})))},forceTokenUpdate:function(){if(j=null,window.cefQuery){const e=r(),t=d.withFields({FCID:e});t.log("forceTokenUpdate: sending updateSessionRequest");const i={type:"updateSessionRequest",updateKey:"authorization",parentPath:"settings.webUI.backendHeaders.Authorization",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("updateSessionRequest successfully sent")},onFailure:(e,i)=>{t.error(`updateSessionRequest failed: ${e} ${i}`)}})}else d.error("forceTokenUpdate: window.cefQuery is undefined")},getClientAssertion:de},V=Object.freeze({UNKNOWN:"unknown",INITIAL_CONNECTION:"initial_connection",UI_RELEASE:"ui_release",UI_TERMINATION:"ui_termination",WEBRTC_ERROR:"webrtc_error",UI_WATCHDOG:"ui_watchdog"});let W=V.UNKNOWN,H={};async function K(){if(d.log(`init ${z}`),window.diagnostics||d.error("[ init ] window.diagnostics is undefined"),window.cefQuery){await new Promise(((e,t)=>{window.cefQuery({request:"apiVersion "+G,persistent:!1,onSuccess:()=>{d.log("api version compatability check succeeded"),e()},onFailure:(e,i)=>{d.error("api version compatability check failed: "+i),t(i)}})}));const e=await new Promise((e=>{window.cefQuery({request:"sessionInfo",persistent:!1,onSuccess:t=>{d.log("sessionInfo request successfully returned "+t),e(t)},onFailure:(e,t)=>{d.error(`sessionInfo request failed: ${e} ${t}`)}})}));c.setSessionInfoStr(e);const t=JSON.parse(e);j=t?.settings?.webUI?.backendHeaders?.Authorization,d.log(`authToken: token = ${j}`),document.addEventListener("updateSession",(e=>{j=e.detail?.updateObj,d.log(`onUpdateSessionEvent: token = ${j}`)})),W=await new Promise((e=>{const t=r(),i=d.withFields({FCID:t}),n={type:"connectReason",fcid:t},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:t=>{i.log(`connectReason request successfully returned '${t}'`),e(t)},onFailure:(t,n)=>{i.error(`connectReason request failed: ${t} ${n}`),e(V.UNKNOWN)}})}));const i=await new Promise((e=>{const t=r(),i=d.withFields({FCID:t}),n={type:"triggerEvent",fcid:t},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:t=>{i.log(`triggerEvent request successfully returned '${t}'`),e(t)},onFailure:(t,n)=>{i.error(`triggerEvent request failed: ${t} ${n}`),e("")}})}));H={};let n={};if(i)try{n=JSON.parse(i),H.type=n.type,"keyPressEvent"===H.type?H.data={keyValue:n.keyValue}:"alarmFiredEvent"===H.type?H.data={alarmName:n.alarmName,payload:n.payload}:"userAlertEvent"===H.type?H.data={eventCode:n.eventCode,message:n.message}:"externalEvent"===H.type?H.data={eventName:n.eventName,payload:n.payload}:"videoPlaybackEvent"===H.type?H.data={eventCode:n.eventCode,errorCode:n.errorCode}:d.warn("unknown trigger event type",H.type)}catch(e){d.error(`failed to parse trigger event string ${i}: ${e.message}`)}await _._init(t?.settings?.["ui-streamer"],n),await N._init();const o=t?.settings?.["ui-streamer"]?.devSequence;o&&(p({lifecycle:N,remotePlayer:_}),h(!0))}else j=ee().sessionInfo?.settings?.webUI?.backendHeaders?.Authorization,d.log(`authToken dummy: token = ${j}`);Object.defineProperty(window,"senzaAuth",{value:B,writable:!1,configurable:!1}),window.close=()=>{d.warn("window.close is disabled on Senza platform. Use lifecycle.exitApplication() instead.")}}function Z(){return W}function Y(){return H}function ee(){if("undefined"==typeof window||!window.diagnostics)return"undefined"==typeof window||window.diagnostics||d.error("[ getPlatformInfo ] window.diagnostics is undefined"),{version:"X.X.XX-X",pod:"ui-streamer-X.X.XX-X-QWERT-ASDFG-XXX-XXXXXX-XXXXX",podIP:"0.0.0.0",sessionInfo:{userAgent:"SynamediaSenza/XX.YY.ZZ",connectionId:"dummy",deviceId:"123456789",community:"LocalDev",tenant:"XXXXXX",tenantId:"XXXXXX",manifest:{transcontainer:"X.X.XX-X"},settings:{webUI:{backendHeaders:{Authorization:"Bearer dummytoken"}}},homeSessionInfo:{tenantId:"XXXXXX",community:"LocalDev"}}};try{const e=window.diagnostics()||{};return e.sessionInfo=c.sessionInfoObj,e}catch(e){d.error("Could not get platform info",e.stack)}}function te(e){if(window.cefQuery){const t={message:JSON.stringify({type:"setTimeZone",timezone:e}),waitForResponse:!1,target:"UI-Streamer"};window.cefQuery({request:JSON.stringify(t),persistent:!1,onSuccess:()=>{d.log("timezome is successfully set to",e)},onFailure:(t,i)=>{d.error(`error occurred setting timezone to ${e}: ${t} ${i}`)}})}}function ie(){return!("undefined"==typeof window||!window.cefQuery)}function ne(){window.cefQuery?window.cefQuery({request:"uiReady",persistent:!1,onSuccess:()=>{d.log("uiReady request successfully sent")},onFailure:(e,t)=>{d.error(`uiReady request failed: ${e} ${t}`)}}):d.error("uiReady: window.cefQuery is undefined")}function oe(){const e=c.sessionInfoObj;return ie()?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp}:(d.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0"})}const se={remoteBrowserIp:window.diagnostics?window.diagnostics().podIP:"127.0.0.1",sdkVersion:z};function re(e,t,i,n){if(200===e&&(t=window.btoa(String.fromCharCode.apply(null,new Uint8Array(t)))),window.cefQuery){const o={type:"updateLicense",sessionId:n,fcid:i};o[200===e?"response":"error"]=t;const s={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{d.log("updateLicense request successfully sent")},onFailure:(e,t)=>{d.error(`updateLicense request failed: ${e} ${t}`)}})}}class ae extends Error{constructor(e,t){super(t),this.code=e}}function de(){if(window.cefQuery)return d.log("getClientAssertion is called"),new Promise(((e,t)=>{window.cefQuery({request:"client_assertion",persistent:!1,onSuccess:i=>{try{const t=JSON.parse(i);d.log(`client_assertion request successfully returned ${i}`),e(t)}catch(e){d.error(`Failed to parse client assertion ${i}`),t(new ae(0,"Failed to parse client assertion"))}},onFailure:(e,i)=>{d.log(`client_assertion request failed: ${e} ${i}`),t(new ae(e,i))}})}));d.warn("getClientAssertion is not supported if NOT running e2e")}return"undefined"!=typeof window&&(window.hs=i,window.senza=window.senza||i),t})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"main": "./src/api.js",
|
|
5
5
|
"description": "API for Senza application",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"coverageThreshold": {
|
|
40
40
|
"global": {
|
|
41
41
|
"branches": 84,
|
|
42
|
-
"functions":
|
|
43
|
-
"lines":
|
|
44
|
-
"statements":
|
|
42
|
+
"functions": 90,
|
|
43
|
+
"lines": 92,
|
|
44
|
+
"statements": 92
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/alarmManager.js
CHANGED
|
@@ -169,7 +169,6 @@ class AlarmManager extends EventTarget {
|
|
|
169
169
|
export const alarmManager = new AlarmManager();
|
|
170
170
|
// Adding alarm manager to window for testing purposes which allows us to use and test alarmManager APIs in pipeline tests
|
|
171
171
|
if (typeof window !== "undefined") {
|
|
172
|
-
window.alarmManager = alarmManager; // this will be deleted once tests are updated to senzaAlarmManager
|
|
173
172
|
Object.defineProperty(window, "senzaAlarmManager", {
|
|
174
173
|
value: alarmManager,
|
|
175
174
|
writable: false,
|
package/src/api.js
CHANGED
|
@@ -193,8 +193,7 @@ export async function init() {
|
|
|
193
193
|
sdkLogger.log(`authToken dummy: token = ${authToken}`);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
// Adding auth to window for testing
|
|
197
|
-
window.auth = auth; // this will be deleted once tests are updated to senzaAuth
|
|
196
|
+
// Adding auth to window for testing purposes which allows us to use and test auth APIs in pipeline tests
|
|
198
197
|
Object.defineProperty(window, "senzaAuth", {
|
|
199
198
|
value: auth,
|
|
200
199
|
writable: false,
|
|
@@ -502,9 +501,9 @@ export function getClientAssertion() {
|
|
|
502
501
|
sdkLogger.warn("getClientAssertion is not supported if NOT running e2e");
|
|
503
502
|
}
|
|
504
503
|
|
|
505
|
-
|
|
506
504
|
// Assign the senza library to the old name (hs) for backward compatibility
|
|
507
505
|
import * as senzaSDK from "./api.js";
|
|
508
506
|
if (typeof window !== "undefined") {
|
|
509
507
|
window.hs = senzaSDK;
|
|
508
|
+
window.senza = window.senza || senzaSDK; // this is only for testing purposes which allows us to use and test senza APIs in pipeline tests
|
|
510
509
|
}
|
package/src/messageManager.js
CHANGED
|
@@ -88,7 +88,6 @@ class MessageManager extends EventTarget {
|
|
|
88
88
|
export const messageManager = new MessageManager();
|
|
89
89
|
// Adding message manager to window for testing purposes which allows us to use and test messageManager APIs in pipeline tests
|
|
90
90
|
if (typeof window !== "undefined") {
|
|
91
|
-
window.messageManager = messageManager; // this will be deleted once tests are updated to senzaMessageManager
|
|
92
91
|
Object.defineProperty(window, "senzaMessageManager", {
|
|
93
92
|
value: messageManager,
|
|
94
93
|
writable: false,
|
package/src/remotePlayer.js
CHANGED
|
@@ -989,7 +989,6 @@ class RemotePlayer extends EventTarget {
|
|
|
989
989
|
export const remotePlayer = new RemotePlayer();
|
|
990
990
|
// Adding remotePlayer to window for testing purposes which allows us to use and test remotePlayer APIs in pipeline tests
|
|
991
991
|
if (typeof window !== "undefined") {
|
|
992
|
-
window.remotePlayer = remotePlayer; // this will be deleted once tests are updated to senzaRemotePlayer
|
|
993
992
|
Object.defineProperty(window, "senzaRemotePlayer", {
|
|
994
993
|
value: remotePlayer,
|
|
995
994
|
writable: false,
|