@castlabs/prestoplay 6.23.1 → 6.25.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.
- package/CHANGELOG.md +35 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +7 -7
- package/cjs/cl.cast.js +116 -116
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +607 -591
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +88 -86
- package/cjs/cl.externs.js +105 -54
- package/cjs/cl.freewheel.js +25 -24
- package/cjs/cl.hls.js +77 -71
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +24 -23
- package/cjs/cl.mse.js +352 -342
- package/cjs/cl.muxdata.js +15 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +15 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.sessions.js +16 -16
- package/cjs/cl.simid.js +15 -15
- package/cjs/cl.smooth.js +72 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +72 -72
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +12 -12
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +4 -4
- package/cjs/cl.youbora.js +37 -37
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +88 -88
- package/cl.conviva.js +27 -27
- package/cl.core.js +491 -478
- package/cl.crypto.js +9 -9
- package/cl.dash.js +82 -80
- package/cl.externs.js +105 -54
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +79 -74
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +18 -17
- package/cl.mse.js +310 -306
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.sessions.js +10 -10
- package/cl.simid.js +13 -13
- package/cl.smooth.js +60 -59
- package/cl.thumbnails.js +19 -19
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +14 -14
- package/cl.vtt.js +12 -12
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +28 -28
- package/package.json +1 -1
- package/typings.d.ts +54 -25
package/cl.htmlcue.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},
|
|
3
|
-
function(a,b){return 1>Math.abs(a-b)||a>b},
|
|
4
|
-
d-e)},
|
|
5
|
-
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return
|
|
6
|
-
_.t)switch(b){case _.
|
|
7
|
-
|
|
8
|
-
a.viewportAnchorUnits;if(d===_.
|
|
9
|
-
`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},
|
|
10
|
-
a.o=[]}},
|
|
11
|
-
if(b||a.J!==c&&a.m.getState()===_.
|
|
12
|
-
_.
|
|
13
|
-
c.a.appendChild(d)}}}}},
|
|
14
|
-
b){const c=
|
|
15
|
-
e[1];var g=e[3];var h=
|
|
16
|
-
"\x26nbsp;":"\u00a0"};var
|
|
17
|
-
_.
|
|
18
|
-
!this.f.region.displayAlign){e=
|
|
19
|
-
100*a)}
|
|
20
|
-
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=
|
|
21
|
-
_.
|
|
22
|
-
b=c;f*=b;break a;default:throw Error(
|
|
23
|
-
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],
|
|
24
|
-
this.G=new _.
|
|
25
|
-
this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;
|
|
26
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var fU="Unsupported unit",gU="clpp-text-plain",hU="clpp-text-ttml",iU="clpp.htmlcue.HtmlTextDisplayer",jU="initial",kU=function(a){return _.ti(a,{Hf:(b,c)=>b.Mc(c)})},lU=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},mU=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},nU=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
|
|
2
|
+
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},pU=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>oU[c]);return a},rU=function(a,b){qU(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{qU(a,c)})},qU=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},sU=function(a,b){return 0===a?"0":a+b},tU=function(a,b){return 1>Math.abs(a-b)||a<b},uU=function(a,b){return a<b&&1<Math.abs(a-b)},vU=function(a,b){return a>b&&1<Math.abs(a-b)},wU=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},yU=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new xU(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},zU=function(a){return new xU(a.left,a.f,a.top,a.a,a.height,a.width)},AU=function(a,b){return b.some(c=>uU(a.left,c.f)&&vU(a.f,c.left)&&uU(a.top,c.a)&&vU(a.a,c.top))},BU=function(a,b){return wU(a.top,b.top)&&tU(a.a,b.a)&&wU(a.left,b.left)&&tU(a.f,b.f)},CU=function(a,b,c){switch(c){case "+x":return uU(a.left,b.left);case "-x":return vU(a.f,b.f);case "+y":return uU(a.top,b.top);case "-y":return vU(a.a,b.a);default:throw Error("Unknown axis");}},DU=function(a){return a.f.writingMode===_.Wt},EU=
|
|
5
|
+
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return DU(a)?b:c},FU=function(a){switch(a.f.writingMode){case _.Wt:return"horizontal-tb";case _.Fg:return _.Fg;case _.Gg:return _.Gg;default:throw Error("Unknown writing mode");}},GU=function(a){switch(a.f.positionAlign){case _.xe:return _.ue;case "auto":case _.ld:return _.Vt;case _.Be:return _.Mf}return a.f.textAlign},HU=function(a,b){if(typeof a.f.position===_.t&&typeof a.f.size===
|
|
6
|
+
_.t)switch(b){case _.xe:return a.f.position;case "auto":case _.ld:return a.f.position-a.f.size/2;case _.Be:return a.f.position-a.f.size}return 0},IU=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.ue:case _.ue:return _.xe;case _.Vt:return _.ld;case _.Mf:case _.Mf:return _.Be}return a.f.positionAlign},LU=function(a,b,c){return(JU(a)||KU(a))&&_.th(c)?sU(c,_.Ff):JU(a)&&_.B(c)?sU(0,_.Ff):DU(a)&&_.th(b)?sU(b,"%"):jU},MU=function(a,b,c){return DU(a)&&_.th(c)?sU(c,_.Ff):(JU(a)||KU(a))&&_.th(b)?
|
|
7
|
+
sU(b,"%"):jU},KU=function(a){return a.f.writingMode===_.Gg},JU=function(a){return a.f.writingMode===_.Fg},NU=function(a,b){if(a.j)switch(b.writingMode){case _.Wt:return["-y"];case _.Fg:return["+x"];case _.Gg:return["-x"]}a=[];switch(b.writingMode){case _.Wt:a=["+y","-y"];break;case _.Fg:a=["+x","-x"];break;case _.Gg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},OU=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=yU(a.l.a)},PU=function(a,b,c){a=a.f;const d=
|
|
8
|
+
a.viewportAnchorUnits;if(d===_.cu)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(fU);},RU=function(a,b,c,d){const e=document.createElement(_.eg),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);QU(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},SU=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,
|
|
9
|
+
`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},TU=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);return c},UU=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.o=[]}},QU=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.g.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},VU=function(a){a=_.mh(a.htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},aV=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();
|
|
11
|
+
if(b||a.J!==c&&a.m.getState()===_.kp)if(a.J=c,c=WU(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,XU(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.Kt(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Ng:g="clpp-text-vtt";break;case _.rg:g=hU;break;case _.Ut:g=gU}g&&!f.classList.contains(g)&&
|
|
12
|
+
_.Ep(f,g);f=yU(c.a.a);if(0===f.width||0===f.height)c.g.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{qU({fontSize:YU(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Ng;var h=d.payloadType===_.rg;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new ZU(d.region,{}),c.B.set(d.region.id,f),c.a.appendChild(f)));d=new $U(d,c.L,e);f?f.appendChild(d):
|
|
13
|
+
c.a.appendChild(d)}}}}},bV=function(a){XU(a);a.J=null;a.o=null;a.f=[]},cV=function(a,b){return a.startTime<=b&&a.endTime>b},WU=function(a,b){var c=mU(a.f,d=>cV(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&cV(a.f[d-1],b);)d--;for(;c+1<a.f.length&&cV(a.f[c+1],b);)c++;return{start:d,end:c}}},XU=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(hU);b.classList.remove(gU);a=a.a;OU(a.h);a.l=[]}},YU=function(a,
|
|
14
|
+
b){const c=yU(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.t&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},gV=class{parse(a){a={input:a};const b=_.Gp(_.Sd),c=[];let d=b;for(var e;null!==(e=nU(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=
|
|
15
|
+
e[1];var g=e[3];var h=dV[f];h?(h=_.Gp(h),(f=eV[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||fV[g.localName]&&fV[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(pU(e)));return b}},dV={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},eV={v:"voice",lang:"lang"},fV={rt:"ruby"},oU={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
|
|
16
|
+
"\x26nbsp;":"\u00a0"};var xU=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var hV=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var $U=class extends hV{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.h=!!this.f.backgroundImage;this.C=c}A(){return!this.h&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.h)_.Ep(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.rg){var c=_.Gp(_.Sd);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.Ng?b=(new gV).parse(b.payload):(c=_.Gp(_.Sd),c.textContent=b.payload,b=c);_.Ep(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.Ep(b,d);qU({writingMode:FU(this)},b);var d=b;this.a.appendChild(d);_.Ep(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.Ep(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.Xt,this.f.line=DU(this)?-1:0);e=FU(this);qU({writingMode:e,webkitWritingMode:e,direction:jU,textAlign:GU(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=HU(this,IU(this));qU({position:"absolute",left:LU(this,e,null),right:KU(this)&&_.B(null)?sU(0,_.Ff):jU,top:MU(this,e,null),width:DU(this)?sU(this.f.size,"%"):jU,height:JU(this)||KU(this)?sU(this.f.size,"%"):jU},this.a);b=this.f;a=DU(this)?a.height:a.width;c=EU(this);if(b.lineInterpretation===_.Xt){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.ld:g-=f/2;break;case _.ie:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}KU(this)&&(f=a-f-c);a=f;qU({left:LU(this,e,a),right:KU(this)&&_.B(a)?sU(0,_.Ff):jU,top:MU(this,e,a)},this.a)}rU(this.C,d)}}o(){return _.Gp(_.Sd)}};var iV=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=yU(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.pe;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=yU(a.a);var d=NU(this,a.f),e=EU(a);const g=zU(c);let h=null,k=0;for(const l of d){for(;CU(c,this.a,l)||BU(c,this.a)&&AU(c,this.h);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||BU(c,this.a))break a;
|
|
20
|
+
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=zU(c),k=d);c=zU(g)}c=h||g}qU({top:sU(c.top-this.a.top,_.Ff),bottom:sU(this.a.a-c.a,_.Ff),left:sU(c.left-this.a.left,_.Ff),right:sU(this.a.f-c.f,_.Ff),height:sU(c.height,_.Ff),width:sU(c.width,_.Ff)},a.a)}b.style.visibility="visible";this.h.push(yU(a.a))}};var jV=class extends hV{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new iV(this);this.j=!0}o(){const a=_.Gp(_.Sd);_.Ep(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){OU(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var ZU=class extends jV{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.cu:b=b.width/100*a.width;break a;default:throw Error(fU);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.cu)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(fU);d=a.height;const e=PU(this,d,a.height);qU(this.B,this.a);qU({left:sU(c,_.Ff),top:sU(e,_.Ff),width:sU(b,
|
|
21
|
+
_.Ff),height:sU(d,_.Ff)},this.a);this.f.writingMode&&qU({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&qU({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.Ep(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.cu:f=f.height/100*a.height;break a;case 2:f=f.height;c=new $U(new _.$t(0,1,"Lorem ipsum",_.Ut),{},{});b=c.a;this.a.appendChild(b);c.init(yU(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(fU);}a=PU(this,f,a.height);qU({top:sU(a,_.Ff),height:sU(f,_.Ff)},this.a);this.h=new iV(this,!0);this.j=!0}getId(){return this.f.id}};var kV=class{constructor(a,b){this.g=new _.S("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=RU(this,this.h,this.j);this.f=RU(this,this.h,this.j,!0);this.f.disabled=!0;this.g.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=SU(this,a);if(TU(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.g.debug(`Added CSS rule ${b}`)}catch(c){this.g.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.g.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],UU(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.g.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var lV=class extends _.Wv{constructor(a){super(a);this.g=new _.S(iU);this.m=a;this.L=VU(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new kV(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new jV(null,"clpp-text-container",{});this.A=new _.Pv(a.getSurface(),this.S.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.g.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
|
|
24
|
+
this.G=new _.Gk(()=>{aV(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=lU(this.f,kU(a));this.o=null;aV(this,!1)}}h(){null==this.j||aV(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(bV(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
|
|
25
|
+
this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;aV(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Eb(.25),this.L.enableResizeObserver&&this.A.start(),aV(this,!0)):(this.G.stop(),this.A.stop(),bV(this)))}S(){aV(this,!0)}};_.z(iU,lV);lV.prototype.setTextVisibility=lV.prototype.setTextVisibility;lV.prototype.isTextVisible=lV.prototype.isTextVisible;lV.prototype.remove=lV.prototype.remove;lV.prototype.destroy=lV.prototype.destroy;
|
|
26
|
+
lV.prototype.append=lV.prototype.append;var mV=class{a(a){return!!a.enableHtmlCue&&!_.Wk()}create(a){return new lV(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Kv{f(){_.Ro(_.qe,new mV)}a(){_.Po.has(_.qe)&&(_.Po.delete(_.qe),_.Qo.info("Removed factory: 'html'"))}id(){return _.fg}});};f.call(g, window);
|
package/cl.ima.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
_.
|
|
3
|
-
c.on(b,d.FIRST_QUARTILE,a.
|
|
4
|
-
{ad:new W(c,a.
|
|
5
|
-
a.
|
|
6
|
-
this.f.
|
|
7
|
-
1}
|
|
8
|
-
|
|
9
|
-
W.prototype.
|
|
10
|
-
W.prototype.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this
|
|
15
|
-
a.
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var MT="clpp.ima.AdsManagerFactory",NT=function(a,b){return new Promise(c=>{if(a.readyState===HTMLMediaElement.HAVE_NOTHING&&0===a.networkState)c();else b.one(a,"emptied",c)})},OT=function(a){a=a.K;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.t&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.$c?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.t&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&
|
|
2
|
+
(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.t&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===_.$c&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},PT=function(a){return!1===a.K.disableCustomPlayback&&a.a.isCustomPlaybackUsed()},QT=function(a){const b=a.a,c=a.A,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.Aa.bind(a));c.on(b,d.LOADED,a.Y.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.qc.bind(a));c.on(b,
|
|
3
|
+
d.STARTED,a.ba.bind(a));c.on(b,d.LOG,a.Oa.bind(a));c.on(b,d.AD_PROGRESS,a.$.bind(a));c.on(b,d.AD_BUFFERING,a.Ha.bind(a));c.on(b,d.FIRST_QUARTILE,a.U.bind(a));c.on(b,d.MIDPOINT,a.pb.bind(a));c.on(b,d.THIRD_QUARTILE,a.ha.bind(a));c.on(b,d.PAUSED,a.Pb.bind(a));c.on(b,d.RESUMED,a.Qb.bind(a));c.on(b,d.CLICK,a.S.bind(a));c.on(b,d.SKIPPED,a.da.bind(a));c.on(b,d.IMPRESSION,a.W.bind(a));c.on(b,d.COMPLETE,a.Za.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.tc.bind(a))},RT=function(a,b){const c=b?a.va.create(b.getErrorCode()):
|
|
4
|
+
null;a.m.onError(new _.I(1,9,10003,{errorType:c},b))},ST=function(a){return _.x(function*(){yield a.m.detach();var b=a.m;b.a&&b.a.stopForwardingEventsTo(b)})},TT=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.H,a.G)});a.m.trigger(new _.D(b,d))},UT=function(a){a.C=null;TT(a,_.Cc);a.m.getSurface().hide(a.O)},VT=function(a){return _.x(function*(){yield NT(a.f,a.A)})},WT=function(a){return _.x(function*(){return new Promise(b=>{a.A.on(a.f,_.Ef,()=>{a.m.getState()===_.jp&&b()})})})},XT=
|
|
5
|
+
function(a){_.Fp(a.f,{visibility:"visible"})},ZT=function(a){return _.x(function*(){a.R.initialize();const b=!!a.m.getConfiguration().muted;(yield a.L.canPlay(b))||PT(a)?(PT(a)&&(yield ST(a)),YT(a)):(TT(a,_.Yc),a.g.warn(_.ja))})},$T=function(a,b){return _.x(function*(){a.R.initialize();yield b.play();YT(a)})},YT=function(a){a.a.init(a.f.offsetWidth,a.f.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.M=!0},aU=function(){return!window.google||!google.ima||!google.ima.AdsLoader},W=class{constructor(a,
|
|
6
|
+
b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.h=c}sb(){return"Google IMA SDK"}tb(){return google.ima.VERSION}xb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}Sb(){return""}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getPosition(){return 0}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Vb(){return this.f?
|
|
7
|
+
this.f.getIsBumper():!1}ub(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Se&&typeof b[d].clickThroughUrl===_.cg);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}ib(){return this.a.getVastMediaWidth()}hb(){return this.a.getVastMediaHeight()}Ta(){return this.a.getVastMediaBitrate()}Ua(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Ib(){return this.f?this.f.getTimeOffset():0}wb(){return this.f?this.f.getAdPosition():
|
|
8
|
+
1}jb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}canSeek(){return!1}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}Ub(){return null}};W.prototype.getVideoElement=W.prototype.Ub;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.canSeek=W.prototype.canSeek;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;
|
|
9
|
+
W.prototype.getSequenceLength=W.prototype.jb;W.prototype.getPositionInSequence=W.prototype.wb;W.prototype.getPodTimeOffset=W.prototype.Ib;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ua;W.prototype.getMediaBitrate=W.prototype.Ta;W.prototype.getMediaHeight=W.prototype.hb;W.prototype.getMediaWidth=W.prototype.ib;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.ub;W.prototype.isBumper=W.prototype.Vb;
|
|
10
|
+
W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getPosition=W.prototype.getPosition;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;W.prototype.getSourceId=W.prototype.Sb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;
|
|
11
|
+
W.prototype.getTechnology=W.prototype.xb;W.prototype.getAdManagerVersion=W.prototype.tb;W.prototype.getAdManagerName=W.prototype.sb;var bU=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var cU=class{constructor(a){this.a=a}getCuePoints(){return this.a}Lb(){return 0<=this.a.indexOf(0)||0===this.a.length}Kb(){return 0<=this.a.indexOf(-1)}};cU.prototype.hasPostroll=cU.prototype.Kb;cU.prototype.hasPreroll=cU.prototype.Lb;cU.prototype.getCuePoints=cU.prototype.getCuePoints;var dU=class{constructor(a){var b=a.fd("ima");if(!b)throw Error("IMA plugin not created.");var c=b.Nc(),d=b.h;b=b.a;if(!c||!d||!b)throw Error("IMA plugin not initialized.");const e=a.getSurface().getMedia();if(!e)throw Error("Missing media element.");this.m=a;this.f=e;a=this.m.getConfiguration();a=_.mh(a.ima||{});this.K=a=_.lh({disableCustomPlayback:!1},a);this.O=c;this.R=d;this.B=b;this.L=new _.Rv;this.g=new _.S("clpp.ima");this.l=this.a=null;this.j=new _.rn;this.M=!1;this.A=new _.St;this.va=new bU;
|
|
12
|
+
this.C=null;this.J=this.G=this.H=!1;this.I=this.F=null;c=this.A;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.B,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.nc.bind(this));c.on(this.B,d,this.lc.bind(this));c.on(this.m,_.je,this.oc.bind(this))}nc(a){this.a=a.getAdsManager(this.f,OT(this));this.a.isCustomPlaybackUsed()&&!PT(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,9,10002)),this.h()):(this.l=new _.Pv(this.m.getSurface(),
|
|
13
|
+
(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.F=new cU(a),this.m.trigger(new _.D(_.Fc,{adsTimeline:this.F})),QT(this));this.j.resolve()}lc(a){RT(this,a.getError());this.j.resolve()}qc(a){const b=this;return _.x(function*(){b.J=!0;PT(b)?(b.I=b.m.getPosition(),yield ST(b)):(yield b.m.pause(),_.Fp(b.f,{visibility:_.pe}));TT(b,_.jc,a);b.l.start()})}Aa(){const a=this;return _.x(function*(){PT(a)&&(yield NT(a.f,a.A));a.a.start()})}Y(a){a.getAd().isLinear()?
|
|
14
|
+
TT(this,_.tc,a):(this.a.discardAdBreak(),this.H||(this.H=!0,this.m.play()))}ba(a){this.C=a.getAd().getDuration();TT(this,_.zc,a);this.m.getSurface().show(this.O)}Oa(a){a=a.getAdData();RT(this,a?a.adError:null);UT(this)}$(a){TT(this,_.wc,a)}Ha(a){TT(this,_.lc,a)}U(a){TT(this,_.oc,a)}pb(a){TT(this,_.uc,a)}ha(a){TT(this,_.Dc,a)}Pb(a){TT(this,_.vc,a)}Qb(a){TT(this,_.xc,a)}S(a){this.pause();TT(this,_.mc,a)}da(a){TT(this,_.yc,a);UT(this)}W(a){TT(this,_.sc,a)}Za(a){TT(this,_.nc,a);UT(this)}tc(){const a=
|
|
15
|
+
this;return _.x(function*(){a.H=!0;if(PT(a)&&null!==a.I)yield VT(a),yield _.fs(a.m),!a.G&&a.I&&(yield WT(a),yield a.m.seek(a.I));else{if(!a.J)return a.m.play();XT(a)}a.J=!1;a.l&&a.l.stop();a.G||(yield a.m.play());TT(a,_.kc)})}oc(){this.G=!0;this.B.contentComplete()}load(){const a=this;return _.x(function*(){var b=a.m;const c=a.K;try{if(typeof c.adTagUrl!==_.cg)throw new _.I(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.j.resolve(),a.j}if(!c.adTagUrl)return a.j.resolve(),a.j;
|
|
16
|
+
b=yield a.L.canPlay(!1);const d=yield a.L.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.B.getSettings().setAutoPlayAdBreaks(!1);a.B.requestAds(e);return a.j})}start(a){const b=this;return _.x(function*(){b.a&&b.F&&!b.M?b.F.Lb()?yield ZT(b):yield $T(b,a):yield a.play()})}w(){}o(){return!0}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&
|
|
17
|
+
this.a.setVolume(a)}getPosition(){if(!this.a||null===this.C)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.C-a}h(){this.a&&(this.a.destroy(),this.a=null);XT(this);this.A.release();this.l&&(this.l.stop(),this.l=null);return Promise.resolve()}};dU.prototype.getPosition=dU.prototype.getPosition;dU.prototype.setVolume=dU.prototype.setVolume;dU.prototype.getVolume=dU.prototype.getVolume;dU.prototype.skip=dU.prototype.skip;dU.prototype.pause=dU.prototype.pause;dU.prototype.resume=dU.prototype.resume;var eU=class extends _.Zv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(aU())return a.onError(new _.I(1,9,1E4));this.f=_.Dp(_.Sd,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.h=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.h);this.a.getSettings().setPlayerType(_.qa);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
|
|
18
|
+
(this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}qh(){return this.a}oh(){return this.h}Nc(){return this.f}id(){return"ima"}};_.z("clpp.ima.ImaPlugin",eU);eU.prototype.getAdContainer=eU.prototype.Nc;eU.prototype.getAdDisplayContainer=eU.prototype.oh;eU.prototype.getAdsLoader=eU.prototype.qh;eU.Id="ima";eU.isSdkMissing=aU;_.Nr(new class{create(){return new eU}});_.Bp(new class{constructor(){this.Wa=new _.S(MT)}name(){return MT}a(a,b){return a.namespace()===_.ud?!1:aU()?(this.Wa.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new dU(a)}});};f.call(g, window);
|