vite 6.2.4 → 6.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ var node_module = require('node:module');
9
9
  var require$$0 = require('tty');
10
10
  var require$$1 = require('util');
11
11
  var require$$1$1 = require('path');
12
+ var pm = require('picomatch');
12
13
  var require$$0$1 = require('crypto');
13
14
  var require$$1$2 = require('fs');
14
15
  var readline = require('node:readline');
@@ -227,9 +228,7 @@ picocolors.exports.createColors = createColors;
227
228
  var picocolorsExports = picocolors.exports;
228
229
  var colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
229
230
 
230
- var src = {exports: {}};
231
-
232
- var browser = {exports: {}};
231
+ var node = {exports: {}};
233
232
 
234
233
  /**
235
234
  * Helpers.
@@ -545,2813 +544,431 @@ function requireCommon () {
545
544
  set: v => {
546
545
  enableOverride = v;
547
546
  }
548
- });
549
-
550
- // Env-specific initialization logic for debug instances
551
- if (typeof createDebug.init === 'function') {
552
- createDebug.init(debug);
553
- }
554
-
555
- return debug;
556
- }
557
-
558
- function extend(namespace, delimiter) {
559
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
560
- newDebug.log = this.log;
561
- return newDebug;
562
- }
563
-
564
- /**
565
- * Enables a debug mode by namespaces. This can include modes
566
- * separated by a colon and wildcards.
567
- *
568
- * @param {String} namespaces
569
- * @api public
570
- */
571
- function enable(namespaces) {
572
- createDebug.save(namespaces);
573
- createDebug.namespaces = namespaces;
574
-
575
- createDebug.names = [];
576
- createDebug.skips = [];
577
-
578
- const split = (typeof namespaces === 'string' ? namespaces : '')
579
- .trim()
580
- .replace(' ', ',')
581
- .split(',')
582
- .filter(Boolean);
583
-
584
- for (const ns of split) {
585
- if (ns[0] === '-') {
586
- createDebug.skips.push(ns.slice(1));
587
- } else {
588
- createDebug.names.push(ns);
589
- }
590
- }
591
- }
592
-
593
- /**
594
- * Checks if the given string matches a namespace template, honoring
595
- * asterisks as wildcards.
596
- *
597
- * @param {String} search
598
- * @param {String} template
599
- * @return {Boolean}
600
- */
601
- function matchesTemplate(search, template) {
602
- let searchIndex = 0;
603
- let templateIndex = 0;
604
- let starIndex = -1;
605
- let matchIndex = 0;
606
-
607
- while (searchIndex < search.length) {
608
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
609
- // Match character or proceed with wildcard
610
- if (template[templateIndex] === '*') {
611
- starIndex = templateIndex;
612
- matchIndex = searchIndex;
613
- templateIndex++; // Skip the '*'
614
- } else {
615
- searchIndex++;
616
- templateIndex++;
617
- }
618
- } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
619
- // Backtrack to the last '*' and try to match more characters
620
- templateIndex = starIndex + 1;
621
- matchIndex++;
622
- searchIndex = matchIndex;
623
- } else {
624
- return false; // No match
625
- }
626
- }
627
-
628
- // Handle trailing '*' in template
629
- while (templateIndex < template.length && template[templateIndex] === '*') {
630
- templateIndex++;
631
- }
632
-
633
- return templateIndex === template.length;
634
- }
635
-
636
- /**
637
- * Disable debug output.
638
- *
639
- * @return {String} namespaces
640
- * @api public
641
- */
642
- function disable() {
643
- const namespaces = [
644
- ...createDebug.names,
645
- ...createDebug.skips.map(namespace => '-' + namespace)
646
- ].join(',');
647
- createDebug.enable('');
648
- return namespaces;
649
- }
650
-
651
- /**
652
- * Returns true if the given mode name is enabled, false otherwise.
653
- *
654
- * @param {String} name
655
- * @return {Boolean}
656
- * @api public
657
- */
658
- function enabled(name) {
659
- for (const skip of createDebug.skips) {
660
- if (matchesTemplate(name, skip)) {
661
- return false;
662
- }
663
- }
664
-
665
- for (const ns of createDebug.names) {
666
- if (matchesTemplate(name, ns)) {
667
- return true;
668
- }
669
- }
670
-
671
- return false;
672
- }
673
-
674
- /**
675
- * Coerce `val`.
676
- *
677
- * @param {Mixed} val
678
- * @return {Mixed}
679
- * @api private
680
- */
681
- function coerce(val) {
682
- if (val instanceof Error) {
683
- return val.stack || val.message;
684
- }
685
- return val;
686
- }
687
-
688
- /**
689
- * XXX DO NOT USE. This is a temporary stub function.
690
- * XXX It WILL be removed in the next major release.
691
- */
692
- function destroy() {
693
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
694
- }
695
-
696
- createDebug.enable(createDebug.load());
697
-
698
- return createDebug;
699
- }
700
-
701
- common = setup;
702
- return common;
703
- }
704
-
705
- /* eslint-env browser */
706
-
707
- var hasRequiredBrowser;
708
-
709
- function requireBrowser () {
710
- if (hasRequiredBrowser) return browser.exports;
711
- hasRequiredBrowser = 1;
712
- (function (module, exports) {
713
- /**
714
- * This is the web browser implementation of `debug()`.
715
- */
716
-
717
- exports.formatArgs = formatArgs;
718
- exports.save = save;
719
- exports.load = load;
720
- exports.useColors = useColors;
721
- exports.storage = localstorage();
722
- exports.destroy = (() => {
723
- let warned = false;
724
-
725
- return () => {
726
- if (!warned) {
727
- warned = true;
728
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
729
- }
730
- };
731
- })();
732
-
733
- /**
734
- * Colors.
735
- */
736
-
737
- exports.colors = [
738
- '#0000CC',
739
- '#0000FF',
740
- '#0033CC',
741
- '#0033FF',
742
- '#0066CC',
743
- '#0066FF',
744
- '#0099CC',
745
- '#0099FF',
746
- '#00CC00',
747
- '#00CC33',
748
- '#00CC66',
749
- '#00CC99',
750
- '#00CCCC',
751
- '#00CCFF',
752
- '#3300CC',
753
- '#3300FF',
754
- '#3333CC',
755
- '#3333FF',
756
- '#3366CC',
757
- '#3366FF',
758
- '#3399CC',
759
- '#3399FF',
760
- '#33CC00',
761
- '#33CC33',
762
- '#33CC66',
763
- '#33CC99',
764
- '#33CCCC',
765
- '#33CCFF',
766
- '#6600CC',
767
- '#6600FF',
768
- '#6633CC',
769
- '#6633FF',
770
- '#66CC00',
771
- '#66CC33',
772
- '#9900CC',
773
- '#9900FF',
774
- '#9933CC',
775
- '#9933FF',
776
- '#99CC00',
777
- '#99CC33',
778
- '#CC0000',
779
- '#CC0033',
780
- '#CC0066',
781
- '#CC0099',
782
- '#CC00CC',
783
- '#CC00FF',
784
- '#CC3300',
785
- '#CC3333',
786
- '#CC3366',
787
- '#CC3399',
788
- '#CC33CC',
789
- '#CC33FF',
790
- '#CC6600',
791
- '#CC6633',
792
- '#CC9900',
793
- '#CC9933',
794
- '#CCCC00',
795
- '#CCCC33',
796
- '#FF0000',
797
- '#FF0033',
798
- '#FF0066',
799
- '#FF0099',
800
- '#FF00CC',
801
- '#FF00FF',
802
- '#FF3300',
803
- '#FF3333',
804
- '#FF3366',
805
- '#FF3399',
806
- '#FF33CC',
807
- '#FF33FF',
808
- '#FF6600',
809
- '#FF6633',
810
- '#FF9900',
811
- '#FF9933',
812
- '#FFCC00',
813
- '#FFCC33'
814
- ];
815
-
816
- /**
817
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
818
- * and the Firebug extension (any Firefox version) are known
819
- * to support "%c" CSS customizations.
820
- *
821
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
822
- */
823
-
824
- // eslint-disable-next-line complexity
825
- function useColors() {
826
- // NB: In an Electron preload script, document will be defined but not fully
827
- // initialized. Since we know we're in Chrome, we'll just detect this case
828
- // explicitly
829
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
830
- return true;
831
- }
832
-
833
- // Internet Explorer and Edge do not support colors.
834
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
835
- return false;
836
- }
837
-
838
- let m;
839
-
840
- // Is webkit? http://stackoverflow.com/a/16459606/376773
841
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
842
- // eslint-disable-next-line no-return-assign
843
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
844
- // Is firebug? http://stackoverflow.com/a/398120/376773
845
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
846
- // Is firefox >= v31?
847
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
848
- (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
849
- // Double check webkit in userAgent just in case we are in a worker
850
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
851
- }
852
-
853
- /**
854
- * Colorize log arguments if enabled.
855
- *
856
- * @api public
857
- */
858
-
859
- function formatArgs(args) {
860
- args[0] = (this.useColors ? '%c' : '') +
861
- this.namespace +
862
- (this.useColors ? ' %c' : ' ') +
863
- args[0] +
864
- (this.useColors ? '%c ' : ' ') +
865
- '+' + module.exports.humanize(this.diff);
866
-
867
- if (!this.useColors) {
868
- return;
869
- }
870
-
871
- const c = 'color: ' + this.color;
872
- args.splice(1, 0, c, 'color: inherit');
873
-
874
- // The final "%c" is somewhat tricky, because there could be other
875
- // arguments passed either before or after the %c, so we need to
876
- // figure out the correct index to insert the CSS into
877
- let index = 0;
878
- let lastC = 0;
879
- args[0].replace(/%[a-zA-Z%]/g, match => {
880
- if (match === '%%') {
881
- return;
882
- }
883
- index++;
884
- if (match === '%c') {
885
- // We only are interested in the *last* %c
886
- // (the user may have provided their own)
887
- lastC = index;
888
- }
889
- });
890
-
891
- args.splice(lastC, 0, c);
892
- }
893
-
894
- /**
895
- * Invokes `console.debug()` when available.
896
- * No-op when `console.debug` is not a "function".
897
- * If `console.debug` is not available, falls back
898
- * to `console.log`.
899
- *
900
- * @api public
901
- */
902
- exports.log = console.debug || console.log || (() => {});
903
-
904
- /**
905
- * Save `namespaces`.
906
- *
907
- * @param {String} namespaces
908
- * @api private
909
- */
910
- function save(namespaces) {
911
- try {
912
- if (namespaces) {
913
- exports.storage.setItem('debug', namespaces);
914
- } else {
915
- exports.storage.removeItem('debug');
916
- }
917
- } catch (error) {
918
- // Swallow
919
- // XXX (@Qix-) should we be logging these?
920
- }
921
- }
922
-
923
- /**
924
- * Load `namespaces`.
925
- *
926
- * @return {String} returns the previously persisted debug modes
927
- * @api private
928
- */
929
- function load() {
930
- let r;
931
- try {
932
- r = exports.storage.getItem('debug');
933
- } catch (error) {
934
- // Swallow
935
- // XXX (@Qix-) should we be logging these?
936
- }
937
-
938
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
939
- if (!r && typeof process !== 'undefined' && 'env' in process) {
940
- r = process.env.DEBUG;
941
- }
942
-
943
- return r;
944
- }
945
-
946
- /**
947
- * Localstorage attempts to return the localstorage.
948
- *
949
- * This is necessary because safari throws
950
- * when a user disables cookies/localstorage
951
- * and you attempt to access it.
952
- *
953
- * @return {LocalStorage}
954
- * @api private
955
- */
956
-
957
- function localstorage() {
958
- try {
959
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
960
- // The Browser also has localStorage in the global context.
961
- return localStorage;
962
- } catch (error) {
963
- // Swallow
964
- // XXX (@Qix-) should we be logging these?
965
- }
966
- }
967
-
968
- module.exports = requireCommon()(exports);
969
-
970
- const {formatters} = module.exports;
971
-
972
- /**
973
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
974
- */
975
-
976
- formatters.j = function (v) {
977
- try {
978
- return JSON.stringify(v);
979
- } catch (error) {
980
- return '[UnexpectedJSONParseError]: ' + error.message;
981
- }
982
- };
983
- } (browser, browser.exports));
984
- return browser.exports;
985
- }
986
-
987
- var node = {exports: {}};
988
-
989
- /**
990
- * Module dependencies.
991
- */
992
-
993
- var hasRequiredNode;
994
-
995
- function requireNode () {
996
- if (hasRequiredNode) return node.exports;
997
- hasRequiredNode = 1;
998
- (function (module, exports) {
999
- const tty = require$$0;
1000
- const util = require$$1;
1001
-
1002
- /**
1003
- * This is the Node.js implementation of `debug()`.
1004
- */
1005
-
1006
- exports.init = init;
1007
- exports.log = log;
1008
- exports.formatArgs = formatArgs;
1009
- exports.save = save;
1010
- exports.load = load;
1011
- exports.useColors = useColors;
1012
- exports.destroy = util.deprecate(
1013
- () => {},
1014
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
1015
- );
1016
-
1017
- /**
1018
- * Colors.
1019
- */
1020
-
1021
- exports.colors = [6, 2, 3, 4, 5, 1];
1022
-
1023
- try {
1024
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
1025
- // eslint-disable-next-line import/no-extraneous-dependencies
1026
- const supportsColor = require('supports-color');
1027
-
1028
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1029
- exports.colors = [
1030
- 20,
1031
- 21,
1032
- 26,
1033
- 27,
1034
- 32,
1035
- 33,
1036
- 38,
1037
- 39,
1038
- 40,
1039
- 41,
1040
- 42,
1041
- 43,
1042
- 44,
1043
- 45,
1044
- 56,
1045
- 57,
1046
- 62,
1047
- 63,
1048
- 68,
1049
- 69,
1050
- 74,
1051
- 75,
1052
- 76,
1053
- 77,
1054
- 78,
1055
- 79,
1056
- 80,
1057
- 81,
1058
- 92,
1059
- 93,
1060
- 98,
1061
- 99,
1062
- 112,
1063
- 113,
1064
- 128,
1065
- 129,
1066
- 134,
1067
- 135,
1068
- 148,
1069
- 149,
1070
- 160,
1071
- 161,
1072
- 162,
1073
- 163,
1074
- 164,
1075
- 165,
1076
- 166,
1077
- 167,
1078
- 168,
1079
- 169,
1080
- 170,
1081
- 171,
1082
- 172,
1083
- 173,
1084
- 178,
1085
- 179,
1086
- 184,
1087
- 185,
1088
- 196,
1089
- 197,
1090
- 198,
1091
- 199,
1092
- 200,
1093
- 201,
1094
- 202,
1095
- 203,
1096
- 204,
1097
- 205,
1098
- 206,
1099
- 207,
1100
- 208,
1101
- 209,
1102
- 214,
1103
- 215,
1104
- 220,
1105
- 221
1106
- ];
1107
- }
1108
- } catch (error) {
1109
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
1110
- }
1111
-
1112
- /**
1113
- * Build up the default `inspectOpts` object from the environment variables.
1114
- *
1115
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1116
- */
1117
-
1118
- exports.inspectOpts = Object.keys(process.env).filter(key => {
1119
- return /^debug_/i.test(key);
1120
- }).reduce((obj, key) => {
1121
- // Camel-case
1122
- const prop = key
1123
- .substring(6)
1124
- .toLowerCase()
1125
- .replace(/_([a-z])/g, (_, k) => {
1126
- return k.toUpperCase();
1127
- });
1128
-
1129
- // Coerce string value into JS value
1130
- let val = process.env[key];
1131
- if (/^(yes|on|true|enabled)$/i.test(val)) {
1132
- val = true;
1133
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
1134
- val = false;
1135
- } else if (val === 'null') {
1136
- val = null;
1137
- } else {
1138
- val = Number(val);
1139
- }
1140
-
1141
- obj[prop] = val;
1142
- return obj;
1143
- }, {});
1144
-
1145
- /**
1146
- * Is stdout a TTY? Colored output is enabled when `true`.
1147
- */
1148
-
1149
- function useColors() {
1150
- return 'colors' in exports.inspectOpts ?
1151
- Boolean(exports.inspectOpts.colors) :
1152
- tty.isatty(process.stderr.fd);
1153
- }
1154
-
1155
- /**
1156
- * Adds ANSI color escape codes if enabled.
1157
- *
1158
- * @api public
1159
- */
1160
-
1161
- function formatArgs(args) {
1162
- const {namespace: name, useColors} = this;
1163
-
1164
- if (useColors) {
1165
- const c = this.color;
1166
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
1167
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
1168
-
1169
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
1170
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
1171
- } else {
1172
- args[0] = getDate() + name + ' ' + args[0];
1173
- }
1174
- }
1175
-
1176
- function getDate() {
1177
- if (exports.inspectOpts.hideDate) {
1178
- return '';
1179
- }
1180
- return new Date().toISOString() + ' ';
1181
- }
1182
-
1183
- /**
1184
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
1185
- */
1186
-
1187
- function log(...args) {
1188
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
1189
- }
1190
-
1191
- /**
1192
- * Save `namespaces`.
1193
- *
1194
- * @param {String} namespaces
1195
- * @api private
1196
- */
1197
- function save(namespaces) {
1198
- if (namespaces) {
1199
- process.env.DEBUG = namespaces;
1200
- } else {
1201
- // If you set a process.env field to null or undefined, it gets cast to the
1202
- // string 'null' or 'undefined'. Just delete instead.
1203
- delete process.env.DEBUG;
1204
- }
1205
- }
1206
-
1207
- /**
1208
- * Load `namespaces`.
1209
- *
1210
- * @return {String} returns the previously persisted debug modes
1211
- * @api private
1212
- */
1213
-
1214
- function load() {
1215
- return process.env.DEBUG;
1216
- }
1217
-
1218
- /**
1219
- * Init logic for `debug` instances.
1220
- *
1221
- * Create a new `inspectOpts` object in case `useColors` is set
1222
- * differently for a particular `debug` instance.
1223
- */
1224
-
1225
- function init(debug) {
1226
- debug.inspectOpts = {};
1227
-
1228
- const keys = Object.keys(exports.inspectOpts);
1229
- for (let i = 0; i < keys.length; i++) {
1230
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1231
- }
1232
- }
1233
-
1234
- module.exports = requireCommon()(exports);
1235
-
1236
- const {formatters} = module.exports;
1237
-
1238
- /**
1239
- * Map %o to `util.inspect()`, all on a single line.
1240
- */
1241
-
1242
- formatters.o = function (v) {
1243
- this.inspectOpts.colors = this.useColors;
1244
- return util.inspect(v, this.inspectOpts)
1245
- .split('\n')
1246
- .map(str => str.trim())
1247
- .join(' ');
1248
- };
1249
-
1250
- /**
1251
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
1252
- */
1253
-
1254
- formatters.O = function (v) {
1255
- this.inspectOpts.colors = this.useColors;
1256
- return util.inspect(v, this.inspectOpts);
1257
- };
1258
- } (node, node.exports));
1259
- return node.exports;
1260
- }
1261
-
1262
- /**
1263
- * Detect Electron renderer / nwjs process, which is node, but we should
1264
- * treat as a browser.
1265
- */
1266
-
1267
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
1268
- src.exports = requireBrowser();
1269
- } else {
1270
- src.exports = requireNode();
1271
- }
1272
-
1273
- var srcExports = src.exports;
1274
- var debug$3 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
1275
-
1276
- var utils$4 = {};
1277
-
1278
- const WIN_SLASH = '\\\\/';
1279
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1280
-
1281
- /**
1282
- * Posix glob regex
1283
- */
1284
-
1285
- const DOT_LITERAL = '\\.';
1286
- const PLUS_LITERAL = '\\+';
1287
- const QMARK_LITERAL = '\\?';
1288
- const SLASH_LITERAL = '\\/';
1289
- const ONE_CHAR = '(?=.)';
1290
- const QMARK = '[^/]';
1291
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1292
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1293
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1294
- const NO_DOT = `(?!${DOT_LITERAL})`;
1295
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1296
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1297
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1298
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1299
- const STAR = `${QMARK}*?`;
1300
- const SEP = '/';
1301
-
1302
- const POSIX_CHARS = {
1303
- DOT_LITERAL,
1304
- PLUS_LITERAL,
1305
- QMARK_LITERAL,
1306
- SLASH_LITERAL,
1307
- ONE_CHAR,
1308
- QMARK,
1309
- END_ANCHOR,
1310
- DOTS_SLASH,
1311
- NO_DOT,
1312
- NO_DOTS,
1313
- NO_DOT_SLASH,
1314
- NO_DOTS_SLASH,
1315
- QMARK_NO_DOT,
1316
- STAR,
1317
- START_ANCHOR,
1318
- SEP
1319
- };
1320
-
1321
- /**
1322
- * Windows glob regex
1323
- */
1324
-
1325
- const WINDOWS_CHARS = {
1326
- ...POSIX_CHARS,
1327
-
1328
- SLASH_LITERAL: `[${WIN_SLASH}]`,
1329
- QMARK: WIN_NO_SLASH,
1330
- STAR: `${WIN_NO_SLASH}*?`,
1331
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1332
- NO_DOT: `(?!${DOT_LITERAL})`,
1333
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1334
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1335
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1336
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1337
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1338
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
1339
- SEP: '\\'
1340
- };
1341
-
1342
- /**
1343
- * POSIX Bracket Regex
1344
- */
1345
-
1346
- const POSIX_REGEX_SOURCE$1 = {
1347
- alnum: 'a-zA-Z0-9',
1348
- alpha: 'a-zA-Z',
1349
- ascii: '\\x00-\\x7F',
1350
- blank: ' \\t',
1351
- cntrl: '\\x00-\\x1F\\x7F',
1352
- digit: '0-9',
1353
- graph: '\\x21-\\x7E',
1354
- lower: 'a-z',
1355
- print: '\\x20-\\x7E ',
1356
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1357
- space: ' \\t\\r\\n\\v\\f',
1358
- upper: 'A-Z',
1359
- word: 'A-Za-z0-9_',
1360
- xdigit: 'A-Fa-f0-9'
1361
- };
1362
-
1363
- var constants$2 = {
1364
- MAX_LENGTH: 1024 * 64,
1365
- POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
1366
-
1367
- // regular expressions
1368
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1369
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1370
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1371
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1372
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1373
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1374
-
1375
- // Replace globs with equivalent patterns to reduce parsing time.
1376
- REPLACEMENTS: {
1377
- '***': '*',
1378
- '**/**': '**',
1379
- '**/**/**': '**'
1380
- },
1381
-
1382
- // Digits
1383
- CHAR_0: 48, /* 0 */
1384
- CHAR_9: 57, /* 9 */
1385
-
1386
- // Alphabet chars.
1387
- CHAR_UPPERCASE_A: 65, /* A */
1388
- CHAR_LOWERCASE_A: 97, /* a */
1389
- CHAR_UPPERCASE_Z: 90, /* Z */
1390
- CHAR_LOWERCASE_Z: 122, /* z */
1391
-
1392
- CHAR_LEFT_PARENTHESES: 40, /* ( */
1393
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
1394
-
1395
- CHAR_ASTERISK: 42, /* * */
1396
-
1397
- // Non-alphabetic chars.
1398
- CHAR_AMPERSAND: 38, /* & */
1399
- CHAR_AT: 64, /* @ */
1400
- CHAR_BACKWARD_SLASH: 92, /* \ */
1401
- CHAR_CARRIAGE_RETURN: 13, /* \r */
1402
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
1403
- CHAR_COLON: 58, /* : */
1404
- CHAR_COMMA: 44, /* , */
1405
- CHAR_DOT: 46, /* . */
1406
- CHAR_DOUBLE_QUOTE: 34, /* " */
1407
- CHAR_EQUAL: 61, /* = */
1408
- CHAR_EXCLAMATION_MARK: 33, /* ! */
1409
- CHAR_FORM_FEED: 12, /* \f */
1410
- CHAR_FORWARD_SLASH: 47, /* / */
1411
- CHAR_GRAVE_ACCENT: 96, /* ` */
1412
- CHAR_HASH: 35, /* # */
1413
- CHAR_HYPHEN_MINUS: 45, /* - */
1414
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
1415
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
1416
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
1417
- CHAR_LINE_FEED: 10, /* \n */
1418
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
1419
- CHAR_PERCENT: 37, /* % */
1420
- CHAR_PLUS: 43, /* + */
1421
- CHAR_QUESTION_MARK: 63, /* ? */
1422
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
1423
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
1424
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
1425
- CHAR_SEMICOLON: 59, /* ; */
1426
- CHAR_SINGLE_QUOTE: 39, /* ' */
1427
- CHAR_SPACE: 32, /* */
1428
- CHAR_TAB: 9, /* \t */
1429
- CHAR_UNDERSCORE: 95, /* _ */
1430
- CHAR_VERTICAL_LINE: 124, /* | */
1431
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1432
-
1433
- /**
1434
- * Create EXTGLOB_CHARS
1435
- */
1436
-
1437
- extglobChars(chars) {
1438
- return {
1439
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
1440
- '?': { type: 'qmark', open: '(?:', close: ')?' },
1441
- '+': { type: 'plus', open: '(?:', close: ')+' },
1442
- '*': { type: 'star', open: '(?:', close: ')*' },
1443
- '@': { type: 'at', open: '(?:', close: ')' }
1444
- };
1445
- },
1446
-
1447
- /**
1448
- * Create GLOB_CHARS
1449
- */
1450
-
1451
- globChars(win32) {
1452
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
1453
- }
1454
- };
1455
-
1456
- /*global navigator*/
1457
-
1458
- (function (exports) {
1459
-
1460
- const {
1461
- REGEX_BACKSLASH,
1462
- REGEX_REMOVE_BACKSLASH,
1463
- REGEX_SPECIAL_CHARS,
1464
- REGEX_SPECIAL_CHARS_GLOBAL
1465
- } = constants$2;
1466
-
1467
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1468
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
1469
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
1470
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1471
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
1472
-
1473
- exports.isWindows = () => {
1474
- if (typeof navigator !== 'undefined' && navigator.platform) {
1475
- const platform = navigator.platform.toLowerCase();
1476
- return platform === 'win32' || platform === 'windows';
1477
- }
1478
-
1479
- if (typeof process !== 'undefined' && process.platform) {
1480
- return process.platform === 'win32';
1481
- }
1482
-
1483
- return false;
1484
- };
1485
-
1486
- exports.removeBackslashes = str => {
1487
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
1488
- return match === '\\' ? '' : match;
1489
- });
1490
- };
1491
-
1492
- exports.escapeLast = (input, char, lastIdx) => {
1493
- const idx = input.lastIndexOf(char, lastIdx);
1494
- if (idx === -1) return input;
1495
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
1496
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1497
- };
1498
-
1499
- exports.removePrefix = (input, state = {}) => {
1500
- let output = input;
1501
- if (output.startsWith('./')) {
1502
- output = output.slice(2);
1503
- state.prefix = './';
1504
- }
1505
- return output;
1506
- };
1507
-
1508
- exports.wrapOutput = (input, state = {}, options = {}) => {
1509
- const prepend = options.contains ? '' : '^';
1510
- const append = options.contains ? '' : '$';
1511
-
1512
- let output = `${prepend}(?:${input})${append}`;
1513
- if (state.negated === true) {
1514
- output = `(?:^(?!${output}).*$)`;
1515
- }
1516
- return output;
1517
- };
1518
-
1519
- exports.basename = (path, { windows } = {}) => {
1520
- const segs = path.split(windows ? /[\\/]/ : '/');
1521
- const last = segs[segs.length - 1];
1522
-
1523
- if (last === '') {
1524
- return segs[segs.length - 2];
1525
- }
1526
-
1527
- return last;
1528
- };
1529
- } (utils$4));
1530
-
1531
- const utils$3 = utils$4;
1532
- const {
1533
- CHAR_ASTERISK, /* * */
1534
- CHAR_AT, /* @ */
1535
- CHAR_BACKWARD_SLASH, /* \ */
1536
- CHAR_COMMA, /* , */
1537
- CHAR_DOT, /* . */
1538
- CHAR_EXCLAMATION_MARK, /* ! */
1539
- CHAR_FORWARD_SLASH, /* / */
1540
- CHAR_LEFT_CURLY_BRACE, /* { */
1541
- CHAR_LEFT_PARENTHESES, /* ( */
1542
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
1543
- CHAR_PLUS, /* + */
1544
- CHAR_QUESTION_MARK, /* ? */
1545
- CHAR_RIGHT_CURLY_BRACE, /* } */
1546
- CHAR_RIGHT_PARENTHESES, /* ) */
1547
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
1548
- } = constants$2;
1549
-
1550
- const isPathSeparator = code => {
1551
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1552
- };
1553
-
1554
- const depth = token => {
1555
- if (token.isPrefix !== true) {
1556
- token.depth = token.isGlobstar ? Infinity : 1;
1557
- }
1558
- };
1559
-
1560
- /**
1561
- * Quickly scans a glob pattern and returns an object with a handful of
1562
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
1563
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
1564
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
1565
- *
1566
- * ```js
1567
- * const pm = require('picomatch');
1568
- * console.log(pm.scan('foo/bar/*.js'));
1569
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
1570
- * ```
1571
- * @param {String} `str`
1572
- * @param {Object} `options`
1573
- * @return {Object} Returns an object with tokens and regex source string.
1574
- * @api public
1575
- */
1576
-
1577
- const scan$1 = (input, options) => {
1578
- const opts = options || {};
1579
-
1580
- const length = input.length - 1;
1581
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
1582
- const slashes = [];
1583
- const tokens = [];
1584
- const parts = [];
1585
-
1586
- let str = input;
1587
- let index = -1;
1588
- let start = 0;
1589
- let lastIndex = 0;
1590
- let isBrace = false;
1591
- let isBracket = false;
1592
- let isGlob = false;
1593
- let isExtglob = false;
1594
- let isGlobstar = false;
1595
- let braceEscaped = false;
1596
- let backslashes = false;
1597
- let negated = false;
1598
- let negatedExtglob = false;
1599
- let finished = false;
1600
- let braces = 0;
1601
- let prev;
1602
- let code;
1603
- let token = { value: '', depth: 0, isGlob: false };
1604
-
1605
- const eos = () => index >= length;
1606
- const peek = () => str.charCodeAt(index + 1);
1607
- const advance = () => {
1608
- prev = code;
1609
- return str.charCodeAt(++index);
1610
- };
1611
-
1612
- while (index < length) {
1613
- code = advance();
1614
- let next;
1615
-
1616
- if (code === CHAR_BACKWARD_SLASH) {
1617
- backslashes = token.backslashes = true;
1618
- code = advance();
1619
-
1620
- if (code === CHAR_LEFT_CURLY_BRACE) {
1621
- braceEscaped = true;
1622
- }
1623
- continue;
1624
- }
1625
-
1626
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1627
- braces++;
1628
-
1629
- while (eos() !== true && (code = advance())) {
1630
- if (code === CHAR_BACKWARD_SLASH) {
1631
- backslashes = token.backslashes = true;
1632
- advance();
1633
- continue;
1634
- }
1635
-
1636
- if (code === CHAR_LEFT_CURLY_BRACE) {
1637
- braces++;
1638
- continue;
1639
- }
1640
-
1641
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1642
- isBrace = token.isBrace = true;
1643
- isGlob = token.isGlob = true;
1644
- finished = true;
1645
-
1646
- if (scanToEnd === true) {
1647
- continue;
1648
- }
1649
-
1650
- break;
1651
- }
1652
-
1653
- if (braceEscaped !== true && code === CHAR_COMMA) {
1654
- isBrace = token.isBrace = true;
1655
- isGlob = token.isGlob = true;
1656
- finished = true;
1657
-
1658
- if (scanToEnd === true) {
1659
- continue;
1660
- }
1661
-
1662
- break;
1663
- }
1664
-
1665
- if (code === CHAR_RIGHT_CURLY_BRACE) {
1666
- braces--;
1667
-
1668
- if (braces === 0) {
1669
- braceEscaped = false;
1670
- isBrace = token.isBrace = true;
1671
- finished = true;
1672
- break;
1673
- }
1674
- }
1675
- }
1676
-
1677
- if (scanToEnd === true) {
1678
- continue;
1679
- }
1680
-
1681
- break;
1682
- }
1683
-
1684
- if (code === CHAR_FORWARD_SLASH) {
1685
- slashes.push(index);
1686
- tokens.push(token);
1687
- token = { value: '', depth: 0, isGlob: false };
1688
-
1689
- if (finished === true) continue;
1690
- if (prev === CHAR_DOT && index === (start + 1)) {
1691
- start += 2;
1692
- continue;
1693
- }
1694
-
1695
- lastIndex = index + 1;
1696
- continue;
1697
- }
1698
-
1699
- if (opts.noext !== true) {
1700
- const isExtglobChar = code === CHAR_PLUS
1701
- || code === CHAR_AT
1702
- || code === CHAR_ASTERISK
1703
- || code === CHAR_QUESTION_MARK
1704
- || code === CHAR_EXCLAMATION_MARK;
1705
-
1706
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1707
- isGlob = token.isGlob = true;
1708
- isExtglob = token.isExtglob = true;
1709
- finished = true;
1710
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
1711
- negatedExtglob = true;
1712
- }
1713
-
1714
- if (scanToEnd === true) {
1715
- while (eos() !== true && (code = advance())) {
1716
- if (code === CHAR_BACKWARD_SLASH) {
1717
- backslashes = token.backslashes = true;
1718
- code = advance();
1719
- continue;
1720
- }
1721
-
1722
- if (code === CHAR_RIGHT_PARENTHESES) {
1723
- isGlob = token.isGlob = true;
1724
- finished = true;
1725
- break;
1726
- }
1727
- }
1728
- continue;
1729
- }
1730
- break;
1731
- }
1732
- }
1733
-
1734
- if (code === CHAR_ASTERISK) {
1735
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1736
- isGlob = token.isGlob = true;
1737
- finished = true;
1738
-
1739
- if (scanToEnd === true) {
1740
- continue;
1741
- }
1742
- break;
1743
- }
1744
-
1745
- if (code === CHAR_QUESTION_MARK) {
1746
- isGlob = token.isGlob = true;
1747
- finished = true;
1748
-
1749
- if (scanToEnd === true) {
1750
- continue;
1751
- }
1752
- break;
1753
- }
1754
-
1755
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
1756
- while (eos() !== true && (next = advance())) {
1757
- if (next === CHAR_BACKWARD_SLASH) {
1758
- backslashes = token.backslashes = true;
1759
- advance();
1760
- continue;
1761
- }
1762
-
1763
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1764
- isBracket = token.isBracket = true;
1765
- isGlob = token.isGlob = true;
1766
- finished = true;
1767
- break;
1768
- }
1769
- }
1770
-
1771
- if (scanToEnd === true) {
1772
- continue;
1773
- }
1774
-
1775
- break;
1776
- }
1777
-
1778
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
1779
- negated = token.negated = true;
1780
- start++;
1781
- continue;
1782
- }
1783
-
1784
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
1785
- isGlob = token.isGlob = true;
1786
-
1787
- if (scanToEnd === true) {
1788
- while (eos() !== true && (code = advance())) {
1789
- if (code === CHAR_LEFT_PARENTHESES) {
1790
- backslashes = token.backslashes = true;
1791
- code = advance();
1792
- continue;
1793
- }
1794
-
1795
- if (code === CHAR_RIGHT_PARENTHESES) {
1796
- finished = true;
1797
- break;
1798
- }
1799
- }
1800
- continue;
1801
- }
1802
- break;
1803
- }
1804
-
1805
- if (isGlob === true) {
1806
- finished = true;
1807
-
1808
- if (scanToEnd === true) {
1809
- continue;
1810
- }
1811
-
1812
- break;
1813
- }
1814
- }
1815
-
1816
- if (opts.noext === true) {
1817
- isExtglob = false;
1818
- isGlob = false;
1819
- }
1820
-
1821
- let base = str;
1822
- let prefix = '';
1823
- let glob = '';
1824
-
1825
- if (start > 0) {
1826
- prefix = str.slice(0, start);
1827
- str = str.slice(start);
1828
- lastIndex -= start;
1829
- }
1830
-
1831
- if (base && isGlob === true && lastIndex > 0) {
1832
- base = str.slice(0, lastIndex);
1833
- glob = str.slice(lastIndex);
1834
- } else if (isGlob === true) {
1835
- base = '';
1836
- glob = str;
1837
- } else {
1838
- base = str;
1839
- }
1840
-
1841
- if (base && base !== '' && base !== '/' && base !== str) {
1842
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
1843
- base = base.slice(0, -1);
1844
- }
1845
- }
1846
-
1847
- if (opts.unescape === true) {
1848
- if (glob) glob = utils$3.removeBackslashes(glob);
1849
-
1850
- if (base && backslashes === true) {
1851
- base = utils$3.removeBackslashes(base);
1852
- }
1853
- }
1854
-
1855
- const state = {
1856
- prefix,
1857
- input,
1858
- start,
1859
- base,
1860
- glob,
1861
- isBrace,
1862
- isBracket,
1863
- isGlob,
1864
- isExtglob,
1865
- isGlobstar,
1866
- negated,
1867
- negatedExtglob
1868
- };
1869
-
1870
- if (opts.tokens === true) {
1871
- state.maxDepth = 0;
1872
- if (!isPathSeparator(code)) {
1873
- tokens.push(token);
1874
- }
1875
- state.tokens = tokens;
1876
- }
1877
-
1878
- if (opts.parts === true || opts.tokens === true) {
1879
- let prevIndex;
1880
-
1881
- for (let idx = 0; idx < slashes.length; idx++) {
1882
- const n = prevIndex ? prevIndex + 1 : start;
1883
- const i = slashes[idx];
1884
- const value = input.slice(n, i);
1885
- if (opts.tokens) {
1886
- if (idx === 0 && start !== 0) {
1887
- tokens[idx].isPrefix = true;
1888
- tokens[idx].value = prefix;
1889
- } else {
1890
- tokens[idx].value = value;
1891
- }
1892
- depth(tokens[idx]);
1893
- state.maxDepth += tokens[idx].depth;
1894
- }
1895
- if (idx !== 0 || value !== '') {
1896
- parts.push(value);
1897
- }
1898
- prevIndex = i;
1899
- }
1900
-
1901
- if (prevIndex && prevIndex + 1 < input.length) {
1902
- const value = input.slice(prevIndex + 1);
1903
- parts.push(value);
1904
-
1905
- if (opts.tokens) {
1906
- tokens[tokens.length - 1].value = value;
1907
- depth(tokens[tokens.length - 1]);
1908
- state.maxDepth += tokens[tokens.length - 1].depth;
1909
- }
1910
- }
1911
-
1912
- state.slashes = slashes;
1913
- state.parts = parts;
1914
- }
1915
-
1916
- return state;
1917
- };
1918
-
1919
- var scan_1 = scan$1;
1920
-
1921
- const constants$1 = constants$2;
1922
- const utils$2 = utils$4;
1923
-
1924
- /**
1925
- * Constants
1926
- */
1927
-
1928
- const {
1929
- MAX_LENGTH,
1930
- POSIX_REGEX_SOURCE,
1931
- REGEX_NON_SPECIAL_CHARS,
1932
- REGEX_SPECIAL_CHARS_BACKREF,
1933
- REPLACEMENTS
1934
- } = constants$1;
1935
-
1936
- /**
1937
- * Helpers
1938
- */
1939
-
1940
- const expandRange = (args, options) => {
1941
- if (typeof options.expandRange === 'function') {
1942
- return options.expandRange(...args, options);
1943
- }
1944
-
1945
- args.sort();
1946
- const value = `[${args.join('-')}]`;
1947
-
1948
- return value;
1949
- };
1950
-
1951
- /**
1952
- * Create the message for a syntax error
1953
- */
1954
-
1955
- const syntaxError = (type, char) => {
1956
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1957
- };
1958
-
1959
- /**
1960
- * Parse the given input string.
1961
- * @param {String} input
1962
- * @param {Object} options
1963
- * @return {Object}
1964
- */
1965
-
1966
- const parse$2 = (input, options) => {
1967
- if (typeof input !== 'string') {
1968
- throw new TypeError('Expected a string');
1969
- }
1970
-
1971
- input = REPLACEMENTS[input] || input;
1972
-
1973
- const opts = { ...options };
1974
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1975
-
1976
- let len = input.length;
1977
- if (len > max) {
1978
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1979
- }
1980
-
1981
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
1982
- const tokens = [bos];
1983
-
1984
- const capture = opts.capture ? '' : '?:';
1985
-
1986
- // create constants based on platform, for windows or posix
1987
- const PLATFORM_CHARS = constants$1.globChars(opts.windows);
1988
- const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
1989
-
1990
- const {
1991
- DOT_LITERAL,
1992
- PLUS_LITERAL,
1993
- SLASH_LITERAL,
1994
- ONE_CHAR,
1995
- DOTS_SLASH,
1996
- NO_DOT,
1997
- NO_DOT_SLASH,
1998
- NO_DOTS_SLASH,
1999
- QMARK,
2000
- QMARK_NO_DOT,
2001
- STAR,
2002
- START_ANCHOR
2003
- } = PLATFORM_CHARS;
2004
-
2005
- const globstar = opts => {
2006
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2007
- };
2008
-
2009
- const nodot = opts.dot ? '' : NO_DOT;
2010
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
2011
- let star = opts.bash === true ? globstar(opts) : STAR;
2012
-
2013
- if (opts.capture) {
2014
- star = `(${star})`;
2015
- }
2016
-
2017
- // minimatch options support
2018
- if (typeof opts.noext === 'boolean') {
2019
- opts.noextglob = opts.noext;
2020
- }
2021
-
2022
- const state = {
2023
- input,
2024
- index: -1,
2025
- start: 0,
2026
- dot: opts.dot === true,
2027
- consumed: '',
2028
- output: '',
2029
- prefix: '',
2030
- backtrack: false,
2031
- negated: false,
2032
- brackets: 0,
2033
- braces: 0,
2034
- parens: 0,
2035
- quotes: 0,
2036
- globstar: false,
2037
- tokens
2038
- };
2039
-
2040
- input = utils$2.removePrefix(input, state);
2041
- len = input.length;
2042
-
2043
- const extglobs = [];
2044
- const braces = [];
2045
- const stack = [];
2046
- let prev = bos;
2047
- let value;
2048
-
2049
- /**
2050
- * Tokenizing helpers
2051
- */
2052
-
2053
- const eos = () => state.index === len - 1;
2054
- const peek = state.peek = (n = 1) => input[state.index + n];
2055
- const advance = state.advance = () => input[++state.index] || '';
2056
- const remaining = () => input.slice(state.index + 1);
2057
- const consume = (value = '', num = 0) => {
2058
- state.consumed += value;
2059
- state.index += num;
2060
- };
2061
-
2062
- const append = token => {
2063
- state.output += token.output != null ? token.output : token.value;
2064
- consume(token.value);
2065
- };
2066
-
2067
- const negate = () => {
2068
- let count = 1;
2069
-
2070
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2071
- advance();
2072
- state.start++;
2073
- count++;
2074
- }
2075
-
2076
- if (count % 2 === 0) {
2077
- return false;
2078
- }
2079
-
2080
- state.negated = true;
2081
- state.start++;
2082
- return true;
2083
- };
2084
-
2085
- const increment = type => {
2086
- state[type]++;
2087
- stack.push(type);
2088
- };
2089
-
2090
- const decrement = type => {
2091
- state[type]--;
2092
- stack.pop();
2093
- };
2094
-
2095
- /**
2096
- * Push tokens onto the tokens array. This helper speeds up
2097
- * tokenizing by 1) helping us avoid backtracking as much as possible,
2098
- * and 2) helping us avoid creating extra tokens when consecutive
2099
- * characters are plain text. This improves performance and simplifies
2100
- * lookbehinds.
2101
- */
2102
-
2103
- const push = tok => {
2104
- if (prev.type === 'globstar') {
2105
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2106
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2107
-
2108
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2109
- state.output = state.output.slice(0, -prev.output.length);
2110
- prev.type = 'star';
2111
- prev.value = '*';
2112
- prev.output = star;
2113
- state.output += prev.output;
2114
- }
2115
- }
2116
-
2117
- if (extglobs.length && tok.type !== 'paren') {
2118
- extglobs[extglobs.length - 1].inner += tok.value;
2119
- }
2120
-
2121
- if (tok.value || tok.output) append(tok);
2122
- if (prev && prev.type === 'text' && tok.type === 'text') {
2123
- prev.output = (prev.output || prev.value) + tok.value;
2124
- prev.value += tok.value;
2125
- return;
2126
- }
2127
-
2128
- tok.prev = prev;
2129
- tokens.push(tok);
2130
- prev = tok;
2131
- };
2132
-
2133
- const extglobOpen = (type, value) => {
2134
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2135
-
2136
- token.prev = prev;
2137
- token.parens = state.parens;
2138
- token.output = state.output;
2139
- const output = (opts.capture ? '(' : '') + token.open;
2140
-
2141
- increment('parens');
2142
- push({ type, value, output: state.output ? '' : ONE_CHAR });
2143
- push({ type: 'paren', extglob: true, value: advance(), output });
2144
- extglobs.push(token);
2145
- };
2146
-
2147
- const extglobClose = token => {
2148
- let output = token.close + (opts.capture ? ')' : '');
2149
- let rest;
2150
-
2151
- if (token.type === 'negate') {
2152
- let extglobStar = star;
2153
-
2154
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2155
- extglobStar = globstar(opts);
2156
- }
2157
-
2158
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2159
- output = token.close = `)$))${extglobStar}`;
2160
- }
2161
-
2162
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2163
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2164
- // In this case, we need to parse the string and use it in the output of the original pattern.
2165
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2166
- //
2167
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2168
- const expression = parse$2(rest, { ...options, fastpaths: false }).output;
2169
-
2170
- output = token.close = `)${expression})${extglobStar})`;
2171
- }
2172
-
2173
- if (token.prev.type === 'bos') {
2174
- state.negatedExtglob = true;
2175
- }
2176
- }
2177
-
2178
- push({ type: 'paren', extglob: true, value, output });
2179
- decrement('parens');
2180
- };
2181
-
2182
- /**
2183
- * Fast paths
2184
- */
2185
-
2186
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2187
- let backslashes = false;
2188
-
2189
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2190
- if (first === '\\') {
2191
- backslashes = true;
2192
- return m;
2193
- }
2194
-
2195
- if (first === '?') {
2196
- if (esc) {
2197
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2198
- }
2199
- if (index === 0) {
2200
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2201
- }
2202
- return QMARK.repeat(chars.length);
2203
- }
2204
-
2205
- if (first === '.') {
2206
- return DOT_LITERAL.repeat(chars.length);
2207
- }
2208
-
2209
- if (first === '*') {
2210
- if (esc) {
2211
- return esc + first + (rest ? star : '');
2212
- }
2213
- return star;
2214
- }
2215
- return esc ? m : `\\${m}`;
2216
- });
2217
-
2218
- if (backslashes === true) {
2219
- if (opts.unescape === true) {
2220
- output = output.replace(/\\/g, '');
2221
- } else {
2222
- output = output.replace(/\\+/g, m => {
2223
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2224
- });
2225
- }
2226
- }
2227
-
2228
- if (output === input && opts.contains === true) {
2229
- state.output = input;
2230
- return state;
2231
- }
2232
-
2233
- state.output = utils$2.wrapOutput(output, state, options);
2234
- return state;
2235
- }
2236
-
2237
- /**
2238
- * Tokenize input until we reach end-of-string
2239
- */
2240
-
2241
- while (!eos()) {
2242
- value = advance();
2243
-
2244
- if (value === '\u0000') {
2245
- continue;
2246
- }
2247
-
2248
- /**
2249
- * Escaped characters
2250
- */
2251
-
2252
- if (value === '\\') {
2253
- const next = peek();
2254
-
2255
- if (next === '/' && opts.bash !== true) {
2256
- continue;
2257
- }
2258
-
2259
- if (next === '.' || next === ';') {
2260
- continue;
2261
- }
2262
-
2263
- if (!next) {
2264
- value += '\\';
2265
- push({ type: 'text', value });
2266
- continue;
2267
- }
2268
-
2269
- // collapse slashes to reduce potential for exploits
2270
- const match = /^\\+/.exec(remaining());
2271
- let slashes = 0;
2272
-
2273
- if (match && match[0].length > 2) {
2274
- slashes = match[0].length;
2275
- state.index += slashes;
2276
- if (slashes % 2 !== 0) {
2277
- value += '\\';
2278
- }
2279
- }
2280
-
2281
- if (opts.unescape === true) {
2282
- value = advance();
2283
- } else {
2284
- value += advance();
2285
- }
2286
-
2287
- if (state.brackets === 0) {
2288
- push({ type: 'text', value });
2289
- continue;
2290
- }
2291
- }
2292
-
2293
- /**
2294
- * If we're inside a regex character class, continue
2295
- * until we reach the closing bracket.
2296
- */
2297
-
2298
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2299
- if (opts.posix !== false && value === ':') {
2300
- const inner = prev.value.slice(1);
2301
- if (inner.includes('[')) {
2302
- prev.posix = true;
2303
-
2304
- if (inner.includes(':')) {
2305
- const idx = prev.value.lastIndexOf('[');
2306
- const pre = prev.value.slice(0, idx);
2307
- const rest = prev.value.slice(idx + 2);
2308
- const posix = POSIX_REGEX_SOURCE[rest];
2309
- if (posix) {
2310
- prev.value = pre + posix;
2311
- state.backtrack = true;
2312
- advance();
2313
-
2314
- if (!bos.output && tokens.indexOf(prev) === 1) {
2315
- bos.output = ONE_CHAR;
2316
- }
2317
- continue;
2318
- }
2319
- }
2320
- }
2321
- }
2322
-
2323
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2324
- value = `\\${value}`;
2325
- }
2326
-
2327
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2328
- value = `\\${value}`;
2329
- }
2330
-
2331
- if (opts.posix === true && value === '!' && prev.value === '[') {
2332
- value = '^';
2333
- }
2334
-
2335
- prev.value += value;
2336
- append({ value });
2337
- continue;
2338
- }
2339
-
2340
- /**
2341
- * If we're inside a quoted string, continue
2342
- * until we reach the closing double quote.
2343
- */
2344
-
2345
- if (state.quotes === 1 && value !== '"') {
2346
- value = utils$2.escapeRegex(value);
2347
- prev.value += value;
2348
- append({ value });
2349
- continue;
2350
- }
2351
-
2352
- /**
2353
- * Double quotes
2354
- */
2355
-
2356
- if (value === '"') {
2357
- state.quotes = state.quotes === 1 ? 0 : 1;
2358
- if (opts.keepQuotes === true) {
2359
- push({ type: 'text', value });
2360
- }
2361
- continue;
2362
- }
2363
-
2364
- /**
2365
- * Parentheses
2366
- */
2367
-
2368
- if (value === '(') {
2369
- increment('parens');
2370
- push({ type: 'paren', value });
2371
- continue;
2372
- }
2373
-
2374
- if (value === ')') {
2375
- if (state.parens === 0 && opts.strictBrackets === true) {
2376
- throw new SyntaxError(syntaxError('opening', '('));
2377
- }
2378
-
2379
- const extglob = extglobs[extglobs.length - 1];
2380
- if (extglob && state.parens === extglob.parens + 1) {
2381
- extglobClose(extglobs.pop());
2382
- continue;
2383
- }
2384
-
2385
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
2386
- decrement('parens');
2387
- continue;
2388
- }
2389
-
2390
- /**
2391
- * Square brackets
2392
- */
2393
-
2394
- if (value === '[') {
2395
- if (opts.nobracket === true || !remaining().includes(']')) {
2396
- if (opts.nobracket !== true && opts.strictBrackets === true) {
2397
- throw new SyntaxError(syntaxError('closing', ']'));
2398
- }
2399
-
2400
- value = `\\${value}`;
2401
- } else {
2402
- increment('brackets');
2403
- }
2404
-
2405
- push({ type: 'bracket', value });
2406
- continue;
2407
- }
2408
-
2409
- if (value === ']') {
2410
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
2411
- push({ type: 'text', value, output: `\\${value}` });
2412
- continue;
2413
- }
2414
-
2415
- if (state.brackets === 0) {
2416
- if (opts.strictBrackets === true) {
2417
- throw new SyntaxError(syntaxError('opening', '['));
2418
- }
2419
-
2420
- push({ type: 'text', value, output: `\\${value}` });
2421
- continue;
2422
- }
2423
-
2424
- decrement('brackets');
2425
-
2426
- const prevValue = prev.value.slice(1);
2427
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
2428
- value = `/${value}`;
2429
- }
2430
-
2431
- prev.value += value;
2432
- append({ value });
2433
-
2434
- // when literal brackets are explicitly disabled
2435
- // assume we should match with a regex character class
2436
- if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
2437
- continue;
2438
- }
2439
-
2440
- const escaped = utils$2.escapeRegex(prev.value);
2441
- state.output = state.output.slice(0, -prev.value.length);
2442
-
2443
- // when literal brackets are explicitly enabled
2444
- // assume we should escape the brackets to match literal characters
2445
- if (opts.literalBrackets === true) {
2446
- state.output += escaped;
2447
- prev.value = escaped;
2448
- continue;
2449
- }
2450
-
2451
- // when the user specifies nothing, try to match both
2452
- prev.value = `(${capture}${escaped}|${prev.value})`;
2453
- state.output += prev.value;
2454
- continue;
2455
- }
2456
-
2457
- /**
2458
- * Braces
2459
- */
2460
-
2461
- if (value === '{' && opts.nobrace !== true) {
2462
- increment('braces');
2463
-
2464
- const open = {
2465
- type: 'brace',
2466
- value,
2467
- output: '(',
2468
- outputIndex: state.output.length,
2469
- tokensIndex: state.tokens.length
2470
- };
2471
-
2472
- braces.push(open);
2473
- push(open);
2474
- continue;
2475
- }
2476
-
2477
- if (value === '}') {
2478
- const brace = braces[braces.length - 1];
2479
-
2480
- if (opts.nobrace === true || !brace) {
2481
- push({ type: 'text', value, output: value });
2482
- continue;
2483
- }
2484
-
2485
- let output = ')';
2486
-
2487
- if (brace.dots === true) {
2488
- const arr = tokens.slice();
2489
- const range = [];
2490
-
2491
- for (let i = arr.length - 1; i >= 0; i--) {
2492
- tokens.pop();
2493
- if (arr[i].type === 'brace') {
2494
- break;
2495
- }
2496
- if (arr[i].type !== 'dots') {
2497
- range.unshift(arr[i].value);
2498
- }
2499
- }
2500
-
2501
- output = expandRange(range, opts);
2502
- state.backtrack = true;
2503
- }
2504
-
2505
- if (brace.comma !== true && brace.dots !== true) {
2506
- const out = state.output.slice(0, brace.outputIndex);
2507
- const toks = state.tokens.slice(brace.tokensIndex);
2508
- brace.value = brace.output = '\\{';
2509
- value = output = '\\}';
2510
- state.output = out;
2511
- for (const t of toks) {
2512
- state.output += (t.output || t.value);
2513
- }
2514
- }
2515
-
2516
- push({ type: 'brace', value, output });
2517
- decrement('braces');
2518
- braces.pop();
2519
- continue;
2520
- }
2521
-
2522
- /**
2523
- * Pipes
2524
- */
2525
-
2526
- if (value === '|') {
2527
- if (extglobs.length > 0) {
2528
- extglobs[extglobs.length - 1].conditions++;
2529
- }
2530
- push({ type: 'text', value });
2531
- continue;
2532
- }
2533
-
2534
- /**
2535
- * Commas
2536
- */
2537
-
2538
- if (value === ',') {
2539
- let output = value;
2540
-
2541
- const brace = braces[braces.length - 1];
2542
- if (brace && stack[stack.length - 1] === 'braces') {
2543
- brace.comma = true;
2544
- output = '|';
2545
- }
2546
-
2547
- push({ type: 'comma', value, output });
2548
- continue;
2549
- }
2550
-
2551
- /**
2552
- * Slashes
2553
- */
2554
-
2555
- if (value === '/') {
2556
- // if the beginning of the glob is "./", advance the start
2557
- // to the current index, and don't add the "./" characters
2558
- // to the state. This greatly simplifies lookbehinds when
2559
- // checking for BOS characters like "!" and "." (not "./")
2560
- if (prev.type === 'dot' && state.index === state.start + 1) {
2561
- state.start = state.index + 1;
2562
- state.consumed = '';
2563
- state.output = '';
2564
- tokens.pop();
2565
- prev = bos; // reset "prev" to the first token
2566
- continue;
2567
- }
2568
-
2569
- push({ type: 'slash', value, output: SLASH_LITERAL });
2570
- continue;
2571
- }
2572
-
2573
- /**
2574
- * Dots
2575
- */
2576
-
2577
- if (value === '.') {
2578
- if (state.braces > 0 && prev.type === 'dot') {
2579
- if (prev.value === '.') prev.output = DOT_LITERAL;
2580
- const brace = braces[braces.length - 1];
2581
- prev.type = 'dots';
2582
- prev.output += value;
2583
- prev.value += value;
2584
- brace.dots = true;
2585
- continue;
2586
- }
2587
-
2588
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
2589
- push({ type: 'text', value, output: DOT_LITERAL });
2590
- continue;
2591
- }
2592
-
2593
- push({ type: 'dot', value, output: DOT_LITERAL });
2594
- continue;
2595
- }
2596
-
2597
- /**
2598
- * Question marks
2599
- */
2600
-
2601
- if (value === '?') {
2602
- const isGroup = prev && prev.value === '(';
2603
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2604
- extglobOpen('qmark', value);
2605
- continue;
2606
- }
2607
-
2608
- if (prev && prev.type === 'paren') {
2609
- const next = peek();
2610
- let output = value;
2611
-
2612
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2613
- output = `\\${value}`;
2614
- }
2615
-
2616
- push({ type: 'text', value, output });
2617
- continue;
2618
- }
2619
-
2620
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2621
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
2622
- continue;
2623
- }
2624
-
2625
- push({ type: 'qmark', value, output: QMARK });
2626
- continue;
2627
- }
2628
-
2629
- /**
2630
- * Exclamation
2631
- */
2632
-
2633
- if (value === '!') {
2634
- if (opts.noextglob !== true && peek() === '(') {
2635
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2636
- extglobOpen('negate', value);
2637
- continue;
2638
- }
2639
- }
2640
-
2641
- if (opts.nonegate !== true && state.index === 0) {
2642
- negate();
2643
- continue;
2644
- }
2645
- }
2646
-
2647
- /**
2648
- * Plus
2649
- */
2650
-
2651
- if (value === '+') {
2652
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2653
- extglobOpen('plus', value);
2654
- continue;
2655
- }
2656
-
2657
- if ((prev && prev.value === '(') || opts.regex === false) {
2658
- push({ type: 'plus', value, output: PLUS_LITERAL });
2659
- continue;
2660
- }
2661
-
2662
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2663
- push({ type: 'plus', value });
2664
- continue;
2665
- }
2666
-
2667
- push({ type: 'plus', value: PLUS_LITERAL });
2668
- continue;
2669
- }
2670
-
2671
- /**
2672
- * Plain text
2673
- */
2674
-
2675
- if (value === '@') {
2676
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2677
- push({ type: 'at', extglob: true, value, output: '' });
2678
- continue;
2679
- }
2680
-
2681
- push({ type: 'text', value });
2682
- continue;
2683
- }
2684
-
2685
- /**
2686
- * Plain text
2687
- */
2688
-
2689
- if (value !== '*') {
2690
- if (value === '$' || value === '^') {
2691
- value = `\\${value}`;
2692
- }
2693
-
2694
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2695
- if (match) {
2696
- value += match[0];
2697
- state.index += match[0].length;
2698
- }
2699
-
2700
- push({ type: 'text', value });
2701
- continue;
2702
- }
2703
-
2704
- /**
2705
- * Stars
2706
- */
2707
-
2708
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
2709
- prev.type = 'star';
2710
- prev.star = true;
2711
- prev.value += value;
2712
- prev.output = star;
2713
- state.backtrack = true;
2714
- state.globstar = true;
2715
- consume(value);
2716
- continue;
2717
- }
2718
-
2719
- let rest = remaining();
2720
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
2721
- extglobOpen('star', value);
2722
- continue;
2723
- }
2724
-
2725
- if (prev.type === 'star') {
2726
- if (opts.noglobstar === true) {
2727
- consume(value);
2728
- continue;
2729
- }
2730
-
2731
- const prior = prev.prev;
2732
- const before = prior.prev;
2733
- const isStart = prior.type === 'slash' || prior.type === 'bos';
2734
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
2735
-
2736
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
2737
- push({ type: 'star', value, output: '' });
2738
- continue;
2739
- }
2740
-
2741
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
2742
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
2743
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
2744
- push({ type: 'star', value, output: '' });
2745
- continue;
2746
- }
2747
-
2748
- // strip consecutive `/**/`
2749
- while (rest.slice(0, 3) === '/**') {
2750
- const after = input[state.index + 4];
2751
- if (after && after !== '/') {
2752
- break;
2753
- }
2754
- rest = rest.slice(3);
2755
- consume('/**', 3);
2756
- }
2757
-
2758
- if (prior.type === 'bos' && eos()) {
2759
- prev.type = 'globstar';
2760
- prev.value += value;
2761
- prev.output = globstar(opts);
2762
- state.output = prev.output;
2763
- state.globstar = true;
2764
- consume(value);
2765
- continue;
2766
- }
2767
-
2768
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
2769
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
2770
- prior.output = `(?:${prior.output}`;
2771
-
2772
- prev.type = 'globstar';
2773
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
2774
- prev.value += value;
2775
- state.globstar = true;
2776
- state.output += prior.output + prev.output;
2777
- consume(value);
2778
- continue;
2779
- }
2780
-
2781
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
2782
- const end = rest[1] !== void 0 ? '|$' : '';
2783
-
2784
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
2785
- prior.output = `(?:${prior.output}`;
2786
-
2787
- prev.type = 'globstar';
2788
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
2789
- prev.value += value;
2790
-
2791
- state.output += prior.output + prev.output;
2792
- state.globstar = true;
2793
-
2794
- consume(value + advance());
2795
-
2796
- push({ type: 'slash', value: '/', output: '' });
2797
- continue;
2798
- }
2799
-
2800
- if (prior.type === 'bos' && rest[0] === '/') {
2801
- prev.type = 'globstar';
2802
- prev.value += value;
2803
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
2804
- state.output = prev.output;
2805
- state.globstar = true;
2806
- consume(value + advance());
2807
- push({ type: 'slash', value: '/', output: '' });
2808
- continue;
2809
- }
2810
-
2811
- // remove single star from output
2812
- state.output = state.output.slice(0, -prev.output.length);
2813
-
2814
- // reset previous token to globstar
2815
- prev.type = 'globstar';
2816
- prev.output = globstar(opts);
2817
- prev.value += value;
2818
-
2819
- // reset output with globstar
2820
- state.output += prev.output;
2821
- state.globstar = true;
2822
- consume(value);
2823
- continue;
2824
- }
2825
-
2826
- const token = { type: 'star', value, output: star };
2827
-
2828
- if (opts.bash === true) {
2829
- token.output = '.*?';
2830
- if (prev.type === 'bos' || prev.type === 'slash') {
2831
- token.output = nodot + token.output;
2832
- }
2833
- push(token);
2834
- continue;
2835
- }
2836
-
2837
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
2838
- token.output = value;
2839
- push(token);
2840
- continue;
2841
- }
2842
-
2843
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
2844
- if (prev.type === 'dot') {
2845
- state.output += NO_DOT_SLASH;
2846
- prev.output += NO_DOT_SLASH;
2847
-
2848
- } else if (opts.dot === true) {
2849
- state.output += NO_DOTS_SLASH;
2850
- prev.output += NO_DOTS_SLASH;
2851
-
2852
- } else {
2853
- state.output += nodot;
2854
- prev.output += nodot;
2855
- }
2856
-
2857
- if (peek() !== '*') {
2858
- state.output += ONE_CHAR;
2859
- prev.output += ONE_CHAR;
2860
- }
2861
- }
2862
-
2863
- push(token);
2864
- }
2865
-
2866
- while (state.brackets > 0) {
2867
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
2868
- state.output = utils$2.escapeLast(state.output, '[');
2869
- decrement('brackets');
2870
- }
2871
-
2872
- while (state.parens > 0) {
2873
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
2874
- state.output = utils$2.escapeLast(state.output, '(');
2875
- decrement('parens');
2876
- }
2877
-
2878
- while (state.braces > 0) {
2879
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
2880
- state.output = utils$2.escapeLast(state.output, '{');
2881
- decrement('braces');
2882
- }
2883
-
2884
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
2885
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
2886
- }
2887
-
2888
- // rebuild the output if we had to backtrack at any point
2889
- if (state.backtrack === true) {
2890
- state.output = '';
2891
-
2892
- for (const token of state.tokens) {
2893
- state.output += token.output != null ? token.output : token.value;
2894
-
2895
- if (token.suffix) {
2896
- state.output += token.suffix;
2897
- }
2898
- }
2899
- }
2900
-
2901
- return state;
2902
- };
2903
-
2904
- /**
2905
- * Fast paths for creating regular expressions for common glob patterns.
2906
- * This can significantly speed up processing and has very little downside
2907
- * impact when none of the fast paths match.
2908
- */
2909
-
2910
- parse$2.fastpaths = (input, options) => {
2911
- const opts = { ...options };
2912
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2913
- const len = input.length;
2914
- if (len > max) {
2915
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2916
- }
2917
-
2918
- input = REPLACEMENTS[input] || input;
2919
-
2920
- // create constants based on platform, for windows or posix
2921
- const {
2922
- DOT_LITERAL,
2923
- SLASH_LITERAL,
2924
- ONE_CHAR,
2925
- DOTS_SLASH,
2926
- NO_DOT,
2927
- NO_DOTS,
2928
- NO_DOTS_SLASH,
2929
- STAR,
2930
- START_ANCHOR
2931
- } = constants$1.globChars(opts.windows);
2932
-
2933
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
2934
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
2935
- const capture = opts.capture ? '' : '?:';
2936
- const state = { negated: false, prefix: '' };
2937
- let star = opts.bash === true ? '.*?' : STAR;
2938
-
2939
- if (opts.capture) {
2940
- star = `(${star})`;
2941
- }
2942
-
2943
- const globstar = opts => {
2944
- if (opts.noglobstar === true) return star;
2945
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2946
- };
2947
-
2948
- const create = str => {
2949
- switch (str) {
2950
- case '*':
2951
- return `${nodot}${ONE_CHAR}${star}`;
2952
-
2953
- case '.*':
2954
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
2955
-
2956
- case '*.*':
2957
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2958
-
2959
- case '*/*':
2960
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
2961
-
2962
- case '**':
2963
- return nodot + globstar(opts);
2964
-
2965
- case '**/*':
2966
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
2967
-
2968
- case '**/*.*':
2969
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2970
-
2971
- case '**/.*':
2972
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
2973
-
2974
- default: {
2975
- const match = /^(.*?)\.(\w+)$/.exec(str);
2976
- if (!match) return;
2977
-
2978
- const source = create(match[1]);
2979
- if (!source) return;
2980
-
2981
- return source + DOT_LITERAL + match[2];
2982
- }
2983
- }
2984
- };
2985
-
2986
- const output = utils$2.removePrefix(input, state);
2987
- let source = create(output);
2988
-
2989
- if (source && opts.strictSlashes !== true) {
2990
- source += `${SLASH_LITERAL}?`;
2991
- }
2992
-
2993
- return source;
2994
- };
2995
-
2996
- var parse_1$1 = parse$2;
2997
-
2998
- const scan = scan_1;
2999
- const parse$1 = parse_1$1;
3000
- const utils$1 = utils$4;
3001
- const constants = constants$2;
3002
- const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
3003
-
3004
- /**
3005
- * Creates a matcher function from one or more glob patterns. The
3006
- * returned function takes a string to match as its first argument,
3007
- * and returns true if the string is a match. The returned matcher
3008
- * function also takes a boolean as the second argument that, when true,
3009
- * returns an object with additional information.
3010
- *
3011
- * ```js
3012
- * const picomatch = require('picomatch');
3013
- * // picomatch(glob[, options]);
3014
- *
3015
- * const isMatch = picomatch('*.!(*a)');
3016
- * console.log(isMatch('a.a')); //=> false
3017
- * console.log(isMatch('a.b')); //=> true
3018
- * ```
3019
- * @name picomatch
3020
- * @param {String|Array} `globs` One or more glob patterns.
3021
- * @param {Object=} `options`
3022
- * @return {Function=} Returns a matcher function.
3023
- * @api public
3024
- */
547
+ });
3025
548
 
