@castlabs/prestoplay 6.9.0 → 6.11.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 +66 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +6 -6
- package/cjs/cl.cast.js +112 -111
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +467 -432
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +72 -72
- package/cjs/cl.externs.js +143 -45
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +78 -73
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -31
- package/cjs/cl.ima.js +24 -24
- package/cjs/cl.mse.js +276 -275
- package/cjs/cl.muxdata.js +14 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.smooth.js +71 -71
- package/cjs/cl.thumbnails.js +24 -24
- package/cjs/cl.tizen.js +71 -71
- package/cjs/cl.ttml.js +29 -27
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +13 -13
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.youbora.js +20 -20
- 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 +396 -365
- package/cl.crypto.js +9 -9
- package/cl.dash.js +68 -67
- package/cl.externs.js +139 -45
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +64 -61
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -25
- package/cl.ima.js +17 -17
- package/cl.mse.js +240 -242
- package/cl.muxdata.js +12 -12
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +11 -11
- package/cl.playlist.js +5 -5
- package/cl.smooth.js +59 -58
- package/cl.thumbnails.js +17 -17
- 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.youbora.js +15 -15
- package/clpp.styles.css +15 -0
- package/package.json +1 -1
- package/typings.d.ts +249 -21
package/cl.htmlcue.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
function(a,b){
|
|
3
|
-
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
|
|
4
|
-
b.
|
|
5
|
-
case _.
|
|
6
|
-
case _.
|
|
7
|
-
["+y","-y"];break;case _.
|
|
8
|
-
f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);
|
|
9
|
-
a)},
|
|
10
|
-
d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},
|
|
11
|
-
backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.
|
|
12
|
-
else{
|
|
13
|
-
c;for(;0<=d-1&&
|
|
14
|
-
a)}px`},
|
|
15
|
-
d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var BK="Unsupported unit",CK="clpp-text-plain",DK="clpp-text-ttml",EK="clpp.htmlcue.HtmlTextDisplayer",FK="initial",GK=function(a){return _.yg(a,{De:(b,c)=>b.bd(c)})},HK=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)},IK=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},JK=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},LK=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>KK[c]);return a},NK=function(a,b){MK(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{MK(a,c)})},MK=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},OK=function(a,b){return 0===a?"0":a+b},PK=function(a,b){return 1>Math.abs(a-b)||a<b},QK=function(a,b){return a<b&&1<Math.abs(a-b)},RK=function(a,b){return a>b&&1<Math.abs(a-b)},SK=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},UK=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 TK(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},VK=function(a){return new TK(a.f,a.g,a.j,a.a,a.height,a.width)},WK=function(a,b){return b.some(c=>QK(a.f,c.g)&&RK(a.g,c.f)&&QK(a.j,c.a)&&RK(a.a,c.j))},XK=function(a,b){return SK(a.j,b.j)&&PK(a.a,b.a)&&SK(a.f,b.f)&&PK(a.g,b.g)},YK=function(a,b,c){switch(c){case "+x":return QK(a.f,b.f);case "-x":return RK(a.g,b.g);case "+y":return QK(a.j,b.j);case "-y":return RK(a.a,b.a);default:throw Error("Unknown axis");}},ZK=function(a){return a.f.writingMode===_.zp},$K=function(a){var b=a.a.childNodes[0],
|
|
5
|
+
c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return ZK(a)?b:c},aL=function(a){switch(a.f.writingMode){case _.zp:return"horizontal-tb";case _.cf:return _.cf;case _.df:return _.df;default:throw Error("Unknown writing mode");}},bL=function(a){switch(a.f.positionAlign){case _.yd:return _.vd;case "auto":case _.zc:return _.yp;case _.zd:return _.ze}return a.f.textAlign},cL=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.yd:return a.f.position;
|
|
6
|
+
case "auto":case _.zc:return a.f.position-a.f.size/2;case _.zd:return a.f.position-a.f.size}return 0},dL=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.vd:case _.vd:return _.yd;case _.yp:return _.zc;case _.ze:case _.ze:return _.zd}return a.f.positionAlign},gL=function(a,b,c){return(eL(a)||fL(a))&&_.Sf(c)?OK(c,_.se):eL(a)&&_.B(c)?OK(0,_.se):ZK(a)&&_.Sf(b)?OK(b,"%"):FK},hL=function(a,b,c){return ZK(a)&&_.Sf(c)?OK(c,_.se):(eL(a)||fL(a))&&_.Sf(b)?OK(b,"%"):FK},fL=function(a){return a.f.writingMode===
|
|
7
|
+
_.df},eL=function(a){return a.f.writingMode===_.cf},iL=function(a,b){if(a.j)switch(b.writingMode){case _.zp:return["-y"];case _.cf:return["+x"];case _.df:return["-x"]}a=[];switch(b.writingMode){case _.zp:a=["+y","-y"];break;case _.cf:a=["+x","-x"];break;case _.df:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},jL=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=UK(a.l.a)},kL=function(a,b){jL(a.g);a.l.unshift(b);for(const c of a.l)a.g.append(c)},lL=function(a,
|
|
8
|
+
b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Gp)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(BK);},nL=function(a,b,c,d){const e=document.createElement(_.Le),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);mL(a,c,b);a.h.debug(`Created HTML style element #${b}.`);return e.sheet},oL=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)},pL=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},qL=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.l=[]}},mL=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.h.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},rL=function(a){a=_.Hf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},xL=function(a,b){if((b||a.l)&&
|
|
11
|
+
a.F){var c=a.m.getPosition();if(b||a.J!==c&&a.m.getState()===_.Dm)if(a.J=c,c=sL(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,tL(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.pp(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 _.lf:g="clpp-text-vtt";break;case _.Ue:g=DK;break;case _.xp:g=
|
|
12
|
+
CK}g&&!f.classList.contains(g)&&_.Ym(f,g);f=UK(c.a.a);if(0===f.width||0===f.height)c.h.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{MK({fontSize:uL(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.lf;var h=d.payloadType===_.Ue;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new vL(d.region,{}),c.B.set(d.region.id,f),kL(c.a,f)));
|
|
13
|
+
d=new wL(d,c.M,e);f?kL(f,d):kL(c.a,d)}}}}},yL=function(a){tL(a);a.J=null;a.o=null;a.f=[]},zL=function(a,b){return a.startTime<=b&&a.endTime>b},sL=function(a,b){var c=IK(a.f,d=>zL(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&zL(a.f[d-1],b);)d--;for(;c+1<a.f.length&&zL(a.f[c+1],b);)c++;return{start:d,end:c}}},tL=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(DK);b.classList.remove(CK);a=a.a;jL(a.g);
|
|
14
|
+
a.l=[]}},uL=function(a,b){const c=UK(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===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},DL=class{parse(a){a={input:a};const b=_.$m(_.Yc),c=[];let d=b;for(var e;null!==(e=JK(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=AL[f];h?(h=_.$m(h),(f=BL[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||CL[g.localName]&&CL[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(LK(e)));return b}},AL={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},BL={v:"voice",lang:"lang"},CL={rt:"ruby"},KK={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
|
|
16
|
+
"\x26nbsp;":"\u00a0"};var TK=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.j=c;this.a=d;this.height=e;this.width=f}};var EL=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 wL=class extends EL{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.g=!!this.f.backgroundImage;this.C=c}A(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.Ym(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===_.Ue){var c=_.$m(_.Yc);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.lf?b=(new DL).parse(b.payload):(c=_.$m(_.Yc),c.textContent=b.payload,b=c);_.Ym(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.Ym(b,d);MK({writingMode:aL(this)},b);var d=b;this.a.appendChild(d);_.Ym(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.Ym(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.Ap,this.f.line=ZK(this)?-1:0);e=aL(this);MK({writingMode:e,webkitWritingMode:e,direction:FK,textAlign:bL(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=cL(this,dL(this));MK({position:"absolute",left:gL(this,e,null),right:fL(this)&&_.B(null)?OK(0,_.se):FK,top:hL(this,e,null),width:ZK(this)?OK(this.f.size,"%"):FK,height:eL(this)||fL(this)?OK(this.f.size,"%"):FK},this.a);b=this.f;a=ZK(this)?a.height:a.width;c=$K(this);if(b.lineInterpretation===_.Ap){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 _.zc:g-=f/2;break;case _.jd:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}fL(this)&&(f=a-f-c);a=f;MK({left:gL(this,e,a),right:fL(this)&&_.B(a)?OK(0,_.se):FK,top:hL(this,e,a)},this.a)}NK(this.C,d)}}o(){return _.$m(_.Yc)}};var FL=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=UK(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.qd;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=UK(a.a);var d=iL(this,a.f),e=$K(a);const g=VK(c);let h=null,k=0;for(const l of d){for(;YK(c,this.a,l)||XK(c,this.a)&&WK(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.j+=f;d.a+=f;break;case "-y":d.j-=f,d.a-=f}}if(this.j||XK(c,this.a))break a;
|
|
20
|
+
d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.j,d.j))/(c.height*c.width);d>k&&(h=VK(c),k=d);c=VK(g)}c=h||g}MK({top:OK(c.j-this.a.j,_.se),bottom:OK(this.a.a-c.a,_.se),left:OK(c.f-this.a.f,_.se),right:OK(this.a.g-c.g,_.se),height:OK(c.height,_.se),width:OK(c.width,_.se)},a.a)}b.style.visibility="visible";this.g.push(UK(a.a))}};var GL=class extends EL{constructor(a,b,c){super(a,b,c);this.g=null;this.l=[]}init(){this.g=new FL(this);this.j=!0}o(){const a=_.$m(_.Yc);_.Ym(a,this.w);this.id&&(a.id=this.id);return a}};var vL=class extends GL{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 _.Gp:b=b.width/100*a.width;break a;default:throw Error(BK);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Gp)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(BK);d=a.height;const e=lL(this,d,a.height);MK(this.B,this.a);MK({left:OK(c,_.se),top:OK(e,_.se),width:OK(b,
|
|
21
|
+
_.se),height:OK(d,_.se)},this.a);this.f.writingMode&&MK({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&MK({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.Ym(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Gp:f=f.height/100*a.height;break a;case 2:f=f.height;c=new wL(new _.Dp(0,1,"Lorem ipsum",_.xp),{},{});b=c.a;this.a.appendChild(b);c.init(UK(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(BK);}a=lL(this,f,a.height);MK({top:OK(a,_.se),height:OK(f,_.se)},this.a);this.g=new FL(this,!0);this.j=!0}getId(){return this.f.id}};var HL=class{constructor(a,b){this.h=new _.R("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.g=b;this.l=[];this.a=nL(this,this.g,this.j);this.f=nL(this,this.g,this.j,!0);this.f.disabled=!0;this.h.debug(`Stylesheet ${this.g} has been created.`)}appendRule(a){if(null!=this.a&&!this.l.some(b=>b===a)){const b=oL(this,a);if(pL(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.h.debug(`Added CSS rule ${b}`)}catch(c){this.h.error(`An error occurred when adding a CSS rule: ${b}`)}this.l.push(a)}else this.h.warn(`Stylesheet ${this.g} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.x(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],qL(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.h.debug(`Stylesheet ${a.g} has been destroyed.`))})}};var IL=class extends _.or{constructor(a){super(a);this.h=new _.R(EK);this.m=a;this.M=rL(a);this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new HL(a,"CLPP Subtitle Styles");this.a=new GL(null,"clpp-text-container",{});this.A=new _.fr(a.getSurface(),this.V.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.h.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.G=
|
|
24
|
+
new _.zi(()=>{xL(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=HK(this.f,GK(a));this.o=null;xL(this,!1)}}g(){null==this.j||xL(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(yL(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;this.f=
|
|
25
|
+
this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;xL(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Ya(.25),this.M.enableResizeObserver&&this.A.start(),xL(this,!0)):(this.G.stop(),this.A.stop(),yL(this)))}V(){xL(this,!0)}};_.z(EK,IL);IL.prototype.setTextVisibility=IL.prototype.setTextVisibility;IL.prototype.isTextVisible=IL.prototype.isTextVisible;IL.prototype.remove=IL.prototype.remove;IL.prototype.destroy=IL.prototype.destroy;
|
|
26
|
+
IL.prototype.append=IL.prototype.append;var JL=class{da(a){return!!a.enableHtmlCue&&!_.Ri()}create(a){return new IL(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Pq{f(){_.hm(_.rd,new JL)}a(){_.fm.has(_.rd)&&(_.fm.delete(_.rd),_.gm.info("Removed factory: 'html'"))}id(){return _.Oe}});};f.call(g, window);
|
package/cl.ima.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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
|
-
b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new
|
|
5
|
-
google.ima.ViewMode.NORMAL);a.
|
|
6
|
-
this.f.getIsBumper():!1}
|
|
7
|
-
1}ub(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
{adsTimeline:this.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a.
|
|
15
|
-
{this.
|
|
16
|
-
|
|
17
|
-
(this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var kK="clpp.ima.AdsManagerFactory",lK=function(a){a=a.I;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.nc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.r&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.r&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
|
|
2
|
+
_.nc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},mK=function(a){return!1===a.I.disableCustomPlayback&&a.a.isCustomPlaybackUsed()&&_.Fi()},nK=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.na.bind(a));c.on(b,d.LOADED,a.W.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.nc.bind(a));c.on(b,d.STARTED,a.aa.bind(a));c.on(b,d.LOG,a.$a.bind(a));c.on(b,d.AD_PROGRESS,a.Eb.bind(a));c.on(b,d.AD_BUFFERING,a.Na.bind(a));
|
|
3
|
+
c.on(b,d.FIRST_QUARTILE,a.S.bind(a));c.on(b,d.MIDPOINT,a.ab.bind(a));c.on(b,d.THIRD_QUARTILE,a.ba.bind(a));c.on(b,d.PAUSED,a.bb.bind(a));c.on(b,d.RESUMED,a.Db.bind(a));c.on(b,d.CLICK,a.R.bind(a));c.on(b,d.SKIPPED,a.Y.bind(a));c.on(b,d.IMPRESSION,a.V.bind(a));c.on(b,d.COMPLETE,a.Za.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.oc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Sb.bind(a))},oK=function(a,b){const c=b?a.fa.create(b.getErrorCode()):null;a.m.onError(new _.H(1,9,10003,{errorType:c},b))},pK=function(a,
|
|
4
|
+
b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new X(c,a.F,a.C)});a.m.trigger(new _.F(b,d))},qK=function(a){a.B=null;pK(a,_.Qb);a.o&&a.m.getSurface().hide(a.o)},rK=function(a){_.Zm(a.A,{visibility:"visible"})},tK=function(a){return _.x(function*(){a.N.initialize();const b=!!a.m.getConfiguration().muted;(yield a.K.canPlay(b))||mK(a)?sK(a):(pK(a,_.lc),a.h.warn(_.ia))})},uK=function(a,b){return _.x(function*(){a.N.initialize();yield b.play();sK(a)})},sK=function(a){a.a.init(a.A.offsetWidth,a.A.offsetHeight,
|
|
5
|
+
google.ima.ViewMode.NORMAL);a.H=!0},vK=function(){return!window.google||!google.ima||!google.ima.AdsLoader},X=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.g=c}pb(){return"Google IMA SDK"}qb(){return google.ima.VERSION}vb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}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()}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}ac(){return this.f?
|
|
6
|
+
this.f.getIsBumper():!1}Ib(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Od&&typeof b[d].clickThroughUrl===_.Je);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}sb(){return this.a.getVastMediaWidth()}rb(){return this.a.getVastMediaHeight()}gb(){return this.a.getVastMediaBitrate()}Ta(){return this.g?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Jb(){return this.f?this.f.getTimeOffset():0}Kb(){return this.f?this.f.getAdPosition():
|
|
7
|
+
1}ub(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.ub;X.prototype.getPositionInSequence=X.prototype.Kb;
|
|
8
|
+
X.prototype.getPodTimeOffset=X.prototype.Jb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ta;X.prototype.getMediaBitrate=X.prototype.gb;X.prototype.getMediaHeight=X.prototype.rb;X.prototype.getMediaWidth=X.prototype.sb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Ib;X.prototype.isBumper=X.prototype.ac;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getDuration=X.prototype.getDuration;
|
|
9
|
+
X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.vb;X.prototype.getAdManagerVersion=X.prototype.qb;X.prototype.getAdManagerName=X.prototype.pb;var wK=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 xK=class{constructor(a){this.a=a}getCuePoints(){return this.a}Lb(){return 0<=this.a.indexOf(0)||0===this.a.length}hb(){return 0<=this.a.indexOf(-1)}};xK.prototype.hasPostroll=xK.prototype.hb;xK.prototype.hasPreroll=xK.prototype.Lb;xK.prototype.getCuePoints=xK.prototype.getCuePoints;var yK=class{constructor(a){this.m=a;this.A=a.getSurface().getMedia();a=this.m.getConfiguration();a=_.Hf(a.ima||{});this.I=a=_.Gf({disableCustomPlayback:!1},a);this.o=this.m.Xb("ima").pc();this.N=this.m.Xb("ima").g;this.l=this.m.Xb("ima").a;this.K=new _.hr;this.h=new _.R("clpp.ima");this.g=this.a=null;this.f=new _.Jl;this.H=!1;this.w=new _.vp;this.fa=new wK;this.B=null;this.M=this.G=this.C=this.F=!1;this.J=this.j=null;{a=this.w;const b=google.ima.AdErrorEvent.Type.AD_ERROR;a.one(this.l,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
10
|
+
this.Rb.bind(this));a.on(this.l,b,this.Fb.bind(this));a.on(this.m,_.kd,this.Ub.bind(this))}}Rb(a){this.a=a.getAdsManager(this.A,lK(this));this.a.isCustomPlaybackUsed()&&!mK(this)?(this.h.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.H(1,9,10002)),this.dispose()):(this.g=new _.fr(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.j=new xK(a),this.m.trigger(new _.F(_.Vb,
|
|
11
|
+
{adsTimeline:this.j})),nK(this));this.f.resolve()}Fb(a){oK(this,a.getError());this.f.resolve()}nc(a){const b=this;return _.x(function*(){b.G=!0;mK(b)||(yield b.m.pause(),_.Zm(b.A,{visibility:_.qd}));pK(b,_.Cb,a);b.g.start()})}na(){const a=this;return _.x(function*(){if(mK(a)){a.J=a.m.getPosition();yield a.m.detach();var b=a.m;b.a&&b.a.removeDelegate(b)}a.a.start()})}W(a){a.getAd().isLinear()?pK(this,_.Jb,a):(this.a.discardAdBreak(),this.F||(this.F=!0,this.m.play()))}aa(a){this.B=a.getAd().getDuration();
|
|
12
|
+
pK(this,_.Pb,a);this.m.getSurface().show(this.o)}$a(a){a=a.getAdData();oK(this,a?a.adError:null);qK(this)}Eb(a){pK(this,_.Mb,a)}Na(a){pK(this,_.Eb,a)}S(a){pK(this,_.Hb,a)}ab(a){pK(this,_.Kb,a)}ba(a){pK(this,_.Rb,a)}bb(a){pK(this,_.Lb,a)}Db(a){pK(this,_.Nb,a)}R(a){this.pause();pK(this,_.Fb,a)}Y(a){pK(this,_.Ob,a);qK(this)}V(a){pK(this,_.Ib,a)}Za(a){pK(this,_.Gb,a);qK(this)}oc(){const a=this;return _.x(function*(){a.F=!0;if(mK(a)&&null!==a.J){var b=a.m;b.a&&b.a.addDelegate(b);yield _.Sn(a.m);a.C||(yield a.m.seek(a.J))}else{if(!a.G)return a.m.play();
|
|
13
|
+
rK(a)}a.G=!1;a.g&&a.g.stop();a.C||(yield a.m.play());pK(a,_.Db)})}Sb(){this.M=!0}Ub(){this.C=!0;this.l.contentComplete()}load(){const a=this;return _.x(function*(){var b=a.m;const c=a.I;try{if(typeof c.adTagUrl!==_.Je)throw new _.H(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.K.canPlay(!1);const d=yield a.K.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);
|
|
14
|
+
a.l.getSettings().setAutoPlayAdBreaks(!1);a.l.requestAds(e);return a.f})}start(a){const b=this;return _.x(function*(){b.a&&b.j&&!b.H?b.j.Lb()?yield tK(b):yield uK(b,a):yield a.play()})}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&&this.a.setVolume(a)}getPosition(){if(!this.a||null===this.B)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.B-a}dispose(){return(new Promise(a=>
|
|
15
|
+
{this.H&&this.j&&this.j.hb()&&!this.M?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.o&&this.m.getSurface().hide(this.o)}),_.kg(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],()=>{this.a&&this.a.discardAdBreak()})):a();this.a.discardAdBreak();this.l.contentComplete()})).then(()=>{rK(this);this.w.release();this.g&&(this.g.stop(),this.g=null);this.a&&(this.a.destroy(),this.a=null)})}};yK.prototype.getPosition=yK.prototype.getPosition;
|
|
16
|
+
yK.prototype.setVolume=yK.prototype.setVolume;yK.prototype.getVolume=yK.prototype.getVolume;yK.prototype.skip=yK.prototype.skip;yK.prototype.pause=yK.prototype.pause;yK.prototype.resume=yK.prototype.resume;var zK=class extends _.rr{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(vK())return a.onError(new _.H(1,9,1E4));this.f=_.Xm(_.Yc,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.g=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.g);this.a.getSettings().setPlayerType(_.na);this.a.getSettings().setPlayerVersion(_.da);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
|
|
17
|
+
(this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}Wf(){return this.a}Uf(){return this.g}pc(){return this.f}id(){return"ima"}};_.z("clpp.ima.ImaPlugin",zK);zK.prototype.getAdContainer=zK.prototype.pc;zK.prototype.getAdDisplayContainer=zK.prototype.Uf;zK.prototype.getAdsLoader=zK.prototype.Wf;zK.Id="ima";zK.isSdkMissing=vK;_.En(new class{create(){return new zK}});var AK=class{constructor(){this.a=new _.R(kK)}name(){return kK}da(a,b){return a.namespace()===_.Gc?!1:vK()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new yK(a)}};AK.prototype.create=AK.prototype.create;AK.prototype.isSupported=AK.prototype.da;AK.prototype.name=AK.prototype.name;_.Um(new AK);};f.call(g, window);
|