ass-compiler
Advanced tools
Comparing version 0.1.8 to 0.1.9
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.assCompiler = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.assCompiler = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -1163,2 +1163,2 @@ function parseEffect(text) { | ||
}))); | ||
})); |
@@ -1,1 +0,1 @@ | ||
(function(t,r){typeof exports==="object"&&typeof module!=="undefined"?r(exports):typeof define==="function"&&define.amd?define(["exports"],r):(t=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 S(t){var r;var e={};for(var a=0;a<x.length;a++){var n=x[a];var i=n.name;var s=n.regex;if(s.test(t)){e[i]=t.slice(i.length)*1;return e}}if(/^fn/.test(t)){e.fn=t.slice(2)}else if(/^r/.test(t)){e.r=t.slice(1)}else if(/^fs[\d+-]/.test(t)){e.fs=t.slice(2)}else if(/^\d?c&?H?[0-9a-fA-F]+|^\d?c$/.test(t)){var o=t.match(/^(\d?)c&?H?(\w*)/);var f=o[1];var l=o[2];e["c"+(f||1)]=l&&("000000"+l).slice(-6)}else if(/^\da&?H?[0-9a-fA-F]+/.test(t)){var u=t.match(/^(\d)a&?H?([0-9a-f]+)/i);var c=u[1];var v=u[2];e["a"+c]=("00"+v).slice(-2)}else if(/^alpha&?H?[0-9a-fA-F]+/.test(t)){r=t.match(/^alpha&?H?([0-9a-f]+)/i),e.alpha=r[1];e.alpha=("00"+e.alpha).slice(-2)}else if(/^(?:pos|org|move|fad|fade)\([^)]+/.test(t)){var p=t.match(/^(\w+)\((.*?)\)?$/);var d=p[1];var g=p[2];e[d]=g.trim().split(/\s*,\s*/).map(Number)}else if(/^i?clip\([^)]+/.test(t)){var y=t.match(/^i?clip\((.*?)\)?$/)[1].trim().split(/\s*,\s*/);e.clip={inverse:/iclip/.test(t),scale:1,drawing:null,dots:null};if(y.length===1){e.clip.drawing=h(y[0])}if(y.length===2){e.clip.scale=y[0]*1;e.clip.drawing=h(y[1])}if(y.length===4){e.clip.dots=y.map(Number)}}else if(/^t\(/.test(t)){var m=t.match(/^t\((.*?)\)?$/)[1].trim().replace(/\\.*/,function(t){return t.replace(/,/g,"\n")}).split(/\s*,\s*/);if(!m[0]){return e}e.t={t1:0,t2:0,accel:1,tags:m[m.length-1].replace(/\n/g,",").split("\\").slice(1).map(S)};if(m.length===2){e.t.accel=m[0]*1}if(m.length===3){e.t.t1=m[0]*1;e.t.t2=m[1]*1}if(m.length===4){e.t.t1=m[0]*1;e.t.t2=m[1]*1;e.t.accel=m[2]*1}}return e}function s(t){var r=[];var e=0;var a="";var n=t.split("\\").slice(1).concat("").join("\\");for(var i=0;i<n.length;i++){var s=n[i];if(s==="("){e++}if(s===")"){e--}if(e<0){e=0}if(!e&&s==="\\"){if(a){r.push(a)}a=""}else{a+=s}}return r.map(S)}function l(t){var r=t.split(/{([^{}]*?)}/);var e=[];if(r[0].length){e.push({tags:[],text:r[0],drawing:[]})}for(var a=1;a<r.length;a+=2){var n=s(r[a]);var i=n.reduce(function(t,r){return r.p===undefined?t:!!r.p},false);e.push({tags:n,text:i?"":r[a+1],drawing:i?h(r[a+1]):[]})}return{raw:t,combined:e.map(function(t){return t.text}).join(""),parsed:e}}function u(t){var r=t.split(":");return r[0]*3600+r[1]*60+r[2]*1}function v(t,r){var e=t.split(",");if(e.length>r.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<e.length;i++){var s=r[i];var o=e[i].trim();switch(s){case"Layer":case"MarginL":case"MarginR":case"MarginV":n[s]=o*1;break;case"Start":case"End":n[s]=u(o);break;case"Effect":n[s]=f(o);break;case"Text":n[s]=l(o);break;default:n[s]=o}}return n}var I=Object.assign||function t(r){var e=[],a=arguments.length-1;while(a-- >0)e[a]=arguments[a+1];for(var n=0;n<e.length;n++){if(!e[n]){continue}var i=Object.keys(e[n]);for(var s=0;s<i.length;s++){r[i[s]]=e[n][i[s]]}}return r};var o=["Name","Fontname","Fontsize","PrimaryColour","SecondaryColour","OutlineColour","BackColour","Bold","Italic","Underline","StrikeOut","ScaleX","ScaleY","Spacing","Angle","BorderStyle","Outline","Shadow","Alignment","MarginL","MarginR","MarginV","Encoding"];var c=["Layer","Start","End","Style","Name","MarginL","MarginR","MarginV","Effect","Text"];function p(t){var e=o.concat(c);return t.match(/Format\s*:\s*(.*)/i)[1].split(/\s*,\s*/).map(function(r){var t=e.find(function(t){return t.toLowerCase()===r.toLowerCase()});return t||r})}function d(t,r){var a=t.match(/Style\s*:\s*(.*)/i)[1].split(/\s*,\s*/);return I.apply(void 0,[{}].concat(r.map(function(t,r){var e;return e={},e[t]=a[r],e})))}function n(t){var r={info:{},styles:{format:[],style:[]},events:{format:[],comment:[],dialogue:[]}};var e=t.split(/\r?\n/);var a=0;for(var n=0;n<e.length;n++){var i=e[n].trim();if(/^;/.test(i)){continue}if(/^\[Script Info\]/i.test(i)){a=1}else if(/^\[V4\+? Styles\]/i.test(i)){a=2}else if(/^\[Events\]/i.test(i)){a=3}else if(/^\[.*\]/.test(i)){a=0}if(a===0){continue}if(a===1){if(/:/.test(i)){var s=i.match(/(.*?)\s*:\s*(.*)/);var o=s[1];var f=s[2];r.info[o]=f}}if(a===2){if(/^Format\s*:/i.test(i)){r.styles.format=p(i)}if(/^Style\s*:/i.test(i)){r.styles.style.push(d(i,r.styles.format))}}if(a===3){if(/^Format\s*:/i.test(i)){r.events.format=p(i)}if(/^(?:Comment|Dialogue)\s*:/i.test(i)){var l=i.match(/^(\w+?)\s*:\s*(.*)/i);var u=l[1];var c=l[2];r.events[u.toLowerCase()].push(v(c,r.events.format))}}}return r}function g(r){return Object.keys(r).map(function(t){return t+": "+r[t]}).join("\n")}function i(t){return("00"+t).slice(-2)}function e(t){var r=t.toFixed(2).slice(-2);var e=(t|0)%60;var a=(t/60|0)%60;var n=t/3600|0;return n+":"+i(a)+":"+i(e)+"."+r}function a(t){if(!t){return""}if(t.name==="banner"){return"Banner;"+t.delay+";"+t.leftToRight+";"+t.fadeAwayWidth}if(/^scroll\s/.test(t.name)){return t.name.replace(/^\w/,function(t){return t.toUpperCase()})+";"+t.y1+";"+t.y2+";"+t.delay+";"+t.fadeAwayHeight}return t.name}function y(t){return t.map(function(t){return t.join(" ")}).join(" ")}function m(t){var r=Object.keys(t);var e=r[0];if(!e){return""}var a=t[e];if(["pos","org","move","fad","fade"].some(function(t){return t===e})){return"\\"+e+"("+a+")"}if(/^[ac]\d$/.test(e)){return"\\"+e[1]+e[0]+"&H"+a+"&"}if(e==="alpha"){return"\\alpha&H"+a+"&"}if(e==="clip"){return"\\"+(a.inverse?"i":"")+"clip("+(a.dots||""+(a.scale===1?"":a.scale+",")+y(a.drawing))+")"}if(e==="t"){return"\\t("+[a.t1,a.t2,a.accel,a.tags.map(m).join("")]+")"}return"\\"+e+a}function b(t){return t.parsed.map(function(t){var r=t.tags;var e=t.text;var a=t.drawing;var n=r.map(m).join("");var i=a.length?y(a):e;return""+(n?"{"+n+"}":"")+i}).join("")}function w(r,t){return t.map(function(t){switch(t){case"Start":case"End":return e(r[t]);case"MarginL":case"MarginR":case"MarginV":return r[t]||"0000";case"Effect":return a(r[t]);case"Text":return b(r.Text);default:return r[t]}}).join()}function M(t){var r;var e=t.info;var a=t.styles;var n=t.events;return["[Script Info]",g(e),"","[V4+ Styles]","Format: "+a.format.join(", ")].concat(a.style.map(function(r){return"Style: "+a.format.map(function(t){return r[t]}).join()}),[""],["[Events]"],["Format: "+n.format.join(", ")],(r=[]).concat.apply(r,["Comment","Dialogue"].map(function(r){return n[r.toLowerCase()].map(function(t){return{start:t.Start,end:t.End,string:r+": "+w(t,n.format)}})})).sort(function(t,r){return t.start-r.start||t.end-r.end}).map(function(t){return t.string}),[""]).join("\n")}function j(t){var r={type:null,prev:null,next:null,points:[]};if(/[mnlbs]/.test(t[0])){r.type=t[0].toUpperCase().replace("N","L").replace("B","C")}for(var e=t.length-!(t.length&1),a=1;a<e;a+=2){r.points.push({x:t[a]*1,y:t[a+1]*1})}return r}function C(t){if(!t.points.length||!t.type){return false}if(/C|S/.test(t.type)&&t.points.length<3){return false}return true}function k(t){var r;var a=Infinity;var n=Infinity;var i=-Infinity;var s=-Infinity;(r=[]).concat.apply(r,t.map(function(t){var r=t.points;return r})).forEach(function(t){var r=t.x;var e=t.y;a=Math.min(a,r);n=Math.min(n,e);i=Math.max(i,r);s=Math.max(s,e)});return{minX:a,minY:n,width:i-a,height:s-n}}function O(t,r,e){var a=[];var n=[0,2/3,1/3,0];var i=[0,1/3,2/3,0];var s=[0,1/6,2/3,1/6];var o=function(t,r){return t[0]*r[0]+t[1]*r[1]+t[2]*r[2]+t[3]*r[3]};var f=[t[t.length-1].x,t[0].x,t[1].x,t[2].x];var l=[t[t.length-1].y,t[0].y,t[1].y,t[2].y];a.push({type:r==="M"?"M":"L",points:[{x:o(s,f),y:o(s,l)}]});for(var u=3;u<t.length;u++){f=[t[u-3].x,t[u-2].x,t[u-1].x,t[u].x];l=[t[u-3].y,t[u-2].y,t[u-1].y,t[u].y];a.push({type:"C",points:[{x:o(n,f),y:o(n,l)},{x:o(i,f),y:o(i,l)},{x:o(s,f),y:o(s,l)}]})}if(e==="L"||e==="C"){var c=t[t.length-1];a.push({type:"L",points:[{x:c.x,y:c.y}]})}return a}function F(t){return t.map(function(t){var r=t.type;var e=t.points;return r+e.map(function(t){var r=t.x;var e=t.y;return r+","+e}).join(",")}).join("")}function B(t){var r;var e=[];var a=0;while(a<t.length){var n=t[a];var i=j(n);if(C(i)){if(i.type==="S"){var s=(e[a-1]||{points:[{x:0,y:0}]}).points.slice(-1)[0];var o=s.x;var f=s.y;i.points.unshift({x:o,y:f})}if(a){i.prev=e[a-1].type;e[a-1].next=i.type}e.push(i);a++}else{if(a&&e[a-1].type==="S"){var l={p:i.points,c:e[a-1].points.slice(0,3)};e[a-1].points=e[a-1].points.concat((l[n[0]]||[]).map(function(t){var r=t.x;var e=t.y;return{x:r,y:e}}))}t.splice(a,1)}}var u=(r=[]).concat.apply(r,e.map(function(t){var r=t.type;var e=t.points;var a=t.prev;var n=t.next;return r==="S"?O(e,a,n):{type:r,points:e}}));return I({instructions:u,d:F(u)},k(e))}var V=["fs","clip","c1","c2","c3","c4","a1","a2","a3","a4","alpha","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"];function $(t,r,e){var a,n,i;if(e===void 0)e={};var s=t[r];if(s===undefined){return null}if(r==="pos"||r==="org"){return s.length===2?(a={},a[r]={x:s[0],y:s[1]},a):null}if(r==="move"){var o=s[0];var f=s[1];var l=s[2];var u=s[3];var c=s[4];if(c===void 0)c=0;var v=s[5];if(v===void 0)v=0;return s.length===4||s.length===6?{move:{x1:o,y1:f,x2:l,y2:u,t1:c,t2:v}}:null}if(r==="fad"||r==="fade"){if(s.length===2){var p=s[0];var d=s[1];return{fade:{type:"fad",t1:p,t2:d}}}if(s.length===7){var g=s[0];var y=s[1];var m=s[2];var h=s[3];var x=s[4];var S=s[5];var b=s[6];return{fade:{type:"fade",a1:g,a2:y,a3:m,t1:h,t2:x,t3:S,t4:b}}}return null}if(r==="clip"){var w=s.inverse;var M=s.scale;var j=s.drawing;var C=s.dots;if(j){return{clip:{inverse:w,scale:M,drawing:B(j),dots:C}}}if(C){var k=C[0];var O=C[1];var F=C[2];var L=C[3];return{clip:{inverse:w,scale:M,drawing:j,dots:{x1:k,y1:O,x2:F,y2:L}}}}return null}if(/^[xy]?(bord|shad)$/.test(r)){s=Math.max(s,0)}if(r==="bord"){return{xbord:s,ybord:s}}if(r==="shad"){return{xshad:s,yshad:s}}if(/^c\d$/.test(r)){return n={},n[r]=s||e[r],n}if(r==="alpha"){return{a1:s,a2:s,a3:s,a4:s}}if(r==="fr"){return{frz:s}}if(r==="fs"){return{fs:/^\+|-/.test(s)?(s*1>-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(~V.indexOf(r)&&!(r==="clip"&&!t[r].dots)){I(R,$(t,r,e))}});return{t:{t1:E,t2:A,accel:H,tag:R}}}return i={},i[r]=s,i}var P=[null,1,2,3,null,7,8,9,null,4,5,6];var D=["r","a","an","pos","org","move","fade","fad","clip"];function z(t){return JSON.parse(JSON.stringify(I({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function L(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 u;var c;var v=[];var p={style:e,fragments:[]};var d={};for(var g=0;g<a.length;g++){var y=a[g];var m=y.tags;var h=y.text;var x=y.drawing;var S=void 0;for(var b=0;b<m.length;b++){var w=m[b];S=w.r===undefined?S:w.r}var M={tag:S===undefined?z(d):{},text:h,drawing:x.length?B(x):null};for(var j=0;j<m.length;j++){var C=m[j];s=s||P[C.a||0]||C.an;o=o||$(C,"pos");f=f||$(C,"org");l=l||$(C,"move");u=u||$(C,"fade")||$(C,"fad");c=$(C,"clip")||c;var k=Object.keys(C)[0];if(k&&!~D.indexOf(k)){var O=r[e].tag;var F=O.c1;var L=O.c2;var E=O.c3;var H=O.c4;var N=d.fs||O.fs;var A=$(C,k,{start:n,end:i,c1:F,c2:L,c3:E,c4:H,fs:N});if(k==="t"){M.tag.t=M.tag.t||[];M.tag.t.push(A.t)}else{I(M.tag,A)}}}d=M.tag;if(S!==undefined){v.push(p);p={style:r[S]?S:e,fragments:[]}}if(M.text||M.drawing){var R=p.fragments[p.fragments.length-1]||{};if(R.text&&M.text&&!Object.keys(M.tag).length){R.text+=M.text}else{p.fragments.push(M)}}}v.push(p);return I({alignment:s,slices:v},o,f,l,u,c)}function E(t){var r=t.styles;var e=t.dialogues;var a=Infinity;var n=[];for(var i=0;i<e.length;i++){var s=e[i];if(s.Start>=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var f=L({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(I({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 u=0;u<n.length;u++){n[u].layer-=a}return n.sort(function(t,r){return t.start-r.start||t.end-r.end})}var H={Name:"Default",Fontname:"Arial",Fontsize:"20",PrimaryColour:"&H00FFFFFF&",SecondaryColour:"&H000000FF&",OutlineColour:"&H00000000&",BackColour:"&H00000000&",Bold:"0",Italic:"0",Underline:"0",StrikeOut:"0",ScaleX:"100",ScaleY:"100",Spacing:"0",Angle:"0",BorderStyle:"1",Outline:"2",Shadow:"2",Alignment:"2",MarginL:"10",MarginR:"10",MarginV:"10",Encoding:"1"};function N(t){if(/^(&|H|&H)[0-9a-f]{6,}/i.test(t)){var r=t.match(/&?H?([0-9a-f]{2})?([0-9a-f]{6})/i);var e=r[1];var a=r[2];return[e||"00",a]}var n=parseInt(t,10);if(!isNaN(n)){var i=-2147483648;var s=2147483647;if(n<i){return["00","000000"]}var o=i<=n&&n<=s?("00000000"+(n<0?n+4294967296:n).toString(16)).slice(-8):String(n).slice(0,8);return[o.slice(0,2),o.slice(2)]}return["00","000000"]}function A(t){var g=t.info;var r=t.style;var e=t.defaultStyle;var y={};var m=[I({},e,{Name:"Default"})].concat(r);var a=function(t){var r=I({},H,m[t]);if(/^(\*+)Default$/.test(r.Name)){r.Name="Default"}Object.keys(r).forEach(function(t){if(t!=="Name"&&t!=="Fontname"&&!/Colour/.test(t)){r[t]*=1}});var e=N(r.PrimaryColour);var a=e[0];var n=e[1];var i=N(r.SecondaryColour);var s=i[0];var o=i[1];var f=N(r.OutlineColour);var l=f[0];var u=f[1];var c=N(r.BackColour);var v=c[0];var p=c[1];var d={fn:r.Fontname,fs:r.Fontsize,c1:n,a1:a,c2:o,a2:s,c3:u,a3:l,c4:p,a4:v,b:Math.abs(r.Bold),i:Math.abs(r.Italic),u:Math.abs(r.Underline),s:Math.abs(r.StrikeOut),fscx:r.ScaleX,fscy:r.ScaleY,fsp:r.Spacing,frz:r.Angle,xbord:r.Outline,ybord:r.Outline,xshad:r.Shadow,yshad:r.Shadow,fe:r.Encoding,q:/^[0-3]$/.test(g.WrapStyle)?g.WrapStyle*1:2};y[r.Name]={style:r,tag:d}};for(var n=0;n<m.length;n++)a(n);return y}function R(t,r){if(r===void 0)r={};var e=n(t);var a=A({info:e.info,style:e.styles.style,defaultStyle:r.defaultStyle||{}});return{info:e.info,width:e.info.PlayResX*1||null,height:e.info.PlayResY*1||null,collisions:e.info.Collisions||"Normal",styles:a,dialogues:E({styles:a,dialogues:e.events.dialogue})}}function T(t){var r=t.style;var e=t.tag;var a=I({},r,{PrimaryColour:"&H"+e.a1+e.c1,SecondaryColour:"&H"+e.a2+e.c2,OutlineColour:"&H"+e.a3+e.c3,BackColour:"&H"+e.a4+e.c4});return"Style: "+o.map(function(t){return a[t]}).join()}var X={M:"m",L:"l",C:"b"};function Y(t){var r=t.instructions;return r.map(function(t){var r;var e=t.type;var a=t.points;return(r=[X[e]]).concat.apply(r,a.map(function(t){var r=t.x;var e=t.y;return[r,e]})).join(" ")}).join(" ")}var U=function(e){return function(r){return function(t){return""+r+e+"&H"+t+"&"}}};var J=U("c");var W=U("a");var q={c1:J(1),c2:J(2),c3:J(3),c4:J(4),a1:W(1),a2:W(2),a3:W(3),a4:W(4),pos:function(t){return"pos("+[t.x,t.y]+")"},org:function(t){return"org("+[t.x,t.y]+")"},move:function(t){return"move("+[t.x1,t.y1,t.x2,t.y2,t.t1,t.t2]+")"},fade:function(t){return t.type==="fad"?"fad("+[t.t1,t.t2]+")":"fade("+[t.a1,t.a2,t.a3,t.t1,t.t2,t.t3,t.t4]+")"},clip:function(t){return(t.inverse?"i":"")+"clip("+(t.dots?""+[t.dots.x1,t.dots.y1,t.dots.x2,t.dots.y2]:""+(t.scale===1?"":t.scale+",")+Y(t.drawing))+")"},t:function(t){return t.map(function(t){return"t("+[t.t1,t.t2,t.accel,K(t.tag)]+")"}).join("\\")}};function K(e){return Object.keys(e).map(function(r){var t=q[r]||function(t){return""+r+t};return"\\"+t(e[r])}).join("")}function _(t){return t.fragments.map(function(t){var r=t.tag;var e=t.text;var a=t.drawing;var n=K(r);return""+(n?"{"+n+"}":"")+(a?Y(a):e)}).join("")}function G(i,s){return i.slices.filter(function(t){return t.fragments.length}).map(function(t,r){var e=JSON.parse(JSON.stringify(t));var a=e.fragments[0];var n=a.tag;if(r){n.r=t.style===i.style?"":t.style}else{if(s.Alignment!==i.alignment){n.an=i.alignment}["pos","org","move","fade","clip"].forEach(function(t){if(i[t]){n[t]=i[t]}})}return e}).map(_).join("")}function Q(t,r){return t===r?"0000":t}function Z(t,r){return"Dialogue: "+[t.layer,e(t.start),e(t.end),t.style,t.name,Q(t.margin.left,r.MarginL),Q(t.margin.right,r.MarginR),Q(t.margin.vertical,r.MarginV),a(t.effect),G(t,r)].join()}function tt(t){var r=t.info;var e=t.width;var a=t.height;var n=t.collisions;var i=t.styles;var s=t.dialogues;return["[Script Info]",g(I({},r,{PlayResX:e,PlayResY:a,Collisions:n})),"","[V4+ Styles]","Format: "+o.join(", ")].concat(Object.keys(i).map(function(t){return T(i[t])}),[""],["[Events]"],["Format: "+c.join(", ")],s.sort(function(t,r){return t.start-r.start||t.end-r.end}).map(function(t){return Z(t,i[t.style].style)}),[""]).join("\n")}t.compile=R;t.decompile=tt;t.parse=n;t.stringify=M;Object.defineProperty(t,"__esModule",{value:true})}); | ||
(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 S(t){var r;var e={};for(var a=0;a<x.length;a++){var n=x[a];var i=n.name;var s=n.regex;if(s.test(t)){e[i]=t.slice(i.length)*1;return e}}if(/^fn/.test(t)){e.fn=t.slice(2)}else if(/^r/.test(t)){e.r=t.slice(1)}else if(/^fs[\d+-]/.test(t)){e.fs=t.slice(2)}else if(/^\d?c&?H?[0-9a-fA-F]+|^\d?c$/.test(t)){var o=t.match(/^(\d?)c&?H?(\w*)/);var f=o[1];var l=o[2];e["c"+(f||1)]=l&&("000000"+l).slice(-6)}else if(/^\da&?H?[0-9a-fA-F]+/.test(t)){var u=t.match(/^(\d)a&?H?([0-9a-f]+)/i);var c=u[1];var v=u[2];e["a"+c]=("00"+v).slice(-2)}else if(/^alpha&?H?[0-9a-fA-F]+/.test(t)){r=t.match(/^alpha&?H?([0-9a-f]+)/i),e.alpha=r[1];e.alpha=("00"+e.alpha).slice(-2)}else if(/^(?:pos|org|move|fad|fade)\([^)]+/.test(t)){var p=t.match(/^(\w+)\((.*?)\)?$/);var d=p[1];var g=p[2];e[d]=g.trim().split(/\s*,\s*/).map(Number)}else if(/^i?clip\([^)]+/.test(t)){var y=t.match(/^i?clip\((.*?)\)?$/)[1].trim().split(/\s*,\s*/);e.clip={inverse:/iclip/.test(t),scale:1,drawing:null,dots:null};if(y.length===1){e.clip.drawing=h(y[0])}if(y.length===2){e.clip.scale=y[0]*1;e.clip.drawing=h(y[1])}if(y.length===4){e.clip.dots=y.map(Number)}}else if(/^t\(/.test(t)){var m=t.match(/^t\((.*?)\)?$/)[1].trim().replace(/\\.*/,function(t){return t.replace(/,/g,"\n")}).split(/\s*,\s*/);if(!m[0]){return e}e.t={t1:0,t2:0,accel:1,tags:m[m.length-1].replace(/\n/g,",").split("\\").slice(1).map(S)};if(m.length===2){e.t.accel=m[0]*1}if(m.length===3){e.t.t1=m[0]*1;e.t.t2=m[1]*1}if(m.length===4){e.t.t1=m[0]*1;e.t.t2=m[1]*1;e.t.accel=m[2]*1}}return e}function s(t){var r=[];var e=0;var a="";var n=t.split("\\").slice(1).concat("").join("\\");for(var i=0;i<n.length;i++){var s=n[i];if(s==="("){e++}if(s===")"){e--}if(e<0){e=0}if(!e&&s==="\\"){if(a){r.push(a)}a=""}else{a+=s}}return r.map(S)}function l(t){var r=t.split(/{([^{}]*?)}/);var e=[];if(r[0].length){e.push({tags:[],text:r[0],drawing:[]})}for(var a=1;a<r.length;a+=2){var n=s(r[a]);var i=n.reduce(function(t,r){return r.p===undefined?t:!!r.p},false);e.push({tags:n,text:i?"":r[a+1],drawing:i?h(r[a+1]):[]})}return{raw:t,combined:e.map(function(t){return t.text}).join(""),parsed:e}}function u(t){var r=t.split(":");return r[0]*3600+r[1]*60+r[2]*1}function v(t,r){var e=t.split(",");if(e.length>r.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<e.length;i++){var s=r[i];var o=e[i].trim();switch(s){case"Layer":case"MarginL":case"MarginR":case"MarginV":n[s]=o*1;break;case"Start":case"End":n[s]=u(o);break;case"Effect":n[s]=f(o);break;case"Text":n[s]=l(o);break;default:n[s]=o}}return n}var I=Object.assign||function t(r){var e=[],a=arguments.length-1;while(a-- >0)e[a]=arguments[a+1];for(var n=0;n<e.length;n++){if(!e[n]){continue}var i=Object.keys(e[n]);for(var s=0;s<i.length;s++){r[i[s]]=e[n][i[s]]}}return r};var o=["Name","Fontname","Fontsize","PrimaryColour","SecondaryColour","OutlineColour","BackColour","Bold","Italic","Underline","StrikeOut","ScaleX","ScaleY","Spacing","Angle","BorderStyle","Outline","Shadow","Alignment","MarginL","MarginR","MarginV","Encoding"];var c=["Layer","Start","End","Style","Name","MarginL","MarginR","MarginV","Effect","Text"];function p(t){var e=o.concat(c);return t.match(/Format\s*:\s*(.*)/i)[1].split(/\s*,\s*/).map(function(r){var t=e.find(function(t){return t.toLowerCase()===r.toLowerCase()});return t||r})}function d(t,r){var a=t.match(/Style\s*:\s*(.*)/i)[1].split(/\s*,\s*/);return I.apply(void 0,[{}].concat(r.map(function(t,r){var e;return e={},e[t]=a[r],e})))}function n(t){var r={info:{},styles:{format:[],style:[]},events:{format:[],comment:[],dialogue:[]}};var e=t.split(/\r?\n/);var a=0;for(var n=0;n<e.length;n++){var i=e[n].trim();if(/^;/.test(i)){continue}if(/^\[Script Info\]/i.test(i)){a=1}else if(/^\[V4\+? Styles\]/i.test(i)){a=2}else if(/^\[Events\]/i.test(i)){a=3}else if(/^\[.*\]/.test(i)){a=0}if(a===0){continue}if(a===1){if(/:/.test(i)){var s=i.match(/(.*?)\s*:\s*(.*)/);var o=s[1];var f=s[2];r.info[o]=f}}if(a===2){if(/^Format\s*:/i.test(i)){r.styles.format=p(i)}if(/^Style\s*:/i.test(i)){r.styles.style.push(d(i,r.styles.format))}}if(a===3){if(/^Format\s*:/i.test(i)){r.events.format=p(i)}if(/^(?:Comment|Dialogue)\s*:/i.test(i)){var l=i.match(/^(\w+?)\s*:\s*(.*)/i);var u=l[1];var c=l[2];r.events[u.toLowerCase()].push(v(c,r.events.format))}}}return r}function g(r){return Object.keys(r).map(function(t){return t+": "+r[t]}).join("\n")}function i(t){return("00"+t).slice(-2)}function e(t){var r=t.toFixed(2).slice(-2);var e=(t|0)%60;var a=(t/60|0)%60;var n=t/3600|0;return n+":"+i(a)+":"+i(e)+"."+r}function a(t){if(!t){return""}if(t.name==="banner"){return"Banner;"+t.delay+";"+t.leftToRight+";"+t.fadeAwayWidth}if(/^scroll\s/.test(t.name)){return t.name.replace(/^\w/,function(t){return t.toUpperCase()})+";"+t.y1+";"+t.y2+";"+t.delay+";"+t.fadeAwayHeight}return t.name}function y(t){return t.map(function(t){return t.join(" ")}).join(" ")}function m(t){var r=Object.keys(t);var e=r[0];if(!e){return""}var a=t[e];if(["pos","org","move","fad","fade"].some(function(t){return t===e})){return"\\"+e+"("+a+")"}if(/^[ac]\d$/.test(e)){return"\\"+e[1]+e[0]+"&H"+a+"&"}if(e==="alpha"){return"\\alpha&H"+a+"&"}if(e==="clip"){return"\\"+(a.inverse?"i":"")+"clip("+(a.dots||""+(a.scale===1?"":a.scale+",")+y(a.drawing))+")"}if(e==="t"){return"\\t("+[a.t1,a.t2,a.accel,a.tags.map(m).join("")]+")"}return"\\"+e+a}function b(t){return t.parsed.map(function(t){var r=t.tags;var e=t.text;var a=t.drawing;var n=r.map(m).join("");var i=a.length?y(a):e;return""+(n?"{"+n+"}":"")+i}).join("")}function w(r,t){return t.map(function(t){switch(t){case"Start":case"End":return e(r[t]);case"MarginL":case"MarginR":case"MarginV":return r[t]||"0000";case"Effect":return a(r[t]);case"Text":return b(r.Text);default:return r[t]}}).join()}function M(t){var r;var e=t.info;var a=t.styles;var n=t.events;return["[Script Info]",g(e),"","[V4+ Styles]","Format: "+a.format.join(", ")].concat(a.style.map(function(r){return"Style: "+a.format.map(function(t){return r[t]}).join()}),[""],["[Events]"],["Format: "+n.format.join(", ")],(r=[]).concat.apply(r,["Comment","Dialogue"].map(function(r){return n[r.toLowerCase()].map(function(t){return{start:t.Start,end:t.End,string:r+": "+w(t,n.format)}})})).sort(function(t,r){return t.start-r.start||t.end-r.end}).map(function(t){return t.string}),[""]).join("\n")}function j(t){var r={type:null,prev:null,next:null,points:[]};if(/[mnlbs]/.test(t[0])){r.type=t[0].toUpperCase().replace("N","L").replace("B","C")}for(var e=t.length-!(t.length&1),a=1;a<e;a+=2){r.points.push({x:t[a]*1,y:t[a+1]*1})}return r}function C(t){if(!t.points.length||!t.type){return false}if(/C|S/.test(t.type)&&t.points.length<3){return false}return true}function A(t){var r;var a=Infinity;var n=Infinity;var i=-Infinity;var s=-Infinity;(r=[]).concat.apply(r,t.map(function(t){var r=t.points;return r})).forEach(function(t){var r=t.x;var e=t.y;a=Math.min(a,r);n=Math.min(n,e);i=Math.max(i,r);s=Math.max(s,e)});return{minX:a,minY:n,width:i-a,height:s-n}}function R(t,r,e){var a=[];var n=[0,2/3,1/3,0];var i=[0,1/3,2/3,0];var s=[0,1/6,2/3,1/6];var o=function(t,r){return t[0]*r[0]+t[1]*r[1]+t[2]*r[2]+t[3]*r[3]};var f=[t[t.length-1].x,t[0].x,t[1].x,t[2].x];var l=[t[t.length-1].y,t[0].y,t[1].y,t[2].y];a.push({type:r==="M"?"M":"L",points:[{x:o(s,f),y:o(s,l)}]});for(var u=3;u<t.length;u++){f=[t[u-3].x,t[u-2].x,t[u-1].x,t[u].x];l=[t[u-3].y,t[u-2].y,t[u-1].y,t[u].y];a.push({type:"C",points:[{x:o(n,f),y:o(n,l)},{x:o(i,f),y:o(i,l)},{x:o(s,f),y:o(s,l)}]})}if(e==="L"||e==="C"){var c=t[t.length-1];a.push({type:"L",points:[{x:c.x,y:c.y}]})}return a}function $(t){return t.map(function(t){var r=t.type;var e=t.points;return r+e.map(function(t){var r=t.x;var e=t.y;return r+","+e}).join(",")}).join("")}function B(t){var r;var e=[];var a=0;while(a<t.length){var n=t[a];var i=j(n);if(C(i)){if(i.type==="S"){var s=(e[a-1]||{points:[{x:0,y:0}]}).points.slice(-1)[0];var o=s.x;var f=s.y;i.points.unshift({x:o,y:f})}if(a){i.prev=e[a-1].type;e[a-1].next=i.type}e.push(i);a++}else{if(a&&e[a-1].type==="S"){var l={p:i.points,c:e[a-1].points.slice(0,3)};e[a-1].points=e[a-1].points.concat((l[n[0]]||[]).map(function(t){var r=t.x;var e=t.y;return{x:r,y:e}}))}t.splice(a,1)}}var u=(r=[]).concat.apply(r,e.map(function(t){var r=t.type;var e=t.points;var a=t.prev;var n=t.next;return r==="S"?R(e,a,n):{type:r,points:e}}));return I({instructions:u,d:$(u)},A(e))}var P=["fs","clip","c1","c2","c3","c4","a1","a2","a3","a4","alpha","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"];function V(t,r,e){var a,n,i;if(e===void 0)e={};var s=t[r];if(s===undefined){return null}if(r==="pos"||r==="org"){return s.length===2?(a={},a[r]={x:s[0],y:s[1]},a):null}if(r==="move"){var o=s[0];var f=s[1];var l=s[2];var u=s[3];var c=s[4];if(c===void 0)c=0;var v=s[5];if(v===void 0)v=0;return s.length===4||s.length===6?{move:{x1:o,y1:f,x2:l,y2:u,t1:c,t2:v}}:null}if(r==="fad"||r==="fade"){if(s.length===2){var p=s[0];var d=s[1];return{fade:{type:"fad",t1:p,t2:d}}}if(s.length===7){var g=s[0];var y=s[1];var m=s[2];var h=s[3];var x=s[4];var S=s[5];var b=s[6];return{fade:{type:"fade",a1:g,a2:y,a3:m,t1:h,t2:x,t3:S,t4:b}}}return null}if(r==="clip"){var w=s.inverse;var M=s.scale;var j=s.drawing;var C=s.dots;if(j){return{clip:{inverse:w,scale:M,drawing:B(j),dots:C}}}if(C){var k=C[0];var O=C[1];var F=C[2];var L=C[3];return{clip:{inverse:w,scale:M,drawing:j,dots:{x1:k,y1:O,x2:F,y2:L}}}}return null}if(/^[xy]?(bord|shad)$/.test(r)){s=Math.max(s,0)}if(r==="bord"){return{xbord:s,ybord:s}}if(r==="shad"){return{xshad:s,yshad:s}}if(/^c\d$/.test(r)){return n={},n[r]=s||e[r],n}if(r==="alpha"){return{a1:s,a2:s,a3:s,a4:s}}if(r==="fr"){return{frz:s}}if(r==="fs"){return{fs:/^\+|-/.test(s)?(s*1>-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(~P.indexOf(r)&&!(r==="clip"&&!t[r].dots)){I(R,V(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 z(t){return JSON.parse(JSON.stringify(I({},t,{k:undefined,kf:undefined,ko:undefined,kt:undefined})))}function X(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 u;var c;var v=[];var p={style:e,fragments:[]};var d={};for(var g=0;g<a.length;g++){var y=a[g];var m=y.tags;var h=y.text;var x=y.drawing;var S=void 0;for(var b=0;b<m.length;b++){var w=m[b];S=w.r===undefined?S:w.r}var M={tag:S===undefined?z(d):{},text:h,drawing:x.length?B(x):null};for(var j=0;j<m.length;j++){var C=m[j];s=s||T[C.a||0]||C.an;o=o||V(C,"pos");f=f||V(C,"org");l=l||V(C,"move");u=u||V(C,"fade")||V(C,"fad");c=V(C,"clip")||c;var k=Object.keys(C)[0];if(k&&!~D.indexOf(k)){var O=r[e].tag;var F=O.c1;var L=O.c2;var E=O.c3;var H=O.c4;var N=d.fs||O.fs;var A=V(C,k,{start:n,end:i,c1:F,c2:L,c3:E,c4:H,fs:N});if(k==="t"){M.tag.t=M.tag.t||[];M.tag.t.push(A.t)}else{I(M.tag,A)}}}d=M.tag;if(S!==undefined){v.push(p);p={style:r[S]?S:e,fragments:[]}}if(M.text||M.drawing){var R=p.fragments[p.fragments.length-1]||{};if(R.text&&M.text&&!Object.keys(M.tag).length){R.text+=M.text}else{p.fragments.push(M)}}}v.push(p);return I({alignment:s,slices:v},o,f,l,u,c)}function Y(t){var r=t.styles;var e=t.dialogues;var a=Infinity;var n=[];for(var i=0;i<e.length;i++){var s=e[i];if(s.Start>=s.End){continue}if(!r[s.Style]){s.Style="Default"}var o=r[s.Style].style;var f=X({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(I({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 u=0;u<n.length;u++){n[u].layer-=a}return n.sort(function(t,r){return t.start-r.start||t.end-r.end})}var U={Name:"Default",Fontname:"Arial",Fontsize:"20",PrimaryColour:"&H00FFFFFF&",SecondaryColour:"&H000000FF&",OutlineColour:"&H00000000&",BackColour:"&H00000000&",Bold:"0",Italic:"0",Underline:"0",StrikeOut:"0",ScaleX:"100",ScaleY:"100",Spacing:"0",Angle:"0",BorderStyle:"1",Outline:"2",Shadow:"2",Alignment:"2",MarginL:"10",MarginR:"10",MarginV:"10",Encoding:"1"};function k(t){if(/^(&|H|&H)[0-9a-f]{6,}/i.test(t)){var r=t.match(/&?H?([0-9a-f]{2})?([0-9a-f]{6})/i);var e=r[1];var a=r[2];return[e||"00",a]}var n=parseInt(t,10);if(!isNaN(n)){var i=-2147483648;var s=2147483647;if(n<i){return["00","000000"]}var o=i<=n&&n<=s?("00000000"+(n<0?n+4294967296:n).toString(16)).slice(-8):String(n).slice(0,8);return[o.slice(0,2),o.slice(2)]}return["00","000000"]}function J(t){var g=t.info;var r=t.style;var e=t.defaultStyle;var y={};var m=[I({},e,{Name:"Default"})].concat(r);var a=function(t){var r=I({},U,m[t]);if(/^(\*+)Default$/.test(r.Name)){r.Name="Default"}Object.keys(r).forEach(function(t){if(t!=="Name"&&t!=="Fontname"&&!/Colour/.test(t)){r[t]*=1}});var e=k(r.PrimaryColour);var a=e[0];var n=e[1];var i=k(r.SecondaryColour);var s=i[0];var o=i[1];var f=k(r.OutlineColour);var l=f[0];var u=f[1];var c=k(r.BackColour);var v=c[0];var p=c[1];var d={fn:r.Fontname,fs:r.Fontsize,c1:n,a1:a,c2:o,a2:s,c3:u,a3:l,c4:p,a4:v,b:Math.abs(r.Bold),i:Math.abs(r.Italic),u:Math.abs(r.Underline),s:Math.abs(r.StrikeOut),fscx:r.ScaleX,fscy:r.ScaleY,fsp:r.Spacing,frz:r.Angle,xbord:r.Outline,ybord:r.Outline,xshad:r.Shadow,yshad:r.Shadow,fe:r.Encoding,q:/^[0-3]$/.test(g.WrapStyle)?g.WrapStyle*1:2};y[r.Name]={style:r,tag:d}};for(var n=0;n<m.length;n++)a(n);return y}function W(t,r){if(r===void 0)r={};var e=n(t);var a=J({info:e.info,style:e.styles.style,defaultStyle:r.defaultStyle||{}});return{info:e.info,width:e.info.PlayResX*1||null,height:e.info.PlayResY*1||null,collisions:e.info.Collisions||"Normal",styles:a,dialogues:Y({styles:a,dialogues:e.events.dialogue})}}function q(t){var r=t.style;var e=t.tag;var a=I({},r,{PrimaryColour:"&H"+e.a1+e.c1,SecondaryColour:"&H"+e.a2+e.c2,OutlineColour:"&H"+e.a3+e.c3,BackColour:"&H"+e.a4+e.c4});return"Style: "+o.map(function(t){return a[t]}).join()}var K={M:"m",L:"l",C:"b"};function O(t){var r=t.instructions;return r.map(function(t){var r;var e=t.type;var a=t.points;return(r=[K[e]]).concat.apply(r,a.map(function(t){var r=t.x;var e=t.y;return[r,e]})).join(" ")}).join(" ")}var F=function(e){return function(r){return function(t){return""+r+e+"&H"+t+"&"}}};var L=F("c");var E=F("a");var _={c1:L(1),c2:L(2),c3:L(3),c4:L(4),a1:E(1),a2:E(2),a3:E(3),a4:E(4),pos:function(t){return"pos("+[t.x,t.y]+")"},org:function(t){return"org("+[t.x,t.y]+")"},move:function(t){return"move("+[t.x1,t.y1,t.x2,t.y2,t.t1,t.t2]+")"},fade:function(t){return t.type==="fad"?"fad("+[t.t1,t.t2]+")":"fade("+[t.a1,t.a2,t.a3,t.t1,t.t2,t.t3,t.t4]+")"},clip:function(t){return(t.inverse?"i":"")+"clip("+(t.dots?""+[t.dots.x1,t.dots.y1,t.dots.x2,t.dots.y2]:""+(t.scale===1?"":t.scale+",")+O(t.drawing))+")"},t:function(t){return t.map(function(t){return"t("+[t.t1,t.t2,t.accel,H(t.tag)]+")"}).join("\\")}};function H(e){return Object.keys(e).map(function(r){var t=_[r]||function(t){return""+r+t};return"\\"+t(e[r])}).join("")}function G(t){return t.fragments.map(function(t){var r=t.tag;var e=t.text;var a=t.drawing;var n=H(r);return""+(n?"{"+n+"}":"")+(a?O(a):e)}).join("")}function Q(i,s){return i.slices.filter(function(t){return t.fragments.length}).map(function(t,r){var e=JSON.parse(JSON.stringify(t));var a=e.fragments[0];var n=a.tag;if(r){n.r=t.style===i.style?"":t.style}else{if(s.Alignment!==i.alignment){n.an=i.alignment}["pos","org","move","fade","clip"].forEach(function(t){if(i[t]){n[t]=i[t]}})}return e}).map(G).join("")}function N(t,r){return t===r?"0000":t}function Z(t,r){return"Dialogue: "+[t.layer,e(t.start),e(t.end),t.style,t.name,N(t.margin.left,r.MarginL),N(t.margin.right,r.MarginR),N(t.margin.vertical,r.MarginV),a(t.effect),Q(t,r)].join()}function tt(t){var r=t.info;var e=t.width;var a=t.height;var n=t.collisions;var i=t.styles;var s=t.dialogues;return["[Script Info]",g(I({},r,{PlayResX:e,PlayResY:a,Collisions:n})),"","[V4+ Styles]","Format: "+o.join(", ")].concat(Object.keys(i).map(function(t){return q(i[t])}),[""],["[Events]"],["Format: "+c.join(", ")],s.sort(function(t,r){return t.start-r.start||t.end-r.end}).map(function(t){return Z(t,i[t.style].style)}),[""]).join("\n")}t.compile=W;t.decompile=tt;t.parse=n;t.stringify=M;Object.defineProperty(t,"__esModule",{value:true})}); |
{ | ||
"name": "ass-compiler", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Parses and compiles ASS subtitle format to easy-to-use data structure.", | ||
@@ -5,0 +5,0 @@ "main": "dist/ass-compiler.js", |
@@ -102,3 +102,3 @@ export interface ParsedTag { | ||
accel: number; | ||
tags: CompiledTag; | ||
tag: CompiledTag; | ||
}[]; | ||
@@ -105,0 +105,0 @@ u?: 0 | 1; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94372