3026
- const picomatch$1 = (glob, options, returnState = false) => {
3027
- if (Array.isArray(glob)) {
3028
- const fns = glob.map(input => picomatch$1(input, options, returnState));
3029
- const arrayMatcher = str => {
3030
- for (const isMatch of fns) {
3031
- const state = isMatch(str);
3032
- if (state) return state;
3033
- }
3034
- return false;
3035
- };
3036
- return arrayMatcher;
3037
- }
549
+ // Env-specific initialization logic for debug instances
550
+ if (typeof createDebug.init === 'function') {
551
+ createDebug.init(debug);
552
+ }
3038
553
 
3039
- const isState = isObject$2(glob) && glob.tokens && glob.input;
554
+ return debug;
555
+ }
3040
556
 
3041
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
3042
- throw new TypeError('Expected pattern to be a non-empty string');
3043
- }
557
+ function extend(namespace, delimiter) {
558
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
559
+ newDebug.log = this.log;
560
+ return newDebug;
561
+ }
3044
562
 
3045
- const opts = options || {};
3046
- const posix = opts.windows;
3047
- const regex = isState
3048
- ? picomatch$1.compileRe(glob, options)
3049
- : picomatch$1.makeRe(glob, options, false, true);
563
+ /**
564
+ * Enables a debug mode by namespaces. This can include modes
565
+ * separated by a colon and wildcards.
566
+ *
567
+ * @param {String} namespaces
568
+ * @api public
569
+ */
570
+ function enable(namespaces) {
571
+ createDebug.save(namespaces);
572
+ createDebug.namespaces = namespaces;
3050
573
 
3051
- const state = regex.state;
3052
- delete regex.state;
574
+ createDebug.names = [];
575
+ createDebug.skips = [];
3053
576
 
3054
- let isIgnored = () => false;
3055
- if (opts.ignore) {
3056
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3057
- isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
3058
- }
577
+ const split = (typeof namespaces === 'string' ? namespaces : '')
578
+ .trim()
579
+ .replace(' ', ',')
580
+ .split(',')
581
+ .filter(Boolean);
3059
582
 
3060
- const matcher = (input, returnObject = false) => {
3061
- const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
3062
- const result = { glob, state, regex, posix, input, output, match, isMatch };
583
+ for (const ns of split) {
584
+ if (ns[0] === '-') {
585
+ createDebug.skips.push(ns.slice(1));
586
+ } else {
587
+ createDebug.names.push(ns);
588
+ }
589
+ }
590
+ }
3063
591
 
3064
- if (typeof opts.onResult === 'function') {
3065
- opts.onResult(result);
3066
- }
592
+ /**
593
+ * Checks if the given string matches a namespace template, honoring
594
+ * asterisks as wildcards.
595
+ *
596
+ * @param {String} search
597
+ * @param {String} template
598
+ * @return {Boolean}
599
+ */
600
+ function matchesTemplate(search, template) {
601
+ let searchIndex = 0;
602
+ let templateIndex = 0;
603
+ let starIndex = -1;
604
+ let matchIndex = 0;
3067
605
 
3068
- if (isMatch === false) {
3069
- result.isMatch = false;
3070
- return returnObject ? result : false;
3071
- }
606
+ while (searchIndex < search.length) {
607
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
608
+ // Match character or proceed with wildcard
609
+ if (template[templateIndex] === '*') {
610
+ starIndex = templateIndex;
611
+ matchIndex = searchIndex;
612
+ templateIndex++; // Skip the '*'
613
+ } else {
614
+ searchIndex++;
615
+ templateIndex++;
616
+ }
617
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
618
+ // Backtrack to the last '*' and try to match more characters
619
+ templateIndex = starIndex + 1;
620
+ matchIndex++;
621
+ searchIndex = matchIndex;
622
+ } else {
623
+ return false; // No match
624
+ }
625
+ }
3072
626
 
3073
- if (isIgnored(input)) {
3074
- if (typeof opts.onIgnore === 'function') {
3075
- opts.onIgnore(result);
3076
- }
3077
- result.isMatch = false;
3078
- return returnObject ? result : false;
3079
- }
627
+ // Handle trailing '*' in template
628
+ while (templateIndex < template.length && template[templateIndex] === '*') {
629
+ templateIndex++;
630
+ }
3080
631
 
3081
- if (typeof opts.onMatch === 'function') {
3082
- opts.onMatch(result);
3083
- }
3084
- return returnObject ? result : true;
3085
- };
632
+ return templateIndex === template.length;
633
+ }
3086
634
 
