@awsless/cli 0.1.33 → 0.1.35
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/bin.js +453 -279
- package/dist/handlers/pubsub-publisher.js +1 -1
- package/dist/handlers/pubsub-server.js +4 -4
- package/dist/handlers/rolldown-worker.js +3765 -0
- package/dist/stack.json +1 -1
- package/dist/stack.stage.json +1 -1
- package/package.json +26 -26
|
@@ -0,0 +1,3765 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (canCache)
|
|
31
|
+
cache.set(mod, to);
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/constants.js
|
|
37
|
+
var require_constants = __commonJS(function(exports, module) {
|
|
38
|
+
var WIN_SLASH = "\\\\/";
|
|
39
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
40
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
41
|
+
var DOT_LITERAL = "\\.";
|
|
42
|
+
var PLUS_LITERAL = "\\+";
|
|
43
|
+
var QMARK_LITERAL = "\\?";
|
|
44
|
+
var SLASH_LITERAL = "\\/";
|
|
45
|
+
var ONE_CHAR = "(?=.)";
|
|
46
|
+
var QMARK = "[^/]";
|
|
47
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
48
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
49
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
50
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
51
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
52
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
53
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
54
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
55
|
+
var STAR = `${QMARK}*?`;
|
|
56
|
+
var SEP = "/";
|
|
57
|
+
var POSIX_CHARS = {
|
|
58
|
+
DOT_LITERAL,
|
|
59
|
+
PLUS_LITERAL,
|
|
60
|
+
QMARK_LITERAL,
|
|
61
|
+
SLASH_LITERAL,
|
|
62
|
+
ONE_CHAR,
|
|
63
|
+
QMARK,
|
|
64
|
+
END_ANCHOR,
|
|
65
|
+
DOTS_SLASH,
|
|
66
|
+
NO_DOT,
|
|
67
|
+
NO_DOTS,
|
|
68
|
+
NO_DOT_SLASH,
|
|
69
|
+
NO_DOTS_SLASH,
|
|
70
|
+
QMARK_NO_DOT,
|
|
71
|
+
STAR,
|
|
72
|
+
START_ANCHOR,
|
|
73
|
+
SEP
|
|
74
|
+
};
|
|
75
|
+
var WINDOWS_CHARS = {
|
|
76
|
+
...POSIX_CHARS,
|
|
77
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
78
|
+
QMARK: WIN_NO_SLASH,
|
|
79
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
80
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
81
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
82
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
83
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
84
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
85
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
86
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
87
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
88
|
+
SEP: "\\"
|
|
89
|
+
};
|
|
90
|
+
var POSIX_REGEX_SOURCE = {
|
|
91
|
+
__proto__: null,
|
|
92
|
+
alnum: "a-zA-Z0-9",
|
|
93
|
+
alpha: "a-zA-Z",
|
|
94
|
+
ascii: "\\x00-\\x7F",
|
|
95
|
+
blank: " \\t",
|
|
96
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
97
|
+
digit: "0-9",
|
|
98
|
+
graph: "\\x21-\\x7E",
|
|
99
|
+
lower: "a-z",
|
|
100
|
+
print: "\\x20-\\x7E ",
|
|
101
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
102
|
+
space: " \\t\\r\\n\\v\\f",
|
|
103
|
+
upper: "A-Z",
|
|
104
|
+
word: "A-Za-z0-9_",
|
|
105
|
+
xdigit: "A-Fa-f0-9"
|
|
106
|
+
};
|
|
107
|
+
module.exports = {
|
|
108
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
109
|
+
MAX_LENGTH: 1024 * 64,
|
|
110
|
+
POSIX_REGEX_SOURCE,
|
|
111
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
112
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
113
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
114
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
115
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
116
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
117
|
+
REPLACEMENTS: {
|
|
118
|
+
__proto__: null,
|
|
119
|
+
"***": "*",
|
|
120
|
+
"**/**": "**",
|
|
121
|
+
"**/**/**": "**"
|
|
122
|
+
},
|
|
123
|
+
CHAR_0: 48,
|
|
124
|
+
CHAR_9: 57,
|
|
125
|
+
CHAR_UPPERCASE_A: 65,
|
|
126
|
+
CHAR_LOWERCASE_A: 97,
|
|
127
|
+
CHAR_UPPERCASE_Z: 90,
|
|
128
|
+
CHAR_LOWERCASE_Z: 122,
|
|
129
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
130
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
131
|
+
CHAR_ASTERISK: 42,
|
|
132
|
+
CHAR_AMPERSAND: 38,
|
|
133
|
+
CHAR_AT: 64,
|
|
134
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
135
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
136
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
137
|
+
CHAR_COLON: 58,
|
|
138
|
+
CHAR_COMMA: 44,
|
|
139
|
+
CHAR_DOT: 46,
|
|
140
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
141
|
+
CHAR_EQUAL: 61,
|
|
142
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
143
|
+
CHAR_FORM_FEED: 12,
|
|
144
|
+
CHAR_FORWARD_SLASH: 47,
|
|
145
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
146
|
+
CHAR_HASH: 35,
|
|
147
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
148
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
149
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
150
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
151
|
+
CHAR_LINE_FEED: 10,
|
|
152
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
153
|
+
CHAR_PERCENT: 37,
|
|
154
|
+
CHAR_PLUS: 43,
|
|
155
|
+
CHAR_QUESTION_MARK: 63,
|
|
156
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
157
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
158
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
159
|
+
CHAR_SEMICOLON: 59,
|
|
160
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
161
|
+
CHAR_SPACE: 32,
|
|
162
|
+
CHAR_TAB: 9,
|
|
163
|
+
CHAR_UNDERSCORE: 95,
|
|
164
|
+
CHAR_VERTICAL_LINE: 124,
|
|
165
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
166
|
+
extglobChars(chars) {
|
|
167
|
+
return {
|
|
168
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
169
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
170
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
171
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
172
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
globChars(win32) {
|
|
176
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/utils.js
|
|
182
|
+
var require_utils = __commonJS(function(exports) {
|
|
183
|
+
var {
|
|
184
|
+
REGEX_BACKSLASH,
|
|
185
|
+
REGEX_REMOVE_BACKSLASH,
|
|
186
|
+
REGEX_SPECIAL_CHARS,
|
|
187
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
188
|
+
} = require_constants();
|
|
189
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
190
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
191
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
192
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
193
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
194
|
+
exports.isWindows = () => {
|
|
195
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
196
|
+
const platform = navigator.platform.toLowerCase();
|
|
197
|
+
return platform === "win32" || platform === "windows";
|
|
198
|
+
}
|
|
199
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
200
|
+
return process.platform === "win32";
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
};
|
|
204
|
+
exports.removeBackslashes = (str) => {
|
|
205
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match2) => {
|
|
206
|
+
return match2 === "\\" ? "" : match2;
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
210
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
211
|
+
if (idx === -1)
|
|
212
|
+
return input;
|
|
213
|
+
if (input[idx - 1] === "\\")
|
|
214
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
215
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
216
|
+
};
|
|
217
|
+
exports.removePrefix = (input, state = {}) => {
|
|
218
|
+
let output = input;
|
|
219
|
+
if (output.startsWith("./")) {
|
|
220
|
+
output = output.slice(2);
|
|
221
|
+
state.prefix = "./";
|
|
222
|
+
}
|
|
223
|
+
return output;
|
|
224
|
+
};
|
|
225
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
226
|
+
const prepend = options.contains ? "" : "^";
|
|
227
|
+
const append = options.contains ? "" : "$";
|
|
228
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
229
|
+
if (state.negated === true) {
|
|
230
|
+
output = `(?:^(?!${output}).*$)`;
|
|
231
|
+
}
|
|
232
|
+
return output;
|
|
233
|
+
};
|
|
234
|
+
exports.basename = (path2, { windows } = {}) => {
|
|
235
|
+
const segs = path2.split(windows ? /[\\/]/ : "/");
|
|
236
|
+
const last = segs[segs.length - 1];
|
|
237
|
+
if (last === "") {
|
|
238
|
+
return segs[segs.length - 2];
|
|
239
|
+
}
|
|
240
|
+
return last;
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/scan.js
|
|
245
|
+
var require_scan = __commonJS(function(exports, module) {
|
|
246
|
+
var utils = require_utils();
|
|
247
|
+
var {
|
|
248
|
+
CHAR_ASTERISK,
|
|
249
|
+
CHAR_AT,
|
|
250
|
+
CHAR_BACKWARD_SLASH,
|
|
251
|
+
CHAR_COMMA,
|
|
252
|
+
CHAR_DOT,
|
|
253
|
+
CHAR_EXCLAMATION_MARK,
|
|
254
|
+
CHAR_FORWARD_SLASH,
|
|
255
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
256
|
+
CHAR_LEFT_PARENTHESES,
|
|
257
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
258
|
+
CHAR_PLUS,
|
|
259
|
+
CHAR_QUESTION_MARK,
|
|
260
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
261
|
+
CHAR_RIGHT_PARENTHESES,
|
|
262
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
263
|
+
} = require_constants();
|
|
264
|
+
var isPathSeparator = (code) => {
|
|
265
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
266
|
+
};
|
|
267
|
+
var depth = (token) => {
|
|
268
|
+
if (token.isPrefix !== true) {
|
|
269
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var scan = (input, options) => {
|
|
273
|
+
const opts = options || {};
|
|
274
|
+
const length = input.length - 1;
|
|
275
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
276
|
+
const slashes = [];
|
|
277
|
+
const tokens = [];
|
|
278
|
+
const parts = [];
|
|
279
|
+
let str = input;
|
|
280
|
+
let index = -1;
|
|
281
|
+
let start = 0;
|
|
282
|
+
let lastIndex = 0;
|
|
283
|
+
let isBrace = false;
|
|
284
|
+
let isBracket = false;
|
|
285
|
+
let isGlob = false;
|
|
286
|
+
let isExtglob = false;
|
|
287
|
+
let isGlobstar = false;
|
|
288
|
+
let braceEscaped = false;
|
|
289
|
+
let backslashes = false;
|
|
290
|
+
let negated = false;
|
|
291
|
+
let negatedExtglob = false;
|
|
292
|
+
let finished = false;
|
|
293
|
+
let braces = 0;
|
|
294
|
+
let prev;
|
|
295
|
+
let code;
|
|
296
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
297
|
+
const eos = () => index >= length;
|
|
298
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
299
|
+
const advance = () => {
|
|
300
|
+
prev = code;
|
|
301
|
+
return str.charCodeAt(++index);
|
|
302
|
+
};
|
|
303
|
+
while (index < length) {
|
|
304
|
+
code = advance();
|
|
305
|
+
let next;
|
|
306
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
307
|
+
backslashes = token.backslashes = true;
|
|
308
|
+
code = advance();
|
|
309
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
310
|
+
braceEscaped = true;
|
|
311
|
+
}
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
315
|
+
braces++;
|
|
316
|
+
while (eos() !== true && (code = advance())) {
|
|
317
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
318
|
+
backslashes = token.backslashes = true;
|
|
319
|
+
advance();
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
323
|
+
braces++;
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
327
|
+
isBrace = token.isBrace = true;
|
|
328
|
+
isGlob = token.isGlob = true;
|
|
329
|
+
finished = true;
|
|
330
|
+
if (scanToEnd === true) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
336
|
+
isBrace = token.isBrace = true;
|
|
337
|
+
isGlob = token.isGlob = true;
|
|
338
|
+
finished = true;
|
|
339
|
+
if (scanToEnd === true) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
345
|
+
braces--;
|
|
346
|
+
if (braces === 0) {
|
|
347
|
+
braceEscaped = false;
|
|
348
|
+
isBrace = token.isBrace = true;
|
|
349
|
+
finished = true;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (scanToEnd === true) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
360
|
+
slashes.push(index);
|
|
361
|
+
tokens.push(token);
|
|
362
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
363
|
+
if (finished === true)
|
|
364
|
+
continue;
|
|
365
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
366
|
+
start += 2;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
lastIndex = index + 1;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (opts.noext !== true) {
|
|
373
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
374
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
375
|
+
isGlob = token.isGlob = true;
|
|
376
|
+
isExtglob = token.isExtglob = true;
|
|
377
|
+
finished = true;
|
|
378
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
379
|
+
negatedExtglob = true;
|
|
380
|
+
}
|
|
381
|
+
if (scanToEnd === true) {
|
|
382
|
+
while (eos() !== true && (code = advance())) {
|
|
383
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
384
|
+
backslashes = token.backslashes = true;
|
|
385
|
+
code = advance();
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
389
|
+
isGlob = token.isGlob = true;
|
|
390
|
+
finished = true;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (code === CHAR_ASTERISK) {
|
|
400
|
+
if (prev === CHAR_ASTERISK)
|
|
401
|
+
isGlobstar = token.isGlobstar = true;
|
|
402
|
+
isGlob = token.isGlob = true;
|
|
403
|
+
finished = true;
|
|
404
|
+
if (scanToEnd === true) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
410
|
+
isGlob = token.isGlob = true;
|
|
411
|
+
finished = true;
|
|
412
|
+
if (scanToEnd === true) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
418
|
+
while (eos() !== true && (next = advance())) {
|
|
419
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
420
|
+
backslashes = token.backslashes = true;
|
|
421
|
+
advance();
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
425
|
+
isBracket = token.isBracket = true;
|
|
426
|
+
isGlob = token.isGlob = true;
|
|
427
|
+
finished = true;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (scanToEnd === true) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
437
|
+
negated = token.negated = true;
|
|
438
|
+
start++;
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
442
|
+
isGlob = token.isGlob = true;
|
|
443
|
+
if (scanToEnd === true) {
|
|
444
|
+
while (eos() !== true && (code = advance())) {
|
|
445
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
446
|
+
backslashes = token.backslashes = true;
|
|
447
|
+
code = advance();
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
451
|
+
finished = true;
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
if (isGlob === true) {
|
|
460
|
+
finished = true;
|
|
461
|
+
if (scanToEnd === true) {
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (opts.noext === true) {
|
|
468
|
+
isExtglob = false;
|
|
469
|
+
isGlob = false;
|
|
470
|
+
}
|
|
471
|
+
let base = str;
|
|
472
|
+
let prefix = "";
|
|
473
|
+
let glob = "";
|
|
474
|
+
if (start > 0) {
|
|
475
|
+
prefix = str.slice(0, start);
|
|
476
|
+
str = str.slice(start);
|
|
477
|
+
lastIndex -= start;
|
|
478
|
+
}
|
|
479
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
480
|
+
base = str.slice(0, lastIndex);
|
|
481
|
+
glob = str.slice(lastIndex);
|
|
482
|
+
} else if (isGlob === true) {
|
|
483
|
+
base = "";
|
|
484
|
+
glob = str;
|
|
485
|
+
} else {
|
|
486
|
+
base = str;
|
|
487
|
+
}
|
|
488
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
489
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
490
|
+
base = base.slice(0, -1);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (opts.unescape === true) {
|
|
494
|
+
if (glob)
|
|
495
|
+
glob = utils.removeBackslashes(glob);
|
|
496
|
+
if (base && backslashes === true) {
|
|
497
|
+
base = utils.removeBackslashes(base);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const state = {
|
|
501
|
+
prefix,
|
|
502
|
+
input,
|
|
503
|
+
start,
|
|
504
|
+
base,
|
|
505
|
+
glob,
|
|
506
|
+
isBrace,
|
|
507
|
+
isBracket,
|
|
508
|
+
isGlob,
|
|
509
|
+
isExtglob,
|
|
510
|
+
isGlobstar,
|
|
511
|
+
negated,
|
|
512
|
+
negatedExtglob
|
|
513
|
+
};
|
|
514
|
+
if (opts.tokens === true) {
|
|
515
|
+
state.maxDepth = 0;
|
|
516
|
+
if (!isPathSeparator(code)) {
|
|
517
|
+
tokens.push(token);
|
|
518
|
+
}
|
|
519
|
+
state.tokens = tokens;
|
|
520
|
+
}
|
|
521
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
522
|
+
let prevIndex;
|
|
523
|
+
for (let idx = 0;idx < slashes.length; idx++) {
|
|
524
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
525
|
+
const i = slashes[idx];
|
|
526
|
+
const value = input.slice(n, i);
|
|
527
|
+
if (opts.tokens) {
|
|
528
|
+
if (idx === 0 && start !== 0) {
|
|
529
|
+
tokens[idx].isPrefix = true;
|
|
530
|
+
tokens[idx].value = prefix;
|
|
531
|
+
} else {
|
|
532
|
+
tokens[idx].value = value;
|
|
533
|
+
}
|
|
534
|
+
depth(tokens[idx]);
|
|
535
|
+
state.maxDepth += tokens[idx].depth;
|
|
536
|
+
}
|
|
537
|
+
if (idx !== 0 || value !== "") {
|
|
538
|
+
parts.push(value);
|
|
539
|
+
}
|
|
540
|
+
prevIndex = i;
|
|
541
|
+
}
|
|
542
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
543
|
+
const value = input.slice(prevIndex + 1);
|
|
544
|
+
parts.push(value);
|
|
545
|
+
if (opts.tokens) {
|
|
546
|
+
tokens[tokens.length - 1].value = value;
|
|
547
|
+
depth(tokens[tokens.length - 1]);
|
|
548
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
state.slashes = slashes;
|
|
552
|
+
state.parts = parts;
|
|
553
|
+
}
|
|
554
|
+
return state;
|
|
555
|
+
};
|
|
556
|
+
module.exports = scan;
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/parse.js
|
|
560
|
+
var require_parse = __commonJS(function(exports, module) {
|
|
561
|
+
var constants = require_constants();
|
|
562
|
+
var utils = require_utils();
|
|
563
|
+
var {
|
|
564
|
+
MAX_LENGTH,
|
|
565
|
+
POSIX_REGEX_SOURCE,
|
|
566
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
567
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
568
|
+
REPLACEMENTS
|
|
569
|
+
} = constants;
|
|
570
|
+
var expandRange = (args, options) => {
|
|
571
|
+
if (typeof options.expandRange === "function") {
|
|
572
|
+
return options.expandRange(...args, options);
|
|
573
|
+
}
|
|
574
|
+
args.sort();
|
|
575
|
+
const value = `[${args.join("-")}]`;
|
|
576
|
+
try {
|
|
577
|
+
new RegExp(value);
|
|
578
|
+
} catch (ex) {
|
|
579
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
580
|
+
}
|
|
581
|
+
return value;
|
|
582
|
+
};
|
|
583
|
+
var syntaxError = (type, char) => {
|
|
584
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
585
|
+
};
|
|
586
|
+
var splitTopLevel = (input) => {
|
|
587
|
+
const parts = [];
|
|
588
|
+
let bracket = 0;
|
|
589
|
+
let paren = 0;
|
|
590
|
+
let quote = 0;
|
|
591
|
+
let value = "";
|
|
592
|
+
let escaped = false;
|
|
593
|
+
for (const ch of input) {
|
|
594
|
+
if (escaped === true) {
|
|
595
|
+
value += ch;
|
|
596
|
+
escaped = false;
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
if (ch === "\\") {
|
|
600
|
+
value += ch;
|
|
601
|
+
escaped = true;
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (ch === '"') {
|
|
605
|
+
quote = quote === 1 ? 0 : 1;
|
|
606
|
+
value += ch;
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
if (quote === 0) {
|
|
610
|
+
if (ch === "[") {
|
|
611
|
+
bracket++;
|
|
612
|
+
} else if (ch === "]" && bracket > 0) {
|
|
613
|
+
bracket--;
|
|
614
|
+
} else if (bracket === 0) {
|
|
615
|
+
if (ch === "(") {
|
|
616
|
+
paren++;
|
|
617
|
+
} else if (ch === ")" && paren > 0) {
|
|
618
|
+
paren--;
|
|
619
|
+
} else if (ch === "|" && paren === 0) {
|
|
620
|
+
parts.push(value);
|
|
621
|
+
value = "";
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
value += ch;
|
|
627
|
+
}
|
|
628
|
+
parts.push(value);
|
|
629
|
+
return parts;
|
|
630
|
+
};
|
|
631
|
+
var isPlainBranch = (branch) => {
|
|
632
|
+
let escaped = false;
|
|
633
|
+
for (const ch of branch) {
|
|
634
|
+
if (escaped === true) {
|
|
635
|
+
escaped = false;
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (ch === "\\") {
|
|
639
|
+
escaped = true;
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return true;
|
|
647
|
+
};
|
|
648
|
+
var normalizeSimpleBranch = (branch) => {
|
|
649
|
+
let value = branch.trim();
|
|
650
|
+
let changed = true;
|
|
651
|
+
while (changed === true) {
|
|
652
|
+
changed = false;
|
|
653
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
654
|
+
value = value.slice(2, -1);
|
|
655
|
+
changed = true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (!isPlainBranch(value)) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
return value.replace(/\\(.)/g, "$1");
|
|
662
|
+
};
|
|
663
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
664
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
665
|
+
for (let i = 0;i < values.length; i++) {
|
|
666
|
+
for (let j = i + 1;j < values.length; j++) {
|
|
667
|
+
const a = values[i];
|
|
668
|
+
const b = values[j];
|
|
669
|
+
const char = a[0];
|
|
670
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return false;
|
|
679
|
+
};
|
|
680
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
681
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
let bracket = 0;
|
|
685
|
+
let paren = 0;
|
|
686
|
+
let quote = 0;
|
|
687
|
+
let escaped = false;
|
|
688
|
+
for (let i = 1;i < pattern.length; i++) {
|
|
689
|
+
const ch = pattern[i];
|
|
690
|
+
if (escaped === true) {
|
|
691
|
+
escaped = false;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (ch === "\\") {
|
|
695
|
+
escaped = true;
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (ch === '"') {
|
|
699
|
+
quote = quote === 1 ? 0 : 1;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if (quote === 1) {
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (ch === "[") {
|
|
706
|
+
bracket++;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (ch === "]" && bracket > 0) {
|
|
710
|
+
bracket--;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (bracket > 0) {
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (ch === "(") {
|
|
717
|
+
paren++;
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (ch === ")") {
|
|
721
|
+
paren--;
|
|
722
|
+
if (paren === 0) {
|
|
723
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
return {
|
|
727
|
+
type: pattern[0],
|
|
728
|
+
body: pattern.slice(2, i),
|
|
729
|
+
end: i
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
var buildCharClassStar = (chars) => {
|
|
736
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
737
|
+
return `${source}*`;
|
|
738
|
+
};
|
|
739
|
+
var getStarExtglobSequenceChars = (pattern) => {
|
|
740
|
+
let index = 0;
|
|
741
|
+
const chars = [];
|
|
742
|
+
while (index < pattern.length) {
|
|
743
|
+
const match2 = parseRepeatedExtglob(pattern.slice(index), false);
|
|
744
|
+
if (!match2 || match2.type !== "*") {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const branches = splitTopLevel(match2.body).map((branch2) => branch2.trim());
|
|
748
|
+
if (branches.length !== 1) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
752
|
+
if (!branch || branch.length !== 1) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
chars.push(branch);
|
|
756
|
+
index += match2.end + 1;
|
|
757
|
+
}
|
|
758
|
+
if (chars.length < 1) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
return chars;
|
|
762
|
+
};
|
|
763
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
764
|
+
let depth = 0;
|
|
765
|
+
let value = pattern.trim();
|
|
766
|
+
let match2 = parseRepeatedExtglob(value);
|
|
767
|
+
while (match2) {
|
|
768
|
+
depth++;
|
|
769
|
+
value = match2.body.trim();
|
|
770
|
+
match2 = parseRepeatedExtglob(value);
|
|
771
|
+
}
|
|
772
|
+
return depth;
|
|
773
|
+
};
|
|
774
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
775
|
+
if (options.maxExtglobRecursion === false) {
|
|
776
|
+
return { risky: false };
|
|
777
|
+
}
|
|
778
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
779
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
780
|
+
if (branches.length > 1) {
|
|
781
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
782
|
+
return { risky: true };
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
const safeChars = [];
|
|
786
|
+
let sawStarSequence = false;
|
|
787
|
+
let combinable = true;
|
|
788
|
+
for (const branch of branches) {
|
|
789
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
790
|
+
if (chars) {
|
|
791
|
+
sawStarSequence = true;
|
|
792
|
+
safeChars.push(...chars);
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
const literal = normalizeSimpleBranch(branch);
|
|
796
|
+
if (literal && literal.length === 1) {
|
|
797
|
+
safeChars.push(literal);
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
combinable = false;
|
|
801
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
802
|
+
return { risky: true };
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (sawStarSequence) {
|
|
806
|
+
return combinable ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) } : { risky: true };
|
|
807
|
+
}
|
|
808
|
+
return { risky: false };
|
|
809
|
+
};
|
|
810
|
+
var parse = (input, options) => {
|
|
811
|
+
if (typeof input !== "string") {
|
|
812
|
+
throw new TypeError("Expected a string");
|
|
813
|
+
}
|
|
814
|
+
input = REPLACEMENTS[input] || input;
|
|
815
|
+
const opts = { ...options };
|
|
816
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
817
|
+
let len = input.length;
|
|
818
|
+
if (len > max) {
|
|
819
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
820
|
+
}
|
|
821
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
822
|
+
const tokens = [bos];
|
|
823
|
+
const capture = opts.capture ? "" : "?:";
|
|
824
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
825
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
826
|
+
const {
|
|
827
|
+
DOT_LITERAL,
|
|
828
|
+
PLUS_LITERAL,
|
|
829
|
+
SLASH_LITERAL,
|
|
830
|
+
ONE_CHAR,
|
|
831
|
+
DOTS_SLASH,
|
|
832
|
+
NO_DOT,
|
|
833
|
+
NO_DOT_SLASH,
|
|
834
|
+
NO_DOTS_SLASH,
|
|
835
|
+
QMARK,
|
|
836
|
+
QMARK_NO_DOT,
|
|
837
|
+
STAR,
|
|
838
|
+
START_ANCHOR
|
|
839
|
+
} = PLATFORM_CHARS;
|
|
840
|
+
const globstar = (opts2) => {
|
|
841
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
842
|
+
};
|
|
843
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
844
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
845
|
+
let star3 = opts.bash === true ? globstar(opts) : STAR;
|
|
846
|
+
if (opts.capture) {
|
|
847
|
+
star3 = `(${star3})`;
|
|
848
|
+
}
|
|
849
|
+
if (typeof opts.noext === "boolean") {
|
|
850
|
+
opts.noextglob = opts.noext;
|
|
851
|
+
}
|
|
852
|
+
const state = {
|
|
853
|
+
input,
|
|
854
|
+
index: -1,
|
|
855
|
+
start: 0,
|
|
856
|
+
dot: opts.dot === true,
|
|
857
|
+
consumed: "",
|
|
858
|
+
output: "",
|
|
859
|
+
prefix: "",
|
|
860
|
+
backtrack: false,
|
|
861
|
+
negated: false,
|
|
862
|
+
brackets: 0,
|
|
863
|
+
braces: 0,
|
|
864
|
+
parens: 0,
|
|
865
|
+
quotes: 0,
|
|
866
|
+
globstar: false,
|
|
867
|
+
tokens
|
|
868
|
+
};
|
|
869
|
+
input = utils.removePrefix(input, state);
|
|
870
|
+
len = input.length;
|
|
871
|
+
const extglobs = [];
|
|
872
|
+
const braces = [];
|
|
873
|
+
const stack = [];
|
|
874
|
+
let prev = bos;
|
|
875
|
+
let value;
|
|
876
|
+
const eos = () => state.index === len - 1;
|
|
877
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
878
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
879
|
+
const remaining = () => input.slice(state.index + 1);
|
|
880
|
+
const consume = (value2 = "", num = 0) => {
|
|
881
|
+
state.consumed += value2;
|
|
882
|
+
state.index += num;
|
|
883
|
+
};
|
|
884
|
+
const append = (token) => {
|
|
885
|
+
state.output += token.output != null ? token.output : token.value;
|
|
886
|
+
consume(token.value);
|
|
887
|
+
};
|
|
888
|
+
const negate = () => {
|
|
889
|
+
let count = 1;
|
|
890
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
891
|
+
advance();
|
|
892
|
+
state.start++;
|
|
893
|
+
count++;
|
|
894
|
+
}
|
|
895
|
+
if (count % 2 === 0) {
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
state.negated = true;
|
|
899
|
+
state.start++;
|
|
900
|
+
return true;
|
|
901
|
+
};
|
|
902
|
+
const increment = (type) => {
|
|
903
|
+
state[type]++;
|
|
904
|
+
stack.push(type);
|
|
905
|
+
};
|
|
906
|
+
const decrement = (type) => {
|
|
907
|
+
state[type]--;
|
|
908
|
+
stack.pop();
|
|
909
|
+
};
|
|
910
|
+
const push = (tok) => {
|
|
911
|
+
if (prev.type === "globstar") {
|
|
912
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
913
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
914
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
915
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
916
|
+
prev.type = "star";
|
|
917
|
+
prev.value = "*";
|
|
918
|
+
prev.output = star3;
|
|
919
|
+
state.output += prev.output;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
923
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
924
|
+
}
|
|
925
|
+
if (tok.value || tok.output)
|
|
926
|
+
append(tok);
|
|
927
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
928
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
929
|
+
prev.value += tok.value;
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
tok.prev = prev;
|
|
933
|
+
tokens.push(tok);
|
|
934
|
+
prev = tok;
|
|
935
|
+
};
|
|
936
|
+
const extglobOpen = (type, value2) => {
|
|
937
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
938
|
+
token.prev = prev;
|
|
939
|
+
token.parens = state.parens;
|
|
940
|
+
token.output = state.output;
|
|
941
|
+
token.startIndex = state.index;
|
|
942
|
+
token.tokensIndex = tokens.length;
|
|
943
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
944
|
+
increment("parens");
|
|
945
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
946
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
947
|
+
extglobs.push(token);
|
|
948
|
+
};
|
|
949
|
+
const extglobClose = (token) => {
|
|
950
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
951
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
952
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
953
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
954
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
955
|
+
const open = tokens[token.tokensIndex];
|
|
956
|
+
open.type = "text";
|
|
957
|
+
open.value = literal;
|
|
958
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
959
|
+
for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
|
|
960
|
+
tokens[i].value = "";
|
|
961
|
+
tokens[i].output = "";
|
|
962
|
+
delete tokens[i].suffix;
|
|
963
|
+
}
|
|
964
|
+
state.output = token.output + open.output;
|
|
965
|
+
state.backtrack = true;
|
|
966
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
967
|
+
decrement("parens");
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
971
|
+
let rest;
|
|
972
|
+
if (token.type === "negate") {
|
|
973
|
+
let extglobStar = star3;
|
|
974
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
975
|
+
extglobStar = globstar(opts);
|
|
976
|
+
}
|
|
977
|
+
if (extglobStar !== star3 || eos() || /^\)+$/.test(remaining())) {
|
|
978
|
+
output = token.close = `)$))${extglobStar}`;
|
|
979
|
+
}
|
|
980
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
981
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
982
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
983
|
+
}
|
|
984
|
+
if (token.prev.type === "bos") {
|
|
985
|
+
state.negatedExtglob = true;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
push({ type: "paren", extglob: true, value, output });
|
|
989
|
+
decrement("parens");
|
|
990
|
+
};
|
|
991
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
992
|
+
let backslashes = false;
|
|
993
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
994
|
+
if (first === "\\") {
|
|
995
|
+
backslashes = true;
|
|
996
|
+
return m;
|
|
997
|
+
}
|
|
998
|
+
if (first === "?") {
|
|
999
|
+
if (esc) {
|
|
1000
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1001
|
+
}
|
|
1002
|
+
if (index === 0) {
|
|
1003
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1004
|
+
}
|
|
1005
|
+
return QMARK.repeat(chars.length);
|
|
1006
|
+
}
|
|
1007
|
+
if (first === ".") {
|
|
1008
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
1009
|
+
}
|
|
1010
|
+
if (first === "*") {
|
|
1011
|
+
if (esc) {
|
|
1012
|
+
return esc + first + (rest ? star3 : "");
|
|
1013
|
+
}
|
|
1014
|
+
return star3;
|
|
1015
|
+
}
|
|
1016
|
+
return esc ? m : `\\${m}`;
|
|
1017
|
+
});
|
|
1018
|
+
if (backslashes === true) {
|
|
1019
|
+
if (opts.unescape === true) {
|
|
1020
|
+
output = output.replace(/\\/g, "");
|
|
1021
|
+
} else {
|
|
1022
|
+
output = output.replace(/\\+/g, (m) => {
|
|
1023
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
if (output === input && opts.contains === true) {
|
|
1028
|
+
state.output = input;
|
|
1029
|
+
return state;
|
|
1030
|
+
}
|
|
1031
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1032
|
+
return state;
|
|
1033
|
+
}
|
|
1034
|
+
while (!eos()) {
|
|
1035
|
+
value = advance();
|
|
1036
|
+
if (value === "\x00") {
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
if (value === "\\") {
|
|
1040
|
+
const next = peek();
|
|
1041
|
+
if (next === "/" && opts.bash !== true) {
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
if (next === "." || next === ";") {
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
if (!next) {
|
|
1048
|
+
value += "\\";
|
|
1049
|
+
push({ type: "text", value });
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
1052
|
+
const match2 = /^\\+/.exec(remaining());
|
|
1053
|
+
let slashes = 0;
|
|
1054
|
+
if (match2 && match2[0].length > 2) {
|
|
1055
|
+
slashes = match2[0].length;
|
|
1056
|
+
state.index += slashes;
|
|
1057
|
+
if (slashes % 2 !== 0) {
|
|
1058
|
+
value += "\\";
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
if (opts.unescape === true) {
|
|
1062
|
+
value = advance();
|
|
1063
|
+
} else {
|
|
1064
|
+
value += advance();
|
|
1065
|
+
}
|
|
1066
|
+
if (state.brackets === 0) {
|
|
1067
|
+
push({ type: "text", value });
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1072
|
+
if (opts.posix !== false && value === ":") {
|
|
1073
|
+
const inner = prev.value.slice(1);
|
|
1074
|
+
if (inner.includes("[")) {
|
|
1075
|
+
prev.posix = true;
|
|
1076
|
+
if (inner.includes(":")) {
|
|
1077
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1078
|
+
const pre = prev.value.slice(0, idx);
|
|
1079
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
1080
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1081
|
+
if (posix) {
|
|
1082
|
+
prev.value = pre + posix;
|
|
1083
|
+
state.backtrack = true;
|
|
1084
|
+
advance();
|
|
1085
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1086
|
+
bos.output = ONE_CHAR;
|
|
1087
|
+
}
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1094
|
+
value = `\\${value}`;
|
|
1095
|
+
}
|
|
1096
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1097
|
+
value = `\\${value}`;
|
|
1098
|
+
}
|
|
1099
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1100
|
+
value = "^";
|
|
1101
|
+
}
|
|
1102
|
+
prev.value += value;
|
|
1103
|
+
append({ value });
|
|
1104
|
+
continue;
|
|
1105
|
+
}
|
|
1106
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1107
|
+
value = utils.escapeRegex(value);
|
|
1108
|
+
prev.value += value;
|
|
1109
|
+
append({ value });
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
if (value === '"') {
|
|
1113
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1114
|
+
if (opts.keepQuotes === true) {
|
|
1115
|
+
push({ type: "text", value });
|
|
1116
|
+
}
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
if (value === "(") {
|
|
1120
|
+
increment("parens");
|
|
1121
|
+
push({ type: "paren", value });
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
if (value === ")") {
|
|
1125
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1126
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1127
|
+
}
|
|
1128
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1129
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1130
|
+
extglobClose(extglobs.pop());
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1134
|
+
decrement("parens");
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1137
|
+
if (value === "[") {
|
|
1138
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1139
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1140
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1141
|
+
}
|
|
1142
|
+
value = `\\${value}`;
|
|
1143
|
+
} else {
|
|
1144
|
+
increment("brackets");
|
|
1145
|
+
}
|
|
1146
|
+
push({ type: "bracket", value });
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
if (value === "]") {
|
|
1150
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1151
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if (state.brackets === 0) {
|
|
1155
|
+
if (opts.strictBrackets === true) {
|
|
1156
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1157
|
+
}
|
|
1158
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
decrement("brackets");
|
|
1162
|
+
const prevValue = prev.value.slice(1);
|
|
1163
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1164
|
+
value = `/${value}`;
|
|
1165
|
+
}
|
|
1166
|
+
prev.value += value;
|
|
1167
|
+
append({ value });
|
|
1168
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1172
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1173
|
+
if (opts.literalBrackets === true) {
|
|
1174
|
+
state.output += escaped;
|
|
1175
|
+
prev.value = escaped;
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1179
|
+
state.output += prev.value;
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1183
|
+
increment("braces");
|
|
1184
|
+
const open = {
|
|
1185
|
+
type: "brace",
|
|
1186
|
+
value,
|
|
1187
|
+
output: "(",
|
|
1188
|
+
outputIndex: state.output.length,
|
|
1189
|
+
tokensIndex: state.tokens.length
|
|
1190
|
+
};
|
|
1191
|
+
braces.push(open);
|
|
1192
|
+
push(open);
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
if (value === "}") {
|
|
1196
|
+
const brace = braces[braces.length - 1];
|
|
1197
|
+
if (opts.nobrace === true || !brace) {
|
|
1198
|
+
push({ type: "text", value, output: value });
|
|
1199
|
+
continue;
|
|
1200
|
+
}
|
|
1201
|
+
let output = ")";
|
|
1202
|
+
if (brace.dots === true) {
|
|
1203
|
+
const arr = tokens.slice();
|
|
1204
|
+
const range2 = [];
|
|
1205
|
+
for (let i = arr.length - 1;i >= 0; i--) {
|
|
1206
|
+
tokens.pop();
|
|
1207
|
+
if (arr[i].type === "brace") {
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
if (arr[i].type !== "dots") {
|
|
1211
|
+
range2.unshift(arr[i].value);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
output = expandRange(range2, opts);
|
|
1215
|
+
state.backtrack = true;
|
|
1216
|
+
}
|
|
1217
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1218
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1219
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1220
|
+
brace.value = brace.output = "\\{";
|
|
1221
|
+
value = output = "\\}";
|
|
1222
|
+
state.output = out;
|
|
1223
|
+
for (const t of toks) {
|
|
1224
|
+
state.output += t.output || t.value;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
push({ type: "brace", value, output });
|
|
1228
|
+
decrement("braces");
|
|
1229
|
+
braces.pop();
|
|
1230
|
+
continue;
|
|
1231
|
+
}
|
|
1232
|
+
if (value === "|") {
|
|
1233
|
+
if (extglobs.length > 0) {
|
|
1234
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1235
|
+
}
|
|
1236
|
+
push({ type: "text", value });
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
if (value === ",") {
|
|
1240
|
+
let output = value;
|
|
1241
|
+
const brace = braces[braces.length - 1];
|
|
1242
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1243
|
+
brace.comma = true;
|
|
1244
|
+
output = "|";
|
|
1245
|
+
}
|
|
1246
|
+
push({ type: "comma", value, output });
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
if (value === "/") {
|
|
1250
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1251
|
+
state.start = state.index + 1;
|
|
1252
|
+
state.consumed = "";
|
|
1253
|
+
state.output = "";
|
|
1254
|
+
tokens.pop();
|
|
1255
|
+
prev = bos;
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
if (value === ".") {
|
|
1262
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1263
|
+
if (prev.value === ".")
|
|
1264
|
+
prev.output = DOT_LITERAL;
|
|
1265
|
+
const brace = braces[braces.length - 1];
|
|
1266
|
+
prev.type = "dots";
|
|
1267
|
+
prev.output += value;
|
|
1268
|
+
prev.value += value;
|
|
1269
|
+
brace.dots = true;
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1273
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
if (value === "?") {
|
|
1280
|
+
const isGroup = prev && prev.value === "(";
|
|
1281
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1282
|
+
extglobOpen("qmark", value);
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
if (prev && prev.type === "paren") {
|
|
1286
|
+
const next = peek();
|
|
1287
|
+
let output = value;
|
|
1288
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1289
|
+
output = `\\${value}`;
|
|
1290
|
+
}
|
|
1291
|
+
push({ type: "text", value, output });
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1295
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
if (value === "!") {
|
|
1302
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1303
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1304
|
+
extglobOpen("negate", value);
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1309
|
+
negate();
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (value === "+") {
|
|
1314
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1315
|
+
extglobOpen("plus", value);
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1319
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1323
|
+
push({ type: "plus", value });
|
|
1324
|
+
continue;
|
|
1325
|
+
}
|
|
1326
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1327
|
+
continue;
|
|
1328
|
+
}
|
|
1329
|
+
if (value === "@") {
|
|
1330
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1331
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
push({ type: "text", value });
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (value !== "*") {
|
|
1338
|
+
if (value === "$" || value === "^") {
|
|
1339
|
+
value = `\\${value}`;
|
|
1340
|
+
}
|
|
1341
|
+
const match2 = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1342
|
+
if (match2) {
|
|
1343
|
+
value += match2[0];
|
|
1344
|
+
state.index += match2[0].length;
|
|
1345
|
+
}
|
|
1346
|
+
push({ type: "text", value });
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1350
|
+
prev.type = "star";
|
|
1351
|
+
prev.star = true;
|
|
1352
|
+
prev.value += value;
|
|
1353
|
+
prev.output = star3;
|
|
1354
|
+
state.backtrack = true;
|
|
1355
|
+
state.globstar = true;
|
|
1356
|
+
consume(value);
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
let rest = remaining();
|
|
1360
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1361
|
+
extglobOpen("star", value);
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
if (prev.type === "star") {
|
|
1365
|
+
if (opts.noglobstar === true) {
|
|
1366
|
+
consume(value);
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
const prior = prev.prev;
|
|
1370
|
+
const before = prior.prev;
|
|
1371
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1372
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1373
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1374
|
+
push({ type: "star", value, output: "" });
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1378
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1379
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1380
|
+
push({ type: "star", value, output: "" });
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1384
|
+
const after = input[state.index + 4];
|
|
1385
|
+
if (after && after !== "/") {
|
|
1386
|
+
break;
|
|
1387
|
+
}
|
|
1388
|
+
rest = rest.slice(3);
|
|
1389
|
+
consume("/**", 3);
|
|
1390
|
+
}
|
|
1391
|
+
if (prior.type === "bos" && eos()) {
|
|
1392
|
+
prev.type = "globstar";
|
|
1393
|
+
prev.value += value;
|
|
1394
|
+
prev.output = globstar(opts);
|
|
1395
|
+
state.output = prev.output;
|
|
1396
|
+
state.globstar = true;
|
|
1397
|
+
consume(value);
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1401
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1402
|
+
prior.output = `(?:${prior.output}`;
|
|
1403
|
+
prev.type = "globstar";
|
|
1404
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1405
|
+
prev.value += value;
|
|
1406
|
+
state.globstar = true;
|
|
1407
|
+
state.output += prior.output + prev.output;
|
|
1408
|
+
consume(value);
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1412
|
+
const end = rest[1] !== undefined ? "|$" : "";
|
|
1413
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1414
|
+
prior.output = `(?:${prior.output}`;
|
|
1415
|
+
prev.type = "globstar";
|
|
1416
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1417
|
+
prev.value += value;
|
|
1418
|
+
state.output += prior.output + prev.output;
|
|
1419
|
+
state.globstar = true;
|
|
1420
|
+
consume(value + advance());
|
|
1421
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1425
|
+
prev.type = "globstar";
|
|
1426
|
+
prev.value += value;
|
|
1427
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1428
|
+
state.output = prev.output;
|
|
1429
|
+
state.globstar = true;
|
|
1430
|
+
consume(value + advance());
|
|
1431
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1435
|
+
prev.type = "globstar";
|
|
1436
|
+
prev.output = globstar(opts);
|
|
1437
|
+
prev.value += value;
|
|
1438
|
+
state.output += prev.output;
|
|
1439
|
+
state.globstar = true;
|
|
1440
|
+
consume(value);
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
const token = { type: "star", value, output: star3 };
|
|
1444
|
+
if (opts.bash === true) {
|
|
1445
|
+
token.output = ".*?";
|
|
1446
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1447
|
+
token.output = nodot + token.output;
|
|
1448
|
+
}
|
|
1449
|
+
push(token);
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1453
|
+
token.output = value;
|
|
1454
|
+
push(token);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1458
|
+
if (prev.type === "dot") {
|
|
1459
|
+
state.output += NO_DOT_SLASH;
|
|
1460
|
+
prev.output += NO_DOT_SLASH;
|
|
1461
|
+
} else if (opts.dot === true) {
|
|
1462
|
+
state.output += NO_DOTS_SLASH;
|
|
1463
|
+
prev.output += NO_DOTS_SLASH;
|
|
1464
|
+
} else {
|
|
1465
|
+
state.output += nodot;
|
|
1466
|
+
prev.output += nodot;
|
|
1467
|
+
}
|
|
1468
|
+
if (peek() !== "*") {
|
|
1469
|
+
state.output += ONE_CHAR;
|
|
1470
|
+
prev.output += ONE_CHAR;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
push(token);
|
|
1474
|
+
}
|
|
1475
|
+
while (state.brackets > 0) {
|
|
1476
|
+
if (opts.strictBrackets === true)
|
|
1477
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1478
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1479
|
+
decrement("brackets");
|
|
1480
|
+
}
|
|
1481
|
+
while (state.parens > 0) {
|
|
1482
|
+
if (opts.strictBrackets === true)
|
|
1483
|
+
throw new SyntaxError(syntaxError("closing", ")"));
|
|
1484
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1485
|
+
decrement("parens");
|
|
1486
|
+
}
|
|
1487
|
+
while (state.braces > 0) {
|
|
1488
|
+
if (opts.strictBrackets === true)
|
|
1489
|
+
throw new SyntaxError(syntaxError("closing", "}"));
|
|
1490
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1491
|
+
decrement("braces");
|
|
1492
|
+
}
|
|
1493
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1494
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1495
|
+
}
|
|
1496
|
+
if (state.backtrack === true) {
|
|
1497
|
+
state.output = "";
|
|
1498
|
+
for (const token of state.tokens) {
|
|
1499
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1500
|
+
if (token.suffix) {
|
|
1501
|
+
state.output += token.suffix;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return state;
|
|
1506
|
+
};
|
|
1507
|
+
parse.fastpaths = (input, options) => {
|
|
1508
|
+
const opts = { ...options };
|
|
1509
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1510
|
+
const len = input.length;
|
|
1511
|
+
if (len > max) {
|
|
1512
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1513
|
+
}
|
|
1514
|
+
input = REPLACEMENTS[input] || input;
|
|
1515
|
+
const {
|
|
1516
|
+
DOT_LITERAL,
|
|
1517
|
+
SLASH_LITERAL,
|
|
1518
|
+
ONE_CHAR,
|
|
1519
|
+
DOTS_SLASH,
|
|
1520
|
+
NO_DOT,
|
|
1521
|
+
NO_DOTS,
|
|
1522
|
+
NO_DOTS_SLASH,
|
|
1523
|
+
STAR,
|
|
1524
|
+
START_ANCHOR
|
|
1525
|
+
} = constants.globChars(opts.windows);
|
|
1526
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1527
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1528
|
+
const capture = opts.capture ? "" : "?:";
|
|
1529
|
+
const state = { negated: false, prefix: "" };
|
|
1530
|
+
let star3 = opts.bash === true ? ".*?" : STAR;
|
|
1531
|
+
if (opts.capture) {
|
|
1532
|
+
star3 = `(${star3})`;
|
|
1533
|
+
}
|
|
1534
|
+
const globstar = (opts2) => {
|
|
1535
|
+
if (opts2.noglobstar === true)
|
|
1536
|
+
return star3;
|
|
1537
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1538
|
+
};
|
|
1539
|
+
const create = (str) => {
|
|
1540
|
+
switch (str) {
|
|
1541
|
+
case "*":
|
|
1542
|
+
return `${nodot}${ONE_CHAR}${star3}`;
|
|
1543
|
+
case ".*":
|
|
1544
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star3}`;
|
|
1545
|
+
case "*.*":
|
|
1546
|
+
return `${nodot}${star3}${DOT_LITERAL}${ONE_CHAR}${star3}`;
|
|
1547
|
+
case "*/*":
|
|
1548
|
+
return `${nodot}${star3}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star3}`;
|
|
1549
|
+
case "**":
|
|
1550
|
+
return nodot + globstar(opts);
|
|
1551
|
+
case "**/*":
|
|
1552
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star3}`;
|
|
1553
|
+
case "**/*.*":
|
|
1554
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star3}${DOT_LITERAL}${ONE_CHAR}${star3}`;
|
|
1555
|
+
case "**/.*":
|
|
1556
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star3}`;
|
|
1557
|
+
default: {
|
|
1558
|
+
const match2 = /^(.*?)\.(\w+)$/.exec(str);
|
|
1559
|
+
if (!match2)
|
|
1560
|
+
return;
|
|
1561
|
+
const source2 = create(match2[1]);
|
|
1562
|
+
if (!source2)
|
|
1563
|
+
return;
|
|
1564
|
+
return source2 + DOT_LITERAL + match2[2];
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
const output = utils.removePrefix(input, state);
|
|
1569
|
+
let source = create(output);
|
|
1570
|
+
if (source && opts.strictSlashes !== true) {
|
|
1571
|
+
source += `${SLASH_LITERAL}?`;
|
|
1572
|
+
}
|
|
1573
|
+
return source;
|
|
1574
|
+
};
|
|
1575
|
+
module.exports = parse;
|
|
1576
|
+
});
|
|
1577
|
+
|
|
1578
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/picomatch.js
|
|
1579
|
+
var require_picomatch = __commonJS(function(exports, module) {
|
|
1580
|
+
var scan = require_scan();
|
|
1581
|
+
var parse = require_parse();
|
|
1582
|
+
var utils = require_utils();
|
|
1583
|
+
var constants = require_constants();
|
|
1584
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1585
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
1586
|
+
if (Array.isArray(glob)) {
|
|
1587
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1588
|
+
const arrayMatcher = (str) => {
|
|
1589
|
+
for (const isMatch of fns) {
|
|
1590
|
+
const state2 = isMatch(str);
|
|
1591
|
+
if (state2)
|
|
1592
|
+
return state2;
|
|
1593
|
+
}
|
|
1594
|
+
return false;
|
|
1595
|
+
};
|
|
1596
|
+
return arrayMatcher;
|
|
1597
|
+
}
|
|
1598
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1599
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1600
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1601
|
+
}
|
|
1602
|
+
const opts = options || {};
|
|
1603
|
+
const posix = opts.windows;
|
|
1604
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1605
|
+
const state = regex.state;
|
|
1606
|
+
delete regex.state;
|
|
1607
|
+
let isIgnored = () => false;
|
|
1608
|
+
if (opts.ignore) {
|
|
1609
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1610
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1611
|
+
}
|
|
1612
|
+
const matcher = (input, returnObject = false) => {
|
|
1613
|
+
const { isMatch, match: match2, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
1614
|
+
const result = { glob, state, regex, posix, input, output, match: match2, isMatch };
|
|
1615
|
+
if (typeof opts.onResult === "function") {
|
|
1616
|
+
opts.onResult(result);
|
|
1617
|
+
}
|
|
1618
|
+
if (isMatch === false) {
|
|
1619
|
+
result.isMatch = false;
|
|
1620
|
+
return returnObject ? result : false;
|
|
1621
|
+
}
|
|
1622
|
+
if (isIgnored(input)) {
|
|
1623
|
+
if (typeof opts.onIgnore === "function") {
|
|
1624
|
+
opts.onIgnore(result);
|
|
1625
|
+
}
|
|
1626
|
+
result.isMatch = false;
|
|
1627
|
+
return returnObject ? result : false;
|
|
1628
|
+
}
|
|
1629
|
+
if (typeof opts.onMatch === "function") {
|
|
1630
|
+
opts.onMatch(result);
|
|
1631
|
+
}
|
|
1632
|
+
return returnObject ? result : true;
|
|
1633
|
+
};
|
|
1634
|
+
if (returnState) {
|
|
1635
|
+
matcher.state = state;
|
|
1636
|
+
}
|
|
1637
|
+
return matcher;
|
|
1638
|
+
};
|
|
1639
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1640
|
+
if (typeof input !== "string") {
|
|
1641
|
+
throw new TypeError("Expected input to be a string");
|
|
1642
|
+
}
|
|
1643
|
+
if (input === "") {
|
|
1644
|
+
return { isMatch: false, output: "" };
|
|
1645
|
+
}
|
|
1646
|
+
const opts = options || {};
|
|
1647
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1648
|
+
let match2 = input === glob;
|
|
1649
|
+
let output = match2 && format ? format(input) : input;
|
|
1650
|
+
if (match2 === false) {
|
|
1651
|
+
output = format ? format(input) : input;
|
|
1652
|
+
match2 = output === glob;
|
|
1653
|
+
}
|
|
1654
|
+
if (match2 === false || opts.capture === true) {
|
|
1655
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1656
|
+
match2 = picomatch.matchBase(input, regex, options, posix);
|
|
1657
|
+
} else {
|
|
1658
|
+
match2 = regex.exec(output);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
return { isMatch: Boolean(match2), match: match2, output };
|
|
1662
|
+
};
|
|
1663
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
1664
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1665
|
+
return regex.test(utils.basename(input, { windows: posix }));
|
|
1666
|
+
};
|
|
1667
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1668
|
+
picomatch.parse = (pattern, options) => {
|
|
1669
|
+
if (Array.isArray(pattern))
|
|
1670
|
+
return pattern.map((p) => picomatch.parse(p, options));
|
|
1671
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
1672
|
+
};
|
|
1673
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
1674
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1675
|
+
if (returnOutput === true) {
|
|
1676
|
+
return state.output;
|
|
1677
|
+
}
|
|
1678
|
+
const opts = options || {};
|
|
1679
|
+
const prepend = opts.contains ? "" : "^";
|
|
1680
|
+
const append = opts.contains ? "" : "$";
|
|
1681
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1682
|
+
if (state && state.negated === true) {
|
|
1683
|
+
source = `^(?!${source}).*$`;
|
|
1684
|
+
}
|
|
1685
|
+
const regex = picomatch.toRegex(source, options);
|
|
1686
|
+
if (returnState === true) {
|
|
1687
|
+
regex.state = state;
|
|
1688
|
+
}
|
|
1689
|
+
return regex;
|
|
1690
|
+
};
|
|
1691
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1692
|
+
if (!input || typeof input !== "string") {
|
|
1693
|
+
throw new TypeError("Expected a non-empty string");
|
|
1694
|
+
}
|
|
1695
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1696
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1697
|
+
parsed.output = parse.fastpaths(input, options);
|
|
1698
|
+
}
|
|
1699
|
+
if (!parsed.output) {
|
|
1700
|
+
parsed = parse(input, options);
|
|
1701
|
+
}
|
|
1702
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1703
|
+
};
|
|
1704
|
+
picomatch.toRegex = (source, options) => {
|
|
1705
|
+
try {
|
|
1706
|
+
const opts = options || {};
|
|
1707
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1708
|
+
} catch (err) {
|
|
1709
|
+
if (options && options.debug === true)
|
|
1710
|
+
throw err;
|
|
1711
|
+
return /$^/;
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
picomatch.constants = constants;
|
|
1715
|
+
module.exports = picomatch;
|
|
1716
|
+
});
|
|
1717
|
+
|
|
1718
|
+
// ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/index.js
|
|
1719
|
+
var require_picomatch2 = __commonJS(function(exports, module) {
|
|
1720
|
+
var pico = require_picomatch();
|
|
1721
|
+
var utils = require_utils();
|
|
1722
|
+
function picomatch(glob, options, returnState = false) {
|
|
1723
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
1724
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1725
|
+
}
|
|
1726
|
+
return pico(glob, options, returnState);
|
|
1727
|
+
}
|
|
1728
|
+
Object.assign(picomatch, pico);
|
|
1729
|
+
module.exports = picomatch;
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
// src/error.ts
|
|
1733
|
+
class ExpectedError extends Error {
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
// src/util/path.ts
|
|
1737
|
+
import { join, normalize, relative } from "path";
|
|
1738
|
+
var root = process.cwd();
|
|
1739
|
+
var directories = {
|
|
1740
|
+
root,
|
|
1741
|
+
buildFolder: "build",
|
|
1742
|
+
get output() {
|
|
1743
|
+
return join(this.root, ".awsless");
|
|
1744
|
+
},
|
|
1745
|
+
get cache() {
|
|
1746
|
+
return join(this.output, "cache");
|
|
1747
|
+
},
|
|
1748
|
+
get state() {
|
|
1749
|
+
return join(this.output, "state");
|
|
1750
|
+
},
|
|
1751
|
+
get build() {
|
|
1752
|
+
return join(this.output, this.buildFolder);
|
|
1753
|
+
},
|
|
1754
|
+
get types() {
|
|
1755
|
+
return join(this.output, "types");
|
|
1756
|
+
},
|
|
1757
|
+
get temp() {
|
|
1758
|
+
return join(this.output, "temp");
|
|
1759
|
+
},
|
|
1760
|
+
get test() {
|
|
1761
|
+
return join(this.output, "test");
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
var setRoot = (path = root) => {
|
|
1765
|
+
directories.root = path;
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
// src/feature/bundle/build/rolldown.ts
|
|
1769
|
+
import { createHash } from "crypto";
|
|
1770
|
+
import { readFile } from "fs/promises";
|
|
1771
|
+
import { dirname, extname as extname2, join as join3 } from "path";
|
|
1772
|
+
|
|
1773
|
+
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
1774
|
+
var balanced = (a, b, str) => {
|
|
1775
|
+
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
1776
|
+
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
1777
|
+
const r = ma !== null && mb != null && range(ma, mb, str);
|
|
1778
|
+
return r && {
|
|
1779
|
+
start: r[0],
|
|
1780
|
+
end: r[1],
|
|
1781
|
+
pre: str.slice(0, r[0]),
|
|
1782
|
+
body: str.slice(r[0] + ma.length, r[1]),
|
|
1783
|
+
post: str.slice(r[1] + mb.length)
|
|
1784
|
+
};
|
|
1785
|
+
};
|
|
1786
|
+
var maybeMatch = (reg, str) => {
|
|
1787
|
+
const m = str.match(reg);
|
|
1788
|
+
return m ? m[0] : null;
|
|
1789
|
+
};
|
|
1790
|
+
var range = (a, b, str) => {
|
|
1791
|
+
let begs, beg, left, right = undefined, result;
|
|
1792
|
+
let ai = str.indexOf(a);
|
|
1793
|
+
let bi = str.indexOf(b, ai + 1);
|
|
1794
|
+
let i = ai;
|
|
1795
|
+
if (ai >= 0 && bi > 0) {
|
|
1796
|
+
if (a === b) {
|
|
1797
|
+
return [ai, bi];
|
|
1798
|
+
}
|
|
1799
|
+
begs = [];
|
|
1800
|
+
left = str.length;
|
|
1801
|
+
while (i >= 0 && !result) {
|
|
1802
|
+
if (i === ai) {
|
|
1803
|
+
begs.push(i);
|
|
1804
|
+
ai = str.indexOf(a, i + 1);
|
|
1805
|
+
} else if (begs.length === 1) {
|
|
1806
|
+
const r = begs.pop();
|
|
1807
|
+
if (r !== undefined)
|
|
1808
|
+
result = [r, bi];
|
|
1809
|
+
} else {
|
|
1810
|
+
beg = begs.pop();
|
|
1811
|
+
if (beg !== undefined && beg < left) {
|
|
1812
|
+
left = beg;
|
|
1813
|
+
right = bi;
|
|
1814
|
+
}
|
|
1815
|
+
bi = str.indexOf(b, i + 1);
|
|
1816
|
+
}
|
|
1817
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
1818
|
+
}
|
|
1819
|
+
if (begs.length && right !== undefined) {
|
|
1820
|
+
result = [left, right];
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
return result;
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// ../../node_modules/.pnpm/brace-expansion@5.0.9/node_modules/brace-expansion/dist/esm/index.js
|
|
1827
|
+
var escSlash = "\x00SLASH" + Math.random() + "\x00";
|
|
1828
|
+
var escOpen = "\x00OPEN" + Math.random() + "\x00";
|
|
1829
|
+
var escClose = "\x00CLOSE" + Math.random() + "\x00";
|
|
1830
|
+
var escComma = "\x00COMMA" + Math.random() + "\x00";
|
|
1831
|
+
var escPeriod = "\x00PERIOD" + Math.random() + "\x00";
|
|
1832
|
+
var escSlashPattern = new RegExp(escSlash, "g");
|
|
1833
|
+
var escOpenPattern = new RegExp(escOpen, "g");
|
|
1834
|
+
var escClosePattern = new RegExp(escClose, "g");
|
|
1835
|
+
var escCommaPattern = new RegExp(escComma, "g");
|
|
1836
|
+
var escPeriodPattern = new RegExp(escPeriod, "g");
|
|
1837
|
+
var slashPattern = /\\\\/g;
|
|
1838
|
+
var openPattern = /\\{/g;
|
|
1839
|
+
var closePattern = /\\}/g;
|
|
1840
|
+
var commaPattern = /\\,/g;
|
|
1841
|
+
var periodPattern = /\\\./g;
|
|
1842
|
+
var EXPANSION_MAX = 1e5;
|
|
1843
|
+
var EXPANSION_MAX_LENGTH = 4000000;
|
|
1844
|
+
function numeric(str) {
|
|
1845
|
+
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
1846
|
+
}
|
|
1847
|
+
function escapeBraces(str) {
|
|
1848
|
+
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
1849
|
+
}
|
|
1850
|
+
function unescapeBraces(str) {
|
|
1851
|
+
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
1852
|
+
}
|
|
1853
|
+
function parseCommaParts(str) {
|
|
1854
|
+
if (!str) {
|
|
1855
|
+
return [""];
|
|
1856
|
+
}
|
|
1857
|
+
const parts = [];
|
|
1858
|
+
const m = balanced("{", "}", str);
|
|
1859
|
+
if (!m) {
|
|
1860
|
+
return str.split(",");
|
|
1861
|
+
}
|
|
1862
|
+
const { pre, body, post } = m;
|
|
1863
|
+
const p = pre.split(",");
|
|
1864
|
+
p[p.length - 1] += "{" + body + "}";
|
|
1865
|
+
const postParts = parseCommaParts(post);
|
|
1866
|
+
if (post.length) {
|
|
1867
|
+
p[p.length - 1] += postParts.shift();
|
|
1868
|
+
p.push.apply(p, postParts);
|
|
1869
|
+
}
|
|
1870
|
+
parts.push.apply(parts, p);
|
|
1871
|
+
return parts;
|
|
1872
|
+
}
|
|
1873
|
+
function expand(str, options = {}) {
|
|
1874
|
+
if (!str) {
|
|
1875
|
+
return [];
|
|
1876
|
+
}
|
|
1877
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
|
1878
|
+
if (str.slice(0, 2) === "{}") {
|
|
1879
|
+
str = "\\{\\}" + str.slice(2);
|
|
1880
|
+
}
|
|
1881
|
+
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
1882
|
+
}
|
|
1883
|
+
function embrace(str) {
|
|
1884
|
+
return "{" + str + "}";
|
|
1885
|
+
}
|
|
1886
|
+
function isPadded(el) {
|
|
1887
|
+
return /^-?0\d/.test(el);
|
|
1888
|
+
}
|
|
1889
|
+
function lte(i, y) {
|
|
1890
|
+
return i <= y;
|
|
1891
|
+
}
|
|
1892
|
+
function gte(i, y) {
|
|
1893
|
+
return i >= y;
|
|
1894
|
+
}
|
|
1895
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
1896
|
+
const out = [];
|
|
1897
|
+
let length = 0;
|
|
1898
|
+
for (let a = 0;a < acc.length; a++) {
|
|
1899
|
+
for (let v = 0;v < values.length; v++) {
|
|
1900
|
+
if (out.length >= max)
|
|
1901
|
+
return out;
|
|
1902
|
+
const expansion = acc[a] + pre + values[v];
|
|
1903
|
+
if (dropEmpties && !expansion)
|
|
1904
|
+
continue;
|
|
1905
|
+
if (length + expansion.length > maxLength)
|
|
1906
|
+
return out;
|
|
1907
|
+
out.push(expansion);
|
|
1908
|
+
length += expansion.length;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
return out;
|
|
1912
|
+
}
|
|
1913
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
1914
|
+
const n = body.split(/\.\./);
|
|
1915
|
+
const N = [];
|
|
1916
|
+
if (n[0] === undefined || n[1] === undefined) {
|
|
1917
|
+
return N;
|
|
1918
|
+
}
|
|
1919
|
+
const x = numeric(n[0]);
|
|
1920
|
+
const y = numeric(n[1]);
|
|
1921
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
1922
|
+
let incr = n.length === 3 && n[2] !== undefined ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
1923
|
+
let test = lte;
|
|
1924
|
+
const reverse = y < x;
|
|
1925
|
+
if (reverse) {
|
|
1926
|
+
incr *= -1;
|
|
1927
|
+
test = gte;
|
|
1928
|
+
}
|
|
1929
|
+
const pad = n.some(isPadded);
|
|
1930
|
+
let length = 0;
|
|
1931
|
+
for (let i = x;test(i, y) && N.length < max; i += incr) {
|
|
1932
|
+
let c;
|
|
1933
|
+
if (isAlphaSequence) {
|
|
1934
|
+
c = String.fromCharCode(i);
|
|
1935
|
+
if (c === "\\") {
|
|
1936
|
+
c = "";
|
|
1937
|
+
}
|
|
1938
|
+
} else {
|
|
1939
|
+
c = String(i);
|
|
1940
|
+
if (pad) {
|
|
1941
|
+
const need = width - c.length;
|
|
1942
|
+
if (need > 0) {
|
|
1943
|
+
const z = new Array(need + 1).join("0");
|
|
1944
|
+
if (i < 0) {
|
|
1945
|
+
c = "-" + z + c.slice(1);
|
|
1946
|
+
} else {
|
|
1947
|
+
c = z + c;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
if (length + c.length > maxLength)
|
|
1953
|
+
break;
|
|
1954
|
+
N.push(c);
|
|
1955
|
+
length += c.length;
|
|
1956
|
+
}
|
|
1957
|
+
return N;
|
|
1958
|
+
}
|
|
1959
|
+
function expand_(str, max, maxLength, isTop) {
|
|
1960
|
+
let acc = [""];
|
|
1961
|
+
let dropEmpties = false;
|
|
1962
|
+
let firstGroup = true;
|
|
1963
|
+
for (;; ) {
|
|
1964
|
+
const m = balanced("{", "}", str);
|
|
1965
|
+
if (!m) {
|
|
1966
|
+
return combine(acc, str, [""], max, maxLength, dropEmpties);
|
|
1967
|
+
}
|
|
1968
|
+
const pre = m.pre;
|
|
1969
|
+
if (/\$$/.test(pre)) {
|
|
1970
|
+
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
|
1971
|
+
firstGroup = false;
|
|
1972
|
+
if (!m.post.length)
|
|
1973
|
+
break;
|
|
1974
|
+
str = m.post;
|
|
1975
|
+
continue;
|
|
1976
|
+
}
|
|
1977
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
1978
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
1979
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
1980
|
+
const isOptions = m.body.indexOf(",") >= 0;
|
|
1981
|
+
if (!isSequence && !isOptions) {
|
|
1982
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
1983
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
1984
|
+
isTop = true;
|
|
1985
|
+
continue;
|
|
1986
|
+
}
|
|
1987
|
+
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
|
1988
|
+
}
|
|
1989
|
+
if (firstGroup) {
|
|
1990
|
+
dropEmpties = isTop && !isSequence;
|
|
1991
|
+
firstGroup = false;
|
|
1992
|
+
}
|
|
1993
|
+
let values;
|
|
1994
|
+
if (isSequence) {
|
|
1995
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
1996
|
+
} else {
|
|
1997
|
+
let n = parseCommaParts(m.body);
|
|
1998
|
+
if (n.length === 1 && n[0] !== undefined) {
|
|
1999
|
+
n = expand_(n[0], max, maxLength, false).map(embrace);
|
|
2000
|
+
if (n.length === 1) {
|
|
2001
|
+
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
|
2002
|
+
if (!m.post.length)
|
|
2003
|
+
break;
|
|
2004
|
+
str = m.post;
|
|
2005
|
+
continue;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
let dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
2009
|
+
for (let d = 0;dropsEmpties && d < acc.length; d++) {
|
|
2010
|
+
if (acc[d]) {
|
|
2011
|
+
dropsEmpties = false;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
values = [];
|
|
2015
|
+
let valuesLength = 0;
|
|
2016
|
+
outer:
|
|
2017
|
+
for (let j = 0;j < n.length; j++) {
|
|
2018
|
+
const expanded = expand_(n[j], max, maxLength, false);
|
|
2019
|
+
for (let k = 0;k < expanded.length; k++) {
|
|
2020
|
+
const v = expanded[k];
|
|
2021
|
+
if (dropsEmpties && !v)
|
|
2022
|
+
continue;
|
|
2023
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
2024
|
+
break outer;
|
|
2025
|
+
}
|
|
2026
|
+
values.push(v);
|
|
2027
|
+
valuesLength += v.length;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
2032
|
+
if (!m.post.length)
|
|
2033
|
+
break;
|
|
2034
|
+
str = m.post;
|
|
2035
|
+
}
|
|
2036
|
+
return acc;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
2040
|
+
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
2041
|
+
var assertValidPattern = (pattern) => {
|
|
2042
|
+
if (typeof pattern !== "string") {
|
|
2043
|
+
throw new TypeError("invalid pattern");
|
|
2044
|
+
}
|
|
2045
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
2046
|
+
throw new TypeError("pattern is too long");
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js
|
|
2051
|
+
var posixClasses = {
|
|
2052
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
2053
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
2054
|
+
"[:ascii:]": ["\\x" + "00-\\x" + "7f", false],
|
|
2055
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
2056
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
2057
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
2058
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
2059
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
2060
|
+
"[:print:]": ["\\p{C}", true],
|
|
2061
|
+
"[:punct:]": ["\\p{P}", true],
|
|
2062
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
2063
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
2064
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
2065
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
2066
|
+
};
|
|
2067
|
+
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
2068
|
+
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2069
|
+
var rangesToString = (ranges) => ranges.join("");
|
|
2070
|
+
var parseClass = (glob, position) => {
|
|
2071
|
+
const pos = position;
|
|
2072
|
+
if (glob.charAt(pos) !== "[") {
|
|
2073
|
+
throw new Error("not in a brace expression");
|
|
2074
|
+
}
|
|
2075
|
+
const ranges = [];
|
|
2076
|
+
const negs = [];
|
|
2077
|
+
let i = pos + 1;
|
|
2078
|
+
let sawStart = false;
|
|
2079
|
+
let uflag = false;
|
|
2080
|
+
let escaping = false;
|
|
2081
|
+
let negate = false;
|
|
2082
|
+
let endPos = pos;
|
|
2083
|
+
let rangeStart = "";
|
|
2084
|
+
WHILE:
|
|
2085
|
+
while (i < glob.length) {
|
|
2086
|
+
const c = glob.charAt(i);
|
|
2087
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
2088
|
+
negate = true;
|
|
2089
|
+
i++;
|
|
2090
|
+
continue;
|
|
2091
|
+
}
|
|
2092
|
+
if (c === "]" && sawStart && !escaping) {
|
|
2093
|
+
endPos = i + 1;
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
sawStart = true;
|
|
2097
|
+
if (c === "\\") {
|
|
2098
|
+
if (!escaping) {
|
|
2099
|
+
escaping = true;
|
|
2100
|
+
i++;
|
|
2101
|
+
continue;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
if (c === "[" && !escaping) {
|
|
2105
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
2106
|
+
if (glob.startsWith(cls, i)) {
|
|
2107
|
+
if (rangeStart) {
|
|
2108
|
+
return ["$.", false, glob.length - pos, true];
|
|
2109
|
+
}
|
|
2110
|
+
i += cls.length;
|
|
2111
|
+
if (neg)
|
|
2112
|
+
negs.push(unip);
|
|
2113
|
+
else
|
|
2114
|
+
ranges.push(unip);
|
|
2115
|
+
uflag = uflag || u;
|
|
2116
|
+
continue WHILE;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
escaping = false;
|
|
2121
|
+
if (rangeStart) {
|
|
2122
|
+
if (c > rangeStart) {
|
|
2123
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
2124
|
+
} else if (c === rangeStart) {
|
|
2125
|
+
ranges.push(braceEscape(c));
|
|
2126
|
+
}
|
|
2127
|
+
rangeStart = "";
|
|
2128
|
+
i++;
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
if (glob.startsWith("-]", i + 1)) {
|
|
2132
|
+
ranges.push(braceEscape(c + "-"));
|
|
2133
|
+
i += 2;
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
if (glob.startsWith("-", i + 1)) {
|
|
2137
|
+
rangeStart = c;
|
|
2138
|
+
i += 2;
|
|
2139
|
+
continue;
|
|
2140
|
+
}
|
|
2141
|
+
ranges.push(braceEscape(c));
|
|
2142
|
+
i++;
|
|
2143
|
+
}
|
|
2144
|
+
if (endPos < i) {
|
|
2145
|
+
return ["", false, 0, false];
|
|
2146
|
+
}
|
|
2147
|
+
if (!ranges.length && !negs.length) {
|
|
2148
|
+
return ["$.", false, glob.length - pos, true];
|
|
2149
|
+
}
|
|
2150
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
2151
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
2152
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
2153
|
+
}
|
|
2154
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
2155
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
2156
|
+
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
2157
|
+
return [comb, uflag, endPos - pos, true];
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js
|
|
2161
|
+
var unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
2162
|
+
if (magicalBraces) {
|
|
2163
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
2164
|
+
}
|
|
2165
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
2166
|
+
};
|
|
2167
|
+
|
|
2168
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js
|
|
2169
|
+
var _a;
|
|
2170
|
+
var types = new Set(["!", "?", "+", "*", "@"]);
|
|
2171
|
+
var isExtglobType = (c) => types.has(c);
|
|
2172
|
+
var isExtglobAST = (c) => isExtglobType(c.type);
|
|
2173
|
+
var adoptionMap = new Map([
|
|
2174
|
+
["!", ["@"]],
|
|
2175
|
+
["?", ["?", "@"]],
|
|
2176
|
+
["@", ["@"]],
|
|
2177
|
+
["*", ["*", "+", "?", "@"]],
|
|
2178
|
+
["+", ["+", "@"]]
|
|
2179
|
+
]);
|
|
2180
|
+
var adoptionWithSpaceMap = new Map([
|
|
2181
|
+
["!", ["?"]],
|
|
2182
|
+
["@", ["?"]],
|
|
2183
|
+
["+", ["?", "*"]]
|
|
2184
|
+
]);
|
|
2185
|
+
var adoptionAnyMap = new Map([
|
|
2186
|
+
["!", ["?", "@"]],
|
|
2187
|
+
["?", ["?", "@"]],
|
|
2188
|
+
["@", ["?", "@"]],
|
|
2189
|
+
["*", ["*", "+", "?", "@"]],
|
|
2190
|
+
["+", ["+", "@", "?", "*"]]
|
|
2191
|
+
]);
|
|
2192
|
+
var usurpMap = new Map([
|
|
2193
|
+
["!", new Map([["!", "@"]])],
|
|
2194
|
+
[
|
|
2195
|
+
"?",
|
|
2196
|
+
new Map([
|
|
2197
|
+
["*", "*"],
|
|
2198
|
+
["+", "*"]
|
|
2199
|
+
])
|
|
2200
|
+
],
|
|
2201
|
+
[
|
|
2202
|
+
"@",
|
|
2203
|
+
new Map([
|
|
2204
|
+
["!", "!"],
|
|
2205
|
+
["?", "?"],
|
|
2206
|
+
["@", "@"],
|
|
2207
|
+
["*", "*"],
|
|
2208
|
+
["+", "+"]
|
|
2209
|
+
])
|
|
2210
|
+
],
|
|
2211
|
+
[
|
|
2212
|
+
"+",
|
|
2213
|
+
new Map([
|
|
2214
|
+
["?", "*"],
|
|
2215
|
+
["*", "*"]
|
|
2216
|
+
])
|
|
2217
|
+
]
|
|
2218
|
+
]);
|
|
2219
|
+
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
2220
|
+
var startNoDot = "(?!\\.)";
|
|
2221
|
+
var addPatternStart = new Set(["[", "."]);
|
|
2222
|
+
var justDots = new Set(["..", "."]);
|
|
2223
|
+
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
2224
|
+
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2225
|
+
var qmark = "[^/]";
|
|
2226
|
+
var star = qmark + "*?";
|
|
2227
|
+
var starNoEmpty = qmark + "+?";
|
|
2228
|
+
var ID = 0;
|
|
2229
|
+
|
|
2230
|
+
class AST {
|
|
2231
|
+
type;
|
|
2232
|
+
#root;
|
|
2233
|
+
#hasMagic;
|
|
2234
|
+
#uflag = false;
|
|
2235
|
+
#parts = [];
|
|
2236
|
+
#parent;
|
|
2237
|
+
#parentIndex;
|
|
2238
|
+
#negs;
|
|
2239
|
+
#filledNegs = false;
|
|
2240
|
+
#options;
|
|
2241
|
+
#toString;
|
|
2242
|
+
#emptyExt = false;
|
|
2243
|
+
id = ++ID;
|
|
2244
|
+
get depth() {
|
|
2245
|
+
return (this.#parent?.depth ?? -1) + 1;
|
|
2246
|
+
}
|
|
2247
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
2248
|
+
return {
|
|
2249
|
+
"@@type": "AST",
|
|
2250
|
+
id: this.id,
|
|
2251
|
+
type: this.type,
|
|
2252
|
+
root: this.#root.id,
|
|
2253
|
+
parent: this.#parent?.id,
|
|
2254
|
+
depth: this.depth,
|
|
2255
|
+
partsLength: this.#parts.length,
|
|
2256
|
+
parts: this.#parts
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
constructor(type, parent, options = {}) {
|
|
2260
|
+
this.type = type;
|
|
2261
|
+
if (type)
|
|
2262
|
+
this.#hasMagic = true;
|
|
2263
|
+
this.#parent = parent;
|
|
2264
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
2265
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
2266
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
2267
|
+
if (type === "!" && !this.#root.#filledNegs)
|
|
2268
|
+
this.#negs.push(this);
|
|
2269
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
2270
|
+
}
|
|
2271
|
+
get hasMagic() {
|
|
2272
|
+
if (this.#hasMagic !== undefined)
|
|
2273
|
+
return this.#hasMagic;
|
|
2274
|
+
for (const p of this.#parts) {
|
|
2275
|
+
if (typeof p === "string")
|
|
2276
|
+
continue;
|
|
2277
|
+
if (p.type || p.hasMagic)
|
|
2278
|
+
return this.#hasMagic = true;
|
|
2279
|
+
}
|
|
2280
|
+
return this.#hasMagic;
|
|
2281
|
+
}
|
|
2282
|
+
toString() {
|
|
2283
|
+
return this.#toString !== undefined ? this.#toString : !this.type ? this.#toString = this.#parts.map((p) => String(p)).join("") : this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
2284
|
+
}
|
|
2285
|
+
#fillNegs() {
|
|
2286
|
+
if (this !== this.#root)
|
|
2287
|
+
throw new Error("should only call on root");
|
|
2288
|
+
if (this.#filledNegs)
|
|
2289
|
+
return this;
|
|
2290
|
+
this.toString();
|
|
2291
|
+
this.#filledNegs = true;
|
|
2292
|
+
let n;
|
|
2293
|
+
while (n = this.#negs.pop()) {
|
|
2294
|
+
if (n.type !== "!")
|
|
2295
|
+
continue;
|
|
2296
|
+
let p = n;
|
|
2297
|
+
let pp = p.#parent;
|
|
2298
|
+
while (pp) {
|
|
2299
|
+
for (let i = p.#parentIndex + 1;!pp.type && i < pp.#parts.length; i++) {
|
|
2300
|
+
for (const part of n.#parts) {
|
|
2301
|
+
if (typeof part === "string") {
|
|
2302
|
+
throw new Error("string part in extglob AST??");
|
|
2303
|
+
}
|
|
2304
|
+
part.copyIn(pp.#parts[i]);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
p = pp;
|
|
2308
|
+
pp = p.#parent;
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return this;
|
|
2312
|
+
}
|
|
2313
|
+
push(...parts) {
|
|
2314
|
+
for (const p of parts) {
|
|
2315
|
+
if (p === "")
|
|
2316
|
+
continue;
|
|
2317
|
+
if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) {
|
|
2318
|
+
throw new Error("invalid part: " + p);
|
|
2319
|
+
}
|
|
2320
|
+
this.#parts.push(p);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
toJSON() {
|
|
2324
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
2325
|
+
if (this.isStart() && !this.type)
|
|
2326
|
+
ret.unshift([]);
|
|
2327
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
2328
|
+
ret.push({});
|
|
2329
|
+
}
|
|
2330
|
+
return ret;
|
|
2331
|
+
}
|
|
2332
|
+
isStart() {
|
|
2333
|
+
if (this.#root === this)
|
|
2334
|
+
return true;
|
|
2335
|
+
if (!this.#parent?.isStart())
|
|
2336
|
+
return false;
|
|
2337
|
+
if (this.#parentIndex === 0)
|
|
2338
|
+
return true;
|
|
2339
|
+
const p = this.#parent;
|
|
2340
|
+
for (let i = 0;i < this.#parentIndex; i++) {
|
|
2341
|
+
const pp = p.#parts[i];
|
|
2342
|
+
if (!(pp instanceof _a && pp.type === "!")) {
|
|
2343
|
+
return false;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
return true;
|
|
2347
|
+
}
|
|
2348
|
+
isEnd() {
|
|
2349
|
+
if (this.#root === this)
|
|
2350
|
+
return true;
|
|
2351
|
+
if (this.#parent?.type === "!")
|
|
2352
|
+
return true;
|
|
2353
|
+
if (!this.#parent?.isEnd())
|
|
2354
|
+
return false;
|
|
2355
|
+
if (!this.type)
|
|
2356
|
+
return this.#parent?.isEnd();
|
|
2357
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
2358
|
+
return this.#parentIndex === pl - 1;
|
|
2359
|
+
}
|
|
2360
|
+
copyIn(part) {
|
|
2361
|
+
if (typeof part === "string")
|
|
2362
|
+
this.push(part);
|
|
2363
|
+
else
|
|
2364
|
+
this.push(part.clone(this));
|
|
2365
|
+
}
|
|
2366
|
+
clone(parent) {
|
|
2367
|
+
const c = new _a(this.type, parent);
|
|
2368
|
+
for (const p of this.#parts) {
|
|
2369
|
+
c.copyIn(p);
|
|
2370
|
+
}
|
|
2371
|
+
return c;
|
|
2372
|
+
}
|
|
2373
|
+
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
2374
|
+
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
2375
|
+
let escaping = false;
|
|
2376
|
+
let inBrace = false;
|
|
2377
|
+
let braceStart = -1;
|
|
2378
|
+
let braceNeg = false;
|
|
2379
|
+
if (ast.type === null) {
|
|
2380
|
+
let i2 = pos;
|
|
2381
|
+
let acc2 = "";
|
|
2382
|
+
while (i2 < str.length) {
|
|
2383
|
+
const c = str.charAt(i2++);
|
|
2384
|
+
if (escaping || c === "\\") {
|
|
2385
|
+
escaping = !escaping;
|
|
2386
|
+
acc2 += c;
|
|
2387
|
+
continue;
|
|
2388
|
+
}
|
|
2389
|
+
if (inBrace) {
|
|
2390
|
+
if (i2 === braceStart + 1) {
|
|
2391
|
+
if (c === "^" || c === "!") {
|
|
2392
|
+
braceNeg = true;
|
|
2393
|
+
}
|
|
2394
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
2395
|
+
inBrace = false;
|
|
2396
|
+
}
|
|
2397
|
+
acc2 += c;
|
|
2398
|
+
continue;
|
|
2399
|
+
} else if (c === "[") {
|
|
2400
|
+
inBrace = true;
|
|
2401
|
+
braceStart = i2;
|
|
2402
|
+
braceNeg = false;
|
|
2403
|
+
acc2 += c;
|
|
2404
|
+
continue;
|
|
2405
|
+
}
|
|
2406
|
+
const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth;
|
|
2407
|
+
if (doRecurse) {
|
|
2408
|
+
ast.push(acc2);
|
|
2409
|
+
acc2 = "";
|
|
2410
|
+
const ext = new _a(c, ast);
|
|
2411
|
+
i2 = _a.#parseAST(str, ext, i2, opt, extDepth + 1);
|
|
2412
|
+
ast.push(ext);
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
acc2 += c;
|
|
2416
|
+
}
|
|
2417
|
+
ast.push(acc2);
|
|
2418
|
+
return i2;
|
|
2419
|
+
}
|
|
2420
|
+
let i = pos + 1;
|
|
2421
|
+
let part = new _a(null, ast);
|
|
2422
|
+
const parts = [];
|
|
2423
|
+
let acc = "";
|
|
2424
|
+
while (i < str.length) {
|
|
2425
|
+
const c = str.charAt(i++);
|
|
2426
|
+
if (escaping || c === "\\") {
|
|
2427
|
+
escaping = !escaping;
|
|
2428
|
+
acc += c;
|
|
2429
|
+
continue;
|
|
2430
|
+
}
|
|
2431
|
+
if (inBrace) {
|
|
2432
|
+
if (i === braceStart + 1) {
|
|
2433
|
+
if (c === "^" || c === "!") {
|
|
2434
|
+
braceNeg = true;
|
|
2435
|
+
}
|
|
2436
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
2437
|
+
inBrace = false;
|
|
2438
|
+
}
|
|
2439
|
+
acc += c;
|
|
2440
|
+
continue;
|
|
2441
|
+
} else if (c === "[") {
|
|
2442
|
+
inBrace = true;
|
|
2443
|
+
braceStart = i;
|
|
2444
|
+
braceNeg = false;
|
|
2445
|
+
acc += c;
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
|
|
2449
|
+
if (doRecurse) {
|
|
2450
|
+
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
2451
|
+
part.push(acc);
|
|
2452
|
+
acc = "";
|
|
2453
|
+
const ext = new _a(c, part);
|
|
2454
|
+
part.push(ext);
|
|
2455
|
+
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
2456
|
+
continue;
|
|
2457
|
+
}
|
|
2458
|
+
if (c === "|") {
|
|
2459
|
+
part.push(acc);
|
|
2460
|
+
acc = "";
|
|
2461
|
+
parts.push(part);
|
|
2462
|
+
part = new _a(null, ast);
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
if (c === ")") {
|
|
2466
|
+
if (acc === "" && ast.#parts.length === 0) {
|
|
2467
|
+
ast.#emptyExt = true;
|
|
2468
|
+
}
|
|
2469
|
+
part.push(acc);
|
|
2470
|
+
acc = "";
|
|
2471
|
+
ast.push(...parts, part);
|
|
2472
|
+
return i;
|
|
2473
|
+
}
|
|
2474
|
+
acc += c;
|
|
2475
|
+
}
|
|
2476
|
+
ast.type = null;
|
|
2477
|
+
ast.#hasMagic = undefined;
|
|
2478
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
2479
|
+
return i;
|
|
2480
|
+
}
|
|
2481
|
+
#canAdoptWithSpace(child) {
|
|
2482
|
+
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
2483
|
+
}
|
|
2484
|
+
#canAdopt(child, map = adoptionMap) {
|
|
2485
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) {
|
|
2486
|
+
return false;
|
|
2487
|
+
}
|
|
2488
|
+
const gc = child.#parts[0];
|
|
2489
|
+
if (!gc || typeof gc !== "object" || gc.type === null) {
|
|
2490
|
+
return false;
|
|
2491
|
+
}
|
|
2492
|
+
return this.#canAdoptType(gc.type, map);
|
|
2493
|
+
}
|
|
2494
|
+
#canAdoptType(c, map = adoptionAnyMap) {
|
|
2495
|
+
return !!map.get(this.type)?.includes(c);
|
|
2496
|
+
}
|
|
2497
|
+
#adoptWithSpace(child, index) {
|
|
2498
|
+
const gc = child.#parts[0];
|
|
2499
|
+
const blank = new _a(null, gc, this.options);
|
|
2500
|
+
blank.#parts.push("");
|
|
2501
|
+
gc.push(blank);
|
|
2502
|
+
this.#adopt(child, index);
|
|
2503
|
+
}
|
|
2504
|
+
#adopt(child, index) {
|
|
2505
|
+
const gc = child.#parts[0];
|
|
2506
|
+
this.#parts.splice(index, 1, ...gc.#parts);
|
|
2507
|
+
for (const p of gc.#parts) {
|
|
2508
|
+
if (typeof p === "object")
|
|
2509
|
+
p.#parent = this;
|
|
2510
|
+
}
|
|
2511
|
+
this.#toString = undefined;
|
|
2512
|
+
}
|
|
2513
|
+
#canUsurpType(c) {
|
|
2514
|
+
const m = usurpMap.get(this.type);
|
|
2515
|
+
return !!m?.has(c);
|
|
2516
|
+
}
|
|
2517
|
+
#canUsurp(child) {
|
|
2518
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) {
|
|
2519
|
+
return false;
|
|
2520
|
+
}
|
|
2521
|
+
const gc = child.#parts[0];
|
|
2522
|
+
if (!gc || typeof gc !== "object" || gc.type === null) {
|
|
2523
|
+
return false;
|
|
2524
|
+
}
|
|
2525
|
+
return this.#canUsurpType(gc.type);
|
|
2526
|
+
}
|
|
2527
|
+
#usurp(child) {
|
|
2528
|
+
const m = usurpMap.get(this.type);
|
|
2529
|
+
const gc = child.#parts[0];
|
|
2530
|
+
const nt = m?.get(gc.type);
|
|
2531
|
+
if (!nt)
|
|
2532
|
+
return false;
|
|
2533
|
+
this.#parts = gc.#parts;
|
|
2534
|
+
for (const p of this.#parts) {
|
|
2535
|
+
if (typeof p === "object") {
|
|
2536
|
+
p.#parent = this;
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
this.type = nt;
|
|
2540
|
+
this.#toString = undefined;
|
|
2541
|
+
this.#emptyExt = false;
|
|
2542
|
+
}
|
|
2543
|
+
static fromGlob(pattern, options = {}) {
|
|
2544
|
+
const ast = new _a(null, undefined, options);
|
|
2545
|
+
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
2546
|
+
return ast;
|
|
2547
|
+
}
|
|
2548
|
+
toMMPattern() {
|
|
2549
|
+
if (this !== this.#root)
|
|
2550
|
+
return this.#root.toMMPattern();
|
|
2551
|
+
const glob = this.toString();
|
|
2552
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
2553
|
+
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
2554
|
+
if (!anyMagic) {
|
|
2555
|
+
return body;
|
|
2556
|
+
}
|
|
2557
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
2558
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
2559
|
+
_src: re,
|
|
2560
|
+
_glob: glob
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
get options() {
|
|
2564
|
+
return this.#options;
|
|
2565
|
+
}
|
|
2566
|
+
toRegExpSource(allowDot) {
|
|
2567
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
2568
|
+
if (this.#root === this) {
|
|
2569
|
+
this.#flatten();
|
|
2570
|
+
this.#fillNegs();
|
|
2571
|
+
}
|
|
2572
|
+
if (!isExtglobAST(this)) {
|
|
2573
|
+
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
|
|
2574
|
+
const src = this.#parts.map((p) => {
|
|
2575
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
2576
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
2577
|
+
this.#uflag = this.#uflag || uflag;
|
|
2578
|
+
return re;
|
|
2579
|
+
}).join("");
|
|
2580
|
+
let start2 = "";
|
|
2581
|
+
if (this.isStart()) {
|
|
2582
|
+
if (typeof this.#parts[0] === "string") {
|
|
2583
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
2584
|
+
if (!dotTravAllowed) {
|
|
2585
|
+
const aps = addPatternStart;
|
|
2586
|
+
const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
|
|
2587
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
2588
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
let end = "";
|
|
2593
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
2594
|
+
end = "(?:$|\\/)";
|
|
2595
|
+
}
|
|
2596
|
+
const final2 = start2 + src + end;
|
|
2597
|
+
return [
|
|
2598
|
+
final2,
|
|
2599
|
+
unescape(src),
|
|
2600
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
2601
|
+
this.#uflag
|
|
2602
|
+
];
|
|
2603
|
+
}
|
|
2604
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
2605
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
2606
|
+
let body = this.#partsToRegExp(dot);
|
|
2607
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
2608
|
+
const s = this.toString();
|
|
2609
|
+
const me = this;
|
|
2610
|
+
me.#parts = [s];
|
|
2611
|
+
me.type = null;
|
|
2612
|
+
me.#hasMagic = undefined;
|
|
2613
|
+
return [s, unescape(this.toString()), false, false];
|
|
2614
|
+
}
|
|
2615
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
2616
|
+
if (bodyDotAllowed === body) {
|
|
2617
|
+
bodyDotAllowed = "";
|
|
2618
|
+
}
|
|
2619
|
+
if (bodyDotAllowed) {
|
|
2620
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
2621
|
+
}
|
|
2622
|
+
let final = "";
|
|
2623
|
+
if (this.type === "!" && this.#emptyExt) {
|
|
2624
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
2625
|
+
} else {
|
|
2626
|
+
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
2627
|
+
final = start + body + close;
|
|
2628
|
+
}
|
|
2629
|
+
return [
|
|
2630
|
+
final,
|
|
2631
|
+
unescape(body),
|
|
2632
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
2633
|
+
this.#uflag
|
|
2634
|
+
];
|
|
2635
|
+
}
|
|
2636
|
+
#flatten() {
|
|
2637
|
+
if (!isExtglobAST(this)) {
|
|
2638
|
+
for (const p of this.#parts) {
|
|
2639
|
+
if (typeof p === "object") {
|
|
2640
|
+
p.#flatten();
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
} else {
|
|
2644
|
+
let iterations = 0;
|
|
2645
|
+
let done = false;
|
|
2646
|
+
do {
|
|
2647
|
+
done = true;
|
|
2648
|
+
for (let i = 0;i < this.#parts.length; i++) {
|
|
2649
|
+
const c = this.#parts[i];
|
|
2650
|
+
if (typeof c === "object") {
|
|
2651
|
+
c.#flatten();
|
|
2652
|
+
if (this.#canAdopt(c)) {
|
|
2653
|
+
done = false;
|
|
2654
|
+
this.#adopt(c, i);
|
|
2655
|
+
} else if (this.#canAdoptWithSpace(c)) {
|
|
2656
|
+
done = false;
|
|
2657
|
+
this.#adoptWithSpace(c, i);
|
|
2658
|
+
} else if (this.#canUsurp(c)) {
|
|
2659
|
+
done = false;
|
|
2660
|
+
this.#usurp(c);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
} while (!done && ++iterations < 10);
|
|
2665
|
+
}
|
|
2666
|
+
this.#toString = undefined;
|
|
2667
|
+
}
|
|
2668
|
+
#partsToRegExp(dot) {
|
|
2669
|
+
return this.#parts.map((p) => {
|
|
2670
|
+
if (typeof p === "string") {
|
|
2671
|
+
throw new Error("string type in extglob ast??");
|
|
2672
|
+
}
|
|
2673
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
2674
|
+
this.#uflag = this.#uflag || uflag;
|
|
2675
|
+
return re;
|
|
2676
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
2677
|
+
}
|
|
2678
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
2679
|
+
let escaping = false;
|
|
2680
|
+
let re = "";
|
|
2681
|
+
let uflag = false;
|
|
2682
|
+
let inStar = false;
|
|
2683
|
+
for (let i = 0;i < glob.length; i++) {
|
|
2684
|
+
const c = glob.charAt(i);
|
|
2685
|
+
if (escaping) {
|
|
2686
|
+
escaping = false;
|
|
2687
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
2688
|
+
continue;
|
|
2689
|
+
}
|
|
2690
|
+
if (c === "*") {
|
|
2691
|
+
if (inStar)
|
|
2692
|
+
continue;
|
|
2693
|
+
inStar = true;
|
|
2694
|
+
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
2695
|
+
hasMagic = true;
|
|
2696
|
+
continue;
|
|
2697
|
+
} else {
|
|
2698
|
+
inStar = false;
|
|
2699
|
+
}
|
|
2700
|
+
if (c === "\\") {
|
|
2701
|
+
if (i === glob.length - 1) {
|
|
2702
|
+
re += "\\\\";
|
|
2703
|
+
} else {
|
|
2704
|
+
escaping = true;
|
|
2705
|
+
}
|
|
2706
|
+
continue;
|
|
2707
|
+
}
|
|
2708
|
+
if (c === "[") {
|
|
2709
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
2710
|
+
if (consumed) {
|
|
2711
|
+
re += src;
|
|
2712
|
+
uflag = uflag || needUflag;
|
|
2713
|
+
i += consumed - 1;
|
|
2714
|
+
hasMagic = hasMagic || magic;
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
if (c === "?") {
|
|
2719
|
+
re += qmark;
|
|
2720
|
+
hasMagic = true;
|
|
2721
|
+
continue;
|
|
2722
|
+
}
|
|
2723
|
+
re += regExpEscape(c);
|
|
2724
|
+
}
|
|
2725
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
_a = AST;
|
|
2729
|
+
|
|
2730
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
|
|
2731
|
+
var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
2732
|
+
if (magicalBraces) {
|
|
2733
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
|
|
2734
|
+
}
|
|
2735
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
2736
|
+
};
|
|
2737
|
+
|
|
2738
|
+
// ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js
|
|
2739
|
+
var minimatch = (p, pattern, options = {}) => {
|
|
2740
|
+
assertValidPattern(pattern);
|
|
2741
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
2742
|
+
return false;
|
|
2743
|
+
}
|
|
2744
|
+
return new Minimatch(pattern, options).match(p);
|
|
2745
|
+
};
|
|
2746
|
+
var starDotExtRE = /^\*+([^+@!?*[(]*)$/;
|
|
2747
|
+
var starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext);
|
|
2748
|
+
var starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
2749
|
+
var starDotExtTestNocase = (ext) => {
|
|
2750
|
+
ext = ext.toLowerCase();
|
|
2751
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
|
|
2752
|
+
};
|
|
2753
|
+
var starDotExtTestNocaseDot = (ext) => {
|
|
2754
|
+
ext = ext.toLowerCase();
|
|
2755
|
+
return (f) => f.toLowerCase().endsWith(ext);
|
|
2756
|
+
};
|
|
2757
|
+
var starDotStarRE = /^\*+\.\*+$/;
|
|
2758
|
+
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
2759
|
+
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
2760
|
+
var dotStarRE = /^\.\*+$/;
|
|
2761
|
+
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
2762
|
+
var starRE = /^\*+$/;
|
|
2763
|
+
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
2764
|
+
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
2765
|
+
var qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
2766
|
+
var qmarksTestNocase = ([$0, ext = ""]) => {
|
|
2767
|
+
const noext = qmarksTestNoExt([$0]);
|
|
2768
|
+
if (!ext)
|
|
2769
|
+
return noext;
|
|
2770
|
+
ext = ext.toLowerCase();
|
|
2771
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
2772
|
+
};
|
|
2773
|
+
var qmarksTestNocaseDot = ([$0, ext = ""]) => {
|
|
2774
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
2775
|
+
if (!ext)
|
|
2776
|
+
return noext;
|
|
2777
|
+
ext = ext.toLowerCase();
|
|
2778
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
2779
|
+
};
|
|
2780
|
+
var qmarksTestDot = ([$0, ext = ""]) => {
|
|
2781
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
2782
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
2783
|
+
};
|
|
2784
|
+
var qmarksTest = ([$0, ext = ""]) => {
|
|
2785
|
+
const noext = qmarksTestNoExt([$0]);
|
|
2786
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
2787
|
+
};
|
|
2788
|
+
var qmarksTestNoExt = ([$0]) => {
|
|
2789
|
+
const len = $0.length;
|
|
2790
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
2791
|
+
};
|
|
2792
|
+
var qmarksTestNoExtDot = ([$0]) => {
|
|
2793
|
+
const len = $0.length;
|
|
2794
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
2795
|
+
};
|
|
2796
|
+
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
2797
|
+
var path = {
|
|
2798
|
+
win32: { sep: "\\" },
|
|
2799
|
+
posix: { sep: "/" }
|
|
2800
|
+
};
|
|
2801
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
2802
|
+
minimatch.sep = sep;
|
|
2803
|
+
var GLOBSTAR = Symbol("globstar **");
|
|
2804
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
2805
|
+
var qmark2 = "[^/]";
|
|
2806
|
+
var star2 = qmark2 + "*?";
|
|
2807
|
+
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
2808
|
+
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
2809
|
+
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
2810
|
+
minimatch.filter = filter;
|
|
2811
|
+
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
2812
|
+
var defaults = (def) => {
|
|
2813
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
2814
|
+
return minimatch;
|
|
2815
|
+
}
|
|
2816
|
+
const orig = minimatch;
|
|
2817
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
2818
|
+
return Object.assign(m, {
|
|
2819
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
2820
|
+
constructor(pattern, options = {}) {
|
|
2821
|
+
super(pattern, ext(def, options));
|
|
2822
|
+
}
|
|
2823
|
+
static defaults(options) {
|
|
2824
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
2825
|
+
}
|
|
2826
|
+
},
|
|
2827
|
+
AST: class AST2 extends orig.AST {
|
|
2828
|
+
constructor(type, parent, options = {}) {
|
|
2829
|
+
super(type, parent, ext(def, options));
|
|
2830
|
+
}
|
|
2831
|
+
static fromGlob(pattern, options = {}) {
|
|
2832
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
2836
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
2837
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
2838
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
2839
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
2840
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
2841
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
2842
|
+
sep: orig.sep,
|
|
2843
|
+
GLOBSTAR
|
|
2844
|
+
});
|
|
2845
|
+
};
|
|
2846
|
+
minimatch.defaults = defaults;
|
|
2847
|
+
var braceExpand = (pattern, options = {}) => {
|
|
2848
|
+
assertValidPattern(pattern);
|
|
2849
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
2850
|
+
return [pattern];
|
|
2851
|
+
}
|
|
2852
|
+
return expand(pattern, { max: options.braceExpandMax });
|
|
2853
|
+
};
|
|
2854
|
+
minimatch.braceExpand = braceExpand;
|
|
2855
|
+
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
2856
|
+
minimatch.makeRe = makeRe;
|
|
2857
|
+
var match = (list, pattern, options = {}) => {
|
|
2858
|
+
const mm = new Minimatch(pattern, options);
|
|
2859
|
+
list = list.filter((f) => mm.match(f));
|
|
2860
|
+
if (mm.options.nonull && !list.length) {
|
|
2861
|
+
list.push(pattern);
|
|
2862
|
+
}
|
|
2863
|
+
return list;
|
|
2864
|
+
};
|
|
2865
|
+
minimatch.match = match;
|
|
2866
|
+
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2867
|
+
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2868
|
+
|
|
2869
|
+
class Minimatch {
|
|
2870
|
+
options;
|
|
2871
|
+
set;
|
|
2872
|
+
pattern;
|
|
2873
|
+
windowsPathsNoEscape;
|
|
2874
|
+
nonegate;
|
|
2875
|
+
negate;
|
|
2876
|
+
comment;
|
|
2877
|
+
empty;
|
|
2878
|
+
preserveMultipleSlashes;
|
|
2879
|
+
partial;
|
|
2880
|
+
globSet;
|
|
2881
|
+
globParts;
|
|
2882
|
+
nocase;
|
|
2883
|
+
isWindows;
|
|
2884
|
+
platform;
|
|
2885
|
+
windowsNoMagicRoot;
|
|
2886
|
+
maxGlobstarRecursion;
|
|
2887
|
+
regexp;
|
|
2888
|
+
constructor(pattern, options = {}) {
|
|
2889
|
+
assertValidPattern(pattern);
|
|
2890
|
+
options = options || {};
|
|
2891
|
+
this.options = options;
|
|
2892
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
2893
|
+
this.pattern = pattern;
|
|
2894
|
+
this.platform = options.platform || defaultPlatform;
|
|
2895
|
+
this.isWindows = this.platform === "win32";
|
|
2896
|
+
const awe = "allowWindow" + "sEscape";
|
|
2897
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
|
|
2898
|
+
if (this.windowsPathsNoEscape) {
|
|
2899
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
2900
|
+
}
|
|
2901
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
2902
|
+
this.regexp = null;
|
|
2903
|
+
this.negate = false;
|
|
2904
|
+
this.nonegate = !!options.nonegate;
|
|
2905
|
+
this.comment = false;
|
|
2906
|
+
this.empty = false;
|
|
2907
|
+
this.partial = !!options.partial;
|
|
2908
|
+
this.nocase = !!this.options.nocase;
|
|
2909
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== undefined ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
2910
|
+
this.globSet = [];
|
|
2911
|
+
this.globParts = [];
|
|
2912
|
+
this.set = [];
|
|
2913
|
+
this.make();
|
|
2914
|
+
}
|
|
2915
|
+
hasMagic() {
|
|
2916
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
2917
|
+
return true;
|
|
2918
|
+
}
|
|
2919
|
+
for (const pattern of this.set) {
|
|
2920
|
+
for (const part of pattern) {
|
|
2921
|
+
if (typeof part !== "string")
|
|
2922
|
+
return true;
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
debug(..._) {}
|
|
2928
|
+
make() {
|
|
2929
|
+
const pattern = this.pattern;
|
|
2930
|
+
const options = this.options;
|
|
2931
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
2932
|
+
this.comment = true;
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2935
|
+
if (!pattern) {
|
|
2936
|
+
this.empty = true;
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
this.parseNegate();
|
|
2940
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
2941
|
+
if (options.debug) {
|
|
2942
|
+
this.debug = (...args) => console.error(...args);
|
|
2943
|
+
}
|
|
2944
|
+
this.debug(this.pattern, this.globSet);
|
|
2945
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
2946
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
2947
|
+
this.debug(this.pattern, this.globParts);
|
|
2948
|
+
let set = this.globParts.map((s, _, __) => {
|
|
2949
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2950
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
2951
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
2952
|
+
if (isUNC) {
|
|
2953
|
+
return [
|
|
2954
|
+
...s.slice(0, 4),
|
|
2955
|
+
...s.slice(4).map((ss) => this.parse(ss))
|
|
2956
|
+
];
|
|
2957
|
+
} else if (isDrive) {
|
|
2958
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
return s.map((ss) => this.parse(ss));
|
|
2962
|
+
});
|
|
2963
|
+
this.debug(this.pattern, set);
|
|
2964
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
2965
|
+
if (this.isWindows) {
|
|
2966
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
2967
|
+
const p = this.set[i];
|
|
2968
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
2969
|
+
p[2] = "?";
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
this.debug(this.pattern, this.set);
|
|
2974
|
+
}
|
|
2975
|
+
preprocess(globParts) {
|
|
2976
|
+
if (this.options.noglobstar) {
|
|
2977
|
+
for (const partset of globParts) {
|
|
2978
|
+
for (let j = 0;j < partset.length; j++) {
|
|
2979
|
+
if (partset[j] === "**") {
|
|
2980
|
+
partset[j] = "*";
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
const { optimizationLevel = 1 } = this.options;
|
|
2986
|
+
if (optimizationLevel >= 2) {
|
|
2987
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
2988
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
2989
|
+
} else if (optimizationLevel >= 1) {
|
|
2990
|
+
globParts = this.levelOneOptimize(globParts);
|
|
2991
|
+
} else {
|
|
2992
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
2993
|
+
}
|
|
2994
|
+
return globParts;
|
|
2995
|
+
}
|
|
2996
|
+
adjascentGlobstarOptimize(globParts) {
|
|
2997
|
+
return globParts.map((parts) => {
|
|
2998
|
+
let gs = -1;
|
|
2999
|
+
while ((gs = parts.indexOf("**", gs + 1)) !== -1) {
|
|
3000
|
+
let i = gs;
|
|
3001
|
+
while (parts[i + 1] === "**") {
|
|
3002
|
+
i++;
|
|
3003
|
+
}
|
|
3004
|
+
if (i !== gs) {
|
|
3005
|
+
parts.splice(gs, i - gs);
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
return parts;
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
levelOneOptimize(globParts) {
|
|
3012
|
+
return globParts.map((parts) => {
|
|
3013
|
+
parts = parts.reduce((set, part) => {
|
|
3014
|
+
const prev = set[set.length - 1];
|
|
3015
|
+
if (part === "**" && prev === "**") {
|
|
3016
|
+
return set;
|
|
3017
|
+
}
|
|
3018
|
+
if (part === "..") {
|
|
3019
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
3020
|
+
set.pop();
|
|
3021
|
+
return set;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
set.push(part);
|
|
3025
|
+
return set;
|
|
3026
|
+
}, []);
|
|
3027
|
+
return parts.length === 0 ? [""] : parts;
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
levelTwoFileOptimize(parts) {
|
|
3031
|
+
if (!Array.isArray(parts)) {
|
|
3032
|
+
parts = this.slashSplit(parts);
|
|
3033
|
+
}
|
|
3034
|
+
let didSomething = false;
|
|
3035
|
+
do {
|
|
3036
|
+
didSomething = false;
|
|
3037
|
+
if (!this.preserveMultipleSlashes) {
|
|
3038
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
3039
|
+
const p = parts[i];
|
|
3040
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
3041
|
+
continue;
|
|
3042
|
+
if (p === "." || p === "") {
|
|
3043
|
+
didSomething = true;
|
|
3044
|
+
parts.splice(i, 1);
|
|
3045
|
+
i--;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
3049
|
+
didSomething = true;
|
|
3050
|
+
parts.pop();
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
let dd = 0;
|
|
3054
|
+
while ((dd = parts.indexOf("..", dd + 1)) !== -1) {
|
|
3055
|
+
const p = parts[dd - 1];
|
|
3056
|
+
if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
|
|
3057
|
+
didSomething = true;
|
|
3058
|
+
parts.splice(dd - 1, 2);
|
|
3059
|
+
dd -= 2;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
} while (didSomething);
|
|
3063
|
+
return parts.length === 0 ? [""] : parts;
|
|
3064
|
+
}
|
|
3065
|
+
firstPhasePreProcess(globParts) {
|
|
3066
|
+
let didSomething = false;
|
|
3067
|
+
do {
|
|
3068
|
+
didSomething = false;
|
|
3069
|
+
for (let parts of globParts) {
|
|
3070
|
+
let gs = -1;
|
|
3071
|
+
while ((gs = parts.indexOf("**", gs + 1)) !== -1) {
|
|
3072
|
+
let gss = gs;
|
|
3073
|
+
while (parts[gss + 1] === "**") {
|
|
3074
|
+
gss++;
|
|
3075
|
+
}
|
|
3076
|
+
if (gss > gs) {
|
|
3077
|
+
parts.splice(gs + 1, gss - gs);
|
|
3078
|
+
}
|
|
3079
|
+
let next = parts[gs + 1];
|
|
3080
|
+
const p = parts[gs + 2];
|
|
3081
|
+
const p2 = parts[gs + 3];
|
|
3082
|
+
if (next !== "..")
|
|
3083
|
+
continue;
|
|
3084
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
didSomething = true;
|
|
3088
|
+
parts.splice(gs, 1);
|
|
3089
|
+
const other = parts.slice(0);
|
|
3090
|
+
other[gs] = "**";
|
|
3091
|
+
globParts.push(other);
|
|
3092
|
+
gs--;
|
|
3093
|
+
}
|
|
3094
|
+
if (!this.preserveMultipleSlashes) {
|
|
3095
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
3096
|
+
const p = parts[i];
|
|
3097
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
3098
|
+
continue;
|
|
3099
|
+
if (p === "." || p === "") {
|
|
3100
|
+
didSomething = true;
|
|
3101
|
+
parts.splice(i, 1);
|
|
3102
|
+
i--;
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
3106
|
+
didSomething = true;
|
|
3107
|
+
parts.pop();
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
let dd = 0;
|
|
3111
|
+
while ((dd = parts.indexOf("..", dd + 1)) !== -1) {
|
|
3112
|
+
const p = parts[dd - 1];
|
|
3113
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
3114
|
+
didSomething = true;
|
|
3115
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
3116
|
+
const splin = needDot ? ["."] : [];
|
|
3117
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
3118
|
+
if (parts.length === 0)
|
|
3119
|
+
parts.push("");
|
|
3120
|
+
dd -= 2;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
} while (didSomething);
|
|
3125
|
+
return globParts;
|
|
3126
|
+
}
|
|
3127
|
+
secondPhasePreProcess(globParts) {
|
|
3128
|
+
for (let i = 0;i < globParts.length - 1; i++) {
|
|
3129
|
+
for (let j = i + 1;j < globParts.length; j++) {
|
|
3130
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
3131
|
+
if (matched) {
|
|
3132
|
+
globParts[i] = [];
|
|
3133
|
+
globParts[j] = matched;
|
|
3134
|
+
break;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
return globParts.filter((gs) => gs.length);
|
|
3139
|
+
}
|
|
3140
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
3141
|
+
let ai = 0;
|
|
3142
|
+
let bi = 0;
|
|
3143
|
+
let result = [];
|
|
3144
|
+
let which = "";
|
|
3145
|
+
while (ai < a.length && bi < b.length) {
|
|
3146
|
+
if (a[ai] === b[bi]) {
|
|
3147
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
3148
|
+
ai++;
|
|
3149
|
+
bi++;
|
|
3150
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
3151
|
+
result.push(a[ai]);
|
|
3152
|
+
ai++;
|
|
3153
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
3154
|
+
result.push(b[bi]);
|
|
3155
|
+
bi++;
|
|
3156
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
3157
|
+
if (which === "b")
|
|
3158
|
+
return false;
|
|
3159
|
+
which = "a";
|
|
3160
|
+
result.push(a[ai]);
|
|
3161
|
+
ai++;
|
|
3162
|
+
bi++;
|
|
3163
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
3164
|
+
if (which === "a")
|
|
3165
|
+
return false;
|
|
3166
|
+
which = "b";
|
|
3167
|
+
result.push(b[bi]);
|
|
3168
|
+
ai++;
|
|
3169
|
+
bi++;
|
|
3170
|
+
} else {
|
|
3171
|
+
return false;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
return a.length === b.length && result;
|
|
3175
|
+
}
|
|
3176
|
+
parseNegate() {
|
|
3177
|
+
if (this.nonegate)
|
|
3178
|
+
return;
|
|
3179
|
+
const pattern = this.pattern;
|
|
3180
|
+
let negate = false;
|
|
3181
|
+
let negateOffset = 0;
|
|
3182
|
+
for (let i = 0;i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
3183
|
+
negate = !negate;
|
|
3184
|
+
negateOffset++;
|
|
3185
|
+
}
|
|
3186
|
+
if (negateOffset)
|
|
3187
|
+
this.pattern = pattern.slice(negateOffset);
|
|
3188
|
+
this.negate = negate;
|
|
3189
|
+
}
|
|
3190
|
+
matchOne(file, pattern, partial = false) {
|
|
3191
|
+
let fileStartIndex = 0;
|
|
3192
|
+
let patternStartIndex = 0;
|
|
3193
|
+
if (this.isWindows) {
|
|
3194
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
3195
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
3196
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
3197
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
3198
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
|
3199
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
|
3200
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
3201
|
+
const [fd, pd] = [
|
|
3202
|
+
file[fdi],
|
|
3203
|
+
pattern[pdi]
|
|
3204
|
+
];
|
|
3205
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
3206
|
+
pattern[pdi] = fd;
|
|
3207
|
+
patternStartIndex = pdi;
|
|
3208
|
+
fileStartIndex = fdi;
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
const { optimizationLevel = 1 } = this.options;
|
|
3213
|
+
if (optimizationLevel >= 2) {
|
|
3214
|
+
file = this.levelTwoFileOptimize(file);
|
|
3215
|
+
}
|
|
3216
|
+
if (pattern.includes(GLOBSTAR)) {
|
|
3217
|
+
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
3218
|
+
}
|
|
3219
|
+
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
3220
|
+
}
|
|
3221
|
+
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
3222
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
3223
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
3224
|
+
const [head, body, tail] = partial ? [
|
|
3225
|
+
pattern.slice(patternIndex, firstgs),
|
|
3226
|
+
pattern.slice(firstgs + 1),
|
|
3227
|
+
[]
|
|
3228
|
+
] : [
|
|
3229
|
+
pattern.slice(patternIndex, firstgs),
|
|
3230
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
3231
|
+
pattern.slice(lastgs + 1)
|
|
3232
|
+
];
|
|
3233
|
+
if (head.length) {
|
|
3234
|
+
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
3235
|
+
if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
|
|
3236
|
+
return false;
|
|
3237
|
+
}
|
|
3238
|
+
fileIndex += head.length;
|
|
3239
|
+
patternIndex += head.length;
|
|
3240
|
+
}
|
|
3241
|
+
let fileTailMatch = 0;
|
|
3242
|
+
if (tail.length) {
|
|
3243
|
+
if (tail.length + fileIndex > file.length)
|
|
3244
|
+
return false;
|
|
3245
|
+
let tailStart = file.length - tail.length;
|
|
3246
|
+
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
3247
|
+
fileTailMatch = tail.length;
|
|
3248
|
+
} else {
|
|
3249
|
+
if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
|
|
3250
|
+
return false;
|
|
3251
|
+
}
|
|
3252
|
+
tailStart--;
|
|
3253
|
+
if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
3254
|
+
return false;
|
|
3255
|
+
}
|
|
3256
|
+
fileTailMatch = tail.length + 1;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
if (!body.length) {
|
|
3260
|
+
let sawSome = !!fileTailMatch;
|
|
3261
|
+
for (let i2 = fileIndex;i2 < file.length - fileTailMatch; i2++) {
|
|
3262
|
+
const f = String(file[i2]);
|
|
3263
|
+
sawSome = true;
|
|
3264
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
3265
|
+
return false;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
return partial || sawSome;
|
|
3269
|
+
}
|
|
3270
|
+
const bodySegments = [[[], 0]];
|
|
3271
|
+
let currentBody = bodySegments[0];
|
|
3272
|
+
let nonGsParts = 0;
|
|
3273
|
+
const nonGsPartsSums = [0];
|
|
3274
|
+
for (const b of body) {
|
|
3275
|
+
if (b === GLOBSTAR) {
|
|
3276
|
+
nonGsPartsSums.push(nonGsParts);
|
|
3277
|
+
currentBody = [[], 0];
|
|
3278
|
+
bodySegments.push(currentBody);
|
|
3279
|
+
} else {
|
|
3280
|
+
currentBody[0].push(b);
|
|
3281
|
+
nonGsParts++;
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
let i = bodySegments.length - 1;
|
|
3285
|
+
const fileLength = file.length - fileTailMatch;
|
|
3286
|
+
for (const b of bodySegments) {
|
|
3287
|
+
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
3288
|
+
}
|
|
3289
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
3290
|
+
}
|
|
3291
|
+
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
3292
|
+
const bs = bodySegments[bodyIndex];
|
|
3293
|
+
if (!bs) {
|
|
3294
|
+
for (let i = fileIndex;i < file.length; i++) {
|
|
3295
|
+
sawTail = true;
|
|
3296
|
+
const f = file[i];
|
|
3297
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
3298
|
+
return false;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
return sawTail;
|
|
3302
|
+
}
|
|
3303
|
+
const [body, after] = bs;
|
|
3304
|
+
while (fileIndex <= after) {
|
|
3305
|
+
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
3306
|
+
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
3307
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
3308
|
+
if (sub !== false) {
|
|
3309
|
+
return sub;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
const f = file[fileIndex];
|
|
3313
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
3314
|
+
return false;
|
|
3315
|
+
}
|
|
3316
|
+
fileIndex++;
|
|
3317
|
+
}
|
|
3318
|
+
return partial || null;
|
|
3319
|
+
}
|
|
3320
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
3321
|
+
let fi;
|
|
3322
|
+
let pi;
|
|
3323
|
+
let pl;
|
|
3324
|
+
let fl;
|
|
3325
|
+
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length;fi < fl && pi < pl; fi++, pi++) {
|
|
3326
|
+
this.debug("matchOne loop");
|
|
3327
|
+
let p = pattern[pi];
|
|
3328
|
+
let f = file[fi];
|
|
3329
|
+
this.debug(pattern, p, f);
|
|
3330
|
+
if (p === false || p === GLOBSTAR) {
|
|
3331
|
+
return false;
|
|
3332
|
+
}
|
|
3333
|
+
let hit;
|
|
3334
|
+
if (typeof p === "string") {
|
|
3335
|
+
hit = f === p;
|
|
3336
|
+
this.debug("string match", p, f, hit);
|
|
3337
|
+
} else {
|
|
3338
|
+
hit = p.test(f);
|
|
3339
|
+
this.debug("pattern match", p, f, hit);
|
|
3340
|
+
}
|
|
3341
|
+
if (!hit)
|
|
3342
|
+
return false;
|
|
3343
|
+
}
|
|
3344
|
+
if (fi === fl && pi === pl) {
|
|
3345
|
+
return true;
|
|
3346
|
+
} else if (fi === fl) {
|
|
3347
|
+
return partial;
|
|
3348
|
+
} else if (pi === pl) {
|
|
3349
|
+
return fi === fl - 1 && file[fi] === "";
|
|
3350
|
+
} else {
|
|
3351
|
+
throw new Error("wtf?");
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
braceExpand() {
|
|
3355
|
+
return braceExpand(this.pattern, this.options);
|
|
3356
|
+
}
|
|
3357
|
+
parse(pattern) {
|
|
3358
|
+
assertValidPattern(pattern);
|
|
3359
|
+
const options = this.options;
|
|
3360
|
+
if (pattern === "**")
|
|
3361
|
+
return GLOBSTAR;
|
|
3362
|
+
if (pattern === "")
|
|
3363
|
+
return "";
|
|
3364
|
+
let m;
|
|
3365
|
+
let fastTest = null;
|
|
3366
|
+
if (m = pattern.match(starRE)) {
|
|
3367
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
3368
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
3369
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
3370
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
3371
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
3372
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
3373
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
3374
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
3375
|
+
fastTest = dotStarTest;
|
|
3376
|
+
}
|
|
3377
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
3378
|
+
if (fastTest && typeof re === "object") {
|
|
3379
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
3380
|
+
}
|
|
3381
|
+
return re;
|
|
3382
|
+
}
|
|
3383
|
+
makeRe() {
|
|
3384
|
+
if (this.regexp || this.regexp === false)
|
|
3385
|
+
return this.regexp;
|
|
3386
|
+
const set = this.set;
|
|
3387
|
+
if (!set.length) {
|
|
3388
|
+
this.regexp = false;
|
|
3389
|
+
return this.regexp;
|
|
3390
|
+
}
|
|
3391
|
+
const options = this.options;
|
|
3392
|
+
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
3393
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
3394
|
+
let re = set.map((pattern) => {
|
|
3395
|
+
const pp = pattern.map((p) => {
|
|
3396
|
+
if (p instanceof RegExp) {
|
|
3397
|
+
for (const f of p.flags.split(""))
|
|
3398
|
+
flags.add(f);
|
|
3399
|
+
}
|
|
3400
|
+
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
3401
|
+
});
|
|
3402
|
+
pp.forEach((p, i) => {
|
|
3403
|
+
const next = pp[i + 1];
|
|
3404
|
+
const prev = pp[i - 1];
|
|
3405
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
3406
|
+
return;
|
|
3407
|
+
}
|
|
3408
|
+
if (prev === undefined) {
|
|
3409
|
+
if (next !== undefined && next !== GLOBSTAR) {
|
|
3410
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
3411
|
+
} else {
|
|
3412
|
+
pp[i] = twoStar;
|
|
3413
|
+
}
|
|
3414
|
+
} else if (next === undefined) {
|
|
3415
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
3416
|
+
} else if (next !== GLOBSTAR) {
|
|
3417
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
3418
|
+
pp[i + 1] = GLOBSTAR;
|
|
3419
|
+
}
|
|
3420
|
+
});
|
|
3421
|
+
const filtered = pp.filter((p) => p !== GLOBSTAR);
|
|
3422
|
+
if (this.partial && filtered.length >= 1) {
|
|
3423
|
+
const prefixes = [];
|
|
3424
|
+
for (let i = 1;i <= filtered.length; i++) {
|
|
3425
|
+
prefixes.push(filtered.slice(0, i).join("/"));
|
|
3426
|
+
}
|
|
3427
|
+
return "(?:" + prefixes.join("|") + ")";
|
|
3428
|
+
}
|
|
3429
|
+
return filtered.join("/");
|
|
3430
|
+
}).join("|");
|
|
3431
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
3432
|
+
re = "^" + open + re + close + "$";
|
|
3433
|
+
if (this.partial) {
|
|
3434
|
+
re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
3435
|
+
}
|
|
3436
|
+
if (this.negate)
|
|
3437
|
+
re = "^(?!" + re + ").+$";
|
|
3438
|
+
try {
|
|
3439
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
3440
|
+
} catch {
|
|
3441
|
+
this.regexp = false;
|
|
3442
|
+
}
|
|
3443
|
+
return this.regexp;
|
|
3444
|
+
}
|
|
3445
|
+
slashSplit(p) {
|
|
3446
|
+
if (this.preserveMultipleSlashes) {
|
|
3447
|
+
return p.split("/");
|
|
3448
|
+
} else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
|
|
3449
|
+
return ["", ...p.split(/\/+/)];
|
|
3450
|
+
} else {
|
|
3451
|
+
return p.split(/\/+/);
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
match(f, partial = this.partial) {
|
|
3455
|
+
this.debug("match", f, this.pattern);
|
|
3456
|
+
if (this.comment) {
|
|
3457
|
+
return false;
|
|
3458
|
+
}
|
|
3459
|
+
if (this.empty) {
|
|
3460
|
+
return f === "";
|
|
3461
|
+
}
|
|
3462
|
+
if (f === "/" && partial) {
|
|
3463
|
+
return true;
|
|
3464
|
+
}
|
|
3465
|
+
const options = this.options;
|
|
3466
|
+
if (this.isWindows) {
|
|
3467
|
+
f = f.split("\\").join("/");
|
|
3468
|
+
}
|
|
3469
|
+
const ff = this.slashSplit(f);
|
|
3470
|
+
this.debug(this.pattern, "split", ff);
|
|
3471
|
+
const set = this.set;
|
|
3472
|
+
this.debug(this.pattern, "set", set);
|
|
3473
|
+
let filename = ff[ff.length - 1];
|
|
3474
|
+
if (!filename) {
|
|
3475
|
+
for (let i = ff.length - 2;!filename && i >= 0; i--) {
|
|
3476
|
+
filename = ff[i];
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
for (const pattern of set) {
|
|
3480
|
+
let file = ff;
|
|
3481
|
+
if (options.matchBase && pattern.length === 1) {
|
|
3482
|
+
file = [filename];
|
|
3483
|
+
}
|
|
3484
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
3485
|
+
if (hit) {
|
|
3486
|
+
if (options.flipNegate) {
|
|
3487
|
+
return true;
|
|
3488
|
+
}
|
|
3489
|
+
return !this.negate;
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
if (options.flipNegate) {
|
|
3493
|
+
return false;
|
|
3494
|
+
}
|
|
3495
|
+
return this.negate;
|
|
3496
|
+
}
|
|
3497
|
+
static defaults(def) {
|
|
3498
|
+
return minimatch.defaults(def).Minimatch;
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
minimatch.AST = AST;
|
|
3502
|
+
minimatch.Minimatch = Minimatch;
|
|
3503
|
+
minimatch.escape = escape;
|
|
3504
|
+
minimatch.unescape = unescape;
|
|
3505
|
+
|
|
3506
|
+
// src/feature/bundle/build/rolldown.ts
|
|
3507
|
+
import { rolldown } from "rolldown";
|
|
3508
|
+
|
|
3509
|
+
// ../../node_modules/.pnpm/@rollup+pluginutils@5.4.0_rollup@4.62.4/node_modules/@rollup/pluginutils/dist/es/index.js
|
|
3510
|
+
import { extname, win32, posix, isAbsolute, resolve } from "path";
|
|
3511
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
3512
|
+
function isArray(arg) {
|
|
3513
|
+
return Array.isArray(arg);
|
|
3514
|
+
}
|
|
3515
|
+
function ensureArray(thing) {
|
|
3516
|
+
if (isArray(thing))
|
|
3517
|
+
return thing;
|
|
3518
|
+
if (thing == null)
|
|
3519
|
+
return [];
|
|
3520
|
+
return [thing];
|
|
3521
|
+
}
|
|
3522
|
+
var normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
|
|
3523
|
+
var normalizePath = function normalizePath2(filename) {
|
|
3524
|
+
return filename.replace(normalizePathRegExp, posix.sep);
|
|
3525
|
+
};
|
|
3526
|
+
function getMatcherString(id, resolutionBase) {
|
|
3527
|
+
if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) {
|
|
3528
|
+
return normalizePath(id);
|
|
3529
|
+
}
|
|
3530
|
+
const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
|
|
3531
|
+
return posix.join(basePath, normalizePath(id));
|
|
3532
|
+
}
|
|
3533
|
+
var createFilter = function createFilter2(include, exclude, options) {
|
|
3534
|
+
const resolutionBase = options && options.resolve;
|
|
3535
|
+
const getMatcher = (id) => id instanceof RegExp ? id : {
|
|
3536
|
+
test: (what) => {
|
|
3537
|
+
const pattern = getMatcherString(id, resolutionBase);
|
|
3538
|
+
const fn = import_picomatch.default(pattern, { dot: true });
|
|
3539
|
+
const result = fn(what);
|
|
3540
|
+
return result;
|
|
3541
|
+
}
|
|
3542
|
+
};
|
|
3543
|
+
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
3544
|
+
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
3545
|
+
if (!includeMatchers.length && !excludeMatchers.length)
|
|
3546
|
+
return (id) => typeof id === "string" && !id.includes("\x00");
|
|
3547
|
+
return function result(id) {
|
|
3548
|
+
if (typeof id !== "string")
|
|
3549
|
+
return false;
|
|
3550
|
+
if (id.includes("\x00"))
|
|
3551
|
+
return false;
|
|
3552
|
+
const pathId = normalizePath(id);
|
|
3553
|
+
for (let i = 0;i < excludeMatchers.length; ++i) {
|
|
3554
|
+
const matcher = excludeMatchers[i];
|
|
3555
|
+
if (matcher instanceof RegExp) {
|
|
3556
|
+
matcher.lastIndex = 0;
|
|
3557
|
+
}
|
|
3558
|
+
if (matcher.test(pathId))
|
|
3559
|
+
return false;
|
|
3560
|
+
}
|
|
3561
|
+
for (let i = 0;i < includeMatchers.length; ++i) {
|
|
3562
|
+
const matcher = includeMatchers[i];
|
|
3563
|
+
if (matcher instanceof RegExp) {
|
|
3564
|
+
matcher.lastIndex = 0;
|
|
3565
|
+
}
|
|
3566
|
+
if (matcher.test(pathId))
|
|
3567
|
+
return true;
|
|
3568
|
+
}
|
|
3569
|
+
return !includeMatchers.length;
|
|
3570
|
+
};
|
|
3571
|
+
};
|
|
3572
|
+
var reservedWords = "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";
|
|
3573
|
+
var builtins = "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";
|
|
3574
|
+
var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
3575
|
+
forbiddenIdentifiers.add("");
|
|
3576
|
+
var hasStringIsWellFormed = "isWellFormed" in String.prototype;
|
|
3577
|
+
|
|
3578
|
+
// ../../node_modules/.pnpm/rollup-plugin-string-import@1.2.6_rollup@4.62.4/node_modules/rollup-plugin-string-import/dist/index.js
|
|
3579
|
+
function importAsString(options) {
|
|
3580
|
+
const { include, exclude, transform = (content) => content } = options;
|
|
3581
|
+
const filter2 = createFilter(include, exclude);
|
|
3582
|
+
return {
|
|
3583
|
+
name: "importAsString",
|
|
3584
|
+
transform(code, id) {
|
|
3585
|
+
if (filter2(id)) {
|
|
3586
|
+
const content = transform(code, id).replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
|
|
3587
|
+
return {
|
|
3588
|
+
code: `export default \`${content}\`;`,
|
|
3589
|
+
map: { mappings: "" }
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
// src/cli/debug.ts
|
|
3597
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "fs";
|
|
3598
|
+
import { join as join2 } from "path";
|
|
3599
|
+
var debugLogFile = join2(directories.output, "debug.log");
|
|
3600
|
+
var ready = false;
|
|
3601
|
+
var clearDebugLog = () => {
|
|
3602
|
+
try {
|
|
3603
|
+
mkdirSync(directories.output, { recursive: true });
|
|
3604
|
+
writeFileSync(debugLogFile, "");
|
|
3605
|
+
ready = true;
|
|
3606
|
+
} catch {}
|
|
3607
|
+
};
|
|
3608
|
+
var sink;
|
|
3609
|
+
var write = (type, message) => {
|
|
3610
|
+
try {
|
|
3611
|
+
if (!ready) {
|
|
3612
|
+
clearDebugLog();
|
|
3613
|
+
}
|
|
3614
|
+
appendFileSync(debugLogFile, `${new Date().toISOString()} [${type}] ${message}
|
|
3615
|
+
`);
|
|
3616
|
+
sink?.(type, message);
|
|
3617
|
+
} catch {}
|
|
3618
|
+
};
|
|
3619
|
+
var format = (parts) => {
|
|
3620
|
+
return parts.map((part) => {
|
|
3621
|
+
if (typeof part === "string") {
|
|
3622
|
+
return part;
|
|
3623
|
+
}
|
|
3624
|
+
if (part instanceof Error) {
|
|
3625
|
+
return part.stack ?? part.message;
|
|
3626
|
+
}
|
|
3627
|
+
if (Array.isArray(part)) {
|
|
3628
|
+
return part.map((entry) => format([entry])).join(`
|
|
3629
|
+
`);
|
|
3630
|
+
}
|
|
3631
|
+
return JSON.stringify(part);
|
|
3632
|
+
}).join(" ");
|
|
3633
|
+
};
|
|
3634
|
+
var debugError = (error) => {
|
|
3635
|
+
write("error", format([error]));
|
|
3636
|
+
};
|
|
3637
|
+
|
|
3638
|
+
// src/feature/bundle/build/rolldown.ts
|
|
3639
|
+
var ROUTE_MODULE_QUERY = "?awsless-route=";
|
|
3640
|
+
var createModuleMatcher = (patterns = []) => {
|
|
3641
|
+
const globs = patterns.map((pattern) => {
|
|
3642
|
+
return new Minimatch(pattern.replaceAll("\\", "/"), { dot: true });
|
|
3643
|
+
});
|
|
3644
|
+
return (id) => {
|
|
3645
|
+
const path2 = id.replaceAll("\\", "/");
|
|
3646
|
+
return globs.some((glob) => glob.match(path2));
|
|
3647
|
+
};
|
|
3648
|
+
};
|
|
3649
|
+
var bundleTypeScriptInProcess = async (props) => {
|
|
3650
|
+
const { format: format2 = "esm", minify = true } = props;
|
|
3651
|
+
const hasModuleSideEffects = createModuleMatcher(props.moduleSideEffects);
|
|
3652
|
+
const bundle = await rolldown({
|
|
3653
|
+
input: props.file,
|
|
3654
|
+
platform: "node",
|
|
3655
|
+
transform: {
|
|
3656
|
+
define: {
|
|
3657
|
+
"process.env.NODE_ENV": JSON.stringify("production")
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3660
|
+
external: (importee) => {
|
|
3661
|
+
return importee.startsWith("@aws-sdk") || importee.startsWith("aws-sdk") || props.external?.includes(importee);
|
|
3662
|
+
},
|
|
3663
|
+
treeshake: {
|
|
3664
|
+
moduleSideEffects: (id, isExternal) => isExternal ? props.external?.includes(id) === true : hasModuleSideEffects(id) || id.startsWith(`${directories.root}/`) && !id.includes("/node_modules/")
|
|
3665
|
+
},
|
|
3666
|
+
onwarn: (error) => {
|
|
3667
|
+
if (error.code === "UNRESOLVED_IMPORT") {
|
|
3668
|
+
throw new ExpectedError(error.message);
|
|
3669
|
+
}
|
|
3670
|
+
debugError(error.message);
|
|
3671
|
+
},
|
|
3672
|
+
plugins: [
|
|
3673
|
+
routeModulePlugin(),
|
|
3674
|
+
props.importAsString ? importAsString({
|
|
3675
|
+
include: props.importAsString
|
|
3676
|
+
}) : undefined
|
|
3677
|
+
]
|
|
3678
|
+
});
|
|
3679
|
+
const extension = format2 === "esm" ? "mjs" : "js";
|
|
3680
|
+
let result;
|
|
3681
|
+
try {
|
|
3682
|
+
result = await bundle.generate({
|
|
3683
|
+
format: format2,
|
|
3684
|
+
sourcemap: "hidden",
|
|
3685
|
+
exports: "auto",
|
|
3686
|
+
minify,
|
|
3687
|
+
entryFileNames: `index.${extension}`,
|
|
3688
|
+
chunkFileNames: (chunk) => {
|
|
3689
|
+
const encodedRouteKey = chunk.facadeModuleId?.split(ROUTE_MODULE_QUERY)[1];
|
|
3690
|
+
if (!encodedRouteKey) {
|
|
3691
|
+
return `[name].${extension}`;
|
|
3692
|
+
}
|
|
3693
|
+
const routeKey = decodeURIComponent(encodedRouteKey);
|
|
3694
|
+
return `${routeKey.replaceAll(":", "--")}.${extension}`;
|
|
3695
|
+
}
|
|
3696
|
+
});
|
|
3697
|
+
} finally {
|
|
3698
|
+
await bundle.close();
|
|
3699
|
+
}
|
|
3700
|
+
const hash = createHash("sha1");
|
|
3701
|
+
const files = [];
|
|
3702
|
+
for (const item of result.output) {
|
|
3703
|
+
if (item.type !== "chunk") {
|
|
3704
|
+
continue;
|
|
3705
|
+
}
|
|
3706
|
+
const code = Buffer.from(item.code, "utf8");
|
|
3707
|
+
const map = item.map ? Buffer.from(item.map.toString(), "utf8") : undefined;
|
|
3708
|
+
hash.update(item.fileName);
|
|
3709
|
+
hash.update(code);
|
|
3710
|
+
files.push({
|
|
3711
|
+
name: item.fileName,
|
|
3712
|
+
code,
|
|
3713
|
+
map
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
return {
|
|
3717
|
+
hash: hash.digest("hex"),
|
|
3718
|
+
files
|
|
3719
|
+
};
|
|
3720
|
+
};
|
|
3721
|
+
var routeModulePlugin = () => ({
|
|
3722
|
+
name: "route-module",
|
|
3723
|
+
resolveId(source) {
|
|
3724
|
+
return source.includes(ROUTE_MODULE_QUERY) ? source : undefined;
|
|
3725
|
+
},
|
|
3726
|
+
async load(id) {
|
|
3727
|
+
const [file, routeKey] = id.split(ROUTE_MODULE_QUERY);
|
|
3728
|
+
if (!file || !routeKey) {
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3731
|
+
const extension = extname2(file);
|
|
3732
|
+
return {
|
|
3733
|
+
code: await readFile(file, "utf8"),
|
|
3734
|
+
moduleType: extension === ".tsx" ? "tsx" : extension === ".jsx" ? "jsx" : "ts"
|
|
3735
|
+
};
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
|
|
3739
|
+
// src/feature/bundle/build/rolldown-worker.ts
|
|
3740
|
+
var chunks = [];
|
|
3741
|
+
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
3742
|
+
process.stdin.on("end", async () => {
|
|
3743
|
+
let output;
|
|
3744
|
+
try {
|
|
3745
|
+
const { root: root2, props } = JSON.parse(Buffer.concat(chunks).toString());
|
|
3746
|
+
setRoot(root2);
|
|
3747
|
+
const result = await bundleTypeScriptInProcess(props);
|
|
3748
|
+
output = JSON.stringify({
|
|
3749
|
+
ok: true,
|
|
3750
|
+
hash: result.hash,
|
|
3751
|
+
files: result.files.map((file) => ({
|
|
3752
|
+
name: file.name,
|
|
3753
|
+
code: file.code.toString("base64"),
|
|
3754
|
+
map: file.map?.toString("base64")
|
|
3755
|
+
}))
|
|
3756
|
+
});
|
|
3757
|
+
} catch (error) {
|
|
3758
|
+
output = JSON.stringify({
|
|
3759
|
+
ok: false,
|
|
3760
|
+
expected: error instanceof ExpectedError,
|
|
3761
|
+
message: error instanceof Error ? error.message : String(error)
|
|
3762
|
+
});
|
|
3763
|
+
}
|
|
3764
|
+
process.stdout.write(output, () => process.exit(0));
|
|
3765
|
+
});
|