vite-plugin-storybook-nextjs 3.0.3--canary.68.b6ee25e.0 → 3.0.4--canary.5f06d44.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/README.md +43 -2
- package/dist/index.cjs +1633 -20
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +1633 -20
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ var nextServerConfig = require('next/dist/server/config.js');
|
|
|
23
23
|
var constants_js = require('next/dist/shared/lib/constants.js');
|
|
24
24
|
var MagicString = require('magic-string');
|
|
25
25
|
var querystring = require('querystring');
|
|
26
|
+
var path = require('path');
|
|
26
27
|
var imageSize = require('image-size');
|
|
27
28
|
|
|
28
29
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -82,8 +83,1520 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
82
83
|
mod
|
|
83
84
|
));
|
|
84
85
|
|
|
85
|
-
// node_modules/.pnpm/
|
|
86
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
86
87
|
var require_constants = __commonJS({
|
|
88
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
89
|
+
var WIN_SLASH = "\\\\/";
|
|
90
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
91
|
+
var DOT_LITERAL = "\\.";
|
|
92
|
+
var PLUS_LITERAL = "\\+";
|
|
93
|
+
var QMARK_LITERAL = "\\?";
|
|
94
|
+
var SLASH_LITERAL = "\\/";
|
|
95
|
+
var ONE_CHAR = "(?=.)";
|
|
96
|
+
var QMARK = "[^/]";
|
|
97
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
98
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
99
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
100
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
101
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
102
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
103
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
104
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
105
|
+
var STAR = `${QMARK}*?`;
|
|
106
|
+
var SEP = "/";
|
|
107
|
+
var POSIX_CHARS = {
|
|
108
|
+
DOT_LITERAL,
|
|
109
|
+
PLUS_LITERAL,
|
|
110
|
+
QMARK_LITERAL,
|
|
111
|
+
SLASH_LITERAL,
|
|
112
|
+
ONE_CHAR,
|
|
113
|
+
QMARK,
|
|
114
|
+
END_ANCHOR,
|
|
115
|
+
DOTS_SLASH,
|
|
116
|
+
NO_DOT,
|
|
117
|
+
NO_DOTS,
|
|
118
|
+
NO_DOT_SLASH,
|
|
119
|
+
NO_DOTS_SLASH,
|
|
120
|
+
QMARK_NO_DOT,
|
|
121
|
+
STAR,
|
|
122
|
+
START_ANCHOR,
|
|
123
|
+
SEP
|
|
124
|
+
};
|
|
125
|
+
var WINDOWS_CHARS = {
|
|
126
|
+
...POSIX_CHARS,
|
|
127
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
128
|
+
QMARK: WIN_NO_SLASH,
|
|
129
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
130
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
131
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
132
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
133
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
134
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
135
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
136
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
137
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
138
|
+
SEP: "\\"
|
|
139
|
+
};
|
|
140
|
+
var POSIX_REGEX_SOURCE = {
|
|
141
|
+
alnum: "a-zA-Z0-9",
|
|
142
|
+
alpha: "a-zA-Z",
|
|
143
|
+
ascii: "\\x00-\\x7F",
|
|
144
|
+
blank: " \\t",
|
|
145
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
146
|
+
digit: "0-9",
|
|
147
|
+
graph: "\\x21-\\x7E",
|
|
148
|
+
lower: "a-z",
|
|
149
|
+
print: "\\x20-\\x7E ",
|
|
150
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
151
|
+
space: " \\t\\r\\n\\v\\f",
|
|
152
|
+
upper: "A-Z",
|
|
153
|
+
word: "A-Za-z0-9_",
|
|
154
|
+
xdigit: "A-Fa-f0-9"
|
|
155
|
+
};
|
|
156
|
+
module.exports = {
|
|
157
|
+
MAX_LENGTH: 1024 * 64,
|
|
158
|
+
POSIX_REGEX_SOURCE,
|
|
159
|
+
// regular expressions
|
|
160
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
161
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
162
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
163
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
164
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
165
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
166
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
167
|
+
REPLACEMENTS: {
|
|
168
|
+
__proto__: null,
|
|
169
|
+
"***": "*",
|
|
170
|
+
"**/**": "**",
|
|
171
|
+
"**/**/**": "**"
|
|
172
|
+
},
|
|
173
|
+
// Digits
|
|
174
|
+
CHAR_0: 48,
|
|
175
|
+
/* 0 */
|
|
176
|
+
CHAR_9: 57,
|
|
177
|
+
/* 9 */
|
|
178
|
+
// Alphabet chars.
|
|
179
|
+
CHAR_UPPERCASE_A: 65,
|
|
180
|
+
/* A */
|
|
181
|
+
CHAR_LOWERCASE_A: 97,
|
|
182
|
+
/* a */
|
|
183
|
+
CHAR_UPPERCASE_Z: 90,
|
|
184
|
+
/* Z */
|
|
185
|
+
CHAR_LOWERCASE_Z: 122,
|
|
186
|
+
/* z */
|
|
187
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
188
|
+
/* ( */
|
|
189
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
190
|
+
/* ) */
|
|
191
|
+
CHAR_ASTERISK: 42,
|
|
192
|
+
/* * */
|
|
193
|
+
// Non-alphabetic chars.
|
|
194
|
+
CHAR_AMPERSAND: 38,
|
|
195
|
+
/* & */
|
|
196
|
+
CHAR_AT: 64,
|
|
197
|
+
/* @ */
|
|
198
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
199
|
+
/* \ */
|
|
200
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
201
|
+
/* \r */
|
|
202
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
203
|
+
/* ^ */
|
|
204
|
+
CHAR_COLON: 58,
|
|
205
|
+
/* : */
|
|
206
|
+
CHAR_COMMA: 44,
|
|
207
|
+
/* , */
|
|
208
|
+
CHAR_DOT: 46,
|
|
209
|
+
/* . */
|
|
210
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
211
|
+
/* " */
|
|
212
|
+
CHAR_EQUAL: 61,
|
|
213
|
+
/* = */
|
|
214
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
215
|
+
/* ! */
|
|
216
|
+
CHAR_FORM_FEED: 12,
|
|
217
|
+
/* \f */
|
|
218
|
+
CHAR_FORWARD_SLASH: 47,
|
|
219
|
+
/* / */
|
|
220
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
221
|
+
/* ` */
|
|
222
|
+
CHAR_HASH: 35,
|
|
223
|
+
/* # */
|
|
224
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
225
|
+
/* - */
|
|
226
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
227
|
+
/* < */
|
|
228
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
229
|
+
/* { */
|
|
230
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
231
|
+
/* [ */
|
|
232
|
+
CHAR_LINE_FEED: 10,
|
|
233
|
+
/* \n */
|
|
234
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
235
|
+
/* \u00A0 */
|
|
236
|
+
CHAR_PERCENT: 37,
|
|
237
|
+
/* % */
|
|
238
|
+
CHAR_PLUS: 43,
|
|
239
|
+
/* + */
|
|
240
|
+
CHAR_QUESTION_MARK: 63,
|
|
241
|
+
/* ? */
|
|
242
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
243
|
+
/* > */
|
|
244
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
245
|
+
/* } */
|
|
246
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
247
|
+
/* ] */
|
|
248
|
+
CHAR_SEMICOLON: 59,
|
|
249
|
+
/* ; */
|
|
250
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
251
|
+
/* ' */
|
|
252
|
+
CHAR_SPACE: 32,
|
|
253
|
+
/* */
|
|
254
|
+
CHAR_TAB: 9,
|
|
255
|
+
/* \t */
|
|
256
|
+
CHAR_UNDERSCORE: 95,
|
|
257
|
+
/* _ */
|
|
258
|
+
CHAR_VERTICAL_LINE: 124,
|
|
259
|
+
/* | */
|
|
260
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
261
|
+
/* \uFEFF */
|
|
262
|
+
/**
|
|
263
|
+
* Create EXTGLOB_CHARS
|
|
264
|
+
*/
|
|
265
|
+
extglobChars(chars) {
|
|
266
|
+
return {
|
|
267
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
268
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
269
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
270
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
271
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
/**
|
|
275
|
+
* Create GLOB_CHARS
|
|
276
|
+
*/
|
|
277
|
+
globChars(win323) {
|
|
278
|
+
return win323 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
285
|
+
var require_utils = __commonJS({
|
|
286
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports) {
|
|
287
|
+
var {
|
|
288
|
+
REGEX_BACKSLASH,
|
|
289
|
+
REGEX_REMOVE_BACKSLASH,
|
|
290
|
+
REGEX_SPECIAL_CHARS,
|
|
291
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
292
|
+
} = require_constants();
|
|
293
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
294
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
295
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
296
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
297
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
298
|
+
exports.isWindows = () => {
|
|
299
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
300
|
+
const platform = navigator.platform.toLowerCase();
|
|
301
|
+
return platform === "win32" || platform === "windows";
|
|
302
|
+
}
|
|
303
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
304
|
+
return process.platform === "win32";
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
};
|
|
308
|
+
exports.removeBackslashes = (str) => {
|
|
309
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
310
|
+
return match === "\\" ? "" : match;
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
314
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
315
|
+
if (idx === -1) return input;
|
|
316
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
317
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
318
|
+
};
|
|
319
|
+
exports.removePrefix = (input, state = {}) => {
|
|
320
|
+
let output = input;
|
|
321
|
+
if (output.startsWith("./")) {
|
|
322
|
+
output = output.slice(2);
|
|
323
|
+
state.prefix = "./";
|
|
324
|
+
}
|
|
325
|
+
return output;
|
|
326
|
+
};
|
|
327
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
328
|
+
const prepend = options.contains ? "" : "^";
|
|
329
|
+
const append = options.contains ? "" : "$";
|
|
330
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
331
|
+
if (state.negated === true) {
|
|
332
|
+
output = `(?:^(?!${output}).*$)`;
|
|
333
|
+
}
|
|
334
|
+
return output;
|
|
335
|
+
};
|
|
336
|
+
exports.basename = (path, { windows } = {}) => {
|
|
337
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
338
|
+
const last = segs[segs.length - 1];
|
|
339
|
+
if (last === "") {
|
|
340
|
+
return segs[segs.length - 2];
|
|
341
|
+
}
|
|
342
|
+
return last;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
348
|
+
var require_scan = __commonJS({
|
|
349
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
350
|
+
var utils = require_utils();
|
|
351
|
+
var {
|
|
352
|
+
CHAR_ASTERISK,
|
|
353
|
+
/* * */
|
|
354
|
+
CHAR_AT,
|
|
355
|
+
/* @ */
|
|
356
|
+
CHAR_BACKWARD_SLASH,
|
|
357
|
+
/* \ */
|
|
358
|
+
CHAR_COMMA,
|
|
359
|
+
/* , */
|
|
360
|
+
CHAR_DOT,
|
|
361
|
+
/* . */
|
|
362
|
+
CHAR_EXCLAMATION_MARK,
|
|
363
|
+
/* ! */
|
|
364
|
+
CHAR_FORWARD_SLASH,
|
|
365
|
+
/* / */
|
|
366
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
367
|
+
/* { */
|
|
368
|
+
CHAR_LEFT_PARENTHESES,
|
|
369
|
+
/* ( */
|
|
370
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
371
|
+
/* [ */
|
|
372
|
+
CHAR_PLUS,
|
|
373
|
+
/* + */
|
|
374
|
+
CHAR_QUESTION_MARK,
|
|
375
|
+
/* ? */
|
|
376
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
377
|
+
/* } */
|
|
378
|
+
CHAR_RIGHT_PARENTHESES,
|
|
379
|
+
/* ) */
|
|
380
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
381
|
+
/* ] */
|
|
382
|
+
} = require_constants();
|
|
383
|
+
var isPathSeparator = (code) => {
|
|
384
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
385
|
+
};
|
|
386
|
+
var depth = (token) => {
|
|
387
|
+
if (token.isPrefix !== true) {
|
|
388
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var scan = (input, options) => {
|
|
392
|
+
const opts = options || {};
|
|
393
|
+
const length = input.length - 1;
|
|
394
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
395
|
+
const slashes = [];
|
|
396
|
+
const tokens = [];
|
|
397
|
+
const parts = [];
|
|
398
|
+
let str = input;
|
|
399
|
+
let index = -1;
|
|
400
|
+
let start = 0;
|
|
401
|
+
let lastIndex = 0;
|
|
402
|
+
let isBrace = false;
|
|
403
|
+
let isBracket = false;
|
|
404
|
+
let isGlob = false;
|
|
405
|
+
let isExtglob = false;
|
|
406
|
+
let isGlobstar = false;
|
|
407
|
+
let braceEscaped = false;
|
|
408
|
+
let backslashes = false;
|
|
409
|
+
let negated = false;
|
|
410
|
+
let negatedExtglob = false;
|
|
411
|
+
let finished = false;
|
|
412
|
+
let braces = 0;
|
|
413
|
+
let prev;
|
|
414
|
+
let code;
|
|
415
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
416
|
+
const eos = () => index >= length;
|
|
417
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
418
|
+
const advance = () => {
|
|
419
|
+
prev = code;
|
|
420
|
+
return str.charCodeAt(++index);
|
|
421
|
+
};
|
|
422
|
+
while (index < length) {
|
|
423
|
+
code = advance();
|
|
424
|
+
let next;
|
|
425
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
426
|
+
backslashes = token.backslashes = true;
|
|
427
|
+
code = advance();
|
|
428
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
429
|
+
braceEscaped = true;
|
|
430
|
+
}
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
434
|
+
braces++;
|
|
435
|
+
while (eos() !== true && (code = advance())) {
|
|
436
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
437
|
+
backslashes = token.backslashes = true;
|
|
438
|
+
advance();
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
442
|
+
braces++;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
446
|
+
isBrace = token.isBrace = true;
|
|
447
|
+
isGlob = token.isGlob = true;
|
|
448
|
+
finished = true;
|
|
449
|
+
if (scanToEnd === true) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
455
|
+
isBrace = token.isBrace = true;
|
|
456
|
+
isGlob = token.isGlob = true;
|
|
457
|
+
finished = true;
|
|
458
|
+
if (scanToEnd === true) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
464
|
+
braces--;
|
|
465
|
+
if (braces === 0) {
|
|
466
|
+
braceEscaped = false;
|
|
467
|
+
isBrace = token.isBrace = true;
|
|
468
|
+
finished = true;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (scanToEnd === true) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
479
|
+
slashes.push(index);
|
|
480
|
+
tokens.push(token);
|
|
481
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
482
|
+
if (finished === true) continue;
|
|
483
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
484
|
+
start += 2;
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
lastIndex = index + 1;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (opts.noext !== true) {
|
|
491
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
492
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
493
|
+
isGlob = token.isGlob = true;
|
|
494
|
+
isExtglob = token.isExtglob = true;
|
|
495
|
+
finished = true;
|
|
496
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
497
|
+
negatedExtglob = true;
|
|
498
|
+
}
|
|
499
|
+
if (scanToEnd === true) {
|
|
500
|
+
while (eos() !== true && (code = advance())) {
|
|
501
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
502
|
+
backslashes = token.backslashes = true;
|
|
503
|
+
code = advance();
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
507
|
+
isGlob = token.isGlob = true;
|
|
508
|
+
finished = true;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (code === CHAR_ASTERISK) {
|
|
518
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
519
|
+
isGlob = token.isGlob = true;
|
|
520
|
+
finished = true;
|
|
521
|
+
if (scanToEnd === true) {
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
527
|
+
isGlob = token.isGlob = true;
|
|
528
|
+
finished = true;
|
|
529
|
+
if (scanToEnd === true) {
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
535
|
+
while (eos() !== true && (next = advance())) {
|
|
536
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
537
|
+
backslashes = token.backslashes = true;
|
|
538
|
+
advance();
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
542
|
+
isBracket = token.isBracket = true;
|
|
543
|
+
isGlob = token.isGlob = true;
|
|
544
|
+
finished = true;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (scanToEnd === true) {
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
554
|
+
negated = token.negated = true;
|
|
555
|
+
start++;
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
559
|
+
isGlob = token.isGlob = true;
|
|
560
|
+
if (scanToEnd === true) {
|
|
561
|
+
while (eos() !== true && (code = advance())) {
|
|
562
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
563
|
+
backslashes = token.backslashes = true;
|
|
564
|
+
code = advance();
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
568
|
+
finished = true;
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
if (isGlob === true) {
|
|
577
|
+
finished = true;
|
|
578
|
+
if (scanToEnd === true) {
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (opts.noext === true) {
|
|
585
|
+
isExtglob = false;
|
|
586
|
+
isGlob = false;
|
|
587
|
+
}
|
|
588
|
+
let base = str;
|
|
589
|
+
let prefix = "";
|
|
590
|
+
let glob = "";
|
|
591
|
+
if (start > 0) {
|
|
592
|
+
prefix = str.slice(0, start);
|
|
593
|
+
str = str.slice(start);
|
|
594
|
+
lastIndex -= start;
|
|
595
|
+
}
|
|
596
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
597
|
+
base = str.slice(0, lastIndex);
|
|
598
|
+
glob = str.slice(lastIndex);
|
|
599
|
+
} else if (isGlob === true) {
|
|
600
|
+
base = "";
|
|
601
|
+
glob = str;
|
|
602
|
+
} else {
|
|
603
|
+
base = str;
|
|
604
|
+
}
|
|
605
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
606
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
607
|
+
base = base.slice(0, -1);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (opts.unescape === true) {
|
|
611
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
612
|
+
if (base && backslashes === true) {
|
|
613
|
+
base = utils.removeBackslashes(base);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const state = {
|
|
617
|
+
prefix,
|
|
618
|
+
input,
|
|
619
|
+
start,
|
|
620
|
+
base,
|
|
621
|
+
glob,
|
|
622
|
+
isBrace,
|
|
623
|
+
isBracket,
|
|
624
|
+
isGlob,
|
|
625
|
+
isExtglob,
|
|
626
|
+
isGlobstar,
|
|
627
|
+
negated,
|
|
628
|
+
negatedExtglob
|
|
629
|
+
};
|
|
630
|
+
if (opts.tokens === true) {
|
|
631
|
+
state.maxDepth = 0;
|
|
632
|
+
if (!isPathSeparator(code)) {
|
|
633
|
+
tokens.push(token);
|
|
634
|
+
}
|
|
635
|
+
state.tokens = tokens;
|
|
636
|
+
}
|
|
637
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
638
|
+
let prevIndex;
|
|
639
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
640
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
641
|
+
const i = slashes[idx];
|
|
642
|
+
const value = input.slice(n, i);
|
|
643
|
+
if (opts.tokens) {
|
|
644
|
+
if (idx === 0 && start !== 0) {
|
|
645
|
+
tokens[idx].isPrefix = true;
|
|
646
|
+
tokens[idx].value = prefix;
|
|
647
|
+
} else {
|
|
648
|
+
tokens[idx].value = value;
|
|
649
|
+
}
|
|
650
|
+
depth(tokens[idx]);
|
|
651
|
+
state.maxDepth += tokens[idx].depth;
|
|
652
|
+
}
|
|
653
|
+
if (idx !== 0 || value !== "") {
|
|
654
|
+
parts.push(value);
|
|
655
|
+
}
|
|
656
|
+
prevIndex = i;
|
|
657
|
+
}
|
|
658
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
659
|
+
const value = input.slice(prevIndex + 1);
|
|
660
|
+
parts.push(value);
|
|
661
|
+
if (opts.tokens) {
|
|
662
|
+
tokens[tokens.length - 1].value = value;
|
|
663
|
+
depth(tokens[tokens.length - 1]);
|
|
664
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
state.slashes = slashes;
|
|
668
|
+
state.parts = parts;
|
|
669
|
+
}
|
|
670
|
+
return state;
|
|
671
|
+
};
|
|
672
|
+
module.exports = scan;
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
677
|
+
var require_parse = __commonJS({
|
|
678
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
679
|
+
var constants = require_constants();
|
|
680
|
+
var utils = require_utils();
|
|
681
|
+
var {
|
|
682
|
+
MAX_LENGTH,
|
|
683
|
+
POSIX_REGEX_SOURCE,
|
|
684
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
685
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
686
|
+
REPLACEMENTS
|
|
687
|
+
} = constants;
|
|
688
|
+
var expandRange = (args, options) => {
|
|
689
|
+
if (typeof options.expandRange === "function") {
|
|
690
|
+
return options.expandRange(...args, options);
|
|
691
|
+
}
|
|
692
|
+
args.sort();
|
|
693
|
+
const value = `[${args.join("-")}]`;
|
|
694
|
+
try {
|
|
695
|
+
new RegExp(value);
|
|
696
|
+
} catch (ex) {
|
|
697
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
698
|
+
}
|
|
699
|
+
return value;
|
|
700
|
+
};
|
|
701
|
+
var syntaxError = (type, char) => {
|
|
702
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
703
|
+
};
|
|
704
|
+
var parse2 = (input, options) => {
|
|
705
|
+
if (typeof input !== "string") {
|
|
706
|
+
throw new TypeError("Expected a string");
|
|
707
|
+
}
|
|
708
|
+
input = REPLACEMENTS[input] || input;
|
|
709
|
+
const opts = { ...options };
|
|
710
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
711
|
+
let len = input.length;
|
|
712
|
+
if (len > max) {
|
|
713
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
714
|
+
}
|
|
715
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
716
|
+
const tokens = [bos];
|
|
717
|
+
const capture = opts.capture ? "" : "?:";
|
|
718
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
719
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
720
|
+
const {
|
|
721
|
+
DOT_LITERAL,
|
|
722
|
+
PLUS_LITERAL,
|
|
723
|
+
SLASH_LITERAL,
|
|
724
|
+
ONE_CHAR,
|
|
725
|
+
DOTS_SLASH,
|
|
726
|
+
NO_DOT,
|
|
727
|
+
NO_DOT_SLASH,
|
|
728
|
+
NO_DOTS_SLASH,
|
|
729
|
+
QMARK,
|
|
730
|
+
QMARK_NO_DOT,
|
|
731
|
+
STAR,
|
|
732
|
+
START_ANCHOR
|
|
733
|
+
} = PLATFORM_CHARS;
|
|
734
|
+
const globstar = (opts2) => {
|
|
735
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
736
|
+
};
|
|
737
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
738
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
739
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
740
|
+
if (opts.capture) {
|
|
741
|
+
star = `(${star})`;
|
|
742
|
+
}
|
|
743
|
+
if (typeof opts.noext === "boolean") {
|
|
744
|
+
opts.noextglob = opts.noext;
|
|
745
|
+
}
|
|
746
|
+
const state = {
|
|
747
|
+
input,
|
|
748
|
+
index: -1,
|
|
749
|
+
start: 0,
|
|
750
|
+
dot: opts.dot === true,
|
|
751
|
+
consumed: "",
|
|
752
|
+
output: "",
|
|
753
|
+
prefix: "",
|
|
754
|
+
backtrack: false,
|
|
755
|
+
negated: false,
|
|
756
|
+
brackets: 0,
|
|
757
|
+
braces: 0,
|
|
758
|
+
parens: 0,
|
|
759
|
+
quotes: 0,
|
|
760
|
+
globstar: false,
|
|
761
|
+
tokens
|
|
762
|
+
};
|
|
763
|
+
input = utils.removePrefix(input, state);
|
|
764
|
+
len = input.length;
|
|
765
|
+
const extglobs = [];
|
|
766
|
+
const braces = [];
|
|
767
|
+
const stack = [];
|
|
768
|
+
let prev = bos;
|
|
769
|
+
let value;
|
|
770
|
+
const eos = () => state.index === len - 1;
|
|
771
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
772
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
773
|
+
const remaining = () => input.slice(state.index + 1);
|
|
774
|
+
const consume = (value2 = "", num = 0) => {
|
|
775
|
+
state.consumed += value2;
|
|
776
|
+
state.index += num;
|
|
777
|
+
};
|
|
778
|
+
const append = (token) => {
|
|
779
|
+
state.output += token.output != null ? token.output : token.value;
|
|
780
|
+
consume(token.value);
|
|
781
|
+
};
|
|
782
|
+
const negate = () => {
|
|
783
|
+
let count = 1;
|
|
784
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
785
|
+
advance();
|
|
786
|
+
state.start++;
|
|
787
|
+
count++;
|
|
788
|
+
}
|
|
789
|
+
if (count % 2 === 0) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
state.negated = true;
|
|
793
|
+
state.start++;
|
|
794
|
+
return true;
|
|
795
|
+
};
|
|
796
|
+
const increment = (type) => {
|
|
797
|
+
state[type]++;
|
|
798
|
+
stack.push(type);
|
|
799
|
+
};
|
|
800
|
+
const decrement = (type) => {
|
|
801
|
+
state[type]--;
|
|
802
|
+
stack.pop();
|
|
803
|
+
};
|
|
804
|
+
const push = (tok) => {
|
|
805
|
+
if (prev.type === "globstar") {
|
|
806
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
807
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
808
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
809
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
810
|
+
prev.type = "star";
|
|
811
|
+
prev.value = "*";
|
|
812
|
+
prev.output = star;
|
|
813
|
+
state.output += prev.output;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
817
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
818
|
+
}
|
|
819
|
+
if (tok.value || tok.output) append(tok);
|
|
820
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
821
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
822
|
+
prev.value += tok.value;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
tok.prev = prev;
|
|
826
|
+
tokens.push(tok);
|
|
827
|
+
prev = tok;
|
|
828
|
+
};
|
|
829
|
+
const extglobOpen = (type, value2) => {
|
|
830
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
831
|
+
token.prev = prev;
|
|
832
|
+
token.parens = state.parens;
|
|
833
|
+
token.output = state.output;
|
|
834
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
835
|
+
increment("parens");
|
|
836
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
837
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
838
|
+
extglobs.push(token);
|
|
839
|
+
};
|
|
840
|
+
const extglobClose = (token) => {
|
|
841
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
842
|
+
let rest;
|
|
843
|
+
if (token.type === "negate") {
|
|
844
|
+
let extglobStar = star;
|
|
845
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
846
|
+
extglobStar = globstar(opts);
|
|
847
|
+
}
|
|
848
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
849
|
+
output = token.close = `)$))${extglobStar}`;
|
|
850
|
+
}
|
|
851
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
852
|
+
const expression = parse2(rest, { ...options, fastpaths: false }).output;
|
|
853
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
854
|
+
}
|
|
855
|
+
if (token.prev.type === "bos") {
|
|
856
|
+
state.negatedExtglob = true;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
push({ type: "paren", extglob: true, value, output });
|
|
860
|
+
decrement("parens");
|
|
861
|
+
};
|
|
862
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
863
|
+
let backslashes = false;
|
|
864
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
865
|
+
if (first === "\\") {
|
|
866
|
+
backslashes = true;
|
|
867
|
+
return m;
|
|
868
|
+
}
|
|
869
|
+
if (first === "?") {
|
|
870
|
+
if (esc) {
|
|
871
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
872
|
+
}
|
|
873
|
+
if (index === 0) {
|
|
874
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
875
|
+
}
|
|
876
|
+
return QMARK.repeat(chars.length);
|
|
877
|
+
}
|
|
878
|
+
if (first === ".") {
|
|
879
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
880
|
+
}
|
|
881
|
+
if (first === "*") {
|
|
882
|
+
if (esc) {
|
|
883
|
+
return esc + first + (rest ? star : "");
|
|
884
|
+
}
|
|
885
|
+
return star;
|
|
886
|
+
}
|
|
887
|
+
return esc ? m : `\\${m}`;
|
|
888
|
+
});
|
|
889
|
+
if (backslashes === true) {
|
|
890
|
+
if (opts.unescape === true) {
|
|
891
|
+
output = output.replace(/\\/g, "");
|
|
892
|
+
} else {
|
|
893
|
+
output = output.replace(/\\+/g, (m) => {
|
|
894
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
if (output === input && opts.contains === true) {
|
|
899
|
+
state.output = input;
|
|
900
|
+
return state;
|
|
901
|
+
}
|
|
902
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
903
|
+
return state;
|
|
904
|
+
}
|
|
905
|
+
while (!eos()) {
|
|
906
|
+
value = advance();
|
|
907
|
+
if (value === "\0") {
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
if (value === "\\") {
|
|
911
|
+
const next = peek();
|
|
912
|
+
if (next === "/" && opts.bash !== true) {
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
if (next === "." || next === ";") {
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
if (!next) {
|
|
919
|
+
value += "\\";
|
|
920
|
+
push({ type: "text", value });
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
const match = /^\\+/.exec(remaining());
|
|
924
|
+
let slashes = 0;
|
|
925
|
+
if (match && match[0].length > 2) {
|
|
926
|
+
slashes = match[0].length;
|
|
927
|
+
state.index += slashes;
|
|
928
|
+
if (slashes % 2 !== 0) {
|
|
929
|
+
value += "\\";
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (opts.unescape === true) {
|
|
933
|
+
value = advance();
|
|
934
|
+
} else {
|
|
935
|
+
value += advance();
|
|
936
|
+
}
|
|
937
|
+
if (state.brackets === 0) {
|
|
938
|
+
push({ type: "text", value });
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
943
|
+
if (opts.posix !== false && value === ":") {
|
|
944
|
+
const inner = prev.value.slice(1);
|
|
945
|
+
if (inner.includes("[")) {
|
|
946
|
+
prev.posix = true;
|
|
947
|
+
if (inner.includes(":")) {
|
|
948
|
+
const idx = prev.value.lastIndexOf("[");
|
|
949
|
+
const pre = prev.value.slice(0, idx);
|
|
950
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
951
|
+
const posix3 = POSIX_REGEX_SOURCE[rest2];
|
|
952
|
+
if (posix3) {
|
|
953
|
+
prev.value = pre + posix3;
|
|
954
|
+
state.backtrack = true;
|
|
955
|
+
advance();
|
|
956
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
957
|
+
bos.output = ONE_CHAR;
|
|
958
|
+
}
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
965
|
+
value = `\\${value}`;
|
|
966
|
+
}
|
|
967
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
968
|
+
value = `\\${value}`;
|
|
969
|
+
}
|
|
970
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
971
|
+
value = "^";
|
|
972
|
+
}
|
|
973
|
+
prev.value += value;
|
|
974
|
+
append({ value });
|
|
975
|
+
continue;
|
|
976
|
+
}
|
|
977
|
+
if (state.quotes === 1 && value !== '"') {
|
|
978
|
+
value = utils.escapeRegex(value);
|
|
979
|
+
prev.value += value;
|
|
980
|
+
append({ value });
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (value === '"') {
|
|
984
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
985
|
+
if (opts.keepQuotes === true) {
|
|
986
|
+
push({ type: "text", value });
|
|
987
|
+
}
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
if (value === "(") {
|
|
991
|
+
increment("parens");
|
|
992
|
+
push({ type: "paren", value });
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (value === ")") {
|
|
996
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
997
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
998
|
+
}
|
|
999
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1000
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1001
|
+
extglobClose(extglobs.pop());
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1005
|
+
decrement("parens");
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
if (value === "[") {
|
|
1009
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1010
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1011
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1012
|
+
}
|
|
1013
|
+
value = `\\${value}`;
|
|
1014
|
+
} else {
|
|
1015
|
+
increment("brackets");
|
|
1016
|
+
}
|
|
1017
|
+
push({ type: "bracket", value });
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
if (value === "]") {
|
|
1021
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1022
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
if (state.brackets === 0) {
|
|
1026
|
+
if (opts.strictBrackets === true) {
|
|
1027
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1028
|
+
}
|
|
1029
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
decrement("brackets");
|
|
1033
|
+
const prevValue = prev.value.slice(1);
|
|
1034
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1035
|
+
value = `/${value}`;
|
|
1036
|
+
}
|
|
1037
|
+
prev.value += value;
|
|
1038
|
+
append({ value });
|
|
1039
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1043
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1044
|
+
if (opts.literalBrackets === true) {
|
|
1045
|
+
state.output += escaped;
|
|
1046
|
+
prev.value = escaped;
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1050
|
+
state.output += prev.value;
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1054
|
+
increment("braces");
|
|
1055
|
+
const open = {
|
|
1056
|
+
type: "brace",
|
|
1057
|
+
value,
|
|
1058
|
+
output: "(",
|
|
1059
|
+
outputIndex: state.output.length,
|
|
1060
|
+
tokensIndex: state.tokens.length
|
|
1061
|
+
};
|
|
1062
|
+
braces.push(open);
|
|
1063
|
+
push(open);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
if (value === "}") {
|
|
1067
|
+
const brace = braces[braces.length - 1];
|
|
1068
|
+
if (opts.nobrace === true || !brace) {
|
|
1069
|
+
push({ type: "text", value, output: value });
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
let output = ")";
|
|
1073
|
+
if (brace.dots === true) {
|
|
1074
|
+
const arr = tokens.slice();
|
|
1075
|
+
const range = [];
|
|
1076
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1077
|
+
tokens.pop();
|
|
1078
|
+
if (arr[i].type === "brace") {
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
if (arr[i].type !== "dots") {
|
|
1082
|
+
range.unshift(arr[i].value);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
output = expandRange(range, opts);
|
|
1086
|
+
state.backtrack = true;
|
|
1087
|
+
}
|
|
1088
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1089
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1090
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1091
|
+
brace.value = brace.output = "\\{";
|
|
1092
|
+
value = output = "\\}";
|
|
1093
|
+
state.output = out;
|
|
1094
|
+
for (const t of toks) {
|
|
1095
|
+
state.output += t.output || t.value;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
push({ type: "brace", value, output });
|
|
1099
|
+
decrement("braces");
|
|
1100
|
+
braces.pop();
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
if (value === "|") {
|
|
1104
|
+
if (extglobs.length > 0) {
|
|
1105
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1106
|
+
}
|
|
1107
|
+
push({ type: "text", value });
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
if (value === ",") {
|
|
1111
|
+
let output = value;
|
|
1112
|
+
const brace = braces[braces.length - 1];
|
|
1113
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1114
|
+
brace.comma = true;
|
|
1115
|
+
output = "|";
|
|
1116
|
+
}
|
|
1117
|
+
push({ type: "comma", value, output });
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
if (value === "/") {
|
|
1121
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1122
|
+
state.start = state.index + 1;
|
|
1123
|
+
state.consumed = "";
|
|
1124
|
+
state.output = "";
|
|
1125
|
+
tokens.pop();
|
|
1126
|
+
prev = bos;
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (value === ".") {
|
|
1133
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1134
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1135
|
+
const brace = braces[braces.length - 1];
|
|
1136
|
+
prev.type = "dots";
|
|
1137
|
+
prev.output += value;
|
|
1138
|
+
prev.value += value;
|
|
1139
|
+
brace.dots = true;
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1143
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
if (value === "?") {
|
|
1150
|
+
const isGroup = prev && prev.value === "(";
|
|
1151
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1152
|
+
extglobOpen("qmark", value);
|
|
1153
|
+
continue;
|
|
1154
|
+
}
|
|
1155
|
+
if (prev && prev.type === "paren") {
|
|
1156
|
+
const next = peek();
|
|
1157
|
+
let output = value;
|
|
1158
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1159
|
+
output = `\\${value}`;
|
|
1160
|
+
}
|
|
1161
|
+
push({ type: "text", value, output });
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1165
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
if (value === "!") {
|
|
1172
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1173
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1174
|
+
extglobOpen("negate", value);
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1179
|
+
negate();
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (value === "+") {
|
|
1184
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1185
|
+
extglobOpen("plus", value);
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1189
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1193
|
+
push({ type: "plus", value });
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
if (value === "@") {
|
|
1200
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1201
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
push({ type: "text", value });
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (value !== "*") {
|
|
1208
|
+
if (value === "$" || value === "^") {
|
|
1209
|
+
value = `\\${value}`;
|
|
1210
|
+
}
|
|
1211
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1212
|
+
if (match) {
|
|
1213
|
+
value += match[0];
|
|
1214
|
+
state.index += match[0].length;
|
|
1215
|
+
}
|
|
1216
|
+
push({ type: "text", value });
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1219
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1220
|
+
prev.type = "star";
|
|
1221
|
+
prev.star = true;
|
|
1222
|
+
prev.value += value;
|
|
1223
|
+
prev.output = star;
|
|
1224
|
+
state.backtrack = true;
|
|
1225
|
+
state.globstar = true;
|
|
1226
|
+
consume(value);
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
let rest = remaining();
|
|
1230
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1231
|
+
extglobOpen("star", value);
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
if (prev.type === "star") {
|
|
1235
|
+
if (opts.noglobstar === true) {
|
|
1236
|
+
consume(value);
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
const prior = prev.prev;
|
|
1240
|
+
const before = prior.prev;
|
|
1241
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1242
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1243
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1244
|
+
push({ type: "star", value, output: "" });
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1248
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1249
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1250
|
+
push({ type: "star", value, output: "" });
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1254
|
+
const after = input[state.index + 4];
|
|
1255
|
+
if (after && after !== "/") {
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
rest = rest.slice(3);
|
|
1259
|
+
consume("/**", 3);
|
|
1260
|
+
}
|
|
1261
|
+
if (prior.type === "bos" && eos()) {
|
|
1262
|
+
prev.type = "globstar";
|
|
1263
|
+
prev.value += value;
|
|
1264
|
+
prev.output = globstar(opts);
|
|
1265
|
+
state.output = prev.output;
|
|
1266
|
+
state.globstar = true;
|
|
1267
|
+
consume(value);
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1271
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1272
|
+
prior.output = `(?:${prior.output}`;
|
|
1273
|
+
prev.type = "globstar";
|
|
1274
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1275
|
+
prev.value += value;
|
|
1276
|
+
state.globstar = true;
|
|
1277
|
+
state.output += prior.output + prev.output;
|
|
1278
|
+
consume(value);
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1282
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1283
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1284
|
+
prior.output = `(?:${prior.output}`;
|
|
1285
|
+
prev.type = "globstar";
|
|
1286
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1287
|
+
prev.value += value;
|
|
1288
|
+
state.output += prior.output + prev.output;
|
|
1289
|
+
state.globstar = true;
|
|
1290
|
+
consume(value + advance());
|
|
1291
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1295
|
+
prev.type = "globstar";
|
|
1296
|
+
prev.value += value;
|
|
1297
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1298
|
+
state.output = prev.output;
|
|
1299
|
+
state.globstar = true;
|
|
1300
|
+
consume(value + advance());
|
|
1301
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1302
|
+
continue;
|
|
1303
|
+
}
|
|
1304
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1305
|
+
prev.type = "globstar";
|
|
1306
|
+
prev.output = globstar(opts);
|
|
1307
|
+
prev.value += value;
|
|
1308
|
+
state.output += prev.output;
|
|
1309
|
+
state.globstar = true;
|
|
1310
|
+
consume(value);
|
|
1311
|
+
continue;
|
|
1312
|
+
}
|
|
1313
|
+
const token = { type: "star", value, output: star };
|
|
1314
|
+
if (opts.bash === true) {
|
|
1315
|
+
token.output = ".*?";
|
|
1316
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1317
|
+
token.output = nodot + token.output;
|
|
1318
|
+
}
|
|
1319
|
+
push(token);
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1323
|
+
token.output = value;
|
|
1324
|
+
push(token);
|
|
1325
|
+
continue;
|
|
1326
|
+
}
|
|
1327
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1328
|
+
if (prev.type === "dot") {
|
|
1329
|
+
state.output += NO_DOT_SLASH;
|
|
1330
|
+
prev.output += NO_DOT_SLASH;
|
|
1331
|
+
} else if (opts.dot === true) {
|
|
1332
|
+
state.output += NO_DOTS_SLASH;
|
|
1333
|
+
prev.output += NO_DOTS_SLASH;
|
|
1334
|
+
} else {
|
|
1335
|
+
state.output += nodot;
|
|
1336
|
+
prev.output += nodot;
|
|
1337
|
+
}
|
|
1338
|
+
if (peek() !== "*") {
|
|
1339
|
+
state.output += ONE_CHAR;
|
|
1340
|
+
prev.output += ONE_CHAR;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
push(token);
|
|
1344
|
+
}
|
|
1345
|
+
while (state.brackets > 0) {
|
|
1346
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1347
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1348
|
+
decrement("brackets");
|
|
1349
|
+
}
|
|
1350
|
+
while (state.parens > 0) {
|
|
1351
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1352
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1353
|
+
decrement("parens");
|
|
1354
|
+
}
|
|
1355
|
+
while (state.braces > 0) {
|
|
1356
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1357
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1358
|
+
decrement("braces");
|
|
1359
|
+
}
|
|
1360
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1361
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1362
|
+
}
|
|
1363
|
+
if (state.backtrack === true) {
|
|
1364
|
+
state.output = "";
|
|
1365
|
+
for (const token of state.tokens) {
|
|
1366
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1367
|
+
if (token.suffix) {
|
|
1368
|
+
state.output += token.suffix;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
return state;
|
|
1373
|
+
};
|
|
1374
|
+
parse2.fastpaths = (input, options) => {
|
|
1375
|
+
const opts = { ...options };
|
|
1376
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1377
|
+
const len = input.length;
|
|
1378
|
+
if (len > max) {
|
|
1379
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1380
|
+
}
|
|
1381
|
+
input = REPLACEMENTS[input] || input;
|
|
1382
|
+
const {
|
|
1383
|
+
DOT_LITERAL,
|
|
1384
|
+
SLASH_LITERAL,
|
|
1385
|
+
ONE_CHAR,
|
|
1386
|
+
DOTS_SLASH,
|
|
1387
|
+
NO_DOT,
|
|
1388
|
+
NO_DOTS,
|
|
1389
|
+
NO_DOTS_SLASH,
|
|
1390
|
+
STAR,
|
|
1391
|
+
START_ANCHOR
|
|
1392
|
+
} = constants.globChars(opts.windows);
|
|
1393
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1394
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1395
|
+
const capture = opts.capture ? "" : "?:";
|
|
1396
|
+
const state = { negated: false, prefix: "" };
|
|
1397
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1398
|
+
if (opts.capture) {
|
|
1399
|
+
star = `(${star})`;
|
|
1400
|
+
}
|
|
1401
|
+
const globstar = (opts2) => {
|
|
1402
|
+
if (opts2.noglobstar === true) return star;
|
|
1403
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1404
|
+
};
|
|
1405
|
+
const create = (str) => {
|
|
1406
|
+
switch (str) {
|
|
1407
|
+
case "*":
|
|
1408
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1409
|
+
case ".*":
|
|
1410
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1411
|
+
case "*.*":
|
|
1412
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1413
|
+
case "*/*":
|
|
1414
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1415
|
+
case "**":
|
|
1416
|
+
return nodot + globstar(opts);
|
|
1417
|
+
case "**/*":
|
|
1418
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1419
|
+
case "**/*.*":
|
|
1420
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1421
|
+
case "**/.*":
|
|
1422
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1423
|
+
default: {
|
|
1424
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1425
|
+
if (!match) return;
|
|
1426
|
+
const source2 = create(match[1]);
|
|
1427
|
+
if (!source2) return;
|
|
1428
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
const output = utils.removePrefix(input, state);
|
|
1433
|
+
let source = create(output);
|
|
1434
|
+
if (source && opts.strictSlashes !== true) {
|
|
1435
|
+
source += `${SLASH_LITERAL}?`;
|
|
1436
|
+
}
|
|
1437
|
+
return source;
|
|
1438
|
+
};
|
|
1439
|
+
module.exports = parse2;
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1444
|
+
var require_picomatch = __commonJS({
|
|
1445
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1446
|
+
var scan = require_scan();
|
|
1447
|
+
var parse2 = require_parse();
|
|
1448
|
+
var utils = require_utils();
|
|
1449
|
+
var constants = require_constants();
|
|
1450
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1451
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
1452
|
+
if (Array.isArray(glob)) {
|
|
1453
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1454
|
+
const arrayMatcher = (str) => {
|
|
1455
|
+
for (const isMatch of fns) {
|
|
1456
|
+
const state2 = isMatch(str);
|
|
1457
|
+
if (state2) return state2;
|
|
1458
|
+
}
|
|
1459
|
+
return false;
|
|
1460
|
+
};
|
|
1461
|
+
return arrayMatcher;
|
|
1462
|
+
}
|
|
1463
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1464
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1465
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1466
|
+
}
|
|
1467
|
+
const opts = options || {};
|
|
1468
|
+
const posix3 = opts.windows;
|
|
1469
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1470
|
+
const state = regex.state;
|
|
1471
|
+
delete regex.state;
|
|
1472
|
+
let isIgnored = () => false;
|
|
1473
|
+
if (opts.ignore) {
|
|
1474
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1475
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1476
|
+
}
|
|
1477
|
+
const matcher = (input, returnObject = false) => {
|
|
1478
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix: posix3 });
|
|
1479
|
+
const result = { glob, state, regex, posix: posix3, input, output, match, isMatch };
|
|
1480
|
+
if (typeof opts.onResult === "function") {
|
|
1481
|
+
opts.onResult(result);
|
|
1482
|
+
}
|
|
1483
|
+
if (isMatch === false) {
|
|
1484
|
+
result.isMatch = false;
|
|
1485
|
+
return returnObject ? result : false;
|
|
1486
|
+
}
|
|
1487
|
+
if (isIgnored(input)) {
|
|
1488
|
+
if (typeof opts.onIgnore === "function") {
|
|
1489
|
+
opts.onIgnore(result);
|
|
1490
|
+
}
|
|
1491
|
+
result.isMatch = false;
|
|
1492
|
+
return returnObject ? result : false;
|
|
1493
|
+
}
|
|
1494
|
+
if (typeof opts.onMatch === "function") {
|
|
1495
|
+
opts.onMatch(result);
|
|
1496
|
+
}
|
|
1497
|
+
return returnObject ? result : true;
|
|
1498
|
+
};
|
|
1499
|
+
if (returnState) {
|
|
1500
|
+
matcher.state = state;
|
|
1501
|
+
}
|
|
1502
|
+
return matcher;
|
|
1503
|
+
};
|
|
1504
|
+
picomatch.test = (input, regex, options, { glob, posix: posix3 } = {}) => {
|
|
1505
|
+
if (typeof input !== "string") {
|
|
1506
|
+
throw new TypeError("Expected input to be a string");
|
|
1507
|
+
}
|
|
1508
|
+
if (input === "") {
|
|
1509
|
+
return { isMatch: false, output: "" };
|
|
1510
|
+
}
|
|
1511
|
+
const opts = options || {};
|
|
1512
|
+
const format2 = opts.format || (posix3 ? utils.toPosixSlashes : null);
|
|
1513
|
+
let match = input === glob;
|
|
1514
|
+
let output = match && format2 ? format2(input) : input;
|
|
1515
|
+
if (match === false) {
|
|
1516
|
+
output = format2 ? format2(input) : input;
|
|
1517
|
+
match = output === glob;
|
|
1518
|
+
}
|
|
1519
|
+
if (match === false || opts.capture === true) {
|
|
1520
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1521
|
+
match = picomatch.matchBase(input, regex, options, posix3);
|
|
1522
|
+
} else {
|
|
1523
|
+
match = regex.exec(output);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
return { isMatch: Boolean(match), match, output };
|
|
1527
|
+
};
|
|
1528
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
1529
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1530
|
+
return regex.test(utils.basename(input));
|
|
1531
|
+
};
|
|
1532
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1533
|
+
picomatch.parse = (pattern, options) => {
|
|
1534
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
1535
|
+
return parse2(pattern, { ...options, fastpaths: false });
|
|
1536
|
+
};
|
|
1537
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
1538
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1539
|
+
if (returnOutput === true) {
|
|
1540
|
+
return state.output;
|
|
1541
|
+
}
|
|
1542
|
+
const opts = options || {};
|
|
1543
|
+
const prepend = opts.contains ? "" : "^";
|
|
1544
|
+
const append = opts.contains ? "" : "$";
|
|
1545
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1546
|
+
if (state && state.negated === true) {
|
|
1547
|
+
source = `^(?!${source}).*$`;
|
|
1548
|
+
}
|
|
1549
|
+
const regex = picomatch.toRegex(source, options);
|
|
1550
|
+
if (returnState === true) {
|
|
1551
|
+
regex.state = state;
|
|
1552
|
+
}
|
|
1553
|
+
return regex;
|
|
1554
|
+
};
|
|
1555
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1556
|
+
if (!input || typeof input !== "string") {
|
|
1557
|
+
throw new TypeError("Expected a non-empty string");
|
|
1558
|
+
}
|
|
1559
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1560
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1561
|
+
parsed.output = parse2.fastpaths(input, options);
|
|
1562
|
+
}
|
|
1563
|
+
if (!parsed.output) {
|
|
1564
|
+
parsed = parse2(input, options);
|
|
1565
|
+
}
|
|
1566
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1567
|
+
};
|
|
1568
|
+
picomatch.toRegex = (source, options) => {
|
|
1569
|
+
try {
|
|
1570
|
+
const opts = options || {};
|
|
1571
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1572
|
+
} catch (err) {
|
|
1573
|
+
if (options && options.debug === true) throw err;
|
|
1574
|
+
return /$^/;
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
picomatch.constants = constants;
|
|
1578
|
+
module.exports = picomatch;
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
1583
|
+
var require_picomatch2 = __commonJS({
|
|
1584
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports, module) {
|
|
1585
|
+
var pico = require_picomatch();
|
|
1586
|
+
var utils = require_utils();
|
|
1587
|
+
function picomatch(glob, options, returnState = false) {
|
|
1588
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1589
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1590
|
+
}
|
|
1591
|
+
return pico(glob, options, returnState);
|
|
1592
|
+
}
|
|
1593
|
+
Object.assign(picomatch, pico);
|
|
1594
|
+
module.exports = picomatch;
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
|
|
1598
|
+
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/constants.js
|
|
1599
|
+
var require_constants2 = __commonJS({
|
|
87
1600
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/constants.js"(exports, module) {
|
|
88
1601
|
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
89
1602
|
var MAX_LENGTH = 256;
|
|
@@ -129,7 +1642,7 @@ var require_re = __commonJS({
|
|
|
129
1642
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
130
1643
|
MAX_SAFE_BUILD_LENGTH,
|
|
131
1644
|
MAX_LENGTH
|
|
132
|
-
} =
|
|
1645
|
+
} = require_constants2();
|
|
133
1646
|
var debug = require_debug();
|
|
134
1647
|
exports = module.exports = {};
|
|
135
1648
|
var re = exports.re = [];
|
|
@@ -255,7 +1768,7 @@ var require_identifiers = __commonJS({
|
|
|
255
1768
|
var require_semver = __commonJS({
|
|
256
1769
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/classes/semver.js"(exports, module) {
|
|
257
1770
|
var debug = require_debug();
|
|
258
|
-
var { MAX_LENGTH, MAX_SAFE_INTEGER } =
|
|
1771
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
|
|
259
1772
|
var { safeRe: re, t } = require_re();
|
|
260
1773
|
var parseOptions = require_parse_options();
|
|
261
1774
|
var { compareIdentifiers } = require_identifiers();
|
|
@@ -530,7 +2043,7 @@ var require_semver = __commonJS({
|
|
|
530
2043
|
});
|
|
531
2044
|
|
|
532
2045
|
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/parse.js
|
|
533
|
-
var
|
|
2046
|
+
var require_parse2 = __commonJS({
|
|
534
2047
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/parse.js"(exports, module) {
|
|
535
2048
|
var SemVer = require_semver();
|
|
536
2049
|
var parse2 = (version, options, throwErrors = false) => {
|
|
@@ -553,7 +2066,7 @@ var require_parse = __commonJS({
|
|
|
553
2066
|
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/valid.js
|
|
554
2067
|
var require_valid = __commonJS({
|
|
555
2068
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/valid.js"(exports, module) {
|
|
556
|
-
var parse2 =
|
|
2069
|
+
var parse2 = require_parse2();
|
|
557
2070
|
var valid = (version, options) => {
|
|
558
2071
|
const v = parse2(version, options);
|
|
559
2072
|
return v ? v.version : null;
|
|
@@ -565,7 +2078,7 @@ var require_valid = __commonJS({
|
|
|
565
2078
|
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/clean.js
|
|
566
2079
|
var require_clean = __commonJS({
|
|
567
2080
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/clean.js"(exports, module) {
|
|
568
|
-
var parse2 =
|
|
2081
|
+
var parse2 = require_parse2();
|
|
569
2082
|
var clean = (version, options) => {
|
|
570
2083
|
const s = parse2(version.trim().replace(/^[=v]+/, ""), options);
|
|
571
2084
|
return s ? s.version : null;
|
|
@@ -600,7 +2113,7 @@ var require_inc = __commonJS({
|
|
|
600
2113
|
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/diff.js
|
|
601
2114
|
var require_diff = __commonJS({
|
|
602
2115
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/diff.js"(exports, module) {
|
|
603
|
-
var parse2 =
|
|
2116
|
+
var parse2 = require_parse2();
|
|
604
2117
|
var diff = (version1, version2) => {
|
|
605
2118
|
const v1 = parse2(version1, null, true);
|
|
606
2119
|
const v2 = parse2(version2, null, true);
|
|
@@ -670,7 +2183,7 @@ var require_patch = __commonJS({
|
|
|
670
2183
|
// node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/prerelease.js
|
|
671
2184
|
var require_prerelease = __commonJS({
|
|
672
2185
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
673
|
-
var parse2 =
|
|
2186
|
+
var parse2 = require_parse2();
|
|
674
2187
|
var prerelease = (version, options) => {
|
|
675
2188
|
const parsed = parse2(version, options);
|
|
676
2189
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
@@ -844,7 +2357,7 @@ var require_cmp = __commonJS({
|
|
|
844
2357
|
var require_coerce = __commonJS({
|
|
845
2358
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/coerce.js"(exports, module) {
|
|
846
2359
|
var SemVer = require_semver();
|
|
847
|
-
var parse2 =
|
|
2360
|
+
var parse2 = require_parse2();
|
|
848
2361
|
var { safeRe: re, t } = require_re();
|
|
849
2362
|
var coerce = (version, options) => {
|
|
850
2363
|
if (version instanceof SemVer) {
|
|
@@ -1078,7 +2591,7 @@ var require_range = __commonJS({
|
|
|
1078
2591
|
tildeTrimReplace,
|
|
1079
2592
|
caretTrimReplace
|
|
1080
2593
|
} = require_re();
|
|
1081
|
-
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } =
|
|
2594
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants2();
|
|
1082
2595
|
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1083
2596
|
var isAny = (c) => c.value === "";
|
|
1084
2597
|
var isSatisfiable = (comparators, options) => {
|
|
@@ -1877,10 +3390,10 @@ var require_subset = __commonJS({
|
|
|
1877
3390
|
var require_semver2 = __commonJS({
|
|
1878
3391
|
"node_modules/.pnpm/semver@7.7.3/node_modules/semver/index.js"(exports, module) {
|
|
1879
3392
|
var internalRe = require_re();
|
|
1880
|
-
var constants =
|
|
3393
|
+
var constants = require_constants2();
|
|
1881
3394
|
var SemVer = require_semver();
|
|
1882
3395
|
var identifiers = require_identifiers();
|
|
1883
|
-
var parse2 =
|
|
3396
|
+
var parse2 = require_parse2();
|
|
1884
3397
|
var valid = require_valid();
|
|
1885
3398
|
var clean = require_clean();
|
|
1886
3399
|
var inc = require_inc();
|
|
@@ -3088,13 +4601,13 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
3088
4601
|
// src/polyfills/promise-with-resolvers.ts
|
|
3089
4602
|
if (typeof Promise.withResolvers === "undefined") {
|
|
3090
4603
|
Promise.withResolvers = () => {
|
|
3091
|
-
let
|
|
4604
|
+
let resolve3;
|
|
3092
4605
|
let reject;
|
|
3093
4606
|
const promise = new Promise((res, rej) => {
|
|
3094
|
-
|
|
4607
|
+
resolve3 = res;
|
|
3095
4608
|
reject = rej;
|
|
3096
4609
|
});
|
|
3097
|
-
return { promise, resolve:
|
|
4610
|
+
return { promise, resolve: resolve3, reject };
|
|
3098
4611
|
};
|
|
3099
4612
|
}
|
|
3100
4613
|
var vitePluginNextDynamic = () => ({
|
|
@@ -3119,6 +4632,70 @@ var vitePluginNextDynamic = () => ({
|
|
|
3119
4632
|
return null;
|
|
3120
4633
|
}
|
|
3121
4634
|
});
|
|
4635
|
+
var import_picomatch = __toESM(require_picomatch2());
|
|
4636
|
+
function isArray(arg) {
|
|
4637
|
+
return Array.isArray(arg);
|
|
4638
|
+
}
|
|
4639
|
+
function ensureArray(thing) {
|
|
4640
|
+
if (isArray(thing))
|
|
4641
|
+
return thing;
|
|
4642
|
+
if (thing == null)
|
|
4643
|
+
return [];
|
|
4644
|
+
return [thing];
|
|
4645
|
+
}
|
|
4646
|
+
var normalizePathRegExp = new RegExp(`\\${path.win32.sep}`, "g");
|
|
4647
|
+
var normalizePath = function normalizePath2(filename) {
|
|
4648
|
+
return filename.replace(normalizePathRegExp, path.posix.sep);
|
|
4649
|
+
};
|
|
4650
|
+
function getMatcherString(id, resolutionBase) {
|
|
4651
|
+
if (path.isAbsolute(id) || id.startsWith("**")) {
|
|
4652
|
+
return normalizePath(id);
|
|
4653
|
+
}
|
|
4654
|
+
const basePath = normalizePath(path.resolve("")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
|
|
4655
|
+
return path.posix.join(basePath, normalizePath(id));
|
|
4656
|
+
}
|
|
4657
|
+
var createFilter2 = function createFilter3(include, exclude, options) {
|
|
4658
|
+
const getMatcher = (id) => id instanceof RegExp ? id : {
|
|
4659
|
+
test: (what) => {
|
|
4660
|
+
const pattern = getMatcherString(id);
|
|
4661
|
+
const fn = (0, import_picomatch.default)(pattern, { dot: true });
|
|
4662
|
+
const result = fn(what);
|
|
4663
|
+
return result;
|
|
4664
|
+
}
|
|
4665
|
+
};
|
|
4666
|
+
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
4667
|
+
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
4668
|
+
if (!includeMatchers.length && !excludeMatchers.length)
|
|
4669
|
+
return (id) => typeof id === "string" && !id.includes("\0");
|
|
4670
|
+
return function result(id) {
|
|
4671
|
+
if (typeof id !== "string")
|
|
4672
|
+
return false;
|
|
4673
|
+
if (id.includes("\0"))
|
|
4674
|
+
return false;
|
|
4675
|
+
const pathId = normalizePath(id);
|
|
4676
|
+
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
4677
|
+
const matcher = excludeMatchers[i];
|
|
4678
|
+
if (matcher instanceof RegExp) {
|
|
4679
|
+
matcher.lastIndex = 0;
|
|
4680
|
+
}
|
|
4681
|
+
if (matcher.test(pathId))
|
|
4682
|
+
return false;
|
|
4683
|
+
}
|
|
4684
|
+
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
4685
|
+
const matcher = includeMatchers[i];
|
|
4686
|
+
if (matcher instanceof RegExp) {
|
|
4687
|
+
matcher.lastIndex = 0;
|
|
4688
|
+
}
|
|
4689
|
+
if (matcher.test(pathId))
|
|
4690
|
+
return true;
|
|
4691
|
+
}
|
|
4692
|
+
return !includeMatchers.length;
|
|
4693
|
+
};
|
|
4694
|
+
};
|
|
4695
|
+
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";
|
|
4696
|
+
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";
|
|
4697
|
+
var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
4698
|
+
forbiddenIdentifiers.add("");
|
|
3122
4699
|
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
3123
4700
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
3124
4701
|
var isVitestEnv = process.env.VITEST === "true";
|
|
@@ -3142,14 +4719,31 @@ var getAlias = (env) => ({
|
|
|
3142
4719
|
});
|
|
3143
4720
|
|
|
3144
4721
|
// src/plugins/next-image/plugin.ts
|
|
4722
|
+
var hasWarned = false;
|
|
4723
|
+
var warnOnce = (message) => {
|
|
4724
|
+
if (!hasWarned) {
|
|
4725
|
+
console.warn(`[vite-plugin-storybook-nextjs] ${message}`);
|
|
4726
|
+
hasWarned = true;
|
|
4727
|
+
}
|
|
4728
|
+
};
|
|
3145
4729
|
var includePattern2 = /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/;
|
|
3146
4730
|
var excludeImporterPattern = /\.(css|scss|sass)$/;
|
|
3147
4731
|
var virtualImage = "virtual:next-image";
|
|
3148
4732
|
var virtualNextImage = "virtual:next/image";
|
|
3149
4733
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
3150
4734
|
var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
3151
|
-
function vitePluginNextImage(nextConfigResolver) {
|
|
4735
|
+
function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
3152
4736
|
let isBrowser = !isVitestEnv;
|
|
4737
|
+
let hasVitePluginSvgr = false;
|
|
4738
|
+
const postfixRE = /[?#].*$/s;
|
|
4739
|
+
const filter = createFilter2(
|
|
4740
|
+
[
|
|
4741
|
+
"**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}",
|
|
4742
|
+
"**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}?*",
|
|
4743
|
+
"**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}#*"
|
|
4744
|
+
],
|
|
4745
|
+
options.excludeFiles
|
|
4746
|
+
);
|
|
3153
4747
|
return {
|
|
3154
4748
|
name: "vite-plugin-storybook-nextjs-image",
|
|
3155
4749
|
enforce: "pre",
|
|
@@ -3157,6 +4751,9 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
3157
4751
|
if (config.test?.browser?.enabled === true) {
|
|
3158
4752
|
isBrowser = true;
|
|
3159
4753
|
}
|
|
4754
|
+
hasVitePluginSvgr = !!config.plugins?.some(
|
|
4755
|
+
(plugin) => plugin && typeof plugin === "object" && "name" in plugin && (plugin.name === "vite-plugin-svgr" || plugin.name.includes("svgr"))
|
|
4756
|
+
);
|
|
3160
4757
|
return {
|
|
3161
4758
|
resolve: {
|
|
3162
4759
|
alias: getAlias(isBrowser ? "browser" : "node")
|
|
@@ -3168,9 +4765,24 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
3168
4765
|
if (queryA === "ignore") {
|
|
3169
4766
|
return null;
|
|
3170
4767
|
}
|
|
4768
|
+
const isSvg = /\.svg$/.test(source);
|
|
4769
|
+
if (isSvg && hasVitePluginSvgr && queryA === "react") {
|
|
4770
|
+
return null;
|
|
4771
|
+
}
|
|
4772
|
+
if (isSvg && hasVitePluginSvgr && !options.includeFiles && !options.excludeFiles) {
|
|
4773
|
+
warnOnce(
|
|
4774
|
+
tsDedent.dedent`Detected vite-plugin-svgr but you are not passing image include or exclude patterns to the nextjs-vite plugin. This may cause a conflict between the two plugins and issues with SVG files.
|
|
4775
|
+
|
|
4776
|
+
For more info and recommended configuration, see: https://github.com/storybookjs/vite-plugin-storybook-nextjs/blob/main/README.md#faq-includingexcluding-images`
|
|
4777
|
+
);
|
|
4778
|
+
}
|
|
3171
4779
|
if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(virtualImage)) {
|
|
3172
|
-
const
|
|
3173
|
-
const imagePath = importer ?
|
|
4780
|
+
const isAbsolute3 = posix.isAbsolute(id);
|
|
4781
|
+
const imagePath = importer ? isAbsolute3 ? source : posix.join(posix.dirname(importer), source) : source;
|
|
4782
|
+
const pathForFilter = imagePath.replace(postfixRE, "");
|
|
4783
|
+
if (!filter(pathForFilter)) {
|
|
4784
|
+
return null;
|
|
4785
|
+
}
|
|
3174
4786
|
return `${virtualImage}?${querystring.encode({ imagePath })}`;
|
|
3175
4787
|
}
|
|
3176
4788
|
if (id === "next/image" && importer !== virtualNextImage) {
|
|
@@ -3316,7 +4928,8 @@ var loadConfig = (
|
|
|
3316
4928
|
nextServerConfig__default.default.default || nextServerConfig__default.default
|
|
3317
4929
|
);
|
|
3318
4930
|
function VitePlugin({
|
|
3319
|
-
dir = process.cwd()
|
|
4931
|
+
dir = process.cwd(),
|
|
4932
|
+
image
|
|
3320
4933
|
} = {}) {
|
|
3321
4934
|
const resolvedDir = resolve(dir);
|
|
3322
4935
|
const nextConfigResolver = Promise.withResolvers();
|
|
@@ -3443,7 +5056,7 @@ function VitePlugin({
|
|
|
3443
5056
|
vitePluginNextFont(),
|
|
3444
5057
|
vitePluginNextSwc(dir, nextConfigResolver),
|
|
3445
5058
|
vitePluginNextEnv(dir, nextConfigResolver),
|
|
3446
|
-
vitePluginNextImage(nextConfigResolver),
|
|
5059
|
+
vitePluginNextImage(nextConfigResolver, image),
|
|
3447
5060
|
vitePluginNextMocks(),
|
|
3448
5061
|
vitePluginNextDynamic()
|
|
3449
5062
|
];
|