senza-sdk 3.19.5 → 3.19.10

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/README.md CHANGED
@@ -1,128 +1,10 @@
1
- <p align="center">
2
- <h1 align="center">Senza - SDK</h1>
3
- <p align="center">
1
+ # Senza SDK
4
2
 
5
- # Installation
3
+ ## Installation
6
4
 
7
- ### Step 1:
5
+ - npm: `npm install senza-sdk`
6
+ - yarn: `yarn add senza-sdk`
8
7
 
9
- Create a file called .npmrc / .yarnrc in your project and add the below line.
10
-
11
- `"@ip-synamedia:registry=https://artifactory01.engit.synamedia.com/artifactory/api/npm/spvss-cloud-ci-npm/"`
12
-
13
- ### Step 2:
14
-
15
- This library can be installed using npm/yarn with the below commands.
16
-
17
- - npm: `npm install @ip-synamedia/hs-sdk --save`
18
- - yarn: `yarn add @ip-synamedia/hs-sdk`
19
-
20
- # Usage
21
-
22
- Import and use required logic.
23
-
24
- # Local Usage and Debugging
25
-
26
- You can point your importing project to use your local code of this repo by creating an NPM link :
27
- 1. In this root of this project run:
28
- first install dependencies
29
- ```bash
30
- npm install OR yarn
31
- ```
32
-
33
-
34
- ```bash
35
- npm link
36
- ```
37
- OR
38
- ```bash
39
- yarn link
40
- ```
41
-
42
- Then in your importing project who uses this repo run:
43
- ```bash
44
- npm link @ip-synamedia/hs-sdk
45
- ```
46
- OR
47
- ```bash
48
- yarn link "@ip-synamedia/hs-sdk"
49
- ```
50
- It will now use the code on your local machine.
51
-
52
- ```
53
- import { init } from '@ip-synamedia/hs-sdk/dist/api';
54
-
55
- init();
56
- ```
57
-
58
- # Contribute to the Library
59
-
60
- ### Step 1:
61
-
62
- Navigate to `src/`
63
-
64
- ### Step 2:
65
-
66
- Contribute your code
67
-
68
- ### Step 3:
69
-
70
- Navigate to `src/api.js` and export your contribution (if needed)
71
-
72
- ### Step 4:
73
-
74
- Upgrade version in `package.json` and `package-lock.json`
75
-
76
- ### Step 5:
77
-
78
- Add the new version to `CHANGELOG.md`. Make sure to follow the existing format (as described in [KeepAChangeLog](https://keepachangelog.com/en/1.0.0/)).
79
-
80
- # Create docs
81
- Edit jsdocs in the relevant file and then run the following command for the updated file:
82
- ```bash
83
- ./node_modules/jsdoc-to-markdown/bin/cli.js src/remotePlayer.js
84
- ./node_modules/jsdoc-to-markdown/bin/cli.js src/api.js
85
- ```
86
- Copy the output of jsdoc-to-markdown (from standard output) and paste it in the relevant page under https://dash.readme.com/project/hyperscale/v1.0/docs/web-app-changes
87
- (replace the content starting from ## Modules).
88
-
89
- <p align="center">
90
- <h1 align="center">SampleApp - DefaultUI</h1>
91
- <p align="center">
92
-
93
- It's /samples/remotePlayer-startPlayback App. This App is used as a default UI App for tenant vending through matisse.
94
-
95
- ## Senza Client Library Installation
96
-
97
- In order to install the Senza Client Library, you first need to generate an access token to github. Follow these steps in order to generate the access token:
98
- 1. Sign in to github.com with your personal account (create one if you don't have one).
99
- 2. Go to your profile settings --> Developer settings
100
- 3. Under 'Personal access tokens' go to 'Tokens (classic)'
101
- 4. Go to 'Generate new token (classic)'
102
- 5. Check 'read:packages'
103
- 6. Generate token
104
- 7. Copy token
105
-
106
- ### Install
107
- Set registery for synamedia namespace
108
- ```bash
109
- npm config set @Synamedia:registry https://npm.pkg.github.com
110
- npm config set -- //npm.pkg.github.com/:_authToken <your access token>
111
- ```
112
-
113
- Install using npm
114
- ```bash
115
- npm install @Synamedia/hs-sdk
116
- ```
117
-
118
- ## Build SampleApp - DefaultUI
119
- After Updating the app you should build remotePlayer-startPlayback app according to samples/README.md
120
-
121
- ## Upload to S3 bucket
122
- After build, the folder should be uploaded to S3 prod bucket "streaming-sample-webui".
123
- ```bash
124
- aws s3 cp remotePlayer-startPlayback/synamedia-logo-dark.gif s3://streaming-sample-webui/main/
125
- aws s3 cp remotePlayer-startPlayback/dist s3://streaming-sample-webui/main/dist/ --recursive
126
- aws s3 cp remotePlayer-startPlayback/index.html s3://streaming-sample-webui/main/
127
- ```
8
+ ## Usage
128
9
 
10
+ Import and use required logic. For detailed documentation go to https://developer.synamedia.com/senza
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.hs=t():e.hs=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:()=>U,ConnectReason:()=>F,alarmManager:()=>v,auth:()=>N,deviceManager:()=>m,envInfo:()=>Q,getClientAssertion:()=>M,getConnectReason:()=>q,getDeviceInfo:()=>J,getPlatformInfo:()=>P,getTriggerEvent:()=>L,init:()=>C,isRunningE2E:()=>X,lifecycle:()=>l,messageManager:()=>S,remotePlayer:()=>y,setTimezone:()=>R,uiReady:()=>D,writeLicenseResponse:()=>x});const i={version:"3.19.5"},{version:n}=i;function s(){return Math.round(1e5*Math.random())+"-"+P().sessionInfo?.connectionId}class o{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 o({...this.logFields,...e})}formatLogString(e){let t="[hs-sdk] "+e.join(" ");return this.logFields&&(t+=" [log-fields] "+JSON.stringify(this.logFields)),t}}const r=new o({sdkVersion:n,url:window?.location?.href??""}),a=new class{sessionInfoStr="{}";get sessionInfoObj(){try{return JSON.parse(this.sessionInfoStr)}catch(e){return void r.warn("Failed to return sdk")}}setSessionInfoStr(e){try{JSON.parse(e)}catch(e){throw Error("Failed to parse sessionInfo")}this.sessionInfoStr=e}};class d extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/uistatechange",(e=>{r.log("Got hs/uistatechange",e.detail);const t=new Event("onstatechange");t.state=e.detail,this.dispatchEvent(t)}))}getState(){if(window.cefQuery)return new Promise(((e,t)=>{window.cefQuery&&window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{r.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(e,i)=>{r.error(`uiState request failed: ${e} ${i}`),t(i)}})}));r.warn("lifecycle getState is not supported if NOT running e2e")}moveToForeground(){if(window.cefQuery){const e=s(),t=r.withFields({FCID:e});t.log("lifecycle moveToForeground: sending uiActiveRequest action"),window.cefQuery({request:JSON.stringify({action:"uiActiveRequest",fcid:e}),persistent:!1,onSuccess:()=>{t.log("uiActiveRequest successfully sent")},onFailure:(e,i)=>{t.error(`uiActiveRequest failed: ${e} ${i}`)}})}else r.error("lifecycle moveToForeground: window.cefQuery is undefined")}switchTenant(e){if(e&&e.length>0){if(e===P().sessionInfo?.tenantId)return r.warn(`SwitchTenant requires a different tenantId than the current one. CurrentTenantId=${P().sessionInfo?.tenantId} and tenantId=${e}`),Promise.reject("SwitchTenant requires a different tenantId than the current one");const t=P().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId,i=P().sessionInfo?.homeSessionInfo?.tenantId;return r.log(`SwitchTenant for ${e}`),window.cefQuery?new Promise(((n,o)=>{const a=s(),d=r.withFields({FCID:a}),l={type:"reconnect",fcid:a,session:btoa(JSON.stringify({tenantId:e,...P().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:()=>{d.log("SwitchTenant request successfully sent"),n(!0)},onFailure:(e,t)=>{d.error(`SwitchTenant failed: ${e} ${t}`),o(`SwitchTenant failed: ${e} ${t}`)}})})):(r.warn("SwitchTenant is not supported if NOT running e2e"),Promise.reject("SwitchTenant is not supported if NOT running e2e"))}return r.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=s(),n=r.withFields({FCID:i});let o,a;P().sessionInfo?.homeSessionInfo&&(P().sessionInfo?.returnToTenantId||P().sessionInfo?.homeSessionInfo.tenantId!==P().sessionInfo?.tenantId)?(a={type:"reconnect",fcid:i},P().sessionInfo?.returnToTenantId&&(a.session=btoa(JSON.stringify({tenantId:P().sessionInfo?.returnToTenantId}))),o={target:"TC",waitForResponse:!1,message:JSON.stringify(a)}):(a={type:"launchHomeApplication",fcid:i},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(a)}),window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{n.log(`exitApplication request with type: '${a.type}' successfully sent`),e(!0)},onFailure:(e,i)=>{n.error(`exitApplication request with type: '${a.type}' failed: ${e} ${i}`),t(`exitApplication request with type: '${a.type}' failed: ${e} ${i}`)}})})):(r.warn("exitApplication is not supported if NOT running e2e"),Promise.reject("exitApplication is not supported if NOT running e2e"))}}const l=new d,c=e=>JSON.parse(JSON.stringify(e));class u extends Error{constructor(e,t){super(t),this.code=e,this.msg=t}}function f(){const e=window.getPlaybackInfo?window.getPlaybackInfo():JSON.stringify({playbackPosition:0,assetDuration:0});let t;try{t=JSON.parse(e)}catch(i){r.error(`Playback Info parse failed. playbackStr = ${e}`),t={playbackPosition:0,assetDuration:0}}return t}class g 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",(()=>{r.info("Got hs/playbackInfoEvent"),this.dispatchEvent(new Event("timeupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/playback",(e=>{r.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("EOS",(()=>{r.info("Got EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/EOS",(()=>{r.info("Got hs/EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/ui_inactive",(()=>{r.info("Got hs/ui_inactive event")})),"undefined"!=typeof document&&document.addEventListener("ERR",(e=>{delete e?.detail?.type,delete e?.detail?.eventCode,r.info("Got ERR event",JSON.stringify(e?.detail)),this.dispatchEvent(new CustomEvent("error",e))})),"undefined"!=typeof document&&document.addEventListener("hs/ERR",(e=>{r.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=>{r.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 s=t.fcid,o=t.sessionId,a=new CustomEvent("license-request",{detail:{licenseRequest:n}});a.writeLicenseResponse=(e,t)=>{x(e,t,s,o)},this.dispatchEvent(a)}))}LoadMode=Object.freeze({NOT_LOADED:"notLoaded",LOADING:"loading",LOADED:"loaded"});async _init(e,t){let i={isLoaded:!1,playbackUrl:""};if(window.cefQuery){const e=s(),t=r.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._requestVideoFrameInfo=e?.requestVideoFrameInfo??!0;let n={};try{n=JSON.parse(t?.playbackMetadata||"{}")}catch(e){r.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 c(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=s(),i=r.withFields({fcid:t}),n=(e,i)=>{const s={type:"currentFramePTS",fcid:t,currentFramePTS:i.mediaTime.toString(),ptsSessionId:this._ptsSessionId},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(o),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++,r.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._handle_video_frame_info(e)}async load(e,t){if(!this._isInitialized)throw new u(6500,"Cannot call load() if remote player is not initialized");if(e&&window.cefQuery){const i=await l.getState();if("background"===i||"inTransitionToBackground"===i)throw new u(6002,"Cannot call load() while in state 'background' or 'inTransitionToBackground'");if(this._loadMode===this.LoadMode.LOADING)throw new u(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)=>{this.currentTime=0;const a=s(),d=t??0,l=r.withFields({FCID:a,loadUrl:e,playbackPosition:d});l.log("remotePlayer load: sending setPlayableUri request");const c={type:"setPlayableUri",url:e,timeout:this._setPlayableUriTimeout,autoPlay:!1,playbackPosition:d,fcid:a},f={target:"TC",waitForResponse:!0,message:JSON.stringify(c)};let g=0;const y=Date.now(),w=window.cefQuery({request:JSON.stringify(f),persistent:!1,onSuccess:()=>{const n=Date.now()-y;l.withFields({duration:n}).log(`setPlayableUri completed successfully after ${n} ms`),t>0&&(this.currentTime=t),g&&(clearTimeout(g),g=0),this._changeLoadMode(this.LoadMode.LOADED),this._loadedUrl=e,i()},onFailure:(e,t)=>{const i=Date.now()-y;l.withFields({duration:i}).log(`setPlayableUri failed after ${i} ms. Error code: ${e}, error message: ${t}`),g&&(clearTimeout(g),g=0),99===e?this._changeLoadMode(n):(this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=""),o(new u(e,t))}});l.log(`window.cefQuery for setPlayableUri returned query id ${w}`);const p=this._setPlayableUriTimeout+1e3;g=setTimeout((()=>{l.log(`setPlayableUri reached timeout of ${p} ms, canceling query id ${w}`),window.cefQueryCancel(w),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl="",o(new u(6e3,`load reached timeout of ${p} ms`))}),p,w)}))}r.error("remotePlayer load: either window.cefQuery or url is undefined")}unload(){r.warn("unload() api is deprecated since version 3.14.0, no need to call unload() anymore at the end of playback")}play(){if(!this._isInitialized)throw new u(6500,"Cannot call play() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new u(6001,"Cannot call play() if player is not loaded");const e=s(),t=r.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||""),window.cefQuery({request:JSON.stringify({action:"play",fcid:e,audioLanguage:i,subtitlesLanguage:n}),persistent:!1,onSuccess:()=>{t.log("play action was successfully sent")},onFailure:(e,i)=>{t.log(`failed to send play action: ${e} ${i}`)}})}else r.error("remotePlayer play: window.cefQuery is undefined")}pause(){if(!this._isInitialized)throw new u(6500,"Cannot call pause() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new u(6001,"Cannot call pause() if player is not loaded");const e=s(),t=r.withFields({FCID:e});t.log("remotePlayer pause: sending pause request");const i={type:"senzaPlayer",action:"pause",fcid:e},n={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(n),persistent:!1,onSuccess:()=>{t.log("pause request successfully sent")},onFailure:(e,i)=>{t.error(`pause request failed: ${e} ${i}`)}})}else r.error("remotePlayer pause: window.cefQuery is undefined")}getAssetUri(){if(!this._isInitialized)throw new u(6500,"Cannot call getAssetUri() if remote player is not initialized");return this._loadedUrl}getLoadMode(){if(!this._isInitialized)throw new u(6500,"Cannot call getLoadMode() if remote player is not initialized");return this._loadMode}getTextTracks(){return c(this._availableTextTracks)}getAudioTracks(){return c(this._availableAudioTracks)}selectAudioTrack(e){for(const t of this.getAudioTracks())if(t.id===e)return void(this._selectedAudioTrack=e);r.warn(`Invalid audioTrackId ${e}`)}selectTextTrack(e){for(const t of this.getTextTracks())if(t.id===e)return void(this._selectedSubtitlesTrack=e);r.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 f()?.playbackPosition}set currentTime(e){!function(e){try{const t=JSON.stringify(e);window.setPlaybackInfo&&window.setPlaybackInfo(t)}catch(e){r.error("Playback Info to json string failed")}}({playbackPosition:e})}get duration(){return f()?.assetDuration}get textTrackVisibility(){return this._textTrackVisibility}getPresentationStartTimeAsDate(){return void 0===this._availabilityStartTime?null:new Date(1e3*this._availabilityStartTime)}}const y=new g;"undefined"!=typeof window&&(window.remotePlayer=y);const w={};class p extends EventTarget{constructor(){super(),w.level=0,w.quality=0,w.ssid="unknown",w.bssid="unknown","undefined"!=typeof document&&document.addEventListener("wifiSignalReport",(e=>{r.log("Got wifiSignalReport",JSON.stringify(e.detail)),w.level=e.detail.level,w.quality=e.detail.quality,w.ssid=e.detail.ssid,w.bssid=e.detail.bssid,this.dispatchEvent(new Event("wifiInfoUpdated"))}))}get deviceInfo(){const e=a.sessionInfoObj;return X()&&e?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp,countryCode:e.general?.location?.["x-country-code"]}:(r.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 w}reboot(){return new Promise(((e,t)=>{if(window.cefQuery){const i=s(),n=r.withFields({FCID:i}),o={type:"reboot",fcid:i},a={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(a),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 r.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=s(),n=r.withFields({FCID:i}),o={type:"resetWifi",fcid:i},a={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(a),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=s(),o=r.withFields({FCID:n}),a={type:"externalCommand",data:{command:"forward",payload:e},fcid:n},d={target:"TC",waitForResponse:!1,message:JSON.stringify(a)};window.cefQuery({request:JSON.stringify(d),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=s(),o=r.withFields({FCID:n}),a={type:"factoryReset",fcid:n,reboot:e},d={target:"TC",waitForResponse:!0,message:JSON.stringify(a)};let l=0;const c=window.cefQuery({request:JSON.stringify(d),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)}))}}const m=new p;class h extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/alarmFiredEvent",(e=>{r.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=s(),o=r.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=s(),i=r.withFields({alarmName:e,FCID:t});if(i.log(`deleteAlarm called for ${e}`),window.cefQuery){const n={type:"deleteAlarm",fcid:t,alarmName:e},s={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(s),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=s(),t=r.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 r.warn("deleteAllAlarms is not supported if NOT running e2e")}getActiveAlarms(){throw Error("NOT IMPLEMENTED")}}const v=new h;"undefined"!=typeof window&&(window.alarmManager=v);class T extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/externalEvent",(e=>{r.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 r.log(`register called for ${e}`),new Promise(((t,i)=>{if(window.cefQuery){const n=s(),o=r.withFields({FCID:n}),a={type:"registerGroupEvent",fcid:n,groups:e},d={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(a)};window.cefQuery({request:JSON.stringify(d),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 r.warn("registerGroupEvent is not supported if NOT running e2e"),i("registerGroupEvent is not supported if NOT running e2e")}))}}const S=new T;let b,I;"undefined"!=typeof window&&(window.messageManager=S),l.getState()?.then((e=>{I=e})),l.addEventListener("onstatechange",(e=>{I=e.state}));const k=e=>{"background"!==I&&"inTransitionToBackground"!==I||(b&&clearTimeout(b),b=setTimeout((()=>{"background"!==I&&"inTransitionToBackground"!==I||r.log(`${e.type} event received while in '${I}' state and there was no call to lifecycle.moveToForeground() for 500 ms. Make sure to call it if you want to move to foreground.`),b=0}),500))};"undefined"!=typeof document&&document.addEventListener("keydown",k),y.addEventListener("error",k),y.addEventListener("ended",k);const{version:_}=i;let E;const O="1.0";"undefined"!=typeof document&&document.addEventListener("keydown",(e=>{r.log(`Got ${e.key} key`)}));const N={getToken:async function(){return E?Promise.resolve(E):(r.log("getToken wait for promise updateSession event"),new Promise((e=>{document.addEventListener("updateSession",(t=>{E=t.detail?.updateObj,r.log(`onUpdateSessionEvent: token= ${E}`),e(E)}),{once:!0})})))},forceTokenUpdate:function(){if(E=null,window.cefQuery){const e=s(),t=r.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 r.error("forceTokenUpdate: window.cefQuery is undefined")},getClientAssertion:M},F=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 $=F.UNKNOWN,A={};async function C(){if(r.log(`init ${_}`),window.diagnostics||r.error("[ init ] window.diagnostics is undefined"),window.cefQuery){await new Promise(((e,t)=>{window.cefQuery({request:"apiVersion "+O,persistent:!1,onSuccess:()=>{r.log("api version compatability check succeeded"),e()},onFailure:(e,i)=>{r.error("api version compatability check failed: "+i),t(i)}})}));const e=await new Promise((e=>{window.cefQuery({request:"sessionInfo",persistent:!1,onSuccess:t=>{r.log("sessionInfo request successfully returned "+t),e(t)},onFailure:(e,t)=>{r.error(`sessionInfo request failed: ${e} ${t}`)}})}));a.setSessionInfoStr(e);const t=JSON.parse(e);E=t?.settings?.webUI?.backendHeaders?.Authorization,r.log(`authToken: token = ${E}`),document.addEventListener("updateSession",(e=>{E=e.detail?.updateObj,r.log(`onUpdateSessionEvent: token = ${E}`)})),t?.settings?.["ui-streamer"]?.enableKeyPressDuration&&function(){const e=document.createElement("div");e.setAttribute("style","height: 8px; width: 8px; background-color: red; position: absolute; left: 0px; top: 0px; z-index: 9999;"),document.body.appendChild(e),document.addEventListener("keydown",(()=>{"red"===e.style.backgroundColor?e.style.backgroundColor="blue":"blue"===e.style.backgroundColor?e.style.backgroundColor="green":e.style.backgroundColor="red"}))}(),$=await new Promise((e=>{const t=s(),i=r.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(F.UNKNOWN)}})}));const i=await new Promise((e=>{const t=s(),i=r.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("")}})}));A={};let n={};if(i)try{n=JSON.parse(i),A.type=n.type,"keyPressEvent"===A.type?A.data={keyValue:n.keyValue}:"alarmFiredEvent"===A.type?A.data={alarmName:n.alarmName,payload:n.payload}:"userAlertEvent"===A.type?A.data={eventCode:n.eventCode,message:n.message}:"externalEvent"===A.type?A.data={eventName:n.eventName,payload:n.payload}:"videoPlaybackEvent"===A.type?A.data={eventCode:n.eventCode,errorCode:n.errorCode}:r.warn("unknown trigger event type",A.type)}catch(e){r.error(`failed to parse trigger event string ${i}: ${e.message}`)}await y._init(t?.settings?.["ui-streamer"],n)}else E=P().sessionInfo?.settings?.webUI?.backendHeaders?.Authorization,r.log(`authToken dummy: token = ${E}`);window.auth=N,window.close=()=>{r.warn("window.close is disabled on Senza platform. Use lifecycle.exitApplication() instead.")}}function q(){return $}function L(){return A}function P(){if("undefined"==typeof window||!window.diagnostics)return"undefined"==typeof window||window.diagnostics||r.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=a.sessionInfoObj,e}catch(e){r.error("Could not get platform info",e.stack)}}function R(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:()=>{r.log("timezome is successfully set to",e)},onFailure:(t,i)=>{r.error(`error occurred setting timezone to ${e}: ${t} ${i}`)}})}}function X(){return!("undefined"==typeof window||!window.cefQuery)}function D(){window.cefQuery?window.cefQuery({request:"uiReady",persistent:!1,onSuccess:()=>{r.log("uiReady request successfully sent")},onFailure:(e,t)=>{r.error(`uiReady request failed: ${e} ${t}`)}}):r.error("uiReady: window.cefQuery is undefined")}function J(){const e=a.sessionInfoObj;return X()?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp}:(r.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0"})}const Q={remoteBrowserIp:window.diagnostics?window.diagnostics().podIP:"127.0.0.1",sdkVersion:_};function x(e,t,i,n){if(200===e&&(t=window.btoa(String.fromCharCode.apply(null,new Uint8Array(t)))),window.cefQuery){const s={type:"updateLicense",sessionId:n,fcid:i};s[200===e?"response":"error"]=t;const o={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{r.log("updateLicense request successfully sent")},onFailure:(e,t)=>{r.error(`updateLicense request failed: ${e} ${t}`)}})}}class U extends Error{constructor(e,t){super(t),this.code=e}}function M(){if(window.cefQuery)return r.log("getClientAssertion is called"),new Promise(((e,t)=>{window.cefQuery({request:"client_assertion",persistent:!1,onSuccess:i=>{try{const t=JSON.parse(i);r.log(`client_assertion request successfully returned ${i}`),e(t)}catch(e){r.error(`Failed to parse client assertion ${i}`),t(new U(0,"Failed to parse client assertion"))}},onFailure:(e,i)=>{r.log(`client_assertion request failed: ${e} ${i}`),t(new U(e,i))}})}));r.warn("getClientAssertion is not supported if NOT running e2e")}return 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,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},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:()=>M,ConnectReason:()=>$,alarmManager:()=>T,auth:()=>F,deviceManager:()=>h,envInfo:()=>x,getClientAssertion:()=>z,getConnectReason:()=>L,getDeviceInfo:()=>Q,getPlatformInfo:()=>R,getTriggerEvent:()=>P,init:()=>q,isRunningE2E:()=>X,lifecycle:()=>c,messageManager:()=>I,remotePlayer:()=>w,setTimezone:()=>J,uiReady:()=>D,writeLicenseResponse:()=>U});var n={};e.r(n),e.d(n,{ClientAssertionError:()=>M,ConnectReason:()=>$,alarmManager:()=>T,auth:()=>F,deviceManager:()=>h,envInfo:()=>x,getClientAssertion:()=>z,getConnectReason:()=>L,getDeviceInfo:()=>Q,getPlatformInfo:()=>R,getTriggerEvent:()=>P,init:()=>q,isRunningE2E:()=>X,lifecycle:()=>c,messageManager:()=>I,remotePlayer:()=>w,setTimezone:()=>J,uiReady:()=>D,writeLicenseResponse:()=>U});const i=JSON.parse('{"version":"3.19.10"}'),{version:s}=i;function o(){return Math.round(1e5*Math.random())+"-"+R().sessionInfo?.connectionId}class r{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 r({...this.logFields,...e})}formatLogString(e){let t="[hs-sdk] "+e.join(" ");return this.logFields&&(t+=" [log-fields] "+JSON.stringify(this.logFields)),t}}const a=new r({sdkVersion:s,url:window?.location?.href??""}),d=new class{sessionInfoStr="{}";get sessionInfoObj(){try{return JSON.parse(this.sessionInfoStr)}catch(e){return void a.warn("Failed to return sdk")}}setSessionInfoStr(e){try{JSON.parse(e)}catch(e){throw Error("Failed to parse sessionInfo")}this.sessionInfoStr=e}};class l extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/uistatechange",(e=>{a.log("Got hs/uistatechange",e.detail);const t=new Event("onstatechange");t.state=e.detail,this.dispatchEvent(t)}))}getState(){if(window.cefQuery)return new Promise(((e,t)=>{window.cefQuery&&window.cefQuery({request:"uiState",persistent:!1,onSuccess:t=>{a.log(`uiState request successfully returned '${t}'`),e(t)},onFailure:(e,n)=>{a.error(`uiState request failed: ${e} ${n}`),t(n)}})}));a.warn("lifecycle getState is not supported if NOT running e2e")}moveToForeground(){if(window.cefQuery){const e=o(),t=a.withFields({FCID:e});t.log("lifecycle moveToForeground: sending uiActiveRequest action"),window.cefQuery({request:JSON.stringify({action:"uiActiveRequest",fcid:e}),persistent:!1,onSuccess:()=>{t.log("uiActiveRequest successfully sent")},onFailure:(e,n)=>{t.error(`uiActiveRequest failed: ${e} ${n}`)}})}else a.error("lifecycle moveToForeground: window.cefQuery is undefined")}moveToBackground(){if(window.cefQuery){const e=o(),t=a.withFields({FCID:e});t.log("lifecycle moveToBackground: sending play action"),window.cefQuery({request:JSON.stringify({action:"play",fcid:e}),persistent:!1,onSuccess:()=>{t.log("[ moveToBackground ] play successfully sent")},onFailure:(e,n)=>{t.error(`[ moveToBackground ] play failed: ${e} ${n}`)}})}else a.error("lifecycle moveToBackground: window.cefQuery is undefined")}switchTenant(e){if(e&&e.length>0){if(e===R().sessionInfo?.tenantId)return a.warn(`SwitchTenant requires a different tenantId than the current one. CurrentTenantId=${R().sessionInfo?.tenantId} and tenantId=${e}`),Promise.reject("SwitchTenant requires a different tenantId than the current one");const t=R().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId,n=R().sessionInfo?.homeSessionInfo?.tenantId;return a.log(`SwitchTenant for ${e}`),window.cefQuery?new Promise(((i,s)=>{const r=o(),d=a.withFields({FCID:r}),l={type:"reconnect",fcid:r,session:btoa(JSON.stringify({tenantId:e,...R().sessionInfo?.tenantId===t&&e!==n&&{returnToTenantId:t}}))},c={target:"TC",waitForResponse:!1,message:JSON.stringify(l)};window.cefQuery({request:JSON.stringify(c),persistent:!1,onSuccess:()=>{d.log("SwitchTenant request successfully sent"),i(!0)},onFailure:(e,t)=>{d.error(`SwitchTenant failed: ${e} ${t}`),s(`SwitchTenant failed: ${e} ${t}`)}})})):(a.warn("SwitchTenant is not supported if NOT running e2e"),Promise.reject("SwitchTenant is not supported if NOT running e2e"))}return a.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 n=o(),i=a.withFields({FCID:n});let s,r;R().sessionInfo?.homeSessionInfo&&(R().sessionInfo?.returnToTenantId||R().sessionInfo?.homeSessionInfo.tenantId!==R().sessionInfo?.tenantId)?(r={type:"reconnect",fcid:n},R().sessionInfo?.returnToTenantId&&(r.session=btoa(JSON.stringify({tenantId:R().sessionInfo?.returnToTenantId}))),s={target:"TC",waitForResponse:!1,message:JSON.stringify(r)}):(r={type:"launchHomeApplication",fcid:n},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(r)}),window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{i.log(`exitApplication request with type: '${r.type}' successfully sent`),e(!0)},onFailure:(e,n)=>{i.error(`exitApplication request with type: '${r.type}' failed: ${e} ${n}`),t(`exitApplication request with type: '${r.type}' failed: ${e} ${n}`)}})})):(a.warn("exitApplication is not supported if NOT running e2e"),Promise.reject("exitApplication is not supported if NOT running e2e"))}}const c=new l,u=e=>JSON.parse(JSON.stringify(e));class f extends Error{constructor(e,t){super(t),this.code=e,this.msg=t}}function g(){const e=window.getPlaybackInfo?window.getPlaybackInfo():JSON.stringify({playbackPosition:0,assetDuration:0});let t;try{t=JSON.parse(e)}catch(n){a.error(`Playback Info parse failed. playbackStr = ${e}`),t={playbackPosition:0,assetDuration:0}}return t}class y 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",(()=>{a.info("Got hs/playbackInfoEvent"),this.dispatchEvent(new Event("timeupdate"))})),"undefined"!=typeof document&&document.addEventListener("hs/playback",(e=>{a.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("EOS",(()=>{a.info("Got EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/EOS",(()=>{a.info("Got hs/EOS event"),this.dispatchEvent(new Event("ended"))})),"undefined"!=typeof document&&document.addEventListener("hs/ui_inactive",(()=>{a.info("Got hs/ui_inactive event")})),"undefined"!=typeof document&&document.addEventListener("ERR",(e=>{delete e?.detail?.type,delete e?.detail?.eventCode,a.info("Got ERR event",JSON.stringify(e?.detail)),this.dispatchEvent(new CustomEvent("error",e))})),"undefined"!=typeof document&&document.addEventListener("hs/ERR",(e=>{a.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=>{a.info("Got hs/getLicense event");const t=e?.detail,n=Uint8Array.from(t.request,(e=>e.charCodeAt(0))),i=new ArrayBuffer(n.byteLength);new Uint8Array(i).set(n),this.licenseRequest=i;const s=t.fcid,o=t.sessionId,r=new CustomEvent("license-request",{detail:{licenseRequest:i}});r.writeLicenseResponse=(e,t)=>{U(e,t,s,o)},this.dispatchEvent(r)}))}LoadMode=Object.freeze({NOT_LOADED:"notLoaded",LOADING:"loading",LOADED:"loaded"});async _init(e,t){let n={isLoaded:!1,playbackUrl:""};if(window.cefQuery){const e=o(),t=a.withFields({FCID:e}),i={type:"playerState",fcid:e},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(i)};try{const e=await new Promise(((e,n)=>{window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:n=>{t.log("playerState request successfully returned",n),e(n)},onFailure:(e,i)=>{t.error(`playerState request failed: ${e} ${i}`),n()}})}));n=JSON.parse(e)}catch{t.error("either failed to get or failed to parse player state")}}this._loadMode=n?.isLoaded?this.LoadMode.LOADED:this.LoadMode.NOT_LOADED,this._loadedUrl=n?.playbackUrl||"",this._isInitialized=!0,this._setPlayableUriTimeout=e?.setPlayableUriTimeout??5e3,this._requestVideoFrameInfo=e?.requestVideoFrameInfo??!0;let i={};try{i=JSON.parse(t?.playbackMetadata||"{}")}catch(e){a.error(`failed to parse playbackMetadata: ${e.message}`)}this._availabilityStartTime=i.availabilityStartTime,this._updateTracks(i)}_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"}],n=[...e];for(const i of t)e.find((e=>e.lang===i.lang))||(i.autoTranslate=!0,n.push(i));return n}(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 u(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=o(),n=a.withFields({fcid:t}),i=(e,n)=>{const s={type:"currentFramePTS",fcid:t,currentFramePTS:n.mediaTime.toString(),ptsSessionId:this._ptsSessionId},o={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(o),persistent:!1}),this._videoElement?.requestVideoFrameCallback(i)};n.log("handle_video_frame_pts: requesting video frame info"),void 0!==this._videoElement&&this._videoElement===e||(e.requestVideoFrameCallback(i),e.addEventListener("loadstart",(e=>{this._ptsSessionId++,a.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._handle_video_frame_info(e)}async load(e,t){if(!this._isInitialized)throw new f(6500,"Cannot call load() if remote player is not initialized");if(e&&window.cefQuery){const n=await c.getState();if("background"===n||"inTransitionToBackground"===n)throw new f(6002,"Cannot call load() while in state 'background' or 'inTransitionToBackground'");if(this._loadMode===this.LoadMode.LOADING)throw new f(6501,"Cannot call load() while previous load is still in progress");this._reset();const i=this._loadMode;return this._changeLoadMode(this.LoadMode.LOADING),new Promise(((n,s)=>{this.currentTime=0;const r=o(),d=t??0,l=a.withFields({FCID:r,loadUrl:e,playbackPosition:d});l.log("remotePlayer load: sending setPlayableUri request");const c={type:"setPlayableUri",url:e,timeout:this._setPlayableUriTimeout,autoPlay:!1,playbackPosition:d,fcid:r},u={target:"TC",waitForResponse:!0,message:JSON.stringify(c)};let g=0;const y=Date.now(),w=window.cefQuery({request:JSON.stringify(u),persistent:!1,onSuccess:()=>{const i=Date.now()-y;l.withFields({duration:i}).log(`setPlayableUri completed successfully after ${i} ms`),t>0&&(this.currentTime=t),g&&(clearTimeout(g),g=0),this._changeLoadMode(this.LoadMode.LOADED),this._loadedUrl=e,n()},onFailure:(e,t)=>{const n=Date.now()-y;l.withFields({duration:n}).log(`setPlayableUri failed after ${n} ms. Error code: ${e}, error message: ${t}`),g&&(clearTimeout(g),g=0),99===e?this._changeLoadMode(i):(this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl=""),s(new f(e,t))}});l.log(`window.cefQuery for setPlayableUri returned query id ${w}`);const p=this._setPlayableUriTimeout+1e3;g=setTimeout((()=>{l.log(`setPlayableUri reached timeout of ${p} ms, canceling query id ${w}`),window.cefQueryCancel(w),this._changeLoadMode(this.LoadMode.NOT_LOADED),this._loadedUrl="",s(new f(6e3,`load reached timeout of ${p} ms`))}),p,w)}))}a.error("remotePlayer load: either window.cefQuery or url is undefined")}unload(){a.warn("unload() api is deprecated since version 3.14.0, no need to call unload() anymore at the end of playback")}play(e=!0){if(!this._isInitialized)throw new f(6500,"Cannot call play() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new f(6001,"Cannot call play() if player is not loaded");const t=o(),n=a.withFields({FCID:t});n.log("remotePlayer play: sending play action");const i=this._selectedAudioTrack||this._config.preferredAudioLanguage||"";let s="";if(this._textTrackVisibility&&(s=this._selectedSubtitlesTrack||this._config.preferredSubtitlesLanguage||""),e)window.cefQuery({request:JSON.stringify({action:"play",fcid:t,audioLanguage:i,subtitlesLanguage:s}),persistent:!1,onSuccess:()=>{n.log("play action was successfully sent")},onFailure:(e,t)=>{n.log(`failed to send play action: ${e} ${t}`)}});else{const e={type:"senzaPlayer",action:"play",fcid:t},i={target:"TC",waitForResponse:!1,message:JSON.stringify(e)};window.cefQuery({request:JSON.stringify(i),persistent:!1,onSuccess:()=>{n.log("senzaPlayer request successfully sent")},onFailure:(e,t)=>{n.error(`senzaPlayer request failed: ${e} ${t}`)}})}}else a.error("remotePlayer play: window.cefQuery is undefined")}pause(){if(!this._isInitialized)throw new f(6500,"Cannot call pause() if remote player is not initialized");if(window.cefQuery){if(this._loadMode!==this.LoadMode.LOADED)throw new f(6001,"Cannot call pause() if player is not loaded");const e=o(),t=a.withFields({FCID:e});t.log("remotePlayer pause: sending pause request");const n={type:"senzaPlayer",action:"pause",fcid:e},i={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(i),persistent:!1,onSuccess:()=>{t.log("pause request successfully sent")},onFailure:(e,n)=>{t.error(`pause request failed: ${e} ${n}`)}})}else a.error("remotePlayer pause: window.cefQuery is undefined")}getAssetUri(){if(!this._isInitialized)throw new f(6500,"Cannot call getAssetUri() if remote player is not initialized");return this._loadedUrl}getLoadMode(){if(!this._isInitialized)throw new f(6500,"Cannot call getLoadMode() if remote player is not initialized");return this._loadMode}getTextTracks(){return u(this._availableTextTracks)}getAudioTracks(){return u(this._availableAudioTracks)}selectAudioTrack(e){for(const t of this.getAudioTracks())if(t.id===e)return void(this._selectedAudioTrack=e);a.warn(`Invalid audioTrackId ${e}`)}selectTextTrack(e){for(const t of this.getTextTracks())if(t.id===e)return void(this._selectedSubtitlesTrack=e);a.warn(`Invalid textTrackId ${e}`)}setTextTrackVisibility(e){const t=this._textTrackVisibility;if("boolean"!=typeof e)throw new TypeError("visible parameter must be a boolean");const n=e;n!==t&&(this._textTrackVisibility=n,n||(this._selectedSubtitlesTrack=""))}get currentTime(){return g()?.playbackPosition}set currentTime(e){!function(e){try{const t=JSON.stringify(e);window.setPlaybackInfo&&window.setPlaybackInfo(t)}catch(e){a.error("Playback Info to json string failed")}}({playbackPosition:e})}get duration(){return g()?.assetDuration}get textTrackVisibility(){return this._textTrackVisibility}getPresentationStartTimeAsDate(){return void 0===this._availabilityStartTime?null:new Date(1e3*this._availabilityStartTime)}}const w=new y;"undefined"!=typeof window&&(window.remotePlayer=w);const p={};class m extends EventTarget{constructor(){super(),p.level=0,p.quality=0,p.ssid="unknown",p.bssid="unknown","undefined"!=typeof document&&document.addEventListener("wifiSignalReport",(e=>{a.log("Got wifiSignalReport",JSON.stringify(e.detail)),p.level=e.detail.level,p.quality=e.detail.quality,p.ssid=e.detail.ssid,p.bssid=e.detail.bssid,this.dispatchEvent(new Event("wifiInfoUpdated"))}))}get deviceInfo(){const e=d.sessionInfoObj;return X()&&e?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp,countryCode:e.general?.location?.["x-country-code"]}:(a.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 p}reboot(){return new Promise(((e,t)=>{if(window.cefQuery){const n=o(),i=a.withFields({FCID:n}),s={type:"reboot",fcid:n},r={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(r),persistent:!1,onSuccess:()=>{i.log("reboot request successfully sent"),e(!0)},onFailure:(e,n)=>{i.error(`reboot failed: ${e} ${n}`),t(`reboot failed: ${e} ${n}`)}})}else a.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 n=o(),i=a.withFields({FCID:n}),s={type:"resetWifi",fcid:n},r={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(r),persistent:!1,onSuccess:()=>{i.log("clearWifi successfully sent"),e(!0)},onFailure:(e,n)=>{i.error(`clearWifi failed: ${e} ${n}`),t(`clearWifi failed: ${e} ${n}`)}})}))}sendDataToDevice(e){if("string"!=typeof e)throw new Error("data must be of type 'string'");return new Promise(((t,n)=>{const i=o(),s=a.withFields({FCID:i}),r={type:"externalCommand",data:{command:"forward",payload:e},fcid:i},d={target:"TC",waitForResponse:!1,message:JSON.stringify(r)};window.cefQuery({request:JSON.stringify(d),persistent:!1,onSuccess:()=>{s.log("externalCommand successfully sent"),t()},onFailure:(e,t)=>{s.error(`externalCommand failed: ${e} ${t}`),n(`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,n)=>{const i=o(),s=a.withFields({FCID:i}),r={type:"factoryReset",fcid:i,reboot:e},d={target:"TC",waitForResponse:!0,message:JSON.stringify(r)};let l=0;const c=window.cefQuery({request:JSON.stringify(d),persistent:!1,onSuccess:()=>{l&&clearTimeout(l),s.log("factoryReset successfully sent"),t(!0)},onFailure:(e,t)=>{l&&clearTimeout(l),s.error(`factoryReset failed: ${e} ${t}`),n(`factoryReset failed: ${e} ${t}`)}});l=setTimeout((()=>{s.error("factoryReset failed: reached timeout of 5000 ms"),window.cefQueryCancel(c),n("factoryReset failed: reached timeout of 5000 ms")}),5e3)}))}}const h=new m;class v extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/alarmFiredEvent",(e=>{a.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,n){if("string"!=typeof n)throw Error("data must be a string");const i=o(),s=a.withFields({alarmName:e,FCID:i});if(s.log(`addAlarm called for ${e} to be fired at ${t}`),window.cefQuery){const o={type:"addAlarm",fcid:i,alarmName:e,alarmTime:t,payload:n},r={target:"TC",waitForResponse:!1,message:JSON.stringify(o)};window.cefQuery({request:JSON.stringify(r),persistent:!1,onSuccess:()=>{s.log("addAlarm request successfully sent")},onFailure:(e,t)=>{s.error(`addAlarm failed: ${e} ${t}`)}})}else s.warn("addAlarm is not supported if NOT running e2e")}deleteAlarm(e){const t=o(),n=a.withFields({alarmName:e,FCID:t});if(n.log(`deleteAlarm called for ${e}`),window.cefQuery){const i={type:"deleteAlarm",fcid:t,alarmName:e},s={target:"TC",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:()=>{n.log("deleteAlarm request successfully sent")},onFailure:(e,t)=>{n.error(`deleteAlarm failed: ${e} ${t}`)}})}else n.warn("deleteAlarm is not supported if NOT running e2e")}deleteAllAlarms(){if(window.cefQuery){const e=o(),t=a.withFields({FCID:e}),n={type:"deleteAllAlarms",fcid:e},i={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(i),persistent:!1,onSuccess:()=>{t.log("deleteAllAlarms request successfully sent")},onFailure:(e,n)=>{t.error(`deleteAllAlarms failed: ${e} ${n}`)}})}else a.warn("deleteAllAlarms is not supported if NOT running e2e")}getActiveAlarms(){throw Error("NOT IMPLEMENTED")}}const T=new v;"undefined"!=typeof window&&(window.alarmManager=T);class S extends EventTarget{constructor(){super(),"undefined"!=typeof document&&document.addEventListener("hs/externalEvent",(e=>{a.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 a.log(`register called for ${e}`),new Promise(((t,n)=>{if(window.cefQuery){const i=o(),s=a.withFields({FCID:i}),r={type:"registerGroupEvent",fcid:i,groups:e},d={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(r)};window.cefQuery({request:JSON.stringify(d),persistent:!1,onSuccess:()=>{s.log("registerGroupEvent request successfully sent"),t(!0)},onFailure:(e,t)=>{s.error(`registerGroupEvent failed: ${e} ${t}`),n(`registerGroupEvent failed: ${e} ${t}`)}})}else a.warn("registerGroupEvent is not supported if NOT running e2e"),n("registerGroupEvent is not supported if NOT running e2e")}))}}const I=new S;let b,k;"undefined"!=typeof window&&(window.messageManager=I),c.getState()?.then((e=>{k=e})),c.addEventListener("onstatechange",(e=>{k=e.state}));const E=e=>{"background"!==k&&"inTransitionToBackground"!==k||(b&&clearTimeout(b),b=setTimeout((()=>{"background"!==k&&"inTransitionToBackground"!==k||a.log(`${e.type} event received while in '${k}' state and there was no call to lifecycle.moveToForeground() for 500 ms. Make sure to call it if you want to move to foreground.`),b=0}),500))};"undefined"!=typeof document&&document.addEventListener("keydown",E),w.addEventListener("error",E),w.addEventListener("ended",E);const{version:_}=i;let O;const N="1.0";"undefined"!=typeof document&&document.addEventListener("keydown",(e=>{a.log(`Got ${e.key} key`)}));const F={getToken:async function(){return O?Promise.resolve(O):(a.log("getToken wait for promise updateSession event"),new Promise((e=>{document.addEventListener("updateSession",(t=>{O=t.detail?.updateObj,a.log(`onUpdateSessionEvent: token= ${O}`),e(O)}),{once:!0})})))},forceTokenUpdate:function(){if(O=null,window.cefQuery){const e=o(),t=a.withFields({FCID:e});t.log("forceTokenUpdate: sending updateSessionRequest");const n={type:"updateSessionRequest",updateKey:"authorization",parentPath:"settings.webUI.backendHeaders.Authorization",fcid:e},i={target:"TC",waitForResponse:!1,message:JSON.stringify(n)};window.cefQuery({request:JSON.stringify(i),persistent:!1,onSuccess:()=>{t.log("updateSessionRequest successfully sent")},onFailure:(e,n)=>{t.error(`updateSessionRequest failed: ${e} ${n}`)}})}else a.error("forceTokenUpdate: window.cefQuery is undefined")},getClientAssertion:z},$=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 C=$.UNKNOWN,A={};async function q(){if(a.log(`init ${_}`),window.diagnostics||a.error("[ init ] window.diagnostics is undefined"),window.cefQuery){await new Promise(((e,t)=>{window.cefQuery({request:"apiVersion "+N,persistent:!1,onSuccess:()=>{a.log("api version compatability check succeeded"),e()},onFailure:(e,n)=>{a.error("api version compatability check failed: "+n),t(n)}})}));const e=await new Promise((e=>{window.cefQuery({request:"sessionInfo",persistent:!1,onSuccess:t=>{a.log("sessionInfo request successfully returned "+t),e(t)},onFailure:(e,t)=>{a.error(`sessionInfo request failed: ${e} ${t}`)}})}));d.setSessionInfoStr(e);const t=JSON.parse(e);O=t?.settings?.webUI?.backendHeaders?.Authorization,a.log(`authToken: token = ${O}`),document.addEventListener("updateSession",(e=>{O=e.detail?.updateObj,a.log(`onUpdateSessionEvent: token = ${O}`)})),t?.settings?.["ui-streamer"]?.enableKeyPressDuration&&function(){const e=document.createElement("div");e.setAttribute("style","height: 8px; width: 8px; background-color: red; position: absolute; left: 0px; top: 0px; z-index: 9999;"),document.body.appendChild(e),document.addEventListener("keydown",(()=>{"red"===e.style.backgroundColor?e.style.backgroundColor="blue":"blue"===e.style.backgroundColor?e.style.backgroundColor="green":e.style.backgroundColor="red"}))}(),C=await new Promise((e=>{const t=o(),n=a.withFields({FCID:t}),i={type:"connectReason",fcid:t},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:t=>{n.log(`connectReason request successfully returned '${t}'`),e(t)},onFailure:(t,i)=>{n.error(`connectReason request failed: ${t} ${i}`),e($.UNKNOWN)}})}));const n=await new Promise((e=>{const t=o(),n=a.withFields({FCID:t}),i={type:"triggerEvent",fcid:t},s={target:"UI-Streamer",waitForResponse:!1,message:JSON.stringify(i)};window.cefQuery({request:JSON.stringify(s),persistent:!1,onSuccess:t=>{n.log(`triggerEvent request successfully returned '${t}'`),e(t)},onFailure:(t,i)=>{n.error(`triggerEvent request failed: ${t} ${i}`),e("")}})}));A={};let i={};if(n)try{i=JSON.parse(n),A.type=i.type,"keyPressEvent"===A.type?A.data={keyValue:i.keyValue}:"alarmFiredEvent"===A.type?A.data={alarmName:i.alarmName,payload:i.payload}:"userAlertEvent"===A.type?A.data={eventCode:i.eventCode,message:i.message}:"externalEvent"===A.type?A.data={eventName:i.eventName,payload:i.payload}:"videoPlaybackEvent"===A.type?A.data={eventCode:i.eventCode,errorCode:i.errorCode}:a.warn("unknown trigger event type",A.type)}catch(e){a.error(`failed to parse trigger event string ${n}: ${e.message}`)}await w._init(t?.settings?.["ui-streamer"],i)}else O=R().sessionInfo?.settings?.webUI?.backendHeaders?.Authorization,a.log(`authToken dummy: token = ${O}`);window.auth=F,window.close=()=>{a.warn("window.close is disabled on Senza platform. Use lifecycle.exitApplication() instead.")}}function L(){return C}function P(){return A}function R(){if("undefined"==typeof window||!window.diagnostics)return"undefined"==typeof window||window.diagnostics||a.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=d.sessionInfoObj,e}catch(e){a.error("Could not get platform info",e.stack)}}function J(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:()=>{a.log("timezome is successfully set to",e)},onFailure:(t,n)=>{a.error(`error occurred setting timezone to ${e}: ${t} ${n}`)}})}}function X(){return!("undefined"==typeof window||!window.cefQuery)}function D(){window.cefQuery?window.cefQuery({request:"uiReady",persistent:!1,onSuccess:()=>{a.log("uiReady request successfully sent")},onFailure:(e,t)=>{a.error(`uiReady request failed: ${e} ${t}`)}}):a.error("uiReady: window.cefQuery is undefined")}function Q(){const e=d.sessionInfoObj;return X()?{deviceId:e.deviceId,connectionId:e.connectionId,community:e.community,tenant:e.tenant,clientIp:e.clientIp}:(a.log("getDeviceInfo running locally, returning dummy info"),{deviceId:"123456789",connectionId:"dummy",community:"LocalDev",tenant:"XXXXXX",clientIp:"0.0.0.0"})}const x={remoteBrowserIp:window.diagnostics?window.diagnostics().podIP:"127.0.0.1",sdkVersion:_};function U(e,t,n,i){if(200===e&&(t=window.btoa(String.fromCharCode.apply(null,new Uint8Array(t)))),window.cefQuery){const s={type:"updateLicense",sessionId:i,fcid:n};s[200===e?"response":"error"]=t;const o={target:"TC",waitForResponse:!1,message:JSON.stringify(s)};window.cefQuery({request:JSON.stringify(o),persistent:!1,onSuccess:()=>{a.log("updateLicense request successfully sent")},onFailure:(e,t)=>{a.error(`updateLicense request failed: ${e} ${t}`)}})}}class M extends Error{constructor(e,t){super(t),this.code=e}}function z(){if(window.cefQuery)return a.log("getClientAssertion is called"),new Promise(((e,t)=>{window.cefQuery({request:"client_assertion",persistent:!1,onSuccess:n=>{try{const t=JSON.parse(n);a.log(`client_assertion request successfully returned ${n}`),e(t)}catch(e){a.error(`Failed to parse client assertion ${n}`),t(new M(0,"Failed to parse client assertion"))}},onFailure:(e,n)=>{a.log(`client_assertion request failed: ${e} ${n}`),t(new M(e,n))}})}));a.warn("getClientAssertion is not supported if NOT running e2e")}return"undefined"!=typeof window&&(window.hs=n),t})()));
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "3.19.5",
3
+ "version": "3.19.10",
4
4
  "main": "./dist/bundle.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "git@github.com:Synamedia/hs-sdk.git"
10
- },
11
7
  "files": [
12
8
  "dist/"
13
9
  ],
10
+ "homepage": "https://www.synamedia.com/",
14
11
  "scripts": {
15
12
  "clean": "rm -rf dist",
16
13
  "prepublish": "npm run build",
@@ -20,7 +17,7 @@
20
17
  },
21
18
  "devDependencies": {
22
19
  "@babel/cli": "^7.13.16",
23
- "@babel/core": "^7.14.0",
20
+ "@babel/core": "7.18.6",
24
21
  "@babel/plugin-transform-modules-commonjs": "^7.16.8",
25
22
  "@babel/preset-env": "^7.14.1",
26
23
  "babel-jest": "^27.5.1",