3087
- if (returnState) {
3088
- matcher.state = state;
3089
- }
635
+ /**
636
+ * Disable debug output.
637
+ *
638
+ * @return {String} namespaces
639
+ * @api public
640
+ */
641
+ function disable() {
642
+ const namespaces = [
643
+ ...createDebug.names,
644
+ ...createDebug.skips.map(namespace => '-' + namespace)
645
+ ].join(',');
646
+ createDebug.enable('');
647
+ return namespaces;
648
+ }
3090
649
 
3091
- return matcher;
3092
- };
650
+ /**
651
+ * Returns true if the given mode name is enabled, false otherwise.
652
+ *
653
+ * @param {String} name
654
+ * @return {Boolean}
655
+ * @api public
656
+ */
657
+ function enabled(name) {
658
+ for (const skip of createDebug.skips) {
659
+ if (matchesTemplate(name, skip)) {
660
+ return false;
661
+ }
662
+ }
3093
663
 
3094
- /**
3095
- * Test `input` with the given `regex`. This is used by the main
3096
- * `picomatch()` function to test the input string.
3097
- *
3098
- * ```js
3099
- * const picomatch = require('picomatch');
3100
- * // picomatch.test(input, regex[, options]);
3101
- *
3102
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3103
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3104
- * ```
3105
- * @param {String} `input` String to test.
3106
- * @param {RegExp} `regex`
3107
- * @return {Object} Returns an object with matching info.
3108
- * @api public
3109
- */
664
+ for (const ns of createDebug.names) {
665
+ if (matchesTemplate(name, ns)) {
666
+ return true;
667
+ }
668
+ }
3110
669
 
3111
- picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3112
- if (typeof input !== 'string') {
3113
- throw new TypeError('Expected input to be a string');
3114
- }
670
+ return false;
671
+ }
3115
672
 
