2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
|
"use strict";var e=require("fs-extra"),r=require("dagrejs"),t=require("svgdom"),n=require("@svgdotjs/svg.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(e),i=o(r),l=o(t),u=o(n);function c(e,r,t,n){this.message=e,this.expected=r,this.found=t,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,c)}!function(e,r){function t(){this.constructor=e}t.prototype=r.prototype,e.prototype=new t}(c,Error),c.buildMessage=function(e,r){var t={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var r,t="";for(r=0;r<e.parts.length;r++)t+=e.parts[r]instanceof Array?a(e.parts[r][0])+"-"+a(e.parts[r][1]):a(e.parts[r]);return"["+(e.inverted?"^":"")+t+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function a(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}return"Expected "+function(e){var r,n,o,a=new Array(e.length);for(r=0;r<e.length;r++)a[r]=(o=e[r],t[o.type](o));if(a.sort(),a.length>0){for(r=1,n=1;r<a.length;r++)a[r-1]!==a[r]&&(a[n]=a[r],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(r)+" found."};var s={SyntaxError:c,parse:function(e,r){r=void 0!==r?r:{};var t,n,o,a,i={},l={FML:Y},u=Y,s="=>",f=H("=>",!1),d="<=",p=H("<=",!1),h="<--\x3e",g=H("<--\x3e",!1),m=H(":",!1),v=H("{",!1),x=",",y=H(",",!1),b=H("}",!1),A=H("(",!1),k=H(")",!1),w=H("[",!1),E=H("]",!1),C="[ ]",q=H("[ ]",!1),F="[]",S=H("[]",!1),M="[*]",j=H("[*]",!1),G=/^[a-zA-Z0-9\/._\- ]/,R=I([["a","z"],["A","Z"],["0","9"],"/",".","_","-"," "],!1,!1),U=function(){return e.substring(_,Z)},W=K("whitespace"),z=/^[ \t\n\r]/,L=I([" ","\t","\n","\r"],!1,!1),N=K("eol"),T=/^[\n\r]/,V=I(["\n","\r"],!1,!1),Z=0,_=0,D=[{line:1,column:1}],J=0,O=[],B=0;if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function H(e,r){return{type:"literal",text:e,ignoreCase:r}}function I(e,r,t){return{type:"class",parts:e,inverted:r,ignoreCase:t}}function K(e){return{type:"other",description:e}}function P(r){var t,n=D[r];if(n)return n;for(t=r-1;!D[t];)t--;for(n={line:(n=D[t]).line,column:n.column};t<r;)10===e.charCodeAt(t)?(n.line++,n.column=1):n.column++,t++;return D[r]=n,n}function Q(e,r){var t=P(e),n=P(r);return{start:{offset:e,line:t.line,column:t.column},end:{offset:r,line:n.line,column:n.column}}}function X(e){Z<J||(Z>J&&(J=Z,O=[]),O.push(e))}function Y(){var e,r,t;return e=Z,(r=ee())!==i?(t=function(){var e,r,t;e=Z,r=[],t=$();for(;t!==i;)r.push(t),t=$();r!==i&&(_=e,(n=r).forEach(((e,r)=>{""==e.from&&(e.from="rimply"==n[r-1].type?n[r-1].from:n[r-1].to),""==e.to&&(e.to="rimply"==n[r-1].type?n[r-1].from:n[r-1].to)})),r={imply:n.filter((e=>"imply"==e.type||"rimply"==e.type)),exclude:n.filter((e=>"exclude"==e.type))});var n;return e=r}(),t!==i?e=r=[r,t]:(Z=e,e=i)):(Z=e,e=i),e}function $(){var r;return(r=function(){var r,t,n,o;r=Z,(t=te())!==i&&ne()!==i?(e.substr(Z,4)===h?(n=h,Z+=4):(n=i,0===B&&X(g)),n!==i&&ne()!==i&&(o=te())!==i&&oe()!==i?(_=r,a=o,r=t={from:t.trim(),to:a.trim(),type:"exclude"}):(Z=r,r=i)):(Z=r,r=i);var a;return r}())===i&&(r=function(){var r,t,n,o;r=Z,(t=te())!==i&&ne()!==i?(e.substr(Z,2)===s?(n=s,Z+=2):(n=i,0===B&&X(f)),n!==i&&ne()!==i&&(o=te())!==i&&oe()!==i?(_=r,a=o,r=t={from:t.trim(),to:a.trim(),type:"
|