8 lines
16 KiB
JavaScript
8 lines
16 KiB
JavaScript
|
"use strict";var p=require("path"),d=require("fs"),ge=require("module"),me=require("resolve-pkg-maps");function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const h=e=>{const t=d[e];return(i,...n)=>{const s=`${e}:${n.join(":")}`;let o=i==null?void 0:i.get(s);return o===void 0&&(o=Reflect.apply(t,d,n),i==null||i.set(s,o)),o}},_=h("existsSync"),ke=h("readFileSync"),P=h("statSync"),Z=(e,t,i)=>{for(;;){const n=p.posix.join(e,t);if(_(i,n))return n;const s=p.dirname(e);if(s===e)return;e=s}},M=/^\.{1,2}(\/.*)?$/,W=e=>{const t=B(e);return M.test(t)?t:`./${t}`};function be(e,t=!1){const i=e.length;let n=0,s="",o=0,l=16,a=0,u=0,w=0,T=0,c=0;function E(r,g){let f=0,$=0;for(;f<r||!g;){let A=e.charCodeAt(n);if(A>=48&&A<=57)$=$*16+A-48;else if(A>=65&&A<=70)$=$*16+A-65+10;else if(A>=97&&A<=102)$=$*16+A-97+10;else break;n++,f++}return f<r&&($=-1),$}function b(r){n=r,s="",o=0,l=16,c=0}function v(){let r=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&y(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&y(e.charCodeAt(n)))for(n++;n<e.length&&y(e.charCodeAt(n));)n++;else return c=3,e.substring(r,n);let g=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&y(e.charCodeAt(n))){for(n++;n<e.length&&y(e.charCodeAt(n));)n++;g=n}else c=3;return e.substring(r,g)}function k(){let r="",g=n;for(;;){if(n>=i){r+=e.substring(g,n),c=2;break}const f=e.charCodeAt(n);if(f===34){r+=e.substring(g,n),n++;break}if(f===92){if(r+=e.substring(g,n),n++,n>=i){c=2;break}switch(e.charCodeAt(n++)){case 34:r+='"';break;case 92:r+="\\";break;case 47:r+="/";break;case 98:r+="\b";break;case 102:r+="\f";break;case 110:r+=`
|
||
|
`;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const A=E(4,!0);A>=0?r+=String.fromCharCode(A):c=4;break;default:c=5}g=n;continue}if(f>=0&&f<=31)if(N(f)){r+=e.substring(g,n),c=2;break}else c=6;n++}return r}function j(){if(s="",c=0,o=n,u=a,T=w,n>=i)return o=i,l=17;let r=e.charCodeAt(n);if(J(r)){do n++,s+=String.fromCharCode(r),r=e.charCodeAt(n);while(J(r));return l=15}if(N(r))return n++,s+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,s+=`
|
||
|
`),a++,w=n,l=14;switch(r){case 123:return n++,l=1;case 125:return n++,l=2;case 91:return n++,l=3;case 93:return n++,l=4;case 58:return n++,l=6;case 44:return n++,l=5;case 34:return n++,s=k(),l=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!N(e.charCodeAt(n));)n++;return s=e.substring(g,n),l=12}if(e.charCodeAt(n+1)===42){n+=2;const f=i-1;let $=!1;for(;n<f;){const A=e.charCodeAt(n);if(A===42&&e.charCodeAt(n+1)===47){n+=2,$=!0;break}n++,N(A)&&(A===13&&e.charCodeAt(n)===10&&n++,a++,w=n)}return $||(n++,c=1),s=e.substring(g,n),l=13}return s+=String.fromCharCode(r),n++,l=16;case 45:if(s+=String.fromCharCode(r),n++,n===i||!y(e.charCodeAt(n)))return l=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return s+=v(),l=11;default:for(;n<i&&L(r);)n++,r=e.charCodeAt(n);if(o!==n){switch(s=e.substring(o,n),s){case"true":return l=8;case"false":return l=9;case"null":return l=7}return l=16}return s+=String.fromCharCode(r),n++,l=16}}function L(r){if(J(r)||N(r))return!1;switch(r){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function U(){let r;do r=j();while(r>=12&&r<=15);return r}return{setPosition:b,getPosition:()=>n,scan:t?U:j,getToken:()=>l,getTokenValue:()=>s,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>u,getTokenStartCharacter:()=>o-T,getTokenError:()=>c}}function J(e){return e===32||e===9}function N(e){return e===10||e===13}function y(e){return e>=48&&e<=57}var K;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(K||(K={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const F=200;new Array(F).fill(0).map((e,t)=>`
|
||
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
||
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`
|
||
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
||
|
`+" ".repeat(t));var I;(function(e){e.DEFAULT={allowTrailingComma:!1}})(I||(I={}));function we(e,t=[],i=I.DEFAULT){let n=null,s=[];const o=[];function l(u){Array.isArray(s)?s.push(u):n!==null&&(s[n]=u)}return ve(e,{onObjectBegin:()=>{const u={};l(u),o.push(s),s=u,n=null},onObjectProperty:u=>{n=u},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{const u=[];l(u),o.push(s),s=u,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:l,onError:(u,w,T)=>{t.push({error:u,offset:w,length:T})}},i),s[0]}function ve(e,t,i=I.DEFAULT){const n=be(e,!1),s=[];function o(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function a(m){return m?O=>m(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(m){return m?O=>m(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}const w=l(t.onObjectBegin),T=u(t.onObjectProperty),c=o(t.onObjectEnd),E=l(t.onArrayBegin),b=o(t.onArrayEnd),v=u(t.onLiteralValue),k=a(t.onSeparator),j=o(t.onComment),L=a(t.onError),U=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const m=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:U||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(m){case 12:case 13:U?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return m}}}function f(m,O=[],Y=[]){if(L(m),O.length+Y.length>0){let x=n.getToken();for(;x!==17;){if(O.indexOf(x)!==-1){g();break}else if(Y.indexOf(x)!==-1)break;x=g()}}}function $(m){const O=n.getTokenValue();return m?v(O):(T(O),s.push(O)),g(),!0}function A(){switch(n.getToken()){case 11:const m=n.getTokenValue();let O=Number(m);isNaN(O)&&(f(2),O=0),v(O);break;case 7:v(null);break;case 8:v(!0);break;case 9:v(!1);break;default:return!1}return g(),!0}function fe(){return n.getToken()!==10?(f(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),S()||f(4,[],[2,5])):f(5,[],[2,5]),s.pop(),!0)}function pe(){w(),g();let m=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(m||f(4,[],[]),k(","),g(),n.getToken()===2&&r)break}else m&&f(6,[],[]);fe()||f(4,[],[2,5]),m=!0}return c(),n.getToken()!==2?f(7,[2],[]):g(),!0}function ae(){E(),g();let m=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||f(4,[],[]),k(","),g(),n.getToken()===4&&r)break}else O&&f(6,[],[]);m?(s.push(0),m=!1):s[s.length-1]++,S()||f(4,[],[4,5]),O=!0}return b(),m||s.pop(),n.getToken()!==4?f(8,[4],[]):g(),!0}function S(){switch(n.getToken()){case 3:return ae();case 1:return pe();case 10:return $(!0);default:return A()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(f(4,[],[]),!1):S()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var C;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(C||(C={}));var ee;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(ee||(ee={}));const Te=we;var ne;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected
|