3116
- if (input === '') {
3117
- return { isMatch: false, output: '' };
3118
- }
673
+ /**
674
+ * Coerce `val`.
675
+ *
676
+ * @param {Mixed} val
677
+ * @return {Mixed}
678
+ * @api private
679
+ */
680
+ function coerce(val) {
681
+ if (val instanceof Error) {
682
+ return val.stack || val.message;
683
+ }
684
+ return val;
685
+ }
3119
686
 
3120
- const opts = options || {};
3121
- const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
3122
- let match = input === glob;
3123
- let output = (match && format) ? format(input) : input;
687
+ /**
688
+ * XXX DO NOT USE. This is a temporary stub function.
689
+ * XXX It WILL be removed in the next major release.
690
+ */
691
+ function destroy() {
692
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
693
+ }
3124
694
 
3125
- if (match === false) {
3126
- output = format ? format(input) : input;
3127
- match = output === glob;
3128
- }
695
+ createDebug.enable(createDebug.load());
3129
696
 
3130
- if (match === false || opts.capture === true) {
3131
- if (opts.matchBase === true || opts.basename === true) {
3132
- match = picomatch$1.matchBase(input, regex, options, posix);
3133
- } else {
3134
- match = regex.exec(output);
3135
- }
3136
- }
697
+ return createDebug;
698
+ }
3137
699
 
