mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 03:18:19 -07:00
24 lines
109 KiB
JavaScript
24 lines
109 KiB
JavaScript
|
/**
|
||
|
* libjass
|
||
|
*
|
||
|
* https://github.com/Arnavion/libjass
|
||
|
*
|
||
|
* Copyright 2013 Arnav Singh
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
!function(e,t){var r=this;"function"==typeof define&&define.amd?define([],function(){return t(r)}):"object"==typeof exports&&"object"==typeof module?module.exports=t(r):"object"==typeof exports?exports.libjass=t(r):e.libjass=t(r)}(this,function(e){"use strict";return function(e){function t(n){if(r[n])return r[n];var i=r[n]=Object.create(null);return e[n](i,t),i}var r=Object.create(null);return t(0)}([function(e,t){var r=t(23),n=t(23);e.debugMode=n.debugMode,e.verboseMode=n.verboseMode;var i=t(33),o=t(33);e.Set=o.Set;var a=t(30),l=t(30);e.Map=l.Map;var s=t(32),u=t(32);e.Promise=u.Promise,e.DeferredPromise=u.DeferredPromise;var p=t(37);e.webworker=p;var c=t(8);e.parts=c;var h=t(1);e.parser=h;var f=t(14);e.renderers=f;var d=t(24);e.ASS=d.ASS;var _=t(25);e.Attachment=_.Attachment,e.AttachmentType=_.AttachmentType;var g=t(26);e.Dialogue=g.Dialogue;var v=t(28);e.ScriptProperties=v.ScriptProperties;var y=t(29);e.Style=y.Style;var m=t(27);e.BorderStyle=m.BorderStyle,e.Format=m.Format,e.WrappingStyle=m.WrappingStyle,Object.defineProperties(e,{debugMode:{get:function(){return r.debugMode},set:r.setDebugMode},verboseMode:{get:function(){return r.verboseMode},set:r.setVerboseMode},Set:{get:function(){return i.Set},set:i.setImplementation},Map:{get:function(){return a.Map},set:a.setImplementation},Promise:{get:function(){return s.Promise},set:s.setImplementation}})},function(e,t){var r=t(3);e.parse=r.parse;var n=t(5);e.BrowserReadableStream=n.BrowserReadableStream,e.StringStream=n.StringStream,e.XhrStream=n.XhrStream;var i=t(4);e.StreamParser=i.StreamParser,e.SrtStreamParser=i.SrtStreamParser},function(e,t){function r(e){var t=e.indexOf(":");if(-1===t)return null;var r=e.substr(0,t),n=e.substr(t+1).replace(/^\s+/,"");return{name:r,value:n}}function n(e,t){var n=r(e);if(null===n)return null;var o=n.value.split(",");o.length>t.length&&(o[t.length-1]=o.slice(t.length-1).join(","));var a=new i.Map;return t.forEach(function(e,t){a.set(e,o[t])}),{type:n.name,template:a}}var i=t(30);e.parseLineIntoProperty=r,e.parseLineIntoTypedTemplate=n},function(e,t){function r(e,t){var r=new s(e,t);if(null===r.result||r.result.end!==e.length)throw o.debugMode&&console.error("Parse failed. %s %s %o",t,e,r.result),new Error("Parse failed.");return r.result.value}function n(e,t,r,n){s.prototype["parse_tag_"+e]=function(i){var o=this,a=new h(i);if(null===o.read(a,e))return i.pop(),null;var l=r.call(o,a);if(null!==l)a.value=new t(l.value);else{if(n)return i.pop(),null;a.value=new t(null)}return a}}var i=t(8),o=t(23),a=t(30),l=new a.Map;e.parse=r;var s=function(){function e(e,t){this.e=e,this.t=new h(null),this.r=l.get(t).call(this,this.t)}return Object.defineProperty(e.prototype,"result",{get:function(){return this.r},enumerable:!0,configurable:!0}),e.prototype.parse_dialogueParts=function(e){var t,n=new h(e);for(n.value=[];this.n();){var o=this.parse_enclosedTags(n);if(null!==o)(t=n.value).push.apply(t,o.value);else{var a=this.parse_newline(n)||this.parse_hardspace(n)||this.parse_text(n);if(null===a)return e.pop(),null;if(a.value instanceof i.Text&&n.value[n.value.length-1]instanceof i.Text){var l=n.value[n.value.length-1];n.value[n.value.length-1]=new i.Text(l.value+a.value.value)}else n.value.push(a.value)}}var s=!1;return n.value.forEach(function(e,t){e instanceof i.DrawingMode?s=0!==e.scale:e instanceof i.Text&&s&&(n.value[t]=new i.DrawingInstructions(r(e.value,"drawingInstructions")))}),n},e.prototype.parse_enclosedTags=function(e){var t=new h(e);if(t.value=[],null===this.read(t,"{"))return e.pop(),null;for(var r=this.i();this.n()&&"}"!==r;r=this.i()){var n=null;if(null!==this.read(t,"\\")&&(n=this.parse_tag_alpha(t)||this.parse_tag_iclip(t)||this.parse_tag_xbord(t)||this.parse_tag_ybord(t)||this.parse_tag_xshad(t)||this.parse_tag_yshad(t)||this.parse_tag_blur(t)||this.parse_tag_bord(t)||this.parse_tag_clip(t)||this.parse_tag_fade(t)||this.parse_tag_fscx(t)||this.parse_tag_fscy(t)||this.parse_tag_move(t)||this.parse_tag_shad(t)||this.parse_tag_fad(t)||this.parse_tag_fax(t)||this.parse_tag_fay(t)||this.parse_tag_frx(t)||this.parse_tag_fry(t)||this.pars
|
||
|
for(var u=h.read(i),d=new s.Set,n=0;n<u.count;n++){var _=f.read(i);switch(_.nameId){case 1:case 4:case 6:var g=a.offset+u.stringOffset+_.offset,v=r.subarray(g,g+_.length);switch(_.platformId){case 1:for(var y="",m=0;m<v.length;m++)y+=String.fromCharCode(v[m]);d.add(y);break;case 3:for(var b="",m=0;m<v.length;m+=2)b+=String.fromCharCode((v[m]<<8)+v[m+1]);d.add(b)}}}return d}function n(e){var t=e.W;return e.read=function(r){for(var n=new e,i=0;i<t.length;i++){var a=t[i],l=void 0;switch(a.type){case o.Char:l=String.fromCharCode(r.dataView.getInt8(r.position)),r.position+=1;break;case o.Uint16:l=r.dataView.getUint16(r.position),r.position+=2;break;case o.Uint32:l=r.dataView.getUint32(r.position),r.position+=4}n[a.field]=l}return n},e}function i(e){var t=u.get(e);return void 0===t&&(t=function(t,r){var n=t.constructor;void 0===n.W&&(n.W=[]),n.W.push({type:e,field:r})},u.set(e,t)),t}var o,a=t(34).L,l=t(30),s=t(33);!function(e){e[e.Char=0]="Char",e[e.Uint16=1]="Uint16",e[e.Uint32=2]="Uint32"}(o||(o={}));var u=new l.Map,p=function(){function e(){}return a([i(o.Uint16)],e.prototype,"majorVersion",void 0),a([i(o.Uint16)],e.prototype,"minorVersion",void 0),a([i(o.Uint16)],e.prototype,"numTables",void 0),a([i(o.Uint16)],e.prototype,"searchRange",void 0),a([i(o.Uint16)],e.prototype,"entrySelector",void 0),a([i(o.Uint16)],e.prototype,"rangeShift",void 0),e=a([n],e)}(),c=function(){function e(){}return a([i(o.Char)],e.prototype,"c1",void 0),a([i(o.Char)],e.prototype,"c2",void 0),a([i(o.Char)],e.prototype,"c3",void 0),a([i(o.Char)],e.prototype,"c4",void 0),a([i(o.Uint32)],e.prototype,"checksum",void 0),a([i(o.Uint32)],e.prototype,"offset",void 0),a([i(o.Uint32)],e.prototype,"length",void 0),e=a([n],e)}(),h=function(){function e(){}return a([i(o.Uint16)],e.prototype,"formatSelector",void 0),a([i(o.Uint16)],e.prototype,"count",void 0),a([i(o.Uint16)],e.prototype,"stringOffset",void 0),e=a([n],e)}(),f=function(){function e(){}return a([i(o.Uint16)],e.prototype,"platformId",void 0),a([i(o.Uint16)],e.prototype,"encodingId",void 0),a([i(o.Uint16)],e.prototype,"languageId",void 0),a([i(o.Uint16)],e.prototype,"nameId",void 0),a([i(o.Uint16)],e.prototype,"length",void 0),a([i(o.Uint16)],e.prototype,"offset",void 0),e=a([n],e)}();e.getTtfNames=r},function(e){var t=function(){function e(e,t){this.I=e,this.X=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this.I},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this.X},enumerable:!0,configurable:!0}),e}();e.MoveInstruction=t;var r=function(){function e(e,t){this.I=e,this.X=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this.I},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this.X},enumerable:!0,configurable:!0}),e}();e.LineInstruction=r;var n=function(){function e(e,t,r,n,i,o){this.Y=e,this.V=t,this.B=r,this.z=n,this.G=i,this.q=o}return Object.defineProperty(e.prototype,"x1",{get:function(){return this.Y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this.V},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this.B},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this.z},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x3",{get:function(){return this.G},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y3",{get:function(){return this.q},enumerable:!0,configurable:!0}),e}();e.CubicBezierCurveInstruction=n},function(e,t){var r=t(7);e.drawing=r;var n=function(){function e(e,t,r,n){void 0===n&&(n=1),this.U=e,this.H=t,this.K=r,this.Z=n}return Object.defineProperty(e.prototype,"red",{get:function(){return this.U},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"green",{get:function(){return this.H},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blue",{get:function(){return this.K},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:functi
|
||
|
}).filter(function(e){return null!==e}),o=p.get(r);void 0!==o&&(v=v.concat(o));var b=v.map(function(e){var t=s.get(e);return void 0===t&&(t=new y.Promise(function(t,r){var n=new XMLHttpRequest;n.addEventListener("load",function(){f.debugMode&&console.log("Preloaded "+e+"."),t(null)}),n.addEventListener("error",function(e){r(e)}),n.open("GET",e,!0),n.send()}),s.set(e,t)),t}),w=0===b.length?y.Promise.resolve(null):y.first(b).catch(function(e){return console.warn("Fetching fonts for "+r+" at "+v.join(", ")+" failed: %o",e),null});n=a.rt(r,w)}l.push(n.then(function(e){return a.Je.set(r,e)}))}),y.Promise.all(l).then(function(){f.debugMode&&console.log("All fonts have been preloaded."),a.xe()})}return n(r,t),Object.defineProperty(r.prototype,"libjassSubsWrapper",{get:function(){return this.He},enumerable:!0,configurable:!0}),r.prototype.resize=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0),this.nt(),this.et.style.width=e.toFixed(3)+"px",this.et.style.height=t.toFixed(3)+"px",this.et.style.left=r.toFixed(3)+"px",this.et.style.top=n.toFixed(3)+"px",this.it=e,this.ot=e/this.ass.properties.resolutionX,this.at=t/this.ass.properties.resolutionY,this.Qe.clear(),-1!==this.clock.currentTime&&this.Me()},r.prototype.preRender=function(e){var t=this,n=this.Qe.get(e.id);if(n)return n;var a=this.clock.currentTime-e.start;if(e.containsTransformTag&&0>a)return null;var u=document.createElement("div");u.style.marginLeft=(this.ot*e.style.marginLeft).toFixed(3)+"px",u.style.marginRight=(this.ot*e.style.marginRight).toFixed(3)+"px",u.style.marginTop=u.style.marginBottom=(this.at*e.style.marginVertical).toFixed(3)+"px",u.style.minWidth=(this.it-this.ot*(e.style.marginLeft+e.style.marginRight)).toFixed(3)+"px";var p=document.createElement("style");p.id="libjass-animation-styles-"+this.id+"-"+e.id,p.type="text/css";var c=new i.AnimationCollection(this,p),d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("version","1.1"),d.setAttribute("class","libjass-filters"),d.width.baseVal.valueAsString="0",d.height.baseVal.valueAsString="0";var g=document.createElementNS("http://www.w3.org/2000/svg","defs");d.appendChild(g);var y=null,m=new s.SpanStyles(this,e,this.ot,this.at,this.settings,this.tt,g,this.Je),b=null,w=!1,S=function(e){null!==y&&y.hasChildNodes()&&u.appendChild(m.setStylesOnSpan(y,b)),null!==b&&b.animationDelays.forEach(function(e,t){return c.animationDelays.set(t,e)}),e&&(w?u.appendChild(m.makeNewLine()):u.appendChild(document.createElement("br"))),y=document.createElement("span"),b=new i.AnimationCollection(t,p),w=e};S(!1);for(var O=new o.DrawingStyles(this.ot,this.at),P=this.ass.properties.wrappingStyle,C=0,k=0,E=e.parts;k<E.length;k++){var x=E[k];if(x instanceof h.Italic)m.italic=x.value;else if(x instanceof h.Bold)m.bold=x.value;else if(x instanceof h.Underline)m.underline=x.value;else if(x instanceof h.StrikeThrough)m.strikeThrough=x.value;else if(x instanceof h.Border)m.outlineWidth=x.value,m.outlineHeight=x.value;else if(x instanceof h.BorderX)m.outlineWidth=x.value;else if(x instanceof h.BorderY)m.outlineHeight=x.value;else if(x instanceof h.Shadow)m.shadowDepthX=x.value,m.shadowDepthY=x.value;else if(x instanceof h.ShadowX)m.shadowDepthX=x.value;else if(x instanceof h.ShadowY)m.shadowDepthY=x.value;else if(x instanceof h.Blur)m.blur=x.value;else if(x instanceof h.GaussianBlur)m.gaussianBlur=x.value;else if(x instanceof h.FontName)m.fontName=x.value;else if(x instanceof h.FontSize)m.fontSize=x.value;else if(x instanceof h.FontSizePlus)m.fontSize+=x.value;else if(x instanceof h.FontSizeMinus)m.fontSize-=x.value;else if(x instanceof h.FontScaleX)m.fontScaleX=x.value;else if(x instanceof h.FontScaleY)m.fontScaleY=x.value;else if(x instanceof h.LetterSpacing)m.letterSpacing=x.value;else if(x instanceof h.RotateX)m.rotationX=x.value;else if(x instanceof h.RotateY)m.rotationY=x.value;else if(x instanceof h.RotateZ)m.rotationZ=x.value;else if(x instanceof h.SkewX)m.skewX=x.value;else if(x instanceof h.SkewY)m.skewY=x.value;else if(x instanceof h.PrimaryColor)m.primaryColor=x.value;else if(x instanceof h.Secon
|
||
|
configurable:!0}),Object.defineProperty(e.prototype,"wrappingStyle",{get:function(){return this.lr},set:function(e){this.lr=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleBorderAndShadow",{get:function(){return this.sr},set:function(e){this.sr=e},enumerable:!0,configurable:!0}),e}();e.ScriptProperties=t},function(e,t){var r=t(27),n=t(3),i=t(30),o=function(){function e(e){var t=new i.Map;if(e.forEach(function(e,r){t.set(r.toLowerCase(),e)}),e=t,this.ur=e.get("name"),void 0===this.ur||null===this.ur||this.ur.constructor!==String)throw new Error("Style doesn't have a name.");this.ur=this.ur.replace(/^\*+/,""),this.vt=!!r.valueOrDefault(e,"italic",parseFloat,function(e){return!isNaN(e)},"0"),this.yt=!!r.valueOrDefault(e,"bold",parseFloat,function(e){return!isNaN(e)},"0"),this.St=!!r.valueOrDefault(e,"underline",parseFloat,function(e){return!isNaN(e)},"0"),this.Ot=!!r.valueOrDefault(e,"strikeout",parseFloat,function(e){return!isNaN(e)},"0"),this.mt=r.valueOrDefault(e,"fontname",function(e){return e},function(e){return e.constructor===String},"sans-serif"),this.bt=r.valueOrDefault(e,"fontsize",parseFloat,function(e){return!isNaN(e)},"18"),this.wt=r.valueOrDefault(e,"scalex",parseFloat,function(e){return e>=0},"100")/100,this.Pt=r.valueOrDefault(e,"scaley",parseFloat,function(e){return e>=0},"100")/100,this.kt=r.valueOrDefault(e,"spacing",parseFloat,function(e){return e>=0},"0"),this.dt=r.valueOrDefault(e,"angle",parseFloat,function(e){return!isNaN(e)},"0"),this.jt=r.valueOrDefault(e,"primarycolour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H00FFFFFF"),this.Yt=r.valueOrDefault(e,"secondarycolour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H00FFFF00"),this.Tt=r.valueOrDefault(e,"outlinecolour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H00000000"),this.Ft=r.valueOrDefault(e,"backcolour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H80000000"),this.pr=r.valueOrDefault(e,"outline",parseFloat,function(e){return e>=0},"2"),this.cr=r.valueOrDefault(e,"borderstyle",parseInt,function(e){return r.BorderStyle[r.BorderStyle[e]]===e},"1"),this.hr=r.valueOrDefault(e,"shadow",parseFloat,function(e){return e>=0},"3"),this.ir=r.valueOrDefault(e,"alignment",parseInt,function(e){return e>=1&&9>=e},"2"),this.fr=r.valueOrDefault(e,"marginl",parseFloat,function(e){return!isNaN(e)},"20"),this.dr=r.valueOrDefault(e,"marginr",parseFloat,function(e){return!isNaN(e)},"20"),this._r=r.valueOrDefault(e,"marginv",parseFloat,function(e){return!isNaN(e)},"20")}return Object.defineProperty(e.prototype,"name",{get:function(){return this.ur},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"italic",{get:function(){return this.vt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bold",{get:function(){return this.yt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"underline",{get:function(){return this.St},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strikeThrough",{get:function(){return this.Ot},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontName",{get:function(){return this.mt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return this.bt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleX",{get:function(){return this.wt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleY",{get:function(){return this.Pt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"letterSpacing",{get:function(){return this.kt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationZ",{get:function(){return this.dt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"primaryColor",{get:function(){return this.jt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secondaryColor",{get:function(){return this.Yt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{get:function(){return this.Tt},enumerable:!0,configurable:!0}),O
|
||
|
//# sourceMappingURL=libjass.min.js.map
|