storybook 10.1.0-alpha.9 → 10.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
- package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-FTVC2JL7.js} +510 -1019
- package/dist/_node-chunks/camelcase-3SMT5WKC.js +37 -0
- package/dist/_node-chunks/chunk-2OVULPK3.js +54 -0
- package/dist/_node-chunks/chunk-3JJPSDXI.js +3043 -0
- package/dist/_node-chunks/chunk-54NMJ4II.js +1564 -0
- package/dist/_node-chunks/chunk-5V4A6MSI.js +943 -0
- package/dist/_node-chunks/chunk-6DEMT5VX.js +299 -0
- package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-6L7FFBOW.js} +8 -10
- package/dist/_node-chunks/chunk-6ULDIDXV.js +46662 -0
- package/dist/_node-chunks/chunk-AREL5IXS.js +603 -0
- package/dist/_node-chunks/chunk-DWA53E73.js +23 -0
- package/dist/_node-chunks/chunk-FNYKBULZ.js +765 -0
- package/dist/_node-chunks/chunk-IUYZQKSX.js +70 -0
- package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-K673CX4Q.js} +469 -983
- package/dist/_node-chunks/chunk-KJAFCNZ3.js +61 -0
- package/dist/_node-chunks/chunk-N3BJOOY5.js +78 -0
- package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-O5FMCQHP.js} +116 -276
- package/dist/_node-chunks/chunk-RIKQZHV3.js +29 -0
- package/dist/_node-chunks/chunk-RURZIE3W.js +3780 -0
- package/dist/_node-chunks/chunk-RVII4SK6.js +919 -0
- package/dist/_node-chunks/chunk-S3PBHOVC.js +6024 -0
- package/dist/_node-chunks/chunk-SQSFX47N.js +61 -0
- package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-TURUTKVH.js} +292 -688
- package/dist/_node-chunks/chunk-VRICJPXY.js +72 -0
- package/dist/_node-chunks/chunk-WIWWMCEU.js +119 -0
- package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-XGNRK7QB.js} +15 -24
- package/dist/_node-chunks/chunk-Y2FOTPAE.js +4523 -0
- package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-Y4UYN72K.js} +8133 -8887
- package/dist/_node-chunks/chunk-Z4BMBA5L.js +18 -0
- package/dist/_node-chunks/chunk-ZMCJS2GU.js +20 -0
- package/dist/_node-chunks/dist-TZLZ3T6L.js +121 -0
- package/dist/_node-chunks/globby-22GFCZQD.js +3452 -0
- package/dist/_node-chunks/lib-37NQ4ZIJ.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-2TRB7OEH.js +14329 -0
- package/dist/_node-chunks/p-limit-UD7TYFDW.js +116 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +10 -11
- package/dist/bin/core.js +602 -1549
- package/dist/bin/dispatcher.js +36 -36
- package/dist/bin/loader.js +24 -38
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -8540
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +575 -273
- package/dist/components/index.js +14863 -4313
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +2911 -8519
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2521 -5233
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +663 -962
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +59044 -67141
- package/dist/manager/globals.js +2 -3
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +11569 -10953
- package/dist/manager-api/index.d.ts +1813 -2
- package/dist/manager-api/index.js +1348 -2401
- package/dist/manager-errors.d.ts +9 -0
- package/dist/manager-errors.js +3 -3
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/mocking-utils/index.js +1181 -0
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -4471
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10799 -22393
- package/dist/preview-api/index.d.ts +1 -1
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +9 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +34 -1
- package/dist/server-errors.js +17 -10
- package/dist/telemetry/index.d.ts +24 -3
- package/dist/telemetry/index.js +25 -24
- package/dist/test/index.js +6131 -11916
- package/dist/theming/create.d.ts +1 -0
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3366 -2599
- package/dist/theming/index.js +501 -1091
- package/dist/types/index.d.ts +72 -8
- package/dist/types/index.js +27 -12
- package/dist/viewport/index.js +3 -3
- package/package.json +26 -17
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
- package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
- package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
- package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
- package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
- package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
- package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
- package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
- package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
- package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
- package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
- package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
- package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
- package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
- package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
- package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
- package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
- package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
- package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
- package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
- package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
- package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
- package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
- package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
- package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
- package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
- package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
- package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
- package/dist/_node-chunks/dist-SL73W244.js +0 -175
- package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
- package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
- package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
- package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
- package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
|
@@ -0,0 +1,4523 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_jdojl2z4eei from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_jdojl2z4eei from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_jdojl2z4eei from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_jdojl2z4eei.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_jdojl2z4eei.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_jdojl2z4eei.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__commonJS,
|
|
14
|
+
__toESM
|
|
15
|
+
} from "./chunk-2OVULPK3.js";
|
|
16
|
+
|
|
17
|
+
// ../node_modules/balanced-match/index.js
|
|
18
|
+
var require_balanced_match = __commonJS({
|
|
19
|
+
"../node_modules/balanced-match/index.js"(exports, module) {
|
|
20
|
+
"use strict";
|
|
21
|
+
module.exports = balanced;
|
|
22
|
+
function balanced(a, b, str) {
|
|
23
|
+
a instanceof RegExp && (a = maybeMatch(a, str)), b instanceof RegExp && (b = maybeMatch(b, str));
|
|
24
|
+
var r = range(a, b, str);
|
|
25
|
+
return r && {
|
|
26
|
+
start: r[0],
|
|
27
|
+
end: r[1],
|
|
28
|
+
pre: str.slice(0, r[0]),
|
|
29
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
30
|
+
post: str.slice(r[1] + b.length)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function maybeMatch(reg, str) {
|
|
34
|
+
var m = str.match(reg);
|
|
35
|
+
return m ? m[0] : null;
|
|
36
|
+
}
|
|
37
|
+
balanced.range = range;
|
|
38
|
+
function range(a, b, str) {
|
|
39
|
+
var begs, beg, left, right, result, ai = str.indexOf(a), bi = str.indexOf(b, ai + 1), i = ai;
|
|
40
|
+
if (ai >= 0 && bi > 0) {
|
|
41
|
+
if (a === b)
|
|
42
|
+
return [ai, bi];
|
|
43
|
+
for (begs = [], left = str.length; i >= 0 && !result; )
|
|
44
|
+
i == ai ? (begs.push(i), ai = str.indexOf(a, i + 1)) : begs.length == 1 ? result = [begs.pop(), bi] : (beg = begs.pop(), beg < left && (left = beg, right = bi), bi = str.indexOf(b, i + 1)), i = ai < bi && ai >= 0 ? ai : bi;
|
|
45
|
+
begs.length && (result = [left, right]);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// ../node_modules/brace-expansion/index.js
|
|
53
|
+
var require_brace_expansion = __commonJS({
|
|
54
|
+
"../node_modules/brace-expansion/index.js"(exports, module) {
|
|
55
|
+
var balanced = require_balanced_match();
|
|
56
|
+
module.exports = expandTop;
|
|
57
|
+
var escSlash = "\0SLASH" + Math.random() + "\0", escOpen = "\0OPEN" + Math.random() + "\0", escClose = "\0CLOSE" + Math.random() + "\0", escComma = "\0COMMA" + Math.random() + "\0", escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
58
|
+
function numeric(str) {
|
|
59
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
60
|
+
}
|
|
61
|
+
function escapeBraces(str) {
|
|
62
|
+
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
|
|
63
|
+
}
|
|
64
|
+
function unescapeBraces(str) {
|
|
65
|
+
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
66
|
+
}
|
|
67
|
+
function parseCommaParts(str) {
|
|
68
|
+
if (!str)
|
|
69
|
+
return [""];
|
|
70
|
+
var parts = [], m = balanced("{", "}", str);
|
|
71
|
+
if (!m)
|
|
72
|
+
return str.split(",");
|
|
73
|
+
var pre = m.pre, body = m.body, post = m.post, p = pre.split(",");
|
|
74
|
+
p[p.length - 1] += "{" + body + "}";
|
|
75
|
+
var postParts = parseCommaParts(post);
|
|
76
|
+
return post.length && (p[p.length - 1] += postParts.shift(), p.push.apply(p, postParts)), parts.push.apply(parts, p), parts;
|
|
77
|
+
}
|
|
78
|
+
function expandTop(str) {
|
|
79
|
+
return str ? (str.substr(0, 2) === "{}" && (str = "\\{\\}" + str.substr(2)), expand2(escapeBraces(str), !0).map(unescapeBraces)) : [];
|
|
80
|
+
}
|
|
81
|
+
function embrace(str) {
|
|
82
|
+
return "{" + str + "}";
|
|
83
|
+
}
|
|
84
|
+
function isPadded(el) {
|
|
85
|
+
return /^-?0\d/.test(el);
|
|
86
|
+
}
|
|
87
|
+
function lte(i, y) {
|
|
88
|
+
return i <= y;
|
|
89
|
+
}
|
|
90
|
+
function gte(i, y) {
|
|
91
|
+
return i >= y;
|
|
92
|
+
}
|
|
93
|
+
function expand2(str, isTop) {
|
|
94
|
+
var expansions = [], m = balanced("{", "}", str);
|
|
95
|
+
if (!m) return [str];
|
|
96
|
+
var pre = m.pre, post = m.post.length ? expand2(m.post, !1) : [""];
|
|
97
|
+
if (/\$$/.test(m.pre))
|
|
98
|
+
for (var k = 0; k < post.length; k++) {
|
|
99
|
+
var expansion = pre + "{" + m.body + "}" + post[k];
|
|
100
|
+
expansions.push(expansion);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body), isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body), isSequence = isNumericSequence || isAlphaSequence, isOptions = m.body.indexOf(",") >= 0;
|
|
104
|
+
if (!isSequence && !isOptions)
|
|
105
|
+
return m.post.match(/,(?!,).*\}/) ? (str = m.pre + "{" + m.body + escClose + m.post, expand2(str)) : [str];
|
|
106
|
+
var n;
|
|
107
|
+
if (isSequence)
|
|
108
|
+
n = m.body.split(/\.\./);
|
|
109
|
+
else if (n = parseCommaParts(m.body), n.length === 1 && (n = expand2(n[0], !1).map(embrace), n.length === 1))
|
|
110
|
+
return post.map(function(p) {
|
|
111
|
+
return m.pre + n[0] + p;
|
|
112
|
+
});
|
|
113
|
+
var N;
|
|
114
|
+
if (isSequence) {
|
|
115
|
+
var x = numeric(n[0]), y = numeric(n[1]), width = Math.max(n[0].length, n[1].length), incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1, test = lte, reverse = y < x;
|
|
116
|
+
reverse && (incr *= -1, test = gte);
|
|
117
|
+
var pad = n.some(isPadded);
|
|
118
|
+
N = [];
|
|
119
|
+
for (var i = x; test(i, y); i += incr) {
|
|
120
|
+
var c;
|
|
121
|
+
if (isAlphaSequence)
|
|
122
|
+
c = String.fromCharCode(i), c === "\\" && (c = "");
|
|
123
|
+
else if (c = String(i), pad) {
|
|
124
|
+
var need = width - c.length;
|
|
125
|
+
if (need > 0) {
|
|
126
|
+
var z = new Array(need + 1).join("0");
|
|
127
|
+
i < 0 ? c = "-" + z + c.slice(1) : c = z + c;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
N.push(c);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
N = [];
|
|
134
|
+
for (var j = 0; j < n.length; j++)
|
|
135
|
+
N.push.apply(N, expand2(n[j], !1));
|
|
136
|
+
}
|
|
137
|
+
for (var j = 0; j < N.length; j++)
|
|
138
|
+
for (var k = 0; k < post.length; k++) {
|
|
139
|
+
var expansion = pre + N[j] + post[k];
|
|
140
|
+
(!isTop || isSequence || expansion) && expansions.push(expansion);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return expansions;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
149
|
+
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
150
|
+
|
|
151
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
152
|
+
var assertValidPattern = (pattern) => {
|
|
153
|
+
if (typeof pattern != "string")
|
|
154
|
+
throw new TypeError("invalid pattern");
|
|
155
|
+
if (pattern.length > 65536)
|
|
156
|
+
throw new TypeError("pattern is too long");
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js
|
|
160
|
+
var posixClasses = {
|
|
161
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
162
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
|
|
163
|
+
"[:ascii:]": ["\\x00-\\x7f", !1],
|
|
164
|
+
"[:blank:]": ["\\p{Zs}\\t", !0],
|
|
165
|
+
"[:cntrl:]": ["\\p{Cc}", !0],
|
|
166
|
+
"[:digit:]": ["\\p{Nd}", !0],
|
|
167
|
+
"[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
|
|
168
|
+
"[:lower:]": ["\\p{Ll}", !0],
|
|
169
|
+
"[:print:]": ["\\p{C}", !0],
|
|
170
|
+
"[:punct:]": ["\\p{P}", !0],
|
|
171
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
|
|
172
|
+
"[:upper:]": ["\\p{Lu}", !0],
|
|
173
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
|
|
174
|
+
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
175
|
+
}, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), rangesToString = (ranges) => ranges.join(""), parseClass = (glob2, position) => {
|
|
176
|
+
let pos = position;
|
|
177
|
+
if (glob2.charAt(pos) !== "[")
|
|
178
|
+
throw new Error("not in a brace expression");
|
|
179
|
+
let ranges = [], negs = [], i = pos + 1, sawStart = !1, uflag = !1, escaping = !1, negate = !1, endPos = pos, rangeStart = "";
|
|
180
|
+
WHILE: for (; i < glob2.length; ) {
|
|
181
|
+
let c = glob2.charAt(i);
|
|
182
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
183
|
+
negate = !0, i++;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (c === "]" && sawStart && !escaping) {
|
|
187
|
+
endPos = i + 1;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (sawStart = !0, c === "\\" && !escaping) {
|
|
191
|
+
escaping = !0, i++;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (c === "[" && !escaping) {
|
|
195
|
+
for (let [cls, [unip, u, neg]] of Object.entries(posixClasses))
|
|
196
|
+
if (glob2.startsWith(cls, i)) {
|
|
197
|
+
if (rangeStart)
|
|
198
|
+
return ["$.", !1, glob2.length - pos, !0];
|
|
199
|
+
i += cls.length, neg ? negs.push(unip) : ranges.push(unip), uflag = uflag || u;
|
|
200
|
+
continue WHILE;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (escaping = !1, rangeStart) {
|
|
204
|
+
c > rangeStart ? ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c)) : c === rangeStart && ranges.push(braceEscape(c)), rangeStart = "", i++;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (glob2.startsWith("-]", i + 1)) {
|
|
208
|
+
ranges.push(braceEscape(c + "-")), i += 2;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (glob2.startsWith("-", i + 1)) {
|
|
212
|
+
rangeStart = c, i += 2;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
ranges.push(braceEscape(c)), i++;
|
|
216
|
+
}
|
|
217
|
+
if (endPos < i)
|
|
218
|
+
return ["", !1, 0, !1];
|
|
219
|
+
if (!ranges.length && !negs.length)
|
|
220
|
+
return ["$.", !1, glob2.length - pos, !0];
|
|
221
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
222
|
+
let r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
223
|
+
return [regexpEscape(r), !1, endPos - pos, !1];
|
|
224
|
+
}
|
|
225
|
+
let sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]", snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
226
|
+
return [ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs, uflag, endPos - pos, !0];
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/unescape.js
|
|
230
|
+
var unescape = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
231
|
+
|
|
232
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/ast.js
|
|
233
|
+
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), isExtglobType = (c) => types.has(c), startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))", startNoDot = "(?!\\.)", addPatternStart = /* @__PURE__ */ new Set(["[", "."]), justDots = /* @__PURE__ */ new Set(["..", "."]), reSpecials = new Set("().*{}+?[]^$\\!"), regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), qmark = "[^/]", star = qmark + "*?", starNoEmpty = qmark + "+?", AST = class _AST {
|
|
234
|
+
type;
|
|
235
|
+
#root;
|
|
236
|
+
#hasMagic;
|
|
237
|
+
#uflag = !1;
|
|
238
|
+
#parts = [];
|
|
239
|
+
#parent;
|
|
240
|
+
#parentIndex;
|
|
241
|
+
#negs;
|
|
242
|
+
#filledNegs = !1;
|
|
243
|
+
#options;
|
|
244
|
+
#toString;
|
|
245
|
+
// set to true if it's an extglob with no children
|
|
246
|
+
// (which really means one child of '')
|
|
247
|
+
#emptyExt = !1;
|
|
248
|
+
constructor(type, parent, options = {}) {
|
|
249
|
+
this.type = type, type && (this.#hasMagic = !0), this.#parent = parent, this.#root = this.#parent ? this.#parent.#root : this, this.#options = this.#root === this ? options : this.#root.#options, this.#negs = this.#root === this ? [] : this.#root.#negs, type === "!" && !this.#root.#filledNegs && this.#negs.push(this), this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
250
|
+
}
|
|
251
|
+
get hasMagic() {
|
|
252
|
+
if (this.#hasMagic !== void 0)
|
|
253
|
+
return this.#hasMagic;
|
|
254
|
+
for (let p of this.#parts)
|
|
255
|
+
if (typeof p != "string" && (p.type || p.hasMagic))
|
|
256
|
+
return this.#hasMagic = !0;
|
|
257
|
+
return this.#hasMagic;
|
|
258
|
+
}
|
|
259
|
+
// reconstructs the pattern
|
|
260
|
+
toString() {
|
|
261
|
+
return this.#toString !== void 0 ? this.#toString : this.type ? this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")" : this.#toString = this.#parts.map((p) => String(p)).join("");
|
|
262
|
+
}
|
|
263
|
+
#fillNegs() {
|
|
264
|
+
if (this !== this.#root)
|
|
265
|
+
throw new Error("should only call on root");
|
|
266
|
+
if (this.#filledNegs)
|
|
267
|
+
return this;
|
|
268
|
+
this.toString(), this.#filledNegs = !0;
|
|
269
|
+
let n;
|
|
270
|
+
for (; n = this.#negs.pop(); ) {
|
|
271
|
+
if (n.type !== "!")
|
|
272
|
+
continue;
|
|
273
|
+
let p = n, pp = p.#parent;
|
|
274
|
+
for (; pp; ) {
|
|
275
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++)
|
|
276
|
+
for (let part of n.#parts) {
|
|
277
|
+
if (typeof part == "string")
|
|
278
|
+
throw new Error("string part in extglob AST??");
|
|
279
|
+
part.copyIn(pp.#parts[i]);
|
|
280
|
+
}
|
|
281
|
+
p = pp, pp = p.#parent;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return this;
|
|
285
|
+
}
|
|
286
|
+
push(...parts) {
|
|
287
|
+
for (let p of parts)
|
|
288
|
+
if (p !== "") {
|
|
289
|
+
if (typeof p != "string" && !(p instanceof _AST && p.#parent === this))
|
|
290
|
+
throw new Error("invalid part: " + p);
|
|
291
|
+
this.#parts.push(p);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
toJSON() {
|
|
295
|
+
let ret = this.type === null ? this.#parts.slice().map((p) => typeof p == "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
296
|
+
return this.isStart() && !this.type && ret.unshift([]), this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!") && ret.push({}), ret;
|
|
297
|
+
}
|
|
298
|
+
isStart() {
|
|
299
|
+
if (this.#root === this)
|
|
300
|
+
return !0;
|
|
301
|
+
if (!this.#parent?.isStart())
|
|
302
|
+
return !1;
|
|
303
|
+
if (this.#parentIndex === 0)
|
|
304
|
+
return !0;
|
|
305
|
+
let p = this.#parent;
|
|
306
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
|
307
|
+
let pp = p.#parts[i];
|
|
308
|
+
if (!(pp instanceof _AST && pp.type === "!"))
|
|
309
|
+
return !1;
|
|
310
|
+
}
|
|
311
|
+
return !0;
|
|
312
|
+
}
|
|
313
|
+
isEnd() {
|
|
314
|
+
if (this.#root === this || this.#parent?.type === "!")
|
|
315
|
+
return !0;
|
|
316
|
+
if (!this.#parent?.isEnd())
|
|
317
|
+
return !1;
|
|
318
|
+
if (!this.type)
|
|
319
|
+
return this.#parent?.isEnd();
|
|
320
|
+
let pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
321
|
+
return this.#parentIndex === pl - 1;
|
|
322
|
+
}
|
|
323
|
+
copyIn(part) {
|
|
324
|
+
typeof part == "string" ? this.push(part) : this.push(part.clone(this));
|
|
325
|
+
}
|
|
326
|
+
clone(parent) {
|
|
327
|
+
let c = new _AST(this.type, parent);
|
|
328
|
+
for (let p of this.#parts)
|
|
329
|
+
c.copyIn(p);
|
|
330
|
+
return c;
|
|
331
|
+
}
|
|
332
|
+
static #parseAST(str, ast, pos, opt) {
|
|
333
|
+
let escaping = !1, inBrace = !1, braceStart = -1, braceNeg = !1;
|
|
334
|
+
if (ast.type === null) {
|
|
335
|
+
let i2 = pos, acc2 = "";
|
|
336
|
+
for (; i2 < str.length; ) {
|
|
337
|
+
let c = str.charAt(i2++);
|
|
338
|
+
if (escaping || c === "\\") {
|
|
339
|
+
escaping = !escaping, acc2 += c;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (inBrace) {
|
|
343
|
+
i2 === braceStart + 1 ? (c === "^" || c === "!") && (braceNeg = !0) : c === "]" && !(i2 === braceStart + 2 && braceNeg) && (inBrace = !1), acc2 += c;
|
|
344
|
+
continue;
|
|
345
|
+
} else if (c === "[") {
|
|
346
|
+
inBrace = !0, braceStart = i2, braceNeg = !1, acc2 += c;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
350
|
+
ast.push(acc2), acc2 = "";
|
|
351
|
+
let ext2 = new _AST(c, ast);
|
|
352
|
+
i2 = _AST.#parseAST(str, ext2, i2, opt), ast.push(ext2);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
acc2 += c;
|
|
356
|
+
}
|
|
357
|
+
return ast.push(acc2), i2;
|
|
358
|
+
}
|
|
359
|
+
let i = pos + 1, part = new _AST(null, ast), parts = [], acc = "";
|
|
360
|
+
for (; i < str.length; ) {
|
|
361
|
+
let c = str.charAt(i++);
|
|
362
|
+
if (escaping || c === "\\") {
|
|
363
|
+
escaping = !escaping, acc += c;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (inBrace) {
|
|
367
|
+
i === braceStart + 1 ? (c === "^" || c === "!") && (braceNeg = !0) : c === "]" && !(i === braceStart + 2 && braceNeg) && (inBrace = !1), acc += c;
|
|
368
|
+
continue;
|
|
369
|
+
} else if (c === "[") {
|
|
370
|
+
inBrace = !0, braceStart = i, braceNeg = !1, acc += c;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
374
|
+
part.push(acc), acc = "";
|
|
375
|
+
let ext2 = new _AST(c, part);
|
|
376
|
+
part.push(ext2), i = _AST.#parseAST(str, ext2, i, opt);
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (c === "|") {
|
|
380
|
+
part.push(acc), acc = "", parts.push(part), part = new _AST(null, ast);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (c === ")")
|
|
384
|
+
return acc === "" && ast.#parts.length === 0 && (ast.#emptyExt = !0), part.push(acc), acc = "", ast.push(...parts, part), i;
|
|
385
|
+
acc += c;
|
|
386
|
+
}
|
|
387
|
+
return ast.type = null, ast.#hasMagic = void 0, ast.#parts = [str.substring(pos - 1)], i;
|
|
388
|
+
}
|
|
389
|
+
static fromGlob(pattern, options = {}) {
|
|
390
|
+
let ast = new _AST(null, void 0, options);
|
|
391
|
+
return _AST.#parseAST(pattern, ast, 0, options), ast;
|
|
392
|
+
}
|
|
393
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
394
|
+
// string if not.
|
|
395
|
+
toMMPattern() {
|
|
396
|
+
if (this !== this.#root)
|
|
397
|
+
return this.#root.toMMPattern();
|
|
398
|
+
let glob2 = this.toString(), [re, body, hasMagic2, uflag] = this.toRegExpSource();
|
|
399
|
+
if (!(hasMagic2 || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob2.toUpperCase() !== glob2.toLowerCase()))
|
|
400
|
+
return body;
|
|
401
|
+
let flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
402
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
403
|
+
_src: re,
|
|
404
|
+
_glob: glob2
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
get options() {
|
|
408
|
+
return this.#options;
|
|
409
|
+
}
|
|
410
|
+
// returns the string match, the regexp source, whether there's magic
|
|
411
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
412
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
413
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
414
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
415
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
416
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
417
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
418
|
+
//
|
|
419
|
+
// In part-matching mode, the start is:
|
|
420
|
+
// - if not isStart: nothing
|
|
421
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
422
|
+
// - if dots allowed or not possible: ^
|
|
423
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
424
|
+
// end is:
|
|
425
|
+
// - if not isEnd(): nothing
|
|
426
|
+
// - else: $
|
|
427
|
+
//
|
|
428
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
429
|
+
// pattern, so start is:
|
|
430
|
+
// - if first pattern: same as part-matching mode
|
|
431
|
+
// - if not isStart(): nothing
|
|
432
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
433
|
+
// - if dots allowed or not possible: /
|
|
434
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
435
|
+
// end is:
|
|
436
|
+
// - if last pattern, same as part-matching mode
|
|
437
|
+
// - else nothing
|
|
438
|
+
//
|
|
439
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
440
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
441
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
442
|
+
// the pattern.
|
|
443
|
+
//
|
|
444
|
+
// We can just always return the same end, and leave it up to the caller
|
|
445
|
+
// to know whether it's going to be used joined or in parts.
|
|
446
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
447
|
+
// - if not isStart: nothing
|
|
448
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
449
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
450
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
451
|
+
//
|
|
452
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
453
|
+
// performance, so probably better to return both start options.
|
|
454
|
+
//
|
|
455
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
456
|
+
// and the start always gets applied.
|
|
457
|
+
//
|
|
458
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
459
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
460
|
+
//
|
|
461
|
+
// So the todo is:
|
|
462
|
+
// - better detect what kind of start is needed
|
|
463
|
+
// - return both flavors of starting pattern
|
|
464
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
465
|
+
//
|
|
466
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
467
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
468
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
469
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
470
|
+
//
|
|
471
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
472
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
473
|
+
// use the (?:^|/) style of start binding.
|
|
474
|
+
//
|
|
475
|
+
// Even simplified further:
|
|
476
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
477
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
478
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
479
|
+
toRegExpSource(allowDot) {
|
|
480
|
+
let dot = allowDot ?? !!this.#options.dot;
|
|
481
|
+
if (this.#root === this && this.#fillNegs(), !this.type) {
|
|
482
|
+
let noEmpty = this.isStart() && this.isEnd(), src = this.#parts.map((p) => {
|
|
483
|
+
let [re, _, hasMagic2, uflag] = typeof p == "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
484
|
+
return this.#hasMagic = this.#hasMagic || hasMagic2, this.#uflag = this.#uflag || uflag, re;
|
|
485
|
+
}).join(""), start2 = "";
|
|
486
|
+
if (this.isStart() && typeof this.#parts[0] == "string" && !(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
|
|
487
|
+
let aps = addPatternStart, needNoTrav = (
|
|
488
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
489
|
+
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
490
|
+
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
491
|
+
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
492
|
+
), needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
493
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
494
|
+
}
|
|
495
|
+
let end = "";
|
|
496
|
+
return this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!" && (end = "(?:$|\\/)"), [
|
|
497
|
+
start2 + src + end,
|
|
498
|
+
unescape(src),
|
|
499
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
500
|
+
this.#uflag
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
let repeated = this.type === "*" || this.type === "+", start = this.type === "!" ? "(?:(?!(?:" : "(?:", body = this.#partsToRegExp(dot);
|
|
504
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
505
|
+
let s = this.toString();
|
|
506
|
+
return this.#parts = [s], this.type = null, this.#hasMagic = void 0, [s, unescape(this.toString()), !1, !1];
|
|
507
|
+
}
|
|
508
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(!0);
|
|
509
|
+
bodyDotAllowed === body && (bodyDotAllowed = ""), bodyDotAllowed && (body = `(?:${body})(?:${bodyDotAllowed})*?`);
|
|
510
|
+
let final = "";
|
|
511
|
+
if (this.type === "!" && this.#emptyExt)
|
|
512
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
513
|
+
else {
|
|
514
|
+
let close = this.type === "!" ? (
|
|
515
|
+
// !() must match something,but !(x) can match ''
|
|
516
|
+
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
|
|
517
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? ")?" : `)${this.type}`;
|
|
518
|
+
final = start + body + close;
|
|
519
|
+
}
|
|
520
|
+
return [
|
|
521
|
+
final,
|
|
522
|
+
unescape(body),
|
|
523
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
524
|
+
this.#uflag
|
|
525
|
+
];
|
|
526
|
+
}
|
|
527
|
+
#partsToRegExp(dot) {
|
|
528
|
+
return this.#parts.map((p) => {
|
|
529
|
+
if (typeof p == "string")
|
|
530
|
+
throw new Error("string type in extglob ast??");
|
|
531
|
+
let [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
532
|
+
return this.#uflag = this.#uflag || uflag, re;
|
|
533
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
534
|
+
}
|
|
535
|
+
static #parseGlob(glob2, hasMagic2, noEmpty = !1) {
|
|
536
|
+
let escaping = !1, re = "", uflag = !1;
|
|
537
|
+
for (let i = 0; i < glob2.length; i++) {
|
|
538
|
+
let c = glob2.charAt(i);
|
|
539
|
+
if (escaping) {
|
|
540
|
+
escaping = !1, re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
if (c === "\\") {
|
|
544
|
+
i === glob2.length - 1 ? re += "\\\\" : escaping = !0;
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
if (c === "[") {
|
|
548
|
+
let [src, needUflag, consumed, magic] = parseClass(glob2, i);
|
|
549
|
+
if (consumed) {
|
|
550
|
+
re += src, uflag = uflag || needUflag, i += consumed - 1, hasMagic2 = hasMagic2 || magic;
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (c === "*") {
|
|
555
|
+
noEmpty && glob2 === "*" ? re += starNoEmpty : re += star, hasMagic2 = !0;
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (c === "?") {
|
|
559
|
+
re += qmark, hasMagic2 = !0;
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
re += regExpEscape(c);
|
|
563
|
+
}
|
|
564
|
+
return [re, unescape(glob2), !!hasMagic2, uflag];
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/escape.js
|
|
569
|
+
var escape = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
570
|
+
|
|
571
|
+
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
572
|
+
var minimatch = (p, pattern, options = {}) => (assertValidPattern(pattern), !options.nocomment && pattern.charAt(0) === "#" ? !1 : new Minimatch(pattern, options).match(p)), starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/, starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2), starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2), starDotExtTestNocase = (ext2) => (ext2 = ext2.toLowerCase(), (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2)), starDotExtTestNocaseDot = (ext2) => (ext2 = ext2.toLowerCase(), (f) => f.toLowerCase().endsWith(ext2)), starDotStarRE = /^\*+\.\*+$/, starDotStarTest = (f) => !f.startsWith(".") && f.includes("."), starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes("."), dotStarRE = /^\.\*+$/, dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith("."), starRE = /^\*+$/, starTest = (f) => f.length !== 0 && !f.startsWith("."), starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..", qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/, qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
573
|
+
let noext = qmarksTestNoExt([$0]);
|
|
574
|
+
return ext2 ? (ext2 = ext2.toLowerCase(), (f) => noext(f) && f.toLowerCase().endsWith(ext2)) : noext;
|
|
575
|
+
}, qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
576
|
+
let noext = qmarksTestNoExtDot([$0]);
|
|
577
|
+
return ext2 ? (ext2 = ext2.toLowerCase(), (f) => noext(f) && f.toLowerCase().endsWith(ext2)) : noext;
|
|
578
|
+
}, qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
579
|
+
let noext = qmarksTestNoExtDot([$0]);
|
|
580
|
+
return ext2 ? (f) => noext(f) && f.endsWith(ext2) : noext;
|
|
581
|
+
}, qmarksTest = ([$0, ext2 = ""]) => {
|
|
582
|
+
let noext = qmarksTestNoExt([$0]);
|
|
583
|
+
return ext2 ? (f) => noext(f) && f.endsWith(ext2) : noext;
|
|
584
|
+
}, qmarksTestNoExt = ([$0]) => {
|
|
585
|
+
let len = $0.length;
|
|
586
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
587
|
+
}, qmarksTestNoExtDot = ([$0]) => {
|
|
588
|
+
let len = $0.length;
|
|
589
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
590
|
+
}, defaultPlatform = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", path = {
|
|
591
|
+
win32: { sep: "\\" },
|
|
592
|
+
posix: { sep: "/" }
|
|
593
|
+
}, sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
594
|
+
minimatch.sep = sep;
|
|
595
|
+
var GLOBSTAR = Symbol("globstar **");
|
|
596
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
597
|
+
var qmark2 = "[^/]", star2 = qmark2 + "*?", twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
598
|
+
minimatch.filter = filter;
|
|
599
|
+
var ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
|
|
600
|
+
if (!def || typeof def != "object" || !Object.keys(def).length)
|
|
601
|
+
return minimatch;
|
|
602
|
+
let orig = minimatch;
|
|
603
|
+
return Object.assign((p, pattern, options = {}) => orig(p, pattern, ext(def, options)), {
|
|
604
|
+
Minimatch: class extends orig.Minimatch {
|
|
605
|
+
constructor(pattern, options = {}) {
|
|
606
|
+
super(pattern, ext(def, options));
|
|
607
|
+
}
|
|
608
|
+
static defaults(options) {
|
|
609
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
AST: class extends orig.AST {
|
|
613
|
+
/* c8 ignore start */
|
|
614
|
+
constructor(type, parent, options = {}) {
|
|
615
|
+
super(type, parent, ext(def, options));
|
|
616
|
+
}
|
|
617
|
+
/* c8 ignore stop */
|
|
618
|
+
static fromGlob(pattern, options = {}) {
|
|
619
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
623
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
624
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
625
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
626
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
627
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
628
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
629
|
+
sep: orig.sep,
|
|
630
|
+
GLOBSTAR
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
minimatch.defaults = defaults;
|
|
634
|
+
var braceExpand = (pattern, options = {}) => (assertValidPattern(pattern), options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern) ? [pattern] : (0, import_brace_expansion.default)(pattern));
|
|
635
|
+
minimatch.braceExpand = braceExpand;
|
|
636
|
+
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
637
|
+
minimatch.makeRe = makeRe;
|
|
638
|
+
var match = (list, pattern, options = {}) => {
|
|
639
|
+
let mm = new Minimatch(pattern, options);
|
|
640
|
+
return list = list.filter((f) => mm.match(f)), mm.options.nonull && !list.length && list.push(pattern), list;
|
|
641
|
+
};
|
|
642
|
+
minimatch.match = match;
|
|
643
|
+
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/, regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Minimatch = class {
|
|
644
|
+
options;
|
|
645
|
+
set;
|
|
646
|
+
pattern;
|
|
647
|
+
windowsPathsNoEscape;
|
|
648
|
+
nonegate;
|
|
649
|
+
negate;
|
|
650
|
+
comment;
|
|
651
|
+
empty;
|
|
652
|
+
preserveMultipleSlashes;
|
|
653
|
+
partial;
|
|
654
|
+
globSet;
|
|
655
|
+
globParts;
|
|
656
|
+
nocase;
|
|
657
|
+
isWindows;
|
|
658
|
+
platform;
|
|
659
|
+
windowsNoMagicRoot;
|
|
660
|
+
regexp;
|
|
661
|
+
constructor(pattern, options = {}) {
|
|
662
|
+
assertValidPattern(pattern), options = options || {}, this.options = options, this.pattern = pattern, this.platform = options.platform || defaultPlatform, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!options.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!options.nonegate, this.comment = !1, this.empty = !1, this.partial = !!options.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
663
|
+
}
|
|
664
|
+
hasMagic() {
|
|
665
|
+
if (this.options.magicalBraces && this.set.length > 1)
|
|
666
|
+
return !0;
|
|
667
|
+
for (let pattern of this.set)
|
|
668
|
+
for (let part of pattern)
|
|
669
|
+
if (typeof part != "string")
|
|
670
|
+
return !0;
|
|
671
|
+
return !1;
|
|
672
|
+
}
|
|
673
|
+
debug(..._) {
|
|
674
|
+
}
|
|
675
|
+
make() {
|
|
676
|
+
let pattern = this.pattern, options = this.options;
|
|
677
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
678
|
+
this.comment = !0;
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (!pattern) {
|
|
682
|
+
this.empty = !0;
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], options.debug && (this.debug = (...args) => console.error(...args)), this.debug(this.pattern, this.globSet);
|
|
686
|
+
let rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
687
|
+
this.globParts = this.preprocess(rawGlobParts), this.debug(this.pattern, this.globParts);
|
|
688
|
+
let set = this.globParts.map((s, _, __) => {
|
|
689
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
690
|
+
let isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]), isDrive = /^[a-z]:/i.test(s[0]);
|
|
691
|
+
if (isUNC)
|
|
692
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
693
|
+
if (isDrive)
|
|
694
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
695
|
+
}
|
|
696
|
+
return s.map((ss) => this.parse(ss));
|
|
697
|
+
});
|
|
698
|
+
if (this.debug(this.pattern, set), this.set = set.filter((s) => s.indexOf(!1) === -1), this.isWindows)
|
|
699
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
700
|
+
let p = this.set[i];
|
|
701
|
+
p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] == "string" && /^[a-z]:$/i.test(p[3]) && (p[2] = "?");
|
|
702
|
+
}
|
|
703
|
+
this.debug(this.pattern, this.set);
|
|
704
|
+
}
|
|
705
|
+
// various transforms to equivalent pattern sets that are
|
|
706
|
+
// faster to process in a filesystem walk. The goal is to
|
|
707
|
+
// eliminate what we can, and push all ** patterns as far
|
|
708
|
+
// to the right as possible, even if it increases the number
|
|
709
|
+
// of patterns that we have to process.
|
|
710
|
+
preprocess(globParts) {
|
|
711
|
+
if (this.options.noglobstar)
|
|
712
|
+
for (let i = 0; i < globParts.length; i++)
|
|
713
|
+
for (let j = 0; j < globParts[i].length; j++)
|
|
714
|
+
globParts[i][j] === "**" && (globParts[i][j] = "*");
|
|
715
|
+
let { optimizationLevel = 1 } = this.options;
|
|
716
|
+
return optimizationLevel >= 2 ? (globParts = this.firstPhasePreProcess(globParts), globParts = this.secondPhasePreProcess(globParts)) : optimizationLevel >= 1 ? globParts = this.levelOneOptimize(globParts) : globParts = this.adjascentGlobstarOptimize(globParts), globParts;
|
|
717
|
+
}
|
|
718
|
+
// just get rid of adjascent ** portions
|
|
719
|
+
adjascentGlobstarOptimize(globParts) {
|
|
720
|
+
return globParts.map((parts) => {
|
|
721
|
+
let gs = -1;
|
|
722
|
+
for (; (gs = parts.indexOf("**", gs + 1)) !== -1; ) {
|
|
723
|
+
let i = gs;
|
|
724
|
+
for (; parts[i + 1] === "**"; )
|
|
725
|
+
i++;
|
|
726
|
+
i !== gs && parts.splice(gs, i - gs);
|
|
727
|
+
}
|
|
728
|
+
return parts;
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
// get rid of adjascent ** and resolve .. portions
|
|
732
|
+
levelOneOptimize(globParts) {
|
|
733
|
+
return globParts.map((parts) => (parts = parts.reduce((set, part) => {
|
|
734
|
+
let prev = set[set.length - 1];
|
|
735
|
+
return part === "**" && prev === "**" ? set : part === ".." && prev && prev !== ".." && prev !== "." && prev !== "**" ? (set.pop(), set) : (set.push(part), set);
|
|
736
|
+
}, []), parts.length === 0 ? [""] : parts));
|
|
737
|
+
}
|
|
738
|
+
levelTwoFileOptimize(parts) {
|
|
739
|
+
Array.isArray(parts) || (parts = this.slashSplit(parts));
|
|
740
|
+
let didSomething = !1;
|
|
741
|
+
do {
|
|
742
|
+
if (didSomething = !1, !this.preserveMultipleSlashes) {
|
|
743
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
744
|
+
let p = parts[i];
|
|
745
|
+
i === 1 && p === "" && parts[0] === "" || (p === "." || p === "") && (didSomething = !0, parts.splice(i, 1), i--);
|
|
746
|
+
}
|
|
747
|
+
parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "") && (didSomething = !0, parts.pop());
|
|
748
|
+
}
|
|
749
|
+
let dd = 0;
|
|
750
|
+
for (; (dd = parts.indexOf("..", dd + 1)) !== -1; ) {
|
|
751
|
+
let p = parts[dd - 1];
|
|
752
|
+
p && p !== "." && p !== ".." && p !== "**" && (didSomething = !0, parts.splice(dd - 1, 2), dd -= 2);
|
|
753
|
+
}
|
|
754
|
+
} while (didSomething);
|
|
755
|
+
return parts.length === 0 ? [""] : parts;
|
|
756
|
+
}
|
|
757
|
+
// First phase: single-pattern processing
|
|
758
|
+
// <pre> is 1 or more portions
|
|
759
|
+
// <rest> is 1 or more portions
|
|
760
|
+
// <p> is any portion other than ., .., '', or **
|
|
761
|
+
// <e> is . or ''
|
|
762
|
+
//
|
|
763
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
764
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
765
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
766
|
+
// or most strings (other than .., ., and '') can be.
|
|
767
|
+
//
|
|
768
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
769
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
770
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
771
|
+
// **/**/<rest> -> **/<rest>
|
|
772
|
+
//
|
|
773
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
774
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
775
|
+
firstPhasePreProcess(globParts) {
|
|
776
|
+
let didSomething = !1;
|
|
777
|
+
do {
|
|
778
|
+
didSomething = !1;
|
|
779
|
+
for (let parts of globParts) {
|
|
780
|
+
let gs = -1;
|
|
781
|
+
for (; (gs = parts.indexOf("**", gs + 1)) !== -1; ) {
|
|
782
|
+
let gss = gs;
|
|
783
|
+
for (; parts[gss + 1] === "**"; )
|
|
784
|
+
gss++;
|
|
785
|
+
gss > gs && parts.splice(gs + 1, gss - gs);
|
|
786
|
+
let next = parts[gs + 1], p = parts[gs + 2], p2 = parts[gs + 3];
|
|
787
|
+
if (next !== ".." || !p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..")
|
|
788
|
+
continue;
|
|
789
|
+
didSomething = !0, parts.splice(gs, 1);
|
|
790
|
+
let other = parts.slice(0);
|
|
791
|
+
other[gs] = "**", globParts.push(other), gs--;
|
|
792
|
+
}
|
|
793
|
+
if (!this.preserveMultipleSlashes) {
|
|
794
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
795
|
+
let p = parts[i];
|
|
796
|
+
i === 1 && p === "" && parts[0] === "" || (p === "." || p === "") && (didSomething = !0, parts.splice(i, 1), i--);
|
|
797
|
+
}
|
|
798
|
+
parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "") && (didSomething = !0, parts.pop());
|
|
799
|
+
}
|
|
800
|
+
let dd = 0;
|
|
801
|
+
for (; (dd = parts.indexOf("..", dd + 1)) !== -1; ) {
|
|
802
|
+
let p = parts[dd - 1];
|
|
803
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
804
|
+
didSomething = !0;
|
|
805
|
+
let splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
|
|
806
|
+
parts.splice(dd - 1, 2, ...splin), parts.length === 0 && parts.push(""), dd -= 2;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
} while (didSomething);
|
|
811
|
+
return globParts;
|
|
812
|
+
}
|
|
813
|
+
// second phase: multi-pattern dedupes
|
|
814
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
815
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
816
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
817
|
+
//
|
|
818
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
819
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
820
|
+
secondPhasePreProcess(globParts) {
|
|
821
|
+
for (let i = 0; i < globParts.length - 1; i++)
|
|
822
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
823
|
+
let matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
824
|
+
if (matched) {
|
|
825
|
+
globParts[i] = [], globParts[j] = matched;
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return globParts.filter((gs) => gs.length);
|
|
830
|
+
}
|
|
831
|
+
partsMatch(a, b, emptyGSMatch = !1) {
|
|
832
|
+
let ai = 0, bi = 0, result = [], which = "";
|
|
833
|
+
for (; ai < a.length && bi < b.length; )
|
|
834
|
+
if (a[ai] === b[bi])
|
|
835
|
+
result.push(which === "b" ? b[bi] : a[ai]), ai++, bi++;
|
|
836
|
+
else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1])
|
|
837
|
+
result.push(a[ai]), ai++;
|
|
838
|
+
else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1])
|
|
839
|
+
result.push(b[bi]), bi++;
|
|
840
|
+
else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
841
|
+
if (which === "b")
|
|
842
|
+
return !1;
|
|
843
|
+
which = "a", result.push(a[ai]), ai++, bi++;
|
|
844
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
845
|
+
if (which === "a")
|
|
846
|
+
return !1;
|
|
847
|
+
which = "b", result.push(b[bi]), ai++, bi++;
|
|
848
|
+
} else
|
|
849
|
+
return !1;
|
|
850
|
+
return a.length === b.length && result;
|
|
851
|
+
}
|
|
852
|
+
parseNegate() {
|
|
853
|
+
if (this.nonegate)
|
|
854
|
+
return;
|
|
855
|
+
let pattern = this.pattern, negate = !1, negateOffset = 0;
|
|
856
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++)
|
|
857
|
+
negate = !negate, negateOffset++;
|
|
858
|
+
negateOffset && (this.pattern = pattern.slice(negateOffset)), this.negate = negate;
|
|
859
|
+
}
|
|
860
|
+
// set partial to true to test if, for example,
|
|
861
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
862
|
+
// Partial means, if you run out of file before you run
|
|
863
|
+
// out of pattern, then that's fine, as long as all
|
|
864
|
+
// the parts match.
|
|
865
|
+
matchOne(file, pattern, partial = !1) {
|
|
866
|
+
let options = this.options;
|
|
867
|
+
if (this.isWindows) {
|
|
868
|
+
let fileDrive = typeof file[0] == "string" && /^[a-z]:$/i.test(file[0]), fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]), patternDrive = typeof pattern[0] == "string" && /^[a-z]:$/i.test(pattern[0]), patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] == "string" && /^[a-z]:$/i.test(pattern[3]), fdi = fileUNC ? 3 : fileDrive ? 0 : void 0, pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
869
|
+
if (typeof fdi == "number" && typeof pdi == "number") {
|
|
870
|
+
let [fd, pd] = [file[fdi], pattern[pdi]];
|
|
871
|
+
fd.toLowerCase() === pd.toLowerCase() && (pattern[pdi] = fd, pdi > fdi ? pattern = pattern.slice(pdi) : fdi > pdi && (file = file.slice(fdi)));
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
let { optimizationLevel = 1 } = this.options;
|
|
875
|
+
optimizationLevel >= 2 && (file = this.levelTwoFileOptimize(file)), this.debug("matchOne", this, { file, pattern }), this.debug("matchOne", file.length, pattern.length);
|
|
876
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
877
|
+
this.debug("matchOne loop");
|
|
878
|
+
var p = pattern[pi], f = file[fi];
|
|
879
|
+
if (this.debug(pattern, p, f), p === !1)
|
|
880
|
+
return !1;
|
|
881
|
+
if (p === GLOBSTAR) {
|
|
882
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
883
|
+
var fr = fi, pr = pi + 1;
|
|
884
|
+
if (pr === pl) {
|
|
885
|
+
for (this.debug("** at the end"); fi < fl; fi++)
|
|
886
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
887
|
+
return !1;
|
|
888
|
+
return !0;
|
|
889
|
+
}
|
|
890
|
+
for (; fr < fl; ) {
|
|
891
|
+
var swallowee = file[fr];
|
|
892
|
+
if (this.debug(`
|
|
893
|
+
globstar while`, file, fr, pattern, pr, swallowee), this.matchOne(file.slice(fr), pattern.slice(pr), partial))
|
|
894
|
+
return this.debug("globstar found match!", fr, fl, swallowee), !0;
|
|
895
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
896
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
this.debug("globstar swallow a segment, and continue"), fr++;
|
|
900
|
+
}
|
|
901
|
+
return !!(partial && (this.debug(`
|
|
902
|
+
>>> no match, partial?`, file, fr, pattern, pr), fr === fl));
|
|
903
|
+
}
|
|
904
|
+
let hit;
|
|
905
|
+
if (typeof p == "string" ? (hit = f === p, this.debug("string match", p, f, hit)) : (hit = p.test(f), this.debug("pattern match", p, f, hit)), !hit)
|
|
906
|
+
return !1;
|
|
907
|
+
}
|
|
908
|
+
if (fi === fl && pi === pl)
|
|
909
|
+
return !0;
|
|
910
|
+
if (fi === fl)
|
|
911
|
+
return partial;
|
|
912
|
+
if (pi === pl)
|
|
913
|
+
return fi === fl - 1 && file[fi] === "";
|
|
914
|
+
throw new Error("wtf?");
|
|
915
|
+
}
|
|
916
|
+
braceExpand() {
|
|
917
|
+
return braceExpand(this.pattern, this.options);
|
|
918
|
+
}
|
|
919
|
+
parse(pattern) {
|
|
920
|
+
assertValidPattern(pattern);
|
|
921
|
+
let options = this.options;
|
|
922
|
+
if (pattern === "**")
|
|
923
|
+
return GLOBSTAR;
|
|
924
|
+
if (pattern === "")
|
|
925
|
+
return "";
|
|
926
|
+
let m, fastTest = null;
|
|
927
|
+
(m = pattern.match(starRE)) ? fastTest = options.dot ? starTestDot : starTest : (m = pattern.match(starDotExtRE)) ? fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]) : (m = pattern.match(qmarksRE)) ? fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m) : (m = pattern.match(starDotStarRE)) ? fastTest = options.dot ? starDotStarTestDot : starDotStarTest : (m = pattern.match(dotStarRE)) && (fastTest = dotStarTest);
|
|
928
|
+
let re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
929
|
+
return fastTest && typeof re == "object" && Reflect.defineProperty(re, "test", { value: fastTest }), re;
|
|
930
|
+
}
|
|
931
|
+
makeRe() {
|
|
932
|
+
if (this.regexp || this.regexp === !1)
|
|
933
|
+
return this.regexp;
|
|
934
|
+
let set = this.set;
|
|
935
|
+
if (!set.length)
|
|
936
|
+
return this.regexp = !1, this.regexp;
|
|
937
|
+
let options = this.options, twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot, flags = new Set(options.nocase ? ["i"] : []), re = set.map((pattern) => {
|
|
938
|
+
let pp = pattern.map((p) => {
|
|
939
|
+
if (p instanceof RegExp)
|
|
940
|
+
for (let f of p.flags.split(""))
|
|
941
|
+
flags.add(f);
|
|
942
|
+
return typeof p == "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
943
|
+
});
|
|
944
|
+
return pp.forEach((p, i) => {
|
|
945
|
+
let next = pp[i + 1], prev = pp[i - 1];
|
|
946
|
+
p !== GLOBSTAR || prev === GLOBSTAR || (prev === void 0 ? next !== void 0 && next !== GLOBSTAR ? pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next : pp[i] = twoStar : next === void 0 ? pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?" : next !== GLOBSTAR && (pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next, pp[i + 1] = GLOBSTAR));
|
|
947
|
+
}), pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
948
|
+
}).join("|"), [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
949
|
+
re = "^" + open + re + close + "$", this.negate && (re = "^(?!" + re + ").+$");
|
|
950
|
+
try {
|
|
951
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
952
|
+
} catch {
|
|
953
|
+
this.regexp = !1;
|
|
954
|
+
}
|
|
955
|
+
return this.regexp;
|
|
956
|
+
}
|
|
957
|
+
slashSplit(p) {
|
|
958
|
+
return this.preserveMultipleSlashes ? p.split("/") : this.isWindows && /^\/\/[^\/]+/.test(p) ? ["", ...p.split(/\/+/)] : p.split(/\/+/);
|
|
959
|
+
}
|
|
960
|
+
match(f, partial = this.partial) {
|
|
961
|
+
if (this.debug("match", f, this.pattern), this.comment)
|
|
962
|
+
return !1;
|
|
963
|
+
if (this.empty)
|
|
964
|
+
return f === "";
|
|
965
|
+
if (f === "/" && partial)
|
|
966
|
+
return !0;
|
|
967
|
+
let options = this.options;
|
|
968
|
+
this.isWindows && (f = f.split("\\").join("/"));
|
|
969
|
+
let ff = this.slashSplit(f);
|
|
970
|
+
this.debug(this.pattern, "split", ff);
|
|
971
|
+
let set = this.set;
|
|
972
|
+
this.debug(this.pattern, "set", set);
|
|
973
|
+
let filename = ff[ff.length - 1];
|
|
974
|
+
if (!filename)
|
|
975
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--)
|
|
976
|
+
filename = ff[i];
|
|
977
|
+
for (let i = 0; i < set.length; i++) {
|
|
978
|
+
let pattern = set[i], file = ff;
|
|
979
|
+
if (options.matchBase && pattern.length === 1 && (file = [filename]), this.matchOne(file, pattern, partial))
|
|
980
|
+
return options.flipNegate ? !0 : !this.negate;
|
|
981
|
+
}
|
|
982
|
+
return options.flipNegate ? !1 : this.negate;
|
|
983
|
+
}
|
|
984
|
+
static defaults(def) {
|
|
985
|
+
return minimatch.defaults(def).Minimatch;
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
minimatch.AST = AST;
|
|
989
|
+
minimatch.Minimatch = Minimatch;
|
|
990
|
+
minimatch.escape = escape;
|
|
991
|
+
minimatch.unescape = unescape;
|
|
992
|
+
|
|
993
|
+
// ../node_modules/glob/dist/esm/glob.js
|
|
994
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
995
|
+
|
|
996
|
+
// ../node_modules/glob/node_modules/lru-cache/dist/esm/index.js
|
|
997
|
+
var perf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, warned = /* @__PURE__ */ new Set(), PROCESS = typeof process == "object" && process ? process : {}, emitWarning = (msg, type, code, fn) => {
|
|
998
|
+
typeof PROCESS.emitWarning == "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
999
|
+
}, AC = globalThis.AbortController, AS = globalThis.AbortSignal;
|
|
1000
|
+
if (typeof AC > "u") {
|
|
1001
|
+
AS = class {
|
|
1002
|
+
onabort;
|
|
1003
|
+
_onabort = [];
|
|
1004
|
+
reason;
|
|
1005
|
+
aborted = !1;
|
|
1006
|
+
addEventListener(_, fn) {
|
|
1007
|
+
this._onabort.push(fn);
|
|
1008
|
+
}
|
|
1009
|
+
}, AC = class {
|
|
1010
|
+
constructor() {
|
|
1011
|
+
warnACPolyfill();
|
|
1012
|
+
}
|
|
1013
|
+
signal = new AS();
|
|
1014
|
+
abort(reason) {
|
|
1015
|
+
if (!this.signal.aborted) {
|
|
1016
|
+
this.signal.reason = reason, this.signal.aborted = !0;
|
|
1017
|
+
for (let fn of this.signal._onabort)
|
|
1018
|
+
fn(reason);
|
|
1019
|
+
this.signal.onabort?.(reason);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", warnACPolyfill = () => {
|
|
1024
|
+
printACPolyfillWarning && (printACPolyfillWarning = !1, emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill));
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
var shouldWarn = (code) => !warned.has(code), TYPE = Symbol("type"), isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n), getUintArray = (max) => isPosInt(max) ? max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null : null, ZeroArray = class extends Array {
|
|
1028
|
+
constructor(size) {
|
|
1029
|
+
super(size), this.fill(0);
|
|
1030
|
+
}
|
|
1031
|
+
}, Stack = class _Stack {
|
|
1032
|
+
heap;
|
|
1033
|
+
length;
|
|
1034
|
+
// private constructor
|
|
1035
|
+
static #constructing = !1;
|
|
1036
|
+
static create(max) {
|
|
1037
|
+
let HeapCls = getUintArray(max);
|
|
1038
|
+
if (!HeapCls)
|
|
1039
|
+
return [];
|
|
1040
|
+
_Stack.#constructing = !0;
|
|
1041
|
+
let s = new _Stack(max, HeapCls);
|
|
1042
|
+
return _Stack.#constructing = !1, s;
|
|
1043
|
+
}
|
|
1044
|
+
constructor(max, HeapCls) {
|
|
1045
|
+
if (!_Stack.#constructing)
|
|
1046
|
+
throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
1047
|
+
this.heap = new HeapCls(max), this.length = 0;
|
|
1048
|
+
}
|
|
1049
|
+
push(n) {
|
|
1050
|
+
this.heap[this.length++] = n;
|
|
1051
|
+
}
|
|
1052
|
+
pop() {
|
|
1053
|
+
return this.heap[--this.length];
|
|
1054
|
+
}
|
|
1055
|
+
}, LRUCache = class _LRUCache {
|
|
1056
|
+
// options that cannot be changed without disaster
|
|
1057
|
+
#max;
|
|
1058
|
+
#maxSize;
|
|
1059
|
+
#dispose;
|
|
1060
|
+
#disposeAfter;
|
|
1061
|
+
#fetchMethod;
|
|
1062
|
+
#memoMethod;
|
|
1063
|
+
/**
|
|
1064
|
+
* {@link LRUCache.OptionsBase.ttl}
|
|
1065
|
+
*/
|
|
1066
|
+
ttl;
|
|
1067
|
+
/**
|
|
1068
|
+
* {@link LRUCache.OptionsBase.ttlResolution}
|
|
1069
|
+
*/
|
|
1070
|
+
ttlResolution;
|
|
1071
|
+
/**
|
|
1072
|
+
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
|
1073
|
+
*/
|
|
1074
|
+
ttlAutopurge;
|
|
1075
|
+
/**
|
|
1076
|
+
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
|
1077
|
+
*/
|
|
1078
|
+
updateAgeOnGet;
|
|
1079
|
+
/**
|
|
1080
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
|
1081
|
+
*/
|
|
1082
|
+
updateAgeOnHas;
|
|
1083
|
+
/**
|
|
1084
|
+
* {@link LRUCache.OptionsBase.allowStale}
|
|
1085
|
+
*/
|
|
1086
|
+
allowStale;
|
|
1087
|
+
/**
|
|
1088
|
+
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
|
1089
|
+
*/
|
|
1090
|
+
noDisposeOnSet;
|
|
1091
|
+
/**
|
|
1092
|
+
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
|
1093
|
+
*/
|
|
1094
|
+
noUpdateTTL;
|
|
1095
|
+
/**
|
|
1096
|
+
* {@link LRUCache.OptionsBase.maxEntrySize}
|
|
1097
|
+
*/
|
|
1098
|
+
maxEntrySize;
|
|
1099
|
+
/**
|
|
1100
|
+
* {@link LRUCache.OptionsBase.sizeCalculation}
|
|
1101
|
+
*/
|
|
1102
|
+
sizeCalculation;
|
|
1103
|
+
/**
|
|
1104
|
+
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
|
1105
|
+
*/
|
|
1106
|
+
noDeleteOnFetchRejection;
|
|
1107
|
+
/**
|
|
1108
|
+
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
|
1109
|
+
*/
|
|
1110
|
+
noDeleteOnStaleGet;
|
|
1111
|
+
/**
|
|
1112
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
|
1113
|
+
*/
|
|
1114
|
+
allowStaleOnFetchAbort;
|
|
1115
|
+
/**
|
|
1116
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
|
1117
|
+
*/
|
|
1118
|
+
allowStaleOnFetchRejection;
|
|
1119
|
+
/**
|
|
1120
|
+
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
1121
|
+
*/
|
|
1122
|
+
ignoreFetchAbort;
|
|
1123
|
+
// computed properties
|
|
1124
|
+
#size;
|
|
1125
|
+
#calculatedSize;
|
|
1126
|
+
#keyMap;
|
|
1127
|
+
#keyList;
|
|
1128
|
+
#valList;
|
|
1129
|
+
#next;
|
|
1130
|
+
#prev;
|
|
1131
|
+
#head;
|
|
1132
|
+
#tail;
|
|
1133
|
+
#free;
|
|
1134
|
+
#disposed;
|
|
1135
|
+
#sizes;
|
|
1136
|
+
#starts;
|
|
1137
|
+
#ttls;
|
|
1138
|
+
#hasDispose;
|
|
1139
|
+
#hasFetchMethod;
|
|
1140
|
+
#hasDisposeAfter;
|
|
1141
|
+
/**
|
|
1142
|
+
* Do not call this method unless you need to inspect the
|
|
1143
|
+
* inner workings of the cache. If anything returned by this
|
|
1144
|
+
* object is modified in any way, strange breakage may occur.
|
|
1145
|
+
*
|
|
1146
|
+
* These fields are private for a reason!
|
|
1147
|
+
*
|
|
1148
|
+
* @internal
|
|
1149
|
+
*/
|
|
1150
|
+
static unsafeExposeInternals(c) {
|
|
1151
|
+
return {
|
|
1152
|
+
// properties
|
|
1153
|
+
starts: c.#starts,
|
|
1154
|
+
ttls: c.#ttls,
|
|
1155
|
+
sizes: c.#sizes,
|
|
1156
|
+
keyMap: c.#keyMap,
|
|
1157
|
+
keyList: c.#keyList,
|
|
1158
|
+
valList: c.#valList,
|
|
1159
|
+
next: c.#next,
|
|
1160
|
+
prev: c.#prev,
|
|
1161
|
+
get head() {
|
|
1162
|
+
return c.#head;
|
|
1163
|
+
},
|
|
1164
|
+
get tail() {
|
|
1165
|
+
return c.#tail;
|
|
1166
|
+
},
|
|
1167
|
+
free: c.#free,
|
|
1168
|
+
// methods
|
|
1169
|
+
isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
|
|
1170
|
+
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
|
|
1171
|
+
moveToTail: (index) => c.#moveToTail(index),
|
|
1172
|
+
indexes: (options) => c.#indexes(options),
|
|
1173
|
+
rindexes: (options) => c.#rindexes(options),
|
|
1174
|
+
isStale: (index) => c.#isStale(index)
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
// Protected read-only members
|
|
1178
|
+
/**
|
|
1179
|
+
* {@link LRUCache.OptionsBase.max} (read-only)
|
|
1180
|
+
*/
|
|
1181
|
+
get max() {
|
|
1182
|
+
return this.#max;
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
|
1186
|
+
*/
|
|
1187
|
+
get maxSize() {
|
|
1188
|
+
return this.#maxSize;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* The total computed size of items in the cache (read-only)
|
|
1192
|
+
*/
|
|
1193
|
+
get calculatedSize() {
|
|
1194
|
+
return this.#calculatedSize;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* The number of items stored in the cache (read-only)
|
|
1198
|
+
*/
|
|
1199
|
+
get size() {
|
|
1200
|
+
return this.#size;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
|
1204
|
+
*/
|
|
1205
|
+
get fetchMethod() {
|
|
1206
|
+
return this.#fetchMethod;
|
|
1207
|
+
}
|
|
1208
|
+
get memoMethod() {
|
|
1209
|
+
return this.#memoMethod;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
1213
|
+
*/
|
|
1214
|
+
get dispose() {
|
|
1215
|
+
return this.#dispose;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
1219
|
+
*/
|
|
1220
|
+
get disposeAfter() {
|
|
1221
|
+
return this.#disposeAfter;
|
|
1222
|
+
}
|
|
1223
|
+
constructor(options) {
|
|
1224
|
+
let { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
1225
|
+
if (max !== 0 && !isPosInt(max))
|
|
1226
|
+
throw new TypeError("max option must be a nonnegative integer");
|
|
1227
|
+
let UintArray = max ? getUintArray(max) : Array;
|
|
1228
|
+
if (!UintArray)
|
|
1229
|
+
throw new Error("invalid max value: " + max);
|
|
1230
|
+
if (this.#max = max, this.#maxSize = maxSize, this.maxEntrySize = maxEntrySize || this.#maxSize, this.sizeCalculation = sizeCalculation, this.sizeCalculation) {
|
|
1231
|
+
if (!this.#maxSize && !this.maxEntrySize)
|
|
1232
|
+
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
1233
|
+
if (typeof this.sizeCalculation != "function")
|
|
1234
|
+
throw new TypeError("sizeCalculation set to non-function");
|
|
1235
|
+
}
|
|
1236
|
+
if (memoMethod !== void 0 && typeof memoMethod != "function")
|
|
1237
|
+
throw new TypeError("memoMethod must be a function if defined");
|
|
1238
|
+
if (this.#memoMethod = memoMethod, fetchMethod !== void 0 && typeof fetchMethod != "function")
|
|
1239
|
+
throw new TypeError("fetchMethod must be a function if specified");
|
|
1240
|
+
if (this.#fetchMethod = fetchMethod, this.#hasFetchMethod = !!fetchMethod, this.#keyMap = /* @__PURE__ */ new Map(), this.#keyList = new Array(max).fill(void 0), this.#valList = new Array(max).fill(void 0), this.#next = new UintArray(max), this.#prev = new UintArray(max), this.#head = 0, this.#tail = 0, this.#free = Stack.create(max), this.#size = 0, this.#calculatedSize = 0, typeof dispose == "function" && (this.#dispose = dispose), typeof disposeAfter == "function" ? (this.#disposeAfter = disposeAfter, this.#disposed = []) : (this.#disposeAfter = void 0, this.#disposed = void 0), this.#hasDispose = !!this.#dispose, this.#hasDisposeAfter = !!this.#disposeAfter, this.noDisposeOnSet = !!noDisposeOnSet, this.noUpdateTTL = !!noUpdateTTL, this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection, this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection, this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort, this.ignoreFetchAbort = !!ignoreFetchAbort, this.maxEntrySize !== 0) {
|
|
1241
|
+
if (this.#maxSize !== 0 && !isPosInt(this.#maxSize))
|
|
1242
|
+
throw new TypeError("maxSize must be a positive integer if specified");
|
|
1243
|
+
if (!isPosInt(this.maxEntrySize))
|
|
1244
|
+
throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
1245
|
+
this.#initializeSizeTracking();
|
|
1246
|
+
}
|
|
1247
|
+
if (this.allowStale = !!allowStale, this.noDeleteOnStaleGet = !!noDeleteOnStaleGet, this.updateAgeOnGet = !!updateAgeOnGet, this.updateAgeOnHas = !!updateAgeOnHas, this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1, this.ttlAutopurge = !!ttlAutopurge, this.ttl = ttl || 0, this.ttl) {
|
|
1248
|
+
if (!isPosInt(this.ttl))
|
|
1249
|
+
throw new TypeError("ttl must be a positive integer if specified");
|
|
1250
|
+
this.#initializeTTLTracking();
|
|
1251
|
+
}
|
|
1252
|
+
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0)
|
|
1253
|
+
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
1254
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
1255
|
+
let code = "LRU_CACHE_UNBOUNDED";
|
|
1256
|
+
shouldWarn(code) && (warned.add(code), emitWarning("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", code, _LRUCache));
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Return the number of ms left in the item's TTL. If item is not in cache,
|
|
1261
|
+
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
1262
|
+
*/
|
|
1263
|
+
getRemainingTTL(key) {
|
|
1264
|
+
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
1265
|
+
}
|
|
1266
|
+
#initializeTTLTracking() {
|
|
1267
|
+
let ttls = new ZeroArray(this.#max), starts = new ZeroArray(this.#max);
|
|
1268
|
+
this.#ttls = ttls, this.#starts = starts, this.#setItemTTL = (index, ttl, start = perf.now()) => {
|
|
1269
|
+
if (starts[index] = ttl !== 0 ? start : 0, ttls[index] = ttl, ttl !== 0 && this.ttlAutopurge) {
|
|
1270
|
+
let t = setTimeout(() => {
|
|
1271
|
+
this.#isStale(index) && this.#delete(this.#keyList[index], "expire");
|
|
1272
|
+
}, ttl + 1);
|
|
1273
|
+
t.unref && t.unref();
|
|
1274
|
+
}
|
|
1275
|
+
}, this.#updateItemAge = (index) => {
|
|
1276
|
+
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
|
|
1277
|
+
}, this.#statusTTL = (status, index) => {
|
|
1278
|
+
if (ttls[index]) {
|
|
1279
|
+
let ttl = ttls[index], start = starts[index];
|
|
1280
|
+
if (!ttl || !start)
|
|
1281
|
+
return;
|
|
1282
|
+
status.ttl = ttl, status.start = start, status.now = cachedNow || getNow();
|
|
1283
|
+
let age = status.now - start;
|
|
1284
|
+
status.remainingTTL = ttl - age;
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
let cachedNow = 0, getNow = () => {
|
|
1288
|
+
let n = perf.now();
|
|
1289
|
+
if (this.ttlResolution > 0) {
|
|
1290
|
+
cachedNow = n;
|
|
1291
|
+
let t = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
|
1292
|
+
t.unref && t.unref();
|
|
1293
|
+
}
|
|
1294
|
+
return n;
|
|
1295
|
+
};
|
|
1296
|
+
this.getRemainingTTL = (key) => {
|
|
1297
|
+
let index = this.#keyMap.get(key);
|
|
1298
|
+
if (index === void 0)
|
|
1299
|
+
return 0;
|
|
1300
|
+
let ttl = ttls[index], start = starts[index];
|
|
1301
|
+
if (!ttl || !start)
|
|
1302
|
+
return 1 / 0;
|
|
1303
|
+
let age = (cachedNow || getNow()) - start;
|
|
1304
|
+
return ttl - age;
|
|
1305
|
+
}, this.#isStale = (index) => {
|
|
1306
|
+
let s = starts[index], t = ttls[index];
|
|
1307
|
+
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
// conditionally set private methods related to TTL
|
|
1311
|
+
#updateItemAge = () => {
|
|
1312
|
+
};
|
|
1313
|
+
#statusTTL = () => {
|
|
1314
|
+
};
|
|
1315
|
+
#setItemTTL = () => {
|
|
1316
|
+
};
|
|
1317
|
+
/* c8 ignore stop */
|
|
1318
|
+
#isStale = () => !1;
|
|
1319
|
+
#initializeSizeTracking() {
|
|
1320
|
+
let sizes = new ZeroArray(this.#max);
|
|
1321
|
+
this.#calculatedSize = 0, this.#sizes = sizes, this.#removeItemSize = (index) => {
|
|
1322
|
+
this.#calculatedSize -= sizes[index], sizes[index] = 0;
|
|
1323
|
+
}, this.#requireSize = (k, v, size, sizeCalculation) => {
|
|
1324
|
+
if (this.#isBackgroundFetch(v))
|
|
1325
|
+
return 0;
|
|
1326
|
+
if (!isPosInt(size))
|
|
1327
|
+
if (sizeCalculation) {
|
|
1328
|
+
if (typeof sizeCalculation != "function")
|
|
1329
|
+
throw new TypeError("sizeCalculation must be a function");
|
|
1330
|
+
if (size = sizeCalculation(v, k), !isPosInt(size))
|
|
1331
|
+
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
1332
|
+
} else
|
|
1333
|
+
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
1334
|
+
return size;
|
|
1335
|
+
}, this.#addItemSize = (index, size, status) => {
|
|
1336
|
+
if (sizes[index] = size, this.#maxSize) {
|
|
1337
|
+
let maxSize = this.#maxSize - sizes[index];
|
|
1338
|
+
for (; this.#calculatedSize > maxSize; )
|
|
1339
|
+
this.#evict(!0);
|
|
1340
|
+
}
|
|
1341
|
+
this.#calculatedSize += sizes[index], status && (status.entrySize = size, status.totalCalculatedSize = this.#calculatedSize);
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
#removeItemSize = (_i) => {
|
|
1345
|
+
};
|
|
1346
|
+
#addItemSize = (_i, _s, _st) => {
|
|
1347
|
+
};
|
|
1348
|
+
#requireSize = (_k, _v, size, sizeCalculation) => {
|
|
1349
|
+
if (size || sizeCalculation)
|
|
1350
|
+
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
1351
|
+
return 0;
|
|
1352
|
+
};
|
|
1353
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
1354
|
+
if (this.#size)
|
|
1355
|
+
for (let i = this.#tail; !(!this.#isValidIndex(i) || ((allowStale || !this.#isStale(i)) && (yield i), i === this.#head)); )
|
|
1356
|
+
i = this.#prev[i];
|
|
1357
|
+
}
|
|
1358
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
1359
|
+
if (this.#size)
|
|
1360
|
+
for (let i = this.#head; !(!this.#isValidIndex(i) || ((allowStale || !this.#isStale(i)) && (yield i), i === this.#tail)); )
|
|
1361
|
+
i = this.#next[i];
|
|
1362
|
+
}
|
|
1363
|
+
#isValidIndex(index) {
|
|
1364
|
+
return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
1368
|
+
* in order from most recently used to least recently used.
|
|
1369
|
+
*/
|
|
1370
|
+
*entries() {
|
|
1371
|
+
for (let i of this.#indexes())
|
|
1372
|
+
this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield [this.#keyList[i], this.#valList[i]]);
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Inverse order version of {@link LRUCache.entries}
|
|
1376
|
+
*
|
|
1377
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
1378
|
+
* in order from least recently used to most recently used.
|
|
1379
|
+
*/
|
|
1380
|
+
*rentries() {
|
|
1381
|
+
for (let i of this.#rindexes())
|
|
1382
|
+
this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield [this.#keyList[i], this.#valList[i]]);
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Return a generator yielding the keys in the cache,
|
|
1386
|
+
* in order from most recently used to least recently used.
|
|
1387
|
+
*/
|
|
1388
|
+
*keys() {
|
|
1389
|
+
for (let i of this.#indexes()) {
|
|
1390
|
+
let k = this.#keyList[i];
|
|
1391
|
+
k !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield k);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Inverse order version of {@link LRUCache.keys}
|
|
1396
|
+
*
|
|
1397
|
+
* Return a generator yielding the keys in the cache,
|
|
1398
|
+
* in order from least recently used to most recently used.
|
|
1399
|
+
*/
|
|
1400
|
+
*rkeys() {
|
|
1401
|
+
for (let i of this.#rindexes()) {
|
|
1402
|
+
let k = this.#keyList[i];
|
|
1403
|
+
k !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield k);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Return a generator yielding the values in the cache,
|
|
1408
|
+
* in order from most recently used to least recently used.
|
|
1409
|
+
*/
|
|
1410
|
+
*values() {
|
|
1411
|
+
for (let i of this.#indexes())
|
|
1412
|
+
this.#valList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield this.#valList[i]);
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Inverse order version of {@link LRUCache.values}
|
|
1416
|
+
*
|
|
1417
|
+
* Return a generator yielding the values in the cache,
|
|
1418
|
+
* in order from least recently used to most recently used.
|
|
1419
|
+
*/
|
|
1420
|
+
*rvalues() {
|
|
1421
|
+
for (let i of this.#rindexes())
|
|
1422
|
+
this.#valList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i]) && (yield this.#valList[i]);
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Iterating over the cache itself yields the same results as
|
|
1426
|
+
* {@link LRUCache.entries}
|
|
1427
|
+
*/
|
|
1428
|
+
[Symbol.iterator]() {
|
|
1429
|
+
return this.entries();
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* A String value that is used in the creation of the default string
|
|
1433
|
+
* description of an object. Called by the built-in method
|
|
1434
|
+
* `Object.prototype.toString`.
|
|
1435
|
+
*/
|
|
1436
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
1437
|
+
/**
|
|
1438
|
+
* Find a value for which the supplied fn method returns a truthy value,
|
|
1439
|
+
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
|
1440
|
+
*/
|
|
1441
|
+
find(fn, getOptions = {}) {
|
|
1442
|
+
for (let i of this.#indexes()) {
|
|
1443
|
+
let v = this.#valList[i], value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1444
|
+
if (value !== void 0 && fn(value, this.#keyList[i], this))
|
|
1445
|
+
return this.get(this.#keyList[i], getOptions);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Call the supplied function on each item in the cache, in order from most
|
|
1450
|
+
* recently used to least recently used.
|
|
1451
|
+
*
|
|
1452
|
+
* `fn` is called as `fn(value, key, cache)`.
|
|
1453
|
+
*
|
|
1454
|
+
* If `thisp` is provided, function will be called in the `this`-context of
|
|
1455
|
+
* the provided object, or the cache if no `thisp` object is provided.
|
|
1456
|
+
*
|
|
1457
|
+
* Does not update age or recenty of use, or iterate over stale values.
|
|
1458
|
+
*/
|
|
1459
|
+
forEach(fn, thisp = this) {
|
|
1460
|
+
for (let i of this.#indexes()) {
|
|
1461
|
+
let v = this.#valList[i], value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1462
|
+
value !== void 0 && fn.call(thisp, value, this.#keyList[i], this);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* The same as {@link LRUCache.forEach} but items are iterated over in
|
|
1467
|
+
* reverse order. (ie, less recently used items are iterated over first.)
|
|
1468
|
+
*/
|
|
1469
|
+
rforEach(fn, thisp = this) {
|
|
1470
|
+
for (let i of this.#rindexes()) {
|
|
1471
|
+
let v = this.#valList[i], value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1472
|
+
value !== void 0 && fn.call(thisp, value, this.#keyList[i], this);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Delete any stale entries. Returns true if anything was removed,
|
|
1477
|
+
* false otherwise.
|
|
1478
|
+
*/
|
|
1479
|
+
purgeStale() {
|
|
1480
|
+
let deleted = !1;
|
|
1481
|
+
for (let i of this.#rindexes({ allowStale: !0 }))
|
|
1482
|
+
this.#isStale(i) && (this.#delete(this.#keyList[i], "expire"), deleted = !0);
|
|
1483
|
+
return deleted;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Get the extended info about a given entry, to get its value, size, and
|
|
1487
|
+
* TTL info simultaneously. Returns `undefined` if the key is not present.
|
|
1488
|
+
*
|
|
1489
|
+
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
|
|
1490
|
+
* serialization, the `start` value is always the current timestamp, and the
|
|
1491
|
+
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
1492
|
+
*
|
|
1493
|
+
* Always returns stale values, if their info is found in the cache, so be
|
|
1494
|
+
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
1495
|
+
* if relevant.
|
|
1496
|
+
*/
|
|
1497
|
+
info(key) {
|
|
1498
|
+
let i = this.#keyMap.get(key);
|
|
1499
|
+
if (i === void 0)
|
|
1500
|
+
return;
|
|
1501
|
+
let v = this.#valList[i], value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1502
|
+
if (value === void 0)
|
|
1503
|
+
return;
|
|
1504
|
+
let entry = { value };
|
|
1505
|
+
if (this.#ttls && this.#starts) {
|
|
1506
|
+
let ttl = this.#ttls[i], start = this.#starts[i];
|
|
1507
|
+
if (ttl && start) {
|
|
1508
|
+
let remain = ttl - (perf.now() - start);
|
|
1509
|
+
entry.ttl = remain, entry.start = Date.now();
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return this.#sizes && (entry.size = this.#sizes[i]), entry;
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
1516
|
+
* passed to {@link LRLUCache#load}.
|
|
1517
|
+
*
|
|
1518
|
+
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
1519
|
+
* timestamp, even if `performance.now()` is available.
|
|
1520
|
+
*
|
|
1521
|
+
* Stale entries are always included in the `dump`, even if
|
|
1522
|
+
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
1523
|
+
*
|
|
1524
|
+
* Note: this returns an actual array, not a generator, so it can be more
|
|
1525
|
+
* easily passed around.
|
|
1526
|
+
*/
|
|
1527
|
+
dump() {
|
|
1528
|
+
let arr = [];
|
|
1529
|
+
for (let i of this.#indexes({ allowStale: !0 })) {
|
|
1530
|
+
let key = this.#keyList[i], v = this.#valList[i], value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1531
|
+
if (value === void 0 || key === void 0)
|
|
1532
|
+
continue;
|
|
1533
|
+
let entry = { value };
|
|
1534
|
+
if (this.#ttls && this.#starts) {
|
|
1535
|
+
entry.ttl = this.#ttls[i];
|
|
1536
|
+
let age = perf.now() - this.#starts[i];
|
|
1537
|
+
entry.start = Math.floor(Date.now() - age);
|
|
1538
|
+
}
|
|
1539
|
+
this.#sizes && (entry.size = this.#sizes[i]), arr.unshift([key, entry]);
|
|
1540
|
+
}
|
|
1541
|
+
return arr;
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Reset the cache and load in the items in entries in the order listed.
|
|
1545
|
+
*
|
|
1546
|
+
* The shape of the resulting cache may be different if the same options are
|
|
1547
|
+
* not used in both caches.
|
|
1548
|
+
*
|
|
1549
|
+
* The `start` fields are assumed to be calculated relative to a portable
|
|
1550
|
+
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
1551
|
+
*/
|
|
1552
|
+
load(arr) {
|
|
1553
|
+
this.clear();
|
|
1554
|
+
for (let [key, entry] of arr) {
|
|
1555
|
+
if (entry.start) {
|
|
1556
|
+
let age = Date.now() - entry.start;
|
|
1557
|
+
entry.start = perf.now() - age;
|
|
1558
|
+
}
|
|
1559
|
+
this.set(key, entry.value, entry);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Add a value to the cache.
|
|
1564
|
+
*
|
|
1565
|
+
* Note: if `undefined` is specified as a value, this is an alias for
|
|
1566
|
+
* {@link LRUCache#delete}
|
|
1567
|
+
*
|
|
1568
|
+
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
1569
|
+
* their corresponding values in the constructor options for the scope
|
|
1570
|
+
* of this single `set()` operation.
|
|
1571
|
+
*
|
|
1572
|
+
* If `start` is provided, then that will set the effective start
|
|
1573
|
+
* time for the TTL calculation. Note that this must be a previous
|
|
1574
|
+
* value of `performance.now()` if supported, or a previous value of
|
|
1575
|
+
* `Date.now()` if not.
|
|
1576
|
+
*
|
|
1577
|
+
* Options object may also include `size`, which will prevent
|
|
1578
|
+
* calling the `sizeCalculation` function and just use the specified
|
|
1579
|
+
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
1580
|
+
* will prevent calling a `dispose` function in the case of
|
|
1581
|
+
* overwrites.
|
|
1582
|
+
*
|
|
1583
|
+
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
1584
|
+
* entry is greater than `maxEntrySize`, then the item will not be
|
|
1585
|
+
* added to the cache.
|
|
1586
|
+
*
|
|
1587
|
+
* Will update the recency of the entry.
|
|
1588
|
+
*
|
|
1589
|
+
* If the value is `undefined`, then this is an alias for
|
|
1590
|
+
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
1591
|
+
*/
|
|
1592
|
+
set(k, v, setOptions = {}) {
|
|
1593
|
+
if (v === void 0)
|
|
1594
|
+
return this.delete(k), this;
|
|
1595
|
+
let { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions, { noUpdateTTL = this.noUpdateTTL } = setOptions, size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
1596
|
+
if (this.maxEntrySize && size > this.maxEntrySize)
|
|
1597
|
+
return status && (status.set = "miss", status.maxEntrySizeExceeded = !0), this.#delete(k, "set"), this;
|
|
1598
|
+
let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
|
|
1599
|
+
if (index === void 0)
|
|
1600
|
+
index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(!1) : this.#size, this.#keyList[index] = k, this.#valList[index] = v, this.#keyMap.set(k, index), this.#next[this.#tail] = index, this.#prev[index] = this.#tail, this.#tail = index, this.#size++, this.#addItemSize(index, size, status), status && (status.set = "add"), noUpdateTTL = !1;
|
|
1601
|
+
else {
|
|
1602
|
+
this.#moveToTail(index);
|
|
1603
|
+
let oldVal = this.#valList[index];
|
|
1604
|
+
if (v !== oldVal) {
|
|
1605
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
1606
|
+
oldVal.__abortController.abort(new Error("replaced"));
|
|
1607
|
+
let { __staleWhileFetching: s } = oldVal;
|
|
1608
|
+
s !== void 0 && !noDisposeOnSet && (this.#hasDispose && this.#dispose?.(s, k, "set"), this.#hasDisposeAfter && this.#disposed?.push([s, k, "set"]));
|
|
1609
|
+
} else noDisposeOnSet || (this.#hasDispose && this.#dispose?.(oldVal, k, "set"), this.#hasDisposeAfter && this.#disposed?.push([oldVal, k, "set"]));
|
|
1610
|
+
if (this.#removeItemSize(index), this.#addItemSize(index, size, status), this.#valList[index] = v, status) {
|
|
1611
|
+
status.set = "replace";
|
|
1612
|
+
let oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
1613
|
+
oldValue !== void 0 && (status.oldValue = oldValue);
|
|
1614
|
+
}
|
|
1615
|
+
} else status && (status.set = "update");
|
|
1616
|
+
}
|
|
1617
|
+
if (ttl !== 0 && !this.#ttls && this.#initializeTTLTracking(), this.#ttls && (noUpdateTTL || this.#setItemTTL(index, ttl, start), status && this.#statusTTL(status, index)), !noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
1618
|
+
let dt = this.#disposed, task;
|
|
1619
|
+
for (; task = dt?.shift(); )
|
|
1620
|
+
this.#disposeAfter?.(...task);
|
|
1621
|
+
}
|
|
1622
|
+
return this;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Evict the least recently used item, returning its value or
|
|
1626
|
+
* `undefined` if cache is empty.
|
|
1627
|
+
*/
|
|
1628
|
+
pop() {
|
|
1629
|
+
try {
|
|
1630
|
+
for (; this.#size; ) {
|
|
1631
|
+
let val = this.#valList[this.#head];
|
|
1632
|
+
if (this.#evict(!0), this.#isBackgroundFetch(val)) {
|
|
1633
|
+
if (val.__staleWhileFetching)
|
|
1634
|
+
return val.__staleWhileFetching;
|
|
1635
|
+
} else if (val !== void 0)
|
|
1636
|
+
return val;
|
|
1637
|
+
}
|
|
1638
|
+
} finally {
|
|
1639
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
1640
|
+
let dt = this.#disposed, task;
|
|
1641
|
+
for (; task = dt?.shift(); )
|
|
1642
|
+
this.#disposeAfter?.(...task);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
#evict(free) {
|
|
1647
|
+
let head = this.#head, k = this.#keyList[head], v = this.#valList[head];
|
|
1648
|
+
return this.#hasFetchMethod && this.#isBackgroundFetch(v) ? v.__abortController.abort(new Error("evicted")) : (this.#hasDispose || this.#hasDisposeAfter) && (this.#hasDispose && this.#dispose?.(v, k, "evict"), this.#hasDisposeAfter && this.#disposed?.push([v, k, "evict"])), this.#removeItemSize(head), free && (this.#keyList[head] = void 0, this.#valList[head] = void 0, this.#free.push(head)), this.#size === 1 ? (this.#head = this.#tail = 0, this.#free.length = 0) : this.#head = this.#next[head], this.#keyMap.delete(k), this.#size--, head;
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Check if a key is in the cache, without updating the recency of use.
|
|
1652
|
+
* Will return false if the item is stale, even though it is technically
|
|
1653
|
+
* in the cache.
|
|
1654
|
+
*
|
|
1655
|
+
* Check if a key is in the cache, without updating the recency of
|
|
1656
|
+
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
1657
|
+
* to `true` in either the options or the constructor.
|
|
1658
|
+
*
|
|
1659
|
+
* Will return `false` if the item is stale, even though it is technically in
|
|
1660
|
+
* the cache. The difference can be determined (if it matters) by using a
|
|
1661
|
+
* `status` argument, and inspecting the `has` field.
|
|
1662
|
+
*
|
|
1663
|
+
* Will not update item age unless
|
|
1664
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
1665
|
+
*/
|
|
1666
|
+
has(k, hasOptions = {}) {
|
|
1667
|
+
let { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions, index = this.#keyMap.get(k);
|
|
1668
|
+
if (index !== void 0) {
|
|
1669
|
+
let v = this.#valList[index];
|
|
1670
|
+
if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0)
|
|
1671
|
+
return !1;
|
|
1672
|
+
if (this.#isStale(index))
|
|
1673
|
+
status && (status.has = "stale", this.#statusTTL(status, index));
|
|
1674
|
+
else return updateAgeOnHas && this.#updateItemAge(index), status && (status.has = "hit", this.#statusTTL(status, index)), !0;
|
|
1675
|
+
} else status && (status.has = "miss");
|
|
1676
|
+
return !1;
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Like {@link LRUCache#get} but doesn't update recency or delete stale
|
|
1680
|
+
* items.
|
|
1681
|
+
*
|
|
1682
|
+
* Returns `undefined` if the item is stale, unless
|
|
1683
|
+
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
1684
|
+
*/
|
|
1685
|
+
peek(k, peekOptions = {}) {
|
|
1686
|
+
let { allowStale = this.allowStale } = peekOptions, index = this.#keyMap.get(k);
|
|
1687
|
+
if (index === void 0 || !allowStale && this.#isStale(index))
|
|
1688
|
+
return;
|
|
1689
|
+
let v = this.#valList[index];
|
|
1690
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1691
|
+
}
|
|
1692
|
+
#backgroundFetch(k, index, options, context) {
|
|
1693
|
+
let v = index === void 0 ? void 0 : this.#valList[index];
|
|
1694
|
+
if (this.#isBackgroundFetch(v))
|
|
1695
|
+
return v;
|
|
1696
|
+
let ac = new AC(), { signal } = options;
|
|
1697
|
+
signal?.addEventListener("abort", () => ac.abort(signal.reason), {
|
|
1698
|
+
signal: ac.signal
|
|
1699
|
+
});
|
|
1700
|
+
let fetchOpts = {
|
|
1701
|
+
signal: ac.signal,
|
|
1702
|
+
options,
|
|
1703
|
+
context
|
|
1704
|
+
}, cb = (v2, updateCache = !1) => {
|
|
1705
|
+
let { aborted } = ac.signal, ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
|
|
1706
|
+
if (options.status && (aborted && !updateCache ? (options.status.fetchAborted = !0, options.status.fetchError = ac.signal.reason, ignoreAbort && (options.status.fetchAbortIgnored = !0)) : options.status.fetchResolved = !0), aborted && !ignoreAbort && !updateCache)
|
|
1707
|
+
return fetchFail(ac.signal.reason);
|
|
1708
|
+
let bf2 = p;
|
|
1709
|
+
return this.#valList[index] === p && (v2 === void 0 ? bf2.__staleWhileFetching ? this.#valList[index] = bf2.__staleWhileFetching : this.#delete(k, "fetch") : (options.status && (options.status.fetchUpdated = !0), this.set(k, v2, fetchOpts.options))), v2;
|
|
1710
|
+
}, eb = (er) => (options.status && (options.status.fetchRejected = !0, options.status.fetchError = er), fetchFail(er)), fetchFail = (er) => {
|
|
1711
|
+
let { aborted } = ac.signal, allowStaleAborted = aborted && options.allowStaleOnFetchAbort, allowStale = allowStaleAborted || options.allowStaleOnFetchRejection, noDelete = allowStale || options.noDeleteOnFetchRejection, bf2 = p;
|
|
1712
|
+
if (this.#valList[index] === p && (!noDelete || bf2.__staleWhileFetching === void 0 ? this.#delete(k, "fetch") : allowStaleAborted || (this.#valList[index] = bf2.__staleWhileFetching)), allowStale)
|
|
1713
|
+
return options.status && bf2.__staleWhileFetching !== void 0 && (options.status.returnedStale = !0), bf2.__staleWhileFetching;
|
|
1714
|
+
if (bf2.__returned === bf2)
|
|
1715
|
+
throw er;
|
|
1716
|
+
}, pcall = (res, rej) => {
|
|
1717
|
+
let fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
1718
|
+
fmp && fmp instanceof Promise && fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej), ac.signal.addEventListener("abort", () => {
|
|
1719
|
+
(!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) && (res(void 0), options.allowStaleOnFetchAbort && (res = (v2) => cb(v2, !0)));
|
|
1720
|
+
});
|
|
1721
|
+
};
|
|
1722
|
+
options.status && (options.status.fetchDispatched = !0);
|
|
1723
|
+
let p = new Promise(pcall).then(cb, eb), bf = Object.assign(p, {
|
|
1724
|
+
__abortController: ac,
|
|
1725
|
+
__staleWhileFetching: v,
|
|
1726
|
+
__returned: void 0
|
|
1727
|
+
});
|
|
1728
|
+
return index === void 0 ? (this.set(k, bf, { ...fetchOpts.options, status: void 0 }), index = this.#keyMap.get(k)) : this.#valList[index] = bf, bf;
|
|
1729
|
+
}
|
|
1730
|
+
#isBackgroundFetch(p) {
|
|
1731
|
+
if (!this.#hasFetchMethod)
|
|
1732
|
+
return !1;
|
|
1733
|
+
let b = p;
|
|
1734
|
+
return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
|
|
1735
|
+
}
|
|
1736
|
+
async fetch(k, fetchOptions = {}) {
|
|
1737
|
+
let {
|
|
1738
|
+
// get options
|
|
1739
|
+
allowStale = this.allowStale,
|
|
1740
|
+
updateAgeOnGet = this.updateAgeOnGet,
|
|
1741
|
+
noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
|
1742
|
+
// set options
|
|
1743
|
+
ttl = this.ttl,
|
|
1744
|
+
noDisposeOnSet = this.noDisposeOnSet,
|
|
1745
|
+
size = 0,
|
|
1746
|
+
sizeCalculation = this.sizeCalculation,
|
|
1747
|
+
noUpdateTTL = this.noUpdateTTL,
|
|
1748
|
+
// fetch exclusive options
|
|
1749
|
+
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
|
|
1750
|
+
allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
|
|
1751
|
+
ignoreFetchAbort = this.ignoreFetchAbort,
|
|
1752
|
+
allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
|
|
1753
|
+
context,
|
|
1754
|
+
forceRefresh = !1,
|
|
1755
|
+
status,
|
|
1756
|
+
signal
|
|
1757
|
+
} = fetchOptions;
|
|
1758
|
+
if (!this.#hasFetchMethod)
|
|
1759
|
+
return status && (status.fetch = "get"), this.get(k, {
|
|
1760
|
+
allowStale,
|
|
1761
|
+
updateAgeOnGet,
|
|
1762
|
+
noDeleteOnStaleGet,
|
|
1763
|
+
status
|
|
1764
|
+
});
|
|
1765
|
+
let options = {
|
|
1766
|
+
allowStale,
|
|
1767
|
+
updateAgeOnGet,
|
|
1768
|
+
noDeleteOnStaleGet,
|
|
1769
|
+
ttl,
|
|
1770
|
+
noDisposeOnSet,
|
|
1771
|
+
size,
|
|
1772
|
+
sizeCalculation,
|
|
1773
|
+
noUpdateTTL,
|
|
1774
|
+
noDeleteOnFetchRejection,
|
|
1775
|
+
allowStaleOnFetchRejection,
|
|
1776
|
+
allowStaleOnFetchAbort,
|
|
1777
|
+
ignoreFetchAbort,
|
|
1778
|
+
status,
|
|
1779
|
+
signal
|
|
1780
|
+
}, index = this.#keyMap.get(k);
|
|
1781
|
+
if (index === void 0) {
|
|
1782
|
+
status && (status.fetch = "miss");
|
|
1783
|
+
let p = this.#backgroundFetch(k, index, options, context);
|
|
1784
|
+
return p.__returned = p;
|
|
1785
|
+
} else {
|
|
1786
|
+
let v = this.#valList[index];
|
|
1787
|
+
if (this.#isBackgroundFetch(v)) {
|
|
1788
|
+
let stale = allowStale && v.__staleWhileFetching !== void 0;
|
|
1789
|
+
return status && (status.fetch = "inflight", stale && (status.returnedStale = !0)), stale ? v.__staleWhileFetching : v.__returned = v;
|
|
1790
|
+
}
|
|
1791
|
+
let isStale = this.#isStale(index);
|
|
1792
|
+
if (!forceRefresh && !isStale)
|
|
1793
|
+
return status && (status.fetch = "hit"), this.#moveToTail(index), updateAgeOnGet && this.#updateItemAge(index), status && this.#statusTTL(status, index), v;
|
|
1794
|
+
let p = this.#backgroundFetch(k, index, options, context), staleVal = p.__staleWhileFetching !== void 0 && allowStale;
|
|
1795
|
+
return status && (status.fetch = isStale ? "stale" : "refresh", staleVal && isStale && (status.returnedStale = !0)), staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
1799
|
+
let v = await this.fetch(k, fetchOptions);
|
|
1800
|
+
if (v === void 0)
|
|
1801
|
+
throw new Error("fetch() returned undefined");
|
|
1802
|
+
return v;
|
|
1803
|
+
}
|
|
1804
|
+
memo(k, memoOptions = {}) {
|
|
1805
|
+
let memoMethod = this.#memoMethod;
|
|
1806
|
+
if (!memoMethod)
|
|
1807
|
+
throw new Error("no memoMethod provided to constructor");
|
|
1808
|
+
let { context, forceRefresh, ...options } = memoOptions, v = this.get(k, options);
|
|
1809
|
+
if (!forceRefresh && v !== void 0)
|
|
1810
|
+
return v;
|
|
1811
|
+
let vv = memoMethod(k, v, {
|
|
1812
|
+
options,
|
|
1813
|
+
context
|
|
1814
|
+
});
|
|
1815
|
+
return this.set(k, vv, options), vv;
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Return a value from the cache. Will update the recency of the cache
|
|
1819
|
+
* entry found.
|
|
1820
|
+
*
|
|
1821
|
+
* If the key is not found, get() will return `undefined`.
|
|
1822
|
+
*/
|
|
1823
|
+
get(k, getOptions = {}) {
|
|
1824
|
+
let { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions, index = this.#keyMap.get(k);
|
|
1825
|
+
if (index !== void 0) {
|
|
1826
|
+
let value = this.#valList[index], fetching = this.#isBackgroundFetch(value);
|
|
1827
|
+
return status && this.#statusTTL(status, index), this.#isStale(index) ? (status && (status.get = "stale"), fetching ? (status && allowStale && value.__staleWhileFetching !== void 0 && (status.returnedStale = !0), allowStale ? value.__staleWhileFetching : void 0) : (noDeleteOnStaleGet || this.#delete(k, "expire"), status && allowStale && (status.returnedStale = !0), allowStale ? value : void 0)) : (status && (status.get = "hit"), fetching ? value.__staleWhileFetching : (this.#moveToTail(index), updateAgeOnGet && this.#updateItemAge(index), value));
|
|
1828
|
+
} else status && (status.get = "miss");
|
|
1829
|
+
}
|
|
1830
|
+
#connect(p, n) {
|
|
1831
|
+
this.#prev[n] = p, this.#next[p] = n;
|
|
1832
|
+
}
|
|
1833
|
+
#moveToTail(index) {
|
|
1834
|
+
index !== this.#tail && (index === this.#head ? this.#head = this.#next[index] : this.#connect(this.#prev[index], this.#next[index]), this.#connect(this.#tail, index), this.#tail = index);
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Deletes a key out of the cache.
|
|
1838
|
+
*
|
|
1839
|
+
* Returns true if the key was deleted, false otherwise.
|
|
1840
|
+
*/
|
|
1841
|
+
delete(k) {
|
|
1842
|
+
return this.#delete(k, "delete");
|
|
1843
|
+
}
|
|
1844
|
+
#delete(k, reason) {
|
|
1845
|
+
let deleted = !1;
|
|
1846
|
+
if (this.#size !== 0) {
|
|
1847
|
+
let index = this.#keyMap.get(k);
|
|
1848
|
+
if (index !== void 0)
|
|
1849
|
+
if (deleted = !0, this.#size === 1)
|
|
1850
|
+
this.#clear(reason);
|
|
1851
|
+
else {
|
|
1852
|
+
this.#removeItemSize(index);
|
|
1853
|
+
let v = this.#valList[index];
|
|
1854
|
+
if (this.#isBackgroundFetch(v) ? v.__abortController.abort(new Error("deleted")) : (this.#hasDispose || this.#hasDisposeAfter) && (this.#hasDispose && this.#dispose?.(v, k, reason), this.#hasDisposeAfter && this.#disposed?.push([v, k, reason])), this.#keyMap.delete(k), this.#keyList[index] = void 0, this.#valList[index] = void 0, index === this.#tail)
|
|
1855
|
+
this.#tail = this.#prev[index];
|
|
1856
|
+
else if (index === this.#head)
|
|
1857
|
+
this.#head = this.#next[index];
|
|
1858
|
+
else {
|
|
1859
|
+
let pi = this.#prev[index];
|
|
1860
|
+
this.#next[pi] = this.#next[index];
|
|
1861
|
+
let ni = this.#next[index];
|
|
1862
|
+
this.#prev[ni] = this.#prev[index];
|
|
1863
|
+
}
|
|
1864
|
+
this.#size--, this.#free.push(index);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
1868
|
+
let dt = this.#disposed, task;
|
|
1869
|
+
for (; task = dt?.shift(); )
|
|
1870
|
+
this.#disposeAfter?.(...task);
|
|
1871
|
+
}
|
|
1872
|
+
return deleted;
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Clear the cache entirely, throwing away all values.
|
|
1876
|
+
*/
|
|
1877
|
+
clear() {
|
|
1878
|
+
return this.#clear("delete");
|
|
1879
|
+
}
|
|
1880
|
+
#clear(reason) {
|
|
1881
|
+
for (let index of this.#rindexes({ allowStale: !0 })) {
|
|
1882
|
+
let v = this.#valList[index];
|
|
1883
|
+
if (this.#isBackgroundFetch(v))
|
|
1884
|
+
v.__abortController.abort(new Error("deleted"));
|
|
1885
|
+
else {
|
|
1886
|
+
let k = this.#keyList[index];
|
|
1887
|
+
this.#hasDispose && this.#dispose?.(v, k, reason), this.#hasDisposeAfter && this.#disposed?.push([v, k, reason]);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
if (this.#keyMap.clear(), this.#valList.fill(void 0), this.#keyList.fill(void 0), this.#ttls && this.#starts && (this.#ttls.fill(0), this.#starts.fill(0)), this.#sizes && this.#sizes.fill(0), this.#head = 0, this.#tail = 0, this.#free.length = 0, this.#calculatedSize = 0, this.#size = 0, this.#hasDisposeAfter && this.#disposed) {
|
|
1891
|
+
let dt = this.#disposed, task;
|
|
1892
|
+
for (; task = dt?.shift(); )
|
|
1893
|
+
this.#disposeAfter?.(...task);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
|
|
1898
|
+
// ../node_modules/glob/node_modules/path-scurry/dist/esm/index.js
|
|
1899
|
+
import { posix, win32 } from "node:path";
|
|
1900
|
+
import { fileURLToPath } from "node:url";
|
|
1901
|
+
import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps } from "fs";
|
|
1902
|
+
import * as actualFS from "node:fs";
|
|
1903
|
+
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
1904
|
+
|
|
1905
|
+
// ../node_modules/minipass/dist/esm/index.js
|
|
1906
|
+
import { EventEmitter } from "node:events";
|
|
1907
|
+
import Stream from "node:stream";
|
|
1908
|
+
import { StringDecoder } from "node:string_decoder";
|
|
1909
|
+
var proc = typeof process == "object" && process ? process : {
|
|
1910
|
+
stdout: null,
|
|
1911
|
+
stderr: null
|
|
1912
|
+
}, isStream = (s) => !!s && typeof s == "object" && (s instanceof Minipass || s instanceof Stream || isReadable(s) || isWritable(s)), isReadable = (s) => !!s && typeof s == "object" && s instanceof EventEmitter && typeof s.pipe == "function" && // node core Writable streams have a pipe() method, but it throws
|
|
1913
|
+
s.pipe !== Stream.Writable.prototype.pipe, isWritable = (s) => !!s && typeof s == "object" && s instanceof EventEmitter && typeof s.write == "function" && typeof s.end == "function", EOF = Symbol("EOF"), MAYBE_EMIT_END = Symbol("maybeEmitEnd"), EMITTED_END = Symbol("emittedEnd"), EMITTING_END = Symbol("emittingEnd"), EMITTED_ERROR = Symbol("emittedError"), CLOSED = Symbol("closed"), READ = Symbol("read"), FLUSH = Symbol("flush"), FLUSHCHUNK = Symbol("flushChunk"), ENCODING = Symbol("encoding"), DECODER = Symbol("decoder"), FLOWING = Symbol("flowing"), PAUSED = Symbol("paused"), RESUME = Symbol("resume"), BUFFER = Symbol("buffer"), PIPES = Symbol("pipes"), BUFFERLENGTH = Symbol("bufferLength"), BUFFERPUSH = Symbol("bufferPush"), BUFFERSHIFT = Symbol("bufferShift"), OBJECTMODE = Symbol("objectMode"), DESTROYED = Symbol("destroyed"), ERROR = Symbol("error"), EMITDATA = Symbol("emitData"), EMITEND = Symbol("emitEnd"), EMITEND2 = Symbol("emitEnd2"), ASYNC = Symbol("async"), ABORT = Symbol("abort"), ABORTED = Symbol("aborted"), SIGNAL = Symbol("signal"), DATALISTENERS = Symbol("dataListeners"), DISCARDED = Symbol("discarded"), defer = (fn) => Promise.resolve().then(fn), nodefer = (fn) => fn(), isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish", isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b == "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0, isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b), Pipe = class {
|
|
1914
|
+
src;
|
|
1915
|
+
dest;
|
|
1916
|
+
opts;
|
|
1917
|
+
ondrain;
|
|
1918
|
+
constructor(src, dest, opts) {
|
|
1919
|
+
this.src = src, this.dest = dest, this.opts = opts, this.ondrain = () => src[RESUME](), this.dest.on("drain", this.ondrain);
|
|
1920
|
+
}
|
|
1921
|
+
unpipe() {
|
|
1922
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
1923
|
+
}
|
|
1924
|
+
// only here for the prototype
|
|
1925
|
+
/* c8 ignore start */
|
|
1926
|
+
proxyErrors(_er) {
|
|
1927
|
+
}
|
|
1928
|
+
/* c8 ignore stop */
|
|
1929
|
+
end() {
|
|
1930
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
1931
|
+
}
|
|
1932
|
+
}, PipeProxyErrors = class extends Pipe {
|
|
1933
|
+
unpipe() {
|
|
1934
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
1935
|
+
}
|
|
1936
|
+
constructor(src, dest, opts) {
|
|
1937
|
+
super(src, dest, opts), this.proxyErrors = (er) => dest.emit("error", er), src.on("error", this.proxyErrors);
|
|
1938
|
+
}
|
|
1939
|
+
}, isObjectModeOptions = (o) => !!o.objectMode, isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer", Minipass = class extends EventEmitter {
|
|
1940
|
+
[FLOWING] = !1;
|
|
1941
|
+
[PAUSED] = !1;
|
|
1942
|
+
[PIPES] = [];
|
|
1943
|
+
[BUFFER] = [];
|
|
1944
|
+
[OBJECTMODE];
|
|
1945
|
+
[ENCODING];
|
|
1946
|
+
[ASYNC];
|
|
1947
|
+
[DECODER];
|
|
1948
|
+
[EOF] = !1;
|
|
1949
|
+
[EMITTED_END] = !1;
|
|
1950
|
+
[EMITTING_END] = !1;
|
|
1951
|
+
[CLOSED] = !1;
|
|
1952
|
+
[EMITTED_ERROR] = null;
|
|
1953
|
+
[BUFFERLENGTH] = 0;
|
|
1954
|
+
[DESTROYED] = !1;
|
|
1955
|
+
[SIGNAL];
|
|
1956
|
+
[ABORTED] = !1;
|
|
1957
|
+
[DATALISTENERS] = 0;
|
|
1958
|
+
[DISCARDED] = !1;
|
|
1959
|
+
/**
|
|
1960
|
+
* true if the stream can be written
|
|
1961
|
+
*/
|
|
1962
|
+
writable = !0;
|
|
1963
|
+
/**
|
|
1964
|
+
* true if the stream can be read
|
|
1965
|
+
*/
|
|
1966
|
+
readable = !0;
|
|
1967
|
+
/**
|
|
1968
|
+
* If `RType` is Buffer, then options do not need to be provided.
|
|
1969
|
+
* Otherwise, an options object must be provided to specify either
|
|
1970
|
+
* {@link Minipass.SharedOptions.objectMode} or
|
|
1971
|
+
* {@link Minipass.SharedOptions.encoding}, as appropriate.
|
|
1972
|
+
*/
|
|
1973
|
+
constructor(...args) {
|
|
1974
|
+
let options = args[0] || {};
|
|
1975
|
+
if (super(), options.objectMode && typeof options.encoding == "string")
|
|
1976
|
+
throw new TypeError("Encoding and objectMode may not be used together");
|
|
1977
|
+
isObjectModeOptions(options) ? (this[OBJECTMODE] = !0, this[ENCODING] = null) : isEncodingOptions(options) ? (this[ENCODING] = options.encoding, this[OBJECTMODE] = !1) : (this[OBJECTMODE] = !1, this[ENCODING] = null), this[ASYNC] = !!options.async, this[DECODER] = this[ENCODING] ? new StringDecoder(this[ENCODING]) : null, options && options.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[BUFFER] }), options && options.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
|
|
1978
|
+
let { signal } = options;
|
|
1979
|
+
signal && (this[SIGNAL] = signal, signal.aborted ? this[ABORT]() : signal.addEventListener("abort", () => this[ABORT]()));
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* The amount of data stored in the buffer waiting to be read.
|
|
1983
|
+
*
|
|
1984
|
+
* For Buffer strings, this will be the total byte length.
|
|
1985
|
+
* For string encoding streams, this will be the string character length,
|
|
1986
|
+
* according to JavaScript's `string.length` logic.
|
|
1987
|
+
* For objectMode streams, this is a count of the items waiting to be
|
|
1988
|
+
* emitted.
|
|
1989
|
+
*/
|
|
1990
|
+
get bufferLength() {
|
|
1991
|
+
return this[BUFFERLENGTH];
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* The `BufferEncoding` currently in use, or `null`
|
|
1995
|
+
*/
|
|
1996
|
+
get encoding() {
|
|
1997
|
+
return this[ENCODING];
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* @deprecated - This is a read only property
|
|
2001
|
+
*/
|
|
2002
|
+
set encoding(_enc) {
|
|
2003
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* @deprecated - Encoding may only be set at instantiation time
|
|
2007
|
+
*/
|
|
2008
|
+
setEncoding(_enc) {
|
|
2009
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* True if this is an objectMode stream
|
|
2013
|
+
*/
|
|
2014
|
+
get objectMode() {
|
|
2015
|
+
return this[OBJECTMODE];
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* @deprecated - This is a read-only property
|
|
2019
|
+
*/
|
|
2020
|
+
set objectMode(_om) {
|
|
2021
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* true if this is an async stream
|
|
2025
|
+
*/
|
|
2026
|
+
get async() {
|
|
2027
|
+
return this[ASYNC];
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Set to true to make this stream async.
|
|
2031
|
+
*
|
|
2032
|
+
* Once set, it cannot be unset, as this would potentially cause incorrect
|
|
2033
|
+
* behavior. Ie, a sync stream can be made async, but an async stream
|
|
2034
|
+
* cannot be safely made sync.
|
|
2035
|
+
*/
|
|
2036
|
+
set async(a) {
|
|
2037
|
+
this[ASYNC] = this[ASYNC] || !!a;
|
|
2038
|
+
}
|
|
2039
|
+
// drop everything and get out of the flow completely
|
|
2040
|
+
[ABORT]() {
|
|
2041
|
+
this[ABORTED] = !0, this.emit("abort", this[SIGNAL]?.reason), this.destroy(this[SIGNAL]?.reason);
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* True if the stream has been aborted.
|
|
2045
|
+
*/
|
|
2046
|
+
get aborted() {
|
|
2047
|
+
return this[ABORTED];
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* No-op setter. Stream aborted status is set via the AbortSignal provided
|
|
2051
|
+
* in the constructor options.
|
|
2052
|
+
*/
|
|
2053
|
+
set aborted(_) {
|
|
2054
|
+
}
|
|
2055
|
+
write(chunk, encoding, cb) {
|
|
2056
|
+
if (this[ABORTED])
|
|
2057
|
+
return !1;
|
|
2058
|
+
if (this[EOF])
|
|
2059
|
+
throw new Error("write after end");
|
|
2060
|
+
if (this[DESTROYED])
|
|
2061
|
+
return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
2062
|
+
typeof encoding == "function" && (cb = encoding, encoding = "utf8"), encoding || (encoding = "utf8");
|
|
2063
|
+
let fn = this[ASYNC] ? defer : nodefer;
|
|
2064
|
+
if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
|
|
2065
|
+
if (isArrayBufferView(chunk))
|
|
2066
|
+
chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
2067
|
+
else if (isArrayBufferLike(chunk))
|
|
2068
|
+
chunk = Buffer.from(chunk);
|
|
2069
|
+
else if (typeof chunk != "string")
|
|
2070
|
+
throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
2071
|
+
}
|
|
2072
|
+
return this[OBJECTMODE] ? (this[FLOWING] && this[BUFFERLENGTH] !== 0 && this[FLUSH](!0), this[FLOWING] ? this.emit("data", chunk) : this[BUFFERPUSH](chunk), this[BUFFERLENGTH] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING]) : chunk.length ? (typeof chunk == "string" && // unless it is a string already ready for us to use
|
|
2073
|
+
!(encoding === this[ENCODING] && !this[DECODER]?.lastNeed) && (chunk = Buffer.from(chunk, encoding)), Buffer.isBuffer(chunk) && this[ENCODING] && (chunk = this[DECODER].write(chunk)), this[FLOWING] && this[BUFFERLENGTH] !== 0 && this[FLUSH](!0), this[FLOWING] ? this.emit("data", chunk) : this[BUFFERPUSH](chunk), this[BUFFERLENGTH] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING]) : (this[BUFFERLENGTH] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING]);
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Low-level explicit read method.
|
|
2077
|
+
*
|
|
2078
|
+
* In objectMode, the argument is ignored, and one item is returned if
|
|
2079
|
+
* available.
|
|
2080
|
+
*
|
|
2081
|
+
* `n` is the number of bytes (or in the case of encoding streams,
|
|
2082
|
+
* characters) to consume. If `n` is not provided, then the entire buffer
|
|
2083
|
+
* is returned, or `null` is returned if no data is available.
|
|
2084
|
+
*
|
|
2085
|
+
* If `n` is greater that the amount of data in the internal buffer,
|
|
2086
|
+
* then `null` is returned.
|
|
2087
|
+
*/
|
|
2088
|
+
read(n) {
|
|
2089
|
+
if (this[DESTROYED])
|
|
2090
|
+
return null;
|
|
2091
|
+
if (this[DISCARDED] = !1, this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH])
|
|
2092
|
+
return this[MAYBE_EMIT_END](), null;
|
|
2093
|
+
this[OBJECTMODE] && (n = null), this[BUFFER].length > 1 && !this[OBJECTMODE] && (this[BUFFER] = [
|
|
2094
|
+
this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])
|
|
2095
|
+
]);
|
|
2096
|
+
let ret = this[READ](n || null, this[BUFFER][0]);
|
|
2097
|
+
return this[MAYBE_EMIT_END](), ret;
|
|
2098
|
+
}
|
|
2099
|
+
[READ](n, chunk) {
|
|
2100
|
+
if (this[OBJECTMODE])
|
|
2101
|
+
this[BUFFERSHIFT]();
|
|
2102
|
+
else {
|
|
2103
|
+
let c = chunk;
|
|
2104
|
+
n === c.length || n === null ? this[BUFFERSHIFT]() : typeof c == "string" ? (this[BUFFER][0] = c.slice(n), chunk = c.slice(0, n), this[BUFFERLENGTH] -= n) : (this[BUFFER][0] = c.subarray(n), chunk = c.subarray(0, n), this[BUFFERLENGTH] -= n);
|
|
2105
|
+
}
|
|
2106
|
+
return this.emit("data", chunk), !this[BUFFER].length && !this[EOF] && this.emit("drain"), chunk;
|
|
2107
|
+
}
|
|
2108
|
+
end(chunk, encoding, cb) {
|
|
2109
|
+
return typeof chunk == "function" && (cb = chunk, chunk = void 0), typeof encoding == "function" && (cb = encoding, encoding = "utf8"), chunk !== void 0 && this.write(chunk, encoding), cb && this.once("end", cb), this[EOF] = !0, this.writable = !1, (this[FLOWING] || !this[PAUSED]) && this[MAYBE_EMIT_END](), this;
|
|
2110
|
+
}
|
|
2111
|
+
// don't let the internal resume be overwritten
|
|
2112
|
+
[RESUME]() {
|
|
2113
|
+
this[DESTROYED] || (!this[DATALISTENERS] && !this[PIPES].length && (this[DISCARDED] = !0), this[PAUSED] = !1, this[FLOWING] = !0, this.emit("resume"), this[BUFFER].length ? this[FLUSH]() : this[EOF] ? this[MAYBE_EMIT_END]() : this.emit("drain"));
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Resume the stream if it is currently in a paused state
|
|
2117
|
+
*
|
|
2118
|
+
* If called when there are no pipe destinations or `data` event listeners,
|
|
2119
|
+
* this will place the stream in a "discarded" state, where all data will
|
|
2120
|
+
* be thrown away. The discarded state is removed if a pipe destination or
|
|
2121
|
+
* data handler is added, if pause() is called, or if any synchronous or
|
|
2122
|
+
* asynchronous iteration is started.
|
|
2123
|
+
*/
|
|
2124
|
+
resume() {
|
|
2125
|
+
return this[RESUME]();
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Pause the stream
|
|
2129
|
+
*/
|
|
2130
|
+
pause() {
|
|
2131
|
+
this[FLOWING] = !1, this[PAUSED] = !0, this[DISCARDED] = !1;
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* true if the stream has been forcibly destroyed
|
|
2135
|
+
*/
|
|
2136
|
+
get destroyed() {
|
|
2137
|
+
return this[DESTROYED];
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* true if the stream is currently in a flowing state, meaning that
|
|
2141
|
+
* any writes will be immediately emitted.
|
|
2142
|
+
*/
|
|
2143
|
+
get flowing() {
|
|
2144
|
+
return this[FLOWING];
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* true if the stream is currently in a paused state
|
|
2148
|
+
*/
|
|
2149
|
+
get paused() {
|
|
2150
|
+
return this[PAUSED];
|
|
2151
|
+
}
|
|
2152
|
+
[BUFFERPUSH](chunk) {
|
|
2153
|
+
this[OBJECTMODE] ? this[BUFFERLENGTH] += 1 : this[BUFFERLENGTH] += chunk.length, this[BUFFER].push(chunk);
|
|
2154
|
+
}
|
|
2155
|
+
[BUFFERSHIFT]() {
|
|
2156
|
+
return this[OBJECTMODE] ? this[BUFFERLENGTH] -= 1 : this[BUFFERLENGTH] -= this[BUFFER][0].length, this[BUFFER].shift();
|
|
2157
|
+
}
|
|
2158
|
+
[FLUSH](noDrain = !1) {
|
|
2159
|
+
do
|
|
2160
|
+
;
|
|
2161
|
+
while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
|
|
2162
|
+
!noDrain && !this[BUFFER].length && !this[EOF] && this.emit("drain");
|
|
2163
|
+
}
|
|
2164
|
+
[FLUSHCHUNK](chunk) {
|
|
2165
|
+
return this.emit("data", chunk), this[FLOWING];
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Pipe all data emitted by this stream into the destination provided.
|
|
2169
|
+
*
|
|
2170
|
+
* Triggers the flow of data.
|
|
2171
|
+
*/
|
|
2172
|
+
pipe(dest, opts) {
|
|
2173
|
+
if (this[DESTROYED])
|
|
2174
|
+
return dest;
|
|
2175
|
+
this[DISCARDED] = !1;
|
|
2176
|
+
let ended = this[EMITTED_END];
|
|
2177
|
+
return opts = opts || {}, dest === proc.stdout || dest === proc.stderr ? opts.end = !1 : opts.end = opts.end !== !1, opts.proxyErrors = !!opts.proxyErrors, ended ? opts.end && dest.end() : (this[PIPES].push(opts.proxyErrors ? new PipeProxyErrors(this, dest, opts) : new Pipe(this, dest, opts)), this[ASYNC] ? defer(() => this[RESUME]()) : this[RESUME]()), dest;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Fully unhook a piped destination stream.
|
|
2181
|
+
*
|
|
2182
|
+
* If the destination stream was the only consumer of this stream (ie,
|
|
2183
|
+
* there are no other piped destinations or `'data'` event listeners)
|
|
2184
|
+
* then the flow of data will stop until there is another consumer or
|
|
2185
|
+
* {@link Minipass#resume} is explicitly called.
|
|
2186
|
+
*/
|
|
2187
|
+
unpipe(dest) {
|
|
2188
|
+
let p = this[PIPES].find((p2) => p2.dest === dest);
|
|
2189
|
+
p && (this[PIPES].length === 1 ? (this[FLOWING] && this[DATALISTENERS] === 0 && (this[FLOWING] = !1), this[PIPES] = []) : this[PIPES].splice(this[PIPES].indexOf(p), 1), p.unpipe());
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Alias for {@link Minipass#on}
|
|
2193
|
+
*/
|
|
2194
|
+
addListener(ev, handler) {
|
|
2195
|
+
return this.on(ev, handler);
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Mostly identical to `EventEmitter.on`, with the following
|
|
2199
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
2200
|
+
*
|
|
2201
|
+
* - Adding a 'data' event handler will trigger the flow of data
|
|
2202
|
+
*
|
|
2203
|
+
* - Adding a 'readable' event handler when there is data waiting to be read
|
|
2204
|
+
* will cause 'readable' to be emitted immediately.
|
|
2205
|
+
*
|
|
2206
|
+
* - Adding an 'endish' event handler ('end', 'finish', etc.) which has
|
|
2207
|
+
* already passed will cause the event to be emitted immediately and all
|
|
2208
|
+
* handlers removed.
|
|
2209
|
+
*
|
|
2210
|
+
* - Adding an 'error' event handler after an error has been emitted will
|
|
2211
|
+
* cause the event to be re-emitted immediately with the error previously
|
|
2212
|
+
* raised.
|
|
2213
|
+
*/
|
|
2214
|
+
on(ev, handler) {
|
|
2215
|
+
let ret = super.on(ev, handler);
|
|
2216
|
+
if (ev === "data")
|
|
2217
|
+
this[DISCARDED] = !1, this[DATALISTENERS]++, !this[PIPES].length && !this[FLOWING] && this[RESUME]();
|
|
2218
|
+
else if (ev === "readable" && this[BUFFERLENGTH] !== 0)
|
|
2219
|
+
super.emit("readable");
|
|
2220
|
+
else if (isEndish(ev) && this[EMITTED_END])
|
|
2221
|
+
super.emit(ev), this.removeAllListeners(ev);
|
|
2222
|
+
else if (ev === "error" && this[EMITTED_ERROR]) {
|
|
2223
|
+
let h = handler;
|
|
2224
|
+
this[ASYNC] ? defer(() => h.call(this, this[EMITTED_ERROR])) : h.call(this, this[EMITTED_ERROR]);
|
|
2225
|
+
}
|
|
2226
|
+
return ret;
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Alias for {@link Minipass#off}
|
|
2230
|
+
*/
|
|
2231
|
+
removeListener(ev, handler) {
|
|
2232
|
+
return this.off(ev, handler);
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Mostly identical to `EventEmitter.off`
|
|
2236
|
+
*
|
|
2237
|
+
* If a 'data' event handler is removed, and it was the last consumer
|
|
2238
|
+
* (ie, there are no pipe destinations or other 'data' event listeners),
|
|
2239
|
+
* then the flow of data will stop until there is another consumer or
|
|
2240
|
+
* {@link Minipass#resume} is explicitly called.
|
|
2241
|
+
*/
|
|
2242
|
+
off(ev, handler) {
|
|
2243
|
+
let ret = super.off(ev, handler);
|
|
2244
|
+
return ev === "data" && (this[DATALISTENERS] = this.listeners("data").length, this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length && (this[FLOWING] = !1)), ret;
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Mostly identical to `EventEmitter.removeAllListeners`
|
|
2248
|
+
*
|
|
2249
|
+
* If all 'data' event handlers are removed, and they were the last consumer
|
|
2250
|
+
* (ie, there are no pipe destinations), then the flow of data will stop
|
|
2251
|
+
* until there is another consumer or {@link Minipass#resume} is explicitly
|
|
2252
|
+
* called.
|
|
2253
|
+
*/
|
|
2254
|
+
removeAllListeners(ev) {
|
|
2255
|
+
let ret = super.removeAllListeners(ev);
|
|
2256
|
+
return (ev === "data" || ev === void 0) && (this[DATALISTENERS] = 0, !this[DISCARDED] && !this[PIPES].length && (this[FLOWING] = !1)), ret;
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* true if the 'end' event has been emitted
|
|
2260
|
+
*/
|
|
2261
|
+
get emittedEnd() {
|
|
2262
|
+
return this[EMITTED_END];
|
|
2263
|
+
}
|
|
2264
|
+
[MAYBE_EMIT_END]() {
|
|
2265
|
+
!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF] && (this[EMITTING_END] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[CLOSED] && this.emit("close"), this[EMITTING_END] = !1);
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Mostly identical to `EventEmitter.emit`, with the following
|
|
2269
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
2270
|
+
*
|
|
2271
|
+
* If the stream has been destroyed, and the event is something other
|
|
2272
|
+
* than 'close' or 'error', then `false` is returned and no handlers
|
|
2273
|
+
* are called.
|
|
2274
|
+
*
|
|
2275
|
+
* If the event is 'end', and has already been emitted, then the event
|
|
2276
|
+
* is ignored. If the stream is in a paused or non-flowing state, then
|
|
2277
|
+
* the event will be deferred until data flow resumes. If the stream is
|
|
2278
|
+
* async, then handlers will be called on the next tick rather than
|
|
2279
|
+
* immediately.
|
|
2280
|
+
*
|
|
2281
|
+
* If the event is 'close', and 'end' has not yet been emitted, then
|
|
2282
|
+
* the event will be deferred until after 'end' is emitted.
|
|
2283
|
+
*
|
|
2284
|
+
* If the event is 'error', and an AbortSignal was provided for the stream,
|
|
2285
|
+
* and there are no listeners, then the event is ignored, matching the
|
|
2286
|
+
* behavior of node core streams in the presense of an AbortSignal.
|
|
2287
|
+
*
|
|
2288
|
+
* If the event is 'finish' or 'prefinish', then all listeners will be
|
|
2289
|
+
* removed after emitting the event, to prevent double-firing.
|
|
2290
|
+
*/
|
|
2291
|
+
emit(ev, ...args) {
|
|
2292
|
+
let data = args[0];
|
|
2293
|
+
if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED])
|
|
2294
|
+
return !1;
|
|
2295
|
+
if (ev === "data")
|
|
2296
|
+
return !this[OBJECTMODE] && !data ? !1 : this[ASYNC] ? (defer(() => this[EMITDATA](data)), !0) : this[EMITDATA](data);
|
|
2297
|
+
if (ev === "end")
|
|
2298
|
+
return this[EMITEND]();
|
|
2299
|
+
if (ev === "close") {
|
|
2300
|
+
if (this[CLOSED] = !0, !this[EMITTED_END] && !this[DESTROYED])
|
|
2301
|
+
return !1;
|
|
2302
|
+
let ret2 = super.emit("close");
|
|
2303
|
+
return this.removeAllListeners("close"), ret2;
|
|
2304
|
+
} else if (ev === "error") {
|
|
2305
|
+
this[EMITTED_ERROR] = data, super.emit(ERROR, data);
|
|
2306
|
+
let ret2 = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : !1;
|
|
2307
|
+
return this[MAYBE_EMIT_END](), ret2;
|
|
2308
|
+
} else if (ev === "resume") {
|
|
2309
|
+
let ret2 = super.emit("resume");
|
|
2310
|
+
return this[MAYBE_EMIT_END](), ret2;
|
|
2311
|
+
} else if (ev === "finish" || ev === "prefinish") {
|
|
2312
|
+
let ret2 = super.emit(ev);
|
|
2313
|
+
return this.removeAllListeners(ev), ret2;
|
|
2314
|
+
}
|
|
2315
|
+
let ret = super.emit(ev, ...args);
|
|
2316
|
+
return this[MAYBE_EMIT_END](), ret;
|
|
2317
|
+
}
|
|
2318
|
+
[EMITDATA](data) {
|
|
2319
|
+
for (let p of this[PIPES])
|
|
2320
|
+
p.dest.write(data) === !1 && this.pause();
|
|
2321
|
+
let ret = this[DISCARDED] ? !1 : super.emit("data", data);
|
|
2322
|
+
return this[MAYBE_EMIT_END](), ret;
|
|
2323
|
+
}
|
|
2324
|
+
[EMITEND]() {
|
|
2325
|
+
return this[EMITTED_END] ? !1 : (this[EMITTED_END] = !0, this.readable = !1, this[ASYNC] ? (defer(() => this[EMITEND2]()), !0) : this[EMITEND2]());
|
|
2326
|
+
}
|
|
2327
|
+
[EMITEND2]() {
|
|
2328
|
+
if (this[DECODER]) {
|
|
2329
|
+
let data = this[DECODER].end();
|
|
2330
|
+
if (data) {
|
|
2331
|
+
for (let p of this[PIPES])
|
|
2332
|
+
p.dest.write(data);
|
|
2333
|
+
this[DISCARDED] || super.emit("data", data);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
for (let p of this[PIPES])
|
|
2337
|
+
p.end();
|
|
2338
|
+
let ret = super.emit("end");
|
|
2339
|
+
return this.removeAllListeners("end"), ret;
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Return a Promise that resolves to an array of all emitted data once
|
|
2343
|
+
* the stream ends.
|
|
2344
|
+
*/
|
|
2345
|
+
async collect() {
|
|
2346
|
+
let buf = Object.assign([], {
|
|
2347
|
+
dataLength: 0
|
|
2348
|
+
});
|
|
2349
|
+
this[OBJECTMODE] || (buf.dataLength = 0);
|
|
2350
|
+
let p = this.promise();
|
|
2351
|
+
return this.on("data", (c) => {
|
|
2352
|
+
buf.push(c), this[OBJECTMODE] || (buf.dataLength += c.length);
|
|
2353
|
+
}), await p, buf;
|
|
2354
|
+
}
|
|
2355
|
+
/**
|
|
2356
|
+
* Return a Promise that resolves to the concatenation of all emitted data
|
|
2357
|
+
* once the stream ends.
|
|
2358
|
+
*
|
|
2359
|
+
* Not allowed on objectMode streams.
|
|
2360
|
+
*/
|
|
2361
|
+
async concat() {
|
|
2362
|
+
if (this[OBJECTMODE])
|
|
2363
|
+
throw new Error("cannot concat in objectMode");
|
|
2364
|
+
let buf = await this.collect();
|
|
2365
|
+
return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Return a void Promise that resolves once the stream ends.
|
|
2369
|
+
*/
|
|
2370
|
+
async promise() {
|
|
2371
|
+
return new Promise((resolve, reject) => {
|
|
2372
|
+
this.on(DESTROYED, () => reject(new Error("stream destroyed"))), this.on("error", (er) => reject(er)), this.on("end", () => resolve());
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Asynchronous `for await of` iteration.
|
|
2377
|
+
*
|
|
2378
|
+
* This will continue emitting all chunks until the stream terminates.
|
|
2379
|
+
*/
|
|
2380
|
+
[Symbol.asyncIterator]() {
|
|
2381
|
+
this[DISCARDED] = !1;
|
|
2382
|
+
let stopped = !1, stop = async () => (this.pause(), stopped = !0, { value: void 0, done: !0 });
|
|
2383
|
+
return {
|
|
2384
|
+
next: () => {
|
|
2385
|
+
if (stopped)
|
|
2386
|
+
return stop();
|
|
2387
|
+
let res = this.read();
|
|
2388
|
+
if (res !== null)
|
|
2389
|
+
return Promise.resolve({ done: !1, value: res });
|
|
2390
|
+
if (this[EOF])
|
|
2391
|
+
return stop();
|
|
2392
|
+
let resolve, reject, onerr = (er) => {
|
|
2393
|
+
this.off("data", ondata), this.off("end", onend), this.off(DESTROYED, ondestroy), stop(), reject(er);
|
|
2394
|
+
}, ondata = (value) => {
|
|
2395
|
+
this.off("error", onerr), this.off("end", onend), this.off(DESTROYED, ondestroy), this.pause(), resolve({ value, done: !!this[EOF] });
|
|
2396
|
+
}, onend = () => {
|
|
2397
|
+
this.off("error", onerr), this.off("data", ondata), this.off(DESTROYED, ondestroy), stop(), resolve({ done: !0, value: void 0 });
|
|
2398
|
+
}, ondestroy = () => onerr(new Error("stream destroyed"));
|
|
2399
|
+
return new Promise((res2, rej) => {
|
|
2400
|
+
reject = rej, resolve = res2, this.once(DESTROYED, ondestroy), this.once("error", onerr), this.once("end", onend), this.once("data", ondata);
|
|
2401
|
+
});
|
|
2402
|
+
},
|
|
2403
|
+
throw: stop,
|
|
2404
|
+
return: stop,
|
|
2405
|
+
[Symbol.asyncIterator]() {
|
|
2406
|
+
return this;
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Synchronous `for of` iteration.
|
|
2412
|
+
*
|
|
2413
|
+
* The iteration will terminate when the internal buffer runs out, even
|
|
2414
|
+
* if the stream has not yet terminated.
|
|
2415
|
+
*/
|
|
2416
|
+
[Symbol.iterator]() {
|
|
2417
|
+
this[DISCARDED] = !1;
|
|
2418
|
+
let stopped = !1, stop = () => (this.pause(), this.off(ERROR, stop), this.off(DESTROYED, stop), this.off("end", stop), stopped = !0, { done: !0, value: void 0 }), next = () => {
|
|
2419
|
+
if (stopped)
|
|
2420
|
+
return stop();
|
|
2421
|
+
let value = this.read();
|
|
2422
|
+
return value === null ? stop() : { done: !1, value };
|
|
2423
|
+
};
|
|
2424
|
+
return this.once("end", stop), this.once(ERROR, stop), this.once(DESTROYED, stop), {
|
|
2425
|
+
next,
|
|
2426
|
+
throw: stop,
|
|
2427
|
+
return: stop,
|
|
2428
|
+
[Symbol.iterator]() {
|
|
2429
|
+
return this;
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Destroy a stream, preventing it from being used for any further purpose.
|
|
2435
|
+
*
|
|
2436
|
+
* If the stream has a `close()` method, then it will be called on
|
|
2437
|
+
* destruction.
|
|
2438
|
+
*
|
|
2439
|
+
* After destruction, any attempt to write data, read data, or emit most
|
|
2440
|
+
* events will be ignored.
|
|
2441
|
+
*
|
|
2442
|
+
* If an error argument is provided, then it will be emitted in an
|
|
2443
|
+
* 'error' event.
|
|
2444
|
+
*/
|
|
2445
|
+
destroy(er) {
|
|
2446
|
+
if (this[DESTROYED])
|
|
2447
|
+
return er ? this.emit("error", er) : this.emit(DESTROYED), this;
|
|
2448
|
+
this[DESTROYED] = !0, this[DISCARDED] = !0, this[BUFFER].length = 0, this[BUFFERLENGTH] = 0;
|
|
2449
|
+
let wc = this;
|
|
2450
|
+
return typeof wc.close == "function" && !this[CLOSED] && wc.close(), er ? this.emit("error", er) : this.emit(DESTROYED), this;
|
|
2451
|
+
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Alias for {@link isStream}
|
|
2454
|
+
*
|
|
2455
|
+
* Former export location, maintained for backwards compatibility.
|
|
2456
|
+
*
|
|
2457
|
+
* @deprecated
|
|
2458
|
+
*/
|
|
2459
|
+
static get isStream() {
|
|
2460
|
+
return isStream;
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2464
|
+
// ../node_modules/glob/node_modules/path-scurry/dist/esm/index.js
|
|
2465
|
+
var realpathSync = rps.native, defaultFS = {
|
|
2466
|
+
lstatSync,
|
|
2467
|
+
readdir: readdirCB,
|
|
2468
|
+
readdirSync,
|
|
2469
|
+
readlinkSync,
|
|
2470
|
+
realpathSync,
|
|
2471
|
+
promises: {
|
|
2472
|
+
lstat,
|
|
2473
|
+
readdir,
|
|
2474
|
+
readlink,
|
|
2475
|
+
realpath
|
|
2476
|
+
}
|
|
2477
|
+
}, fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ? defaultFS : {
|
|
2478
|
+
...defaultFS,
|
|
2479
|
+
...fsOption,
|
|
2480
|
+
promises: {
|
|
2481
|
+
...defaultFS.promises,
|
|
2482
|
+
...fsOption.promises || {}
|
|
2483
|
+
}
|
|
2484
|
+
}, uncDriveRegexp = /^\\\\\?\\([a-z]:)\\?$/i, uncToDrive = (rootPath) => rootPath.replace(/\//g, "\\").replace(uncDriveRegexp, "$1\\"), eitherSep = /[\\\/]/, UNKNOWN = 0, IFIFO = 1, IFCHR = 2, IFDIR = 4, IFBLK = 6, IFREG = 8, IFLNK = 10, IFSOCK = 12, IFMT = 15, IFMT_UNKNOWN = ~IFMT, READDIR_CALLED = 16, LSTAT_CALLED = 32, ENOTDIR = 64, ENOENT = 128, ENOREADLINK = 256, ENOREALPATH = 512, ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH, TYPEMASK = 1023, entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN, normalizeCache = /* @__PURE__ */ new Map(), normalize = (s) => {
|
|
2485
|
+
let c = normalizeCache.get(s);
|
|
2486
|
+
if (c)
|
|
2487
|
+
return c;
|
|
2488
|
+
let n = s.normalize("NFKD");
|
|
2489
|
+
return normalizeCache.set(s, n), n;
|
|
2490
|
+
}, normalizeNocaseCache = /* @__PURE__ */ new Map(), normalizeNocase = (s) => {
|
|
2491
|
+
let c = normalizeNocaseCache.get(s);
|
|
2492
|
+
if (c)
|
|
2493
|
+
return c;
|
|
2494
|
+
let n = normalize(s.toLowerCase());
|
|
2495
|
+
return normalizeNocaseCache.set(s, n), n;
|
|
2496
|
+
}, ResolveCache = class extends LRUCache {
|
|
2497
|
+
constructor() {
|
|
2498
|
+
super({ max: 256 });
|
|
2499
|
+
}
|
|
2500
|
+
}, ChildrenCache = class extends LRUCache {
|
|
2501
|
+
constructor(maxSize = 16 * 1024) {
|
|
2502
|
+
super({
|
|
2503
|
+
maxSize,
|
|
2504
|
+
// parent + children
|
|
2505
|
+
sizeCalculation: (a) => a.length + 1
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
}, setAsCwd = Symbol("PathScurry setAsCwd"), PathBase = class {
|
|
2509
|
+
/**
|
|
2510
|
+
* the basename of this path
|
|
2511
|
+
*
|
|
2512
|
+
* **Important**: *always* test the path name against any test string
|
|
2513
|
+
* usingthe {@link isNamed} method, and not by directly comparing this
|
|
2514
|
+
* string. Otherwise, unicode path strings that the system sees as identical
|
|
2515
|
+
* will not be properly treated as the same path, leading to incorrect
|
|
2516
|
+
* behavior and possible security issues.
|
|
2517
|
+
*/
|
|
2518
|
+
name;
|
|
2519
|
+
/**
|
|
2520
|
+
* the Path entry corresponding to the path root.
|
|
2521
|
+
*
|
|
2522
|
+
* @internal
|
|
2523
|
+
*/
|
|
2524
|
+
root;
|
|
2525
|
+
/**
|
|
2526
|
+
* All roots found within the current PathScurry family
|
|
2527
|
+
*
|
|
2528
|
+
* @internal
|
|
2529
|
+
*/
|
|
2530
|
+
roots;
|
|
2531
|
+
/**
|
|
2532
|
+
* a reference to the parent path, or undefined in the case of root entries
|
|
2533
|
+
*
|
|
2534
|
+
* @internal
|
|
2535
|
+
*/
|
|
2536
|
+
parent;
|
|
2537
|
+
/**
|
|
2538
|
+
* boolean indicating whether paths are compared case-insensitively
|
|
2539
|
+
* @internal
|
|
2540
|
+
*/
|
|
2541
|
+
nocase;
|
|
2542
|
+
/**
|
|
2543
|
+
* boolean indicating that this path is the current working directory
|
|
2544
|
+
* of the PathScurry collection that contains it.
|
|
2545
|
+
*/
|
|
2546
|
+
isCWD = !1;
|
|
2547
|
+
// potential default fs override
|
|
2548
|
+
#fs;
|
|
2549
|
+
// Stats fields
|
|
2550
|
+
#dev;
|
|
2551
|
+
get dev() {
|
|
2552
|
+
return this.#dev;
|
|
2553
|
+
}
|
|
2554
|
+
#mode;
|
|
2555
|
+
get mode() {
|
|
2556
|
+
return this.#mode;
|
|
2557
|
+
}
|
|
2558
|
+
#nlink;
|
|
2559
|
+
get nlink() {
|
|
2560
|
+
return this.#nlink;
|
|
2561
|
+
}
|
|
2562
|
+
#uid;
|
|
2563
|
+
get uid() {
|
|
2564
|
+
return this.#uid;
|
|
2565
|
+
}
|
|
2566
|
+
#gid;
|
|
2567
|
+
get gid() {
|
|
2568
|
+
return this.#gid;
|
|
2569
|
+
}
|
|
2570
|
+
#rdev;
|
|
2571
|
+
get rdev() {
|
|
2572
|
+
return this.#rdev;
|
|
2573
|
+
}
|
|
2574
|
+
#blksize;
|
|
2575
|
+
get blksize() {
|
|
2576
|
+
return this.#blksize;
|
|
2577
|
+
}
|
|
2578
|
+
#ino;
|
|
2579
|
+
get ino() {
|
|
2580
|
+
return this.#ino;
|
|
2581
|
+
}
|
|
2582
|
+
#size;
|
|
2583
|
+
get size() {
|
|
2584
|
+
return this.#size;
|
|
2585
|
+
}
|
|
2586
|
+
#blocks;
|
|
2587
|
+
get blocks() {
|
|
2588
|
+
return this.#blocks;
|
|
2589
|
+
}
|
|
2590
|
+
#atimeMs;
|
|
2591
|
+
get atimeMs() {
|
|
2592
|
+
return this.#atimeMs;
|
|
2593
|
+
}
|
|
2594
|
+
#mtimeMs;
|
|
2595
|
+
get mtimeMs() {
|
|
2596
|
+
return this.#mtimeMs;
|
|
2597
|
+
}
|
|
2598
|
+
#ctimeMs;
|
|
2599
|
+
get ctimeMs() {
|
|
2600
|
+
return this.#ctimeMs;
|
|
2601
|
+
}
|
|
2602
|
+
#birthtimeMs;
|
|
2603
|
+
get birthtimeMs() {
|
|
2604
|
+
return this.#birthtimeMs;
|
|
2605
|
+
}
|
|
2606
|
+
#atime;
|
|
2607
|
+
get atime() {
|
|
2608
|
+
return this.#atime;
|
|
2609
|
+
}
|
|
2610
|
+
#mtime;
|
|
2611
|
+
get mtime() {
|
|
2612
|
+
return this.#mtime;
|
|
2613
|
+
}
|
|
2614
|
+
#ctime;
|
|
2615
|
+
get ctime() {
|
|
2616
|
+
return this.#ctime;
|
|
2617
|
+
}
|
|
2618
|
+
#birthtime;
|
|
2619
|
+
get birthtime() {
|
|
2620
|
+
return this.#birthtime;
|
|
2621
|
+
}
|
|
2622
|
+
#matchName;
|
|
2623
|
+
#depth;
|
|
2624
|
+
#fullpath;
|
|
2625
|
+
#fullpathPosix;
|
|
2626
|
+
#relative;
|
|
2627
|
+
#relativePosix;
|
|
2628
|
+
#type;
|
|
2629
|
+
#children;
|
|
2630
|
+
#linkTarget;
|
|
2631
|
+
#realpath;
|
|
2632
|
+
/**
|
|
2633
|
+
* This property is for compatibility with the Dirent class as of
|
|
2634
|
+
* Node v20, where Dirent['parentPath'] refers to the path of the
|
|
2635
|
+
* directory that was passed to readdir. For root entries, it's the path
|
|
2636
|
+
* to the entry itself.
|
|
2637
|
+
*/
|
|
2638
|
+
get parentPath() {
|
|
2639
|
+
return (this.parent || this).fullpath();
|
|
2640
|
+
}
|
|
2641
|
+
/**
|
|
2642
|
+
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
|
|
2643
|
+
* this property refers to the *parent* path, not the path object itself.
|
|
2644
|
+
*/
|
|
2645
|
+
get path() {
|
|
2646
|
+
return this.parentPath;
|
|
2647
|
+
}
|
|
2648
|
+
/**
|
|
2649
|
+
* Do not create new Path objects directly. They should always be accessed
|
|
2650
|
+
* via the PathScurry class or other methods on the Path class.
|
|
2651
|
+
*
|
|
2652
|
+
* @internal
|
|
2653
|
+
*/
|
|
2654
|
+
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
2655
|
+
this.name = name, this.#matchName = nocase ? normalizeNocase(name) : normalize(name), this.#type = type & TYPEMASK, this.nocase = nocase, this.roots = roots, this.root = root || this, this.#children = children, this.#fullpath = opts.fullpath, this.#relative = opts.relative, this.#relativePosix = opts.relativePosix, this.parent = opts.parent, this.parent ? this.#fs = this.parent.#fs : this.#fs = fsFromOption(opts.fs);
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Returns the depth of the Path object from its root.
|
|
2659
|
+
*
|
|
2660
|
+
* For example, a path at `/foo/bar` would have a depth of 2.
|
|
2661
|
+
*/
|
|
2662
|
+
depth() {
|
|
2663
|
+
return this.#depth !== void 0 ? this.#depth : this.parent ? this.#depth = this.parent.depth() + 1 : this.#depth = 0;
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* @internal
|
|
2667
|
+
*/
|
|
2668
|
+
childrenCache() {
|
|
2669
|
+
return this.#children;
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Get the Path object referenced by the string path, resolved from this Path
|
|
2673
|
+
*/
|
|
2674
|
+
resolve(path2) {
|
|
2675
|
+
if (!path2)
|
|
2676
|
+
return this;
|
|
2677
|
+
let rootPath = this.getRootString(path2), dirParts = path2.substring(rootPath.length).split(this.splitSep);
|
|
2678
|
+
return rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
2679
|
+
}
|
|
2680
|
+
#resolveParts(dirParts) {
|
|
2681
|
+
let p = this;
|
|
2682
|
+
for (let part of dirParts)
|
|
2683
|
+
p = p.child(part);
|
|
2684
|
+
return p;
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Returns the cached children Path objects, if still available. If they
|
|
2688
|
+
* have fallen out of the cache, then returns an empty array, and resets the
|
|
2689
|
+
* READDIR_CALLED bit, so that future calls to readdir() will require an fs
|
|
2690
|
+
* lookup.
|
|
2691
|
+
*
|
|
2692
|
+
* @internal
|
|
2693
|
+
*/
|
|
2694
|
+
children() {
|
|
2695
|
+
let cached = this.#children.get(this);
|
|
2696
|
+
if (cached)
|
|
2697
|
+
return cached;
|
|
2698
|
+
let children = Object.assign([], { provisional: 0 });
|
|
2699
|
+
return this.#children.set(this, children), this.#type &= ~READDIR_CALLED, children;
|
|
2700
|
+
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Resolves a path portion and returns or creates the child Path.
|
|
2703
|
+
*
|
|
2704
|
+
* Returns `this` if pathPart is `''` or `'.'`, or `parent` if pathPart is
|
|
2705
|
+
* `'..'`.
|
|
2706
|
+
*
|
|
2707
|
+
* This should not be called directly. If `pathPart` contains any path
|
|
2708
|
+
* separators, it will lead to unsafe undefined behavior.
|
|
2709
|
+
*
|
|
2710
|
+
* Use `Path.resolve()` instead.
|
|
2711
|
+
*
|
|
2712
|
+
* @internal
|
|
2713
|
+
*/
|
|
2714
|
+
child(pathPart, opts) {
|
|
2715
|
+
if (pathPart === "" || pathPart === ".")
|
|
2716
|
+
return this;
|
|
2717
|
+
if (pathPart === "..")
|
|
2718
|
+
return this.parent || this;
|
|
2719
|
+
let children = this.children(), name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
|
|
2720
|
+
for (let p of children)
|
|
2721
|
+
if (p.#matchName === name)
|
|
2722
|
+
return p;
|
|
2723
|
+
let s = this.parent ? this.sep : "", fullpath = this.#fullpath ? this.#fullpath + s + pathPart : void 0, pchild = this.newChild(pathPart, UNKNOWN, {
|
|
2724
|
+
...opts,
|
|
2725
|
+
parent: this,
|
|
2726
|
+
fullpath
|
|
2727
|
+
});
|
|
2728
|
+
return this.canReaddir() || (pchild.#type |= ENOENT), children.push(pchild), pchild;
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* The relative path from the cwd. If it does not share an ancestor with
|
|
2732
|
+
* the cwd, then this ends up being equivalent to the fullpath()
|
|
2733
|
+
*/
|
|
2734
|
+
relative() {
|
|
2735
|
+
if (this.isCWD)
|
|
2736
|
+
return "";
|
|
2737
|
+
if (this.#relative !== void 0)
|
|
2738
|
+
return this.#relative;
|
|
2739
|
+
let name = this.name, p = this.parent;
|
|
2740
|
+
if (!p)
|
|
2741
|
+
return this.#relative = this.name;
|
|
2742
|
+
let pv = p.relative();
|
|
2743
|
+
return pv + (!pv || !p.parent ? "" : this.sep) + name;
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* The relative path from the cwd, using / as the path separator.
|
|
2747
|
+
* If it does not share an ancestor with
|
|
2748
|
+
* the cwd, then this ends up being equivalent to the fullpathPosix()
|
|
2749
|
+
* On posix systems, this is identical to relative().
|
|
2750
|
+
*/
|
|
2751
|
+
relativePosix() {
|
|
2752
|
+
if (this.sep === "/")
|
|
2753
|
+
return this.relative();
|
|
2754
|
+
if (this.isCWD)
|
|
2755
|
+
return "";
|
|
2756
|
+
if (this.#relativePosix !== void 0)
|
|
2757
|
+
return this.#relativePosix;
|
|
2758
|
+
let name = this.name, p = this.parent;
|
|
2759
|
+
if (!p)
|
|
2760
|
+
return this.#relativePosix = this.fullpathPosix();
|
|
2761
|
+
let pv = p.relativePosix();
|
|
2762
|
+
return pv + (!pv || !p.parent ? "" : "/") + name;
|
|
2763
|
+
}
|
|
2764
|
+
/**
|
|
2765
|
+
* The fully resolved path string for this Path entry
|
|
2766
|
+
*/
|
|
2767
|
+
fullpath() {
|
|
2768
|
+
if (this.#fullpath !== void 0)
|
|
2769
|
+
return this.#fullpath;
|
|
2770
|
+
let name = this.name, p = this.parent;
|
|
2771
|
+
if (!p)
|
|
2772
|
+
return this.#fullpath = this.name;
|
|
2773
|
+
let fp = p.fullpath() + (p.parent ? this.sep : "") + name;
|
|
2774
|
+
return this.#fullpath = fp;
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* On platforms other than windows, this is identical to fullpath.
|
|
2778
|
+
*
|
|
2779
|
+
* On windows, this is overridden to return the forward-slash form of the
|
|
2780
|
+
* full UNC path.
|
|
2781
|
+
*/
|
|
2782
|
+
fullpathPosix() {
|
|
2783
|
+
if (this.#fullpathPosix !== void 0)
|
|
2784
|
+
return this.#fullpathPosix;
|
|
2785
|
+
if (this.sep === "/")
|
|
2786
|
+
return this.#fullpathPosix = this.fullpath();
|
|
2787
|
+
if (!this.parent) {
|
|
2788
|
+
let p2 = this.fullpath().replace(/\\/g, "/");
|
|
2789
|
+
return /^[a-z]:\//i.test(p2) ? this.#fullpathPosix = `//?/${p2}` : this.#fullpathPosix = p2;
|
|
2790
|
+
}
|
|
2791
|
+
let p = this.parent, pfpp = p.fullpathPosix(), fpp = pfpp + (!pfpp || !p.parent ? "" : "/") + this.name;
|
|
2792
|
+
return this.#fullpathPosix = fpp;
|
|
2793
|
+
}
|
|
2794
|
+
/**
|
|
2795
|
+
* Is the Path of an unknown type?
|
|
2796
|
+
*
|
|
2797
|
+
* Note that we might know *something* about it if there has been a previous
|
|
2798
|
+
* filesystem operation, for example that it does not exist, or is not a
|
|
2799
|
+
* link, or whether it has child entries.
|
|
2800
|
+
*/
|
|
2801
|
+
isUnknown() {
|
|
2802
|
+
return (this.#type & IFMT) === UNKNOWN;
|
|
2803
|
+
}
|
|
2804
|
+
isType(type) {
|
|
2805
|
+
return this[`is${type}`]();
|
|
2806
|
+
}
|
|
2807
|
+
getType() {
|
|
2808
|
+
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : (
|
|
2809
|
+
/* c8 ignore start */
|
|
2810
|
+
this.isSocket() ? "Socket" : "Unknown"
|
|
2811
|
+
);
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
* Is the Path a regular file?
|
|
2815
|
+
*/
|
|
2816
|
+
isFile() {
|
|
2817
|
+
return (this.#type & IFMT) === IFREG;
|
|
2818
|
+
}
|
|
2819
|
+
/**
|
|
2820
|
+
* Is the Path a directory?
|
|
2821
|
+
*/
|
|
2822
|
+
isDirectory() {
|
|
2823
|
+
return (this.#type & IFMT) === IFDIR;
|
|
2824
|
+
}
|
|
2825
|
+
/**
|
|
2826
|
+
* Is the path a character device?
|
|
2827
|
+
*/
|
|
2828
|
+
isCharacterDevice() {
|
|
2829
|
+
return (this.#type & IFMT) === IFCHR;
|
|
2830
|
+
}
|
|
2831
|
+
/**
|
|
2832
|
+
* Is the path a block device?
|
|
2833
|
+
*/
|
|
2834
|
+
isBlockDevice() {
|
|
2835
|
+
return (this.#type & IFMT) === IFBLK;
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Is the path a FIFO pipe?
|
|
2839
|
+
*/
|
|
2840
|
+
isFIFO() {
|
|
2841
|
+
return (this.#type & IFMT) === IFIFO;
|
|
2842
|
+
}
|
|
2843
|
+
/**
|
|
2844
|
+
* Is the path a socket?
|
|
2845
|
+
*/
|
|
2846
|
+
isSocket() {
|
|
2847
|
+
return (this.#type & IFMT) === IFSOCK;
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Is the path a symbolic link?
|
|
2851
|
+
*/
|
|
2852
|
+
isSymbolicLink() {
|
|
2853
|
+
return (this.#type & IFLNK) === IFLNK;
|
|
2854
|
+
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Return the entry if it has been subject of a successful lstat, or
|
|
2857
|
+
* undefined otherwise.
|
|
2858
|
+
*
|
|
2859
|
+
* Does not read the filesystem, so an undefined result *could* simply
|
|
2860
|
+
* mean that we haven't called lstat on it.
|
|
2861
|
+
*/
|
|
2862
|
+
lstatCached() {
|
|
2863
|
+
return this.#type & LSTAT_CALLED ? this : void 0;
|
|
2864
|
+
}
|
|
2865
|
+
/**
|
|
2866
|
+
* Return the cached link target if the entry has been the subject of a
|
|
2867
|
+
* successful readlink, or undefined otherwise.
|
|
2868
|
+
*
|
|
2869
|
+
* Does not read the filesystem, so an undefined result *could* just mean we
|
|
2870
|
+
* don't have any cached data. Only use it if you are very sure that a
|
|
2871
|
+
* readlink() has been called at some point.
|
|
2872
|
+
*/
|
|
2873
|
+
readlinkCached() {
|
|
2874
|
+
return this.#linkTarget;
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* Returns the cached realpath target if the entry has been the subject
|
|
2878
|
+
* of a successful realpath, or undefined otherwise.
|
|
2879
|
+
*
|
|
2880
|
+
* Does not read the filesystem, so an undefined result *could* just mean we
|
|
2881
|
+
* don't have any cached data. Only use it if you are very sure that a
|
|
2882
|
+
* realpath() has been called at some point.
|
|
2883
|
+
*/
|
|
2884
|
+
realpathCached() {
|
|
2885
|
+
return this.#realpath;
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Returns the cached child Path entries array if the entry has been the
|
|
2889
|
+
* subject of a successful readdir(), or [] otherwise.
|
|
2890
|
+
*
|
|
2891
|
+
* Does not read the filesystem, so an empty array *could* just mean we
|
|
2892
|
+
* don't have any cached data. Only use it if you are very sure that a
|
|
2893
|
+
* readdir() has been called recently enough to still be valid.
|
|
2894
|
+
*/
|
|
2895
|
+
readdirCached() {
|
|
2896
|
+
let children = this.children();
|
|
2897
|
+
return children.slice(0, children.provisional);
|
|
2898
|
+
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Return true if it's worth trying to readlink. Ie, we don't (yet) have
|
|
2901
|
+
* any indication that readlink will definitely fail.
|
|
2902
|
+
*
|
|
2903
|
+
* Returns false if the path is known to not be a symlink, if a previous
|
|
2904
|
+
* readlink failed, or if the entry does not exist.
|
|
2905
|
+
*/
|
|
2906
|
+
canReadlink() {
|
|
2907
|
+
if (this.#linkTarget)
|
|
2908
|
+
return !0;
|
|
2909
|
+
if (!this.parent)
|
|
2910
|
+
return !1;
|
|
2911
|
+
let ifmt = this.#type & IFMT;
|
|
2912
|
+
return !(ifmt !== UNKNOWN && ifmt !== IFLNK || this.#type & ENOREADLINK || this.#type & ENOENT);
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Return true if readdir has previously been successfully called on this
|
|
2916
|
+
* path, indicating that cachedReaddir() is likely valid.
|
|
2917
|
+
*/
|
|
2918
|
+
calledReaddir() {
|
|
2919
|
+
return !!(this.#type & READDIR_CALLED);
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Returns true if the path is known to not exist. That is, a previous lstat
|
|
2923
|
+
* or readdir failed to verify its existence when that would have been
|
|
2924
|
+
* expected, or a parent entry was marked either enoent or enotdir.
|
|
2925
|
+
*/
|
|
2926
|
+
isENOENT() {
|
|
2927
|
+
return !!(this.#type & ENOENT);
|
|
2928
|
+
}
|
|
2929
|
+
/**
|
|
2930
|
+
* Return true if the path is a match for the given path name. This handles
|
|
2931
|
+
* case sensitivity and unicode normalization.
|
|
2932
|
+
*
|
|
2933
|
+
* Note: even on case-sensitive systems, it is **not** safe to test the
|
|
2934
|
+
* equality of the `.name` property to determine whether a given pathname
|
|
2935
|
+
* matches, due to unicode normalization mismatches.
|
|
2936
|
+
*
|
|
2937
|
+
* Always use this method instead of testing the `path.name` property
|
|
2938
|
+
* directly.
|
|
2939
|
+
*/
|
|
2940
|
+
isNamed(n) {
|
|
2941
|
+
return this.nocase ? this.#matchName === normalizeNocase(n) : this.#matchName === normalize(n);
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Return the Path object corresponding to the target of a symbolic link.
|
|
2945
|
+
*
|
|
2946
|
+
* If the Path is not a symbolic link, or if the readlink call fails for any
|
|
2947
|
+
* reason, `undefined` is returned.
|
|
2948
|
+
*
|
|
2949
|
+
* Result is cached, and thus may be outdated if the filesystem is mutated.
|
|
2950
|
+
*/
|
|
2951
|
+
async readlink() {
|
|
2952
|
+
let target = this.#linkTarget;
|
|
2953
|
+
if (target)
|
|
2954
|
+
return target;
|
|
2955
|
+
if (this.canReadlink() && this.parent)
|
|
2956
|
+
try {
|
|
2957
|
+
let read = await this.#fs.promises.readlink(this.fullpath()), linkTarget = (await this.parent.realpath())?.resolve(read);
|
|
2958
|
+
if (linkTarget)
|
|
2959
|
+
return this.#linkTarget = linkTarget;
|
|
2960
|
+
} catch (er) {
|
|
2961
|
+
this.#readlinkFail(er.code);
|
|
2962
|
+
return;
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
/**
|
|
2966
|
+
* Synchronous {@link PathBase.readlink}
|
|
2967
|
+
*/
|
|
2968
|
+
readlinkSync() {
|
|
2969
|
+
let target = this.#linkTarget;
|
|
2970
|
+
if (target)
|
|
2971
|
+
return target;
|
|
2972
|
+
if (this.canReadlink() && this.parent)
|
|
2973
|
+
try {
|
|
2974
|
+
let read = this.#fs.readlinkSync(this.fullpath()), linkTarget = this.parent.realpathSync()?.resolve(read);
|
|
2975
|
+
if (linkTarget)
|
|
2976
|
+
return this.#linkTarget = linkTarget;
|
|
2977
|
+
} catch (er) {
|
|
2978
|
+
this.#readlinkFail(er.code);
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
#readdirSuccess(children) {
|
|
2983
|
+
this.#type |= READDIR_CALLED;
|
|
2984
|
+
for (let p = children.provisional; p < children.length; p++) {
|
|
2985
|
+
let c = children[p];
|
|
2986
|
+
c && c.#markENOENT();
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
#markENOENT() {
|
|
2990
|
+
this.#type & ENOENT || (this.#type = (this.#type | ENOENT) & IFMT_UNKNOWN, this.#markChildrenENOENT());
|
|
2991
|
+
}
|
|
2992
|
+
#markChildrenENOENT() {
|
|
2993
|
+
let children = this.children();
|
|
2994
|
+
children.provisional = 0;
|
|
2995
|
+
for (let p of children)
|
|
2996
|
+
p.#markENOENT();
|
|
2997
|
+
}
|
|
2998
|
+
#markENOREALPATH() {
|
|
2999
|
+
this.#type |= ENOREALPATH, this.#markENOTDIR();
|
|
3000
|
+
}
|
|
3001
|
+
// save the information when we know the entry is not a dir
|
|
3002
|
+
#markENOTDIR() {
|
|
3003
|
+
if (this.#type & ENOTDIR)
|
|
3004
|
+
return;
|
|
3005
|
+
let t = this.#type;
|
|
3006
|
+
(t & IFMT) === IFDIR && (t &= IFMT_UNKNOWN), this.#type = t | ENOTDIR, this.#markChildrenENOENT();
|
|
3007
|
+
}
|
|
3008
|
+
#readdirFail(code = "") {
|
|
3009
|
+
code === "ENOTDIR" || code === "EPERM" ? this.#markENOTDIR() : code === "ENOENT" ? this.#markENOENT() : this.children().provisional = 0;
|
|
3010
|
+
}
|
|
3011
|
+
#lstatFail(code = "") {
|
|
3012
|
+
code === "ENOTDIR" ? this.parent.#markENOTDIR() : code === "ENOENT" && this.#markENOENT();
|
|
3013
|
+
}
|
|
3014
|
+
#readlinkFail(code = "") {
|
|
3015
|
+
let ter = this.#type;
|
|
3016
|
+
ter |= ENOREADLINK, code === "ENOENT" && (ter |= ENOENT), (code === "EINVAL" || code === "UNKNOWN") && (ter &= IFMT_UNKNOWN), this.#type = ter, code === "ENOTDIR" && this.parent && this.parent.#markENOTDIR();
|
|
3017
|
+
}
|
|
3018
|
+
#readdirAddChild(e, c) {
|
|
3019
|
+
return this.#readdirMaybePromoteChild(e, c) || this.#readdirAddNewChild(e, c);
|
|
3020
|
+
}
|
|
3021
|
+
#readdirAddNewChild(e, c) {
|
|
3022
|
+
let type = entToType(e), child = this.newChild(e.name, type, { parent: this }), ifmt = child.#type & IFMT;
|
|
3023
|
+
return ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN && (child.#type |= ENOTDIR), c.unshift(child), c.provisional++, child;
|
|
3024
|
+
}
|
|
3025
|
+
#readdirMaybePromoteChild(e, c) {
|
|
3026
|
+
for (let p = c.provisional; p < c.length; p++) {
|
|
3027
|
+
let pchild = c[p];
|
|
3028
|
+
if ((this.nocase ? normalizeNocase(e.name) : normalize(e.name)) === pchild.#matchName)
|
|
3029
|
+
return this.#readdirPromoteChild(e, pchild, p, c);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
#readdirPromoteChild(e, p, index, c) {
|
|
3033
|
+
let v = p.name;
|
|
3034
|
+
return p.#type = p.#type & IFMT_UNKNOWN | entToType(e), v !== e.name && (p.name = e.name), index !== c.provisional && (index === c.length - 1 ? c.pop() : c.splice(index, 1), c.unshift(p)), c.provisional++, p;
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* Call lstat() on this Path, and update all known information that can be
|
|
3038
|
+
* determined.
|
|
3039
|
+
*
|
|
3040
|
+
* Note that unlike `fs.lstat()`, the returned value does not contain some
|
|
3041
|
+
* information, such as `mode`, `dev`, `nlink`, and `ino`. If that
|
|
3042
|
+
* information is required, you will need to call `fs.lstat` yourself.
|
|
3043
|
+
*
|
|
3044
|
+
* If the Path refers to a nonexistent file, or if the lstat call fails for
|
|
3045
|
+
* any reason, `undefined` is returned. Otherwise the updated Path object is
|
|
3046
|
+
* returned.
|
|
3047
|
+
*
|
|
3048
|
+
* Results are cached, and thus may be out of date if the filesystem is
|
|
3049
|
+
* mutated.
|
|
3050
|
+
*/
|
|
3051
|
+
async lstat() {
|
|
3052
|
+
if ((this.#type & ENOENT) === 0)
|
|
3053
|
+
try {
|
|
3054
|
+
return this.#applyStat(await this.#fs.promises.lstat(this.fullpath())), this;
|
|
3055
|
+
} catch (er) {
|
|
3056
|
+
this.#lstatFail(er.code);
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
/**
|
|
3060
|
+
* synchronous {@link PathBase.lstat}
|
|
3061
|
+
*/
|
|
3062
|
+
lstatSync() {
|
|
3063
|
+
if ((this.#type & ENOENT) === 0)
|
|
3064
|
+
try {
|
|
3065
|
+
return this.#applyStat(this.#fs.lstatSync(this.fullpath())), this;
|
|
3066
|
+
} catch (er) {
|
|
3067
|
+
this.#lstatFail(er.code);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
#applyStat(st) {
|
|
3071
|
+
let { atime, atimeMs, birthtime, birthtimeMs, blksize, blocks, ctime, ctimeMs, dev, gid, ino, mode, mtime, mtimeMs, nlink, rdev, size, uid } = st;
|
|
3072
|
+
this.#atime = atime, this.#atimeMs = atimeMs, this.#birthtime = birthtime, this.#birthtimeMs = birthtimeMs, this.#blksize = blksize, this.#blocks = blocks, this.#ctime = ctime, this.#ctimeMs = ctimeMs, this.#dev = dev, this.#gid = gid, this.#ino = ino, this.#mode = mode, this.#mtime = mtime, this.#mtimeMs = mtimeMs, this.#nlink = nlink, this.#rdev = rdev, this.#size = size, this.#uid = uid;
|
|
3073
|
+
let ifmt = entToType(st);
|
|
3074
|
+
this.#type = this.#type & IFMT_UNKNOWN | ifmt | LSTAT_CALLED, ifmt !== UNKNOWN && ifmt !== IFDIR && ifmt !== IFLNK && (this.#type |= ENOTDIR);
|
|
3075
|
+
}
|
|
3076
|
+
#onReaddirCB = [];
|
|
3077
|
+
#readdirCBInFlight = !1;
|
|
3078
|
+
#callOnReaddirCB(children) {
|
|
3079
|
+
this.#readdirCBInFlight = !1;
|
|
3080
|
+
let cbs = this.#onReaddirCB.slice();
|
|
3081
|
+
this.#onReaddirCB.length = 0, cbs.forEach((cb) => cb(null, children));
|
|
3082
|
+
}
|
|
3083
|
+
/**
|
|
3084
|
+
* Standard node-style callback interface to get list of directory entries.
|
|
3085
|
+
*
|
|
3086
|
+
* If the Path cannot or does not contain any children, then an empty array
|
|
3087
|
+
* is returned.
|
|
3088
|
+
*
|
|
3089
|
+
* Results are cached, and thus may be out of date if the filesystem is
|
|
3090
|
+
* mutated.
|
|
3091
|
+
*
|
|
3092
|
+
* @param cb The callback called with (er, entries). Note that the `er`
|
|
3093
|
+
* param is somewhat extraneous, as all readdir() errors are handled and
|
|
3094
|
+
* simply result in an empty set of entries being returned.
|
|
3095
|
+
* @param allowZalgo Boolean indicating that immediately known results should
|
|
3096
|
+
* *not* be deferred with `queueMicrotask`. Defaults to `false`. Release
|
|
3097
|
+
* zalgo at your peril, the dark pony lord is devious and unforgiving.
|
|
3098
|
+
*/
|
|
3099
|
+
readdirCB(cb, allowZalgo = !1) {
|
|
3100
|
+
if (!this.canReaddir()) {
|
|
3101
|
+
allowZalgo ? cb(null, []) : queueMicrotask(() => cb(null, []));
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
let children = this.children();
|
|
3105
|
+
if (this.calledReaddir()) {
|
|
3106
|
+
let c = children.slice(0, children.provisional);
|
|
3107
|
+
allowZalgo ? cb(null, c) : queueMicrotask(() => cb(null, c));
|
|
3108
|
+
return;
|
|
3109
|
+
}
|
|
3110
|
+
if (this.#onReaddirCB.push(cb), this.#readdirCBInFlight)
|
|
3111
|
+
return;
|
|
3112
|
+
this.#readdirCBInFlight = !0;
|
|
3113
|
+
let fullpath = this.fullpath();
|
|
3114
|
+
this.#fs.readdir(fullpath, { withFileTypes: !0 }, (er, entries) => {
|
|
3115
|
+
if (er)
|
|
3116
|
+
this.#readdirFail(er.code), children.provisional = 0;
|
|
3117
|
+
else {
|
|
3118
|
+
for (let e of entries)
|
|
3119
|
+
this.#readdirAddChild(e, children);
|
|
3120
|
+
this.#readdirSuccess(children);
|
|
3121
|
+
}
|
|
3122
|
+
this.#callOnReaddirCB(children.slice(0, children.provisional));
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
#asyncReaddirInFlight;
|
|
3126
|
+
/**
|
|
3127
|
+
* Return an array of known child entries.
|
|
3128
|
+
*
|
|
3129
|
+
* If the Path cannot or does not contain any children, then an empty array
|
|
3130
|
+
* is returned.
|
|
3131
|
+
*
|
|
3132
|
+
* Results are cached, and thus may be out of date if the filesystem is
|
|
3133
|
+
* mutated.
|
|
3134
|
+
*/
|
|
3135
|
+
async readdir() {
|
|
3136
|
+
if (!this.canReaddir())
|
|
3137
|
+
return [];
|
|
3138
|
+
let children = this.children();
|
|
3139
|
+
if (this.calledReaddir())
|
|
3140
|
+
return children.slice(0, children.provisional);
|
|
3141
|
+
let fullpath = this.fullpath();
|
|
3142
|
+
if (this.#asyncReaddirInFlight)
|
|
3143
|
+
await this.#asyncReaddirInFlight;
|
|
3144
|
+
else {
|
|
3145
|
+
let resolve = () => {
|
|
3146
|
+
};
|
|
3147
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve = res);
|
|
3148
|
+
try {
|
|
3149
|
+
for (let e of await this.#fs.promises.readdir(fullpath, {
|
|
3150
|
+
withFileTypes: !0
|
|
3151
|
+
}))
|
|
3152
|
+
this.#readdirAddChild(e, children);
|
|
3153
|
+
this.#readdirSuccess(children);
|
|
3154
|
+
} catch (er) {
|
|
3155
|
+
this.#readdirFail(er.code), children.provisional = 0;
|
|
3156
|
+
}
|
|
3157
|
+
this.#asyncReaddirInFlight = void 0, resolve();
|
|
3158
|
+
}
|
|
3159
|
+
return children.slice(0, children.provisional);
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* synchronous {@link PathBase.readdir}
|
|
3163
|
+
*/
|
|
3164
|
+
readdirSync() {
|
|
3165
|
+
if (!this.canReaddir())
|
|
3166
|
+
return [];
|
|
3167
|
+
let children = this.children();
|
|
3168
|
+
if (this.calledReaddir())
|
|
3169
|
+
return children.slice(0, children.provisional);
|
|
3170
|
+
let fullpath = this.fullpath();
|
|
3171
|
+
try {
|
|
3172
|
+
for (let e of this.#fs.readdirSync(fullpath, {
|
|
3173
|
+
withFileTypes: !0
|
|
3174
|
+
}))
|
|
3175
|
+
this.#readdirAddChild(e, children);
|
|
3176
|
+
this.#readdirSuccess(children);
|
|
3177
|
+
} catch (er) {
|
|
3178
|
+
this.#readdirFail(er.code), children.provisional = 0;
|
|
3179
|
+
}
|
|
3180
|
+
return children.slice(0, children.provisional);
|
|
3181
|
+
}
|
|
3182
|
+
canReaddir() {
|
|
3183
|
+
if (this.#type & ENOCHILD)
|
|
3184
|
+
return !1;
|
|
3185
|
+
let ifmt = IFMT & this.#type;
|
|
3186
|
+
return ifmt === UNKNOWN || ifmt === IFDIR || ifmt === IFLNK;
|
|
3187
|
+
}
|
|
3188
|
+
shouldWalk(dirs, walkFilter) {
|
|
3189
|
+
return (this.#type & IFDIR) === IFDIR && !(this.#type & ENOCHILD) && !dirs.has(this) && (!walkFilter || walkFilter(this));
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* Return the Path object corresponding to path as resolved
|
|
3193
|
+
* by realpath(3).
|
|
3194
|
+
*
|
|
3195
|
+
* If the realpath call fails for any reason, `undefined` is returned.
|
|
3196
|
+
*
|
|
3197
|
+
* Result is cached, and thus may be outdated if the filesystem is mutated.
|
|
3198
|
+
* On success, returns a Path object.
|
|
3199
|
+
*/
|
|
3200
|
+
async realpath() {
|
|
3201
|
+
if (this.#realpath)
|
|
3202
|
+
return this.#realpath;
|
|
3203
|
+
if (!((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type))
|
|
3204
|
+
try {
|
|
3205
|
+
let rp = await this.#fs.promises.realpath(this.fullpath());
|
|
3206
|
+
return this.#realpath = this.resolve(rp);
|
|
3207
|
+
} catch {
|
|
3208
|
+
this.#markENOREALPATH();
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Synchronous {@link realpath}
|
|
3213
|
+
*/
|
|
3214
|
+
realpathSync() {
|
|
3215
|
+
if (this.#realpath)
|
|
3216
|
+
return this.#realpath;
|
|
3217
|
+
if (!((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type))
|
|
3218
|
+
try {
|
|
3219
|
+
let rp = this.#fs.realpathSync(this.fullpath());
|
|
3220
|
+
return this.#realpath = this.resolve(rp);
|
|
3221
|
+
} catch {
|
|
3222
|
+
this.#markENOREALPATH();
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Internal method to mark this Path object as the scurry cwd,
|
|
3227
|
+
* called by {@link PathScurry#chdir}
|
|
3228
|
+
*
|
|
3229
|
+
* @internal
|
|
3230
|
+
*/
|
|
3231
|
+
[setAsCwd](oldCwd) {
|
|
3232
|
+
if (oldCwd === this)
|
|
3233
|
+
return;
|
|
3234
|
+
oldCwd.isCWD = !1, this.isCWD = !0;
|
|
3235
|
+
let changed = /* @__PURE__ */ new Set([]), rp = [], p = this;
|
|
3236
|
+
for (; p && p.parent; )
|
|
3237
|
+
changed.add(p), p.#relative = rp.join(this.sep), p.#relativePosix = rp.join("/"), p = p.parent, rp.push("..");
|
|
3238
|
+
for (p = oldCwd; p && p.parent && !changed.has(p); )
|
|
3239
|
+
p.#relative = void 0, p.#relativePosix = void 0, p = p.parent;
|
|
3240
|
+
}
|
|
3241
|
+
}, PathWin32 = class _PathWin32 extends PathBase {
|
|
3242
|
+
/**
|
|
3243
|
+
* Separator for generating path strings.
|
|
3244
|
+
*/
|
|
3245
|
+
sep = "\\";
|
|
3246
|
+
/**
|
|
3247
|
+
* Separator for parsing path strings.
|
|
3248
|
+
*/
|
|
3249
|
+
splitSep = eitherSep;
|
|
3250
|
+
/**
|
|
3251
|
+
* Do not create new Path objects directly. They should always be accessed
|
|
3252
|
+
* via the PathScurry class or other methods on the Path class.
|
|
3253
|
+
*
|
|
3254
|
+
* @internal
|
|
3255
|
+
*/
|
|
3256
|
+
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
3257
|
+
super(name, type, root, roots, nocase, children, opts);
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* @internal
|
|
3261
|
+
*/
|
|
3262
|
+
newChild(name, type = UNKNOWN, opts = {}) {
|
|
3263
|
+
return new _PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
3264
|
+
}
|
|
3265
|
+
/**
|
|
3266
|
+
* @internal
|
|
3267
|
+
*/
|
|
3268
|
+
getRootString(path2) {
|
|
3269
|
+
return win32.parse(path2).root;
|
|
3270
|
+
}
|
|
3271
|
+
/**
|
|
3272
|
+
* @internal
|
|
3273
|
+
*/
|
|
3274
|
+
getRoot(rootPath) {
|
|
3275
|
+
if (rootPath = uncToDrive(rootPath.toUpperCase()), rootPath === this.root.name)
|
|
3276
|
+
return this.root;
|
|
3277
|
+
for (let [compare, root] of Object.entries(this.roots))
|
|
3278
|
+
if (this.sameRoot(rootPath, compare))
|
|
3279
|
+
return this.roots[rootPath] = root;
|
|
3280
|
+
return this.roots[rootPath] = new PathScurryWin32(rootPath, this).root;
|
|
3281
|
+
}
|
|
3282
|
+
/**
|
|
3283
|
+
* @internal
|
|
3284
|
+
*/
|
|
3285
|
+
sameRoot(rootPath, compare = this.root.name) {
|
|
3286
|
+
return rootPath = rootPath.toUpperCase().replace(/\//g, "\\").replace(uncDriveRegexp, "$1\\"), rootPath === compare;
|
|
3287
|
+
}
|
|
3288
|
+
}, PathPosix = class _PathPosix extends PathBase {
|
|
3289
|
+
/**
|
|
3290
|
+
* separator for parsing path strings
|
|
3291
|
+
*/
|
|
3292
|
+
splitSep = "/";
|
|
3293
|
+
/**
|
|
3294
|
+
* separator for generating path strings
|
|
3295
|
+
*/
|
|
3296
|
+
sep = "/";
|
|
3297
|
+
/**
|
|
3298
|
+
* Do not create new Path objects directly. They should always be accessed
|
|
3299
|
+
* via the PathScurry class or other methods on the Path class.
|
|
3300
|
+
*
|
|
3301
|
+
* @internal
|
|
3302
|
+
*/
|
|
3303
|
+
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
3304
|
+
super(name, type, root, roots, nocase, children, opts);
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* @internal
|
|
3308
|
+
*/
|
|
3309
|
+
getRootString(path2) {
|
|
3310
|
+
return path2.startsWith("/") ? "/" : "";
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* @internal
|
|
3314
|
+
*/
|
|
3315
|
+
getRoot(_rootPath) {
|
|
3316
|
+
return this.root;
|
|
3317
|
+
}
|
|
3318
|
+
/**
|
|
3319
|
+
* @internal
|
|
3320
|
+
*/
|
|
3321
|
+
newChild(name, type = UNKNOWN, opts = {}) {
|
|
3322
|
+
return new _PathPosix(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
3323
|
+
}
|
|
3324
|
+
}, PathScurryBase = class {
|
|
3325
|
+
/**
|
|
3326
|
+
* The root Path entry for the current working directory of this Scurry
|
|
3327
|
+
*/
|
|
3328
|
+
root;
|
|
3329
|
+
/**
|
|
3330
|
+
* The string path for the root of this Scurry's current working directory
|
|
3331
|
+
*/
|
|
3332
|
+
rootPath;
|
|
3333
|
+
/**
|
|
3334
|
+
* A collection of all roots encountered, referenced by rootPath
|
|
3335
|
+
*/
|
|
3336
|
+
roots;
|
|
3337
|
+
/**
|
|
3338
|
+
* The Path entry corresponding to this PathScurry's current working directory.
|
|
3339
|
+
*/
|
|
3340
|
+
cwd;
|
|
3341
|
+
#resolveCache;
|
|
3342
|
+
#resolvePosixCache;
|
|
3343
|
+
#children;
|
|
3344
|
+
/**
|
|
3345
|
+
* Perform path comparisons case-insensitively.
|
|
3346
|
+
*
|
|
3347
|
+
* Defaults true on Darwin and Windows systems, false elsewhere.
|
|
3348
|
+
*/
|
|
3349
|
+
nocase;
|
|
3350
|
+
#fs;
|
|
3351
|
+
/**
|
|
3352
|
+
* This class should not be instantiated directly.
|
|
3353
|
+
*
|
|
3354
|
+
* Use PathScurryWin32, PathScurryDarwin, PathScurryPosix, or PathScurry
|
|
3355
|
+
*
|
|
3356
|
+
* @internal
|
|
3357
|
+
*/
|
|
3358
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS } = {}) {
|
|
3359
|
+
this.#fs = fsFromOption(fs), (cwd instanceof URL || cwd.startsWith("file://")) && (cwd = fileURLToPath(cwd));
|
|
3360
|
+
let cwdPath = pathImpl.resolve(cwd);
|
|
3361
|
+
this.roots = /* @__PURE__ */ Object.create(null), this.rootPath = this.parseRootPath(cwdPath), this.#resolveCache = new ResolveCache(), this.#resolvePosixCache = new ResolveCache(), this.#children = new ChildrenCache(childrenCacheSize);
|
|
3362
|
+
let split = cwdPath.substring(this.rootPath.length).split(sep2);
|
|
3363
|
+
if (split.length === 1 && !split[0] && split.pop(), nocase === void 0)
|
|
3364
|
+
throw new TypeError("must provide nocase setting to PathScurryBase ctor");
|
|
3365
|
+
this.nocase = nocase, this.root = this.newRoot(this.#fs), this.roots[this.rootPath] = this.root;
|
|
3366
|
+
let prev = this.root, len = split.length - 1, joinSep = pathImpl.sep, abs = this.rootPath, sawFirst = !1;
|
|
3367
|
+
for (let part of split) {
|
|
3368
|
+
let l = len--;
|
|
3369
|
+
prev = prev.child(part, {
|
|
3370
|
+
relative: new Array(l).fill("..").join(joinSep),
|
|
3371
|
+
relativePosix: new Array(l).fill("..").join("/"),
|
|
3372
|
+
fullpath: abs += (sawFirst ? "" : joinSep) + part
|
|
3373
|
+
}), sawFirst = !0;
|
|
3374
|
+
}
|
|
3375
|
+
this.cwd = prev;
|
|
3376
|
+
}
|
|
3377
|
+
/**
|
|
3378
|
+
* Get the depth of a provided path, string, or the cwd
|
|
3379
|
+
*/
|
|
3380
|
+
depth(path2 = this.cwd) {
|
|
3381
|
+
return typeof path2 == "string" && (path2 = this.cwd.resolve(path2)), path2.depth();
|
|
3382
|
+
}
|
|
3383
|
+
/**
|
|
3384
|
+
* Return the cache of child entries. Exposed so subclasses can create
|
|
3385
|
+
* child Path objects in a platform-specific way.
|
|
3386
|
+
*
|
|
3387
|
+
* @internal
|
|
3388
|
+
*/
|
|
3389
|
+
childrenCache() {
|
|
3390
|
+
return this.#children;
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* Resolve one or more path strings to a resolved string
|
|
3394
|
+
*
|
|
3395
|
+
* Same interface as require('path').resolve.
|
|
3396
|
+
*
|
|
3397
|
+
* Much faster than path.resolve() when called multiple times for the same
|
|
3398
|
+
* path, because the resolved Path objects are cached. Much slower
|
|
3399
|
+
* otherwise.
|
|
3400
|
+
*/
|
|
3401
|
+
resolve(...paths) {
|
|
3402
|
+
let r = "";
|
|
3403
|
+
for (let i = paths.length - 1; i >= 0; i--) {
|
|
3404
|
+
let p = paths[i];
|
|
3405
|
+
if (!(!p || p === ".") && (r = r ? `${p}/${r}` : p, this.isAbsolute(p)))
|
|
3406
|
+
break;
|
|
3407
|
+
}
|
|
3408
|
+
let cached = this.#resolveCache.get(r);
|
|
3409
|
+
if (cached !== void 0)
|
|
3410
|
+
return cached;
|
|
3411
|
+
let result = this.cwd.resolve(r).fullpath();
|
|
3412
|
+
return this.#resolveCache.set(r, result), result;
|
|
3413
|
+
}
|
|
3414
|
+
/**
|
|
3415
|
+
* Resolve one or more path strings to a resolved string, returning
|
|
3416
|
+
* the posix path. Identical to .resolve() on posix systems, but on
|
|
3417
|
+
* windows will return a forward-slash separated UNC path.
|
|
3418
|
+
*
|
|
3419
|
+
* Same interface as require('path').resolve.
|
|
3420
|
+
*
|
|
3421
|
+
* Much faster than path.resolve() when called multiple times for the same
|
|
3422
|
+
* path, because the resolved Path objects are cached. Much slower
|
|
3423
|
+
* otherwise.
|
|
3424
|
+
*/
|
|
3425
|
+
resolvePosix(...paths) {
|
|
3426
|
+
let r = "";
|
|
3427
|
+
for (let i = paths.length - 1; i >= 0; i--) {
|
|
3428
|
+
let p = paths[i];
|
|
3429
|
+
if (!(!p || p === ".") && (r = r ? `${p}/${r}` : p, this.isAbsolute(p)))
|
|
3430
|
+
break;
|
|
3431
|
+
}
|
|
3432
|
+
let cached = this.#resolvePosixCache.get(r);
|
|
3433
|
+
if (cached !== void 0)
|
|
3434
|
+
return cached;
|
|
3435
|
+
let result = this.cwd.resolve(r).fullpathPosix();
|
|
3436
|
+
return this.#resolvePosixCache.set(r, result), result;
|
|
3437
|
+
}
|
|
3438
|
+
/**
|
|
3439
|
+
* find the relative path from the cwd to the supplied path string or entry
|
|
3440
|
+
*/
|
|
3441
|
+
relative(entry = this.cwd) {
|
|
3442
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), entry.relative();
|
|
3443
|
+
}
|
|
3444
|
+
/**
|
|
3445
|
+
* find the relative path from the cwd to the supplied path string or
|
|
3446
|
+
* entry, using / as the path delimiter, even on Windows.
|
|
3447
|
+
*/
|
|
3448
|
+
relativePosix(entry = this.cwd) {
|
|
3449
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), entry.relativePosix();
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Return the basename for the provided string or Path object
|
|
3453
|
+
*/
|
|
3454
|
+
basename(entry = this.cwd) {
|
|
3455
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), entry.name;
|
|
3456
|
+
}
|
|
3457
|
+
/**
|
|
3458
|
+
* Return the dirname for the provided string or Path object
|
|
3459
|
+
*/
|
|
3460
|
+
dirname(entry = this.cwd) {
|
|
3461
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), (entry.parent || entry).fullpath();
|
|
3462
|
+
}
|
|
3463
|
+
async readdir(entry = this.cwd, opts = {
|
|
3464
|
+
withFileTypes: !0
|
|
3465
|
+
}) {
|
|
3466
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3467
|
+
let { withFileTypes } = opts;
|
|
3468
|
+
if (entry.canReaddir()) {
|
|
3469
|
+
let p = await entry.readdir();
|
|
3470
|
+
return withFileTypes ? p : p.map((e) => e.name);
|
|
3471
|
+
} else
|
|
3472
|
+
return [];
|
|
3473
|
+
}
|
|
3474
|
+
readdirSync(entry = this.cwd, opts = {
|
|
3475
|
+
withFileTypes: !0
|
|
3476
|
+
}) {
|
|
3477
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3478
|
+
let { withFileTypes = !0 } = opts;
|
|
3479
|
+
return entry.canReaddir() ? withFileTypes ? entry.readdirSync() : entry.readdirSync().map((e) => e.name) : [];
|
|
3480
|
+
}
|
|
3481
|
+
/**
|
|
3482
|
+
* Call lstat() on the string or Path object, and update all known
|
|
3483
|
+
* information that can be determined.
|
|
3484
|
+
*
|
|
3485
|
+
* Note that unlike `fs.lstat()`, the returned value does not contain some
|
|
3486
|
+
* information, such as `mode`, `dev`, `nlink`, and `ino`. If that
|
|
3487
|
+
* information is required, you will need to call `fs.lstat` yourself.
|
|
3488
|
+
*
|
|
3489
|
+
* If the Path refers to a nonexistent file, or if the lstat call fails for
|
|
3490
|
+
* any reason, `undefined` is returned. Otherwise the updated Path object is
|
|
3491
|
+
* returned.
|
|
3492
|
+
*
|
|
3493
|
+
* Results are cached, and thus may be out of date if the filesystem is
|
|
3494
|
+
* mutated.
|
|
3495
|
+
*/
|
|
3496
|
+
async lstat(entry = this.cwd) {
|
|
3497
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), entry.lstat();
|
|
3498
|
+
}
|
|
3499
|
+
/**
|
|
3500
|
+
* synchronous {@link PathScurryBase.lstat}
|
|
3501
|
+
*/
|
|
3502
|
+
lstatSync(entry = this.cwd) {
|
|
3503
|
+
return typeof entry == "string" && (entry = this.cwd.resolve(entry)), entry.lstatSync();
|
|
3504
|
+
}
|
|
3505
|
+
async readlink(entry = this.cwd, { withFileTypes } = {
|
|
3506
|
+
withFileTypes: !1
|
|
3507
|
+
}) {
|
|
3508
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (withFileTypes = entry.withFileTypes, entry = this.cwd);
|
|
3509
|
+
let e = await entry.readlink();
|
|
3510
|
+
return withFileTypes ? e : e?.fullpath();
|
|
3511
|
+
}
|
|
3512
|
+
readlinkSync(entry = this.cwd, { withFileTypes } = {
|
|
3513
|
+
withFileTypes: !1
|
|
3514
|
+
}) {
|
|
3515
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (withFileTypes = entry.withFileTypes, entry = this.cwd);
|
|
3516
|
+
let e = entry.readlinkSync();
|
|
3517
|
+
return withFileTypes ? e : e?.fullpath();
|
|
3518
|
+
}
|
|
3519
|
+
async realpath(entry = this.cwd, { withFileTypes } = {
|
|
3520
|
+
withFileTypes: !1
|
|
3521
|
+
}) {
|
|
3522
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (withFileTypes = entry.withFileTypes, entry = this.cwd);
|
|
3523
|
+
let e = await entry.realpath();
|
|
3524
|
+
return withFileTypes ? e : e?.fullpath();
|
|
3525
|
+
}
|
|
3526
|
+
realpathSync(entry = this.cwd, { withFileTypes } = {
|
|
3527
|
+
withFileTypes: !1
|
|
3528
|
+
}) {
|
|
3529
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (withFileTypes = entry.withFileTypes, entry = this.cwd);
|
|
3530
|
+
let e = entry.realpathSync();
|
|
3531
|
+
return withFileTypes ? e : e?.fullpath();
|
|
3532
|
+
}
|
|
3533
|
+
async walk(entry = this.cwd, opts = {}) {
|
|
3534
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3535
|
+
let { withFileTypes = !0, follow = !1, filter: filter2, walkFilter } = opts, results = [];
|
|
3536
|
+
(!filter2 || filter2(entry)) && results.push(withFileTypes ? entry : entry.fullpath());
|
|
3537
|
+
let dirs = /* @__PURE__ */ new Set(), walk = (dir, cb) => {
|
|
3538
|
+
dirs.add(dir), dir.readdirCB((er, entries) => {
|
|
3539
|
+
if (er)
|
|
3540
|
+
return cb(er);
|
|
3541
|
+
let len = entries.length;
|
|
3542
|
+
if (!len)
|
|
3543
|
+
return cb();
|
|
3544
|
+
let next = () => {
|
|
3545
|
+
--len === 0 && cb();
|
|
3546
|
+
};
|
|
3547
|
+
for (let e of entries)
|
|
3548
|
+
(!filter2 || filter2(e)) && results.push(withFileTypes ? e : e.fullpath()), follow && e.isSymbolicLink() ? e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r).then((r) => r?.shouldWalk(dirs, walkFilter) ? walk(r, next) : next()) : e.shouldWalk(dirs, walkFilter) ? walk(e, next) : next();
|
|
3549
|
+
}, !0);
|
|
3550
|
+
}, start = entry;
|
|
3551
|
+
return new Promise((res, rej) => {
|
|
3552
|
+
walk(start, (er) => {
|
|
3553
|
+
if (er)
|
|
3554
|
+
return rej(er);
|
|
3555
|
+
res(results);
|
|
3556
|
+
});
|
|
3557
|
+
});
|
|
3558
|
+
}
|
|
3559
|
+
walkSync(entry = this.cwd, opts = {}) {
|
|
3560
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3561
|
+
let { withFileTypes = !0, follow = !1, filter: filter2, walkFilter } = opts, results = [];
|
|
3562
|
+
(!filter2 || filter2(entry)) && results.push(withFileTypes ? entry : entry.fullpath());
|
|
3563
|
+
let dirs = /* @__PURE__ */ new Set([entry]);
|
|
3564
|
+
for (let dir of dirs) {
|
|
3565
|
+
let entries = dir.readdirSync();
|
|
3566
|
+
for (let e of entries) {
|
|
3567
|
+
(!filter2 || filter2(e)) && results.push(withFileTypes ? e : e.fullpath());
|
|
3568
|
+
let r = e;
|
|
3569
|
+
if (e.isSymbolicLink()) {
|
|
3570
|
+
if (!(follow && (r = e.realpathSync())))
|
|
3571
|
+
continue;
|
|
3572
|
+
r.isUnknown() && r.lstatSync();
|
|
3573
|
+
}
|
|
3574
|
+
r.shouldWalk(dirs, walkFilter) && dirs.add(r);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
return results;
|
|
3578
|
+
}
|
|
3579
|
+
/**
|
|
3580
|
+
* Support for `for await`
|
|
3581
|
+
*
|
|
3582
|
+
* Alias for {@link PathScurryBase.iterate}
|
|
3583
|
+
*
|
|
3584
|
+
* Note: As of Node 19, this is very slow, compared to other methods of
|
|
3585
|
+
* walking. Consider using {@link PathScurryBase.stream} if memory overhead
|
|
3586
|
+
* and backpressure are concerns, or {@link PathScurryBase.walk} if not.
|
|
3587
|
+
*/
|
|
3588
|
+
[Symbol.asyncIterator]() {
|
|
3589
|
+
return this.iterate();
|
|
3590
|
+
}
|
|
3591
|
+
iterate(entry = this.cwd, options = {}) {
|
|
3592
|
+
return typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (options = entry, entry = this.cwd), this.stream(entry, options)[Symbol.asyncIterator]();
|
|
3593
|
+
}
|
|
3594
|
+
/**
|
|
3595
|
+
* Iterating over a PathScurry performs a synchronous walk.
|
|
3596
|
+
*
|
|
3597
|
+
* Alias for {@link PathScurryBase.iterateSync}
|
|
3598
|
+
*/
|
|
3599
|
+
[Symbol.iterator]() {
|
|
3600
|
+
return this.iterateSync();
|
|
3601
|
+
}
|
|
3602
|
+
*iterateSync(entry = this.cwd, opts = {}) {
|
|
3603
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3604
|
+
let { withFileTypes = !0, follow = !1, filter: filter2, walkFilter } = opts;
|
|
3605
|
+
(!filter2 || filter2(entry)) && (yield withFileTypes ? entry : entry.fullpath());
|
|
3606
|
+
let dirs = /* @__PURE__ */ new Set([entry]);
|
|
3607
|
+
for (let dir of dirs) {
|
|
3608
|
+
let entries = dir.readdirSync();
|
|
3609
|
+
for (let e of entries) {
|
|
3610
|
+
(!filter2 || filter2(e)) && (yield withFileTypes ? e : e.fullpath());
|
|
3611
|
+
let r = e;
|
|
3612
|
+
if (e.isSymbolicLink()) {
|
|
3613
|
+
if (!(follow && (r = e.realpathSync())))
|
|
3614
|
+
continue;
|
|
3615
|
+
r.isUnknown() && r.lstatSync();
|
|
3616
|
+
}
|
|
3617
|
+
r.shouldWalk(dirs, walkFilter) && dirs.add(r);
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
stream(entry = this.cwd, opts = {}) {
|
|
3622
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3623
|
+
let { withFileTypes = !0, follow = !1, filter: filter2, walkFilter } = opts, results = new Minipass({ objectMode: !0 });
|
|
3624
|
+
(!filter2 || filter2(entry)) && results.write(withFileTypes ? entry : entry.fullpath());
|
|
3625
|
+
let dirs = /* @__PURE__ */ new Set(), queue = [entry], processing = 0, process2 = () => {
|
|
3626
|
+
let paused = !1;
|
|
3627
|
+
for (; !paused; ) {
|
|
3628
|
+
let dir = queue.shift();
|
|
3629
|
+
if (!dir) {
|
|
3630
|
+
processing === 0 && results.end();
|
|
3631
|
+
return;
|
|
3632
|
+
}
|
|
3633
|
+
processing++, dirs.add(dir);
|
|
3634
|
+
let onReaddir = (er, entries, didRealpaths = !1) => {
|
|
3635
|
+
if (er)
|
|
3636
|
+
return results.emit("error", er);
|
|
3637
|
+
if (follow && !didRealpaths) {
|
|
3638
|
+
let promises = [];
|
|
3639
|
+
for (let e of entries)
|
|
3640
|
+
e.isSymbolicLink() && promises.push(e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r));
|
|
3641
|
+
if (promises.length) {
|
|
3642
|
+
Promise.all(promises).then(() => onReaddir(null, entries, !0));
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
for (let e of entries)
|
|
3647
|
+
e && (!filter2 || filter2(e)) && (results.write(withFileTypes ? e : e.fullpath()) || (paused = !0));
|
|
3648
|
+
processing--;
|
|
3649
|
+
for (let e of entries) {
|
|
3650
|
+
let r = e.realpathCached() || e;
|
|
3651
|
+
r.shouldWalk(dirs, walkFilter) && queue.push(r);
|
|
3652
|
+
}
|
|
3653
|
+
paused && !results.flowing ? results.once("drain", process2) : sync2 || process2();
|
|
3654
|
+
}, sync2 = !0;
|
|
3655
|
+
dir.readdirCB(onReaddir, !0), sync2 = !1;
|
|
3656
|
+
}
|
|
3657
|
+
};
|
|
3658
|
+
return process2(), results;
|
|
3659
|
+
}
|
|
3660
|
+
streamSync(entry = this.cwd, opts = {}) {
|
|
3661
|
+
typeof entry == "string" ? entry = this.cwd.resolve(entry) : entry instanceof PathBase || (opts = entry, entry = this.cwd);
|
|
3662
|
+
let { withFileTypes = !0, follow = !1, filter: filter2, walkFilter } = opts, results = new Minipass({ objectMode: !0 }), dirs = /* @__PURE__ */ new Set();
|
|
3663
|
+
(!filter2 || filter2(entry)) && results.write(withFileTypes ? entry : entry.fullpath());
|
|
3664
|
+
let queue = [entry], processing = 0, process2 = () => {
|
|
3665
|
+
let paused = !1;
|
|
3666
|
+
for (; !paused; ) {
|
|
3667
|
+
let dir = queue.shift();
|
|
3668
|
+
if (!dir) {
|
|
3669
|
+
processing === 0 && results.end();
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
processing++, dirs.add(dir);
|
|
3673
|
+
let entries = dir.readdirSync();
|
|
3674
|
+
for (let e of entries)
|
|
3675
|
+
(!filter2 || filter2(e)) && (results.write(withFileTypes ? e : e.fullpath()) || (paused = !0));
|
|
3676
|
+
processing--;
|
|
3677
|
+
for (let e of entries) {
|
|
3678
|
+
let r = e;
|
|
3679
|
+
if (e.isSymbolicLink()) {
|
|
3680
|
+
if (!(follow && (r = e.realpathSync())))
|
|
3681
|
+
continue;
|
|
3682
|
+
r.isUnknown() && r.lstatSync();
|
|
3683
|
+
}
|
|
3684
|
+
r.shouldWalk(dirs, walkFilter) && queue.push(r);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
paused && !results.flowing && results.once("drain", process2);
|
|
3688
|
+
};
|
|
3689
|
+
return process2(), results;
|
|
3690
|
+
}
|
|
3691
|
+
chdir(path2 = this.cwd) {
|
|
3692
|
+
let oldCwd = this.cwd;
|
|
3693
|
+
this.cwd = typeof path2 == "string" ? this.cwd.resolve(path2) : path2, this.cwd[setAsCwd](oldCwd);
|
|
3694
|
+
}
|
|
3695
|
+
}, PathScurryWin32 = class extends PathScurryBase {
|
|
3696
|
+
/**
|
|
3697
|
+
* separator for generating path strings
|
|
3698
|
+
*/
|
|
3699
|
+
sep = "\\";
|
|
3700
|
+
constructor(cwd = process.cwd(), opts = {}) {
|
|
3701
|
+
let { nocase = !0 } = opts;
|
|
3702
|
+
super(cwd, win32, "\\", { ...opts, nocase }), this.nocase = nocase;
|
|
3703
|
+
for (let p = this.cwd; p; p = p.parent)
|
|
3704
|
+
p.nocase = this.nocase;
|
|
3705
|
+
}
|
|
3706
|
+
/**
|
|
3707
|
+
* @internal
|
|
3708
|
+
*/
|
|
3709
|
+
parseRootPath(dir) {
|
|
3710
|
+
return win32.parse(dir).root.toUpperCase();
|
|
3711
|
+
}
|
|
3712
|
+
/**
|
|
3713
|
+
* @internal
|
|
3714
|
+
*/
|
|
3715
|
+
newRoot(fs) {
|
|
3716
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
|
|
3717
|
+
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Return true if the provided path string is an absolute path
|
|
3720
|
+
*/
|
|
3721
|
+
isAbsolute(p) {
|
|
3722
|
+
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
3723
|
+
}
|
|
3724
|
+
}, PathScurryPosix = class extends PathScurryBase {
|
|
3725
|
+
/**
|
|
3726
|
+
* separator for generating path strings
|
|
3727
|
+
*/
|
|
3728
|
+
sep = "/";
|
|
3729
|
+
constructor(cwd = process.cwd(), opts = {}) {
|
|
3730
|
+
let { nocase = !1 } = opts;
|
|
3731
|
+
super(cwd, posix, "/", { ...opts, nocase }), this.nocase = nocase;
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* @internal
|
|
3735
|
+
*/
|
|
3736
|
+
parseRootPath(_dir) {
|
|
3737
|
+
return "/";
|
|
3738
|
+
}
|
|
3739
|
+
/**
|
|
3740
|
+
* @internal
|
|
3741
|
+
*/
|
|
3742
|
+
newRoot(fs) {
|
|
3743
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
|
|
3744
|
+
}
|
|
3745
|
+
/**
|
|
3746
|
+
* Return true if the provided path string is an absolute path
|
|
3747
|
+
*/
|
|
3748
|
+
isAbsolute(p) {
|
|
3749
|
+
return p.startsWith("/");
|
|
3750
|
+
}
|
|
3751
|
+
}, PathScurryDarwin = class extends PathScurryPosix {
|
|
3752
|
+
constructor(cwd = process.cwd(), opts = {}) {
|
|
3753
|
+
let { nocase = !0 } = opts;
|
|
3754
|
+
super(cwd, { ...opts, nocase });
|
|
3755
|
+
}
|
|
3756
|
+
}, Path = process.platform === "win32" ? PathWin32 : PathPosix, PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
|
|
3757
|
+
|
|
3758
|
+
// ../node_modules/glob/dist/esm/pattern.js
|
|
3759
|
+
var isPatternList = (pl) => pl.length >= 1, isGlobList = (gl) => gl.length >= 1, Pattern = class _Pattern {
|
|
3760
|
+
#patternList;
|
|
3761
|
+
#globList;
|
|
3762
|
+
#index;
|
|
3763
|
+
length;
|
|
3764
|
+
#platform;
|
|
3765
|
+
#rest;
|
|
3766
|
+
#globString;
|
|
3767
|
+
#isDrive;
|
|
3768
|
+
#isUNC;
|
|
3769
|
+
#isAbsolute;
|
|
3770
|
+
#followGlobstar = !0;
|
|
3771
|
+
constructor(patternList, globList, index, platform) {
|
|
3772
|
+
if (!isPatternList(patternList))
|
|
3773
|
+
throw new TypeError("empty pattern list");
|
|
3774
|
+
if (!isGlobList(globList))
|
|
3775
|
+
throw new TypeError("empty glob list");
|
|
3776
|
+
if (globList.length !== patternList.length)
|
|
3777
|
+
throw new TypeError("mismatched pattern list and glob list lengths");
|
|
3778
|
+
if (this.length = patternList.length, index < 0 || index >= this.length)
|
|
3779
|
+
throw new TypeError("index out of range");
|
|
3780
|
+
if (this.#patternList = patternList, this.#globList = globList, this.#index = index, this.#platform = platform, this.#index === 0) {
|
|
3781
|
+
if (this.isUNC()) {
|
|
3782
|
+
let [p0, p1, p2, p3, ...prest] = this.#patternList, [g0, g1, g2, g3, ...grest] = this.#globList;
|
|
3783
|
+
prest[0] === "" && (prest.shift(), grest.shift());
|
|
3784
|
+
let p = [p0, p1, p2, p3, ""].join("/"), g = [g0, g1, g2, g3, ""].join("/");
|
|
3785
|
+
this.#patternList = [p, ...prest], this.#globList = [g, ...grest], this.length = this.#patternList.length;
|
|
3786
|
+
} else if (this.isDrive() || this.isAbsolute()) {
|
|
3787
|
+
let [p1, ...prest] = this.#patternList, [g1, ...grest] = this.#globList;
|
|
3788
|
+
prest[0] === "" && (prest.shift(), grest.shift());
|
|
3789
|
+
let p = p1 + "/", g = g1 + "/";
|
|
3790
|
+
this.#patternList = [p, ...prest], this.#globList = [g, ...grest], this.length = this.#patternList.length;
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
/**
|
|
3795
|
+
* The first entry in the parsed list of patterns
|
|
3796
|
+
*/
|
|
3797
|
+
pattern() {
|
|
3798
|
+
return this.#patternList[this.#index];
|
|
3799
|
+
}
|
|
3800
|
+
/**
|
|
3801
|
+
* true of if pattern() returns a string
|
|
3802
|
+
*/
|
|
3803
|
+
isString() {
|
|
3804
|
+
return typeof this.#patternList[this.#index] == "string";
|
|
3805
|
+
}
|
|
3806
|
+
/**
|
|
3807
|
+
* true of if pattern() returns GLOBSTAR
|
|
3808
|
+
*/
|
|
3809
|
+
isGlobstar() {
|
|
3810
|
+
return this.#patternList[this.#index] === GLOBSTAR;
|
|
3811
|
+
}
|
|
3812
|
+
/**
|
|
3813
|
+
* true if pattern() returns a regexp
|
|
3814
|
+
*/
|
|
3815
|
+
isRegExp() {
|
|
3816
|
+
return this.#patternList[this.#index] instanceof RegExp;
|
|
3817
|
+
}
|
|
3818
|
+
/**
|
|
3819
|
+
* The /-joined set of glob parts that make up this pattern
|
|
3820
|
+
*/
|
|
3821
|
+
globString() {
|
|
3822
|
+
return this.#globString = this.#globString || (this.#index === 0 ? this.isAbsolute() ? this.#globList[0] + this.#globList.slice(1).join("/") : this.#globList.join("/") : this.#globList.slice(this.#index).join("/"));
|
|
3823
|
+
}
|
|
3824
|
+
/**
|
|
3825
|
+
* true if there are more pattern parts after this one
|
|
3826
|
+
*/
|
|
3827
|
+
hasMore() {
|
|
3828
|
+
return this.length > this.#index + 1;
|
|
3829
|
+
}
|
|
3830
|
+
/**
|
|
3831
|
+
* The rest of the pattern after this part, or null if this is the end
|
|
3832
|
+
*/
|
|
3833
|
+
rest() {
|
|
3834
|
+
return this.#rest !== void 0 ? this.#rest : this.hasMore() ? (this.#rest = new _Pattern(this.#patternList, this.#globList, this.#index + 1, this.#platform), this.#rest.#isAbsolute = this.#isAbsolute, this.#rest.#isUNC = this.#isUNC, this.#rest.#isDrive = this.#isDrive, this.#rest) : this.#rest = null;
|
|
3835
|
+
}
|
|
3836
|
+
/**
|
|
3837
|
+
* true if the pattern represents a //unc/path/ on windows
|
|
3838
|
+
*/
|
|
3839
|
+
isUNC() {
|
|
3840
|
+
let pl = this.#patternList;
|
|
3841
|
+
return this.#isUNC !== void 0 ? this.#isUNC : this.#isUNC = this.#platform === "win32" && this.#index === 0 && pl[0] === "" && pl[1] === "" && typeof pl[2] == "string" && !!pl[2] && typeof pl[3] == "string" && !!pl[3];
|
|
3842
|
+
}
|
|
3843
|
+
// pattern like C:/...
|
|
3844
|
+
// split = ['C:', ...]
|
|
3845
|
+
// XXX: would be nice to handle patterns like `c:*` to test the cwd
|
|
3846
|
+
// in c: for *, but I don't know of a way to even figure out what that
|
|
3847
|
+
// cwd is without actually chdir'ing into it?
|
|
3848
|
+
/**
|
|
3849
|
+
* True if the pattern starts with a drive letter on Windows
|
|
3850
|
+
*/
|
|
3851
|
+
isDrive() {
|
|
3852
|
+
let pl = this.#patternList;
|
|
3853
|
+
return this.#isDrive !== void 0 ? this.#isDrive : this.#isDrive = this.#platform === "win32" && this.#index === 0 && this.length > 1 && typeof pl[0] == "string" && /^[a-z]:$/i.test(pl[0]);
|
|
3854
|
+
}
|
|
3855
|
+
// pattern = '/' or '/...' or '/x/...'
|
|
3856
|
+
// split = ['', ''] or ['', ...] or ['', 'x', ...]
|
|
3857
|
+
// Drive and UNC both considered absolute on windows
|
|
3858
|
+
/**
|
|
3859
|
+
* True if the pattern is rooted on an absolute path
|
|
3860
|
+
*/
|
|
3861
|
+
isAbsolute() {
|
|
3862
|
+
let pl = this.#patternList;
|
|
3863
|
+
return this.#isAbsolute !== void 0 ? this.#isAbsolute : this.#isAbsolute = pl[0] === "" && pl.length > 1 || this.isDrive() || this.isUNC();
|
|
3864
|
+
}
|
|
3865
|
+
/**
|
|
3866
|
+
* consume the root of the pattern, and return it
|
|
3867
|
+
*/
|
|
3868
|
+
root() {
|
|
3869
|
+
let p = this.#patternList[0];
|
|
3870
|
+
return typeof p == "string" && this.isAbsolute() && this.#index === 0 ? p : "";
|
|
3871
|
+
}
|
|
3872
|
+
/**
|
|
3873
|
+
* Check to see if the current globstar pattern is allowed to follow
|
|
3874
|
+
* a symbolic link.
|
|
3875
|
+
*/
|
|
3876
|
+
checkFollowGlobstar() {
|
|
3877
|
+
return !(this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar);
|
|
3878
|
+
}
|
|
3879
|
+
/**
|
|
3880
|
+
* Mark that the current globstar pattern is following a symbolic link
|
|
3881
|
+
*/
|
|
3882
|
+
markFollowGlobstar() {
|
|
3883
|
+
return this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar ? !1 : (this.#followGlobstar = !1, !0);
|
|
3884
|
+
}
|
|
3885
|
+
};
|
|
3886
|
+
|
|
3887
|
+
// ../node_modules/glob/dist/esm/ignore.js
|
|
3888
|
+
var defaultPlatform2 = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", Ignore = class {
|
|
3889
|
+
relative;
|
|
3890
|
+
relativeChildren;
|
|
3891
|
+
absolute;
|
|
3892
|
+
absoluteChildren;
|
|
3893
|
+
platform;
|
|
3894
|
+
mmopts;
|
|
3895
|
+
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform2 }) {
|
|
3896
|
+
this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = platform, this.mmopts = {
|
|
3897
|
+
dot: !0,
|
|
3898
|
+
nobrace,
|
|
3899
|
+
nocase,
|
|
3900
|
+
noext,
|
|
3901
|
+
noglobstar,
|
|
3902
|
+
optimizationLevel: 2,
|
|
3903
|
+
platform,
|
|
3904
|
+
nocomment: !0,
|
|
3905
|
+
nonegate: !0
|
|
3906
|
+
};
|
|
3907
|
+
for (let ign of ignored)
|
|
3908
|
+
this.add(ign);
|
|
3909
|
+
}
|
|
3910
|
+
add(ign) {
|
|
3911
|
+
let mm = new Minimatch(ign, this.mmopts);
|
|
3912
|
+
for (let i = 0; i < mm.set.length; i++) {
|
|
3913
|
+
let parsed = mm.set[i], globParts = mm.globParts[i];
|
|
3914
|
+
if (!parsed || !globParts)
|
|
3915
|
+
throw new Error("invalid pattern object");
|
|
3916
|
+
for (; parsed[0] === "." && globParts[0] === "."; )
|
|
3917
|
+
parsed.shift(), globParts.shift();
|
|
3918
|
+
let p = new Pattern(parsed, globParts, 0, this.platform), m = new Minimatch(p.globString(), this.mmopts), children = globParts[globParts.length - 1] === "**", absolute = p.isAbsolute();
|
|
3919
|
+
absolute ? this.absolute.push(m) : this.relative.push(m), children && (absolute ? this.absoluteChildren.push(m) : this.relativeChildren.push(m));
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
ignored(p) {
|
|
3923
|
+
let fullpath = p.fullpath(), fullpaths = `${fullpath}/`, relative = p.relative() || ".", relatives = `${relative}/`;
|
|
3924
|
+
for (let m of this.relative)
|
|
3925
|
+
if (m.match(relative) || m.match(relatives))
|
|
3926
|
+
return !0;
|
|
3927
|
+
for (let m of this.absolute)
|
|
3928
|
+
if (m.match(fullpath) || m.match(fullpaths))
|
|
3929
|
+
return !0;
|
|
3930
|
+
return !1;
|
|
3931
|
+
}
|
|
3932
|
+
childrenIgnored(p) {
|
|
3933
|
+
let fullpath = p.fullpath() + "/", relative = (p.relative() || ".") + "/";
|
|
3934
|
+
for (let m of this.relativeChildren)
|
|
3935
|
+
if (m.match(relative))
|
|
3936
|
+
return !0;
|
|
3937
|
+
for (let m of this.absoluteChildren)
|
|
3938
|
+
if (m.match(fullpath))
|
|
3939
|
+
return !0;
|
|
3940
|
+
return !1;
|
|
3941
|
+
}
|
|
3942
|
+
};
|
|
3943
|
+
|
|
3944
|
+
// ../node_modules/glob/dist/esm/processor.js
|
|
3945
|
+
var HasWalkedCache = class _HasWalkedCache {
|
|
3946
|
+
store;
|
|
3947
|
+
constructor(store = /* @__PURE__ */ new Map()) {
|
|
3948
|
+
this.store = store;
|
|
3949
|
+
}
|
|
3950
|
+
copy() {
|
|
3951
|
+
return new _HasWalkedCache(new Map(this.store));
|
|
3952
|
+
}
|
|
3953
|
+
hasWalked(target, pattern) {
|
|
3954
|
+
return this.store.get(target.fullpath())?.has(pattern.globString());
|
|
3955
|
+
}
|
|
3956
|
+
storeWalked(target, pattern) {
|
|
3957
|
+
let fullpath = target.fullpath(), cached = this.store.get(fullpath);
|
|
3958
|
+
cached ? cached.add(pattern.globString()) : this.store.set(fullpath, /* @__PURE__ */ new Set([pattern.globString()]));
|
|
3959
|
+
}
|
|
3960
|
+
}, MatchRecord = class {
|
|
3961
|
+
store = /* @__PURE__ */ new Map();
|
|
3962
|
+
add(target, absolute, ifDir) {
|
|
3963
|
+
let n = (absolute ? 2 : 0) | (ifDir ? 1 : 0), current = this.store.get(target);
|
|
3964
|
+
this.store.set(target, current === void 0 ? n : n & current);
|
|
3965
|
+
}
|
|
3966
|
+
// match, absolute, ifdir
|
|
3967
|
+
entries() {
|
|
3968
|
+
return [...this.store.entries()].map(([path2, n]) => [
|
|
3969
|
+
path2,
|
|
3970
|
+
!!(n & 2),
|
|
3971
|
+
!!(n & 1)
|
|
3972
|
+
]);
|
|
3973
|
+
}
|
|
3974
|
+
}, SubWalks = class {
|
|
3975
|
+
store = /* @__PURE__ */ new Map();
|
|
3976
|
+
add(target, pattern) {
|
|
3977
|
+
if (!target.canReaddir())
|
|
3978
|
+
return;
|
|
3979
|
+
let subs = this.store.get(target);
|
|
3980
|
+
subs ? subs.find((p) => p.globString() === pattern.globString()) || subs.push(pattern) : this.store.set(target, [pattern]);
|
|
3981
|
+
}
|
|
3982
|
+
get(target) {
|
|
3983
|
+
let subs = this.store.get(target);
|
|
3984
|
+
if (!subs)
|
|
3985
|
+
throw new Error("attempting to walk unknown path");
|
|
3986
|
+
return subs;
|
|
3987
|
+
}
|
|
3988
|
+
entries() {
|
|
3989
|
+
return this.keys().map((k) => [k, this.store.get(k)]);
|
|
3990
|
+
}
|
|
3991
|
+
keys() {
|
|
3992
|
+
return [...this.store.keys()].filter((t) => t.canReaddir());
|
|
3993
|
+
}
|
|
3994
|
+
}, Processor = class _Processor {
|
|
3995
|
+
hasWalkedCache;
|
|
3996
|
+
matches = new MatchRecord();
|
|
3997
|
+
subwalks = new SubWalks();
|
|
3998
|
+
patterns;
|
|
3999
|
+
follow;
|
|
4000
|
+
dot;
|
|
4001
|
+
opts;
|
|
4002
|
+
constructor(opts, hasWalkedCache) {
|
|
4003
|
+
this.opts = opts, this.follow = !!opts.follow, this.dot = !!opts.dot, this.hasWalkedCache = hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache();
|
|
4004
|
+
}
|
|
4005
|
+
processPatterns(target, patterns) {
|
|
4006
|
+
this.patterns = patterns;
|
|
4007
|
+
let processingSet = patterns.map((p) => [target, p]);
|
|
4008
|
+
for (let [t, pattern] of processingSet) {
|
|
4009
|
+
this.hasWalkedCache.storeWalked(t, pattern);
|
|
4010
|
+
let root = pattern.root(), absolute = pattern.isAbsolute() && this.opts.absolute !== !1;
|
|
4011
|
+
if (root) {
|
|
4012
|
+
t = t.resolve(root === "/" && this.opts.root !== void 0 ? this.opts.root : root);
|
|
4013
|
+
let rest2 = pattern.rest();
|
|
4014
|
+
if (rest2)
|
|
4015
|
+
pattern = rest2;
|
|
4016
|
+
else {
|
|
4017
|
+
this.matches.add(t, !0, !1);
|
|
4018
|
+
continue;
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
if (t.isENOENT())
|
|
4022
|
+
continue;
|
|
4023
|
+
let p, rest, changed = !1;
|
|
4024
|
+
for (; typeof (p = pattern.pattern()) == "string" && (rest = pattern.rest()); )
|
|
4025
|
+
t = t.resolve(p), pattern = rest, changed = !0;
|
|
4026
|
+
if (p = pattern.pattern(), rest = pattern.rest(), changed) {
|
|
4027
|
+
if (this.hasWalkedCache.hasWalked(t, pattern))
|
|
4028
|
+
continue;
|
|
4029
|
+
this.hasWalkedCache.storeWalked(t, pattern);
|
|
4030
|
+
}
|
|
4031
|
+
if (typeof p == "string") {
|
|
4032
|
+
let ifDir = p === ".." || p === "" || p === ".";
|
|
4033
|
+
this.matches.add(t.resolve(p), absolute, ifDir);
|
|
4034
|
+
continue;
|
|
4035
|
+
} else if (p === GLOBSTAR) {
|
|
4036
|
+
(!t.isSymbolicLink() || this.follow || pattern.checkFollowGlobstar()) && this.subwalks.add(t, pattern);
|
|
4037
|
+
let rp = rest?.pattern(), rrest = rest?.rest();
|
|
4038
|
+
if (!rest || (rp === "" || rp === ".") && !rrest)
|
|
4039
|
+
this.matches.add(t, absolute, rp === "" || rp === ".");
|
|
4040
|
+
else if (rp === "..") {
|
|
4041
|
+
let tp = t.parent || t;
|
|
4042
|
+
rrest ? this.hasWalkedCache.hasWalked(tp, rrest) || this.subwalks.add(tp, rrest) : this.matches.add(tp, absolute, !0);
|
|
4043
|
+
}
|
|
4044
|
+
} else p instanceof RegExp && this.subwalks.add(t, pattern);
|
|
4045
|
+
}
|
|
4046
|
+
return this;
|
|
4047
|
+
}
|
|
4048
|
+
subwalkTargets() {
|
|
4049
|
+
return this.subwalks.keys();
|
|
4050
|
+
}
|
|
4051
|
+
child() {
|
|
4052
|
+
return new _Processor(this.opts, this.hasWalkedCache);
|
|
4053
|
+
}
|
|
4054
|
+
// return a new Processor containing the subwalks for each
|
|
4055
|
+
// child entry, and a set of matches, and
|
|
4056
|
+
// a hasWalkedCache that's a copy of this one
|
|
4057
|
+
// then we're going to call
|
|
4058
|
+
filterEntries(parent, entries) {
|
|
4059
|
+
let patterns = this.subwalks.get(parent), results = this.child();
|
|
4060
|
+
for (let e of entries)
|
|
4061
|
+
for (let pattern of patterns) {
|
|
4062
|
+
let absolute = pattern.isAbsolute(), p = pattern.pattern(), rest = pattern.rest();
|
|
4063
|
+
p === GLOBSTAR ? results.testGlobstar(e, pattern, rest, absolute) : p instanceof RegExp ? results.testRegExp(e, p, rest, absolute) : results.testString(e, p, rest, absolute);
|
|
4064
|
+
}
|
|
4065
|
+
return results;
|
|
4066
|
+
}
|
|
4067
|
+
testGlobstar(e, pattern, rest, absolute) {
|
|
4068
|
+
if ((this.dot || !e.name.startsWith(".")) && (pattern.hasMore() || this.matches.add(e, absolute, !1), e.canReaddir() && (this.follow || !e.isSymbolicLink() ? this.subwalks.add(e, pattern) : e.isSymbolicLink() && (rest && pattern.checkFollowGlobstar() ? this.subwalks.add(e, rest) : pattern.markFollowGlobstar() && this.subwalks.add(e, pattern)))), rest) {
|
|
4069
|
+
let rp = rest.pattern();
|
|
4070
|
+
if (typeof rp == "string" && // dots and empty were handled already
|
|
4071
|
+
rp !== ".." && rp !== "" && rp !== ".")
|
|
4072
|
+
this.testString(e, rp, rest.rest(), absolute);
|
|
4073
|
+
else if (rp === "..") {
|
|
4074
|
+
let ep = e.parent || e;
|
|
4075
|
+
this.subwalks.add(ep, rest);
|
|
4076
|
+
} else rp instanceof RegExp && this.testRegExp(e, rp, rest.rest(), absolute);
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
testRegExp(e, p, rest, absolute) {
|
|
4080
|
+
p.test(e.name) && (rest ? this.subwalks.add(e, rest) : this.matches.add(e, absolute, !1));
|
|
4081
|
+
}
|
|
4082
|
+
testString(e, p, rest, absolute) {
|
|
4083
|
+
e.isNamed(p) && (rest ? this.subwalks.add(e, rest) : this.matches.add(e, absolute, !1));
|
|
4084
|
+
}
|
|
4085
|
+
};
|
|
4086
|
+
|
|
4087
|
+
// ../node_modules/glob/dist/esm/walker.js
|
|
4088
|
+
var makeIgnore = (ignore, opts) => typeof ignore == "string" ? new Ignore([ignore], opts) : Array.isArray(ignore) ? new Ignore(ignore, opts) : ignore, GlobUtil = class {
|
|
4089
|
+
path;
|
|
4090
|
+
patterns;
|
|
4091
|
+
opts;
|
|
4092
|
+
seen = /* @__PURE__ */ new Set();
|
|
4093
|
+
paused = !1;
|
|
4094
|
+
aborted = !1;
|
|
4095
|
+
#onResume = [];
|
|
4096
|
+
#ignore;
|
|
4097
|
+
#sep;
|
|
4098
|
+
signal;
|
|
4099
|
+
maxDepth;
|
|
4100
|
+
includeChildMatches;
|
|
4101
|
+
constructor(patterns, path2, opts) {
|
|
4102
|
+
if (this.patterns = patterns, this.path = path2, this.opts = opts, this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/", this.includeChildMatches = opts.includeChildMatches !== !1, (opts.ignore || !this.includeChildMatches) && (this.#ignore = makeIgnore(opts.ignore ?? [], opts), !this.includeChildMatches && typeof this.#ignore.add != "function")) {
|
|
4103
|
+
let m = "cannot ignore child matches, ignore lacks add() method.";
|
|
4104
|
+
throw new Error(m);
|
|
4105
|
+
}
|
|
4106
|
+
this.maxDepth = opts.maxDepth || 1 / 0, opts.signal && (this.signal = opts.signal, this.signal.addEventListener("abort", () => {
|
|
4107
|
+
this.#onResume.length = 0;
|
|
4108
|
+
}));
|
|
4109
|
+
}
|
|
4110
|
+
#ignored(path2) {
|
|
4111
|
+
return this.seen.has(path2) || !!this.#ignore?.ignored?.(path2);
|
|
4112
|
+
}
|
|
4113
|
+
#childrenIgnored(path2) {
|
|
4114
|
+
return !!this.#ignore?.childrenIgnored?.(path2);
|
|
4115
|
+
}
|
|
4116
|
+
// backpressure mechanism
|
|
4117
|
+
pause() {
|
|
4118
|
+
this.paused = !0;
|
|
4119
|
+
}
|
|
4120
|
+
resume() {
|
|
4121
|
+
if (this.signal?.aborted)
|
|
4122
|
+
return;
|
|
4123
|
+
this.paused = !1;
|
|
4124
|
+
let fn;
|
|
4125
|
+
for (; !this.paused && (fn = this.#onResume.shift()); )
|
|
4126
|
+
fn();
|
|
4127
|
+
}
|
|
4128
|
+
onResume(fn) {
|
|
4129
|
+
this.signal?.aborted || (this.paused ? this.#onResume.push(fn) : fn());
|
|
4130
|
+
}
|
|
4131
|
+
// do the requisite realpath/stat checking, and return the path
|
|
4132
|
+
// to add or undefined to filter it out.
|
|
4133
|
+
async matchCheck(e, ifDir) {
|
|
4134
|
+
if (ifDir && this.opts.nodir)
|
|
4135
|
+
return;
|
|
4136
|
+
let rpc;
|
|
4137
|
+
if (this.opts.realpath) {
|
|
4138
|
+
if (rpc = e.realpathCached() || await e.realpath(), !rpc)
|
|
4139
|
+
return;
|
|
4140
|
+
e = rpc;
|
|
4141
|
+
}
|
|
4142
|
+
let s = e.isUnknown() || this.opts.stat ? await e.lstat() : e;
|
|
4143
|
+
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
|
|
4144
|
+
let target = await s.realpath();
|
|
4145
|
+
target && (target.isUnknown() || this.opts.stat) && await target.lstat();
|
|
4146
|
+
}
|
|
4147
|
+
return this.matchCheckTest(s, ifDir);
|
|
4148
|
+
}
|
|
4149
|
+
matchCheckTest(e, ifDir) {
|
|
4150
|
+
return e && (this.maxDepth === 1 / 0 || e.depth() <= this.maxDepth) && (!ifDir || e.canReaddir()) && (!this.opts.nodir || !e.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !e.isSymbolicLink() || !e.realpathCached()?.isDirectory()) && !this.#ignored(e) ? e : void 0;
|
|
4151
|
+
}
|
|
4152
|
+
matchCheckSync(e, ifDir) {
|
|
4153
|
+
if (ifDir && this.opts.nodir)
|
|
4154
|
+
return;
|
|
4155
|
+
let rpc;
|
|
4156
|
+
if (this.opts.realpath) {
|
|
4157
|
+
if (rpc = e.realpathCached() || e.realpathSync(), !rpc)
|
|
4158
|
+
return;
|
|
4159
|
+
e = rpc;
|
|
4160
|
+
}
|
|
4161
|
+
let s = e.isUnknown() || this.opts.stat ? e.lstatSync() : e;
|
|
4162
|
+
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
|
|
4163
|
+
let target = s.realpathSync();
|
|
4164
|
+
target && (target?.isUnknown() || this.opts.stat) && target.lstatSync();
|
|
4165
|
+
}
|
|
4166
|
+
return this.matchCheckTest(s, ifDir);
|
|
4167
|
+
}
|
|
4168
|
+
matchFinish(e, absolute) {
|
|
4169
|
+
if (this.#ignored(e))
|
|
4170
|
+
return;
|
|
4171
|
+
if (!this.includeChildMatches && this.#ignore?.add) {
|
|
4172
|
+
let ign = `${e.relativePosix()}/**`;
|
|
4173
|
+
this.#ignore.add(ign);
|
|
4174
|
+
}
|
|
4175
|
+
let abs = this.opts.absolute === void 0 ? absolute : this.opts.absolute;
|
|
4176
|
+
this.seen.add(e);
|
|
4177
|
+
let mark = this.opts.mark && e.isDirectory() ? this.#sep : "";
|
|
4178
|
+
if (this.opts.withFileTypes)
|
|
4179
|
+
this.matchEmit(e);
|
|
4180
|
+
else if (abs) {
|
|
4181
|
+
let abs2 = this.opts.posix ? e.fullpathPosix() : e.fullpath();
|
|
4182
|
+
this.matchEmit(abs2 + mark);
|
|
4183
|
+
} else {
|
|
4184
|
+
let rel = this.opts.posix ? e.relativePosix() : e.relative(), pre = this.opts.dotRelative && !rel.startsWith(".." + this.#sep) ? "." + this.#sep : "";
|
|
4185
|
+
this.matchEmit(rel ? pre + rel + mark : "." + mark);
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
async match(e, absolute, ifDir) {
|
|
4189
|
+
let p = await this.matchCheck(e, ifDir);
|
|
4190
|
+
p && this.matchFinish(p, absolute);
|
|
4191
|
+
}
|
|
4192
|
+
matchSync(e, absolute, ifDir) {
|
|
4193
|
+
let p = this.matchCheckSync(e, ifDir);
|
|
4194
|
+
p && this.matchFinish(p, absolute);
|
|
4195
|
+
}
|
|
4196
|
+
walkCB(target, patterns, cb) {
|
|
4197
|
+
this.signal?.aborted && cb(), this.walkCB2(target, patterns, new Processor(this.opts), cb);
|
|
4198
|
+
}
|
|
4199
|
+
walkCB2(target, patterns, processor, cb) {
|
|
4200
|
+
if (this.#childrenIgnored(target))
|
|
4201
|
+
return cb();
|
|
4202
|
+
if (this.signal?.aborted && cb(), this.paused) {
|
|
4203
|
+
this.onResume(() => this.walkCB2(target, patterns, processor, cb));
|
|
4204
|
+
return;
|
|
4205
|
+
}
|
|
4206
|
+
processor.processPatterns(target, patterns);
|
|
4207
|
+
let tasks = 1, next = () => {
|
|
4208
|
+
--tasks === 0 && cb();
|
|
4209
|
+
};
|
|
4210
|
+
for (let [m, absolute, ifDir] of processor.matches.entries())
|
|
4211
|
+
this.#ignored(m) || (tasks++, this.match(m, absolute, ifDir).then(() => next()));
|
|
4212
|
+
for (let t of processor.subwalkTargets()) {
|
|
4213
|
+
if (this.maxDepth !== 1 / 0 && t.depth() >= this.maxDepth)
|
|
4214
|
+
continue;
|
|
4215
|
+
tasks++;
|
|
4216
|
+
let childrenCached = t.readdirCached();
|
|
4217
|
+
t.calledReaddir() ? this.walkCB3(t, childrenCached, processor, next) : t.readdirCB((_, entries) => this.walkCB3(t, entries, processor, next), !0);
|
|
4218
|
+
}
|
|
4219
|
+
next();
|
|
4220
|
+
}
|
|
4221
|
+
walkCB3(target, entries, processor, cb) {
|
|
4222
|
+
processor = processor.filterEntries(target, entries);
|
|
4223
|
+
let tasks = 1, next = () => {
|
|
4224
|
+
--tasks === 0 && cb();
|
|
4225
|
+
};
|
|
4226
|
+
for (let [m, absolute, ifDir] of processor.matches.entries())
|
|
4227
|
+
this.#ignored(m) || (tasks++, this.match(m, absolute, ifDir).then(() => next()));
|
|
4228
|
+
for (let [target2, patterns] of processor.subwalks.entries())
|
|
4229
|
+
tasks++, this.walkCB2(target2, patterns, processor.child(), next);
|
|
4230
|
+
next();
|
|
4231
|
+
}
|
|
4232
|
+
walkCBSync(target, patterns, cb) {
|
|
4233
|
+
this.signal?.aborted && cb(), this.walkCB2Sync(target, patterns, new Processor(this.opts), cb);
|
|
4234
|
+
}
|
|
4235
|
+
walkCB2Sync(target, patterns, processor, cb) {
|
|
4236
|
+
if (this.#childrenIgnored(target))
|
|
4237
|
+
return cb();
|
|
4238
|
+
if (this.signal?.aborted && cb(), this.paused) {
|
|
4239
|
+
this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb));
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
processor.processPatterns(target, patterns);
|
|
4243
|
+
let tasks = 1, next = () => {
|
|
4244
|
+
--tasks === 0 && cb();
|
|
4245
|
+
};
|
|
4246
|
+
for (let [m, absolute, ifDir] of processor.matches.entries())
|
|
4247
|
+
this.#ignored(m) || this.matchSync(m, absolute, ifDir);
|
|
4248
|
+
for (let t of processor.subwalkTargets()) {
|
|
4249
|
+
if (this.maxDepth !== 1 / 0 && t.depth() >= this.maxDepth)
|
|
4250
|
+
continue;
|
|
4251
|
+
tasks++;
|
|
4252
|
+
let children = t.readdirSync();
|
|
4253
|
+
this.walkCB3Sync(t, children, processor, next);
|
|
4254
|
+
}
|
|
4255
|
+
next();
|
|
4256
|
+
}
|
|
4257
|
+
walkCB3Sync(target, entries, processor, cb) {
|
|
4258
|
+
processor = processor.filterEntries(target, entries);
|
|
4259
|
+
let tasks = 1, next = () => {
|
|
4260
|
+
--tasks === 0 && cb();
|
|
4261
|
+
};
|
|
4262
|
+
for (let [m, absolute, ifDir] of processor.matches.entries())
|
|
4263
|
+
this.#ignored(m) || this.matchSync(m, absolute, ifDir);
|
|
4264
|
+
for (let [target2, patterns] of processor.subwalks.entries())
|
|
4265
|
+
tasks++, this.walkCB2Sync(target2, patterns, processor.child(), next);
|
|
4266
|
+
next();
|
|
4267
|
+
}
|
|
4268
|
+
}, GlobWalker = class extends GlobUtil {
|
|
4269
|
+
matches = /* @__PURE__ */ new Set();
|
|
4270
|
+
constructor(patterns, path2, opts) {
|
|
4271
|
+
super(patterns, path2, opts);
|
|
4272
|
+
}
|
|
4273
|
+
matchEmit(e) {
|
|
4274
|
+
this.matches.add(e);
|
|
4275
|
+
}
|
|
4276
|
+
async walk() {
|
|
4277
|
+
if (this.signal?.aborted)
|
|
4278
|
+
throw this.signal.reason;
|
|
4279
|
+
return this.path.isUnknown() && await this.path.lstat(), await new Promise((res, rej) => {
|
|
4280
|
+
this.walkCB(this.path, this.patterns, () => {
|
|
4281
|
+
this.signal?.aborted ? rej(this.signal.reason) : res(this.matches);
|
|
4282
|
+
});
|
|
4283
|
+
}), this.matches;
|
|
4284
|
+
}
|
|
4285
|
+
walkSync() {
|
|
4286
|
+
if (this.signal?.aborted)
|
|
4287
|
+
throw this.signal.reason;
|
|
4288
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
|
|
4289
|
+
if (this.signal?.aborted)
|
|
4290
|
+
throw this.signal.reason;
|
|
4291
|
+
}), this.matches;
|
|
4292
|
+
}
|
|
4293
|
+
}, GlobStream = class extends GlobUtil {
|
|
4294
|
+
results;
|
|
4295
|
+
constructor(patterns, path2, opts) {
|
|
4296
|
+
super(patterns, path2, opts), this.results = new Minipass({
|
|
4297
|
+
signal: this.signal,
|
|
4298
|
+
objectMode: !0
|
|
4299
|
+
}), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
|
|
4300
|
+
}
|
|
4301
|
+
matchEmit(e) {
|
|
4302
|
+
this.results.write(e), this.results.flowing || this.pause();
|
|
4303
|
+
}
|
|
4304
|
+
stream() {
|
|
4305
|
+
let target = this.path;
|
|
4306
|
+
return target.isUnknown() ? target.lstat().then(() => {
|
|
4307
|
+
this.walkCB(target, this.patterns, () => this.results.end());
|
|
4308
|
+
}) : this.walkCB(target, this.patterns, () => this.results.end()), this.results;
|
|
4309
|
+
}
|
|
4310
|
+
streamSync() {
|
|
4311
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
|
|
4312
|
+
}
|
|
4313
|
+
};
|
|
4314
|
+
|
|
4315
|
+
// ../node_modules/glob/dist/esm/glob.js
|
|
4316
|
+
var defaultPlatform3 = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", Glob = class {
|
|
4317
|
+
absolute;
|
|
4318
|
+
cwd;
|
|
4319
|
+
root;
|
|
4320
|
+
dot;
|
|
4321
|
+
dotRelative;
|
|
4322
|
+
follow;
|
|
4323
|
+
ignore;
|
|
4324
|
+
magicalBraces;
|
|
4325
|
+
mark;
|
|
4326
|
+
matchBase;
|
|
4327
|
+
maxDepth;
|
|
4328
|
+
nobrace;
|
|
4329
|
+
nocase;
|
|
4330
|
+
nodir;
|
|
4331
|
+
noext;
|
|
4332
|
+
noglobstar;
|
|
4333
|
+
pattern;
|
|
4334
|
+
platform;
|
|
4335
|
+
realpath;
|
|
4336
|
+
scurry;
|
|
4337
|
+
stat;
|
|
4338
|
+
signal;
|
|
4339
|
+
windowsPathsNoEscape;
|
|
4340
|
+
withFileTypes;
|
|
4341
|
+
includeChildMatches;
|
|
4342
|
+
/**
|
|
4343
|
+
* The options provided to the constructor.
|
|
4344
|
+
*/
|
|
4345
|
+
opts;
|
|
4346
|
+
/**
|
|
4347
|
+
* An array of parsed immutable {@link Pattern} objects.
|
|
4348
|
+
*/
|
|
4349
|
+
patterns;
|
|
4350
|
+
/**
|
|
4351
|
+
* All options are stored as properties on the `Glob` object.
|
|
4352
|
+
*
|
|
4353
|
+
* See {@link GlobOptions} for full options descriptions.
|
|
4354
|
+
*
|
|
4355
|
+
* Note that a previous `Glob` object can be passed as the
|
|
4356
|
+
* `GlobOptions` to another `Glob` instantiation to re-use settings
|
|
4357
|
+
* and caches with a new pattern.
|
|
4358
|
+
*
|
|
4359
|
+
* Traversal functions can be called multiple times to run the walk
|
|
4360
|
+
* again.
|
|
4361
|
+
*/
|
|
4362
|
+
constructor(pattern, opts) {
|
|
4363
|
+
if (!opts)
|
|
4364
|
+
throw new TypeError("glob options required");
|
|
4365
|
+
if (this.withFileTypes = !!opts.withFileTypes, this.signal = opts.signal, this.follow = !!opts.follow, this.dot = !!opts.dot, this.dotRelative = !!opts.dotRelative, this.nodir = !!opts.nodir, this.mark = !!opts.mark, opts.cwd ? (opts.cwd instanceof URL || opts.cwd.startsWith("file://")) && (opts.cwd = fileURLToPath2(opts.cwd)) : this.cwd = "", this.cwd = opts.cwd || "", this.root = opts.root, this.magicalBraces = !!opts.magicalBraces, this.nobrace = !!opts.nobrace, this.noext = !!opts.noext, this.realpath = !!opts.realpath, this.absolute = opts.absolute, this.includeChildMatches = opts.includeChildMatches !== !1, this.noglobstar = !!opts.noglobstar, this.matchBase = !!opts.matchBase, this.maxDepth = typeof opts.maxDepth == "number" ? opts.maxDepth : 1 / 0, this.stat = !!opts.stat, this.ignore = opts.ignore, this.withFileTypes && this.absolute !== void 0)
|
|
4366
|
+
throw new Error("cannot set absolute and withFileTypes:true");
|
|
4367
|
+
if (typeof pattern == "string" && (pattern = [pattern]), this.windowsPathsNoEscape = !!opts.windowsPathsNoEscape || opts.allowWindowsEscape === !1, this.windowsPathsNoEscape && (pattern = pattern.map((p) => p.replace(/\\/g, "/"))), this.matchBase) {
|
|
4368
|
+
if (opts.noglobstar)
|
|
4369
|
+
throw new TypeError("base matching requires globstar");
|
|
4370
|
+
pattern = pattern.map((p) => p.includes("/") ? p : `./**/${p}`);
|
|
4371
|
+
}
|
|
4372
|
+
if (this.pattern = pattern, this.platform = opts.platform || defaultPlatform3, this.opts = { ...opts, platform: this.platform }, opts.scurry) {
|
|
4373
|
+
if (this.scurry = opts.scurry, opts.nocase !== void 0 && opts.nocase !== opts.scurry.nocase)
|
|
4374
|
+
throw new Error("nocase option contradicts provided scurry option");
|
|
4375
|
+
} else {
|
|
4376
|
+
let Scurry = opts.platform === "win32" ? PathScurryWin32 : opts.platform === "darwin" ? PathScurryDarwin : opts.platform ? PathScurryPosix : PathScurry;
|
|
4377
|
+
this.scurry = new Scurry(this.cwd, {
|
|
4378
|
+
nocase: opts.nocase,
|
|
4379
|
+
fs: opts.fs
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
4382
|
+
this.nocase = this.scurry.nocase;
|
|
4383
|
+
let nocaseMagicOnly = this.platform === "darwin" || this.platform === "win32", mmo = {
|
|
4384
|
+
// default nocase based on platform
|
|
4385
|
+
...opts,
|
|
4386
|
+
dot: this.dot,
|
|
4387
|
+
matchBase: this.matchBase,
|
|
4388
|
+
nobrace: this.nobrace,
|
|
4389
|
+
nocase: this.nocase,
|
|
4390
|
+
nocaseMagicOnly,
|
|
4391
|
+
nocomment: !0,
|
|
4392
|
+
noext: this.noext,
|
|
4393
|
+
nonegate: !0,
|
|
4394
|
+
optimizationLevel: 2,
|
|
4395
|
+
platform: this.platform,
|
|
4396
|
+
windowsPathsNoEscape: this.windowsPathsNoEscape,
|
|
4397
|
+
debug: !!this.opts.debug
|
|
4398
|
+
}, mms = this.pattern.map((p) => new Minimatch(p, mmo)), [matchSet, globParts] = mms.reduce((set, m) => (set[0].push(...m.set), set[1].push(...m.globParts), set), [[], []]);
|
|
4399
|
+
this.patterns = matchSet.map((set, i) => {
|
|
4400
|
+
let g = globParts[i];
|
|
4401
|
+
if (!g)
|
|
4402
|
+
throw new Error("invalid pattern object");
|
|
4403
|
+
return new Pattern(set, g, 0, this.platform);
|
|
4404
|
+
});
|
|
4405
|
+
}
|
|
4406
|
+
async walk() {
|
|
4407
|
+
return [
|
|
4408
|
+
...await new GlobWalker(this.patterns, this.scurry.cwd, {
|
|
4409
|
+
...this.opts,
|
|
4410
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
4411
|
+
platform: this.platform,
|
|
4412
|
+
nocase: this.nocase,
|
|
4413
|
+
includeChildMatches: this.includeChildMatches
|
|
4414
|
+
}).walk()
|
|
4415
|
+
];
|
|
4416
|
+
}
|
|
4417
|
+
walkSync() {
|
|
4418
|
+
return [
|
|
4419
|
+
...new GlobWalker(this.patterns, this.scurry.cwd, {
|
|
4420
|
+
...this.opts,
|
|
4421
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
4422
|
+
platform: this.platform,
|
|
4423
|
+
nocase: this.nocase,
|
|
4424
|
+
includeChildMatches: this.includeChildMatches
|
|
4425
|
+
}).walkSync()
|
|
4426
|
+
];
|
|
4427
|
+
}
|
|
4428
|
+
stream() {
|
|
4429
|
+
return new GlobStream(this.patterns, this.scurry.cwd, {
|
|
4430
|
+
...this.opts,
|
|
4431
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
4432
|
+
platform: this.platform,
|
|
4433
|
+
nocase: this.nocase,
|
|
4434
|
+
includeChildMatches: this.includeChildMatches
|
|
4435
|
+
}).stream();
|
|
4436
|
+
}
|
|
4437
|
+
streamSync() {
|
|
4438
|
+
return new GlobStream(this.patterns, this.scurry.cwd, {
|
|
4439
|
+
...this.opts,
|
|
4440
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
4441
|
+
platform: this.platform,
|
|
4442
|
+
nocase: this.nocase,
|
|
4443
|
+
includeChildMatches: this.includeChildMatches
|
|
4444
|
+
}).streamSync();
|
|
4445
|
+
}
|
|
4446
|
+
/**
|
|
4447
|
+
* Default sync iteration function. Returns a Generator that
|
|
4448
|
+
* iterates over the results.
|
|
4449
|
+
*/
|
|
4450
|
+
iterateSync() {
|
|
4451
|
+
return this.streamSync()[Symbol.iterator]();
|
|
4452
|
+
}
|
|
4453
|
+
[Symbol.iterator]() {
|
|
4454
|
+
return this.iterateSync();
|
|
4455
|
+
}
|
|
4456
|
+
/**
|
|
4457
|
+
* Default async iteration function. Returns an AsyncGenerator that
|
|
4458
|
+
* iterates over the results.
|
|
4459
|
+
*/
|
|
4460
|
+
iterate() {
|
|
4461
|
+
return this.stream()[Symbol.asyncIterator]();
|
|
4462
|
+
}
|
|
4463
|
+
[Symbol.asyncIterator]() {
|
|
4464
|
+
return this.iterate();
|
|
4465
|
+
}
|
|
4466
|
+
};
|
|
4467
|
+
|
|
4468
|
+
// ../node_modules/glob/dist/esm/has-magic.js
|
|
4469
|
+
var hasMagic = (pattern, options = {}) => {
|
|
4470
|
+
Array.isArray(pattern) || (pattern = [pattern]);
|
|
4471
|
+
for (let p of pattern)
|
|
4472
|
+
if (new Minimatch(p, options).hasMagic())
|
|
4473
|
+
return !0;
|
|
4474
|
+
return !1;
|
|
4475
|
+
};
|
|
4476
|
+
|
|
4477
|
+
// ../node_modules/glob/dist/esm/index.js
|
|
4478
|
+
function globStreamSync(pattern, options = {}) {
|
|
4479
|
+
return new Glob(pattern, options).streamSync();
|
|
4480
|
+
}
|
|
4481
|
+
function globStream(pattern, options = {}) {
|
|
4482
|
+
return new Glob(pattern, options).stream();
|
|
4483
|
+
}
|
|
4484
|
+
function globSync(pattern, options = {}) {
|
|
4485
|
+
return new Glob(pattern, options).walkSync();
|
|
4486
|
+
}
|
|
4487
|
+
async function glob_(pattern, options = {}) {
|
|
4488
|
+
return new Glob(pattern, options).walk();
|
|
4489
|
+
}
|
|
4490
|
+
function globIterateSync(pattern, options = {}) {
|
|
4491
|
+
return new Glob(pattern, options).iterateSync();
|
|
4492
|
+
}
|
|
4493
|
+
function globIterate(pattern, options = {}) {
|
|
4494
|
+
return new Glob(pattern, options).iterate();
|
|
4495
|
+
}
|
|
4496
|
+
var streamSync = globStreamSync, stream = Object.assign(globStream, { sync: globStreamSync }), iterateSync = globIterateSync, iterate = Object.assign(globIterate, {
|
|
4497
|
+
sync: globIterateSync
|
|
4498
|
+
}), sync = Object.assign(globSync, {
|
|
4499
|
+
stream: globStreamSync,
|
|
4500
|
+
iterate: globIterateSync
|
|
4501
|
+
}), glob = Object.assign(glob_, {
|
|
4502
|
+
glob: glob_,
|
|
4503
|
+
globSync,
|
|
4504
|
+
sync,
|
|
4505
|
+
globStream,
|
|
4506
|
+
stream,
|
|
4507
|
+
globStreamSync,
|
|
4508
|
+
streamSync,
|
|
4509
|
+
globIterate,
|
|
4510
|
+
iterate,
|
|
4511
|
+
globIterateSync,
|
|
4512
|
+
iterateSync,
|
|
4513
|
+
Glob,
|
|
4514
|
+
hasMagic,
|
|
4515
|
+
escape,
|
|
4516
|
+
unescape
|
|
4517
|
+
});
|
|
4518
|
+
glob.glob = glob;
|
|
4519
|
+
|
|
4520
|
+
export {
|
|
4521
|
+
globSync,
|
|
4522
|
+
glob
|
|
4523
|
+
};
|