kirbyup 1.2.1 → 1.2.4

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.
@@ -1,7 +1,10 @@
1
1
  import { existsSync as existsSync$1 } from 'node:fs';
2
- import { resolve, normalize, relative, dirname, basename } from 'pathe';
3
- import { build as build$1, mergeConfig } from 'vite';
4
- import vuePlugin from '@vitejs/plugin-vue2';
2
+ import { resolve as resolve$1, normalize, relative, dirname, basename } from 'pathe';
3
+ import { transformWithEsbuild, formatPostcssSourceMap, build as build$1, mergeConfig } from 'vite';
4
+ import fs, { existsSync, statSync } from 'fs';
5
+ import path$2, { win32, posix, isAbsolute, resolve } from 'path';
6
+ import { createRequire } from 'module';
7
+ import { createHash } from 'crypto';
5
8
  import postcssrc from 'postcss-load-config';
6
9
  import postcssLogical from 'postcss-logical';
7
10
  import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
@@ -11,12 +14,3261 @@ import colors from 'picocolors';
11
14
  import { readFile } from 'fs/promises';
12
15
  import { gzip } from 'zlib';
13
16
  import { promisify } from 'util';
14
- import { existsSync, statSync } from 'fs';
15
17
  import { createConfigLoader } from 'unconfig';
16
18
  import MagicString from 'magic-string';
17
19
 