3138
- return { isMatch: Boolean(match), match, output };
3139
- };
700
+ common = setup;
701
+ return common;
702
+ }
3140
703
 
3141
704
  /**
3142
- * Match the basename of a filepath.
3143
- *
3144
- * ```js
3145
- * const picomatch = require('picomatch');
3146
- * // picomatch.matchBase(input, glob[, options]);
3147
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3148
- * ```
3149
- * @param {String} `input` String to test.
3150
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3151
- * @return {Boolean}
3152
- * @api public
705
+ * Module dependencies.
3153
706
  */
3154
707
 
3155
- picomatch$1.matchBase = (input, glob, options) => {
3156
- const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
3157
- return regex.test(utils$1.basename(input));
3158
- };
708
+ (function (module, exports) {
709
+ const tty = require$$0;
710
+ const util = require$$1;
3159
711
 
3160
- /**
3161
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
3162
- *
3163
- * ```js
3164
- * const picomatch = require('picomatch');
3165
- * // picomatch.isMatch(string, patterns[, options]);
3166
- *
3167
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3168
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3169
- * ```
3170
- * @param {String|Array} str The string to test.
3171
- * @param {String|Array} patterns One or more glob patterns to use for matching.
3172
- * @param {Object} [options] See available [options](#options).
3173
- * @return {Boolean} Returns true if any patterns match `str`
3174
- * @api public
3175
- */
712
+ /**
713
+ * This is the Node.js implementation of `debug()`.
714
+ */
3176
715
 
3177
- picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
716
+ exports.init = init;
717
+ exports.log = log;
718
+ exports.formatArgs = formatArgs;
719
+ exports.save = save;
720
+ exports.load = load;
721
+ exports.useColors = useColors;
722
+ exports.destroy = util.deprecate(
723
+ () => {},
724
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
725
+ );
3178
726
 
3179
- /**
3180
- * Parse a glob pattern to create the source string for a regular
3181
- * expression.
3182
- *
3183
- * ```js
3184
- * const picomatch = require('picomatch');
3185
- * const result = picomatch.parse(pattern[, options]);
3186
- * ```
3187
- * @param {String} `pattern`
3188
- * @param {Object} `options`
3189
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3190
- * @api public
3191
- */
727
+ /**
728
+ * Colors.
729
+ */
3192
730
 
3193
- picomatch$1.parse = (pattern, options) => {
3194
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
3195
- return parse$1(pattern, { ...options, fastpaths: false });
3196
- };
731
+ exports.colors = [6, 2, 3, 4, 5, 1];
732
+
733
+ try {
734
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
735
+ // eslint-disable-next-line import/no-extraneous-dependencies
736
+ const supportsColor = require('supports-color');
737
+
738
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
739
+ exports.colors = [
740
+ 20,
741
+ 21,
742
+ 26,
743
+ 27,
744
+ 32,
745
+ 33,
746
+ 38,
747
+ 39,
748
+ 40,
749
+ 41,
750
+ 42,
751
+ 43,
752
+ 44,
753
+ 45,
754
+ 56,
755
+ 57,
756
+ 62,
757
+ 63,
758
+ 68,
759
+ 69,
760
+ 74,
761
+ 75,
762
+ 76,
763
+ 77,
764
+ 78,
765
+ 79,
766
+ 80,
767
+ 81,
768
+ 92,
769
+ 93,
770
+ 98,
771
+ 99,
772
+ 112,
773
+ 113,
774
+ 128,
775
+ 129,
776
+ 134,
777
+ 135,
778
+ 148,
779
+ 149,
780
+ 160,
781
+ 161,
782
+ 162,
783
+ 163,
784
+ 164,
785
+ 165,
786
+ 166,
787
+ 167,
788
+ 168,
789
+ 169,
790
+ 170,
791
+ 171,
792
+ 172,
793
+ 173,
794
+ 178,
795
+ 179,
796
+ 184,
797
+ 185,
798
+ 196,
799
+ 197,
800
+ 198,
801
+ 199,
802
+ 200,
803
+ 201,
804
+ 202,
805
+ 203,
806
+ 204,
807
+ 205,
808
+ 206,
809
+ 207,
810
+ 208,
811
+ 209,
812
+ 214,
813
+ 215,
814
+ 220,
815
+ 221
816
+ ];
817
+ }
818
+ } catch (error) {
819
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
820
+ }
3197
821
 
3198
- /**
3199
- * Scan a glob pattern to separate the pattern into segments.
3200
- *
3201
- * ```js
3202
- * const picomatch = require('picomatch');
3203
- * // picomatch.scan(input[, options]);
3204
- *
3205
- * const result = picomatch.scan('!./foo/*.js');
3206
- * console.log(result);
3207
- * { prefix: '!./',
3208
- * input: '!./foo/*.js',
3209
- * start: 3,
3210
- * base: 'foo',
3211
- * glob: '*.js',
3212
- * isBrace: false,
3213
- * isBracket: false,
3214
- * isGlob: true,
3215
- * isExtglob: false,
3216
- * isGlobstar: false,
3217
- * negated: true }
3218
- * ```
3219
- * @param {String} `input` Glob pattern to scan.
3220
- * @param {Object} `options`
3221
- * @return {Object} Returns an object with
3222
- * @api public
3223
- */
822
+ /**
823
+ * Build up the default `inspectOpts` object from the environment variables.
824
+ *
825
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
826
+ */
827
+
828
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
829
+ return /^debug_/i.test(key);
830
+ }).reduce((obj, key) => {
831
+ // Camel-case
832
+ const prop = key
833
+ .substring(6)
834
+ .toLowerCase()
835
+ .replace(/_([a-z])/g, (_, k) => {
836
+ return k.toUpperCase();
837
+ });
3224
838
 
3225
- picomatch$1.scan = (input, options) => scan(input, options);
839
+ // Coerce string value into JS value
840
+ let val = process.env[key];
841
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
842
+ val = true;
843
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
844
+ val = false;
845
+ } else if (val === 'null') {
846
+ val = null;
847
+ } else {
848
+ val = Number(val);
849
+ }
3226
850
 
3227
- /**
3228
- * Compile a regular expression from the `state` object returned by the
3229
- * [parse()](#parse) method.
3230
- *
3231
- * @param {Object} `state`
3232
- * @param {Object} `options`
3233
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3234
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3235
- * @return {RegExp}
3236
- * @api public
3237
- */
851
+ obj[prop] = val;
852
+ return obj;
853
+ }, {});
3238
854
 
