diff --git a/dist/ass-compiler.js b/dist/ass-compiler.js index 7c1f54a..4ec563c 100644 --- a/dist/ass-compiler.js +++ b/dist/ass-compiler.js @@ -728,6 +728,7 @@ var end = ref.end; var alignment; + var q = { q: styles[style].tag.q }; var pos; var org; var move; @@ -754,6 +755,7 @@ for (var j$1 = 0; j$1 < tags.length; j$1++) { var tag$1 = tags[j$1]; alignment = alignment || a2an[tag$1.a || 0] || tag$1.an; + q = compileTag(tag$1, 'q') || q; pos = pos || compileTag(tag$1, 'pos'); org = org || compileTag(tag$1, 'org'); move = move || compileTag(tag$1, 'move'); @@ -793,7 +795,7 @@ } slices.push(slice); - return Object.assign({ alignment: alignment, slices: slices }, pos, org, move, fade, clip); + return Object.assign({ alignment: alignment, slices: slices }, q, pos, org, move, fade, clip); } function compileDialogues(ref) { @@ -949,6 +951,7 @@ xshad: s.Shadow, yshad: s.Shadow, fe: s.Encoding, + // TODO: [breaking change] remove `q` from style q: /^[0-3]$/.test(info.WrapStyle) ? info.WrapStyle * 1 : 2, }; result[s.Name] = { style: s, tag: tag }; @@ -971,6 +974,7 @@ info: tree.info, width: tree.info.PlayResX * 1 || null, height: tree.info.PlayResY * 1 || null, + wrapStyle: /^[0-3]$/.test(tree.info.WrapStyle) ? tree.info.WrapStyle * 1 : 2, collisions: tree.info.Collisions || 'Normal', styles: styles, dialogues: compileDialogues({ diff --git a/dist/ass-compiler.min.js b/dist/ass-compiler.min.js index e548fcf..0748937 100644 --- a/dist/ass-compiler.min.js +++ b/dist/ass-compiler.min.js @@ -1 +1 @@ -(function(t,r){typeof exports==="object"&&typeof module!=="undefined"?r(exports):typeof define==="function"&&define.amd?define(["exports"],r):(t=typeof globalThis!=="undefined"?globalThis:t||self,r(t.assCompiler={}))})(this,function(t){"use strict";function f(t){var r=t.toLowerCase().trim().split(/\s*;\s*/);if(r[0]==="banner"){return{name:r[0],delay:r[1]*1||0,leftToRight:r[2]*1||0,fadeAwayWidth:r[3]*1||0}}if(/^scroll\s/.test(r[0])){return{name:r[0],y1:Math.min(r[1]*1,r[2]*1),y2:Math.max(r[1]*1,r[2]*1),delay:r[3]*1||0,fadeAwayHeight:r[4]*1||0}}if(t!==""){return{name:t}}return null}function h(t){if(!t){return[]}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,r){return!(r&&isNaN(t*1))})})}var r=["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=r.map(function(t){return{name:t,regex:new RegExp("^"+t+"-?\\d")}});function b(t){var r;var e={};for(var a=0;ar.length){var a=e.slice(r.length-1).join();e=e.slice(0,r.length-1);e.push(a)}var n={};for(var i=0;i-10?1+s/10:1)*e.fs:s*1}}if(r==="K"){return{kf:s}}if(r==="t"){var E=s.t1;var H=s.accel;var N=s.tags;var A=s.t2||(e.end-e.start)*1e3;var R={};N.forEach(function(t){var r=Object.keys(t)[0];if(~$.indexOf(r)&&!(r==="clip"&&!t[r].dots)){Object.assign(R,B(t,r,e))}});return{t:{t1:E,t2:A,accel:H,tag:R}}}return i={},i[r]=s,i}var T=[null,1,2,3,null,7,8,9,null,4,5,6];var D=["r","a","an","pos","org","move","fade","fad","clip"];function P(t){return JSON.parse(JSON.stringify(Object.assign({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function z(t){var r=t.styles;var e=t.style;var a=t.parsed;var n=t.start;var i=t.end;var s;var o;var f;var l;var c;var u;var v=[];var p={style:e,fragments:[]};var d={};for(var g=0;g=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var f=z({styles:r,style:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var l=f.alignment||o.Alignment;a=Math.min(a,s.Layer);n.push(Object.assign({layer:s.Layer,start:s.Start,end:s.End,style:s.Style,name:s.Name,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},f,{alignment:l}))}for(var c=0;cr.length){var e=a.slice(r.length-1).join();a=a.slice(0,r.length-1);a.push(e)}var n={};for(var i=0;i-10?1+s/10:1)*a.fs:s*1}}if(r==="K"){return{kf:s}}if(r==="t"){var E=s.t1;var H=s.accel;var N=s.tags;var A=s.t2||(a.end-a.start)*1e3;var R={};N.forEach(function(t){var r=Object.keys(t)[0];if(~V.indexOf(r)&&!(r==="clip"&&!t[r].dots)){Object.assign(R,B(t,r,a))}});return{t:{t1:E,t2:A,accel:H,tag:R}}}return i={},i[r]=s,i}var T=[null,1,2,3,null,7,8,9,null,4,5,6];var D=["r","a","an","pos","org","move","fade","fad","clip"];function P(t){return JSON.parse(JSON.stringify(Object.assign({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function z(t){var r=t.styles;var a=t.style;var e=t.parsed;var n=t.start;var i=t.end;var s;var o={q:r[a].tag.q};var f;var l;var c;var u;var v;var p=[];var d={style:a,fragments:[]};var g={};for(var y=0;y=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var f=z({styles:r,style:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var l=f.alignment||o.Alignment;e=Math.min(e,s.Layer);n.push(Object.assign({layer:s.Layer,start:s.Start,end:s.End,style:s.Style,name:s.Name,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},f,{alignment:l}))}for(var c=0;cr.length){var a=e.slice(r.length-1).join();e=e.slice(0,r.length-1);e.push(a)}var n={};for(var i=0;i-10?1+s/10:1)*e.fs:s*1}}if(r==="K"){return{kf:s}}if(r==="t"){var D=s.t1;var k=s.accel;var L=s.tags;var H=s.t2||(e.end-e.start)*1e3;var N={};L.forEach(function(t){var r=Object.keys(t)[0];if(~tTags.indexOf(r)&&!(r==="clip"&&!t[r].dots)){Object.assign(N,compileTag(t,r,e))}});return{t:{t1:D,t2:H,accel:k,tag:N}}}return i={},i[r]=s,i}var a2an=[null,1,2,3,null,7,8,9,null,4,5,6];var globalTags=["r","a","an","pos","org","move","fade","fad","clip"];function inheritTag(t){return JSON.parse(JSON.stringify(Object.assign({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function compileText(t){var r=t.styles;var e=t.style;var a=t.parsed;var n=t.start;var i=t.end;var s;var o;var l;var f;var c;var u;var v=[];var g={style:e,fragments:[]};var p={};for(var m=0;m=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var l=compileText({styles:r,style:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;a=Math.min(a,s.Layer);n.push(Object.assign({layer:s.Layer,start:s.Start,end:s.End,style:s.Style,name:s.Name,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var c=0;cr.length){var a=e.slice(r.length-1).join();e=e.slice(0,r.length-1);e.push(a)}var n={};for(var i=0;i-10?1+s/10:1)*e.fs:s*1}}if(r==="K"){return{kf:s}}if(r==="t"){var D=s.t1;var k=s.accel;var L=s.tags;var H=s.t2||(e.end-e.start)*1e3;var N={};L.forEach(function(t){var r=Object.keys(t)[0];if(~tTags.indexOf(r)&&!(r==="clip"&&!t[r].dots)){Object.assign(N,compileTag(t,r,e))}});return{t:{t1:D,t2:H,accel:k,tag:N}}}return i={},i[r]=s,i}var a2an=[null,1,2,3,null,7,8,9,null,4,5,6];var globalTags=["r","a","an","pos","org","move","fade","fad","clip"];function inheritTag(t){return JSON.parse(JSON.stringify(Object.assign({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function compileText(t){var r=t.styles;var e=t.style;var a=t.parsed;var n=t.start;var i=t.end;var s;var o={q:r[e].tag.q};var l;var f;var c;var u;var v;var g=[];var p={style:e,fragments:[]};var m={};for(var y=0;y=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var l=compileText({styles:r,style:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;a=Math.min(a,s.Layer);n.push(Object.assign({layer:s.Layer,start:s.Start,end:s.End,style:s.Style,name:s.Name,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var c=0;c