@castlabs/prestoplay 6.20.0 → 6.21.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +109 -110
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +553 -550
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +78 -77
  10. package/cjs/cl.externs.js +81 -97
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +69 -69
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -29
  15. package/cjs/cl.ima.js +22 -24
  16. package/cjs/cl.mse.js +305 -305
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +13 -13
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +25 -25
  25. package/cjs/cl.tizen.js +70 -69
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +13 -13
  29. package/cjs/cl.vr.js +18 -18
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +9 -0
  32. package/cjs/cl.youbora.js +38 -20
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +88 -89
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +471 -468
  39. package/cl.crypto.js +8 -8
  40. package/cl.dash.js +74 -72
  41. package/cl.externs.js +71 -99
  42. package/cl.freewheel.js +19 -19
  43. package/cl.hls.js +74 -74
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +16 -17
  47. package/cl.mse.js +276 -276
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +11 -11
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +59 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +14 -14
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -0
  63. package/cl.youbora.js +27 -15
  64. package/package.json +3 -1
  65. package/typings.d.ts +123 -24
package/cl.muxdata.js CHANGED
@@ -1,13 +1,13 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Lz=function(a){switch(a.type){case 1:return Iz;case 2:return Jz;case 3:return Kz}},Nz=function(a){const b=Object.keys(a).find(c=>Mz.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},Pz=function(a){let b={debug:!0,data:Oz(a)};a.f&&a.f.muxOptionsOverride&&_.Sg(a.f.muxOptionsOverride)&&(b=_.Og(b,a.f.muxOptionsOverride));b=_.Og(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.g.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
- a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.cm(c.url);e.video_source_url=_.Ej(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().ma(),
3
- c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.g.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.la())&&d.language&&(e.player_language_code=d.language)}return e}});a.g.debug("Mux SDK options",b);return b},Qz=function(a){_.ph(a.a);a.j.ed(a.F);a.j.ze(a.C)},Oz=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.pa,player_software_name:_.pa,player_software_version:_.da,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
- player_mux_plugin_version:_.da};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},Rz=function(a){a.a.on(a.m,_.Wf,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.Wf,b)});a.a.on(a.m,_.Re,()=>a.emit(_.Re));a.a.on(a.m,_.Oc,a.G.bind(a));a.a.on(a.m,_.Mf,a.I.bind(a));a.a.on(a.m,_.fg,()=>a.emit(_.Ef));a.a.on(a.m,_.eg,()=>a.emit(_.Df));a.a.on(a.m,_.Ud,a.H.bind(a));a.a.on(a.m,_.bc,()=>a.emit("adbreakstart"));a.a.on(a.m,_.cc,()=>a.emit("adbreakend"));a.a.on(a.m,_.rc,()=>
5
- {a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.nc,()=>a.emit("adpause"));a.a.on(a.m,_.pc,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.sc,()=>a.emit("adended"));a.a.on(a.m,_.gc,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.mc,()=>a.emit("admidpoint"));a.a.on(a.m,_.tc,()=>a.emit("adthirdquartile"));a.j.sc(a.F);a.j.Od(a.C);a.a.on(a.m,_.Ud,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
- var d=new _.cm(b.uris[b.uriIndex]);b={request_start:c,request_type:Lz(b),request_hostname:d.a};a.g.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.cm(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:Lz(c),request_hostname:f.a,request_error:`${Lz(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
- a.g.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},Sz=function(a){return!_.z(a)&&typeof a.init===_.Yd&&typeof a.emit===_.Yd},Iz="manifest",Jz="media",Kz="encryption",Mz=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var Tz=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.Rs;this.g=b;this.A=this.l=this.h=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.J.bind(this);this.C=this.K.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.h){try{this.h=!0,this.w.init(this.B,Pz(this))}catch(d){throw this.h=!1,Qz(this),new _.G(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=Oz(this),this.emit("videochange",
8
- a),this.l=!1);Rz(this)}release(){this.g.debug("release()");this.l?this.g.debug(_.ha):(Qz(this),this.l=!0,this.o=this.f=null)}destroy(){this.g.debug(_.Cd);this.A?this.g.debug(_.fa):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.G(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.g.debug(_.Ee);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Ua())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.g.debug(_.Ie);
9
- switch(a.detail.currentState){case _.qo:this.m.getConfiguration().autoplay&&this.emit(_.Re);break;case _.so:this.emit(_.bf);break;case _.ro:this.emit(_.Ne);break;case _.ho:this.emit(_.Td)}}H(a){this.g.debug(_.Fe);if(this.h&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.E){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
- this.emit(_.Ud,{player_error_code:a.code,player_error_message:b})}}J(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.cm(b.uris[b.uriIndex]);a={request_start:g,request_type:Lz(b),request_hostname:d.a,request_id:Nz(e),request_bytes_loaded:f,request_response_start:h,
11
- request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.Ej(d)};this.g.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}K(a){a.requestStartTimestamp=Date.now()}};var Uz=class extends _.Ru{constructor(){super();this.f=this.m=null;this.a=!1;this.g=new _.R("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new Tz(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.Pg(c.muxdata);try{var d=[];typeof c===_.De&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.G(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.z(f.muxdata)&&typeof f.muxdata===_.De){const g=f.muxdata;d=Sz(g.muxLib)?g.muxLib:window.mux;if(!Sz(d)){this.g.warn("Mux SDK is not loaded. Will do nothing.");
12
- this.a=!1;const h=new _.G(1,9,9301);this.T(a,h)}}else this.g.debug("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,this.T(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&this.T(this.m,c),c;}}T(a,b){a.trigger(new _.C(_.Ud,{detail:b}))}};
13
- _.x("clpp.muxdata.MuxDataPlugin",Uz);Uz.prototype.emit=Uz.prototype.emit;Uz.Id="mux";_.Hq(new class{create(){return new Uz}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var pA=function(a){switch(a.type){case 1:return mA;case 2:return nA;case 3:return oA}},rA=function(a){const b=Object.keys(a).find(c=>qA.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},tA=function(a){let b={debug:!0,data:sA(a)};a.f&&a.f.muxOptionsOverride&&_.Tg(a.f.muxOptionsOverride)&&(b=_.Pg(b,a.f.muxOptionsOverride));b=_.Pg(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.g.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
+ a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.fm(c.url);e.video_source_url=_.Hj(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().ja(),
3
+ c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.g.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.ma())&&d.language&&(e.player_language_code=d.language)}return e}});a.g.debug("Mux SDK options",b);return b},uA=function(a){_.qh(a.a);a.j.cd(a.F);a.j.ze(a.C)},sA=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.pa,player_software_name:_.pa,player_software_version:_.da,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
+ player_mux_plugin_version:_.da};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},vA=function(a){a.a.on(a.m,_.Vf,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.Vf,b)});a.a.on(a.m,_.Qe,()=>a.emit(_.Qe));a.a.on(a.m,_.Oc,a.G.bind(a));a.a.on(a.m,_.Lf,a.I.bind(a));a.a.on(a.m,_.eg,()=>a.emit(_.Df));a.a.on(a.m,_.dg,()=>a.emit(_.Cf));a.a.on(a.m,_.r,a.H.bind(a));a.a.on(a.m,_.bc,()=>a.emit("adbreakstart"));a.a.on(a.m,_.cc,()=>a.emit("adbreakend"));a.a.on(a.m,_.rc,()=>{a.emit("adplay");
5
+ a.emit("adplaying")});a.a.on(a.m,_.mc,()=>a.emit("adpause"));a.a.on(a.m,_.oc,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.sc,()=>a.emit("adended"));a.a.on(a.m,_.gc,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.lc,()=>a.emit("admidpoint"));a.a.on(a.m,_.tc,()=>a.emit("adthirdquartile"));a.j.sc(a.F);a.j.Od(a.C);a.a.on(a.m,_.r,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
+ var d=new _.fm(b.uris[b.uriIndex]);b={request_start:c,request_type:pA(b),request_hostname:d.a};a.g.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.fm(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:pA(c),request_hostname:f.a,request_error:`${pA(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
+ a.g.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},wA=function(a){return!_.B(a)&&typeof a.init===_.Xd&&typeof a.emit===_.Xd},mA="manifest",nA="media",oA="encryption",qA=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var xA=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.bt;this.g=b;this.A=this.l=this.h=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.J.bind(this);this.C=this.K.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.h){try{this.h=!0,this.w.init(this.B,tA(this))}catch(d){throw this.h=!1,uA(this),new _.I(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=sA(this),this.emit("videochange",
8
+ a),this.l=!1);vA(this)}release(){this.g.debug("release()");this.l?this.g.debug(_.ha):(uA(this),this.l=!0,this.o=this.f=null)}destroy(){this.g.debug(_.Cd);this.A?this.g.debug(_.fa):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.I(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.g.debug(_.De);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Xa())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.g.debug(_.He);
9
+ switch(a.detail.currentState){case _.xo:this.m.getConfiguration().autoplay&&this.emit(_.Qe);break;case _.zo:this.emit(_.af);break;case _.yo:this.emit(_.Me);break;case _.oo:this.emit(_.Td)}}H(a){this.g.debug(_.Ee);if(this.h&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.F){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
+ this.emit(_.r,{player_error_code:a.code,player_error_message:b})}}J(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.fm(b.uris[b.uriIndex]);a={request_start:g,request_type:pA(b),request_hostname:d.a,request_id:rA(e),request_bytes_loaded:f,request_response_start:h,
11
+ request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.Hj(d)};this.g.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}K(a){a.requestStartTimestamp=Date.now()}};var yA=class extends _.av{constructor(){super();this.f=this.m=null;this.a=!1;this.g=new _.S("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new xA(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.Qg(c.muxdata);try{var d=[];typeof c===_.Ce&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.I(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.B(f.muxdata)&&typeof f.muxdata===_.Ce){const g=f.muxdata;d=wA(g.muxLib)?g.muxLib:window.mux;if(!wA(d)){this.g.warn("Mux SDK is not loaded. Will do nothing.");
12
+ this.a=!1;const h=new _.I(1,9,9301);this.T(a,h)}}else this.g.debug("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,this.T(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&this.T(this.m,c),c;}}T(a,b){a.trigger(new _.E(_.r,{detail:b}))}};
13
+ _.z("clpp.muxdata.MuxDataPlugin",yA);yA.prototype.emit=yA.prototype.emit;yA.Id="mux";_.Qq(new class{create(){return new yA}});};f.call(g, window);
package/cl.onboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Hz=function(a,b){let c=b.baseUrl;_.Mi(c,"/")||(c+="/");const d=g=>g&&(_.Li(g,"https://")||_.Li(g,"http://")||_.Li(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.It(a);a.Xa(_.xd,{licenseUrl:e,videoRobustness:[_.Gb,void 0],audioRobustness:[_.Fb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.um,licenseResponse:_.vm}});a.Xa(_.sd,{licenseUrl:b,
2
- certificateUrl:b,modifiers:{licenseRequest:_.xm,licenseResponse:_.ym,extractContentId:_.zm,certificateRequest:_.Am}});a.Xa(_.vd,{licenseUrl:f,modifiers:{licenseRequest:_.um}});_.Hl(a)};
3
- _.x("clpp.onboard.OnboardComponent",class extends _.qu{constructor(){super();this.g=new _.R("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.Gl[a];this.j.clear()}h(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.g.info(`Registering the DRMtoday Onboard environment, name='${b}'`),Hz(b,a),this.j.add(b))}id(){return"onboard"}});
4
- _.x("clpp.onboard.register",Hz);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var lA=function(a,b){let c=b.baseUrl;_.Ni(c,"/")||(c+="/");const d=g=>g&&(_.Mi(g,"https://")||_.Mi(g,"http://")||_.Mi(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.Tt(a);a.Za(_.xd,{licenseUrl:e,videoRobustness:[_.Gb,void 0],audioRobustness:[_.Fb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.xm,licenseResponse:_.ym}});a.Za(_.sd,{licenseUrl:b,
2
+ certificateUrl:b,modifiers:{licenseRequest:_.Am,licenseResponse:_.Bm,extractContentId:_.Cm,certificateRequest:_.Dm}});a.Za(_.vd,{licenseUrl:f,modifiers:{licenseRequest:_.xm}});_.Kl(a)};
3
+ _.z("clpp.onboard.OnboardComponent",class extends _.Au{constructor(){super();this.g=new _.S("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.Jl[a];this.j.clear()}h(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.g.info(`Registering the DRMtoday Onboard environment, name='${b}'`),lA(b,a),this.j.add(b))}id(){return"onboard"}});
4
+ _.z("clpp.onboard.register",lA);};f.call(g, window);
package/cl.persistent.js CHANGED
@@ -1,11 +1,11 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var rz="A persistent DRM session already exists for: ",sz="No DRM configuration.",tz="clpp.persistent",uz="clpp.persistent.SimpleSessionStorage",vz=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},xz=function(a,b){a.I=wz;a.J=[];a.C=!0;return _.un(a,b)},zz=function(a,b,c,d,e,f){a.I=yz;const g=new Map,h=_.dn(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ke,persistentState:_.wf,sessionTypes:[_.Pe],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,
2
- distinctiveIdentifierRequired:!1,persistentStateRequired:!0,audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.tn(a,g)},Az=function(a,b){return _.w(function*(){const c=yield _.Kn(a,b);if(c){var d=[],e=a.f.get(c);e&&a.A&&(e.Jb=new _.xn,d.push(e.Jb));a.g.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.g.debug("Ignoring attempt to remove missing session",b)})},Bz=function(a){a=a.f.keys();a=vz(a,b=>b.sessionId);return Array.from(a)},
3
- Cz=function(a,b){const c=_.Jl(a),d=_.pl({drm:a});d.drm=a;a=new _.Bo({Hb:b,onError:()=>{},pe:()=>{},oe:()=>{},onEvent:()=>{},getConfiguration:()=>d,Ac:()=>null});a.h=c;return a},Fz=function(a,b,c){return _.w(function*(){const d=Dz;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)Ez.debug(rz,e);else{var g=Cz(a,c);try{yield xz(g,b);yield _.In(g);yield _.Ln(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.gk(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:Bz(g),
4
- keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw Ez.error(`Error while persisting DRM session ${e}`),new _.G(1,6,6200,null,h);}finally{yield g.destroy()}}}}else Ez.debug(sz)})},wz=1,yz=2,Gz=class{constructor(){this.g=new _.R(uz)}store(a,b){return _.w(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
5
- const e=JSON.stringify(b.audioCapabilities),f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){const b=this;return _.w(function*(){const c=window.localStorage.getItem(encodeURIComponent(a));if(c)try{{const e=JSON.parse(atob(c)),f=JSON.parse(e.sessionIds),
6
- g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.g.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.w(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.w(function*(){window.localStorage.clear()})}getName(){return uz}};_.x("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.z(a)||(_.Tg(a.store)||c.push("store"),_.Tg(a.get)||c.push("get"),_.Tg(a.delete)||c.push("delete"),_.Tg(a.clear)||c.push("clear"),_.Tg(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw Ez.warn("Invalid session storage implementation"),new _.G(1,6,6202,{missingMethods:b});Dz=a});
7
- _.x("clpp.persistent.fetchLicense",function(a,b,...c){return _.w(function*(){var d=Dz,e=(l,m)=>new _.G(1,6,6200,l,m);const f=_.vo(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(sz);var g=b.offlineId;if(typeof g!==_.Pf||!g.length)throw e("Missing offline id.");if(yield d.get(g))Ez.debug(rz,g);else{var h=_.pl();d=new _.yq;g=[];for(var k of c){const l=new k;_.sl(l.id())||(l.f(),_.ul(l),g.push(l))}k=null;try{k=yield _.cs(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
- const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.G(_.E,4,4014));const m=_.as(l.periods);yield Fz(b,m,d)}catch(l){if(l instanceof _.G&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.rl.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
- _.x("clpp.persistent.removeLicense",function(a){return _.w(function*(){var b=Dz;if(_.Vg(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.yq,c=Cz(e.drmConfig,d),yield zz(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.In(c),yield Promise.all(e.sessionIds.map(f=>_.w(function*(){yield Az(c,f);Ez.debug("successfully removed session with id",f)}))),yield b.delete(a)):Ez.debug("No persistent DRM session found")}catch(e){throw Ez.error("Failed to remove session"),
10
- new _.G(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else Ez.warn("Invalid offlineId")})});var Dz=new Gz,Ez=new _.R(tz);_.x("clpp.persistent.PersistentLicenseComponent",class extends _.qu{constructor(){super();this.g=new _.R(tz)}id(){return _.Oe}l(a,b){const c=this;return _.w(function*(){const d=a.getConfiguration().drm;if(d){c.g.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield Fz(d,b,e),a.trigger(new _.C(_.Md,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.g.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.w(function*(){b.g.debug(`Getting EME session IDs for ${a}`);
11
- const c=Dz;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.g.debug(`No offline session found for ${a}`);return[]}catch(d){return b.g.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Wz="A persistent DRM session already exists for: ",Xz="No DRM configuration.",Yz="clpp.persistent",Zz="clpp.persistent.SimpleSessionStorage",$z=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},bA=function(a,b,c,d,e,f){a.I=aA;const g=new Map,h=_.gn(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Je,persistentState:_.vf,sessionTypes:[_.Oe],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
2
+ audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.yn(a,g)},dA=function(a,b){a.I=cA;a.J=[];a.C=!0;return _.zn(a,b)},eA=function(a,b){return _.x(function*(){const c=yield _.Rn(a,b);if(c){var d=[],e=a.f.get(c);e&&a.A&&(e.Jb=new _.Cn,d.push(e.Jb));a.g.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.g.debug("Ignoring attempt to remove missing session",b)})},fA=function(a){a=a.f.keys();a=$z(a,b=>b.sessionId);return Array.from(a)},
3
+ gA=function(a,b){const c=_.Ml(a),d=_.sl({drm:a});d.drm=a;a=new _.Io({Hb:b,onError:()=>{},pe:()=>{},oe:()=>{},onEvent:()=>{},getConfiguration:()=>d,Ac:()=>null});a.h=c;return a},jA=function(a,b,c){return _.x(function*(){const d=hA;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)iA.debug(Wz,e);else{var g=gA(a,c);try{yield dA(g,b);yield _.Pn(g);yield _.Sn(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.jk(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:fA(g),
4
+ keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw iA.error(`Error while persisting DRM session ${e}`),new _.I(1,6,6200,null,h);}finally{yield g.destroy()}}}}else iA.debug(Xz)})},cA=1,aA=2,kA=class{constructor(){this.g=new _.S(Zz)}store(a,b){return _.x(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
5
+ const e=JSON.stringify(b.audioCapabilities),f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){const b=this;return _.x(function*(){const c=window.localStorage.getItem(encodeURIComponent(a));if(c)try{{const e=JSON.parse(atob(c)),f=JSON.parse(e.sessionIds),
6
+ g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.g.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.x(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.x(function*(){window.localStorage.clear()})}getName(){return Zz}};_.z("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.B(a)||(_.Ug(a.store)||c.push("store"),_.Ug(a.get)||c.push("get"),_.Ug(a.delete)||c.push("delete"),_.Ug(a.clear)||c.push("clear"),_.Ug(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw iA.warn("Invalid session storage implementation"),new _.I(1,6,6202,{missingMethods:b});hA=a});
7
+ _.z("clpp.persistent.fetchLicense",function(a,b,...c){return _.x(function*(){var d=hA,e=(l,m)=>new _.I(1,6,6200,l,m);const f=_.Co(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(Xz);var g=b.offlineId;if(typeof g!==_.Of||!g.length)throw e("Missing offline id.");if(yield d.get(g))iA.debug(Wz,g);else{var h=_.sl();d=new _.Hq;g=[];for(var k of c){const l=new k;_.vl(l.id())||(l.f(),_.xl(l),g.push(l))}k=null;try{k=yield _.ns(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
+ const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.I(_.F,4,4014));const m=_.ls(l.periods);yield jA(b,m,d)}catch(l){if(l instanceof _.I&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.ul.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
+ _.z("clpp.persistent.removeLicense",function(a){return _.x(function*(){var b=hA;if(_.Wg(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.Hq,c=gA(e.drmConfig,d),yield bA(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.Pn(c),yield Promise.all(e.sessionIds.map(f=>_.x(function*(){yield eA(c,f);iA.debug("successfully removed session with id",f)}))),yield b.delete(a)):iA.debug("No persistent DRM session found")}catch(e){throw iA.error("Failed to remove session"),
10
+ new _.I(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else iA.warn("Invalid offlineId")})});var hA=new kA,iA=new _.S(Yz);_.z("clpp.persistent.PersistentLicenseComponent",class extends _.Au{constructor(){super();this.g=new _.S(Yz)}id(){return _.Ne}l(a,b){const c=this;return _.x(function*(){const d=a.getConfiguration().drm;if(d){c.g.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield jA(d,b,e),a.trigger(new _.E(_.Md,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.g.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.x(function*(){b.g.debug(`Getting EME session IDs for ${a}`);
11
+ const c=hA;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.g.debug(`No offline session found for ${a}`);return[]}catch(d){return b.g.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
package/cl.playlist.js CHANGED
@@ -1,5 +1,5 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oz=function(a,b){return 0<=b&&b<a.a.length},pz=function(a){a.trigger(new _.C(_.df))},qz=class extends _.Dt{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.h=!1;this.j=this.pb.bind(this)}getPosition(){return this.f}Kg(){return this.a}Rc(){return 0<this.a.length&&oz(this,this.f)?this.a[this.f]:null}Lg(){const a=this.f+1;return 0<
2
- this.a.length&&oz(this,a)?this.a[a]:null}Vg(){return this.h}start(){this.h||(this.h=!0,this.m.on(_.Td,this.j),this.wd(this.f,!0))}stop(){this.h=!1;this.m.off(_.Td,this.j)}pb(){this.next()}next(){const a=this;return _.w(function*(){yield a.wd(Math.min(a.a.length-1,a.f+1))})}mh(){const a=this;return _.w(function*(){yield a.wd(Math.max(0,a.f-1))})}wd(a,b){b=void 0===b?!1:b;const c=this;return _.w(function*(){if(0<c.a.length&&oz(c,a)&&(b||c.f!==a)){c.f=a;var d=c.Rc();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
- c.trigger(new _.C(_.cf,{item:d})))}})}append(a){this.a.push(a);pz(this)}Tg(a,b){if(0<=b&&b<=this.a.length){const c=this.Rc();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));pz(this)}}remove(a){if(0<this.a.length&&oz(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);pz(this)}}clear(){this.stop();this.f=0;this.a=[];this.h=!1;pz(this)}};_.x("clpp.Playlist",qz);qz.prototype.clear=qz.prototype.clear;qz.prototype.remove=qz.prototype.remove;qz.prototype.insert=qz.prototype.Tg;
4
- qz.prototype.append=qz.prototype.append;qz.prototype.goTo=qz.prototype.wd;qz.prototype.previous=qz.prototype.mh;qz.prototype.next=qz.prototype.next;qz.prototype.onEnded=qz.prototype.pb;qz.prototype.stop=qz.prototype.stop;qz.prototype.start=qz.prototype.start;qz.prototype.isStarted=qz.prototype.Vg;qz.prototype.getUpcoming=qz.prototype.Lg;qz.prototype.getCurrent=qz.prototype.Rc;qz.prototype.getQueue=qz.prototype.Kg;qz.prototype.getPosition=qz.prototype.getPosition;qz.prototype.off=qz.prototype.off;
5
- qz.prototype.one=qz.prototype.one;qz.prototype.on=qz.prototype.on;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Tz=function(a,b){return 0<=b&&b<a.a.length},Uz=function(a){a.trigger(new _.E(_.cf))},Vz=class extends _.Ot{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.h=!1;this.j=this.qb.bind(this)}getPosition(){return this.f}Ng(){return this.a}Pc(){return 0<this.a.length&&Tz(this,this.f)?this.a[this.f]:null}Og(){const a=this.f+1;return 0<
2
+ this.a.length&&Tz(this,a)?this.a[a]:null}Yg(){return this.h}start(){this.h||(this.h=!0,this.m.on(_.Td,this.j),this.ud(this.f,!0))}stop(){this.h=!1;this.m.off(_.Td,this.j)}qb(){this.next()}next(){const a=this;return _.x(function*(){yield a.ud(Math.min(a.a.length-1,a.f+1))})}qh(){const a=this;return _.x(function*(){yield a.ud(Math.max(0,a.f-1))})}ud(a,b){b=void 0===b?!1:b;const c=this;return _.x(function*(){if(0<c.a.length&&Tz(c,a)&&(b||c.f!==a)){c.f=a;var d=c.Pc();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
+ c.trigger(new _.E(_.bf,{item:d})))}})}append(a){this.a.push(a);Uz(this)}Wg(a,b){if(0<=b&&b<=this.a.length){const c=this.Pc();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));Uz(this)}}remove(a){if(0<this.a.length&&Tz(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);Uz(this)}}clear(){this.stop();this.f=0;this.a=[];this.h=!1;Uz(this)}};_.z("clpp.Playlist",Vz);Vz.prototype.clear=Vz.prototype.clear;Vz.prototype.remove=Vz.prototype.remove;Vz.prototype.insert=Vz.prototype.Wg;
4
+ Vz.prototype.append=Vz.prototype.append;Vz.prototype.goTo=Vz.prototype.ud;Vz.prototype.previous=Vz.prototype.qh;Vz.prototype.next=Vz.prototype.next;Vz.prototype.onEnded=Vz.prototype.qb;Vz.prototype.stop=Vz.prototype.stop;Vz.prototype.start=Vz.prototype.start;Vz.prototype.isStarted=Vz.prototype.Yg;Vz.prototype.getUpcoming=Vz.prototype.Og;Vz.prototype.getCurrent=Vz.prototype.Pc;Vz.prototype.getQueue=Vz.prototype.Ng;Vz.prototype.getPosition=Vz.prototype.getPosition;Vz.prototype.off=Vz.prototype.off;
5
+ Vz.prototype.one=Vz.prototype.one;Vz.prototype.on=Vz.prototype.on;};f.call(g, window);
package/cl.sessions.js CHANGED
@@ -1,10 +1,10 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var jy="apiUrl config is missing",ky=function(a,b){a.j=a.j.filter(c=>c!==b)},ly=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},qy=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.r&&0===c||typeof c===_.Pf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){my(a,b<<3|2);b=new ny;for(let e=0;e<c.length;e++)d(b,c[e]);oy(a,b.length());py(a,b.end())}else my(a,
2
- b<<3|0),d(a,c)},oy=function(a,b){if(0<=b)my(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},ry=function(a,b,c){qy(a,b,c,(d,e)=>{oy(d,e)})},my=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},ty=function(a,b,c){qy(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=ly(e);sy(d,f,g)}}else{{const [f,g]=ly(e);sy(d,f,g)}}})},uy=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.r&&0===c||typeof c===_.Pf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
- 0;e<c.length;e++){my(a,b<<3|2);const f=new ny;d(f,c[e]);oy(a,f.length());py(a,f.end())}else my(a,b<<3|2),b=new ny,d(b,c),oy(a,b.length()),py(a,b.end())},vy=function(a,b,c){uy(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
- 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},py=function(a,b){a.a.push.apply(a.a,b)},wy=function(a,b,c){uy(a,b,c,(d,e)=>{py(d,e.a())})},xy=function(a,b,c){uy(a,b,c,(d,e)=>{py(d,e)})},sy=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},zy=function(a){const b=new yy;b.h=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},Dy=function(a){return _.w(function*(){if(!a.j&&!a.f){0===a.a.length&&Ay(a,new By);var b=()=>
5
- {};a.f=new Promise(c=>{b=c});try{const c=new Cy;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:_.tb,headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},Gy=function(a,b,c,d,e,f,g){const h=new Ey;h.headers=[new Fy("CL-BROWSER-NAME",b),new Fy("CL-BROWSER-VERSION",
6
- c),new Fy("CL-OS-FAMILY",d),new Fy("CL-OS-VERSION",e),new Fy("CL-SDK-NAME",f),new Fy("CL-SDK-NAME",f),new Fy("CL-SDK-VERSION",g)];Ay(a,h)},Ay=function(a,b){if(!a.j){var c=new Hy(a.w);c.sessionId=a.A;{var d=Date.now();const e=new Iy;e.h=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.h=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},Jy=function(a){return _.w(function*(){a.h&&(clearInterval(a.h),a.h=null);a.f&&(yield a.f);0<a.a.length&&(yield Dy(a),a.a=[]);a.j=!0})},Ky=function(a){_.w(function*(){a.g.info("Destroy the session and stop sending events.");
7
- _.ph(a.f);a.a=!1;const b=a.m.getNetworkEngine();b.ze(a.o);b.ed(a.j);ky(b,a.j);a.h&&(yield Jy(a.h),a.h=null)})},Sy=function(a){switch(a){case _.po:return Ly;case _.qo:return My;case _.ko:return Ny;case _.so:return Oy;case _.ro:return Py;case _.ho:return Qy;case _.oo:return Ry;default:return null}},Ty=function(a,b){a.g.debug("Sending event",b);Ay(a.h,b)},az=function(a,b){switch(a){case 1:return Uy;case 2:return b===_.t?Vy:b===_.p?Wy:b===_.F?Xy:b===_.be?Yy:Zy;case 3:return $y;default:return Zy}};var ny=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var bz=class{constructor(a,b,c,d){this.downloadId=a;this.h=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new ny;wy(a,1,this.downloadId);ry(a,2,this.h);wy(a,3,this.duration);ry(a,4,this.j);wy(a,5,this.f);return a.end()}getId(){return 4}};var cz=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new ny;ry(a,1,this.f);wy(a,2,this.downloadId);vy(a,3,this.url);wy(a,4,this.headers);vy(a,5,null);wy(a,6,null);wy(a,7,this.duration);ty(a,8,this.size);return a.end()}getId(){return 2}};var dz=class{constructor(a,b){this.h=a;this.f=b}a(){const a=new ny;ry(a,1,this.h);xy(a,2,this.f);return a.end()}};var ez=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new ny;ry(a,1,this.errorCode);ry(a,2,this.severity);vy(a,3,this.message);vy(a,4,this.f);wy(a,5,this.cause);return a.end()}getId(){return 7}};var Fy=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new ny;vy(a,1,this.key);vy(a,2,this.value);return a.end()}};var fz=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new ny;ry(a,1,this.code);ry(a,2,this.severity);wy(a,3,this.cause);return a.end()}getId(){return 12}};var gz=class{constructor(){this.data=null}a(){const a=new ny;xy(a,1,this.data);return a.end()}};var hz=class extends gz{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var Ey=class{constructor(){this.headers=[]}a(){const a=new ny;wy(a,1,this.headers);return a.end()}getId(){return 1}};var By=class{constructor(){}a(){return(new ny).end()}getId(){return 6}};var Hy=class{constructor(a){this.j=a;this.f=this.h=this.time=this.sessionId=null}a(){const a=new ny;wy(a,1,this.j);wy(a,2,this.sessionId);wy(a,3,this.time);ty(a,4,null);vy(a,5,null);ry(a,6,this.h);xy(a,7,this.f);return a.end()}};var Cy=class{constructor(){this.f=null;this.events=[]}a(){const a=new ny;xy(a,1,this.f);wy(a,2,this.events);return a.end()}};var Iy=class{constructor(){this.f=this.h=null}a(){const a=new ny;ty(a,1,this.h);ry(a,2,this.f);return a.end()}};var yy=class{constructor(){this.f=this.h=null}a(){const a=new ny;ty(a,1,this.h);ry(a,2,this.f);return a.end()}};var iz=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new hz;this.A=new hz;this.a=[];this.h=setInterval(()=>Dy(this),k);this.f=null;this.j=!1;Gy(this,b,c,d,e,f,g)}};var jz=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new ny;ry(a,1,this.previousState);ry(a,2,this.currentState);ry(a,3,this.reason);wy(a,4,null);wy(a,5,null);wy(a,6,null);return a.end()}getId(){return 5}};var nz=class extends _.Ru{constructor(){super();this.m=null;this.a=this.l=!1;this.f=new _.Rs;this.h=null;this.g=new _.R("clpp.sessions.SessionsPlugin");this.o=this.F.bind(this);this.j=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.De))||this.g.debug("Sessions plugin is loaded but not configured. Will do nothing.");if(this.l=b)b=a.getConfiguration().sessions,b.apiUrl?(this.g.debug(_.qa),this.g.info("Create a session and start sending events."),
8
- a=_.Ok(),this.h=new iz(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.da,b.apiUrl),this.f.on(this.m,_.Mf,this.B.bind(this)),this.f.on(this.m,_.Ef,this.A.bind(this)),this.f.on(this.m,_.Df,this.w.bind(this)),this.f.on(this.m,_.Ud,this.T.bind(this)),a=this.m.getNetworkEngine(),a.Od(this.o),a.sc(this.j),a.j.push(this.j)):(this.g.warn(jy),a.onError(new _.G(1,9,15E3,jy)))}onPlayerWillRelease(){Ky(this)}id(){return"sessions"}B(a){if(!this.a){a=a.detail;var b=
9
- a.currentState,c=new jz;c.previousState=Sy(a.previousState);c.currentState=Sy(b);Ty(this,c)}}A(){if(!this.a){var a=new jz;a.previousState=Sy(this.m.getState());a.currentState=kz;Ty(this,a);this.a=!0}}w(){if(this.a){var a=new jz;a.previousState=kz;a.currentState=Sy(this.m.getState());Ty(this,a);this.a=!1}}T(a){a=a.detail;var b=new fz;b=new ez(new dz(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.E?lz:mz;Ty(this,b)}F(a){const b=new hz;
10
- a.downloadId=b;const c=new cz(az(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new Fy(d,a.headers[d]));Ty(this,c)}C(a){var b=a.request.downloadId;b?(b=new bz(b,a.data.byteLength,zy(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new Fy(c,a.headers[c])),Ty(this,b)):this.g.warn("Download ID is missing on download completed event.")}};_.Hq(new class{create(){return new nz}});var mz=1,lz=2;var Ly=0,My=2,Ry=3,kz=5,Ny=6,Oy=8,Py=10,Qy=11;var Uy=0,Vy=1,Wy=2,Xy=3,Yy=4,$y=5,Zy=9;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Oy="apiUrl config is missing",Py=function(a,b){a.j=a.j.filter(c=>c!==b)},Qy=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},Vy=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Of&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){Ry(a,b<<3|2);b=new Sy;for(let e=0;e<c.length;e++)d(b,c[e]);Ty(a,b.length());Uy(a,b.end())}else Ry(a,
2
+ b<<3|0),d(a,c)},Ty=function(a,b){if(0<=b)Ry(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},Wy=function(a,b,c){Vy(a,b,c,(d,e)=>{Ty(d,e)})},Ry=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},Yy=function(a,b,c){Vy(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=Qy(e);Xy(d,f,g)}}else{{const [f,g]=Qy(e);Xy(d,f,g)}}})},Zy=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Of&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
+ 0;e<c.length;e++){Ry(a,b<<3|2);const f=new Sy;d(f,c[e]);Ty(a,f.length());Uy(a,f.end())}else Ry(a,b<<3|2),b=new Sy,d(b,c),Ty(a,b.length()),Uy(a,b.end())},$y=function(a,b,c){Zy(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
+ 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},Uy=function(a,b){a.a.push.apply(a.a,b)},az=function(a,b,c){Zy(a,b,c,(d,e)=>{Uy(d,e.a())})},bz=function(a,b,c){Zy(a,b,c,(d,e)=>{Uy(d,e)})},Xy=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},dz=function(a){const b=new cz;b.h=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},hz=function(a){return _.x(function*(){if(!a.j&&!a.f){0===a.a.length&&ez(a,new fz);var b=()=>
5
+ {};a.f=new Promise(c=>{b=c});try{const c=new gz;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:_.tb,headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},kz=function(a,b,c,d,e,f,g){const h=new iz;h.headers=[new jz("CL-BROWSER-NAME",b),new jz("CL-BROWSER-VERSION",
6
+ c),new jz("CL-OS-FAMILY",d),new jz("CL-OS-VERSION",e),new jz("CL-SDK-NAME",f),new jz("CL-SDK-NAME",f),new jz("CL-SDK-VERSION",g)];ez(a,h)},ez=function(a,b){if(!a.j){var c=new lz(a.w);c.sessionId=a.A;{var d=Date.now();const e=new mz;e.h=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.h=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},nz=function(a){return _.x(function*(){a.h&&(clearInterval(a.h),a.h=null);a.f&&(yield a.f);0<a.a.length&&(yield hz(a),a.a=[]);a.j=!0})},oz=function(a){_.x(function*(){a.g.info("Destroy the session and stop sending events.");
7
+ _.qh(a.f);a.a=!1;const b=a.m.getNetworkEngine();b.ze(a.o);b.cd(a.j);Py(b,a.j);a.h&&(yield nz(a.h),a.h=null)})},wz=function(a){switch(a){case _.wo:return pz;case _.xo:return qz;case _.ro:return rz;case _.zo:return sz;case _.yo:return tz;case _.oo:return uz;case _.vo:return vz;default:return null}},xz=function(a,b){a.g.debug("Sending event",b);ez(a.h,b)},Fz=function(a,b){switch(a){case 1:return yz;case 2:return b===_.w?zz:b===_.p?Az:b===_.G?Bz:b===_.ae?Cz:Dz;case 3:return Ez;default:return Dz}};var Sy=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var Gz=class{constructor(a,b,c,d){this.downloadId=a;this.h=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new Sy;az(a,1,this.downloadId);Wy(a,2,this.h);az(a,3,this.duration);Wy(a,4,this.j);az(a,5,this.f);return a.end()}getId(){return 4}};var Hz=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new Sy;Wy(a,1,this.f);az(a,2,this.downloadId);$y(a,3,this.url);az(a,4,this.headers);$y(a,5,null);az(a,6,null);az(a,7,this.duration);Yy(a,8,this.size);return a.end()}getId(){return 2}};var Iz=class{constructor(a,b){this.h=a;this.f=b}a(){const a=new Sy;Wy(a,1,this.h);bz(a,2,this.f);return a.end()}};var Jz=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new Sy;Wy(a,1,this.errorCode);Wy(a,2,this.severity);$y(a,3,this.message);$y(a,4,this.f);az(a,5,this.cause);return a.end()}getId(){return 7}};var jz=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new Sy;$y(a,1,this.key);$y(a,2,this.value);return a.end()}};var Kz=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new Sy;Wy(a,1,this.code);Wy(a,2,this.severity);az(a,3,this.cause);return a.end()}getId(){return 12}};var Lz=class{constructor(){this.data=null}a(){const a=new Sy;bz(a,1,this.data);return a.end()}};var Mz=class extends Lz{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var iz=class{constructor(){this.headers=[]}a(){const a=new Sy;az(a,1,this.headers);return a.end()}getId(){return 1}};var fz=class{constructor(){}a(){return(new Sy).end()}getId(){return 6}};var lz=class{constructor(a){this.j=a;this.f=this.h=this.time=this.sessionId=null}a(){const a=new Sy;az(a,1,this.j);az(a,2,this.sessionId);az(a,3,this.time);Yy(a,4,null);$y(a,5,null);Wy(a,6,this.h);bz(a,7,this.f);return a.end()}};var gz=class{constructor(){this.f=null;this.events=[]}a(){const a=new Sy;bz(a,1,this.f);az(a,2,this.events);return a.end()}};var mz=class{constructor(){this.f=this.h=null}a(){const a=new Sy;Yy(a,1,this.h);Wy(a,2,this.f);return a.end()}};var cz=class{constructor(){this.f=this.h=null}a(){const a=new Sy;Yy(a,1,this.h);Wy(a,2,this.f);return a.end()}};var Nz=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new Mz;this.A=new Mz;this.a=[];this.h=setInterval(()=>hz(this),k);this.f=null;this.j=!1;kz(this,b,c,d,e,f,g)}};var Oz=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new Sy;Wy(a,1,this.previousState);Wy(a,2,this.currentState);Wy(a,3,this.reason);az(a,4,null);az(a,5,null);az(a,6,null);return a.end()}getId(){return 5}};var Sz=class extends _.av{constructor(){super();this.m=null;this.a=this.l=!1;this.f=new _.bt;this.h=null;this.g=new _.S("clpp.sessions.SessionsPlugin");this.o=this.F.bind(this);this.j=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.Ce))||this.g.debug("Sessions plugin is loaded but not configured. Will do nothing.");if(this.l=b)b=a.getConfiguration().sessions,b.apiUrl?(this.g.debug(_.qa),this.g.info("Create a session and start sending events."),
8
+ a=_.Rk(),this.h=new Nz(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.da,b.apiUrl),this.f.on(this.m,_.Lf,this.B.bind(this)),this.f.on(this.m,_.Df,this.A.bind(this)),this.f.on(this.m,_.Cf,this.w.bind(this)),this.f.on(this.m,_.r,this.T.bind(this)),a=this.m.getNetworkEngine(),a.Od(this.o),a.sc(this.j),a.j.push(this.j)):(this.g.warn(Oy),a.onError(new _.I(1,9,15E3,Oy)))}onPlayerWillRelease(){oz(this)}id(){return"sessions"}B(a){if(!this.a){a=a.detail;var b=a.currentState,
9
+ c=new Oz;c.previousState=wz(a.previousState);c.currentState=wz(b);xz(this,c)}}A(){if(!this.a){var a=new Oz;a.previousState=wz(this.m.getState());a.currentState=Pz;xz(this,a);this.a=!0}}w(){if(this.a){var a=new Oz;a.previousState=Pz;a.currentState=wz(this.m.getState());xz(this,a);this.a=!1}}T(a){a=a.detail;var b=new Kz;b=new Jz(new Iz(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.F?Qz:Rz;xz(this,b)}F(a){const b=new Mz;a.downloadId=b;
10
+ const c=new Hz(Fz(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new jz(d,a.headers[d]));xz(this,c)}C(a){var b=a.request.downloadId;b?(b=new Gz(b,a.data.byteLength,dz(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new jz(c,a.headers[c])),xz(this,b)):this.g.warn("Download ID is missing on download completed event.")}};_.Qq(new class{create(){return new Sz}});var Rz=1,Qz=2;var pz=0,qz=2,vz=3,Pz=5,rz=6,sz=8,tz=10,uz=11;var yz=0,zz=1,Az=2,Bz=3,Cz=4,Ez=5,Dz=9;};f.call(g, window);
package/cl.simid.js CHANGED
@@ -1,13 +1,13 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Tx="No surface found. Can not attach frame!",Ux="SIMID:Media:timeupdate",Vx="Starting creative",Wx=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),args:c}},Zx=function(a,b){return new Promise((c,d)=>{new Xx(a.j,c,d,b);Yx(a,b)})},$x=function(a){const b=Wx(a,"SIMID:Player:startCreative",void 0);Zx(a,b).then(()=>{var c=a.f;c.g.info(Vx);c.m.trigger(new _.C(_.Gf));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.g.error("Error while starting creative",
2
- c)})},by=function(a,b){_.w(function*(){a.h=b.sessionId;ay(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
- !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=Wx(a,"SIMID:Player:init",d);var e=Zx(a,f)}yield e;a.g.info("Player Init acknowledged");a.f.g.info("SIMID Player initialized")}catch(f){a.g.error("Error while initializing",f),a.f.g.error("Error while initializing SIMID player: ",f),a.unload()}})},ay=function(a,b){Yx(a,Wx(a,"resolve",{messageId:b.messageId,
4
- value:void 0}))},Yx=function(a,b){a.h?(b.type!==Ux&&a.g.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn(`WARNING: no session available to send message '${b.type}'`)},cy=function(a,b,c){return new ResizeObserver(()=>{if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
- e=Wx(d,"SIMID:Player:resize",e);Yx(d,e)}})},dy=function(a,b){a.g.info("SIMID Session created");a.a=b},ey=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
- "";a.h=!1;a.m.trigger(new _.C(_.Hf))},fy=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},gy=class{constructor(a){this.f=a;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";this.a.style.border=_.Ce;this.a.style.backgroundColor="transparent";this.a.style.transition="opacity .5s";this.a.style.transitionDelay=".5s";this.a.style.pointerEvents=
7
- _.Ce;this.a.style.overflow=_.$d;this.a.classList.add(_.fd);this.o=b=>{if(b.source===this.a.contentWindow&&(b=(b=b.data)?typeof b===_.Pf?JSON.parse(b):b:null))if(b.type)switch(this.g.info(`Received message [${b.messageId}] '${b.type}':`,b.args),b.type){case "createSession":by(this,b);break;case "resolve":b=b.args;var c=this.j.get(b.messageId);c&&c.resolve(b);break;case "reject":b=b.args;(c=this.j.get(b.messageId))&&c.reject(b);break;case "SIMID:Creative:requestResize":c=this.f;var d=b.args;c.g.info("Creative requested resize",
8
- d);if(c.m&&c.m.getSurface()&&c.m.getSurface().getMedia()&&d.mediaDimensions){c.h?c.m.getSurface().getMedia().style.transition="":(c.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",c.h=!0);const e=fy(c,d.mediaDimensions);c.m.getSurface().getMedia().style.left=e.left;c.m.getSurface().getMedia().style.top=e.top;c.m.getSurface().getMedia().style.width=e.width;c.m.getSurface().getMedia().style.height=e.height}d.creativeDimensions&&(d=fy(c,d.creativeDimensions),c.a.a.style.left=
9
- d.left,c.a.a.style.top=d.top,c.a.a.style.width=d.width,c.a.a.style.height=d.height);ay(this,b)}else this.g.warn("WARNING: received message without 'type' property")};this.g=new _.R("clpp.simid.SimidPlayer");dy(this.f,this)}load(a){window.addEventListener(_.ve,this.o);this.h="";this.l=0;const b=this.f.url();this.g.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)}unload(){ey(this.f);this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.ve,
10
- this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},Xx=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.h=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.j(a)}};var iy=class extends _.Ru{constructor(){super();this.g=new _.R("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new hy(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length)if(this.l=b.simid.creatives,this.g.info(`Setting up SIMID plugin for ${this.l.length} creatives`),
11
- b=this.m.getSurface()){this.g.info("Creating new session");this.a=new gy(this.h);var c=b.getContainer();this.j=cy(this,c,b);this.j.observe(c);a.on(_.Wf,this.w)}else this.g.warn(Tx)}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&($x(this.a),this.o=!0,this.g.info(Vx)),
12
- c&&(c=this.a,Yx(c,Wx(c,Ux,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(Tx),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.Wf,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))}},hy=class{constructor(a){this.m=a;this.a=null;this.g=new _.R("clpp.simid.Loader");
13
- this.h=!1;this.f=null}release(){this.g.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.G(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.G(1,10,10100,"No surface");return a}url(){return this.f?this.f.url:""}};_.Hq(new class{create(){return new iy}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var xy="No surface found. Can not attach frame!",yy="SIMID:Media:timeupdate",zy="Starting creative",Ay=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),args:c}},Dy=function(a,b){return new Promise((c,d)=>{new By(a.j,c,d,b);Cy(a,b)})},Ey=function(a){const b=Ay(a,"SIMID:Player:startCreative",void 0);Dy(a,b).then(()=>{var c=a.f;c.g.info(zy);c.m.trigger(new _.E(_.Ff));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.g.error("Error while starting creative",
2
+ c)})},Gy=function(a,b){_.x(function*(){a.h=b.sessionId;Fy(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
+ !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=Ay(a,"SIMID:Player:init",d);var e=Dy(a,f)}yield e;a.g.info("Player Init acknowledged");a.f.g.info("SIMID Player initialized")}catch(f){a.g.error("Error while initializing",f),a.f.g.error("Error while initializing SIMID player: ",f),a.unload()}})},Fy=function(a,b){Cy(a,Ay(a,"resolve",{messageId:b.messageId,
4
+ value:void 0}))},Cy=function(a,b){a.h?(b.type!==yy&&a.g.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn(`WARNING: no session available to send message '${b.type}'`)},Hy=function(a,b,c){return new ResizeObserver(()=>{if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
+ e=Ay(d,"SIMID:Player:resize",e);Cy(d,e)}})},Iy=function(a,b){a.g.info("SIMID Session created");a.a=b},Jy=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
+ "";a.h=!1;a.m.trigger(new _.E(_.Gf))},Ky=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},Ly=class{constructor(a){this.f=a;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";this.a.style.border=_.Be;this.a.style.backgroundColor="transparent";this.a.style.transition="opacity .5s";this.a.style.transitionDelay=".5s";this.a.style.pointerEvents=
7
+ _.Be;this.a.style.overflow=_.Zd;this.a.classList.add(_.fd);this.o=b=>{if(b.source===this.a.contentWindow&&(b=(b=b.data)?typeof b===_.Of?JSON.parse(b):b:null))if(b.type)switch(this.g.info(`Received message [${b.messageId}] '${b.type}':`,b.args),b.type){case "createSession":Gy(this,b);break;case "resolve":b=b.args;var c=this.j.get(b.messageId);c&&c.resolve(b);break;case "reject":b=b.args;(c=this.j.get(b.messageId))&&c.reject(b);break;case "SIMID:Creative:requestResize":c=this.f;var d=b.args;c.g.info("Creative requested resize",
8
+ d);if(c.m&&c.m.getSurface()&&c.m.getSurface().getMedia()&&d.mediaDimensions){c.h?c.m.getSurface().getMedia().style.transition="":(c.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",c.h=!0);const e=Ky(c,d.mediaDimensions);c.m.getSurface().getMedia().style.left=e.left;c.m.getSurface().getMedia().style.top=e.top;c.m.getSurface().getMedia().style.width=e.width;c.m.getSurface().getMedia().style.height=e.height}d.creativeDimensions&&(d=Ky(c,d.creativeDimensions),c.a.a.style.left=
9
+ d.left,c.a.a.style.top=d.top,c.a.a.style.width=d.width,c.a.a.style.height=d.height);Fy(this,b)}else this.g.warn("WARNING: received message without 'type' property")};this.g=new _.S("clpp.simid.SimidPlayer");Iy(this.f,this)}load(a){window.addEventListener(_.ue,this.o);this.h="";this.l=0;const b=this.f.url();this.g.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)}unload(){Jy(this.f);this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.ue,
10
+ this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},By=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.h=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.j(a)}};var Ny=class extends _.av{constructor(){super();this.g=new _.S("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new My(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length)if(this.l=b.simid.creatives,this.g.info(`Setting up SIMID plugin for ${this.l.length} creatives`),
11
+ b=this.m.getSurface()){this.g.info("Creating new session");this.a=new Ly(this.h);var c=b.getContainer();this.j=Hy(this,c,b);this.j.observe(c);a.on(_.Vf,this.w)}else this.g.warn(xy)}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(Ey(this.a),this.o=!0,this.g.info(zy)),
12
+ c&&(c=this.a,Cy(c,Ay(c,yy,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(xy),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.Vf,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))}},My=class{constructor(a){this.m=a;this.a=null;this.g=new _.S("clpp.simid.Loader");
13
+ this.h=!1;this.f=null}release(){this.g.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.I(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.I(1,10,10100,"No surface");return a}uf(){return this.a}url(){return this.f?this.f.url:""}};_.Qq(new class{create(){return new Ny}});};f.call(g, window);