unplugin-raw 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/chunk-RQWTRTVO.mjs +1710 -0
- package/dist/chunk-Y6TXJ2BX.js +1710 -0
- package/dist/esbuild.d.mts +7 -0
- package/dist/esbuild.d.ts +7 -0
- package/dist/esbuild.js +11 -0
- package/dist/esbuild.mjs +9 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +8 -0
- package/dist/index.mjs +8 -0
- package/dist/options-O-dLpMHU.d.mts +18 -0
- package/dist/options-O-dLpMHU.d.ts +18 -0
- package/dist/rollup.d.mts +8 -0
- package/dist/rollup.d.ts +8 -0
- package/dist/rollup.js +11 -0
- package/dist/rollup.mjs +9 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +11 -0
- package/dist/vite.mjs +9 -0
- package/dist/webpack.d.mts +7 -0
- package/dist/webpack.d.ts +7 -0
- package/dist/webpack.js +11 -0
- package/dist/webpack.mjs +9 -0
- package/package.json +98 -0
|
@@ -0,0 +1,1710 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined")
|
|
11
|
+
return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
|
|
35
|
+
var require_constants = __commonJS({
|
|
36
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var path2 = __require("path");
|
|
39
|
+
var WIN_SLASH = "\\\\/";
|
|
40
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
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 POSIX_CHARS = {
|
|
57
|
+
DOT_LITERAL,
|
|
58
|
+
PLUS_LITERAL,
|
|
59
|
+
QMARK_LITERAL,
|
|
60
|
+
SLASH_LITERAL,
|
|
61
|
+
ONE_CHAR,
|
|
62
|
+
QMARK,
|
|
63
|
+
END_ANCHOR,
|
|
64
|
+
DOTS_SLASH,
|
|
65
|
+
NO_DOT,
|
|
66
|
+
NO_DOTS,
|
|
67
|
+
NO_DOT_SLASH,
|
|
68
|
+
NO_DOTS_SLASH,
|
|
69
|
+
QMARK_NO_DOT,
|
|
70
|
+
STAR,
|
|
71
|
+
START_ANCHOR
|
|
72
|
+
};
|
|
73
|
+
var WINDOWS_CHARS = {
|
|
74
|
+
...POSIX_CHARS,
|
|
75
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
76
|
+
QMARK: WIN_NO_SLASH,
|
|
77
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
78
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
79
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
80
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
81
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
82
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
83
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
84
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
85
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
86
|
+
};
|
|
87
|
+
var POSIX_REGEX_SOURCE = {
|
|
88
|
+
alnum: "a-zA-Z0-9",
|
|
89
|
+
alpha: "a-zA-Z",
|
|
90
|
+
ascii: "\\x00-\\x7F",
|
|
91
|
+
blank: " \\t",
|
|
92
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
93
|
+
digit: "0-9",
|
|
94
|
+
graph: "\\x21-\\x7E",
|
|
95
|
+
lower: "a-z",
|
|
96
|
+
print: "\\x20-\\x7E ",
|
|
97
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
98
|
+
space: " \\t\\r\\n\\v\\f",
|
|
99
|
+
upper: "A-Z",
|
|
100
|
+
word: "A-Za-z0-9_",
|
|
101
|
+
xdigit: "A-Fa-f0-9"
|
|
102
|
+
};
|
|
103
|
+
module.exports = {
|
|
104
|
+
MAX_LENGTH: 1024 * 64,
|
|
105
|
+
POSIX_REGEX_SOURCE,
|
|
106
|
+
// regular expressions
|
|
107
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
108
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
109
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
110
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
111
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
112
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
113
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
114
|
+
REPLACEMENTS: {
|
|
115
|
+
"***": "*",
|
|
116
|
+
"**/**": "**",
|
|
117
|
+
"**/**/**": "**"
|
|
118
|
+
},
|
|
119
|
+
// Digits
|
|
120
|
+
CHAR_0: 48,
|
|
121
|
+
/* 0 */
|
|
122
|
+
CHAR_9: 57,
|
|
123
|
+
/* 9 */
|
|
124
|
+
// Alphabet chars.
|
|
125
|
+
CHAR_UPPERCASE_A: 65,
|
|
126
|
+
/* A */
|
|
127
|
+
CHAR_LOWERCASE_A: 97,
|
|
128
|
+
/* a */
|
|
129
|
+
CHAR_UPPERCASE_Z: 90,
|
|
130
|
+
/* Z */
|
|
131
|
+
CHAR_LOWERCASE_Z: 122,
|
|
132
|
+
/* z */
|
|
133
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
134
|
+
/* ( */
|
|
135
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
136
|
+
/* ) */
|
|
137
|
+
CHAR_ASTERISK: 42,
|
|
138
|
+
/* * */
|
|
139
|
+
// Non-alphabetic chars.
|
|
140
|
+
CHAR_AMPERSAND: 38,
|
|
141
|
+
/* & */
|
|
142
|
+
CHAR_AT: 64,
|
|
143
|
+
/* @ */
|
|
144
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
145
|
+
/* \ */
|
|
146
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
147
|
+
/* \r */
|
|
148
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
149
|
+
/* ^ */
|
|
150
|
+
CHAR_COLON: 58,
|
|
151
|
+
/* : */
|
|
152
|
+
CHAR_COMMA: 44,
|
|
153
|
+
/* , */
|
|
154
|
+
CHAR_DOT: 46,
|
|
155
|
+
/* . */
|
|
156
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
157
|
+
/* " */
|
|
158
|
+
CHAR_EQUAL: 61,
|
|
159
|
+
/* = */
|
|
160
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
161
|
+
/* ! */
|
|
162
|
+
CHAR_FORM_FEED: 12,
|
|
163
|
+
/* \f */
|
|
164
|
+
CHAR_FORWARD_SLASH: 47,
|
|
165
|
+
/* / */
|
|
166
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
167
|
+
/* ` */
|
|
168
|
+
CHAR_HASH: 35,
|
|
169
|
+
/* # */
|
|
170
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
171
|
+
/* - */
|
|
172
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
173
|
+
/* < */
|
|
174
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
175
|
+
/* { */
|
|
176
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
177
|
+
/* [ */
|
|
178
|
+
CHAR_LINE_FEED: 10,
|
|
179
|
+
/* \n */
|
|
180
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
181
|
+
/* \u00A0 */
|
|
182
|
+
CHAR_PERCENT: 37,
|
|
183
|
+
/* % */
|
|
184
|
+
CHAR_PLUS: 43,
|
|
185
|
+
/* + */
|
|
186
|
+
CHAR_QUESTION_MARK: 63,
|
|
187
|
+
/* ? */
|
|
188
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
189
|
+
/* > */
|
|
190
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
191
|
+
/* } */
|
|
192
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
193
|
+
/* ] */
|
|
194
|
+
CHAR_SEMICOLON: 59,
|
|
195
|
+
/* ; */
|
|
196
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
197
|
+
/* ' */
|
|
198
|
+
CHAR_SPACE: 32,
|
|
199
|
+
/* */
|
|
200
|
+
CHAR_TAB: 9,
|
|
201
|
+
/* \t */
|
|
202
|
+
CHAR_UNDERSCORE: 95,
|
|
203
|
+
/* _ */
|
|
204
|
+
CHAR_VERTICAL_LINE: 124,
|
|
205
|
+
/* | */
|
|
206
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
207
|
+
/* \uFEFF */
|
|
208
|
+
SEP: path2.sep,
|
|
209
|
+
/**
|
|
210
|
+
* Create EXTGLOB_CHARS
|
|
211
|
+
*/
|
|
212
|
+
extglobChars(chars) {
|
|
213
|
+
return {
|
|
214
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
215
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
216
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
217
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
218
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
/**
|
|
222
|
+
* Create GLOB_CHARS
|
|
223
|
+
*/
|
|
224
|
+
globChars(win322) {
|
|
225
|
+
return win322 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
|
|
232
|
+
var require_utils = __commonJS({
|
|
233
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports) {
|
|
234
|
+
"use strict";
|
|
235
|
+
var path2 = __require("path");
|
|
236
|
+
var win322 = process.platform === "win32";
|
|
237
|
+
var {
|
|
238
|
+
REGEX_BACKSLASH,
|
|
239
|
+
REGEX_REMOVE_BACKSLASH,
|
|
240
|
+
REGEX_SPECIAL_CHARS,
|
|
241
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
242
|
+
} = require_constants();
|
|
243
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
244
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
245
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
246
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
247
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
248
|
+
exports.removeBackslashes = (str) => {
|
|
249
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
250
|
+
return match === "\\" ? "" : match;
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
exports.supportsLookbehinds = () => {
|
|
254
|
+
const segs = process.version.slice(1).split(".").map(Number);
|
|
255
|
+
if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
};
|
|
260
|
+
exports.isWindows = (options) => {
|
|
261
|
+
if (options && typeof options.windows === "boolean") {
|
|
262
|
+
return options.windows;
|
|
263
|
+
}
|
|
264
|
+
return win322 === true || path2.sep === "\\";
|
|
265
|
+
};
|
|
266
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
267
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
268
|
+
if (idx === -1)
|
|
269
|
+
return input;
|
|
270
|
+
if (input[idx - 1] === "\\")
|
|
271
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
272
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
273
|
+
};
|
|
274
|
+
exports.removePrefix = (input, state = {}) => {
|
|
275
|
+
let output = input;
|
|
276
|
+
if (output.startsWith("./")) {
|
|
277
|
+
output = output.slice(2);
|
|
278
|
+
state.prefix = "./";
|
|
279
|
+
}
|
|
280
|
+
return output;
|
|
281
|
+
};
|
|
282
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
283
|
+
const prepend = options.contains ? "" : "^";
|
|
284
|
+
const append = options.contains ? "" : "$";
|
|
285
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
286
|
+
if (state.negated === true) {
|
|
287
|
+
output = `(?:^(?!${output}).*$)`;
|
|
288
|
+
}
|
|
289
|
+
return output;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/scan.js
|
|
295
|
+
var require_scan = __commonJS({
|
|
296
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
297
|
+
"use strict";
|
|
298
|
+
var utils = require_utils();
|
|
299
|
+
var {
|
|
300
|
+
CHAR_ASTERISK,
|
|
301
|
+
/* * */
|
|
302
|
+
CHAR_AT,
|
|
303
|
+
/* @ */
|
|
304
|
+
CHAR_BACKWARD_SLASH,
|
|
305
|
+
/* \ */
|
|
306
|
+
CHAR_COMMA,
|
|
307
|
+
/* , */
|
|
308
|
+
CHAR_DOT,
|
|
309
|
+
/* . */
|
|
310
|
+
CHAR_EXCLAMATION_MARK,
|
|
311
|
+
/* ! */
|
|
312
|
+
CHAR_FORWARD_SLASH,
|
|
313
|
+
/* / */
|
|
314
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
315
|
+
/* { */
|
|
316
|
+
CHAR_LEFT_PARENTHESES,
|
|
317
|
+
/* ( */
|
|
318
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
319
|
+
/* [ */
|
|
320
|
+
CHAR_PLUS,
|
|
321
|
+
/* + */
|
|
322
|
+
CHAR_QUESTION_MARK,
|
|
323
|
+
/* ? */
|
|
324
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
325
|
+
/* } */
|
|
326
|
+
CHAR_RIGHT_PARENTHESES,
|
|
327
|
+
/* ) */
|
|
328
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
329
|
+
/* ] */
|
|
330
|
+
} = require_constants();
|
|
331
|
+
var isPathSeparator = (code) => {
|
|
332
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
333
|
+
};
|
|
334
|
+
var depth = (token) => {
|
|
335
|
+
if (token.isPrefix !== true) {
|
|
336
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var scan = (input, options) => {
|
|
340
|
+
const opts = options || {};
|
|
341
|
+
const length = input.length - 1;
|
|
342
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
343
|
+
const slashes = [];
|
|
344
|
+
const tokens = [];
|
|
345
|
+
const parts = [];
|
|
346
|
+
let str = input;
|
|
347
|
+
let index = -1;
|
|
348
|
+
let start = 0;
|
|
349
|
+
let lastIndex = 0;
|
|
350
|
+
let isBrace = false;
|
|
351
|
+
let isBracket = false;
|
|
352
|
+
let isGlob = false;
|
|
353
|
+
let isExtglob = false;
|
|
354
|
+
let isGlobstar = false;
|
|
355
|
+
let braceEscaped = false;
|
|
356
|
+
let backslashes = false;
|
|
357
|
+
let negated = false;
|
|
358
|
+
let negatedExtglob = false;
|
|
359
|
+
let finished = false;
|
|
360
|
+
let braces = 0;
|
|
361
|
+
let prev;
|
|
362
|
+
let code;
|
|
363
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
364
|
+
const eos = () => index >= length;
|
|
365
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
366
|
+
const advance = () => {
|
|
367
|
+
prev = code;
|
|
368
|
+
return str.charCodeAt(++index);
|
|
369
|
+
};
|
|
370
|
+
while (index < length) {
|
|
371
|
+
code = advance();
|
|
372
|
+
let next;
|
|
373
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
374
|
+
backslashes = token.backslashes = true;
|
|
375
|
+
code = advance();
|
|
376
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
377
|
+
braceEscaped = true;
|
|
378
|
+
}
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
382
|
+
braces++;
|
|
383
|
+
while (eos() !== true && (code = advance())) {
|
|
384
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
385
|
+
backslashes = token.backslashes = true;
|
|
386
|
+
advance();
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
390
|
+
braces++;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
394
|
+
isBrace = token.isBrace = true;
|
|
395
|
+
isGlob = token.isGlob = true;
|
|
396
|
+
finished = true;
|
|
397
|
+
if (scanToEnd === true) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
403
|
+
isBrace = token.isBrace = true;
|
|
404
|
+
isGlob = token.isGlob = true;
|
|
405
|
+
finished = true;
|
|
406
|
+
if (scanToEnd === true) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
412
|
+
braces--;
|
|
413
|
+
if (braces === 0) {
|
|
414
|
+
braceEscaped = false;
|
|
415
|
+
isBrace = token.isBrace = true;
|
|
416
|
+
finished = true;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (scanToEnd === true) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
427
|
+
slashes.push(index);
|
|
428
|
+
tokens.push(token);
|
|
429
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
430
|
+
if (finished === true)
|
|
431
|
+
continue;
|
|
432
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
433
|
+
start += 2;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
lastIndex = index + 1;
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (opts.noext !== true) {
|
|
440
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
441
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
442
|
+
isGlob = token.isGlob = true;
|
|
443
|
+
isExtglob = token.isExtglob = true;
|
|
444
|
+
finished = true;
|
|
445
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
446
|
+
negatedExtglob = true;
|
|
447
|
+
}
|
|
448
|
+
if (scanToEnd === true) {
|
|
449
|
+
while (eos() !== true && (code = advance())) {
|
|
450
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
451
|
+
backslashes = token.backslashes = true;
|
|
452
|
+
code = advance();
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
456
|
+
isGlob = token.isGlob = true;
|
|
457
|
+
finished = true;
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (code === CHAR_ASTERISK) {
|
|
467
|
+
if (prev === CHAR_ASTERISK)
|
|
468
|
+
isGlobstar = token.isGlobstar = true;
|
|
469
|
+
isGlob = token.isGlob = true;
|
|
470
|
+
finished = true;
|
|
471
|
+
if (scanToEnd === true) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
477
|
+
isGlob = token.isGlob = true;
|
|
478
|
+
finished = true;
|
|
479
|
+
if (scanToEnd === true) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
485
|
+
while (eos() !== true && (next = advance())) {
|
|
486
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
487
|
+
backslashes = token.backslashes = true;
|
|
488
|
+
advance();
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
492
|
+
isBracket = token.isBracket = true;
|
|
493
|
+
isGlob = token.isGlob = true;
|
|
494
|
+
finished = true;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (scanToEnd === true) {
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
504
|
+
negated = token.negated = true;
|
|
505
|
+
start++;
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
509
|
+
isGlob = token.isGlob = true;
|
|
510
|
+
if (scanToEnd === true) {
|
|
511
|
+
while (eos() !== true && (code = advance())) {
|
|
512
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
513
|
+
backslashes = token.backslashes = true;
|
|
514
|
+
code = advance();
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
518
|
+
finished = true;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
if (isGlob === true) {
|
|
527
|
+
finished = true;
|
|
528
|
+
if (scanToEnd === true) {
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (opts.noext === true) {
|
|
535
|
+
isExtglob = false;
|
|
536
|
+
isGlob = false;
|
|
537
|
+
}
|
|
538
|
+
let base = str;
|
|
539
|
+
let prefix = "";
|
|
540
|
+
let glob = "";
|
|
541
|
+
if (start > 0) {
|
|
542
|
+
prefix = str.slice(0, start);
|
|
543
|
+
str = str.slice(start);
|
|
544
|
+
lastIndex -= start;
|
|
545
|
+
}
|
|
546
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
547
|
+
base = str.slice(0, lastIndex);
|
|
548
|
+
glob = str.slice(lastIndex);
|
|
549
|
+
} else if (isGlob === true) {
|
|
550
|
+
base = "";
|
|
551
|
+
glob = str;
|
|
552
|
+
} else {
|
|
553
|
+
base = str;
|
|
554
|
+
}
|
|
555
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
556
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
557
|
+
base = base.slice(0, -1);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (opts.unescape === true) {
|
|
561
|
+
if (glob)
|
|
562
|
+
glob = utils.removeBackslashes(glob);
|
|
563
|
+
if (base && backslashes === true) {
|
|
564
|
+
base = utils.removeBackslashes(base);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
const state = {
|
|
568
|
+
prefix,
|
|
569
|
+
input,
|
|
570
|
+
start,
|
|
571
|
+
base,
|
|
572
|
+
glob,
|
|
573
|
+
isBrace,
|
|
574
|
+
isBracket,
|
|
575
|
+
isGlob,
|
|
576
|
+
isExtglob,
|
|
577
|
+
isGlobstar,
|
|
578
|
+
negated,
|
|
579
|
+
negatedExtglob
|
|
580
|
+
};
|
|
581
|
+
if (opts.tokens === true) {
|
|
582
|
+
state.maxDepth = 0;
|
|
583
|
+
if (!isPathSeparator(code)) {
|
|
584
|
+
tokens.push(token);
|
|
585
|
+
}
|
|
586
|
+
state.tokens = tokens;
|
|
587
|
+
}
|
|
588
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
589
|
+
let prevIndex;
|
|
590
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
591
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
592
|
+
const i = slashes[idx];
|
|
593
|
+
const value = input.slice(n, i);
|
|
594
|
+
if (opts.tokens) {
|
|
595
|
+
if (idx === 0 && start !== 0) {
|
|
596
|
+
tokens[idx].isPrefix = true;
|
|
597
|
+
tokens[idx].value = prefix;
|
|
598
|
+
} else {
|
|
599
|
+
tokens[idx].value = value;
|
|
600
|
+
}
|
|
601
|
+
depth(tokens[idx]);
|
|
602
|
+
state.maxDepth += tokens[idx].depth;
|
|
603
|
+
}
|
|
604
|
+
if (idx !== 0 || value !== "") {
|
|
605
|
+
parts.push(value);
|
|
606
|
+
}
|
|
607
|
+
prevIndex = i;
|
|
608
|
+
}
|
|
609
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
610
|
+
const value = input.slice(prevIndex + 1);
|
|
611
|
+
parts.push(value);
|
|
612
|
+
if (opts.tokens) {
|
|
613
|
+
tokens[tokens.length - 1].value = value;
|
|
614
|
+
depth(tokens[tokens.length - 1]);
|
|
615
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
state.slashes = slashes;
|
|
619
|
+
state.parts = parts;
|
|
620
|
+
}
|
|
621
|
+
return state;
|
|
622
|
+
};
|
|
623
|
+
module.exports = scan;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/parse.js
|
|
628
|
+
var require_parse = __commonJS({
|
|
629
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
630
|
+
"use strict";
|
|
631
|
+
var constants = require_constants();
|
|
632
|
+
var utils = require_utils();
|
|
633
|
+
var {
|
|
634
|
+
MAX_LENGTH,
|
|
635
|
+
POSIX_REGEX_SOURCE,
|
|
636
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
637
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
638
|
+
REPLACEMENTS
|
|
639
|
+
} = constants;
|
|
640
|
+
var expandRange = (args, options) => {
|
|
641
|
+
if (typeof options.expandRange === "function") {
|
|
642
|
+
return options.expandRange(...args, options);
|
|
643
|
+
}
|
|
644
|
+
args.sort();
|
|
645
|
+
const value = `[${args.join("-")}]`;
|
|
646
|
+
try {
|
|
647
|
+
new RegExp(value);
|
|
648
|
+
} catch (ex) {
|
|
649
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
650
|
+
}
|
|
651
|
+
return value;
|
|
652
|
+
};
|
|
653
|
+
var syntaxError = (type, char) => {
|
|
654
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
655
|
+
};
|
|
656
|
+
var parse = (input, options) => {
|
|
657
|
+
if (typeof input !== "string") {
|
|
658
|
+
throw new TypeError("Expected a string");
|
|
659
|
+
}
|
|
660
|
+
input = REPLACEMENTS[input] || input;
|
|
661
|
+
const opts = { ...options };
|
|
662
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
663
|
+
let len = input.length;
|
|
664
|
+
if (len > max) {
|
|
665
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
666
|
+
}
|
|
667
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
668
|
+
const tokens = [bos];
|
|
669
|
+
const capture = opts.capture ? "" : "?:";
|
|
670
|
+
const win322 = utils.isWindows(options);
|
|
671
|
+
const PLATFORM_CHARS = constants.globChars(win322);
|
|
672
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
673
|
+
const {
|
|
674
|
+
DOT_LITERAL,
|
|
675
|
+
PLUS_LITERAL,
|
|
676
|
+
SLASH_LITERAL,
|
|
677
|
+
ONE_CHAR,
|
|
678
|
+
DOTS_SLASH,
|
|
679
|
+
NO_DOT,
|
|
680
|
+
NO_DOT_SLASH,
|
|
681
|
+
NO_DOTS_SLASH,
|
|
682
|
+
QMARK,
|
|
683
|
+
QMARK_NO_DOT,
|
|
684
|
+
STAR,
|
|
685
|
+
START_ANCHOR
|
|
686
|
+
} = PLATFORM_CHARS;
|
|
687
|
+
const globstar = (opts2) => {
|
|
688
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
689
|
+
};
|
|
690
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
691
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
692
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
693
|
+
if (opts.capture) {
|
|
694
|
+
star = `(${star})`;
|
|
695
|
+
}
|
|
696
|
+
if (typeof opts.noext === "boolean") {
|
|
697
|
+
opts.noextglob = opts.noext;
|
|
698
|
+
}
|
|
699
|
+
const state = {
|
|
700
|
+
input,
|
|
701
|
+
index: -1,
|
|
702
|
+
start: 0,
|
|
703
|
+
dot: opts.dot === true,
|
|
704
|
+
consumed: "",
|
|
705
|
+
output: "",
|
|
706
|
+
prefix: "",
|
|
707
|
+
backtrack: false,
|
|
708
|
+
negated: false,
|
|
709
|
+
brackets: 0,
|
|
710
|
+
braces: 0,
|
|
711
|
+
parens: 0,
|
|
712
|
+
quotes: 0,
|
|
713
|
+
globstar: false,
|
|
714
|
+
tokens
|
|
715
|
+
};
|
|
716
|
+
input = utils.removePrefix(input, state);
|
|
717
|
+
len = input.length;
|
|
718
|
+
const extglobs = [];
|
|
719
|
+
const braces = [];
|
|
720
|
+
const stack = [];
|
|
721
|
+
let prev = bos;
|
|
722
|
+
let value;
|
|
723
|
+
const eos = () => state.index === len - 1;
|
|
724
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
725
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
726
|
+
const remaining = () => input.slice(state.index + 1);
|
|
727
|
+
const consume = (value2 = "", num = 0) => {
|
|
728
|
+
state.consumed += value2;
|
|
729
|
+
state.index += num;
|
|
730
|
+
};
|
|
731
|
+
const append = (token) => {
|
|
732
|
+
state.output += token.output != null ? token.output : token.value;
|
|
733
|
+
consume(token.value);
|
|
734
|
+
};
|
|
735
|
+
const negate = () => {
|
|
736
|
+
let count = 1;
|
|
737
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
738
|
+
advance();
|
|
739
|
+
state.start++;
|
|
740
|
+
count++;
|
|
741
|
+
}
|
|
742
|
+
if (count % 2 === 0) {
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
state.negated = true;
|
|
746
|
+
state.start++;
|
|
747
|
+
return true;
|
|
748
|
+
};
|
|
749
|
+
const increment = (type) => {
|
|
750
|
+
state[type]++;
|
|
751
|
+
stack.push(type);
|
|
752
|
+
};
|
|
753
|
+
const decrement = (type) => {
|
|
754
|
+
state[type]--;
|
|
755
|
+
stack.pop();
|
|
756
|
+
};
|
|
757
|
+
const push = (tok) => {
|
|
758
|
+
if (prev.type === "globstar") {
|
|
759
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
760
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
761
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
762
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
763
|
+
prev.type = "star";
|
|
764
|
+
prev.value = "*";
|
|
765
|
+
prev.output = star;
|
|
766
|
+
state.output += prev.output;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
770
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
771
|
+
}
|
|
772
|
+
if (tok.value || tok.output)
|
|
773
|
+
append(tok);
|
|
774
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
775
|
+
prev.value += tok.value;
|
|
776
|
+
prev.output = (prev.output || "") + tok.value;
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
tok.prev = prev;
|
|
780
|
+
tokens.push(tok);
|
|
781
|
+
prev = tok;
|
|
782
|
+
};
|
|
783
|
+
const extglobOpen = (type, value2) => {
|
|
784
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
785
|
+
token.prev = prev;
|
|
786
|
+
token.parens = state.parens;
|
|
787
|
+
token.output = state.output;
|
|
788
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
789
|
+
increment("parens");
|
|
790
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
791
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
792
|
+
extglobs.push(token);
|
|
793
|
+
};
|
|
794
|
+
const extglobClose = (token) => {
|
|
795
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
796
|
+
let rest;
|
|
797
|
+
if (token.type === "negate") {
|
|
798
|
+
let extglobStar = star;
|
|
799
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
800
|
+
extglobStar = globstar(opts);
|
|
801
|
+
}
|
|
802
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
803
|
+
output = token.close = `)$))${extglobStar}`;
|
|
804
|
+
}
|
|
805
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
806
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
807
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
808
|
+
}
|
|
809
|
+
if (token.prev.type === "bos") {
|
|
810
|
+
state.negatedExtglob = true;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
push({ type: "paren", extglob: true, value, output });
|
|
814
|
+
decrement("parens");
|
|
815
|
+
};
|
|
816
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
817
|
+
let backslashes = false;
|
|
818
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
819
|
+
if (first === "\\") {
|
|
820
|
+
backslashes = true;
|
|
821
|
+
return m;
|
|
822
|
+
}
|
|
823
|
+
if (first === "?") {
|
|
824
|
+
if (esc) {
|
|
825
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
826
|
+
}
|
|
827
|
+
if (index === 0) {
|
|
828
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
829
|
+
}
|
|
830
|
+
return QMARK.repeat(chars.length);
|
|
831
|
+
}
|
|
832
|
+
if (first === ".") {
|
|
833
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
834
|
+
}
|
|
835
|
+
if (first === "*") {
|
|
836
|
+
if (esc) {
|
|
837
|
+
return esc + first + (rest ? star : "");
|
|
838
|
+
}
|
|
839
|
+
return star;
|
|
840
|
+
}
|
|
841
|
+
return esc ? m : `\\${m}`;
|
|
842
|
+
});
|
|
843
|
+
if (backslashes === true) {
|
|
844
|
+
if (opts.unescape === true) {
|
|
845
|
+
output = output.replace(/\\/g, "");
|
|
846
|
+
} else {
|
|
847
|
+
output = output.replace(/\\+/g, (m) => {
|
|
848
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (output === input && opts.contains === true) {
|
|
853
|
+
state.output = input;
|
|
854
|
+
return state;
|
|
855
|
+
}
|
|
856
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
857
|
+
return state;
|
|
858
|
+
}
|
|
859
|
+
while (!eos()) {
|
|
860
|
+
value = advance();
|
|
861
|
+
if (value === "\0") {
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
if (value === "\\") {
|
|
865
|
+
const next = peek();
|
|
866
|
+
if (next === "/" && opts.bash !== true) {
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if (next === "." || next === ";") {
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
if (!next) {
|
|
873
|
+
value += "\\";
|
|
874
|
+
push({ type: "text", value });
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
const match = /^\\+/.exec(remaining());
|
|
878
|
+
let slashes = 0;
|
|
879
|
+
if (match && match[0].length > 2) {
|
|
880
|
+
slashes = match[0].length;
|
|
881
|
+
state.index += slashes;
|
|
882
|
+
if (slashes % 2 !== 0) {
|
|
883
|
+
value += "\\";
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (opts.unescape === true) {
|
|
887
|
+
value = advance();
|
|
888
|
+
} else {
|
|
889
|
+
value += advance();
|
|
890
|
+
}
|
|
891
|
+
if (state.brackets === 0) {
|
|
892
|
+
push({ type: "text", value });
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
897
|
+
if (opts.posix !== false && value === ":") {
|
|
898
|
+
const inner = prev.value.slice(1);
|
|
899
|
+
if (inner.includes("[")) {
|
|
900
|
+
prev.posix = true;
|
|
901
|
+
if (inner.includes(":")) {
|
|
902
|
+
const idx = prev.value.lastIndexOf("[");
|
|
903
|
+
const pre = prev.value.slice(0, idx);
|
|
904
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
905
|
+
const posix2 = POSIX_REGEX_SOURCE[rest2];
|
|
906
|
+
if (posix2) {
|
|
907
|
+
prev.value = pre + posix2;
|
|
908
|
+
state.backtrack = true;
|
|
909
|
+
advance();
|
|
910
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
911
|
+
bos.output = ONE_CHAR;
|
|
912
|
+
}
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
919
|
+
value = `\\${value}`;
|
|
920
|
+
}
|
|
921
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
922
|
+
value = `\\${value}`;
|
|
923
|
+
}
|
|
924
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
925
|
+
value = "^";
|
|
926
|
+
}
|
|
927
|
+
prev.value += value;
|
|
928
|
+
append({ value });
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (state.quotes === 1 && value !== '"') {
|
|
932
|
+
value = utils.escapeRegex(value);
|
|
933
|
+
prev.value += value;
|
|
934
|
+
append({ value });
|
|
935
|
+
continue;
|
|
936
|
+
}
|
|
937
|
+
if (value === '"') {
|
|
938
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
939
|
+
if (opts.keepQuotes === true) {
|
|
940
|
+
push({ type: "text", value });
|
|
941
|
+
}
|
|
942
|
+
continue;
|
|
943
|
+
}
|
|
944
|
+
if (value === "(") {
|
|
945
|
+
increment("parens");
|
|
946
|
+
push({ type: "paren", value });
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
if (value === ")") {
|
|
950
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
951
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
952
|
+
}
|
|
953
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
954
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
955
|
+
extglobClose(extglobs.pop());
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
959
|
+
decrement("parens");
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (value === "[") {
|
|
963
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
964
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
965
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
966
|
+
}
|
|
967
|
+
value = `\\${value}`;
|
|
968
|
+
} else {
|
|
969
|
+
increment("brackets");
|
|
970
|
+
}
|
|
971
|
+
push({ type: "bracket", value });
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
if (value === "]") {
|
|
975
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
976
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
if (state.brackets === 0) {
|
|
980
|
+
if (opts.strictBrackets === true) {
|
|
981
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
982
|
+
}
|
|
983
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
decrement("brackets");
|
|
987
|
+
const prevValue = prev.value.slice(1);
|
|
988
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
989
|
+
value = `/${value}`;
|
|
990
|
+
}
|
|
991
|
+
prev.value += value;
|
|
992
|
+
append({ value });
|
|
993
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
997
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
998
|
+
if (opts.literalBrackets === true) {
|
|
999
|
+
state.output += escaped;
|
|
1000
|
+
prev.value = escaped;
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1004
|
+
state.output += prev.value;
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1008
|
+
increment("braces");
|
|
1009
|
+
const open = {
|
|
1010
|
+
type: "brace",
|
|
1011
|
+
value,
|
|
1012
|
+
output: "(",
|
|
1013
|
+
outputIndex: state.output.length,
|
|
1014
|
+
tokensIndex: state.tokens.length
|
|
1015
|
+
};
|
|
1016
|
+
braces.push(open);
|
|
1017
|
+
push(open);
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
if (value === "}") {
|
|
1021
|
+
const brace = braces[braces.length - 1];
|
|
1022
|
+
if (opts.nobrace === true || !brace) {
|
|
1023
|
+
push({ type: "text", value, output: value });
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
let output = ")";
|
|
1027
|
+
if (brace.dots === true) {
|
|
1028
|
+
const arr = tokens.slice();
|
|
1029
|
+
const range = [];
|
|
1030
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1031
|
+
tokens.pop();
|
|
1032
|
+
if (arr[i].type === "brace") {
|
|
1033
|
+
break;
|
|
1034
|
+
}
|
|
1035
|
+
if (arr[i].type !== "dots") {
|
|
1036
|
+
range.unshift(arr[i].value);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
output = expandRange(range, opts);
|
|
1040
|
+
state.backtrack = true;
|
|
1041
|
+
}
|
|
1042
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1043
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1044
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1045
|
+
brace.value = brace.output = "\\{";
|
|
1046
|
+
value = output = "\\}";
|
|
1047
|
+
state.output = out;
|
|
1048
|
+
for (const t of toks) {
|
|
1049
|
+
state.output += t.output || t.value;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
push({ type: "brace", value, output });
|
|
1053
|
+
decrement("braces");
|
|
1054
|
+
braces.pop();
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
if (value === "|") {
|
|
1058
|
+
if (extglobs.length > 0) {
|
|
1059
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1060
|
+
}
|
|
1061
|
+
push({ type: "text", value });
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
if (value === ",") {
|
|
1065
|
+
let output = value;
|
|
1066
|
+
const brace = braces[braces.length - 1];
|
|
1067
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1068
|
+
brace.comma = true;
|
|
1069
|
+
output = "|";
|
|
1070
|
+
}
|
|
1071
|
+
push({ type: "comma", value, output });
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
if (value === "/") {
|
|
1075
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1076
|
+
state.start = state.index + 1;
|
|
1077
|
+
state.consumed = "";
|
|
1078
|
+
state.output = "";
|
|
1079
|
+
tokens.pop();
|
|
1080
|
+
prev = bos;
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
if (value === ".") {
|
|
1087
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1088
|
+
if (prev.value === ".")
|
|
1089
|
+
prev.output = DOT_LITERAL;
|
|
1090
|
+
const brace = braces[braces.length - 1];
|
|
1091
|
+
prev.type = "dots";
|
|
1092
|
+
prev.output += value;
|
|
1093
|
+
prev.value += value;
|
|
1094
|
+
brace.dots = true;
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1098
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
if (value === "?") {
|
|
1105
|
+
const isGroup = prev && prev.value === "(";
|
|
1106
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1107
|
+
extglobOpen("qmark", value);
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
if (prev && prev.type === "paren") {
|
|
1111
|
+
const next = peek();
|
|
1112
|
+
let output = value;
|
|
1113
|
+
if (next === "<" && !utils.supportsLookbehinds()) {
|
|
1114
|
+
throw new Error("Node.js v10 or higher is required for regex lookbehinds");
|
|
1115
|
+
}
|
|
1116
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1117
|
+
output = `\\${value}`;
|
|
1118
|
+
}
|
|
1119
|
+
push({ type: "text", value, output });
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1123
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
if (value === "!") {
|
|
1130
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1131
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1132
|
+
extglobOpen("negate", value);
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1137
|
+
negate();
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
if (value === "+") {
|
|
1142
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1143
|
+
extglobOpen("plus", value);
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1147
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1151
|
+
push({ type: "plus", value });
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
if (value === "@") {
|
|
1158
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1159
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
push({ type: "text", value });
|
|
1163
|
+
continue;
|
|
1164
|
+
}
|
|
1165
|
+
if (value !== "*") {
|
|
1166
|
+
if (value === "$" || value === "^") {
|
|
1167
|
+
value = `\\${value}`;
|
|
1168
|
+
}
|
|
1169
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1170
|
+
if (match) {
|
|
1171
|
+
value += match[0];
|
|
1172
|
+
state.index += match[0].length;
|
|
1173
|
+
}
|
|
1174
|
+
push({ type: "text", value });
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1178
|
+
prev.type = "star";
|
|
1179
|
+
prev.star = true;
|
|
1180
|
+
prev.value += value;
|
|
1181
|
+
prev.output = star;
|
|
1182
|
+
state.backtrack = true;
|
|
1183
|
+
state.globstar = true;
|
|
1184
|
+
consume(value);
|
|
1185
|
+
continue;
|
|
1186
|
+
}
|
|
1187
|
+
let rest = remaining();
|
|
1188
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1189
|
+
extglobOpen("star", value);
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (prev.type === "star") {
|
|
1193
|
+
if (opts.noglobstar === true) {
|
|
1194
|
+
consume(value);
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
const prior = prev.prev;
|
|
1198
|
+
const before = prior.prev;
|
|
1199
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1200
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1201
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1202
|
+
push({ type: "star", value, output: "" });
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1206
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1207
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1208
|
+
push({ type: "star", value, output: "" });
|
|
1209
|
+
continue;
|
|
1210
|
+
}
|
|
1211
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1212
|
+
const after = input[state.index + 4];
|
|
1213
|
+
if (after && after !== "/") {
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
rest = rest.slice(3);
|
|
1217
|
+
consume("/**", 3);
|
|
1218
|
+
}
|
|
1219
|
+
if (prior.type === "bos" && eos()) {
|
|
1220
|
+
prev.type = "globstar";
|
|
1221
|
+
prev.value += value;
|
|
1222
|
+
prev.output = globstar(opts);
|
|
1223
|
+
state.output = prev.output;
|
|
1224
|
+
state.globstar = true;
|
|
1225
|
+
consume(value);
|
|
1226
|
+
continue;
|
|
1227
|
+
}
|
|
1228
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1229
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1230
|
+
prior.output = `(?:${prior.output}`;
|
|
1231
|
+
prev.type = "globstar";
|
|
1232
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1233
|
+
prev.value += value;
|
|
1234
|
+
state.globstar = true;
|
|
1235
|
+
state.output += prior.output + prev.output;
|
|
1236
|
+
consume(value);
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1240
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1241
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1242
|
+
prior.output = `(?:${prior.output}`;
|
|
1243
|
+
prev.type = "globstar";
|
|
1244
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1245
|
+
prev.value += value;
|
|
1246
|
+
state.output += prior.output + prev.output;
|
|
1247
|
+
state.globstar = true;
|
|
1248
|
+
consume(value + advance());
|
|
1249
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1253
|
+
prev.type = "globstar";
|
|
1254
|
+
prev.value += value;
|
|
1255
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1256
|
+
state.output = prev.output;
|
|
1257
|
+
state.globstar = true;
|
|
1258
|
+
consume(value + advance());
|
|
1259
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1263
|
+
prev.type = "globstar";
|
|
1264
|
+
prev.output = globstar(opts);
|
|
1265
|
+
prev.value += value;
|
|
1266
|
+
state.output += prev.output;
|
|
1267
|
+
state.globstar = true;
|
|
1268
|
+
consume(value);
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
const token = { type: "star", value, output: star };
|
|
1272
|
+
if (opts.bash === true) {
|
|
1273
|
+
token.output = ".*?";
|
|
1274
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1275
|
+
token.output = nodot + token.output;
|
|
1276
|
+
}
|
|
1277
|
+
push(token);
|
|
1278
|
+
continue;
|
|
1279
|
+
}
|
|
1280
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1281
|
+
token.output = value;
|
|
1282
|
+
push(token);
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1286
|
+
if (prev.type === "dot") {
|
|
1287
|
+
state.output += NO_DOT_SLASH;
|
|
1288
|
+
prev.output += NO_DOT_SLASH;
|
|
1289
|
+
} else if (opts.dot === true) {
|
|
1290
|
+
state.output += NO_DOTS_SLASH;
|
|
1291
|
+
prev.output += NO_DOTS_SLASH;
|
|
1292
|
+
} else {
|
|
1293
|
+
state.output += nodot;
|
|
1294
|
+
prev.output += nodot;
|
|
1295
|
+
}
|
|
1296
|
+
if (peek() !== "*") {
|
|
1297
|
+
state.output += ONE_CHAR;
|
|
1298
|
+
prev.output += ONE_CHAR;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
push(token);
|
|
1302
|
+
}
|
|
1303
|
+
while (state.brackets > 0) {
|
|
1304
|
+
if (opts.strictBrackets === true)
|
|
1305
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1306
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1307
|
+
decrement("brackets");
|
|
1308
|
+
}
|
|
1309
|
+
while (state.parens > 0) {
|
|
1310
|
+
if (opts.strictBrackets === true)
|
|
1311
|
+
throw new SyntaxError(syntaxError("closing", ")"));
|
|
1312
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1313
|
+
decrement("parens");
|
|
1314
|
+
}
|
|
1315
|
+
while (state.braces > 0) {
|
|
1316
|
+
if (opts.strictBrackets === true)
|
|
1317
|
+
throw new SyntaxError(syntaxError("closing", "}"));
|
|
1318
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1319
|
+
decrement("braces");
|
|
1320
|
+
}
|
|
1321
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1322
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1323
|
+
}
|
|
1324
|
+
if (state.backtrack === true) {
|
|
1325
|
+
state.output = "";
|
|
1326
|
+
for (const token of state.tokens) {
|
|
1327
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1328
|
+
if (token.suffix) {
|
|
1329
|
+
state.output += token.suffix;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
return state;
|
|
1334
|
+
};
|
|
1335
|
+
parse.fastpaths = (input, options) => {
|
|
1336
|
+
const opts = { ...options };
|
|
1337
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1338
|
+
const len = input.length;
|
|
1339
|
+
if (len > max) {
|
|
1340
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1341
|
+
}
|
|
1342
|
+
input = REPLACEMENTS[input] || input;
|
|
1343
|
+
const win322 = utils.isWindows(options);
|
|
1344
|
+
const {
|
|
1345
|
+
DOT_LITERAL,
|
|
1346
|
+
SLASH_LITERAL,
|
|
1347
|
+
ONE_CHAR,
|
|
1348
|
+
DOTS_SLASH,
|
|
1349
|
+
NO_DOT,
|
|
1350
|
+
NO_DOTS,
|
|
1351
|
+
NO_DOTS_SLASH,
|
|
1352
|
+
STAR,
|
|
1353
|
+
START_ANCHOR
|
|
1354
|
+
} = constants.globChars(win322);
|
|
1355
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1356
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1357
|
+
const capture = opts.capture ? "" : "?:";
|
|
1358
|
+
const state = { negated: false, prefix: "" };
|
|
1359
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1360
|
+
if (opts.capture) {
|
|
1361
|
+
star = `(${star})`;
|
|
1362
|
+
}
|
|
1363
|
+
const globstar = (opts2) => {
|
|
1364
|
+
if (opts2.noglobstar === true)
|
|
1365
|
+
return star;
|
|
1366
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1367
|
+
};
|
|
1368
|
+
const create = (str) => {
|
|
1369
|
+
switch (str) {
|
|
1370
|
+
case "*":
|
|
1371
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1372
|
+
case ".*":
|
|
1373
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1374
|
+
case "*.*":
|
|
1375
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1376
|
+
case "*/*":
|
|
1377
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1378
|
+
case "**":
|
|
1379
|
+
return nodot + globstar(opts);
|
|
1380
|
+
case "**/*":
|
|
1381
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1382
|
+
case "**/*.*":
|
|
1383
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1384
|
+
case "**/.*":
|
|
1385
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1386
|
+
default: {
|
|
1387
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1388
|
+
if (!match)
|
|
1389
|
+
return;
|
|
1390
|
+
const source2 = create(match[1]);
|
|
1391
|
+
if (!source2)
|
|
1392
|
+
return;
|
|
1393
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
const output = utils.removePrefix(input, state);
|
|
1398
|
+
let source = create(output);
|
|
1399
|
+
if (source && opts.strictSlashes !== true) {
|
|
1400
|
+
source += `${SLASH_LITERAL}?`;
|
|
1401
|
+
}
|
|
1402
|
+
return source;
|
|
1403
|
+
};
|
|
1404
|
+
module.exports = parse;
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
|
|
1409
|
+
var require_picomatch = __commonJS({
|
|
1410
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1411
|
+
"use strict";
|
|
1412
|
+
var path2 = __require("path");
|
|
1413
|
+
var scan = require_scan();
|
|
1414
|
+
var parse = require_parse();
|
|
1415
|
+
var utils = require_utils();
|
|
1416
|
+
var constants = require_constants();
|
|
1417
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1418
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
1419
|
+
if (Array.isArray(glob)) {
|
|
1420
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1421
|
+
const arrayMatcher = (str) => {
|
|
1422
|
+
for (const isMatch of fns) {
|
|
1423
|
+
const state2 = isMatch(str);
|
|
1424
|
+
if (state2)
|
|
1425
|
+
return state2;
|
|
1426
|
+
}
|
|
1427
|
+
return false;
|
|
1428
|
+
};
|
|
1429
|
+
return arrayMatcher;
|
|
1430
|
+
}
|
|
1431
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1432
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1433
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1434
|
+
}
|
|
1435
|
+
const opts = options || {};
|
|
1436
|
+
const posix2 = utils.isWindows(options);
|
|
1437
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1438
|
+
const state = regex.state;
|
|
1439
|
+
delete regex.state;
|
|
1440
|
+
let isIgnored = () => false;
|
|
1441
|
+
if (opts.ignore) {
|
|
1442
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1443
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1444
|
+
}
|
|
1445
|
+
const matcher = (input, returnObject = false) => {
|
|
1446
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix: posix2 });
|
|
1447
|
+
const result = { glob, state, regex, posix: posix2, input, output, match, isMatch };
|
|
1448
|
+
if (typeof opts.onResult === "function") {
|
|
1449
|
+
opts.onResult(result);
|
|
1450
|
+
}
|
|
1451
|
+
if (isMatch === false) {
|
|
1452
|
+
result.isMatch = false;
|
|
1453
|
+
return returnObject ? result : false;
|
|
1454
|
+
}
|
|
1455
|
+
if (isIgnored(input)) {
|
|
1456
|
+
if (typeof opts.onIgnore === "function") {
|
|
1457
|
+
opts.onIgnore(result);
|
|
1458
|
+
}
|
|
1459
|
+
result.isMatch = false;
|
|
1460
|
+
return returnObject ? result : false;
|
|
1461
|
+
}
|
|
1462
|
+
if (typeof opts.onMatch === "function") {
|
|
1463
|
+
opts.onMatch(result);
|
|
1464
|
+
}
|
|
1465
|
+
return returnObject ? result : true;
|
|
1466
|
+
};
|
|
1467
|
+
if (returnState) {
|
|
1468
|
+
matcher.state = state;
|
|
1469
|
+
}
|
|
1470
|
+
return matcher;
|
|
1471
|
+
};
|
|
1472
|
+
picomatch.test = (input, regex, options, { glob, posix: posix2 } = {}) => {
|
|
1473
|
+
if (typeof input !== "string") {
|
|
1474
|
+
throw new TypeError("Expected input to be a string");
|
|
1475
|
+
}
|
|
1476
|
+
if (input === "") {
|
|
1477
|
+
return { isMatch: false, output: "" };
|
|
1478
|
+
}
|
|
1479
|
+
const opts = options || {};
|
|
1480
|
+
const format = opts.format || (posix2 ? utils.toPosixSlashes : null);
|
|
1481
|
+
let match = input === glob;
|
|
1482
|
+
let output = match && format ? format(input) : input;
|
|
1483
|
+
if (match === false) {
|
|
1484
|
+
output = format ? format(input) : input;
|
|
1485
|
+
match = output === glob;
|
|
1486
|
+
}
|
|
1487
|
+
if (match === false || opts.capture === true) {
|
|
1488
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1489
|
+
match = picomatch.matchBase(input, regex, options, posix2);
|
|
1490
|
+
} else {
|
|
1491
|
+
match = regex.exec(output);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return { isMatch: Boolean(match), match, output };
|
|
1495
|
+
};
|
|
1496
|
+
picomatch.matchBase = (input, glob, options, posix2 = utils.isWindows(options)) => {
|
|
1497
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1498
|
+
return regex.test(path2.basename(input));
|
|
1499
|
+
};
|
|
1500
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1501
|
+
picomatch.parse = (pattern, options) => {
|
|
1502
|
+
if (Array.isArray(pattern))
|
|
1503
|
+
return pattern.map((p) => picomatch.parse(p, options));
|
|
1504
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
1505
|
+
};
|
|
1506
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
1507
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1508
|
+
if (returnOutput === true) {
|
|
1509
|
+
return state.output;
|
|
1510
|
+
}
|
|
1511
|
+
const opts = options || {};
|
|
1512
|
+
const prepend = opts.contains ? "" : "^";
|
|
1513
|
+
const append = opts.contains ? "" : "$";
|
|
1514
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1515
|
+
if (state && state.negated === true) {
|
|
1516
|
+
source = `^(?!${source}).*$`;
|
|
1517
|
+
}
|
|
1518
|
+
const regex = picomatch.toRegex(source, options);
|
|
1519
|
+
if (returnState === true) {
|
|
1520
|
+
regex.state = state;
|
|
1521
|
+
}
|
|
1522
|
+
return regex;
|
|
1523
|
+
};
|
|
1524
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1525
|
+
if (!input || typeof input !== "string") {
|
|
1526
|
+
throw new TypeError("Expected a non-empty string");
|
|
1527
|
+
}
|
|
1528
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1529
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1530
|
+
parsed.output = parse.fastpaths(input, options);
|
|
1531
|
+
}
|
|
1532
|
+
if (!parsed.output) {
|
|
1533
|
+
parsed = parse(input, options);
|
|
1534
|
+
}
|
|
1535
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1536
|
+
};
|
|
1537
|
+
picomatch.toRegex = (source, options) => {
|
|
1538
|
+
try {
|
|
1539
|
+
const opts = options || {};
|
|
1540
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
if (options && options.debug === true)
|
|
1543
|
+
throw err;
|
|
1544
|
+
return /$^/;
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
picomatch.constants = constants;
|
|
1548
|
+
module.exports = picomatch;
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
// node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/index.js
|
|
1553
|
+
var require_picomatch2 = __commonJS({
|
|
1554
|
+
"node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/index.js"(exports, module) {
|
|
1555
|
+
"use strict";
|
|
1556
|
+
module.exports = require_picomatch();
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
|
|
1560
|
+
// src/index.ts
|
|
1561
|
+
var _promises = require('fs/promises');
|
|
1562
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
1563
|
+
var _unplugin = require('unplugin');
|
|
1564
|
+
|
|
1565
|
+
// node_modules/.pnpm/@rollup+pluginutils@5.1.0_rollup@4.6.0/node_modules/@rollup/pluginutils/dist/es/index.js
|
|
1566
|
+
|
|
1567
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
1568
|
+
function isArray(arg) {
|
|
1569
|
+
return Array.isArray(arg);
|
|
1570
|
+
}
|
|
1571
|
+
function ensureArray(thing) {
|
|
1572
|
+
if (isArray(thing))
|
|
1573
|
+
return thing;
|
|
1574
|
+
if (thing == null)
|
|
1575
|
+
return [];
|
|
1576
|
+
return [thing];
|
|
1577
|
+
}
|
|
1578
|
+
var normalizePath = function normalizePath2(filename) {
|
|
1579
|
+
return filename.split(_path.win32.sep).join(_path.posix.sep);
|
|
1580
|
+
};
|
|
1581
|
+
function getMatcherString(id, resolutionBase) {
|
|
1582
|
+
if (resolutionBase === false || _path.isAbsolute.call(void 0, id) || id.startsWith("**")) {
|
|
1583
|
+
return normalizePath(id);
|
|
1584
|
+
}
|
|
1585
|
+
const basePath = normalizePath(_path.resolve.call(void 0, resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
|
|
1586
|
+
return _path.posix.join(basePath, normalizePath(id));
|
|
1587
|
+
}
|
|
1588
|
+
var createFilter = function createFilter2(include, exclude, options) {
|
|
1589
|
+
const resolutionBase = options && options.resolve;
|
|
1590
|
+
const getMatcher = (id) => id instanceof RegExp ? id : {
|
|
1591
|
+
test: (what) => {
|
|
1592
|
+
const pattern = getMatcherString(id, resolutionBase);
|
|
1593
|
+
const fn = (0, import_picomatch.default)(pattern, { dot: true });
|
|
1594
|
+
const result = fn(what);
|
|
1595
|
+
return result;
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
1599
|
+
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
1600
|
+
return function result(id) {
|
|
1601
|
+
if (typeof id !== "string")
|
|
1602
|
+
return false;
|
|
1603
|
+
if (/\0/.test(id))
|
|
1604
|
+
return false;
|
|
1605
|
+
const pathId = normalizePath(id);
|
|
1606
|
+
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
1607
|
+
const matcher = excludeMatchers[i];
|
|
1608
|
+
if (matcher.test(pathId))
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
1612
|
+
const matcher = includeMatchers[i];
|
|
1613
|
+
if (matcher.test(pathId))
|
|
1614
|
+
return true;
|
|
1615
|
+
}
|
|
1616
|
+
return !includeMatchers.length;
|
|
1617
|
+
};
|
|
1618
|
+
};
|
|
1619
|
+
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";
|
|
1620
|
+
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";
|
|
1621
|
+
var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
1622
|
+
forbiddenIdentifiers.add("");
|
|
1623
|
+
var hasStringIsWellFormed = "isWellFormed" in String.prototype;
|
|
1624
|
+
|
|
1625
|
+
// src/core/options.ts
|
|
1626
|
+
function resolveOptions(options) {
|
|
1627
|
+
return {
|
|
1628
|
+
...options,
|
|
1629
|
+
enforce: "enforce" in options ? options.enforce : "pre",
|
|
1630
|
+
transform: {
|
|
1631
|
+
...options.transform,
|
|
1632
|
+
include: _optionalChain([options, 'access', _ => _.transform, 'optionalAccess', _2 => _2.include]) || [/\.[cm]?[jt]sx?$/],
|
|
1633
|
+
exclude: _optionalChain([options, 'access', _3 => _3.transform, 'optionalAccess', _4 => _4.exclude]) || [/node_modules/],
|
|
1634
|
+
options: _optionalChain([options, 'access', _5 => _5.transform, 'optionalAccess', _6 => _6.options]) || {}
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// src/index.ts
|
|
1640
|
+
var src_default = _unplugin.createUnplugin.call(void 0,
|
|
1641
|
+
(rawOptions = {}, meta) => {
|
|
1642
|
+
const options = resolveOptions(rawOptions);
|
|
1643
|
+
const transformFilter = createFilter(
|
|
1644
|
+
options.transform.include,
|
|
1645
|
+
options.transform.exclude
|
|
1646
|
+
);
|
|
1647
|
+
return {
|
|
1648
|
+
name: "unplugin-raw",
|
|
1649
|
+
enforce: options.enforce,
|
|
1650
|
+
resolveId: meta.framework === "rollup" ? async function(id, importer) {
|
|
1651
|
+
if (!rawRE.test(id))
|
|
1652
|
+
return;
|
|
1653
|
+
const file = cleanUrl(id);
|
|
1654
|
+
const resolved = await this.resolve(file, importer);
|
|
1655
|
+
if (!resolved)
|
|
1656
|
+
return;
|
|
1657
|
+
return id.replace(file, resolved.id);
|
|
1658
|
+
} : void 0,
|
|
1659
|
+
loadInclude: (id) => rawRE.test(id),
|
|
1660
|
+
async load(id) {
|
|
1661
|
+
const file = cleanUrl(id);
|
|
1662
|
+
let contents = await _promises.readFile.call(void 0, file, "utf-8");
|
|
1663
|
+
if (transformFilter(file)) {
|
|
1664
|
+
let transform;
|
|
1665
|
+
if (meta.framework === "esbuild") {
|
|
1666
|
+
;
|
|
1667
|
+
({ transform } = meta.build.esbuild);
|
|
1668
|
+
} else {
|
|
1669
|
+
transform = (await Promise.resolve().then(() => _interopRequireWildcard(require("esbuild")))).transform;
|
|
1670
|
+
}
|
|
1671
|
+
contents = (await transform(contents, {
|
|
1672
|
+
loader: guessLoader(file),
|
|
1673
|
+
...options.transform.options
|
|
1674
|
+
})).code;
|
|
1675
|
+
}
|
|
1676
|
+
return `export default ${JSON.stringify(contents)}`;
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
);
|
|
1681
|
+
var rawRE = /[&?]raw(?:&|$)/;
|
|
1682
|
+
var postfixRE = /[#?].*$/s;
|
|
1683
|
+
function cleanUrl(url) {
|
|
1684
|
+
return url.replace(postfixRE, "");
|
|
1685
|
+
}
|
|
1686
|
+
var ExtToLoader = {
|
|
1687
|
+
".js": "js",
|
|
1688
|
+
".mjs": "js",
|
|
1689
|
+
".cjs": "js",
|
|
1690
|
+
".jsx": "jsx",
|
|
1691
|
+
".ts": "ts",
|
|
1692
|
+
".cts": "ts",
|
|
1693
|
+
".mts": "ts",
|
|
1694
|
+
".tsx": "tsx",
|
|
1695
|
+
".css": "css",
|
|
1696
|
+
".less": "css",
|
|
1697
|
+
".stylus": "css",
|
|
1698
|
+
".scss": "css",
|
|
1699
|
+
".sass": "css",
|
|
1700
|
+
".json": "json",
|
|
1701
|
+
".txt": "text"
|
|
1702
|
+
};
|
|
1703
|
+
function guessLoader(id) {
|
|
1704
|
+
return ExtToLoader[_path2.default.extname(id).toLowerCase()] || "js";
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
exports.src_default = src_default; exports.guessLoader = guessLoader;
|