From 8545124744ca0bd632d6b8cdbc2afe06d79f5b5a Mon Sep 17 00:00:00 2001 From: weizhenye Date: Wed, 24 Jul 2019 00:56:40 +0800 Subject: [PATCH] 0.0.10 --- dist/ass.js | 6 +++--- dist/ass.min.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/ass.js b/dist/ass.js index dbac79b..f2658c5 100644 --- a/dist/ass.js +++ b/dist/ass.js @@ -1,8 +1,8 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global.ASS = factory()); -}(this, (function () { 'use strict'; + (global = global || self, global.ASS = factory()); +}(this, function () { 'use strict'; function parseEffect(text) { var param = text @@ -2058,4 +2058,4 @@ return ASS; -}))); +})); diff --git a/dist/ass.min.js b/dist/ass.min.js index 2163567..bf2d71b 100644 --- a/dist/ass.min.js +++ b/dist/ass.min.js @@ -1 +1 @@ -(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?module.exports=e():typeof define==="function"&&define.amd?define(e):t.ASS=e()})(this,function(){"use strict";function l(t){var e=t.toLowerCase().trim().split(/\s*;\s*/);if(e[0]==="banner"){return{name:e[0],delay:e[1]*1||0,leftToRight:e[2]*1||0,fadeAwayWidth:e[3]*1||0}}if(/^scroll\s/.test(e[0])){return{name:e[0],y1:Math.min(e[1]*1,e[2]*1),y2:Math.max(e[1]*1,e[2]*1),delay:e[3]*1||0,fadeAwayHeight:e[4]*1||0}}return null}function y(t){return t.toLowerCase().replace(/([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/g," $1 ").replace(/([mnlbspc])/g," $1 ").trim().replace(/\s+/g," ").split(/\s(?=[mnlbspc])/).map(function(t){return t.split(" ").filter(function(t,e){return!(e&&Number.isNaN(t*1))})})}var t=["b","i","u","s","fsp","k","K","kf","ko","kt","fe","q","p","pbo","a","an","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"];var x=t.map(function(t){return{name:t,regex:new RegExp("^"+t+"-?\\d")}});function b(t){var e;var a={};for(var r=0;re.length){var r=a.slice(e.length-1).join();a=a.slice(0,e.length-1);a.push(r)}var i={};for(var n=0;n0)a[r]=arguments[r+1];for(var i=0;i-10?1+s/10:1)*a.fs:s*1}}if(e==="t"){var T=s.t1;var E=s.accel;var F=s.tags;var j=s.t2||(a.end-a.start)*1e3;var L={};F.forEach(function(t){var e=Object.keys(t)[0];if(~O.indexOf(e)&&!(e==="clip"&&!t[e].dots)){q(L,R(t,e,a))}});return{t:{t1:T,t2:j,accel:E,tag:L}}}return n={},n[e]=s,n}var z=[null,1,2,3,null,7,8,9,null,4,5,6];var H=["r","a","an","pos","org","move","fade","fad","clip"];function I(t,e){return{name:t,borderStyle:e[t].style.BorderStyle,tag:e[t].tag,fragments:[]}}function S(t){var e=t.styles;var a=t.name;var r=t.parsed;var i=t.start;var n=t.end;var s;var o;var l;var f;var h;var v;var c=[];var d=I(a,e);var p={};for(var u=0;u=s.End){continue}if(!e[s.Style]){s.Style="Default"}var o=e[s.Style].style;var l=S({styles:e,name:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;r=Math.min(r,s.Layer);i.push(q({layer:s.Layer,start:s.Start,end:s.End,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var h=0;h0?1:-1;var u=l>0?1:-1;o=Math.abs(o);l=Math.abs(l);for(var g=Math.max(i,o-i);g=4&&e<=6){o.y=n+r/2}if(e>=7){o.y=n}}for(var l=s.childNodes.length-1;l>=0;l--){var f=s.childNodes[l];if(f.dataset.hasRotate==="true"){var h=o.x-i-f.offsetLeft;var v=o.y-n-f.offsetTop;f.style.cssText+=M.transform+"transform-origin:"+h+"px "+v+"px;"}}}function V(t,e){return"@"+M.animation+"keyframes "+t+" {"+e+"}\n"}var J=function t(){this.obj={}};J.prototype.set=function t(e,a,r){if(!this.obj[e]){this.obj[e]={}}this.obj[e][a]=r};J.prototype.setT=function t(e){var a=e.t1;var r=e.t2;var i=e.duration;var n=e.prop;var s=e.from;var o=e.to;this.set("0.000%",n,s);if(a/g,">").replace(/\s/g," ").replace(/\\h/g," ").replace(/\\N/g,"
").replace(/\\n/g,e===2?"
":" ")}function at(t){var d=this;var e=document.createElement("div");e.className="ASS-dialogue";var p=document.createDocumentFragment();var a=t.slices;var u=t.start;var g=t.end;a.forEach(function(v){var c=v.borderStyle;v.fragments.forEach(function(i){var t=i.text;var n=i.drawing;var e=i.animationName;var a=q({},v.tag,i.tag);var s="display:inline-block;";var r=d.video.currentTime;if(!n){s+='font-family:"'+a.fn+'",Arial;';s+="font-size:"+d.scale*G(a.fn,a.fs)+"px;";s+="color:"+P(a.a1+a.c1)+";";var o=/Yes/i.test(d.info.ScaledBorderAndShadow)?d.scale:1;if(c===1){s+="text-shadow:"+X(a,o)+";"}if(c===3){s+="background-color:"+P(a.a3+a.c3)+";"+"box-shadow:"+X(a,o)+";"}s+=a.b?"font-weight:"+(a.b===1?"bold":a.b)+";":"";s+=a.i?"font-style:italic;":"";s+=a.u||a.s?"text-decoration:"+(a.u?"underline":"")+" "+(a.s?"line-through":"")+";":"";s+=a.fsp?"letter-spacing:"+a.fsp+"px;":"";if(a.q===1||a.q===0||a.q===3){s+="word-break:break-all;white-space:normal;"}if(a.q===2){s+="word-break:normal;white-space:nowrap;"}}var l=D.some(function(t){return/^fsc[xy]$/.test(t)?a[t]!==100:!!a[t]});if(l){s+=M.transform+"transform:"+W(a)+";";if(!n){s+="transform-style:preserve-3d;word-break:normal;white-space:nowrap;"}}if(e){s+=Q(e,g-u,Math.min(0,u-r))}if(n&&a.pbo){var f=d.scale*-a.pbo*(a.fscy||100)/100;s+="vertical-align:"+f+"px;"}var h=/"fr[xyz]":[^0]/.test(JSON.stringify(a));et(t,a.q).split("
").forEach(function(t,e){var a=document.createElement("span");a.dataset.hasRotate=h;if(n){var r=tt.call(d,i,v.tag);a.style.cssText=r.cssText;a.appendChild(r.$svg)}else{if(e){p.appendChild(document.createElement("br"))}if(!t){return}a.innerHTML=t}a.style.cssText+=s;p.appendChild(a)})})});e.appendChild(p);return e}function rt(t){var e=t.layer;var a=t.margin;var o=t.width;var r=t.height;var i=t.alignment;var n=t.end;var l=this.width-(this.scale*(a.left+a.right)|0);var s=this.height;var f=this.scale*a.vertical|0;var h=this.video.currentTime*100;this._.space[e]=this._.space[e]||{left:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},center:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},right:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)}};var v=this._.space[e];var c=["right","left","center"][i%3];var d=function(t){var e=v.left.width[t];var a=v.center.width[t];var r=v.right.width[t];var i=v.left.end[t];var n=v.center.end[t];var s=v.right.end[t];return c==="left"&&(i>h&&e||n>h&&a&&2*o+a>l||s>h&&r&&o+r>l)||c==="center"&&(i>h&&e&&2*e+o>l||n>h&&a||s>h&&r&&2*r+o>l)||c==="right"&&(i>h&&e&&e+o>l||n>h&&a&&2*o+a>l||s>h&&r)};var p=0;var u=0;var g=function(t){p=d(t)?0:p+1;if(p>=r){u=t;return true}return false};if(i<=3){for(var m=s-f-1;m>f;m--){if(g(m)){break}}}else if(i>=7){for(var y=f+1;y>1;x3){u-=r-1}for(var b=u;b=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}l=e.lefttoright?-i:this.width}}else if(t.pos||a){var h=t.pos||{x:0,y:0};if(r%3===1){l=this.scale*h.x}if(r%3===2){l=this.scale*h.x-i/2}if(r%3===0){l=this.scale*h.x-i}if(r<=3){f=this.scale*h.y-n}if(r>=4&&r<=6){f=this.scale*h.y-n/2}if(r>=7){f=this.scale*h.y}}else{if(r%3===1){l=0}if(r%3===2){l=(this.width-i)/2}if(r%3===0){l=this.width-i-this.scale*s.right}var v=o.some(function(t){return t.fragments.some(function(t){var e=t.animationName;return e})});if(v){if(r<=3){f=this.height-n-s.vertical}if(r>=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}}else{f=rt.call(this,t)}}return{x:l,y:f}}function nt(t){var e=t.layer;var a=t.start;var r=t.end;var i=t.alignment;var n=t.effect;var s=t.pos;var o=t.margin;var l=t.animationName;var f=t.width;var h=t.height;var v=t.x;var c=t.y;var d=this.video.currentTime;var p="";if(e){p+="z-index:"+e+";"}if(l){p+=Q(l,r-a,Math.min(0,a-d))}p+="text-align:"+["right","left","center"][i%3]+";";if(!n){var u=this.width-this.scale*(o.left+o.right);p+="max-width:"+u+"px;";if(!s){if(i%3===1){p+="margin-left:"+this.scale*o.left+"px;"}if(i%3===0){p+="margin-right:"+this.scale*o.right+"px;"}if(f>this.width-this.scale*(o.left+o.right)){p+="margin-left:"+this.scale*o.left+"px;";p+="margin-right:"+this.scale*o.right+"px;"}}}p+="width:"+f+"px;height:"+h+"px;left:"+v+"px;top:"+c+"px;";return p}function st(t){var e=at.call(this,t);q(t,{$div:e});this._.$stage.appendChild(e);var a=e.getBoundingClientRect();var r=a.width;var i=a.height;q(t,{width:r,height:i});q(t,it.call(this,t));e.style.cssText=nt.call(this,t);L(t);T.call(this,t);return t}function ot(){var t=this.video.currentTime;for(var e=this._.stagings.length-1;e>=0;e--){var a=this._.stagings[e];var r=a.end;if(a.effect&&/scroll/.test(a.effect.name)){var i=a.effect;var n=i.y1;var s=i.y2;var o=i.delay;var l=((s||this._.resampledRes.height)-n)/(1e3/o);r=Math.min(r,a.start+l)}if(r=f[this._.index].start){if(ti[e+t>>1].end){t=e+t>>1}if(!t){return 0}for(var a=t;ar&&r>=i[a].start||a&&i[a-1].ende.length){var r=a.slice(e.length-1).join();a=a.slice(0,e.length-1);a.push(r)}var i={};for(var n=0;n0)a[r]=arguments[r+1];for(var i=0;i-10?1+s/10:1)*a.fs:s*1}}if(e==="t"){var T=s.t1;var E=s.accel;var F=s.tags;var j=s.t2||(a.end-a.start)*1e3;var L={};F.forEach(function(t){var e=Object.keys(t)[0];if(~O.indexOf(e)&&!(e==="clip"&&!t[e].dots)){q(L,R(t,e,a))}});return{t:{t1:T,t2:j,accel:E,tag:L}}}return n={},n[e]=s,n}var z=[null,1,2,3,null,7,8,9,null,4,5,6];var H=["r","a","an","pos","org","move","fade","fad","clip"];function I(t,e){return{name:t,borderStyle:e[t].style.BorderStyle,tag:e[t].tag,fragments:[]}}function S(t){var e=t.styles;var a=t.name;var r=t.parsed;var i=t.start;var n=t.end;var s;var o;var l;var f;var h;var v;var c=[];var d=I(a,e);var p={};for(var u=0;u=s.End){continue}if(!e[s.Style]){s.Style="Default"}var o=e[s.Style].style;var l=S({styles:e,name:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;r=Math.min(r,s.Layer);i.push(q({layer:s.Layer,start:s.Start,end:s.End,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var h=0;h0?1:-1;var u=l>0?1:-1;o=Math.abs(o);l=Math.abs(l);for(var g=Math.max(i,o-i);g=4&&e<=6){o.y=n+r/2}if(e>=7){o.y=n}}for(var l=s.childNodes.length-1;l>=0;l--){var f=s.childNodes[l];if(f.dataset.hasRotate==="true"){var h=o.x-i-f.offsetLeft;var v=o.y-n-f.offsetTop;f.style.cssText+=M.transform+"transform-origin:"+h+"px "+v+"px;"}}}function V(t,e){return"@"+M.animation+"keyframes "+t+" {"+e+"}\n"}var J=function t(){this.obj={}};J.prototype.set=function t(e,a,r){if(!this.obj[e]){this.obj[e]={}}this.obj[e][a]=r};J.prototype.setT=function t(e){var a=e.t1;var r=e.t2;var i=e.duration;var n=e.prop;var s=e.from;var o=e.to;this.set("0.000%",n,s);if(a/g,">").replace(/\s/g," ").replace(/\\h/g," ").replace(/\\N/g,"
").replace(/\\n/g,e===2?"
":" ")}function at(t){var d=this;var e=document.createElement("div");e.className="ASS-dialogue";var p=document.createDocumentFragment();var a=t.slices;var u=t.start;var g=t.end;a.forEach(function(v){var c=v.borderStyle;v.fragments.forEach(function(i){var t=i.text;var n=i.drawing;var e=i.animationName;var a=q({},v.tag,i.tag);var s="display:inline-block;";var r=d.video.currentTime;if(!n){s+='font-family:"'+a.fn+'",Arial;';s+="font-size:"+d.scale*G(a.fn,a.fs)+"px;";s+="color:"+P(a.a1+a.c1)+";";var o=/Yes/i.test(d.info.ScaledBorderAndShadow)?d.scale:1;if(c===1){s+="text-shadow:"+X(a,o)+";"}if(c===3){s+="background-color:"+P(a.a3+a.c3)+";"+"box-shadow:"+X(a,o)+";"}s+=a.b?"font-weight:"+(a.b===1?"bold":a.b)+";":"";s+=a.i?"font-style:italic;":"";s+=a.u||a.s?"text-decoration:"+(a.u?"underline":"")+" "+(a.s?"line-through":"")+";":"";s+=a.fsp?"letter-spacing:"+a.fsp+"px;":"";if(a.q===1||a.q===0||a.q===3){s+="word-break:break-all;white-space:normal;"}if(a.q===2){s+="word-break:normal;white-space:nowrap;"}}var l=D.some(function(t){return/^fsc[xy]$/.test(t)?a[t]!==100:!!a[t]});if(l){s+=M.transform+"transform:"+W(a)+";";if(!n){s+="transform-style:preserve-3d;word-break:normal;white-space:nowrap;"}}if(e){s+=Q(e,g-u,Math.min(0,u-r))}if(n&&a.pbo){var f=d.scale*-a.pbo*(a.fscy||100)/100;s+="vertical-align:"+f+"px;"}var h=/"fr[xyz]":[^0]/.test(JSON.stringify(a));et(t,a.q).split("
").forEach(function(t,e){var a=document.createElement("span");a.dataset.hasRotate=h;if(n){var r=tt.call(d,i,v.tag);a.style.cssText=r.cssText;a.appendChild(r.$svg)}else{if(e){p.appendChild(document.createElement("br"))}if(!t){return}a.innerHTML=t}a.style.cssText+=s;p.appendChild(a)})})});e.appendChild(p);return e}function rt(t){var e=t.layer;var a=t.margin;var o=t.width;var r=t.height;var i=t.alignment;var n=t.end;var l=this.width-(this.scale*(a.left+a.right)|0);var s=this.height;var f=this.scale*a.vertical|0;var h=this.video.currentTime*100;this._.space[e]=this._.space[e]||{left:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},center:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},right:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)}};var v=this._.space[e];var c=["right","left","center"][i%3];var d=function(t){var e=v.left.width[t];var a=v.center.width[t];var r=v.right.width[t];var i=v.left.end[t];var n=v.center.end[t];var s=v.right.end[t];return c==="left"&&(i>h&&e||n>h&&a&&2*o+a>l||s>h&&r&&o+r>l)||c==="center"&&(i>h&&e&&2*e+o>l||n>h&&a||s>h&&r&&2*r+o>l)||c==="right"&&(i>h&&e&&e+o>l||n>h&&a&&2*o+a>l||s>h&&r)};var p=0;var u=0;var g=function(t){p=d(t)?0:p+1;if(p>=r){u=t;return true}return false};if(i<=3){for(var m=s-f-1;m>f;m--){if(g(m)){break}}}else if(i>=7){for(var y=f+1;y>1;x3){u-=r-1}for(var b=u;b=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}l=e.lefttoright?-i:this.width}}else if(t.pos||a){var h=t.pos||{x:0,y:0};if(r%3===1){l=this.scale*h.x}if(r%3===2){l=this.scale*h.x-i/2}if(r%3===0){l=this.scale*h.x-i}if(r<=3){f=this.scale*h.y-n}if(r>=4&&r<=6){f=this.scale*h.y-n/2}if(r>=7){f=this.scale*h.y}}else{if(r%3===1){l=0}if(r%3===2){l=(this.width-i)/2}if(r%3===0){l=this.width-i-this.scale*s.right}var v=o.some(function(t){return t.fragments.some(function(t){var e=t.animationName;return e})});if(v){if(r<=3){f=this.height-n-s.vertical}if(r>=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}}else{f=rt.call(this,t)}}return{x:l,y:f}}function nt(t){var e=t.layer;var a=t.start;var r=t.end;var i=t.alignment;var n=t.effect;var s=t.pos;var o=t.margin;var l=t.animationName;var f=t.width;var h=t.height;var v=t.x;var c=t.y;var d=this.video.currentTime;var p="";if(e){p+="z-index:"+e+";"}if(l){p+=Q(l,r-a,Math.min(0,a-d))}p+="text-align:"+["right","left","center"][i%3]+";";if(!n){var u=this.width-this.scale*(o.left+o.right);p+="max-width:"+u+"px;";if(!s){if(i%3===1){p+="margin-left:"+this.scale*o.left+"px;"}if(i%3===0){p+="margin-right:"+this.scale*o.right+"px;"}if(f>this.width-this.scale*(o.left+o.right)){p+="margin-left:"+this.scale*o.left+"px;";p+="margin-right:"+this.scale*o.right+"px;"}}}p+="width:"+f+"px;height:"+h+"px;left:"+v+"px;top:"+c+"px;";return p}function st(t){var e=at.call(this,t);q(t,{$div:e});this._.$stage.appendChild(e);var a=e.getBoundingClientRect();var r=a.width;var i=a.height;q(t,{width:r,height:i});q(t,it.call(this,t));e.style.cssText=nt.call(this,t);L(t);T.call(this,t);return t}function ot(){var t=this.video.currentTime;for(var e=this._.stagings.length-1;e>=0;e--){var a=this._.stagings[e];var r=a.end;if(a.effect&&/scroll/.test(a.effect.name)){var i=a.effect;var n=i.y1;var s=i.y2;var o=i.delay;var l=((s||this._.resampledRes.height)-n)/(1e3/o);r=Math.min(r,a.start+l)}if(r=f[this._.index].start){if(ti[e+t>>1].end){t=e+t>>1}if(!t){return 0}for(var a=t;ar&&r>=i[a].start||a&&i[a-1].end