3239
- picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
3240
- if (returnOutput === true) {
3241
- return state.output;
3242
- }
855
+ /**
856
+ * Is stdout a TTY? Colored output is enabled when `true`.
857
+ */
3243
858
 
3244
- const opts = options || {};
3245
- const prepend = opts.contains ? '' : '^';
3246
- const append = opts.contains ? '' : '$';
859
+ function useColors() {
860
+ return 'colors' in exports.inspectOpts ?
861
+ Boolean(exports.inspectOpts.colors) :
862
+ tty.isatty(process.stderr.fd);
863
+ }
3247
864
 
3248
- let source = `${prepend}(?:${state.output})${append}`;
3249
- if (state && state.negated === true) {
3250
- source = `^(?!${source}).*$`;
3251
- }
865
+ /**
866
+ * Adds ANSI color escape codes if enabled.
867
+ *
868
+ * @api public
869
+ */
3252
870
 
3253
- const regex = picomatch$1.toRegex(source, options);
3254
- if (returnState === true) {
3255
- regex.state = state;
3256
- }
871
+ function formatArgs(args) {
872
+ const {namespace: name, useColors} = this;
3257
873
 
3258
- return regex;
3259
- };
874
+ if (useColors) {
875
+ const c = this.color;
876
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
877
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
3260
878
 
3261
- /**
3262
- * Create a regular expression from a parsed glob pattern.
3263
- *
3264
- * ```js
3265
- * const picomatch = require('picomatch');
3266
- * const state = picomatch.parse('*.js');
3267
- * // picomatch.compileRe(state[, options]);
3268
- *
3269
- * console.log(picomatch.compileRe(state));
3270
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3271
- * ```
3272
- * @param {String} `state` The object returned from the `.parse` method.
3273
- * @param {Object} `options`
3274
- * @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.
3275
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3276
- * @return {RegExp} Returns a regex created from the given pattern.
3277
- * @api public
3278
- */
879
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
880
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
881
+ } else {
882
+ args[0] = getDate() + name + ' ' + args[0];
883
+ }
884
+ }
3279
885
 
