nitro-nightly 3.0.1-20260106-122901-e9c3a660 → 3.0.1-20260106-182834-5019d347
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/_build/rolldown.mjs +11 -11
- package/dist/_build/rollup.mjs +19 -11
- package/dist/_build/shared.mjs +3 -2
- package/dist/_build/shared2.mjs +1 -1
- package/dist/_build/shared3.mjs +2 -2
- package/dist/_build/vite.build.mjs +8 -9
- package/dist/_dev.mjs +4 -3
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +6 -1561
- package/dist/_libs/@jridgewell/gen-mapping.mjs +2 -304
- package/dist/_libs/@jridgewell/remapping.mjs +2 -1
- package/dist/_libs/@jridgewell/resolve-uri.mjs +166 -0
- package/dist/_libs/@jridgewell/sourcemap-codec.mjs +167 -0
- package/dist/_libs/@jridgewell/trace-mapping.mjs +141 -0
- package/dist/_libs/@rolldown/pluginutils.mjs +31 -0
- package/dist/_libs/@rollup/plugin-commonjs.mjs +33 -2636
- package/dist/_libs/@rollup/plugin-inject.mjs +3 -2
- package/dist/_libs/@rollup/plugin-json.mjs +1 -1
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +8 -1112
- package/dist/_libs/@rollup/plugin-replace.mjs +2 -2
- package/dist/_libs/@rollup/pluginutils.mjs +241 -0
- package/dist/_libs/c12.mjs +63 -2513
- package/dist/_libs/chokidar.mjs +2 -235
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/confbox.mjs +1511 -911
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/dotenv.mjs +345 -0
- package/dist/_libs/estree-walker.mjs +144 -1
- package/dist/_libs/exsolve.mjs +1007 -0
- package/dist/_libs/fdir.mjs +514 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/giget.mjs +1380 -2238
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +33 -0
- package/dist/_libs/js-tokens.mjs +382 -0
- package/dist/_libs/local-pkg.mjs +7 -1561
- package/dist/_libs/magic-string.mjs +939 -0
- package/dist/_libs/mlly.mjs +1415 -0
- package/dist/_libs/node-fetch-native.mjs +7 -0
- package/dist/_libs/nypm.mjs +239 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +163 -2
- package/dist/_libs/perfect-debounce.mjs +89 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/pkg-types.mjs +197 -0
- package/dist/_libs/quansync.mjs +90 -0
- package/dist/_libs/rc9.mjs +136 -0
- package/dist/_libs/readdirp.mjs +237 -0
- package/dist/_libs/resolve.mjs +689 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/_libs/tinyexec.mjs +627 -0
- package/dist/_libs/tinyglobby.mjs +2 -1
- package/dist/_libs/tsconfck.mjs +1 -1
- package/dist/_libs/unimport.mjs +93 -1617
- package/dist/_libs/unplugin-utils.mjs +61 -0
- package/dist/_libs/unplugin.mjs +1225 -0
- package/dist/_libs/unwasm.mjs +3 -2
- package/dist/_libs/webpack-virtual-modules.mjs +272 -0
- package/dist/_nitro.mjs +9 -7
- package/dist/_nitro2.mjs +6 -7
- package/dist/_presets.mjs +9 -7
- package/dist/builder.mjs +5 -5
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +1 -1
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/vite.mjs +1825 -22
- package/package.json +2 -2
- package/dist/_build/shared4.mjs +0 -1112
- package/dist/_build/vite.plugin.mjs +0 -712
|
@@ -1,2616 +1,13 @@
|
|
|
1
|
-
import { i as __toESM
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { i as __toESM } from "../../_rolldown.mjs";
|
|
2
|
+
import { t as Builder } from "../fdir.mjs";
|
|
3
|
+
import { t as MagicString } from "../magic-string.mjs";
|
|
4
|
+
import { n as walk } from "../estree-walker.mjs";
|
|
5
|
+
import { a as makeLegalIdentifier, i as extractAssignedNames, n as createFilter, t as attachScopes } from "./pluginutils.mjs";
|
|
6
|
+
import { t as require_commondir } from "../commondir.mjs";
|
|
7
|
+
import { t as require_is_reference } from "../is-reference.mjs";
|
|
4
8
|
import { existsSync, readFileSync, statSync } from "fs";
|
|
5
|
-
import { basename, dirname, extname,
|
|
6
|
-
import { createRequire } from "module";
|
|
9
|
+
import { basename, dirname, extname, join, relative, resolve, sep } from "path";
|
|
7
10
|
|
|
8
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
9
|
-
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10
|
-
const WIN_SLASH = "\\\\/";
|
|
11
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
12
|
-
/**
|
|
13
|
-
* Posix glob regex
|
|
14
|
-
*/
|
|
15
|
-
const DOT_LITERAL = "\\.";
|
|
16
|
-
const PLUS_LITERAL = "\\+";
|
|
17
|
-
const QMARK_LITERAL = "\\?";
|
|
18
|
-
const SLASH_LITERAL = "\\/";
|
|
19
|
-
const ONE_CHAR = "(?=.)";
|
|
20
|
-
const QMARK = "[^/]";
|
|
21
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
22
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
23
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
24
|
-
const POSIX_CHARS = {
|
|
25
|
-
DOT_LITERAL,
|
|
26
|
-
PLUS_LITERAL,
|
|
27
|
-
QMARK_LITERAL,
|
|
28
|
-
SLASH_LITERAL,
|
|
29
|
-
ONE_CHAR,
|
|
30
|
-
QMARK,
|
|
31
|
-
END_ANCHOR,
|
|
32
|
-
DOTS_SLASH,
|
|
33
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
34
|
-
NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
|
|
35
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
|
|
36
|
-
NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
|
|
37
|
-
QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
|
|
38
|
-
STAR: `${QMARK}*?`,
|
|
39
|
-
START_ANCHOR,
|
|
40
|
-
SEP: "/"
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Windows glob regex
|
|
44
|
-
*/
|
|
45
|
-
const WINDOWS_CHARS = {
|
|
46
|
-
...POSIX_CHARS,
|
|
47
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
48
|
-
QMARK: WIN_NO_SLASH,
|
|
49
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
50
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
51
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
52
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
53
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
54
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
55
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
56
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
57
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
58
|
-
SEP: "\\"
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* POSIX Bracket Regex
|
|
62
|
-
*/
|
|
63
|
-
const POSIX_REGEX_SOURCE = {
|
|
64
|
-
alnum: "a-zA-Z0-9",
|
|
65
|
-
alpha: "a-zA-Z",
|
|
66
|
-
ascii: "\\x00-\\x7F",
|
|
67
|
-
blank: " \\t",
|
|
68
|
-
cntrl: "\\x00-\\x1F\\x7F",
|
|
69
|
-
digit: "0-9",
|
|
70
|
-
graph: "\\x21-\\x7E",
|
|
71
|
-
lower: "a-z",
|
|
72
|
-
print: "\\x20-\\x7E ",
|
|
73
|
-
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
74
|
-
space: " \\t\\r\\n\\v\\f",
|
|
75
|
-
upper: "A-Z",
|
|
76
|
-
word: "A-Za-z0-9_",
|
|
77
|
-
xdigit: "A-Fa-f0-9"
|
|
78
|
-
};
|
|
79
|
-
module.exports = {
|
|
80
|
-
MAX_LENGTH: 1024 * 64,
|
|
81
|
-
POSIX_REGEX_SOURCE,
|
|
82
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
83
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
84
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
85
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
86
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
87
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
88
|
-
REPLACEMENTS: {
|
|
89
|
-
__proto__: null,
|
|
90
|
-
"***": "*",
|
|
91
|
-
"**/**": "**",
|
|
92
|
-
"**/**/**": "**"
|
|
93
|
-
},
|
|
94
|
-
CHAR_0: 48,
|
|
95
|
-
CHAR_9: 57,
|
|
96
|
-
CHAR_UPPERCASE_A: 65,
|
|
97
|
-
CHAR_LOWERCASE_A: 97,
|
|
98
|
-
CHAR_UPPERCASE_Z: 90,
|
|
99
|
-
CHAR_LOWERCASE_Z: 122,
|
|
100
|
-
CHAR_LEFT_PARENTHESES: 40,
|
|
101
|
-
CHAR_RIGHT_PARENTHESES: 41,
|
|
102
|
-
CHAR_ASTERISK: 42,
|
|
103
|
-
CHAR_AMPERSAND: 38,
|
|
104
|
-
CHAR_AT: 64,
|
|
105
|
-
CHAR_BACKWARD_SLASH: 92,
|
|
106
|
-
CHAR_CARRIAGE_RETURN: 13,
|
|
107
|
-
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
108
|
-
CHAR_COLON: 58,
|
|
109
|
-
CHAR_COMMA: 44,
|
|
110
|
-
CHAR_DOT: 46,
|
|
111
|
-
CHAR_DOUBLE_QUOTE: 34,
|
|
112
|
-
CHAR_EQUAL: 61,
|
|
113
|
-
CHAR_EXCLAMATION_MARK: 33,
|
|
114
|
-
CHAR_FORM_FEED: 12,
|
|
115
|
-
CHAR_FORWARD_SLASH: 47,
|
|
116
|
-
CHAR_GRAVE_ACCENT: 96,
|
|
117
|
-
CHAR_HASH: 35,
|
|
118
|
-
CHAR_HYPHEN_MINUS: 45,
|
|
119
|
-
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
120
|
-
CHAR_LEFT_CURLY_BRACE: 123,
|
|
121
|
-
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
122
|
-
CHAR_LINE_FEED: 10,
|
|
123
|
-
CHAR_NO_BREAK_SPACE: 160,
|
|
124
|
-
CHAR_PERCENT: 37,
|
|
125
|
-
CHAR_PLUS: 43,
|
|
126
|
-
CHAR_QUESTION_MARK: 63,
|
|
127
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
128
|
-
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
129
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
130
|
-
CHAR_SEMICOLON: 59,
|
|
131
|
-
CHAR_SINGLE_QUOTE: 39,
|
|
132
|
-
CHAR_SPACE: 32,
|
|
133
|
-
CHAR_TAB: 9,
|
|
134
|
-
CHAR_UNDERSCORE: 95,
|
|
135
|
-
CHAR_VERTICAL_LINE: 124,
|
|
136
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
137
|
-
extglobChars(chars) {
|
|
138
|
-
return {
|
|
139
|
-
"!": {
|
|
140
|
-
type: "negate",
|
|
141
|
-
open: "(?:(?!(?:",
|
|
142
|
-
close: `))${chars.STAR})`
|
|
143
|
-
},
|
|
144
|
-
"?": {
|
|
145
|
-
type: "qmark",
|
|
146
|
-
open: "(?:",
|
|
147
|
-
close: ")?"
|
|
148
|
-
},
|
|
149
|
-
"+": {
|
|
150
|
-
type: "plus",
|
|
151
|
-
open: "(?:",
|
|
152
|
-
close: ")+"
|
|
153
|
-
},
|
|
154
|
-
"*": {
|
|
155
|
-
type: "star",
|
|
156
|
-
open: "(?:",
|
|
157
|
-
close: ")*"
|
|
158
|
-
},
|
|
159
|
-
"@": {
|
|
160
|
-
type: "at",
|
|
161
|
-
open: "(?:",
|
|
162
|
-
close: ")"
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
globChars(win32$1) {
|
|
167
|
-
return win32$1 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
174
|
-
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
175
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
176
|
-
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
177
|
-
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
178
|
-
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
179
|
-
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
180
|
-
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
181
|
-
exports.isWindows = () => {
|
|
182
|
-
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
183
|
-
const platform = navigator.platform.toLowerCase();
|
|
184
|
-
return platform === "win32" || platform === "windows";
|
|
185
|
-
}
|
|
186
|
-
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
|
|
187
|
-
return false;
|
|
188
|
-
};
|
|
189
|
-
exports.removeBackslashes = (str) => {
|
|
190
|
-
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
191
|
-
return match === "\\" ? "" : match;
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
195
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
196
|
-
if (idx === -1) return input;
|
|
197
|
-
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
198
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
199
|
-
};
|
|
200
|
-
exports.removePrefix = (input, state = {}) => {
|
|
201
|
-
let output = input;
|
|
202
|
-
if (output.startsWith("./")) {
|
|
203
|
-
output = output.slice(2);
|
|
204
|
-
state.prefix = "./";
|
|
205
|
-
}
|
|
206
|
-
return output;
|
|
207
|
-
};
|
|
208
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
209
|
-
let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
|
|
210
|
-
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
211
|
-
return output;
|
|
212
|
-
};
|
|
213
|
-
exports.basename = (path$2, { windows } = {}) => {
|
|
214
|
-
const segs = path$2.split(windows ? /[\\/]/ : "/");
|
|
215
|
-
const last = segs[segs.length - 1];
|
|
216
|
-
if (last === "") return segs[segs.length - 2];
|
|
217
|
-
return last;
|
|
218
|
-
};
|
|
219
|
-
}));
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
223
|
-
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
224
|
-
const utils = require_utils();
|
|
225
|
-
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 } = require_constants();
|
|
226
|
-
const isPathSeparator = (code) => {
|
|
227
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
228
|
-
};
|
|
229
|
-
const depth = (token) => {
|
|
230
|
-
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
234
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
235
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
236
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
237
|
-
*
|
|
238
|
-
* ```js
|
|
239
|
-
* const pm = require('picomatch');
|
|
240
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
241
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
242
|
-
* ```
|
|
243
|
-
* @param {String} `str`
|
|
244
|
-
* @param {Object} `options`
|
|
245
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
246
|
-
* @api public
|
|
247
|
-
*/
|
|
248
|
-
const scan = (input, options) => {
|
|
249
|
-
const opts = options || {};
|
|
250
|
-
const length = input.length - 1;
|
|
251
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
252
|
-
const slashes = [];
|
|
253
|
-
const tokens = [];
|
|
254
|
-
const parts = [];
|
|
255
|
-
let str = input;
|
|
256
|
-
let index = -1;
|
|
257
|
-
let start = 0;
|
|
258
|
-
let lastIndex = 0;
|
|
259
|
-
let isBrace = false;
|
|
260
|
-
let isBracket = false;
|
|
261
|
-
let isGlob = false;
|
|
262
|
-
let isExtglob = false;
|
|
263
|
-
let isGlobstar = false;
|
|
264
|
-
let braceEscaped = false;
|
|
265
|
-
let backslashes = false;
|
|
266
|
-
let negated = false;
|
|
267
|
-
let negatedExtglob = false;
|
|
268
|
-
let finished = false;
|
|
269
|
-
let braces = 0;
|
|
270
|
-
let prev;
|
|
271
|
-
let code;
|
|
272
|
-
let token = {
|
|
273
|
-
value: "",
|
|
274
|
-
depth: 0,
|
|
275
|
-
isGlob: false
|
|
276
|
-
};
|
|
277
|
-
const eos = () => index >= length;
|
|
278
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
279
|
-
const advance = () => {
|
|
280
|
-
prev = code;
|
|
281
|
-
return str.charCodeAt(++index);
|
|
282
|
-
};
|
|
283
|
-
while (index < length) {
|
|
284
|
-
code = advance();
|
|
285
|
-
let next;
|
|
286
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
287
|
-
backslashes = token.backslashes = true;
|
|
288
|
-
code = advance();
|
|
289
|
-
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
293
|
-
braces++;
|
|
294
|
-
while (eos() !== true && (code = advance())) {
|
|
295
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
296
|
-
backslashes = token.backslashes = true;
|
|
297
|
-
advance();
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
301
|
-
braces++;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
305
|
-
isBrace = token.isBrace = true;
|
|
306
|
-
isGlob = token.isGlob = true;
|
|
307
|
-
finished = true;
|
|
308
|
-
if (scanToEnd === true) continue;
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
312
|
-
isBrace = token.isBrace = true;
|
|
313
|
-
isGlob = token.isGlob = true;
|
|
314
|
-
finished = true;
|
|
315
|
-
if (scanToEnd === true) continue;
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
319
|
-
braces--;
|
|
320
|
-
if (braces === 0) {
|
|
321
|
-
braceEscaped = false;
|
|
322
|
-
isBrace = token.isBrace = true;
|
|
323
|
-
finished = true;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (scanToEnd === true) continue;
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
332
|
-
slashes.push(index);
|
|
333
|
-
tokens.push(token);
|
|
334
|
-
token = {
|
|
335
|
-
value: "",
|
|
336
|
-
depth: 0,
|
|
337
|
-
isGlob: false
|
|
338
|
-
};
|
|
339
|
-
if (finished === true) continue;
|
|
340
|
-
if (prev === CHAR_DOT && index === start + 1) {
|
|
341
|
-
start += 2;
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
lastIndex = index + 1;
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
if (opts.noext !== true) {
|
|
348
|
-
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
349
|
-
isGlob = token.isGlob = true;
|
|
350
|
-
isExtglob = token.isExtglob = true;
|
|
351
|
-
finished = true;
|
|
352
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
353
|
-
if (scanToEnd === true) {
|
|
354
|
-
while (eos() !== true && (code = advance())) {
|
|
355
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
356
|
-
backslashes = token.backslashes = true;
|
|
357
|
-
code = advance();
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
361
|
-
isGlob = token.isGlob = true;
|
|
362
|
-
finished = true;
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (code === CHAR_ASTERISK) {
|
|
372
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
373
|
-
isGlob = token.isGlob = true;
|
|
374
|
-
finished = true;
|
|
375
|
-
if (scanToEnd === true) continue;
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
379
|
-
isGlob = token.isGlob = true;
|
|
380
|
-
finished = true;
|
|
381
|
-
if (scanToEnd === true) continue;
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
385
|
-
while (eos() !== true && (next = advance())) {
|
|
386
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
387
|
-
backslashes = token.backslashes = true;
|
|
388
|
-
advance();
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
392
|
-
isBracket = token.isBracket = true;
|
|
393
|
-
isGlob = token.isGlob = true;
|
|
394
|
-
finished = true;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (scanToEnd === true) continue;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
402
|
-
negated = token.negated = true;
|
|
403
|
-
start++;
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
407
|
-
isGlob = token.isGlob = true;
|
|
408
|
-
if (scanToEnd === true) {
|
|
409
|
-
while (eos() !== true && (code = advance())) {
|
|
410
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
411
|
-
backslashes = token.backslashes = true;
|
|
412
|
-
code = advance();
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
416
|
-
finished = true;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
if (isGlob === true) {
|
|
425
|
-
finished = true;
|
|
426
|
-
if (scanToEnd === true) continue;
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (opts.noext === true) {
|
|
431
|
-
isExtglob = false;
|
|
432
|
-
isGlob = false;
|
|
433
|
-
}
|
|
434
|
-
let base = str;
|
|
435
|
-
let prefix = "";
|
|
436
|
-
let glob = "";
|
|
437
|
-
if (start > 0) {
|
|
438
|
-
prefix = str.slice(0, start);
|
|
439
|
-
str = str.slice(start);
|
|
440
|
-
lastIndex -= start;
|
|
441
|
-
}
|
|
442
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
443
|
-
base = str.slice(0, lastIndex);
|
|
444
|
-
glob = str.slice(lastIndex);
|
|
445
|
-
} else if (isGlob === true) {
|
|
446
|
-
base = "";
|
|
447
|
-
glob = str;
|
|
448
|
-
} else base = str;
|
|
449
|
-
if (base && base !== "" && base !== "/" && base !== str) {
|
|
450
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
451
|
-
}
|
|
452
|
-
if (opts.unescape === true) {
|
|
453
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
454
|
-
if (base && backslashes === true) base = utils.removeBackslashes(base);
|
|
455
|
-
}
|
|
456
|
-
const state = {
|
|
457
|
-
prefix,
|
|
458
|
-
input,
|
|
459
|
-
start,
|
|
460
|
-
base,
|
|
461
|
-
glob,
|
|
462
|
-
isBrace,
|
|
463
|
-
isBracket,
|
|
464
|
-
isGlob,
|
|
465
|
-
isExtglob,
|
|
466
|
-
isGlobstar,
|
|
467
|
-
negated,
|
|
468
|
-
negatedExtglob
|
|
469
|
-
};
|
|
470
|
-
if (opts.tokens === true) {
|
|
471
|
-
state.maxDepth = 0;
|
|
472
|
-
if (!isPathSeparator(code)) tokens.push(token);
|
|
473
|
-
state.tokens = tokens;
|
|
474
|
-
}
|
|
475
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
476
|
-
let prevIndex;
|
|
477
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
478
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
479
|
-
const i = slashes[idx];
|
|
480
|
-
const value = input.slice(n, i);
|
|
481
|
-
if (opts.tokens) {
|
|
482
|
-
if (idx === 0 && start !== 0) {
|
|
483
|
-
tokens[idx].isPrefix = true;
|
|
484
|
-
tokens[idx].value = prefix;
|
|
485
|
-
} else tokens[idx].value = value;
|
|
486
|
-
depth(tokens[idx]);
|
|
487
|
-
state.maxDepth += tokens[idx].depth;
|
|
488
|
-
}
|
|
489
|
-
if (idx !== 0 || value !== "") parts.push(value);
|
|
490
|
-
prevIndex = i;
|
|
491
|
-
}
|
|
492
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
493
|
-
const value = input.slice(prevIndex + 1);
|
|
494
|
-
parts.push(value);
|
|
495
|
-
if (opts.tokens) {
|
|
496
|
-
tokens[tokens.length - 1].value = value;
|
|
497
|
-
depth(tokens[tokens.length - 1]);
|
|
498
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
state.slashes = slashes;
|
|
502
|
-
state.parts = parts;
|
|
503
|
-
}
|
|
504
|
-
return state;
|
|
505
|
-
};
|
|
506
|
-
module.exports = scan;
|
|
507
|
-
}));
|
|
508
|
-
|
|
509
|
-
//#endregion
|
|
510
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
511
|
-
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
512
|
-
const constants = require_constants();
|
|
513
|
-
const utils = require_utils();
|
|
514
|
-
/**
|
|
515
|
-
* Constants
|
|
516
|
-
*/
|
|
517
|
-
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
518
|
-
/**
|
|
519
|
-
* Helpers
|
|
520
|
-
*/
|
|
521
|
-
const expandRange = (args, options) => {
|
|
522
|
-
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
523
|
-
args.sort();
|
|
524
|
-
const value = `[${args.join("-")}]`;
|
|
525
|
-
try {
|
|
526
|
-
new RegExp(value);
|
|
527
|
-
} catch (ex) {
|
|
528
|
-
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
529
|
-
}
|
|
530
|
-
return value;
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* Create the message for a syntax error
|
|
534
|
-
*/
|
|
535
|
-
const syntaxError = (type, char) => {
|
|
536
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
537
|
-
};
|
|
538
|
-
/**
|
|
539
|
-
* Parse the given input string.
|
|
540
|
-
* @param {String} input
|
|
541
|
-
* @param {Object} options
|
|
542
|
-
* @return {Object}
|
|
543
|
-
*/
|
|
544
|
-
const parse = (input, options) => {
|
|
545
|
-
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
546
|
-
input = REPLACEMENTS[input] || input;
|
|
547
|
-
const opts = { ...options };
|
|
548
|
-
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
549
|
-
let len = input.length;
|
|
550
|
-
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
551
|
-
const bos = {
|
|
552
|
-
type: "bos",
|
|
553
|
-
value: "",
|
|
554
|
-
output: opts.prepend || ""
|
|
555
|
-
};
|
|
556
|
-
const tokens = [bos];
|
|
557
|
-
const capture = opts.capture ? "" : "?:";
|
|
558
|
-
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
559
|
-
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
560
|
-
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;
|
|
561
|
-
const globstar = (opts$1) => {
|
|
562
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
563
|
-
};
|
|
564
|
-
const nodot = opts.dot ? "" : NO_DOT;
|
|
565
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
566
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
567
|
-
if (opts.capture) star = `(${star})`;
|
|
568
|
-
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
569
|
-
const state = {
|
|
570
|
-
input,
|
|
571
|
-
index: -1,
|
|
572
|
-
start: 0,
|
|
573
|
-
dot: opts.dot === true,
|
|
574
|
-
consumed: "",
|
|
575
|
-
output: "",
|
|
576
|
-
prefix: "",
|
|
577
|
-
backtrack: false,
|
|
578
|
-
negated: false,
|
|
579
|
-
brackets: 0,
|
|
580
|
-
braces: 0,
|
|
581
|
-
parens: 0,
|
|
582
|
-
quotes: 0,
|
|
583
|
-
globstar: false,
|
|
584
|
-
tokens
|
|
585
|
-
};
|
|
586
|
-
input = utils.removePrefix(input, state);
|
|
587
|
-
len = input.length;
|
|
588
|
-
const extglobs = [];
|
|
589
|
-
const braces = [];
|
|
590
|
-
const stack = [];
|
|
591
|
-
let prev = bos;
|
|
592
|
-
let value;
|
|
593
|
-
/**
|
|
594
|
-
* Tokenizing helpers
|
|
595
|
-
*/
|
|
596
|
-
const eos = () => state.index === len - 1;
|
|
597
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
598
|
-
const advance = state.advance = () => input[++state.index] || "";
|
|
599
|
-
const remaining = () => input.slice(state.index + 1);
|
|
600
|
-
const consume = (value$1 = "", num = 0) => {
|
|
601
|
-
state.consumed += value$1;
|
|
602
|
-
state.index += num;
|
|
603
|
-
};
|
|
604
|
-
const append = (token) => {
|
|
605
|
-
state.output += token.output != null ? token.output : token.value;
|
|
606
|
-
consume(token.value);
|
|
607
|
-
};
|
|
608
|
-
const negate = () => {
|
|
609
|
-
let count = 1;
|
|
610
|
-
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
611
|
-
advance();
|
|
612
|
-
state.start++;
|
|
613
|
-
count++;
|
|
614
|
-
}
|
|
615
|
-
if (count % 2 === 0) return false;
|
|
616
|
-
state.negated = true;
|
|
617
|
-
state.start++;
|
|
618
|
-
return true;
|
|
619
|
-
};
|
|
620
|
-
const increment = (type) => {
|
|
621
|
-
state[type]++;
|
|
622
|
-
stack.push(type);
|
|
623
|
-
};
|
|
624
|
-
const decrement = (type) => {
|
|
625
|
-
state[type]--;
|
|
626
|
-
stack.pop();
|
|
627
|
-
};
|
|
628
|
-
/**
|
|
629
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
630
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
631
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
632
|
-
* characters are plain text. This improves performance and simplifies
|
|
633
|
-
* lookbehinds.
|
|
634
|
-
*/
|
|
635
|
-
const push = (tok) => {
|
|
636
|
-
if (prev.type === "globstar") {
|
|
637
|
-
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
638
|
-
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
639
|
-
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
640
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
641
|
-
prev.type = "star";
|
|
642
|
-
prev.value = "*";
|
|
643
|
-
prev.output = star;
|
|
644
|
-
state.output += prev.output;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
648
|
-
if (tok.value || tok.output) append(tok);
|
|
649
|
-
if (prev && prev.type === "text" && tok.type === "text") {
|
|
650
|
-
prev.output = (prev.output || prev.value) + tok.value;
|
|
651
|
-
prev.value += tok.value;
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
tok.prev = prev;
|
|
655
|
-
tokens.push(tok);
|
|
656
|
-
prev = tok;
|
|
657
|
-
};
|
|
658
|
-
const extglobOpen = (type, value$1) => {
|
|
659
|
-
const token = {
|
|
660
|
-
...EXTGLOB_CHARS[value$1],
|
|
661
|
-
conditions: 1,
|
|
662
|
-
inner: ""
|
|
663
|
-
};
|
|
664
|
-
token.prev = prev;
|
|
665
|
-
token.parens = state.parens;
|
|
666
|
-
token.output = state.output;
|
|
667
|
-
const output = (opts.capture ? "(" : "") + token.open;
|
|
668
|
-
increment("parens");
|
|
669
|
-
push({
|
|
670
|
-
type,
|
|
671
|
-
value: value$1,
|
|
672
|
-
output: state.output ? "" : ONE_CHAR
|
|
673
|
-
});
|
|
674
|
-
push({
|
|
675
|
-
type: "paren",
|
|
676
|
-
extglob: true,
|
|
677
|
-
value: advance(),
|
|
678
|
-
output
|
|
679
|
-
});
|
|
680
|
-
extglobs.push(token);
|
|
681
|
-
};
|
|
682
|
-
const extglobClose = (token) => {
|
|
683
|
-
let output = token.close + (opts.capture ? ")" : "");
|
|
684
|
-
let rest;
|
|
685
|
-
if (token.type === "negate") {
|
|
686
|
-
let extglobStar = star;
|
|
687
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
688
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
689
|
-
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
690
|
-
...options,
|
|
691
|
-
fastpaths: false
|
|
692
|
-
}).output})${extglobStar})`;
|
|
693
|
-
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
694
|
-
}
|
|
695
|
-
push({
|
|
696
|
-
type: "paren",
|
|
697
|
-
extglob: true,
|
|
698
|
-
value,
|
|
699
|
-
output
|
|
700
|
-
});
|
|
701
|
-
decrement("parens");
|
|
702
|
-
};
|
|
703
|
-
/**
|
|
704
|
-
* Fast paths
|
|
705
|
-
*/
|
|
706
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
707
|
-
let backslashes = false;
|
|
708
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
709
|
-
if (first === "\\") {
|
|
710
|
-
backslashes = true;
|
|
711
|
-
return m;
|
|
712
|
-
}
|
|
713
|
-
if (first === "?") {
|
|
714
|
-
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
715
|
-
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
716
|
-
return QMARK.repeat(chars.length);
|
|
717
|
-
}
|
|
718
|
-
if (first === ".") return DOT_LITERAL.repeat(chars.length);
|
|
719
|
-
if (first === "*") {
|
|
720
|
-
if (esc) return esc + first + (rest ? star : "");
|
|
721
|
-
return star;
|
|
722
|
-
}
|
|
723
|
-
return esc ? m : `\\${m}`;
|
|
724
|
-
});
|
|
725
|
-
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
726
|
-
else output = output.replace(/\\+/g, (m) => {
|
|
727
|
-
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
728
|
-
});
|
|
729
|
-
if (output === input && opts.contains === true) {
|
|
730
|
-
state.output = input;
|
|
731
|
-
return state;
|
|
732
|
-
}
|
|
733
|
-
state.output = utils.wrapOutput(output, state, options);
|
|
734
|
-
return state;
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Tokenize input until we reach end-of-string
|
|
738
|
-
*/
|
|
739
|
-
while (!eos()) {
|
|
740
|
-
value = advance();
|
|
741
|
-
if (value === "\0") continue;
|
|
742
|
-
/**
|
|
743
|
-
* Escaped characters
|
|
744
|
-
*/
|
|
745
|
-
if (value === "\\") {
|
|
746
|
-
const next = peek();
|
|
747
|
-
if (next === "/" && opts.bash !== true) continue;
|
|
748
|
-
if (next === "." || next === ";") continue;
|
|
749
|
-
if (!next) {
|
|
750
|
-
value += "\\";
|
|
751
|
-
push({
|
|
752
|
-
type: "text",
|
|
753
|
-
value
|
|
754
|
-
});
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
const match = /^\\+/.exec(remaining());
|
|
758
|
-
let slashes = 0;
|
|
759
|
-
if (match && match[0].length > 2) {
|
|
760
|
-
slashes = match[0].length;
|
|
761
|
-
state.index += slashes;
|
|
762
|
-
if (slashes % 2 !== 0) value += "\\";
|
|
763
|
-
}
|
|
764
|
-
if (opts.unescape === true) value = advance();
|
|
765
|
-
else value += advance();
|
|
766
|
-
if (state.brackets === 0) {
|
|
767
|
-
push({
|
|
768
|
-
type: "text",
|
|
769
|
-
value
|
|
770
|
-
});
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* If we're inside a regex character class, continue
|
|
776
|
-
* until we reach the closing bracket.
|
|
777
|
-
*/
|
|
778
|
-
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
779
|
-
if (opts.posix !== false && value === ":") {
|
|
780
|
-
const inner = prev.value.slice(1);
|
|
781
|
-
if (inner.includes("[")) {
|
|
782
|
-
prev.posix = true;
|
|
783
|
-
if (inner.includes(":")) {
|
|
784
|
-
const idx = prev.value.lastIndexOf("[");
|
|
785
|
-
const pre = prev.value.slice(0, idx);
|
|
786
|
-
const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
787
|
-
if (posix$1) {
|
|
788
|
-
prev.value = pre + posix$1;
|
|
789
|
-
state.backtrack = true;
|
|
790
|
-
advance();
|
|
791
|
-
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
792
|
-
continue;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
798
|
-
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
799
|
-
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
800
|
-
prev.value += value;
|
|
801
|
-
append({ value });
|
|
802
|
-
continue;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* If we're inside a quoted string, continue
|
|
806
|
-
* until we reach the closing double quote.
|
|
807
|
-
*/
|
|
808
|
-
if (state.quotes === 1 && value !== "\"") {
|
|
809
|
-
value = utils.escapeRegex(value);
|
|
810
|
-
prev.value += value;
|
|
811
|
-
append({ value });
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Double quotes
|
|
816
|
-
*/
|
|
817
|
-
if (value === "\"") {
|
|
818
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
819
|
-
if (opts.keepQuotes === true) push({
|
|
820
|
-
type: "text",
|
|
821
|
-
value
|
|
822
|
-
});
|
|
823
|
-
continue;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Parentheses
|
|
827
|
-
*/
|
|
828
|
-
if (value === "(") {
|
|
829
|
-
increment("parens");
|
|
830
|
-
push({
|
|
831
|
-
type: "paren",
|
|
832
|
-
value
|
|
833
|
-
});
|
|
834
|
-
continue;
|
|
835
|
-
}
|
|
836
|
-
if (value === ")") {
|
|
837
|
-
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
838
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
839
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
840
|
-
extglobClose(extglobs.pop());
|
|
841
|
-
continue;
|
|
842
|
-
}
|
|
843
|
-
push({
|
|
844
|
-
type: "paren",
|
|
845
|
-
value,
|
|
846
|
-
output: state.parens ? ")" : "\\)"
|
|
847
|
-
});
|
|
848
|
-
decrement("parens");
|
|
849
|
-
continue;
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Square brackets
|
|
853
|
-
*/
|
|
854
|
-
if (value === "[") {
|
|
855
|
-
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
856
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
857
|
-
value = `\\${value}`;
|
|
858
|
-
} else increment("brackets");
|
|
859
|
-
push({
|
|
860
|
-
type: "bracket",
|
|
861
|
-
value
|
|
862
|
-
});
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
if (value === "]") {
|
|
866
|
-
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
867
|
-
push({
|
|
868
|
-
type: "text",
|
|
869
|
-
value,
|
|
870
|
-
output: `\\${value}`
|
|
871
|
-
});
|
|
872
|
-
continue;
|
|
873
|
-
}
|
|
874
|
-
if (state.brackets === 0) {
|
|
875
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
876
|
-
push({
|
|
877
|
-
type: "text",
|
|
878
|
-
value,
|
|
879
|
-
output: `\\${value}`
|
|
880
|
-
});
|
|
881
|
-
continue;
|
|
882
|
-
}
|
|
883
|
-
decrement("brackets");
|
|
884
|
-
const prevValue = prev.value.slice(1);
|
|
885
|
-
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
886
|
-
prev.value += value;
|
|
887
|
-
append({ value });
|
|
888
|
-
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
889
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
890
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
891
|
-
if (opts.literalBrackets === true) {
|
|
892
|
-
state.output += escaped;
|
|
893
|
-
prev.value = escaped;
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
897
|
-
state.output += prev.value;
|
|
898
|
-
continue;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Braces
|
|
902
|
-
*/
|
|
903
|
-
if (value === "{" && opts.nobrace !== true) {
|
|
904
|
-
increment("braces");
|
|
905
|
-
const open = {
|
|
906
|
-
type: "brace",
|
|
907
|
-
value,
|
|
908
|
-
output: "(",
|
|
909
|
-
outputIndex: state.output.length,
|
|
910
|
-
tokensIndex: state.tokens.length
|
|
911
|
-
};
|
|
912
|
-
braces.push(open);
|
|
913
|
-
push(open);
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
if (value === "}") {
|
|
917
|
-
const brace = braces[braces.length - 1];
|
|
918
|
-
if (opts.nobrace === true || !brace) {
|
|
919
|
-
push({
|
|
920
|
-
type: "text",
|
|
921
|
-
value,
|
|
922
|
-
output: value
|
|
923
|
-
});
|
|
924
|
-
continue;
|
|
925
|
-
}
|
|
926
|
-
let output = ")";
|
|
927
|
-
if (brace.dots === true) {
|
|
928
|
-
const arr = tokens.slice();
|
|
929
|
-
const range = [];
|
|
930
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
931
|
-
tokens.pop();
|
|
932
|
-
if (arr[i].type === "brace") break;
|
|
933
|
-
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
934
|
-
}
|
|
935
|
-
output = expandRange(range, opts);
|
|
936
|
-
state.backtrack = true;
|
|
937
|
-
}
|
|
938
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
939
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
940
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
941
|
-
brace.value = brace.output = "\\{";
|
|
942
|
-
value = output = "\\}";
|
|
943
|
-
state.output = out;
|
|
944
|
-
for (const t of toks) state.output += t.output || t.value;
|
|
945
|
-
}
|
|
946
|
-
push({
|
|
947
|
-
type: "brace",
|
|
948
|
-
value,
|
|
949
|
-
output
|
|
950
|
-
});
|
|
951
|
-
decrement("braces");
|
|
952
|
-
braces.pop();
|
|
953
|
-
continue;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Pipes
|
|
957
|
-
*/
|
|
958
|
-
if (value === "|") {
|
|
959
|
-
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
960
|
-
push({
|
|
961
|
-
type: "text",
|
|
962
|
-
value
|
|
963
|
-
});
|
|
964
|
-
continue;
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Commas
|
|
968
|
-
*/
|
|
969
|
-
if (value === ",") {
|
|
970
|
-
let output = value;
|
|
971
|
-
const brace = braces[braces.length - 1];
|
|
972
|
-
if (brace && stack[stack.length - 1] === "braces") {
|
|
973
|
-
brace.comma = true;
|
|
974
|
-
output = "|";
|
|
975
|
-
}
|
|
976
|
-
push({
|
|
977
|
-
type: "comma",
|
|
978
|
-
value,
|
|
979
|
-
output
|
|
980
|
-
});
|
|
981
|
-
continue;
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Slashes
|
|
985
|
-
*/
|
|
986
|
-
if (value === "/") {
|
|
987
|
-
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
988
|
-
state.start = state.index + 1;
|
|
989
|
-
state.consumed = "";
|
|
990
|
-
state.output = "";
|
|
991
|
-
tokens.pop();
|
|
992
|
-
prev = bos;
|
|
993
|
-
continue;
|
|
994
|
-
}
|
|
995
|
-
push({
|
|
996
|
-
type: "slash",
|
|
997
|
-
value,
|
|
998
|
-
output: SLASH_LITERAL
|
|
999
|
-
});
|
|
1000
|
-
continue;
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Dots
|
|
1004
|
-
*/
|
|
1005
|
-
if (value === ".") {
|
|
1006
|
-
if (state.braces > 0 && prev.type === "dot") {
|
|
1007
|
-
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1008
|
-
const brace = braces[braces.length - 1];
|
|
1009
|
-
prev.type = "dots";
|
|
1010
|
-
prev.output += value;
|
|
1011
|
-
prev.value += value;
|
|
1012
|
-
brace.dots = true;
|
|
1013
|
-
continue;
|
|
1014
|
-
}
|
|
1015
|
-
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1016
|
-
push({
|
|
1017
|
-
type: "text",
|
|
1018
|
-
value,
|
|
1019
|
-
output: DOT_LITERAL
|
|
1020
|
-
});
|
|
1021
|
-
continue;
|
|
1022
|
-
}
|
|
1023
|
-
push({
|
|
1024
|
-
type: "dot",
|
|
1025
|
-
value,
|
|
1026
|
-
output: DOT_LITERAL
|
|
1027
|
-
});
|
|
1028
|
-
continue;
|
|
1029
|
-
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Question marks
|
|
1032
|
-
*/
|
|
1033
|
-
if (value === "?") {
|
|
1034
|
-
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1035
|
-
extglobOpen("qmark", value);
|
|
1036
|
-
continue;
|
|
1037
|
-
}
|
|
1038
|
-
if (prev && prev.type === "paren") {
|
|
1039
|
-
const next = peek();
|
|
1040
|
-
let output = value;
|
|
1041
|
-
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1042
|
-
push({
|
|
1043
|
-
type: "text",
|
|
1044
|
-
value,
|
|
1045
|
-
output
|
|
1046
|
-
});
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1050
|
-
push({
|
|
1051
|
-
type: "qmark",
|
|
1052
|
-
value,
|
|
1053
|
-
output: QMARK_NO_DOT
|
|
1054
|
-
});
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
push({
|
|
1058
|
-
type: "qmark",
|
|
1059
|
-
value,
|
|
1060
|
-
output: QMARK
|
|
1061
|
-
});
|
|
1062
|
-
continue;
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* Exclamation
|
|
1066
|
-
*/
|
|
1067
|
-
if (value === "!") {
|
|
1068
|
-
if (opts.noextglob !== true && peek() === "(") {
|
|
1069
|
-
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1070
|
-
extglobOpen("negate", value);
|
|
1071
|
-
continue;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
if (opts.nonegate !== true && state.index === 0) {
|
|
1075
|
-
negate();
|
|
1076
|
-
continue;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Plus
|
|
1081
|
-
*/
|
|
1082
|
-
if (value === "+") {
|
|
1083
|
-
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1084
|
-
extglobOpen("plus", value);
|
|
1085
|
-
continue;
|
|
1086
|
-
}
|
|
1087
|
-
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1088
|
-
push({
|
|
1089
|
-
type: "plus",
|
|
1090
|
-
value,
|
|
1091
|
-
output: PLUS_LITERAL
|
|
1092
|
-
});
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1096
|
-
push({
|
|
1097
|
-
type: "plus",
|
|
1098
|
-
value
|
|
1099
|
-
});
|
|
1100
|
-
continue;
|
|
1101
|
-
}
|
|
1102
|
-
push({
|
|
1103
|
-
type: "plus",
|
|
1104
|
-
value: PLUS_LITERAL
|
|
1105
|
-
});
|
|
1106
|
-
continue;
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Plain text
|
|
1110
|
-
*/
|
|
1111
|
-
if (value === "@") {
|
|
1112
|
-
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1113
|
-
push({
|
|
1114
|
-
type: "at",
|
|
1115
|
-
extglob: true,
|
|
1116
|
-
value,
|
|
1117
|
-
output: ""
|
|
1118
|
-
});
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
push({
|
|
1122
|
-
type: "text",
|
|
1123
|
-
value
|
|
1124
|
-
});
|
|
1125
|
-
continue;
|
|
1126
|
-
}
|
|
1127
|
-
/**
|
|
1128
|
-
* Plain text
|
|
1129
|
-
*/
|
|
1130
|
-
if (value !== "*") {
|
|
1131
|
-
if (value === "$" || value === "^") value = `\\${value}`;
|
|
1132
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1133
|
-
if (match) {
|
|
1134
|
-
value += match[0];
|
|
1135
|
-
state.index += match[0].length;
|
|
1136
|
-
}
|
|
1137
|
-
push({
|
|
1138
|
-
type: "text",
|
|
1139
|
-
value
|
|
1140
|
-
});
|
|
1141
|
-
continue;
|
|
1142
|
-
}
|
|
1143
|
-
/**
|
|
1144
|
-
* Stars
|
|
1145
|
-
*/
|
|
1146
|
-
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1147
|
-
prev.type = "star";
|
|
1148
|
-
prev.star = true;
|
|
1149
|
-
prev.value += value;
|
|
1150
|
-
prev.output = star;
|
|
1151
|
-
state.backtrack = true;
|
|
1152
|
-
state.globstar = true;
|
|
1153
|
-
consume(value);
|
|
1154
|
-
continue;
|
|
1155
|
-
}
|
|
1156
|
-
let rest = remaining();
|
|
1157
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1158
|
-
extglobOpen("star", value);
|
|
1159
|
-
continue;
|
|
1160
|
-
}
|
|
1161
|
-
if (prev.type === "star") {
|
|
1162
|
-
if (opts.noglobstar === true) {
|
|
1163
|
-
consume(value);
|
|
1164
|
-
continue;
|
|
1165
|
-
}
|
|
1166
|
-
const prior = prev.prev;
|
|
1167
|
-
const before = prior.prev;
|
|
1168
|
-
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1169
|
-
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1170
|
-
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1171
|
-
push({
|
|
1172
|
-
type: "star",
|
|
1173
|
-
value,
|
|
1174
|
-
output: ""
|
|
1175
|
-
});
|
|
1176
|
-
continue;
|
|
1177
|
-
}
|
|
1178
|
-
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1179
|
-
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1180
|
-
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1181
|
-
push({
|
|
1182
|
-
type: "star",
|
|
1183
|
-
value,
|
|
1184
|
-
output: ""
|
|
1185
|
-
});
|
|
1186
|
-
continue;
|
|
1187
|
-
}
|
|
1188
|
-
while (rest.slice(0, 3) === "/**") {
|
|
1189
|
-
const after = input[state.index + 4];
|
|
1190
|
-
if (after && after !== "/") break;
|
|
1191
|
-
rest = rest.slice(3);
|
|
1192
|
-
consume("/**", 3);
|
|
1193
|
-
}
|
|
1194
|
-
if (prior.type === "bos" && eos()) {
|
|
1195
|
-
prev.type = "globstar";
|
|
1196
|
-
prev.value += value;
|
|
1197
|
-
prev.output = globstar(opts);
|
|
1198
|
-
state.output = prev.output;
|
|
1199
|
-
state.globstar = true;
|
|
1200
|
-
consume(value);
|
|
1201
|
-
continue;
|
|
1202
|
-
}
|
|
1203
|
-
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1204
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1205
|
-
prior.output = `(?:${prior.output}`;
|
|
1206
|
-
prev.type = "globstar";
|
|
1207
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1208
|
-
prev.value += value;
|
|
1209
|
-
state.globstar = true;
|
|
1210
|
-
state.output += prior.output + prev.output;
|
|
1211
|
-
consume(value);
|
|
1212
|
-
continue;
|
|
1213
|
-
}
|
|
1214
|
-
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1215
|
-
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1216
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1217
|
-
prior.output = `(?:${prior.output}`;
|
|
1218
|
-
prev.type = "globstar";
|
|
1219
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1220
|
-
prev.value += value;
|
|
1221
|
-
state.output += prior.output + prev.output;
|
|
1222
|
-
state.globstar = true;
|
|
1223
|
-
consume(value + advance());
|
|
1224
|
-
push({
|
|
1225
|
-
type: "slash",
|
|
1226
|
-
value: "/",
|
|
1227
|
-
output: ""
|
|
1228
|
-
});
|
|
1229
|
-
continue;
|
|
1230
|
-
}
|
|
1231
|
-
if (prior.type === "bos" && rest[0] === "/") {
|
|
1232
|
-
prev.type = "globstar";
|
|
1233
|
-
prev.value += value;
|
|
1234
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1235
|
-
state.output = prev.output;
|
|
1236
|
-
state.globstar = true;
|
|
1237
|
-
consume(value + advance());
|
|
1238
|
-
push({
|
|
1239
|
-
type: "slash",
|
|
1240
|
-
value: "/",
|
|
1241
|
-
output: ""
|
|
1242
|
-
});
|
|
1243
|
-
continue;
|
|
1244
|
-
}
|
|
1245
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
1246
|
-
prev.type = "globstar";
|
|
1247
|
-
prev.output = globstar(opts);
|
|
1248
|
-
prev.value += value;
|
|
1249
|
-
state.output += prev.output;
|
|
1250
|
-
state.globstar = true;
|
|
1251
|
-
consume(value);
|
|
1252
|
-
continue;
|
|
1253
|
-
}
|
|
1254
|
-
const token = {
|
|
1255
|
-
type: "star",
|
|
1256
|
-
value,
|
|
1257
|
-
output: star
|
|
1258
|
-
};
|
|
1259
|
-
if (opts.bash === true) {
|
|
1260
|
-
token.output = ".*?";
|
|
1261
|
-
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
|
|
1262
|
-
push(token);
|
|
1263
|
-
continue;
|
|
1264
|
-
}
|
|
1265
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1266
|
-
token.output = value;
|
|
1267
|
-
push(token);
|
|
1268
|
-
continue;
|
|
1269
|
-
}
|
|
1270
|
-
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1271
|
-
if (prev.type === "dot") {
|
|
1272
|
-
state.output += NO_DOT_SLASH;
|
|
1273
|
-
prev.output += NO_DOT_SLASH;
|
|
1274
|
-
} else if (opts.dot === true) {
|
|
1275
|
-
state.output += NO_DOTS_SLASH;
|
|
1276
|
-
prev.output += NO_DOTS_SLASH;
|
|
1277
|
-
} else {
|
|
1278
|
-
state.output += nodot;
|
|
1279
|
-
prev.output += nodot;
|
|
1280
|
-
}
|
|
1281
|
-
if (peek() !== "*") {
|
|
1282
|
-
state.output += ONE_CHAR;
|
|
1283
|
-
prev.output += ONE_CHAR;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
push(token);
|
|
1287
|
-
}
|
|
1288
|
-
while (state.brackets > 0) {
|
|
1289
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1290
|
-
state.output = utils.escapeLast(state.output, "[");
|
|
1291
|
-
decrement("brackets");
|
|
1292
|
-
}
|
|
1293
|
-
while (state.parens > 0) {
|
|
1294
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1295
|
-
state.output = utils.escapeLast(state.output, "(");
|
|
1296
|
-
decrement("parens");
|
|
1297
|
-
}
|
|
1298
|
-
while (state.braces > 0) {
|
|
1299
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1300
|
-
state.output = utils.escapeLast(state.output, "{");
|
|
1301
|
-
decrement("braces");
|
|
1302
|
-
}
|
|
1303
|
-
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
1304
|
-
type: "maybe_slash",
|
|
1305
|
-
value: "",
|
|
1306
|
-
output: `${SLASH_LITERAL}?`
|
|
1307
|
-
});
|
|
1308
|
-
if (state.backtrack === true) {
|
|
1309
|
-
state.output = "";
|
|
1310
|
-
for (const token of state.tokens) {
|
|
1311
|
-
state.output += token.output != null ? token.output : token.value;
|
|
1312
|
-
if (token.suffix) state.output += token.suffix;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return state;
|
|
1316
|
-
};
|
|
1317
|
-
/**
|
|
1318
|
-
* Fast paths for creating regular expressions for common glob patterns.
|
|
1319
|
-
* This can significantly speed up processing and has very little downside
|
|
1320
|
-
* impact when none of the fast paths match.
|
|
1321
|
-
*/
|
|
1322
|
-
parse.fastpaths = (input, options) => {
|
|
1323
|
-
const opts = { ...options };
|
|
1324
|
-
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1325
|
-
const len = input.length;
|
|
1326
|
-
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1327
|
-
input = REPLACEMENTS[input] || input;
|
|
1328
|
-
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
1329
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1330
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1331
|
-
const capture = opts.capture ? "" : "?:";
|
|
1332
|
-
const state = {
|
|
1333
|
-
negated: false,
|
|
1334
|
-
prefix: ""
|
|
1335
|
-
};
|
|
1336
|
-
let star = opts.bash === true ? ".*?" : STAR;
|
|
1337
|
-
if (opts.capture) star = `(${star})`;
|
|
1338
|
-
const globstar = (opts$1) => {
|
|
1339
|
-
if (opts$1.noglobstar === true) return star;
|
|
1340
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1341
|
-
};
|
|
1342
|
-
const create = (str) => {
|
|
1343
|
-
switch (str) {
|
|
1344
|
-
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
1345
|
-
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1346
|
-
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1347
|
-
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1348
|
-
case "**": return nodot + globstar(opts);
|
|
1349
|
-
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1350
|
-
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1351
|
-
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1352
|
-
default: {
|
|
1353
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1354
|
-
if (!match) return;
|
|
1355
|
-
const source$1 = create(match[1]);
|
|
1356
|
-
if (!source$1) return;
|
|
1357
|
-
return source$1 + DOT_LITERAL + match[2];
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
};
|
|
1361
|
-
let source = create(utils.removePrefix(input, state));
|
|
1362
|
-
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
1363
|
-
return source;
|
|
1364
|
-
};
|
|
1365
|
-
module.exports = parse;
|
|
1366
|
-
}));
|
|
1367
|
-
|
|
1368
|
-
//#endregion
|
|
1369
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1370
|
-
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1371
|
-
const scan = require_scan();
|
|
1372
|
-
const parse = require_parse();
|
|
1373
|
-
const utils = require_utils();
|
|
1374
|
-
const constants = require_constants();
|
|
1375
|
-
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1376
|
-
/**
|
|
1377
|
-
* Creates a matcher function from one or more glob patterns. The
|
|
1378
|
-
* returned function takes a string to match as its first argument,
|
|
1379
|
-
* and returns true if the string is a match. The returned matcher
|
|
1380
|
-
* function also takes a boolean as the second argument that, when true,
|
|
1381
|
-
* returns an object with additional information.
|
|
1382
|
-
*
|
|
1383
|
-
* ```js
|
|
1384
|
-
* const picomatch = require('picomatch');
|
|
1385
|
-
* // picomatch(glob[, options]);
|
|
1386
|
-
*
|
|
1387
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
1388
|
-
* console.log(isMatch('a.a')); //=> false
|
|
1389
|
-
* console.log(isMatch('a.b')); //=> true
|
|
1390
|
-
* ```
|
|
1391
|
-
* @name picomatch
|
|
1392
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
1393
|
-
* @param {Object=} `options`
|
|
1394
|
-
* @return {Function=} Returns a matcher function.
|
|
1395
|
-
* @api public
|
|
1396
|
-
*/
|
|
1397
|
-
const picomatch = (glob, options, returnState = false) => {
|
|
1398
|
-
if (Array.isArray(glob)) {
|
|
1399
|
-
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1400
|
-
const arrayMatcher = (str) => {
|
|
1401
|
-
for (const isMatch of fns) {
|
|
1402
|
-
const state$1 = isMatch(str);
|
|
1403
|
-
if (state$1) return state$1;
|
|
1404
|
-
}
|
|
1405
|
-
return false;
|
|
1406
|
-
};
|
|
1407
|
-
return arrayMatcher;
|
|
1408
|
-
}
|
|
1409
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1410
|
-
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
1411
|
-
const opts = options || {};
|
|
1412
|
-
const posix$1 = opts.windows;
|
|
1413
|
-
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1414
|
-
const state = regex.state;
|
|
1415
|
-
delete regex.state;
|
|
1416
|
-
let isIgnored = () => false;
|
|
1417
|
-
if (opts.ignore) {
|
|
1418
|
-
const ignoreOpts = {
|
|
1419
|
-
...options,
|
|
1420
|
-
ignore: null,
|
|
1421
|
-
onMatch: null,
|
|
1422
|
-
onResult: null
|
|
1423
|
-
};
|
|
1424
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1425
|
-
}
|
|
1426
|
-
const matcher = (input, returnObject = false) => {
|
|
1427
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1428
|
-
glob,
|
|
1429
|
-
posix: posix$1
|
|
1430
|
-
});
|
|
1431
|
-
const result = {
|
|
1432
|
-
glob,
|
|
1433
|
-
state,
|
|
1434
|
-
regex,
|
|
1435
|
-
posix: posix$1,
|
|
1436
|
-
input,
|
|
1437
|
-
output,
|
|
1438
|
-
match,
|
|
1439
|
-
isMatch
|
|
1440
|
-
};
|
|
1441
|
-
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
1442
|
-
if (isMatch === false) {
|
|
1443
|
-
result.isMatch = false;
|
|
1444
|
-
return returnObject ? result : false;
|
|
1445
|
-
}
|
|
1446
|
-
if (isIgnored(input)) {
|
|
1447
|
-
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
1448
|
-
result.isMatch = false;
|
|
1449
|
-
return returnObject ? result : false;
|
|
1450
|
-
}
|
|
1451
|
-
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
1452
|
-
return returnObject ? result : true;
|
|
1453
|
-
};
|
|
1454
|
-
if (returnState) matcher.state = state;
|
|
1455
|
-
return matcher;
|
|
1456
|
-
};
|
|
1457
|
-
/**
|
|
1458
|
-
* Test `input` with the given `regex`. This is used by the main
|
|
1459
|
-
* `picomatch()` function to test the input string.
|
|
1460
|
-
*
|
|
1461
|
-
* ```js
|
|
1462
|
-
* const picomatch = require('picomatch');
|
|
1463
|
-
* // picomatch.test(input, regex[, options]);
|
|
1464
|
-
*
|
|
1465
|
-
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
1466
|
-
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
1467
|
-
* ```
|
|
1468
|
-
* @param {String} `input` String to test.
|
|
1469
|
-
* @param {RegExp} `regex`
|
|
1470
|
-
* @return {Object} Returns an object with matching info.
|
|
1471
|
-
* @api public
|
|
1472
|
-
*/
|
|
1473
|
-
picomatch.test = (input, regex, options, { glob, posix: posix$1 } = {}) => {
|
|
1474
|
-
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
1475
|
-
if (input === "") return {
|
|
1476
|
-
isMatch: false,
|
|
1477
|
-
output: ""
|
|
1478
|
-
};
|
|
1479
|
-
const opts = options || {};
|
|
1480
|
-
const format = opts.format || (posix$1 ? utils.toPosixSlashes : null);
|
|
1481
|
-
let match = input === glob;
|
|
1482
|
-
let output = match && format ? format(input) : input;
|
|
1483
|
-
if (match === false) {
|
|
1484
|
-
output = format ? format(input) : input;
|
|
1485
|
-
match = output === glob;
|
|
1486
|
-
}
|
|
1487
|
-
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix$1);
|
|
1488
|
-
else match = regex.exec(output);
|
|
1489
|
-
return {
|
|
1490
|
-
isMatch: Boolean(match),
|
|
1491
|
-
match,
|
|
1492
|
-
output
|
|
1493
|
-
};
|
|
1494
|
-
};
|
|
1495
|
-
/**
|
|
1496
|
-
* Match the basename of a filepath.
|
|
1497
|
-
*
|
|
1498
|
-
* ```js
|
|
1499
|
-
* const picomatch = require('picomatch');
|
|
1500
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
1501
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
1502
|
-
* ```
|
|
1503
|
-
* @param {String} `input` String to test.
|
|
1504
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
1505
|
-
* @return {Boolean}
|
|
1506
|
-
* @api public
|
|
1507
|
-
*/
|
|
1508
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
1509
|
-
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
1510
|
-
};
|
|
1511
|
-
/**
|
|
1512
|
-
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
1513
|
-
*
|
|
1514
|
-
* ```js
|
|
1515
|
-
* const picomatch = require('picomatch');
|
|
1516
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
1517
|
-
*
|
|
1518
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
1519
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
1520
|
-
* ```
|
|
1521
|
-
* @param {String|Array} str The string to test.
|
|
1522
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
1523
|
-
* @param {Object} [options] See available [options](#options).
|
|
1524
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
1525
|
-
* @api public
|
|
1526
|
-
*/
|
|
1527
|
-
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1528
|
-
/**
|
|
1529
|
-
* Parse a glob pattern to create the source string for a regular
|
|
1530
|
-
* expression.
|
|
1531
|
-
*
|
|
1532
|
-
* ```js
|
|
1533
|
-
* const picomatch = require('picomatch');
|
|
1534
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
1535
|
-
* ```
|
|
1536
|
-
* @param {String} `pattern`
|
|
1537
|
-
* @param {Object} `options`
|
|
1538
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
1539
|
-
* @api public
|
|
1540
|
-
*/
|
|
1541
|
-
picomatch.parse = (pattern, options) => {
|
|
1542
|
-
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
1543
|
-
return parse(pattern, {
|
|
1544
|
-
...options,
|
|
1545
|
-
fastpaths: false
|
|
1546
|
-
});
|
|
1547
|
-
};
|
|
1548
|
-
/**
|
|
1549
|
-
* Scan a glob pattern to separate the pattern into segments.
|
|
1550
|
-
*
|
|
1551
|
-
* ```js
|
|
1552
|
-
* const picomatch = require('picomatch');
|
|
1553
|
-
* // picomatch.scan(input[, options]);
|
|
1554
|
-
*
|
|
1555
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
1556
|
-
* console.log(result);
|
|
1557
|
-
* { prefix: '!./',
|
|
1558
|
-
* input: '!./foo/*.js',
|
|
1559
|
-
* start: 3,
|
|
1560
|
-
* base: 'foo',
|
|
1561
|
-
* glob: '*.js',
|
|
1562
|
-
* isBrace: false,
|
|
1563
|
-
* isBracket: false,
|
|
1564
|
-
* isGlob: true,
|
|
1565
|
-
* isExtglob: false,
|
|
1566
|
-
* isGlobstar: false,
|
|
1567
|
-
* negated: true }
|
|
1568
|
-
* ```
|
|
1569
|
-
* @param {String} `input` Glob pattern to scan.
|
|
1570
|
-
* @param {Object} `options`
|
|
1571
|
-
* @return {Object} Returns an object with
|
|
1572
|
-
* @api public
|
|
1573
|
-
*/
|
|
1574
|
-
picomatch.scan = (input, options) => scan(input, options);
|
|
1575
|
-
/**
|
|
1576
|
-
* Compile a regular expression from the `state` object returned by the
|
|
1577
|
-
* [parse()](#parse) method.
|
|
1578
|
-
*
|
|
1579
|
-
* @param {Object} `state`
|
|
1580
|
-
* @param {Object} `options`
|
|
1581
|
-
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
1582
|
-
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
1583
|
-
* @return {RegExp}
|
|
1584
|
-
* @api public
|
|
1585
|
-
*/
|
|
1586
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1587
|
-
if (returnOutput === true) return state.output;
|
|
1588
|
-
const opts = options || {};
|
|
1589
|
-
const prepend = opts.contains ? "" : "^";
|
|
1590
|
-
const append = opts.contains ? "" : "$";
|
|
1591
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
1592
|
-
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
1593
|
-
const regex = picomatch.toRegex(source, options);
|
|
1594
|
-
if (returnState === true) regex.state = state;
|
|
1595
|
-
return regex;
|
|
1596
|
-
};
|
|
1597
|
-
/**
|
|
1598
|
-
* Create a regular expression from a parsed glob pattern.
|
|
1599
|
-
*
|
|
1600
|
-
* ```js
|
|
1601
|
-
* const picomatch = require('picomatch');
|
|
1602
|
-
* const state = picomatch.parse('*.js');
|
|
1603
|
-
* // picomatch.compileRe(state[, options]);
|
|
1604
|
-
*
|
|
1605
|
-
* console.log(picomatch.compileRe(state));
|
|
1606
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1607
|
-
* ```
|
|
1608
|
-
* @param {String} `state` The object returned from the `.parse` method.
|
|
1609
|
-
* @param {Object} `options`
|
|
1610
|
-
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
1611
|
-
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
1612
|
-
* @return {RegExp} Returns a regex created from the given pattern.
|
|
1613
|
-
* @api public
|
|
1614
|
-
*/
|
|
1615
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1616
|
-
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
1617
|
-
let parsed = {
|
|
1618
|
-
negated: false,
|
|
1619
|
-
fastpaths: true
|
|
1620
|
-
};
|
|
1621
|
-
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
1622
|
-
if (!parsed.output) parsed = parse(input, options);
|
|
1623
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1624
|
-
};
|
|
1625
|
-
/**
|
|
1626
|
-
* Create a regular expression from the given regex source string.
|
|
1627
|
-
*
|
|
1628
|
-
* ```js
|
|
1629
|
-
* const picomatch = require('picomatch');
|
|
1630
|
-
* // picomatch.toRegex(source[, options]);
|
|
1631
|
-
*
|
|
1632
|
-
* const { output } = picomatch.parse('*.js');
|
|
1633
|
-
* console.log(picomatch.toRegex(output));
|
|
1634
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1635
|
-
* ```
|
|
1636
|
-
* @param {String} `source` Regular expression source string.
|
|
1637
|
-
* @param {Object} `options`
|
|
1638
|
-
* @return {RegExp}
|
|
1639
|
-
* @api public
|
|
1640
|
-
*/
|
|
1641
|
-
picomatch.toRegex = (source, options) => {
|
|
1642
|
-
try {
|
|
1643
|
-
const opts = options || {};
|
|
1644
|
-
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1645
|
-
} catch (err) {
|
|
1646
|
-
if (options && options.debug === true) throw err;
|
|
1647
|
-
return /$^/;
|
|
1648
|
-
}
|
|
1649
|
-
};
|
|
1650
|
-
/**
|
|
1651
|
-
* Picomatch constants.
|
|
1652
|
-
* @return {Object}
|
|
1653
|
-
*/
|
|
1654
|
-
picomatch.constants = constants;
|
|
1655
|
-
/**
|
|
1656
|
-
* Expose "picomatch"
|
|
1657
|
-
*/
|
|
1658
|
-
module.exports = picomatch;
|
|
1659
|
-
}));
|
|
1660
|
-
|
|
1661
|
-
//#endregion
|
|
1662
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
1663
|
-
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1664
|
-
const pico = require_picomatch$1();
|
|
1665
|
-
const utils = require_utils();
|
|
1666
|
-
function picomatch(glob, options, returnState = false) {
|
|
1667
|
-
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
1668
|
-
...options,
|
|
1669
|
-
windows: utils.isWindows()
|
|
1670
|
-
};
|
|
1671
|
-
return pico(glob, options, returnState);
|
|
1672
|
-
}
|
|
1673
|
-
Object.assign(picomatch, pico);
|
|
1674
|
-
module.exports = picomatch;
|
|
1675
|
-
}));
|
|
1676
|
-
|
|
1677
|
-
//#endregion
|
|
1678
|
-
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
1679
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1680
|
-
function cleanPath(path$2) {
|
|
1681
|
-
let normalized = normalize(path$2);
|
|
1682
|
-
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
1683
|
-
return normalized;
|
|
1684
|
-
}
|
|
1685
|
-
const SLASHES_REGEX = /[\\/]/g;
|
|
1686
|
-
function convertSlashes(path$2, separator) {
|
|
1687
|
-
return path$2.replace(SLASHES_REGEX, separator);
|
|
1688
|
-
}
|
|
1689
|
-
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
1690
|
-
function isRootDirectory(path$2) {
|
|
1691
|
-
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
1692
|
-
}
|
|
1693
|
-
function normalizePath$1(path$2, options) {
|
|
1694
|
-
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
1695
|
-
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
1696
|
-
if (resolvePaths) path$2 = resolve(path$2);
|
|
1697
|
-
if (normalizePath$1$1 || pathNeedsCleaning) path$2 = cleanPath(path$2);
|
|
1698
|
-
if (path$2 === ".") return "";
|
|
1699
|
-
return convertSlashes(path$2[path$2.length - 1] !== pathSeparator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
1700
|
-
}
|
|
1701
|
-
function joinPathWithBasePath(filename, directoryPath) {
|
|
1702
|
-
return directoryPath + filename;
|
|
1703
|
-
}
|
|
1704
|
-
function joinPathWithRelativePath(root, options) {
|
|
1705
|
-
return function(filename, directoryPath) {
|
|
1706
|
-
if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
|
|
1707
|
-
else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
function joinPath(filename) {
|
|
1711
|
-
return filename;
|
|
1712
|
-
}
|
|
1713
|
-
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
1714
|
-
return directoryPath + filename + separator;
|
|
1715
|
-
}
|
|
1716
|
-
function build$7(root, options) {
|
|
1717
|
-
const { relativePaths, includeBasePath } = options;
|
|
1718
|
-
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
1719
|
-
}
|
|
1720
|
-
function pushDirectoryWithRelativePath(root) {
|
|
1721
|
-
return function(directoryPath, paths) {
|
|
1722
|
-
paths.push(directoryPath.substring(root.length) || ".");
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
function pushDirectoryFilterWithRelativePath(root) {
|
|
1726
|
-
return function(directoryPath, paths, filters) {
|
|
1727
|
-
const relativePath = directoryPath.substring(root.length) || ".";
|
|
1728
|
-
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
const pushDirectory = (directoryPath, paths) => {
|
|
1732
|
-
paths.push(directoryPath || ".");
|
|
1733
|
-
};
|
|
1734
|
-
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
1735
|
-
const path$2 = directoryPath || ".";
|
|
1736
|
-
if (filters.every((filter) => filter(path$2, true))) paths.push(path$2);
|
|
1737
|
-
};
|
|
1738
|
-
const empty$2 = () => {};
|
|
1739
|
-
function build$6(root, options) {
|
|
1740
|
-
const { includeDirs, filters, relativePaths } = options;
|
|
1741
|
-
if (!includeDirs) return empty$2;
|
|
1742
|
-
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
1743
|
-
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
1744
|
-
}
|
|
1745
|
-
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
1746
|
-
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
1747
|
-
};
|
|
1748
|
-
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
1749
|
-
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
1750
|
-
};
|
|
1751
|
-
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
1752
|
-
counts.files++;
|
|
1753
|
-
};
|
|
1754
|
-
const pushFile = (filename, paths) => {
|
|
1755
|
-
paths.push(filename);
|
|
1756
|
-
};
|
|
1757
|
-
const empty$1 = () => {};
|
|
1758
|
-
function build$5(options) {
|
|
1759
|
-
const { excludeFiles, filters, onlyCounts } = options;
|
|
1760
|
-
if (excludeFiles) return empty$1;
|
|
1761
|
-
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
1762
|
-
else if (onlyCounts) return pushFileCount;
|
|
1763
|
-
else return pushFile;
|
|
1764
|
-
}
|
|
1765
|
-
const getArray = (paths) => {
|
|
1766
|
-
return paths;
|
|
1767
|
-
};
|
|
1768
|
-
const getArrayGroup = () => {
|
|
1769
|
-
return [""].slice(0, 0);
|
|
1770
|
-
};
|
|
1771
|
-
function build$4(options) {
|
|
1772
|
-
return options.group ? getArrayGroup : getArray;
|
|
1773
|
-
}
|
|
1774
|
-
const groupFiles = (groups, directory, files) => {
|
|
1775
|
-
groups.push({
|
|
1776
|
-
directory,
|
|
1777
|
-
files,
|
|
1778
|
-
dir: directory
|
|
1779
|
-
});
|
|
1780
|
-
};
|
|
1781
|
-
const empty = () => {};
|
|
1782
|
-
function build$3(options) {
|
|
1783
|
-
return options.group ? groupFiles : empty;
|
|
1784
|
-
}
|
|
1785
|
-
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
1786
|
-
const { queue, fs, options: { suppressErrors } } = state;
|
|
1787
|
-
queue.enqueue();
|
|
1788
|
-
fs.realpath(path$2, (error, resolvedPath) => {
|
|
1789
|
-
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
1790
|
-
fs.stat(resolvedPath, (error$1, stat) => {
|
|
1791
|
-
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
1792
|
-
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1793
|
-
callback$1(stat, resolvedPath);
|
|
1794
|
-
queue.dequeue(null, state);
|
|
1795
|
-
});
|
|
1796
|
-
});
|
|
1797
|
-
};
|
|
1798
|
-
const resolveSymlinks = function(path$2, state, callback$1) {
|
|
1799
|
-
const { queue, fs, options: { suppressErrors } } = state;
|
|
1800
|
-
queue.enqueue();
|
|
1801
|
-
try {
|
|
1802
|
-
const resolvedPath = fs.realpathSync(path$2);
|
|
1803
|
-
const stat = fs.statSync(resolvedPath);
|
|
1804
|
-
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return;
|
|
1805
|
-
callback$1(stat, resolvedPath);
|
|
1806
|
-
} catch (e) {
|
|
1807
|
-
if (!suppressErrors) throw e;
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
function build$2(options, isSynchronous) {
|
|
1811
|
-
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
1812
|
-
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
1813
|
-
}
|
|
1814
|
-
function isRecursive(path$2, resolved, state) {
|
|
1815
|
-
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
1816
|
-
let parent = dirname(path$2);
|
|
1817
|
-
let depth = 1;
|
|
1818
|
-
while (parent !== state.root && depth < 2) {
|
|
1819
|
-
const resolvedPath = state.symlinks.get(parent);
|
|
1820
|
-
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth++;
|
|
1821
|
-
else parent = dirname(parent);
|
|
1822
|
-
}
|
|
1823
|
-
state.symlinks.set(path$2, resolved);
|
|
1824
|
-
return depth > 1;
|
|
1825
|
-
}
|
|
1826
|
-
function isRecursiveUsingRealPaths(resolved, state) {
|
|
1827
|
-
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
1828
|
-
}
|
|
1829
|
-
const onlyCountsSync = (state) => {
|
|
1830
|
-
return state.counts;
|
|
1831
|
-
};
|
|
1832
|
-
const groupsSync = (state) => {
|
|
1833
|
-
return state.groups;
|
|
1834
|
-
};
|
|
1835
|
-
const defaultSync = (state) => {
|
|
1836
|
-
return state.paths;
|
|
1837
|
-
};
|
|
1838
|
-
const limitFilesSync = (state) => {
|
|
1839
|
-
return state.paths.slice(0, state.options.maxFiles);
|
|
1840
|
-
};
|
|
1841
|
-
const onlyCountsAsync = (state, error, callback$1) => {
|
|
1842
|
-
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
1843
|
-
return null;
|
|
1844
|
-
};
|
|
1845
|
-
const defaultAsync = (state, error, callback$1) => {
|
|
1846
|
-
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
1847
|
-
return null;
|
|
1848
|
-
};
|
|
1849
|
-
const limitFilesAsync = (state, error, callback$1) => {
|
|
1850
|
-
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
1851
|
-
return null;
|
|
1852
|
-
};
|
|
1853
|
-
const groupsAsync = (state, error, callback$1) => {
|
|
1854
|
-
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
1855
|
-
return null;
|
|
1856
|
-
};
|
|
1857
|
-
function report(error, callback$1, output, suppressErrors) {
|
|
1858
|
-
if (error && !suppressErrors) callback$1(error, output);
|
|
1859
|
-
else callback$1(null, output);
|
|
1860
|
-
}
|
|
1861
|
-
function build$1(options, isSynchronous) {
|
|
1862
|
-
const { onlyCounts, group, maxFiles } = options;
|
|
1863
|
-
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
1864
|
-
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
1865
|
-
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
1866
|
-
else return isSynchronous ? defaultSync : defaultAsync;
|
|
1867
|
-
}
|
|
1868
|
-
const readdirOpts = { withFileTypes: true };
|
|
1869
|
-
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
1870
|
-
state.queue.enqueue();
|
|
1871
|
-
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
1872
|
-
const { fs } = state;
|
|
1873
|
-
state.visited.push(crawlPath);
|
|
1874
|
-
state.counts.directories++;
|
|
1875
|
-
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
1876
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1877
|
-
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
1878
|
-
});
|
|
1879
|
-
};
|
|
1880
|
-
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
1881
|
-
const { fs } = state;
|
|
1882
|
-
if (currentDepth < 0) return;
|
|
1883
|
-
state.visited.push(crawlPath);
|
|
1884
|
-
state.counts.directories++;
|
|
1885
|
-
let entries = [];
|
|
1886
|
-
try {
|
|
1887
|
-
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
1888
|
-
} catch (e) {
|
|
1889
|
-
if (!state.options.suppressErrors) throw e;
|
|
1890
|
-
}
|
|
1891
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1892
|
-
};
|
|
1893
|
-
function build(isSynchronous) {
|
|
1894
|
-
return isSynchronous ? walkSync : walkAsync;
|
|
1895
|
-
}
|
|
1896
|
-
/**
|
|
1897
|
-
* This is a custom stateless queue to track concurrent async fs calls.
|
|
1898
|
-
* It increments a counter whenever a call is queued and decrements it
|
|
1899
|
-
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
1900
|
-
*/
|
|
1901
|
-
var Queue = class {
|
|
1902
|
-
count = 0;
|
|
1903
|
-
constructor(onQueueEmpty) {
|
|
1904
|
-
this.onQueueEmpty = onQueueEmpty;
|
|
1905
|
-
}
|
|
1906
|
-
enqueue() {
|
|
1907
|
-
this.count++;
|
|
1908
|
-
return this.count;
|
|
1909
|
-
}
|
|
1910
|
-
dequeue(error, output) {
|
|
1911
|
-
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
1912
|
-
this.onQueueEmpty(error, output);
|
|
1913
|
-
if (error) {
|
|
1914
|
-
output.controller.abort();
|
|
1915
|
-
this.onQueueEmpty = void 0;
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
};
|
|
1920
|
-
var Counter = class {
|
|
1921
|
-
_files = 0;
|
|
1922
|
-
_directories = 0;
|
|
1923
|
-
set files(num) {
|
|
1924
|
-
this._files = num;
|
|
1925
|
-
}
|
|
1926
|
-
get files() {
|
|
1927
|
-
return this._files;
|
|
1928
|
-
}
|
|
1929
|
-
set directories(num) {
|
|
1930
|
-
this._directories = num;
|
|
1931
|
-
}
|
|
1932
|
-
get directories() {
|
|
1933
|
-
return this._directories;
|
|
1934
|
-
}
|
|
1935
|
-
/**
|
|
1936
|
-
* @deprecated use `directories` instead
|
|
1937
|
-
*/
|
|
1938
|
-
/* c8 ignore next 3 */
|
|
1939
|
-
get dirs() {
|
|
1940
|
-
return this._directories;
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
/**
|
|
1944
|
-
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
1945
|
-
* support for Node 14.
|
|
1946
|
-
*/
|
|
1947
|
-
var Aborter = class {
|
|
1948
|
-
aborted = false;
|
|
1949
|
-
abort() {
|
|
1950
|
-
this.aborted = true;
|
|
1951
|
-
}
|
|
1952
|
-
};
|
|
1953
|
-
var Walker = class {
|
|
1954
|
-
root;
|
|
1955
|
-
isSynchronous;
|
|
1956
|
-
state;
|
|
1957
|
-
joinPath;
|
|
1958
|
-
pushDirectory;
|
|
1959
|
-
pushFile;
|
|
1960
|
-
getArray;
|
|
1961
|
-
groupFiles;
|
|
1962
|
-
resolveSymlink;
|
|
1963
|
-
walkDirectory;
|
|
1964
|
-
callbackInvoker;
|
|
1965
|
-
constructor(root, options, callback$1) {
|
|
1966
|
-
this.isSynchronous = !callback$1;
|
|
1967
|
-
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
1968
|
-
this.root = normalizePath$1(root, options);
|
|
1969
|
-
this.state = {
|
|
1970
|
-
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
1971
|
-
paths: [""].slice(0, 0),
|
|
1972
|
-
groups: [],
|
|
1973
|
-
counts: new Counter(),
|
|
1974
|
-
options,
|
|
1975
|
-
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
1976
|
-
symlinks: /* @__PURE__ */ new Map(),
|
|
1977
|
-
visited: [""].slice(0, 0),
|
|
1978
|
-
controller: new Aborter(),
|
|
1979
|
-
fs: options.fs || nativeFs$1
|
|
1980
|
-
};
|
|
1981
|
-
this.joinPath = build$7(this.root, options);
|
|
1982
|
-
this.pushDirectory = build$6(this.root, options);
|
|
1983
|
-
this.pushFile = build$5(options);
|
|
1984
|
-
this.getArray = build$4(options);
|
|
1985
|
-
this.groupFiles = build$3(options);
|
|
1986
|
-
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
1987
|
-
this.walkDirectory = build(this.isSynchronous);
|
|
1988
|
-
}
|
|
1989
|
-
start() {
|
|
1990
|
-
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
1991
|
-
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
1992
|
-
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
1993
|
-
}
|
|
1994
|
-
walk = (entries, directoryPath, depth) => {
|
|
1995
|
-
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
1996
|
-
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
1997
|
-
const files = this.getArray(this.state.paths);
|
|
1998
|
-
for (let i = 0; i < entries.length; ++i) {
|
|
1999
|
-
const entry = entries[i];
|
|
2000
|
-
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
2001
|
-
const filename = this.joinPath(entry.name, directoryPath);
|
|
2002
|
-
this.pushFile(filename, files, this.state.counts, filters);
|
|
2003
|
-
} else if (entry.isDirectory()) {
|
|
2004
|
-
let path$2 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
2005
|
-
if (exclude && exclude(entry.name, path$2)) continue;
|
|
2006
|
-
this.pushDirectory(path$2, paths, filters);
|
|
2007
|
-
this.walkDirectory(this.state, path$2, path$2, depth - 1, this.walk);
|
|
2008
|
-
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
2009
|
-
let path$2 = joinPathWithBasePath(entry.name, directoryPath);
|
|
2010
|
-
this.resolveSymlink(path$2, this.state, (stat, resolvedPath) => {
|
|
2011
|
-
if (stat.isDirectory()) {
|
|
2012
|
-
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
2013
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$2 + pathSeparator)) return;
|
|
2014
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$2 + pathSeparator, depth - 1, this.walk);
|
|
2015
|
-
} else {
|
|
2016
|
-
resolvedPath = useRealPaths ? resolvedPath : path$2;
|
|
2017
|
-
const filename = basename(resolvedPath);
|
|
2018
|
-
const directoryPath$1 = normalizePath$1(dirname(resolvedPath), this.state.options);
|
|
2019
|
-
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
2020
|
-
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
2021
|
-
}
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
this.groupFiles(this.state.groups, directoryPath, files);
|
|
2026
|
-
};
|
|
2027
|
-
};
|
|
2028
|
-
function promise(root, options) {
|
|
2029
|
-
return new Promise((resolve$1, reject) => {
|
|
2030
|
-
callback(root, options, (err, output) => {
|
|
2031
|
-
if (err) return reject(err);
|
|
2032
|
-
resolve$1(output);
|
|
2033
|
-
});
|
|
2034
|
-
});
|
|
2035
|
-
}
|
|
2036
|
-
function callback(root, options, callback$1) {
|
|
2037
|
-
new Walker(root, options, callback$1).start();
|
|
2038
|
-
}
|
|
2039
|
-
function sync(root, options) {
|
|
2040
|
-
return new Walker(root, options).start();
|
|
2041
|
-
}
|
|
2042
|
-
var APIBuilder = class {
|
|
2043
|
-
constructor(root, options) {
|
|
2044
|
-
this.root = root;
|
|
2045
|
-
this.options = options;
|
|
2046
|
-
}
|
|
2047
|
-
withPromise() {
|
|
2048
|
-
return promise(this.root, this.options);
|
|
2049
|
-
}
|
|
2050
|
-
withCallback(cb) {
|
|
2051
|
-
callback(this.root, this.options, cb);
|
|
2052
|
-
}
|
|
2053
|
-
sync() {
|
|
2054
|
-
return sync(this.root, this.options);
|
|
2055
|
-
}
|
|
2056
|
-
};
|
|
2057
|
-
let pm$1 = null;
|
|
2058
|
-
/* c8 ignore next 6 */
|
|
2059
|
-
try {
|
|
2060
|
-
__require.resolve("picomatch");
|
|
2061
|
-
pm$1 = __require("picomatch");
|
|
2062
|
-
} catch {}
|
|
2063
|
-
var Builder = class {
|
|
2064
|
-
globCache = {};
|
|
2065
|
-
options = {
|
|
2066
|
-
maxDepth: Infinity,
|
|
2067
|
-
suppressErrors: true,
|
|
2068
|
-
pathSeparator: sep,
|
|
2069
|
-
filters: []
|
|
2070
|
-
};
|
|
2071
|
-
globFunction;
|
|
2072
|
-
constructor(options) {
|
|
2073
|
-
this.options = {
|
|
2074
|
-
...this.options,
|
|
2075
|
-
...options
|
|
2076
|
-
};
|
|
2077
|
-
this.globFunction = this.options.globFunction;
|
|
2078
|
-
}
|
|
2079
|
-
group() {
|
|
2080
|
-
this.options.group = true;
|
|
2081
|
-
return this;
|
|
2082
|
-
}
|
|
2083
|
-
withPathSeparator(separator) {
|
|
2084
|
-
this.options.pathSeparator = separator;
|
|
2085
|
-
return this;
|
|
2086
|
-
}
|
|
2087
|
-
withBasePath() {
|
|
2088
|
-
this.options.includeBasePath = true;
|
|
2089
|
-
return this;
|
|
2090
|
-
}
|
|
2091
|
-
withRelativePaths() {
|
|
2092
|
-
this.options.relativePaths = true;
|
|
2093
|
-
return this;
|
|
2094
|
-
}
|
|
2095
|
-
withDirs() {
|
|
2096
|
-
this.options.includeDirs = true;
|
|
2097
|
-
return this;
|
|
2098
|
-
}
|
|
2099
|
-
withMaxDepth(depth) {
|
|
2100
|
-
this.options.maxDepth = depth;
|
|
2101
|
-
return this;
|
|
2102
|
-
}
|
|
2103
|
-
withMaxFiles(limit) {
|
|
2104
|
-
this.options.maxFiles = limit;
|
|
2105
|
-
return this;
|
|
2106
|
-
}
|
|
2107
|
-
withFullPaths() {
|
|
2108
|
-
this.options.resolvePaths = true;
|
|
2109
|
-
this.options.includeBasePath = true;
|
|
2110
|
-
return this;
|
|
2111
|
-
}
|
|
2112
|
-
withErrors() {
|
|
2113
|
-
this.options.suppressErrors = false;
|
|
2114
|
-
return this;
|
|
2115
|
-
}
|
|
2116
|
-
withSymlinks({ resolvePaths = true } = {}) {
|
|
2117
|
-
this.options.resolveSymlinks = true;
|
|
2118
|
-
this.options.useRealPaths = resolvePaths;
|
|
2119
|
-
return this.withFullPaths();
|
|
2120
|
-
}
|
|
2121
|
-
withAbortSignal(signal) {
|
|
2122
|
-
this.options.signal = signal;
|
|
2123
|
-
return this;
|
|
2124
|
-
}
|
|
2125
|
-
normalize() {
|
|
2126
|
-
this.options.normalizePath = true;
|
|
2127
|
-
return this;
|
|
2128
|
-
}
|
|
2129
|
-
filter(predicate) {
|
|
2130
|
-
this.options.filters.push(predicate);
|
|
2131
|
-
return this;
|
|
2132
|
-
}
|
|
2133
|
-
onlyDirs() {
|
|
2134
|
-
this.options.excludeFiles = true;
|
|
2135
|
-
this.options.includeDirs = true;
|
|
2136
|
-
return this;
|
|
2137
|
-
}
|
|
2138
|
-
exclude(predicate) {
|
|
2139
|
-
this.options.exclude = predicate;
|
|
2140
|
-
return this;
|
|
2141
|
-
}
|
|
2142
|
-
onlyCounts() {
|
|
2143
|
-
this.options.onlyCounts = true;
|
|
2144
|
-
return this;
|
|
2145
|
-
}
|
|
2146
|
-
crawl(root) {
|
|
2147
|
-
return new APIBuilder(root || ".", this.options);
|
|
2148
|
-
}
|
|
2149
|
-
withGlobFunction(fn) {
|
|
2150
|
-
this.globFunction = fn;
|
|
2151
|
-
return this;
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* @deprecated Pass options using the constructor instead:
|
|
2155
|
-
* ```ts
|
|
2156
|
-
* new fdir(options).crawl("/path/to/root");
|
|
2157
|
-
* ```
|
|
2158
|
-
* This method will be removed in v7.0
|
|
2159
|
-
*/
|
|
2160
|
-
/* c8 ignore next 4 */
|
|
2161
|
-
crawlWithOptions(root, options) {
|
|
2162
|
-
this.options = {
|
|
2163
|
-
...this.options,
|
|
2164
|
-
...options
|
|
2165
|
-
};
|
|
2166
|
-
return new APIBuilder(root || ".", this.options);
|
|
2167
|
-
}
|
|
2168
|
-
glob(...patterns) {
|
|
2169
|
-
if (this.globFunction) return this.globWithOptions(patterns);
|
|
2170
|
-
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
2171
|
-
}
|
|
2172
|
-
globWithOptions(patterns, ...options) {
|
|
2173
|
-
const globFn = this.globFunction || pm$1;
|
|
2174
|
-
/* c8 ignore next 5 */
|
|
2175
|
-
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
2176
|
-
var isMatch = this.globCache[patterns.join("\0")];
|
|
2177
|
-
if (!isMatch) {
|
|
2178
|
-
isMatch = globFn(patterns, ...options);
|
|
2179
|
-
this.globCache[patterns.join("\0")] = isMatch;
|
|
2180
|
-
}
|
|
2181
|
-
this.options.filters.push((path$2) => isMatch(path$2));
|
|
2182
|
-
return this;
|
|
2183
|
-
}
|
|
2184
|
-
};
|
|
2185
|
-
|
|
2186
|
-
//#endregion
|
|
2187
|
-
//#region node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
|
|
2188
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
2189
|
-
/** @typedef {{
|
|
2190
|
-
skip: () => void;
|
|
2191
|
-
remove: () => void;
|
|
2192
|
-
replace: (node: BaseNode) => void;
|
|
2193
|
-
}} WalkerContext */
|
|
2194
|
-
var WalkerBase = class {
|
|
2195
|
-
constructor() {
|
|
2196
|
-
/** @type {boolean} */
|
|
2197
|
-
this.should_skip = false;
|
|
2198
|
-
/** @type {boolean} */
|
|
2199
|
-
this.should_remove = false;
|
|
2200
|
-
/** @type {BaseNode | null} */
|
|
2201
|
-
this.replacement = null;
|
|
2202
|
-
/** @type {WalkerContext} */
|
|
2203
|
-
this.context = {
|
|
2204
|
-
skip: () => this.should_skip = true,
|
|
2205
|
-
remove: () => this.should_remove = true,
|
|
2206
|
-
replace: (node) => this.replacement = node
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2209
|
-
/**
|
|
2210
|
-
*
|
|
2211
|
-
* @param {any} parent
|
|
2212
|
-
* @param {string} prop
|
|
2213
|
-
* @param {number} index
|
|
2214
|
-
* @param {BaseNode} node
|
|
2215
|
-
*/
|
|
2216
|
-
replace(parent, prop, index, node) {
|
|
2217
|
-
if (parent) if (index !== null) parent[prop][index] = node;
|
|
2218
|
-
else parent[prop] = node;
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
*
|
|
2222
|
-
* @param {any} parent
|
|
2223
|
-
* @param {string} prop
|
|
2224
|
-
* @param {number} index
|
|
2225
|
-
*/
|
|
2226
|
-
remove(parent, prop, index) {
|
|
2227
|
-
if (parent) if (index !== null) parent[prop].splice(index, 1);
|
|
2228
|
-
else delete parent[prop];
|
|
2229
|
-
}
|
|
2230
|
-
};
|
|
2231
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
2232
|
-
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
|
2233
|
-
/** @typedef {(
|
|
2234
|
-
* this: WalkerContext,
|
|
2235
|
-
* node: BaseNode,
|
|
2236
|
-
* parent: BaseNode,
|
|
2237
|
-
* key: string,
|
|
2238
|
-
* index: number
|
|
2239
|
-
* ) => void} SyncHandler */
|
|
2240
|
-
var SyncWalker = class extends WalkerBase {
|
|
2241
|
-
/**
|
|
2242
|
-
*
|
|
2243
|
-
* @param {SyncHandler} enter
|
|
2244
|
-
* @param {SyncHandler} leave
|
|
2245
|
-
*/
|
|
2246
|
-
constructor(enter, leave) {
|
|
2247
|
-
super();
|
|
2248
|
-
/** @type {SyncHandler} */
|
|
2249
|
-
this.enter = enter;
|
|
2250
|
-
/** @type {SyncHandler} */
|
|
2251
|
-
this.leave = leave;
|
|
2252
|
-
}
|
|
2253
|
-
/**
|
|
2254
|
-
*
|
|
2255
|
-
* @param {BaseNode} node
|
|
2256
|
-
* @param {BaseNode} parent
|
|
2257
|
-
* @param {string} [prop]
|
|
2258
|
-
* @param {number} [index]
|
|
2259
|
-
* @returns {BaseNode}
|
|
2260
|
-
*/
|
|
2261
|
-
visit(node, parent, prop, index) {
|
|
2262
|
-
if (node) {
|
|
2263
|
-
if (this.enter) {
|
|
2264
|
-
const _should_skip = this.should_skip;
|
|
2265
|
-
const _should_remove = this.should_remove;
|
|
2266
|
-
const _replacement = this.replacement;
|
|
2267
|
-
this.should_skip = false;
|
|
2268
|
-
this.should_remove = false;
|
|
2269
|
-
this.replacement = null;
|
|
2270
|
-
this.enter.call(this.context, node, parent, prop, index);
|
|
2271
|
-
if (this.replacement) {
|
|
2272
|
-
node = this.replacement;
|
|
2273
|
-
this.replace(parent, prop, index, node);
|
|
2274
|
-
}
|
|
2275
|
-
if (this.should_remove) this.remove(parent, prop, index);
|
|
2276
|
-
const skipped = this.should_skip;
|
|
2277
|
-
const removed = this.should_remove;
|
|
2278
|
-
this.should_skip = _should_skip;
|
|
2279
|
-
this.should_remove = _should_remove;
|
|
2280
|
-
this.replacement = _replacement;
|
|
2281
|
-
if (skipped) return node;
|
|
2282
|
-
if (removed) return null;
|
|
2283
|
-
}
|
|
2284
|
-
for (const key in node) {
|
|
2285
|
-
const value = node[key];
|
|
2286
|
-
if (typeof value !== "object") continue;
|
|
2287
|
-
else if (Array.isArray(value)) {
|
|
2288
|
-
for (let i = 0; i < value.length; i += 1) if (value[i] !== null && typeof value[i].type === "string") {
|
|
2289
|
-
if (!this.visit(value[i], node, key, i)) i--;
|
|
2290
|
-
}
|
|
2291
|
-
} else if (value !== null && typeof value.type === "string") this.visit(value, node, key, null);
|
|
2292
|
-
}
|
|
2293
|
-
if (this.leave) {
|
|
2294
|
-
const _replacement = this.replacement;
|
|
2295
|
-
const _should_remove = this.should_remove;
|
|
2296
|
-
this.replacement = null;
|
|
2297
|
-
this.should_remove = false;
|
|
2298
|
-
this.leave.call(this.context, node, parent, prop, index);
|
|
2299
|
-
if (this.replacement) {
|
|
2300
|
-
node = this.replacement;
|
|
2301
|
-
this.replace(parent, prop, index, node);
|
|
2302
|
-
}
|
|
2303
|
-
if (this.should_remove) this.remove(parent, prop, index);
|
|
2304
|
-
const removed = this.should_remove;
|
|
2305
|
-
this.replacement = _replacement;
|
|
2306
|
-
this.should_remove = _should_remove;
|
|
2307
|
-
if (removed) return null;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
return node;
|
|
2311
|
-
}
|
|
2312
|
-
};
|
|
2313
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
2314
|
-
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
|
2315
|
-
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
|
2316
|
-
/**
|
|
2317
|
-
*
|
|
2318
|
-
* @param {BaseNode} ast
|
|
2319
|
-
* @param {{
|
|
2320
|
-
* enter?: SyncHandler
|
|
2321
|
-
* leave?: SyncHandler
|
|
2322
|
-
* }} walker
|
|
2323
|
-
* @returns {BaseNode}
|
|
2324
|
-
*/
|
|
2325
|
-
function walk(ast, { enter, leave }) {
|
|
2326
|
-
return new SyncWalker(enter, leave).visit(ast, null);
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
//#endregion
|
|
2330
|
-
//#region node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.55.1/node_modules/@rollup/pluginutils/dist/es/index.js
|
|
2331
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
2332
|
-
const extractors = {
|
|
2333
|
-
ArrayPattern(names, param) {
|
|
2334
|
-
for (const element of param.elements) if (element) extractors[element.type](names, element);
|
|
2335
|
-
},
|
|
2336
|
-
AssignmentPattern(names, param) {
|
|
2337
|
-
extractors[param.left.type](names, param.left);
|
|
2338
|
-
},
|
|
2339
|
-
Identifier(names, param) {
|
|
2340
|
-
names.push(param.name);
|
|
2341
|
-
},
|
|
2342
|
-
MemberExpression() {},
|
|
2343
|
-
ObjectPattern(names, param) {
|
|
2344
|
-
for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
|
|
2345
|
-
else extractors[prop.value.type](names, prop.value);
|
|
2346
|
-
},
|
|
2347
|
-
RestElement(names, param) {
|
|
2348
|
-
extractors[param.argument.type](names, param.argument);
|
|
2349
|
-
}
|
|
2350
|
-
};
|
|
2351
|
-
const extractAssignedNames = function extractAssignedNames$1(param) {
|
|
2352
|
-
const names = [];
|
|
2353
|
-
extractors[param.type](names, param);
|
|
2354
|
-
return names;
|
|
2355
|
-
};
|
|
2356
|
-
const blockDeclarations = {
|
|
2357
|
-
const: true,
|
|
2358
|
-
let: true
|
|
2359
|
-
};
|
|
2360
|
-
var Scope = class {
|
|
2361
|
-
constructor(options = {}) {
|
|
2362
|
-
this.parent = options.parent;
|
|
2363
|
-
this.isBlockScope = !!options.block;
|
|
2364
|
-
this.declarations = Object.create(null);
|
|
2365
|
-
if (options.params) options.params.forEach((param) => {
|
|
2366
|
-
extractAssignedNames(param).forEach((name) => {
|
|
2367
|
-
this.declarations[name] = true;
|
|
2368
|
-
});
|
|
2369
|
-
});
|
|
2370
|
-
}
|
|
2371
|
-
addDeclaration(node, isBlockDeclaration, isVar) {
|
|
2372
|
-
if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
|
|
2373
|
-
else if (node.id) extractAssignedNames(node.id).forEach((name) => {
|
|
2374
|
-
this.declarations[name] = true;
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
contains(name) {
|
|
2378
|
-
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
|
2379
|
-
}
|
|
2380
|
-
};
|
|
2381
|
-
const attachScopes = function attachScopes$1(ast, propertyName = "scope") {
|
|
2382
|
-
let scope = new Scope();
|
|
2383
|
-
walk(ast, {
|
|
2384
|
-
enter(n, parent) {
|
|
2385
|
-
const node = n;
|
|
2386
|
-
if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
|
|
2387
|
-
if (node.type === "VariableDeclaration") {
|
|
2388
|
-
const { kind } = node;
|
|
2389
|
-
const isBlockDeclaration = blockDeclarations[kind];
|
|
2390
|
-
node.declarations.forEach((declaration) => {
|
|
2391
|
-
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
|
2392
|
-
});
|
|
2393
|
-
}
|
|
2394
|
-
let newScope;
|
|
2395
|
-
if (node.type.includes("Function")) {
|
|
2396
|
-
const func = node;
|
|
2397
|
-
newScope = new Scope({
|
|
2398
|
-
parent: scope,
|
|
2399
|
-
block: false,
|
|
2400
|
-
params: func.params
|
|
2401
|
-
});
|
|
2402
|
-
if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
|
|
2403
|
-
}
|
|
2404
|
-
if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
|
|
2405
|
-
parent: scope,
|
|
2406
|
-
block: true
|
|
2407
|
-
});
|
|
2408
|
-
if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
|
|
2409
|
-
parent: scope,
|
|
2410
|
-
block: true
|
|
2411
|
-
});
|
|
2412
|
-
if (node.type === "CatchClause") newScope = new Scope({
|
|
2413
|
-
parent: scope,
|
|
2414
|
-
params: node.param ? [node.param] : [],
|
|
2415
|
-
block: true
|
|
2416
|
-
});
|
|
2417
|
-
if (newScope) {
|
|
2418
|
-
Object.defineProperty(node, propertyName, {
|
|
2419
|
-
value: newScope,
|
|
2420
|
-
configurable: true
|
|
2421
|
-
});
|
|
2422
|
-
scope = newScope;
|
|
2423
|
-
}
|
|
2424
|
-
},
|
|
2425
|
-
leave(n) {
|
|
2426
|
-
if (n[propertyName]) scope = scope.parent;
|
|
2427
|
-
}
|
|
2428
|
-
});
|
|
2429
|
-
return scope;
|
|
2430
|
-
};
|
|
2431
|
-
function isArray(arg) {
|
|
2432
|
-
return Array.isArray(arg);
|
|
2433
|
-
}
|
|
2434
|
-
function ensureArray(thing) {
|
|
2435
|
-
if (isArray(thing)) return thing;
|
|
2436
|
-
if (thing == null) return [];
|
|
2437
|
-
return [thing];
|
|
2438
|
-
}
|
|
2439
|
-
const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
|
|
2440
|
-
const normalizePath = function normalizePath$2(filename) {
|
|
2441
|
-
return filename.replace(normalizePathRegExp, posix.sep);
|
|
2442
|
-
};
|
|
2443
|
-
function getMatcherString(id, resolutionBase) {
|
|
2444
|
-
if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
|
|
2445
|
-
const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
|
|
2446
|
-
return posix.join(basePath, normalizePath(id));
|
|
2447
|
-
}
|
|
2448
|
-
const createFilter = function createFilter$1(include, exclude, options) {
|
|
2449
|
-
const resolutionBase = options && options.resolve;
|
|
2450
|
-
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
|
|
2451
|
-
return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
|
|
2452
|
-
} };
|
|
2453
|
-
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
2454
|
-
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
2455
|
-
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
|
|
2456
|
-
return function result(id) {
|
|
2457
|
-
if (typeof id !== "string") return false;
|
|
2458
|
-
if (id.includes("\0")) return false;
|
|
2459
|
-
const pathId = normalizePath(id);
|
|
2460
|
-
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
2461
|
-
const matcher = excludeMatchers[i];
|
|
2462
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
2463
|
-
if (matcher.test(pathId)) return false;
|
|
2464
|
-
}
|
|
2465
|
-
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
2466
|
-
const matcher = includeMatchers[i];
|
|
2467
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
2468
|
-
if (matcher.test(pathId)) return true;
|
|
2469
|
-
}
|
|
2470
|
-
return !includeMatchers.length;
|
|
2471
|
-
};
|
|
2472
|
-
};
|
|
2473
|
-
const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl`.split(" "));
|
|
2474
|
-
forbiddenIdentifiers.add("");
|
|
2475
|
-
const makeLegalIdentifier = function makeLegalIdentifier$1(str) {
|
|
2476
|
-
let identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
|
|
2477
|
-
if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) identifier = `_${identifier}`;
|
|
2478
|
-
return identifier || "_";
|
|
2479
|
-
};
|
|
2480
|
-
function stringify(obj) {
|
|
2481
|
-
return (JSON.stringify(obj) || "undefined").replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
|
2482
|
-
}
|
|
2483
|
-
function serializeArray(arr, indent, baseIndent) {
|
|
2484
|
-
let output = "[";
|
|
2485
|
-
const separator = indent ? `\n${baseIndent}${indent}` : "";
|
|
2486
|
-
for (let i = 0; i < arr.length; i++) {
|
|
2487
|
-
const key = arr[i];
|
|
2488
|
-
output += `${i > 0 ? "," : ""}${separator}${serialize(key, indent, baseIndent + indent)}`;
|
|
2489
|
-
}
|
|
2490
|
-
return `${output}${indent ? `\n${baseIndent}` : ""}]`;
|
|
2491
|
-
}
|
|
2492
|
-
function serializeObject(obj, indent, baseIndent) {
|
|
2493
|
-
let output = "{";
|
|
2494
|
-
const separator = indent ? `\n${baseIndent}${indent}` : "";
|
|
2495
|
-
const entries = Object.entries(obj);
|
|
2496
|
-
for (let i = 0; i < entries.length; i++) {
|
|
2497
|
-
const [key, value] = entries[i];
|
|
2498
|
-
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
|
2499
|
-
output += `${i > 0 ? "," : ""}${separator}${stringKey}:${indent ? " " : ""}${serialize(value, indent, baseIndent + indent)}`;
|
|
2500
|
-
}
|
|
2501
|
-
return `${output}${indent ? `\n${baseIndent}` : ""}}`;
|
|
2502
|
-
}
|
|
2503
|
-
function serialize(obj, indent, baseIndent) {
|
|
2504
|
-
if (typeof obj === "object" && obj !== null) {
|
|
2505
|
-
if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
|
|
2506
|
-
if (obj instanceof Date) return `new Date(${obj.getTime()})`;
|
|
2507
|
-
if (obj instanceof RegExp) return obj.toString();
|
|
2508
|
-
return serializeObject(obj, indent, baseIndent);
|
|
2509
|
-
}
|
|
2510
|
-
if (typeof obj === "number") {
|
|
2511
|
-
if (obj === Infinity) return "Infinity";
|
|
2512
|
-
if (obj === -Infinity) return "-Infinity";
|
|
2513
|
-
if (obj === 0) return 1 / obj === Infinity ? "0" : "-0";
|
|
2514
|
-
if (obj !== obj) return "NaN";
|
|
2515
|
-
}
|
|
2516
|
-
if (typeof obj === "symbol") {
|
|
2517
|
-
const key = Symbol.keyFor(obj);
|
|
2518
|
-
if (key !== void 0) return `Symbol.for(${stringify(key)})`;
|
|
2519
|
-
}
|
|
2520
|
-
if (typeof obj === "bigint") return `${obj}n`;
|
|
2521
|
-
return stringify(obj);
|
|
2522
|
-
}
|
|
2523
|
-
const hasStringIsWellFormed = "isWellFormed" in String.prototype;
|
|
2524
|
-
function isWellFormedString(input) {
|
|
2525
|
-
if (hasStringIsWellFormed) return input.isWellFormed();
|
|
2526
|
-
return !/\p{Surrogate}/u.test(input);
|
|
2527
|
-
}
|
|
2528
|
-
const dataToEsm = function dataToEsm$1(data, options = {}) {
|
|
2529
|
-
var _a, _b;
|
|
2530
|
-
const t = options.compact ? "" : "indent" in options ? options.indent : " ";
|
|
2531
|
-
const _ = options.compact ? "" : " ";
|
|
2532
|
-
const n = options.compact ? "" : "\n";
|
|
2533
|
-
const declarationType = options.preferConst ? "const" : "var";
|
|
2534
|
-
if (options.namedExports === false || typeof data !== "object" || Array.isArray(data) || data instanceof Date || data instanceof RegExp || data === null) {
|
|
2535
|
-
const code = serialize(data, options.compact ? null : t, "");
|
|
2536
|
-
return `export default${_ || (/^[{[\-\/]/.test(code) ? "" : " ")}${code};`;
|
|
2537
|
-
}
|
|
2538
|
-
let maxUnderbarPrefixLength = 0;
|
|
2539
|
-
for (const key of Object.keys(data)) {
|
|
2540
|
-
const underbarPrefixLength = (_b = (_a = /^(_+)/.exec(key)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
2541
|
-
if (underbarPrefixLength > maxUnderbarPrefixLength) maxUnderbarPrefixLength = underbarPrefixLength;
|
|
2542
|
-
}
|
|
2543
|
-
const arbitraryNamePrefix = `${"_".repeat(maxUnderbarPrefixLength + 1)}arbitrary`;
|
|
2544
|
-
let namedExportCode = "";
|
|
2545
|
-
const defaultExportRows = [];
|
|
2546
|
-
const arbitraryNameExportRows = [];
|
|
2547
|
-
for (const [key, value] of Object.entries(data)) if (key === makeLegalIdentifier(key)) {
|
|
2548
|
-
if (options.objectShorthand) defaultExportRows.push(key);
|
|
2549
|
-
else defaultExportRows.push(`${key}:${_}${key}`);
|
|
2550
|
-
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
|
|
2551
|
-
} else {
|
|
2552
|
-
defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, "")}`);
|
|
2553
|
-
if (options.includeArbitraryNames && isWellFormedString(key)) {
|
|
2554
|
-
const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`;
|
|
2555
|
-
namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
|
|
2556
|
-
arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`);
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
const arbitraryExportCode = arbitraryNameExportRows.length > 0 ? `export${_}{${n}${t}${arbitraryNameExportRows.join(`,${n}${t}`)}${n}};${n}` : "";
|
|
2560
|
-
const defaultExportCode = `export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
|
2561
|
-
return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
|
-
//#endregion
|
|
2565
|
-
//#region node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js
|
|
2566
|
-
var require_commondir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2567
|
-
var path$1 = __require$1("path");
|
|
2568
|
-
module.exports = function(basedir, relfiles) {
|
|
2569
|
-
if (relfiles) var files = relfiles.map(function(r) {
|
|
2570
|
-
return path$1.resolve(basedir, r);
|
|
2571
|
-
});
|
|
2572
|
-
else var files = basedir;
|
|
2573
|
-
var res = files.slice(1).reduce(function(ps, file) {
|
|
2574
|
-
if (!file.match(/^([A-Za-z]:)?\/|\\/)) throw new Error("relative path without a basedir");
|
|
2575
|
-
var xs = file.split(/\/+|\\+/);
|
|
2576
|
-
for (var i = 0; ps[i] === xs[i] && i < Math.min(ps.length, xs.length); i++);
|
|
2577
|
-
return ps.slice(0, i);
|
|
2578
|
-
}, files[0].split(/\/+|\\+/));
|
|
2579
|
-
return res.length > 1 ? res.join("/") : "/";
|
|
2580
|
-
};
|
|
2581
|
-
}));
|
|
2582
|
-
|
|
2583
|
-
//#endregion
|
|
2584
|
-
//#region node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.js
|
|
2585
|
-
var require_is_reference = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2586
|
-
(function(global, factory) {
|
|
2587
|
-
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.isReference = factory());
|
|
2588
|
-
})(exports, (function() {
|
|
2589
|
-
"use strict";
|
|
2590
|
-
function isReference$1(node, parent) {
|
|
2591
|
-
if (node.type === "MemberExpression") return !node.computed && isReference$1(node.object, node);
|
|
2592
|
-
if (node.type === "Identifier") {
|
|
2593
|
-
if (!parent) return true;
|
|
2594
|
-
switch (parent.type) {
|
|
2595
|
-
case "MemberExpression": return parent.computed || node === parent.object;
|
|
2596
|
-
case "MethodDefinition": return parent.computed;
|
|
2597
|
-
case "FieldDefinition": return parent.computed || node === parent.value;
|
|
2598
|
-
case "Property": return parent.computed || node === parent.value;
|
|
2599
|
-
case "ExportSpecifier":
|
|
2600
|
-
case "ImportSpecifier": return node === parent.local;
|
|
2601
|
-
case "LabeledStatement":
|
|
2602
|
-
case "BreakStatement":
|
|
2603
|
-
case "ContinueStatement": return false;
|
|
2604
|
-
default: return true;
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
return false;
|
|
2608
|
-
}
|
|
2609
|
-
return isReference$1;
|
|
2610
|
-
}));
|
|
2611
|
-
}));
|
|
2612
|
-
|
|
2613
|
-
//#endregion
|
|
2614
11
|
//#region node_modules/.pnpm/@rollup+plugin-commonjs@29.0.0_rollup@4.55.1/node_modules/@rollup/plugin-commonjs/dist/es/index.js
|
|
2615
12
|
var import_commondir = /* @__PURE__ */ __toESM(require_commondir(), 1);
|
|
2616
13
|
var import_is_reference = /* @__PURE__ */ __toESM(require_is_reference(), 1);
|
|
@@ -2677,10 +74,10 @@ function getName(id) {
|
|
|
2677
74
|
if (name !== "index") return name;
|
|
2678
75
|
return makeLegalIdentifier(basename(dirname(id)));
|
|
2679
76
|
}
|
|
2680
|
-
function normalizePathSlashes(path$
|
|
2681
|
-
return path$
|
|
77
|
+
function normalizePathSlashes(path$1) {
|
|
78
|
+
return path$1.replace(/\\/g, "/");
|
|
2682
79
|
}
|
|
2683
|
-
const getVirtualPathForDynamicRequirePath = (path$
|
|
80
|
+
const getVirtualPathForDynamicRequirePath = (path$1, commonDir) => `/${normalizePathSlashes(relative(commonDir, path$1))}`;
|
|
2684
81
|
function capitalize(name) {
|
|
2685
82
|
return name[0].toUpperCase() + name.slice(1);
|
|
2686
83
|
}
|
|
@@ -2716,9 +113,9 @@ function getPackageEntryPoint(dirPath) {
|
|
|
2716
113
|
} catch (ignored) {}
|
|
2717
114
|
return entryPoint;
|
|
2718
115
|
}
|
|
2719
|
-
function isDirectory(path$
|
|
116
|
+
function isDirectory(path$1) {
|
|
2720
117
|
try {
|
|
2721
|
-
if (statSync(path$
|
|
118
|
+
if (statSync(path$1).isDirectory()) return true;
|
|
2722
119
|
} catch (ignored) {}
|
|
2723
120
|
return false;
|
|
2724
121
|
}
|
|
@@ -2728,12 +125,12 @@ function getDynamicRequireModules(patterns, dynamicRequireRoot) {
|
|
|
2728
125
|
for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
|
|
2729
126
|
const isNegated = pattern.startsWith("!");
|
|
2730
127
|
const modifyMap = (targetPath, resolvedPath) => isNegated ? dynamicRequireModules.delete(targetPath) : dynamicRequireModules.set(targetPath, resolvedPath);
|
|
2731
|
-
for (const path$
|
|
2732
|
-
const resolvedPath = resolve(path$
|
|
128
|
+
for (const path$1 of new Builder().withBasePath().withDirs().glob(isNegated ? pattern.substr(1) : pattern).crawl(relative(".", dynamicRequireRoot)).sync().sort((a, b) => a.localeCompare(b, "en"))) {
|
|
129
|
+
const resolvedPath = resolve(path$1);
|
|
2733
130
|
const requirePath = normalizePathSlashes(resolvedPath);
|
|
2734
131
|
if (isDirectory(resolvedPath)) {
|
|
2735
132
|
dirNames.add(resolvedPath);
|
|
2736
|
-
const modulePath = resolve(join(resolvedPath, getPackageEntryPoint(path$
|
|
133
|
+
const modulePath = resolve(join(resolvedPath, getPackageEntryPoint(path$1)));
|
|
2737
134
|
modifyMap(requirePath, modulePath);
|
|
2738
135
|
modifyMap(normalizePathSlashes(modulePath), modulePath);
|
|
2739
136
|
} else {
|
|
@@ -3252,23 +649,23 @@ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRan
|
|
|
3252
649
|
magicString.trim().indent(" ", { exclude: indentExclusionRanges }).prepend(`(function (${args.join(", ")}) {\n`).append(` \n} (${passedArgs.join(", ")}));`);
|
|
3253
650
|
}
|
|
3254
651
|
function rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, wrapped, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, defineCompiledEsmExpressions, deconflictedExportNames, code, HELPERS_NAME, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName) {
|
|
3255
|
-
const exports
|
|
652
|
+
const exports = [];
|
|
3256
653
|
const exportDeclarations = [];
|
|
3257
|
-
if (usesRequireWrapper) getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports
|
|
3258
|
-
else if (exportMode === "replace") getExportsForReplacedModuleExports(magicString, exports
|
|
654
|
+
if (usesRequireWrapper) getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions);
|
|
655
|
+
else if (exportMode === "replace") getExportsForReplacedModuleExports(magicString, exports, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME);
|
|
3259
656
|
else {
|
|
3260
657
|
if (exportMode === "module") {
|
|
3261
658
|
exportDeclarations.push(`var ${exportedExportsName} = ${moduleName}.exports`);
|
|
3262
|
-
exports
|
|
3263
|
-
} else exports
|
|
659
|
+
exports.push(`${exportedExportsName} as __moduleExports`);
|
|
660
|
+
} else exports.push(`${exportsName} as __moduleExports`);
|
|
3264
661
|
if (wrapped) exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
|
|
3265
|
-
else getExports(magicString, exports
|
|
662
|
+
else getExports(magicString, exports, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode);
|
|
3266
663
|
}
|
|
3267
|
-
if (exports
|
|
664
|
+
if (exports.length) exportDeclarations.push(`export { ${exports.join(", ")} }`);
|
|
3268
665
|
return `\n\n${exportDeclarations.join(";\n")};`;
|
|
3269
666
|
}
|
|
3270
|
-
function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports
|
|
3271
|
-
exports
|
|
667
|
+
function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions) {
|
|
668
|
+
exports.push(`${requireName} as __require`);
|
|
3272
669
|
if (wrapped) return;
|
|
3273
670
|
if (exportMode === "replace") rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName);
|
|
3274
671
|
else {
|
|
@@ -3277,16 +674,16 @@ function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exp
|
|
|
3277
674
|
replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
|
|
3278
675
|
}
|
|
3279
676
|
}
|
|
3280
|
-
function getExportsForReplacedModuleExports(magicString, exports
|
|
677
|
+
function getExportsForReplacedModuleExports(magicString, exports, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME) {
|
|
3281
678
|
for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
|
|
3282
679
|
magicString.prependRight(firstTopLevelModuleExportsAssignment.left.start, "var ");
|
|
3283
|
-
exports
|
|
680
|
+
exports.push(`${exportsName} as __moduleExports`);
|
|
3284
681
|
exportDeclarations.push(getDefaultExportDeclaration(exportsName, defaultIsModuleExports, HELPERS_NAME));
|
|
3285
682
|
}
|
|
3286
683
|
function getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) {
|
|
3287
684
|
return `export default ${defaultIsModuleExports === true ? exportedExportsName : defaultIsModuleExports === false ? `${exportedExportsName}.default` : `/*@__PURE__*/${HELPERS_NAME}.getDefaultExportFromCjs(${exportedExportsName})`}`;
|
|
3288
685
|
}
|
|
3289
|
-
function getExports(magicString, exports
|
|
686
|
+
function getExports(magicString, exports, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode) {
|
|
3290
687
|
let deconflictedDefaultExportName;
|
|
3291
688
|
for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, `${moduleName}.exports`);
|
|
3292
689
|
for (const [exportName, { nodes }] of exportsAssignmentsByName) {
|
|
@@ -3302,11 +699,11 @@ function getExports(magicString, exports$1, exportDeclarations, moduleExportsAss
|
|
|
3302
699
|
}
|
|
3303
700
|
if (needsDeclaration) magicString.prepend(`var ${deconflicted};\n`);
|
|
3304
701
|
if (exportName === "default") deconflictedDefaultExportName = deconflicted;
|
|
3305
|
-
else exports
|
|
702
|
+
else exports.push(exportName === deconflicted ? exportName : `${deconflicted} as ${exportName}`);
|
|
3306
703
|
}
|
|
3307
704
|
const isRestorableCompiledEsm = replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
|
|
3308
|
-
if (defaultIsModuleExports === false || defaultIsModuleExports === "auto" && isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports
|
|
3309
|
-
else if (defaultIsModuleExports === true || !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports
|
|
705
|
+
if (defaultIsModuleExports === false || defaultIsModuleExports === "auto" && isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports.push(`${deconflictedDefaultExportName || exportedExportsName} as default`);
|
|
706
|
+
else if (defaultIsModuleExports === true || !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports.push(`${exportedExportsName} as default`);
|
|
3310
707
|
else exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
|
|
3311
708
|
}
|
|
3312
709
|
function rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName) {
|
|
@@ -3370,7 +767,7 @@ function getRequireHandlers() {
|
|
|
3370
767
|
processRequireExpressions(imports, await resolveRequireSourcesAndUpdateMeta(id, needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule, commonjsMeta, Object.keys(requiresBySource).map((source) => {
|
|
3371
768
|
return {
|
|
3372
769
|
source,
|
|
3373
|
-
isConditional: requiresBySource[source].every((require
|
|
770
|
+
isConditional: requiresBySource[source].every((require) => require.isInsideConditional)
|
|
3374
771
|
};
|
|
3375
772
|
})), requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString);
|
|
3376
773
|
return imports.length ? `${imports.join(";\n")};\n\n` : "";
|
|
@@ -3856,4 +1253,4 @@ function commonjs(options = {}) {
|
|
|
3856
1253
|
}
|
|
3857
1254
|
|
|
3858
1255
|
//#endregion
|
|
3859
|
-
export {
|
|
1256
|
+
export { commonjs as t };
|