jiek 0.4.7-alpha.14 → 0.4.7-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,4140 +5,18 @@ var path = require('node:path');
5
5
  var entrypoints = require('@jiek/pkger/entrypoints');
6
6
  var rollupPluginDts = require('@jiek/rollup-plugin-dts');
7
7
  var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
8
- var commonjs = require('@rollup/plugin-commonjs');
9
8
  var json = require('@rollup/plugin-json');
10
9
  var pluginNodeResolve = require('@rollup/plugin-node-resolve');
11
10
  var terser = require('@rollup/plugin-terser');
12
11
  var execa = require('execa');
13
12
  var jsoncParser = require('jsonc-parser');
14
- var require$$0 = require('util');
15
- var require$$0$1 = require('path');
13
+ var micromatch = require('micromatch');
16
14
  var esbuild = require('rollup-plugin-esbuild');
17
15
  var ts = require('typescript');
18
16
  var commander = require('commander');
19
17
  var jsYaml = require('js-yaml');
20
- var node_module = require('node:module');
21
18
  require('@pnpm/filter-workspace-packages');
22
19
 
23
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
24
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
25
-
26
- var fs__default = /*#__PURE__*/_interopDefault(fs);
27
- var path__default = /*#__PURE__*/_interopDefault(path);
28
- var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
29
- var json__default = /*#__PURE__*/_interopDefault(json);
30
- var terser__default = /*#__PURE__*/_interopDefault(terser);
31
- var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
32
- var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
33
- var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
34
- var ts__default = /*#__PURE__*/_interopDefault(ts);
35
-
36
- var utils$1 = {};
37
-
38
- var hasRequiredUtils$1;
39
-
40
- function requireUtils$1 () {
41
- if (hasRequiredUtils$1) return utils$1;
42
- hasRequiredUtils$1 = 1;
43
- (function (exports) {
44
-
45
- exports.isInteger = num => {
46
- if (typeof num === 'number') {
47
- return Number.isInteger(num);
48
- }
49
- if (typeof num === 'string' && num.trim() !== '') {
50
- return Number.isInteger(Number(num));
51
- }
52
- return false;
53
- };
54
-
55
- /**
56
- * Find a node of the given type
57
- */
58
-
59
- exports.find = (node, type) => node.nodes.find(node => node.type === type);
60
-
61
- /**
62
- * Find a node of the given type
63
- */
64
-
65
- exports.exceedsLimit = (min, max, step = 1, limit) => {
66
- if (limit === false) return false;
67
- if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
68
- return ((Number(max) - Number(min)) / Number(step)) >= limit;
69
- };
70
-
71
- /**
72
- * Escape the given node with '\\' before node.value
73
- */
74
-
75
- exports.escapeNode = (block, n = 0, type) => {
76
- let node = block.nodes[n];
77
- if (!node) return;
78
-
79
- if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
80
- if (node.escaped !== true) {
81
- node.value = '\\' + node.value;
82
- node.escaped = true;
83
- }
84
- }
85
- };
86
-
87
- /**
88
- * Returns true if the given brace node should be enclosed in literal braces
89
- */
90
-
91
- exports.encloseBrace = node => {
92
- if (node.type !== 'brace') return false;
93
- if ((node.commas >> 0 + node.ranges >> 0) === 0) {
94
- node.invalid = true;
95
- return true;
96
- }
97
- return false;
98
- };
99
-
100
- /**
101
- * Returns true if a brace node is invalid.
102
- */
103
-
104
- exports.isInvalidBrace = block => {
105
- if (block.type !== 'brace') return false;
106
- if (block.invalid === true || block.dollar) return true;
107
- if ((block.commas >> 0 + block.ranges >> 0) === 0) {
108
- block.invalid = true;
109
- return true;
110
- }
111
- if (block.open !== true || block.close !== true) {
112
- block.invalid = true;
113
- return true;
114
- }
115
- return false;
116
- };
117
-
118
- /**
119
- * Returns true if a node is an open or close node
120
- */
121
-
122
- exports.isOpenOrClose = node => {
123
- if (node.type === 'open' || node.type === 'close') {
124
- return true;
125
- }
126
- return node.open === true || node.close === true;
127
- };
128
-
129
- /**
130
- * Reduce an array of text nodes.
131
- */
132
-
133
- exports.reduce = nodes => nodes.reduce((acc, node) => {
134
- if (node.type === 'text') acc.push(node.value);
135
- if (node.type === 'range') node.type = 'text';
136
- return acc;
137
- }, []);
138
-
139
- /**
140
- * Flatten an array
141
- */
142
-
143
- exports.flatten = (...args) => {
144
- const result = [];
145
- const flat = arr => {
146
- for (let i = 0; i < arr.length; i++) {
147
- let ele = arr[i];
148
- Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
149
- }
150
- return result;
151
- };
152
- flat(args);
153
- return result;
154
- };
155
- } (utils$1));
156
- return utils$1;
157
- }
158
-
159
- var stringify;
160
- var hasRequiredStringify;
161
-
162
- function requireStringify () {
163
- if (hasRequiredStringify) return stringify;
164
- hasRequiredStringify = 1;
165
-
166
- const utils = requireUtils$1();
167
-
168
- stringify = (ast, options = {}) => {
169
- let stringify = (node, parent = {}) => {
170
- let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
171
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
172
- let output = '';
173
-
174
- if (node.value) {
175
- if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
176
- return '\\' + node.value;
177
- }
178
- return node.value;
179
- }
180
-
181
- if (node.value) {
182
- return node.value;
183
- }
184
-
185
- if (node.nodes) {
186
- for (let child of node.nodes) {
187
- output += stringify(child);
188
- }
189
- }
190
- return output;
191
- };
192
-
193
- return stringify(ast);
194
- };
195
- return stringify;
196
- }
197
-
198
- /*!
199
- * is-number <https://github.com/jonschlinkert/is-number>
200
- *
201
- * Copyright (c) 2014-present, Jon Schlinkert.
202
- * Released under the MIT License.
203
- */
204
-
205
- var isNumber;
206
- var hasRequiredIsNumber;
207
-
208
- function requireIsNumber () {
209
- if (hasRequiredIsNumber) return isNumber;
210
- hasRequiredIsNumber = 1;
211
-
212
- isNumber = function(num) {
213
- if (typeof num === 'number') {
214
- return num - num === 0;
215
- }
216
- if (typeof num === 'string' && num.trim() !== '') {
217
- return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
218
- }
219
- return false;
220
- };
221
- return isNumber;
222
- }
223
-
224
- /*!
225
- * to-regex-range <https://github.com/micromatch/to-regex-range>
226
- *
227
- * Copyright (c) 2015-present, Jon Schlinkert.
228
- * Released under the MIT License.
229
- */
230
-
231
- var toRegexRange_1;
232
- var hasRequiredToRegexRange;
233
-
234
- function requireToRegexRange () {
235
- if (hasRequiredToRegexRange) return toRegexRange_1;
236
- hasRequiredToRegexRange = 1;
237
-
238
- const isNumber = requireIsNumber();
239
-
240
- const toRegexRange = (min, max, options) => {
241
- if (isNumber(min) === false) {
242
- throw new TypeError('toRegexRange: expected the first argument to be a number');
243
- }
244
-
245
- if (max === void 0 || min === max) {
246
- return String(min);
247
- }
248
-
249
- if (isNumber(max) === false) {
250
- throw new TypeError('toRegexRange: expected the second argument to be a number.');
251
- }
252
-
253
- let opts = { relaxZeros: true, ...options };
254
- if (typeof opts.strictZeros === 'boolean') {
255
- opts.relaxZeros = opts.strictZeros === false;
256
- }
257
-
258
- let relax = String(opts.relaxZeros);
259
- let shorthand = String(opts.shorthand);
260
- let capture = String(opts.capture);
261
- let wrap = String(opts.wrap);
262
- let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
263
-
264
- if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
265
- return toRegexRange.cache[cacheKey].result;
266
- }
267
-
268
- let a = Math.min(min, max);
269
- let b = Math.max(min, max);
270
-
271
- if (Math.abs(a - b) === 1) {
272
- let result = min + '|' + max;
273
- if (opts.capture) {
274
- return `(${result})`;
275
- }
276
- if (opts.wrap === false) {
277
- return result;
278
- }
279
- return `(?:${result})`;
280
- }
281
-
282
- let isPadded = hasPadding(min) || hasPadding(max);
283
- let state = { min, max, a, b };
284
- let positives = [];
285
- let negatives = [];
286
-
287
- if (isPadded) {
288
- state.isPadded = isPadded;
289
- state.maxLen = String(state.max).length;
290
- }
291
-
292
- if (a < 0) {
293
- let newMin = b < 0 ? Math.abs(b) : 1;
294
- negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
295
- a = state.a = 0;
296
- }
297
-
298
- if (b >= 0) {
299
- positives = splitToPatterns(a, b, state, opts);
300
- }
301
-
302
- state.negatives = negatives;
303
- state.positives = positives;
304
- state.result = collatePatterns(negatives, positives);
305
-
306
- if (opts.capture === true) {
307
- state.result = `(${state.result})`;
308
- } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
309
- state.result = `(?:${state.result})`;
310
- }
311
-
312
- toRegexRange.cache[cacheKey] = state;
313
- return state.result;
314
- };
315
-
316
- function collatePatterns(neg, pos, options) {
317
- let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
318
- let onlyPositive = filterPatterns(pos, neg, '', false) || [];
319
- let intersected = filterPatterns(neg, pos, '-?', true) || [];
320
- let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
321
- return subpatterns.join('|');
322
- }
323
-
324
- function splitToRanges(min, max) {
325
- let nines = 1;
326
- let zeros = 1;
327
-
328
- let stop = countNines(min, nines);
329
- let stops = new Set([max]);
330
-
331
- while (min <= stop && stop <= max) {
332
- stops.add(stop);
333
- nines += 1;
334
- stop = countNines(min, nines);
335
- }
336
-
337
- stop = countZeros(max + 1, zeros) - 1;
338
-
339
- while (min < stop && stop <= max) {
340
- stops.add(stop);
341
- zeros += 1;
342
- stop = countZeros(max + 1, zeros) - 1;
343
- }
344
-
345
- stops = [...stops];
346
- stops.sort(compare);
347
- return stops;
348
- }
349
-
350
- /**
351
- * Convert a range to a regex pattern
352
- * @param {Number} `start`
353
- * @param {Number} `stop`
354
- * @return {String}
355
- */
356
-
357
- function rangeToPattern(start, stop, options) {
358
- if (start === stop) {
359
- return { pattern: start, count: [], digits: 0 };
360
- }
361
-
362
- let zipped = zip(start, stop);
363
- let digits = zipped.length;
364
- let pattern = '';
365
- let count = 0;
366
-
367
- for (let i = 0; i < digits; i++) {
368
- let [startDigit, stopDigit] = zipped[i];
369
-
370
- if (startDigit === stopDigit) {
371
- pattern += startDigit;
372
-
373
- } else if (startDigit !== '0' || stopDigit !== '9') {
374
- pattern += toCharacterClass(startDigit, stopDigit);
375
-
376
- } else {
377
- count++;
378
- }
379
- }
380
-
381
- if (count) {
382
- pattern += options.shorthand === true ? '\\d' : '[0-9]';
383
- }
384
-
385
- return { pattern, count: [count], digits };
386
- }
387
-
388
- function splitToPatterns(min, max, tok, options) {
389
- let ranges = splitToRanges(min, max);
390
- let tokens = [];
391
- let start = min;
392
- let prev;
393
-
394
- for (let i = 0; i < ranges.length; i++) {
395
- let max = ranges[i];
396
- let obj = rangeToPattern(String(start), String(max), options);
397
- let zeros = '';
398
-
399
- if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
400
- if (prev.count.length > 1) {
401
- prev.count.pop();
402
- }
403
-
404
- prev.count.push(obj.count[0]);
405
- prev.string = prev.pattern + toQuantifier(prev.count);
406
- start = max + 1;
407
- continue;
408
- }
409
-
410
- if (tok.isPadded) {
411
- zeros = padZeros(max, tok, options);
412
- }
413
-
414
- obj.string = zeros + obj.pattern + toQuantifier(obj.count);
415
- tokens.push(obj);
416
- start = max + 1;
417
- prev = obj;
418
- }
419
-
420
- return tokens;
421
- }
422
-
423
- function filterPatterns(arr, comparison, prefix, intersection, options) {
424
- let result = [];
425
-
426
- for (let ele of arr) {
427
- let { string } = ele;
428
-
429
- // only push if _both_ are negative...
430
- if (!intersection && !contains(comparison, 'string', string)) {
431
- result.push(prefix + string);
432
- }
433
-
434
- // or _both_ are positive
435
- if (intersection && contains(comparison, 'string', string)) {
436
- result.push(prefix + string);
437
- }
438
- }
439
- return result;
440
- }
441
-
442
- /**
443
- * Zip strings
444
- */
445
-
446
- function zip(a, b) {
447
- let arr = [];
448
- for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
449
- return arr;
450
- }
451
-
452
- function compare(a, b) {
453
- return a > b ? 1 : b > a ? -1 : 0;
454
- }
455
-
456
- function contains(arr, key, val) {
457
- return arr.some(ele => ele[key] === val);
458
- }
459
-
460
- function countNines(min, len) {
461
- return Number(String(min).slice(0, -len) + '9'.repeat(len));
462
- }
463
-
464
- function countZeros(integer, zeros) {
465
- return integer - (integer % Math.pow(10, zeros));
466
- }
467
-
468
- function toQuantifier(digits) {
469
- let [start = 0, stop = ''] = digits;
470
- if (stop || start > 1) {
471
- return `{${start + (stop ? ',' + stop : '')}}`;
472
- }
473
- return '';
474
- }
475
-
476
- function toCharacterClass(a, b, options) {
477
- return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
478
- }
479
-
480
- function hasPadding(str) {
481
- return /^-?(0+)\d/.test(str);
482
- }
483
-
484
- function padZeros(value, tok, options) {
485
- if (!tok.isPadded) {
486
- return value;
487
- }
488
-
489
- let diff = Math.abs(tok.maxLen - String(value).length);
490
- let relax = options.relaxZeros !== false;
491
-
492
- switch (diff) {
493
- case 0:
494
- return '';
495
- case 1:
496
- return relax ? '0?' : '0';
497
- case 2:
498
- return relax ? '0{0,2}' : '00';
499
- default: {
500
- return relax ? `0{0,${diff}}` : `0{${diff}}`;
501
- }
502
- }
503
- }
504
-
505
- /**
506
- * Cache
507
- */
508
-
509
- toRegexRange.cache = {};
510
- toRegexRange.clearCache = () => (toRegexRange.cache = {});
511
-
512
- /**
513
- * Expose `toRegexRange`
514
- */
515
-
516
- toRegexRange_1 = toRegexRange;
517
- return toRegexRange_1;
518
- }
519
-
520
- /*!
521
- * fill-range <https://github.com/jonschlinkert/fill-range>
522
- *
523
- * Copyright (c) 2014-present, Jon Schlinkert.
524
- * Licensed under the MIT License.
525
- */
526
-
527
- var fillRange;
528
- var hasRequiredFillRange;
529
-
530
- function requireFillRange () {
531
- if (hasRequiredFillRange) return fillRange;
532
- hasRequiredFillRange = 1;
533
-
534
- const util = require$$0__default.default;
535
- const toRegexRange = requireToRegexRange();
536
-
537
- const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
538
-
539
- const transform = toNumber => {
540
- return value => toNumber === true ? Number(value) : String(value);
541
- };
542
-
543
- const isValidValue = value => {
544
- return typeof value === 'number' || (typeof value === 'string' && value !== '');
545
- };
546
-
547
- const isNumber = num => Number.isInteger(+num);
548
-
549
- const zeros = input => {
550
- let value = `${input}`;
551
- let index = -1;
552
- if (value[0] === '-') value = value.slice(1);
553
- if (value === '0') return false;
554
- while (value[++index] === '0');
555
- return index > 0;
556
- };
557
-
558
- const stringify = (start, end, options) => {
559
- if (typeof start === 'string' || typeof end === 'string') {
560
- return true;
561
- }
562
- return options.stringify === true;
563
- };
564
-
565
- const pad = (input, maxLength, toNumber) => {
566
- if (maxLength > 0) {
567
- let dash = input[0] === '-' ? '-' : '';
568
- if (dash) input = input.slice(1);
569
- input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
570
- }
571
- if (toNumber === false) {
572
- return String(input);
573
- }
574
- return input;
575
- };
576
-
577
- const toMaxLen = (input, maxLength) => {
578
- let negative = input[0] === '-' ? '-' : '';
579
- if (negative) {
580
- input = input.slice(1);
581
- maxLength--;
582
- }
583
- while (input.length < maxLength) input = '0' + input;
584
- return negative ? ('-' + input) : input;
585
- };
586
-
587
- const toSequence = (parts, options) => {
588
- parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
589
- parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
590
-
591
- let prefix = options.capture ? '' : '?:';
592
- let positives = '';
593
- let negatives = '';
594
- let result;
595
-
596
- if (parts.positives.length) {
597
- positives = parts.positives.join('|');
598
- }
599
-
600
- if (parts.negatives.length) {
601
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
602
- }
603
-
604
- if (positives && negatives) {
605
- result = `${positives}|${negatives}`;
606
- } else {
607
- result = positives || negatives;
608
- }
609
-
610
- if (options.wrap) {
611
- return `(${prefix}${result})`;
612
- }
613
-
614
- return result;
615
- };
616
-
617
- const toRange = (a, b, isNumbers, options) => {
618
- if (isNumbers) {
619
- return toRegexRange(a, b, { wrap: false, ...options });
620
- }
621
-
622
- let start = String.fromCharCode(a);
623
- if (a === b) return start;
624
-
625
- let stop = String.fromCharCode(b);
626
- return `[${start}-${stop}]`;
627
- };
628
-
629
- const toRegex = (start, end, options) => {
630
- if (Array.isArray(start)) {
631
- let wrap = options.wrap === true;
632
- let prefix = options.capture ? '' : '?:';
633
- return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
634
- }
635
- return toRegexRange(start, end, options);
636
- };
637
-
638
- const rangeError = (...args) => {
639
- return new RangeError('Invalid range arguments: ' + util.inspect(...args));
640
- };
641
-
642
- const invalidRange = (start, end, options) => {
643
- if (options.strictRanges === true) throw rangeError([start, end]);
644
- return [];
645
- };
646
-
647
- const invalidStep = (step, options) => {
648
- if (options.strictRanges === true) {
649
- throw new TypeError(`Expected step "${step}" to be a number`);
650
- }
651
- return [];
652
- };
653
-
654
- const fillNumbers = (start, end, step = 1, options = {}) => {
655
- let a = Number(start);
656
- let b = Number(end);
657
-
658
- if (!Number.isInteger(a) || !Number.isInteger(b)) {
659
- if (options.strictRanges === true) throw rangeError([start, end]);
660
- return [];
661
- }
662
-
663
- // fix negative zero
664
- if (a === 0) a = 0;
665
- if (b === 0) b = 0;
666
-
667
- let descending = a > b;
668
- let startString = String(start);
669
- let endString = String(end);
670
- let stepString = String(step);
671
- step = Math.max(Math.abs(step), 1);
672
-
673
- let padded = zeros(startString) || zeros(endString) || zeros(stepString);
674
- let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
675
- let toNumber = padded === false && stringify(start, end, options) === false;
676
- let format = options.transform || transform(toNumber);
677
-
678
- if (options.toRegex && step === 1) {
679
- return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
680
- }
681
-
682
- let parts = { negatives: [], positives: [] };
683
- let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
684
- let range = [];
685
- let index = 0;
686
-
687
- while (descending ? a >= b : a <= b) {
688
- if (options.toRegex === true && step > 1) {
689
- push(a);
690
- } else {
691
- range.push(pad(format(a, index), maxLen, toNumber));
692
- }
693
- a = descending ? a - step : a + step;
694
- index++;
695
- }
696
-
697
- if (options.toRegex === true) {
698
- return step > 1
699
- ? toSequence(parts, options)
700
- : toRegex(range, null, { wrap: false, ...options });
701
- }
702
-
703
- return range;
704
- };
705
-
706
- const fillLetters = (start, end, step = 1, options = {}) => {
707
- if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
708
- return invalidRange(start, end, options);
709
- }
710
-
711
-
712
- let format = options.transform || (val => String.fromCharCode(val));
713
- let a = `${start}`.charCodeAt(0);
714
- let b = `${end}`.charCodeAt(0);
715
-
716
- let descending = a > b;
717
- let min = Math.min(a, b);
718
- let max = Math.max(a, b);
719
-
720
- if (options.toRegex && step === 1) {
721
- return toRange(min, max, false, options);
722
- }
723
-
724
- let range = [];
725
- let index = 0;
726
-
727
- while (descending ? a >= b : a <= b) {
728
- range.push(format(a, index));
729
- a = descending ? a - step : a + step;
730
- index++;
731
- }
732
-
733
- if (options.toRegex === true) {
734
- return toRegex(range, null, { wrap: false, options });
735
- }
736
-
737
- return range;
738
- };
739
-
740
- const fill = (start, end, step, options = {}) => {
741
- if (end == null && isValidValue(start)) {
742
- return [start];
743
- }
744
-
745
- if (!isValidValue(start) || !isValidValue(end)) {
746
- return invalidRange(start, end, options);
747
- }
748
-
749
- if (typeof step === 'function') {
750
- return fill(start, end, 1, { transform: step });
751
- }
752
-
753
- if (isObject(step)) {
754
- return fill(start, end, 0, step);
755
- }
756
-
757
- let opts = { ...options };
758
- if (opts.capture === true) opts.wrap = true;
759
- step = step || opts.step || 1;
760
-
761
- if (!isNumber(step)) {
762
- if (step != null && !isObject(step)) return invalidStep(step, opts);
763
- return fill(start, end, 1, step);
764
- }
765
-
766
- if (isNumber(start) && isNumber(end)) {
767
- return fillNumbers(start, end, step, opts);
768
- }
769
-
770
- return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
771
- };
772
-
773
- fillRange = fill;
774
- return fillRange;
775
- }
776
-
777
- var compile_1;
778
- var hasRequiredCompile;
779
-
780
- function requireCompile () {
781
- if (hasRequiredCompile) return compile_1;
782
- hasRequiredCompile = 1;
783
-
784
- const fill = requireFillRange();
785
- const utils = requireUtils$1();
786
-
787
- const compile = (ast, options = {}) => {
788
- let walk = (node, parent = {}) => {
789
- let invalidBlock = utils.isInvalidBrace(parent);
790
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
791
- let invalid = invalidBlock === true || invalidNode === true;
792
- let prefix = options.escapeInvalid === true ? '\\' : '';
793
- let output = '';
794
-
795
- if (node.isOpen === true) {
796
- return prefix + node.value;
797
- }
798
- if (node.isClose === true) {
799
- return prefix + node.value;
800
- }
801
-
802
- if (node.type === 'open') {
803
- return invalid ? (prefix + node.value) : '(';
804
- }
805
-
806
- if (node.type === 'close') {
807
- return invalid ? (prefix + node.value) : ')';
808
- }
809
-
810
- if (node.type === 'comma') {
811
- return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
812
- }
813
-
814
- if (node.value) {
815
- return node.value;
816
- }
817
-
818
- if (node.nodes && node.ranges > 0) {
819
- let args = utils.reduce(node.nodes);
820
- let range = fill(...args, { ...options, wrap: false, toRegex: true });
821
-
822
- if (range.length !== 0) {
823
- return args.length > 1 && range.length > 1 ? `(${range})` : range;
824
- }
825
- }
826
-
827
- if (node.nodes) {
828
- for (let child of node.nodes) {
829
- output += walk(child, node);
830
- }
831
- }
832
- return output;
833
- };
834
-
835
- return walk(ast);
836
- };
837
-
838
- compile_1 = compile;
839
- return compile_1;
840
- }
841
-
842
- var expand_1;
843
- var hasRequiredExpand;
844
-
845
- function requireExpand () {
846
- if (hasRequiredExpand) return expand_1;
847
- hasRequiredExpand = 1;
848
-
849
- const fill = requireFillRange();
850
- const stringify = requireStringify();
851
- const utils = requireUtils$1();
852
-
853
- const append = (queue = '', stash = '', enclose = false) => {
854
- let result = [];
855
-
856
- queue = [].concat(queue);
857
- stash = [].concat(stash);
858
-
859
- if (!stash.length) return queue;
860
- if (!queue.length) {
861
- return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
862
- }
863
-
864
- for (let item of queue) {
865
- if (Array.isArray(item)) {
866
- for (let value of item) {
867
- result.push(append(value, stash, enclose));
868
- }
869
- } else {
870
- for (let ele of stash) {
871
- if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
872
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
873
- }
874
- }
875
- }
876
- return utils.flatten(result);
877
- };
878
-
879
- const expand = (ast, options = {}) => {
880
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
881
-
882
- let walk = (node, parent = {}) => {
883
- node.queue = [];
884
-
885
- let p = parent;
886
- let q = parent.queue;
887
-
888
- while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
889
- p = p.parent;
890
- q = p.queue;
891
- }
892
-
893
- if (node.invalid || node.dollar) {
894
- q.push(append(q.pop(), stringify(node, options)));
895
- return;
896
- }
897
-
898
- if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
899
- q.push(append(q.pop(), ['{}']));
900
- return;
901
- }
902
-
903
- if (node.nodes && node.ranges > 0) {
904
- let args = utils.reduce(node.nodes);
905
-
906
- if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
907
- throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
908
- }
909
-
910
- let range = fill(...args, options);
911
- if (range.length === 0) {
912
- range = stringify(node, options);
913
- }
914
-
915
- q.push(append(q.pop(), range));
916
- node.nodes = [];
917
- return;
918
- }
919
-
920
- let enclose = utils.encloseBrace(node);
921
- let queue = node.queue;
922
- let block = node;
923
-
924
- while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
925
- block = block.parent;
926
- queue = block.queue;
927
- }
928
-
929
- for (let i = 0; i < node.nodes.length; i++) {
930
- let child = node.nodes[i];
931
-
932
- if (child.type === 'comma' && node.type === 'brace') {
933
- if (i === 1) queue.push('');
934
- queue.push('');
935
- continue;
936
- }
937
-
938
- if (child.type === 'close') {
939
- q.push(append(q.pop(), queue, enclose));
940
- continue;
941
- }
942
-
943
- if (child.value && child.type !== 'open') {
944
- queue.push(append(queue.pop(), child.value));
945
- continue;
946
- }
947
-
948
- if (child.nodes) {
949
- walk(child, node);
950
- }
951
- }
952
-
953
- return queue;
954
- };
955
-
956
- return utils.flatten(walk(ast));
957
- };
958
-
959
- expand_1 = expand;
960
- return expand_1;
961
- }
962
-
963
- var constants$1;
964
- var hasRequiredConstants$1;
965
-
966
- function requireConstants$1 () {
967
- if (hasRequiredConstants$1) return constants$1;
968
- hasRequiredConstants$1 = 1;
969
-
970
- constants$1 = {
971
- MAX_LENGTH: 1024 * 64,
972
-
973
- // Digits
974
- CHAR_0: '0', /* 0 */
975
- CHAR_9: '9', /* 9 */
976
-
977
- // Alphabet chars.
978
- CHAR_UPPERCASE_A: 'A', /* A */
979
- CHAR_LOWERCASE_A: 'a', /* a */
980
- CHAR_UPPERCASE_Z: 'Z', /* Z */
981
- CHAR_LOWERCASE_Z: 'z', /* z */
982
-
983
- CHAR_LEFT_PARENTHESES: '(', /* ( */
984
- CHAR_RIGHT_PARENTHESES: ')', /* ) */
985
-
986
- CHAR_ASTERISK: '*', /* * */
987
-
988
- // Non-alphabetic chars.
989
- CHAR_AMPERSAND: '&', /* & */
990
- CHAR_AT: '@', /* @ */
991
- CHAR_BACKSLASH: '\\', /* \ */
992
- CHAR_BACKTICK: '`', /* ` */
993
- CHAR_CARRIAGE_RETURN: '\r', /* \r */
994
- CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
995
- CHAR_COLON: ':', /* : */
996
- CHAR_COMMA: ',', /* , */
997
- CHAR_DOLLAR: '$', /* . */
998
- CHAR_DOT: '.', /* . */
999
- CHAR_DOUBLE_QUOTE: '"', /* " */
1000
- CHAR_EQUAL: '=', /* = */
1001
- CHAR_EXCLAMATION_MARK: '!', /* ! */
1002
- CHAR_FORM_FEED: '\f', /* \f */
1003
- CHAR_FORWARD_SLASH: '/', /* / */
1004
- CHAR_HASH: '#', /* # */
1005
- CHAR_HYPHEN_MINUS: '-', /* - */
1006
- CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
1007
- CHAR_LEFT_CURLY_BRACE: '{', /* { */
1008
- CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
1009
- CHAR_LINE_FEED: '\n', /* \n */
1010
- CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
1011
- CHAR_PERCENT: '%', /* % */
1012
- CHAR_PLUS: '+', /* + */
1013
- CHAR_QUESTION_MARK: '?', /* ? */
1014
- CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
1015
- CHAR_RIGHT_CURLY_BRACE: '}', /* } */
1016
- CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
1017
- CHAR_SEMICOLON: ';', /* ; */
1018
- CHAR_SINGLE_QUOTE: '\'', /* ' */
1019
- CHAR_SPACE: ' ', /* */
1020
- CHAR_TAB: '\t', /* \t */
1021
- CHAR_UNDERSCORE: '_', /* _ */
1022
- CHAR_VERTICAL_LINE: '|', /* | */
1023
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
1024
- };
1025
- return constants$1;
1026
- }
1027
-
1028
- var parse_1$1;
1029
- var hasRequiredParse$1;
1030
-
1031
- function requireParse$1 () {
1032
- if (hasRequiredParse$1) return parse_1$1;
1033
- hasRequiredParse$1 = 1;
1034
-
1035
- const stringify = requireStringify();
1036
-
1037
- /**
1038
- * Constants
1039
- */
1040
-
1041
- const {
1042
- MAX_LENGTH,
1043
- CHAR_BACKSLASH, /* \ */
1044
- CHAR_BACKTICK, /* ` */
1045
- CHAR_COMMA, /* , */
1046
- CHAR_DOT, /* . */
1047
- CHAR_LEFT_PARENTHESES, /* ( */
1048
- CHAR_RIGHT_PARENTHESES, /* ) */
1049
- CHAR_LEFT_CURLY_BRACE, /* { */
1050
- CHAR_RIGHT_CURLY_BRACE, /* } */
1051
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
1052
- CHAR_RIGHT_SQUARE_BRACKET, /* ] */
1053
- CHAR_DOUBLE_QUOTE, /* " */
1054
- CHAR_SINGLE_QUOTE, /* ' */
1055
- CHAR_NO_BREAK_SPACE,
1056
- CHAR_ZERO_WIDTH_NOBREAK_SPACE
1057
- } = requireConstants$1();
1058
-
1059
- /**
1060
- * parse
1061
- */
1062
-
1063
- const parse = (input, options = {}) => {
1064
- if (typeof input !== 'string') {
1065
- throw new TypeError('Expected a string');
1066
- }
1067
-
1068
- let opts = options || {};
1069
- let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1070
- if (input.length > max) {
1071
- throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
1072
- }
1073
-
1074
- let ast = { type: 'root', input, nodes: [] };
1075
- let stack = [ast];
1076
- let block = ast;
1077
- let prev = ast;
1078
- let brackets = 0;
1079
- let length = input.length;
1080
- let index = 0;
1081
- let depth = 0;
1082
- let value;
1083
-
1084
- /**
1085
- * Helpers
1086
- */
1087
-
1088
- const advance = () => input[index++];
1089
- const push = node => {
1090
- if (node.type === 'text' && prev.type === 'dot') {
1091
- prev.type = 'text';
1092
- }
1093
-
1094
- if (prev && prev.type === 'text' && node.type === 'text') {
1095
- prev.value += node.value;
1096
- return;
1097
- }
1098
-
1099
- block.nodes.push(node);
1100
- node.parent = block;
1101
- node.prev = prev;
1102
- prev = node;
1103
- return node;
1104
- };
1105
-
1106
- push({ type: 'bos' });
1107
-
1108
- while (index < length) {
1109
- block = stack[stack.length - 1];
1110
- value = advance();
1111
-
1112
- /**
1113
- * Invalid chars
1114
- */
1115
-
1116
- if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
1117
- continue;
1118
- }
1119
-
1120
- /**
1121
- * Escaped chars
1122
- */
1123
-
1124
- if (value === CHAR_BACKSLASH) {
1125
- push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
1126
- continue;
1127
- }
1128
-
1129
- /**
1130
- * Right square bracket (literal): ']'
1131
- */
1132
-
1133
- if (value === CHAR_RIGHT_SQUARE_BRACKET) {
1134
- push({ type: 'text', value: '\\' + value });
1135
- continue;
1136
- }
1137
-
1138
- /**
1139
- * Left square bracket: '['
1140
- */
1141
-
1142
- if (value === CHAR_LEFT_SQUARE_BRACKET) {
1143
- brackets++;
1144
- let next;
1145
-
1146
- while (index < length && (next = advance())) {
1147
- value += next;
1148
-
1149
- if (next === CHAR_LEFT_SQUARE_BRACKET) {
1150
- brackets++;
1151
- continue;
1152
- }
1153
-
1154
- if (next === CHAR_BACKSLASH) {
1155
- value += advance();
1156
- continue;
1157
- }
1158
-
1159
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1160
- brackets--;
1161
-
1162
- if (brackets === 0) {
1163
- break;
1164
- }
1165
- }
1166
- }
1167
-
1168
- push({ type: 'text', value });
1169
- continue;
1170
- }
1171
-
1172
- /**
1173
- * Parentheses
1174
- */
1175
-
1176
- if (value === CHAR_LEFT_PARENTHESES) {
1177
- block = push({ type: 'paren', nodes: [] });
1178
- stack.push(block);
1179
- push({ type: 'text', value });
1180
- continue;
1181
- }
1182
-
1183
- if (value === CHAR_RIGHT_PARENTHESES) {
1184
- if (block.type !== 'paren') {
1185
- push({ type: 'text', value });
1186
- continue;
1187
- }
1188
- block = stack.pop();
1189
- push({ type: 'text', value });
1190
- block = stack[stack.length - 1];
1191
- continue;
1192
- }
1193
-
1194
- /**
1195
- * Quotes: '|"|`
1196
- */
1197
-
1198
- if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
1199
- let open = value;
1200
- let next;
1201
-
1202
- if (options.keepQuotes !== true) {
1203
- value = '';
1204
- }
1205
-
1206
- while (index < length && (next = advance())) {
1207
- if (next === CHAR_BACKSLASH) {
1208
- value += next + advance();
1209
- continue;
1210
- }
1211
-
1212
- if (next === open) {
1213
- if (options.keepQuotes === true) value += next;
1214
- break;
1215
- }
1216
-
1217
- value += next;
1218
- }
1219
-
1220
- push({ type: 'text', value });
1221
- continue;
1222
- }
1223
-
1224
- /**
1225
- * Left curly brace: '{'
1226
- */
1227
-
1228
- if (value === CHAR_LEFT_CURLY_BRACE) {
1229
- depth++;
1230
-
1231
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
1232
- let brace = {
1233
- type: 'brace',
1234
- open: true,
1235
- close: false,
1236
- dollar,
1237
- depth,
1238
- commas: 0,
1239
- ranges: 0,
1240
- nodes: []
1241
- };
1242
-
1243
- block = push(brace);
1244
- stack.push(block);
1245
- push({ type: 'open', value });
1246
- continue;
1247
- }
1248
-
1249
- /**
1250
- * Right curly brace: '}'
1251
- */
1252
-
1253
- if (value === CHAR_RIGHT_CURLY_BRACE) {
1254
- if (block.type !== 'brace') {
1255
- push({ type: 'text', value });
1256
- continue;
1257
- }
1258
-
1259
- let type = 'close';
1260
- block = stack.pop();
1261
- block.close = true;
1262
-
1263
- push({ type, value });
1264
- depth--;
1265
-
1266
- block = stack[stack.length - 1];
1267
- continue;
1268
- }
1269
-
1270
- /**
1271
- * Comma: ','
1272
- */
1273
-
1274
- if (value === CHAR_COMMA && depth > 0) {
1275
- if (block.ranges > 0) {
1276
- block.ranges = 0;
1277
- let open = block.nodes.shift();
1278
- block.nodes = [open, { type: 'text', value: stringify(block) }];
1279
- }
1280
-
1281
- push({ type: 'comma', value });
1282
- block.commas++;
1283
- continue;
1284
- }
1285
-
1286
- /**
1287
- * Dot: '.'
1288
- */
1289
-
1290
- if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
1291
- let siblings = block.nodes;
1292
-
1293
- if (depth === 0 || siblings.length === 0) {
1294
- push({ type: 'text', value });
1295
- continue;
1296
- }
1297
-
1298
- if (prev.type === 'dot') {
1299
- block.range = [];
1300
- prev.value += value;
1301
- prev.type = 'range';
1302
-
1303
- if (block.nodes.length !== 3 && block.nodes.length !== 5) {
1304
- block.invalid = true;
1305
- block.ranges = 0;
1306
- prev.type = 'text';
1307
- continue;
1308
- }
1309
-
1310
- block.ranges++;
1311
- block.args = [];
1312
- continue;
1313
- }
1314
-
1315
- if (prev.type === 'range') {
1316
- siblings.pop();
1317
-
1318
- let before = siblings[siblings.length - 1];
1319
- before.value += prev.value + value;
1320
- prev = before;
1321
- block.ranges--;
1322
- continue;
1323
- }
1324
-
1325
- push({ type: 'dot', value });
1326
- continue;
1327
- }
1328
-
1329
- /**
1330
- * Text
1331
- */
1332
-
1333
- push({ type: 'text', value });
1334
- }
1335
-
1336
- // Mark imbalanced braces and brackets as invalid
1337
- do {
1338
- block = stack.pop();
1339
-
1340
- if (block.type !== 'root') {
1341
- block.nodes.forEach(node => {
1342
- if (!node.nodes) {
1343
- if (node.type === 'open') node.isOpen = true;
1344
- if (node.type === 'close') node.isClose = true;
1345
- if (!node.nodes) node.type = 'text';
1346
- node.invalid = true;
1347
- }
1348
- });
1349
-
1350
- // get the location of the block on parent.nodes (block's siblings)
1351
- let parent = stack[stack.length - 1];
1352
- let index = parent.nodes.indexOf(block);
1353
- // replace the (invalid) block with it's nodes
1354
- parent.nodes.splice(index, 1, ...block.nodes);
1355
- }
1356
- } while (stack.length > 0);
1357
-
1358
- push({ type: 'eos' });
1359
- return ast;
1360
- };
1361
-
1362
- parse_1$1 = parse;
1363
- return parse_1$1;
1364
- }
1365
-
1366
- var braces_1;
1367
- var hasRequiredBraces;
1368
-
1369
- function requireBraces () {
1370
- if (hasRequiredBraces) return braces_1;
1371
- hasRequiredBraces = 1;
1372
-
1373
- const stringify = requireStringify();
1374
- const compile = requireCompile();
1375
- const expand = requireExpand();
1376
- const parse = requireParse$1();
1377
-
1378
- /**
1379
- * Expand the given pattern or create a regex-compatible string.
1380
- *
1381
- * ```js
1382
- * const braces = require('braces');
1383
- * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
1384
- * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
1385
- * ```
1386
- * @param {String} `str`
1387
- * @param {Object} `options`
1388
- * @return {String}
1389
- * @api public
1390
- */
1391
-
1392
- const braces = (input, options = {}) => {
1393
- let output = [];
1394
-
1395
- if (Array.isArray(input)) {
1396
- for (let pattern of input) {
1397
- let result = braces.create(pattern, options);
1398
- if (Array.isArray(result)) {
1399
- output.push(...result);
1400
- } else {
1401
- output.push(result);
1402
- }
1403
- }
1404
- } else {
1405
- output = [].concat(braces.create(input, options));
1406
- }
1407
-
1408
- if (options && options.expand === true && options.nodupes === true) {
1409
- output = [...new Set(output)];
1410
- }
1411
- return output;
1412
- };
1413
-
1414
- /**
1415
- * Parse the given `str` with the given `options`.
1416
- *
1417
- * ```js
1418
- * // braces.parse(pattern, [, options]);
1419
- * const ast = braces.parse('a/{b,c}/d');
1420
- * console.log(ast);
1421
- * ```
1422
- * @param {String} pattern Brace pattern to parse
1423
- * @param {Object} options
1424
- * @return {Object} Returns an AST
1425
- * @api public
1426
- */
1427
-
1428
- braces.parse = (input, options = {}) => parse(input, options);
1429
-
1430
- /**
1431
- * Creates a braces string from an AST, or an AST node.
1432
- *
1433
- * ```js
1434
- * const braces = require('braces');
1435
- * let ast = braces.parse('foo/{a,b}/bar');
1436
- * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
1437
- * ```
1438
- * @param {String} `input` Brace pattern or AST.
1439
- * @param {Object} `options`
1440
- * @return {Array} Returns an array of expanded values.
1441
- * @api public
1442
- */
1443
-
1444
- braces.stringify = (input, options = {}) => {
1445
- if (typeof input === 'string') {
1446
- return stringify(braces.parse(input, options), options);
1447
- }
1448
- return stringify(input, options);
1449
- };
1450
-
1451
- /**
1452
- * Compiles a brace pattern into a regex-compatible, optimized string.
1453
- * This method is called by the main [braces](#braces) function by default.
1454
- *
1455
- * ```js
1456
- * const braces = require('braces');
1457
- * console.log(braces.compile('a/{b,c}/d'));
1458
- * //=> ['a/(b|c)/d']
1459
- * ```
1460
- * @param {String} `input` Brace pattern or AST.
1461
- * @param {Object} `options`
1462
- * @return {Array} Returns an array of expanded values.
1463
- * @api public
1464
- */
1465
-
1466
- braces.compile = (input, options = {}) => {
1467
- if (typeof input === 'string') {
1468
- input = braces.parse(input, options);
1469
- }
1470
- return compile(input, options);
1471
- };
1472
-
1473
- /**
1474
- * Expands a brace pattern into an array. This method is called by the
1475
- * main [braces](#braces) function when `options.expand` is true. Before
1476
- * using this method it's recommended that you read the [performance notes](#performance))
1477
- * and advantages of using [.compile](#compile) instead.
1478
- *
1479
- * ```js
1480
- * const braces = require('braces');
1481
- * console.log(braces.expand('a/{b,c}/d'));
1482
- * //=> ['a/b/d', 'a/c/d'];
1483
- * ```
1484
- * @param {String} `pattern` Brace pattern
1485
- * @param {Object} `options`
1486
- * @return {Array} Returns an array of expanded values.
1487
- * @api public
1488
- */
1489
-
1490
- braces.expand = (input, options = {}) => {
1491
- if (typeof input === 'string') {
1492
- input = braces.parse(input, options);
1493
- }
1494
-
1495
- let result = expand(input, options);
1496
-
1497
- // filter out empty strings if specified
1498
- if (options.noempty === true) {
1499
- result = result.filter(Boolean);
1500
- }
1501
-
1502
- // filter out duplicates if specified
1503
- if (options.nodupes === true) {
1504
- result = [...new Set(result)];
1505
- }
1506
-
1507
- return result;
1508
- };
1509
-
1510
- /**
1511
- * Processes a brace pattern and returns either an expanded array
1512
- * (if `options.expand` is true), a highly optimized regex-compatible string.
1513
- * This method is called by the main [braces](#braces) function.
1514
- *
1515
- * ```js
1516
- * const braces = require('braces');
1517
- * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
1518
- * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
1519
- * ```
1520
- * @param {String} `pattern` Brace pattern
1521
- * @param {Object} `options`
1522
- * @return {Array} Returns an array of expanded values.
1523
- * @api public
1524
- */
1525
-
1526
- braces.create = (input, options = {}) => {
1527
- if (input === '' || input.length < 3) {
1528
- return [input];
1529
- }
1530
-
1531
- return options.expand !== true
1532
- ? braces.compile(input, options)
1533
- : braces.expand(input, options);
1534
- };
1535
-
1536
- /**
1537
- * Expose "braces"
1538
- */
1539
-
1540
- braces_1 = braces;
1541
- return braces_1;
1542
- }
1543
-
1544
- var utils = {};
1545
-
1546
- var constants;
1547
- var hasRequiredConstants;
1548
-
1549
- function requireConstants () {
1550
- if (hasRequiredConstants) return constants;
1551
- hasRequiredConstants = 1;
1552
-
1553
- const path = require$$0__default$1.default;
1554
- const WIN_SLASH = '\\\\/';
1555
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1556
-
1557
- /**
1558
- * Posix glob regex
1559
- */
1560
-
1561
- const DOT_LITERAL = '\\.';
1562
- const PLUS_LITERAL = '\\+';
1563
- const QMARK_LITERAL = '\\?';
1564
- const SLASH_LITERAL = '\\/';
1565
- const ONE_CHAR = '(?=.)';
1566
- const QMARK = '[^/]';
1567
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1568
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1569
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1570
- const NO_DOT = `(?!${DOT_LITERAL})`;
1571
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1572
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1573
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1574
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1575
- const STAR = `${QMARK}*?`;
1576
-
1577
- const POSIX_CHARS = {
1578
- DOT_LITERAL,
1579
- PLUS_LITERAL,
1580
- QMARK_LITERAL,
1581
- SLASH_LITERAL,
1582
- ONE_CHAR,
1583
- QMARK,
1584
- END_ANCHOR,
1585
- DOTS_SLASH,
1586
- NO_DOT,
1587
- NO_DOTS,
1588
- NO_DOT_SLASH,
1589
- NO_DOTS_SLASH,
1590
- QMARK_NO_DOT,
1591
- STAR,
1592
- START_ANCHOR
1593
- };
1594
-
1595
- /**
1596
- * Windows glob regex
1597
- */
1598
-
1599
- const WINDOWS_CHARS = {
1600
- ...POSIX_CHARS,
1601
-
1602
- SLASH_LITERAL: `[${WIN_SLASH}]`,
1603
- QMARK: WIN_NO_SLASH,
1604
- STAR: `${WIN_NO_SLASH}*?`,
1605
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1606
- NO_DOT: `(?!${DOT_LITERAL})`,
1607
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1608
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1609
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1610
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1611
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1612
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1613
- };
1614
-
1615
- /**
1616
- * POSIX Bracket Regex
1617
- */
1618
-
1619
- const POSIX_REGEX_SOURCE = {
1620
- alnum: 'a-zA-Z0-9',
1621
- alpha: 'a-zA-Z',
1622
- ascii: '\\x00-\\x7F',
1623
- blank: ' \\t',
1624
- cntrl: '\\x00-\\x1F\\x7F',
1625
- digit: '0-9',
1626
- graph: '\\x21-\\x7E',
1627
- lower: 'a-z',
1628
- print: '\\x20-\\x7E ',
1629
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1630
- space: ' \\t\\r\\n\\v\\f',
1631
- upper: 'A-Z',
1632
- word: 'A-Za-z0-9_',
1633
- xdigit: 'A-Fa-f0-9'
1634
- };
1635
-
1636
- constants = {
1637
- MAX_LENGTH: 1024 * 64,
1638
- POSIX_REGEX_SOURCE,
1639
-
1640
- // regular expressions
1641
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1642
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1643
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1644
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1645
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1646
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1647
-
1648
- // Replace globs with equivalent patterns to reduce parsing time.
1649
- REPLACEMENTS: {
1650
- '***': '*',
1651
- '**/**': '**',
1652
- '**/**/**': '**'
1653
- },
1654
-
1655
- // Digits
1656
- CHAR_0: 48, /* 0 */
1657
- CHAR_9: 57, /* 9 */
1658
-
1659
- // Alphabet chars.
1660
- CHAR_UPPERCASE_A: 65, /* A */
1661
- CHAR_LOWERCASE_A: 97, /* a */
1662
- CHAR_UPPERCASE_Z: 90, /* Z */
1663
- CHAR_LOWERCASE_Z: 122, /* z */
1664
-
1665
- CHAR_LEFT_PARENTHESES: 40, /* ( */
1666
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
1667
-
1668
- CHAR_ASTERISK: 42, /* * */
1669
-
1670
- // Non-alphabetic chars.
1671
- CHAR_AMPERSAND: 38, /* & */
1672
- CHAR_AT: 64, /* @ */
1673
- CHAR_BACKWARD_SLASH: 92, /* \ */
1674
- CHAR_CARRIAGE_RETURN: 13, /* \r */
1675
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
1676
- CHAR_COLON: 58, /* : */
1677
- CHAR_COMMA: 44, /* , */
1678
- CHAR_DOT: 46, /* . */
1679
- CHAR_DOUBLE_QUOTE: 34, /* " */
1680
- CHAR_EQUAL: 61, /* = */
1681
- CHAR_EXCLAMATION_MARK: 33, /* ! */
1682
- CHAR_FORM_FEED: 12, /* \f */
1683
- CHAR_FORWARD_SLASH: 47, /* / */
1684
- CHAR_GRAVE_ACCENT: 96, /* ` */
1685
- CHAR_HASH: 35, /* # */
1686
- CHAR_HYPHEN_MINUS: 45, /* - */
1687
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
1688
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
1689
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
1690
- CHAR_LINE_FEED: 10, /* \n */
1691
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
1692
- CHAR_PERCENT: 37, /* % */
1693
- CHAR_PLUS: 43, /* + */
1694
- CHAR_QUESTION_MARK: 63, /* ? */
1695
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
1696
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
1697
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
1698
- CHAR_SEMICOLON: 59, /* ; */
1699
- CHAR_SINGLE_QUOTE: 39, /* ' */
1700
- CHAR_SPACE: 32, /* */
1701
- CHAR_TAB: 9, /* \t */
1702
- CHAR_UNDERSCORE: 95, /* _ */
1703
- CHAR_VERTICAL_LINE: 124, /* | */
1704
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1705
-
1706
- SEP: path.sep,
1707
-
1708
- /**
1709
- * Create EXTGLOB_CHARS
1710
- */
1711
-
1712
- extglobChars(chars) {
1713
- return {
1714
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
1715
- '?': { type: 'qmark', open: '(?:', close: ')?' },
1716
- '+': { type: 'plus', open: '(?:', close: ')+' },
1717
- '*': { type: 'star', open: '(?:', close: ')*' },
1718
- '@': { type: 'at', open: '(?:', close: ')' }
1719
- };
1720
- },
1721
-
1722
- /**
1723
- * Create GLOB_CHARS
1724
- */
1725
-
1726
- globChars(win32) {
1727
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
1728
- }
1729
- };
1730
- return constants;
1731
- }
1732
-
1733
- var hasRequiredUtils;
1734
-
1735
- function requireUtils () {
1736
- if (hasRequiredUtils) return utils;
1737
- hasRequiredUtils = 1;
1738
- (function (exports) {
1739
-
1740
- const path = require$$0__default$1.default;
1741
- const win32 = process.platform === 'win32';
1742
- const {
1743
- REGEX_BACKSLASH,
1744
- REGEX_REMOVE_BACKSLASH,
1745
- REGEX_SPECIAL_CHARS,
1746
- REGEX_SPECIAL_CHARS_GLOBAL
1747
- } = requireConstants();
1748
-
1749
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1750
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
1751
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
1752
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1753
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
1754
-
1755
- exports.removeBackslashes = str => {
1756
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
1757
- return match === '\\' ? '' : match;
1758
- });
1759
- };
1760
-
1761
- exports.supportsLookbehinds = () => {
1762
- const segs = process.version.slice(1).split('.').map(Number);
1763
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
1764
- return true;
1765
- }
1766
- return false;
1767
- };
1768
-
1769
- exports.isWindows = options => {
1770
- if (options && typeof options.windows === 'boolean') {
1771
- return options.windows;
1772
- }
1773
- return win32 === true || path.sep === '\\';
1774
- };
1775
-
1776
- exports.escapeLast = (input, char, lastIdx) => {
1777
- const idx = input.lastIndexOf(char, lastIdx);
1778
- if (idx === -1) return input;
1779
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
1780
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1781
- };
1782
-
1783
- exports.removePrefix = (input, state = {}) => {
1784
- let output = input;
1785
- if (output.startsWith('./')) {
1786
- output = output.slice(2);
1787
- state.prefix = './';
1788
- }
1789
- return output;
1790
- };
1791
-
1792
- exports.wrapOutput = (input, state = {}, options = {}) => {
1793
- const prepend = options.contains ? '' : '^';
1794
- const append = options.contains ? '' : '$';
1795
-
1796
- let output = `${prepend}(?:${input})${append}`;
1797
- if (state.negated === true) {
1798
- output = `(?:^(?!${output}).*$)`;
1799
- }
1800
- return output;
1801
- };
1802
- } (utils));
1803
- return utils;
1804
- }
1805
-
1806
- var scan_1;
1807
- var hasRequiredScan;
1808
-
1809
- function requireScan () {
1810
- if (hasRequiredScan) return scan_1;
1811
- hasRequiredScan = 1;
1812
-
1813
- const utils = requireUtils();
1814
- const {
1815
- CHAR_ASTERISK, /* * */
1816
- CHAR_AT, /* @ */
1817
- CHAR_BACKWARD_SLASH, /* \ */
1818
- CHAR_COMMA, /* , */
1819
- CHAR_DOT, /* . */
1820
- CHAR_EXCLAMATION_MARK, /* ! */
1821
- CHAR_FORWARD_SLASH, /* / */
1822
- CHAR_LEFT_CURLY_BRACE, /* { */
1823
- CHAR_LEFT_PARENTHESES, /* ( */
1824
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
1825
- CHAR_PLUS, /* + */
1826
- CHAR_QUESTION_MARK, /* ? */
1827
- CHAR_RIGHT_CURLY_BRACE, /* } */
1828
- CHAR_RIGHT_PARENTHESES, /* ) */
1829
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
1830
- } = requireConstants();
1831
-
1832
- const isPathSeparator = code => {
1833
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1834
- };
1835
-
1836
- const depth = token => {
1837
- if (token.isPrefix !== true) {
1838
- token.depth = token.isGlobstar ? Infinity : 1;
1839
- }
1840
- };
1841
-
1842
- /**
1843
- * Quickly scans a glob pattern and returns an object with a handful of
1844
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
1845
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
1846
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
1847
- *
1848
- * ```js
1849
- * const pm = require('picomatch');
1850
- * console.log(pm.scan('foo/bar/*.js'));
1851
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
1852
- * ```
1853
- * @param {String} `str`
1854
- * @param {Object} `options`
1855
- * @return {Object} Returns an object with tokens and regex source string.
1856
- * @api public
1857
- */
1858
-
1859
- const scan = (input, options) => {
1860
- const opts = options || {};
1861
-
1862
- const length = input.length - 1;
1863
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
1864
- const slashes = [];
1865
- const tokens = [];
1866
- const parts = [];
1867
-
1868
- let str = input;
1869
- let index = -1;
1870
- let start = 0;
1871
- let lastIndex = 0;
1872
- let isBrace = false;
1873
- let isBracket = false;
1874
- let isGlob = false;
1875
- let isExtglob = false;
1876
- let isGlobstar = false;
1877
- let braceEscaped = false;
1878
- let backslashes = false;
1879
- let negated = false;
1880
- let negatedExtglob = false;
1881
- let finished = false;
1882
- let braces = 0;
1883
- let prev;
1884
- let code;
1885
- let token = { value: '', depth: 0, isGlob: false };
1886
-
1887
- const eos = () => index >= length;
1888
- const peek = () => str.charCodeAt(index + 1);
1889
- const advance = () => {
1890
- prev = code;
1891
- return str.charCodeAt(++index);
1892
- };
1893
-
1894
- while (index < length) {
1895
- code = advance();
1896
- let next;
1897
-
1898
- if (code === CHAR_BACKWARD_SLASH) {
1899
- backslashes = token.backslashes = true;
1900
- code = advance();
1901
-
1902
- if (code === CHAR_LEFT_CURLY_BRACE) {
1903
- braceEscaped = true;
1904
- }
1905
- continue;
1906
- }
1907
-
1908
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1909
- braces++;
1910
-
1911
- while (eos() !== true && (code = advance())) {
1912
- if (code === CHAR_BACKWARD_SLASH) {
1913
- backslashes = token.backslashes = true;
1914
- advance();
1915
- continue;
1916
- }
1917
-
1918
- if (code === CHAR_LEFT_CURLY_BRACE) {
1919
- braces++;
1920
- continue;
1921
- }
1922
-
1923
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1924
- isBrace = token.isBrace = true;
1925
- isGlob = token.isGlob = true;
1926
- finished = true;
1927
-
1928
- if (scanToEnd === true) {
1929
- continue;
1930
- }
1931
-
1932
- break;
1933
- }
1934
-
1935
- if (braceEscaped !== true && code === CHAR_COMMA) {
1936
- isBrace = token.isBrace = true;
1937
- isGlob = token.isGlob = true;
1938
- finished = true;
1939
-
1940
- if (scanToEnd === true) {
1941
- continue;
1942
- }
1943
-
1944
- break;
1945
- }
1946
-
1947
- if (code === CHAR_RIGHT_CURLY_BRACE) {
1948
- braces--;
1949
-
1950
- if (braces === 0) {
1951
- braceEscaped = false;
1952
- isBrace = token.isBrace = true;
1953
- finished = true;
1954
- break;
1955
- }
1956
- }
1957
- }
1958
-
1959
- if (scanToEnd === true) {
1960
- continue;
1961
- }
1962
-
1963
- break;
1964
- }
1965
-
1966
- if (code === CHAR_FORWARD_SLASH) {
1967
- slashes.push(index);
1968
- tokens.push(token);
1969
- token = { value: '', depth: 0, isGlob: false };
1970
-
1971
- if (finished === true) continue;
1972
- if (prev === CHAR_DOT && index === (start + 1)) {
1973
- start += 2;
1974
- continue;
1975
- }
1976
-
1977
- lastIndex = index + 1;
1978
- continue;
1979
- }
1980
-
1981
- if (opts.noext !== true) {
1982
- const isExtglobChar = code === CHAR_PLUS
1983
- || code === CHAR_AT
1984
- || code === CHAR_ASTERISK
1985
- || code === CHAR_QUESTION_MARK
1986
- || code === CHAR_EXCLAMATION_MARK;
1987
-
1988
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1989
- isGlob = token.isGlob = true;
1990
- isExtglob = token.isExtglob = true;
1991
- finished = true;
1992
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
1993
- negatedExtglob = true;
1994
- }
1995
-
1996
- if (scanToEnd === true) {
1997
- while (eos() !== true && (code = advance())) {
1998
- if (code === CHAR_BACKWARD_SLASH) {
1999
- backslashes = token.backslashes = true;
2000
- code = advance();
2001
- continue;
2002
- }
2003
-
2004
- if (code === CHAR_RIGHT_PARENTHESES) {
2005
- isGlob = token.isGlob = true;
2006
- finished = true;
2007
- break;
2008
- }
2009
- }
2010
- continue;
2011
- }
2012
- break;
2013
- }
2014
- }
2015
-
2016
- if (code === CHAR_ASTERISK) {
2017
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
2018
- isGlob = token.isGlob = true;
2019
- finished = true;
2020
-
2021
- if (scanToEnd === true) {
2022
- continue;
2023
- }
2024
- break;
2025
- }
2026
-
2027
- if (code === CHAR_QUESTION_MARK) {
2028
- isGlob = token.isGlob = true;
2029
- finished = true;
2030
-
2031
- if (scanToEnd === true) {
2032
- continue;
2033
- }
2034
- break;
2035
- }
2036
-
2037
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
2038
- while (eos() !== true && (next = advance())) {
2039
- if (next === CHAR_BACKWARD_SLASH) {
2040
- backslashes = token.backslashes = true;
2041
- advance();
2042
- continue;
2043
- }
2044
-
2045
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
2046
- isBracket = token.isBracket = true;
2047
- isGlob = token.isGlob = true;
2048
- finished = true;
2049
- break;
2050
- }
2051
- }
2052
-
2053
- if (scanToEnd === true) {
2054
- continue;
2055
- }
2056
-
2057
- break;
2058
- }
2059
-
2060
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
2061
- negated = token.negated = true;
2062
- start++;
2063
- continue;
2064
- }
2065
-
2066
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
2067
- isGlob = token.isGlob = true;
2068
-
2069
- if (scanToEnd === true) {
2070
- while (eos() !== true && (code = advance())) {
2071
- if (code === CHAR_LEFT_PARENTHESES) {
2072
- backslashes = token.backslashes = true;
2073
- code = advance();
2074
- continue;
2075
- }
2076
-
2077
- if (code === CHAR_RIGHT_PARENTHESES) {
2078
- finished = true;
2079
- break;
2080
- }
2081
- }
2082
- continue;
2083
- }
2084
- break;
2085
- }
2086
-
2087
- if (isGlob === true) {
2088
- finished = true;
2089
-
2090
- if (scanToEnd === true) {
2091
- continue;
2092
- }
2093
-
2094
- break;
2095
- }
2096
- }
2097
-
2098
- if (opts.noext === true) {
2099
- isExtglob = false;
2100
- isGlob = false;
2101
- }
2102
-
2103
- let base = str;
2104
- let prefix = '';
2105
- let glob = '';
2106
-
2107
- if (start > 0) {
2108
- prefix = str.slice(0, start);
2109
- str = str.slice(start);
2110
- lastIndex -= start;
2111
- }
2112
-
2113
- if (base && isGlob === true && lastIndex > 0) {
2114
- base = str.slice(0, lastIndex);
2115
- glob = str.slice(lastIndex);
2116
- } else if (isGlob === true) {
2117
- base = '';
2118
- glob = str;
2119
- } else {
2120
- base = str;
2121
- }
2122
-
2123
- if (base && base !== '' && base !== '/' && base !== str) {
2124
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
2125
- base = base.slice(0, -1);
2126
- }
2127
- }
2128
-
2129
- if (opts.unescape === true) {
2130
- if (glob) glob = utils.removeBackslashes(glob);
2131
-
2132
- if (base && backslashes === true) {
2133
- base = utils.removeBackslashes(base);
2134
- }
2135
- }
2136
-
2137
- const state = {
2138
- prefix,
2139
- input,
2140
- start,
2141
- base,
2142
- glob,
2143
- isBrace,
2144
- isBracket,
2145
- isGlob,
2146
- isExtglob,
2147
- isGlobstar,
2148
- negated,
2149
- negatedExtglob
2150
- };
2151
-
2152
- if (opts.tokens === true) {
2153
- state.maxDepth = 0;
2154
- if (!isPathSeparator(code)) {
2155
- tokens.push(token);
2156
- }
2157
- state.tokens = tokens;
2158
- }
2159
-
2160
- if (opts.parts === true || opts.tokens === true) {
2161
- let prevIndex;
2162
-
2163
- for (let idx = 0; idx < slashes.length; idx++) {
2164
- const n = prevIndex ? prevIndex + 1 : start;
2165
- const i = slashes[idx];
2166
- const value = input.slice(n, i);
2167
- if (opts.tokens) {
2168
- if (idx === 0 && start !== 0) {
2169
- tokens[idx].isPrefix = true;
2170
- tokens[idx].value = prefix;
2171
- } else {
2172
- tokens[idx].value = value;
2173
- }
2174
- depth(tokens[idx]);
2175
- state.maxDepth += tokens[idx].depth;
2176
- }
2177
- if (idx !== 0 || value !== '') {
2178
- parts.push(value);
2179
- }
2180
- prevIndex = i;
2181
- }
2182
-
2183
- if (prevIndex && prevIndex + 1 < input.length) {
2184
- const value = input.slice(prevIndex + 1);
2185
- parts.push(value);
2186
-
2187
- if (opts.tokens) {
2188
- tokens[tokens.length - 1].value = value;
2189
- depth(tokens[tokens.length - 1]);
2190
- state.maxDepth += tokens[tokens.length - 1].depth;
2191
- }
2192
- }
2193
-
2194
- state.slashes = slashes;
2195
- state.parts = parts;
2196
- }
2197
-
2198
- return state;
2199
- };
2200
-
2201
- scan_1 = scan;
2202
- return scan_1;
2203
- }
2204
-
2205
- var parse_1;
2206
- var hasRequiredParse;
2207
-
2208
- function requireParse () {
2209
- if (hasRequiredParse) return parse_1;
2210
- hasRequiredParse = 1;
2211
-
2212
- const constants = requireConstants();
2213
- const utils = requireUtils();
2214
-
2215
- /**
2216
- * Constants
2217
- */
2218
-
2219
- const {
2220
- MAX_LENGTH,
2221
- POSIX_REGEX_SOURCE,
2222
- REGEX_NON_SPECIAL_CHARS,
2223
- REGEX_SPECIAL_CHARS_BACKREF,
2224
- REPLACEMENTS
2225
- } = constants;
2226
-
2227
- /**
2228
- * Helpers
2229
- */
2230
-
2231
- const expandRange = (args, options) => {
2232
- if (typeof options.expandRange === 'function') {
2233
- return options.expandRange(...args, options);
2234
- }
2235
-
2236
- args.sort();
2237
- const value = `[${args.join('-')}]`;
2238
-
2239
- try {
2240
- /* eslint-disable-next-line no-new */
2241
- new RegExp(value);
2242
- } catch (ex) {
2243
- return args.map(v => utils.escapeRegex(v)).join('..');
2244
- }
2245
-
2246
- return value;
2247
- };
2248
-
2249
- /**
2250
- * Create the message for a syntax error
2251
- */
2252
-
2253
- const syntaxError = (type, char) => {
2254
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
2255
- };
2256
-
2257
- /**
2258
- * Parse the given input string.
2259
- * @param {String} input
2260
- * @param {Object} options
2261
- * @return {Object}
2262
- */
2263
-
2264
- const parse = (input, options) => {
2265
- if (typeof input !== 'string') {
2266
- throw new TypeError('Expected a string');
2267
- }
2268
-
2269
- input = REPLACEMENTS[input] || input;
2270
-
2271
- const opts = { ...options };
2272
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2273
-
2274
- let len = input.length;
2275
- if (len > max) {
2276
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2277
- }
2278
-
2279
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
2280
- const tokens = [bos];
2281
-
2282
- const capture = opts.capture ? '' : '?:';
2283
- const win32 = utils.isWindows(options);
2284
-
2285
- // create constants based on platform, for windows or posix
2286
- const PLATFORM_CHARS = constants.globChars(win32);
2287
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
2288
-
2289
- const {
2290
- DOT_LITERAL,
2291
- PLUS_LITERAL,
2292
- SLASH_LITERAL,
2293
- ONE_CHAR,
2294
- DOTS_SLASH,
2295
- NO_DOT,
2296
- NO_DOT_SLASH,
2297
- NO_DOTS_SLASH,
2298
- QMARK,
2299
- QMARK_NO_DOT,
2300
- STAR,
2301
- START_ANCHOR
2302
- } = PLATFORM_CHARS;
2303
-
2304
- const globstar = opts => {
2305
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2306
- };
2307
-
2308
- const nodot = opts.dot ? '' : NO_DOT;
2309
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
2310
- let star = opts.bash === true ? globstar(opts) : STAR;
2311
-
2312
- if (opts.capture) {
2313
- star = `(${star})`;
2314
- }
2315
-
2316
- // minimatch options support
2317
- if (typeof opts.noext === 'boolean') {
2318
- opts.noextglob = opts.noext;
2319
- }
2320
-
2321
- const state = {
2322
- input,
2323
- index: -1,
2324
- start: 0,
2325
- dot: opts.dot === true,
2326
- consumed: '',
2327
- output: '',
2328
- prefix: '',
2329
- backtrack: false,
2330
- negated: false,
2331
- brackets: 0,
2332
- braces: 0,
2333
- parens: 0,
2334
- quotes: 0,
2335
- globstar: false,
2336
- tokens
2337
- };
2338
-
2339
- input = utils.removePrefix(input, state);
2340
- len = input.length;
2341
-
2342
- const extglobs = [];
2343
- const braces = [];
2344
- const stack = [];
2345
- let prev = bos;
2346
- let value;
2347
-
2348
- /**
2349
- * Tokenizing helpers
2350
- */
2351
-
2352
- const eos = () => state.index === len - 1;
2353
- const peek = state.peek = (n = 1) => input[state.index + n];
2354
- const advance = state.advance = () => input[++state.index] || '';
2355
- const remaining = () => input.slice(state.index + 1);
2356
- const consume = (value = '', num = 0) => {
2357
- state.consumed += value;
2358
- state.index += num;
2359
- };
2360
-
2361
- const append = token => {
2362
- state.output += token.output != null ? token.output : token.value;
2363
- consume(token.value);
2364
- };
2365
-
2366
- const negate = () => {
2367
- let count = 1;
2368
-
2369
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2370
- advance();
2371
- state.start++;
2372
- count++;
2373
- }
2374
-
2375
- if (count % 2 === 0) {
2376
- return false;
2377
- }
2378
-
2379
- state.negated = true;
2380
- state.start++;
2381
- return true;
2382
- };
2383
-
2384
- const increment = type => {
2385
- state[type]++;
2386
- stack.push(type);
2387
- };
2388
-
2389
- const decrement = type => {
2390
- state[type]--;
2391
- stack.pop();
2392
- };
2393
-
2394
- /**
2395
- * Push tokens onto the tokens array. This helper speeds up
2396
- * tokenizing by 1) helping us avoid backtracking as much as possible,
2397
- * and 2) helping us avoid creating extra tokens when consecutive
2398
- * characters are plain text. This improves performance and simplifies
2399
- * lookbehinds.
2400
- */
2401
-
2402
- const push = tok => {
2403
- if (prev.type === 'globstar') {
2404
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2405
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2406
-
2407
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2408
- state.output = state.output.slice(0, -prev.output.length);
2409
- prev.type = 'star';
2410
- prev.value = '*';
2411
- prev.output = star;
2412
- state.output += prev.output;
2413
- }
2414
- }
2415
-
2416
- if (extglobs.length && tok.type !== 'paren') {
2417
- extglobs[extglobs.length - 1].inner += tok.value;
2418
- }
2419
-
2420
- if (tok.value || tok.output) append(tok);
2421
- if (prev && prev.type === 'text' && tok.type === 'text') {
2422
- prev.value += tok.value;
2423
- prev.output = (prev.output || '') + tok.value;
2424
- return;
2425
- }
2426
-
2427
- tok.prev = prev;
2428
- tokens.push(tok);
2429
- prev = tok;
2430
- };
2431
-
2432
- const extglobOpen = (type, value) => {
2433
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2434
-
2435
- token.prev = prev;
2436
- token.parens = state.parens;
2437
- token.output = state.output;
2438
- const output = (opts.capture ? '(' : '') + token.open;
2439
-
2440
- increment('parens');
2441
- push({ type, value, output: state.output ? '' : ONE_CHAR });
2442
- push({ type: 'paren', extglob: true, value: advance(), output });
2443
- extglobs.push(token);
2444
- };
2445
-
2446
- const extglobClose = token => {
2447
- let output = token.close + (opts.capture ? ')' : '');
2448
- let rest;
2449
-
2450
- if (token.type === 'negate') {
2451
- let extglobStar = star;
2452
-
2453
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2454
- extglobStar = globstar(opts);
2455
- }
2456
-
2457
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2458
- output = token.close = `)$))${extglobStar}`;
2459
- }
2460
-
2461
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2462
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2463
- // In this case, we need to parse the string and use it in the output of the original pattern.
2464
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2465
- //
2466
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2467
- const expression = parse(rest, { ...options, fastpaths: false }).output;
2468
-
2469
- output = token.close = `)${expression})${extglobStar})`;
2470
- }
2471
-
2472
- if (token.prev.type === 'bos') {
2473
- state.negatedExtglob = true;
2474
- }
2475
- }
2476
-
2477
- push({ type: 'paren', extglob: true, value, output });
2478
- decrement('parens');
2479
- };
2480
-
2481
- /**
2482
- * Fast paths
2483
- */
2484
-
2485
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2486
- let backslashes = false;
2487
-
2488
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2489
- if (first === '\\') {
2490
- backslashes = true;
2491
- return m;
2492
- }
2493
-
2494
- if (first === '?') {
2495
- if (esc) {
2496
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2497
- }
2498
- if (index === 0) {
2499
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2500
- }
2501
- return QMARK.repeat(chars.length);
2502
- }
2503
-
2504
- if (first === '.') {
2505
- return DOT_LITERAL.repeat(chars.length);
2506
- }
2507
-
2508
- if (first === '*') {
2509
- if (esc) {
2510
- return esc + first + (rest ? star : '');
2511
- }
2512
- return star;
2513
- }
2514
- return esc ? m : `\\${m}`;
2515
- });
2516
-
2517
- if (backslashes === true) {
2518
- if (opts.unescape === true) {
2519
- output = output.replace(/\\/g, '');
2520
- } else {
2521
- output = output.replace(/\\+/g, m => {
2522
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2523
- });
2524
- }
2525
- }
2526
-
2527
- if (output === input && opts.contains === true) {
2528
- state.output = input;
2529
- return state;
2530
- }
2531
-
2532
- state.output = utils.wrapOutput(output, state, options);
2533
- return state;
2534
- }
2535
-
2536
- /**
2537
- * Tokenize input until we reach end-of-string
2538
- */
2539
-
2540
- while (!eos()) {
2541
- value = advance();
2542
-
2543
- if (value === '\u0000') {
2544
- continue;
2545
- }
2546
-
2547
- /**
2548
- * Escaped characters
2549
- */
2550
-
2551
- if (value === '\\') {
2552
- const next = peek();
2553
-
2554
- if (next === '/' && opts.bash !== true) {
2555
- continue;
2556
- }
2557
-
2558
- if (next === '.' || next === ';') {
2559
- continue;
2560
- }
2561
-
2562
- if (!next) {
2563
- value += '\\';
2564
- push({ type: 'text', value });
2565
- continue;
2566
- }
2567
-
2568
- // collapse slashes to reduce potential for exploits
2569
- const match = /^\\+/.exec(remaining());
2570
- let slashes = 0;
2571
-
2572
- if (match && match[0].length > 2) {
2573
- slashes = match[0].length;
2574
- state.index += slashes;
2575
- if (slashes % 2 !== 0) {
2576
- value += '\\';
2577
- }
2578
- }
2579
-
2580
- if (opts.unescape === true) {
2581
- value = advance();
2582
- } else {
2583
- value += advance();
2584
- }
2585
-
2586
- if (state.brackets === 0) {
2587
- push({ type: 'text', value });
2588
- continue;
2589
- }
2590
- }
2591
-
2592
- /**
2593
- * If we're inside a regex character class, continue
2594
- * until we reach the closing bracket.
2595
- */
2596
-
2597
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2598
- if (opts.posix !== false && value === ':') {
2599
- const inner = prev.value.slice(1);
2600
- if (inner.includes('[')) {
2601
- prev.posix = true;
2602
-
2603
- if (inner.includes(':')) {
2604
- const idx = prev.value.lastIndexOf('[');
2605
- const pre = prev.value.slice(0, idx);
2606
- const rest = prev.value.slice(idx + 2);
2607
- const posix = POSIX_REGEX_SOURCE[rest];
2608
- if (posix) {
2609
- prev.value = pre + posix;
2610
- state.backtrack = true;
2611
- advance();
2612
-
2613
- if (!bos.output && tokens.indexOf(prev) === 1) {
2614
- bos.output = ONE_CHAR;
2615
- }
2616
- continue;
2617
- }
2618
- }
2619
- }
2620
- }
2621
-
2622
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2623
- value = `\\${value}`;
2624
- }
2625
-
2626
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2627
- value = `\\${value}`;
2628
- }
2629
-
2630
- if (opts.posix === true && value === '!' && prev.value === '[') {
2631
- value = '^';
2632
- }
2633
-
2634
- prev.value += value;
2635
- append({ value });
2636
- continue;
2637
- }
2638
-
2639
- /**
2640
- * If we're inside a quoted string, continue
2641
- * until we reach the closing double quote.
2642
- */
2643
-
2644
- if (state.quotes === 1 && value !== '"') {
2645
- value = utils.escapeRegex(value);
2646
- prev.value += value;
2647
- append({ value });
2648
- continue;
2649
- }
2650
-
2651
- /**
2652
- * Double quotes
2653
- */
2654
-
2655
- if (value === '"') {
2656
- state.quotes = state.quotes === 1 ? 0 : 1;
2657
- if (opts.keepQuotes === true) {
2658
- push({ type: 'text', value });
2659
- }
2660
- continue;
2661
- }
2662
-
2663
- /**
2664
- * Parentheses
2665
- */
2666
-
2667
- if (value === '(') {
2668
- increment('parens');
2669
- push({ type: 'paren', value });
2670
- continue;
2671
- }
2672
-
2673
- if (value === ')') {
2674
- if (state.parens === 0 && opts.strictBrackets === true) {
2675
- throw new SyntaxError(syntaxError('opening', '('));
2676
- }
2677
-
2678
- const extglob = extglobs[extglobs.length - 1];
2679
- if (extglob && state.parens === extglob.parens + 1) {
2680
- extglobClose(extglobs.pop());
2681
- continue;
2682
- }
2683
-
2684
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
2685
- decrement('parens');
2686
- continue;
2687
- }
2688
-
2689
- /**
2690
- * Square brackets
2691
- */
2692
-
2693
- if (value === '[') {
2694
- if (opts.nobracket === true || !remaining().includes(']')) {
2695
- if (opts.nobracket !== true && opts.strictBrackets === true) {
2696
- throw new SyntaxError(syntaxError('closing', ']'));
2697
- }
2698
-
2699
- value = `\\${value}`;
2700
- } else {
2701
- increment('brackets');
2702
- }
2703
-
2704
- push({ type: 'bracket', value });
2705
- continue;
2706
- }
2707
-
2708
- if (value === ']') {
2709
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
2710
- push({ type: 'text', value, output: `\\${value}` });
2711
- continue;
2712
- }
2713
-
2714
- if (state.brackets === 0) {
2715
- if (opts.strictBrackets === true) {
2716
- throw new SyntaxError(syntaxError('opening', '['));
2717
- }
2718
-
2719
- push({ type: 'text', value, output: `\\${value}` });
2720
- continue;
2721
- }
2722
-
2723
- decrement('brackets');
2724
-
2725
- const prevValue = prev.value.slice(1);
2726
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
2727
- value = `/${value}`;
2728
- }
2729
-
2730
- prev.value += value;
2731
- append({ value });
2732
-
2733
- // when literal brackets are explicitly disabled
2734
- // assume we should match with a regex character class
2735
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
2736
- continue;
2737
- }
2738
-
2739
- const escaped = utils.escapeRegex(prev.value);
2740
- state.output = state.output.slice(0, -prev.value.length);
2741
-
2742
- // when literal brackets are explicitly enabled
2743
- // assume we should escape the brackets to match literal characters
2744
- if (opts.literalBrackets === true) {
2745
- state.output += escaped;
2746
- prev.value = escaped;
2747
- continue;
2748
- }
2749
-
2750
- // when the user specifies nothing, try to match both
2751
- prev.value = `(${capture}${escaped}|${prev.value})`;
2752
- state.output += prev.value;
2753
- continue;
2754
- }
2755
-
2756
- /**
2757
- * Braces
2758
- */
2759
-
2760
- if (value === '{' && opts.nobrace !== true) {
2761
- increment('braces');
2762
-
2763
- const open = {
2764
- type: 'brace',
2765
- value,
2766
- output: '(',
2767
- outputIndex: state.output.length,
2768
- tokensIndex: state.tokens.length
2769
- };
2770
-
2771
- braces.push(open);
2772
- push(open);
2773
- continue;
2774
- }
2775
-
2776
- if (value === '}') {
2777
- const brace = braces[braces.length - 1];
2778
-
2779
- if (opts.nobrace === true || !brace) {
2780
- push({ type: 'text', value, output: value });
2781
- continue;
2782
- }
2783
-
2784
- let output = ')';
2785
-
2786
- if (brace.dots === true) {
2787
- const arr = tokens.slice();
2788
- const range = [];
2789
-
2790
- for (let i = arr.length - 1; i >= 0; i--) {
2791
- tokens.pop();
2792
- if (arr[i].type === 'brace') {
2793
- break;
2794
- }
2795
- if (arr[i].type !== 'dots') {
2796
- range.unshift(arr[i].value);
2797
- }
2798
- }
2799
-
2800
- output = expandRange(range, opts);
2801
- state.backtrack = true;
2802
- }
2803
-
2804
- if (brace.comma !== true && brace.dots !== true) {
2805
- const out = state.output.slice(0, brace.outputIndex);
2806
- const toks = state.tokens.slice(brace.tokensIndex);
2807
- brace.value = brace.output = '\\{';
2808
- value = output = '\\}';
2809
- state.output = out;
2810
- for (const t of toks) {
2811
- state.output += (t.output || t.value);
2812
- }
2813
- }
2814
-
2815
- push({ type: 'brace', value, output });
2816
- decrement('braces');
2817
- braces.pop();
2818
- continue;
2819
- }
2820
-
2821
- /**
2822
- * Pipes
2823
- */
2824
-
2825
- if (value === '|') {
2826
- if (extglobs.length > 0) {
2827
- extglobs[extglobs.length - 1].conditions++;
2828
- }
2829
- push({ type: 'text', value });
2830
- continue;
2831
- }
2832
-
2833
- /**
2834
- * Commas
2835
- */
2836
-
2837
- if (value === ',') {
2838
- let output = value;
2839
-
2840
- const brace = braces[braces.length - 1];
2841
- if (brace && stack[stack.length - 1] === 'braces') {
2842
- brace.comma = true;
2843
- output = '|';
2844
- }
2845
-
2846
- push({ type: 'comma', value, output });
2847
- continue;
2848
- }
2849
-
2850
- /**
2851
- * Slashes
2852
- */
2853
-
2854
- if (value === '/') {
2855
- // if the beginning of the glob is "./", advance the start
2856
- // to the current index, and don't add the "./" characters
2857
- // to the state. This greatly simplifies lookbehinds when
2858
- // checking for BOS characters like "!" and "." (not "./")
2859
- if (prev.type === 'dot' && state.index === state.start + 1) {
2860
- state.start = state.index + 1;
2861
- state.consumed = '';
2862
- state.output = '';
2863
- tokens.pop();
2864
- prev = bos; // reset "prev" to the first token
2865
- continue;
2866
- }
2867
-
2868
- push({ type: 'slash', value, output: SLASH_LITERAL });
2869
- continue;
2870
- }
2871
-
2872
- /**
2873
- * Dots
2874
- */
2875
-
2876
- if (value === '.') {
2877
- if (state.braces > 0 && prev.type === 'dot') {
2878
- if (prev.value === '.') prev.output = DOT_LITERAL;
2879
- const brace = braces[braces.length - 1];
2880
- prev.type = 'dots';
2881
- prev.output += value;
2882
- prev.value += value;
2883
- brace.dots = true;
2884
- continue;
2885
- }
2886
-
2887
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
2888
- push({ type: 'text', value, output: DOT_LITERAL });
2889
- continue;
2890
- }
2891
-
2892
- push({ type: 'dot', value, output: DOT_LITERAL });
2893
- continue;
2894
- }
2895
-
2896
- /**
2897
- * Question marks
2898
- */
2899
-
2900
- if (value === '?') {
2901
- const isGroup = prev && prev.value === '(';
2902
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2903
- extglobOpen('qmark', value);
2904
- continue;
2905
- }
2906
-
2907
- if (prev && prev.type === 'paren') {
2908
- const next = peek();
2909
- let output = value;
2910
-
2911
- if (next === '<' && !utils.supportsLookbehinds()) {
2912
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
2913
- }
2914
-
2915
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2916
- output = `\\${value}`;
2917
- }
2918
-
2919
- push({ type: 'text', value, output });
2920
- continue;
2921
- }
2922
-
2923
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2924
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
2925
- continue;
2926
- }
2927
-
2928
- push({ type: 'qmark', value, output: QMARK });
2929
- continue;
2930
- }
2931
-
2932
- /**
2933
- * Exclamation
2934
- */
2935
-
2936
- if (value === '!') {
2937
- if (opts.noextglob !== true && peek() === '(') {
2938
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2939
- extglobOpen('negate', value);
2940
- continue;
2941
- }
2942
- }
2943
-
2944
- if (opts.nonegate !== true && state.index === 0) {
2945
- negate();
2946
- continue;
2947
- }
2948
- }
2949
-
2950
- /**
2951
- * Plus
2952
- */
2953
-
2954
- if (value === '+') {
2955
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2956
- extglobOpen('plus', value);
2957
- continue;
2958
- }
2959
-
2960
- if ((prev && prev.value === '(') || opts.regex === false) {
2961
- push({ type: 'plus', value, output: PLUS_LITERAL });
2962
- continue;
2963
- }
2964
-
2965
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2966
- push({ type: 'plus', value });
2967
- continue;
2968
- }
2969
-
2970
- push({ type: 'plus', value: PLUS_LITERAL });
2971
- continue;
2972
- }
2973
-
2974
- /**
2975
- * Plain text
2976
- */
2977
-
2978
- if (value === '@') {
2979
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2980
- push({ type: 'at', extglob: true, value, output: '' });
2981
- continue;
2982
- }
2983
-
2984
- push({ type: 'text', value });
2985
- continue;
2986
- }
2987
-
2988
- /**
2989
- * Plain text
2990
- */
2991
-
2992
- if (value !== '*') {
2993
- if (value === '$' || value === '^') {
2994
- value = `\\${value}`;
2995
- }
2996
-
2997
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2998
- if (match) {
2999
- value += match[0];
3000
- state.index += match[0].length;
3001
- }
3002
-
3003
- push({ type: 'text', value });
3004
- continue;
3005
- }
3006
-
3007
- /**
3008
- * Stars
3009
- */
3010
-
3011
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
3012
- prev.type = 'star';
3013
- prev.star = true;
3014
- prev.value += value;
3015
- prev.output = star;
3016
- state.backtrack = true;
3017
- state.globstar = true;
3018
- consume(value);
3019
- continue;
3020
- }
3021
-
3022
- let rest = remaining();
3023
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
3024
- extglobOpen('star', value);
3025
- continue;
3026
- }
3027
-
3028
- if (prev.type === 'star') {
3029
- if (opts.noglobstar === true) {
3030
- consume(value);
3031
- continue;
3032
- }
3033
-
3034
- const prior = prev.prev;
3035
- const before = prior.prev;
3036
- const isStart = prior.type === 'slash' || prior.type === 'bos';
3037
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
3038
-
3039
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
3040
- push({ type: 'star', value, output: '' });
3041
- continue;
3042
- }
3043
-
3044
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
3045
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
3046
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
3047
- push({ type: 'star', value, output: '' });
3048
- continue;
3049
- }
3050
-
3051
- // strip consecutive `/**/`
3052
- while (rest.slice(0, 3) === '/**') {
3053
- const after = input[state.index + 4];
3054
- if (after && after !== '/') {
3055
- break;
3056
- }
3057
- rest = rest.slice(3);
3058
- consume('/**', 3);
3059
- }
3060
-
3061
- if (prior.type === 'bos' && eos()) {
3062
- prev.type = 'globstar';
3063
- prev.value += value;
3064
- prev.output = globstar(opts);
3065
- state.output = prev.output;
3066
- state.globstar = true;
3067
- consume(value);
3068
- continue;
3069
- }
3070
-
3071
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
3072
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
3073
- prior.output = `(?:${prior.output}`;
3074
-
3075
- prev.type = 'globstar';
3076
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
3077
- prev.value += value;
3078
- state.globstar = true;
3079
- state.output += prior.output + prev.output;
3080
- consume(value);
3081
- continue;
3082
- }
3083
-
3084
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
3085
- const end = rest[1] !== void 0 ? '|$' : '';
3086
-
3087
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
3088
- prior.output = `(?:${prior.output}`;
3089
-
3090
- prev.type = 'globstar';
3091
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
3092
- prev.value += value;
3093
-
3094
- state.output += prior.output + prev.output;
3095
- state.globstar = true;
3096
-
3097
- consume(value + advance());
3098
-
3099
- push({ type: 'slash', value: '/', output: '' });
3100
- continue;
3101
- }
3102
-
3103
- if (prior.type === 'bos' && rest[0] === '/') {
3104
- prev.type = 'globstar';
3105
- prev.value += value;
3106
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
3107
- state.output = prev.output;
3108
- state.globstar = true;
3109
- consume(value + advance());
3110
- push({ type: 'slash', value: '/', output: '' });
3111
- continue;
3112
- }
3113
-
3114
- // remove single star from output
3115
- state.output = state.output.slice(0, -prev.output.length);
3116
-
3117
- // reset previous token to globstar
3118
- prev.type = 'globstar';
3119
- prev.output = globstar(opts);
3120
- prev.value += value;
3121
-
3122
- // reset output with globstar
3123
- state.output += prev.output;
3124
- state.globstar = true;
3125
- consume(value);
3126
- continue;
3127
- }
3128
-
3129
- const token = { type: 'star', value, output: star };
3130
-
3131
- if (opts.bash === true) {
3132
- token.output = '.*?';
3133
- if (prev.type === 'bos' || prev.type === 'slash') {
3134
- token.output = nodot + token.output;
3135
- }
3136
- push(token);
3137
- continue;
3138
- }
3139
-
3140
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
3141
- token.output = value;
3142
- push(token);
3143
- continue;
3144
- }
3145
-
3146
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
3147
- if (prev.type === 'dot') {
3148
- state.output += NO_DOT_SLASH;
3149
- prev.output += NO_DOT_SLASH;
3150
-
3151
- } else if (opts.dot === true) {
3152
- state.output += NO_DOTS_SLASH;
3153
- prev.output += NO_DOTS_SLASH;
3154
-
3155
- } else {
3156
- state.output += nodot;
3157
- prev.output += nodot;
3158
- }
3159
-
3160
- if (peek() !== '*') {
3161
- state.output += ONE_CHAR;
3162
- prev.output += ONE_CHAR;
3163
- }
3164
- }
3165
-
3166
- push(token);
3167
- }
3168
-
3169
- while (state.brackets > 0) {
3170
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
3171
- state.output = utils.escapeLast(state.output, '[');
3172
- decrement('brackets');
3173
- }
3174
-
3175
- while (state.parens > 0) {
3176
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
3177
- state.output = utils.escapeLast(state.output, '(');
3178
- decrement('parens');
3179
- }
3180
-
3181
- while (state.braces > 0) {
3182
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
3183
- state.output = utils.escapeLast(state.output, '{');
3184
- decrement('braces');
3185
- }
3186
-
3187
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
3188
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
3189
- }
3190
-
3191
- // rebuild the output if we had to backtrack at any point
3192
- if (state.backtrack === true) {
3193
- state.output = '';
3194
-
3195
- for (const token of state.tokens) {
3196
- state.output += token.output != null ? token.output : token.value;
3197
-
3198
- if (token.suffix) {
3199
- state.output += token.suffix;
3200
- }
3201
- }
3202
- }
3203
-
3204
- return state;
3205
- };
3206
-
3207
- /**
3208
- * Fast paths for creating regular expressions for common glob patterns.
3209
- * This can significantly speed up processing and has very little downside
3210
- * impact when none of the fast paths match.
3211
- */
3212
-
3213
- parse.fastpaths = (input, options) => {
3214
- const opts = { ...options };
3215
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
3216
- const len = input.length;
3217
- if (len > max) {
3218
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
3219
- }
3220
-
3221
- input = REPLACEMENTS[input] || input;
3222
- const win32 = utils.isWindows(options);
3223
-
3224
- // create constants based on platform, for windows or posix
3225
- const {
3226
- DOT_LITERAL,
3227
- SLASH_LITERAL,
3228
- ONE_CHAR,
3229
- DOTS_SLASH,
3230
- NO_DOT,
3231
- NO_DOTS,
3232
- NO_DOTS_SLASH,
3233
- STAR,
3234
- START_ANCHOR
3235
- } = constants.globChars(win32);
3236
-
3237
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
3238
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
3239
- const capture = opts.capture ? '' : '?:';
3240
- const state = { negated: false, prefix: '' };
3241
- let star = opts.bash === true ? '.*?' : STAR;
3242
-
3243
- if (opts.capture) {
3244
- star = `(${star})`;
3245
- }
3246
-
3247
- const globstar = opts => {
3248
- if (opts.noglobstar === true) return star;
3249
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
3250
- };
3251
-
3252
- const create = str => {
3253
- switch (str) {
3254
- case '*':
3255
- return `${nodot}${ONE_CHAR}${star}`;
3256
-
3257
- case '.*':
3258
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
3259
-
3260
- case '*.*':
3261
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3262
-
3263
- case '*/*':
3264
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
3265
-
3266
- case '**':
3267
- return nodot + globstar(opts);
3268
-
3269
- case '**/*':
3270
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
3271
-
3272
- case '**/*.*':
3273
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3274
-
3275
- case '**/.*':
3276
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
3277
-
3278
- default: {
3279
- const match = /^(.*?)\.(\w+)$/.exec(str);
3280
- if (!match) return;
3281
-
3282
- const source = create(match[1]);
3283
- if (!source) return;
3284
-
3285
- return source + DOT_LITERAL + match[2];
3286
- }
3287
- }
3288
- };
3289
-
3290
- const output = utils.removePrefix(input, state);
3291
- let source = create(output);
3292
-
3293
- if (source && opts.strictSlashes !== true) {
3294
- source += `${SLASH_LITERAL}?`;
3295
- }
3296
-
3297
- return source;
3298
- };
3299
-
3300
- parse_1 = parse;
3301
- return parse_1;
3302
- }
3303
-
3304
- var picomatch_1;
3305
- var hasRequiredPicomatch$1;
3306
-
3307
- function requirePicomatch$1 () {
3308
- if (hasRequiredPicomatch$1) return picomatch_1;
3309
- hasRequiredPicomatch$1 = 1;
3310
-
3311
- const path = require$$0__default$1.default;
3312
- const scan = requireScan();
3313
- const parse = requireParse();
3314
- const utils = requireUtils();
3315
- const constants = requireConstants();
3316
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3317
-
3318
- /**
3319
- * Creates a matcher function from one or more glob patterns. The
3320
- * returned function takes a string to match as its first argument,
3321
- * and returns true if the string is a match. The returned matcher
3322
- * function also takes a boolean as the second argument that, when true,
3323
- * returns an object with additional information.
3324
- *
3325
- * ```js
3326
- * const picomatch = require('picomatch');
3327
- * // picomatch(glob[, options]);
3328
- *
3329
- * const isMatch = picomatch('*.!(*a)');
3330
- * console.log(isMatch('a.a')); //=> false
3331
- * console.log(isMatch('a.b')); //=> true
3332
- * ```
3333
- * @name picomatch
3334
- * @param {String|Array} `globs` One or more glob patterns.
3335
- * @param {Object=} `options`
3336
- * @return {Function=} Returns a matcher function.
3337
- * @api public
3338
- */
3339
-
3340
- const picomatch = (glob, options, returnState = false) => {
3341
- if (Array.isArray(glob)) {
3342
- const fns = glob.map(input => picomatch(input, options, returnState));
3343
- const arrayMatcher = str => {
3344
- for (const isMatch of fns) {
3345
- const state = isMatch(str);
3346
- if (state) return state;
3347
- }
3348
- return false;
3349
- };
3350
- return arrayMatcher;
3351
- }
3352
-
3353
- const isState = isObject(glob) && glob.tokens && glob.input;
3354
-
3355
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
3356
- throw new TypeError('Expected pattern to be a non-empty string');
3357
- }
3358
-
3359
- const opts = options || {};
3360
- const posix = utils.isWindows(options);
3361
- const regex = isState
3362
- ? picomatch.compileRe(glob, options)
3363
- : picomatch.makeRe(glob, options, false, true);
3364
-
3365
- const state = regex.state;
3366
- delete regex.state;
3367
-
3368
- let isIgnored = () => false;
3369
- if (opts.ignore) {
3370
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3371
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
3372
- }
3373
-
3374
- const matcher = (input, returnObject = false) => {
3375
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
3376
- const result = { glob, state, regex, posix, input, output, match, isMatch };
3377
-
3378
- if (typeof opts.onResult === 'function') {
3379
- opts.onResult(result);
3380
- }
3381
-
3382
- if (isMatch === false) {
3383
- result.isMatch = false;
3384
- return returnObject ? result : false;
3385
- }
3386
-
3387
- if (isIgnored(input)) {
3388
- if (typeof opts.onIgnore === 'function') {
3389
- opts.onIgnore(result);
3390
- }
3391
- result.isMatch = false;
3392
- return returnObject ? result : false;
3393
- }
3394
-
3395
- if (typeof opts.onMatch === 'function') {
3396
- opts.onMatch(result);
3397
- }
3398
- return returnObject ? result : true;
3399
- };
3400
-
3401
- if (returnState) {
3402
- matcher.state = state;
3403
- }
3404
-
3405
- return matcher;
3406
- };
3407
-
3408
- /**
3409
- * Test `input` with the given `regex`. This is used by the main
3410
- * `picomatch()` function to test the input string.
3411
- *
3412
- * ```js
3413
- * const picomatch = require('picomatch');
3414
- * // picomatch.test(input, regex[, options]);
3415
- *
3416
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3417
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3418
- * ```
3419
- * @param {String} `input` String to test.
3420
- * @param {RegExp} `regex`
3421
- * @return {Object} Returns an object with matching info.
3422
- * @api public
3423
- */
3424
-
3425
- picomatch.test = (input, regex, options, { glob, posix } = {}) => {
3426
- if (typeof input !== 'string') {
3427
- throw new TypeError('Expected input to be a string');
3428
- }
3429
-
3430
- if (input === '') {
3431
- return { isMatch: false, output: '' };
3432
- }
3433
-
3434
- const opts = options || {};
3435
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
3436
- let match = input === glob;
3437
- let output = (match && format) ? format(input) : input;
3438
-
3439
- if (match === false) {
3440
- output = format ? format(input) : input;
3441
- match = output === glob;
3442
- }
3443
-
3444
- if (match === false || opts.capture === true) {
3445
- if (opts.matchBase === true || opts.basename === true) {
3446
- match = picomatch.matchBase(input, regex, options, posix);
3447
- } else {
3448
- match = regex.exec(output);
3449
- }
3450
- }
3451
-
3452
- return { isMatch: Boolean(match), match, output };
3453
- };
3454
-
3455
- /**
3456
- * Match the basename of a filepath.
3457
- *
3458
- * ```js
3459
- * const picomatch = require('picomatch');
3460
- * // picomatch.matchBase(input, glob[, options]);
3461
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3462
- * ```
3463
- * @param {String} `input` String to test.
3464
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3465
- * @return {Boolean}
3466
- * @api public
3467
- */
3468
-
3469
- picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3470
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3471
- return regex.test(path.basename(input));
3472
- };
3473
-
3474
- /**
3475
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
3476
- *
3477
- * ```js
3478
- * const picomatch = require('picomatch');
3479
- * // picomatch.isMatch(string, patterns[, options]);
3480
- *
3481
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3482
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3483
- * ```
3484
- * @param {String|Array} str The string to test.
3485
- * @param {String|Array} patterns One or more glob patterns to use for matching.
3486
- * @param {Object} [options] See available [options](#options).
3487
- * @return {Boolean} Returns true if any patterns match `str`
3488
- * @api public
3489
- */
3490
-
3491
- picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3492
-
3493
- /**
3494
- * Parse a glob pattern to create the source string for a regular
3495
- * expression.
3496
- *
3497
- * ```js
3498
- * const picomatch = require('picomatch');
3499
- * const result = picomatch.parse(pattern[, options]);
3500
- * ```
3501
- * @param {String} `pattern`
3502
- * @param {Object} `options`
3503
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3504
- * @api public
3505
- */
3506
-
3507
- picomatch.parse = (pattern, options) => {
3508
- if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
3509
- return parse(pattern, { ...options, fastpaths: false });
3510
- };
3511
-
3512
- /**
3513
- * Scan a glob pattern to separate the pattern into segments.
3514
- *
3515
- * ```js
3516
- * const picomatch = require('picomatch');
3517
- * // picomatch.scan(input[, options]);
3518
- *
3519
- * const result = picomatch.scan('!./foo/*.js');
3520
- * console.log(result);
3521
- * { prefix: '!./',
3522
- * input: '!./foo/*.js',
3523
- * start: 3,
3524
- * base: 'foo',
3525
- * glob: '*.js',
3526
- * isBrace: false,
3527
- * isBracket: false,
3528
- * isGlob: true,
3529
- * isExtglob: false,
3530
- * isGlobstar: false,
3531
- * negated: true }
3532
- * ```
3533
- * @param {String} `input` Glob pattern to scan.
3534
- * @param {Object} `options`
3535
- * @return {Object} Returns an object with
3536
- * @api public
3537
- */
3538
-
3539
- picomatch.scan = (input, options) => scan(input, options);
3540
-
3541
- /**
3542
- * Compile a regular expression from the `state` object returned by the
3543
- * [parse()](#parse) method.
3544
- *
3545
- * @param {Object} `state`
3546
- * @param {Object} `options`
3547
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3548
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3549
- * @return {RegExp}
3550
- * @api public
3551
- */
3552
-
3553
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
3554
- if (returnOutput === true) {
3555
- return state.output;
3556
- }
3557
-
3558
- const opts = options || {};
3559
- const prepend = opts.contains ? '' : '^';
3560
- const append = opts.contains ? '' : '$';
3561
-
3562
- let source = `${prepend}(?:${state.output})${append}`;
3563
- if (state && state.negated === true) {
3564
- source = `^(?!${source}).*$`;
3565
- }
3566
-
3567
- const regex = picomatch.toRegex(source, options);
3568
- if (returnState === true) {
3569
- regex.state = state;
3570
- }
3571
-
3572
- return regex;
3573
- };
3574
-
3575
- /**
3576
- * Create a regular expression from a parsed glob pattern.
3577
- *
3578
- * ```js
3579
- * const picomatch = require('picomatch');
3580
- * const state = picomatch.parse('*.js');
3581
- * // picomatch.compileRe(state[, options]);
3582
- *
3583
- * console.log(picomatch.compileRe(state));
3584
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3585
- * ```
3586
- * @param {String} `state` The object returned from the `.parse` method.
3587
- * @param {Object} `options`
3588
- * @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.
3589
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3590
- * @return {RegExp} Returns a regex created from the given pattern.
3591
- * @api public
3592
- */
3593
-
3594
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3595
- if (!input || typeof input !== 'string') {
3596
- throw new TypeError('Expected a non-empty string');
3597
- }
3598
-
3599
- let parsed = { negated: false, fastpaths: true };
3600
-
3601
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3602
- parsed.output = parse.fastpaths(input, options);
3603
- }
3604
-
3605
- if (!parsed.output) {
3606
- parsed = parse(input, options);
3607
- }
3608
-
3609
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
3610
- };
3611
-
3612
- /**
3613
- * Create a regular expression from the given regex source string.
3614
- *
3615
- * ```js
3616
- * const picomatch = require('picomatch');
3617
- * // picomatch.toRegex(source[, options]);
3618
- *
3619
- * const { output } = picomatch.parse('*.js');
3620
- * console.log(picomatch.toRegex(output));
3621
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3622
- * ```
3623
- * @param {String} `source` Regular expression source string.
3624
- * @param {Object} `options`
3625
- * @return {RegExp}
3626
- * @api public
3627
- */
3628
-
3629
- picomatch.toRegex = (source, options) => {
3630
- try {
3631
- const opts = options || {};
3632
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3633
- } catch (err) {
3634
- if (options && options.debug === true) throw err;
3635
- return /$^/;
3636
- }
3637
- };
3638
-
3639
- /**
3640
- * Picomatch constants.
3641
- * @return {Object}
3642
- */
3643
-
3644
- picomatch.constants = constants;
3645
-
3646
- /**
3647
- * Expose "picomatch"
3648
- */
3649
-
3650
- picomatch_1 = picomatch;
3651
- return picomatch_1;
3652
- }
3653
-
3654
- var picomatch;
3655
- var hasRequiredPicomatch;
3656
-
3657
- function requirePicomatch () {
3658
- if (hasRequiredPicomatch) return picomatch;
3659
- hasRequiredPicomatch = 1;
3660
-
3661
- picomatch = requirePicomatch$1();
3662
- return picomatch;
3663
- }
3664
-
3665
- var micromatch_1;
3666
- var hasRequiredMicromatch;
3667
-
3668
- function requireMicromatch () {
3669
- if (hasRequiredMicromatch) return micromatch_1;
3670
- hasRequiredMicromatch = 1;
3671
-
3672
- const util = require$$0__default.default;
3673
- const braces = requireBraces();
3674
- const picomatch = requirePicomatch();
3675
- const utils = requireUtils();
3676
- const isEmptyString = val => val === '' || val === './';
3677
-
3678
- /**
3679
- * Returns an array of strings that match one or more glob patterns.
3680
- *
3681
- * ```js
3682
- * const mm = require('micromatch');
3683
- * // mm(list, patterns[, options]);
3684
- *
3685
- * console.log(mm(['a.js', 'a.txt'], ['*.js']));
3686
- * //=> [ 'a.js' ]
3687
- * ```
3688
- * @param {String|Array<string>} `list` List of strings to match.
3689
- * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
3690
- * @param {Object} `options` See available [options](#options)
3691
- * @return {Array} Returns an array of matches
3692
- * @summary false
3693
- * @api public
3694
- */
3695
-
3696
- const micromatch = (list, patterns, options) => {
3697
- patterns = [].concat(patterns);
3698
- list = [].concat(list);
3699
-
3700
- let omit = new Set();
3701
- let keep = new Set();
3702
- let items = new Set();
3703
- let negatives = 0;
3704
-
3705
- let onResult = state => {
3706
- items.add(state.output);
3707
- if (options && options.onResult) {
3708
- options.onResult(state);
3709
- }
3710
- };
3711
-
3712
- for (let i = 0; i < patterns.length; i++) {
3713
- let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
3714
- let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
3715
- if (negated) negatives++;
3716
-
3717
- for (let item of list) {
3718
- let matched = isMatch(item, true);
3719
-
3720
- let match = negated ? !matched.isMatch : matched.isMatch;
3721
- if (!match) continue;
3722
-
3723
- if (negated) {
3724
- omit.add(matched.output);
3725
- } else {
3726
- omit.delete(matched.output);
3727
- keep.add(matched.output);
3728
- }
3729
- }
3730
- }
3731
-
3732
- let result = negatives === patterns.length ? [...items] : [...keep];
3733
- let matches = result.filter(item => !omit.has(item));
3734
-
3735
- if (options && matches.length === 0) {
3736
- if (options.failglob === true) {
3737
- throw new Error(`No matches found for "${patterns.join(', ')}"`);
3738
- }
3739
-
3740
- if (options.nonull === true || options.nullglob === true) {
3741
- return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
3742
- }
3743
- }
3744
-
3745
- return matches;
3746
- };
3747
-
3748
- /**
3749
- * Backwards compatibility
3750
- */
3751
-
3752
- micromatch.match = micromatch;
3753
-
3754
- /**
3755
- * Returns a matcher function from the given glob `pattern` and `options`.
3756
- * The returned function takes a string to match as its only argument and returns
3757
- * true if the string is a match.
3758
- *
3759
- * ```js
3760
- * const mm = require('micromatch');
3761
- * // mm.matcher(pattern[, options]);
3762
- *
3763
- * const isMatch = mm.matcher('*.!(*a)');
3764
- * console.log(isMatch('a.a')); //=> false
3765
- * console.log(isMatch('a.b')); //=> true
3766
- * ```
3767
- * @param {String} `pattern` Glob pattern
3768
- * @param {Object} `options`
3769
- * @return {Function} Returns a matcher function.
3770
- * @api public
3771
- */
3772
-
3773
- micromatch.matcher = (pattern, options) => picomatch(pattern, options);
3774
-
3775
- /**
3776
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
3777
- *
3778
- * ```js
3779
- * const mm = require('micromatch');
3780
- * // mm.isMatch(string, patterns[, options]);
3781
- *
3782
- * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
3783
- * console.log(mm.isMatch('a.a', 'b.*')); //=> false
3784
- * ```
3785
- * @param {String} `str` The string to test.
3786
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3787
- * @param {Object} `[options]` See available [options](#options).
3788
- * @return {Boolean} Returns true if any patterns match `str`
3789
- * @api public
3790
- */
3791
-
3792
- micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3793
-
3794
- /**
3795
- * Backwards compatibility
3796
- */
3797
-
3798
- micromatch.any = micromatch.isMatch;
3799
-
3800
- /**
3801
- * Returns a list of strings that _**do not match any**_ of the given `patterns`.
3802
- *
3803
- * ```js
3804
- * const mm = require('micromatch');
3805
- * // mm.not(list, patterns[, options]);
3806
- *
3807
- * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
3808
- * //=> ['b.b', 'c.c']
3809
- * ```
3810
- * @param {Array} `list` Array of strings to match.
3811
- * @param {String|Array} `patterns` One or more glob pattern to use for matching.
3812
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3813
- * @return {Array} Returns an array of strings that **do not match** the given patterns.
3814
- * @api public
3815
- */
3816
-
3817
- micromatch.not = (list, patterns, options = {}) => {
3818
- patterns = [].concat(patterns).map(String);
3819
- let result = new Set();
3820
- let items = [];
3821
-
3822
- let onResult = state => {
3823
- if (options.onResult) options.onResult(state);
3824
- items.push(state.output);
3825
- };
3826
-
3827
- let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
3828
-
3829
- for (let item of items) {
3830
- if (!matches.has(item)) {
3831
- result.add(item);
3832
- }
3833
- }
3834
- return [...result];
3835
- };
3836
-
3837
- /**
3838
- * Returns true if the given `string` contains the given pattern. Similar
3839
- * to [.isMatch](#isMatch) but the pattern can match any part of the string.
3840
- *
3841
- * ```js
3842
- * var mm = require('micromatch');
3843
- * // mm.contains(string, pattern[, options]);
3844
- *
3845
- * console.log(mm.contains('aa/bb/cc', '*b'));
3846
- * //=> true
3847
- * console.log(mm.contains('aa/bb/cc', '*d'));
3848
- * //=> false
3849
- * ```
3850
- * @param {String} `str` The string to match.
3851
- * @param {String|Array} `patterns` Glob pattern to use for matching.
3852
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3853
- * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
3854
- * @api public
3855
- */
3856
-
3857
- micromatch.contains = (str, pattern, options) => {
3858
- if (typeof str !== 'string') {
3859
- throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
3860
- }
3861
-
3862
- if (Array.isArray(pattern)) {
3863
- return pattern.some(p => micromatch.contains(str, p, options));
3864
- }
3865
-
3866
- if (typeof pattern === 'string') {
3867
- if (isEmptyString(str) || isEmptyString(pattern)) {
3868
- return false;
3869
- }
3870
-
3871
- if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
3872
- return true;
3873
- }
3874
- }
3875
-
3876
- return micromatch.isMatch(str, pattern, { ...options, contains: true });
3877
- };
3878
-
3879
- /**
3880
- * Filter the keys of the given object with the given `glob` pattern
3881
- * and `options`. Does not attempt to match nested keys. If you need this feature,
3882
- * use [glob-object][] instead.
3883
- *
3884
- * ```js
3885
- * const mm = require('micromatch');
3886
- * // mm.matchKeys(object, patterns[, options]);
3887
- *
3888
- * const obj = { aa: 'a', ab: 'b', ac: 'c' };
3889
- * console.log(mm.matchKeys(obj, '*b'));
3890
- * //=> { ab: 'b' }
3891
- * ```
3892
- * @param {Object} `object` The object with keys to filter.
3893
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3894
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3895
- * @return {Object} Returns an object with only keys that match the given patterns.
3896
- * @api public
3897
- */
3898
-
3899
- micromatch.matchKeys = (obj, patterns, options) => {
3900
- if (!utils.isObject(obj)) {
3901
- throw new TypeError('Expected the first argument to be an object');
3902
- }
3903
- let keys = micromatch(Object.keys(obj), patterns, options);
3904
- let res = {};
3905
- for (let key of keys) res[key] = obj[key];
3906
- return res;
3907
- };
3908
-
3909
- /**
3910
- * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
3911
- *
3912
- * ```js
3913
- * const mm = require('micromatch');
3914
- * // mm.some(list, patterns[, options]);
3915
- *
3916
- * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
3917
- * // true
3918
- * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
3919
- * // false
3920
- * ```
3921
- * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
3922
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3923
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3924
- * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
3925
- * @api public
3926
- */
3927
-
3928
- micromatch.some = (list, patterns, options) => {
3929
- let items = [].concat(list);
3930
-
3931
- for (let pattern of [].concat(patterns)) {
3932
- let isMatch = picomatch(String(pattern), options);
3933
- if (items.some(item => isMatch(item))) {
3934
- return true;
3935
- }
3936
- }
3937
- return false;
3938
- };
3939
-
3940
- /**
3941
- * Returns true if every string in the given `list` matches
3942
- * any of the given glob `patterns`.
3943
- *
3944
- * ```js
3945
- * const mm = require('micromatch');
3946
- * // mm.every(list, patterns[, options]);
3947
- *
3948
- * console.log(mm.every('foo.js', ['foo.js']));
3949
- * // true
3950
- * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
3951
- * // true
3952
- * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
3953
- * // false
3954
- * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
3955
- * // false
3956
- * ```
3957
- * @param {String|Array} `list` The string or array of strings to test.
3958
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3959
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3960
- * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
3961
- * @api public
3962
- */
3963
-
3964
- micromatch.every = (list, patterns, options) => {
3965
- let items = [].concat(list);
3966
-
3967
- for (let pattern of [].concat(patterns)) {
3968
- let isMatch = picomatch(String(pattern), options);
3969
- if (!items.every(item => isMatch(item))) {
3970
- return false;
3971
- }
3972
- }
3973
- return true;
3974
- };
3975
-
3976
- /**
3977
- * Returns true if **all** of the given `patterns` match
3978
- * the specified string.
3979
- *
3980
- * ```js
3981
- * const mm = require('micromatch');
3982
- * // mm.all(string, patterns[, options]);
3983
- *
3984
- * console.log(mm.all('foo.js', ['foo.js']));
3985
- * // true
3986
- *
3987
- * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
3988
- * // false
3989
- *
3990
- * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
3991
- * // true
3992
- *
3993
- * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
3994
- * // true
3995
- * ```
3996
- * @param {String|Array} `str` The string to test.
3997
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3998
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
3999
- * @return {Boolean} Returns true if any patterns match `str`
4000
- * @api public
4001
- */
4002
-
4003
- micromatch.all = (str, patterns, options) => {
4004
- if (typeof str !== 'string') {
4005
- throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
4006
- }
4007
-
4008
- return [].concat(patterns).every(p => picomatch(p, options)(str));
4009
- };
4010
-
4011
- /**
4012
- * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
4013
- *
4014
- * ```js
4015
- * const mm = require('micromatch');
4016
- * // mm.capture(pattern, string[, options]);
4017
- *
4018
- * console.log(mm.capture('test/*.js', 'test/foo.js'));
4019
- * //=> ['foo']
4020
- * console.log(mm.capture('test/*.js', 'foo/bar.css'));
4021
- * //=> null
4022
- * ```
4023
- * @param {String} `glob` Glob pattern to use for matching.
4024
- * @param {String} `input` String to match
4025
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4026
- * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
4027
- * @api public
4028
- */
4029
-
4030
- micromatch.capture = (glob, input, options) => {
4031
- let posix = utils.isWindows(options);
4032
- let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
4033
- let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
4034
-
4035
- if (match) {
4036
- return match.slice(1).map(v => v === void 0 ? '' : v);
4037
- }
4038
- };
4039
-
4040
- /**
4041
- * Create a regular expression from the given glob `pattern`.
4042
- *
4043
- * ```js
4044
- * const mm = require('micromatch');
4045
- * // mm.makeRe(pattern[, options]);
4046
- *
4047
- * console.log(mm.makeRe('*.js'));
4048
- * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
4049
- * ```
4050
- * @param {String} `pattern` A glob pattern to convert to regex.
4051
- * @param {Object} `options`
4052
- * @return {RegExp} Returns a regex created from the given pattern.
4053
- * @api public
4054
- */
4055
-
4056
- micromatch.makeRe = (...args) => picomatch.makeRe(...args);
4057
-
4058
- /**
4059
- * Scan a glob pattern to separate the pattern into segments. Used
4060
- * by the [split](#split) method.
4061
- *
4062
- * ```js
4063
- * const mm = require('micromatch');
4064
- * const state = mm.scan(pattern[, options]);
4065
- * ```
4066
- * @param {String} `pattern`
4067
- * @param {Object} `options`
4068
- * @return {Object} Returns an object with
4069
- * @api public
4070
- */
4071
-
4072
- micromatch.scan = (...args) => picomatch.scan(...args);
4073
-
4074
- /**
4075
- * Parse a glob pattern to create the source string for a regular
4076
- * expression.
4077
- *
4078
- * ```js
4079
- * const mm = require('micromatch');
4080
- * const state = mm.parse(pattern[, options]);
4081
- * ```
4082
- * @param {String} `glob`
4083
- * @param {Object} `options`
4084
- * @return {Object} Returns an object with useful properties and output to be used as regex source string.
4085
- * @api public
4086
- */
4087
-
4088
- micromatch.parse = (patterns, options) => {
4089
- let res = [];
4090
- for (let pattern of [].concat(patterns || [])) {
4091
- for (let str of braces(String(pattern), options)) {
4092
- res.push(picomatch.parse(str, options));
4093
- }
4094
- }
4095
- return res;
4096
- };
4097
-
4098
- /**
4099
- * Process the given brace `pattern`.
4100
- *
4101
- * ```js
4102
- * const { braces } = require('micromatch');
4103
- * console.log(braces('foo/{a,b,c}/bar'));
4104
- * //=> [ 'foo/(a|b|c)/bar' ]
4105
- *
4106
- * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
4107
- * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
4108
- * ```
4109
- * @param {String} `pattern` String with brace pattern to process.
4110
- * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
4111
- * @return {Array}
4112
- * @api public
4113
- */
4114
-
4115
- micromatch.braces = (pattern, options) => {
4116
- if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4117
- if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
4118
- return [pattern];
4119
- }
4120
- return braces(pattern, options);
4121
- };
4122
-
4123
- /**
4124
- * Expand braces
4125
- */
4126
-
4127
- micromatch.braceExpand = (pattern, options) => {
4128
- if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4129
- return micromatch.braces(pattern, { ...options, expand: true });
4130
- };
4131
-
4132
- /**
4133
- * Expose micromatch
4134
- */
4135
-
4136
- micromatch_1 = micromatch;
4137
- return micromatch_1;
4138
- }
4139
-
4140
- var micromatchExports = requireMicromatch();
4141
-
4142
20
  const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4143
21
  function getExports({
4144
22
  entrypoints: entrypoints$1,
@@ -4147,17 +25,12 @@ function getExports({
4147
25
  config,
4148
26
  dir,
4149
27
  noFilter,
4150
- isPublish
28
+ withSource,
29
+ withSuffix
4151
30
  }) {
4152
31
  const dirResolve = (...paths) => path.resolve(dir ?? process.cwd(), ...paths);
4153
32
  const dirRelative = (path$1) => path.relative(dir ?? process.cwd(), path$1);
4154
- const {
4155
- build = {},
4156
- publish: {
4157
- withSuffix = false,
4158
- withSource = true
4159
- } = {}
4160
- } = config ?? {};
33
+ const { build = {} } = config ?? {};
4161
34
  const {
4162
35
  crossModuleConvertor = true
4163
36
  } = build;
@@ -4167,7 +40,7 @@ function getExports({
4167
40
  const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
4168
41
  if (entries) {
4169
42
  Object.entries(resolvedEntrypoints).forEach(([key]) => {
4170
- if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
43
+ if (!entries.some((e) => micromatch.isMatch(key, e, { matchBase: true }))) {
4171
44
  delete resolvedEntrypoints[key];
4172
45
  }
4173
46
  });
@@ -4196,8 +69,8 @@ function getExports({
4196
69
  filteredResolvedEntrypoints,
4197
70
  entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
4198
71
  outdir: jsOutdir,
4199
- withSuffix: isPublish ? withSuffix : void 0,
4200
- withSource: isPublish ? withSource : void 0,
72
+ withSource,
73
+ withSuffix,
4201
74
  withConditional: {
4202
75
  ...crossModuleWithConditional
4203
76
  }
@@ -4210,14 +83,13 @@ function getRoot() {
4210
83
  if (root)
4211
84
  return root;
4212
85
  const rootOption = commander.program.getOptionValue("root");
4213
- root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
86
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
4214
87
  return root;
4215
88
  }
4216
89
 
4217
90
  let type = "";
4218
91
  try {
4219
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4220
- require$1.resolve("@pnpm/filter-workspace-packages");
92
+ require.resolve("@pnpm/filter-workspace-packages");
4221
93
  type = "pnpm";
4222
94
  } catch {
4223
95
  }
@@ -4250,10 +122,9 @@ function getWD() {
4250
122
  return { wd, notWorkspace };
4251
123
  }
4252
124
 
4253
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4254
125
  function packageIsExist(name) {
4255
126
  try {
4256
- require$1.resolve(name);
127
+ require.resolve(name);
4257
128
  return true;
4258
129
  } catch (e) {
4259
130
  return false;
@@ -4278,19 +149,19 @@ function getConfigPath(root, dir) {
4278
149
  const isSupportTsLoader = !!tsRegisterName;
4279
150
  function configWithExtIsExist(ext) {
4280
151
  const filenames = [
4281
- path__default.default.resolve(process.cwd(), `${configName}.${ext}`),
4282
- path__default.default.resolve(process.cwd(), `.${configName}.${ext}`),
4283
- path__default.default.resolve(root, `${configName}.${ext}`),
4284
- path__default.default.resolve(root, `.${configName}.${ext}`)
152
+ path.resolve(process.cwd(), `${configName}.${ext}`),
153
+ path.resolve(process.cwd(), `.${configName}.${ext}`),
154
+ path.resolve(root, `${configName}.${ext}`),
155
+ path.resolve(root, `.${configName}.${ext}`)
4285
156
  ];
4286
157
  if (dir) {
4287
158
  filenames.unshift(...[
4288
- path__default.default.resolve(dir, `${configName}.${ext}`),
4289
- path__default.default.resolve(dir, `.${configName}.${ext}`)
159
+ path.resolve(dir, `${configName}.${ext}`),
160
+ path.resolve(dir, `.${configName}.${ext}`)
4290
161
  ]);
4291
162
  }
4292
163
  for (const filename of filenames) {
4293
- if (fs__default.default.existsSync(filename) && fs__default.default.lstatSync(filename).isFile()) {
164
+ if (fs.existsSync(filename) && fs.lstatSync(filename).isFile()) {
4294
165
  return filename;
4295
166
  }
4296
167
  }
@@ -4302,7 +173,7 @@ function getConfigPath(root, dir) {
4302
173
  if (isSupportTsLoader) {
4303
174
  configName = configWithExtIsExist("ts") ?? configName;
4304
175
  }
4305
- return path__default.default.resolve(root, configName);
176
+ return path.resolve(root, configName);
4306
177
  }
4307
178
  function loadConfig(dir) {
4308
179
  const { wd: root } = getWD();
@@ -4310,14 +181,14 @@ function loadConfig(dir) {
4310
181
  if (!configPath) {
4311
182
  configPath = getConfigPath(root, dir);
4312
183
  } else {
4313
- if (!fs__default.default.existsSync(configPath)) {
184
+ if (!fs.existsSync(configPath)) {
4314
185
  throw new Error(`config file not found: ${configPath}`);
4315
186
  }
4316
- if (!path__default.default.isAbsolute(configPath)) {
4317
- configPath = path__default.default.resolve(root, configPath);
187
+ if (!path.isAbsolute(configPath)) {
188
+ configPath = path.resolve(root, configPath);
4318
189
  }
4319
190
  }
4320
- const ext = path__default.default.extname(configPath);
191
+ const ext = path.extname(configPath);
4321
192
  let module;
4322
193
  switch (ext) {
4323
194
  case ".js":
@@ -4326,7 +197,7 @@ function loadConfig(dir) {
4326
197
  case ".json":
4327
198
  return require(configPath);
4328
199
  case ".yaml":
4329
- return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
200
+ return jsYaml.load(fs.readFileSync(configPath, "utf-8"));
4330
201
  case ".ts":
4331
202
  if (tsRegisterName) {
4332
203
  require(tsRegisterName);
@@ -4383,7 +254,7 @@ var skip = (options = {}) => {
4383
254
  };
4384
255
 
4385
256
  function externalResolver(jsonOrPath = process.cwd()) {
4386
- const pkg = typeof jsonOrPath === "string" ? fs__default.default.existsSync(`${jsonOrPath}/package.json`) ? JSON.parse(fs__default.default.readFileSync(`${jsonOrPath}/package.json`, "utf-8")) : {} : jsonOrPath;
257
+ const pkg = typeof jsonOrPath === "string" ? fs.existsSync(`${jsonOrPath}/package.json`) ? JSON.parse(fs.readFileSync(`${jsonOrPath}/package.json`, "utf-8")) : {} : jsonOrPath;
4387
258
  const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
4388
259
  const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
4389
260
  return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
@@ -4398,7 +269,7 @@ const {
4398
269
  const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
4399
270
  const COMMON_OPTIONS = {};
4400
271
  const COMMON_PLUGINS = [
4401
- json__default.default()
272
+ json()
4402
273
  ];
4403
274
  const config = loadConfig() ?? {};
4404
275
  const { build = {} } = config;
@@ -4425,7 +296,7 @@ const withMinify = (output, minify = build?.output?.minify) => minify === false
4425
296
  file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
4426
297
  plugins: [
4427
298
  ...output.plugins ?? [],
4428
- terser__default.default()
299
+ terser()
4429
300
  ]
4430
301
  }] : [
4431
302
  output,
@@ -4434,11 +305,11 @@ const withMinify = (output, minify = build?.output?.minify) => minify === false
4434
305
  file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
4435
306
  plugins: [
4436
307
  ...output.plugins ?? [],
4437
- terser__default.default()
308
+ terser()
4438
309
  ]
4439
310
  }
4440
311
  ];
4441
- const getTSConfig = (p) => !fs__default.default.existsSync(p) || !fs__default.default.statSync(p).isFile() ? {} : jsoncParser.parse(fs__default.default.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
312
+ const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : jsoncParser.parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
4442
313
  const getExtendTSConfig = (tsconfigPath) => {
4443
314
  tsconfigPath = path.resolve(tsconfigPath);
4444
315
  const tsconfigPathDirname = path.dirname(tsconfigPath);
@@ -4449,14 +320,14 @@ const getExtendTSConfig = (tsconfigPath) => {
4449
320
  );
4450
321
  if (extendsPaths.length === 0)
4451
322
  return tsconfig;
4452
- return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
323
+ return extendsPaths.map(getExtendTSConfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
4453
324
  ...acc,
4454
325
  ...curr,
4455
326
  compilerOptions: {
4456
327
  ...acc.compilerOptions,
4457
328
  ...compilerOptions
4458
329
  }
4459
- }), {});
330
+ }), tsconfig);
4460
331
  };
4461
332
  const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4462
333
  tsconfigPath = path.resolve(tsconfigPath);
@@ -4475,13 +346,13 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4475
346
  tsconfig.include,
4476
347
  tsconfig.exclude
4477
348
  ].map(resolvePaths);
4478
- if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i)))
349
+ if (exclude.length > 0 && exclude.some((i) => micromatch.isMatch(filePath, i)))
4479
350
  return;
4480
351
  if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
4481
352
  return;
4482
353
  let isInclude = false;
4483
354
  isInclude || (isInclude = files.length > 0 && files.includes(filePath));
4484
- isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
355
+ isInclude || (isInclude = include.length > 0 && include.some((i) => micromatch.isMatch(filePath, i)));
4485
356
  if (isInclude) {
4486
357
  return tsconfig.compilerOptions ?? {};
4487
358
  } else {
@@ -4514,14 +385,14 @@ const generateConfigs = ({
4514
385
  ];
4515
386
  let dtsTSConfigPath;
4516
387
  dtsTSConfigPaths.forEach((p) => {
4517
- if (fs__default.default.existsSync(p) && fs__default.default.statSync(p).isFile()) {
388
+ if (fs.existsSync(p) && fs.statSync(p).isFile()) {
4518
389
  dtsTSConfigPath = p;
4519
390
  }
4520
391
  });
4521
392
  let compilerOptions = {};
4522
393
  if (dtsTSConfigPath) {
4523
394
  const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, path.resolve(input));
4524
- const { options: options2, errors } = ts__default.default.convertCompilerOptionsFromJson(
395
+ const { options: options2, errors } = ts.convertCompilerOptionsFromJson(
4525
396
  jsonCompilerOptions,
4526
397
  path.dirname(dtsTSConfigPath)
4527
398
  );
@@ -4544,7 +415,6 @@ const generateConfigs = ({
4544
415
  ...withMinify({
4545
416
  file: output,
4546
417
  name,
4547
- interop: "auto",
4548
418
  sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap,
4549
419
  format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
4550
420
  strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict
@@ -4558,8 +428,7 @@ const generateConfigs = ({
4558
428
  minimize: true
4559
429
  })
4560
430
  ).catch(() => void 0),
4561
- esbuild__default.default(),
4562
- commonjs__default.default(),
431
+ esbuild(),
4563
432
  progress({
4564
433
  onEvent: (event, message) => execa.sendMessage(
4565
434
  {