pathe.BSlhyZSM.cjs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. 'use strict';
  2. let _lazyMatch = () => { var __lib__=(()=>{var m=Object.defineProperty,V=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyNames,T=Object.prototype.hasOwnProperty,q=(r,e)=>{for(var n in e)m(r,n,{get:e[n],enumerable:true});},H=(r,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of G(e))!T.call(r,t)&&t!==n&&m(r,t,{get:()=>e[t],enumerable:!(a=V(e,t))||a.enumerable});return r},J=r=>H(m({},"__esModule",{value:true}),r),w={};q(w,{default:()=>re});var A=r=>Array.isArray(r),d=r=>typeof r=="function",Q=r=>r.length===0,W=r=>typeof r=="number",K=r=>typeof r=="object"&&r!==null,X=r=>r instanceof RegExp,b=r=>typeof r=="string",h=r=>r===void 0,Y=r=>{const e=new Map;return n=>{const a=e.get(n);if(a)return a;const t=r(n);return e.set(n,t),t}},rr=(r,e,n={})=>{const a={cache:{},input:r,index:0,indexMax:0,options:n,output:[]};if(v(e)(a)&&a.index===r.length)return a.output;throw new Error(`Failed to parse at index ${a.indexMax}`)},i=(r,e)=>A(r)?er(r,e):b(r)?ar(r,e):nr(r,e),er=(r,e)=>{const n={};for(const a of r){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const t=a.charCodeAt(0);n[t]=true;}return a=>{const t=a.index,o=a.input;for(;a.index<o.length&&o.charCodeAt(a.index)in n;)a.index+=1;const u=a.index;if(u>t){if(!h(e)&&!a.options.silent){const s=a.input.slice(t,u),c=d(e)?e(s,o,String(t)):e;h(c)||a.output.push(c);}a.indexMax=Math.max(a.indexMax,a.index);}return true}},nr=(r,e)=>{const n=r.source,a=r.flags.replace(/y|$/,"y"),t=new RegExp(n,a);return g(o=>{t.lastIndex=o.index;const u=t.exec(o.input);if(u){if(!h(e)&&!o.options.silent){const s=d(e)?e(...u,o.input,String(o.index)):e;h(s)||o.output.push(s);}return o.index+=u[0].length,o.indexMax=Math.max(o.indexMax,o.index),true}else return false})},ar=(r,e)=>n=>{if(n.input.startsWith(r,n.index)){if(!h(e)&&!n.options.silent){const t=d(e)?e(r,n.input,String(n.index)):e;h(t)||n.output.push(t);}return n.index+=r.length,n.indexMax=Math.max(n.indexMax,n.index),true}else return false},C=(r,e,n,a)=>{const t=v(r);return g(_(M(o=>{let u=0;for(;u<n;){const s=o.index;if(!t(o)||(u+=1,o.index===s))break}return u>=e})))},tr=(r,e)=>C(r,0,1),f=(r,e)=>C(r,0,1/0),x=(r,e)=>{const n=r.map(v);return g(_(M(a=>{for(let t=0,o=n.length;t<o;t++)if(!n[t](a))return false;return true})))},l=(r,e)=>{const n=r.map(v);return g(_(a=>{for(let t=0,o=n.length;t<o;t++)if(n[t](a))return true;return false}))},M=(r,e=false)=>{const n=v(r);return a=>{const t=a.index,o=a.output.length,u=n(a);return (!u||e)&&(a.index=t,a.output.length!==o&&(a.output.length=o)),u}},_=(r,e)=>{const n=v(r);return n},g=(()=>{let r=0;return e=>{const n=v(e),a=r+=1;return t=>{var o;if(t.options.memoization===false)return n(t);const u=t.index,s=(o=t.cache)[a]||(o[a]=new Map),c=s.get(u);if(c===false)return false;if(W(c))return t.index=c,true;if(c)return t.index=c.index,c.output?.length&&t.output.push(...c.output),true;{const Z=t.output.length;if(n(t)){const D=t.index,U=t.output.length;if(U>Z){const ee=t.output.slice(Z,U);s.set(u,{index:D,output:ee});}else s.set(u,D);return true}else return s.set(u,false),false}}}})(),E=r=>{let e;return n=>(e||(e=v(r())),e(n))},v=Y(r=>{if(d(r))return Q(r)?E(r):r;if(b(r)||X(r))return i(r);if(A(r))return x(r);if(K(r))return l(Object.values(r));throw new Error("Invalid rule")}),P="abcdefghijklmnopqrstuvwxyz",ir=r=>{let e="";for(;r>0;){const n=(r-1)%26;e=P[n]+e,r=Math.floor((r-1)/26);}return e},O=r=>{let e=0;for(let n=0,a=r.length;n<a;n++)e=e*26+P.indexOf(r[n])+1;return e},S=(r,e)=>{if(e<r)return S(e,r);const n=[];for(;r<=e;)n.push(r++);return n},or=(r,e,n)=>S(r,e).map(a=>String(a).padStart(n,"0")),R=(r,e)=>S(O(r),O(e)).map(ir),p=r=>r,z=r=>ur(e=>rr(e,r,{memoization:false}).join("")),ur=r=>{const e={};return n=>e[n]??(e[n]=r(n))},sr=i(/^\*\*\/\*$/,".*"),cr=i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(r,e,n)=>`.*${e?"":"(?:^|/)"}${n.replaceAll(".","\\.")}`),lr=i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(r,e,n,a)=>`.*${e?"":"(?:^|/)"}${n.replaceAll(".","\\.")}(?:${a.replaceAll(",","|").replaceAll(".","\\.")})`),y=i(/\\./,p),pr=i(/[$.*+?^(){}[\]\|]/,r=>`\\${r}`),vr=i(/./,p),hr=i(/^(?:!!)*!(.*)$/,(r,e)=>`(?!^${L(e)}$).*?`),dr=i(/^(!!)+/,""),fr=l([hr,dr]),xr=i(/\/(\*\*\/)+/,"(?:/.+/|/)"),gr=i(/^(\*\*\/)+/,"(?:^|.*/)"),mr=i(/\/(\*\*)$/,"(?:/.*|$)"),_r=i(/\*\*/,".*"),j=l([xr,gr,mr,_r]),Sr=i(/\*\/(?!\*\*\/)/,"[^/]*/"),yr=i(/\*/,"[^/]*"),N=l([Sr,yr]),k=i("?","[^/]"),$r=i("[",p),wr=i("]",p),Ar=i(/[!^]/,"^/"),br=i(/[a-z]-[a-z]|[0-9]-[0-9]/i,p),Cr=i(/[$.*+?^(){}[\|]/,r=>`\\${r}`),Mr=i(/[^\]]/,p),Er=l([y,Cr,br,Mr]),B=x([$r,tr(Ar),f(Er),wr]),Pr=i("{","(?:"),Or=i("}",")"),Rr=i(/(\d+)\.\.(\d+)/,(r,e,n)=>or(+e,+n,Math.min(e.length,n.length)).join("|")),zr=i(/([a-z]+)\.\.([a-z]+)/,(r,e,n)=>R(e,n).join("|")),jr=i(/([A-Z]+)\.\.([A-Z]+)/,(r,e,n)=>R(e.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),Nr=l([Rr,zr,jr]),I=x([Pr,Nr,Or]),kr=i("{","(?:"),Br=i("}",")"),Ir=i(",","|"),Fr=i(/[$.*+?^(){[\]\|]/,r=>`\\${r}`),Lr=i(/[^}]/,p),Zr=E(()=>F),Dr=l([j,N,k,B,I,Zr,y,Fr,Ir,Lr]),F=x([kr,f(Dr),Br]),Ur=f(l([sr,cr,lr,fr,j,N,k,B,I,F,y,pr,vr])),Vr=Ur,Gr=z(Vr),L=Gr,Tr=i(/\\./,p),qr=i(/./,p),Hr=i(/\*\*\*+/,"*"),Jr=i(/([^/{[(!])\*\*/,(r,e)=>`${e}*`),Qr=i(/(^|.)\*\*(?=[^*/)\]}])/,(r,e)=>`${e}*`),Wr=f(l([Tr,Hr,Jr,Qr,qr])),Kr=Wr,Xr=z(Kr),Yr=Xr,$=(r,e)=>{const n=Array.isArray(r)?r:[r];if(!n.length)return false;const a=n.map($.compile),t=n.every(s=>/(\/(?:\*\*)?|\[\/\])$/.test(s)),o=e.replace(/[\\\/]+/g,"/").replace(/\/$/,t?"/":"");return a.some(s=>s.test(o))};$.compile=r=>new RegExp(`^${L(Yr(r))}$`,"s");var re=$;return J(w)})();
  3. return __lib__.default || __lib__; };
  4. let _match;
  5. const zeptomatch = (path, pattern) => {
  6. if (!_match) {
  7. _match = _lazyMatch();
  8. _lazyMatch = null;
  9. }
  10. return _match(path, pattern);
  11. };
  12. const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
  13. function normalizeWindowsPath(input = "") {
  14. if (!input) {
  15. return input;
  16. }
  17. return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
  18. }
  19. const _UNC_REGEX = /^[/\\]{2}/;
  20. const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
  21. const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
  22. const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
  23. const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
  24. const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
  25. const sep = "/";
  26. const normalize = function(path) {
  27. if (path.length === 0) {
  28. return ".";
  29. }
  30. path = normalizeWindowsPath(path);
  31. const isUNCPath = path.match(_UNC_REGEX);
  32. const isPathAbsolute = isAbsolute(path);
  33. const trailingSeparator = path[path.length - 1] === "/";
  34. path = normalizeString(path, !isPathAbsolute);
  35. if (path.length === 0) {
  36. if (isPathAbsolute) {
  37. return "/";
  38. }
  39. return trailingSeparator ? "./" : ".";
  40. }
  41. if (trailingSeparator) {
  42. path += "/";
  43. }
  44. if (_DRIVE_LETTER_RE.test(path)) {
  45. path += "/";
  46. }
  47. if (isUNCPath) {
  48. if (!isPathAbsolute) {
  49. return `//./${path}`;
  50. }
  51. return `//${path}`;
  52. }
  53. return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
  54. };
  55. const join = function(...segments) {
  56. let path = "";
  57. for (const seg of segments) {
  58. if (!seg) {
  59. continue;
  60. }
  61. if (path.length > 0) {
  62. const pathTrailing = path[path.length - 1] === "/";
  63. const segLeading = seg[0] === "/";
  64. const both = pathTrailing && segLeading;
  65. if (both) {
  66. path += seg.slice(1);
  67. } else {
  68. path += pathTrailing || segLeading ? seg : `/${seg}`;
  69. }
  70. } else {
  71. path += seg;
  72. }
  73. }
  74. return normalize(path);
  75. };
  76. function cwd() {
  77. if (typeof process !== "undefined" && typeof process.cwd === "function") {
  78. return process.cwd().replace(/\\/g, "/");
  79. }
  80. return "/";
  81. }
  82. const resolve = function(...arguments_) {
  83. arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
  84. let resolvedPath = "";
  85. let resolvedAbsolute = false;
  86. for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
  87. const path = index >= 0 ? arguments_[index] : cwd();
  88. if (!path || path.length === 0) {
  89. continue;
  90. }
  91. resolvedPath = `${path}/${resolvedPath}`;
  92. resolvedAbsolute = isAbsolute(path);
  93. }
  94. resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
  95. if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
  96. return `/${resolvedPath}`;
  97. }
  98. return resolvedPath.length > 0 ? resolvedPath : ".";
  99. };
  100. function normalizeString(path, allowAboveRoot) {
  101. let res = "";
  102. let lastSegmentLength = 0;
  103. let lastSlash = -1;
  104. let dots = 0;
  105. let char = null;
  106. for (let index = 0; index <= path.length; ++index) {
  107. if (index < path.length) {
  108. char = path[index];
  109. } else if (char === "/") {
  110. break;
  111. } else {
  112. char = "/";
  113. }
  114. if (char === "/") {
  115. if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
  116. if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
  117. if (res.length > 2) {
  118. const lastSlashIndex = res.lastIndexOf("/");
  119. if (lastSlashIndex === -1) {
  120. res = "";
  121. lastSegmentLength = 0;
  122. } else {
  123. res = res.slice(0, lastSlashIndex);
  124. lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
  125. }
  126. lastSlash = index;
  127. dots = 0;
  128. continue;
  129. } else if (res.length > 0) {
  130. res = "";
  131. lastSegmentLength = 0;
  132. lastSlash = index;
  133. dots = 0;
  134. continue;
  135. }
  136. }
  137. if (allowAboveRoot) {
  138. res += res.length > 0 ? "/.." : "..";
  139. lastSegmentLength = 2;
  140. }
  141. } else {
  142. if (res.length > 0) {
  143. res += `/${path.slice(lastSlash + 1, index)}`;
  144. } else {
  145. res = path.slice(lastSlash + 1, index);
  146. }
  147. lastSegmentLength = index - lastSlash - 1;
  148. }
  149. lastSlash = index;
  150. dots = 0;
  151. } else if (char === "." && dots !== -1) {
  152. ++dots;
  153. } else {
  154. dots = -1;
  155. }
  156. }
  157. return res;
  158. }
  159. const isAbsolute = function(p) {
  160. return _IS_ABSOLUTE_RE.test(p);
  161. };
  162. const toNamespacedPath = function(p) {
  163. return normalizeWindowsPath(p);
  164. };
  165. const extname = function(p) {
  166. if (p === "..") return "";
  167. const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
  168. return match && match[1] || "";
  169. };
  170. const relative = function(from, to) {
  171. const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
  172. const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
  173. if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
  174. return _to.join("/");
  175. }
  176. const _fromCopy = [..._from];
  177. for (const segment of _fromCopy) {
  178. if (_to[0] !== segment) {
  179. break;
  180. }
  181. _from.shift();
  182. _to.shift();
  183. }
  184. return [..._from.map(() => ".."), ..._to].join("/");
  185. };
  186. const dirname = function(p) {
  187. const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
  188. if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
  189. segments[0] += "/";
  190. }
  191. return segments.join("/") || (isAbsolute(p) ? "/" : ".");
  192. };
  193. const format = function(p) {
  194. const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
  195. const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
  196. Boolean
  197. );
  198. return normalizeWindowsPath(
  199. p.root ? resolve(...segments) : segments.join("/")
  200. );
  201. };
  202. const basename = function(p, extension) {
  203. const segments = normalizeWindowsPath(p).split("/");
  204. let lastSegment = "";
  205. for (let i = segments.length - 1; i >= 0; i--) {
  206. const val = segments[i];
  207. if (val) {
  208. lastSegment = val;
  209. break;
  210. }
  211. }
  212. return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
  213. };
  214. const parse = function(p) {
  215. const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
  216. const base = basename(p);
  217. const extension = extname(base);
  218. return {
  219. root,
  220. dir: dirname(p),
  221. base,
  222. ext: extension,
  223. name: base.slice(0, base.length - extension.length)
  224. };
  225. };
  226. const matchesGlob = (path, pattern) => {
  227. return zeptomatch(pattern, normalize(path));
  228. };
  229. const _path = {
  230. __proto__: null,
  231. basename: basename,
  232. dirname: dirname,
  233. extname: extname,
  234. format: format,
  235. isAbsolute: isAbsolute,
  236. join: join,
  237. matchesGlob: matchesGlob,
  238. normalize: normalize,
  239. normalizeString: normalizeString,
  240. parse: parse,
  241. relative: relative,
  242. resolve: resolve,
  243. sep: sep,
  244. toNamespacedPath: toNamespacedPath
  245. };
  246. exports._path = _path;
  247. exports.basename = basename;
  248. exports.dirname = dirname;
  249. exports.extname = extname;
  250. exports.format = format;
  251. exports.isAbsolute = isAbsolute;
  252. exports.join = join;
  253. exports.matchesGlob = matchesGlob;
  254. exports.normalize = normalize;
  255. exports.normalizeString = normalizeString;
  256. exports.normalizeWindowsPath = normalizeWindowsPath;
  257. exports.parse = parse;
  258. exports.relative = relative;
  259. exports.resolve = resolve;
  260. exports.sep = sep;
  261. exports.toNamespacedPath = toNamespacedPath;