site/node_modules/get-tsconfig/dist/index.mjs

8 lines
16 KiB
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
import p from"path";import d from"fs";import ge from"module";import{resolveExports as ae}from"resolve-pkg-maps";function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const W=e=>{const t=d[e];return(i,...n)=>{const l=`${e}:${n.join(":")}`;let s=i==null?void 0:i.get(l);return s===void 0&&(s=Reflect.apply(t,d,n),i==null||i.set(l,s)),s}},_=W("existsSync"),ke=W("readFileSync"),I=W("statSync"),q=(e,t,i)=>{for(;;){const n=p.posix.join(e,t);if(_(i,n))return n;const l=p.dirname(e);if(l===e)return;e=l}},h=/^\.{1,2}(\/.*)?$/,J=e=>{const t=B(e);return h.test(t)?t:`./${t}`};function be(e,t=!1){const i=e.length;let n=0,l="",s=0,o=16,m=0,u=0,w=0,v=0,f=0;function E(r,g){let c=0,$=0;for(;c<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++,c++}return c<r&&($=-1),$}function b(r){n=r,l="",s=0,o=16,f=0}function T(){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 f=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 f=3;return e.substring(r,g)}function k(){let r="",g=n;for(;;){if(n>=i){r+=e.substring(g,n),f=2;break}const c=e.charCodeAt(n);if(c===34){r+=e.substring(g,n),n++;break}if(c===92){if(r+=e.substring(g,n),n++,n>=i){f=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):f=4;break;default:f=5}g=n;continue}if(c>=0&&c<=31)if(N(c)){r+=e.substring(g,n),f=2;break}else f=6;n++}return r}function j(){if(l="",f=0,s=n,u=m,v=w,n>=i)return s=i,o=17;let r=e.charCodeAt(n);if(M(r)){do n++,l+=String.fromCharCode(r),r=e.charCodeAt(n);while(M(r));return o=15}if(N(r))return n++,l+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,l+=`
`),m++,w=n,o=14;switch(r){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,l=k(),o=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!N(e.charCodeAt(n));)n++;return l=e.substring(g,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const c=i-1;let $=!1;for(;n<c;){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++,m++,w=n)}return $||(n++,f=1),l=e.substring(g,n),o=13}return l+=String.fromCharCode(r),n++,o=16;case 45:if(l+=String.fromCharCode(r),n++,n===i||!y(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return l+=T(),o=11;default:for(;n<i&&L(r);)n++,r=e.charCodeAt(n);if(s!==n){switch(l=e.substring(s,n),l){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return l+=String.fromCharCode(r),n++,o=16}}function L(r){if(M(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:()=>o,getTokenValue:()=>l,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>u,getTokenStartCharacter:()=>s-v,getTokenError:()=>f}}function M(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 P;(function(e){e.DEFAULT={allowTrailingComma:!1}})(P||(P={}));function we(e,t=[],i=P.DEFAULT){let n=null,l=[];const s=[];function o(u){Array.isArray(l)?l.push(u):n!==null&&(l[n]=u)}return Te(e,{onObjectBegin:()=>{const u={};o(u),s.push(l),l=u,n=null},onObjectProperty:u=>{n=u},onObjectEnd:()=>{l=s.pop()},onArrayBegin:()=>{const u=[];o(u),s.push(l),l=u,n=null},onArrayEnd:()=>{l=s.pop()},onLiteralValue:o,onError:(u,w,v)=>{t.push({error:u,offset:w,length:v})}},i),l[0]}function Te(e,t,i=P.DEFAULT){const n=be(e,!1),l=[];function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function o(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}function m(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}const w=o(t.onObjectBegin),v=u(t.onObjectProperty),f=s(t.onObjectEnd),E=o(t.onArrayBegin),b=s(t.onArrayEnd),T=u(t.onLiteralValue),k=m(t.onSeparator),j=s(t.onComment),L=m(t.onError),U=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:c(14);break;case 5:c(15);break;case 3:c(13);break;case 1:U||c(11);break;case 2:c(12);break;case 6:c(16);break}switch(a){case 12:case 13:U?c(10):j();break;case 16:c(1);break;case 15:case 14:break;default:return a}}}function c(a,O=[],Z=[]){if(L(a),O.length+Z.length>0){let x=n.getToken();for(;x!==17;){if(O.indexOf(x)!==-1){g();break}else if(Z.indexOf(x)!==-1)break;x=g()}}}function $(a){const O=n.getTokenValue();return a?T(O):(v(O),l.push(O)),g(),!0}function A(){switch(n.getToken()){case 11:const a=n.getTokenValue();let O=Number(a);isNaN(O)&&(c(2),O=0),T(O);break;case 7:T(null);break;case 8:T(!0);break;case 9:T(!1);break;default:return!1}return g(),!0}function ce(){return n.getToken()!==10?(c(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),S()||c(4,[],[2,5])):c(5,[],[2,5]),l.pop(),!0)}function pe(){w(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||c(4,[],[]),k(","),g(),n.getToken()===2&&r)break}else a&&c(6,[],[]);ce()||c(4,[],[2,5]),a=!0}return f(),n.getToken()!==2?c(7,[2],[]):g(),!0}function me(){E(),g();let a=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||c(4,[],[]),k(","),g(),n.getToken()===4&&r)break}else O&&c(6,[],[]);a?(l.push(0),a=!1):l[l.length-1]++,S()||c(4,[],[4,5]),O=!0}return b(),a||l.pop(),n.getToken()!==4?c(8,[4],[]):g(),!0}function S(){switch(n.getToken()){case 3:return me();case 1:return pe();case 10:return $(!0);default:return A()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(c(4,[],[]),!1):S()?(n.getToken()!==17&&c(9,[],[]),!0):(c(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 ve=we;var ne;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected