heading-case 1.1.7 → 2.0.0

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/index.js CHANGED
@@ -1,2821 +1,49 @@
1
- import { execFileSync } from "node:child_process";
2
- import node_fs from "node:fs";
3
- import node_util from "node:util";
4
- import * as __rspack_external_fs from "fs";
5
- import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
6
- import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
7
- import { fileURLToPath } from "url";
8
- import { createRequire } from "module";
9
- var __webpack_modules__ = {};
10
- var __webpack_module_cache__ = {};
11
- function __webpack_require__(moduleId) {
12
- var cachedModule = __webpack_module_cache__[moduleId];
13
- if (void 0 !== cachedModule) return cachedModule.exports;
14
- var module = __webpack_module_cache__[moduleId] = {
15
- exports: {}
16
- };
17
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
18
- return module.exports;
19
- }
20
- __webpack_require__.m = __webpack_modules__;
21
- (()=>{
22
- __webpack_require__.n = (module)=>{
23
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
24
- __webpack_require__.d(getter, {
25
- a: getter
26
- });
27
- return getter;
28
- };
29
- })();
30
- (()=>{
31
- __webpack_require__.d = (exports, getters, values)=>{
32
- var define = (defs, kind)=>{
33
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
34
- enumerable: true,
35
- [kind]: defs[key]
36
- });
37
- };
38
- define(getters, "get");
39
- define(values, "value");
40
- };
41
- })();
42
- (()=>{
43
- __webpack_require__.add = function(modules) {
44
- Object.assign(__webpack_require__.m, modules);
45
- };
46
- })();
47
- (()=>{
48
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
49
- })();
50
- __webpack_require__.add({
51
- "./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
52
- let p = process || {}, argv = p.argv || [], env = p.env || {};
53
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
54
- let formatter = (open, close, replace = open)=>(input)=>{
55
- let string = "" + input, index = string.indexOf(close, open.length);
56
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
57
- };
58
- let replaceClose = (string, close, replace, index)=>{
59
- let result = "", cursor = 0;
60
- do {
61
- result += string.substring(cursor, index) + replace;
62
- cursor = index + close.length;
63
- index = string.indexOf(close, cursor);
64
- }while (~index);
65
- return result + string.substring(cursor);
66
- };
67
- let createColors = (enabled = isColorSupported)=>{
68
- let f = enabled ? formatter : ()=>String;
69
- return {
70
- isColorSupported: enabled,
71
- reset: f("\x1b[0m", "\x1b[0m"),
72
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
73
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
74
- italic: f("\x1b[3m", "\x1b[23m"),
75
- underline: f("\x1b[4m", "\x1b[24m"),
76
- inverse: f("\x1b[7m", "\x1b[27m"),
77
- hidden: f("\x1b[8m", "\x1b[28m"),
78
- strikethrough: f("\x1b[9m", "\x1b[29m"),
79
- black: f("\x1b[30m", "\x1b[39m"),
80
- red: f("\x1b[31m", "\x1b[39m"),
81
- green: f("\x1b[32m", "\x1b[39m"),
82
- yellow: f("\x1b[33m", "\x1b[39m"),
83
- blue: f("\x1b[34m", "\x1b[39m"),
84
- magenta: f("\x1b[35m", "\x1b[39m"),
85
- cyan: f("\x1b[36m", "\x1b[39m"),
86
- white: f("\x1b[37m", "\x1b[39m"),
87
- gray: f("\x1b[90m", "\x1b[39m"),
88
- bgBlack: f("\x1b[40m", "\x1b[49m"),
89
- bgRed: f("\x1b[41m", "\x1b[49m"),
90
- bgGreen: f("\x1b[42m", "\x1b[49m"),
91
- bgYellow: f("\x1b[43m", "\x1b[49m"),
92
- bgBlue: f("\x1b[44m", "\x1b[49m"),
93
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
94
- bgCyan: f("\x1b[46m", "\x1b[49m"),
95
- bgWhite: f("\x1b[47m", "\x1b[49m"),
96
- blackBright: f("\x1b[90m", "\x1b[39m"),
97
- redBright: f("\x1b[91m", "\x1b[39m"),
98
- greenBright: f("\x1b[92m", "\x1b[39m"),
99
- yellowBright: f("\x1b[93m", "\x1b[39m"),
100
- blueBright: f("\x1b[94m", "\x1b[39m"),
101
- magentaBright: f("\x1b[95m", "\x1b[39m"),
102
- cyanBright: f("\x1b[96m", "\x1b[39m"),
103
- whiteBright: f("\x1b[97m", "\x1b[39m"),
104
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
105
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
106
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
107
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
108
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
109
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
110
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
111
- bgWhiteBright: f("\x1b[107m", "\x1b[49m")
112
- };
113
- };
114
- module.exports = createColors();
115
- module.exports.createColors = createColors;
116
- },
117
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
118
- const pico = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js");
119
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
120
- function picomatch(glob, options, returnState = false) {
121
- if (options && (null === options.windows || void 0 === options.windows)) options = {
122
- ...options,
123
- windows: utils.isWindows()
124
- };
125
- return pico(glob, options, returnState);
126
- }
127
- Object.assign(picomatch, pico);
128
- module.exports = picomatch;
129
- },
130
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js" (module) {
131
- const WIN_SLASH = '\\\\/';
132
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
133
- const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
134
- const DOT_LITERAL = '\\.';
135
- const PLUS_LITERAL = '\\+';
136
- const QMARK_LITERAL = '\\?';
137
- const SLASH_LITERAL = '\\/';
138
- const ONE_CHAR = '(?=.)';
139
- const QMARK = '[^/]';
140
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
141
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
142
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
143
- const NO_DOT = `(?!${DOT_LITERAL})`;
144
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
145
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
146
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
147
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
148
- const STAR = `${QMARK}*?`;
149
- const SEP = '/';
150
- const POSIX_CHARS = {
151
- DOT_LITERAL,
152
- PLUS_LITERAL,
153
- QMARK_LITERAL,
154
- SLASH_LITERAL,
155
- ONE_CHAR,
156
- QMARK,
157
- END_ANCHOR,
158
- DOTS_SLASH,
159
- NO_DOT,
160
- NO_DOTS,
161
- NO_DOT_SLASH,
162
- NO_DOTS_SLASH,
163
- QMARK_NO_DOT,
164
- STAR,
165
- START_ANCHOR,
166
- SEP
167
- };
168
- const WINDOWS_CHARS = {
169
- ...POSIX_CHARS,
170
- SLASH_LITERAL: `[${WIN_SLASH}]`,
171
- QMARK: WIN_NO_SLASH,
172
- STAR: `${WIN_NO_SLASH}*?`,
173
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
174
- NO_DOT: `(?!${DOT_LITERAL})`,
175
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
176
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
177
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
178
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
179
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
180
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
181
- SEP: '\\'
182
- };
183
- const POSIX_REGEX_SOURCE = {
184
- __proto__: null,
185
- alnum: 'a-zA-Z0-9',
186
- alpha: 'a-zA-Z',
187
- ascii: '\\x00-\\x7F',
188
- blank: ' \\t',
189
- cntrl: '\\x00-\\x1F\\x7F',
190
- digit: '0-9',
191
- graph: '\\x21-\\x7E',
192
- lower: 'a-z',
193
- print: '\\x20-\\x7E ',
194
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
195
- space: ' \\t\\r\\n\\v\\f',
196
- upper: 'A-Z',
197
- word: 'A-Za-z0-9_',
198
- xdigit: 'A-Fa-f0-9'
199
- };
200
- module.exports = {
201
- DEFAULT_MAX_EXTGLOB_RECURSION,
202
- MAX_LENGTH: 65536,
203
- POSIX_REGEX_SOURCE,
204
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
205
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
206
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
207
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
208
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
209
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
210
- REPLACEMENTS: {
211
- __proto__: null,
212
- '***': '*',
213
- '**/**': '**',
214
- '**/**/**': '**'
215
- },
216
- CHAR_0: 48,
217
- CHAR_9: 57,
218
- CHAR_UPPERCASE_A: 65,
219
- CHAR_LOWERCASE_A: 97,
220
- CHAR_UPPERCASE_Z: 90,
221
- CHAR_LOWERCASE_Z: 122,
222
- CHAR_LEFT_PARENTHESES: 40,
223
- CHAR_RIGHT_PARENTHESES: 41,
224
- CHAR_ASTERISK: 42,
225
- CHAR_AMPERSAND: 38,
226
- CHAR_AT: 64,
227
- CHAR_BACKWARD_SLASH: 92,
228
- CHAR_CARRIAGE_RETURN: 13,
229
- CHAR_CIRCUMFLEX_ACCENT: 94,
230
- CHAR_COLON: 58,
231
- CHAR_COMMA: 44,
232
- CHAR_DOT: 46,
233
- CHAR_DOUBLE_QUOTE: 34,
234
- CHAR_EQUAL: 61,
235
- CHAR_EXCLAMATION_MARK: 33,
236
- CHAR_FORM_FEED: 12,
237
- CHAR_FORWARD_SLASH: 47,
238
- CHAR_GRAVE_ACCENT: 96,
239
- CHAR_HASH: 35,
240
- CHAR_HYPHEN_MINUS: 45,
241
- CHAR_LEFT_ANGLE_BRACKET: 60,
242
- CHAR_LEFT_CURLY_BRACE: 123,
243
- CHAR_LEFT_SQUARE_BRACKET: 91,
244
- CHAR_LINE_FEED: 10,
245
- CHAR_NO_BREAK_SPACE: 160,
246
- CHAR_PERCENT: 37,
247
- CHAR_PLUS: 43,
248
- CHAR_QUESTION_MARK: 63,
249
- CHAR_RIGHT_ANGLE_BRACKET: 62,
250
- CHAR_RIGHT_CURLY_BRACE: 125,
251
- CHAR_RIGHT_SQUARE_BRACKET: 93,
252
- CHAR_SEMICOLON: 59,
253
- CHAR_SINGLE_QUOTE: 39,
254
- CHAR_SPACE: 32,
255
- CHAR_TAB: 9,
256
- CHAR_UNDERSCORE: 95,
257
- CHAR_VERTICAL_LINE: 124,
258
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
259
- extglobChars (chars) {
260
- return {
261
- '!': {
262
- type: 'negate',
263
- open: '(?:(?!(?:',
264
- close: `))${chars.STAR})`
265
- },
266
- '?': {
267
- type: 'qmark',
268
- open: '(?:',
269
- close: ')?'
270
- },
271
- '+': {
272
- type: 'plus',
273
- open: '(?:',
274
- close: ')+'
275
- },
276
- '*': {
277
- type: 'star',
278
- open: '(?:',
279
- close: ')*'
280
- },
281
- '@': {
282
- type: 'at',
283
- open: '(?:',
284
- close: ')'
285
- }
286
- };
287
- },
288
- globChars (win32) {
289
- return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
290
- }
291
- };
292
- },
293
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
294
- const constants = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
295
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
296
- const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
297
- const expandRange = (args, options)=>{
298
- if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
299
- args.sort();
300
- const value = `[${args.join('-')}]`;
301
- try {
302
- new RegExp(value);
303
- } catch (ex) {
304
- return args.map((v)=>utils.escapeRegex(v)).join('..');
305
- }
306
- return value;
307
- };
308
- const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
309
- const splitTopLevel = (input)=>{
310
- const parts = [];
311
- let bracket = 0;
312
- let paren = 0;
313
- let quote = 0;
314
- let value = '';
315
- let escaped = false;
316
- for (const ch of input){
317
- if (true === escaped) {
318
- value += ch;
319
- escaped = false;
320
- continue;
321
- }
322
- if ('\\' === ch) {
323
- value += ch;
324
- escaped = true;
325
- continue;
326
- }
327
- if ('"' === ch) {
328
- quote = 1 === quote ? 0 : 1;
329
- value += ch;
330
- continue;
331
- }
332
- if (0 === quote) {
333
- if ('[' === ch) bracket++;
334
- else if (']' === ch && bracket > 0) bracket--;
335
- else if (0 === bracket) {
336
- if ('(' === ch) paren++;
337
- else if (')' === ch && paren > 0) paren--;
338
- else if ('|' === ch && 0 === paren) {
339
- parts.push(value);
340
- value = '';
341
- continue;
342
- }
343
- }
344
- }
345
- value += ch;
346
- }
347
- parts.push(value);
348
- return parts;
349
- };
350
- const isPlainBranch = (branch)=>{
351
- let escaped = false;
352
- for (const ch of branch){
353
- if (true === escaped) {
354
- escaped = false;
355
- continue;
356
- }
357
- if ('\\' === ch) {
358
- escaped = true;
359
- continue;
360
- }
361
- if (/[?*+@!()[\]{}]/.test(ch)) return false;
362
- }
363
- return true;
364
- };
365
- const normalizeSimpleBranch = (branch)=>{
366
- let value = branch.trim();
367
- let changed = true;
368
- while(true === changed){
369
- changed = false;
370
- if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
371
- value = value.slice(2, -1);
372
- changed = true;
373
- }
374
- }
375
- if (!isPlainBranch(value)) return;
376
- return value.replace(/\\(.)/g, '$1');
377
- };
378
- const hasRepeatedCharPrefixOverlap = (branches)=>{
379
- const values = branches.map(normalizeSimpleBranch).filter(Boolean);
380
- for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
381
- const a = values[i];
382
- const b = values[j];
383
- const char = a[0];
384
- if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
385
- if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
386
- }
387
- }
388
- return false;
389
- };
390
- const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
391
- if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
392
- let bracket = 0;
393
- let paren = 0;
394
- let quote = 0;
395
- let escaped = false;
396
- for(let i = 1; i < pattern.length; i++){
397
- const ch = pattern[i];
398
- if (true === escaped) {
399
- escaped = false;
400
- continue;
401
- }
402
- if ('\\' === ch) {
403
- escaped = true;
404
- continue;
405
- }
406
- if ('"' === ch) {
407
- quote = 1 === quote ? 0 : 1;
408
- continue;
409
- }
410
- if (1 !== quote) {
411
- if ('[' === ch) {
412
- bracket++;
413
- continue;
414
- }
415
- if (']' === ch && bracket > 0) {
416
- bracket--;
417
- continue;
418
- }
419
- if (!(bracket > 0)) {
420
- if ('(' === ch) {
421
- paren++;
422
- continue;
423
- }
424
- if (')' === ch) {
425
- paren--;
426
- if (0 === paren) {
427
- if (true === requireEnd && i !== pattern.length - 1) return;
428
- return {
429
- type: pattern[0],
430
- body: pattern.slice(2, i),
431
- end: i
432
- };
433
- }
434
- }
435
- }
436
- }
437
- }
438
- };
439
- const getStarExtglobSequenceOutput = (pattern)=>{
440
- let index = 0;
441
- const chars = [];
442
- while(index < pattern.length){
443
- const match = parseRepeatedExtglob(pattern.slice(index), false);
444
- if (!match || '*' !== match.type) return;
445
- const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
446
- if (1 !== branches.length) return;
447
- const branch = normalizeSimpleBranch(branches[0]);
448
- if (!branch || 1 !== branch.length) return;
449
- chars.push(branch);
450
- index += match.end + 1;
451
- }
452
- if (chars.length < 1) return;
453
- const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
454
- return `${source}*`;
455
- };
456
- const repeatedExtglobRecursion = (pattern)=>{
457
- let depth = 0;
458
- let value = pattern.trim();
459
- let match = parseRepeatedExtglob(value);
460
- while(match){
461
- depth++;
462
- value = match.body.trim();
463
- match = parseRepeatedExtglob(value);
464
- }
465
- return depth;
466
- };
467
- const analyzeRepeatedExtglob = (body, options)=>{
468
- if (false === options.maxExtglobRecursion) return {
469
- risky: false
470
- };
471
- const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
472
- const branches = splitTopLevel(body).map((branch)=>branch.trim());
473
- if (branches.length > 1) {
474
- if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
475
- risky: true
476
- };
477
- }
478
- for (const branch of branches){
479
- const safeOutput = getStarExtglobSequenceOutput(branch);
480
- if (safeOutput) return {
481
- risky: true,
482
- safeOutput
483
- };
484
- if (repeatedExtglobRecursion(branch) > max) return {
485
- risky: true
486
- };
487
- }
488
- return {
489
- risky: false
490
- };
491
- };
492
- const parse = (input, options)=>{
493
- if ('string' != typeof input) throw new TypeError('Expected a string');
494
- input = REPLACEMENTS[input] || input;
495
- const opts = {
496
- ...options
497
- };
498
- const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
499
- let len = input.length;
500
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
501
- const bos = {
502
- type: 'bos',
503
- value: '',
504
- output: opts.prepend || ''
505
- };
506
- const tokens = [
507
- bos
508
- ];
509
- const capture = opts.capture ? '' : '?:';
510
- const PLATFORM_CHARS = constants.globChars(opts.windows);
511
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
512
- 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;
513
- const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
514
- const nodot = opts.dot ? '' : NO_DOT;
515
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
516
- let star = true === opts.bash ? globstar(opts) : STAR;
517
- if (opts.capture) star = `(${star})`;
518
- if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
519
- const state = {
520
- input,
521
- index: -1,
522
- start: 0,
523
- dot: true === opts.dot,
524
- consumed: '',
525
- output: '',
526
- prefix: '',
527
- backtrack: false,
528
- negated: false,
529
- brackets: 0,
530
- braces: 0,
531
- parens: 0,
532
- quotes: 0,
533
- globstar: false,
534
- tokens
535
- };
536
- input = utils.removePrefix(input, state);
537
- len = input.length;
538
- const extglobs = [];
539
- const braces = [];
540
- const stack = [];
541
- let prev = bos;
542
- let value;
543
- const eos = ()=>state.index === len - 1;
544
- const peek = state.peek = (n = 1)=>input[state.index + n];
545
- const advance = state.advance = ()=>input[++state.index] || '';
546
- const remaining = ()=>input.slice(state.index + 1);
547
- const consume = (value = '', num = 0)=>{
548
- state.consumed += value;
549
- state.index += num;
550
- };
551
- const append = (token)=>{
552
- state.output += null != token.output ? token.output : token.value;
553
- consume(token.value);
554
- };
555
- const negate = ()=>{
556
- let count = 1;
557
- while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
558
- advance();
559
- state.start++;
560
- count++;
561
- }
562
- if (count % 2 === 0) return false;
563
- state.negated = true;
564
- state.start++;
565
- return true;
566
- };
567
- const increment = (type)=>{
568
- state[type]++;
569
- stack.push(type);
570
- };
571
- const decrement = (type)=>{
572
- state[type]--;
573
- stack.pop();
574
- };
575
- const push = (tok)=>{
576
- if ('globstar' === prev.type) {
577
- const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
578
- const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
579
- if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
580
- state.output = state.output.slice(0, -prev.output.length);
581
- prev.type = 'star';
582
- prev.value = '*';
583
- prev.output = star;
584
- state.output += prev.output;
585
- }
586
- }
587
- if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
588
- if (tok.value || tok.output) append(tok);
589
- if (prev && 'text' === prev.type && 'text' === tok.type) {
590
- prev.output = (prev.output || prev.value) + tok.value;
591
- prev.value += tok.value;
592
- return;
593
- }
594
- tok.prev = prev;
595
- tokens.push(tok);
596
- prev = tok;
597
- };
598
- const extglobOpen = (type, value)=>{
599
- const token = {
600
- ...EXTGLOB_CHARS[value],
601
- conditions: 1,
602
- inner: ''
603
- };
604
- token.prev = prev;
605
- token.parens = state.parens;
606
- token.output = state.output;
607
- token.startIndex = state.index;
608
- token.tokensIndex = tokens.length;
609
- const output = (opts.capture ? '(' : '') + token.open;
610
- increment('parens');
611
- push({
612
- type,
613
- value,
614
- output: state.output ? '' : ONE_CHAR
615
- });
616
- push({
617
- type: 'paren',
618
- extglob: true,
619
- value: advance(),
620
- output
621
- });
622
- extglobs.push(token);
623
- };
624
- const extglobClose = (token)=>{
625
- const literal = input.slice(token.startIndex, state.index + 1);
626
- const body = input.slice(token.startIndex + 2, state.index);
627
- const analysis = analyzeRepeatedExtglob(body, opts);
628
- if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
629
- const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
630
- const open = tokens[token.tokensIndex];
631
- open.type = 'text';
632
- open.value = literal;
633
- open.output = safeOutput || utils.escapeRegex(literal);
634
- for(let i = token.tokensIndex + 1; i < tokens.length; i++){
635
- tokens[i].value = '';
636
- tokens[i].output = '';
637
- delete tokens[i].suffix;
638
- }
639
- state.output = token.output + open.output;
640
- state.backtrack = true;
641
- push({
642
- type: 'paren',
643
- extglob: true,
644
- value,
645
- output: ''
646
- });
647
- decrement('parens');
648
- return;
649
- }
650
- let output = token.close + (opts.capture ? ')' : '');
651
- let rest;
652
- if ('negate' === token.type) {
653
- let extglobStar = star;
654
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
655
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
656
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
657
- const expression = parse(rest, {
658
- ...options,
659
- fastpaths: false
660
- }).output;
661
- output = token.close = `)${expression})${extglobStar})`;
662
- }
663
- if ('bos' === token.prev.type) state.negatedExtglob = true;
664
- }
665
- push({
666
- type: 'paren',
667
- extglob: true,
668
- value,
669
- output
670
- });
671
- decrement('parens');
672
- };
673
- if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
674
- let backslashes = false;
675
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
676
- if ('\\' === first) {
677
- backslashes = true;
678
- return m;
679
- }
680
- if ('?' === first) {
681
- if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
682
- if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
683
- return QMARK.repeat(chars.length);
684
- }
685
- if ('.' === first) return DOT_LITERAL.repeat(chars.length);
686
- if ('*' === first) {
687
- if (esc) return esc + first + (rest ? star : '');
688
- return star;
689
- }
690
- return esc ? m : `\\${m}`;
691
- });
692
- if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
693
- if (output === input && true === opts.contains) {
694
- state.output = input;
695
- return state;
696
- }
697
- state.output = utils.wrapOutput(output, state, options);
698
- return state;
699
- }
700
- while(!eos()){
701
- value = advance();
702
- if ('\u0000' === value) continue;
703
- if ('\\' === value) {
704
- const next = peek();
705
- if ('/' === next && true !== opts.bash) continue;
706
- if ('.' === next || ';' === next) continue;
707
- if (!next) {
708
- value += '\\';
709
- push({
710
- type: 'text',
711
- value
712
- });
713
- continue;
714
- }
715
- const match = /^\\+/.exec(remaining());
716
- let slashes = 0;
717
- if (match && match[0].length > 2) {
718
- slashes = match[0].length;
719
- state.index += slashes;
720
- if (slashes % 2 !== 0) value += '\\';
721
- }
722
- if (true === opts.unescape) value = advance();
723
- else value += advance();
724
- if (0 === state.brackets) {
725
- push({
726
- type: 'text',
727
- value
728
- });
729
- continue;
730
- }
731
- }
732
- if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
733
- if (false !== opts.posix && ':' === value) {
734
- const inner = prev.value.slice(1);
735
- if (inner.includes('[')) {
736
- prev.posix = true;
737
- if (inner.includes(':')) {
738
- const idx = prev.value.lastIndexOf('[');
739
- const pre = prev.value.slice(0, idx);
740
- const rest = prev.value.slice(idx + 2);
741
- const posix = POSIX_REGEX_SOURCE[rest];
742
- if (posix) {
743
- prev.value = pre + posix;
744
- state.backtrack = true;
745
- advance();
746
- if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
747
- continue;
748
- }
749
- }
750
- }
751
- }
752
- if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
753
- if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
754
- if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
755
- prev.value += value;
756
- append({
757
- value
758
- });
759
- continue;
760
- }
761
- if (1 === state.quotes && '"' !== value) {
762
- value = utils.escapeRegex(value);
763
- prev.value += value;
764
- append({
765
- value
766
- });
767
- continue;
768
- }
769
- if ('"' === value) {
770
- state.quotes = 1 === state.quotes ? 0 : 1;
771
- if (true === opts.keepQuotes) push({
772
- type: 'text',
773
- value
774
- });
775
- continue;
776
- }
777
- if ('(' === value) {
778
- increment('parens');
779
- push({
780
- type: 'paren',
781
- value
782
- });
783
- continue;
784
- }
785
- if (')' === value) {
786
- if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
787
- const extglob = extglobs[extglobs.length - 1];
788
- if (extglob && state.parens === extglob.parens + 1) {
789
- extglobClose(extglobs.pop());
790
- continue;
791
- }
792
- push({
793
- type: 'paren',
794
- value,
795
- output: state.parens ? ')' : '\\)'
796
- });
797
- decrement('parens');
798
- continue;
799
- }
800
- if ('[' === value) {
801
- if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
802
- else {
803
- if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
804
- value = `\\${value}`;
805
- }
806
- push({
807
- type: 'bracket',
808
- value
809
- });
810
- continue;
811
- }
812
- if (']' === value) {
813
- if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
814
- push({
815
- type: 'text',
816
- value,
817
- output: `\\${value}`
818
- });
819
- continue;
820
- }
821
- if (0 === state.brackets) {
822
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
823
- push({
824
- type: 'text',
825
- value,
826
- output: `\\${value}`
827
- });
828
- continue;
829
- }
830
- decrement('brackets');
831
- const prevValue = prev.value.slice(1);
832
- if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
833
- prev.value += value;
834
- append({
835
- value
836
- });
837
- if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
838
- const escaped = utils.escapeRegex(prev.value);
839
- state.output = state.output.slice(0, -prev.value.length);
840
- if (true === opts.literalBrackets) {
841
- state.output += escaped;
842
- prev.value = escaped;
843
- continue;
844
- }
845
- prev.value = `(${capture}${escaped}|${prev.value})`;
846
- state.output += prev.value;
847
- continue;
848
- }
849
- if ('{' === value && true !== opts.nobrace) {
850
- increment('braces');
851
- const open = {
852
- type: 'brace',
853
- value,
854
- output: '(',
855
- outputIndex: state.output.length,
856
- tokensIndex: state.tokens.length
857
- };
858
- braces.push(open);
859
- push(open);
860
- continue;
861
- }
862
- if ('}' === value) {
863
- const brace = braces[braces.length - 1];
864
- if (true === opts.nobrace || !brace) {
865
- push({
866
- type: 'text',
867
- value,
868
- output: value
869
- });
870
- continue;
871
- }
872
- let output = ')';
873
- if (true === brace.dots) {
874
- const arr = tokens.slice();
875
- const range = [];
876
- for(let i = arr.length - 1; i >= 0; i--){
877
- tokens.pop();
878
- if ('brace' === arr[i].type) break;
879
- if ('dots' !== arr[i].type) range.unshift(arr[i].value);
880
- }
881
- output = expandRange(range, opts);
882
- state.backtrack = true;
883
- }
884
- if (true !== brace.comma && true !== brace.dots) {
885
- const out = state.output.slice(0, brace.outputIndex);
886
- const toks = state.tokens.slice(brace.tokensIndex);
887
- brace.value = brace.output = '\\{';
888
- value = output = '\\}';
889
- state.output = out;
890
- for (const t of toks)state.output += t.output || t.value;
891
- }
892
- push({
893
- type: 'brace',
894
- value,
895
- output
896
- });
897
- decrement('braces');
898
- braces.pop();
899
- continue;
900
- }
901
- if ('|' === value) {
902
- if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
903
- push({
904
- type: 'text',
905
- value
906
- });
907
- continue;
908
- }
909
- if (',' === value) {
910
- let output = value;
911
- const brace = braces[braces.length - 1];
912
- if (brace && 'braces' === stack[stack.length - 1]) {
913
- brace.comma = true;
914
- output = '|';
915
- }
916
- push({
917
- type: 'comma',
918
- value,
919
- output
920
- });
921
- continue;
922
- }
923
- if ('/' === value) {
924
- if ('dot' === prev.type && state.index === state.start + 1) {
925
- state.start = state.index + 1;
926
- state.consumed = '';
927
- state.output = '';
928
- tokens.pop();
929
- prev = bos;
930
- continue;
931
- }
932
- push({
933
- type: 'slash',
934
- value,
935
- output: SLASH_LITERAL
936
- });
937
- continue;
938
- }
939
- if ('.' === value) {
940
- if (state.braces > 0 && 'dot' === prev.type) {
941
- if ('.' === prev.value) prev.output = DOT_LITERAL;
942
- const brace = braces[braces.length - 1];
943
- prev.type = 'dots';
944
- prev.output += value;
945
- prev.value += value;
946
- brace.dots = true;
947
- continue;
948
- }
949
- if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
950
- push({
951
- type: 'text',
952
- value,
953
- output: DOT_LITERAL
954
- });
955
- continue;
956
- }
957
- push({
958
- type: 'dot',
959
- value,
960
- output: DOT_LITERAL
961
- });
962
- continue;
963
- }
964
- if ('?' === value) {
965
- const isGroup = prev && '(' === prev.value;
966
- if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
967
- extglobOpen('qmark', value);
968
- continue;
969
- }
970
- if (prev && 'paren' === prev.type) {
971
- const next = peek();
972
- let output = value;
973
- if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
974
- push({
975
- type: 'text',
976
- value,
977
- output
978
- });
979
- continue;
980
- }
981
- if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
982
- push({
983
- type: 'qmark',
984
- value,
985
- output: QMARK_NO_DOT
986
- });
987
- continue;
988
- }
989
- push({
990
- type: 'qmark',
991
- value,
992
- output: QMARK
993
- });
994
- continue;
995
- }
996
- if ('!' === value) {
997
- if (true !== opts.noextglob && '(' === peek()) {
998
- if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
999
- extglobOpen('negate', value);
1000
- continue;
1001
- }
1002
- }
1003
- if (true !== opts.nonegate && 0 === state.index) {
1004
- negate();
1005
- continue;
1006
- }
1007
- }
1008
- if ('+' === value) {
1009
- if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
1010
- extglobOpen('plus', value);
1011
- continue;
1012
- }
1013
- if (prev && '(' === prev.value || false === opts.regex) {
1014
- push({
1015
- type: 'plus',
1016
- value,
1017
- output: PLUS_LITERAL
1018
- });
1019
- continue;
1020
- }
1021
- if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
1022
- push({
1023
- type: 'plus',
1024
- value
1025
- });
1026
- continue;
1027
- }
1028
- push({
1029
- type: 'plus',
1030
- value: PLUS_LITERAL
1031
- });
1032
- continue;
1033
- }
1034
- if ('@' === value) {
1035
- if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
1036
- push({
1037
- type: 'at',
1038
- extglob: true,
1039
- value,
1040
- output: ''
1041
- });
1042
- continue;
1043
- }
1044
- push({
1045
- type: 'text',
1046
- value
1047
- });
1048
- continue;
1049
- }
1050
- if ('*' !== value) {
1051
- if ('$' === value || '^' === value) value = `\\${value}`;
1052
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1053
- if (match) {
1054
- value += match[0];
1055
- state.index += match[0].length;
1056
- }
1057
- push({
1058
- type: 'text',
1059
- value
1060
- });
1061
- continue;
1062
- }
1063
- if (prev && ('globstar' === prev.type || true === prev.star)) {
1064
- prev.type = 'star';
1065
- prev.star = true;
1066
- prev.value += value;
1067
- prev.output = star;
1068
- state.backtrack = true;
1069
- state.globstar = true;
1070
- consume(value);
1071
- continue;
1072
- }
1073
- let rest = remaining();
1074
- if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
1075
- extglobOpen('star', value);
1076
- continue;
1077
- }
1078
- if ('star' === prev.type) {
1079
- if (true === opts.noglobstar) {
1080
- consume(value);
1081
- continue;
1082
- }
1083
- const prior = prev.prev;
1084
- const before = prior.prev;
1085
- const isStart = 'slash' === prior.type || 'bos' === prior.type;
1086
- const afterStar = before && ('star' === before.type || 'globstar' === before.type);
1087
- if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
1088
- push({
1089
- type: 'star',
1090
- value,
1091
- output: ''
1092
- });
1093
- continue;
1094
- }
1095
- const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
1096
- const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
1097
- if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
1098
- push({
1099
- type: 'star',
1100
- value,
1101
- output: ''
1102
- });
1103
- continue;
1104
- }
1105
- while('/**' === rest.slice(0, 3)){
1106
- const after = input[state.index + 4];
1107
- if (after && '/' !== after) break;
1108
- rest = rest.slice(3);
1109
- consume('/**', 3);
1110
- }
1111
- if ('bos' === prior.type && eos()) {
1112
- prev.type = 'globstar';
1113
- prev.value += value;
1114
- prev.output = globstar(opts);
1115
- state.output = prev.output;
1116
- state.globstar = true;
1117
- consume(value);
1118
- continue;
1119
- }
1120
- if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
1121
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1122
- prior.output = `(?:${prior.output}`;
1123
- prev.type = 'globstar';
1124
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
1125
- prev.value += value;
1126
- state.globstar = true;
1127
- state.output += prior.output + prev.output;
1128
- consume(value);
1129
- continue;
1130
- }
1131
- if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
1132
- const end = void 0 !== rest[1] ? '|$' : '';
1133
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1134
- prior.output = `(?:${prior.output}`;
1135
- prev.type = 'globstar';
1136
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1137
- prev.value += value;
1138
- state.output += prior.output + prev.output;
1139
- state.globstar = true;
1140
- consume(value + advance());
1141
- push({
1142
- type: 'slash',
1143
- value: '/',
1144
- output: ''
1145
- });
1146
- continue;
1147
- }
1148
- if ('bos' === prior.type && '/' === rest[0]) {
1149
- prev.type = 'globstar';
1150
- prev.value += value;
1151
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1152
- state.output = prev.output;
1153
- state.globstar = true;
1154
- consume(value + advance());
1155
- push({
1156
- type: 'slash',
1157
- value: '/',
1158
- output: ''
1159
- });
1160
- continue;
1161
- }
1162
- state.output = state.output.slice(0, -prev.output.length);
1163
- prev.type = 'globstar';
1164
- prev.output = globstar(opts);
1165
- prev.value += value;
1166
- state.output += prev.output;
1167
- state.globstar = true;
1168
- consume(value);
1169
- continue;
1170
- }
1171
- const token = {
1172
- type: 'star',
1173
- value,
1174
- output: star
1175
- };
1176
- if (true === opts.bash) {
1177
- token.output = '.*?';
1178
- if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
1179
- push(token);
1180
- continue;
1181
- }
1182
- if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
1183
- token.output = value;
1184
- push(token);
1185
- continue;
1186
- }
1187
- if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
1188
- if ('dot' === prev.type) {
1189
- state.output += NO_DOT_SLASH;
1190
- prev.output += NO_DOT_SLASH;
1191
- } else if (true === opts.dot) {
1192
- state.output += NO_DOTS_SLASH;
1193
- prev.output += NO_DOTS_SLASH;
1194
- } else {
1195
- state.output += nodot;
1196
- prev.output += nodot;
1197
- }
1198
- if ('*' !== peek()) {
1199
- state.output += ONE_CHAR;
1200
- prev.output += ONE_CHAR;
1201
- }
1202
- }
1203
- push(token);
1204
- }
1205
- while(state.brackets > 0){
1206
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
1207
- state.output = utils.escapeLast(state.output, '[');
1208
- decrement('brackets');
1209
- }
1210
- while(state.parens > 0){
1211
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
1212
- state.output = utils.escapeLast(state.output, '(');
1213
- decrement('parens');
1214
- }
1215
- while(state.braces > 0){
1216
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
1217
- state.output = utils.escapeLast(state.output, '{');
1218
- decrement('braces');
1219
- }
1220
- if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
1221
- type: 'maybe_slash',
1222
- value: '',
1223
- output: `${SLASH_LITERAL}?`
1224
- });
1225
- if (true === state.backtrack) {
1226
- state.output = '';
1227
- for (const token of state.tokens){
1228
- state.output += null != token.output ? token.output : token.value;
1229
- if (token.suffix) state.output += token.suffix;
1230
- }
1231
- }
1232
- return state;
1233
- };
1234
- parse.fastpaths = (input, options)=>{
1235
- const opts = {
1236
- ...options
1237
- };
1238
- const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1239
- const len = input.length;
1240
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1241
- input = REPLACEMENTS[input] || input;
1242
- const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
1243
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1244
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1245
- const capture = opts.capture ? '' : '?:';
1246
- const state = {
1247
- negated: false,
1248
- prefix: ''
1249
- };
1250
- let star = true === opts.bash ? '.*?' : STAR;
1251
- if (opts.capture) star = `(${star})`;
1252
- const globstar = (opts)=>{
1253
- if (true === opts.noglobstar) return star;
1254
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1255
- };
1256
- const create = (str)=>{
1257
- switch(str){
1258
- case '*':
1259
- return `${nodot}${ONE_CHAR}${star}`;
1260
- case '.*':
1261
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1262
- case '*.*':
1263
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1264
- case '*/*':
1265
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1266
- case '**':
1267
- return nodot + globstar(opts);
1268
- case '**/*':
1269
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1270
- case '**/*.*':
1271
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1272
- case '**/.*':
1273
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1274
- default:
1275
- {
1276
- const match = /^(.*?)\.(\w+)$/.exec(str);
1277
- if (!match) return;
1278
- const source = create(match[1]);
1279
- if (!source) return;
1280
- return source + DOT_LITERAL + match[2];
1281
- }
1282
- }
1283
- };
1284
- const output = utils.removePrefix(input, state);
1285
- let source = create(output);
1286
- if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
1287
- return source;
1288
- };
1289
- module.exports = parse;
1290
- },
1291
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
1292
- const scan = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js");
1293
- const parse = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js");
1294
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
1295
- const constants = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
1296
- const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
1297
- const picomatch = (glob, options, returnState = false)=>{
1298
- if (Array.isArray(glob)) {
1299
- const fns = glob.map((input)=>picomatch(input, options, returnState));
1300
- const arrayMatcher = (str)=>{
1301
- for (const isMatch of fns){
1302
- const state = isMatch(str);
1303
- if (state) return state;
1304
- }
1305
- return false;
1306
- };
1307
- return arrayMatcher;
1308
- }
1309
- const isState = isObject(glob) && glob.tokens && glob.input;
1310
- if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
1311
- const opts = options || {};
1312
- const posix = opts.windows;
1313
- const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
1314
- const state = regex.state;
1315
- delete regex.state;
1316
- let isIgnored = ()=>false;
1317
- if (opts.ignore) {
1318
- const ignoreOpts = {
1319
- ...options,
1320
- ignore: null,
1321
- onMatch: null,
1322
- onResult: null
1323
- };
1324
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1325
- }
1326
- const matcher = (input, returnObject = false)=>{
1327
- const { isMatch, match, output } = picomatch.test(input, regex, options, {
1328
- glob,
1329
- posix
1330
- });
1331
- const result = {
1332
- glob,
1333
- state,
1334
- regex,
1335
- posix,
1336
- input,
1337
- output,
1338
- match,
1339
- isMatch
1340
- };
1341
- if ('function' == typeof opts.onResult) opts.onResult(result);
1342
- if (false === isMatch) {
1343
- result.isMatch = false;
1344
- return returnObject ? result : false;
1345
- }
1346
- if (isIgnored(input)) {
1347
- if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
1348
- result.isMatch = false;
1349
- return returnObject ? result : false;
1350
- }
1351
- if ('function' == typeof opts.onMatch) opts.onMatch(result);
1352
- return returnObject ? result : true;
1353
- };
1354
- if (returnState) matcher.state = state;
1355
- return matcher;
1356
- };
1357
- picomatch.test = (input, regex, options, { glob, posix } = {})=>{
1358
- if ('string' != typeof input) throw new TypeError('Expected input to be a string');
1359
- if ('' === input) return {
1360
- isMatch: false,
1361
- output: ''
1362
- };
1363
- const opts = options || {};
1364
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
1365
- let match = input === glob;
1366
- let output = match && format ? format(input) : input;
1367
- if (false === match) {
1368
- output = format ? format(input) : input;
1369
- match = output === glob;
1370
- }
1371
- if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
1372
- return {
1373
- isMatch: Boolean(match),
1374
- match,
1375
- output
1376
- };
1377
- };
1378
- picomatch.matchBase = (input, glob, options)=>{
1379
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1380
- return regex.test(utils.basename(input));
1381
- };
1382
- picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
1383
- picomatch.parse = (pattern, options)=>{
1384
- if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
1385
- return parse(pattern, {
1386
- ...options,
1387
- fastpaths: false
1388
- });
1389
- };
1390
- picomatch.scan = (input, options)=>scan(input, options);
1391
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
1392
- if (true === returnOutput) return state.output;
1393
- const opts = options || {};
1394
- const prepend = opts.contains ? '' : '^';
1395
- const append = opts.contains ? '' : '$';
1396
- let source = `${prepend}(?:${state.output})${append}`;
1397
- if (state && true === state.negated) source = `^(?!${source}).*$`;
1398
- const regex = picomatch.toRegex(source, options);
1399
- if (true === returnState) regex.state = state;
1400
- return regex;
1401
- };
1402
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
1403
- if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
1404
- let parsed = {
1405
- negated: false,
1406
- fastpaths: true
1407
- };
1408
- if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
1409
- if (!parsed.output) parsed = parse(input, options);
1410
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
1411
- };
1412
- picomatch.toRegex = (source, options)=>{
1413
- try {
1414
- const opts = options || {};
1415
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
1416
- } catch (err) {
1417
- if (options && true === options.debug) throw err;
1418
- return /$^/;
1419
- }
1420
- };
1421
- picomatch.constants = constants;
1422
- module.exports = picomatch;
1423
- },
1424
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
1425
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
1426
- 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.4/node_modules/picomatch/lib/constants.js");
1427
- const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1428
- const depth = (token)=>{
1429
- if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
1430
- };
1431
- const scan = (input, options)=>{
1432
- const opts = options || {};
1433
- const length = input.length - 1;
1434
- const scanToEnd = true === opts.parts || true === opts.scanToEnd;
1435
- const slashes = [];
1436
- const tokens = [];
1437
- const parts = [];
1438
- let str = input;
1439
- let index = -1;
1440
- let start = 0;
1441
- let lastIndex = 0;
1442
- let isBrace = false;
1443
- let isBracket = false;
1444
- let isGlob = false;
1445
- let isExtglob = false;
1446
- let isGlobstar = false;
1447
- let braceEscaped = false;
1448
- let backslashes = false;
1449
- let negated = false;
1450
- let negatedExtglob = false;
1451
- let finished = false;
1452
- let braces = 0;
1453
- let prev;
1454
- let code;
1455
- let token = {
1456
- value: '',
1457
- depth: 0,
1458
- isGlob: false
1459
- };
1460
- const eos = ()=>index >= length;
1461
- const peek = ()=>str.charCodeAt(index + 1);
1462
- const advance = ()=>{
1463
- prev = code;
1464
- return str.charCodeAt(++index);
1465
- };
1466
- while(index < length){
1467
- code = advance();
1468
- let next;
1469
- if (code === CHAR_BACKWARD_SLASH) {
1470
- backslashes = token.backslashes = true;
1471
- code = advance();
1472
- if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
1473
- continue;
1474
- }
1475
- if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
1476
- braces++;
1477
- while(true !== eos() && (code = advance())){
1478
- if (code === CHAR_BACKWARD_SLASH) {
1479
- backslashes = token.backslashes = true;
1480
- advance();
1481
- continue;
1482
- }
1483
- if (code === CHAR_LEFT_CURLY_BRACE) {
1484
- braces++;
1485
- continue;
1486
- }
1487
- if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1488
- isBrace = token.isBrace = true;
1489
- isGlob = token.isGlob = true;
1490
- finished = true;
1491
- if (true === scanToEnd) continue;
1492
- break;
1493
- }
1494
- if (true !== braceEscaped && code === CHAR_COMMA) {
1495
- isBrace = token.isBrace = true;
1496
- isGlob = token.isGlob = true;
1497
- finished = true;
1498
- if (true === scanToEnd) continue;
1499
- break;
1500
- }
1501
- if (code === CHAR_RIGHT_CURLY_BRACE) {
1502
- braces--;
1503
- if (0 === braces) {
1504
- braceEscaped = false;
1505
- isBrace = token.isBrace = true;
1506
- finished = true;
1507
- break;
1508
- }
1509
- }
1510
- }
1511
- if (true === scanToEnd) continue;
1512
- break;
1513
- }
1514
- if (code === CHAR_FORWARD_SLASH) {
1515
- slashes.push(index);
1516
- tokens.push(token);
1517
- token = {
1518
- value: '',
1519
- depth: 0,
1520
- isGlob: false
1521
- };
1522
- if (true === finished) continue;
1523
- if (prev === CHAR_DOT && index === start + 1) {
1524
- start += 2;
1525
- continue;
1526
- }
1527
- lastIndex = index + 1;
1528
- continue;
1529
- }
1530
- if (true !== opts.noext) {
1531
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
1532
- if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
1533
- isGlob = token.isGlob = true;
1534
- isExtglob = token.isExtglob = true;
1535
- finished = true;
1536
- if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
1537
- if (true === scanToEnd) {
1538
- while(true !== eos() && (code = advance())){
1539
- if (code === CHAR_BACKWARD_SLASH) {
1540
- backslashes = token.backslashes = true;
1541
- code = advance();
1542
- continue;
1543
- }
1544
- if (code === CHAR_RIGHT_PARENTHESES) {
1545
- isGlob = token.isGlob = true;
1546
- finished = true;
1547
- break;
1548
- }
1549
- }
1550
- continue;
1551
- }
1552
- break;
1553
- }
1554
- }
1555
- if (code === CHAR_ASTERISK) {
1556
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1557
- isGlob = token.isGlob = true;
1558
- finished = true;
1559
- if (true === scanToEnd) continue;
1560
- break;
1561
- }
1562
- if (code === CHAR_QUESTION_MARK) {
1563
- isGlob = token.isGlob = true;
1564
- finished = true;
1565
- if (true === scanToEnd) continue;
1566
- break;
1567
- }
1568
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
1569
- while(true !== eos() && (next = advance())){
1570
- if (next === CHAR_BACKWARD_SLASH) {
1571
- backslashes = token.backslashes = true;
1572
- advance();
1573
- continue;
1574
- }
1575
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1576
- isBracket = token.isBracket = true;
1577
- isGlob = token.isGlob = true;
1578
- finished = true;
1579
- break;
1580
- }
1581
- }
1582
- if (true === scanToEnd) continue;
1583
- break;
1584
- }
1585
- if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
1586
- negated = token.negated = true;
1587
- start++;
1588
- continue;
1589
- }
1590
- if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
1591
- isGlob = token.isGlob = true;
1592
- if (true === scanToEnd) {
1593
- while(true !== eos() && (code = advance())){
1594
- if (code === CHAR_LEFT_PARENTHESES) {
1595
- backslashes = token.backslashes = true;
1596
- code = advance();
1597
- continue;
1598
- }
1599
- if (code === CHAR_RIGHT_PARENTHESES) {
1600
- finished = true;
1601
- break;
1602
- }
1603
- }
1604
- continue;
1605
- }
1606
- break;
1607
- }
1608
- if (true === isGlob) {
1609
- finished = true;
1610
- if (true === scanToEnd) continue;
1611
- break;
1612
- }
1613
- }
1614
- if (true === opts.noext) {
1615
- isExtglob = false;
1616
- isGlob = false;
1617
- }
1618
- let base = str;
1619
- let prefix = '';
1620
- let glob = '';
1621
- if (start > 0) {
1622
- prefix = str.slice(0, start);
1623
- str = str.slice(start);
1624
- lastIndex -= start;
1625
- }
1626
- if (base && true === isGlob && lastIndex > 0) {
1627
- base = str.slice(0, lastIndex);
1628
- glob = str.slice(lastIndex);
1629
- } else if (true === isGlob) {
1630
- base = '';
1631
- glob = str;
1632
- } else base = str;
1633
- if (base && '' !== base && '/' !== base && base !== str) {
1634
- if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
1635
- }
1636
- if (true === opts.unescape) {
1637
- if (glob) glob = utils.removeBackslashes(glob);
1638
- if (base && true === backslashes) base = utils.removeBackslashes(base);
1639
- }
1640
- const state = {
1641
- prefix,
1642
- input,
1643
- start,
1644
- base,
1645
- glob,
1646
- isBrace,
1647
- isBracket,
1648
- isGlob,
1649
- isExtglob,
1650
- isGlobstar,
1651
- negated,
1652
- negatedExtglob
1653
- };
1654
- if (true === opts.tokens) {
1655
- state.maxDepth = 0;
1656
- if (!isPathSeparator(code)) tokens.push(token);
1657
- state.tokens = tokens;
1658
- }
1659
- if (true === opts.parts || true === opts.tokens) {
1660
- let prevIndex;
1661
- for(let idx = 0; idx < slashes.length; idx++){
1662
- const n = prevIndex ? prevIndex + 1 : start;
1663
- const i = slashes[idx];
1664
- const value = input.slice(n, i);
1665
- if (opts.tokens) {
1666
- if (0 === idx && 0 !== start) {
1667
- tokens[idx].isPrefix = true;
1668
- tokens[idx].value = prefix;
1669
- } else tokens[idx].value = value;
1670
- depth(tokens[idx]);
1671
- state.maxDepth += tokens[idx].depth;
1672
- }
1673
- if (0 !== idx || '' !== value) parts.push(value);
1674
- prevIndex = i;
1675
- }
1676
- if (prevIndex && prevIndex + 1 < input.length) {
1677
- const value = input.slice(prevIndex + 1);
1678
- parts.push(value);
1679
- if (opts.tokens) {
1680
- tokens[tokens.length - 1].value = value;
1681
- depth(tokens[tokens.length - 1]);
1682
- state.maxDepth += tokens[tokens.length - 1].depth;
1683
- }
1684
- }
1685
- state.slashes = slashes;
1686
- state.parts = parts;
1687
- }
1688
- return state;
1689
- };
1690
- module.exports = scan;
1691
- },
1692
- "./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
1693
- const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
1694
- exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
1695
- exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
1696
- exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
1697
- exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1698
- exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
1699
- exports.isWindows = ()=>{
1700
- if ("u" > typeof navigator && navigator.platform) {
1701
- const platform = navigator.platform.toLowerCase();
1702
- return 'win32' === platform || 'windows' === platform;
1703
- }
1704
- if ("u" > typeof process && process.platform) return 'win32' === process.platform;
1705
- return false;
1706
- };
1707
- exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
1708
- exports.escapeLast = (input, char, lastIdx)=>{
1709
- const idx = input.lastIndexOf(char, lastIdx);
1710
- if (-1 === idx) return input;
1711
- if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
1712
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1713
- };
1714
- exports.removePrefix = (input, state = {})=>{
1715
- let output = input;
1716
- if (output.startsWith('./')) {
1717
- output = output.slice(2);
1718
- state.prefix = './';
1719
- }
1720
- return output;
1721
- };
1722
- exports.wrapOutput = (input, state = {}, options = {})=>{
1723
- const prepend = options.contains ? '' : '^';
1724
- const append = options.contains ? '' : '$';
1725
- let output = `${prepend}(?:${input})${append}`;
1726
- if (true === state.negated) output = `(?:^(?!${output}).*$)`;
1727
- return output;
1728
- };
1729
- exports.basename = (path, { windows } = {})=>{
1730
- const segs = path.split(windows ? /[\\/]/ : '/');
1731
- const last = segs[segs.length - 1];
1732
- if ('' === last) return segs[segs.length - 2];
1733
- return last;
1734
- };
1735
- }
1736
- });
1737
- function checkNodeVersion() {
1738
- const { versions } = process;
1739
- if ("styleText" in node_util || !versions.node || versions.bun || versions.deno) return;
1740
- throw new Error(`Unsupported Node.js version: "${process.versions.node || 'unknown'}". Expected Node.js >= 20.`);
1741
- }
1742
- checkNodeVersion();
1743
- const createStyler = (style)=>(text)=>node_util.styleText(style, String(text));
1744
- const color = {
1745
- dim: createStyler('dim'),
1746
- red: createStyler('red'),
1747
- bold: createStyler('bold'),
1748
- blue: createStyler('blue'),
1749
- cyan: createStyler('cyan'),
1750
- gray: createStyler('gray'),
1751
- black: createStyler('black'),
1752
- green: createStyler('green'),
1753
- white: createStyler('white'),
1754
- reset: createStyler('reset'),
1755
- yellow: createStyler('yellow'),
1756
- magenta: createStyler('magenta'),
1757
- underline: createStyler('underline'),
1758
- strikethrough: createStyler('strikethrough')
1759
- };
1760
- const supportsTrueColor = true === process.stdout.isTTY && process.stdout.hasColors(2 ** 24, process.env);
1761
- const boldMint = (text)=>supportsTrueColor ? `\x1b[1;38;2;132;225;199m${text}\x1b[39;22m` : color.bold(color.cyan(text));
1762
- const LOG_LEVEL = {
1763
- silent: -1,
1764
- error: 0,
1765
- warn: 1,
1766
- info: 2,
1767
- log: 2,
1768
- verbose: 3
1769
- };
1770
- const createLogType = (label, level, style)=>{
1771
- let formattedLabel;
1772
- return {
1773
- get label () {
1774
- return formattedLabel ??= color.bold(style(label.padEnd(7)));
1775
- },
1776
- level
1777
- };
1778
- };
1779
- const LOG_TYPES = {
1780
- error: createLogType('error', 'error', color.red),
1781
- warn: createLogType('warn', 'warn', color.yellow),
1782
- info: createLogType('info', 'info', color.cyan),
1783
- start: createLogType('start', 'info', color.cyan),
1784
- ready: createLogType('ready', 'info', color.green),
1785
- success: createLogType('success', 'info', color.green),
1786
- log: {
1787
- level: 'info'
1788
- },
1789
- debug: createLogType('debug', 'verbose', color.magenta)
1790
- };
1791
- const ANSI_REGEXP = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, 'g');
1792
- const stripAnsi = (text)=>text.replace(ANSI_REGEXP, '');
1793
- const errorStackRegExp = /at [^\r\n]{0,200}(?::\d+:\d+[\s)]*|\(<anonymous>\)|\(index\s\d+\))$/;
1794
- const isErrorStackMessage = (message)=>{
1795
- const stripped = stripAnsi(message);
1796
- return errorStackRegExp.test(stripped);
1797
- };
1798
- const normalizeErrorMessage = (err)=>{
1799
- if (err.stack) {
1800
- const [rawName, ...rest] = err.stack.split('\n');
1801
- const name = rawName.startsWith('Error: ') ? rawName.slice(7) : rawName;
1802
- return `${name}\n${color.gray(rest.join('\n'))}`;
1803
- }
1804
- return err.message;
1805
- };
1806
- const createLogger = (options = {})=>{
1807
- const { level = 'info', prefix, console: console1 = globalThis.console, alignMultiline } = options;
1808
- let maxLevel = level;
1809
- const log = (type, message, ...args)=>{
1810
- const logType = LOG_TYPES[type];
1811
- const { level } = logType;
1812
- if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
1813
- if (null == message) return console1.log();
1814
- const label = 'label' in logType ? logType.label : '';
1815
- const header = label ? prefix ? `${label} ${prefix}` : label : prefix;
1816
- let text = '';
1817
- const isErrorObject = message instanceof Error;
1818
- if (isErrorObject) {
1819
- text += normalizeErrorMessage(message);
1820
- const { cause } = message;
1821
- if (cause) {
1822
- text += color.yellow('\n [cause]: ');
1823
- text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
1824
- }
1825
- } else if ('error' === level && 'string' == typeof message) {
1826
- const lines = message.split('\n');
1827
- text = lines.map((line)=>isErrorStackMessage(line) ? color.gray(line) : line).join('\n');
1828
- } else text = `${message}`;
1829
- if (alignMultiline && header && !isErrorObject && text.includes('\n')) {
1830
- const indent = ' '.repeat(stripAnsi(header).length + 1);
1831
- const skipStack = 'error' === level;
1832
- text = text.split('\n').map((line, i)=>0 === i || '' === line || skipStack && isErrorStackMessage(line) ? line : indent + line).join('\n');
1833
- }
1834
- const method = 'error' === level || 'warn' === level ? level : 'log';
1835
- console1[method](header ? `${header} ${text}` : text, ...args);
1836
- };
1837
- const logger = {
1838
- greet: (message)=>log('log', boldMint(message))
1839
- };
1840
- Object.keys(LOG_TYPES).forEach((key)=>{
1841
- logger[key] = (...args)=>log(key, ...args);
1842
- });
1843
- Object.defineProperty(logger, 'level', {
1844
- get: ()=>maxLevel,
1845
- set (val) {
1846
- maxLevel = val;
1847
- }
1848
- });
1849
- Object.defineProperty(logger, 'options', {
1850
- get: ()=>({
1851
- ...options
1852
- })
1853
- });
1854
- logger.override = (customLogger)=>{
1855
- Object.assign(logger, customLogger);
1856
- };
1857
- return logger;
1858
- };
1859
- const src_logger = createLogger();
1860
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
1861
- function cleanPath(path) {
1862
- let normalized = normalize(path);
1863
- if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
1864
- return normalized;
1865
- }
1866
- const SLASHES_REGEX = /[\\/]/g;
1867
- function convertSlashes(path, separator) {
1868
- return path.replace(SLASHES_REGEX, separator);
1869
- }
1870
- const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
1871
- function isRootDirectory(path) {
1872
- return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
1873
- }
1874
- function normalizePath(path, options) {
1875
- const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
1876
- const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
1877
- if (resolvePaths) path = resolve(path);
1878
- if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
1879
- if ("." === path) return "";
1880
- const needsSeperator = path[path.length - 1] !== pathSeparator;
1881
- return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
1882
- }
1883
- function joinPathWithBasePath(filename, directoryPath) {
1884
- return directoryPath + filename;
1885
- }
1886
- function joinPathWithRelativePath(root, options) {
1887
- return function(filename, directoryPath) {
1888
- const sameRoot = directoryPath.startsWith(root);
1889
- if (sameRoot) return directoryPath.slice(root.length) + filename;
1890
- return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
1891
- };
1892
- }
1893
- function joinPath(filename) {
1894
- return filename;
1895
- }
1896
- function joinDirectoryPath(filename, directoryPath, separator) {
1897
- return directoryPath + filename + separator;
1898
- }
1899
- function build$7(root, options) {
1900
- const { relativePaths, includeBasePath } = options;
1901
- return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
1902
- }
1903
- function pushDirectoryWithRelativePath(root) {
1904
- return function(directoryPath, paths) {
1905
- paths.push(directoryPath.substring(root.length) || ".");
1906
- };
1907
- }
1908
- function pushDirectoryFilterWithRelativePath(root) {
1909
- return function(directoryPath, paths, filters) {
1910
- const relativePath = directoryPath.substring(root.length) || ".";
1911
- if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
1912
- };
1913
- }
1914
- const pushDirectory = (directoryPath, paths)=>{
1915
- paths.push(directoryPath || ".");
1916
- };
1917
- const pushDirectoryFilter = (directoryPath, paths, filters)=>{
1918
- const path = directoryPath || ".";
1919
- if (filters.every((filter)=>filter(path, true))) paths.push(path);
1920
- };
1921
- const empty$2 = ()=>{};
1922
- function build$6(root, options) {
1923
- const { includeDirs, filters, relativePaths } = options;
1924
- if (!includeDirs) return empty$2;
1925
- if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
1926
- return filters && filters.length ? pushDirectoryFilter : pushDirectory;
1927
- }
1928
- const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
1929
- if (filters.every((filter)=>filter(filename, false))) counts.files++;
1930
- };
1931
- const pushFileFilter = (filename, paths, _counts, filters)=>{
1932
- if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
1933
- };
1934
- const pushFileCount = (_filename, _paths, counts, _filters)=>{
1935
- counts.files++;
1936
- };
1937
- const pushFile = (filename, paths)=>{
1938
- paths.push(filename);
1939
- };
1940
- const empty$1 = ()=>{};
1941
- function build$5(options) {
1942
- const { excludeFiles, filters, onlyCounts } = options;
1943
- if (excludeFiles) return empty$1;
1944
- if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
1945
- if (onlyCounts) return pushFileCount;
1946
- return pushFile;
1947
- }
1948
- const getArray = (paths)=>paths;
1949
- const getArrayGroup = ()=>[
1950
- ""
1951
- ].slice(0, 0);
1952
- function build$4(options) {
1953
- return options.group ? getArrayGroup : getArray;
1954
- }
1955
- const groupFiles = (groups, directory, files)=>{
1956
- groups.push({
1957
- directory,
1958
- files,
1959
- dir: directory
1960
- });
1961
- };
1962
- const empty = ()=>{};
1963
- function build$3(options) {
1964
- return options.group ? groupFiles : empty;
1965
- }
1966
- const resolveSymlinksAsync = function(path, state, callback$1) {
1967
- const { queue, fs, options: { suppressErrors } } = state;
1968
- queue.enqueue();
1969
- fs.realpath(path, (error, resolvedPath)=>{
1970
- if (error) return queue.dequeue(suppressErrors ? null : error, state);
1971
- fs.stat(resolvedPath, (error$1, stat)=>{
1972
- if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
1973
- if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
1974
- callback$1(stat, resolvedPath);
1975
- queue.dequeue(null, state);
1976
- });
1977
- });
1978
- };
1979
- const resolveSymlinks = function(path, state, callback$1) {
1980
- const { queue, fs, options: { suppressErrors } } = state;
1981
- queue.enqueue();
1982
- try {
1983
- const resolvedPath = fs.realpathSync(path);
1984
- const stat = fs.statSync(resolvedPath);
1985
- if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
1986
- callback$1(stat, resolvedPath);
1987
- } catch (e) {
1988
- if (!suppressErrors) throw e;
1989
- }
1990
- };
1991
- function build$2(options, isSynchronous) {
1992
- if (!options.resolveSymlinks || options.excludeSymlinks) return null;
1993
- return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
1994
- }
1995
- function isRecursive(path, resolved, state) {
1996
- if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
1997
- let parent = dirname(path);
1998
- let depth = 1;
1999
- while(parent !== state.root && depth < 2){
2000
- const resolvedPath = state.symlinks.get(parent);
2001
- const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
2002
- if (isSameRoot) depth++;
2003
- else parent = dirname(parent);
2004
- }
2005
- state.symlinks.set(path, resolved);
2006
- return depth > 1;
2007
- }
2008
- function isRecursiveUsingRealPaths(resolved, state) {
2009
- return state.visited.includes(resolved + state.options.pathSeparator);
2010
- }
2011
- const onlyCountsSync = (state)=>state.counts;
2012
- const groupsSync = (state)=>state.groups;
2013
- const defaultSync = (state)=>state.paths;
2014
- const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
2015
- const onlyCountsAsync = (state, error, callback$1)=>{
2016
- report(error, callback$1, state.counts, state.options.suppressErrors);
2017
- return null;
2018
- };
2019
- const defaultAsync = (state, error, callback$1)=>{
2020
- report(error, callback$1, state.paths, state.options.suppressErrors);
2021
- return null;
2022
- };
2023
- const limitFilesAsync = (state, error, callback$1)=>{
2024
- report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
2025
- return null;
2026
- };
2027
- const groupsAsync = (state, error, callback$1)=>{
2028
- report(error, callback$1, state.groups, state.options.suppressErrors);
2029
- return null;
2030
- };
2031
- function report(error, callback$1, output, suppressErrors) {
2032
- callback$1(error && !suppressErrors ? error : null, output);
2033
- }
2034
- function build$1(options, isSynchronous) {
2035
- const { onlyCounts, group, maxFiles } = options;
2036
- if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
2037
- if (group) return isSynchronous ? groupsSync : groupsAsync;
2038
- if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
2039
- return isSynchronous ? defaultSync : defaultAsync;
2040
- }
2041
- const readdirOpts = {
2042
- withFileTypes: true
2043
- };
2044
- const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
2045
- state.queue.enqueue();
2046
- if (currentDepth < 0) return state.queue.dequeue(null, state);
2047
- const { fs } = state;
2048
- state.visited.push(crawlPath);
2049
- state.counts.directories++;
2050
- fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
2051
- callback$1(entries, directoryPath, currentDepth);
2052
- state.queue.dequeue(state.options.suppressErrors ? null : error, state);
2053
- });
2054
- };
2055
- const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
2056
- const { fs } = state;
2057
- if (currentDepth < 0) return;
2058
- state.visited.push(crawlPath);
2059
- state.counts.directories++;
2060
- let entries = [];
2061
- try {
2062
- entries = fs.readdirSync(crawlPath || ".", readdirOpts);
2063
- } catch (e) {
2064
- if (!state.options.suppressErrors) throw e;
2065
- }
2066
- callback$1(entries, directoryPath, currentDepth);
2067
- };
2068
- function build(isSynchronous) {
2069
- return isSynchronous ? walkSync : walkAsync;
2070
- }
2071
- var Queue = class {
2072
- count = 0;
2073
- constructor(onQueueEmpty){
2074
- this.onQueueEmpty = onQueueEmpty;
2075
- }
2076
- enqueue() {
2077
- this.count++;
2078
- return this.count;
2079
- }
2080
- dequeue(error, output) {
2081
- if (this.onQueueEmpty && (--this.count <= 0 || error)) {
2082
- this.onQueueEmpty(error, output);
2083
- if (error) {
2084
- output.controller.abort();
2085
- this.onQueueEmpty = void 0;
2086
- }
2087
- }
2088
- }
2089
- };
2090
- var Counter = class {
2091
- _files = 0;
2092
- _directories = 0;
2093
- set files(num) {
2094
- this._files = num;
2095
- }
2096
- get files() {
2097
- return this._files;
2098
- }
2099
- set directories(num) {
2100
- this._directories = num;
2101
- }
2102
- get directories() {
2103
- return this._directories;
2104
- }
2105
- get dirs() {
2106
- return this._directories;
2107
- }
2108
- };
2109
- var Aborter = class {
2110
- aborted = false;
2111
- abort() {
2112
- this.aborted = true;
2113
- }
2114
- };
2115
- var Walker = class {
2116
- root;
2117
- isSynchronous;
2118
- state;
2119
- joinPath;
2120
- pushDirectory;
2121
- pushFile;
2122
- getArray;
2123
- groupFiles;
2124
- resolveSymlink;
2125
- walkDirectory;
2126
- callbackInvoker;
2127
- constructor(root, options, callback$1){
2128
- this.isSynchronous = !callback$1;
2129
- this.callbackInvoker = build$1(options, this.isSynchronous);
2130
- this.root = normalizePath(root, options);
2131
- this.state = {
2132
- root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
2133
- paths: [
2134
- ""
2135
- ].slice(0, 0),
2136
- groups: [],
2137
- counts: new Counter(),
2138
- options,
2139
- queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
2140
- symlinks: /* @__PURE__ */ new Map(),
2141
- visited: [
2142
- ""
2143
- ].slice(0, 0),
2144
- controller: new Aborter(),
2145
- fs: options.fs || __rspack_external_fs
2146
- };
2147
- this.joinPath = build$7(this.root, options);
2148
- this.pushDirectory = build$6(this.root, options);
2149
- this.pushFile = build$5(options);
2150
- this.getArray = build$4(options);
2151
- this.groupFiles = build$3(options);
2152
- this.resolveSymlink = build$2(options, this.isSynchronous);
2153
- this.walkDirectory = build(this.isSynchronous);
2154
- }
2155
- start() {
2156
- this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
2157
- this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
2158
- return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
2159
- }
2160
- walk = (entries, directoryPath, depth)=>{
2161
- const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
2162
- if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
2163
- const files = this.getArray(this.state.paths);
2164
- for(let i = 0; i < entries.length; ++i){
2165
- const entry = entries[i];
2166
- if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
2167
- const filename = this.joinPath(entry.name, directoryPath);
2168
- this.pushFile(filename, files, this.state.counts, filters);
2169
- } else if (entry.isDirectory()) {
2170
- let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
2171
- if (exclude && exclude(entry.name, path)) continue;
2172
- this.pushDirectory(path, paths, filters);
2173
- this.walkDirectory(this.state, path, path, depth - 1, this.walk);
2174
- } else if (this.resolveSymlink && entry.isSymbolicLink()) {
2175
- let path = joinPathWithBasePath(entry.name, directoryPath);
2176
- this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
2177
- if (stat.isDirectory()) {
2178
- resolvedPath = normalizePath(resolvedPath, this.state.options);
2179
- if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
2180
- this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
2181
- } else {
2182
- resolvedPath = useRealPaths ? resolvedPath : path;
2183
- const filename = basename(resolvedPath);
2184
- const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
2185
- resolvedPath = this.joinPath(filename, directoryPath$1);
2186
- this.pushFile(resolvedPath, files, this.state.counts, filters);
2187
- }
2188
- });
2189
- }
2190
- }
2191
- this.groupFiles(this.state.groups, directoryPath, files);
2192
- };
2193
- };
2194
- function promise(root, options) {
2195
- return new Promise((resolve$1, reject)=>{
2196
- callback(root, options, (err, output)=>{
2197
- if (err) return reject(err);
2198
- resolve$1(output);
2199
- });
2200
- });
2201
- }
2202
- function callback(root, options, callback$1) {
2203
- let walker = new Walker(root, options, callback$1);
2204
- walker.start();
2205
- }
2206
- function sync(root, options) {
2207
- const walker = new Walker(root, options);
2208
- return walker.start();
2209
- }
2210
- var APIBuilder = class {
2211
- constructor(root, options){
2212
- this.root = root;
2213
- this.options = options;
2214
- }
2215
- withPromise() {
2216
- return promise(this.root, this.options);
2217
- }
2218
- withCallback(cb) {
2219
- callback(this.root, this.options, cb);
2220
- }
2221
- sync() {
2222
- return sync(this.root, this.options);
2223
- }
2224
- };
2225
- let pm = null;
2226
- try {
2227
- __require.resolve("picomatch");
2228
- pm = __require("picomatch");
2229
- } catch {}
2230
- var Builder = class {
2231
- globCache = {};
2232
- options = {
2233
- maxDepth: 1 / 0,
2234
- suppressErrors: true,
2235
- pathSeparator: sep,
2236
- filters: []
2237
- };
2238
- globFunction;
2239
- constructor(options){
2240
- this.options = {
2241
- ...this.options,
2242
- ...options
2243
- };
2244
- this.globFunction = this.options.globFunction;
2245
- }
2246
- group() {
2247
- this.options.group = true;
2248
- return this;
2249
- }
2250
- withPathSeparator(separator) {
2251
- this.options.pathSeparator = separator;
2252
- return this;
2253
- }
2254
- withBasePath() {
2255
- this.options.includeBasePath = true;
2256
- return this;
2257
- }
2258
- withRelativePaths() {
2259
- this.options.relativePaths = true;
2260
- return this;
2261
- }
2262
- withDirs() {
2263
- this.options.includeDirs = true;
2264
- return this;
2265
- }
2266
- withMaxDepth(depth) {
2267
- this.options.maxDepth = depth;
2268
- return this;
2269
- }
2270
- withMaxFiles(limit) {
2271
- this.options.maxFiles = limit;
2272
- return this;
2273
- }
2274
- withFullPaths() {
2275
- this.options.resolvePaths = true;
2276
- this.options.includeBasePath = true;
2277
- return this;
2278
- }
2279
- withErrors() {
2280
- this.options.suppressErrors = false;
2281
- return this;
2282
- }
2283
- withSymlinks({ resolvePaths = true } = {}) {
2284
- this.options.resolveSymlinks = true;
2285
- this.options.useRealPaths = resolvePaths;
2286
- return this.withFullPaths();
2287
- }
2288
- withAbortSignal(signal) {
2289
- this.options.signal = signal;
2290
- return this;
2291
- }
2292
- normalize() {
2293
- this.options.normalizePath = true;
2294
- return this;
2295
- }
2296
- filter(predicate) {
2297
- this.options.filters.push(predicate);
2298
- return this;
2299
- }
2300
- onlyDirs() {
2301
- this.options.excludeFiles = true;
2302
- this.options.includeDirs = true;
2303
- return this;
2304
- }
2305
- exclude(predicate) {
2306
- this.options.exclude = predicate;
2307
- return this;
2308
- }
2309
- onlyCounts() {
2310
- this.options.onlyCounts = true;
2311
- return this;
2312
- }
2313
- crawl(root) {
2314
- return new APIBuilder(root || ".", this.options);
2315
- }
2316
- withGlobFunction(fn) {
2317
- this.globFunction = fn;
2318
- return this;
2319
- }
2320
- crawlWithOptions(root, options) {
2321
- this.options = {
2322
- ...this.options,
2323
- ...options
2324
- };
2325
- return new APIBuilder(root || ".", this.options);
2326
- }
2327
- glob(...patterns) {
2328
- if (this.globFunction) return this.globWithOptions(patterns);
2329
- return this.globWithOptions(patterns, {
2330
- dot: true
2331
- });
2332
- }
2333
- globWithOptions(patterns, ...options) {
2334
- const globFn = this.globFunction || pm;
2335
- if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
2336
- var isMatch = this.globCache[patterns.join("\0")];
2337
- if (!isMatch) {
2338
- isMatch = globFn(patterns, ...options);
2339
- this.globCache[patterns.join("\0")] = isMatch;
2340
- }
2341
- this.options.filters.push((path)=>isMatch(path));
2342
- return this;
2343
- }
2344
- };
2345
- const picomatch = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
2346
- const isReadonlyArray = Array.isArray;
2347
- const BACKSLASHES = /\\/g;
2348
- const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
2349
- const isWin = "win32" === process.platform;
2350
- const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2351
- function getPartialMatcher(patterns, options = {}) {
2352
- const patternsCount = patterns.length;
2353
- const patternsParts = Array(patternsCount);
2354
- const matchers = Array(patternsCount);
2355
- let i, j;
2356
- for(i = 0; i < patternsCount; i++){
2357
- const parts = splitPattern(patterns[i]);
2358
- patternsParts[i] = parts;
2359
- const partsCount = parts.length;
2360
- const partMatchers = Array(partsCount);
2361
- for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
2362
- matchers[i] = partMatchers;
2363
- }
2364
- return (input)=>{
2365
- const inputParts = input.split("/");
2366
- if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
2367
- for(i = 0; i < patternsCount; i++){
2368
- const patternParts = patternsParts[i];
2369
- const matcher = matchers[i];
2370
- const inputPatternCount = inputParts.length;
2371
- const minParts = Math.min(inputPatternCount, patternParts.length);
2372
- j = 0;
2373
- while(j < minParts){
2374
- const part = patternParts[j];
2375
- if (part.includes("/")) return true;
2376
- if (!matcher[j](inputParts[j])) break;
2377
- if (!options.noglobstar && "**" === part) return true;
2378
- j++;
2379
- }
2380
- if (j === inputPatternCount) return true;
2381
- }
2382
- return false;
2383
- };
2384
- }
2385
- const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
2386
- const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
2387
- function buildFormat(cwd, root, absolute) {
2388
- if (cwd === root || root.startsWith(`${cwd}/`)) {
2389
- if (absolute) {
2390
- const start = cwd.length + +!isRoot(cwd);
2391
- return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
2392
- }
2393
- const prefix = root.slice(cwd.length + 1);
2394
- if (prefix) return (p, isDir)=>{
2395
- if ("." === p) return prefix;
2396
- const result = `${prefix}/${p}`;
2397
- return isDir ? result.slice(0, -1) : result;
2398
- };
2399
- return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
2400
- }
2401
- if (absolute) return (p)=>posix.relative(cwd, p) || ".";
2402
- return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
2403
- }
2404
- function buildRelative(cwd, root) {
2405
- if (root.startsWith(`${cwd}/`)) {
2406
- const prefix = root.slice(cwd.length + 1);
2407
- return (p)=>`${prefix}/${p}`;
2408
- }
2409
- return (p)=>{
2410
- const result = posix.relative(cwd, `${root}/${p}`);
2411
- return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
2412
- };
2413
- }
2414
- function ensureNonDriveRelativePath(path) {
2415
- return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
2416
- }
2417
- const splitPatternOptions = {
2418
- parts: true
2419
- };
2420
- function splitPattern(path) {
2421
- var _result$parts;
2422
- const result = picomatch.scan(path, splitPatternOptions);
2423
- return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
2424
- path
2425
- ];
2426
- }
2427
- const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2428
- const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
2429
- const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2430
- const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2431
- const escapePath = isWin ? escapeWin32Path : escapePosixPath;
2432
- function isDynamicPattern(pattern, options) {
2433
- if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
2434
- const scan = picomatch.scan(pattern);
2435
- return scan.isGlob || scan.negated;
2436
- }
2437
- function dist_log(...tasks) {
2438
- console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
2439
- }
2440
- function ensureStringArray(value) {
2441
- return "string" == typeof value ? [
2442
- value
2443
- ] : null != value ? value : [];
2444
- }
2445
- const PARENT_DIRECTORY = /^(\/?\.\.)+/;
2446
- const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2447
- function normalizePattern(pattern, opts, props, isIgnore) {
2448
- var _PARENT_DIRECTORY$exe;
2449
- const cwd = opts.cwd;
2450
- let result = pattern;
2451
- if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
2452
- if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
2453
- const escapedCwd = escapePath(cwd);
2454
- result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
2455
- const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
2456
- const parts = splitPattern(result);
2457
- if (parentDir) {
2458
- const n = (parentDir.length + 1) / 3;
2459
- let i = 0;
2460
- const cwdParts = escapedCwd.split("/");
2461
- while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
2462
- result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
2463
- i++;
2464
- }
2465
- const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
2466
- if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
2467
- props.root = ensureNonDriveRelativePath(potentialRoot);
2468
- props.depthOffset = -n + i;
2469
- }
2470
- }
2471
- if (!isIgnore && props.depthOffset >= 0) {
2472
- null != props.commonPath || (props.commonPath = parts);
2473
- const newCommonPath = [];
2474
- const length = Math.min(props.commonPath.length, parts.length);
2475
- for(let i = 0; i < length; i++){
2476
- const part = parts[i];
2477
- if ("**" === part && !parts[i + 1]) {
2478
- newCommonPath.pop();
2479
- break;
2480
- }
2481
- if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
2482
- newCommonPath.push(part);
2483
- }
2484
- props.depthOffset = newCommonPath.length;
2485
- props.commonPath = newCommonPath;
2486
- props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
2487
- }
2488
- return result;
2489
- }
2490
- function processPatterns(options, patterns, props) {
2491
- const matchPatterns = [];
2492
- const ignorePatterns = [];
2493
- for (const pattern of options.ignore)if (pattern) {
2494
- if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
2495
- }
2496
- for (const pattern of patterns)if (pattern) {
2497
- if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
2498
- else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
2499
- }
2500
- return {
2501
- match: matchPatterns,
2502
- ignore: ignorePatterns
2503
- };
2504
- }
2505
- function buildCrawler(options, patterns) {
2506
- const cwd = options.cwd;
2507
- const props = {
2508
- root: cwd,
2509
- depthOffset: 0
2510
- };
2511
- const processed = processPatterns(options, patterns, props);
2512
- if (options.debug) dist_log("internal processing patterns:", processed);
2513
- const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
2514
- const root = props.root.replace(BACKSLASHES, "");
2515
- const matchOptions = {
2516
- dot,
2517
- nobrace: false === options.braceExpansion,
2518
- nocase: !caseSensitiveMatch,
2519
- noextglob: false === options.extglob,
2520
- noglobstar: false === options.globstar,
2521
- posix: true
2522
- };
2523
- const matcher = picomatch(processed.match, matchOptions);
2524
- const ignore = picomatch(processed.ignore, matchOptions);
2525
- const partialMatcher = getPartialMatcher(processed.match, matchOptions);
2526
- const format = buildFormat(cwd, root, absolute);
2527
- const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
2528
- const excludePredicate = (_, p)=>{
2529
- const relativePath = excludeFormatter(p, true);
2530
- return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2531
- };
2532
- let maxDepth;
2533
- if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
2534
- const crawler = new Builder({
2535
- filters: [
2536
- debug ? (p, isDirectory)=>{
2537
- const path = format(p, isDirectory);
2538
- const matches = matcher(path) && !ignore(path);
2539
- if (matches) dist_log(`matched ${path}`);
2540
- return matches;
2541
- } : (p, isDirectory)=>{
2542
- const path = format(p, isDirectory);
2543
- return matcher(path) && !ignore(path);
2544
- }
2545
- ],
2546
- exclude: debug ? (_, p)=>{
2547
- const skipped = excludePredicate(_, p);
2548
- dist_log(`${skipped ? "skipped" : "crawling"} ${p}`);
2549
- return skipped;
2550
- } : excludePredicate,
2551
- fs: options.fs,
2552
- pathSeparator: "/",
2553
- relativePaths: !absolute,
2554
- resolvePaths: absolute,
2555
- includeBasePath: absolute,
2556
- resolveSymlinks: followSymbolicLinks,
2557
- excludeSymlinks: !followSymbolicLinks,
2558
- excludeFiles: onlyDirectories,
2559
- includeDirs: onlyDirectories || !options.onlyFiles,
2560
- maxDepth,
2561
- signal: options.signal
2562
- }).crawl(root);
2563
- if (options.debug) dist_log("internal properties:", {
2564
- ...props,
2565
- root
2566
- });
2567
- return [
2568
- crawler,
2569
- cwd !== root && !absolute && buildRelative(cwd, root)
2570
- ];
2571
- }
2572
- function formatPaths(paths, mapper) {
2573
- if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
2574
- return paths;
2575
- }
2576
- const defaultOptions = {
2577
- caseSensitiveMatch: true,
2578
- debug: !!process.env.TINYGLOBBY_DEBUG,
2579
- expandDirectories: true,
2580
- followSymbolicLinks: true,
2581
- onlyFiles: true
2582
- };
2583
- function getOptions(options) {
2584
- const opts = Object.assign({}, options);
2585
- for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
2586
- [key]: defaultOptions[key]
2587
- });
2588
- opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
2589
- opts.ignore = ensureStringArray(opts.ignore);
2590
- opts.fs && (opts.fs = {
2591
- readdir: opts.fs.readdir || readdir,
2592
- readdirSync: opts.fs.readdirSync || readdirSync,
2593
- realpath: opts.fs.realpath || realpath,
2594
- realpathSync: opts.fs.realpathSync || realpathSync,
2595
- stat: opts.fs.stat || external_fs_stat,
2596
- statSync: opts.fs.statSync || statSync
2597
- });
2598
- if (opts.debug) dist_log("globbing with options:", opts);
2599
- return opts;
2600
- }
2601
- function getCrawler(globInput, inputOptions = {}) {
2602
- var _ref;
2603
- if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2604
- const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
2605
- const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
2606
- const options = getOptions(isModern ? inputOptions : globInput);
2607
- return patterns.length > 0 ? buildCrawler(options, patterns) : [];
2608
- }
2609
- async function glob(globInput, options) {
2610
- const [crawler, relative] = getCrawler(globInput, options);
2611
- return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
2612
- }
2613
- var abbreviates_namespaceObject = /*#__PURE__*/ JSON.parse('{"abi":"ABI","amd":"AMD","api":"API","ast":"AST","bom":"BOM","bsd":"BSD","cdn":"CDN","cjs":"CJS","cli":"CLI","cncf":"CNCF","cors":"CORS","cpu":"CPU","crud":"CRUD","csrf":"CSRF","css":"CSS","csv":"CSV","db2":"DB2","dns":"DNS","dom":"DOM","dos":"DOS","es6":"ES6","esm":"ESM","fbi":"FBI","ftp":"FTP","ftps":"FTPS","gcc":"GCC","gcp":"GCP","glsl":"GLSL","gorm":"GORM","gpl":"GPL","gps":"GPS","gpu":"GPU","gre":"GRE","gui":"GUI","hdmi":"HDMI","hmr":"HMR","html":"HTML","http":"HTTP","https":"HTTPS","iife":"IIFE","iot":"IoT","ipc":"IPC","ipfs":"IPFS","ipmi":"IPMI","jdbc":"JDBC","jdk":"JDK","jit":"JIT","jpeg":"JPEG","jpg":"JPG","jre":"JRE","jsf":"JSF","json":"JSON","jsonp":"JSONP","jsp":"JSP","jwt":"JWT","kcp":"KCP","kde":"KDE","kpi":"KPI","lfu":"LFU","llvm":"LLVM","lru":"LRU","lts":"LTS","mdn":"MDN","mdx":"MDX","mvc":"MVC","mvp":"MVP","mvvm":"MVVM","nft":"NFT","odbc":"ODBC","ont":"ONT","orm":"ORM","oss":"OSS","pdf":"PDF","pdo":"PDO","posix":"POSIX","pwa":"PWA","qemu":"QEMU","qgis":"QGIS","quic":"QUIC","rfc":"RFC","rom":"ROM","rpc":"RPC","rss":"RSS","rss3":"RSS3","sdk":"SDK","seo":"SEO","sip":"SIP","smtp":"SMTP","sql":"SQL","sre":"SRE","ssg":"SSG","ssh":"SSH","sso":"SSO","ssr":"SSR","stp":"STP","svg":"SVG","svn":"SVN","tcp":"TCP","tls":"TLS","toml":"TOML","tsc":"TSC","udp":"UDP","umd":"UMD","uri":"URI","url":"URL","usb":"USB","vlan":"VLAN","vnc":"VNC","vpn":"VPN","vps":"VPS","wgsl":"WGSL","wlan":"WLAN","wsa":"WSA","wsl":"WSL","xhtml":"XHTML","xml":"XML","xss":"XSS","yaml":"YAML"}');
2614
- var brands_namespaceObject = /*#__PURE__*/ JSON.parse('{"airbnb":"Airbnb","alphago":"AlphaGo","bitbucket":"Bitbucket","bytedance":"ByteDance","circleci":"CircleCI","cloudflare":"Cloudflare","freecodecamp":"freeCodeCamp","gitea":"Gitea","gitee":"Gitee","github":"GitHub","gitlab":"GitLab","gitops":"GitOps","gitpod":"Gitpod","hp":"HP","ibm":"IBM","jsdelivr":"jsDelivr","kfc":"KFC","leetcode":"LeetCode","linkedin":"LinkedIn","mcdonald":"McDonald","nvidia":"NVIDIA","pagerduty":"PagerDuty","producthunt":"Product Hunt","stackblitz":"StackBlitz","stackit":"STACKIT","stackoverflow":"Stack Overflow","unjs":"UnJS","v2ex":"V2EX","vuefes":"Vue Fes","youtube":"YouTube"}');
2615
- var general_namespaceObject = /*#__PURE__*/ JSON.parse('{"aiaas":"AIaaS","baas":"BaaS","caas":"CaaS","daas":"DaaS","ddos":"DDoS","devops":"DevOps","devtools":"DevTools","esim":"eSIM","faas":"FaaS","iac":"IaC","iaas":"IaaS","ioc":"IoC","ipsec":"IPsec","mpaas":"mPaaS","paas":"PaaS","saas":"SaaS","wifi":"Wi-Fi","xaas":"XaaS"}');
2616
- var products_namespaceObject = /*#__PURE__*/ JSON.parse('{"airdrop":"AirDrop","airpods":"AirPods","airtag":"AirTag","homekit":"HomeKit","homepod":"HomePod","imac":"iMac","ipad":"iPad","iphone":"iPhone","ipod":"iPod","macbook":"MacBook","macbook air":"MacBook Air","macbook pro":"MacBook Pro","yubikey":"YubiKey"}');
2617
- var softwares_namespaceObject = /*#__PURE__*/ JSON.parse('{"1password":"1Password","3dtiles":"3DTiles","actionscript":"ActionScript","adblock":"AdBlock","ajax":"AJAX","alipay":"Alipay","amap":"AMap","angularjs":"AngularJS","ant design":"Ant Design","ant design vue":"Ant Design Vue","antd":"AntD","antdesign":"AntDesign","antdesignvue":"AntDesignVue","antv":"AntV","apifox":"Apifox","app store":"App Store","apple pay":"Apple Pay","applescript":"AppleScript","appletalk":"AppleTalk","arangodb":"ArangoDB","arcgis":"ArcGIS","arcmap":"ArcMap","arcobjects":"ArcObjects","beego":"Beego","bittorrent":"BitTorrent","bluesky":"Bluesky","busybox":"BusyBox","centos":"CentOS","cesiumjs":"CesiumJS","chatgpt":"ChatGPT","citygml":"CityGML","cityjson":"CityJSON","ckeditor":"CKEditor","clashx":"ClashX","clickhouse":"ClickHouse","cloudfront":"CloudFront","cmake":"CMake","cockroachdb":"CockroachDB","cocoapods":"CocoaPods","codepen":"CodePen","codesandbox":"CodeSandbox","coffeescript":"CoffeeScript","commonjs":"CommonJS","composition api":"Composition API","compositionapi":"CompositionAPI","coredns":"CoreDNS","css modules":"CSS Modules","dapr":"Dapr","datadog":"Datadog","datagrip":"DataGrip","dbase":"dBase","definitelytyped":"DefinitelyTyped","denodeploy":"DenoDeploy","digital ocean":"DigitalOcean","digitalocean":"DigitalOcean","dingtalk":"DingTalk","directx":"DirectX","django":"Django","duckduckgo":"DuckDuckGo","dynamodb":"DynamoDB","echarts":"ECharts","ecmascript":"ECMAScript","edgedb":"EdgeDB","eggjs":"Egg.js","elasticsearch":"Elasticsearch","element plus":"Element Plus","elementui":"ElementUI","esbuild":"esbuild","eslint":"ESLint","esxi":"ESXi","etcd":"etcd","facetime":"FaceTime","fastapi":"FastAPI","ffmpeg":"FFmpeg","filezilla":"FileZilla","firefox":"Firefox","freemarker":"FreeMarker","gdnative":"GDNative","gdscript":"GDScript","geforce":"GeForce","geojson":"GeoJSON","geopackage":"GeoPackage","geopandas":"GeoPandas","geoserver":"GeoServer","gitbook":"GitBook","gitkraken":"GitKraken","gltf":"glTF","gnome":"GNOME","gnu":"GNU","gnupg":"GnuPG","goland":"GoLand","google pay":"Google Pay","graph rag":"Graph RAG","graphql":"GraphQL","graphrag":"GraphRAG","greensock":"GreenSock","grpc":"gRPC","hackernews":"Hacker News","hacpai":"HacPai","hbase":"HBase","hbuilderx":"HBuilderX","ibook":"iBook","icloud":"iCloud","idrac":"iDRAC","ilo":"iLO","imessage":"iMessage","imovie":"iMovie","imtoken":"imToken","influxdb":"InfluxDB","intellij":"IntelliJ","intellij idea":"IntelliJ IDEA","ios":"iOS","ipados":"iPadOS","iphoto":"iPhoto","iscsi":"iSCSI","iterm":"iTerm","itunes":"iTunes","iwork":"iWork","javascript":"JavaScript","jetbrains":"JetBrains","jquery":"jQuery","jsdoc":"JSDoc","jupyterlab":"JupyterLab","katex":"KaTeX","kubernetes":"Kubernetes","latex":"LaTeX","less":"Less","libreoffice":"LibreOffice","line pay":"LINE Pay","lineageos":"LineageOS","macos":"macOS","mariadb":"MariaDB","markdown":"Markdown","markdownlint":"MarkdownLint","mathjax":"MathJax","mathml":"MathML","mathtype":"MathType","matlab":"MATLAB","mediawiki":"MediaWiki","memcached":"Memcached","messagepack":"MessagePack","metamask":"MetaMask","mkdocs":"MkDocs","mlaas":"MLaaS","mlops":"MLOps","mobx":"MobX","mongodb":"MongoDB","mongoose":"Mongoose","ms-dos":"MS-DOS","mybatis":"MyBatis","mysql":"MySQL","naive ui":"Naive UI","naiveui":"NaiveUI","neo4j":"Neo4j","nestjs":"NestJS","netbeans":"NetBeans","netbios":"NetBIOS","nextjs":"Next.js","nixos":"NixOS","nocodb":"NocoDB","node.js":"Node.js","nosql":"NoSQL","notepad ++":"Notepad++","npm":"npm","numpy":"NumPy","nuxtjs":"NuxtJS","oauth":"OAuth","obs":"OBS","ocaml":"OCaml","onedrive":"OneDrive","onenote":"OneNote","openai":"OpenAI","openapi":"OpenAPI","opencv":"OpenCV","openfaas":"OpenFaaS","openflow":"OpenFlow","opengauss":"openGauss","opengl":"OpenGL","opengl es":"OpenGL ES","openjdk":"OpenJDK","openlayers":"OpenLayers","openpgp":"OpenPGP","opensea":"OpenSea","openssl":"OpenSSL","openstack":"OpenStack","openstreetmap":"OpenStreetMap","opensuse":"openSUSE","openvino":"OpenVINO","openwrt":"OpenWrt","opnsense":"OPNsense","pagp":"PAgP","paypal":"PayPal","photoshop":"Photoshop","php":"PHP","phpstorm":"PhpStorm","pihole":"Pi-hole","planetscale":"PlanetScale","postcss":"PostCSS","postgis":"PostGIS","postgresql":"PostgreSQL","potplayer":"PotPlayer","powerpoint":"PowerPoint","powershell":"PowerShell","premid":"PreMiD","primevue":"PrimeVue","protobuf":"Protobuf","pycharm":"PyCharm","pytorch":"PyTorch","qtscript":"QtScript","raii":"RAII","react native":"React Native","redhat":"RedHat","redisearch":"RediSearch","redisjson":"RedisJSON","rescript":"ReScript","restful":"RESTful","rethinkdb":"RethinkDB","rsshub":"RSSHub","rust":"Rust","rxdb":"RxDB","rxjs":"RxJS","samsung pay":"Samsung Pay","sass":"Sass","scss":"SCSS","segmentfault":"SegmentFault","socket.io":"Socket.IO","solarwinds":"SolarWinds","spatiallite":"SpatialLite","spir-v":"SPIR-V","springboot":"SpringBoot","springcloud":"SpringCloud","springmvc":"SpringMVC","sqlite":"SQLite","sqlserver":"SQLServer","storybook":"Storybook","stylus":"Stylus","sublime text":"Sublime Text","surrealdb":"SurrealDB","sveltekit":"SvelteKit","tailwind css":"Tailwind CSS","tailwindcss":"TailwindCSS","teamviewer":"TeamViewer","tensorflow":"TensorFlow","testflight":"TestFlight","tex":"TeX","threejs":"ThreeJS","tianocore":"TianoCore","tidb":"TiDB","tiflash":"TiFlash","tiktok":"TikTok","tikv":"TiKV","travis ci":"Travis CI","trpc":"tRPC","tsconfig":"TSConfig","tsdoc":"TSDoc","tsdx":"TSdx","turbopack":"Turbopack","turborepo":"Turborepo","typeorm":"TypeORM","typescript":"TypeScript","uniapp":"uniapp","unifi":"UniFi","unix":"UNIX","unocss":"UnoCSS","upnp":"UPnP","vercel":"Vercel","videolan":"VideoLAN","vim":"Vim","virtualbox":"VirtualBox","visual studio":"Visual Studio","visual studio code":"Visual Studio Code","vitepress":"VitePress","vividcortex":"VividCortex","vlc":"VLC","vmware":"VMware","voip":"VoIP","vs code":"VS Code","vs codium":"VSCodium","vscode":"VS Code","vscodium":"VSCodium","vue cli":"Vue CLI","vuepress":"VuePress","vueuse":"VueUse","vulkan":"Vulkan","w3c":"W3C","wasm":"Wasm","watchos":"watchOS","web assembly":"WebAssembly","webar":"WebAR","webassembly":"WebAssembly","webgl":"WebGL","webgpu":"WebGPU","webkit":"WebKit","webpack":"webpack","webrtc":"WebRTC","websocket":"WebSocket","webstorm":"WebStorm","webvr":"WebVR","webxr":"WebXR","wechat":"WeChat","wechat pay":"WeChat Pay","whatsapp":"WhatsApp","windi css":"Windi CSS","windicss":"WindiCSS","wireguard":"WireGuard","wordpress":"WordPress","xmind":"XMind","xstate":"XState","yapi":"YApi"}');
2618
- const dict = [
2619
- ...Object.values(abbreviates_namespaceObject),
2620
- ...Object.values(brands_namespaceObject),
2621
- ...Object.values(general_namespaceObject),
2622
- ...Object.values(products_namespaceObject),
2623
- ...Object.values(softwares_namespaceObject),
2624
- 'Angular',
2625
- 'Agent Skills',
2626
- 'API Report File',
2627
- 'App Router',
2628
- 'Babel',
2629
- 'Baseline',
2630
- 'Create React App',
2631
- 'Cloudflare Pages',
2632
- 'Cloudflare Workers',
2633
- 'CSS Modules',
2634
- 'Coding Agent',
2635
- 'Coding Agents',
2636
- 'Docusaurus',
2637
- 'Docusaurus Faster',
2638
- 'EJS',
2639
- 'Emotion',
2640
- 'Fast Refresh',
2641
- 'Git',
2642
- 'GitHub Actions',
2643
- 'GitHub Pages',
2644
- 'I',
2645
- 'Jest',
2646
- 'Lightning CSS',
2647
- 'Lynx',
2648
- 'Module Federation',
2649
- 'Nextra',
2650
- 'Netlify',
2651
- 'Kinsta',
2652
- 'Open Graph',
2653
- 'Page Router',
2654
- 'Parcel',
2655
- 'Playwright',
2656
- 'Preact',
2657
- 'Preact Refresh',
2658
- 'Relay',
2659
- 'React',
2660
- 'React Compiler',
2661
- 'React Router',
2662
- 'React Scan',
2663
- 'React Server Components',
2664
- 'Rollup',
2665
- 'Rsbuild',
2666
- 'Rsdoctor',
2667
- 'Rslib',
2668
- 'Rspack',
2669
- 'Rstack',
2670
- 'Rspack Stack',
2671
- 'Rspress',
2672
- 'Rstest',
2673
- 'Rslint',
2674
- 'Solid',
2675
- 'Svelte',
2676
- 'Server Action',
2677
- 'Service Worker',
2678
- 'TanStack Router',
2679
- 'TanStack Start',
2680
- 'Vite',
2681
- 'Vitest',
2682
- 'Vue',
2683
- 'Web Workers',
2684
- 'Xcode',
2685
- 'Yarn',
2686
- 'Zeabur',
2687
- 'Zephyr',
2688
- 'Zephyr Cloud'
2689
- ];
2690
- const picocolors = __webpack_require__("./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
2691
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
2692
- const DEFAULT_IGNORE = [
2693
- '**/node_modules',
2694
- '**/dist',
2695
- '**/.git',
2696
- '**/.cache',
2697
- '**/temp'
2698
- ];
2699
- function getGitIgnorePatterns(cwd) {
2700
- try {
2701
- const stdout = execFileSync('git', [
2702
- 'ls-files',
2703
- '--others',
2704
- '--ignored',
2705
- '--exclude-standard',
2706
- '--directory',
2707
- '-z'
2708
- ], {
2709
- cwd,
2710
- encoding: 'utf8',
2711
- stdio: [
2712
- 'ignore',
2713
- 'pipe',
2714
- 'ignore'
2715
- ]
2716
- });
2717
- return stdout.split('\0').filter(Boolean).map((path)=>escapePath(path));
2718
- } catch {
2719
- return [];
2720
- }
2721
- }
2722
- async function globMarkdownFiles(cwd) {
2723
- return glob([
2724
- '**/*.md',
2725
- '**/*.mdx'
2726
- ], {
2727
- cwd,
2728
- ignore: [
2729
- ...DEFAULT_IGNORE,
2730
- ...getGitIgnorePatterns(cwd)
2731
- ],
2732
- absolute: true
2733
- });
2734
- }
2735
- const isTitleLine = (line)=>/^#{1,6}\s+\S/.test(line.trim());
2736
- const isEnglishWord = (word)=>/^[a-zA-Z]+$/.test(word);
2737
- const isFirstCharUppercase = (word)=>/^[A-Z][a-z]*$/.test(word);
2738
- const isTerm = (word, line)=>dict.some((term)=>{
2739
- if (term.includes(` ${word}`) || term.includes(`${word} `)) return line.includes(term);
2740
- return term === word;
2741
- });
2742
- const shouldWrite = process.argv.includes('--write');
2743
- const lineToWords = (line)=>{
2744
- const words = [];
2745
- let lastWord = {
2746
- type: 'word',
2747
- value: ''
2748
- };
2749
- for (const char of line.split(''))if (/\s/.test(char)) if ('space' === lastWord.type) lastWord.value += char;
2750
- else {
2751
- words.push(lastWord);
2752
- lastWord = {
2753
- type: 'space',
2754
- value: char
2755
- };
2756
- }
2757
- else if ('word' === lastWord.type) lastWord.value += char;
2758
- else {
2759
- words.push(lastWord);
2760
- lastWord = {
2761
- type: 'word',
2762
- value: char
2763
- };
2764
- }
2765
- words.push(lastWord);
2766
- return words;
2767
- };
2768
- const formatLine = (line)=>{
2769
- const words = lineToWords(line);
2770
- const englishWords = [];
2771
- for(let index = 0; index < words.length; index++){
2772
- const word = words[index];
2773
- const { type, value } = word;
2774
- if ('space' === type) continue;
2775
- if (isEnglishWord(value)) englishWords.push(value);
2776
- if (englishWords.length <= 1 || isTerm(value, line) || !isFirstCharUppercase(value)) continue;
2777
- const lowerCase = value.toLowerCase();
2778
- if (lowerCase !== value) word.value = lowerCase;
2779
- }
2780
- return words.map((word)=>word.value).join('');
2781
- };
2782
- function formatContent(content, filePath) {
2783
- const lines = content.split('\n');
2784
- return lines.map((originalLine)=>{
2785
- if (isTitleLine(originalLine)) {
2786
- const formattedLine = formatLine(originalLine);
2787
- if (!shouldWrite && formattedLine !== originalLine) {
2788
- src_logger.error(`Unexpected heading case in ${picocolors_default().dim(filePath)}`);
2789
- src_logger.log(` Current: ${picocolors_default().cyan(originalLine)}`);
2790
- src_logger.log(` Expected: ${picocolors_default().cyan(formattedLine)}\n`);
2791
- }
2792
- return formattedLine;
2793
- }
2794
- return originalLine;
2795
- }).join('\n');
2796
- }
2797
- async function formatFile(filePath) {
2798
- const content = await node_fs.promises.readFile(filePath, 'utf-8');
2799
- const formatted = formatContent(content, filePath);
2800
- const isChanged = formatted !== content;
2801
- if (isChanged && shouldWrite) {
2802
- await node_fs.promises.writeFile(filePath, formatted);
2803
- src_logger.success(`[heading-case] formatted: ${picocolors_default().dim(filePath)}`);
2804
- }
2805
- return isChanged;
2806
- }
2807
- async function headingCase({ root = process.cwd() } = {}) {
2808
- const files = await globMarkdownFiles(root);
2809
- let count = 0;
2810
- for (const file of files){
2811
- const isFormatted = await formatFile(file);
2812
- if (isFormatted) count++;
2813
- }
2814
- if (count) if (shouldWrite) src_logger.success(`[heading-case] formatted ${picocolors_default().yellow(count.toString())} files.`);
2815
- else {
2816
- src_logger.info(`[heading-case] found issues in ${picocolors_default().yellow(count.toString())} files.`);
2817
- process.exit(1);
2818
- }
2819
- else src_logger.success(`[heading-case] ${picocolors_default().yellow(files.length)} files scanned, no issues found.`);
2820
- }
2821
- export { formatLine, globMarkdownFiles, headingCase };
1
+ import { parsers, printers } from "prettier/plugins/markdown";
2
+ import { formatWords } from "./core.js";
3
+ const AST_FORMAT = 'heading-case-mdast';
4
+ const collectWordNodes = (node, words)=>{
5
+ if (('word' === node.type || 'whitespace' === node.type) && 'string' == typeof node.value) return void words.push(node);
6
+ for (const child of node.children ?? [])collectWordNodes(child, words);
7
+ };
8
+ const formatHeading = (heading)=>{
9
+ const wordNodes = [];
10
+ collectWordNodes(heading, wordNodes);
11
+ const words = wordNodes.map((node)=>({
12
+ type: 'whitespace' === node.type ? 'space' : 'word',
13
+ value: node.value ?? ''
14
+ }));
15
+ formatWords(words);
16
+ for(let index = 0; index < wordNodes.length; index++)wordNodes[index].value = words[index].value;
17
+ };
18
+ const formatHeadings = (node)=>{
19
+ if ('heading' === node.type) return void formatHeading(node);
20
+ for (const child of node.children ?? [])formatHeadings(child);
21
+ };
22
+ const wrapParser = (parser)=>({
23
+ ...parser,
24
+ astFormat: AST_FORMAT
25
+ });
26
+ const src_parsers = {
27
+ markdown: wrapParser(parsers.markdown),
28
+ mdx: wrapParser(parsers.mdx),
29
+ remark: wrapParser(parsers.remark)
30
+ };
31
+ const markdownPrinter = printers.mdast;
32
+ const printer = {
33
+ ...markdownPrinter,
34
+ async preprocess (ast, options) {
35
+ const preprocessed = markdownPrinter.preprocess ? await markdownPrinter.preprocess(ast, options) : ast;
36
+ if (void 0 === options.parentParser) formatHeadings(preprocessed);
37
+ return preprocessed;
38
+ }
39
+ };
40
+ const src_printers = {
41
+ [AST_FORMAT]: printer
42
+ };
43
+ const src_plugin = {
44
+ parsers: src_parsers,
45
+ printers: src_printers
46
+ };
47
+ const src = src_plugin;
48
+ export default src;
49
+ export { src_parsers as parsers, src_printers as printers };