3280
- picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3281
- if (!input || typeof input !== 'string') {
3282
- throw new TypeError('Expected a non-empty string');
3283
- }
886
+ function getDate() {
887
+ if (exports.inspectOpts.hideDate) {
888
+ return '';
889
+ }
890
+ return new Date().toISOString() + ' ';
891
+ }
3284
892
 
3285
- let parsed = { negated: false, fastpaths: true };
893
+ /**
894
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
895
+ */
3286
896
 
3287
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3288
- parsed.output = parse$1.fastpaths(input, options);
3289
- }
897
+ function log(...args) {
898
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
899
+ }
3290
900
 
3291
- if (!parsed.output) {
3292
- parsed = parse$1(input, options);
3293
- }
901
+ /**
902
+ * Save `namespaces`.
903
+ *
904
+ * @param {String} namespaces
905
+ * @api private
906
+ */
907
+ function save(namespaces) {
908
+ if (namespaces) {
909
+ process.env.DEBUG = namespaces;
910
+ } else {
911
+ // If you set a process.env field to null or undefined, it gets cast to the
912
+ // string 'null' or 'undefined'. Just delete instead.
913
+ delete process.env.DEBUG;
914
+ }
915
+ }
3294
916
 
3295
- return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
3296
- };
917
+ /**
918
+ * Load `namespaces`.
919
+ *
920
+ * @return {String} returns the previously persisted debug modes
921
+ * @api private
922
+ */
3297
923
 