20
+ var utils$3 = {};
21
+
22
+ const path$1 = path$2;
23
+ const WIN_SLASH = '\\\\/';
24
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
25
+
26
+ /**
27
+ * Posix glob regex
28
+ */
29
+
30
+ const DOT_LITERAL = '\\.';
31
+ const PLUS_LITERAL = '\\+';
32
+ const QMARK_LITERAL = '\\?';
33
+ const SLASH_LITERAL = '\\/';
34
+ const ONE_CHAR = '(?=.)';
35
+ const QMARK = '[^/]';
36
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
37
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
38
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
39
+ const NO_DOT = `(?!${DOT_LITERAL})`;
40
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
41
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
42
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
43
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
44
+ const STAR = `${QMARK}*?`;
45
+
46
+ const POSIX_CHARS = {
47
+ DOT_LITERAL,
48
+ PLUS_LITERAL,
49
+ QMARK_LITERAL,
50
+ SLASH_LITERAL,
51
+ ONE_CHAR,
52
+ QMARK,
53
+ END_ANCHOR,
54
+ DOTS_SLASH,
55
+ NO_DOT,
56
+ NO_DOTS,
57
+ NO_DOT_SLASH,
58
+ NO_DOTS_SLASH,
59
+ QMARK_NO_DOT,
60
+ STAR,
61
+ START_ANCHOR
62
+ };
63
+
64
+ /**
65
+ * Windows glob regex
66
+ */
67
+
68
+ const WINDOWS_CHARS = {
69
+ ...POSIX_CHARS,
70
+
71
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
72
+ QMARK: WIN_NO_SLASH,
73
+ STAR: `${WIN_NO_SLASH}*?`,
74
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
75
+ NO_DOT: `(?!${DOT_LITERAL})`,
76
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
77
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
78
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
79
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
80
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
81
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
82
+ };
83
+
84
+ /**
85
+ * POSIX Bracket Regex
86
+ */
87
+
88
+ const POSIX_REGEX_SOURCE$1 = {
89
+ alnum: 'a-zA-Z0-9',
90
+ alpha: 'a-zA-Z',
91
+ ascii: '\\x00-\\x7F',
92
+ blank: ' \\t',
93
+ cntrl: '\\x00-\\x1F\\x7F',
94
+ digit: '0-9',
95
+ graph: '\\x21-\\x7E',
96
+ lower: 'a-z',
97
+ print: '\\x20-\\x7E ',
98
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
99
+ space: ' \\t\\r\\n\\v\\f',
100
+ upper: 'A-Z',
101
+ word: 'A-Za-z0-9_',
102
+ xdigit: 'A-Fa-f0-9'
103
+ };
104
+
105
+ var constants$2 = {
106
+ MAX_LENGTH: 1024 * 64,
107
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
108
+
109
+ // regular expressions
110
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
111
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
112
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
113
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
114
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
115
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
116
+
117
+ // Replace globs with equivalent patterns to reduce parsing time.
118
+ REPLACEMENTS: {
119
+ '***': '*',
120
+ '**/**': '**',
121
+ '**/**/**': '**'
122
+ },
123
+
124
+ // Digits
125
+ CHAR_0: 48, /* 0 */
126
+ CHAR_9: 57, /* 9 */
127
+
128
+ // Alphabet chars.
129
+ CHAR_UPPERCASE_A: 65, /* A */
130
+ CHAR_LOWERCASE_A: 97, /* a */
131
+ CHAR_UPPERCASE_Z: 90, /* Z */
132
+ CHAR_LOWERCASE_Z: 122, /* z */
133
+
134
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
135
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
136
+
137
+ CHAR_ASTERISK: 42, /* * */
138
+
139
+ // Non-alphabetic chars.
140
+ CHAR_AMPERSAND: 38, /* & */
141
+ CHAR_AT: 64, /* @ */
142
+ CHAR_BACKWARD_SLASH: 92, /* \ */
143
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
144
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
145
+ CHAR_COLON: 58, /* : */
146
+ CHAR_COMMA: 44, /* , */
147
+ CHAR_DOT: 46, /* . */
148
+ CHAR_DOUBLE_QUOTE: 34, /* " */
149
+ CHAR_EQUAL: 61, /* = */
150
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
151
+ CHAR_FORM_FEED: 12, /* \f */
152
+ CHAR_FORWARD_SLASH: 47, /* / */
153
+ CHAR_GRAVE_ACCENT: 96, /* ` */
154
+ CHAR_HASH: 35, /* # */
155
+ CHAR_HYPHEN_MINUS: 45, /* - */
156
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
157
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
158
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
159
+ CHAR_LINE_FEED: 10, /* \n */
160
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
161
+ CHAR_PERCENT: 37, /* % */
162
+ CHAR_PLUS: 43, /* + */
163
+ CHAR_QUESTION_MARK: 63, /* ? */
164
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
165
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
166
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
167
+ CHAR_SEMICOLON: 59, /* ; */
168
+ CHAR_SINGLE_QUOTE: 39, /* ' */
169
+ CHAR_SPACE: 32, /* */
170
+ CHAR_TAB: 9, /* \t */
171
+ CHAR_UNDERSCORE: 95, /* _ */
172
+ CHAR_VERTICAL_LINE: 124, /* | */
173
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
174
+
175
+ SEP: path$1.sep,
176
+
177
+ /**
178
+ * Create EXTGLOB_CHARS
179
+ */
180
+
181
+ extglobChars(chars) {
182
+ return {
183
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
184
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
185
+ '+': { type: 'plus', open: '(?:', close: ')+' },
186
+ '*': { type: 'star', open: '(?:', close: ')*' },
187
+ '@': { type: 'at', open: '(?:', close: ')' }
188
+ };
189
+ },
190
+
191
+ /**
192
+ * Create GLOB_CHARS
193
+ */
194
+
195
+ globChars(win32) {
196
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
197
+ }
198
+ };
199
+
200
+ (function (exports) {
201
+
202
+ const path = path$2;
203
+ const win32 = process.platform === 'win32';
204
+ const {
205
+ REGEX_BACKSLASH,
206
+ REGEX_REMOVE_BACKSLASH,
207
+ REGEX_SPECIAL_CHARS,
208
+ REGEX_SPECIAL_CHARS_GLOBAL
209
+ } = constants$2;
210
+
211
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
212
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
213
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
214
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
215
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
216
+
217
+ exports.removeBackslashes = str => {
218
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
219
+ return match === '\\' ? '' : match;
220
+ });
221
+ };
222
+
223
+ exports.supportsLookbehinds = () => {
224
+ const segs = process.version.slice(1).split('.').map(Number);
225
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
226
+ return true;
227
+ }
228
+ return false;
229
+ };
230
+
231
+ exports.isWindows = options => {
232
+ if (options && typeof options.windows === 'boolean') {
233
+ return options.windows;
234
+ }
235
+ return win32 === true || path.sep === '\\';
236
+ };
237
+
238
+ exports.escapeLast = (input, char, lastIdx) => {
239
+ const idx = input.lastIndexOf(char, lastIdx);
240
+ if (idx === -1) return input;
241
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
242
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
243
+ };
244
+
245
+ exports.removePrefix = (input, state = {}) => {
246
+ let output = input;
247
+ if (output.startsWith('./')) {
248
+ output = output.slice(2);
249
+ state.prefix = './';
250
+ }
251
+ return output;
252
+ };
253
+
254
+ exports.wrapOutput = (input, state = {}, options = {}) => {
255
+ const prepend = options.contains ? '' : '^';
256
+ const append = options.contains ? '' : '$';
257
+
258
+ let output = `${prepend}(?:${input})${append}`;
259
+ if (state.negated === true) {
260
+ output = `(?:^(?!${output}).*$)`;
261
+ }
262
+ return output;
263
+ };
264
+ }(utils$3));
265
+
266
+ const utils$2 = utils$3;
267
+ const {
268
+ CHAR_ASTERISK, /* * */
269
+ CHAR_AT, /* @ */
270
+ CHAR_BACKWARD_SLASH, /* \ */
271
+ CHAR_COMMA, /* , */
272
+ CHAR_DOT, /* . */
273
+ CHAR_EXCLAMATION_MARK, /* ! */
274
+ CHAR_FORWARD_SLASH, /* / */
275
+ CHAR_LEFT_CURLY_BRACE, /* { */
276
+ CHAR_LEFT_PARENTHESES, /* ( */
277
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
278
+ CHAR_PLUS, /* + */
279
+ CHAR_QUESTION_MARK, /* ? */
280
+ CHAR_RIGHT_CURLY_BRACE, /* } */
281
+ CHAR_RIGHT_PARENTHESES, /* ) */
282
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
283
+ } = constants$2;
284
+
285
+ const isPathSeparator = code => {
286
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
287
+ };
288
+
289
+ const depth = token => {
290
+ if (token.isPrefix !== true) {
291
+ token.depth = token.isGlobstar ? Infinity : 1;
292
+ }
293
+ };
294
+
295
+ /**
296
+ * Quickly scans a glob pattern and returns an object with a handful of
297
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
298
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
299
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
300
+ *
301
+ * ```js
302
+ * const pm = require('picomatch');
303
+ * console.log(pm.scan('foo/bar/*.js'));
304
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
305
+ * ```
306
+ * @param {String} `str`
307
+ * @param {Object} `options`
308
+ * @return {Object} Returns an object with tokens and regex source string.
309
+ * @api public
310
+ */
311
+
312
+ const scan$1 = (input, options) => {
313
+ const opts = options || {};
314
+
315
+ const length = input.length - 1;
316
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
317
+ const slashes = [];
318
+ const tokens = [];
319
+ const parts = [];
320
+
321
+ let str = input;
322
+ let index = -1;
323
+ let start = 0;
324
+ let lastIndex = 0;
325
+ let isBrace = false;
326
+ let isBracket = false;
327
+ let isGlob = false;
328
+ let isExtglob = false;
329
+ let isGlobstar = false;
330
+ let braceEscaped = false;
331
+ let backslashes = false;
332
+ let negated = false;
333
+ let negatedExtglob = false;
334
+ let finished = false;
335
+ let braces = 0;
336
+ let prev;
337
+ let code;
338
+ let token = { value: '', depth: 0, isGlob: false };
339
+
340
+ const eos = () => index >= length;
341
+ const peek = () => str.charCodeAt(index + 1);
342
+ const advance = () => {
343
+ prev = code;
344
+ return str.charCodeAt(++index);
345
+ };
346
+
347
+ while (index < length) {
348
+ code = advance();
349
+ let next;
350
+
351
+ if (code === CHAR_BACKWARD_SLASH) {
352
+ backslashes = token.backslashes = true;
353
+ code = advance();
354
+
355
+ if (code === CHAR_LEFT_CURLY_BRACE) {
356
+ braceEscaped = true;
357
+ }
358
+ continue;
359
+ }
360
+
361
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
362
+ braces++;
363
+
364
+ while (eos() !== true && (code = advance())) {
365
+ if (code === CHAR_BACKWARD_SLASH) {
366
+ backslashes = token.backslashes = true;
367
+ advance();
368
+ continue;
369
+ }
370
+
371
+ if (code === CHAR_LEFT_CURLY_BRACE) {
372
+ braces++;
373
+ continue;
374
+ }
375
+
376
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
377
+ isBrace = token.isBrace = true;
378
+ isGlob = token.isGlob = true;
379
+ finished = true;
380
+
381
+ if (scanToEnd === true) {
382
+ continue;
383
+ }
384
+
385
+ break;
386
+ }
387
+
388
+ if (braceEscaped !== true && code === CHAR_COMMA) {
389
+ isBrace = token.isBrace = true;
390
+ isGlob = token.isGlob = true;
391
+ finished = true;
392
+
393
+ if (scanToEnd === true) {
394
+ continue;
395
+ }
396
+
397
+ break;
398
+ }
399
+
400
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
401
+ braces--;
402
+
403
+ if (braces === 0) {
404
+ braceEscaped = false;
405
+ isBrace = token.isBrace = true;
406
+ finished = true;
407
+ break;
408
+ }
409
+ }
410
+ }
411
+
412
+ if (scanToEnd === true) {
413
+ continue;
414
+ }
415
+
416
+ break;
417
+ }
418
+
419
+ if (code === CHAR_FORWARD_SLASH) {
420
+ slashes.push(index);
421
+ tokens.push(token);
422
+ token = { value: '', depth: 0, isGlob: false };
423
+
424
+ if (finished === true) continue;
425
+ if (prev === CHAR_DOT && index === (start + 1)) {
426
+ start += 2;
427
+ continue;
428
+ }
429
+
430
+ lastIndex = index + 1;
431
+ continue;
432
+ }
433
+
434
+ if (opts.noext !== true) {
435
+ const isExtglobChar = code === CHAR_PLUS
436
+ || code === CHAR_AT
437
+ || code === CHAR_ASTERISK
438
+ || code === CHAR_QUESTION_MARK
439
+ || code === CHAR_EXCLAMATION_MARK;
440
+
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
+
449
+ if (scanToEnd === true) {
450
+ while (eos() !== true && (code = advance())) {
451
+ if (code === CHAR_BACKWARD_SLASH) {
452
+ backslashes = token.backslashes = true;
453
+ code = advance();
454
+ continue;
455
+ }
456
+
457
+ if (code === CHAR_RIGHT_PARENTHESES) {
458
+ isGlob = token.isGlob = true;
459
+ finished = true;
460
+ break;
461
+ }
462
+ }
463
+ continue;
464
+ }
465
+ break;
466
+ }
467
+ }
468
+
469
+ if (code === CHAR_ASTERISK) {
470
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
471
+ isGlob = token.isGlob = true;
472
+ finished = true;
473
+
474
+ if (scanToEnd === true) {
475
+ continue;
476
+ }
477
+ break;
478
+ }
479
+
480
+ if (code === CHAR_QUESTION_MARK) {
481
+ isGlob = token.isGlob = true;
482
+ finished = true;
483
+
484
+ if (scanToEnd === true) {
485
+ continue;
486
+ }
487
+ break;
488
+ }
489
+
490
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
491
+ while (eos() !== true && (next = advance())) {
492
+ if (next === CHAR_BACKWARD_SLASH) {
493
+ backslashes = token.backslashes = true;
494
+ advance();
495
+ continue;
496
+ }
497
+
498
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
499
+ isBracket = token.isBracket = true;
500
+ isGlob = token.isGlob = true;
501
+ finished = true;
502
+ break;
503
+ }
504
+ }
505
+
506
+ if (scanToEnd === true) {
507
+ continue;
508
+ }
509
+
510
+ break;
511
+ }
512
+
513
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
514
+ negated = token.negated = true;
515
+ start++;
516
+ continue;
517
+ }
518
+
519
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
520
+ isGlob = token.isGlob = true;
521
+
522
+ if (scanToEnd === true) {
523
+ while (eos() !== true && (code = advance())) {
524
+ if (code === CHAR_LEFT_PARENTHESES) {
525
+ backslashes = token.backslashes = true;
526
+ code = advance();
527
+ continue;
528
+ }
529
+
530
+ if (code === CHAR_RIGHT_PARENTHESES) {
531
+ finished = true;
532
+ break;
533
+ }
534
+ }
535
+ continue;
536
+ }
537
+ break;
538
+ }
539
+
540
+ if (isGlob === true) {
541
+ finished = true;
542
+
543
+ if (scanToEnd === true) {
544
+ continue;
545
+ }
546
+
547
+ break;
548
+ }
549
+ }
550
+
551
+ if (opts.noext === true) {
552
+ isExtglob = false;
553
+ isGlob = false;
554
+ }
555
+
556
+ let base = str;
557
+ let prefix = '';
558
+ let glob = '';
559
+
560
+ if (start > 0) {
561
+ prefix = str.slice(0, start);
562
+ str = str.slice(start);
563
+ lastIndex -= start;
564
+ }
565
+
566
+ if (base && isGlob === true && lastIndex > 0) {
567
+ base = str.slice(0, lastIndex);
568
+ glob = str.slice(lastIndex);
569
+ } else if (isGlob === true) {
570
+ base = '';
571
+ glob = str;
572
+ } else {
573
+ base = str;
574
+ }
575
+
576
+ if (base && base !== '' && base !== '/' && base !== str) {
577
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
578
+ base = base.slice(0, -1);
579
+ }
580
+ }
581
+
582
+ if (opts.unescape === true) {
583
+ if (glob) glob = utils$2.removeBackslashes(glob);
584
+
585
+ if (base && backslashes === true) {
586
+ base = utils$2.removeBackslashes(base);
587
+ }
588
+ }
589
+
590
+ const state = {
591
+ prefix,
592
+ input,
593
+ start,
594
+ base,
595
+ glob,
596
+ isBrace,
597
+ isBracket,
598
+ isGlob,
599
+ isExtglob,
600
+ isGlobstar,
601
+ negated,
602
+ negatedExtglob
603
+ };
604
+
605
+ if (opts.tokens === true) {
606
+ state.maxDepth = 0;
607
+ if (!isPathSeparator(code)) {
608
+ tokens.push(token);
609
+ }
610
+ state.tokens = tokens;
611
+ }
612
+
613
+ if (opts.parts === true || opts.tokens === true) {
614
+ let prevIndex;
615
+
616
+ for (let idx = 0; idx < slashes.length; idx++) {
617
+ const n = prevIndex ? prevIndex + 1 : start;
618
+ const i = slashes[idx];
619
+ const value = input.slice(n, i);
620
+ if (opts.tokens) {
621
+ if (idx === 0 && start !== 0) {
622
+ tokens[idx].isPrefix = true;
623
+ tokens[idx].value = prefix;
624
+ } else {
625
+ tokens[idx].value = value;
626
+ }
627
+ depth(tokens[idx]);
628
+ state.maxDepth += tokens[idx].depth;
629
+ }
630
+ if (idx !== 0 || value !== '') {
631
+ parts.push(value);
632
+ }
633
+ prevIndex = i;
634
+ }
635
+
636
+ if (prevIndex && prevIndex + 1 < input.length) {
637
+ const value = input.slice(prevIndex + 1);
638
+ parts.push(value);
639
+
640
+ if (opts.tokens) {
641
+ tokens[tokens.length - 1].value = value;
642
+ depth(tokens[tokens.length - 1]);
643
+ state.maxDepth += tokens[tokens.length - 1].depth;
644
+ }
645
+ }
646
+
647
+ state.slashes = slashes;
648
+ state.parts = parts;
649
+ }
650
+
651
+ return state;
652
+ };
653
+
654
+ var scan_1 = scan$1;
655
+
656
+ const constants$1 = constants$2;
657
+ const utils$1 = utils$3;
658
+
659
+ /**
660
+ * Constants
661
+ */
662
+
663
+ const {
664
+ MAX_LENGTH,
665
+ POSIX_REGEX_SOURCE,
666
+ REGEX_NON_SPECIAL_CHARS,
667
+ REGEX_SPECIAL_CHARS_BACKREF,
668
+ REPLACEMENTS
669
+ } = constants$1;
670
+
671
+ /**
672
+ * Helpers
673
+ */
674
+
675
+ const expandRange = (args, options) => {
676
+ if (typeof options.expandRange === 'function') {
677
+ return options.expandRange(...args, options);
678
+ }
679
+
680
+ args.sort();
681
+ const value = `[${args.join('-')}]`;
682
+
683
+ try {
684
+ /* eslint-disable-next-line no-new */
685
+ new RegExp(value);
686
+ } catch (ex) {
687
+ return args.map(v => utils$1.escapeRegex(v)).join('..');
688
+ }
689
+
690
+ return value;
691
+ };
692
+
693
+ /**
694
+ * Create the message for a syntax error
695
+ */
696
+
697
+ const syntaxError = (type, char) => {
698
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
699
+ };
700
+
701
+ /**
702
+ * Parse the given input string.
703
+ * @param {String} input
704
+ * @param {Object} options
705
+ * @return {Object}
706
+ */
707
+
708
+ const parse$1 = (input, options) => {
709
+ if (typeof input !== 'string') {
710
+ throw new TypeError('Expected a string');
711
+ }
712
+
713
+ input = REPLACEMENTS[input] || input;
714
+
715
+ const opts = { ...options };
716
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
717
+
718
+ let len = input.length;
719
+ if (len > max) {
720
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
721
+ }
722
+
723
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
724
+ const tokens = [bos];
725
+
726
+ const capture = opts.capture ? '' : '?:';
727
+ const win32 = utils$1.isWindows(options);
728
+
729
+ // create constants based on platform, for windows or posix
730
+ const PLATFORM_CHARS = constants$1.globChars(win32);
731
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
732
+
733
+ const {
734
+ DOT_LITERAL,
735
+ PLUS_LITERAL,
736
+ SLASH_LITERAL,
737
+ ONE_CHAR,
738
+ DOTS_SLASH,
739
+ NO_DOT,
740
+ NO_DOT_SLASH,
741
+ NO_DOTS_SLASH,
742
+ QMARK,
743
+ QMARK_NO_DOT,
744
+ STAR,
745
+ START_ANCHOR
746
+ } = PLATFORM_CHARS;
747
+
748
+ const globstar = opts => {
749
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
750
+ };
751
+
752
+ const nodot = opts.dot ? '' : NO_DOT;
753
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
754
+ let star = opts.bash === true ? globstar(opts) : STAR;
755
+
756
+ if (opts.capture) {
757
+ star = `(${star})`;
758
+ }
759
+
760
+ // minimatch options support
761
+ if (typeof opts.noext === 'boolean') {
762
+ opts.noextglob = opts.noext;
763
+ }
764
+
765
+ const state = {
766
+ input,
767
+ index: -1,
768
+ start: 0,
769
+ dot: opts.dot === true,
770
+ consumed: '',
771
+ output: '',
772
+ prefix: '',
773
+ backtrack: false,
774
+ negated: false,
775
+ brackets: 0,
776
+ braces: 0,
777
+ parens: 0,
778
+ quotes: 0,
779
+ globstar: false,
780
+ tokens
781
+ };
782
+
783
+ input = utils$1.removePrefix(input, state);
784
+ len = input.length;
785
+
786
+ const extglobs = [];
787
+ const braces = [];
788
+ const stack = [];
789
+ let prev = bos;
790
+ let value;
791
+
792
+ /**
793
+ * Tokenizing helpers
794
+ */
795
+
796
+ const eos = () => state.index === len - 1;
797
+ const peek = state.peek = (n = 1) => input[state.index + n];
798
+ const advance = state.advance = () => input[++state.index] || '';
799
+ const remaining = () => input.slice(state.index + 1);
800
+ const consume = (value = '', num = 0) => {
801
+ state.consumed += value;
802
+ state.index += num;
803
+ };
804
+
805
+ const append = token => {
806
+ state.output += token.output != null ? token.output : token.value;
807
+ consume(token.value);
808
+ };
809
+
810
+ const negate = () => {
811
+ let count = 1;
812
+
813
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
814
+ advance();
815
+ state.start++;
816
+ count++;
817
+ }
818
+
819
+ if (count % 2 === 0) {
820
+ return false;
821
+ }
822
+
823
+ state.negated = true;
824
+ state.start++;
825
+ return true;
826
+ };
827
+
828
+ const increment = type => {
829
+ state[type]++;
830
+ stack.push(type);
831
+ };
832
+
833
+ const decrement = type => {
834
+ state[type]--;
835
+ stack.pop();
836
+ };
837
+
838
+ /**
839
+ * Push tokens onto the tokens array. This helper speeds up
840
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
841
+ * and 2) helping us avoid creating extra tokens when consecutive
842
+ * characters are plain text. This improves performance and simplifies
843
+ * lookbehinds.
844
+ */
845
+
846
+ const push = tok => {
847
+ if (prev.type === 'globstar') {
848
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
849
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
850
+
851
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
852
+ state.output = state.output.slice(0, -prev.output.length);
853
+ prev.type = 'star';
854
+ prev.value = '*';
855
+ prev.output = star;
856
+ state.output += prev.output;
857
+ }
858
+ }
859
+
860
+ if (extglobs.length && tok.type !== 'paren') {
861
+ extglobs[extglobs.length - 1].inner += tok.value;
862
+ }
863
+
864
+ if (tok.value || tok.output) append(tok);
865
+ if (prev && prev.type === 'text' && tok.type === 'text') {
866
+ prev.value += tok.value;
867
+ prev.output = (prev.output || '') + tok.value;
868
+ return;
869
+ }
870
+
871
+ tok.prev = prev;
872
+ tokens.push(tok);
873
+ prev = tok;
874
+ };
875
+
876
+ const extglobOpen = (type, value) => {
877
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
878
+
879
+ token.prev = prev;
880
+ token.parens = state.parens;
881
+ token.output = state.output;
882
+ const output = (opts.capture ? '(' : '') + token.open;
883
+
884
+ increment('parens');
885
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
886
+ push({ type: 'paren', extglob: true, value: advance(), output });
887
+ extglobs.push(token);
888
+ };
889
+
890
+ const extglobClose = token => {
891
+ let output = token.close + (opts.capture ? ')' : '');
892
+ let rest;
893
+
894
+ if (token.type === 'negate') {
895
+ let extglobStar = star;
896
+
897
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
898
+ extglobStar = globstar(opts);
899
+ }
900
+
901
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
902
+ output = token.close = `)$))${extglobStar}`;
903
+ }
904
+
905
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
906
+ // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
907
+ // In this case, we need to parse the string and use it in the output of the original pattern.
908
+ // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
909
+ //
910
+ // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
911
+ const expression = parse$1(rest, { ...options, fastpaths: false }).output;
912
+
913
+ output = token.close = `)${expression})${extglobStar})`;
914
+ }
915
+
916
+ if (token.prev.type === 'bos') {
917
+ state.negatedExtglob = true;
918
+ }
919
+ }
920
+
921
+ push({ type: 'paren', extglob: true, value, output });
922
+ decrement('parens');
923
+ };
924
+
925
+ /**
926
+ * Fast paths
927
+ */
928
+
929
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
930
+ let backslashes = false;
931
+
932
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
933
+ if (first === '\\') {
934
+ backslashes = true;
935
+ return m;
936
+ }
937
+
938
+ if (first === '?') {
939
+ if (esc) {
940
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
941
+ }
942
+ if (index === 0) {
943
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
944
+ }
945
+ return QMARK.repeat(chars.length);
946
+ }
947
+
948
+ if (first === '.') {
949
+ return DOT_LITERAL.repeat(chars.length);
950
+ }
951
+
952
+ if (first === '*') {
953
+ if (esc) {
954
+ return esc + first + (rest ? star : '');
955
+ }
956
+ return star;
957
+ }
958
+ return esc ? m : `\\${m}`;
959
+ });
960
+
961
+ if (backslashes === true) {
962
+ if (opts.unescape === true) {
963
+ output = output.replace(/\\/g, '');
964
+ } else {
965
+ output = output.replace(/\\+/g, m => {
966
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
967
+ });
968
+ }
969
+ }
970
+
971
+ if (output === input && opts.contains === true) {
972
+ state.output = input;
973
+ return state;
974
+ }
975
+
976
+ state.output = utils$1.wrapOutput(output, state, options);
977
+ return state;
978
+ }
979
+
980
+ /**
981
+ * Tokenize input until we reach end-of-string
982
+ */
983
+
984
+ while (!eos()) {
985
+ value = advance();
986
+
987
+ if (value === '\u0000') {
988
+ continue;
989
+ }
990
+
991
+ /**
992
+ * Escaped characters
993
+ */
994
+
995
+ if (value === '\\') {
996
+ const next = peek();
997
+
998
+ if (next === '/' && opts.bash !== true) {
999
+ continue;
1000
+ }
1001
+
1002
+ if (next === '.' || next === ';') {
1003
+ continue;
1004
+ }
1005
+
1006
+ if (!next) {
1007
+ value += '\\';
1008
+ push({ type: 'text', value });
1009
+ continue;
1010
+ }
1011
+
1012
+ // collapse slashes to reduce potential for exploits
1013
+ const match = /^\\+/.exec(remaining());
1014
+ let slashes = 0;
1015
+
1016
+ if (match && match[0].length > 2) {
1017
+ slashes = match[0].length;
1018
+ state.index += slashes;
1019
+ if (slashes % 2 !== 0) {
1020
+ value += '\\';
1021
+ }
1022
+ }
1023
+
1024
+ if (opts.unescape === true) {
1025
+ value = advance();
1026
+ } else {
1027
+ value += advance();
1028
+ }
1029
+
1030
+ if (state.brackets === 0) {
1031
+ push({ type: 'text', value });
1032
+ continue;
1033
+ }
1034
+ }
1035
+
1036
+ /**
1037
+ * If we're inside a regex character class, continue
1038
+ * until we reach the closing bracket.
1039
+ */
1040
+
1041
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
1042
+ if (opts.posix !== false && value === ':') {
1043
+ const inner = prev.value.slice(1);
1044
+ if (inner.includes('[')) {
1045
+ prev.posix = true;
1046
+
1047
+ if (inner.includes(':')) {
1048
+ const idx = prev.value.lastIndexOf('[');
1049
+ const pre = prev.value.slice(0, idx);
1050
+ const rest = prev.value.slice(idx + 2);
1051
+ const posix = POSIX_REGEX_SOURCE[rest];
1052
+ if (posix) {
1053
+ prev.value = pre + posix;
1054
+ state.backtrack = true;
1055
+ advance();
1056
+
1057
+ if (!bos.output && tokens.indexOf(prev) === 1) {
1058
+ bos.output = ONE_CHAR;
1059
+ }
1060
+ continue;
1061
+ }
1062
+ }
1063
+ }
1064
+ }
1065
+
1066
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
1067
+ value = `\\${value}`;
1068
+ }
1069
+
1070
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
1071
+ value = `\\${value}`;
1072
+ }
1073
+
1074
+ if (opts.posix === true && value === '!' && prev.value === '[') {
1075
+ value = '^';
1076
+ }
1077
+
1078
+ prev.value += value;
1079
+ append({ value });
1080
+ continue;
1081
+ }
1082
+
1083
+ /**
1084
+ * If we're inside a quoted string, continue
1085
+ * until we reach the closing double quote.
1086
+ */
1087
+
1088
+ if (state.quotes === 1 && value !== '"') {
1089
+ value = utils$1.escapeRegex(value);
1090
+ prev.value += value;
1091
+ append({ value });
1092
+ continue;
1093
+ }
1094
+
1095
+ /**
1096
+ * Double quotes
1097
+ */
1098
+
1099
+ if (value === '"') {
1100
+ state.quotes = state.quotes === 1 ? 0 : 1;
1101
+ if (opts.keepQuotes === true) {
1102
+ push({ type: 'text', value });
1103
+ }
1104
+ continue;
1105
+ }
1106
+
1107
+ /**
1108
+ * Parentheses
1109
+ */
1110
+
1111
+ if (value === '(') {
1112
+ increment('parens');
1113
+ push({ type: 'paren', value });
1114
+ continue;
1115
+ }
1116
+
1117
+ if (value === ')') {
1118
+ if (state.parens === 0 && opts.strictBrackets === true) {
1119
+ throw new SyntaxError(syntaxError('opening', '('));
1120
+ }
1121
+
1122
+ const extglob = extglobs[extglobs.length - 1];
1123
+ if (extglob && state.parens === extglob.parens + 1) {
1124
+ extglobClose(extglobs.pop());
1125
+ continue;
1126
+ }
1127
+
1128
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
1129
+ decrement('parens');
1130
+ continue;
1131
+ }
1132
+
1133
+ /**
1134
+ * Square brackets
1135
+ */
1136
+
1137
+ if (value === '[') {
1138
+ if (opts.nobracket === true || !remaining().includes(']')) {
1139
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
1140
+ throw new SyntaxError(syntaxError('closing', ']'));
1141
+ }
1142
+
1143
+ value = `\\${value}`;
1144
+ } else {
1145
+ increment('brackets');
1146
+ }
1147
+
1148
+ push({ type: 'bracket', value });
1149
+ continue;
1150
+ }
1151
+
1152
+ if (value === ']') {
1153
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
1154
+ push({ type: 'text', value, output: `\\${value}` });
1155
+ continue;
1156
+ }
1157
+
1158
+ if (state.brackets === 0) {
1159
+ if (opts.strictBrackets === true) {
1160
+ throw new SyntaxError(syntaxError('opening', '['));
1161
+ }
1162
+
1163
+ push({ type: 'text', value, output: `\\${value}` });
1164
+ continue;
1165
+ }
1166
+
1167
+ decrement('brackets');
1168
+
1169
+ const prevValue = prev.value.slice(1);
1170
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
1171
+ value = `/${value}`;
1172
+ }
1173
+
1174
+ prev.value += value;
1175
+ append({ value });
1176
+
1177
+ // when literal brackets are explicitly disabled
1178
+ // assume we should match with a regex character class
1179
+ if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
1180
+ continue;
1181
+ }
1182
+
1183
+ const escaped = utils$1.escapeRegex(prev.value);
1184
+ state.output = state.output.slice(0, -prev.value.length);
1185
+
1186
+ // when literal brackets are explicitly enabled
1187
+ // assume we should escape the brackets to match literal characters
1188
+ if (opts.literalBrackets === true) {
1189
+ state.output += escaped;
1190
+ prev.value = escaped;
1191
+ continue;
1192
+ }
1193
+
1194
+ // when the user specifies nothing, try to match both
1195
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1196
+ state.output += prev.value;
1197
+ continue;
1198
+ }
1199
+
1200
+ /**
1201
+ * Braces
1202
+ */
1203
+
1204
+ if (value === '{' && opts.nobrace !== true) {
1205
+ increment('braces');
1206
+
1207
+ const open = {
1208
+ type: 'brace',
1209
+ value,
1210
+ output: '(',
1211
+ outputIndex: state.output.length,
1212
+ tokensIndex: state.tokens.length
1213
+ };
1214
+
1215
+ braces.push(open);
1216
+ push(open);
1217
+ continue;
1218
+ }
1219
+
1220
+ if (value === '}') {
1221
+ const brace = braces[braces.length - 1];
1222
+
1223
+ if (opts.nobrace === true || !brace) {
1224
+ push({ type: 'text', value, output: value });
1225
+ continue;
1226
+ }
1227
+
1228
+ let output = ')';
1229
+
1230
+ if (brace.dots === true) {
1231
+ const arr = tokens.slice();
1232
+ const range = [];
1233
+
1234
+ for (let i = arr.length - 1; i >= 0; i--) {
1235
+ tokens.pop();
1236
+ if (arr[i].type === 'brace') {
1237
+ break;
1238
+ }
1239
+ if (arr[i].type !== 'dots') {
1240
+ range.unshift(arr[i].value);
1241
+ }
1242
+ }
1243
+
1244
+ output = expandRange(range, opts);
1245
+ state.backtrack = true;
1246
+ }
1247
+
1248
+ if (brace.comma !== true && brace.dots !== true) {
1249
+ const out = state.output.slice(0, brace.outputIndex);
1250
+ const toks = state.tokens.slice(brace.tokensIndex);
1251
+ brace.value = brace.output = '\\{';
1252
+ value = output = '\\}';
1253
+ state.output = out;
1254
+ for (const t of toks) {
1255
+ state.output += (t.output || t.value);
1256
+ }
1257
+ }
1258
+
1259
+ push({ type: 'brace', value, output });
1260
+ decrement('braces');
1261
+ braces.pop();
1262
+ continue;
1263
+ }
1264
+
1265
+ /**
1266
+ * Pipes
1267
+ */
1268
+
1269
+ if (value === '|') {
1270
+ if (extglobs.length > 0) {
1271
+ extglobs[extglobs.length - 1].conditions++;
1272
+ }
1273
+ push({ type: 'text', value });
1274
+ continue;
1275
+ }
1276
+
1277
+ /**
1278
+ * Commas
1279
+ */
1280
+
1281
+ if (value === ',') {
1282
+ let output = value;
1283
+
1284
+ const brace = braces[braces.length - 1];
1285
+ if (brace && stack[stack.length - 1] === 'braces') {
1286
+ brace.comma = true;
1287
+ output = '|';
1288
+ }
1289
+
1290
+ push({ type: 'comma', value, output });
1291
+ continue;
1292
+ }
1293
+
1294
+ /**
1295
+ * Slashes
1296
+ */
1297
+
1298
+ if (value === '/') {
1299
+ // if the beginning of the glob is "./", advance the start
1300
+ // to the current index, and don't add the "./" characters
1301
+ // to the state. This greatly simplifies lookbehinds when
1302
+ // checking for BOS characters like "!" and "." (not "./")
1303
+ if (prev.type === 'dot' && state.index === state.start + 1) {
1304
+ state.start = state.index + 1;
1305
+ state.consumed = '';
1306
+ state.output = '';
1307
+ tokens.pop();
1308
+ prev = bos; // reset "prev" to the first token
1309
+ continue;
1310
+ }
1311
+
1312
+ push({ type: 'slash', value, output: SLASH_LITERAL });
1313
+ continue;
1314
+ }
1315
+
1316
+ /**
1317
+ * Dots
1318
+ */
1319
+
1320
+ if (value === '.') {
1321
+ if (state.braces > 0 && prev.type === 'dot') {
1322
+ if (prev.value === '.') prev.output = DOT_LITERAL;
1323
+ const brace = braces[braces.length - 1];
1324
+ prev.type = 'dots';
1325
+ prev.output += value;
1326
+ prev.value += value;
1327
+ brace.dots = true;
1328
+ continue;
1329
+ }
1330
+
1331
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
1332
+ push({ type: 'text', value, output: DOT_LITERAL });
1333
+ continue;
1334
+ }
1335
+
1336
+ push({ type: 'dot', value, output: DOT_LITERAL });
1337
+ continue;
1338
+ }
1339
+
1340
+ /**
1341
+ * Question marks
1342
+ */
1343
+
1344
+ if (value === '?') {
1345
+ const isGroup = prev && prev.value === '(';
1346
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1347
+ extglobOpen('qmark', value);
1348
+ continue;
1349
+ }
1350
+
1351
+ if (prev && prev.type === 'paren') {
1352
+ const next = peek();
1353
+ let output = value;
1354
+
1355
+ if (next === '<' && !utils$1.supportsLookbehinds()) {
1356
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
1357
+ }
1358
+
1359
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
1360
+ output = `\\${value}`;
1361
+ }
1362
+
1363
+ push({ type: 'text', value, output });
1364
+ continue;
1365
+ }
1366
+
1367
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
1368
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
1369
+ continue;
1370
+ }
1371
+
1372
+ push({ type: 'qmark', value, output: QMARK });
1373
+ continue;
1374
+ }
1375
+
1376
+ /**
1377
+ * Exclamation
1378
+ */
1379
+
1380
+ if (value === '!') {
1381
+ if (opts.noextglob !== true && peek() === '(') {
1382
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
1383
+ extglobOpen('negate', value);
1384
+ continue;
1385
+ }
1386
+ }
1387
+
1388
+ if (opts.nonegate !== true && state.index === 0) {
1389
+ negate();
1390
+ continue;
1391
+ }
1392
+ }
1393
+
1394
+ /**
1395
+ * Plus
1396
+ */
1397
+
1398
+ if (value === '+') {
1399
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1400
+ extglobOpen('plus', value);
1401
+ continue;
1402
+ }
1403
+
1404
+ if ((prev && prev.value === '(') || opts.regex === false) {
1405
+ push({ type: 'plus', value, output: PLUS_LITERAL });
1406
+ continue;
1407
+ }
1408
+
1409
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
1410
+ push({ type: 'plus', value });
1411
+ continue;
1412
+ }
1413
+
1414
+ push({ type: 'plus', value: PLUS_LITERAL });
1415
+ continue;
1416
+ }
1417
+
1418
+ /**
1419
+ * Plain text
1420
+ */
1421
+
1422
+ if (value === '@') {
1423
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1424
+ push({ type: 'at', extglob: true, value, output: '' });
1425
+ continue;
1426
+ }
1427
+
1428
+ push({ type: 'text', value });
1429
+ continue;
1430
+ }
1431
+
1432
+ /**
1433
+ * Plain text
1434
+ */
1435
+
1436
+ if (value !== '*') {
1437
+ if (value === '$' || value === '^') {
1438
+ value = `\\${value}`;
1439
+ }
1440
+
1441
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1442
+ if (match) {
1443
+ value += match[0];
1444
+ state.index += match[0].length;
1445
+ }
1446
+
1447
+ push({ type: 'text', value });
1448
+ continue;
1449
+ }
1450
+
1451
+ /**
1452
+ * Stars
1453
+ */
1454
+
1455
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
1456
+ prev.type = 'star';
1457
+ prev.star = true;
1458
+ prev.value += value;
1459
+ prev.output = star;
1460
+ state.backtrack = true;
1461
+ state.globstar = true;
1462
+ consume(value);
1463
+ continue;
1464
+ }
1465
+
1466
+ let rest = remaining();
1467
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1468
+ extglobOpen('star', value);
1469
+ continue;
1470
+ }
1471
+
1472
+ if (prev.type === 'star') {
1473
+ if (opts.noglobstar === true) {
1474
+ consume(value);
1475
+ continue;
1476
+ }
1477
+
1478
+ const prior = prev.prev;
1479
+ const before = prior.prev;
1480
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
1481
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
1482
+
1483
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
1484
+ push({ type: 'star', value, output: '' });
1485
+ continue;
1486
+ }
1487
+
1488
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
1489
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
1490
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
1491
+ push({ type: 'star', value, output: '' });
1492
+ continue;
1493
+ }
1494
+
1495
+ // strip consecutive `/**/`
1496
+ while (rest.slice(0, 3) === '/**') {
1497
+ const after = input[state.index + 4];
1498
+ if (after && after !== '/') {
1499
+ break;
1500
+ }
1501
+ rest = rest.slice(3);
1502
+ consume('/**', 3);
1503
+ }
1504
+
1505
+ if (prior.type === 'bos' && eos()) {
1506
+ prev.type = 'globstar';
1507
+ prev.value += value;
1508
+ prev.output = globstar(opts);
1509
+ state.output = prev.output;
1510
+ state.globstar = true;
1511
+ consume(value);
1512
+ continue;
1513
+ }
1514
+
1515
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
1516
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1517
+ prior.output = `(?:${prior.output}`;
1518
+
1519
+ prev.type = 'globstar';
1520
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
1521
+ prev.value += value;
1522
+ state.globstar = true;
1523
+ state.output += prior.output + prev.output;
1524
+ consume(value);
1525
+ continue;
1526
+ }
1527
+
1528
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
1529
+ const end = rest[1] !== void 0 ? '|$' : '';
1530
+
1531
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1532
+ prior.output = `(?:${prior.output}`;
1533
+
1534
+ prev.type = 'globstar';
1535
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1536
+ prev.value += value;
1537
+
1538
+ state.output += prior.output + prev.output;
1539
+ state.globstar = true;
1540
+
1541
+ consume(value + advance());
1542
+
1543
+ push({ type: 'slash', value: '/', output: '' });
1544
+ continue;
1545
+ }
1546
+
1547
+ if (prior.type === 'bos' && rest[0] === '/') {
1548
+ prev.type = 'globstar';
1549
+ prev.value += value;
1550
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1551
+ state.output = prev.output;
1552
+ state.globstar = true;
1553
+ consume(value + advance());
1554
+ push({ type: 'slash', value: '/', output: '' });
1555
+ continue;
1556
+ }
1557
+
1558
+ // remove single star from output
1559
+ state.output = state.output.slice(0, -prev.output.length);
1560
+
1561
+ // reset previous token to globstar
1562
+ prev.type = 'globstar';
1563
+ prev.output = globstar(opts);
1564
+ prev.value += value;
1565
+
1566
+ // reset output with globstar
1567
+ state.output += prev.output;
1568
+ state.globstar = true;
1569
+ consume(value);
1570
+ continue;
1571
+ }
1572
+
1573
+ const token = { type: 'star', value, output: star };
1574
+
1575
+ if (opts.bash === true) {
1576
+ token.output = '.*?';
1577
+ if (prev.type === 'bos' || prev.type === 'slash') {
1578
+ token.output = nodot + token.output;
1579
+ }
1580
+ push(token);
1581
+ continue;
1582
+ }
1583
+
1584
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
1585
+ token.output = value;
1586
+ push(token);
1587
+ continue;
1588
+ }
1589
+
1590
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
1591
+ if (prev.type === 'dot') {
1592
+ state.output += NO_DOT_SLASH;
1593
+ prev.output += NO_DOT_SLASH;
1594
+
1595
+ } else if (opts.dot === true) {
1596
+ state.output += NO_DOTS_SLASH;
1597
+ prev.output += NO_DOTS_SLASH;
1598
+
1599
+ } else {
1600
+ state.output += nodot;
1601
+ prev.output += nodot;
1602
+ }
1603
+
1604
+ if (peek() !== '*') {
1605
+ state.output += ONE_CHAR;
1606
+ prev.output += ONE_CHAR;
1607
+ }
1608
+ }
1609
+
1610
+ push(token);
1611
+ }
1612
+
1613
+ while (state.brackets > 0) {
1614
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
1615
+ state.output = utils$1.escapeLast(state.output, '[');
1616
+ decrement('brackets');
1617
+ }
1618
+
1619
+ while (state.parens > 0) {
1620
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
1621
+ state.output = utils$1.escapeLast(state.output, '(');
1622
+ decrement('parens');
1623
+ }
1624
+
1625
+ while (state.braces > 0) {
1626
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
1627
+ state.output = utils$1.escapeLast(state.output, '{');
1628
+ decrement('braces');
1629
+ }
1630
+
1631
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
1632
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
1633
+ }
1634
+
1635
+ // rebuild the output if we had to backtrack at any point
1636
+ if (state.backtrack === true) {
1637
+ state.output = '';
1638
+
1639
+ for (const token of state.tokens) {
1640
+ state.output += token.output != null ? token.output : token.value;
1641
+
1642
+ if (token.suffix) {
1643
+ state.output += token.suffix;
1644
+ }
1645
+ }
1646
+ }
1647
+
1648
+ return state;
1649
+ };
1650
+
1651
+ /**
1652
+ * Fast paths for creating regular expressions for common glob patterns.
1653
+ * This can significantly speed up processing and has very little downside
1654
+ * impact when none of the fast paths match.
1655
+ */
1656
+
1657
+ parse$1.fastpaths = (input, options) => {
1658
+ const opts = { ...options };
1659
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1660
+ const len = input.length;
1661
+ if (len > max) {
1662
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1663
+ }
1664
+
1665
+ input = REPLACEMENTS[input] || input;
1666
+ const win32 = utils$1.isWindows(options);
1667
+
1668
+ // create constants based on platform, for windows or posix
1669
+ const {
1670
+ DOT_LITERAL,
1671
+ SLASH_LITERAL,
1672
+ ONE_CHAR,
1673
+ DOTS_SLASH,
1674
+ NO_DOT,
1675
+ NO_DOTS,
1676
+ NO_DOTS_SLASH,
1677
+ STAR,
1678
+ START_ANCHOR
1679
+ } = constants$1.globChars(win32);
1680
+
1681
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
1682
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1683
+ const capture = opts.capture ? '' : '?:';
1684
+ const state = { negated: false, prefix: '' };
1685
+ let star = opts.bash === true ? '.*?' : STAR;
1686
+
1687
+ if (opts.capture) {
1688
+ star = `(${star})`;
1689
+ }
1690
+
1691
+ const globstar = opts => {
1692
+ if (opts.noglobstar === true) return star;
1693
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1694
+ };
1695
+
1696
+ const create = str => {
1697
+ switch (str) {
1698
+ case '*':
1699
+ return `${nodot}${ONE_CHAR}${star}`;
1700
+
1701
+ case '.*':
1702
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1703
+
1704
+ case '*.*':
1705
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1706
+
1707
+ case '*/*':
1708
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1709
+
1710
+ case '**':
1711
+ return nodot + globstar(opts);
1712
+
1713
+ case '**/*':
1714
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1715
+
1716
+ case '**/*.*':
1717
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1718
+
1719
+ case '**/.*':
1720
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1721
+
1722
+ default: {
1723
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1724
+ if (!match) return;
1725
+
1726
+ const source = create(match[1]);
1727
+ if (!source) return;
1728
+
1729
+ return source + DOT_LITERAL + match[2];
1730
+ }
1731
+ }
1732
+ };
1733
+
1734
+ const output = utils$1.removePrefix(input, state);
1735
+ let source = create(output);
1736
+
1737
+ if (source && opts.strictSlashes !== true) {
1738
+ source += `${SLASH_LITERAL}?`;
1739
+ }
1740
+
1741
+ return source;
1742
+ };
1743
+
1744
+ var parse_1 = parse$1;
1745
+
1746
+ const path = path$2;
1747
+ const scan = scan_1;
1748
+ const parse = parse_1;
1749
+ const utils = utils$3;
1750
+ const constants = constants$2;
1751
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
1752
+
1753
+ /**
1754
+ * Creates a matcher function from one or more glob patterns. The
1755
+ * returned function takes a string to match as its first argument,
1756
+ * and returns true if the string is a match. The returned matcher
1757
+ * function also takes a boolean as the second argument that, when true,
1758
+ * returns an object with additional information.
1759
+ *
1760
+ * ```js
1761
+ * const picomatch = require('picomatch');
1762
+ * // picomatch(glob[, options]);
1763
+ *
1764
+ * const isMatch = picomatch('*.!(*a)');
1765
+ * console.log(isMatch('a.a')); //=> false
1766
+ * console.log(isMatch('a.b')); //=> true
1767
+ * ```
1768
+ * @name picomatch
1769
+ * @param {String|Array} `globs` One or more glob patterns.
1770
+ * @param {Object=} `options`
1771
+ * @return {Function=} Returns a matcher function.
1772
+ * @api public
1773
+ */
1774
+
1775
+ const picomatch$1 = (glob, options, returnState = false) => {
1776
+ if (Array.isArray(glob)) {
1777
+ const fns = glob.map(input => picomatch$1(input, options, returnState));
1778
+ const arrayMatcher = str => {
1779
+ for (const isMatch of fns) {
1780
+ const state = isMatch(str);
1781
+ if (state) return state;
1782
+ }
1783
+ return false;
1784
+ };
1785
+ return arrayMatcher;
1786
+ }
1787
+
1788
+ const isState = isObject(glob) && glob.tokens && glob.input;
1789
+
1790
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
1791
+ throw new TypeError('Expected pattern to be a non-empty string');
1792
+ }
1793
+
1794
+ const opts = options || {};
1795
+ const posix = utils.isWindows(options);
1796
+ const regex = isState
1797
+ ? picomatch$1.compileRe(glob, options)
1798
+ : picomatch$1.makeRe(glob, options, false, true);
1799
+
1800
+ const state = regex.state;
1801
+ delete regex.state;
1802
+
1803
+ let isIgnored = () => false;
1804
+ if (opts.ignore) {
1805
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1806
+ isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
1807
+ }
1808
+
1809
+ const matcher = (input, returnObject = false) => {
1810
+ const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
1811
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
1812
+
1813
+ if (typeof opts.onResult === 'function') {
1814
+ opts.onResult(result);
1815
+ }
1816
+
1817
+ if (isMatch === false) {
1818
+ result.isMatch = false;
1819
+ return returnObject ? result : false;
1820
+ }
1821
+
1822
+ if (isIgnored(input)) {
1823
+ if (typeof opts.onIgnore === 'function') {
1824
+ opts.onIgnore(result);
1825
+ }
1826
+ result.isMatch = false;
1827
+ return returnObject ? result : false;
1828
+ }
1829
+
1830
+ if (typeof opts.onMatch === 'function') {
1831
+ opts.onMatch(result);
1832
+ }
1833
+ return returnObject ? result : true;
1834
+ };
1835
+
1836
+ if (returnState) {
1837
+ matcher.state = state;
1838
+ }
1839
+
1840
+ return matcher;
1841
+ };
1842
+
1843
+ /**
1844
+ * Test `input` with the given `regex`. This is used by the main
1845
+ * `picomatch()` function to test the input string.
1846
+ *
1847
+ * ```js
1848
+ * const picomatch = require('picomatch');
1849
+ * // picomatch.test(input, regex[, options]);
1850
+ *
1851
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
1852
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
1853
+ * ```
1854
+ * @param {String} `input` String to test.
1855
+ * @param {RegExp} `regex`
1856
+ * @return {Object} Returns an object with matching info.
1857
+ * @api public
1858
+ */
1859
+
1860
+ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
1861
+ if (typeof input !== 'string') {
1862
+ throw new TypeError('Expected input to be a string');
1863
+ }
1864
+
1865
+ if (input === '') {
1866
+ return { isMatch: false, output: '' };
1867
+ }
1868
+
1869
+ const opts = options || {};
1870
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
1871
+ let match = input === glob;
1872
+ let output = (match && format) ? format(input) : input;
1873
+
1874
+ if (match === false) {
1875
+ output = format ? format(input) : input;
1876
+ match = output === glob;
1877
+ }
1878
+
1879
+ if (match === false || opts.capture === true) {
1880
+ if (opts.matchBase === true || opts.basename === true) {
1881
+ match = picomatch$1.matchBase(input, regex, options, posix);
1882
+ } else {
1883
+ match = regex.exec(output);
1884
+ }
1885
+ }
1886
+
1887
+ return { isMatch: Boolean(match), match, output };
1888
+ };
1889
+
1890
+ /**
1891
+ * Match the basename of a filepath.
1892
+ *
1893
+ * ```js
1894
+ * const picomatch = require('picomatch');
1895
+ * // picomatch.matchBase(input, glob[, options]);
1896
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
1897
+ * ```
1898
+ * @param {String} `input` String to test.
1899
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
1900
+ * @return {Boolean}
1901
+ * @api public
1902
+ */
1903
+
1904
+ picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
1905
+ const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
1906
+ return regex.test(path.basename(input));
1907
+ };
1908
+
1909
+ /**
1910
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
1911
+ *
1912
+ * ```js
1913
+ * const picomatch = require('picomatch');
1914
+ * // picomatch.isMatch(string, patterns[, options]);
1915
+ *
1916
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
1917
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
1918
+ * ```
1919
+ * @param {String|Array} str The string to test.
1920
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
1921
+ * @param {Object} [options] See available [options](#options).
1922
+ * @return {Boolean} Returns true if any patterns match `str`
1923
+ * @api public
1924
+ */
1925
+
1926
+ picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
1927
+
1928
+ /**
1929
+ * Parse a glob pattern to create the source string for a regular
1930
+ * expression.
1931
+ *
1932
+ * ```js
1933
+ * const picomatch = require('picomatch');
1934
+ * const result = picomatch.parse(pattern[, options]);
1935
+ * ```
1936
+ * @param {String} `pattern`
1937
+ * @param {Object} `options`
1938
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
1939
+ * @api public
1940
+ */
1941
+
1942
+ picomatch$1.parse = (pattern, options) => {
1943
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
1944
+ return parse(pattern, { ...options, fastpaths: false });
1945
+ };
1946
+
1947
+ /**
1948
+ * Scan a glob pattern to separate the pattern into segments.
1949
+ *
1950
+ * ```js
1951
+ * const picomatch = require('picomatch');
1952
+ * // picomatch.scan(input[, options]);
1953
+ *
1954
+ * const result = picomatch.scan('!./foo/*.js');
1955
+ * console.log(result);
1956
+ * { prefix: '!./',
1957
+ * input: '!./foo/*.js',
1958
+ * start: 3,
1959
+ * base: 'foo',
1960
+ * glob: '*.js',
1961
+ * isBrace: false,
1962
+ * isBracket: false,
1963
+ * isGlob: true,
1964
+ * isExtglob: false,
1965
+ * isGlobstar: false,
1966
+ * negated: true }
1967
+ * ```
1968
+ * @param {String} `input` Glob pattern to scan.
1969
+ * @param {Object} `options`
1970
+ * @return {Object} Returns an object with
1971
+ * @api public
1972
+ */
1973
+
1974
+ picomatch$1.scan = (input, options) => scan(input, options);
1975
+
1976
+ /**
1977
+ * Compile a regular expression from the `state` object returned by the
1978
+ * [parse()](#parse) method.
1979
+ *
1980
+ * @param {Object} `state`
1981
+ * @param {Object} `options`
1982
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
1983
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
1984
+ * @return {RegExp}
1985
+ * @api public
1986
+ */
1987
+
1988
+ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
1989
+ if (returnOutput === true) {
1990
+ return state.output;
1991
+ }
1992
+
1993
+ const opts = options || {};
1994
+ const prepend = opts.contains ? '' : '^';
1995
+ const append = opts.contains ? '' : '$';
1996
+
1997
+ let source = `${prepend}(?:${state.output})${append}`;
1998
+ if (state && state.negated === true) {
1999
+ source = `^(?!${source}).*$`;
2000
+ }
2001
+
2002
+ const regex = picomatch$1.toRegex(source, options);
2003
+ if (returnState === true) {
2004
+ regex.state = state;
2005
+ }
2006
+
2007
+ return regex;
2008
+ };
2009
+
2010
+ /**
2011
+ * Create a regular expression from a parsed glob pattern.
2012
+ *
2013
+ * ```js
2014
+ * const picomatch = require('picomatch');
2015
+ * const state = picomatch.parse('*.js');
2016
+ * // picomatch.compileRe(state[, options]);
2017
+ *
2018
+ * console.log(picomatch.compileRe(state));
2019
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2020
+ * ```
2021
+ * @param {String} `state` The object returned from the `.parse` method.
2022
+ * @param {Object} `options`
2023
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
2024
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
2025
+ * @return {RegExp} Returns a regex created from the given pattern.
2026
+ * @api public
2027
+ */
2028
+
2029
+ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
2030
+ if (!input || typeof input !== 'string') {
2031
+ throw new TypeError('Expected a non-empty string');
2032
+ }
2033
+
2034
+ let parsed = { negated: false, fastpaths: true };
2035
+
2036
+ if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
2037
+ parsed.output = parse.fastpaths(input, options);
2038
+ }
2039
+
2040
+ if (!parsed.output) {
2041
+ parsed = parse(input, options);
2042
+ }
2043
+
2044
+ return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
2045
+ };
2046
+
2047
+ /**
2048
+ * Create a regular expression from the given regex source string.
2049
+ *
2050
+ * ```js
2051
+ * const picomatch = require('picomatch');
2052
+ * // picomatch.toRegex(source[, options]);
2053
+ *
2054
+ * const { output } = picomatch.parse('*.js');
2055
+ * console.log(picomatch.toRegex(output));
2056
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2057
+ * ```
2058
+ * @param {String} `source` Regular expression source string.
2059
+ * @param {Object} `options`
2060
+ * @return {RegExp}
2061
+ * @api public
2062
+ */
2063
+
2064
+ picomatch$1.toRegex = (source, options) => {
2065
+ try {
2066
+ const opts = options || {};
2067
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
2068
+ } catch (err) {
2069
+ if (options && options.debug === true) throw err;
2070
+ return /$^/;
2071
+ }
2072
+ };
2073
+
2074
+ /**
2075
+ * Picomatch constants.
2076
+ * @return {Object}
2077
+ */
2078
+
2079
+ picomatch$1.constants = constants;
2080
+
2081
+ /**
2082
+ * Expose "picomatch"
2083
+ */
2084
+
2085
+ var picomatch_1 = picomatch$1;
2086
+
2087
+ var picomatch = picomatch_1;
2088
+
2089
+ // Helper since Typescript can't detect readonly arrays with Array.isArray
2090
+ function isArray(arg) {
2091
+ return Array.isArray(arg);
2092
+ }
2093
+ function ensureArray(thing) {
2094
+ if (isArray(thing))
2095
+ return thing;
2096
+ if (thing == null)
2097
+ return [];
2098
+ return [thing];
2099
+ }
2100
+
2101
+ const normalizePath = function normalizePath(filename) {
2102
+ return filename.split(win32.sep).join(posix.sep);
2103
+ };
2104
+
2105
+ function getMatcherString(id, resolutionBase) {
2106
+ if (resolutionBase === false || isAbsolute(id) || id.startsWith('*')) {
2107
+ return normalizePath(id);
2108
+ }
2109
+ // resolve('') is valid and will default to process.cwd()
2110
+ const basePath = normalizePath(resolve(resolutionBase || ''))
2111
+ // escape all possible (posix + win) path characters that might interfere with regex
2112
+ .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
2113
+ // Note that we use posix.join because:
2114
+ // 1. the basePath has been normalized to use /
2115
+ // 2. the incoming glob (id) matcher, also uses /
2116
+ // otherwise Node will force backslash (\) on windows
2117
+ return posix.join(basePath, normalizePath(id));
2118
+ }
2119
+ const createFilter = function createFilter(include, exclude, options) {
2120
+ const resolutionBase = options && options.resolve;
2121
+ const getMatcher = (id) => id instanceof RegExp
2122
+ ? id
2123
+ : {
2124
+ test: (what) => {
2125
+ // this refactor is a tad overly verbose but makes for easy debugging
2126
+ const pattern = getMatcherString(id, resolutionBase);
2127
+ const fn = picomatch(pattern, { dot: true });
2128
+ const result = fn(what);
2129
+ return result;
2130
+ }
2131
+ };
2132
+ const includeMatchers = ensureArray(include).map(getMatcher);
2133
+ const excludeMatchers = ensureArray(exclude).map(getMatcher);
2134
+ return function result(id) {
2135
+ if (typeof id !== 'string')
2136
+ return false;
2137
+ if (/\0/.test(id))
2138
+ return false;
2139
+ const pathId = normalizePath(id);
2140
+ for (let i = 0; i < excludeMatchers.length; ++i) {
2141
+ const matcher = excludeMatchers[i];
2142
+ if (matcher.test(pathId))
2143
+ return false;
2144
+ }
2145
+ for (let i = 0; i < includeMatchers.length; ++i) {
2146
+ const matcher = includeMatchers[i];
2147
+ if (matcher.test(pathId))
2148
+ return true;
2149
+ }
2150
+ return !includeMatchers.length;
2151
+ };
2152
+ };
2153
+
2154
+ const 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';
2155
+ const 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';
2156
+ const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
2157
+ forbiddenIdentifiers.add('');
2158
+
2159
+ function resolveCompiler(root) {
2160
+ const compiler = tryRequire("vue/compiler-sfc", root);
2161
+ if (!compiler) {
2162
+ throw new Error(`Failed to resolve vue/compiler-sfc.
2163
+ @vitejs/plugin-vue2 requires vue (>=2.7.0) to be present in the dependency tree.`);
2164
+ }
2165
+ return compiler;
2166
+ }
2167
+ const _require = createRequire(import.meta.url);
2168
+ function tryRequire(id, from) {
2169
+ try {
2170
+ return from ? _require(_require.resolve(id, { paths: [from] })) : _require(id);
2171
+ } catch (e) {
2172
+ }
2173
+ }
2174
+
2175
+ function parseVueRequest(id) {
2176
+ const [filename, rawQuery] = id.split(`?`, 2);
2177
+ const query = Object.fromEntries(new URLSearchParams(rawQuery));
2178
+ if (query.vue != null) {
2179
+ query.vue = true;
2180
+ }
2181
+ if (query.index != null) {
2182
+ query.index = Number(query.index);
2183
+ }
2184
+ if (query.raw != null) {
2185
+ query.raw = true;
2186
+ }
2187
+ if (query.scoped != null) {
2188
+ query.scoped = true;
2189
+ }
2190
+ return {
2191
+ filename,
2192
+ query
2193
+ };
2194
+ }
2195
+
2196
+ var slash = path => {
2197
+ const isExtendedLengthPath = /^\\\\\?\\/.test(path);
2198
+ const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
2199
+
2200
+ if (isExtendedLengthPath || hasNonAscii) {
2201
+ return path;
2202
+ }
2203
+
2204
+ return path.replace(/\\/g, '/');
2205
+ };
2206
+
2207
+ const cache = /* @__PURE__ */ new Map();
2208
+ const prevCache = /* @__PURE__ */ new Map();
2209
+ function createDescriptor(filename, source, { root, isProduction, sourceMap, compiler }) {
2210
+ let descriptor;
2211
+ let errors = [];
2212
+ try {
2213
+ descriptor = compiler.parse({
2214
+ source,
2215
+ filename,
2216
+ sourceMap
2217
+ });
2218
+ } catch (e) {
2219
+ errors = [e];
2220
+ descriptor = compiler.parse({ source: ``, filename });
2221
+ }
2222
+ const normalizedPath = slash(path$2.normalize(path$2.relative(root, filename)));
2223
+ descriptor.id = getHash(normalizedPath + (isProduction ? source : ""));
2224
+ cache.set(filename, descriptor);
2225
+ return { descriptor, errors };
2226
+ }
2227
+ function getPrevDescriptor(filename) {
2228
+ return prevCache.get(filename);
2229
+ }
2230
+ function setPrevDescriptor(filename, entry) {
2231
+ prevCache.set(filename, entry);
2232
+ }
2233
+ function getDescriptor(filename, options, createIfNotFound = true) {
2234
+ if (cache.has(filename)) {
2235
+ return cache.get(filename);
2236
+ }
2237
+ if (createIfNotFound) {
2238
+ const { descriptor, errors } = createDescriptor(filename, fs.readFileSync(filename, "utf-8"), options);
2239
+ if (errors.length) {
2240
+ throw errors[0];
2241
+ }
2242
+ return descriptor;
2243
+ }
2244
+ }
2245
+ function getSrcDescriptor(filename, query) {
2246
+ if (query.scoped) {
2247
+ return cache.get(`${filename}?src=${query.src}`);
2248
+ }
2249
+ return cache.get(filename);
2250
+ }
2251
+ function setSrcDescriptor(filename, entry, scoped) {
2252
+ if (scoped) {
2253
+ cache.set(`${filename}?src=${entry.id}`, entry);
2254
+ return;
2255
+ }
2256
+ cache.set(filename, entry);
2257
+ }
2258
+ function getHash(text) {
2259
+ return createHash("sha256").update(text).digest("hex").substring(0, 8);
2260
+ }
2261
+
2262
+ const clientCache = /* @__PURE__ */ new WeakMap();
2263
+ const ssrCache = /* @__PURE__ */ new WeakMap();
2264
+ function getResolvedScript(descriptor, ssr) {
2265
+ return (ssr ? ssrCache : clientCache).get(descriptor);
2266
+ }
2267
+ function setResolvedScript(descriptor, script, ssr) {
2268
+ (ssr ? ssrCache : clientCache).set(descriptor, script);
2269
+ }
2270
+ function resolveScript(descriptor, options, ssr) {
2271
+ if (!descriptor.script && !descriptor.scriptSetup) {
2272
+ return null;
2273
+ }
2274
+ const cacheToUse = ssr ? ssrCache : clientCache;
2275
+ const cached = cacheToUse.get(descriptor);
2276
+ if (cached) {
2277
+ return cached;
2278
+ }
2279
+ let resolved = null;
2280
+ resolved = options.compiler.compileScript(descriptor, {
2281
+ ...options.script,
2282
+ id: descriptor.id,
2283
+ isProd: options.isProduction,
2284
+ sourceMap: options.sourceMap
2285
+ });
2286
+ cacheToUse.set(descriptor, resolved);
2287
+ return resolved;
2288
+ }
2289
+
2290
+ function pad (hash, len) {
2291
+ while (hash.length < len) {
2292
+ hash = '0' + hash;
2293
+ }
2294
+ return hash;
2295
+ }
2296
+
2297
+ function fold (hash, text) {
2298
+ var i;
2299
+ var chr;
2300
+ var len;
2301
+ if (text.length === 0) {
2302
+ return hash;
2303
+ }
2304
+ for (i = 0, len = text.length; i < len; i++) {
2305
+ chr = text.charCodeAt(i);
2306
+ hash = ((hash << 5) - hash) + chr;
2307
+ hash |= 0;
2308
+ }
2309
+ return hash < 0 ? hash * -2 : hash;
2310
+ }
2311
+
2312
+ function foldObject (hash, o, seen) {
2313
+ return Object.keys(o).sort().reduce(foldKey, hash);
2314
+ function foldKey (hash, key) {
2315
+ return foldValue(hash, o[key], key, seen);
2316
+ }
2317
+ }
2318
+
2319
+ function foldValue (input, value, key, seen) {
2320
+ var hash = fold(fold(fold(input, key), toString(value)), typeof value);
2321
+ if (value === null) {
2322
+ return fold(hash, 'null');
2323
+ }
2324
+ if (value === undefined) {
2325
+ return fold(hash, 'undefined');
2326
+ }
2327
+ if (typeof value === 'object' || typeof value === 'function') {
2328
+ if (seen.indexOf(value) !== -1) {
2329
+ return fold(hash, '[Circular]' + key);
2330
+ }
2331
+ seen.push(value);
2332
+
2333
+ var objHash = foldObject(hash, value, seen);
2334
+
2335
+ if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
2336
+ return objHash;
2337
+ }
2338
+
2339
+ try {
2340
+ return fold(objHash, String(value.valueOf()))
2341
+ } catch (err) {
2342
+ return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
2343
+ }
2344
+ }
2345
+ return fold(hash, value.toString());
2346
+ }
2347
+
2348
+ function toString (o) {
2349
+ return Object.prototype.toString.call(o);
2350
+ }
2351
+
2352
+ function sum (o) {
2353
+ return pad(foldValue(0, o, '', []).toString(16), 8);
2354
+ }
2355
+
2356
+ var hashSum = sum;
2357
+
2358
+ function createRollupError(id, error) {
2359
+ if ("msg" in error) {
2360
+ return {
2361
+ id,
2362
+ plugin: "vue",
2363
+ message: error.msg,
2364
+ name: "vue-compiler-error"
2365
+ };
2366
+ } else {
2367
+ return {
2368
+ id,
2369
+ plugin: "vue",
2370
+ message: error.message,
2371
+ name: error.name,
2372
+ stack: error.stack
2373
+ };
2374
+ }
2375
+ }
2376
+
2377
+ const HMR_RUNTIME_ID = "plugin-vue2:hmr-runtime";
2378
+ const hmrRuntimeCode = `
2379
+ var __VUE_HMR_RUNTIME__ = Object.create(null)
2380
+ var map = Object.create(null)
2381
+
2382
+ __VUE_HMR_RUNTIME__.createRecord = function (id, options) {
2383
+ if(map[id]) { return }
2384
+
2385
+ var Ctor = null
2386
+ if (typeof options === 'function') {
2387
+ Ctor = options
2388
+ options = Ctor.options
2389
+ }
2390
+ makeOptionsHot(id, options)
2391
+ map[id] = {
2392
+ Ctor: Ctor,
2393
+ options: options,
2394
+ instances: []
2395
+ }
2396
+ }
2397
+
2398
+ __VUE_HMR_RUNTIME__.isRecorded = function (id) {
2399
+ return typeof map[id] !== 'undefined'
2400
+ }
2401
+
2402
+ function makeOptionsHot(id, options) {
2403
+ if (options.functional) {
2404
+ var render = options.render
2405
+ options.render = function (h, ctx) {
2406
+ var instances = map[id].instances
2407
+ if (ctx && instances.indexOf(ctx.parent) < 0) {
2408
+ instances.push(ctx.parent)
2409
+ }
2410
+ return render(h, ctx)
2411
+ }
2412
+ } else {
2413
+ injectHook(options, 'beforeCreate', function() {
2414
+ var record = map[id]
2415
+ if (!record.Ctor) {
2416
+ record.Ctor = this.constructor
2417
+ }
2418
+ record.instances.push(this)
2419
+ })
2420
+ injectHook(options, 'beforeDestroy', function() {
2421
+ var instances = map[id].instances
2422
+ instances.splice(instances.indexOf(this), 1)
2423
+ })
2424
+ }
2425
+ }
2426
+
2427
+ function injectHook(options, name, hook) {
2428
+ var existing = options[name]
2429
+ options[name] = existing
2430
+ ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
2431
+ : [hook]
2432
+ }
2433
+
2434
+ function tryWrap(fn) {
2435
+ return function (id, arg) {
2436
+ try {
2437
+ fn(id, arg)
2438
+ } catch (e) {
2439
+ console.error(e)
2440
+ console.warn(
2441
+ 'Something went wrong during Vue component hot-reload. Full reload required.'
2442
+ )
2443
+ }
2444
+ }
2445
+ }
2446
+
2447
+ function updateOptions (oldOptions, newOptions) {
2448
+ for (var key in oldOptions) {
2449
+ if (!(key in newOptions)) {
2450
+ delete oldOptions[key]
2451
+ }
2452
+ }
2453
+ for (var key$1 in newOptions) {
2454
+ oldOptions[key$1] = newOptions[key$1]
2455
+ }
2456
+ }
2457
+
2458
+ __VUE_HMR_RUNTIME__.rerender = tryWrap(function (id, options) {
2459
+ var record = map[id]
2460
+ if (!options) {
2461
+ record.instances.slice().forEach(function (instance) {
2462
+ instance.$forceUpdate()
2463
+ })
2464
+ return
2465
+ }
2466
+ if (typeof options === 'function') {
2467
+ options = options.options
2468
+ }
2469
+ if(record.functional){
2470
+ record.render = options.render
2471
+ record.staticRenderFns = options.staticRenderFns
2472
+ __VUE_HMR_RUNTIME__.reload(id, record)
2473
+ return
2474
+ }
2475
+ if (record.Ctor) {
2476
+ record.Ctor.options.render = options.render
2477
+ record.Ctor.options.staticRenderFns = options.staticRenderFns
2478
+ record.instances.slice().forEach(function (instance) {
2479
+ instance.$options.render = options.render
2480
+ instance.$options.staticRenderFns = options.staticRenderFns
2481
+ // reset static trees
2482
+ // pre 2.5, all static trees are cached together on the instance
2483
+ if (instance._staticTrees) {
2484
+ instance._staticTrees = []
2485
+ }
2486
+ // 2.5.0
2487
+ if (Array.isArray(record.Ctor.options.cached)) {
2488
+ record.Ctor.options.cached = []
2489
+ }
2490
+ // 2.5.3
2491
+ if (Array.isArray(instance.$options.cached)) {
2492
+ instance.$options.cached = []
2493
+ }
2494
+
2495
+ // post 2.5.4: v-once trees are cached on instance._staticTrees.
2496
+ // Pure static trees are cached on the staticRenderFns array
2497
+ // (both already reset above)
2498
+
2499
+ // 2.6: temporarily mark rendered scoped slots as unstable so that
2500
+ // child components can be forced to update
2501
+ var restore = patchScopedSlots(instance)
2502
+ instance.$forceUpdate()
2503
+ instance.$nextTick(restore)
2504
+ })
2505
+ } else {
2506
+ // functional or no instance created yet
2507
+ record.options.render = options.render
2508
+ record.options.staticRenderFns = options.staticRenderFns
2509
+
2510
+ // handle functional component re-render
2511
+ if (record.options.functional) {
2512
+ // rerender with full options
2513
+ if (Object.keys(options).length > 2) {
2514
+ updateOptions(record.options, options)
2515
+ } else {
2516
+ // template-only rerender.
2517
+ // need to inject the style injection code for CSS modules
2518
+ // to work properly.
2519
+ var injectStyles = record.options._injectStyles
2520
+ if (injectStyles) {
2521
+ var render = options.render
2522
+ record.options.render = function (h, ctx) {
2523
+ injectStyles.call(ctx)
2524
+ return render(h, ctx)
2525
+ }
2526
+ }
2527
+ }
2528
+ record.options._Ctor = null
2529
+ // 2.5.3
2530
+ if (Array.isArray(record.options.cached)) {
2531
+ record.options.cached = []
2532
+ }
2533
+ record.instances.slice().forEach(function (instance) {
2534
+ instance.$forceUpdate()
2535
+ })
2536
+ }
2537
+ }
2538
+ })
2539
+
2540
+ __VUE_HMR_RUNTIME__.reload = tryWrap(function (id, options) {
2541
+ var record = map[id]
2542
+ if (options) {
2543
+ if (typeof options === 'function') {
2544
+ options = options.options
2545
+ }
2546
+ makeOptionsHot(id, options)
2547
+ if (record.Ctor) {
2548
+ var newCtor = record.Ctor.super.extend(options)
2549
+ // prevent record.options._Ctor from being overwritten accidentally
2550
+ newCtor.options._Ctor = record.options._Ctor
2551
+ record.Ctor.options = newCtor.options
2552
+ record.Ctor.cid = newCtor.cid
2553
+ record.Ctor.prototype = newCtor.prototype
2554
+ if (newCtor.release) {
2555
+ // temporary global mixin strategy used in < 2.0.0-alpha.6
2556
+ newCtor.release()
2557
+ }
2558
+ } else {
2559
+ updateOptions(record.options, options)
2560
+ }
2561
+ }
2562
+ record.instances.slice().forEach(function (instance) {
2563
+ if (instance.$vnode && instance.$vnode.context) {
2564
+ instance.$vnode.context.$forceUpdate()
2565
+ } else {
2566
+ console.warn(
2567
+ 'Root or manually mounted instance modified. Full reload required.'
2568
+ )
2569
+ }
2570
+ })
2571
+ })
2572
+
2573
+ // 2.6 optimizes template-compiled scoped slots and skips updates if child
2574
+ // only uses scoped slots. We need to patch the scoped slots resolving helper
2575
+ // to temporarily mark all scoped slots as unstable in order to force child
2576
+ // updates.
2577
+ function patchScopedSlots (instance) {
2578
+ if (!instance._u) { return }
2579
+ // https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js
2580
+ var original = instance._u
2581
+ instance._u = function (slots) {
2582
+ try {
2583
+ // 2.6.4 ~ 2.6.6
2584
+ return original(slots, true)
2585
+ } catch (e) {
2586
+ // 2.5 / >= 2.6.7
2587
+ return original(slots, null, true)
2588
+ }
2589
+ }
2590
+ return function () {
2591
+ instance._u = original
2592
+ }
2593
+ }
2594
+ export default __VUE_HMR_RUNTIME__
2595
+ `;
2596
+
2597
+ async function transformTemplateAsModule(code, descriptor, options, pluginContext, ssr) {
2598
+ let returnCode = compile(code, descriptor, options, pluginContext, ssr);
2599
+ if (options.devServer && options.devServer.config.server.hmr !== false && !ssr && !options.isProduction) {
2600
+ returnCode += `
2601
+ import __VUE_HMR_RUNTIME__ from "${HMR_RUNTIME_ID}"`;
2602
+ returnCode += `
2603
+ import.meta.hot.accept((updated) => {
2604
+ __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, updated)
2605
+ })`;
2606
+ }
2607
+ return returnCode + `
2608
+ export { render, staticRenderFns }`;
2609
+ }
2610
+ function transformTemplateInMain(code, descriptor, options, pluginContext, ssr) {
2611
+ return compile(code, descriptor, options, pluginContext, ssr).replace(/var (render|staticRenderFns) =/g, "var _sfc_$1 =").replace(/(render._withStripped)/, "_sfc_$1");
2612
+ }
2613
+ function compile(code, descriptor, options, pluginContext, ssr) {
2614
+ const filename = descriptor.filename;
2615
+ const result = options.compiler.compileTemplate({
2616
+ ...resolveTemplateCompilerOptions(descriptor, options, ssr),
2617
+ source: code
2618
+ });
2619
+ if (result.errors.length) {
2620
+ result.errors.forEach((error) => pluginContext.error(typeof error === "string" ? { id: filename, message: error } : createRollupError(filename, error)));
2621
+ }
2622
+ if (result.tips.length) {
2623
+ result.tips.forEach((tip) => pluginContext.warn({
2624
+ id: filename,
2625
+ message: typeof tip === "string" ? tip : tip.msg
2626
+ }));
2627
+ }
2628
+ return transformRequireToImport(result.code);
2629
+ }
2630
+ function resolveTemplateCompilerOptions(descriptor, options, ssr) {
2631
+ const block = descriptor.template;
2632
+ if (!block) {
2633
+ return;
2634
+ }
2635
+ const resolvedScript = getResolvedScript(descriptor, ssr);
2636
+ const hasScoped = descriptor.styles.some((s) => s.scoped);
2637
+ const { id, filename } = descriptor;
2638
+ let preprocessOptions = block.lang && options.template?.preprocessOptions;
2639
+ if (block.lang === "pug") {
2640
+ preprocessOptions = {
2641
+ doctype: "html",
2642
+ ...preprocessOptions
2643
+ };
2644
+ }
2645
+ const transformAssetUrls = options.template?.transformAssetUrls ?? true;
2646
+ let assetUrlOptions;
2647
+ if (options.devServer) {
2648
+ if (filename.startsWith(options.root)) {
2649
+ assetUrlOptions = {
2650
+ base: (options.devServer.config.server?.origin ?? "") + options.devServer.config.base + slash(path$2.relative(options.root, path$2.dirname(filename)))
2651
+ };
2652
+ }
2653
+ } else if (transformAssetUrls !== false) {
2654
+ assetUrlOptions = {
2655
+ includeAbsolute: true
2656
+ };
2657
+ }
2658
+ return {
2659
+ transformAssetUrls,
2660
+ ...options.template,
2661
+ filename,
2662
+ isProduction: options.isProduction,
2663
+ isFunctional: !!block.attrs.functional,
2664
+ optimizeSSR: ssr,
2665
+ transformAssetUrlsOptions: {
2666
+ ...options.template?.transformAssetUrlsOptions,
2667
+ ...assetUrlOptions
2668
+ },
2669
+ preprocessLang: block.lang,
2670
+ preprocessOptions,
2671
+ bindings: resolvedScript ? resolvedScript.bindings : void 0,
2672
+ prettify: false,
2673
+ compilerOptions: {
2674
+ whitespace: "condense",
2675
+ outputSourceRange: true,
2676
+ ...options.template?.compilerOptions,
2677
+ scopeId: hasScoped ? `data-v-${id}` : void 0
2678
+ }
2679
+ };
2680
+ }
2681
+ function transformRequireToImport(code) {
2682
+ const imports = {};
2683
+ let strImports = "";
2684
+ code = code.replace(/require\(("(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+')\)/g, (_, name) => {
2685
+ if (!(name in imports)) {
2686
+ imports[name] = `__$_require_${hashSum(name)}__`;
2687
+ strImports += `import ${imports[name]} from ${name}
2688
+ `;
2689
+ }
2690
+ return imports[name];
2691
+ });
2692
+ return strImports + code;
2693
+ }
2694
+
2695
+ const directRequestRE = /(\?|&)direct\b/;
2696
+ async function handleHotUpdate({ file, modules, read, server }, options) {
2697
+ const prevDescriptor = getDescriptor(file, options, false);
2698
+ if (!prevDescriptor) {
2699
+ return;
2700
+ }
2701
+ setPrevDescriptor(file, prevDescriptor);
2702
+ const content = await read();
2703
+ const { descriptor } = createDescriptor(file, content, options);
2704
+ let needRerender = false;
2705
+ const affectedModules = /* @__PURE__ */ new Set();
2706
+ const mainModule = modules.find((m) => !/type=/.test(m.url) || /type=script/.test(m.url));
2707
+ const templateModule = modules.find((m) => /type=template/.test(m.url));
2708
+ if (hasScriptChanged(prevDescriptor, descriptor)) {
2709
+ let scriptModule;
2710
+ if (descriptor.scriptSetup?.lang && !descriptor.scriptSetup.src || descriptor.script?.lang && !descriptor.script.src) {
2711
+ const scriptModuleRE = new RegExp(`type=script.*&lang.${descriptor.scriptSetup?.lang || descriptor.script?.lang}$`);
2712
+ scriptModule = modules.find((m) => scriptModuleRE.test(m.url));
2713
+ }
2714
+ affectedModules.add(scriptModule || mainModule);
2715
+ }
2716
+ if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
2717
+ if (mainModule && !affectedModules.has(mainModule)) {
2718
+ setResolvedScript(descriptor, getResolvedScript(prevDescriptor, false), false);
2719
+ }
2720
+ affectedModules.add(templateModule);
2721
+ needRerender = true;
2722
+ }
2723
+ const prevStyles = prevDescriptor.styles || [];
2724
+ const nextStyles = descriptor.styles || [];
2725
+ if (prevStyles.some((s) => s.scoped) !== nextStyles.some((s) => s.scoped)) {
2726
+ affectedModules.add(templateModule);
2727
+ affectedModules.add(mainModule);
2728
+ }
2729
+ for (let i = 0; i < nextStyles.length; i++) {
2730
+ const prev = prevStyles[i];
2731
+ const next = nextStyles[i];
2732
+ if (!prev || !isEqualBlock(prev, next)) {
2733
+ const mod = modules.find((m) => m.url.includes(`type=style&index=${i}`) && m.url.endsWith(`.${next.lang || "css"}`) && !directRequestRE.test(m.url));
2734
+ if (mod) {
2735
+ affectedModules.add(mod);
2736
+ if (mod.url.includes("&inline")) {
2737
+ affectedModules.add(mainModule);
2738
+ }
2739
+ } else {
2740
+ affectedModules.add(mainModule);
2741
+ }
2742
+ }
2743
+ }
2744
+ if (prevStyles.length > nextStyles.length) {
2745
+ affectedModules.add(mainModule);
2746
+ }
2747
+ const prevCustoms = prevDescriptor.customBlocks || [];
2748
+ const nextCustoms = descriptor.customBlocks || [];
2749
+ if (prevCustoms.length !== nextCustoms.length) {
2750
+ affectedModules.add(mainModule);
2751
+ } else {
2752
+ for (let i = 0; i < nextCustoms.length; i++) {
2753
+ const prev = prevCustoms[i];
2754
+ const next = nextCustoms[i];
2755
+ if (!prev || !isEqualBlock(prev, next)) {
2756
+ const mod = modules.find((m) => m.url.includes(`type=${prev.type}&index=${i}`));
2757
+ if (mod) {
2758
+ affectedModules.add(mod);
2759
+ } else {
2760
+ affectedModules.add(mainModule);
2761
+ }
2762
+ }
2763
+ }
2764
+ }
2765
+ if (needRerender) {
2766
+ if (!templateModule) {
2767
+ affectedModules.add(mainModule);
2768
+ } else if (mainModule && !affectedModules.has(mainModule)) {
2769
+ const styleImporters = [...mainModule.importers].filter((m) => /\.css($|\?)/.test(m.url));
2770
+ styleImporters.forEach((m) => affectedModules.add(m));
2771
+ }
2772
+ }
2773
+ return [...affectedModules].filter(Boolean);
2774
+ }
2775
+ function isEqualBlock(a, b) {
2776
+ if (!a && !b)
2777
+ return true;
2778
+ if (!a || !b)
2779
+ return false;
2780
+ if (a.src && b.src && a.src === b.src)
2781
+ return true;
2782
+ if (a.content !== b.content)
2783
+ return false;
2784
+ const keysA = Object.keys(a.attrs);
2785
+ const keysB = Object.keys(b.attrs);
2786
+ if (keysA.length !== keysB.length) {
2787
+ return false;
2788
+ }
2789
+ return keysA.every((key) => a.attrs[key] === b.attrs[key]);
2790
+ }
2791
+ function isOnlyTemplateChanged(prev, next) {
2792
+ return !hasScriptChanged(prev, next) && prev.styles.length === next.styles.length && prev.styles.every((s, i) => isEqualBlock(s, next.styles[i])) && prev.customBlocks.length === next.customBlocks.length && prev.customBlocks.every((s, i) => isEqualBlock(s, next.customBlocks[i]));
2793
+ }
2794
+ function hasScriptChanged(prev, next) {
2795
+ if (!isEqualBlock(prev.script, next.script)) {
2796
+ return true;
2797
+ }
2798
+ if (!isEqualBlock(prev.scriptSetup, next.scriptSetup)) {
2799
+ return true;
2800
+ }
2801
+ const prevResolvedScript = getResolvedScript(prev, false);
2802
+ const prevImports = prevResolvedScript?.imports;
2803
+ if (prevImports) {
2804
+ return next.shouldForceReload(prevImports);
2805
+ }
2806
+ return false;
2807
+ }
2808
+
2809
+ const NORMALIZER_ID = "plugin-vue2:normalizer";
2810
+ const normalizerCode = `
2811
+ export default function normalizeComponent (
2812
+ scriptExports,
2813
+ render,
2814
+ staticRenderFns,
2815
+ functionalTemplate,
2816
+ injectStyles,
2817
+ scopeId,
2818
+ moduleIdentifier, /* server only */
2819
+ shadowMode /* vue-cli only */
2820
+ ) {
2821
+ // Vue.extend constructor export interop
2822
+ var options = typeof scriptExports === 'function'
2823
+ ? scriptExports.options
2824
+ : scriptExports
2825
+
2826
+ // render functions
2827
+ if (render) {
2828
+ options.render = render
2829
+ options.staticRenderFns = staticRenderFns
2830
+ options._compiled = true
2831
+ }
2832
+
2833
+ // functional template
2834
+ if (functionalTemplate) {
2835
+ options.functional = true
2836
+ }
2837
+
2838
+ // scopedId
2839
+ if (scopeId) {
2840
+ options._scopeId = 'data-v-' + scopeId
2841
+ }
2842
+
2843
+ var hook
2844
+ if (moduleIdentifier) { // server build
2845
+ hook = function (context) {
2846
+ // 2.3 injection
2847
+ context =
2848
+ context || // cached call
2849
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
2850
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
2851
+ // 2.2 with runInNewContext: true
2852
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
2853
+ context = __VUE_SSR_CONTEXT__
2854
+ }
2855
+ // inject component styles
2856
+ if (injectStyles) {
2857
+ injectStyles.call(this, context)
2858
+ }
2859
+ // register component module identifier for async chunk inference
2860
+ if (context && context._registeredComponents) {
2861
+ context._registeredComponents.add(moduleIdentifier)
2862
+ }
2863
+ }
2864
+ // used by ssr in case component is cached and beforeCreate
2865
+ // never gets called
2866
+ options._ssrRegister = hook
2867
+ } else if (injectStyles) {
2868
+ hook = shadowMode
2869
+ ? function () {
2870
+ injectStyles.call(
2871
+ this,
2872
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
2873
+ )
2874
+ }
2875
+ : injectStyles
2876
+ }
2877
+
2878
+ if (hook) {
2879
+ if (options.functional) {
2880
+ // for template-only hot-reload because in that case the render fn doesn't
2881
+ // go through the normalizer
2882
+ options._injectStyles = hook
2883
+ // register for functional component in vue file
2884
+ var originalRender = options.render
2885
+ options.render = function renderWithStyleInjection (h, context) {
2886
+ hook.call(context)
2887
+ return originalRender(h, context)
2888
+ }
2889
+ } else {
2890
+ // inject component registration as beforeCreate hook
2891
+ var existing = options.beforeCreate
2892
+ options.beforeCreate = existing
2893
+ ? [].concat(existing, hook)
2894
+ : [hook]
2895
+ }
2896
+ }
2897
+
2898
+ return {
2899
+ exports: scriptExports,
2900
+ options: options
2901
+ }
2902
+ }`;
2903
+
2904
+ async function transformMain(code, filename, options, pluginContext, ssr) {
2905
+ const { devServer, isProduction, devToolsEnabled } = options;
2906
+ const prevDescriptor = getPrevDescriptor(filename);
2907
+ const { descriptor, errors } = createDescriptor(filename, code, options);
2908
+ if (errors.length) {
2909
+ errors.forEach((error) => pluginContext.error(createRollupError(filename, error)));
2910
+ return null;
2911
+ }
2912
+ const hasScoped = descriptor.styles.some((s) => s.scoped);
2913
+ const hasCssModules = descriptor.styles.some((s) => s.module);
2914
+ const hasFunctional = descriptor.template && descriptor.template.attrs.functional;
2915
+ const { code: scriptCode, map: scriptMap } = await genScriptCode(descriptor, options, pluginContext, ssr);
2916
+ const templateCode = await genTemplateCode(descriptor, options, pluginContext, ssr);
2917
+ const stylesCode = await genStyleCode(descriptor, pluginContext);
2918
+ const customBlocksCode = await genCustomBlockCode(descriptor, pluginContext);
2919
+ const output = [
2920
+ scriptCode,
2921
+ templateCode,
2922
+ stylesCode,
2923
+ customBlocksCode
2924
+ ];
2925
+ output.push(`/* normalize component */
2926
+ import __normalizer from "${NORMALIZER_ID}"
2927
+ var __component__ = /*#__PURE__*/__normalizer(
2928
+ _sfc_main,
2929
+ _sfc_render,
2930
+ _sfc_staticRenderFns,
2931
+ ${hasFunctional ? "true" : "false"},
2932
+ ${hasCssModules ? `_sfc_injectStyles` : `null`},
2933
+ ${hasScoped ? JSON.stringify(descriptor.id) : "null"},
2934
+ null,
2935
+ null
2936
+ )`);
2937
+ if (devToolsEnabled || devServer && !isProduction) {
2938
+ output.push(`__component__.options.__file = ${JSON.stringify(isProduction ? path$2.basename(filename) : filename)}`);
2939
+ }
2940
+ if (devServer && devServer.config.server.hmr !== false && !ssr && !isProduction) {
2941
+ const id = JSON.stringify(descriptor.id);
2942
+ output.push(`import __VUE_HMR_RUNTIME__ from "${HMR_RUNTIME_ID}"`, `if (!__VUE_HMR_RUNTIME__.isRecorded(${id})) {`, ` __VUE_HMR_RUNTIME__.createRecord(${id}, __component__.options)`, `}`);
2943
+ if (hasFunctional || prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
2944
+ output.push(`export const _rerender_only = true`);
2945
+ }
2946
+ output.push(`import.meta.hot.accept(({ default: updated, _rerender_only }) => {`, ` if (_rerender_only) {`, ` __VUE_HMR_RUNTIME__.rerender(${id}, updated)`, ` } else {`, ` __VUE_HMR_RUNTIME__.reload(${id}, updated)`, ` }`, `})`);
2947
+ }
2948
+ let resolvedMap = scriptMap;
2949
+ output.push(`export default __component__.exports`);
2950
+ let resolvedCode = output.join("\n");
2951
+ if ((descriptor.script?.lang === "ts" || descriptor.scriptSetup?.lang === "ts") && !descriptor.script?.src) {
2952
+ const { code: code2, map } = await transformWithEsbuild(resolvedCode, filename, { loader: "ts", sourcemap: options.sourceMap }, resolvedMap);
2953
+ resolvedCode = code2;
2954
+ resolvedMap = resolvedMap ? map : resolvedMap;
2955
+ }
2956
+ return {
2957
+ code: resolvedCode,
2958
+ map: resolvedMap || {
2959
+ mappings: ""
2960
+ },
2961
+ meta: {
2962
+ vite: {
2963
+ lang: descriptor.script?.lang || descriptor.scriptSetup?.lang || "js"
2964
+ }
2965
+ }
2966
+ };
2967
+ }
2968
+ async function genTemplateCode(descriptor, options, pluginContext, ssr) {
2969
+ const template = descriptor.template;
2970
+ if (!template) {
2971
+ return "const _sfc_render = null; const _sfc_staticRenderFns = null";
2972
+ }
2973
+ const hasScoped = descriptor.styles.some((style) => style.scoped);
2974
+ if (!template.lang && !template.src) {
2975
+ return transformTemplateInMain(template.content, descriptor, options, pluginContext, ssr);
2976
+ } else {
2977
+ if (template.src) {
2978
+ await linkSrcToDescriptor(template.src, descriptor, pluginContext, hasScoped);
2979
+ }
2980
+ const src = template.src || descriptor.filename;
2981
+ const srcQuery = template.src ? hasScoped ? `&src=${descriptor.id}` : "&src=true" : "";
2982
+ const scopedQuery = hasScoped ? `&scoped=${descriptor.id}` : ``;
2983
+ const attrsQuery = attrsToQuery(template.attrs, "js", true);
2984
+ const query = `?vue&type=template${srcQuery}${scopedQuery}${attrsQuery}`;
2985
+ const request = JSON.stringify(src + query);
2986
+ return `import { render as _sfc_render, staticRenderFns as _sfc_staticRenderFns } from ${request}`;
2987
+ }
2988
+ }
2989
+ async function genScriptCode(descriptor, options, pluginContext, ssr) {
2990
+ let scriptCode = `const _sfc_main = {}`;
2991
+ let map;
2992
+ const script = resolveScript(descriptor, options, ssr);
2993
+ if (script) {
2994
+ if ((!script.lang || script.lang === "ts" && options.devServer) && !script.src) {
2995
+ const userPlugins = options.script?.babelParserPlugins || [];
2996
+ const defaultPlugins = script.lang === "ts" ? userPlugins.includes("decorators") ? ["typescript"] : ["typescript", "decorators-legacy"] : [];
2997
+ scriptCode = options.compiler.rewriteDefault(script.content, "_sfc_main", [...defaultPlugins, ...userPlugins]);
2998
+ map = script.map;
2999
+ } else {
3000
+ if (script.src) {
3001
+ await linkSrcToDescriptor(script.src, descriptor, pluginContext, false);
3002
+ }
3003
+ const src = script.src || descriptor.filename;
3004
+ const langFallback = script.src && path$2.extname(src).slice(1) || "js";
3005
+ const attrsQuery = attrsToQuery(script.attrs, langFallback);
3006
+ const srcQuery = script.src ? `&src=true` : ``;
3007
+ const query = `?vue&type=script${srcQuery}${attrsQuery}`;
3008
+ const request = JSON.stringify(src + query);
3009
+ scriptCode = `import _sfc_main from ${request}
3010
+ export * from ${request}`;
3011
+ }
3012
+ }
3013
+ return {
3014
+ code: scriptCode,
3015
+ map
3016
+ };
3017
+ }
3018
+ async function genStyleCode(descriptor, pluginContext) {
3019
+ let stylesCode = ``;
3020
+ let cssModulesMap;
3021
+ if (descriptor.styles.length) {
3022
+ for (let i = 0; i < descriptor.styles.length; i++) {
3023
+ const style = descriptor.styles[i];
3024
+ if (style.src) {
3025
+ await linkSrcToDescriptor(style.src, descriptor, pluginContext, style.scoped);
3026
+ }
3027
+ const src = style.src || descriptor.filename;
3028
+ const attrsQuery = attrsToQuery(style.attrs, "css");
3029
+ const srcQuery = style.src ? style.scoped ? `&src=${descriptor.id}` : "&src=true" : "";
3030
+ const directQuery = ``;
3031
+ const scopedQuery = style.scoped ? `&scoped=${descriptor.id}` : ``;
3032
+ const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}${scopedQuery}`;
3033
+ const styleRequest = src + query + attrsQuery;
3034
+ if (style.module) {
3035
+ const [importCode, nameMap] = genCSSModulesCode(i, styleRequest, style.module);
3036
+ stylesCode += importCode;
3037
+ Object.assign(cssModulesMap || (cssModulesMap = {}), nameMap);
3038
+ } else {
3039
+ stylesCode += `
3040
+ import ${JSON.stringify(styleRequest)}`;
3041
+ }
3042
+ }
3043
+ }
3044
+ if (cssModulesMap) {
3045
+ const mappingCode = Object.entries(cssModulesMap).reduce((code, [key, value]) => code + `"${key}":${value},
3046
+ `, "{\n") + "}";
3047
+ stylesCode += `
3048
+ const __cssModules = ${mappingCode}`;
3049
+ stylesCode += `
3050
+ function _sfc_injectStyles(ctx) {
3051
+ for (var key in __cssModules) {
3052
+ this[key] = __cssModules[key]
3053
+ }
3054
+ }`;
3055
+ }
3056
+ return stylesCode;
3057
+ }
3058
+ function genCSSModulesCode(index, request, moduleName) {
3059
+ const styleVar = `style${index}`;
3060
+ const exposedName = typeof moduleName === "string" ? moduleName : "$style";
3061
+ const moduleRequest = request.replace(/\.(\w+)$/, ".module.$1");
3062
+ return [
3063
+ `
3064
+ import ${styleVar} from ${JSON.stringify(moduleRequest)}`,
3065
+ { [exposedName]: styleVar }
3066
+ ];
3067
+ }
3068
+ async function genCustomBlockCode(descriptor, pluginContext) {
3069
+ let code = "";
3070
+ for (let index = 0; index < descriptor.customBlocks.length; index++) {
3071
+ const block = descriptor.customBlocks[index];
3072
+ if (block.src) {
3073
+ await linkSrcToDescriptor(block.src, descriptor, pluginContext, false);
3074
+ }
3075
+ const src = block.src || descriptor.filename;
3076
+ const attrsQuery = attrsToQuery(block.attrs, block.type);
3077
+ const srcQuery = block.src ? `&src=true` : ``;
3078
+ const query = `?vue&type=${block.type}&index=${index}${srcQuery}${attrsQuery}`;
3079
+ const request = JSON.stringify(src + query);
3080
+ code += `import block${index} from ${request}
3081
+ `;
3082
+ code += `if (typeof block${index} === 'function') block${index}(_sfc_main)
3083
+ `;
3084
+ }
3085
+ return code;
3086
+ }
3087
+ async function linkSrcToDescriptor(src, descriptor, pluginContext, scoped) {
3088
+ const srcFile = (await pluginContext.resolve(src, descriptor.filename))?.id || src;
3089
+ setSrcDescriptor(srcFile.replace(/\?.*$/, ""), descriptor, scoped);
3090
+ }
3091
+ const ignoreList = ["id", "index", "src", "type", "lang", "module", "scoped"];
3092
+ function attrsToQuery(attrs, langFallback, forceLangFallback = false) {
3093
+ let query = ``;
3094
+ for (const name in attrs) {
3095
+ const value = attrs[name];
3096
+ if (!ignoreList.includes(name)) {
3097
+ query += `&${encodeURIComponent(name)}${value ? `=${encodeURIComponent(value)}` : ``}`;
3098
+ }
3099
+ }
3100
+ if (langFallback || attrs.lang) {
3101
+ query += `lang` in attrs ? forceLangFallback ? `&lang.${langFallback}` : `&lang.${attrs.lang}` : `&lang.${langFallback}`;
3102
+ }
3103
+ return query;
3104
+ }
3105
+
3106
+ async function transformStyle(code, descriptor, index, options, pluginContext, filename) {
3107
+ const block = descriptor.styles[index];
3108
+ const result = await options.compiler.compileStyleAsync({
3109
+ ...options.style,
3110
+ filename: descriptor.filename,
3111
+ id: `data-v-${descriptor.id}`,
3112
+ isProd: options.isProduction,
3113
+ source: code,
3114
+ scoped: !!block.scoped,
3115
+ ...options.cssDevSourcemap ? {
3116
+ postcssOptions: {
3117
+ map: {
3118
+ from: filename,
3119
+ inline: false,
3120
+ annotation: false
3121
+ }
3122
+ }
3123
+ } : {}
3124
+ });
3125
+ if (result.errors.length) {
3126
+ result.errors.forEach((error) => {
3127
+ if (error.line && error.column) {
3128
+ error.loc = {
3129
+ file: descriptor.filename,
3130
+ line: error.line + getLine(descriptor.source, block.start),
3131
+ column: error.column
3132
+ };
3133
+ }
3134
+ pluginContext.error(error);
3135
+ });
3136
+ return null;
3137
+ }
3138
+ const map = result.map ? await formatPostcssSourceMap(result.map, filename) : { mappings: "" };
3139
+ return {
3140
+ code: result.code,
3141
+ map
3142
+ };
3143
+ }
3144
+ function getLine(source, start) {
3145
+ const lines = source.split(/\r?\n/g);
3146
+ let cur = 0;
3147
+ for (let i = 0; i < lines.length; i++) {
3148
+ cur += lines[i].length;
3149
+ if (cur >= start) {
3150
+ return i;
3151
+ }
3152
+ }
3153
+ }
3154
+
3155
+ function vuePlugin(rawOptions = {}) {
3156
+ const {
3157
+ include = /\.vue$/,
3158
+ exclude
3159
+ } = rawOptions;
3160
+ const filter = createFilter(include, exclude);
3161
+ let options = {
3162
+ isProduction: process.env.NODE_ENV === "production",
3163
+ compiler: null,
3164
+ ...rawOptions,
3165
+ include,
3166
+ exclude,
3167
+ root: process.cwd(),
3168
+ sourceMap: true,
3169
+ cssDevSourcemap: false,
3170
+ devToolsEnabled: process.env.NODE_ENV !== "production"
3171
+ };
3172
+ return {
3173
+ name: "vite:vue2",
3174
+ handleHotUpdate(ctx) {
3175
+ if (!filter(ctx.file)) {
3176
+ return;
3177
+ }
3178
+ return handleHotUpdate(ctx, options);
3179
+ },
3180
+ configResolved(config) {
3181
+ options = {
3182
+ ...options,
3183
+ root: config.root,
3184
+ isProduction: config.isProduction,
3185
+ sourceMap: config.command === "build" ? !!config.build.sourcemap : true,
3186
+ cssDevSourcemap: config.css?.devSourcemap ?? false,
3187
+ devToolsEnabled: !config.isProduction
3188
+ };
3189
+ if (!config.resolve.alias.some(({ find }) => find === "vue")) {
3190
+ config.resolve.alias.push({
3191
+ find: "vue",
3192
+ replacement: "vue/dist/vue.runtime.esm.js"
3193
+ });
3194
+ }
3195
+ },
3196
+ configureServer(server) {
3197
+ options.devServer = server;
3198
+ },
3199
+ buildStart() {
3200
+ options.compiler = resolveCompiler();
3201
+ },
3202
+ async resolveId(id) {
3203
+ if (id === NORMALIZER_ID || id === HMR_RUNTIME_ID) {
3204
+ return id;
3205
+ }
3206
+ if (parseVueRequest(id).query.vue) {
3207
+ return id;
3208
+ }
3209
+ },
3210
+ load(id, opt) {
3211
+ const ssr = opt?.ssr === true;
3212
+ if (id === NORMALIZER_ID) {
3213
+ return normalizerCode;
3214
+ }
3215
+ if (id === HMR_RUNTIME_ID) {
3216
+ return hmrRuntimeCode;
3217
+ }
3218
+ const { filename, query } = parseVueRequest(id);
3219
+ if (query.vue) {
3220
+ if (query.src) {
3221
+ return fs.readFileSync(filename, "utf-8");
3222
+ }
3223
+ const descriptor = getDescriptor(filename, options);
3224
+ let block;
3225
+ if (query.type === "script") {
3226
+ block = getResolvedScript(descriptor, ssr);
3227
+ } else if (query.type === "template") {
3228
+ block = descriptor.template;
3229
+ } else if (query.type === "style") {
3230
+ block = descriptor.styles[query.index];
3231
+ } else if (query.index != null) {
3232
+ block = descriptor.customBlocks[query.index];
3233
+ }
3234
+ if (block) {
3235
+ return {
3236
+ code: block.content,
3237
+ map: block.map
3238
+ };
3239
+ }
3240
+ }
3241
+ },
3242
+ async transform(code, id, opt) {
3243
+ const ssr = opt?.ssr === true;
3244
+ const { filename, query } = parseVueRequest(id);
3245
+ if (query.raw) {
3246
+ return;
3247
+ }
3248
+ if (!filter(filename) && !query.vue) {
3249
+ return;
3250
+ }
3251
+ if (!query.vue) {
3252
+ return transformMain(code, filename, options, this, ssr);
3253
+ } else {
3254
+ const descriptor = query.src ? getSrcDescriptor(filename, query) : getDescriptor(filename, options);
3255
+ if (query.type === "template") {
3256
+ return {
3257
+ code: await transformTemplateAsModule(code, descriptor, options, this, ssr),
3258
+ map: {
3259
+ mappings: ""
3260
+ }
3261
+ };
3262
+ } else if (query.type === "style") {
3263
+ return transformStyle(code, descriptor, Number(query.index), options, this, filename);
3264
+ }
3265
+ }
3266
+ }
3267
+ };
3268
+ }
3269
+
18
3270
  const name = "kirbyup";
19
- const version = "1.2.1";
3271
+ const version = "1.2.4";
20
3272
 
21
3273
  class PrettyError extends Error {
22
3274
  constructor(message) {
@@ -45,8 +3297,8 @@ async function getCompressedSize(code) {
45
3297
  return ` / gzip: ${size.toFixed(2)} KiB`;
46
3298
  }
47
3299
  async function printFileInfo(root, outDir, filePath, type, content) {
48
- content ?? (content = await readFile(resolve(outDir, filePath), "utf8"));
49
- const prettyOutDir = `${normalize(relative(root, resolve(root, outDir)))}/`;
3300
+ content ?? (content = await readFile(resolve$1(outDir, filePath), "utf8"));
3301
+ const prettyOutDir = `${normalize(relative(root, resolve$1(root, outDir)))}/`;
50
3302
  const kibs = content.length / 1024;
51
3303
  const compressedSize = await getCompressedSize(content);
52
3304
  const writeColor = type === "chunk" ? colors.cyan : colors.magenta;
@@ -69,7 +3321,7 @@ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSo
69
3321
  configOrPath = inlineConfig.configFile || process.cwd();
70
3322
  }
71
3323
  }
72
- const resolved = resolve(configOrPath);
3324
+ const resolved = resolve$1(configOrPath);
73
3325
  let isFile = false;
74
3326
  if (existsSync(resolved) && statSync(resolved).isFile()) {
75
3327
  isFile = true;
@@ -135,14 +3387,14 @@ async function generate(options) {
135
3387
  let result;
136
3388
  const mode = options.watch ? "development" : "production";
137
3389
  const outDir = options.outDir || options.cwd;
138
- const aliasDir = resolve(options.cwd, dirname(options.entry));
3390
+ const aliasDir = resolve$1(options.cwd, dirname(options.entry));
139
3391
  const { alias = {}, extendViteConfig = {} } = resolvedKirbyupConfig;
140
3392
  const defaultConfig = {
141
3393
  mode,
142
3394
  plugins: [vuePlugin(), kirbyupAutoImportPlugin()],
143
3395
  build: {
144
3396
  lib: {
145
- entry: resolve(options.cwd, options.entry),
3397
+ entry: resolve$1(options.cwd, options.entry),
146
3398
  formats: ["iife"],
147
3399
  name: "kirbyupExport",
148
3400
  fileName: () => "index.js"
@@ -192,7 +3444,7 @@ async function resolveOptions(options) {
192
3444
  if (!options.entry) {
193
3445
  throw new PrettyError(`No input file, try ${colors.cyan(`${name} <path/to/file.js>`)}`);
194
3446
  }
195
- if (!existsSync$1(resolve(options.cwd, options.entry)))
3447
+ if (!existsSync$1(resolve$1(options.cwd, options.entry)))
196
3448
  throw new PrettyError(`Cannot find "${options.entry}"`);
197
3449
  return options;
198
3450
  }