@castlabs/prestoplay 6.8.0 → 6.10.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 +111 -110
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +414 -411
- package/cjs/cl.crypto.js +10 -9
- package/cjs/cl.dash.js +72 -72
- package/cjs/cl.externs.js +36 -37
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +73 -67
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -31
- package/cjs/cl.ima.js +22 -22
- package/cjs/cl.mse.js +275 -274
- package/cjs/cl.muxdata.js +14 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +13 -13
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.smooth.js +70 -70
- package/cjs/cl.thumbnails.js +24 -24
- package/cjs/cl.tizen.js +70 -70
- package/cjs/cl.ttml.js +27 -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 +19 -19
- 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 +366 -362
- package/cl.crypto.js +9 -9
- package/cl.dash.js +66 -66
- package/cl.externs.js +36 -37
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +61 -58
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -25
- package/cl.ima.js +17 -17
- package/cl.mse.js +238 -239
- package/cl.muxdata.js +12 -12
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +9 -9
- 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/package.json +1 -1
- package/typings.d.ts +74 -2
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.h)
|
|
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
|
-
this;return _.y(function*(){null!=a.h&&(
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var iJ="Unsupported unit",jJ="clpp-text-plain",kJ="clpp-text-ttml",lJ="clpp.htmlcue.HtmlTextDisplayer",mJ="initial",nJ=function(a){return _.bg(a,{ze:(b,c)=>b.bd(c)})},oJ=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)},pJ=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},qJ=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},sJ=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>rJ[c]);return a},uJ=function(a,b){tJ(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{tJ(a,c)})},tJ=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},vJ=function(a,b){return 0===a?"0":a+b},wJ=function(a,b){return 1>Math.abs(a-b)||a<b},xJ=function(a,b){return a<b&&1<Math.abs(a-b)},yJ=function(a,b){return a>b&&1<Math.abs(a-b)},zJ=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},BJ=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 AJ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},CJ=function(a){return new AJ(a.f,a.g,a.h,a.a,a.height,a.width)},DJ=function(a,b){return b.some(c=>xJ(a.f,c.g)&&yJ(a.g,c.f)&&xJ(a.h,c.a)&&yJ(a.a,c.h))},EJ=function(a,b){return zJ(a.h,b.h)&&wJ(a.a,b.a)&&zJ(a.f,b.f)&&wJ(a.g,b.g)},FJ=function(a,b,c){switch(c){case "+x":return xJ(a.f,b.f);case "-x":return yJ(a.g,b.g);case "+y":return xJ(a.h,b.h);case "-y":return yJ(a.a,b.a);default:throw Error("Unknown axis");}},GJ=function(a){return a.f.writingMode===_.to},HJ=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 GJ(a)?b:c},IJ=function(a){switch(a.f.writingMode){case _.to:return"horizontal-tb";case _.He:return _.He;case _.Ie:return _.Ie;default:throw Error("Unknown writing mode");}},JJ=function(a){switch(a.f.positionAlign){case _.nd:return _.id;case "auto":case _.vc:return _.so;case _.od:return _.fe}return a.f.textAlign},KJ=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.nd:return a.f.position;
|
|
6
|
+
case "auto":case _.vc:return a.f.position-a.f.size/2;case _.od:return a.f.position-a.f.size}return 0},LJ=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.nd;case _.so:return _.vc;case _.fe:case _.fe:return _.od}return a.f.positionAlign},OJ=function(a,b,c){return(MJ(a)||NJ(a))&&_.rf(c)?vJ(c,_.Zd):MJ(a)&&_.B(c)?vJ(0,_.Zd):GJ(a)&&_.rf(b)?vJ(b,"%"):mJ},PJ=function(a,b,c){return GJ(a)&&_.rf(c)?vJ(c,_.Zd):(MJ(a)||NJ(a))&&_.rf(b)?vJ(b,"%"):mJ},NJ=function(a){return a.f.writingMode===
|
|
7
|
+
_.Ie},MJ=function(a){return a.f.writingMode===_.He},QJ=function(a,b){if(a.h)switch(b.writingMode){case _.to:return["-y"];case _.He:return["+x"];case _.Ie:return["-x"]}a=[];switch(b.writingMode){case _.to:a=["+y","-y"];break;case _.He:a=["+x","-x"];break;case _.Ie:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},RJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=BJ(a.j.a)},SJ=function(a,b){RJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},TJ=function(a,
|
|
8
|
+
b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Ao)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(iJ);},VJ=function(a,b,c,d){const e=document.createElement(_.re),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);UJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},WJ=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)},XJ=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},YJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.m=[]}},UJ=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.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())},ZJ=function(a){a=_.lf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},eK=function(a,b){if((b||a.j)&&
|
|
11
|
+
a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Nl)if(a.I=c,c=$J(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,aK(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.jo(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 _.Pe:g="clpp-text-vtt";break;case _.ze:g=kJ;break;case _.ro:g=
|
|
12
|
+
jJ}g&&!f.classList.contains(g)&&_.hm(f,g);f=BJ(c.a.a);if(0===f.width||0===f.height)c.M.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{tJ({fontSize:bK(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Pe;var h=d.payloadType===_.ze;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new cK(d.region,{}),c.A.set(d.region.id,f),SJ(c.a,f)));
|
|
13
|
+
d=new dK(d,c.K,e);f?SJ(f,d):SJ(c.a,d)}}}}},fK=function(a){aK(a);a.I=null;a.m=null;a.f=[]},gK=function(a,b){return a.startTime<=b&&a.endTime>b},$J=function(a,b){var c=pJ(a.f,d=>gK(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&gK(a.f[d-1],b);)d--;for(;c+1<a.f.length&&gK(a.f[c+1],b);)c++;return{start:d,end:c}}},aK=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(kJ);b.classList.remove(jJ);a=a.a;RJ(a.g);
|
|
14
|
+
a.j=[]}},bK=function(a,b){const c=BJ(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)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`},kK=class{parse(a){a={input:a};const b=_.jm(_.Rc),c=[];let d=b;for(var e;null!==(e=qJ(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=hK[f];h?(h=_.jm(h),(f=iK[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||jK[g.localName]&&jK[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(sJ(e)));return b}},hK={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},iK={v:"voice",lang:"lang"},jK={rt:"ruby"},rJ={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
|
|
16
|
+
"\x26nbsp;":"\u00a0"};var AJ=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var lK=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var dK=class extends lK{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.hm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.ze){var c=_.jm(_.Rc);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.Pe?b=(new kK).parse(b.payload):(c=_.jm(_.Rc),c.textContent=b.payload,b=c);_.hm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.hm(b,d);tJ({writingMode:IJ(this)},b);var d=b;this.a.appendChild(d);_.hm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.hm(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.uo,this.f.line=GJ(this)?-1:0);e=IJ(this);tJ({writingMode:e,webkitWritingMode:e,direction:mJ,textAlign:JJ(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=KJ(this,LJ(this));tJ({position:"absolute",left:OJ(this,e,null),right:NJ(this)&&_.B(null)?vJ(0,_.Zd):mJ,top:PJ(this,e,null),width:GJ(this)?vJ(this.f.size,"%"):mJ,height:MJ(this)||NJ(this)?vJ(this.f.size,"%"):mJ},this.a);b=this.f;a=GJ(this)?a.height:a.width;c=HJ(this);if(b.lineInterpretation===_.uo){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 _.vc:g-=f/2;break;case _.Zc:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}NJ(this)&&(f=a-f-c);a=f;tJ({left:OJ(this,e,a),right:NJ(this)&&_.B(a)?vJ(0,_.Zd):mJ,top:PJ(this,e,a)},this.a)}uJ(this.B,d)}}m(){return _.jm(_.Rc)}};var mK=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=BJ(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.ed;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=BJ(a.a);var d=QJ(this,a.f),e=HJ(a);const g=CJ(c);let h=null,k=0;for(const l of d){for(;FJ(c,this.a,l)||EJ(c,this.a)&&DJ(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.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||EJ(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.h,d.h))/(c.height*c.width);d>k&&(h=CJ(c),k=d);c=CJ(g)}c=h||g}tJ({top:vJ(c.h-this.a.h,_.Zd),bottom:vJ(this.a.a-c.a,_.Zd),left:vJ(c.f-this.a.f,_.Zd),right:vJ(this.a.g-c.g,_.Zd),height:vJ(c.height,_.Zd),width:vJ(c.width,_.Zd)},a.a)}b.style.visibility="visible";this.g.push(BJ(a.a))}};var nK=class extends lK{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new mK(this);this.h=!0}m(){const a=_.jm(_.Rc);_.hm(a,this.o);this.id&&(a.id=this.id);return a}};var cK=class extends nK{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 _.Ao:b=b.width/100*a.width;break a;default:throw Error(iJ);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Ao)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(iJ);d=a.height;const e=TJ(this,d,a.height);tJ(this.A,this.a);tJ({left:vJ(c,_.Zd),top:vJ(e,_.Zd),width:vJ(b,
|
|
21
|
+
_.Zd),height:vJ(d,_.Zd)},this.a);this.f.writingMode&&tJ({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&tJ({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.hm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Ao:f=f.height/100*a.height;break a;case 2:f=f.height;c=new dK(new _.xo(0,1,"Lorem ipsum",_.ro),{},{});b=c.a;this.a.appendChild(b);c.init(BJ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(iJ);}a=TJ(this,f,a.height);tJ({top:vJ(a,_.Zd),height:vJ(f,_.Zd)},this.a);this.g=new mK(this,!0);this.h=!0}getId(){return this.f.id}};var oK=class{constructor(a,b){this.f=new _.Q("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=VJ(this,this.h,this.j);this.g=VJ(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=WJ(this,a);if(XJ(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.y(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],YJ(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var pK=class extends _.cq{constructor(a){super(a);this.M=new _.Q(lJ);this.l=a;this.K=ZJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new oK(a,"CLPP Subtitle Styles");this.a=new nK(null,"clpp-text-container",{});this.w=new _.Yp(a.getSurface(),this.V.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.M.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
|
|
24
|
+
new _.ci(()=>{eK(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=oJ(this.f,nJ(a));this.m=null;eK(this,!1)}}g(){null==this.h||eK(this,!0)}destroy(){const a=this;return _.y(function*(){null!=a.h&&(fK(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=
|
|
25
|
+
this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;eK(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Xa(.25),this.K.enableResizeObserver&&this.w.start(),eK(this,!0)):(this.F.stop(),this.w.stop(),fK(this)))}V(){eK(this,!0)}};_.z(lJ,pK);pK.prototype.setTextVisibility=pK.prototype.setTextVisibility;pK.prototype.isTextVisible=pK.prototype.isTextVisible;pK.prototype.remove=pK.prototype.remove;pK.prototype.destroy=pK.prototype.destroy;
|
|
26
|
+
pK.prototype.append=pK.prototype.append;var qK=class{ea(a){return!!a.enableHtmlCue&&!_.si()}create(a){return new pK(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Fp{f(){_.rl("html",new qK)}a(){}id(){return _.se}});};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.G=!0},
|
|
6
|
-
this.f.getIsBumper():!1}
|
|
7
|
-
1}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
{adsTimeline:this.h})),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a.j.getSettings().setAutoPlayAdBreaks(!1);a.j.requestAds(e);return a.f})}start(a){const b=this;return _.y(function*(){b.a&&b.h&&!b.G?b.h.
|
|
15
|
-
{this.G&&this.h&&this.h.
|
|
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 SI="clpp.ima.AdsManagerFactory",TI=function(a){a=a.H;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.jc?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
|
+
_.jc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},UI=function(a){return!1===a.H.disableCustomPlayback&&a.a.isCustomPlaybackUsed()&&_.gi()},VI=function(a){const b=a.a,c=a.o,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.ma.bind(a));c.on(b,d.LOADED,a.W.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.pc.bind(a));c.on(b,d.STARTED,a.aa.bind(a));c.on(b,d.LOG,a.Za.bind(a));c.on(b,d.AD_PROGRESS,a.Db.bind(a));c.on(b,d.AD_BUFFERING,a.Na.bind(a));
|
|
3
|
+
c.on(b,d.FIRST_QUARTILE,a.T.bind(a));c.on(b,d.MIDPOINT,a.$a.bind(a));c.on(b,d.THIRD_QUARTILE,a.ba.bind(a));c.on(b,d.PAUSED,a.ab.bind(a));c.on(b,d.RESUMED,a.Qb.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.Ya.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.qc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.kc.bind(a))},WI=function(a,b){const c=b?a.ga.create(b.getErrorCode()):null;a.l.onError(new _.H(1,9,10003,{errorType:c},b))},XI=function(a,
|
|
4
|
+
b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new X(c,a.C,a.B)});a.l.trigger(new _.F(b,d))},YI=function(a){a.A=null;XI(a,_.Kb);a.m&&a.l.getSurface().hide(a.m)},ZI=function(a){_.im(a.w,{visibility:"visible"})},aJ=function(a){return _.y(function*(){a.M.initialize();const b=!!a.l.getConfiguration().muted;(yield a.J.canPlay(b))||UI(a)?$I(a):(XI(a,_.fc),a.N.warn(_.ia))})},bJ=function(a,b){return _.y(function*(){a.M.initialize();yield b.play();$I(a)})},$I=function(a){a.a.init(a.w.offsetWidth,a.w.offsetHeight,
|
|
5
|
+
google.ima.ViewMode.NORMAL);a.G=!0},cJ=function(){return!window.google||!google.ima||!google.ima.AdsLoader},X=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.h=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()}$b(){return this.f?
|
|
6
|
+
this.f.getIsBumper():!1}Hb(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Dd&&typeof b[d].clickThroughUrl===_.pe);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()}Sa(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Ib(){return this.f?this.f.getTimeOffset():0}Jb(){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.Jb;
|
|
8
|
+
X.prototype.getPodTimeOffset=X.prototype.Ib;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Sa;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.Hb;X.prototype.isBumper=X.prototype.$b;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 dJ=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 eJ=class{constructor(a){this.a=a}getCuePoints(){return this.a}Kb(){return 0<=this.a.indexOf(0)||0===this.a.length}hb(){return 0<=this.a.indexOf(-1)}};eJ.prototype.hasPostroll=eJ.prototype.hb;eJ.prototype.hasPreroll=eJ.prototype.Kb;eJ.prototype.getCuePoints=eJ.prototype.getCuePoints;var fJ=class{constructor(a){this.l=a;this.w=a.getSurface().getMedia();a=this.l.getConfiguration();a=_.lf(a.ima||{});this.H=a=_.kf({disableCustomPlayback:!1},a);this.m=this.l.Wb("ima").rc();this.M=this.l.Wb("ima").g;this.j=this.l.Wb("ima").a;this.J=new _.$p;this.N=new _.Q("clpp.ima");this.g=this.a=null;this.f=new _.Sk;this.G=!1;this.o=new _.po;this.ga=new dJ;this.A=null;this.K=this.F=this.B=this.C=!1;this.I=this.h=null;{a=this.o;const b=google.ima.AdErrorEvent.Type.AD_ERROR;a.one(this.j,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
10
|
+
this.Sb.bind(this));a.on(this.j,b,this.Rb.bind(this));a.on(this.l,_.$c,this.oc.bind(this))}}Sb(a){this.a=a.getAdsManager(this.w,TI(this));this.a.isCustomPlaybackUsed()&&!UI(this)?(this.N.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.l.onError(new _.H(1,9,10002)),this.dispose()):(this.g=new _.Yp(this.l.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.h=new eJ(a),this.l.trigger(new _.F(_.Nb,
|
|
11
|
+
{adsTimeline:this.h})),VI(this));this.f.resolve()}Rb(a){WI(this,a.getError());this.f.resolve()}pc(a){const b=this;return _.y(function*(){b.F=!0;UI(b)||(yield b.l.pause(),_.im(b.w,{visibility:_.ed}));XI(b,_.wb,a);b.g.start()})}ma(){const a=this;return _.y(function*(){if(UI(a)){a.I=a.l.getPosition();yield a.l.detach();var b=a.l;b.a&&b.a.removeDelegate(b)}a.a.start()})}W(a){a.getAd().isLinear()?XI(this,_.Db,a):(this.a.discardAdBreak(),this.C||(this.C=!0,this.l.play()))}aa(a){this.A=a.getAd().getDuration();
|
|
12
|
+
XI(this,_.Jb,a);this.l.getSurface().show(this.m)}Za(a){a=a.getAdData();WI(this,a?a.adError:null);YI(this)}Db(a){XI(this,_.Gb,a)}Na(a){XI(this,_.yb,a)}T(a){XI(this,_.Bb,a)}$a(a){XI(this,_.Eb,a)}ba(a){XI(this,_.Lb,a)}ab(a){XI(this,_.Fb,a)}Qb(a){XI(this,_.Hb,a)}R(a){this.pause();XI(this,_.zb,a)}Y(a){XI(this,_.Ib,a);YI(this)}V(a){XI(this,_.Cb,a)}Ya(a){XI(this,_.Ab,a);YI(this)}qc(){const a=this;return _.y(function*(){a.C=!0;if(UI(a)&&null!==a.I){var b=a.l;b.a&&b.a.addDelegate(b);yield _.an(a.l);a.B||(yield a.l.seek(a.I))}else{if(!a.F)return a.l.play();
|
|
13
|
+
ZI(a)}a.F=!1;a.g&&a.g.stop();a.B||(yield a.l.play());XI(a,_.xb)})}kc(){this.K=!0}oc(){this.B=!0;this.j.contentComplete()}load(){const a=this;return _.y(function*(){var b=a.l;const c=a.H;try{if(typeof c.adTagUrl!==_.pe)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.J.canPlay(!1);const d=yield a.J.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);
|
|
14
|
+
a.j.getSettings().setAutoPlayAdBreaks(!1);a.j.requestAds(e);return a.f})}start(a){const b=this;return _.y(function*(){b.a&&b.h&&!b.G?b.h.Kb()?yield aJ(b):yield bJ(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.A)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.A-a}dispose(){return(new Promise(a=>
|
|
15
|
+
{this.G&&this.h&&this.h.hb()&&!this.K?(this.o.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Of(this.o,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],()=>{this.a&&this.a.discardAdBreak()})):a();this.a.discardAdBreak();this.j.contentComplete()})).then(()=>{ZI(this);this.o.release();this.g&&(this.g.stop(),this.g=null);this.a&&(this.a.destroy(),this.a=null)})}};fJ.prototype.getPosition=fJ.prototype.getPosition;
|
|
16
|
+
fJ.prototype.setVolume=fJ.prototype.setVolume;fJ.prototype.getVolume=fJ.prototype.getVolume;fJ.prototype.skip=fJ.prototype.skip;fJ.prototype.pause=fJ.prototype.pause;fJ.prototype.resume=fJ.prototype.resume;var gJ=class extends _.fq{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(cJ())return a.onError(new _.H(1,9,1E4));this.f=_.gm(_.Rc,{"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(_.ma);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)}Lf(){return this.a}Jf(){return this.g}rc(){return this.f}id(){return"ima"}};_.z("clpp.ima.ImaPlugin",gJ);gJ.prototype.getAdContainer=gJ.prototype.rc;gJ.prototype.getAdDisplayContainer=gJ.prototype.Jf;gJ.prototype.getAdsLoader=gJ.prototype.Lf;gJ.Id="ima";gJ.isSdkMissing=cJ;_.Nm(new class{create(){return new gJ}});var hJ=class{constructor(){this.a=new _.Q(SI)}name(){return SI}ea(a,b){return a.namespace()===_.Bc?!1:cJ()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new fJ(a)}};hJ.prototype.create=hJ.prototype.create;hJ.prototype.isSupported=hJ.prototype.ea;hJ.prototype.name=hJ.prototype.name;_.dm(new hJ);};f.call(g, window);
|