@castlabs/prestoplay 6.14.0 → 6.15.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 +25 -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 +113 -111
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +550 -529
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +74 -73
- package/cjs/cl.externs.js +191 -64
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +69 -68
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -30
- package/cjs/cl.ima.js +23 -23
- package/cjs/cl.mse.js +290 -275
- package/cjs/cl.muxdata.js +15 -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.simid.js +15 -15
- package/cjs/cl.smooth.js +72 -71
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +70 -70
- package/cjs/cl.ttml.js +28 -28
- 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 +89 -88
- package/cl.conviva.js +27 -27
- package/cl.core.js +457 -438
- package/cl.crypto.js +9 -9
- package/cl.dash.js +70 -68
- package/cl.externs.js +187 -64
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +71 -69
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +17 -17
- package/cl.mse.js +255 -240
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +11 -11
- package/cl.playlist.js +5 -5
- package/cl.simid.js +13 -13
- package/cl.smooth.js +59 -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 +15 -15
- package/cl.vtt.js +12 -12
- package/cl.youbora.js +15 -15
- package/clpp.styles.css +2 -0
- package/package.json +1 -1
- package/typings.d.ts +387 -90
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
|
-
_.r)switch(b){case _.
|
|
7
|
-
|
|
8
|
-
for(const c of a.l)a.
|
|
9
|
-
const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${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
|
-
return c},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
b.classList.remove(
|
|
15
|
-
else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=
|
|
16
|
-
"\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\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 _.
|
|
24
|
-
new _.
|
|
25
|
-
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 xO="Unsupported unit",yO="clpp-text-plain",zO="clpp-text-ttml",AO="clpp.htmlcue.HtmlTextDisplayer",BO="initial",CO=function(a){return _.Bh(a,{Ye:(b,c)=>b.vc(c)})},DO=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)},EO=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},FO=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},HO=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>GO[c]);return a},JO=function(a,b){IO(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{IO(a,c)})},IO=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},KO=function(a,b){return 0===a?"0":a+b},LO=function(a,b){return 1>Math.abs(a-b)||a<b},MO=function(a,b){return a<b&&1<Math.abs(a-b)},NO=function(a,b){return a>b&&1<Math.abs(a-b)},OO=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},QO=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 PO(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},RO=function(a){return new PO(a.left,a.f,a.top,a.a,a.height,a.width)},SO=function(a,b){return b.some(c=>MO(a.left,c.f)&&NO(a.f,c.left)&&MO(a.top,c.a)&&NO(a.a,c.top))},TO=function(a,b){return OO(a.top,b.top)&&LO(a.a,b.a)&&OO(a.left,b.left)&&LO(a.f,b.f)},UO=function(a,b,c){switch(c){case "+x":return MO(a.left,b.left);case "-x":return NO(a.f,b.f);case "+y":return MO(a.top,b.top);case "-y":return NO(a.a,b.a);default:throw Error("Unknown axis");}},VO=function(a){return a.f.writingMode===_.es},WO=
|
|
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 VO(a)?b:c},XO=function(a){switch(a.f.writingMode){case _.es:return"horizontal-tb";case _.hg:return _.hg;case _.ig:return _.ig;default:throw Error("Unknown writing mode");}},YO=function(a){switch(a.f.positionAlign){case _.me:return _.je;case "auto":case _.$c:return _.ds;case _.ne:return _.vf}return a.f.textAlign},ZO=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===
|
|
6
|
+
_.r)switch(b){case _.me:return a.f.position;case "auto":case _.$c:return a.f.position-a.f.size/2;case _.ne:return a.f.position-a.f.size}return 0},$O=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.je:case _.je:return _.me;case _.ds:return _.$c;case _.vf:case _.vf:return _.ne}return a.f.positionAlign},cP=function(a,b,c){return(aP(a)||bP(a))&&_.Sg(c)?KO(c,_.of):aP(a)&&_.z(c)?KO(0,_.of):VO(a)&&_.Sg(b)?KO(b,"%"):BO},dP=function(a,b,c){return VO(a)&&_.Sg(c)?KO(c,_.of):(aP(a)||bP(a))&&_.Sg(b)?
|
|
7
|
+
KO(b,"%"):BO},bP=function(a){return a.f.writingMode===_.ig},aP=function(a){return a.f.writingMode===_.hg},eP=function(a,b){if(a.j)switch(b.writingMode){case _.es:return["-y"];case _.hg:return["+x"];case _.ig:return["-x"]}a=[];switch(b.writingMode){case _.es:a=["+y","-y"];break;case _.hg:a=["+x","-x"];break;case _.ig:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},fP=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=QO(a.l.a)},gP=function(a,b){fP(a.g);a.l.unshift(b);
|
|
8
|
+
for(const c of a.l)a.g.append(c)},hP=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.ls)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(xO);},jP=function(a,b,c,d){const e=document.createElement(_.Nf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);iP(a,c,b);a.h.debug(`Created HTML style element #${b}.`);return e.sheet},kP=function(a,b){a=`.${a.j} .clpp-text-container`;
|
|
9
|
+
const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${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)},lP=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);
|
|
10
|
+
return c},mP=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.o=[]}},iP=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.l.push(()=>d.disconnect())},nP=function(a){a=_.Lg(a.htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=
|
|
11
|
+
!0);return a},tP=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();if(b||a.J!==c&&a.m.getState()===_.Tn)if(a.J=c,c=oP(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,pP(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.Vr(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 _.pg:g="clpp-text-vtt";
|
|
12
|
+
break;case _.Vf:g=zO;break;case _.cs:g=yO}g&&!f.classList.contains(g)&&_.po(f,g);f=QO(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{IO({fontSize:qP(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.pg;var h=d.payloadType===_.Vf;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new rP(d.region,
|
|
13
|
+
{}),c.B.set(d.region.id,f),gP(c.a,f)));d=new sP(d,c.L,e);f?gP(f,d):gP(c.a,d)}}}}},uP=function(a){pP(a);a.J=null;a.o=null;a.f=[]},vP=function(a,b){return a.startTime<=b&&a.endTime>b},oP=function(a,b){var c=EO(a.f,d=>vP(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&vP(a.f[d-1],b);)d--;for(;c+1<a.f.length&&vP(a.f[c+1],b);)c++;return{start:d,end:c}}},pP=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(zO);
|
|
14
|
+
b.classList.remove(yO);a=a.a;fP(a.g);a.l=[]}},qP=function(a,b){const c=QO(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`},zP=class{parse(a){a={input:a};const b=_.ro(_.Gd),c=[];let d=b;for(var e;null!==(e=FO(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);
|
|
15
|
+
else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=wP[f];h?(h=_.ro(h),(f=xP[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||yP[g.localName]&&yP[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(HO(e)));return b}},wP={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},xP={v:"voice",lang:"lang"},yP={rt:"ruby"},GO={"\x26amp;":"\x26",
|
|
16
|
+
"\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var PO=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 AP=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 sP=class extends AP{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)_.po(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===_.Vf){var c=_.ro(_.Gd);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.pg?b=(new zP).parse(b.payload):(c=_.ro(_.Gd),c.textContent=b.payload,b=c);_.po(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.po(b,d);IO({writingMode:XO(this)},b);var d=b;this.a.appendChild(d);_.po(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.po(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.fs,this.f.line=VO(this)?-1:0);e=XO(this);IO({writingMode:e,webkitWritingMode:e,direction:BO,textAlign:YO(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=ZO(this,$O(this));IO({position:"absolute",left:cP(this,e,null),right:bP(this)&&_.z(null)?KO(0,_.of):BO,top:dP(this,e,null),width:VO(this)?KO(this.f.size,"%"):BO,height:aP(this)||bP(this)?KO(this.f.size,"%"):BO},this.a);b=this.f;a=VO(this)?a.height:a.width;c=WO(this);if(b.lineInterpretation===_.fs){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 _.$c:g-=f/2;break;case _.Td:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}bP(this)&&(f=a-f-c);a=f;IO({left:cP(this,e,a),right:bP(this)&&_.z(a)?KO(0,_.of):BO,top:dP(this,e,a)},this.a)}JO(this.C,d)}}o(){return _.ro(_.Gd)}};var BP=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=QO(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.$d;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=QO(a.a);var d=eP(this,a.f),e=WO(a);const g=RO(c);let h=null,k=0;for(const l of d){for(;UO(c,this.a,l)||TO(c,this.a)&&SO(c,this.g);){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||TO(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=RO(c),k=d);c=RO(g)}c=h||g}IO({top:KO(c.top-this.a.top,_.of),bottom:KO(this.a.a-c.a,_.of),left:KO(c.left-this.a.left,_.of),right:KO(this.a.f-c.f,_.of),height:KO(c.height,_.of),width:KO(c.width,_.of)},a.a)}b.style.visibility="visible";this.g.push(QO(a.a))}};var CP=class extends AP{constructor(a,b,c){super(a,b,c);this.g=null;this.l=[]}init(){this.g=new BP(this);this.j=!0}o(){const a=_.ro(_.Gd);_.po(a,this.w);this.id&&(a.id=this.id);return a}};var rP=class extends CP{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 _.ls:b=b.width/100*a.width;break a;default:throw Error(xO);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.ls)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(xO);d=a.height;const e=hP(this,d,a.height);IO(this.B,this.a);IO({left:KO(c,_.of),top:KO(e,_.of),width:KO(b,
|
|
21
|
+
_.of),height:KO(d,_.of)},this.a);this.f.writingMode&&IO({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&IO({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.po(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.ls:f=f.height/100*a.height;break a;case 2:f=f.height;c=new sP(new _.is(0,1,"Lorem ipsum",_.cs),{},{});b=c.a;this.a.appendChild(b);c.init(QO(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(xO);}a=hP(this,f,a.height);IO({top:KO(a,_.of),height:KO(f,_.of)},this.a);this.g=new BP(this,!0);this.j=!0}getId(){return this.f.id}};var DP=class{constructor(a,b){this.h=new _.Q("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.g=b;this.o=[];this.a=jP(this,this.g,this.j);this.f=jP(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.o.some(b=>b===a)){const b=kP(this,a);if(lP(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.o.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 _.w(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],mP(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 EP=class extends _.eu{constructor(a){super(a);this.h=new _.Q(AO);this.m=a;this.L=nP(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new DP(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new CP(null,"clpp-text-container",{});this.A=new _.Wt(a.getSurface(),this.U.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.");
|
|
24
|
+
this.G=new _.Nj(()=>{tP(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=DO(this.f,CO(a));this.o=null;tP(this,!1)}}g(){null==this.j||tP(this,!0)}destroy(){const a=this;return _.w(function*(){null!=a.j&&(uP(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;tP(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.ab(.25),this.L.enableResizeObserver&&this.A.start(),tP(this,!0)):(this.G.stop(),this.A.stop(),uP(this)))}Oc(){return this.f}U(){tP(this,!0)}};_.x(AO,EP);EP.prototype.setTextVisibility=EP.prototype.setTextVisibility;EP.prototype.isTextVisible=EP.prototype.isTextVisible;EP.prototype.remove=EP.prototype.remove;
|
|
26
|
+
EP.prototype.destroy=EP.prototype.destroy;EP.prototype.append=EP.prototype.append;var FP=class{isSupported(a){return!!a.enableHtmlCue&&!_.dk()}create(a){return new EP(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Ft{f(){_.xn(_.ae,new FP)}a(){_.vn.has(_.ae)&&(_.vn.delete(_.ae),_.wn.info("Removed factory: 'html'"))}id(){return _.Of}});};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.T.bind(a));c.on(b,d.MIDPOINT,a.
|
|
4
|
-
b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new
|
|
5
|
-
google.ima.ViewMode.NORMAL);a.H=!0},
|
|
6
|
-
this.f.getIsBumper():!1}
|
|
7
|
-
1}xb(){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.j})),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a.l.getSettings().setAutoPlayAdBreaks(!1);a.l.requestAds(e);return a.f})}start(a){const b=this;return _.
|
|
15
|
-
{this.H&&this.j&&this.j.lb()&&!this.
|
|
16
|
-
|
|
17
|
-
(this.a.destroy(),this.a=null);this.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var gO="clpp.ima.AdsManagerFactory",hO=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===_.Rc?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
|
+
_.Rc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},iO=function(a){return!1===a.I.disableCustomPlayback&&a.a.isCustomPlaybackUsed()&&_.Rj()},jO=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.ha.bind(a));c.on(b,d.LOADED,a.W.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.Yb.bind(a));c.on(b,d.STARTED,a.$.bind(a));c.on(b,d.LOG,a.cb.bind(a));c.on(b,d.AD_PROGRESS,a.Gb.bind(a));c.on(b,d.AD_BUFFERING,a.Fa.bind(a));
|
|
3
|
+
c.on(b,d.FIRST_QUARTILE,a.T.bind(a));c.on(b,d.MIDPOINT,a.eb.bind(a));c.on(b,d.THIRD_QUARTILE,a.aa.bind(a));c.on(b,d.PAUSED,a.fb.bind(a));c.on(b,d.RESUMED,a.Fb.bind(a));c.on(b,d.CLICK,a.R.bind(a));c.on(b,d.SKIPPED,a.X.bind(a));c.on(b,d.IMPRESSION,a.U.bind(a));c.on(b,d.COMPLETE,a.bb.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.$b.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Vb.bind(a))},kO=function(a,b){const c=b?a.ea.create(b.getErrorCode()):null;a.m.onError(new _.G(1,9,10003,{errorType:c},b))},lO=function(a,
|
|
4
|
+
b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.F,a.C)});a.m.trigger(new _.C(b,d))},mO=function(a){a.B=null;lO(a,_.qc);a.o&&a.m.getSurface().hide(a.o)},nO=function(a){_.qo(a.A,{visibility:"visible"})},pO=function(a){return _.w(function*(){a.N.initialize();const b=!!a.m.getConfiguration().muted;(yield a.K.canPlay(b))||iO(a)?oO(a):(lO(a,_.Pc),a.h.warn(_.ka))})},qO=function(a,b){return _.w(function*(){a.N.initialize();yield b.play();oO(a)})},oO=function(a){a.a.init(a.A.offsetWidth,a.A.offsetHeight,
|
|
5
|
+
google.ima.ViewMode.NORMAL);a.a.start();a.H=!0},rO=function(){return!window.google||!google.ima||!google.ima.AdsLoader},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.g=c}rb(){return"Google IMA SDK"}sb(){return google.ima.VERSION}yb(){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()}gc(){return this.f?
|
|
6
|
+
this.f.getIsBumper():!1}Lb(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.De&&typeof b[d].clickThroughUrl===_.Lf);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}vb(){return this.a.getVastMediaWidth()}ub(){return this.a.getVastMediaHeight()}jb(){return this.a.getVastMediaBitrate()}Va(){return this.g?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Mb(){return this.f?this.f.getTimeOffset():0}Nb(){return this.f?this.f.getAdPosition():
|
|
7
|
+
1}xb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.xb;W.prototype.getPositionInSequence=W.prototype.Nb;
|
|
8
|
+
W.prototype.getPodTimeOffset=W.prototype.Mb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Va;W.prototype.getMediaBitrate=W.prototype.jb;W.prototype.getMediaHeight=W.prototype.ub;W.prototype.getMediaWidth=W.prototype.vb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Lb;W.prototype.isBumper=W.prototype.gc;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getDuration=W.prototype.getDuration;
|
|
9
|
+
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.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.yb;W.prototype.getAdManagerVersion=W.prototype.sb;W.prototype.getAdManagerName=W.prototype.rb;var sO=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 tO=class{constructor(a){this.a=a}getCuePoints(){return this.a}Ob(){return 0<=this.a.indexOf(0)||0===this.a.length}lb(){return 0<=this.a.indexOf(-1)}};tO.prototype.hasPostroll=tO.prototype.lb;tO.prototype.hasPreroll=tO.prototype.Ob;tO.prototype.getCuePoints=tO.prototype.getCuePoints;var uO=class{constructor(a){this.m=a;this.A=a.getSurface().getMedia();a=this.m.getConfiguration();a=_.Lg(a.ima||{});this.I=a=_.Kg({disableCustomPlayback:!1},a);this.o=this.m.bc("ima").wc();this.N=this.m.bc("ima").g;this.l=this.m.bc("ima").a;this.K=new _.Yt;this.h=new _.Q("clpp.ima");this.g=this.a=null;this.f=new _.Ym;this.H=!1;this.w=new _.as;this.ea=new sO;this.B=null;this.L=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.Jb.bind(this));a.on(this.l,b,this.Hb.bind(this));a.on(this.m,_.Ud,this.Xb.bind(this))}}Jb(a){this.a=a.getAdsManager(this.A,hO(this));this.a.isCustomPlaybackUsed()&&!iO(this)?(this.h.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.G(1,9,10002)),this.dispose()):(this.g=new _.Wt(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 tO(a),this.m.trigger(new _.C(_.tc,
|
|
11
|
+
{adsTimeline:this.j})),jO(this));this.f.resolve()}Hb(a){kO(this,a.getError());this.f.resolve()}Yb(a){const b=this;return _.w(function*(){b.G=!0;if(iO(b)){b.J=b.m.getPosition();yield b.m.detach();var c=b.m;c.a&&c.a.stopForwardingEventsTo(c)}else yield b.m.pause(),_.qo(b.A,{visibility:_.$d});lO(b,_.bc,a);b.g.start()})}ha(){const a=this;return _.w(function*(){a.a.start()})}W(a){a.getAd().isLinear()?lO(this,_.jc,a):(this.a.discardAdBreak(),this.F||(this.F=!0,this.m.play()))}$(a){this.B=a.getAd().getDuration();
|
|
12
|
+
lO(this,_.pc,a);this.m.getSurface().show(this.o)}cb(a){a=a.getAdData();kO(this,a?a.adError:null);mO(this)}Gb(a){lO(this,_.mc,a)}Fa(a){lO(this,_.ec,a)}T(a){lO(this,_.hc,a)}eb(a){lO(this,_.kc,a)}aa(a){lO(this,_.rc,a)}fb(a){lO(this,_.lc,a)}Fb(a){lO(this,_.nc,a)}R(a){this.pause();lO(this,_.fc,a)}X(a){lO(this,_.oc,a);mO(this)}U(a){lO(this,_.ic,a)}bb(a){lO(this,_.gc,a);mO(this)}$b(){const a=this;return _.w(function*(){a.F=!0;if(iO(a)&&null!==a.J){var b=a.m;b.a&&b.a.forwardEventsTo(b);yield _.kp(a.m);a.C||
|
|
13
|
+
(yield a.m.seek(a.J))}else{if(!a.G)return a.m.play();nO(a)}a.G=!1;a.g&&a.g.stop();a.C||(yield a.m.play());lO(a,_.cc)})}Vb(){this.L=!0}Xb(){this.C=!0;this.l.contentComplete()}load(){const a=this;return _.w(function*(){var b=a.m;const c=a.I;try{if(typeof c.adTagUrl!==_.Lf)throw new _.G(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=
|
|
14
|
+
c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.l.getSettings().setAutoPlayAdBreaks(!1);a.l.requestAds(e);return a.f})}start(a){const b=this;return _.w(function*(){b.a&&b.j&&!b.H?b.j.Ob()?yield pO(b):yield qO(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();
|
|
15
|
+
return 0>a?0:this.B-a}dispose(){return(new Promise(a=>{this.H&&this.j&&this.j.lb()&&!this.L?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.o&&this.m.getSurface().hide(this.o)}),_.lh(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(()=>{nO(this);this.w.release();this.g&&(this.g.stop(),this.g=null);this.a&&(this.a.destroy(),this.a=null)})}};
|
|
16
|
+
uO.prototype.getPosition=uO.prototype.getPosition;uO.prototype.setVolume=uO.prototype.setVolume;uO.prototype.getVolume=uO.prototype.getVolume;uO.prototype.skip=uO.prototype.skip;uO.prototype.pause=uO.prototype.pause;uO.prototype.resume=uO.prototype.resume;var vO=class extends _.hu{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(rO())return a.onError(new _.G(1,9,1E4));this.f=_.oo(_.Gd,{"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(_.ra);this.a.getSettings().setPlayerVersion(_.fa);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)}xg(){return this.a}vg(){return this.g}wc(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",vO);vO.prototype.getAdContainer=vO.prototype.wc;vO.prototype.getAdDisplayContainer=vO.prototype.vg;vO.prototype.getAdsLoader=vO.prototype.xg;vO.Id="ima";vO.isSdkMissing=rO;_.Vo(new class{create(){return new vO}});var wO=class{constructor(){this.a=new _.Q(gO)}name(){return gO}isSupported(a,b){return a.namespace()===_.kd?!1:rO()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new uO(a)}};wO.prototype.create=wO.prototype.create;wO.prototype.isSupported=wO.prototype.isSupported;wO.prototype.name=wO.prototype.name;_.lo(new wO);};f.call(g, window);
|