rollup 4.60.0 → 4.60.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.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +358 -17
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +614 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +614 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +358 -17
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +32 -32
package/dist/es/shared/watch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.60.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.60.1
|
|
4
|
+
Mon, 30 Mar 2026 04:32:12 GMT - commit ae871d762f6bbeb4320d28fe179211168f27a434
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -37,6 +37,8 @@ function requireConstants$3 () {
|
|
|
37
37
|
const WIN_SLASH = '\\\\/';
|
|
38
38
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
39
39
|
|
|
40
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
41
|
+
|
|
40
42
|
/**
|
|
41
43
|
* Posix glob regex
|
|
42
44
|
*/
|
|
@@ -100,6 +102,7 @@ function requireConstants$3 () {
|
|
|
100
102
|
*/
|
|
101
103
|
|
|
102
104
|
const POSIX_REGEX_SOURCE = {
|
|
105
|
+
__proto__: null,
|
|
103
106
|
alnum: 'a-zA-Z0-9',
|
|
104
107
|
alpha: 'a-zA-Z',
|
|
105
108
|
ascii: '\\x00-\\x7F',
|
|
@@ -117,6 +120,7 @@ function requireConstants$3 () {
|
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
constants$3 = {
|
|
123
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
120
124
|
MAX_LENGTH: 1024 * 64,
|
|
121
125
|
POSIX_REGEX_SOURCE,
|
|
122
126
|
|
|
@@ -130,6 +134,7 @@ function requireConstants$3 () {
|
|
|
130
134
|
|
|
131
135
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
132
136
|
REPLACEMENTS: {
|
|
137
|
+
__proto__: null,
|
|
133
138
|
'***': '*',
|
|
134
139
|
'**/**': '**',
|
|
135
140
|
'**/**/**': '**'
|
|
@@ -730,6 +735,277 @@ function requireParse$2 () {
|
|
|
730
735
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
731
736
|
};
|
|
732
737
|
|
|
738
|
+
const splitTopLevel = input => {
|
|
739
|
+
const parts = [];
|
|
740
|
+
let bracket = 0;
|
|
741
|
+
let paren = 0;
|
|
742
|
+
let quote = 0;
|
|
743
|
+
let value = '';
|
|
744
|
+
let escaped = false;
|
|
745
|
+
|
|
746
|
+
for (const ch of input) {
|
|
747
|
+
if (escaped === true) {
|
|
748
|
+
value += ch;
|
|
749
|
+
escaped = false;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (ch === '\\') {
|
|
754
|
+
value += ch;
|
|
755
|
+
escaped = true;
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
if (ch === '"') {
|
|
760
|
+
quote = quote === 1 ? 0 : 1;
|
|
761
|
+
value += ch;
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (quote === 0) {
|
|
766
|
+
if (ch === '[') {
|
|
767
|
+
bracket++;
|
|
768
|
+
} else if (ch === ']' && bracket > 0) {
|
|
769
|
+
bracket--;
|
|
770
|
+
} else if (bracket === 0) {
|
|
771
|
+
if (ch === '(') {
|
|
772
|
+
paren++;
|
|
773
|
+
} else if (ch === ')' && paren > 0) {
|
|
774
|
+
paren--;
|
|
775
|
+
} else if (ch === '|' && paren === 0) {
|
|
776
|
+
parts.push(value);
|
|
777
|
+
value = '';
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
value += ch;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
parts.push(value);
|
|
787
|
+
return parts;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
const isPlainBranch = branch => {
|
|
791
|
+
let escaped = false;
|
|
792
|
+
|
|
793
|
+
for (const ch of branch) {
|
|
794
|
+
if (escaped === true) {
|
|
795
|
+
escaped = false;
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (ch === '\\') {
|
|
800
|
+
escaped = true;
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
return true;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
const normalizeSimpleBranch = branch => {
|
|
813
|
+
let value = branch.trim();
|
|
814
|
+
let changed = true;
|
|
815
|
+
|
|
816
|
+
while (changed === true) {
|
|
817
|
+
changed = false;
|
|
818
|
+
|
|
819
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
820
|
+
value = value.slice(2, -1);
|
|
821
|
+
changed = true;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (!isPlainBranch(value)) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return value.replace(/\\(.)/g, '$1');
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
833
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
834
|
+
|
|
835
|
+
for (let i = 0; i < values.length; i++) {
|
|
836
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
837
|
+
const a = values[i];
|
|
838
|
+
const b = values[j];
|
|
839
|
+
const char = a[0];
|
|
840
|
+
|
|
841
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
846
|
+
return true;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
return false;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
855
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
let bracket = 0;
|
|
860
|
+
let paren = 0;
|
|
861
|
+
let quote = 0;
|
|
862
|
+
let escaped = false;
|
|
863
|
+
|
|
864
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
865
|
+
const ch = pattern[i];
|
|
866
|
+
|
|
867
|
+
if (escaped === true) {
|
|
868
|
+
escaped = false;
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (ch === '\\') {
|
|
873
|
+
escaped = true;
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (ch === '"') {
|
|
878
|
+
quote = quote === 1 ? 0 : 1;
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (quote === 1) {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if (ch === '[') {
|
|
887
|
+
bracket++;
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
if (ch === ']' && bracket > 0) {
|
|
892
|
+
bracket--;
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (bracket > 0) {
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
if (ch === '(') {
|
|
901
|
+
paren++;
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
if (ch === ')') {
|
|
906
|
+
paren--;
|
|
907
|
+
|
|
908
|
+
if (paren === 0) {
|
|
909
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
return {
|
|
914
|
+
type: pattern[0],
|
|
915
|
+
body: pattern.slice(2, i),
|
|
916
|
+
end: i
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
924
|
+
let index = 0;
|
|
925
|
+
const chars = [];
|
|
926
|
+
|
|
927
|
+
while (index < pattern.length) {
|
|
928
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
929
|
+
|
|
930
|
+
if (!match || match.type !== '*') {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
935
|
+
if (branches.length !== 1) {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
940
|
+
if (!branch || branch.length !== 1) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
chars.push(branch);
|
|
945
|
+
index += match.end + 1;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (chars.length < 1) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const source = chars.length === 1
|
|
953
|
+
? utils.escapeRegex(chars[0])
|
|
954
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
955
|
+
|
|
956
|
+
return `${source}*`;
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
const repeatedExtglobRecursion = pattern => {
|
|
960
|
+
let depth = 0;
|
|
961
|
+
let value = pattern.trim();
|
|
962
|
+
let match = parseRepeatedExtglob(value);
|
|
963
|
+
|
|
964
|
+
while (match) {
|
|
965
|
+
depth++;
|
|
966
|
+
value = match.body.trim();
|
|
967
|
+
match = parseRepeatedExtglob(value);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
return depth;
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
974
|
+
if (options.maxExtglobRecursion === false) {
|
|
975
|
+
return { risky: false };
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
const max =
|
|
979
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
980
|
+
? options.maxExtglobRecursion
|
|
981
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
982
|
+
|
|
983
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
984
|
+
|
|
985
|
+
if (branches.length > 1) {
|
|
986
|
+
if (
|
|
987
|
+
branches.some(branch => branch === '') ||
|
|
988
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
989
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
990
|
+
) {
|
|
991
|
+
return { risky: true };
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
for (const branch of branches) {
|
|
996
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
997
|
+
if (safeOutput) {
|
|
998
|
+
return { risky: true, safeOutput };
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
1002
|
+
return { risky: true };
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return { risky: false };
|
|
1007
|
+
};
|
|
1008
|
+
|
|
733
1009
|
/**
|
|
734
1010
|
* Parse the given input string.
|
|
735
1011
|
* @param {String} input
|
|
@@ -911,6 +1187,8 @@ function requireParse$2 () {
|
|
|
911
1187
|
token.prev = prev;
|
|
912
1188
|
token.parens = state.parens;
|
|
913
1189
|
token.output = state.output;
|
|
1190
|
+
token.startIndex = state.index;
|
|
1191
|
+
token.tokensIndex = tokens.length;
|
|
914
1192
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
915
1193
|
|
|
916
1194
|
increment('parens');
|
|
@@ -920,6 +1198,34 @@ function requireParse$2 () {
|
|
|
920
1198
|
};
|
|
921
1199
|
|
|
922
1200
|
const extglobClose = token => {
|
|
1201
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
1202
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
1203
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
1204
|
+
|
|
1205
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
1206
|
+
const safeOutput = analysis.safeOutput
|
|
1207
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
1208
|
+
: undefined;
|
|
1209
|
+
const open = tokens[token.tokensIndex];
|
|
1210
|
+
|
|
1211
|
+
open.type = 'text';
|
|
1212
|
+
open.value = literal;
|
|
1213
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
1214
|
+
|
|
1215
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1216
|
+
tokens[i].value = '';
|
|
1217
|
+
tokens[i].output = '';
|
|
1218
|
+
delete tokens[i].suffix;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
state.output = token.output + open.output;
|
|
1222
|
+
state.backtrack = true;
|
|
1223
|
+
|
|
1224
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
1225
|
+
decrement('parens');
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
923
1229
|
let output = token.close + (opts.capture ? ')' : '');
|
|
924
1230
|
let rest;
|
|
925
1231
|
|
|
@@ -2448,6 +2754,8 @@ function requireConstants$2 () {
|
|
|
2448
2754
|
const WIN_SLASH = '\\\\/';
|
|
2449
2755
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2450
2756
|
|
|
2757
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
2758
|
+
|
|
2451
2759
|
/**
|
|
2452
2760
|
* Posix glob regex
|
|
2453
2761
|
*/
|
|
@@ -2511,6 +2819,7 @@ function requireConstants$2 () {
|
|
|
2511
2819
|
*/
|
|
2512
2820
|
|
|
2513
2821
|
const POSIX_REGEX_SOURCE = {
|
|
2822
|
+
__proto__: null,
|
|
2514
2823
|
alnum: 'a-zA-Z0-9',
|
|
2515
2824
|
alpha: 'a-zA-Z',
|
|
2516
2825
|
ascii: '\\x00-\\x7F',
|
|
@@ -2528,6 +2837,7 @@ function requireConstants$2 () {
|
|
|
2528
2837
|
};
|
|
2529
2838
|
|
|
2530
2839
|
constants$2 = {
|
|
2840
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
2531
2841
|
MAX_LENGTH: 1024 * 64,
|
|
2532
2842
|
POSIX_REGEX_SOURCE,
|
|
2533
2843
|
|
|
@@ -2541,6 +2851,7 @@ function requireConstants$2 () {
|
|
|
2541
2851
|
|
|
2542
2852
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
2543
2853
|
REPLACEMENTS: {
|
|
2854
|
+
__proto__: null,
|
|
2544
2855
|
'***': '*',
|
|
2545
2856
|
'**/**': '**',
|
|
2546
2857
|
'**/**/**': '**'
|
|
@@ -3141,6 +3452,277 @@ function requireParse$1 () {
|
|
|
3141
3452
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
3142
3453
|
};
|
|
3143
3454
|
|
|
3455
|
+
const splitTopLevel = input => {
|
|
3456
|
+
const parts = [];
|
|
3457
|
+
let bracket = 0;
|
|
3458
|
+
let paren = 0;
|
|
3459
|
+
let quote = 0;
|
|
3460
|
+
let value = '';
|
|
3461
|
+
let escaped = false;
|
|
3462
|
+
|
|
3463
|
+
for (const ch of input) {
|
|
3464
|
+
if (escaped === true) {
|
|
3465
|
+
value += ch;
|
|
3466
|
+
escaped = false;
|
|
3467
|
+
continue;
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
if (ch === '\\') {
|
|
3471
|
+
value += ch;
|
|
3472
|
+
escaped = true;
|
|
3473
|
+
continue;
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
if (ch === '"') {
|
|
3477
|
+
quote = quote === 1 ? 0 : 1;
|
|
3478
|
+
value += ch;
|
|
3479
|
+
continue;
|
|
3480
|
+
}
|
|
3481
|
+
|
|
3482
|
+
if (quote === 0) {
|
|
3483
|
+
if (ch === '[') {
|
|
3484
|
+
bracket++;
|
|
3485
|
+
} else if (ch === ']' && bracket > 0) {
|
|
3486
|
+
bracket--;
|
|
3487
|
+
} else if (bracket === 0) {
|
|
3488
|
+
if (ch === '(') {
|
|
3489
|
+
paren++;
|
|
3490
|
+
} else if (ch === ')' && paren > 0) {
|
|
3491
|
+
paren--;
|
|
3492
|
+
} else if (ch === '|' && paren === 0) {
|
|
3493
|
+
parts.push(value);
|
|
3494
|
+
value = '';
|
|
3495
|
+
continue;
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3500
|
+
value += ch;
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
parts.push(value);
|
|
3504
|
+
return parts;
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
const isPlainBranch = branch => {
|
|
3508
|
+
let escaped = false;
|
|
3509
|
+
|
|
3510
|
+
for (const ch of branch) {
|
|
3511
|
+
if (escaped === true) {
|
|
3512
|
+
escaped = false;
|
|
3513
|
+
continue;
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
if (ch === '\\') {
|
|
3517
|
+
escaped = true;
|
|
3518
|
+
continue;
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
3522
|
+
return false;
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3526
|
+
return true;
|
|
3527
|
+
};
|
|
3528
|
+
|
|
3529
|
+
const normalizeSimpleBranch = branch => {
|
|
3530
|
+
let value = branch.trim();
|
|
3531
|
+
let changed = true;
|
|
3532
|
+
|
|
3533
|
+
while (changed === true) {
|
|
3534
|
+
changed = false;
|
|
3535
|
+
|
|
3536
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
3537
|
+
value = value.slice(2, -1);
|
|
3538
|
+
changed = true;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
if (!isPlainBranch(value)) {
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
return value.replace(/\\(.)/g, '$1');
|
|
3547
|
+
};
|
|
3548
|
+
|
|
3549
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
3550
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
3551
|
+
|
|
3552
|
+
for (let i = 0; i < values.length; i++) {
|
|
3553
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
3554
|
+
const a = values[i];
|
|
3555
|
+
const b = values[j];
|
|
3556
|
+
const char = a[0];
|
|
3557
|
+
|
|
3558
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
3559
|
+
continue;
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
3563
|
+
return true;
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
return false;
|
|
3569
|
+
};
|
|
3570
|
+
|
|
3571
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
3572
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
|
|
3576
|
+
let bracket = 0;
|
|
3577
|
+
let paren = 0;
|
|
3578
|
+
let quote = 0;
|
|
3579
|
+
let escaped = false;
|
|
3580
|
+
|
|
3581
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
3582
|
+
const ch = pattern[i];
|
|
3583
|
+
|
|
3584
|
+
if (escaped === true) {
|
|
3585
|
+
escaped = false;
|
|
3586
|
+
continue;
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
if (ch === '\\') {
|
|
3590
|
+
escaped = true;
|
|
3591
|
+
continue;
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
if (ch === '"') {
|
|
3595
|
+
quote = quote === 1 ? 0 : 1;
|
|
3596
|
+
continue;
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
if (quote === 1) {
|
|
3600
|
+
continue;
|
|
3601
|
+
}
|
|
3602
|
+
|
|
3603
|
+
if (ch === '[') {
|
|
3604
|
+
bracket++;
|
|
3605
|
+
continue;
|
|
3606
|
+
}
|
|
3607
|
+
|
|
3608
|
+
if (ch === ']' && bracket > 0) {
|
|
3609
|
+
bracket--;
|
|
3610
|
+
continue;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
if (bracket > 0) {
|
|
3614
|
+
continue;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
if (ch === '(') {
|
|
3618
|
+
paren++;
|
|
3619
|
+
continue;
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
if (ch === ')') {
|
|
3623
|
+
paren--;
|
|
3624
|
+
|
|
3625
|
+
if (paren === 0) {
|
|
3626
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
3627
|
+
return;
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
return {
|
|
3631
|
+
type: pattern[0],
|
|
3632
|
+
body: pattern.slice(2, i),
|
|
3633
|
+
end: i
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
};
|
|
3639
|
+
|
|
3640
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
3641
|
+
let index = 0;
|
|
3642
|
+
const chars = [];
|
|
3643
|
+
|
|
3644
|
+
while (index < pattern.length) {
|
|
3645
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
3646
|
+
|
|
3647
|
+
if (!match || match.type !== '*') {
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
3652
|
+
if (branches.length !== 1) {
|
|
3653
|
+
return;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
3657
|
+
if (!branch || branch.length !== 1) {
|
|
3658
|
+
return;
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
chars.push(branch);
|
|
3662
|
+
index += match.end + 1;
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
if (chars.length < 1) {
|
|
3666
|
+
return;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
const source = chars.length === 1
|
|
3670
|
+
? utils.escapeRegex(chars[0])
|
|
3671
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
3672
|
+
|
|
3673
|
+
return `${source}*`;
|
|
3674
|
+
};
|
|
3675
|
+
|
|
3676
|
+
const repeatedExtglobRecursion = pattern => {
|
|
3677
|
+
let depth = 0;
|
|
3678
|
+
let value = pattern.trim();
|
|
3679
|
+
let match = parseRepeatedExtglob(value);
|
|
3680
|
+
|
|
3681
|
+
while (match) {
|
|
3682
|
+
depth++;
|
|
3683
|
+
value = match.body.trim();
|
|
3684
|
+
match = parseRepeatedExtglob(value);
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
return depth;
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
3691
|
+
if (options.maxExtglobRecursion === false) {
|
|
3692
|
+
return { risky: false };
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
const max =
|
|
3696
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
3697
|
+
? options.maxExtglobRecursion
|
|
3698
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
3699
|
+
|
|
3700
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
3701
|
+
|
|
3702
|
+
if (branches.length > 1) {
|
|
3703
|
+
if (
|
|
3704
|
+
branches.some(branch => branch === '') ||
|
|
3705
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
3706
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
3707
|
+
) {
|
|
3708
|
+
return { risky: true };
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
for (const branch of branches) {
|
|
3713
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
3714
|
+
if (safeOutput) {
|
|
3715
|
+
return { risky: true, safeOutput };
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
3719
|
+
return { risky: true };
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
return { risky: false };
|
|
3724
|
+
};
|
|
3725
|
+
|
|
3144
3726
|
/**
|
|
3145
3727
|
* Parse the given input string.
|
|
3146
3728
|
* @param {String} input
|
|
@@ -3322,6 +3904,8 @@ function requireParse$1 () {
|
|
|
3322
3904
|
token.prev = prev;
|
|
3323
3905
|
token.parens = state.parens;
|
|
3324
3906
|
token.output = state.output;
|
|
3907
|
+
token.startIndex = state.index;
|
|
3908
|
+
token.tokensIndex = tokens.length;
|
|
3325
3909
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
3326
3910
|
|
|
3327
3911
|
increment('parens');
|
|
@@ -3331,6 +3915,34 @@ function requireParse$1 () {
|
|
|
3331
3915
|
};
|
|
3332
3916
|
|
|
3333
3917
|
const extglobClose = token => {
|
|
3918
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
3919
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
3920
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
3921
|
+
|
|
3922
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
3923
|
+
const safeOutput = analysis.safeOutput
|
|
3924
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
3925
|
+
: undefined;
|
|
3926
|
+
const open = tokens[token.tokensIndex];
|
|
3927
|
+
|
|
3928
|
+
open.type = 'text';
|
|
3929
|
+
open.value = literal;
|
|
3930
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
3931
|
+
|
|
3932
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
3933
|
+
tokens[i].value = '';
|
|
3934
|
+
tokens[i].output = '';
|
|
3935
|
+
delete tokens[i].suffix;
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
state.output = token.output + open.output;
|
|
3939
|
+
state.backtrack = true;
|
|
3940
|
+
|
|
3941
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
3942
|
+
decrement('parens');
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
|
|
3334
3946
|
let output = token.close + (opts.capture ? ')' : '');
|
|
3335
3947
|
let rest;
|
|
3336
3948
|
|
package/dist/getLogFilter.js
CHANGED