@rslib/core 0.20.0 → 0.20.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/compiled/rslog/index.d.ts +18 -2
- package/compiled/rslog/package.json +1 -1
- package/dist/chokidar.js +1467 -0
- package/dist/chokidar.js.LICENSE.txt +1 -0
- package/dist/index.js +375 -80
- package/dist/rslib-runtime.js +18 -0
- package/dist/tinyglobby.js +2177 -0
- package/dist-types/config.d.ts +6 -1
- package/dist-types/css/cssConfig.d.ts +2 -2
- package/dist-types/utils/color.d.ts +1 -2
- package/dist-types/utils/helper.d.ts +1 -1
- package/package.json +13 -14
- package/compiled/chokidar/index.d.ts +0 -346
- package/compiled/chokidar/index.js +0 -1778
- package/compiled/chokidar/license +0 -21
- package/compiled/chokidar/package.json +0 -1
- package/compiled/picocolors/index.d.ts +0 -55
- package/compiled/picocolors/index.js +0 -132
- package/compiled/picocolors/license +0 -15
- package/compiled/picocolors/package.json +0 -1
- package/compiled/rslog/index.js +0 -300
- package/compiled/tinyglobby/index.d.ts +0 -46
- package/compiled/tinyglobby/index.js +0 -3061
- package/compiled/tinyglobby/license +0 -21
- package/compiled/tinyglobby/package.json +0 -1
|
@@ -0,0 +1,2177 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import fs_0, * as __rspack_external_fs from "fs";
|
|
3
|
+
import path_0, { basename, dirname, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
__webpack_require__.add({
|
|
7
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
8
|
+
const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js");
|
|
9
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
|
|
10
|
+
function picomatch(glob, options, returnState = false) {
|
|
11
|
+
if (options && (null === options.windows || void 0 === options.windows)) options = {
|
|
12
|
+
...options,
|
|
13
|
+
windows: utils.isWindows()
|
|
14
|
+
};
|
|
15
|
+
return pico(glob, options, returnState);
|
|
16
|
+
}
|
|
17
|
+
Object.assign(picomatch, pico);
|
|
18
|
+
module.exports = picomatch;
|
|
19
|
+
},
|
|
20
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js" (module) {
|
|
21
|
+
const WIN_SLASH = '\\\\/';
|
|
22
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
23
|
+
const DOT_LITERAL = '\\.';
|
|
24
|
+
const PLUS_LITERAL = '\\+';
|
|
25
|
+
const QMARK_LITERAL = '\\?';
|
|
26
|
+
const SLASH_LITERAL = '\\/';
|
|
27
|
+
const ONE_CHAR = '(?=.)';
|
|
28
|
+
const QMARK = '[^/]';
|
|
29
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
30
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
31
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
32
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
33
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
34
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
35
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
36
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
37
|
+
const STAR = `${QMARK}*?`;
|
|
38
|
+
const SEP = '/';
|
|
39
|
+
const POSIX_CHARS = {
|
|
40
|
+
DOT_LITERAL,
|
|
41
|
+
PLUS_LITERAL,
|
|
42
|
+
QMARK_LITERAL,
|
|
43
|
+
SLASH_LITERAL,
|
|
44
|
+
ONE_CHAR,
|
|
45
|
+
QMARK,
|
|
46
|
+
END_ANCHOR,
|
|
47
|
+
DOTS_SLASH,
|
|
48
|
+
NO_DOT,
|
|
49
|
+
NO_DOTS,
|
|
50
|
+
NO_DOT_SLASH,
|
|
51
|
+
NO_DOTS_SLASH,
|
|
52
|
+
QMARK_NO_DOT,
|
|
53
|
+
STAR,
|
|
54
|
+
START_ANCHOR,
|
|
55
|
+
SEP
|
|
56
|
+
};
|
|
57
|
+
const WINDOWS_CHARS = {
|
|
58
|
+
...POSIX_CHARS,
|
|
59
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
60
|
+
QMARK: WIN_NO_SLASH,
|
|
61
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
62
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
63
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
64
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
65
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
66
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
67
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
68
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
69
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
70
|
+
SEP: '\\'
|
|
71
|
+
};
|
|
72
|
+
const POSIX_REGEX_SOURCE = {
|
|
73
|
+
alnum: 'a-zA-Z0-9',
|
|
74
|
+
alpha: 'a-zA-Z',
|
|
75
|
+
ascii: '\\x00-\\x7F',
|
|
76
|
+
blank: ' \\t',
|
|
77
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
78
|
+
digit: '0-9',
|
|
79
|
+
graph: '\\x21-\\x7E',
|
|
80
|
+
lower: 'a-z',
|
|
81
|
+
print: '\\x20-\\x7E ',
|
|
82
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
83
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
84
|
+
upper: 'A-Z',
|
|
85
|
+
word: 'A-Za-z0-9_',
|
|
86
|
+
xdigit: 'A-Fa-f0-9'
|
|
87
|
+
};
|
|
88
|
+
module.exports = {
|
|
89
|
+
MAX_LENGTH: 65536,
|
|
90
|
+
POSIX_REGEX_SOURCE,
|
|
91
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
92
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
93
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
94
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
95
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
96
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
97
|
+
REPLACEMENTS: {
|
|
98
|
+
__proto__: null,
|
|
99
|
+
'***': '*',
|
|
100
|
+
'**/**': '**',
|
|
101
|
+
'**/**/**': '**'
|
|
102
|
+
},
|
|
103
|
+
CHAR_0: 48,
|
|
104
|
+
CHAR_9: 57,
|
|
105
|
+
CHAR_UPPERCASE_A: 65,
|
|
106
|
+
CHAR_LOWERCASE_A: 97,
|
|
107
|
+
CHAR_UPPERCASE_Z: 90,
|
|
108
|
+
CHAR_LOWERCASE_Z: 122,
|
|
109
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
110
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
111
|
+
CHAR_ASTERISK: 42,
|
|
112
|
+
CHAR_AMPERSAND: 38,
|
|
113
|
+
CHAR_AT: 64,
|
|
114
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
115
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
116
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
117
|
+
CHAR_COLON: 58,
|
|
118
|
+
CHAR_COMMA: 44,
|
|
119
|
+
CHAR_DOT: 46,
|
|
120
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
121
|
+
CHAR_EQUAL: 61,
|
|
122
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
123
|
+
CHAR_FORM_FEED: 12,
|
|
124
|
+
CHAR_FORWARD_SLASH: 47,
|
|
125
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
126
|
+
CHAR_HASH: 35,
|
|
127
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
128
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
129
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
130
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
131
|
+
CHAR_LINE_FEED: 10,
|
|
132
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
133
|
+
CHAR_PERCENT: 37,
|
|
134
|
+
CHAR_PLUS: 43,
|
|
135
|
+
CHAR_QUESTION_MARK: 63,
|
|
136
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
137
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
138
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
139
|
+
CHAR_SEMICOLON: 59,
|
|
140
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
141
|
+
CHAR_SPACE: 32,
|
|
142
|
+
CHAR_TAB: 9,
|
|
143
|
+
CHAR_UNDERSCORE: 95,
|
|
144
|
+
CHAR_VERTICAL_LINE: 124,
|
|
145
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
146
|
+
extglobChars (chars) {
|
|
147
|
+
return {
|
|
148
|
+
'!': {
|
|
149
|
+
type: 'negate',
|
|
150
|
+
open: '(?:(?!(?:',
|
|
151
|
+
close: `))${chars.STAR})`
|
|
152
|
+
},
|
|
153
|
+
'?': {
|
|
154
|
+
type: 'qmark',
|
|
155
|
+
open: '(?:',
|
|
156
|
+
close: ')?'
|
|
157
|
+
},
|
|
158
|
+
'+': {
|
|
159
|
+
type: 'plus',
|
|
160
|
+
open: '(?:',
|
|
161
|
+
close: ')+'
|
|
162
|
+
},
|
|
163
|
+
'*': {
|
|
164
|
+
type: 'star',
|
|
165
|
+
open: '(?:',
|
|
166
|
+
close: ')*'
|
|
167
|
+
},
|
|
168
|
+
'@': {
|
|
169
|
+
type: 'at',
|
|
170
|
+
open: '(?:',
|
|
171
|
+
close: ')'
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
globChars (win32) {
|
|
176
|
+
return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
181
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
|
|
182
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
|
|
183
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
184
|
+
const expandRange = (args, options)=>{
|
|
185
|
+
if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
|
|
186
|
+
args.sort();
|
|
187
|
+
const value = `[${args.join('-')}]`;
|
|
188
|
+
try {
|
|
189
|
+
new RegExp(value);
|
|
190
|
+
} catch (ex) {
|
|
191
|
+
return args.map((v)=>utils.escapeRegex(v)).join('..');
|
|
192
|
+
}
|
|
193
|
+
return value;
|
|
194
|
+
};
|
|
195
|
+
const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
196
|
+
const parse = (input, options)=>{
|
|
197
|
+
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
198
|
+
input = REPLACEMENTS[input] || input;
|
|
199
|
+
const opts = {
|
|
200
|
+
...options
|
|
201
|
+
};
|
|
202
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
203
|
+
let len = input.length;
|
|
204
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
205
|
+
const bos = {
|
|
206
|
+
type: 'bos',
|
|
207
|
+
value: '',
|
|
208
|
+
output: opts.prepend || ''
|
|
209
|
+
};
|
|
210
|
+
const tokens = [
|
|
211
|
+
bos
|
|
212
|
+
];
|
|
213
|
+
const capture = opts.capture ? '' : '?:';
|
|
214
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
215
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
216
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
217
|
+
const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
218
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
219
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
220
|
+
let star = true === opts.bash ? globstar(opts) : STAR;
|
|
221
|
+
if (opts.capture) star = `(${star})`;
|
|
222
|
+
if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
|
|
223
|
+
const state = {
|
|
224
|
+
input,
|
|
225
|
+
index: -1,
|
|
226
|
+
start: 0,
|
|
227
|
+
dot: true === opts.dot,
|
|
228
|
+
consumed: '',
|
|
229
|
+
output: '',
|
|
230
|
+
prefix: '',
|
|
231
|
+
backtrack: false,
|
|
232
|
+
negated: false,
|
|
233
|
+
brackets: 0,
|
|
234
|
+
braces: 0,
|
|
235
|
+
parens: 0,
|
|
236
|
+
quotes: 0,
|
|
237
|
+
globstar: false,
|
|
238
|
+
tokens
|
|
239
|
+
};
|
|
240
|
+
input = utils.removePrefix(input, state);
|
|
241
|
+
len = input.length;
|
|
242
|
+
const extglobs = [];
|
|
243
|
+
const braces = [];
|
|
244
|
+
const stack = [];
|
|
245
|
+
let prev = bos;
|
|
246
|
+
let value;
|
|
247
|
+
const eos = ()=>state.index === len - 1;
|
|
248
|
+
const peek = state.peek = (n = 1)=>input[state.index + n];
|
|
249
|
+
const advance = state.advance = ()=>input[++state.index] || '';
|
|
250
|
+
const remaining = ()=>input.slice(state.index + 1);
|
|
251
|
+
const consume = (value = '', num = 0)=>{
|
|
252
|
+
state.consumed += value;
|
|
253
|
+
state.index += num;
|
|
254
|
+
};
|
|
255
|
+
const append = (token)=>{
|
|
256
|
+
state.output += null != token.output ? token.output : token.value;
|
|
257
|
+
consume(token.value);
|
|
258
|
+
};
|
|
259
|
+
const negate = ()=>{
|
|
260
|
+
let count = 1;
|
|
261
|
+
while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
|
|
262
|
+
advance();
|
|
263
|
+
state.start++;
|
|
264
|
+
count++;
|
|
265
|
+
}
|
|
266
|
+
if (count % 2 === 0) return false;
|
|
267
|
+
state.negated = true;
|
|
268
|
+
state.start++;
|
|
269
|
+
return true;
|
|
270
|
+
};
|
|
271
|
+
const increment = (type)=>{
|
|
272
|
+
state[type]++;
|
|
273
|
+
stack.push(type);
|
|
274
|
+
};
|
|
275
|
+
const decrement = (type)=>{
|
|
276
|
+
state[type]--;
|
|
277
|
+
stack.pop();
|
|
278
|
+
};
|
|
279
|
+
const push = (tok)=>{
|
|
280
|
+
if ('globstar' === prev.type) {
|
|
281
|
+
const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
|
|
282
|
+
const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
|
|
283
|
+
if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
|
|
284
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
285
|
+
prev.type = 'star';
|
|
286
|
+
prev.value = '*';
|
|
287
|
+
prev.output = star;
|
|
288
|
+
state.output += prev.output;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
|
|
292
|
+
if (tok.value || tok.output) append(tok);
|
|
293
|
+
if (prev && 'text' === prev.type && 'text' === tok.type) {
|
|
294
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
295
|
+
prev.value += tok.value;
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
tok.prev = prev;
|
|
299
|
+
tokens.push(tok);
|
|
300
|
+
prev = tok;
|
|
301
|
+
};
|
|
302
|
+
const extglobOpen = (type, value)=>{
|
|
303
|
+
const token = {
|
|
304
|
+
...EXTGLOB_CHARS[value],
|
|
305
|
+
conditions: 1,
|
|
306
|
+
inner: ''
|
|
307
|
+
};
|
|
308
|
+
token.prev = prev;
|
|
309
|
+
token.parens = state.parens;
|
|
310
|
+
token.output = state.output;
|
|
311
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
312
|
+
increment('parens');
|
|
313
|
+
push({
|
|
314
|
+
type,
|
|
315
|
+
value,
|
|
316
|
+
output: state.output ? '' : ONE_CHAR
|
|
317
|
+
});
|
|
318
|
+
push({
|
|
319
|
+
type: 'paren',
|
|
320
|
+
extglob: true,
|
|
321
|
+
value: advance(),
|
|
322
|
+
output
|
|
323
|
+
});
|
|
324
|
+
extglobs.push(token);
|
|
325
|
+
};
|
|
326
|
+
const extglobClose = (token)=>{
|
|
327
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
328
|
+
let rest;
|
|
329
|
+
if ('negate' === token.type) {
|
|
330
|
+
let extglobStar = star;
|
|
331
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
|
|
332
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
333
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
334
|
+
const expression = parse(rest, {
|
|
335
|
+
...options,
|
|
336
|
+
fastpaths: false
|
|
337
|
+
}).output;
|
|
338
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
339
|
+
}
|
|
340
|
+
if ('bos' === token.prev.type) state.negatedExtglob = true;
|
|
341
|
+
}
|
|
342
|
+
push({
|
|
343
|
+
type: 'paren',
|
|
344
|
+
extglob: true,
|
|
345
|
+
value,
|
|
346
|
+
output
|
|
347
|
+
});
|
|
348
|
+
decrement('parens');
|
|
349
|
+
};
|
|
350
|
+
if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
351
|
+
let backslashes = false;
|
|
352
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
|
|
353
|
+
if ('\\' === first) {
|
|
354
|
+
backslashes = true;
|
|
355
|
+
return m;
|
|
356
|
+
}
|
|
357
|
+
if ('?' === first) {
|
|
358
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
359
|
+
if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
360
|
+
return QMARK.repeat(chars.length);
|
|
361
|
+
}
|
|
362
|
+
if ('.' === first) return DOT_LITERAL.repeat(chars.length);
|
|
363
|
+
if ('*' === first) {
|
|
364
|
+
if (esc) return esc + first + (rest ? star : '');
|
|
365
|
+
return star;
|
|
366
|
+
}
|
|
367
|
+
return esc ? m : `\\${m}`;
|
|
368
|
+
});
|
|
369
|
+
if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
|
|
370
|
+
if (output === input && true === opts.contains) {
|
|
371
|
+
state.output = input;
|
|
372
|
+
return state;
|
|
373
|
+
}
|
|
374
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
375
|
+
return state;
|
|
376
|
+
}
|
|
377
|
+
while(!eos()){
|
|
378
|
+
value = advance();
|
|
379
|
+
if ('\u0000' === value) continue;
|
|
380
|
+
if ('\\' === value) {
|
|
381
|
+
const next = peek();
|
|
382
|
+
if ('/' === next && true !== opts.bash) continue;
|
|
383
|
+
if ('.' === next || ';' === next) continue;
|
|
384
|
+
if (!next) {
|
|
385
|
+
value += '\\';
|
|
386
|
+
push({
|
|
387
|
+
type: 'text',
|
|
388
|
+
value
|
|
389
|
+
});
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const match = /^\\+/.exec(remaining());
|
|
393
|
+
let slashes = 0;
|
|
394
|
+
if (match && match[0].length > 2) {
|
|
395
|
+
slashes = match[0].length;
|
|
396
|
+
state.index += slashes;
|
|
397
|
+
if (slashes % 2 !== 0) value += '\\';
|
|
398
|
+
}
|
|
399
|
+
if (true === opts.unescape) value = advance();
|
|
400
|
+
else value += advance();
|
|
401
|
+
if (0 === state.brackets) {
|
|
402
|
+
push({
|
|
403
|
+
type: 'text',
|
|
404
|
+
value
|
|
405
|
+
});
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
|
|
410
|
+
if (false !== opts.posix && ':' === value) {
|
|
411
|
+
const inner = prev.value.slice(1);
|
|
412
|
+
if (inner.includes('[')) {
|
|
413
|
+
prev.posix = true;
|
|
414
|
+
if (inner.includes(':')) {
|
|
415
|
+
const idx = prev.value.lastIndexOf('[');
|
|
416
|
+
const pre = prev.value.slice(0, idx);
|
|
417
|
+
const rest = prev.value.slice(idx + 2);
|
|
418
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
419
|
+
if (posix) {
|
|
420
|
+
prev.value = pre + posix;
|
|
421
|
+
state.backtrack = true;
|
|
422
|
+
advance();
|
|
423
|
+
if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
|
|
430
|
+
if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
|
|
431
|
+
if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
|
|
432
|
+
prev.value += value;
|
|
433
|
+
append({
|
|
434
|
+
value
|
|
435
|
+
});
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (1 === state.quotes && '"' !== value) {
|
|
439
|
+
value = utils.escapeRegex(value);
|
|
440
|
+
prev.value += value;
|
|
441
|
+
append({
|
|
442
|
+
value
|
|
443
|
+
});
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
if ('"' === value) {
|
|
447
|
+
state.quotes = 1 === state.quotes ? 0 : 1;
|
|
448
|
+
if (true === opts.keepQuotes) push({
|
|
449
|
+
type: 'text',
|
|
450
|
+
value
|
|
451
|
+
});
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if ('(' === value) {
|
|
455
|
+
increment('parens');
|
|
456
|
+
push({
|
|
457
|
+
type: 'paren',
|
|
458
|
+
value
|
|
459
|
+
});
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
if (')' === value) {
|
|
463
|
+
if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
|
|
464
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
465
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
466
|
+
extglobClose(extglobs.pop());
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
push({
|
|
470
|
+
type: 'paren',
|
|
471
|
+
value,
|
|
472
|
+
output: state.parens ? ')' : '\\)'
|
|
473
|
+
});
|
|
474
|
+
decrement('parens');
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if ('[' === value) {
|
|
478
|
+
if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
|
|
479
|
+
else {
|
|
480
|
+
if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
481
|
+
value = `\\${value}`;
|
|
482
|
+
}
|
|
483
|
+
push({
|
|
484
|
+
type: 'bracket',
|
|
485
|
+
value
|
|
486
|
+
});
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (']' === value) {
|
|
490
|
+
if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
|
|
491
|
+
push({
|
|
492
|
+
type: 'text',
|
|
493
|
+
value,
|
|
494
|
+
output: `\\${value}`
|
|
495
|
+
});
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (0 === state.brackets) {
|
|
499
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
|
|
500
|
+
push({
|
|
501
|
+
type: 'text',
|
|
502
|
+
value,
|
|
503
|
+
output: `\\${value}`
|
|
504
|
+
});
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
decrement('brackets');
|
|
508
|
+
const prevValue = prev.value.slice(1);
|
|
509
|
+
if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
|
|
510
|
+
prev.value += value;
|
|
511
|
+
append({
|
|
512
|
+
value
|
|
513
|
+
});
|
|
514
|
+
if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
|
|
515
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
516
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
517
|
+
if (true === opts.literalBrackets) {
|
|
518
|
+
state.output += escaped;
|
|
519
|
+
prev.value = escaped;
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
523
|
+
state.output += prev.value;
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
if ('{' === value && true !== opts.nobrace) {
|
|
527
|
+
increment('braces');
|
|
528
|
+
const open = {
|
|
529
|
+
type: 'brace',
|
|
530
|
+
value,
|
|
531
|
+
output: '(',
|
|
532
|
+
outputIndex: state.output.length,
|
|
533
|
+
tokensIndex: state.tokens.length
|
|
534
|
+
};
|
|
535
|
+
braces.push(open);
|
|
536
|
+
push(open);
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
if ('}' === value) {
|
|
540
|
+
const brace = braces[braces.length - 1];
|
|
541
|
+
if (true === opts.nobrace || !brace) {
|
|
542
|
+
push({
|
|
543
|
+
type: 'text',
|
|
544
|
+
value,
|
|
545
|
+
output: value
|
|
546
|
+
});
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
let output = ')';
|
|
550
|
+
if (true === brace.dots) {
|
|
551
|
+
const arr = tokens.slice();
|
|
552
|
+
const range = [];
|
|
553
|
+
for(let i = arr.length - 1; i >= 0; i--){
|
|
554
|
+
tokens.pop();
|
|
555
|
+
if ('brace' === arr[i].type) break;
|
|
556
|
+
if ('dots' !== arr[i].type) range.unshift(arr[i].value);
|
|
557
|
+
}
|
|
558
|
+
output = expandRange(range, opts);
|
|
559
|
+
state.backtrack = true;
|
|
560
|
+
}
|
|
561
|
+
if (true !== brace.comma && true !== brace.dots) {
|
|
562
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
563
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
564
|
+
brace.value = brace.output = '\\{';
|
|
565
|
+
value = output = '\\}';
|
|
566
|
+
state.output = out;
|
|
567
|
+
for (const t of toks)state.output += t.output || t.value;
|
|
568
|
+
}
|
|
569
|
+
push({
|
|
570
|
+
type: 'brace',
|
|
571
|
+
value,
|
|
572
|
+
output
|
|
573
|
+
});
|
|
574
|
+
decrement('braces');
|
|
575
|
+
braces.pop();
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
if ('|' === value) {
|
|
579
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
580
|
+
push({
|
|
581
|
+
type: 'text',
|
|
582
|
+
value
|
|
583
|
+
});
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (',' === value) {
|
|
587
|
+
let output = value;
|
|
588
|
+
const brace = braces[braces.length - 1];
|
|
589
|
+
if (brace && 'braces' === stack[stack.length - 1]) {
|
|
590
|
+
brace.comma = true;
|
|
591
|
+
output = '|';
|
|
592
|
+
}
|
|
593
|
+
push({
|
|
594
|
+
type: 'comma',
|
|
595
|
+
value,
|
|
596
|
+
output
|
|
597
|
+
});
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
if ('/' === value) {
|
|
601
|
+
if ('dot' === prev.type && state.index === state.start + 1) {
|
|
602
|
+
state.start = state.index + 1;
|
|
603
|
+
state.consumed = '';
|
|
604
|
+
state.output = '';
|
|
605
|
+
tokens.pop();
|
|
606
|
+
prev = bos;
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
push({
|
|
610
|
+
type: 'slash',
|
|
611
|
+
value,
|
|
612
|
+
output: SLASH_LITERAL
|
|
613
|
+
});
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if ('.' === value) {
|
|
617
|
+
if (state.braces > 0 && 'dot' === prev.type) {
|
|
618
|
+
if ('.' === prev.value) prev.output = DOT_LITERAL;
|
|
619
|
+
const brace = braces[braces.length - 1];
|
|
620
|
+
prev.type = 'dots';
|
|
621
|
+
prev.output += value;
|
|
622
|
+
prev.value += value;
|
|
623
|
+
brace.dots = true;
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
|
|
627
|
+
push({
|
|
628
|
+
type: 'text',
|
|
629
|
+
value,
|
|
630
|
+
output: DOT_LITERAL
|
|
631
|
+
});
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
push({
|
|
635
|
+
type: 'dot',
|
|
636
|
+
value,
|
|
637
|
+
output: DOT_LITERAL
|
|
638
|
+
});
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
if ('?' === value) {
|
|
642
|
+
const isGroup = prev && '(' === prev.value;
|
|
643
|
+
if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
644
|
+
extglobOpen('qmark', value);
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
if (prev && 'paren' === prev.type) {
|
|
648
|
+
const next = peek();
|
|
649
|
+
let output = value;
|
|
650
|
+
if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
651
|
+
push({
|
|
652
|
+
type: 'text',
|
|
653
|
+
value,
|
|
654
|
+
output
|
|
655
|
+
});
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
|
|
659
|
+
push({
|
|
660
|
+
type: 'qmark',
|
|
661
|
+
value,
|
|
662
|
+
output: QMARK_NO_DOT
|
|
663
|
+
});
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
push({
|
|
667
|
+
type: 'qmark',
|
|
668
|
+
value,
|
|
669
|
+
output: QMARK
|
|
670
|
+
});
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
if ('!' === value) {
|
|
674
|
+
if (true !== opts.noextglob && '(' === peek()) {
|
|
675
|
+
if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
|
|
676
|
+
extglobOpen('negate', value);
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (true !== opts.nonegate && 0 === state.index) {
|
|
681
|
+
negate();
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if ('+' === value) {
|
|
686
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
687
|
+
extglobOpen('plus', value);
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (prev && '(' === prev.value || false === opts.regex) {
|
|
691
|
+
push({
|
|
692
|
+
type: 'plus',
|
|
693
|
+
value,
|
|
694
|
+
output: PLUS_LITERAL
|
|
695
|
+
});
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
|
|
699
|
+
push({
|
|
700
|
+
type: 'plus',
|
|
701
|
+
value
|
|
702
|
+
});
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
push({
|
|
706
|
+
type: 'plus',
|
|
707
|
+
value: PLUS_LITERAL
|
|
708
|
+
});
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
if ('@' === value) {
|
|
712
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
713
|
+
push({
|
|
714
|
+
type: 'at',
|
|
715
|
+
extglob: true,
|
|
716
|
+
value,
|
|
717
|
+
output: ''
|
|
718
|
+
});
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
push({
|
|
722
|
+
type: 'text',
|
|
723
|
+
value
|
|
724
|
+
});
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
if ('*' !== value) {
|
|
728
|
+
if ('$' === value || '^' === value) value = `\\${value}`;
|
|
729
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
730
|
+
if (match) {
|
|
731
|
+
value += match[0];
|
|
732
|
+
state.index += match[0].length;
|
|
733
|
+
}
|
|
734
|
+
push({
|
|
735
|
+
type: 'text',
|
|
736
|
+
value
|
|
737
|
+
});
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
if (prev && ('globstar' === prev.type || true === prev.star)) {
|
|
741
|
+
prev.type = 'star';
|
|
742
|
+
prev.star = true;
|
|
743
|
+
prev.value += value;
|
|
744
|
+
prev.output = star;
|
|
745
|
+
state.backtrack = true;
|
|
746
|
+
state.globstar = true;
|
|
747
|
+
consume(value);
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
let rest = remaining();
|
|
751
|
+
if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
|
|
752
|
+
extglobOpen('star', value);
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
if ('star' === prev.type) {
|
|
756
|
+
if (true === opts.noglobstar) {
|
|
757
|
+
consume(value);
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
const prior = prev.prev;
|
|
761
|
+
const before = prior.prev;
|
|
762
|
+
const isStart = 'slash' === prior.type || 'bos' === prior.type;
|
|
763
|
+
const afterStar = before && ('star' === before.type || 'globstar' === before.type);
|
|
764
|
+
if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
|
|
765
|
+
push({
|
|
766
|
+
type: 'star',
|
|
767
|
+
value,
|
|
768
|
+
output: ''
|
|
769
|
+
});
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
|
|
773
|
+
const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
|
|
774
|
+
if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
|
|
775
|
+
push({
|
|
776
|
+
type: 'star',
|
|
777
|
+
value,
|
|
778
|
+
output: ''
|
|
779
|
+
});
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
while('/**' === rest.slice(0, 3)){
|
|
783
|
+
const after = input[state.index + 4];
|
|
784
|
+
if (after && '/' !== after) break;
|
|
785
|
+
rest = rest.slice(3);
|
|
786
|
+
consume('/**', 3);
|
|
787
|
+
}
|
|
788
|
+
if ('bos' === prior.type && eos()) {
|
|
789
|
+
prev.type = 'globstar';
|
|
790
|
+
prev.value += value;
|
|
791
|
+
prev.output = globstar(opts);
|
|
792
|
+
state.output = prev.output;
|
|
793
|
+
state.globstar = true;
|
|
794
|
+
consume(value);
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
|
|
798
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
799
|
+
prior.output = `(?:${prior.output}`;
|
|
800
|
+
prev.type = 'globstar';
|
|
801
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
802
|
+
prev.value += value;
|
|
803
|
+
state.globstar = true;
|
|
804
|
+
state.output += prior.output + prev.output;
|
|
805
|
+
consume(value);
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
|
|
809
|
+
const end = void 0 !== rest[1] ? '|$' : '';
|
|
810
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
811
|
+
prior.output = `(?:${prior.output}`;
|
|
812
|
+
prev.type = 'globstar';
|
|
813
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
814
|
+
prev.value += value;
|
|
815
|
+
state.output += prior.output + prev.output;
|
|
816
|
+
state.globstar = true;
|
|
817
|
+
consume(value + advance());
|
|
818
|
+
push({
|
|
819
|
+
type: 'slash',
|
|
820
|
+
value: '/',
|
|
821
|
+
output: ''
|
|
822
|
+
});
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
if ('bos' === prior.type && '/' === rest[0]) {
|
|
826
|
+
prev.type = 'globstar';
|
|
827
|
+
prev.value += value;
|
|
828
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
829
|
+
state.output = prev.output;
|
|
830
|
+
state.globstar = true;
|
|
831
|
+
consume(value + advance());
|
|
832
|
+
push({
|
|
833
|
+
type: 'slash',
|
|
834
|
+
value: '/',
|
|
835
|
+
output: ''
|
|
836
|
+
});
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
840
|
+
prev.type = 'globstar';
|
|
841
|
+
prev.output = globstar(opts);
|
|
842
|
+
prev.value += value;
|
|
843
|
+
state.output += prev.output;
|
|
844
|
+
state.globstar = true;
|
|
845
|
+
consume(value);
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
const token = {
|
|
849
|
+
type: 'star',
|
|
850
|
+
value,
|
|
851
|
+
output: star
|
|
852
|
+
};
|
|
853
|
+
if (true === opts.bash) {
|
|
854
|
+
token.output = '.*?';
|
|
855
|
+
if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
|
|
856
|
+
push(token);
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
|
|
860
|
+
token.output = value;
|
|
861
|
+
push(token);
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
|
|
865
|
+
if ('dot' === prev.type) {
|
|
866
|
+
state.output += NO_DOT_SLASH;
|
|
867
|
+
prev.output += NO_DOT_SLASH;
|
|
868
|
+
} else if (true === opts.dot) {
|
|
869
|
+
state.output += NO_DOTS_SLASH;
|
|
870
|
+
prev.output += NO_DOTS_SLASH;
|
|
871
|
+
} else {
|
|
872
|
+
state.output += nodot;
|
|
873
|
+
prev.output += nodot;
|
|
874
|
+
}
|
|
875
|
+
if ('*' !== peek()) {
|
|
876
|
+
state.output += ONE_CHAR;
|
|
877
|
+
prev.output += ONE_CHAR;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
push(token);
|
|
881
|
+
}
|
|
882
|
+
while(state.brackets > 0){
|
|
883
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
884
|
+
state.output = utils.escapeLast(state.output, '[');
|
|
885
|
+
decrement('brackets');
|
|
886
|
+
}
|
|
887
|
+
while(state.parens > 0){
|
|
888
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
|
|
889
|
+
state.output = utils.escapeLast(state.output, '(');
|
|
890
|
+
decrement('parens');
|
|
891
|
+
}
|
|
892
|
+
while(state.braces > 0){
|
|
893
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
|
|
894
|
+
state.output = utils.escapeLast(state.output, '{');
|
|
895
|
+
decrement('braces');
|
|
896
|
+
}
|
|
897
|
+
if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
|
|
898
|
+
type: 'maybe_slash',
|
|
899
|
+
value: '',
|
|
900
|
+
output: `${SLASH_LITERAL}?`
|
|
901
|
+
});
|
|
902
|
+
if (true === state.backtrack) {
|
|
903
|
+
state.output = '';
|
|
904
|
+
for (const token of state.tokens){
|
|
905
|
+
state.output += null != token.output ? token.output : token.value;
|
|
906
|
+
if (token.suffix) state.output += token.suffix;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return state;
|
|
910
|
+
};
|
|
911
|
+
parse.fastpaths = (input, options)=>{
|
|
912
|
+
const opts = {
|
|
913
|
+
...options
|
|
914
|
+
};
|
|
915
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
916
|
+
const len = input.length;
|
|
917
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
918
|
+
input = REPLACEMENTS[input] || input;
|
|
919
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
920
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
921
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
922
|
+
const capture = opts.capture ? '' : '?:';
|
|
923
|
+
const state = {
|
|
924
|
+
negated: false,
|
|
925
|
+
prefix: ''
|
|
926
|
+
};
|
|
927
|
+
let star = true === opts.bash ? '.*?' : STAR;
|
|
928
|
+
if (opts.capture) star = `(${star})`;
|
|
929
|
+
const globstar = (opts)=>{
|
|
930
|
+
if (true === opts.noglobstar) return star;
|
|
931
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
932
|
+
};
|
|
933
|
+
const create = (str)=>{
|
|
934
|
+
switch(str){
|
|
935
|
+
case '*':
|
|
936
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
937
|
+
case '.*':
|
|
938
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
939
|
+
case '*.*':
|
|
940
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
941
|
+
case '*/*':
|
|
942
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
943
|
+
case '**':
|
|
944
|
+
return nodot + globstar(opts);
|
|
945
|
+
case '**/*':
|
|
946
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
947
|
+
case '**/*.*':
|
|
948
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
949
|
+
case '**/.*':
|
|
950
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
951
|
+
default:
|
|
952
|
+
{
|
|
953
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
954
|
+
if (!match) return;
|
|
955
|
+
const source = create(match[1]);
|
|
956
|
+
if (!source) return;
|
|
957
|
+
return source + DOT_LITERAL + match[2];
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
const output = utils.removePrefix(input, state);
|
|
962
|
+
let source = create(output);
|
|
963
|
+
if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
|
|
964
|
+
return source;
|
|
965
|
+
};
|
|
966
|
+
module.exports = parse;
|
|
967
|
+
},
|
|
968
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
969
|
+
const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js");
|
|
970
|
+
const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js");
|
|
971
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
|
|
972
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
|
|
973
|
+
const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
|
|
974
|
+
const picomatch = (glob, options, returnState = false)=>{
|
|
975
|
+
if (Array.isArray(glob)) {
|
|
976
|
+
const fns = glob.map((input)=>picomatch(input, options, returnState));
|
|
977
|
+
const arrayMatcher = (str)=>{
|
|
978
|
+
for (const isMatch of fns){
|
|
979
|
+
const state = isMatch(str);
|
|
980
|
+
if (state) return state;
|
|
981
|
+
}
|
|
982
|
+
return false;
|
|
983
|
+
};
|
|
984
|
+
return arrayMatcher;
|
|
985
|
+
}
|
|
986
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
987
|
+
if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
|
|
988
|
+
const opts = options || {};
|
|
989
|
+
const posix = opts.windows;
|
|
990
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
991
|
+
const state = regex.state;
|
|
992
|
+
delete regex.state;
|
|
993
|
+
let isIgnored = ()=>false;
|
|
994
|
+
if (opts.ignore) {
|
|
995
|
+
const ignoreOpts = {
|
|
996
|
+
...options,
|
|
997
|
+
ignore: null,
|
|
998
|
+
onMatch: null,
|
|
999
|
+
onResult: null
|
|
1000
|
+
};
|
|
1001
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1002
|
+
}
|
|
1003
|
+
const matcher = (input, returnObject = false)=>{
|
|
1004
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1005
|
+
glob,
|
|
1006
|
+
posix
|
|
1007
|
+
});
|
|
1008
|
+
const result = {
|
|
1009
|
+
glob,
|
|
1010
|
+
state,
|
|
1011
|
+
regex,
|
|
1012
|
+
posix,
|
|
1013
|
+
input,
|
|
1014
|
+
output,
|
|
1015
|
+
match,
|
|
1016
|
+
isMatch
|
|
1017
|
+
};
|
|
1018
|
+
if ('function' == typeof opts.onResult) opts.onResult(result);
|
|
1019
|
+
if (false === isMatch) {
|
|
1020
|
+
result.isMatch = false;
|
|
1021
|
+
return returnObject ? result : false;
|
|
1022
|
+
}
|
|
1023
|
+
if (isIgnored(input)) {
|
|
1024
|
+
if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
|
|
1025
|
+
result.isMatch = false;
|
|
1026
|
+
return returnObject ? result : false;
|
|
1027
|
+
}
|
|
1028
|
+
if ('function' == typeof opts.onMatch) opts.onMatch(result);
|
|
1029
|
+
return returnObject ? result : true;
|
|
1030
|
+
};
|
|
1031
|
+
if (returnState) matcher.state = state;
|
|
1032
|
+
return matcher;
|
|
1033
|
+
};
|
|
1034
|
+
picomatch.test = (input, regex, options, { glob, posix } = {})=>{
|
|
1035
|
+
if ('string' != typeof input) throw new TypeError('Expected input to be a string');
|
|
1036
|
+
if ('' === input) return {
|
|
1037
|
+
isMatch: false,
|
|
1038
|
+
output: ''
|
|
1039
|
+
};
|
|
1040
|
+
const opts = options || {};
|
|
1041
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1042
|
+
let match = input === glob;
|
|
1043
|
+
let output = match && format ? format(input) : input;
|
|
1044
|
+
if (false === match) {
|
|
1045
|
+
output = format ? format(input) : input;
|
|
1046
|
+
match = output === glob;
|
|
1047
|
+
}
|
|
1048
|
+
if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
|
|
1049
|
+
return {
|
|
1050
|
+
isMatch: Boolean(match),
|
|
1051
|
+
match,
|
|
1052
|
+
output
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
picomatch.matchBase = (input, glob, options)=>{
|
|
1056
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1057
|
+
return regex.test(utils.basename(input));
|
|
1058
|
+
};
|
|
1059
|
+
picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
|
|
1060
|
+
picomatch.parse = (pattern, options)=>{
|
|
1061
|
+
if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
|
|
1062
|
+
return parse(pattern, {
|
|
1063
|
+
...options,
|
|
1064
|
+
fastpaths: false
|
|
1065
|
+
});
|
|
1066
|
+
};
|
|
1067
|
+
picomatch.scan = (input, options)=>scan(input, options);
|
|
1068
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
|
|
1069
|
+
if (true === returnOutput) return state.output;
|
|
1070
|
+
const opts = options || {};
|
|
1071
|
+
const prepend = opts.contains ? '' : '^';
|
|
1072
|
+
const append = opts.contains ? '' : '$';
|
|
1073
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1074
|
+
if (state && true === state.negated) source = `^(?!${source}).*$`;
|
|
1075
|
+
const regex = picomatch.toRegex(source, options);
|
|
1076
|
+
if (true === returnState) regex.state = state;
|
|
1077
|
+
return regex;
|
|
1078
|
+
};
|
|
1079
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
|
|
1080
|
+
if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
|
|
1081
|
+
let parsed = {
|
|
1082
|
+
negated: false,
|
|
1083
|
+
fastpaths: true
|
|
1084
|
+
};
|
|
1085
|
+
if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
|
|
1086
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
1087
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1088
|
+
};
|
|
1089
|
+
picomatch.toRegex = (source, options)=>{
|
|
1090
|
+
try {
|
|
1091
|
+
const opts = options || {};
|
|
1092
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
1093
|
+
} catch (err) {
|
|
1094
|
+
if (options && true === options.debug) throw err;
|
|
1095
|
+
return /$^/;
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
picomatch.constants = constants;
|
|
1099
|
+
module.exports = picomatch;
|
|
1100
|
+
},
|
|
1101
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1102
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
|
|
1103
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
|
|
1104
|
+
const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1105
|
+
const depth = (token)=>{
|
|
1106
|
+
if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
|
|
1107
|
+
};
|
|
1108
|
+
const scan = (input, options)=>{
|
|
1109
|
+
const opts = options || {};
|
|
1110
|
+
const length = input.length - 1;
|
|
1111
|
+
const scanToEnd = true === opts.parts || true === opts.scanToEnd;
|
|
1112
|
+
const slashes = [];
|
|
1113
|
+
const tokens = [];
|
|
1114
|
+
const parts = [];
|
|
1115
|
+
let str = input;
|
|
1116
|
+
let index = -1;
|
|
1117
|
+
let start = 0;
|
|
1118
|
+
let lastIndex = 0;
|
|
1119
|
+
let isBrace = false;
|
|
1120
|
+
let isBracket = false;
|
|
1121
|
+
let isGlob = false;
|
|
1122
|
+
let isExtglob = false;
|
|
1123
|
+
let isGlobstar = false;
|
|
1124
|
+
let braceEscaped = false;
|
|
1125
|
+
let backslashes = false;
|
|
1126
|
+
let negated = false;
|
|
1127
|
+
let negatedExtglob = false;
|
|
1128
|
+
let finished = false;
|
|
1129
|
+
let braces = 0;
|
|
1130
|
+
let prev;
|
|
1131
|
+
let code;
|
|
1132
|
+
let token = {
|
|
1133
|
+
value: '',
|
|
1134
|
+
depth: 0,
|
|
1135
|
+
isGlob: false
|
|
1136
|
+
};
|
|
1137
|
+
const eos = ()=>index >= length;
|
|
1138
|
+
const peek = ()=>str.charCodeAt(index + 1);
|
|
1139
|
+
const advance = ()=>{
|
|
1140
|
+
prev = code;
|
|
1141
|
+
return str.charCodeAt(++index);
|
|
1142
|
+
};
|
|
1143
|
+
while(index < length){
|
|
1144
|
+
code = advance();
|
|
1145
|
+
let next;
|
|
1146
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1147
|
+
backslashes = token.backslashes = true;
|
|
1148
|
+
code = advance();
|
|
1149
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1153
|
+
braces++;
|
|
1154
|
+
while(true !== eos() && (code = advance())){
|
|
1155
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1156
|
+
backslashes = token.backslashes = true;
|
|
1157
|
+
advance();
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1161
|
+
braces++;
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1165
|
+
isBrace = token.isBrace = true;
|
|
1166
|
+
isGlob = token.isGlob = true;
|
|
1167
|
+
finished = true;
|
|
1168
|
+
if (true === scanToEnd) continue;
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
if (true !== braceEscaped && code === CHAR_COMMA) {
|
|
1172
|
+
isBrace = token.isBrace = true;
|
|
1173
|
+
isGlob = token.isGlob = true;
|
|
1174
|
+
finished = true;
|
|
1175
|
+
if (true === scanToEnd) continue;
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1179
|
+
braces--;
|
|
1180
|
+
if (0 === braces) {
|
|
1181
|
+
braceEscaped = false;
|
|
1182
|
+
isBrace = token.isBrace = true;
|
|
1183
|
+
finished = true;
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
if (true === scanToEnd) continue;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1192
|
+
slashes.push(index);
|
|
1193
|
+
tokens.push(token);
|
|
1194
|
+
token = {
|
|
1195
|
+
value: '',
|
|
1196
|
+
depth: 0,
|
|
1197
|
+
isGlob: false
|
|
1198
|
+
};
|
|
1199
|
+
if (true === finished) continue;
|
|
1200
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1201
|
+
start += 2;
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
lastIndex = index + 1;
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (true !== opts.noext) {
|
|
1208
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1209
|
+
if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1210
|
+
isGlob = token.isGlob = true;
|
|
1211
|
+
isExtglob = token.isExtglob = true;
|
|
1212
|
+
finished = true;
|
|
1213
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
1214
|
+
if (true === scanToEnd) {
|
|
1215
|
+
while(true !== eos() && (code = advance())){
|
|
1216
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1217
|
+
backslashes = token.backslashes = true;
|
|
1218
|
+
code = advance();
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1222
|
+
isGlob = token.isGlob = true;
|
|
1223
|
+
finished = true;
|
|
1224
|
+
break;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (code === CHAR_ASTERISK) {
|
|
1233
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1234
|
+
isGlob = token.isGlob = true;
|
|
1235
|
+
finished = true;
|
|
1236
|
+
if (true === scanToEnd) continue;
|
|
1237
|
+
break;
|
|
1238
|
+
}
|
|
1239
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1240
|
+
isGlob = token.isGlob = true;
|
|
1241
|
+
finished = true;
|
|
1242
|
+
if (true === scanToEnd) continue;
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1246
|
+
while(true !== eos() && (next = advance())){
|
|
1247
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1248
|
+
backslashes = token.backslashes = true;
|
|
1249
|
+
advance();
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1253
|
+
isBracket = token.isBracket = true;
|
|
1254
|
+
isGlob = token.isGlob = true;
|
|
1255
|
+
finished = true;
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
if (true === scanToEnd) continue;
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1263
|
+
negated = token.negated = true;
|
|
1264
|
+
start++;
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
|
|
1268
|
+
isGlob = token.isGlob = true;
|
|
1269
|
+
if (true === scanToEnd) {
|
|
1270
|
+
while(true !== eos() && (code = advance())){
|
|
1271
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1272
|
+
backslashes = token.backslashes = true;
|
|
1273
|
+
code = advance();
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1277
|
+
finished = true;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
continue;
|
|
1282
|
+
}
|
|
1283
|
+
break;
|
|
1284
|
+
}
|
|
1285
|
+
if (true === isGlob) {
|
|
1286
|
+
finished = true;
|
|
1287
|
+
if (true === scanToEnd) continue;
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
if (true === opts.noext) {
|
|
1292
|
+
isExtglob = false;
|
|
1293
|
+
isGlob = false;
|
|
1294
|
+
}
|
|
1295
|
+
let base = str;
|
|
1296
|
+
let prefix = '';
|
|
1297
|
+
let glob = '';
|
|
1298
|
+
if (start > 0) {
|
|
1299
|
+
prefix = str.slice(0, start);
|
|
1300
|
+
str = str.slice(start);
|
|
1301
|
+
lastIndex -= start;
|
|
1302
|
+
}
|
|
1303
|
+
if (base && true === isGlob && lastIndex > 0) {
|
|
1304
|
+
base = str.slice(0, lastIndex);
|
|
1305
|
+
glob = str.slice(lastIndex);
|
|
1306
|
+
} else if (true === isGlob) {
|
|
1307
|
+
base = '';
|
|
1308
|
+
glob = str;
|
|
1309
|
+
} else base = str;
|
|
1310
|
+
if (base && '' !== base && '/' !== base && base !== str) {
|
|
1311
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
1312
|
+
}
|
|
1313
|
+
if (true === opts.unescape) {
|
|
1314
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
1315
|
+
if (base && true === backslashes) base = utils.removeBackslashes(base);
|
|
1316
|
+
}
|
|
1317
|
+
const state = {
|
|
1318
|
+
prefix,
|
|
1319
|
+
input,
|
|
1320
|
+
start,
|
|
1321
|
+
base,
|
|
1322
|
+
glob,
|
|
1323
|
+
isBrace,
|
|
1324
|
+
isBracket,
|
|
1325
|
+
isGlob,
|
|
1326
|
+
isExtglob,
|
|
1327
|
+
isGlobstar,
|
|
1328
|
+
negated,
|
|
1329
|
+
negatedExtglob
|
|
1330
|
+
};
|
|
1331
|
+
if (true === opts.tokens) {
|
|
1332
|
+
state.maxDepth = 0;
|
|
1333
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
1334
|
+
state.tokens = tokens;
|
|
1335
|
+
}
|
|
1336
|
+
if (true === opts.parts || true === opts.tokens) {
|
|
1337
|
+
let prevIndex;
|
|
1338
|
+
for(let idx = 0; idx < slashes.length; idx++){
|
|
1339
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1340
|
+
const i = slashes[idx];
|
|
1341
|
+
const value = input.slice(n, i);
|
|
1342
|
+
if (opts.tokens) {
|
|
1343
|
+
if (0 === idx && 0 !== start) {
|
|
1344
|
+
tokens[idx].isPrefix = true;
|
|
1345
|
+
tokens[idx].value = prefix;
|
|
1346
|
+
} else tokens[idx].value = value;
|
|
1347
|
+
depth(tokens[idx]);
|
|
1348
|
+
state.maxDepth += tokens[idx].depth;
|
|
1349
|
+
}
|
|
1350
|
+
if (0 !== idx || '' !== value) parts.push(value);
|
|
1351
|
+
prevIndex = i;
|
|
1352
|
+
}
|
|
1353
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1354
|
+
const value = input.slice(prevIndex + 1);
|
|
1355
|
+
parts.push(value);
|
|
1356
|
+
if (opts.tokens) {
|
|
1357
|
+
tokens[tokens.length - 1].value = value;
|
|
1358
|
+
depth(tokens[tokens.length - 1]);
|
|
1359
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
state.slashes = slashes;
|
|
1363
|
+
state.parts = parts;
|
|
1364
|
+
}
|
|
1365
|
+
return state;
|
|
1366
|
+
};
|
|
1367
|
+
module.exports = scan;
|
|
1368
|
+
},
|
|
1369
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1370
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
|
|
1371
|
+
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
1372
|
+
exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
|
|
1373
|
+
exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
|
|
1374
|
+
exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
1375
|
+
exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
|
|
1376
|
+
exports.isWindows = ()=>{
|
|
1377
|
+
if ("u" > typeof navigator && navigator.platform) {
|
|
1378
|
+
const platform = navigator.platform.toLowerCase();
|
|
1379
|
+
return 'win32' === platform || 'windows' === platform;
|
|
1380
|
+
}
|
|
1381
|
+
if ("u" > typeof process && process.platform) return 'win32' === process.platform;
|
|
1382
|
+
return false;
|
|
1383
|
+
};
|
|
1384
|
+
exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
|
|
1385
|
+
exports.escapeLast = (input, char, lastIdx)=>{
|
|
1386
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1387
|
+
if (-1 === idx) return input;
|
|
1388
|
+
if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
|
|
1389
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1390
|
+
};
|
|
1391
|
+
exports.removePrefix = (input, state = {})=>{
|
|
1392
|
+
let output = input;
|
|
1393
|
+
if (output.startsWith('./')) {
|
|
1394
|
+
output = output.slice(2);
|
|
1395
|
+
state.prefix = './';
|
|
1396
|
+
}
|
|
1397
|
+
return output;
|
|
1398
|
+
};
|
|
1399
|
+
exports.wrapOutput = (input, state = {}, options = {})=>{
|
|
1400
|
+
const prepend = options.contains ? '' : '^';
|
|
1401
|
+
const append = options.contains ? '' : '$';
|
|
1402
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
1403
|
+
if (true === state.negated) output = `(?:^(?!${output}).*$)`;
|
|
1404
|
+
return output;
|
|
1405
|
+
};
|
|
1406
|
+
exports.basename = (path, { windows } = {})=>{
|
|
1407
|
+
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
1408
|
+
const last = segs[segs.length - 1];
|
|
1409
|
+
if ('' === last) return segs[segs.length - 2];
|
|
1410
|
+
return last;
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1415
|
+
function cleanPath(path) {
|
|
1416
|
+
let normalized = normalize(path);
|
|
1417
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
1418
|
+
return normalized;
|
|
1419
|
+
}
|
|
1420
|
+
const SLASHES_REGEX = /[\\/]/g;
|
|
1421
|
+
function convertSlashes(path, separator) {
|
|
1422
|
+
return path.replace(SLASHES_REGEX, separator);
|
|
1423
|
+
}
|
|
1424
|
+
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
1425
|
+
function isRootDirectory(path) {
|
|
1426
|
+
return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
1427
|
+
}
|
|
1428
|
+
function normalizePath(path, options) {
|
|
1429
|
+
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
1430
|
+
const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
|
|
1431
|
+
if (resolvePaths) path = resolve(path);
|
|
1432
|
+
if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
1433
|
+
if ("." === path) return "";
|
|
1434
|
+
const needsSeperator = path[path.length - 1] !== pathSeparator;
|
|
1435
|
+
return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
|
|
1436
|
+
}
|
|
1437
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
1438
|
+
return directoryPath + filename;
|
|
1439
|
+
}
|
|
1440
|
+
function joinPathWithRelativePath(root, options) {
|
|
1441
|
+
return function(filename, directoryPath) {
|
|
1442
|
+
const sameRoot = directoryPath.startsWith(root);
|
|
1443
|
+
if (sameRoot) return directoryPath.slice(root.length) + filename;
|
|
1444
|
+
return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
function joinPath(filename) {
|
|
1448
|
+
return filename;
|
|
1449
|
+
}
|
|
1450
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
1451
|
+
return directoryPath + filename + separator;
|
|
1452
|
+
}
|
|
1453
|
+
function build$7(root, options) {
|
|
1454
|
+
const { relativePaths, includeBasePath } = options;
|
|
1455
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
1456
|
+
}
|
|
1457
|
+
function pushDirectoryWithRelativePath(root) {
|
|
1458
|
+
return function(directoryPath, paths) {
|
|
1459
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
1463
|
+
return function(directoryPath, paths, filters) {
|
|
1464
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
1465
|
+
if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
const pushDirectory = (directoryPath, paths)=>{
|
|
1469
|
+
paths.push(directoryPath || ".");
|
|
1470
|
+
};
|
|
1471
|
+
const pushDirectoryFilter = (directoryPath, paths, filters)=>{
|
|
1472
|
+
const path = directoryPath || ".";
|
|
1473
|
+
if (filters.every((filter)=>filter(path, true))) paths.push(path);
|
|
1474
|
+
};
|
|
1475
|
+
const empty$2 = ()=>{};
|
|
1476
|
+
function build$6(root, options) {
|
|
1477
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
1478
|
+
if (!includeDirs) return empty$2;
|
|
1479
|
+
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
1480
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
1481
|
+
}
|
|
1482
|
+
const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
|
|
1483
|
+
if (filters.every((filter)=>filter(filename, false))) counts.files++;
|
|
1484
|
+
};
|
|
1485
|
+
const pushFileFilter = (filename, paths, _counts, filters)=>{
|
|
1486
|
+
if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
|
|
1487
|
+
};
|
|
1488
|
+
const pushFileCount = (_filename, _paths, counts, _filters)=>{
|
|
1489
|
+
counts.files++;
|
|
1490
|
+
};
|
|
1491
|
+
const pushFile = (filename, paths)=>{
|
|
1492
|
+
paths.push(filename);
|
|
1493
|
+
};
|
|
1494
|
+
const empty$1 = ()=>{};
|
|
1495
|
+
function build$5(options) {
|
|
1496
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
1497
|
+
if (excludeFiles) return empty$1;
|
|
1498
|
+
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
1499
|
+
if (onlyCounts) return pushFileCount;
|
|
1500
|
+
return pushFile;
|
|
1501
|
+
}
|
|
1502
|
+
const getArray = (paths)=>paths;
|
|
1503
|
+
const getArrayGroup = ()=>[
|
|
1504
|
+
""
|
|
1505
|
+
].slice(0, 0);
|
|
1506
|
+
function build$4(options) {
|
|
1507
|
+
return options.group ? getArrayGroup : getArray;
|
|
1508
|
+
}
|
|
1509
|
+
const groupFiles = (groups, directory, files)=>{
|
|
1510
|
+
groups.push({
|
|
1511
|
+
directory,
|
|
1512
|
+
files,
|
|
1513
|
+
dir: directory
|
|
1514
|
+
});
|
|
1515
|
+
};
|
|
1516
|
+
const empty = ()=>{};
|
|
1517
|
+
function build$3(options) {
|
|
1518
|
+
return options.group ? groupFiles : empty;
|
|
1519
|
+
}
|
|
1520
|
+
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
1521
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
1522
|
+
queue.enqueue();
|
|
1523
|
+
fs.realpath(path, (error, resolvedPath)=>{
|
|
1524
|
+
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
1525
|
+
fs.stat(resolvedPath, (error$1, stat)=>{
|
|
1526
|
+
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
1527
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1528
|
+
callback$1(stat, resolvedPath);
|
|
1529
|
+
queue.dequeue(null, state);
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
};
|
|
1533
|
+
const resolveSymlinks = function(path, state, callback$1) {
|
|
1534
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
1535
|
+
queue.enqueue();
|
|
1536
|
+
try {
|
|
1537
|
+
const resolvedPath = fs.realpathSync(path);
|
|
1538
|
+
const stat = fs.statSync(resolvedPath);
|
|
1539
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
1540
|
+
callback$1(stat, resolvedPath);
|
|
1541
|
+
} catch (e) {
|
|
1542
|
+
if (!suppressErrors) throw e;
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
function build$2(options, isSynchronous) {
|
|
1546
|
+
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
1547
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
1548
|
+
}
|
|
1549
|
+
function isRecursive(path, resolved, state) {
|
|
1550
|
+
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
1551
|
+
let parent = dirname(path);
|
|
1552
|
+
let depth = 1;
|
|
1553
|
+
while(parent !== state.root && depth < 2){
|
|
1554
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
1555
|
+
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
1556
|
+
if (isSameRoot) depth++;
|
|
1557
|
+
else parent = dirname(parent);
|
|
1558
|
+
}
|
|
1559
|
+
state.symlinks.set(path, resolved);
|
|
1560
|
+
return depth > 1;
|
|
1561
|
+
}
|
|
1562
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
1563
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
1564
|
+
}
|
|
1565
|
+
const onlyCountsSync = (state)=>state.counts;
|
|
1566
|
+
const groupsSync = (state)=>state.groups;
|
|
1567
|
+
const defaultSync = (state)=>state.paths;
|
|
1568
|
+
const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
|
|
1569
|
+
const onlyCountsAsync = (state, error, callback$1)=>{
|
|
1570
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
1571
|
+
return null;
|
|
1572
|
+
};
|
|
1573
|
+
const defaultAsync = (state, error, callback$1)=>{
|
|
1574
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
1575
|
+
return null;
|
|
1576
|
+
};
|
|
1577
|
+
const limitFilesAsync = (state, error, callback$1)=>{
|
|
1578
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
1579
|
+
return null;
|
|
1580
|
+
};
|
|
1581
|
+
const groupsAsync = (state, error, callback$1)=>{
|
|
1582
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
1583
|
+
return null;
|
|
1584
|
+
};
|
|
1585
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
1586
|
+
callback$1(error && !suppressErrors ? error : null, output);
|
|
1587
|
+
}
|
|
1588
|
+
function build$1(options, isSynchronous) {
|
|
1589
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
1590
|
+
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
1591
|
+
if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
1592
|
+
if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
1593
|
+
return isSynchronous ? defaultSync : defaultAsync;
|
|
1594
|
+
}
|
|
1595
|
+
const readdirOpts = {
|
|
1596
|
+
withFileTypes: true
|
|
1597
|
+
};
|
|
1598
|
+
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
1599
|
+
state.queue.enqueue();
|
|
1600
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
1601
|
+
const { fs } = state;
|
|
1602
|
+
state.visited.push(crawlPath);
|
|
1603
|
+
state.counts.directories++;
|
|
1604
|
+
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
|
|
1605
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
1606
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
1607
|
+
});
|
|
1608
|
+
};
|
|
1609
|
+
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
1610
|
+
const { fs } = state;
|
|
1611
|
+
if (currentDepth < 0) return;
|
|
1612
|
+
state.visited.push(crawlPath);
|
|
1613
|
+
state.counts.directories++;
|
|
1614
|
+
let entries = [];
|
|
1615
|
+
try {
|
|
1616
|
+
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
1617
|
+
} catch (e) {
|
|
1618
|
+
if (!state.options.suppressErrors) throw e;
|
|
1619
|
+
}
|
|
1620
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
1621
|
+
};
|
|
1622
|
+
function build(isSynchronous) {
|
|
1623
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
1624
|
+
}
|
|
1625
|
+
var Queue = class {
|
|
1626
|
+
count = 0;
|
|
1627
|
+
constructor(onQueueEmpty){
|
|
1628
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
1629
|
+
}
|
|
1630
|
+
enqueue() {
|
|
1631
|
+
this.count++;
|
|
1632
|
+
return this.count;
|
|
1633
|
+
}
|
|
1634
|
+
dequeue(error, output) {
|
|
1635
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
1636
|
+
this.onQueueEmpty(error, output);
|
|
1637
|
+
if (error) {
|
|
1638
|
+
output.controller.abort();
|
|
1639
|
+
this.onQueueEmpty = void 0;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
var Counter = class {
|
|
1645
|
+
_files = 0;
|
|
1646
|
+
_directories = 0;
|
|
1647
|
+
set files(num) {
|
|
1648
|
+
this._files = num;
|
|
1649
|
+
}
|
|
1650
|
+
get files() {
|
|
1651
|
+
return this._files;
|
|
1652
|
+
}
|
|
1653
|
+
set directories(num) {
|
|
1654
|
+
this._directories = num;
|
|
1655
|
+
}
|
|
1656
|
+
get directories() {
|
|
1657
|
+
return this._directories;
|
|
1658
|
+
}
|
|
1659
|
+
get dirs() {
|
|
1660
|
+
return this._directories;
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
var Aborter = class {
|
|
1664
|
+
aborted = false;
|
|
1665
|
+
abort() {
|
|
1666
|
+
this.aborted = true;
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
var Walker = class {
|
|
1670
|
+
root;
|
|
1671
|
+
isSynchronous;
|
|
1672
|
+
state;
|
|
1673
|
+
joinPath;
|
|
1674
|
+
pushDirectory;
|
|
1675
|
+
pushFile;
|
|
1676
|
+
getArray;
|
|
1677
|
+
groupFiles;
|
|
1678
|
+
resolveSymlink;
|
|
1679
|
+
walkDirectory;
|
|
1680
|
+
callbackInvoker;
|
|
1681
|
+
constructor(root, options, callback$1){
|
|
1682
|
+
this.isSynchronous = !callback$1;
|
|
1683
|
+
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
1684
|
+
this.root = normalizePath(root, options);
|
|
1685
|
+
this.state = {
|
|
1686
|
+
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
1687
|
+
paths: [
|
|
1688
|
+
""
|
|
1689
|
+
].slice(0, 0),
|
|
1690
|
+
groups: [],
|
|
1691
|
+
counts: new Counter(),
|
|
1692
|
+
options,
|
|
1693
|
+
queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
|
|
1694
|
+
symlinks: /* @__PURE__ */ new Map(),
|
|
1695
|
+
visited: [
|
|
1696
|
+
""
|
|
1697
|
+
].slice(0, 0),
|
|
1698
|
+
controller: new Aborter(),
|
|
1699
|
+
fs: options.fs || __rspack_external_fs
|
|
1700
|
+
};
|
|
1701
|
+
this.joinPath = build$7(this.root, options);
|
|
1702
|
+
this.pushDirectory = build$6(this.root, options);
|
|
1703
|
+
this.pushFile = build$5(options);
|
|
1704
|
+
this.getArray = build$4(options);
|
|
1705
|
+
this.groupFiles = build$3(options);
|
|
1706
|
+
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
1707
|
+
this.walkDirectory = build(this.isSynchronous);
|
|
1708
|
+
}
|
|
1709
|
+
start() {
|
|
1710
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
1711
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
1712
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
1713
|
+
}
|
|
1714
|
+
walk = (entries, directoryPath, depth)=>{
|
|
1715
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
1716
|
+
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
1717
|
+
const files = this.getArray(this.state.paths);
|
|
1718
|
+
for(let i = 0; i < entries.length; ++i){
|
|
1719
|
+
const entry = entries[i];
|
|
1720
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
1721
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
1722
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
1723
|
+
} else if (entry.isDirectory()) {
|
|
1724
|
+
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
1725
|
+
if (exclude && exclude(entry.name, path)) continue;
|
|
1726
|
+
this.pushDirectory(path, paths, filters);
|
|
1727
|
+
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
1728
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
1729
|
+
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
1730
|
+
this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
|
|
1731
|
+
if (stat.isDirectory()) {
|
|
1732
|
+
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
1733
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
1734
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
1735
|
+
} else {
|
|
1736
|
+
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
1737
|
+
const filename = basename(resolvedPath);
|
|
1738
|
+
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
1739
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
1740
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
1746
|
+
};
|
|
1747
|
+
};
|
|
1748
|
+
function promise(root, options) {
|
|
1749
|
+
return new Promise((resolve$1, reject)=>{
|
|
1750
|
+
callback(root, options, (err, output)=>{
|
|
1751
|
+
if (err) return reject(err);
|
|
1752
|
+
resolve$1(output);
|
|
1753
|
+
});
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
function callback(root, options, callback$1) {
|
|
1757
|
+
let walker = new Walker(root, options, callback$1);
|
|
1758
|
+
walker.start();
|
|
1759
|
+
}
|
|
1760
|
+
function sync(root, options) {
|
|
1761
|
+
const walker = new Walker(root, options);
|
|
1762
|
+
return walker.start();
|
|
1763
|
+
}
|
|
1764
|
+
var APIBuilder = class {
|
|
1765
|
+
constructor(root, options){
|
|
1766
|
+
this.root = root;
|
|
1767
|
+
this.options = options;
|
|
1768
|
+
}
|
|
1769
|
+
withPromise() {
|
|
1770
|
+
return promise(this.root, this.options);
|
|
1771
|
+
}
|
|
1772
|
+
withCallback(cb) {
|
|
1773
|
+
callback(this.root, this.options, cb);
|
|
1774
|
+
}
|
|
1775
|
+
sync() {
|
|
1776
|
+
return sync(this.root, this.options);
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
let pm = null;
|
|
1780
|
+
try {
|
|
1781
|
+
__require.resolve("picomatch");
|
|
1782
|
+
pm = __require("picomatch");
|
|
1783
|
+
} catch {}
|
|
1784
|
+
var Builder = class {
|
|
1785
|
+
globCache = {};
|
|
1786
|
+
options = {
|
|
1787
|
+
maxDepth: 1 / 0,
|
|
1788
|
+
suppressErrors: true,
|
|
1789
|
+
pathSeparator: sep,
|
|
1790
|
+
filters: []
|
|
1791
|
+
};
|
|
1792
|
+
globFunction;
|
|
1793
|
+
constructor(options){
|
|
1794
|
+
this.options = {
|
|
1795
|
+
...this.options,
|
|
1796
|
+
...options
|
|
1797
|
+
};
|
|
1798
|
+
this.globFunction = this.options.globFunction;
|
|
1799
|
+
}
|
|
1800
|
+
group() {
|
|
1801
|
+
this.options.group = true;
|
|
1802
|
+
return this;
|
|
1803
|
+
}
|
|
1804
|
+
withPathSeparator(separator) {
|
|
1805
|
+
this.options.pathSeparator = separator;
|
|
1806
|
+
return this;
|
|
1807
|
+
}
|
|
1808
|
+
withBasePath() {
|
|
1809
|
+
this.options.includeBasePath = true;
|
|
1810
|
+
return this;
|
|
1811
|
+
}
|
|
1812
|
+
withRelativePaths() {
|
|
1813
|
+
this.options.relativePaths = true;
|
|
1814
|
+
return this;
|
|
1815
|
+
}
|
|
1816
|
+
withDirs() {
|
|
1817
|
+
this.options.includeDirs = true;
|
|
1818
|
+
return this;
|
|
1819
|
+
}
|
|
1820
|
+
withMaxDepth(depth) {
|
|
1821
|
+
this.options.maxDepth = depth;
|
|
1822
|
+
return this;
|
|
1823
|
+
}
|
|
1824
|
+
withMaxFiles(limit) {
|
|
1825
|
+
this.options.maxFiles = limit;
|
|
1826
|
+
return this;
|
|
1827
|
+
}
|
|
1828
|
+
withFullPaths() {
|
|
1829
|
+
this.options.resolvePaths = true;
|
|
1830
|
+
this.options.includeBasePath = true;
|
|
1831
|
+
return this;
|
|
1832
|
+
}
|
|
1833
|
+
withErrors() {
|
|
1834
|
+
this.options.suppressErrors = false;
|
|
1835
|
+
return this;
|
|
1836
|
+
}
|
|
1837
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
1838
|
+
this.options.resolveSymlinks = true;
|
|
1839
|
+
this.options.useRealPaths = resolvePaths;
|
|
1840
|
+
return this.withFullPaths();
|
|
1841
|
+
}
|
|
1842
|
+
withAbortSignal(signal) {
|
|
1843
|
+
this.options.signal = signal;
|
|
1844
|
+
return this;
|
|
1845
|
+
}
|
|
1846
|
+
normalize() {
|
|
1847
|
+
this.options.normalizePath = true;
|
|
1848
|
+
return this;
|
|
1849
|
+
}
|
|
1850
|
+
filter(predicate) {
|
|
1851
|
+
this.options.filters.push(predicate);
|
|
1852
|
+
return this;
|
|
1853
|
+
}
|
|
1854
|
+
onlyDirs() {
|
|
1855
|
+
this.options.excludeFiles = true;
|
|
1856
|
+
this.options.includeDirs = true;
|
|
1857
|
+
return this;
|
|
1858
|
+
}
|
|
1859
|
+
exclude(predicate) {
|
|
1860
|
+
this.options.exclude = predicate;
|
|
1861
|
+
return this;
|
|
1862
|
+
}
|
|
1863
|
+
onlyCounts() {
|
|
1864
|
+
this.options.onlyCounts = true;
|
|
1865
|
+
return this;
|
|
1866
|
+
}
|
|
1867
|
+
crawl(root) {
|
|
1868
|
+
return new APIBuilder(root || ".", this.options);
|
|
1869
|
+
}
|
|
1870
|
+
withGlobFunction(fn) {
|
|
1871
|
+
this.globFunction = fn;
|
|
1872
|
+
return this;
|
|
1873
|
+
}
|
|
1874
|
+
crawlWithOptions(root, options) {
|
|
1875
|
+
this.options = {
|
|
1876
|
+
...this.options,
|
|
1877
|
+
...options
|
|
1878
|
+
};
|
|
1879
|
+
return new APIBuilder(root || ".", this.options);
|
|
1880
|
+
}
|
|
1881
|
+
glob(...patterns) {
|
|
1882
|
+
if (this.globFunction) return this.globWithOptions(patterns);
|
|
1883
|
+
return this.globWithOptions(patterns, {
|
|
1884
|
+
dot: true
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
globWithOptions(patterns, ...options) {
|
|
1888
|
+
const globFn = this.globFunction || pm;
|
|
1889
|
+
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
1890
|
+
var isMatch = this.globCache[patterns.join("\0")];
|
|
1891
|
+
if (!isMatch) {
|
|
1892
|
+
isMatch = globFn(patterns, ...options);
|
|
1893
|
+
this.globCache[patterns.join("\0")] = isMatch;
|
|
1894
|
+
}
|
|
1895
|
+
this.options.filters.push((path)=>isMatch(path));
|
|
1896
|
+
return this;
|
|
1897
|
+
}
|
|
1898
|
+
};
|
|
1899
|
+
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
|
|
1900
|
+
const isReadonlyArray = Array.isArray;
|
|
1901
|
+
const isWin = "win32" === process.platform;
|
|
1902
|
+
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
1903
|
+
function getPartialMatcher(patterns, options = {}) {
|
|
1904
|
+
const patternsCount = patterns.length;
|
|
1905
|
+
const patternsParts = Array(patternsCount);
|
|
1906
|
+
const matchers = Array(patternsCount);
|
|
1907
|
+
const globstarEnabled = !options.noglobstar;
|
|
1908
|
+
for(let i = 0; i < patternsCount; i++){
|
|
1909
|
+
const parts = splitPattern(patterns[i]);
|
|
1910
|
+
patternsParts[i] = parts;
|
|
1911
|
+
const partsCount = parts.length;
|
|
1912
|
+
const partMatchers = Array(partsCount);
|
|
1913
|
+
for(let j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
|
|
1914
|
+
matchers[i] = partMatchers;
|
|
1915
|
+
}
|
|
1916
|
+
return (input)=>{
|
|
1917
|
+
const inputParts = input.split("/");
|
|
1918
|
+
if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
1919
|
+
for(let i = 0; i < patterns.length; i++){
|
|
1920
|
+
const patternParts = patternsParts[i];
|
|
1921
|
+
const matcher = matchers[i];
|
|
1922
|
+
const inputPatternCount = inputParts.length;
|
|
1923
|
+
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
1924
|
+
let j = 0;
|
|
1925
|
+
while(j < minParts){
|
|
1926
|
+
const part = patternParts[j];
|
|
1927
|
+
if (part.includes("/")) return true;
|
|
1928
|
+
const match = matcher[j](inputParts[j]);
|
|
1929
|
+
if (!match) break;
|
|
1930
|
+
if (globstarEnabled && "**" === part) return true;
|
|
1931
|
+
j++;
|
|
1932
|
+
}
|
|
1933
|
+
if (j === inputPatternCount) return true;
|
|
1934
|
+
}
|
|
1935
|
+
return false;
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
1939
|
+
const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
|
|
1940
|
+
function buildFormat(cwd, root, absolute) {
|
|
1941
|
+
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
1942
|
+
if (absolute) {
|
|
1943
|
+
const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
|
|
1944
|
+
return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
|
|
1945
|
+
}
|
|
1946
|
+
const prefix = root.slice(cwd.length + 1);
|
|
1947
|
+
if (prefix) return (p, isDir)=>{
|
|
1948
|
+
if ("." === p) return prefix;
|
|
1949
|
+
const result = `${prefix}/${p}`;
|
|
1950
|
+
return isDir ? result.slice(0, -1) : result;
|
|
1951
|
+
};
|
|
1952
|
+
return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
|
|
1953
|
+
}
|
|
1954
|
+
if (absolute) return (p)=>posix.relative(cwd, p) || ".";
|
|
1955
|
+
return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
|
|
1956
|
+
}
|
|
1957
|
+
function buildRelative(cwd, root) {
|
|
1958
|
+
if (root.startsWith(`${cwd}/`)) {
|
|
1959
|
+
const prefix = root.slice(cwd.length + 1);
|
|
1960
|
+
return (p)=>`${prefix}/${p}`;
|
|
1961
|
+
}
|
|
1962
|
+
return (p)=>{
|
|
1963
|
+
const result = posix.relative(cwd, `${root}/${p}`);
|
|
1964
|
+
if (p.endsWith("/") && "" !== result) return `${result}/`;
|
|
1965
|
+
return result || ".";
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
const splitPatternOptions = {
|
|
1969
|
+
parts: true
|
|
1970
|
+
};
|
|
1971
|
+
function splitPattern(path$1) {
|
|
1972
|
+
var _result$parts;
|
|
1973
|
+
const result = picomatch.scan(path$1, splitPatternOptions);
|
|
1974
|
+
return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
|
|
1975
|
+
path$1
|
|
1976
|
+
];
|
|
1977
|
+
}
|
|
1978
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
1979
|
+
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
1980
|
+
const escapePosixPath = (path$1)=>path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
1981
|
+
const escapeWin32Path = (path$1)=>path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
1982
|
+
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
1983
|
+
function isDynamicPattern(pattern, options) {
|
|
1984
|
+
if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
1985
|
+
const scan = picomatch.scan(pattern);
|
|
1986
|
+
return scan.isGlob || scan.negated;
|
|
1987
|
+
}
|
|
1988
|
+
function log(...tasks) {
|
|
1989
|
+
console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
1990
|
+
}
|
|
1991
|
+
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
1992
|
+
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
1993
|
+
const BACKSLASHES = /\\/g;
|
|
1994
|
+
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
1995
|
+
let result = pattern;
|
|
1996
|
+
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
|
1997
|
+
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
|
1998
|
+
const escapedCwd = escapePath(cwd);
|
|
1999
|
+
result = path_0.isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
|
|
2000
|
+
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2001
|
+
const parts = splitPattern(result);
|
|
2002
|
+
if (null == parentDirectoryMatch ? void 0 : parentDirectoryMatch[0]) {
|
|
2003
|
+
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2004
|
+
let i = 0;
|
|
2005
|
+
const cwdParts = escapedCwd.split("/");
|
|
2006
|
+
while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
|
|
2007
|
+
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2008
|
+
i++;
|
|
2009
|
+
}
|
|
2010
|
+
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(3 * i));
|
|
2011
|
+
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2012
|
+
props.root = potentialRoot;
|
|
2013
|
+
props.depthOffset = -n + i;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
if (!isIgnore && props.depthOffset >= 0) {
|
|
2017
|
+
null != props.commonPath || (props.commonPath = parts);
|
|
2018
|
+
const newCommonPath = [];
|
|
2019
|
+
const length = Math.min(props.commonPath.length, parts.length);
|
|
2020
|
+
for(let i = 0; i < length; i++){
|
|
2021
|
+
const part = parts[i];
|
|
2022
|
+
if ("**" === part && !parts[i + 1]) {
|
|
2023
|
+
newCommonPath.pop();
|
|
2024
|
+
break;
|
|
2025
|
+
}
|
|
2026
|
+
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
|
|
2027
|
+
newCommonPath.push(part);
|
|
2028
|
+
}
|
|
2029
|
+
props.depthOffset = newCommonPath.length;
|
|
2030
|
+
props.commonPath = newCommonPath;
|
|
2031
|
+
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
|
|
2032
|
+
}
|
|
2033
|
+
return result;
|
|
2034
|
+
}
|
|
2035
|
+
function processPatterns({ patterns = [
|
|
2036
|
+
"**/*"
|
|
2037
|
+
], ignore = [], expandDirectories = true }, cwd, props) {
|
|
2038
|
+
if ("string" == typeof patterns) patterns = [
|
|
2039
|
+
patterns
|
|
2040
|
+
];
|
|
2041
|
+
if ("string" == typeof ignore) ignore = [
|
|
2042
|
+
ignore
|
|
2043
|
+
];
|
|
2044
|
+
const matchPatterns = [];
|
|
2045
|
+
const ignorePatterns = [];
|
|
2046
|
+
for (const pattern of ignore)if (pattern) {
|
|
2047
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
|
2048
|
+
}
|
|
2049
|
+
for (const pattern of patterns)if (pattern) {
|
|
2050
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
|
2051
|
+
else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
|
2052
|
+
}
|
|
2053
|
+
return {
|
|
2054
|
+
match: matchPatterns,
|
|
2055
|
+
ignore: ignorePatterns
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
function formatPaths(paths, relative) {
|
|
2059
|
+
for(let i = paths.length - 1; i >= 0; i--){
|
|
2060
|
+
const path$1 = paths[i];
|
|
2061
|
+
paths[i] = relative(path$1);
|
|
2062
|
+
}
|
|
2063
|
+
return paths;
|
|
2064
|
+
}
|
|
2065
|
+
function normalizeCwd(cwd) {
|
|
2066
|
+
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
|
2067
|
+
if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
|
|
2068
|
+
return path_0.resolve(cwd).replace(BACKSLASHES, "/");
|
|
2069
|
+
}
|
|
2070
|
+
function getCrawler(patterns, inputOptions = {}) {
|
|
2071
|
+
const options = process.env.TINYGLOBBY_DEBUG ? {
|
|
2072
|
+
...inputOptions,
|
|
2073
|
+
debug: true
|
|
2074
|
+
} : inputOptions;
|
|
2075
|
+
const cwd = normalizeCwd(options.cwd);
|
|
2076
|
+
if (options.debug) log("globbing with:", {
|
|
2077
|
+
patterns,
|
|
2078
|
+
options,
|
|
2079
|
+
cwd
|
|
2080
|
+
});
|
|
2081
|
+
if (Array.isArray(patterns) && 0 === patterns.length) return [
|
|
2082
|
+
{
|
|
2083
|
+
sync: ()=>[],
|
|
2084
|
+
withPromise: async ()=>[]
|
|
2085
|
+
},
|
|
2086
|
+
false
|
|
2087
|
+
];
|
|
2088
|
+
const props = {
|
|
2089
|
+
root: cwd,
|
|
2090
|
+
commonPath: null,
|
|
2091
|
+
depthOffset: 0
|
|
2092
|
+
};
|
|
2093
|
+
const processed = processPatterns({
|
|
2094
|
+
...options,
|
|
2095
|
+
patterns
|
|
2096
|
+
}, cwd, props);
|
|
2097
|
+
if (options.debug) log("internal processing patterns:", processed);
|
|
2098
|
+
const matchOptions = {
|
|
2099
|
+
dot: options.dot,
|
|
2100
|
+
nobrace: false === options.braceExpansion,
|
|
2101
|
+
nocase: false === options.caseSensitiveMatch,
|
|
2102
|
+
noextglob: false === options.extglob,
|
|
2103
|
+
noglobstar: false === options.globstar,
|
|
2104
|
+
posix: true
|
|
2105
|
+
};
|
|
2106
|
+
const matcher = picomatch(processed.match, {
|
|
2107
|
+
...matchOptions,
|
|
2108
|
+
ignore: processed.ignore
|
|
2109
|
+
});
|
|
2110
|
+
const ignore = picomatch(processed.ignore, matchOptions);
|
|
2111
|
+
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2112
|
+
const format = buildFormat(cwd, props.root, options.absolute);
|
|
2113
|
+
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
|
|
2114
|
+
const fdirOptions = {
|
|
2115
|
+
filters: [
|
|
2116
|
+
options.debug ? (p, isDirectory)=>{
|
|
2117
|
+
const path$1 = format(p, isDirectory);
|
|
2118
|
+
const matches = matcher(path$1);
|
|
2119
|
+
if (matches) log(`matched ${path$1}`);
|
|
2120
|
+
return matches;
|
|
2121
|
+
} : (p, isDirectory)=>matcher(format(p, isDirectory))
|
|
2122
|
+
],
|
|
2123
|
+
exclude: options.debug ? (_, p)=>{
|
|
2124
|
+
const relativePath = formatExclude(p, true);
|
|
2125
|
+
const skipped = "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2126
|
+
skipped ? log(`skipped ${p}`) : log(`crawling ${p}`);
|
|
2127
|
+
return skipped;
|
|
2128
|
+
} : (_, p)=>{
|
|
2129
|
+
const relativePath = formatExclude(p, true);
|
|
2130
|
+
return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2131
|
+
},
|
|
2132
|
+
fs: options.fs ? {
|
|
2133
|
+
readdir: options.fs.readdir || fs_0.readdir,
|
|
2134
|
+
readdirSync: options.fs.readdirSync || fs_0.readdirSync,
|
|
2135
|
+
realpath: options.fs.realpath || fs_0.realpath,
|
|
2136
|
+
realpathSync: options.fs.realpathSync || fs_0.realpathSync,
|
|
2137
|
+
stat: options.fs.stat || fs_0.stat,
|
|
2138
|
+
statSync: options.fs.statSync || fs_0.statSync
|
|
2139
|
+
} : void 0,
|
|
2140
|
+
pathSeparator: "/",
|
|
2141
|
+
relativePaths: true,
|
|
2142
|
+
resolveSymlinks: true,
|
|
2143
|
+
signal: options.signal
|
|
2144
|
+
};
|
|
2145
|
+
if (void 0 !== options.deep) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2146
|
+
if (options.absolute) {
|
|
2147
|
+
fdirOptions.relativePaths = false;
|
|
2148
|
+
fdirOptions.resolvePaths = true;
|
|
2149
|
+
fdirOptions.includeBasePath = true;
|
|
2150
|
+
}
|
|
2151
|
+
if (false === options.followSymbolicLinks) {
|
|
2152
|
+
fdirOptions.resolveSymlinks = false;
|
|
2153
|
+
fdirOptions.excludeSymlinks = true;
|
|
2154
|
+
}
|
|
2155
|
+
if (options.onlyDirectories) {
|
|
2156
|
+
fdirOptions.excludeFiles = true;
|
|
2157
|
+
fdirOptions.includeDirs = true;
|
|
2158
|
+
} else if (false === options.onlyFiles) fdirOptions.includeDirs = true;
|
|
2159
|
+
props.root = props.root.replace(BACKSLASHES, "");
|
|
2160
|
+
const root = props.root;
|
|
2161
|
+
if (options.debug) log("internal properties:", props);
|
|
2162
|
+
const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
|
2163
|
+
return [
|
|
2164
|
+
new Builder(fdirOptions).crawl(root),
|
|
2165
|
+
relative
|
|
2166
|
+
];
|
|
2167
|
+
}
|
|
2168
|
+
async function glob(patternsOrOptions, options) {
|
|
2169
|
+
if (patternsOrOptions && (null == options ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2170
|
+
const isModern = isReadonlyArray(patternsOrOptions) || "string" == typeof patternsOrOptions;
|
|
2171
|
+
const opts = isModern ? options : patternsOrOptions;
|
|
2172
|
+
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
|
2173
|
+
const [crawler, relative] = getCrawler(patterns, opts);
|
|
2174
|
+
if (!relative) return crawler.withPromise();
|
|
2175
|
+
return formatPaths(await crawler.withPromise(), relative);
|
|
2176
|
+
}
|
|
2177
|
+
export { glob };
|