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