4 lines
16 KiB
JavaScript
Executable File
4 lines
16 KiB
JavaScript
Executable File
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ue=require("path"),fe=require("fs"),ce=require("module");function x(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var p=x(ue),L=x(fe),re=x(ce);function d(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}function M(e,l){for(;;){const t=p.default.posix.join(e,l);if(L.default.existsSync(t))return t;const n=p.default.dirname(e);if(n===e)return;e=n}}const S=/^\.{1,2}(\/.*)?$/,W=e=>d(S.test(e)?e:`./${e}`);function pe(e,l=!1){const t=e.length;let n=0,i="",o=0,u=16,m=0,a=0,O=0,k=0,r=0;function $(s,c){let f=0,j=0;for(;f<s||!c;){let T=e.charCodeAt(n);if(T>=48&&T<=57)j=j*16+T-48;else if(T>=65&&T<=70)j=j*16+T-65+10;else if(T>=97&&T<=102)j=j*16+T-97+10;else break;n++,f++}return f<s&&(j=-1),j}function E(s){n=s,i="",o=0,u=16,r=0}function A(){let s=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&U(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&U(e.charCodeAt(n)))for(n++;n<e.length&&U(e.charCodeAt(n));)n++;else return r=3,e.substring(s,n);let c=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&&U(e.charCodeAt(n))){for(n++;n<e.length&&U(e.charCodeAt(n));)n++;c=n}else r=3;return e.substring(s,c)}function b(){let s="",c=n;for(;;){if(n>=t){s+=e.substring(c,n),r=2;break}const f=e.charCodeAt(n);if(f===34){s+=e.substring(c,n),n++;break}if(f===92){if(s+=e.substring(c,n),n++,n>=t){r=2;break}switch(e.charCodeAt(n++)){case 34:s+='"';break;case 92:s+="\\";break;case 47:s+="/";break;case 98:s+="\b";break;case 102:s+="\f";break;case 110:s+=`
|
|
`;break;case 114:s+="\r";break;case 116:s+=" ";break;case 117:const T=$(4,!0);T>=0?s+=String.fromCharCode(T):r=4;break;default:r=5}c=n;continue}if(f>=0&&f<=31)if(F(f)){s+=e.substring(c,n),r=2;break}else r=6;n++}return s}function v(){if(i="",r=0,o=n,a=m,k=O,n>=t)return o=t,u=17;let s=e.charCodeAt(n);if(R(s)){do n++,i+=String.fromCharCode(s),s=e.charCodeAt(n);while(R(s));return u=15}if(F(s))return n++,i+=String.fromCharCode(s),s===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
`),m++,O=n,u=14;switch(s){case 123:return n++,u=1;case 125:return n++,u=2;case 91:return n++,u=3;case 93:return n++,u=4;case 58:return n++,u=6;case 44:return n++,u=5;case 34:return n++,i=b(),u=10;case 47:const c=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<t&&!F(e.charCodeAt(n));)n++;return i=e.substring(c,n),u=12}if(e.charCodeAt(n+1)===42){n+=2;const f=t-1;let j=!1;for(;n<f;){const T=e.charCodeAt(n);if(T===42&&e.charCodeAt(n+1)===47){n+=2,j=!0;break}n++,F(T)&&(T===13&&e.charCodeAt(n)===10&&n++,m++,O=n)}return j||(n++,r=1),i=e.substring(c,n),u=13}return i+=String.fromCharCode(s),n++,u=16;case 45:if(i+=String.fromCharCode(s),n++,n===t||!U(e.charCodeAt(n)))return u=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=A(),u=11;default:for(;n<t&&_(s);)n++,s=e.charCodeAt(n);if(o!==n){switch(i=e.substring(o,n),i){case"true":return u=8;case"false":return u=9;case"null":return u=7}return u=16}return i+=String.fromCharCode(s),n++,u=16}}function _(s){if(R(s)||F(s))return!1;switch(s){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function B(){let s;do s=v();while(s>=12&&s<=15);return s}return{setPosition:E,getPosition:()=>n,scan:l?B:v,getToken:()=>u,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>a,getTokenStartCharacter:()=>o-k,getTokenError:()=>r}}function R(e){return e===32||e===9}function F(e){return e===10||e===13}function U(e){return e>=48&&e<=57}var H;(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"})(H||(H={}));var D;(function(e){e.DEFAULT={allowTrailingComma:!1}})(D||(D={}));function ae(e,l=[],t=D.DEFAULT){let n=null,i=[];const o=[];function u(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return ge(e,{onObjectBegin:()=>{const a={};u(a),o.push(i),i=a,n=null},onObjectProperty:a=>{n=a},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const a=[];u(a),o.push(i),i=a,n=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:u,onError:(a,O,k)=>{l.push({error:a,offset:O,length:k})}},t),i[0]}function ge(e,l,t=D.DEFAULT){const n=pe(e,!1),i=[];function o(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function m(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}const O=u(l.onObjectBegin),k=a(l.onObjectProperty),r=o(l.onObjectEnd),$=u(l.onArrayBegin),E=o(l.onArrayEnd),A=a(l.onLiteralValue),b=m(l.onSeparator),v=o(l.onComment),_=m(l.onError),B=t&&t.disallowComments,s=t&&t.allowTrailingComma;function c(){for(;;){const g=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:B||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(g){case 12:case 13:B?f(10):v();break;case 16:f(1);break;case 15:case 14:break;default:return g}}}function f(g,w=[],z=[]){if(_(g),w.length+z.length>0){let h=n.getToken();for(;h!==17;){if(w.indexOf(h)!==-1){c();break}else if(z.indexOf(h)!==-1)break;h=c()}}}function j(g){const w=n.getTokenValue();return g?A(w):(k(w),i.push(w)),c(),!0}function T(){switch(n.getToken()){case 11:const g=n.getTokenValue();let w=Number(g);isNaN(w)&&(f(2),w=0),A(w);break;case 7:A(null);break;case 8:A(!0);break;case 9:A(!1);break;default:return!1}return c(),!0}function le(){return n.getToken()!==10?(f(3,[],[2,5]),!1):(j(!1),n.getToken()===6?(b(":"),c(),V()||f(4,[],[2,5])):f(5,[],[2,5]),i.pop(),!0)}function se(){O(),c();let g=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(g||f(4,[],[]),b(","),c(),n.getToken()===2&&s)break}else g&&f(6,[],[]);le()||f(4,[],[2,5]),g=!0}return r(),n.getToken()!==2?f(7,[2],[]):c(),!0}function oe(){$(),c();let g=!0,w=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(w||f(4,[],[]),b(","),c(),n.getToken()===4&&s)break}else w&&f(6,[],[]);g?(i.push(0),g=!1):i[i.length-1]++,V()||f(4,[],[4,5]),w=!0}return E(),g||i.pop(),n.getToken()!==4?f(8,[4],[]):c(),!0}function V(){switch(n.getToken()){case 3:return oe();case 1:return se();case 10:return j(!0);default:return T()}}return c(),n.getToken()===17?t.allowEmptyContent?!0:(f(4,[],[]),!1):V()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var X;(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"})(X||(X={}));var Y;(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"})(Y||(Y={}));const me=ae;var Z;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Z||(Z={}));const q=e=>me(L.default.readFileSync(e,"utf8")),{existsSync:N}=L.default,ke=()=>{const{findPnpApi:e}=re.default;return e&&e(process.cwd())};function K(e){const l=q(e);return p.default.join(e,"..",l&&"tsconfig"in l?l.tsconfig:"tsconfig.json")}function be(e,l){let t=e;const n=e[0]===".";if(n||p.default.isAbsolute(e)){if(n&&(t===".."&&(t+="/tsconfig.json"),t=p.default.resolve(l,t)),N(t)&&L.default.statSync(t).isFile()||!t.endsWith(".json")&&(t+=".json",N(t)))return t;throw new Error(`File '${e}' not found.`)}const i=ke();if(i){const{resolveRequest:u}=i,[m,a]=e.split("/"),O=m.startsWith("@")?`${m}/${a}`:m;try{if(O===e){const k=u(p.default.join(O,"package.json"),l);if(k){const r=K(k);if(N(r))return r}}else{let k;try{k=u(e,l,{extensions:[".json"]})}catch{k=u(p.default.join(e,"tsconfig.json"),l)}if(k)return k}}catch{}}let o=M(l,p.default.join("node_modules",t));if(o){if(L.default.statSync(o).isDirectory()){const u=p.default.join(o,"package.json");if(N(u)?o=K(u):o=p.default.join(o,"tsconfig.json"),N(o))return o}else if(o.endsWith(".json"))return o}if(!t.endsWith(".json")&&(t+=".json",o=M(l,p.default.join("node_modules",t)),o))return o;throw new Error(`File '${e}' not found.`)}const Te=(e,l)=>{var t;const n=be(e,l),i=J(n);if(delete i.references,(t=i.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:o}=i;o.baseUrl=p.default.relative(l,p.default.join(p.default.dirname(n),o.baseUrl))||"./"}return i.files&&(i.files=i.files.map(o=>p.default.relative(l,p.default.join(p.default.dirname(n),o)))),i.include&&(i.include=i.include.map(o=>p.default.relative(l,p.default.join(p.default.dirname(n),o)))),i},J=e=>{let l;try{l=L.default.realpathSync(e)}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}const t=p.default.dirname(l);let n=q(l)||{};if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);if(n.extends){const i=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const o of i.reverse()){const u=Te(o,t),m={...u,...n,compilerOptions:{...u.compilerOptions,...n.compilerOptions}};u.watchOptions&&(m.watchOptions={...u.watchOptions,...n.watchOptions}),n=m}}if(n.compilerOptions){const{compilerOptions:i}=n;i.baseUrl&&(i.baseUrl=W(i.baseUrl)),i.outDir&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.push(i.outDir),i.outDir=W(i.outDir))}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(W)),n.include&&(n.include=n.include.map(d)),n.watchOptions){const{watchOptions:i}=n;i.excludeDirectories&&(i.excludeDirectories=i.excludeDirectories.map(o=>d(p.default.resolve(t,o))))}return n};function we(e=process.cwd(),l="tsconfig.json"){const t=M(d(e),l);if(!t)return null;const n=J(t);return{path:t,config:n}}const ve=/\*/g,C=(e,l)=>{const t=e.match(ve);if(t&&t.length>1)throw new Error(l)};function Oe(e){if(e.includes("*")){const[l,t]=e.split("*");return{prefix:l,suffix:t}}return e}const je=({prefix:e,suffix:l},t)=>t.startsWith(e)&&t.endsWith(l);function Ae(e,l,t){return Object.entries(e).map(([n,i])=>(C(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:Oe(n),substitutions:i.map(o=>{if(C(o,`Substitution '${o}' in pattern '${n}' can have at most one '*' character.`),!l&&!S.test(o))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return p.default.join(t,o)})}))}function de(e){if(!e.config.compilerOptions)return null;const{baseUrl:l,paths:t}=e.config.compilerOptions;if(!l&&!t)return null;const n=p.default.resolve(p.default.dirname(e.path),l||"."),i=t?Ae(t,l,n):[];return function(u){if(S.test(u))return[];const m=[];for(const r of i){if(r.pattern===u)return r.substitutions.map(d);typeof r.pattern!="string"&&m.push(r)}let a,O=-1;for(const r of m)je(r.pattern,u)&&r.pattern.prefix.length>O&&(O=r.pattern.prefix.length,a=r);if(!a)return l?[d(p.default.join(n,u))]:[];const k=u.slice(a.pattern.prefix.length,u.length-a.pattern.suffix.length);return a.substitutions.map(r=>d(r.replace("*",k)))}}const ee=e=>{let l="";for(let t=0;t<e.length;t+=1){const n=e[t],i=n.toUpperCase();l+=n===i?n.toLowerCase():i}return l},_e=65,Le=97,Ee=()=>Math.floor(Math.random()*26),Be=e=>Array.from({length:e},()=>String.fromCodePoint(Ee()+(Math.random()>.5?_e:Le))).join(""),Ue=(e=L.default)=>{const l=process.execPath;if(e.existsSync(l))return!e.existsSync(ee(l));const t=`/${Be(10)}`;e.writeFileSync(t,"");const n=!e.existsSync(ee(t));return e.unlinkSync(t),n},{join:y}=p.default.posix,G={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},$e=e=>{const l=[...G.ts],t=[...G.cts],n=[...G.mts];return e!=null&&e.allowJs&&(l.push(".js",".jsx"),t.push(".cjs"),n.push(".mjs")),[...l,...t,...n]},Fe=e=>{const l=[];if(!e)return l;const{outDir:t,declarationDir:n}=e;return t&&l.push(t),n&&l.push(n),l},ne=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ne=["node_modules","bower_components","jspm_packages"],P=`(?!(${Ne.join("|")})(/|$))`,he=/(?:^|\/)[^.*?]+$/,te="**/*",I="[^/]",Q="[^./]",ie=process.platform==="win32",De=({config:e,path:l},t=Ue())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!p.default.isAbsolute(l))throw new Error("The tsconfig path must be absolute");ie&&(l=d(l));const n=p.default.dirname(l),{files:i,include:o,exclude:u,compilerOptions:m}=e,a=i==null?void 0:i.map(b=>y(n,b)),O=$e(m),k=t?"":"i",$=(u||Fe(m)).map(b=>{const v=y(n,b),_=ne(v).replace(/\\\*\\\*\//g,"(.+/)?").replace(/\\\*/g,`${I}*`).replace(/\\\?/g,I);return new RegExp(`^${_}($|/)`,k)}),E=i||o?o:[te],A=E?E.map(b=>{let v=y(n,b);he.test(v)&&(v=y(v,te));const _=ne(v).replace(/\/\\\*\\\*/g,`(/${P}${Q}${I}*)*?`).replace(/(\/)?\\\*/g,(B,s)=>{const c=`(${Q}|(\\.(?!min\\.js$))?)*`;return s?`/${P}${Q}${c}`:c}).replace(/(\/)?\\\?/g,(B,s)=>{const c=I;return s?`/${P}${c}`:c});return new RegExp(`^${_}$`,k)}):void 0;return b=>{if(!p.default.isAbsolute(b))throw new Error("filePath must be absolute");if(ie&&(b=d(b)),a!=null&&a.includes(b))return e;if(!(!O.some(v=>b.endsWith(v))||$.some(v=>v.test(b)))&&A&&A.some(v=>v.test(b)))return e}};exports.createFilesMatcher=De,exports.createPathsMatcher=de,exports.getTsconfig=we,exports.parseTsconfig=J;
|