3298
- /**
3299
- * Create a regular expression from the given regex source string.
3300
- *
3301
- * ```js
3302
- * const picomatch = require('picomatch');
3303
- * // picomatch.toRegex(source[, options]);
3304
- *
3305
- * const { output } = picomatch.parse('*.js');
3306
- * console.log(picomatch.toRegex(output));
3307
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3308
- * ```
3309
- * @param {String} `source` Regular expression source string.
3310
- * @param {Object} `options`
3311
- * @return {RegExp}
3312
- * @api public
3313
- */
924
+ function load() {
925
+ return process.env.DEBUG;
926
+ }
3314
927
 
3315
- picomatch$1.toRegex = (source, options) => {
3316
- try {
3317
- const opts = options || {};
3318
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3319
- } catch (err) {
3320
- if (options && options.debug === true) throw err;
3321
- return /$^/;
3322
- }
3323
- };
928
+ /**
929
+ * Init logic for `debug` instances.
930
+ *
931
+ * Create a new `inspectOpts` object in case `useColors` is set
932
+ * differently for a particular `debug` instance.
933
+ */
3324
934
 
3325
- /**
3326
- * Picomatch constants.
3327
- * @return {Object}
3328
- */
935
+ function init(debug) {
936
+ debug.inspectOpts = {};
3329
937
 
3330
- picomatch$1.constants = constants;
938
+ const keys = Object.keys(exports.inspectOpts);
939
+ for (let i = 0; i < keys.length; i++) {
940
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
941
+ }
942
+ }
3331
943
 
3332
- /**
3333
- * Expose "picomatch"
3334
- */
944
+ module.exports = requireCommon()(exports);
3335
945
 
3336
- var picomatch_1$1 = picomatch$1;
946
+ const {formatters} = module.exports;
3337
947
 
3338
- const pico = picomatch_1$1;
3339
- const utils = utils$4;
948
+ /**
949
+ * Map %o to `util.inspect()`, all on a single line.
950
+ */
3340
951
 
3341
- function picomatch(glob, options, returnState = false) {
3342
- // default to os.platform()
3343
- if (options && (options.windows === null || options.windows === undefined)) {
3344
- // don't mutate the original options object
3345
- options = { ...options, windows: utils.isWindows() };
3346
- }
952
+ formatters.o = function (v) {
953
+ this.inspectOpts.colors = this.useColors;
954
+ return util.inspect(v, this.inspectOpts)
955
+ .split('\n')
956
+ .map(str => str.trim())
957
+ .join(' ');
958
+ };
3347
959
 
3348
- return pico(glob, options, returnState);
3349
- }
960
+ /**
961
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
962
+ */
3350
963
 
3351
- Object.assign(picomatch, pico);
3352
- var picomatch_1 = picomatch;
964
+ formatters.O = function (v) {
965
+ this.inspectOpts.colors = this.useColors;
966
+ return util.inspect(v, this.inspectOpts);
967
+ };
968
+ } (node, node.exports));
3353
969
 
3354
- var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch_1);
970
+ var nodeExports = node.exports;
971
+ var debug$3 = /*@__PURE__*/getDefaultExportFromCjs(nodeExports);
3355
972
 
3356
973
  // Helper since Typescript can't detect readonly arrays with Array.isArray
3357
974
  function isArray(arg) {
@@ -6275,16 +3892,19 @@ var expand_1 = expand;
6275
3892
 
6276
3893
  const debug = createDebugger("vite:env");
6277
3894
  function getEnvFilesForMode(mode, envDir) {
6278
- return [
6279
- /** default file */
6280
- `.env`,
6281
- /** local file */
6282
- `.env.local`,
6283
- /** mode file */
6284
- `.env.${mode}`,
6285
- /** mode local file */
6286
- `.env.${mode}.local`
6287
- ].map((file) => normalizePath(path$1.join(envDir, file)));
3895
+ if (envDir !== false) {
3896
+ return [
3897
+ /** default file */
3898
+ `.env`,
3899
+ /** local file */
3900
+ `.env.local`,
3901
+ /** mode file */
3902
+ `.env.${mode}`,
3903
+ /** mode local file */
3904
+ `.env.${mode}.local`
3905
+ ].map((file) => normalizePath(path$1.join(envDir, file)));
3906
+ }
3907
+ return [];
6288
3908
  }
6289
3909
  function loadEnv(mode, envDir, prefixes = "VITE_") {
6290
3910
  const start = performance.now();